From 7170b1c999066ee81605d9073d09ec085d01be46 Mon Sep 17 00:00:00 2001 From: ZeroEpoch1969 <13510767+ZeroEpoch1969@users.noreply.github.com> Date: Tue, 24 Jul 2018 19:08:29 -0700 Subject: [PATCH] More progress towards 1.13 --- .../totalfreedommod/FrontDoor.java | 4 +- .../totalfreedommod/Monitors.java | 13 ++---- .../blocking/BlockBlocker.java | 2 - .../blocking/InteractBlocker.java | 2 +- .../totalfreedommod/blocking/PVPBlocker.java | 9 ++++ .../totalfreedommod/blocking/SignBlocker.java | 4 +- .../totalfreedommod/caging/CageData.java | 6 +-- .../totalfreedommod/command/Command_cage.java | 21 +++------ .../command/Command_debugstick.java | 35 +++++++++++++++ .../command/Command_dispfill.java | 11 ----- .../totalfreedommod/command/Command_mp44.java | 2 +- .../totalfreedommod/command/Command_ro.java | 41 +++++++++--------- .../command/Command_setlever.java | 10 +++-- .../command/Command_whohas.java | 17 +------- .../totalfreedommod/fun/ItemFun.java | 14 ++---- .../totalfreedommod/fun/Jumppads.java | 15 +++---- .../totalfreedommod/fun/MobStacker.java | 2 +- .../totalfreedommod/fun/Trailer.java | 5 +-- .../rollback/RollbackEntry.java | 11 ++--- .../rollback/RollbackManager.java | 2 +- .../util/DepreciationAggregator.java | 15 ------- .../totalfreedommod/util/FUtil.java | 1 + .../totalfreedommod/util/MaterialGroup.java | 43 +++++++++++++++++++ .../totalfreedommod/world/AdminWorld.java | 2 +- .../world/CleanroomBlockPopulator.java | 3 +- .../world/CleanroomChunkGenerator.java | 3 +- .../totalfreedommod/world/Flatlands.java | 2 +- .../world/MasterBuilderWorld.java | 2 +- src/main/resources/plugin.yml | 3 +- 29 files changed, 164 insertions(+), 136 deletions(-) create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java create mode 100644 src/main/java/me/totalfreedom/totalfreedommod/util/MaterialGroup.java diff --git a/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java b/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java index 3eff7608..9303ddcd 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java @@ -464,7 +464,7 @@ public class FrontDoor extends FreedomService continue; } - block.setType(Material.SIGN_POST); + block.setType(Material.SIGN); org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData(); @@ -542,7 +542,7 @@ public class FrontDoor extends FreedomService FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true); Location targetPos = player.getLocation().clone().add(0, 1, 0); - playerdata.getCageData().cage(targetPos, Material.SKULL, Material.AIR); + playerdata.getCageData().cage(targetPos, Material.PLAYER_HEAD, Material.AIR, "Prozza"); break; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java index 1f859f4b..3ea2ec66 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/Monitors.java @@ -33,11 +33,6 @@ public class Monitors extends FreedomService { } - public String getMaterial(final int id) - { - return String.valueOf(Material.getMaterial(id)).replace("_", " ").toLowerCase(); - } - @EventHandler(priority = EventPriority.MONITOR) public void onLingeringPotionSplash(LingeringPotionSplashEvent event) { @@ -53,14 +48,14 @@ public class Monitors extends FreedomService { return; } - final int droppedItem = event.getEntity().getItem().getTypeId(); + final Material droppedItem = event.getEntity().getItem().getType(); final Location location = player.getLocation(); for (Player p : server.getOnlinePlayers()) { if (plugin.al.isAdmin(p) && plugin.al.getAdmin(p).getPotionSpy()) { - FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + getMaterial(droppedItem) + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'."); + FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + droppedItem + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'."); } } } @@ -80,14 +75,14 @@ public class Monitors extends FreedomService { return; } - final int droppedItem = event.getPotion().getItem().getTypeId(); + final Material droppedItem = event.getPotion().getItem().getType(); final Location location = player.getLocation(); for (Player p : server.getOnlinePlayers()) { if (plugin.al.isAdmin(p) && plugin.al.getAdmin(p).getPotionSpy()) { - FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + getMaterial(droppedItem) + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'."); + FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + droppedItem + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'."); } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java index a8623ada..ff844c2a 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/BlockBlocker.java @@ -39,7 +39,6 @@ public class BlockBlocker extends FreedomService switch (event.getBlockPlaced().getType()) { case LAVA: - case STATIONARY_LAVA: { if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean()) { @@ -54,7 +53,6 @@ public class BlockBlocker extends FreedomService break; } case WATER: - case STATIONARY_WATER: { if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean()) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java index 67c34609..9fffd1f3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/InteractBlocker.java @@ -83,7 +83,7 @@ public class InteractBlocker extends FreedomService break; } - case EXPLOSIVE_MINECART: + case TNT_MINECART: { if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean()) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java index 4110b796..041f1bc3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/PVPBlocker.java @@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.entity.Arrow; +import org.bukkit.entity.Trident; public class PVPBlocker extends FreedomService { @@ -48,6 +49,14 @@ public class PVPBlocker extends FreedomService player = (Player) arrow.getShooter(); } } + else if (event.getDamager() instanceof Trident) + { + Trident trident = (Trident) event.getDamager(); + if (trident.getShooter() instanceof Player) + { + player = (Player) trident.getShooter(); + } + } } if (player != null &! plugin.al.isAdmin(player)) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java b/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java index d0e84da4..19b94559 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java @@ -38,7 +38,7 @@ public class SignBlocker extends FreedomService { final Player player = event.getPlayer(); - if (event.getBlock().getType().equals(Material.SIGN) || event.getBlock().getType().equals(Material.SIGN_POST) || event.getBlock().getType().equals(Material.WALL_SIGN)) + if (event.getBlock().getType().equals(Material.SIGN) || event.getBlock().getType().equals(Material.WALL_SIGN)) { ItemStack sign = event.getItemInHand(); @@ -65,7 +65,7 @@ public class SignBlocker extends FreedomService return; } - if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.SIGN) || event.getClickedBlock().getType().equals(Material.SIGN_POST) || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) + if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.SIGN) || event.getClickedBlock().getType().equals(Material.WALL_SIGN)) { event.setCancelled(true); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java b/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java index a23bc033..20b4a957 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/caging/CageData.java @@ -185,7 +185,7 @@ public class CageData final Block block = center.getRelative(xOffset, yOffset, zOffset); - if (material != Material.SKULL) + if (material != Material.PLAYER_HEAD) { // Glowstone light if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0) @@ -204,11 +204,11 @@ public class CageData continue; } - block.setType(Material.SKULL); + block.setType(Material.PLAYER_HEAD); if (input != null) { Skull skull = (Skull) block.getState(); - skull.setSkullType(SkullType.PLAYER); + // This may or may not work in future versions of spigot skull.setOwner(input); skull.update(); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java index 7762ce4c..a66a9bba 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_cage.java @@ -12,7 +12,7 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH) -@CommandParameters(description = "Place a cage around someone.", usage = "/ [skull | block] [blockname | skullname]") +@CommandParameters(description = "Place a cage around someone.", usage = "/ [skull | block] [blockname | playername]") public class Command_cage extends FreedomCommand { @@ -62,11 +62,15 @@ public class Command_cage extends FreedomCommand } case "skull": { - outerMaterial = Material.SKULL; + outerMaterial = Material.PLAYER_HEAD; if (args.length >= 3) { skullName = args[2]; } + else + { + outerMaterial = Material.SKELETON_SKULL; + } break; } case "block": @@ -81,17 +85,6 @@ public class Command_cage extends FreedomCommand } } } - if (args.length >= 3) - { - if (args[2].equalsIgnoreCase("water")) - { - innerMaterial = Material.STATIONARY_WATER; - } - else if (args[2].equalsIgnoreCase("lava")) - { - innerMaterial = Material.STATIONARY_LAVA; - } - } Location location = player.getLocation().clone().add(0.0, 1.0, 0.0); if (skullName != null) { @@ -102,7 +95,7 @@ public class Command_cage extends FreedomCommand fPlayer.getCageData().cage(location, outerMaterial, innerMaterial); } player.setGameMode(GameMode.SURVIVAL); - if (outerMaterial == Material.SKULL && skullName != null) + if (outerMaterial == Material.PLAYER_HEAD) { FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java new file mode 100644 index 00000000..bc45efe4 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_debugstick.java @@ -0,0 +1,35 @@ +package me.totalfreedom.totalfreedommod.command; + +import me.totalfreedom.totalfreedommod.rank.Rank; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import java.util.Arrays; +import java.util.List; + +@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) +@CommandParameters(description = "Get a stuck of happiness.", usage = "/") +public class Command_debugstick extends FreedomCommand +{ + + @Override + public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + ItemStack itemStack = new ItemStack(Material.DEBUG_STICK); + ItemMeta itemMeta = itemStack.getItemMeta(); + itemMeta.setDisplayName(ChatColor.GOLD.toString() + ChatColor.BOLD.toString() + "Stick of Happiness"); + List lore = Arrays.asList( + ChatColor.RED + "This is the most powerfull stick in the game.", + ChatColor.DARK_BLUE + "You can left click to select what you want to change.", + ChatColor.DARK_GREEN + "And then you can right click to change it!", + ChatColor.DARK_PURPLE + "Isn't technology amazing?"); + itemMeta.setLore(lore); + itemStack.setItemMeta(itemMeta); + playerSender.getInventory().addItem(itemStack); + return true; + } +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java index 8d0e12e3..faac6135 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_dispfill.java @@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.command; import java.util.ArrayList; import java.util.List; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import me.totalfreedom.totalfreedommod.util.FUtil; import org.apache.commons.lang3.StringUtils; import org.bukkit.Location; @@ -44,16 +43,6 @@ public class Command_dispfill extends FreedomCommand for (final String searchItem : itemsRaw) { Material material = Material.matchMaterial(searchItem); - if (material == null) - { - try - { - material = DepreciationAggregator.getMaterial(Integer.parseInt(searchItem)); - } - catch (NumberFormatException ex) - { - } - } if (material != null) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java index 97cf6ee2..6f34ab27 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_mp44.java @@ -38,7 +38,7 @@ public class Command_mp44 extends FreedomCommand msg("mp44 is ARMED! Left click with gunpowder to start firing, left click again to quit.", ChatColor.GREEN); msg("Type /mp44 sling to disable. -by Madgeek1450", ChatColor.GREEN); - playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.SULPHUR, 1)); + playerSender.getEquipment().setItemInMainHand(new ItemStack(Material.GUNPOWDER, 1)); } else { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java index 40cdb49d..6f305f2b 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_ro.java @@ -3,8 +3,8 @@ package me.totalfreedom.totalfreedommod.command; import java.util.ArrayList; import java.util.List; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import me.totalfreedom.totalfreedommod.util.FUtil; +import me.totalfreedom.totalfreedommod.util.MaterialGroup; import org.apache.commons.lang3.StringUtils; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -29,28 +29,26 @@ public class Command_ro extends FreedomCommand } final List materials = new ArrayList<>(); - - for (String materialName : StringUtils.split(args[0], ",")) + String names = null; + if (args[0].equalsIgnoreCase("shulker_boxes") || args[0].equalsIgnoreCase("shulkers")) { - Material fromMaterial = Material.matchMaterial(materialName); - if (fromMaterial == null) + materials.addAll(MaterialGroup.SHULKER_BOX_COLORS); + names = "shulker boxes"; + } + else + { + for (String materialName : StringUtils.split(args[0], ",")) { - try - { - fromMaterial = DepreciationAggregator.getMaterial(Integer.parseInt(materialName)); - } - catch (NumberFormatException ex) - { - } - } + Material fromMaterial = Material.matchMaterial(materialName); - if (fromMaterial == null || fromMaterial == Material.AIR || !fromMaterial.isBlock()) - { - msg("Invalid material: " + materialName, ChatColor.RED); - return true; - } + if (fromMaterial == null || fromMaterial == Material.AIR || !fromMaterial.isBlock()) + { + msg("Invalid material: " + materialName, ChatColor.RED); + return true; + } - materials.add(fromMaterial); + materials.add(fromMaterial); + } } int radius = 20; @@ -82,7 +80,10 @@ public class Command_ro extends FreedomCommand targetPlayer = null; } - final String names = StringUtils.join(materials, ", "); + if (names == null) + { + names = StringUtils.join(materials, ", "); + } World adminWorld = null; try diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java index 27df9e02..8061ddc5 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_setlever.java @@ -2,14 +2,15 @@ package me.totalfreedom.totalfreedommod.command; import java.util.List; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; +import org.bukkit.block.BlockState; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.material.Lever; @CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH) @CommandParameters(description = "Set the on/off state of the lever at position x, y, z in world 'worldname'.", usage = "/ ") @@ -63,10 +64,11 @@ public class Command_setlever extends FreedomCommand if (targetBlock.getType() == Material.LEVER) { - org.bukkit.material.Lever lever = DepreciationAggregator.makeLeverWithData(DepreciationAggregator.getData_Block(targetBlock)); + BlockState state = targetBlock.getState(); + Lever lever = (Lever) state.getData(); lever.setPowered(leverOn); - DepreciationAggregator.setData_Block(targetBlock, DepreciationAggregator.getData_MaterialData(lever)); - targetBlock.getState().update(); + state.setData(lever); + state.update(); } else { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java index 74494aaa..023dd2a3 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/command/Command_whohas.java @@ -2,12 +2,7 @@ package me.totalfreedom.totalfreedommod.command; import java.util.ArrayList; import java.util.List; -import me.totalfreedom.totalfreedommod.command.CommandParameters; -import me.totalfreedom.totalfreedommod.command.CommandPermissions; -import me.totalfreedom.totalfreedommod.command.FreedomCommand; -import me.totalfreedom.totalfreedommod.command.SourceType; import me.totalfreedom.totalfreedommod.rank.Rank; -import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import org.apache.commons.lang3.StringUtils; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -32,20 +27,10 @@ public class Command_whohas extends FreedomCommand final String materialName = args[0]; Material material = Material.matchMaterial(materialName); - if (material == null) - { - try - { - material = DepreciationAggregator.getMaterial(Integer.parseInt(materialName)); - } - catch (NumberFormatException ex) - { - } - } if (material == null) { - msg("Invalid block: " + materialName, ChatColor.RED); + msg("Invalid item: " + materialName, ChatColor.RED); return true; } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java index da8f2e3d..31c26ba7 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/ItemFun.java @@ -56,17 +56,11 @@ public class ItemFun extends FreedomService switch (event.getMaterial()) { - case RAW_FISH: + case TROPICAL_FISH: { final int RADIUS_HIT = 5; final int STRENGTH = 4; - // Clownfish - if (DepreciationAggregator.getData_MaterialData(event.getItem().getData()) != 2) - { - break; - } - if (!plugin.al.isSeniorAdmin(player)) { final StringBuilder msg = new StringBuilder(); @@ -77,7 +71,7 @@ public class ItemFun extends FreedomService } player.sendMessage(msg.toString()); - player.getEquipment().getItemInMainHand().setType(Material.POTATO_ITEM); + player.getEquipment().getItemInMainHand().setType(Material.POTATO); break; } @@ -126,7 +120,7 @@ public class ItemFun extends FreedomService break; } - case CARROT_ITEM: + case CARROT: { if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()) { @@ -214,7 +208,7 @@ public class ItemFun extends FreedomService break; } - case SULPHUR: + case GUNPOWDER: { if (!fPlayer.isMP44Armed()) { diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java index 2385bd21..9d3c816c 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/Jumppads.java @@ -6,7 +6,7 @@ import lombok.Getter; import lombok.Setter; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.TotalFreedomMod; -import org.bukkit.Material; +import me.totalfreedom.totalfreedommod.util.MaterialGroup; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -16,7 +16,6 @@ import org.bukkit.util.Vector; public class Jumppads extends FreedomService { - public static final Material BLOCK_ID = Material.WOOL; public static final double DAMPING_COEFFICIENT = 0.8; // private final Map pushMap = Maps.newHashMap(); @@ -64,7 +63,7 @@ public class Jumppads extends FreedomService { canPush = true; } - if (block.getRelative(0, -1, 0).getType() == BLOCK_ID) + if (MaterialGroup.WOOL_COLORS.contains(block.getRelative(0, -1, 0).getType())) { if (canPush) { @@ -80,29 +79,29 @@ public class Jumppads extends FreedomService } else { - if (block.getRelative(0, -1, 0).getType() == BLOCK_ID) + if (MaterialGroup.WOOL_COLORS.contains(block.getRelative(0, -1, 0).getType())) { velocity.add(new Vector(0.0, strength, 0.0)); } if (mode == JumpPadMode.NORMAL_AND_SIDEWAYS) { - if (block.getRelative(1, 0, 0).getType() == BLOCK_ID) + if (MaterialGroup.WOOL_COLORS.contains(block.getRelative(1, 0, 0).getType())) { velocity.add(new Vector(-DAMPING_COEFFICIENT * strength, 0.0, 0.0)); } - if (block.getRelative(-1, 0, 0).getType() == BLOCK_ID) + if (MaterialGroup.WOOL_COLORS.contains(block.getRelative(-1, 0, 0).getType())) { velocity.add(new Vector(DAMPING_COEFFICIENT * strength, 0.0, 0.0)); } - if (block.getRelative(0, 0, 1).getType() == BLOCK_ID) + if (MaterialGroup.WOOL_COLORS.contains(block.getRelative(0, 0, 1).getType())) { velocity.add(new Vector(0.0, 0.0, -DAMPING_COEFFICIENT * strength)); } - if (block.getRelative(0, 0, -1).getType() == BLOCK_ID) + if (MaterialGroup.WOOL_COLORS.contains(block.getRelative(0, 0, -1).getType())) { velocity.add(new Vector(0.0, 0.0, DAMPING_COEFFICIENT * strength)); } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java index ac894466..9ead256f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/MobStacker.java @@ -44,7 +44,7 @@ public class MobStacker extends FreedomService ItemStack item = attacker.getInventory().getItemInMainHand(); - if (item != null && item.getType().equals(Material.POTATO_ITEM)) + if (item != null && item.getType().equals(Material.POTATO)) { event.setCancelled(true); attacker.addPassenger(event.getEntity()); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java b/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java index dabd177b..72147947 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/fun/Trailer.java @@ -2,6 +2,7 @@ package me.totalfreedom.totalfreedommod.fun; import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.TotalFreedomMod; +import me.totalfreedom.totalfreedommod.util.MaterialGroup; import me.totalfreedom.totalfreedommod.util.DepreciationAggregator; import org.bukkit.Location; import org.bukkit.Material; @@ -10,7 +11,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerMoveEvent; - import java.util.HashSet; import java.util.Random; import java.util.Set; @@ -66,8 +66,7 @@ public class Trailer extends FreedomService } final Location location = fromBlock.getLocation(); - fromBlock.setType(Material.WOOL); - DepreciationAggregator.setData_Block(fromBlock, (byte) random.nextInt(16)); + fromBlock.setType(MaterialGroup.WOOL_COLORS.get(random.nextInt(MaterialGroup.WOOL_COLORS.size()))); byte data = DepreciationAggregator.getData_Block(fromBlock); Material material = Material.getMaterial(String.valueOf(fromBlock.getType())); for (int x = -1; x <= 1; x++) diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rollback/RollbackEntry.java b/src/main/java/me/totalfreedom/totalfreedommod/rollback/RollbackEntry.java index fc4dcc31..ba7568a2 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/rollback/RollbackEntry.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/rollback/RollbackEntry.java @@ -6,6 +6,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; public class RollbackEntry { @@ -16,7 +17,7 @@ public class RollbackEntry public final int x; public final short y; public final int z; - public final byte data; + public final BlockData data; public final Material blockMaterial; private final boolean isBreak; @@ -33,13 +34,13 @@ public class RollbackEntry if (entryType == EntryType.BLOCK_BREAK) { this.blockMaterial = block.getType(); - this.data = DepreciationAggregator.getData_Block(block); + this.data = block.getBlockData(); this.isBreak = true; } else { this.blockMaterial = block.getType(); - this.data = DepreciationAggregator.getData_Block(block); + this.data = block.getBlockData(); this.isBreak = false; } } @@ -73,7 +74,7 @@ public class RollbackEntry if (isBreak) { block.setType(getMaterial()); - DepreciationAggregator.setData_Block(block, data); + block.setBlockData(data); } else { @@ -92,7 +93,7 @@ public class RollbackEntry else { block.setType(getMaterial()); - DepreciationAggregator.setData_Block(block, data); + block.setBlockData(data); } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/rollback/RollbackManager.java b/src/main/java/me/totalfreedom/totalfreedommod/rollback/RollbackManager.java index 23293c0a..7146bb54 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/rollback/RollbackManager.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/rollback/RollbackManager.java @@ -275,7 +275,7 @@ public class RollbackManager extends FreedomService for (RollbackEntry entry : entries) { FUtil.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " " - + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == 0 ? "" : ":" + entry.data)); + + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == null ? "" : ":" + entry.data)); } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/DepreciationAggregator.java b/src/main/java/me/totalfreedom/totalfreedommod/util/DepreciationAggregator.java index eba8053d..a9c1ab5f 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/DepreciationAggregator.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/DepreciationAggregator.java @@ -24,11 +24,6 @@ public class DepreciationAggregator return server.getOfflinePlayer(name); } - public static Material getMaterial(int id) - { - return Material.getMaterial(id); - } - public static byte getData_MaterialData(MaterialData md) { return md.getData(); @@ -44,21 +39,11 @@ public class DepreciationAggregator return block.getData(); } - public static void setData_Block(Block block, byte data) - { - block.setData(data); - } - public static org.bukkit.material.Lever makeLeverWithData(byte data) { return new org.bukkit.material.Lever(Material.LEVER, data); } - public static int getTypeId_Block(Block block) - { - return block.getTypeId(); - } - public static String getName_EntityType(EntityType et) { return et.getName(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java index 480f898a..1e57e549 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/FUtil.java @@ -26,6 +26,7 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.OfflinePlayer; +import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; diff --git a/src/main/java/me/totalfreedom/totalfreedommod/util/MaterialGroup.java b/src/main/java/me/totalfreedom/totalfreedommod/util/MaterialGroup.java new file mode 100644 index 00000000..2ce46908 --- /dev/null +++ b/src/main/java/me/totalfreedom/totalfreedommod/util/MaterialGroup.java @@ -0,0 +1,43 @@ +package me.totalfreedom.totalfreedommod.util; + +import org.bukkit.Material; +import java.util.Arrays; +import java.util.List; + +public class MaterialGroup +{ + public static final List WOOL_COLORS = Arrays.asList( + Material.WHITE_WOOL, + Material.RED_WOOL, + Material.ORANGE_WOOL, + Material.YELLOW_WOOL, + Material.GREEN_WOOL, + Material.LIME_WOOL, + Material.LIGHT_BLUE_WOOL, + Material.CYAN_WOOL, + Material.BLUE_WOOL, + Material.PURPLE_WOOL, + Material.MAGENTA_WOOL, + Material.PINK_WOOL, + Material.BROWN_WOOL, + Material.GRAY_WOOL, + Material.LIGHT_GRAY_WOOL, + Material.BLACK_WOOL); + public static final List SHULKER_BOX_COLORS = Arrays.asList( + Material.WHITE_SHULKER_BOX, + Material.RED_SHULKER_BOX, + Material.ORANGE_SHULKER_BOX, + Material.YELLOW_SHULKER_BOX, + Material.GREEN_SHULKER_BOX, + Material.LIME_SHULKER_BOX, + Material.LIGHT_BLUE_SHULKER_BOX, + Material.CYAN_SHULKER_BOX, + Material.BLUE_SHULKER_BOX, + Material.PURPLE_SHULKER_BOX, + Material.MAGENTA_SHULKER_BOX, + Material.PINK_SHULKER_BOX, + Material.BROWN_SHULKER_BOX, + Material.GRAY_SHULKER_BOX, + Material.LIGHT_GRAY_SHULKER_BOX, + Material.BLACK_SHULKER_BOX); +} diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java b/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java index 671e5a1f..a396a075 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/AdminWorld.java @@ -68,7 +68,7 @@ public final class AdminWorld extends CustomWorld world.setSpawnLocation(0, 50, 0); final Block welcomeSignBlock = world.getBlockAt(0, 50, 0); - welcomeSignBlock.setType(Material.SIGN_POST); + welcomeSignBlock.setType(Material.SIGN); org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomBlockPopulator.java b/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomBlockPopulator.java index 4fed4c73..075c0e91 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomBlockPopulator.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomBlockPopulator.java @@ -52,7 +52,8 @@ public class CleanroomBlockPopulator extends BlockPopulator { for (int zz = 0; zz < 16; zz++) { - world.getBlockAt(x + xx, y, z + zz).setData(dataValue); + // xd dont know what im gonna do, ill come back to this later + //world.getBlockAt(x + xx, y, z + zz).setData(dataValue); } } } diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java b/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java index 21bad077..ec4e77bf 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/CleanroomChunkGenerator.java @@ -102,7 +102,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator try { // Mabe it's an integer? - mat = Material.getMaterial(Integer.parseInt(materialTokens[0])); + mat = Material.getMaterial(String.valueOf(materialTokens[0])); } catch (Exception e) { @@ -181,7 +181,6 @@ public class CleanroomChunkGenerator extends ChunkGenerator } } - @Override public short[][] generateExtBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) { int maxHeight = world.getMaxHeight(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java b/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java index 6d660108..d151a671 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/Flatlands.java @@ -46,7 +46,7 @@ public class Flatlands extends CustomWorld world.setSpawnLocation(0, 50, 0); final Block welcomeSignBlock = world.getBlockAt(0, 50, 0); - welcomeSignBlock.setType(Material.SIGN_POST); + welcomeSignBlock.setType(Material.SIGN); org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); diff --git a/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java b/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java index 0bd6dcea..668861bd 100644 --- a/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java +++ b/src/main/java/me/totalfreedom/totalfreedommod/world/MasterBuilderWorld.java @@ -55,7 +55,7 @@ public final class MasterBuilderWorld extends CustomWorld world.setSpawnLocation(0, 50, 0); final Block welcomeSignBlock = world.getBlockAt(0, 50, 0); - welcomeSignBlock.setType(Material.SIGN_POST); + welcomeSignBlock.setType(Material.SIGN); org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState(); org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 96a65655..87e17ae5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,5 +5,4 @@ description: Plugin for the Total Freedom server. depend: [Aero] softdepend: [BukkitTelnet, Essentials, LibsDisguises] authors: [Madgeek1450, Prozza] - -# plugin.yml is no longer used to define commands. +api-version: 1.13