1.16, overhaul of player data

This commit is contained in:
Seth
2020-06-30 00:25:38 -07:00
parent 4ddcc3b8d7
commit eb58419a3a
95 changed files with 1553 additions and 3263 deletions

View File

@ -29,6 +29,7 @@ import java.util.regex.Pattern;
import javax.net.ssl.HttpsURLConnection;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.player.PlayerData;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.WordUtils;
@ -52,7 +53,7 @@ public class FUtil
//
public static final String SAVED_FLAGS_FILENAME = "savedflags.dat";
// See https://github.com/TotalFreedom/License - None of the listed names may be removed.
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "Demonic_Mario");
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "supernt");
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
@ -124,11 +125,6 @@ public class FUtil
return FUtil.DEVELOPERS.contains(name);
}
public static boolean canManageMasterBuilders(String name)
{
return ConfigEntry.SERVER_OWNERS.getStringList().contains(name) || ConfigEntry.SERVER_EXECUTIVES.getStringList().contains(name) || ConfigEntry.SERVER_MASTER_BUILDER_MANAGEMENT.getStringList().contains(name);
}
public static String formatName(String name)
{
return WordUtils.capitalizeFully(name.replace("_", " "));
@ -191,7 +187,10 @@ public class FUtil
{
JSONArray json = new JSONArray();
json.add(name);
String response = postRequestToEndpoint("https://api.mojang.com/profiles/minecraft", json.toString());
List<String> headers = new ArrayList<>();
headers.add("Accept:application/json");
headers.add("Content-Type:application/json");
String response = postRequestToEndpoint("https://api.mojang.com/profiles/minecraft", "POST", headers, json.toString());
// Don't care how stupid this looks, couldn't find anything to parse a json string to something readable in java with something not horrendously huge, maybe im just retarded
Pattern pattern = Pattern.compile("(?<=\"id\":\")[a-f0-9].{31}");
Matcher matcher = pattern.matcher(response);
@ -208,13 +207,16 @@ public class FUtil
return null;
}
public static String postRequestToEndpoint(String endpoint, String body) throws IOException
public static String postRequestToEndpoint(String endpoint, String method, List<String>headers, String body) throws IOException
{
URL url = new URL(endpoint);
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestMethod(method);
for (String header : headers)
{
String[] kv = header.split(":");
connection.setRequestProperty(kv[0], kv[1]);
}
connection.setDoOutput(true);
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.writeBytes(body);
@ -556,7 +558,15 @@ public class FUtil
public static String colorize(String string)
{
return ChatColor.translateAlternateColorCodes('&', string);
Matcher matcher = Pattern.compile("&#[a-f0-9]{6}").matcher(string);
while (matcher.find())
{
String code = matcher.group().replace("&", "");
string = string.replace("&" + code, net.md_5.bungee.api.ChatColor.of(code) + "");
}
string = ChatColor.translateAlternateColorCodes('&', string);
return string;
}
public static Date getUnixDate(long unix)

View File

@ -54,51 +54,57 @@ public class Groups
EntityType.COW,
EntityType.CREEPER,
EntityType.DOLPHIN,
EntityType.DONKEY,
EntityType.DROWNED,
EntityType.ENDER_DRAGON,
EntityType.ELDER_GUARDIAN,
EntityType.ENDERMAN,
EntityType.ENDERMITE,
EntityType.EVOKER,
EntityType.FOX,
EntityType.GHAST,
EntityType.GIANT,
EntityType.HUSK,
EntityType.ILLUSIONER,
EntityType.IRON_GOLEM,
EntityType.GUARDIAN,
EntityType.HOGLIN,
EntityType.HORSE,
EntityType.HUSK,
EntityType.LLAMA,
EntityType.MAGMA_CUBE,
EntityType.MUSHROOM_COW,
EntityType.MULE,
EntityType.OCELOT,
EntityType.PANDA,
EntityType.PARROT,
EntityType.PILLAGER,
EntityType.PHANTOM,
EntityType.PIG,
EntityType.PIG_ZOMBIE,
EntityType.PILLAGER,
EntityType.POLAR_BEAR,
EntityType.PUFFERFISH,
EntityType.RABBIT,
EntityType.RAVAGER,
EntityType.SALMON,
EntityType.SHEEP,
EntityType.SHULKER,
EntityType.SILVERFISH,
EntityType.SKELETON,
EntityType.SKELETON_HORSE,
EntityType.SLIME,
EntityType.SNOWMAN,
EntityType.SPIDER,
EntityType.SQUID,
EntityType.STRAY,
EntityType.TROPICAL_FISH,
EntityType.STRIDER,
EntityType.TRADER_LLAMA,
EntityType.TROPICAL_FISH,
EntityType.TURTLE,
EntityType.VEX,
EntityType.VILLAGER,
EntityType.WITCH,
EntityType.WITHER,
EntityType.WITHER_SKELETON,
EntityType.VINDICATOR,
EntityType.WANDERING_TRADER,
EntityType.WITCH,
EntityType.WITHER_SKELETON,
EntityType.WOLF,
EntityType.ZOMBIE);
EntityType.ZOMBIE,
EntityType.ZOMBIE_HORSE,
EntityType.ZOMBIFIED_PIGLIN,
EntityType.ZOMBIE_VILLAGER);
public static final List<Material> SPAWN_EGGS = Arrays.asList(
Material.BAT_SPAWN_EGG,
@ -120,6 +126,7 @@ public class Groups
Material.FOX_SPAWN_EGG,
Material.GHAST_SPAWN_EGG,
Material.GUARDIAN_SPAWN_EGG,
Material.HOGLIN_SPAWN_EGG,
Material.HORSE_SPAWN_EGG,
Material.HUSK_SPAWN_EGG,
Material.LLAMA_SPAWN_EGG,
@ -146,6 +153,7 @@ public class Groups
Material.SPIDER_SPAWN_EGG,
Material.SQUID_SPAWN_EGG,
Material.STRAY_SPAWN_EGG,
Material.STRIDER_SPAWN_EGG,
Material.TRADER_LLAMA_SPAWN_EGG,
Material.TROPICAL_FISH_SPAWN_EGG,
Material.TURTLE_SPAWN_EGG,
@ -158,7 +166,7 @@ public class Groups
Material.WOLF_SPAWN_EGG,
Material.ZOMBIE_SPAWN_EGG,
Material.ZOMBIE_HORSE_SPAWN_EGG,
Material.ZOMBIE_PIGMAN_SPAWN_EGG,
Material.ZOMBIFIED_PIGLIN_SPAWN_EGG,
Material.ZOMBIE_VILLAGER_SPAWN_EGG);
public static final List<Material> BANNERS = Arrays.asList(