|
@@ -19,18 +19,7 @@
|
|
|
package de.butzlabben.missilewars.util.version;
|
|
|
|
|
|
import de.butzlabben.missilewars.Logger;
|
|
|
-import de.butzlabben.missilewars.configuration.Messages;
|
|
|
-import de.butzlabben.missilewars.game.Team;
|
|
|
import org.bukkit.Bukkit;
|
|
|
-import org.bukkit.Location;
|
|
|
-import org.bukkit.Material;
|
|
|
-import org.bukkit.Sound;
|
|
|
-import org.bukkit.entity.EntityType;
|
|
|
-import org.bukkit.entity.Player;
|
|
|
-import org.bukkit.inventory.ItemStack;
|
|
|
-import org.bukkit.inventory.meta.ItemMeta;
|
|
|
-
|
|
|
-import java.lang.reflect.Method;
|
|
|
|
|
|
/**
|
|
|
* @author Butzlabben
|
|
@@ -70,179 +59,10 @@ public class VersionUtil {
|
|
|
|
|
|
if (version == 0) {
|
|
|
Logger.WARN.log("Unknown version: " + Bukkit.getVersion());
|
|
|
- Logger.WARN.log("Choosing version 1.12.2");
|
|
|
- version = 12;
|
|
|
+ Logger.WARN.log("Choosing version 1.13");
|
|
|
+ version = 13;
|
|
|
}
|
|
|
return version;
|
|
|
}
|
|
|
-
|
|
|
- public static void sendTitle(Player p, String title, String subtitle) {
|
|
|
- if (getVersion() > 8) {
|
|
|
- try {
|
|
|
- Method m = p.getClass().getMethod("sendTitle", String.class, String.class);
|
|
|
- m.invoke(p, title, subtitle);
|
|
|
- } catch (Exception e) {
|
|
|
- Logger.ERROR.log("Couldn't send title to player");
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- } else {
|
|
|
- p.sendMessage(Messages.getPrefix() + title + " " + subtitle);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static void playFireball(Player p, Location loc) {
|
|
|
- if (getVersion() <= 8) {
|
|
|
- p.playSound(loc, sound("ANVIL_LAND"), 100.0F, 2.0F);
|
|
|
- p.playSound(loc, sound("FIRE_IGNITE"), 100.0F, 1.0F);
|
|
|
- } else {
|
|
|
- p.playSound(loc, sound("BLOCK_ANVIL_LAND"), 100.0F, 2.0F);
|
|
|
- p.playSound(loc, sound("ITEM_FLINTANDSTEEL_USE"), 100.0F, 1.0F);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static void playSnowball(Player p, Location loc) {
|
|
|
- if (getVersion() <= 8)
|
|
|
- p.playSound(loc, sound("ENDERDRAGON_WINGS"), 1.0F, 1.0F);
|
|
|
- else if (getVersion() <= 12)
|
|
|
- p.playSound(loc, sound("ENTITY_ENDERDRAGON_FLAP"), 1, 1);
|
|
|
- else
|
|
|
- p.playSound(loc, sound("ENTITY_ENDER_DRAGON_FLAP"), 1, 1);
|
|
|
- }
|
|
|
-
|
|
|
- public static void playPling(Player p) {
|
|
|
- if (getVersion() <= 8)
|
|
|
- p.playSound(p.getLocation(), sound("NOTE_PLING"), 100, 3);
|
|
|
- else if (getVersion() >= 13)
|
|
|
- p.playSound(p.getLocation(), sound("BLOCK_NOTE_BLOCK_PLING"), 100, 3);
|
|
|
- else
|
|
|
- p.playSound(p.getLocation(), sound("BLOCK_NOTE_PLING"), 100, 3);
|
|
|
- }
|
|
|
-
|
|
|
- public static void playDraw(Player p) {
|
|
|
- if (getVersion() <= 8)
|
|
|
- p.playSound(p.getLocation(), sound("WITHER_DEATH"), 100, 0);
|
|
|
- else
|
|
|
- p.playSound(p.getLocation(), sound("ENTITY_WITHER_DEATH"), 100, 0);
|
|
|
- }
|
|
|
-
|
|
|
- private static Sound sound(String s) {
|
|
|
- Sound sound = null;
|
|
|
- try {
|
|
|
- sound = Sound.valueOf(s);
|
|
|
- } catch (Exception e) {
|
|
|
- Logger.ERROR.log("Couldn't find sound " + s);
|
|
|
- }
|
|
|
- return sound;
|
|
|
- }
|
|
|
-
|
|
|
- public static Material getFireball() {
|
|
|
- if (getVersion() < 13)
|
|
|
- return Material.valueOf("FIREBALL");
|
|
|
- else
|
|
|
- return Material.valueOf("FIRE_CHARGE");
|
|
|
- }
|
|
|
-
|
|
|
- public static Material getSnowball() {
|
|
|
- if (getVersion() < 13)
|
|
|
- return Material.valueOf("SNOW_BALL");
|
|
|
- else
|
|
|
- return Material.valueOf("SNOWBALL");
|
|
|
- }
|
|
|
-
|
|
|
- public static Material getMonsterEgg(EntityType type) {
|
|
|
- if (getVersion() < 13)
|
|
|
- return Material.valueOf("MONSTER_EGG");
|
|
|
- else {
|
|
|
- if (type == EntityType.MUSHROOM_COW) {
|
|
|
- //noinspection SpellCheckingInspection
|
|
|
- return Material.valueOf("MOOSHROOM_SPAWN_EGG");
|
|
|
-
|
|
|
- }
|
|
|
- return Material.valueOf(type.name() + "_SPAWN_EGG");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static boolean isMonsterEgg(Material material) {
|
|
|
- if (material == null)
|
|
|
- return false;
|
|
|
- String name = material.name();
|
|
|
- if (name.equals("EGG"))
|
|
|
- return false;
|
|
|
- if (name.contains("SPAWN_EGG"))
|
|
|
- return true;
|
|
|
- return name.equals("MONSTER_EGG");
|
|
|
- }
|
|
|
-
|
|
|
- public static Material getPortal() {
|
|
|
- if (getVersion() < 13)
|
|
|
- return Material.valueOf("PORTAL");
|
|
|
- else
|
|
|
- return Material.valueOf("NETHER_PORTAL");
|
|
|
- }
|
|
|
-
|
|
|
- public static Material getSunFlower() {
|
|
|
- if (getVersion() > 12)
|
|
|
- return Material.valueOf("SUNFLOWER");
|
|
|
- else
|
|
|
- return Material.valueOf("DOUBLE_PLANT");
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressWarnings("deprecation")
|
|
|
- public static ItemStack getGlassPlane(Team team) {
|
|
|
- String colorCode = team.getColorCode();
|
|
|
- ItemStack is;
|
|
|
- if (getVersion() < 13) {
|
|
|
- is = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, ColorConverter.getColorIDforBlockFromColorCode(colorCode));
|
|
|
- } else {
|
|
|
- is = new ItemStack(ColorConverter.getGlassPaneFromColorCode(colorCode));
|
|
|
- }
|
|
|
-
|
|
|
- ItemMeta im = is.getItemMeta();
|
|
|
- im.setDisplayName(team.getFullname());
|
|
|
- is.setItemMeta(im);
|
|
|
- return is;
|
|
|
- }
|
|
|
-
|
|
|
- public static boolean isStainedGlassPane(Material material) {
|
|
|
- if (material == null)
|
|
|
- return false;
|
|
|
- return material.name().contains("STAINED_GLASS_PANE");
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressWarnings("deprecation")
|
|
|
- public static ItemStack getGlassPlane(String colorCode) {
|
|
|
- ItemStack is;
|
|
|
- if (getVersion() < 13) {
|
|
|
- is = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, ColorConverter.getColorIDforBlockFromColorCode(colorCode));
|
|
|
- } else {
|
|
|
- is = new ItemStack(ColorConverter.getGlassPaneFromColorCode(colorCode));
|
|
|
- }
|
|
|
- return is;
|
|
|
- }
|
|
|
-
|
|
|
- public static Material getPlayerSkullMaterial() {
|
|
|
- if (getVersion() > 12) {
|
|
|
- return Material.valueOf("PLAYER_HEAD");
|
|
|
- } else {
|
|
|
- return Material.valueOf("SKULL_ITEM");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public static boolean isWallSignMaterial(Material material) {
|
|
|
- return material.name().contains("_SIGN");
|
|
|
- }
|
|
|
-
|
|
|
- public static void setUnbreakable(ItemStack is) {
|
|
|
- ItemMeta im = is.getItemMeta();
|
|
|
- if (getVersion() >= 11) {
|
|
|
- im.setUnbreakable(true);
|
|
|
- } else {
|
|
|
-// im.spigot().setUnbreakable(true);
|
|
|
- }
|
|
|
- is.setItemMeta(im);
|
|
|
- }
|
|
|
-
|
|
|
- public static void restart() {
|
|
|
- Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "restart");
|
|
|
- }
|
|
|
+
|
|
|
}
|