public static String getBuild() { if (!updated) { loadData(); updated = true; } return build; }
public static boolean isDevBuild() { return getVersion().contains("SNAPSHOT"); }
private static void loadData() { try { String path = MyPetVersion.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath(); Attributes attr = getClassLoaderForExtraModule(path).getMainAttributes(); if (attr.getValue("Project-Version") != null) { version = attr.getValue("Project-Version"); } if (attr.getValue("Project-Build") != null) { build = attr.getValue("Project-Build"); } if (attr.getValue("Project-Minecraft-Version") != null) { minecraftVersion = attr.getValue("Project-Minecraft-Version"); } if (attr.getValue("Project-Bukkit-Packets") != null) { String bukkitPackets = attr.getValue("Project-Bukkit-Packets"); MyPetVersion.bukkitPackets.clear(); Collections.addAll(MyPetVersion.bukkitPackets, bukkitPackets.split(";")); } if (attr.getValue("Premium") != null) { premium = true; } } catch (IOException | URISyntaxException e) { e.printStackTrace(); } }
@Override protected void onOpen() { System.out.println("WS: Open connection"); if (!MyPetVersion.isPremium()) { try { this.send("{\"action\": \"TOGGLE_PREMIUM\", \"data\": \"Plugin is not premium.\"}"); } catch (IOException ignored) { } } String lang = Preferences.userNodeForPackage(Main.MyPetPlugin.class).get("Language", "NO-Language"); if (!lang.equals("NO-Language")) { try { this.send("{\"action\": \"CHANGE_LANGUAGE\", \"data\": \"" + lang + "\"}"); } catch (IOException ignored) { } } }
public static String getVersion() { if (!updated) { loadData(); updated = true; } return version; }
public static boolean isPremium() { if (!updated) { loadData(); updated = true; } return premium; }
public static String getMinecraftVersion() { if (!updated) { loadData(); updated = true; } return minecraftVersion; }
public static boolean isValidBukkitPacket(String p1) { if (!updated) { loadData(); updated = true; } for (String p2 : bukkitPackets) { if (p1.equals(p2)) { return true; } } return false; }
public static List<String> getBukkitPackets() { if (!updated) { loadData(); updated = true; } return Collections.unmodifiableList(bukkitPackets); }