diff --git a/1_12/pom.xml b/1_12/pom.xml
deleted file mode 100644
index 3bd1c7bb..00000000
--- a/1_12/pom.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
- missilewars
- de.butzlabben
- 1.0
-
-
- 4.0.0
-
- 1_12
-
-
-
-
- com.sk89q
- worldedit
- 6.0.0-SNAPSHOT
- provided
-
-
-
\ No newline at end of file
diff --git a/1_12/src/main/java/de/butzlabben/missilewars/missile/paste/r1_12/BlockFilterExtent.java b/1_12/src/main/java/de/butzlabben/missilewars/missile/paste/r1_12/BlockFilterExtent.java
deleted file mode 100644
index 5fc6cf0f..00000000
--- a/1_12/src/main/java/de/butzlabben/missilewars/missile/paste/r1_12/BlockFilterExtent.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
- * Copyright (c) 2018-2021 Daniel Nägele.
- *
- * MissileWars is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MissileWars is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MissileWars. If not, see .
- */
-
-package de.butzlabben.missilewars.missile.paste.r1_12;
-
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.WorldEditException;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.blocks.BlockID;
-import com.sk89q.worldedit.extent.AbstractDelegateExtent;
-import com.sk89q.worldedit.extent.Extent;
-
-/**
- * @author Butzlabben
- * @since 28.09.2018
- */
-public class BlockFilterExtent extends AbstractDelegateExtent {
-
- private byte data;
-
- protected BlockFilterExtent(Extent extent) {
- super(extent);
- }
-
- public BlockFilterExtent(Extent extent, byte data) {
- this(extent);
- this.data = data;
- }
-
- @Override
- public BaseBlock getBlock(Vector position) {
- BaseBlock block = super.getBlock(position);
- if (block.getId() == BlockID.STAINED_GLASS_PANE)
- block.setData(data);
- if (block.getId() == BlockID.STAINED_GLASS)
- block.setData(data);
- return block;
- }
-
- @Override
- public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
- if (block.getId() == 160)
- block.setData(data);
- return super.setBlock(location, block);
- }
-}
diff --git a/1_12/src/main/java/de/butzlabben/missilewars/missile/paste/r1_12/R1_12Paster.java b/1_12/src/main/java/de/butzlabben/missilewars/missile/paste/r1_12/R1_12Paster.java
deleted file mode 100644
index e4b251ac..00000000
--- a/1_12/src/main/java/de/butzlabben/missilewars/missile/paste/r1_12/R1_12Paster.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
- * Copyright (c) 2018-2021 Daniel Nägele.
- *
- * MissileWars is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MissileWars is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MissileWars. If not, see .
- */
-
-package de.butzlabben.missilewars.missile.paste.r1_12;
-
-import com.sk89q.worldedit.EditSession;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.WorldEdit;
-import com.sk89q.worldedit.bukkit.BukkitWorld;
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.extent.clipboard.Clipboard;
-import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
-import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
-import com.sk89q.worldedit.function.mask.ExistingBlockMask;
-import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
-import com.sk89q.worldedit.function.operation.Operations;
-import com.sk89q.worldedit.math.transform.AffineTransform;
-import com.sk89q.worldedit.regions.CuboidRegion;
-import com.sk89q.worldedit.world.World;
-import com.sk89q.worldedit.world.registry.WorldData;
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.HashSet;
-import java.util.Set;
-import org.bukkit.Material;
-import org.bukkit.block.Block;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitRunnable;
-
-/**
- * @author Butzlabben
- * @since 23.09.2018
- */
-public class R1_12Paster {
-
- public void pasteMissile(File schematic, org.bukkit.util.Vector pos, int rotation, org.bukkit.World world,
- byte data, int radius, Material replaceType, JavaPlugin plugin, int replaceTicks) {
- try {
- Vector position = new Vector(pos.getX(), pos.getY(), pos.getZ());
-
- World weWorld = new BukkitWorld(world);
- WorldData worldData = weWorld.getWorldData();
- Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(schematic)).read(worldData);
- EditSession session = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1);
- AffineTransform transform = new AffineTransform();
-
- transform = transform.rotateY(rotation);
- Extent extent = new BlockTransformExtent(clipboard, transform, worldData.getBlockRegistry());
- extent = new BlockFilterExtent(extent, data);
-
- ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(),
- session, position);
-
- if (!transform.isIdentity())
- copy.setTransform(transform);
-
- copy.setSourceMask(new ExistingBlockMask(extent));
-
- Operations.completeLegacy(copy);
-
- // Replace given blocks
- Set replace = new HashSet<>();
- Vector min = new Vector(position.getX() - radius, position.getY() - radius, position.getZ() - radius);
- Vector max = new Vector(position.getX() + radius, position.getY() + radius, position.getZ() + radius);
- for (Vector v : new CuboidRegion(min, max)) {
- Block b = world.getBlockAt(v.getBlockX(), v.getBlockY(), v.getBlockZ());
- if (b.getType() == replaceType) {
- replace.add(b);
- }
- }
- new BukkitRunnable() {
- @Override
- public void run() {
- replace.forEach(b -> b.setType(Material.AIR));
- }
- }.runTaskLater(plugin, replaceTicks);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- public void pasteSchematic(File schematic, org.bukkit.util.Vector pos, org.bukkit.World world) {
- try {
- Vector position = new Vector(pos.getX(), pos.getY(), pos.getZ());
-
- World weWorld = new BukkitWorld(world);
- WorldData worldData = weWorld.getWorldData();
- Clipboard clipboard = ClipboardFormat.SCHEMATIC.getReader(new FileInputStream(schematic)).read(worldData);
- EditSession session = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1);
-
- ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(),
- session, position);
-
- copy.setSourceMask(new ExistingBlockMask(clipboard));
- Operations.completeLegacy(copy);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/missilewars-plugin/pom.xml b/missilewars-plugin/pom.xml
index 2e866735..e97636b8 100644
--- a/missilewars-plugin/pom.xml
+++ b/missilewars-plugin/pom.xml
@@ -48,12 +48,6 @@
-
- de.butzlabben
- 1_12
- 1.0
- compile
-
de.butzlabben
1_13
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/MissileWars.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/MissileWars.java
index afa7b816..1397eefb 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/MissileWars.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/MissileWars.java
@@ -216,9 +216,9 @@ private void sendPluginInfo() {
Logger.BOOT.log("This server is running MissileWars v" + version + " by Butzlabben");
- if (VersionUtil.getVersion() < 8) {
+ if (VersionUtil.getVersion() < 13) {
Logger.WARN.log("====================================================");
- Logger.WARN.log("It seems that you are using version older than 1.8");
+ Logger.WARN.log("It seems that you are using version older than 1.13");
Logger.WARN.log("There is no guarantee for this to work");
Logger.WARN.log("Proceed with extreme caution");
Logger.WARN.log("====================================================");
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java
index 05ddea48..f233f9c1 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java
@@ -31,7 +31,6 @@
import de.butzlabben.missilewars.util.stats.PlayerGuiFactory;
import de.butzlabben.missilewars.util.stats.PreFetcher;
import de.butzlabben.missilewars.util.stats.StatsUtil;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -83,7 +82,7 @@ public void onStats(CommandSender sender, String[] args) {
inv.addItem(9, new OrcItem(Material.SLIME_BLOCK, "§aGeneral statistics", generalLore));
List playerLore = Arrays.asList("§7Unique players: §e" + fetcher.getUniquePlayers(), "", "§7Click to list players");
- OrcItem players = new OrcItem(VersionUtil.getPlayerSkullMaterial(), "§aPlayers", playerLore);
+ OrcItem players = new OrcItem(Material.PLAYER_HEAD, "§aPlayers", playerLore);
players.setOnClick((p, inventory, item) -> {
p.closeInventory();
preFetchRunnable.stop();
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Game.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Game.java
index 1abfcdc1..8c753113 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Game.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Game.java
@@ -52,19 +52,9 @@
import de.butzlabben.missilewars.util.geometry.GameArea;
import de.butzlabben.missilewars.util.geometry.Geometry;
import de.butzlabben.missilewars.util.serialization.Serializer;
-import de.butzlabben.missilewars.util.version.VersionUtil;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.function.Consumer;
import lombok.Getter;
import lombok.ToString;
-import org.bukkit.Bukkit;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.World;
+import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player;
@@ -76,6 +66,12 @@
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.util.Vector;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Consumer;
+
/**
* @author Butzlabben
* @since 01.01.2018
@@ -350,8 +346,8 @@ public void playerJoinInGame(Player player, boolean isSpectatorJoin) {
// team change menu:
if (player.hasPermission("mw.change")) {
- player.getInventory().setItem(0, VersionUtil.getGlassPlane(team1));
- player.getInventory().setItem(8, VersionUtil.getGlassPlane(team2));
+ player.getInventory().setItem(0, team1.getGlassPlane());
+ player.getInventory().setItem(8, team2.getGlassPlane());
}
// map choose menu:
@@ -544,10 +540,10 @@ private void createGameItems() {
bow.addEnchantment(Enchantment.ARROW_FIRE, 1);
bow.addEnchantment(Enchantment.ARROW_DAMAGE, 1);
bow.addEnchantment(Enchantment.ARROW_KNOCKBACK, 1);
- ItemMeta im = bow.getItemMeta();
- im.addEnchant(Enchantment.DAMAGE_ALL, 6, true);
- bow.setItemMeta(im);
- VersionUtil.setUnbreakable(bow);
+ ItemMeta bowMeta = bow.getItemMeta();
+ bowMeta.setUnbreakable(true);
+ bowMeta.addEnchant(Enchantment.DAMAGE_ALL, 6, true);
+ bow.setItemMeta(bowMeta);
this.customBow = bow;
}
@@ -555,7 +551,9 @@ private void createGameItems() {
if (this.getArena().getSpawn().isSendPickaxe() || this.getArena().getRespawn().isSendPickaxe()) {
ItemStack pickaxe = new ItemStack(Material.IRON_PICKAXE);
- VersionUtil.setUnbreakable(pickaxe);
+ ItemMeta pickaxeMeta = pickaxe.getItemMeta();
+ pickaxeMeta.setUnbreakable(true);
+ pickaxe.setItemMeta(pickaxeMeta);
this.customPickaxe = pickaxe;
}
@@ -585,26 +583,15 @@ public void sendGameItems(Player player, boolean isRespawn) {
// send kit items
if (isRespawn) {
- if (this.getArena().getRespawn().isSendBow()) {
- player.getInventory().addItem(this.customBow);
- }
-
- if (this.getArena().getRespawn().isSendPickaxe()) {
- player.getInventory().addItem(this.customPickaxe);
- }
+ if (this.getArena().getRespawn().isSendBow()) player.getInventory().addItem(this.customBow);
+ if (this.getArena().getRespawn().isSendPickaxe()) player.getInventory().addItem(this.customPickaxe);
} else {
- if (this.getArena().getSpawn().isSendBow()) {
- player.getInventory().addItem(this.customBow);
- }
-
- if (this.getArena().getSpawn().isSendPickaxe()) {
- player.getInventory().addItem(this.customPickaxe);
- }
-
+ if (this.getArena().getSpawn().isSendBow()) player.getInventory().addItem(this.customBow);
+ if (this.getArena().getSpawn().isSendPickaxe()) player.getInventory().addItem(this.customPickaxe);
+
}
-
}
/**
@@ -663,14 +650,11 @@ public void spawnMissile(Player player, ItemStack itemStack) {
public void spawnFireball(Player player, ItemStack itemStack) {
int amount = itemStack.getAmount();
itemStack.setAmount(amount - 1);
-
- if (amount == 1 && VersionUtil.getVersion() == 8) {
- player.getInventory().remove(VersionUtil.getFireball());
- }
-
+
Fireball fb = player.launchProjectile(Fireball.class);
fb.setVelocity(player.getLocation().getDirection().multiply(2.5D));
- VersionUtil.playFireball(player, fb.getLocation());
+ player.playSound(fb.getLocation(), Sound.BLOCK_ANVIL_LAND, 100.0F, 2.0F);
+ player.playSound(fb.getLocation(), Sound.ITEM_FLINTANDSTEEL_USE, 100.0F, 1.0F);
fb.setYield(3F);
fb.setIsIncendiary(true);
fb.setBounce(false);
@@ -810,8 +794,8 @@ public void sendNeutralGameResultTitle(Player player) {
subTitle = Messages.getNativeMessage("game_result.subtitle_draw");
}
-
- VersionUtil.sendTitle(player, title, subTitle);
+
+ player.sendTitle(title, subTitle);
}
/**
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Team.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Team.java
index d5a14b8d..c027343d 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Team.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/Team.java
@@ -24,7 +24,6 @@
import de.butzlabben.missilewars.player.MWPlayer;
import de.butzlabben.missilewars.util.MoneyUtil;
import de.butzlabben.missilewars.util.version.ColorConverter;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
@@ -32,8 +31,10 @@
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Material;
+import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import java.util.ArrayList;
@@ -118,28 +119,28 @@ public void createTeamArmor() {
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
LeatherArmorMeta bootsMeta = (LeatherArmorMeta) boots.getItemMeta();
+ bootsMeta.setUnbreakable(true);
bootsMeta.setColor(color);
boots.setItemMeta(bootsMeta);
- VersionUtil.setUnbreakable(boots);
ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS);
LeatherArmorMeta leggingsMeta = (LeatherArmorMeta) leggings.getItemMeta();
+ leggingsMeta.setUnbreakable(true);
leggingsMeta.setColor(color);
leggings.setItemMeta(leggingsMeta);
- VersionUtil.setUnbreakable(leggings);
ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta chestplateMeta = (LeatherArmorMeta) chestplate.getItemMeta();
+ chestplateMeta.setUnbreakable(true);
chestplateMeta.setColor(color);
chestplate.setItemMeta(chestplateMeta);
- VersionUtil.setUnbreakable(chestplate);
ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
LeatherArmorMeta helmetMeta = (LeatherArmorMeta) helmet.getItemMeta();
+ helmetMeta.setUnbreakable(true);
helmetMeta.setColor(color);
helmet.setItemMeta(helmetMeta);
- VersionUtil.setUnbreakable(helmet);
-
+
teamArmor = new ItemStack[] {boots, leggings, chestplate, helmet};
}
@@ -202,8 +203,8 @@ public void sendGameResultTitle(MWPlayer mwPlayer) {
subTitle = null;
break;
}
-
- VersionUtil.sendTitle(mwPlayer.getPlayer(), title, subTitle);
+
+ mwPlayer.getPlayer().sendTitle(title, subTitle);
}
/**
@@ -211,14 +212,16 @@ public void sendGameResultTitle(MWPlayer mwPlayer) {
* game result.
*/
public void sendGameResultSound(MWPlayer mwPlayer) {
+
+ Player player = mwPlayer.getPlayer();
switch (gameResult) {
case WIN:
- VersionUtil.playPling(mwPlayer.getPlayer());
+ player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 100, 3);
break;
case LOSE:
case DRAW:
- VersionUtil.playDraw(mwPlayer.getPlayer());
+ player.playSound(player.getLocation(), Sound.ENTITY_WITHER_DEATH, 100, 0);
break;
default:
break;
@@ -235,4 +238,13 @@ public void updateIntervals(int newInterval) {
}
}
+ public ItemStack getGlassPlane() {
+ ItemStack is = new ItemStack(ColorConverter.getGlassPaneFromColorCode(getColorCode()));
+
+ ItemMeta im = is.getItemMeta();
+ im.setDisplayName(getFullname());
+ is.setItemMeta(im);
+ return is;
+ }
+
}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/equipment/SpecialGameEquipment.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/equipment/SpecialGameEquipment.java
index 3194e0d0..ddd8cd25 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/equipment/SpecialGameEquipment.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/equipment/SpecialGameEquipment.java
@@ -19,7 +19,6 @@
package de.butzlabben.missilewars.game.equipment;
import de.butzlabben.missilewars.game.Game;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import lombok.Getter;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@@ -85,7 +84,7 @@ private void createSpecialEquipmentList() {
* This method creates the shield item stack.
*/
private void createShield() {
- shield = new ItemStack(VersionUtil.getSnowball());
+ shield = new ItemStack(Material.SNOWBALL);
ItemMeta shieldMeta = shield.getItemMeta();
shieldMeta.setDisplayName(game.getArena().getShieldConfiguration().getName());
shield.setItemMeta(shieldMeta);
@@ -102,7 +101,7 @@ private void createArrow() {
* This method creates the fireball item stack.
*/
private void createFireball() {
- fireball = new ItemStack(VersionUtil.getFireball());
+ fireball = new ItemStack(Material.FIRE_CHARGE);
ItemMeta fireballMeta = fireball.getItemMeta();
fireballMeta.setDisplayName(game.getArena().getFireballConfiguration().getName());
fireball.setItemMeta(fireballMeta);
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/misc/RespawnGoldBlock.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/misc/RespawnGoldBlock.java
index ef69a4c6..11701adc 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/misc/RespawnGoldBlock.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/misc/RespawnGoldBlock.java
@@ -23,10 +23,6 @@
import de.butzlabben.missilewars.game.Game;
import de.butzlabben.missilewars.game.enums.GameState;
import de.butzlabben.missilewars.util.version.BlockSetterProvider;
-import de.butzlabben.missilewars.util.version.VersionUtil;
-import java.util.AbstractMap;
-import java.util.HashMap;
-import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -38,6 +34,10 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerToggleSneakEvent;
+import java.util.AbstractMap;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* @author Butzlabben
* @since 14.01.2018
@@ -112,9 +112,7 @@ private void activate() {
private void setBlock(Block b) {
if ((b.getType() != Material.GOLD_BLOCK) && (b.getType() == Material.AIR)) {
- Object data = b.getData();
- if (VersionUtil.getVersion() >= 13)
- data = b.getBlockData();
+ Object data = b.getBlockData();
map.put(b.getLocation(), new AbstractMap.SimpleEntry<>(b.getType(), data));
b.setType(Material.GOLD_BLOCK);
}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/misc/Shield.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/misc/Shield.java
index 22c88867..64c13dba 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/misc/Shield.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/misc/Shield.java
@@ -21,10 +21,10 @@
import de.butzlabben.missilewars.MissileWars;
import de.butzlabben.missilewars.configuration.arena.ShieldConfiguration;
import de.butzlabben.missilewars.game.missile.paste.PasteProvider;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.Location;
+import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
@@ -71,6 +71,6 @@ public void pasteShield() {
File schem = new File(pluginDir, "shields/" + shieldConfiguration.getSchematic());
PasteProvider.getPaster().pasteSchematic(schem, pastePos, loc.getWorld());
- VersionUtil.playSnowball(player, player.getLocation());
+ player.playSound(player.getLocation(), Sound.ENTITY_ENDER_DRAGON_FLAP, 1, 1);
}
}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/Missile.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/Missile.java
index 5f3fcc30..b17f0050 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/Missile.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/Missile.java
@@ -23,19 +23,18 @@
import de.butzlabben.missilewars.configuration.Config;
import de.butzlabben.missilewars.game.Game;
import de.butzlabben.missilewars.game.missile.paste.PasteProvider;
-import de.butzlabben.missilewars.util.version.VersionUtil;
-import java.io.File;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.bukkit.Location;
+import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.inventory.meta.SpawnEggMeta;
-import org.bukkit.material.SpawnEgg;
import org.bukkit.util.Vector;
+import java.io.File;
+
/**
* @author Butzlabben
* @since 06.01.2018
@@ -109,21 +108,26 @@ public String getDisplayName() {
* @return ItemStack = the spawn egg with the missile name
*/
public ItemStack getItem() {
- ItemStack is = new ItemStack(VersionUtil.getMonsterEgg(egg));
- if (VersionUtil.getVersion() > 10) {
- SpawnEggMeta sm = (SpawnEggMeta) is.getItemMeta();
- if (VersionUtil.getVersion() < 13)
- sm.setSpawnedType(egg);
- is.setItemMeta(sm);
- } else {
- SpawnEgg se = new SpawnEgg(egg);
- se.setSpawnedType(egg);
- is = se.toItemStack();
- is.setAmount(1);
+ ItemStack spawnEgg = new ItemStack(getSpawnEgg(egg));
+ ItemMeta spawnEggMeta = spawnEgg.getItemMeta();
+ spawnEggMeta.setDisplayName(getDisplayName());
+ spawnEgg.setItemMeta(spawnEggMeta);
+ return spawnEgg;
+ }
+
+ public static Material getSpawnEgg(EntityType type) {
+ if (type == EntityType.MUSHROOM_COW) {
+ //noinspection SpellCheckingInspection
+ return Material.valueOf("MOOSHROOM_SPAWN_EGG");
+
}
- ItemMeta im = is.getItemMeta();
- im.setDisplayName(getDisplayName());
- is.setItemMeta(im);
- return is;
+ return Material.valueOf(type.name() + "_SPAWN_EGG");
+ }
+
+ public static boolean isSpawnEgg(Material material) {
+ if (material == null) return false;
+
+ String name = material.name();
+ return name.contains("SPAWN_EGG") || name.equals("MONSTER_EGG");
}
}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/paste/PasteProvider.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/paste/PasteProvider.java
index 9aa7338b..4eb484aa 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/paste/PasteProvider.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/paste/PasteProvider.java
@@ -32,22 +32,17 @@ public class PasteProvider {
private static final Paster paster;
static {
- if (VersionUtil.getVersion() < 13) {
- paster = new R1_12PasteProvider();
- Logger.DEBUG.log("Chose 1.12 normal paster");
- } else {
- if (MissileWars.getInstance().foundFAWE()) {
- if (VersionUtil.getVersion() < 16) {
- paster = new R1_13FawePasteProvider();
- Logger.DEBUG.log("Chose 1.13 FAWE paster");
- } else {
- paster = new R1_16FawePasteProvider();
- Logger.DEBUG.log("Chose 1.16 FAWE paster");
- }
+ if (MissileWars.getInstance().foundFAWE()) {
+ if (VersionUtil.getVersion() < 16) {
+ paster = new R1_13FawePasteProvider();
+ Logger.DEBUG.log("Chose 1.13 FAWE paster");
} else {
- paster = new R1_13WEPasteProvider();
- Logger.DEBUG.log("Chose 1.13 WE paster");
+ paster = new R1_16FawePasteProvider();
+ Logger.DEBUG.log("Chose 1.16 FAWE paster");
}
+ } else {
+ paster = new R1_13WEPasteProvider();
+ Logger.DEBUG.log("Chose 1.13 WE paster");
}
}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/paste/R1_12PasteProvider.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/paste/R1_12PasteProvider.java
deleted file mode 100644
index 7181a7a7..00000000
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/missile/paste/R1_12PasteProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of MissileWars (https://github.com/Butzlabben/missilewars).
- * Copyright (c) 2018-2021 Daniel Nägele.
- *
- * MissileWars is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MissileWars is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MissileWars. If not, see .
- */
-
-package de.butzlabben.missilewars.game.missile.paste;
-
-import de.butzlabben.missilewars.MissileWars;
-import de.butzlabben.missilewars.configuration.Config;
-import de.butzlabben.missilewars.game.Team;
-import de.butzlabben.missilewars.missile.paste.r1_12.R1_12Paster;
-import de.butzlabben.missilewars.util.version.ColorConverter;
-import org.bukkit.World;
-import org.bukkit.util.Vector;
-
-import java.io.File;
-
-/**
- * @author Butzlabben
- * @since 23.09.2018
- */
-public class R1_12PasteProvider implements Paster {
-
- R1_12Paster paster = new R1_12Paster();
-
- @Override
- public void pasteMissile(File schematic, Vector position, int rotation, World world, Team team) {
- paster.pasteMissile(schematic, position, rotation, world, ColorConverter.getColorIDforBlockFromColorCode(team.getColorCode()),
- Config.getReplaceRadius(), Config.getStartReplace(), MissileWars.getInstance(), Config.getReplaceTicks());
- }
-
- @Override
- public void pasteSchematic(File schematic, Vector position, World world) {
- paster.pasteSchematic(schematic, position, world);
- }
-}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/signs/MWSign.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/signs/MWSign.java
index d47f0169..21808631 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/signs/MWSign.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/signs/MWSign.java
@@ -23,7 +23,6 @@
import de.butzlabben.missilewars.configuration.Messages;
import de.butzlabben.missilewars.game.Game;
import de.butzlabben.missilewars.game.GameManager;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -31,6 +30,7 @@
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
+import org.bukkit.block.data.type.WallSign;
import java.util.ArrayList;
import java.util.List;
@@ -46,7 +46,8 @@ public class MWSign {
public boolean isValid() {
boolean worldExists = location.getWorld() != null;
boolean lobbyValid = GameManager.getInstance().getGames().containsKey(lobby);
- boolean blockIsSign = VersionUtil.isWallSignMaterial(location.getBlock().getType());
+ boolean blockIsSign = (location.getBlock().getBlockData() instanceof WallSign);
+
return worldExists && lobbyValid && blockIsSign;
}
@@ -73,7 +74,7 @@ public void update() {
public void editSign(Location location, List lines) {
Block block = location.getBlock();
- if (!VersionUtil.isWallSignMaterial(block.getType())) {
+ if (!(block.getBlockData() instanceof WallSign)) {
Logger.WARN.log("Configured sign at: " + location + " is not a wall sign");
return;
}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/timer/LobbyTimer.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/timer/LobbyTimer.java
index 0362dbed..76683153 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/timer/LobbyTimer.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/game/timer/LobbyTimer.java
@@ -24,7 +24,7 @@
import de.butzlabben.missilewars.game.Game;
import de.butzlabben.missilewars.game.enums.MapChooseProcedure;
import de.butzlabben.missilewars.player.MWPlayer;
-import de.butzlabben.missilewars.util.version.VersionUtil;
+import org.bukkit.Sound;
import java.util.Map;
import java.util.Optional;
@@ -109,7 +109,7 @@ public void tick() {
private void playPling() {
for (MWPlayer mwPlayer : getGame().getPlayers().values()) {
- VersionUtil.playPling(mwPlayer.getPlayer());
+ mwPlayer.getPlayer().playSound(mwPlayer.getPlayer().getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 100, 3);
}
}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/inventory/OrcItem.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/inventory/OrcItem.java
index c2e5b0d1..f32ade8b 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/inventory/OrcItem.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/inventory/OrcItem.java
@@ -18,24 +18,25 @@
package de.butzlabben.missilewars.inventory;
-import de.butzlabben.missilewars.util.version.VersionUtil;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import de.butzlabben.missilewars.util.version.ColorConverter;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
public class OrcItem {
public static OrcItem enabled, disabled, coming_soon, back, fill, error = new OrcItem(Material.BARRIER, null,
"§cERROR: Item is wrong configured!", "§cPath in properties: see Displayname");
static {
- fill = new OrcItem(VersionUtil.getGlassPlane("§8"));
+ fill = new OrcItem(new ItemStack(ColorConverter.getGlassPaneFromColorCode("§8")));
}
private ItemStack is;
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/inventory/pages/InventoryPage.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/inventory/pages/InventoryPage.java
index 7a46655f..a3e4392b 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/inventory/pages/InventoryPage.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/inventory/pages/InventoryPage.java
@@ -21,7 +21,6 @@
import de.butzlabben.missilewars.Logger;
import de.butzlabben.missilewars.inventory.OrcInventory;
import de.butzlabben.missilewars.inventory.OrcItem;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
@@ -38,7 +37,7 @@ public class InventoryPage extends OrcInventory {
public InventoryPage(String title, int page, int pages) {
super(title, 6);
- OrcItem oi = new OrcItem(VersionUtil.getSunFlower(), "§aPage §e" + page + " §aof§e " + pages);
+ OrcItem oi = new OrcItem(Material.SUNFLOWER, "§aPage §e" + page + " §aof§e " + pages);
addItem(5, 4, oi);
oi = new OrcItem(Material.PAPER, "§ePrevious page");
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/SignListener.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/SignListener.java
index 9044ccee..e718ae4c 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/SignListener.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/SignListener.java
@@ -24,8 +24,8 @@
import de.butzlabben.missilewars.game.GameManager;
import de.butzlabben.missilewars.game.signs.MWSign;
import de.butzlabben.missilewars.game.signs.SignRepository;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import org.bukkit.block.Block;
+import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -45,7 +45,7 @@ public void onSignClick(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
Block block = event.getClickedBlock();
- if (!VersionUtil.isWallSignMaterial(block.getType())) return;
+ if (!(block.getBlockData() instanceof WallSign)) return;
SignRepository repository = MissileWars.getInstance().getSignRepository();
Optional optional = repository.getSign(block.getLocation());
@@ -61,7 +61,7 @@ public void onSignClick(PlayerInteractEvent event) {
@EventHandler
public void onSignChange(SignChangeEvent event) {
Block block = event.getBlock();
- if (!VersionUtil.isWallSignMaterial(block.getType())) return;
+ if (!(block.getBlockData() instanceof WallSign)) return;
Player player = event.getPlayer();
if (!hasManageSignPermission(player)) return;
@@ -90,7 +90,7 @@ public void onSignChange(SignChangeEvent event) {
@EventHandler
public void onSignBreak(BlockBreakEvent event) {
Block block = event.getBlock();
- if (!VersionUtil.isWallSignMaterial(block.getType())) return;
+ if (!(block.getBlockData() instanceof WallSign)) return;
Player player = event.getPlayer();
if (!hasManageSignPermission(player)) return;
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/GameListener.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/GameListener.java
index b5f69eef..d494a789 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/GameListener.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/GameListener.java
@@ -27,11 +27,12 @@
import de.butzlabben.missilewars.game.enums.GameResult;
import de.butzlabben.missilewars.game.misc.RespawnGoldBlock;
import de.butzlabben.missilewars.game.misc.Shield;
+import de.butzlabben.missilewars.game.missile.Missile;
import de.butzlabben.missilewars.player.MWPlayer;
import de.butzlabben.missilewars.util.geometry.Geometry;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import org.bukkit.GameMode;
import org.bukkit.Location;
+import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
@@ -66,14 +67,14 @@ public void onExplode(EntityExplodeEvent event) {
if (event.getEntity().getType() != EntityType.FIREBALL) return;
if (getGame().getArena().getFireballConfiguration().isDestroysPortal()) return;
- event.blockList().removeIf(b -> b.getType() == VersionUtil.getPortal());
+ event.blockList().removeIf(b -> b.getType() == Material.NETHER_PORTAL);
}
@EventHandler
public void onBlockPhysics(BlockPhysicsEvent event) {
if (!isInGameWorld(event.getBlock().getLocation())) return;
- if (event.getChangedType() != VersionUtil.getPortal()) return;
+ if (event.getChangedType() != Material.NETHER_PORTAL) return;
Location location = event.getBlock().getLocation();
@@ -103,9 +104,9 @@ public void onInteract(PlayerInteractEvent event) {
ItemStack itemStack = event.getItem();
// missile spawn with using of a missile spawn egg
- if (VersionUtil.isMonsterEgg(itemStack.getType())) {
+ if (Missile.isSpawnEgg(itemStack.getType())) {
event.setCancelled(true);
-
+
// Can missiles only be spawned if the item interaction was performed on a block (no air)?
boolean isOnlyBlockPlaceable = getGame().getArena().getMissileConfiguration().isOnlyBlockPlaceable();
if (isOnlyBlockPlaceable) {
@@ -117,7 +118,7 @@ public void onInteract(PlayerInteractEvent event) {
}
// shield spawn with using of a shield spawn egg
- if (itemStack.getType() == VersionUtil.getFireball()) {
+ if (itemStack.getType() == Material.FIRE_CHARGE) {
getGame().spawnFireball(player, itemStack);
}
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/LobbyListener.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/LobbyListener.java
index 8dd231ab..c12b9d25 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/LobbyListener.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/listener/game/LobbyListener.java
@@ -24,7 +24,6 @@
import de.butzlabben.missilewars.game.Game;
import de.butzlabben.missilewars.inventory.VoteInventory;
import de.butzlabben.missilewars.player.MWPlayer;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -60,7 +59,7 @@ public void onInteract(PlayerInteractEvent event) {
if (event.getItem() == null) return;
- if (VersionUtil.isStainedGlassPane(event.getItem().getType())) {
+ if (event.getItem().getType().name().contains("STAINED_GLASS_PANE")) {
// team change:
if (!player.hasPermission("mw.change")) return;
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/player/PlayerData.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/player/PlayerData.java
index 8e440c45..1b6b27a7 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/player/PlayerData.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/player/PlayerData.java
@@ -19,13 +19,6 @@
package de.butzlabben.missilewars.player;
import com.google.common.base.Preconditions;
-import de.butzlabben.missilewars.util.version.VersionUtil;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.ToString;
import org.bukkit.GameMode;
@@ -35,6 +28,13 @@
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
@ToString
@AllArgsConstructor
public class PlayerData implements ConfigurationSerializable {
@@ -76,15 +76,7 @@ public static PlayerData loadFromFile(File file) {
Preconditions.checkArgument(file.isFile(), file.getAbsolutePath() + " is not a file");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(file);
- PlayerData data;
-
- if (VersionUtil.getVersion() > 12) {
- data = yamlConfiguration.getSerializable("data", PlayerData.class);
- } else {
- data = (PlayerData) yamlConfiguration.get("data");
- }
-
- return data;
+ return yamlConfiguration.getSerializable("data", PlayerData.class);
}
public void apply(Player player) {
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PlayerGuiFactory.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PlayerGuiFactory.java
index ee23d419..fa6e2ccd 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PlayerGuiFactory.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PlayerGuiFactory.java
@@ -27,9 +27,9 @@
import de.butzlabben.missilewars.game.stats.PlayerStatsComparator;
import de.butzlabben.missilewars.inventory.OrcItem;
import de.butzlabben.missilewars.inventory.pages.PageGUICreator;
-import de.butzlabben.missilewars.util.version.VersionUtil;
import lombok.Getter;
import org.bukkit.Bukkit;
+import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -113,7 +113,7 @@ private void open(Player player) {
PageGUICreator creator = new PageGUICreator<>("§ePlayer statistics", stats, (item) -> {
String name = item.getName();
- ItemStack itemStack = new ItemStack(VersionUtil.getPlayerSkullMaterial());
+ ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD);
SkullMeta sm = (SkullMeta) itemStack.getItemMeta();
if (Config.isShowRealSkins()) {
//noinspection deprecation
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PreFetcher.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PreFetcher.java
index 7c9bfdfc..f6ebe52d 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PreFetcher.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PreFetcher.java
@@ -25,18 +25,14 @@
import de.butzlabben.missilewars.inventory.OrcItem;
import de.butzlabben.missilewars.inventory.pages.InventoryPage;
import de.butzlabben.missilewars.inventory.pages.PageGUICreator;
-import de.butzlabben.missilewars.util.version.VersionUtil;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
+import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
+import java.util.*;
+
public class PreFetcher {
@Getter
@@ -117,7 +113,7 @@ public void stop() {
private PageGUICreator getPreFetchCreator(Collection names) {
return new PageGUICreator<>("§ePlayer statistics", names, (item) -> {
- ItemStack itemStack = new ItemStack(VersionUtil.getPlayerSkullMaterial());
+ ItemStack itemStack = new ItemStack(Material.PLAYER_HEAD);
SkullMeta sm = (SkullMeta) itemStack.getItemMeta();
//noinspection deprecation
sm.setOwner(item);
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/version/BlockSetterProvider.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/version/BlockSetterProvider.java
index 38f7047e..112a8be9 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/version/BlockSetterProvider.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/version/BlockSetterProvider.java
@@ -18,9 +18,10 @@
package de.butzlabben.missilewars.util.version;
+import org.bukkit.block.Block;
+
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import org.bukkit.block.Block;
/**
* @author Butzlabben
@@ -31,10 +32,7 @@ public class BlockSetterProvider {
private static final BlockDataSetter blockSetter;
static {
- if (VersionUtil.getVersion() < 13)
- blockSetter = new LegacyBlockSetter();
- else
- blockSetter = new NewBlockSetter();
+ blockSetter = new NewBlockSetter();
}
private BlockSetterProvider() {
@@ -64,30 +62,7 @@ public static void changeBlockData(String method, Object object, Object... args)
e.printStackTrace();
}
}
-
- private static class LegacyBlockSetter implements BlockDataSetter {
-
- @Override
- public void setData(Block block, Object data) {
- try {
- Method m = block.getClass().getMethod("setData", byte.class);
- m.invoke(block, data);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void setData(Block block, Object data, boolean update) {
- try {
- Method m = block.getClass().getMethod("setData", byte.class, boolean.class);
- m.invoke(block, data, update);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
+
private static class NewBlockSetter implements BlockDataSetter {
@Override
diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/version/VersionUtil.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/version/VersionUtil.java
index ec697aa5..46a48589 100644
--- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/version/VersionUtil.java
+++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/version/VersionUtil.java
@@ -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 static int getVersion() {
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");
- }
+
}
diff --git a/pom.xml b/pom.xml
index da055dcf..922264e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,7 +34,6 @@
1_13
- 1_12
1_13_FAWE
1_16_FAWE
missilewars-plugin