diff --git a/.gitignore b/.gitignore index 75efe34..5f71efe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,16 @@ /bin/ /out/ +/target/ +/ShopChest/target/ +/ShopChest NMS-Abstract/target/ +/ShopChest NMS-v1_8_R1/target/ +/ShopChest NMS-v1_8_R2/target/ +/ShopChest NMS-v1_8_R3/target/ +/ShopChest NMS-v1_9_R1/target/ +/ShopChest NMS-v1_9_R2/target/ +/ShopChest NMS-v1_10_R1/target/ /.idea/ /.settings/ .classpath .project -ShopChest.iml \ No newline at end of file +*.iml \ No newline at end of file diff --git a/ShopChest NMS-Abstract/pom.xml b/ShopChest NMS-Abstract/pom.xml new file mode 100644 index 0000000..7dd0aed --- /dev/null +++ b/ShopChest NMS-Abstract/pom.xml @@ -0,0 +1,14 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + + ShopChest_NMS-Abstract + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/Hologram.java b/ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/IHologram.java similarity index 83% rename from src/de/epiceric/shopchest/interfaces/Hologram.java rename to ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/IHologram.java index be43db8..233a94d 100644 --- a/src/de/epiceric/shopchest/interfaces/Hologram.java +++ b/ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/IHologram.java @@ -1,10 +1,9 @@ -package de.epiceric.shopchest.interfaces; - +package de.epiceric.shopchest.nms; import org.bukkit.Location; import org.bukkit.OfflinePlayer; -public interface Hologram { +public interface IHologram { /** * @return Location of the hologram @@ -35,7 +34,7 @@ public interface Hologram { /** * Removes the hologram.
- * Hologram will be hidden from all players and will be killed + * IHologram will be hidden from all players and will be killed */ void remove(); diff --git a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R1.java b/ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/IJsonBuilder.java similarity index 54% rename from src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R1.java rename to ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/IJsonBuilder.java index 9258c1e..a699792 100644 --- a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R1.java +++ b/ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/IJsonBuilder.java @@ -1,39 +1,26 @@ -package de.epiceric.shopchest.interfaces.jsonbuilder; +package de.epiceric.shopchest.nms; -import de.epiceric.shopchest.ShopChest; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.language.LanguageUtils; -import de.epiceric.shopchest.language.LocalizedMessage; -import net.minecraft.server.v1_8_R1.ChatSerializer; -import net.minecraft.server.v1_8_R1.PacketPlayOutChat; +import com.google.common.collect.ImmutableMap; import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.regex.Pattern; +public abstract class IJsonBuilder { -public class JsonBuilder_1_8_R1 implements JsonBuilder { - - /* JsonBuilder by FisheyLP */ + public abstract void sendJson(Player p); - private List extras = new ArrayList(); - private ShopChest plugin; + private List extras = new ArrayList<>(); - public JsonBuilder_1_8_R1(ShopChest plugin, String... text) { - this.plugin = plugin; - for (String extra : text) - parse(extra); - } - - @Override - public JsonBuilder_1_8_R1 parse(String text) { + public IJsonBuilder parse(String text, String hoverText, String downloadLink) { String regex = "[&�]{1}([a-fA-Fl-oL-O0-9]){1}"; text = text.replaceAll(regex, "�$1"); if (!Pattern.compile(regex).matcher(text).find()) { - withText(text).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); + withText(text).withHoverEvent(HoverAction.SHOW_TEXT, hoverText).withClickEvent(ClickAction.OPEN_URL, downloadLink); return this; } String[] words = text.split(regex); @@ -42,43 +29,37 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder { for (String word : words) { try { if (index != words[0].length()) - withText(word).withColor("�" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - } catch (Exception e) { - } + withText(word).withColor("�" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, hoverText).withClickEvent(ClickAction.OPEN_URL, downloadLink); + } catch (Exception e) {} index += word.length() + 2; } return this; } - @Override - public JsonBuilder_1_8_R1 withText(String text) { + private IJsonBuilder withText(String text) { extras.add("{\"text\":\"" + text + "\"}"); return this; } - @Override - public JsonBuilder_1_8_R1 withColor(ChatColor color) { + private IJsonBuilder withColor(ChatColor color) { String c = color.name().toLowerCase(); addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true"); return this; } - @Override - public JsonBuilder_1_8_R1 withColor(String color) { + private IJsonBuilder withColor(String color) { while (color.length() != 1) color = color.substring(1).trim(); withColor(ChatColor.getByChar(color)); return this; } - @Override - public JsonBuilder_1_8_R1 withClickEvent(ClickAction action, String value) { + private IJsonBuilder withClickEvent(ClickAction action, String value) { addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase() + "\",\"value\":\"" + value + "\"}"); return this; } - @Override - public JsonBuilder_1_8_R1 withHoverEvent(HoverAction action, String value) { + private IJsonBuilder withHoverEvent(HoverAction action, String value) { addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase() + "\",\"value\":\"" + value + "\"}"); return this; @@ -92,23 +73,22 @@ public class JsonBuilder_1_8_R1 implements JsonBuilder { extras.add(lastText); } - @Override public String toString() { if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0); String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":["; extras.remove(0); - ; for (String extra : extras) text = text + extra + ","; text = text.substring(0, text.length() - 1) + "]}"; return text; } - @Override - public void sendJson(Player p) { - ((CraftPlayer) p).getHandle().playerConnection.sendPacket( - new PacketPlayOutChat(ChatSerializer.a(toString()))); - - + private enum ClickAction { + RUN_COMMAND, SUGGEST_COMMAND, OPEN_URL } -} \ No newline at end of file + + private enum HoverAction { + SHOW_TEXT + } + +} diff --git a/src/de/epiceric/shopchest/interfaces/SpawnEggMeta.java b/ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/ISpawnEggMeta.java similarity index 93% rename from src/de/epiceric/shopchest/interfaces/SpawnEggMeta.java rename to ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/ISpawnEggMeta.java index a87aaed..ed86959 100644 --- a/src/de/epiceric/shopchest/interfaces/SpawnEggMeta.java +++ b/ShopChest NMS-Abstract/src/main/java/de/epiceric/shopchest/nms/ISpawnEggMeta.java @@ -1,8 +1,8 @@ -package de.epiceric.shopchest.interfaces; +package de.epiceric.shopchest.nms; import org.bukkit.entity.EntityType; -public abstract class SpawnEggMeta { +public abstract class ISpawnEggMeta { /** * @return The NBT Tag EntityTag.id of the Spawn Egg diff --git a/ShopChest NMS-v1_10_R1/pom.xml b/ShopChest NMS-v1_10_R1/pom.xml new file mode 100644 index 0000000..6a13d3d --- /dev/null +++ b/ShopChest NMS-v1_10_R1/pom.xml @@ -0,0 +1,29 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + + ShopChest_NMS-v1_10_R1 + + + + org.bukkit + craftbukkit + 1.10-R0.1-SNAPSHOT + provided + + + de.epiceric + ShopChest_NMS-Abstract + 1.8.0 + provided + + + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_10_R1.java b/ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/Hologram.java similarity index 85% rename from src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_10_R1.java rename to ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/Hologram.java index d4f75f0..51c7a26 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_10_R1.java +++ b/ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/Hologram.java @@ -1,7 +1,9 @@ -package de.epiceric.shopchest.interfaces.hologram; +package de.epiceric.shopchest.nms.v1_10_R1; -import de.epiceric.shopchest.interfaces.Hologram; -import net.minecraft.server.v1_10_R1.*; +import de.epiceric.shopchest.nms.IHologram; +import net.minecraft.server.v1_10_R1.EntityArmorStand; +import net.minecraft.server.v1_10_R1.PacketPlayOutEntityDestroy; +import net.minecraft.server.v1_10_R1.PacketPlayOutSpawnEntityLiving; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; @@ -10,7 +12,7 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; import java.util.ArrayList; import java.util.List; -public class Hologram_1_10_R1 implements Hologram { +public class Hologram implements IHologram { private boolean exists = false; private int count; @@ -19,7 +21,7 @@ public class Hologram_1_10_R1 implements Hologram { private Location location; private List visible = new ArrayList<>(); - public Hologram_1_10_R1(String[] text, Location location) { + public Hologram(String[] text, Location location) { this.text = text; this.location = location; create(); diff --git a/ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/JsonBuilder.java b/ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/JsonBuilder.java new file mode 100644 index 0000000..3273466 --- /dev/null +++ b/ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/JsonBuilder.java @@ -0,0 +1,20 @@ +package de.epiceric.shopchest.nms.v1_10_R1; + +import de.epiceric.shopchest.nms.IJsonBuilder; +import net.minecraft.server.v1_10_R1.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_10_R1.PacketPlayOutChat; +import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class JsonBuilder extends IJsonBuilder { + + public JsonBuilder(String text, String hoverText, String downloadLink) { + parse(text, hoverText, downloadLink); + } + + @Override + public void sendJson(Player p) { + ((CraftPlayer) p).getHandle().playerConnection.sendPacket( + new PacketPlayOutChat(ChatSerializer.a(toString()))); + } +} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_10_R1.java b/ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/SpawnEggMeta.java similarity index 69% rename from src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_10_R1.java rename to ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/SpawnEggMeta.java index d5bf804..97f8d4b 100644 --- a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_10_R1.java +++ b/ShopChest NMS-v1_10_R1/src/main/java/de/epiceric/shopchest/nms/v1_10_R1/SpawnEggMeta.java @@ -1,16 +1,15 @@ -package de.epiceric.shopchest.interfaces.spawneggmeta; +package de.epiceric.shopchest.nms.v1_10_R1; - -import de.epiceric.shopchest.interfaces.SpawnEggMeta; +import de.epiceric.shopchest.nms.ISpawnEggMeta; import net.minecraft.server.v1_10_R1.NBTTagCompound; import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -public class SpawnEggMeta_1_10_R1 extends SpawnEggMeta { +public class SpawnEggMeta extends ISpawnEggMeta { private ItemStack stack; - public SpawnEggMeta_1_10_R1(ItemStack stack) { + public SpawnEggMeta(ItemStack stack) { this.stack = stack; } diff --git a/ShopChest NMS-v1_8_R1/pom.xml b/ShopChest NMS-v1_8_R1/pom.xml new file mode 100644 index 0000000..33ad136 --- /dev/null +++ b/ShopChest NMS-v1_8_R1/pom.xml @@ -0,0 +1,29 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + + ShopChest_NMS-v1_8_R1 + + + + org.bukkit + craftbukkit + 1.8-R0.1-SNAPSHOT + provided + + + de.epiceric + ShopChest_NMS-Abstract + 1.8.0 + provided + + + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R1.java b/ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/Hologram.java similarity index 92% rename from src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R1.java rename to ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/Hologram.java index c52bc8f..c6ce62a 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R1.java +++ b/ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/Hologram.java @@ -1,6 +1,6 @@ -package de.epiceric.shopchest.interfaces.hologram; +package de.epiceric.shopchest.nms.v1_8_R1; -import de.epiceric.shopchest.interfaces.Hologram; +import de.epiceric.shopchest.nms.IHologram; import net.minecraft.server.v1_8_R1.EntityArmorStand; import net.minecraft.server.v1_8_R1.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R1.PacketPlayOutSpawnEntityLiving; @@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; import java.util.ArrayList; import java.util.List; -public class Hologram_1_8_R1 implements Hologram { +public class Hologram implements IHologram { private boolean exists = false; private int count; @@ -21,7 +21,7 @@ public class Hologram_1_8_R1 implements Hologram { private Location location; private List visible = new ArrayList<>(); - public Hologram_1_8_R1(String[] text, Location location) { + public Hologram(String[] text, Location location) { this.text = text; this.location = location; create(); diff --git a/ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/JsonBuilder.java b/ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/JsonBuilder.java new file mode 100644 index 0000000..0feb56a --- /dev/null +++ b/ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/JsonBuilder.java @@ -0,0 +1,20 @@ +package de.epiceric.shopchest.nms.v1_8_R1; + +import de.epiceric.shopchest.nms.IJsonBuilder; +import net.minecraft.server.v1_8_R1.ChatSerializer; +import net.minecraft.server.v1_8_R1.PacketPlayOutChat; +import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class JsonBuilder extends IJsonBuilder { + + public JsonBuilder(String text, String hoverText, String downloadLink) { + parse(text, hoverText, downloadLink); + } + + @Override + public void sendJson(Player p) { + ((CraftPlayer) p).getHandle().playerConnection.sendPacket( + new PacketPlayOutChat(ChatSerializer.a(toString()))); + } +} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R1.java b/ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/SpawnEggMeta.java similarity index 69% rename from src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R1.java rename to ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/SpawnEggMeta.java index 4b254a5..a713267 100644 --- a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R1.java +++ b/ShopChest NMS-v1_8_R1/src/main/java/de/epiceric/shopchest/nms/v1_8_R1/SpawnEggMeta.java @@ -1,16 +1,15 @@ -package de.epiceric.shopchest.interfaces.spawneggmeta; +package de.epiceric.shopchest.nms.v1_8_R1; - -import de.epiceric.shopchest.interfaces.SpawnEggMeta; +import de.epiceric.shopchest.nms.ISpawnEggMeta; import net.minecraft.server.v1_8_R1.NBTTagCompound; import org.bukkit.craftbukkit.v1_8_R1.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -public class SpawnEggMeta_1_8_R1 extends SpawnEggMeta { +public class SpawnEggMeta extends ISpawnEggMeta { private ItemStack stack; - public SpawnEggMeta_1_8_R1(ItemStack stack) { + public SpawnEggMeta(ItemStack stack) { this.stack = stack; } diff --git a/ShopChest NMS-v1_8_R2/pom.xml b/ShopChest NMS-v1_8_R2/pom.xml new file mode 100644 index 0000000..368c3c0 --- /dev/null +++ b/ShopChest NMS-v1_8_R2/pom.xml @@ -0,0 +1,30 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + + ShopChest_NMS-v1_8_R2 + + + + org.bukkit + craftbukkit + 1.8.3-R0.1-SNAPSHOT + provided + + + de.epiceric + ShopChest_NMS-Abstract + 1.8.0 + provided + + + + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R2.java b/ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/Hologram.java similarity index 91% rename from src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R2.java rename to ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/Hologram.java index c8148fa..e321026 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R2.java +++ b/ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/Hologram.java @@ -1,6 +1,6 @@ -package de.epiceric.shopchest.interfaces.hologram; +package de.epiceric.shopchest.nms.v1_8_R2; -import de.epiceric.shopchest.interfaces.Hologram; +import de.epiceric.shopchest.nms.IHologram; import net.minecraft.server.v1_8_R2.EntityArmorStand; import net.minecraft.server.v1_8_R2.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R2.PacketPlayOutSpawnEntityLiving; @@ -10,10 +10,9 @@ import org.bukkit.craftbukkit.v1_8_R2.CraftWorld; import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -public class Hologram_1_8_R2 implements Hologram { +public class Hologram implements IHologram { private boolean exists = false; private int count; @@ -22,7 +21,7 @@ public class Hologram_1_8_R2 implements Hologram { private Location location; private List visible = new ArrayList<>(); - public Hologram_1_8_R2(String[] text, Location location) { + public Hologram(String[] text, Location location) { this.text = text; this.location = location; create(); diff --git a/ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/JsonBuilder.java b/ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/JsonBuilder.java new file mode 100644 index 0000000..ed19d5e --- /dev/null +++ b/ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/JsonBuilder.java @@ -0,0 +1,20 @@ +package de.epiceric.shopchest.nms.v1_8_R2; + +import de.epiceric.shopchest.nms.IJsonBuilder; +import net.minecraft.server.v1_8_R2.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_8_R2.PacketPlayOutChat; +import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class JsonBuilder extends IJsonBuilder { + + public JsonBuilder(String text, String hoverText, String downloadLink) { + parse(text, hoverText, downloadLink); + } + + @Override + public void sendJson(Player p) { + ((CraftPlayer) p).getHandle().playerConnection.sendPacket( + new PacketPlayOutChat(ChatSerializer.a(toString()))); + } +} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R2.java b/ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/SpawnEggMeta.java similarity index 69% rename from src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R2.java rename to ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/SpawnEggMeta.java index dab17d9..3508407 100644 --- a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R2.java +++ b/ShopChest NMS-v1_8_R2/src/main/java/de/epiceric/shopchest/nms/v1_8_R2/SpawnEggMeta.java @@ -1,16 +1,15 @@ -package de.epiceric.shopchest.interfaces.spawneggmeta; +package de.epiceric.shopchest.nms.v1_8_R2; - -import de.epiceric.shopchest.interfaces.SpawnEggMeta; +import de.epiceric.shopchest.nms.ISpawnEggMeta; import net.minecraft.server.v1_8_R2.NBTTagCompound; import org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -public class SpawnEggMeta_1_8_R2 extends SpawnEggMeta { +public class SpawnEggMeta extends ISpawnEggMeta { private ItemStack stack; - public SpawnEggMeta_1_8_R2(ItemStack stack) { + public SpawnEggMeta(ItemStack stack) { this.stack = stack; } diff --git a/ShopChest NMS-v1_8_R3/pom.xml b/ShopChest NMS-v1_8_R3/pom.xml new file mode 100644 index 0000000..5603c0b --- /dev/null +++ b/ShopChest NMS-v1_8_R3/pom.xml @@ -0,0 +1,30 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + + ShopChest_NMS-v1_8_R3 + + + + org.bukkit + craftbukkit + 1.8.8-R0.1-SNAPSHOT + provided + + + de.epiceric + ShopChest_NMS-Abstract + 1.8.0 + provided + + + + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R3.java b/ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/Hologram.java similarity index 91% rename from src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R3.java rename to ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/Hologram.java index b502039..088119c 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_8_R3.java +++ b/ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/Hologram.java @@ -1,6 +1,6 @@ -package de.epiceric.shopchest.interfaces.hologram; +package de.epiceric.shopchest.nms.v1_8_R3; -import de.epiceric.shopchest.interfaces.Hologram; +import de.epiceric.shopchest.nms.IHologram; import net.minecraft.server.v1_8_R3.EntityArmorStand; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; @@ -10,10 +10,9 @@ import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -public class Hologram_1_8_R3 implements Hologram { +public class Hologram implements IHologram { private boolean exists = false; private int count; @@ -22,7 +21,7 @@ public class Hologram_1_8_R3 implements Hologram { private Location location; private List visible = new ArrayList<>(); - public Hologram_1_8_R3(String[] text, Location location) { + public Hologram(String[] text, Location location) { this.text = text; this.location = location; create(); diff --git a/ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/JsonBuilder.java b/ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/JsonBuilder.java new file mode 100644 index 0000000..1d94a36 --- /dev/null +++ b/ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/JsonBuilder.java @@ -0,0 +1,20 @@ +package de.epiceric.shopchest.nms.v1_8_R3; + +import de.epiceric.shopchest.nms.IJsonBuilder; +import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_8_R3.PacketPlayOutChat; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class JsonBuilder extends IJsonBuilder { + + public JsonBuilder(String text, String hoverText, String downloadLink) { + parse(text, hoverText, downloadLink); + } + + @Override + public void sendJson(Player p) { + ((CraftPlayer) p).getHandle().playerConnection.sendPacket( + new PacketPlayOutChat(ChatSerializer.a(toString()))); + } +} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R3.java b/ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/SpawnEggMeta.java similarity index 69% rename from src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R3.java rename to ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/SpawnEggMeta.java index ec0e13c..5b3fd82 100644 --- a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_8_R3.java +++ b/ShopChest NMS-v1_8_R3/src/main/java/de/epiceric/shopchest/nms/v1_8_R3/SpawnEggMeta.java @@ -1,16 +1,15 @@ -package de.epiceric.shopchest.interfaces.spawneggmeta; +package de.epiceric.shopchest.nms.v1_8_R3; - -import de.epiceric.shopchest.interfaces.SpawnEggMeta; +import de.epiceric.shopchest.nms.ISpawnEggMeta; import net.minecraft.server.v1_8_R3.NBTTagCompound; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -public class SpawnEggMeta_1_8_R3 extends SpawnEggMeta { +public class SpawnEggMeta extends ISpawnEggMeta { private ItemStack stack; - public SpawnEggMeta_1_8_R3(ItemStack stack) { + public SpawnEggMeta(ItemStack stack) { this.stack = stack; } diff --git a/ShopChest NMS-v1_9_R1/pom.xml b/ShopChest NMS-v1_9_R1/pom.xml new file mode 100644 index 0000000..c3e298c --- /dev/null +++ b/ShopChest NMS-v1_9_R1/pom.xml @@ -0,0 +1,29 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + + ShopChest_NMS-v1_9_R1 + + + + org.bukkit + craftbukkit + 1.9.2-R0.1-SNAPSHOT + provided + + + de.epiceric + ShopChest_NMS-Abstract + 1.8.0 + provided + + + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R1.java b/ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/Hologram.java similarity index 91% rename from src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R1.java rename to ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/Hologram.java index 8e01d09..4d52529 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R1.java +++ b/ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/Hologram.java @@ -1,6 +1,6 @@ -package de.epiceric.shopchest.interfaces.hologram; +package de.epiceric.shopchest.nms.v1_9_R1; -import de.epiceric.shopchest.interfaces.Hologram; +import de.epiceric.shopchest.nms.IHologram; import net.minecraft.server.v1_9_R1.EntityArmorStand; import net.minecraft.server.v1_9_R1.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_9_R1.PacketPlayOutSpawnEntityLiving; @@ -10,10 +10,9 @@ import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -public class Hologram_1_9_R1 implements Hologram { +public class Hologram implements IHologram { private boolean exists = false; private int count; @@ -22,7 +21,7 @@ public class Hologram_1_9_R1 implements Hologram { private Location location; private List visible = new ArrayList<>(); - public Hologram_1_9_R1(String[] text, Location location) { + public Hologram(String[] text, Location location) { this.text = text; this.location = location; create(); diff --git a/ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/JsonBuilder.java b/ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/JsonBuilder.java new file mode 100644 index 0000000..15a19d4 --- /dev/null +++ b/ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/JsonBuilder.java @@ -0,0 +1,20 @@ +package de.epiceric.shopchest.nms.v1_9_R1; + +import de.epiceric.shopchest.nms.IJsonBuilder; +import net.minecraft.server.v1_9_R1.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_9_R1.PacketPlayOutChat; +import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class JsonBuilder extends IJsonBuilder { + + public JsonBuilder(String text, String hoverText, String downloadLink) { + parse(text, hoverText, downloadLink); + } + + @Override + public void sendJson(Player p) { + ((CraftPlayer) p).getHandle().playerConnection.sendPacket( + new PacketPlayOutChat(ChatSerializer.a(toString()))); + } +} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_9_R1.java b/ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/SpawnEggMeta.java similarity index 69% rename from src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_9_R1.java rename to ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/SpawnEggMeta.java index 654324d..7e307f0 100644 --- a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_9_R1.java +++ b/ShopChest NMS-v1_9_R1/src/main/java/de/epiceric/shopchest/nms/v1_9_R1/SpawnEggMeta.java @@ -1,16 +1,15 @@ -package de.epiceric.shopchest.interfaces.spawneggmeta; +package de.epiceric.shopchest.nms.v1_9_R1; - -import de.epiceric.shopchest.interfaces.SpawnEggMeta; +import de.epiceric.shopchest.nms.ISpawnEggMeta; import net.minecraft.server.v1_9_R1.NBTTagCompound; import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -public class SpawnEggMeta_1_9_R1 extends SpawnEggMeta { +public class SpawnEggMeta extends ISpawnEggMeta { private ItemStack stack; - public SpawnEggMeta_1_9_R1(ItemStack stack) { + public SpawnEggMeta(ItemStack stack) { this.stack = stack; } diff --git a/ShopChest NMS-v1_9_R2/pom.xml b/ShopChest NMS-v1_9_R2/pom.xml new file mode 100644 index 0000000..6976080 --- /dev/null +++ b/ShopChest NMS-v1_9_R2/pom.xml @@ -0,0 +1,29 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + + ShopChest_NMS-v1_9_R2 + + + + org.bukkit + craftbukkit + 1.9.4-R0.1-SNAPSHOT + provided + + + de.epiceric + ShopChest_NMS-Abstract + 1.8.0 + provided + + + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R2.java b/ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/Hologram.java similarity index 92% rename from src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R2.java rename to ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/Hologram.java index 138400d..9f0a404 100644 --- a/src/de/epiceric/shopchest/interfaces/hologram/Hologram_1_9_R2.java +++ b/ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/Hologram.java @@ -1,6 +1,6 @@ -package de.epiceric.shopchest.interfaces.hologram; +package de.epiceric.shopchest.nms.v1_9_R2; -import de.epiceric.shopchest.interfaces.Hologram; +import de.epiceric.shopchest.nms.IHologram; import net.minecraft.server.v1_9_R2.EntityArmorStand; import net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_9_R2.PacketPlayOutSpawnEntityLiving; @@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; import java.util.ArrayList; import java.util.List; -public class Hologram_1_9_R2 implements Hologram { +public class Hologram implements IHologram { private boolean exists = false; private int count; @@ -21,7 +21,7 @@ public class Hologram_1_9_R2 implements Hologram { private Location location; private List visible = new ArrayList<>(); - public Hologram_1_9_R2(String[] text, Location location) { + public Hologram(String[] text, Location location) { this.text = text; this.location = location; create(); diff --git a/ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/JsonBuilder.java b/ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/JsonBuilder.java new file mode 100644 index 0000000..7c5c1d9 --- /dev/null +++ b/ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/JsonBuilder.java @@ -0,0 +1,20 @@ +package de.epiceric.shopchest.nms.v1_9_R2; + +import de.epiceric.shopchest.nms.IJsonBuilder; +import net.minecraft.server.v1_9_R2.IChatBaseComponent.ChatSerializer; +import net.minecraft.server.v1_9_R2.PacketPlayOutChat; +import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; +import org.bukkit.entity.Player; + +public class JsonBuilder extends IJsonBuilder { + + public JsonBuilder(String text, String hoverText, String downloadLink) { + parse(text, hoverText, downloadLink); + } + + @Override + public void sendJson(Player p) { + ((CraftPlayer) p).getHandle().playerConnection.sendPacket( + new PacketPlayOutChat(ChatSerializer.a(toString()))); + } +} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_9_R2.java b/ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/SpawnEggMeta.java similarity index 69% rename from src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_9_R2.java rename to ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/SpawnEggMeta.java index 13e1f46..8e1e799 100644 --- a/src/de/epiceric/shopchest/interfaces/spawneggmeta/SpawnEggMeta_1_9_R2.java +++ b/ShopChest NMS-v1_9_R2/src/main/java/de/epiceric/shopchest/nms/v1_9_R2/SpawnEggMeta.java @@ -1,16 +1,15 @@ -package de.epiceric.shopchest.interfaces.spawneggmeta; +package de.epiceric.shopchest.nms.v1_9_R2; - -import de.epiceric.shopchest.interfaces.SpawnEggMeta; +import de.epiceric.shopchest.nms.ISpawnEggMeta; import net.minecraft.server.v1_9_R2.NBTTagCompound; import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; -public class SpawnEggMeta_1_9_R2 extends SpawnEggMeta { +public class SpawnEggMeta extends ISpawnEggMeta { private ItemStack stack; - public SpawnEggMeta_1_9_R2(ItemStack stack) { + public SpawnEggMeta(ItemStack stack) { this.stack = stack; } diff --git a/ShopChest/dependency-reduced-pom.xml b/ShopChest/dependency-reduced-pom.xml new file mode 100644 index 0000000..ae124dd --- /dev/null +++ b/ShopChest/dependency-reduced-pom.xml @@ -0,0 +1,111 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + ShopChest + + + org.bukkit + craftbukkit + 1.10-R0.1-SNAPSHOT + provided + + + org.spigotmc + spigot-api + 1.10.2-R0.1-SNAPSHOT + provided + + + commons-lang + commons-lang + + + json-simple + com.googlecode.json-simple + + + guava + com.google.guava + + + gson + com.google.code.gson + + + ebean + org.avaje + + + snakeyaml + org.yaml + + + bungeecord-chat + net.md-5 + + + + + org.bukkit + bukkit + 1.10.2-R0.1-SNAPSHOT + provided + + + commons-lang + commons-lang + + + json-simple + com.googlecode.json-simple + + + guava + com.google.guava + + + gson + com.google.code.gson + + + ebean + org.avaje + + + snakeyaml + org.yaml + + + + + net.milkbowl.vault + VaultAPI + 1.5 + provided + + + org.yi.acru.bukkit + lockette + 1.8.36 + provided + + + me.minebuilders + clearlag + 2.9.1 + provided + + + com.griefcraft.lwc + lwc-entity-locking + 1.7.3 + provided + + + + diff --git a/ShopChest/pom.xml b/ShopChest/pom.xml new file mode 100644 index 0000000..754c5cf --- /dev/null +++ b/ShopChest/pom.xml @@ -0,0 +1,59 @@ + + + + ShopChest-Root + de.epiceric + 1.8.0 + + 4.0.0 + + ShopChest + + + + org.bukkit + craftbukkit + 1.10-R0.1-SNAPSHOT + provided + + + + de.epiceric + ShopChest_NMS-Abstract + 1.8.0 + + + de.epiceric + ShopChest_NMS-v1_8_R1 + 1.8.0 + + + de.epiceric + ShopChest_NMS-v1_8_R2 + 1.8.0 + + + de.epiceric + ShopChest_NMS-v1_8_R3 + 1.8.0 + + + de.epiceric + ShopChest_NMS-v1_9_R1 + 1.8.0 + + + de.epiceric + ShopChest_NMS-v1_9_R2 + 1.8.0 + + + de.epiceric + ShopChest_NMS-v1_10_R1 + 1.8.0 + + + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/Commands.java b/ShopChest/src/main/java/de/epiceric/shopchest/Commands.java similarity index 88% rename from src/de/epiceric/shopchest/Commands.java rename to ShopChest/src/main/java/de/epiceric/shopchest/Commands.java index 0996ee8..7ee7ae3 100644 --- a/src/de/epiceric/shopchest/Commands.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/Commands.java @@ -2,10 +2,9 @@ package de.epiceric.shopchest; import de.epiceric.shopchest.config.Config; import de.epiceric.shopchest.config.Regex; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.interfaces.jsonbuilder.*; import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LocalizedMessage; +import de.epiceric.shopchest.nms.IJsonBuilder; import de.epiceric.shopchest.shop.Shop.ShopType; import de.epiceric.shopchest.utils.ClickType; import de.epiceric.shopchest.utils.ClickType.EnumClickType; @@ -152,25 +151,25 @@ public class Commands extends BukkitCommand { plugin.setDownloadLink(uc.getLink()); plugin.setUpdateNeeded(true); - JsonBuilder jb; + IJsonBuilder jb; switch (Utils.getServerVersion()) { case "v1_8_R1": - jb = new JsonBuilder_1_8_R1(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion()))); + jb = new de.epiceric.shopchest.nms.v1_8_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink()); break; case "v1_8_R2": - jb = new JsonBuilder_1_8_R2(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion()))); + jb = new de.epiceric.shopchest.nms.v1_8_R2.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink()); break; case "v1_8_R3": - jb = new JsonBuilder_1_8_R3(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion()))); + jb = new de.epiceric.shopchest.nms.v1_8_R3.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink()); break; case "v1_9_R1": - jb = new JsonBuilder_1_9_R1(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion()))); + jb = new de.epiceric.shopchest.nms.v1_9_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink()); break; case "v1_9_R2": - jb = new JsonBuilder_1_9_R2(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion()))); + jb = new de.epiceric.shopchest.nms.v1_9_R2.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink()); break; case "v1_10_R1": - jb = new JsonBuilder_1_10_R1(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion()))); + jb = new de.epiceric.shopchest.nms.v1_10_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, uc.getVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), uc.getLink()); break; default: return; diff --git a/src/de/epiceric/shopchest/ShopChest.java b/ShopChest/src/main/java/de/epiceric/shopchest/ShopChest.java similarity index 88% rename from src/de/epiceric/shopchest/ShopChest.java rename to ShopChest/src/main/java/de/epiceric/shopchest/ShopChest.java index c70e206..829581f 100644 --- a/src/de/epiceric/shopchest/ShopChest.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/ShopChest.java @@ -3,11 +3,10 @@ package de.epiceric.shopchest; import de.epiceric.shopchest.config.Config; import de.epiceric.shopchest.config.LanguageConfiguration; import de.epiceric.shopchest.config.Regex; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.interfaces.jsonbuilder.*; import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LocalizedMessage; import de.epiceric.shopchest.listeners.*; +import de.epiceric.shopchest.nms.IJsonBuilder; import de.epiceric.shopchest.shop.Shop; import de.epiceric.shopchest.shop.Shop.ShopType; import de.epiceric.shopchest.sql.Database; @@ -274,25 +273,25 @@ public class ShopChest extends JavaPlugin { for (Player p : getServer().getOnlinePlayers()) { if (p.isOp() || perm.has(p, "shopchest.notification.update")) { - JsonBuilder jb; + IJsonBuilder jb; switch (Utils.getServerVersion()) { case "v1_8_R1": - jb = new JsonBuilder_1_8_R1(this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion))); + jb = new de.epiceric.shopchest.nms.v1_8_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink); break; case "v1_8_R2": - jb = new JsonBuilder_1_8_R2(this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion))); + jb = new de.epiceric.shopchest.nms.v1_8_R2.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink); break; case "v1_8_R3": - jb = new JsonBuilder_1_8_R3(this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion))); + jb = new de.epiceric.shopchest.nms.v1_8_R3.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink); break; case "v1_9_R1": - jb = new JsonBuilder_1_9_R1(this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion))); + jb = new de.epiceric.shopchest.nms.v1_9_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink); break; case "v1_9_R2": - jb = new JsonBuilder_1_9_R2(this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion))); + jb = new de.epiceric.shopchest.nms.v1_9_R2.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink); break; case "v1_10_R1": - jb = new JsonBuilder_1_10_R1(this, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion))); + jb = new de.epiceric.shopchest.nms.v1_10_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, latestVersion)), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), downloadLink); break; default: return; diff --git a/src/de/epiceric/shopchest/config/Config.java b/ShopChest/src/main/java/de/epiceric/shopchest/config/Config.java similarity index 100% rename from src/de/epiceric/shopchest/config/Config.java rename to ShopChest/src/main/java/de/epiceric/shopchest/config/Config.java diff --git a/src/de/epiceric/shopchest/config/LanguageConfiguration.java b/ShopChest/src/main/java/de/epiceric/shopchest/config/LanguageConfiguration.java similarity index 100% rename from src/de/epiceric/shopchest/config/LanguageConfiguration.java rename to ShopChest/src/main/java/de/epiceric/shopchest/config/LanguageConfiguration.java diff --git a/src/de/epiceric/shopchest/config/Regex.java b/ShopChest/src/main/java/de/epiceric/shopchest/config/Regex.java similarity index 100% rename from src/de/epiceric/shopchest/config/Regex.java rename to ShopChest/src/main/java/de/epiceric/shopchest/config/Regex.java diff --git a/src/de/epiceric/shopchest/language/EnchantmentName.java b/ShopChest/src/main/java/de/epiceric/shopchest/language/EnchantmentName.java similarity index 100% rename from src/de/epiceric/shopchest/language/EnchantmentName.java rename to ShopChest/src/main/java/de/epiceric/shopchest/language/EnchantmentName.java diff --git a/src/de/epiceric/shopchest/language/EntityName.java b/ShopChest/src/main/java/de/epiceric/shopchest/language/EntityName.java similarity index 100% rename from src/de/epiceric/shopchest/language/EntityName.java rename to ShopChest/src/main/java/de/epiceric/shopchest/language/EntityName.java diff --git a/src/de/epiceric/shopchest/language/ItemName.java b/ShopChest/src/main/java/de/epiceric/shopchest/language/ItemName.java similarity index 100% rename from src/de/epiceric/shopchest/language/ItemName.java rename to ShopChest/src/main/java/de/epiceric/shopchest/language/ItemName.java diff --git a/src/de/epiceric/shopchest/language/LanguageUtils.java b/ShopChest/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java similarity index 99% rename from src/de/epiceric/shopchest/language/LanguageUtils.java rename to ShopChest/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java index 98c7b63..2bdbacc 100644 --- a/src/de/epiceric/shopchest/language/LanguageUtils.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/language/LanguageUtils.java @@ -3,8 +3,7 @@ package de.epiceric.shopchest.language; import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.config.LanguageConfiguration; import de.epiceric.shopchest.config.Regex; -import de.epiceric.shopchest.interfaces.SpawnEggMeta; -import de.epiceric.shopchest.interfaces.spawneggmeta.*; +import de.epiceric.shopchest.nms.ISpawnEggMeta; import de.epiceric.shopchest.utils.Utils; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; @@ -960,26 +959,26 @@ public class LanguageUtils { for (ItemName itemName : itemNames) { if (itemName.getMaterial() == Material.MONSTER_EGG && material == Material.MONSTER_EGG) { - SpawnEggMeta spawnEggMeta; + ISpawnEggMeta spawnEggMeta; switch (Utils.getServerVersion()) { case "v1_8_R1": - spawnEggMeta = new SpawnEggMeta_1_8_R1(stack); + spawnEggMeta = new de.epiceric.shopchest.nms.v1_8_R1.SpawnEggMeta(stack); break; case "v1_8_R2": - spawnEggMeta = new SpawnEggMeta_1_8_R2(stack); + spawnEggMeta = new de.epiceric.shopchest.nms.v1_8_R2.SpawnEggMeta(stack); break; case "v1_8_R3": - spawnEggMeta = new SpawnEggMeta_1_8_R3(stack); + spawnEggMeta = new de.epiceric.shopchest.nms.v1_8_R3.SpawnEggMeta(stack); break; case "v1_9_R1": - spawnEggMeta = new SpawnEggMeta_1_9_R1(stack); + spawnEggMeta = new de.epiceric.shopchest.nms.v1_9_R1.SpawnEggMeta(stack); break; case "v1_9_R2": - spawnEggMeta = new SpawnEggMeta_1_9_R2(stack); + spawnEggMeta = new de.epiceric.shopchest.nms.v1_9_R2.SpawnEggMeta(stack); break; case "v1_10_R1": - spawnEggMeta = new SpawnEggMeta_1_10_R1(stack); + spawnEggMeta = new de.epiceric.shopchest.nms.v1_10_R1.SpawnEggMeta(stack); break; default: return itemName.getLocalizedName(); diff --git a/src/de/epiceric/shopchest/language/LocalizedMessage.java b/ShopChest/src/main/java/de/epiceric/shopchest/language/LocalizedMessage.java similarity index 100% rename from src/de/epiceric/shopchest/language/LocalizedMessage.java rename to ShopChest/src/main/java/de/epiceric/shopchest/language/LocalizedMessage.java diff --git a/src/de/epiceric/shopchest/language/MusicDiscName.java b/ShopChest/src/main/java/de/epiceric/shopchest/language/MusicDiscName.java similarity index 100% rename from src/de/epiceric/shopchest/language/MusicDiscName.java rename to ShopChest/src/main/java/de/epiceric/shopchest/language/MusicDiscName.java diff --git a/src/de/epiceric/shopchest/language/PotionEffectName.java b/ShopChest/src/main/java/de/epiceric/shopchest/language/PotionEffectName.java similarity index 100% rename from src/de/epiceric/shopchest/language/PotionEffectName.java rename to ShopChest/src/main/java/de/epiceric/shopchest/language/PotionEffectName.java diff --git a/src/de/epiceric/shopchest/language/PotionName.java b/ShopChest/src/main/java/de/epiceric/shopchest/language/PotionName.java similarity index 100% rename from src/de/epiceric/shopchest/language/PotionName.java rename to ShopChest/src/main/java/de/epiceric/shopchest/language/PotionName.java diff --git a/src/de/epiceric/shopchest/listeners/ChestProtectListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java similarity index 100% rename from src/de/epiceric/shopchest/listeners/ChestProtectListener.java rename to ShopChest/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java diff --git a/src/de/epiceric/shopchest/listeners/ClearLagListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/ClearLagListener.java similarity index 100% rename from src/de/epiceric/shopchest/listeners/ClearLagListener.java rename to ShopChest/src/main/java/de/epiceric/shopchest/listeners/ClearLagListener.java diff --git a/src/de/epiceric/shopchest/listeners/HologramUpdateListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/HologramUpdateListener.java similarity index 100% rename from src/de/epiceric/shopchest/listeners/HologramUpdateListener.java rename to ShopChest/src/main/java/de/epiceric/shopchest/listeners/HologramUpdateListener.java diff --git a/src/de/epiceric/shopchest/listeners/ItemCustomNameListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/ItemCustomNameListener.java similarity index 100% rename from src/de/epiceric/shopchest/listeners/ItemCustomNameListener.java rename to ShopChest/src/main/java/de/epiceric/shopchest/listeners/ItemCustomNameListener.java diff --git a/src/de/epiceric/shopchest/listeners/ItemProtectListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/ItemProtectListener.java similarity index 100% rename from src/de/epiceric/shopchest/listeners/ItemProtectListener.java rename to ShopChest/src/main/java/de/epiceric/shopchest/listeners/ItemProtectListener.java diff --git a/src/de/epiceric/shopchest/listeners/LWCMagnetListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/LWCMagnetListener.java similarity index 100% rename from src/de/epiceric/shopchest/listeners/LWCMagnetListener.java rename to ShopChest/src/main/java/de/epiceric/shopchest/listeners/LWCMagnetListener.java diff --git a/ShopChest/src/main/java/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java new file mode 100644 index 0000000..efc8473 --- /dev/null +++ b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java @@ -0,0 +1,70 @@ +package de.epiceric.shopchest.listeners; + +import de.epiceric.shopchest.ShopChest; +import de.epiceric.shopchest.config.Regex; +import de.epiceric.shopchest.language.LanguageUtils; +import de.epiceric.shopchest.language.LocalizedMessage; +import de.epiceric.shopchest.nms.IJsonBuilder; +import de.epiceric.shopchest.utils.Utils; +import net.milkbowl.vault.permission.Permission; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +public class NotifyUpdateOnJoinListener implements Listener { + + private ShopChest plugin; + private Permission perm; + + public NotifyUpdateOnJoinListener(ShopChest plugin) { + this.plugin = plugin; + perm = plugin.getPermission(); + } + + @EventHandler + public void onPlayerJoin(PlayerJoinEvent e) { + + Player p = e.getPlayer(); + + if (plugin.isUpdateNeeded()) { + if (p.isOp() || perm.has(p, "shopchest.notification.update")) { + IJsonBuilder jb; + + switch (Utils.getServerVersion()) { + case "v1_8_R1": + jb = new de.epiceric.shopchest.nms.v1_8_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink()); + break; + case "v1_8_R2": + jb = new de.epiceric.shopchest.nms.v1_8_R2.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink()); + break; + case "v1_8_R3": + jb = new de.epiceric.shopchest.nms.v1_8_R3.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink()); + break; + case "v1_9_R1": + jb = new de.epiceric.shopchest.nms.v1_9_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink()); + break; + case "v1_9_R2": + jb = new de.epiceric.shopchest.nms.v1_9_R2.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink()); + break; + case "v1_10_R1": + jb = new de.epiceric.shopchest.nms.v1_10_R1.JsonBuilder(LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion())), LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD), plugin.getDownloadLink()); + break; + default: + return; + } + jb.sendJson(p); + } + } + + if (perm.has(p, "shopchest.broadcast")) { + if (plugin.getBroadcast() != null) { + for (String message : plugin.getBroadcast()) { + p.sendMessage(message); + } + } + } + + } + +} diff --git a/src/de/epiceric/shopchest/listeners/ShopInteractListener.java b/ShopChest/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java similarity index 100% rename from src/de/epiceric/shopchest/listeners/ShopInteractListener.java rename to ShopChest/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java diff --git a/src/de/epiceric/shopchest/shop/Shop.java b/ShopChest/src/main/java/de/epiceric/shopchest/shop/Shop.java similarity index 91% rename from src/de/epiceric/shopchest/shop/Shop.java rename to ShopChest/src/main/java/de/epiceric/shopchest/shop/Shop.java index 3c67807..42dccab 100644 --- a/src/de/epiceric/shopchest/shop/Shop.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/shop/Shop.java @@ -2,10 +2,9 @@ package de.epiceric.shopchest.shop; import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.config.Regex; -import de.epiceric.shopchest.interfaces.Hologram; -import de.epiceric.shopchest.interfaces.hologram.*; import de.epiceric.shopchest.language.LanguageUtils; import de.epiceric.shopchest.language.LocalizedMessage; +import de.epiceric.shopchest.nms.IHologram; import de.epiceric.shopchest.utils.Utils; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -31,7 +30,7 @@ public class Shop { private OfflinePlayer vendor; private ItemStack product; private Location location; - private Hologram hologram; + private IHologram hologram; private Item item; private double buyPrice; private double sellPrice; @@ -179,22 +178,22 @@ public class Shop { switch (Utils.getServerVersion()) { case "v1_8_R1": - hologram = new Hologram_1_8_R1(holoText, holoLocation); + hologram = new de.epiceric.shopchest.nms.v1_8_R1.Hologram(holoText, holoLocation); break; case "v1_8_R2": - hologram = new Hologram_1_8_R2(holoText, holoLocation); + hologram = new de.epiceric.shopchest.nms.v1_8_R2.Hologram(holoText, holoLocation); break; case "v1_8_R3": - hologram = new Hologram_1_8_R3(holoText, holoLocation); + hologram = new de.epiceric.shopchest.nms.v1_8_R3.Hologram(holoText, holoLocation); break; case "v1_9_R1": - hologram = new Hologram_1_9_R1(holoText, holoLocation); + hologram = new de.epiceric.shopchest.nms.v1_9_R1.Hologram(holoText, holoLocation); break; case "v1_9_R2": - hologram = new Hologram_1_9_R2(holoText, holoLocation); + hologram = new de.epiceric.shopchest.nms.v1_9_R2.Hologram(holoText, holoLocation); break; case "v1_10_R1": - hologram = new Hologram_1_10_R1(holoText, holoLocation); + hologram = new de.epiceric.shopchest.nms.v1_10_R1.Hologram(holoText, holoLocation); break; } @@ -250,9 +249,9 @@ public class Shop { } /** - * @return Hologram of the shop + * @return IHologram of the shop */ - public Hologram getHologram() { + public IHologram getHologram() { return hologram; } diff --git a/src/de/epiceric/shopchest/sql/Database.java b/ShopChest/src/main/java/de/epiceric/shopchest/sql/Database.java similarity index 100% rename from src/de/epiceric/shopchest/sql/Database.java rename to ShopChest/src/main/java/de/epiceric/shopchest/sql/Database.java diff --git a/src/de/epiceric/shopchest/sql/MySQL.java b/ShopChest/src/main/java/de/epiceric/shopchest/sql/MySQL.java similarity index 100% rename from src/de/epiceric/shopchest/sql/MySQL.java rename to ShopChest/src/main/java/de/epiceric/shopchest/sql/MySQL.java diff --git a/src/de/epiceric/shopchest/sql/SQLite.java b/ShopChest/src/main/java/de/epiceric/shopchest/sql/SQLite.java similarity index 100% rename from src/de/epiceric/shopchest/sql/SQLite.java rename to ShopChest/src/main/java/de/epiceric/shopchest/sql/SQLite.java diff --git a/src/de/epiceric/shopchest/utils/ClickType.java b/ShopChest/src/main/java/de/epiceric/shopchest/utils/ClickType.java similarity index 100% rename from src/de/epiceric/shopchest/utils/ClickType.java rename to ShopChest/src/main/java/de/epiceric/shopchest/utils/ClickType.java diff --git a/src/de/epiceric/shopchest/utils/Metrics.java b/ShopChest/src/main/java/de/epiceric/shopchest/utils/Metrics.java similarity index 99% rename from src/de/epiceric/shopchest/utils/Metrics.java rename to ShopChest/src/main/java/de/epiceric/shopchest/utils/Metrics.java index 9753581..f7fadf8 100644 --- a/src/de/epiceric/shopchest/utils/Metrics.java +++ b/ShopChest/src/main/java/de/epiceric/shopchest/utils/Metrics.java @@ -372,7 +372,7 @@ public class Metrics { /** * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. * - * @throws java.io.IOException + * @throws IOException */ public void enable() throws IOException { // This has to be synchronized or it can collide with the check in the task. @@ -393,7 +393,7 @@ public class Metrics { /** * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. * - * @throws java.io.IOException + * @throws IOException */ public void disable() throws IOException { // This has to be synchronized or it can collide with the check in the task. @@ -677,7 +677,7 @@ public class Metrics { /** * Gets an unmodifiable set of the plotter objects in the graph * - * @return an unmodifiable {@link java.util.Set} of the plotter objects + * @return an unmodifiable {@link Set} of the plotter objects */ public Set getPlotters() { return Collections.unmodifiableSet(plotters); diff --git a/src/de/epiceric/shopchest/utils/ShopUtils.java b/ShopChest/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java similarity index 100% rename from src/de/epiceric/shopchest/utils/ShopUtils.java rename to ShopChest/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java diff --git a/src/de/epiceric/shopchest/utils/UpdateChecker.java b/ShopChest/src/main/java/de/epiceric/shopchest/utils/UpdateChecker.java similarity index 100% rename from src/de/epiceric/shopchest/utils/UpdateChecker.java rename to ShopChest/src/main/java/de/epiceric/shopchest/utils/UpdateChecker.java diff --git a/src/de/epiceric/shopchest/utils/Utils.java b/ShopChest/src/main/java/de/epiceric/shopchest/utils/Utils.java similarity index 100% rename from src/de/epiceric/shopchest/utils/Utils.java rename to ShopChest/src/main/java/de/epiceric/shopchest/utils/Utils.java diff --git a/config.yml b/ShopChest/src/main/resources/config.yml similarity index 100% rename from config.yml rename to ShopChest/src/main/resources/config.yml diff --git a/item_names.txt b/ShopChest/src/main/resources/item_names.txt similarity index 100% rename from item_names.txt rename to ShopChest/src/main/resources/item_names.txt diff --git a/lang/de_DE.lang b/ShopChest/src/main/resources/lang/de_DE.lang similarity index 100% rename from lang/de_DE.lang rename to ShopChest/src/main/resources/lang/de_DE.lang diff --git a/lang/en_US.lang b/ShopChest/src/main/resources/lang/en_US.lang similarity index 100% rename from lang/en_US.lang rename to ShopChest/src/main/resources/lang/en_US.lang diff --git a/plugin.yml b/ShopChest/src/main/resources/plugin.yml similarity index 97% rename from plugin.yml rename to ShopChest/src/main/resources/plugin.yml index fa6abf8..8f1473b 100644 --- a/plugin.yml +++ b/ShopChest/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ # Do not change anything in here unless you know what you're doing! name: ShopChest -main: de.epiceric.shopchest.ShopChest +main: de.epiceric.ShopChest version: 1.8.0 author: EpicEric website: https://www.spigotmc.org/resources/shopchest.11431/ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..eecfdce --- /dev/null +++ b/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + de.epiceric + ShopChest-Root + pom + 1.8.0 + + + 1.7 + 1.7 + + + + ShopChest + ShopChest NMS-Abstract + ShopChest NMS-v1_8_R1 + ShopChest NMS-v1_8_R2 + ShopChest NMS-v1_8_R3 + ShopChest NMS-v1_9_R1 + ShopChest NMS-v1_9_R2 + ShopChest NMS-v1_10_R1 + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + shopchest-repo + https://epicericee.github.io/ShopChest/maven/ + + + + + + org.spigotmc + spigot-api + 1.10.2-R0.1-SNAPSHOT + provided + + + org.bukkit + bukkit + 1.10.2-R0.1-SNAPSHOT + provided + + + + net.milkbowl.vault + VaultAPI + 1.5 + provided + + + org.yi.acru.bukkit + lockette + 1.8.36 + provided + + + me.minebuilders + clearlag + 2.9.1 + provided + + + com.griefcraft.lwc + lwc-entity-locking + 1.7.3 + provided + + + + + + + src/main/resources + . + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.4.3 + + + package + + shade + + + + + + + + \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/JsonBuilder.java b/src/de/epiceric/shopchest/interfaces/JsonBuilder.java deleted file mode 100644 index 3b58f81..0000000 --- a/src/de/epiceric/shopchest/interfaces/JsonBuilder.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.epiceric.shopchest.interfaces; - -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; - -public interface JsonBuilder { - - JsonBuilder parse(String text); - - JsonBuilder withText(String text); - - JsonBuilder withColor(ChatColor color); - - JsonBuilder withColor(String color); - - JsonBuilder withClickEvent(ClickAction action, String value); - - JsonBuilder withHoverEvent(HoverAction action, String value); - - String toString(); - - void sendJson(Player p); - - enum ClickAction { - RUN_COMMAND, SUGGEST_COMMAND, OPEN_URL - } - - enum HoverAction { - SHOW_TEXT - } - -} diff --git a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_10_R1.java b/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_10_R1.java deleted file mode 100644 index 84920c3..0000000 --- a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_10_R1.java +++ /dev/null @@ -1,113 +0,0 @@ -package de.epiceric.shopchest.interfaces.jsonbuilder; - -import de.epiceric.shopchest.ShopChest; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.language.LanguageUtils; -import de.epiceric.shopchest.language.LocalizedMessage; -import net.minecraft.server.v1_10_R1.IChatBaseComponent.ChatSerializer; -import net.minecraft.server.v1_10_R1.PacketPlayOutChat; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - - -public class JsonBuilder_1_10_R1 implements JsonBuilder { - - /* JsonBuilder by FisheyLP */ - - private List extras = new ArrayList(); - private ShopChest plugin; - - public JsonBuilder_1_10_R1(ShopChest plugin, String... text) { - this.plugin = plugin; - for (String extra : text) - parse(extra); - } - - @Override - public JsonBuilder_1_10_R1 parse(String text) { - String regex = "[&�]{1}([a-fA-Fl-oL-O0-9]){1}"; - text = text.replaceAll(regex, "�$1"); - if (!Pattern.compile(regex).matcher(text).find()) { - withText(text).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - return this; - } - String[] words = text.split(regex); - - int index = words[0].length(); - for (String word : words) { - try { - if (index != words[0].length()) - withText(word).withColor("�" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - } catch (Exception e) { - } - index += word.length() + 2; - } - return this; - } - - @Override - public JsonBuilder_1_10_R1 withText(String text) { - extras.add("{\"text\":\"" + text + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_10_R1 withColor(ChatColor color) { - String c = color.name().toLowerCase(); - addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true"); - return this; - } - - @Override - public JsonBuilder_1_10_R1 withColor(String color) { - while (color.length() != 1) color = color.substring(1).trim(); - withColor(ChatColor.getByChar(color)); - return this; - } - - @Override - public JsonBuilder_1_10_R1 withClickEvent(ClickAction action, String value) { - addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_10_R1 withHoverEvent(HoverAction action, String value) { - addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - private void addSegment(String segment) { - String lastText = extras.get(extras.size() - 1); - lastText = lastText.substring(0, lastText.length() - 1) - + "," + segment + "}"; - extras.remove(extras.size() - 1); - extras.add(lastText); - } - - @Override - public String toString() { - if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0); - String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":["; - extras.remove(0); - for (String extra : extras) - text = text + extra + ","; - text = text.substring(0, text.length() - 1) + "]}"; - return text; - } - - @Override - public void sendJson(Player p) { - ((CraftPlayer) p).getHandle().playerConnection.sendPacket( - new PacketPlayOutChat(ChatSerializer.a(toString()))); - - - } -} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R2.java b/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R2.java deleted file mode 100644 index 306f46c..0000000 --- a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R2.java +++ /dev/null @@ -1,114 +0,0 @@ -package de.epiceric.shopchest.interfaces.jsonbuilder; - -import de.epiceric.shopchest.ShopChest; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.language.LanguageUtils; -import de.epiceric.shopchest.language.LocalizedMessage; -import net.minecraft.server.v1_8_R2.IChatBaseComponent.ChatSerializer; -import net.minecraft.server.v1_8_R2.PacketPlayOutChat; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - - -public class JsonBuilder_1_8_R2 implements JsonBuilder { - - /* JsonBuilder by FisheyLP */ - - private List extras = new ArrayList(); - private ShopChest plugin; - - public JsonBuilder_1_8_R2(ShopChest plugin, String... text) { - this.plugin = plugin; - for (String extra : text) - parse(extra); - } - - @Override - public JsonBuilder_1_8_R2 parse(String text) { - String regex = "[&�]{1}([a-fA-Fl-oL-O0-9]){1}"; - text = text.replaceAll(regex, "�$1"); - if (!Pattern.compile(regex).matcher(text).find()) { - withText(text).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - return this; - } - String[] words = text.split(regex); - - int index = words[0].length(); - for (String word : words) { - try { - if (index != words[0].length()) - withText(word).withColor("�" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - } catch (Exception e) { - } - index += word.length() + 2; - } - return this; - } - - @Override - public JsonBuilder_1_8_R2 withText(String text) { - extras.add("{\"text\":\"" + text + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_8_R2 withColor(ChatColor color) { - String c = color.name().toLowerCase(); - addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true"); - return this; - } - - @Override - public JsonBuilder_1_8_R2 withColor(String color) { - while (color.length() != 1) color = color.substring(1).trim(); - withColor(ChatColor.getByChar(color)); - return this; - } - - @Override - public JsonBuilder_1_8_R2 withClickEvent(ClickAction action, String value) { - addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_8_R2 withHoverEvent(HoverAction action, String value) { - addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - private void addSegment(String segment) { - String lastText = extras.get(extras.size() - 1); - lastText = lastText.substring(0, lastText.length() - 1) - + "," + segment + "}"; - extras.remove(extras.size() - 1); - extras.add(lastText); - } - - @Override - public String toString() { - if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0); - String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":["; - extras.remove(0); - ; - for (String extra : extras) - text = text + extra + ","; - text = text.substring(0, text.length() - 1) + "]}"; - return text; - } - - @Override - public void sendJson(Player p) { - ((CraftPlayer) p).getHandle().playerConnection.sendPacket( - new PacketPlayOutChat(ChatSerializer.a(toString()))); - - - } -} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R3.java b/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R3.java deleted file mode 100644 index ff0bd33..0000000 --- a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_8_R3.java +++ /dev/null @@ -1,114 +0,0 @@ -package de.epiceric.shopchest.interfaces.jsonbuilder; - -import de.epiceric.shopchest.ShopChest; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.language.LanguageUtils; -import de.epiceric.shopchest.language.LocalizedMessage; -import net.minecraft.server.v1_8_R3.IChatBaseComponent.ChatSerializer; -import net.minecraft.server.v1_8_R3.PacketPlayOutChat; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - - -public class JsonBuilder_1_8_R3 implements JsonBuilder { - - /* JsonBuilder by FisheyLP */ - - private List extras = new ArrayList(); - private ShopChest plugin; - - public JsonBuilder_1_8_R3(ShopChest plugin, String... text) { - this.plugin = plugin; - for (String extra : text) - parse(extra); - } - - @Override - public JsonBuilder_1_8_R3 parse(String text) { - String regex = "[&�]{1}([a-fA-Fl-oL-O0-9]){1}"; - text = text.replaceAll(regex, "�$1"); - if (!Pattern.compile(regex).matcher(text).find()) { - withText(text).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - return this; - } - String[] words = text.split(regex); - - int index = words[0].length(); - for (String word : words) { - try { - if (index != words[0].length()) - withText(word).withColor("�" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - } catch (Exception e) { - } - index += word.length() + 2; - } - return this; - } - - @Override - public JsonBuilder_1_8_R3 withText(String text) { - extras.add("{\"text\":\"" + text + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_8_R3 withColor(ChatColor color) { - String c = color.name().toLowerCase(); - addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true"); - return this; - } - - @Override - public JsonBuilder_1_8_R3 withColor(String color) { - while (color.length() != 1) color = color.substring(1).trim(); - withColor(ChatColor.getByChar(color)); - return this; - } - - @Override - public JsonBuilder_1_8_R3 withClickEvent(ClickAction action, String value) { - addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_8_R3 withHoverEvent(HoverAction action, String value) { - addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - private void addSegment(String segment) { - String lastText = extras.get(extras.size() - 1); - lastText = lastText.substring(0, lastText.length() - 1) - + "," + segment + "}"; - extras.remove(extras.size() - 1); - extras.add(lastText); - } - - @Override - public String toString() { - if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0); - String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":["; - extras.remove(0); - ; - for (String extra : extras) - text = text + extra + ","; - text = text.substring(0, text.length() - 1) + "]}"; - return text; - } - - @Override - public void sendJson(Player p) { - ((CraftPlayer) p).getHandle().playerConnection.sendPacket( - new PacketPlayOutChat(ChatSerializer.a(toString()))); - - - } -} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_9_R1.java b/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_9_R1.java deleted file mode 100644 index 6d722b1..0000000 --- a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_9_R1.java +++ /dev/null @@ -1,114 +0,0 @@ -package de.epiceric.shopchest.interfaces.jsonbuilder; - -import de.epiceric.shopchest.ShopChest; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.language.LanguageUtils; -import de.epiceric.shopchest.language.LocalizedMessage; -import net.minecraft.server.v1_9_R1.IChatBaseComponent.ChatSerializer; -import net.minecraft.server.v1_9_R1.PacketPlayOutChat; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - - -public class JsonBuilder_1_9_R1 implements JsonBuilder { - - /* JsonBuilder by FisheyLP */ - - private List extras = new ArrayList(); - private ShopChest plugin; - - public JsonBuilder_1_9_R1(ShopChest plugin, String... text) { - this.plugin = plugin; - for (String extra : text) - parse(extra); - } - - @Override - public JsonBuilder_1_9_R1 parse(String text) { - String regex = "[&�]{1}([a-fA-Fl-oL-O0-9]){1}"; - text = text.replaceAll(regex, "�$1"); - if (!Pattern.compile(regex).matcher(text).find()) { - withText(text).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - return this; - } - String[] words = text.split(regex); - - int index = words[0].length(); - for (String word : words) { - try { - if (index != words[0].length()) - withText(word).withColor("�" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - } catch (Exception e) { - } - index += word.length() + 2; - } - return this; - } - - @Override - public JsonBuilder_1_9_R1 withText(String text) { - extras.add("{\"text\":\"" + text + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_9_R1 withColor(ChatColor color) { - String c = color.name().toLowerCase(); - addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true"); - return this; - } - - @Override - public JsonBuilder_1_9_R1 withColor(String color) { - while (color.length() != 1) color = color.substring(1).trim(); - withColor(ChatColor.getByChar(color)); - return this; - } - - @Override - public JsonBuilder_1_9_R1 withClickEvent(ClickAction action, String value) { - addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_9_R1 withHoverEvent(HoverAction action, String value) { - addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - private void addSegment(String segment) { - String lastText = extras.get(extras.size() - 1); - lastText = lastText.substring(0, lastText.length() - 1) - + "," + segment + "}"; - extras.remove(extras.size() - 1); - extras.add(lastText); - } - - @Override - public String toString() { - if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0); - String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":["; - extras.remove(0); - ; - for (String extra : extras) - text = text + extra + ","; - text = text.substring(0, text.length() - 1) + "]}"; - return text; - } - - @Override - public void sendJson(Player p) { - ((CraftPlayer) p).getHandle().playerConnection.sendPacket( - new PacketPlayOutChat(ChatSerializer.a(toString()))); - - - } -} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_9_R2.java b/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_9_R2.java deleted file mode 100644 index d4111cc..0000000 --- a/src/de/epiceric/shopchest/interfaces/jsonbuilder/JsonBuilder_1_9_R2.java +++ /dev/null @@ -1,114 +0,0 @@ -package de.epiceric.shopchest.interfaces.jsonbuilder; - -import de.epiceric.shopchest.ShopChest; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.language.LanguageUtils; -import de.epiceric.shopchest.language.LocalizedMessage; -import net.minecraft.server.v1_9_R2.IChatBaseComponent.ChatSerializer; -import net.minecraft.server.v1_9_R2.PacketPlayOutChat; -import org.bukkit.ChatColor; -import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Pattern; - - -public class JsonBuilder_1_9_R2 implements JsonBuilder { - - /* JsonBuilder by FisheyLP */ - - private List extras = new ArrayList(); - private ShopChest plugin; - - public JsonBuilder_1_9_R2(ShopChest plugin, String... text) { - this.plugin = plugin; - for (String extra : text) - parse(extra); - } - - @Override - public JsonBuilder_1_9_R2 parse(String text) { - String regex = "[&�]{1}([a-fA-Fl-oL-O0-9]){1}"; - text = text.replaceAll(regex, "�$1"); - if (!Pattern.compile(regex).matcher(text).find()) { - withText(text).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - return this; - } - String[] words = text.split(regex); - - int index = words[0].length(); - for (String word : words) { - try { - if (index != words[0].length()) - withText(word).withColor("�" + text.charAt(index - 1)).withHoverEvent(HoverAction.SHOW_TEXT, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_CLICK_TO_DOWNLOAD)).withClickEvent(ClickAction.OPEN_URL, plugin.getDownloadLink()); - } catch (Exception e) { - } - index += word.length() + 2; - } - return this; - } - - @Override - public JsonBuilder_1_9_R2 withText(String text) { - extras.add("{\"text\":\"" + text + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_9_R2 withColor(ChatColor color) { - String c = color.name().toLowerCase(); - addSegment(color.isColor() ? "\"color\":\"" + c + "\"" : "\"" + c + "\"" + ":true"); - return this; - } - - @Override - public JsonBuilder_1_9_R2 withColor(String color) { - while (color.length() != 1) color = color.substring(1).trim(); - withColor(ChatColor.getByChar(color)); - return this; - } - - @Override - public JsonBuilder_1_9_R2 withClickEvent(ClickAction action, String value) { - addSegment("\"clickEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - @Override - public JsonBuilder_1_9_R2 withHoverEvent(HoverAction action, String value) { - addSegment("\"hoverEvent\":{\"action\":\"" + action.toString().toLowerCase() - + "\",\"value\":\"" + value + "\"}"); - return this; - } - - private void addSegment(String segment) { - String lastText = extras.get(extras.size() - 1); - lastText = lastText.substring(0, lastText.length() - 1) - + "," + segment + "}"; - extras.remove(extras.size() - 1); - extras.add(lastText); - } - - @Override - public String toString() { - if (extras.size() <= 1) return extras.size() == 0 ? "{\"text\":\"\"}" : extras.get(0); - String text = extras.get(0).substring(0, extras.get(0).length() - 1) + ",\"extra\":["; - extras.remove(0); - ; - for (String extra : extras) - text = text + extra + ","; - text = text.substring(0, text.length() - 1) + "]}"; - return text; - } - - @Override - public void sendJson(Player p) { - ((CraftPlayer) p).getHandle().playerConnection.sendPacket( - new PacketPlayOutChat(ChatSerializer.a(toString()))); - - - } -} \ No newline at end of file diff --git a/src/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java b/src/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java deleted file mode 100644 index de72f68..0000000 --- a/src/de/epiceric/shopchest/listeners/NotifyUpdateOnJoinListener.java +++ /dev/null @@ -1,71 +0,0 @@ -package de.epiceric.shopchest.listeners; - -import de.epiceric.shopchest.ShopChest; -import de.epiceric.shopchest.config.Regex; -import de.epiceric.shopchest.interfaces.JsonBuilder; -import de.epiceric.shopchest.interfaces.jsonbuilder.*; -import de.epiceric.shopchest.language.LanguageUtils; -import de.epiceric.shopchest.language.LocalizedMessage; -import de.epiceric.shopchest.utils.Utils; -import net.milkbowl.vault.permission.Permission; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; - -public class NotifyUpdateOnJoinListener implements Listener { - - private ShopChest plugin; - private Permission perm; - - public NotifyUpdateOnJoinListener(ShopChest plugin) { - this.plugin = plugin; - perm = plugin.getPermission(); - } - - @EventHandler - public void onPlayerJoin(PlayerJoinEvent e) { - - Player p = e.getPlayer(); - - if (plugin.isUpdateNeeded()) { - if (p.isOp() || perm.has(p, "shopchest.notification.update")) { - JsonBuilder jb; - - switch (Utils.getServerVersion()) { - case "v1_8_R1": - jb = new JsonBuilder_1_8_R1(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion()))); - break; - case "v1_8_R2": - jb = new JsonBuilder_1_8_R2(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion()))); - break; - case "v1_8_R3": - jb = new JsonBuilder_1_8_R3(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion()))); - break; - case "v1_9_R1": - jb = new JsonBuilder_1_9_R1(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion()))); - break; - case "v1_9_R2": - jb = new JsonBuilder_1_9_R2(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion()))); - break; - case "v1_10_R1": - jb = new JsonBuilder_1_10_R1(plugin, LanguageUtils.getMessage(LocalizedMessage.Message.UPDATE_AVAILABLE, new LocalizedMessage.ReplacedRegex(Regex.VERSION, plugin.getLatestVersion()))); - break; - default: - return; - } - jb.sendJson(p); - } - } - - if (perm.has(p, "shopchest.broadcast")) { - if (plugin.getBroadcast() != null) { - for (String message : plugin.getBroadcast()) { - p.sendMessage(message); - } - } - } - - } - -}