mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-26 04:25:21 +01:00
Build against Bukkit API for Minecraft 1.13.
This very likely introduces a few bugs and breaks some functionality, but at least we're compiling...
This commit is contained in:
parent
754eb156d1
commit
934eb2d8cc
2
pom.xml
2
pom.xml
@ -100,7 +100,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.11-R0.1-SNAPSHOT</version>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -220,12 +220,12 @@ public class ArenaClass
|
||||
* Used by isWeapon() to determine if an ItemStack is a weapon type.
|
||||
*/
|
||||
private static EnumSet<Material> weaponTypes = EnumSet.of(
|
||||
WOOD_SWORD, GOLD_SWORD, STONE_SWORD, IRON_SWORD, DIAMOND_SWORD,
|
||||
WOOD_AXE, GOLD_AXE, STONE_AXE, IRON_AXE, DIAMOND_AXE,
|
||||
WOOD_PICKAXE, GOLD_PICKAXE, STONE_PICKAXE, IRON_PICKAXE, DIAMOND_PICKAXE,
|
||||
WOOD_SPADE, GOLD_SPADE, STONE_SPADE, IRON_SPADE, DIAMOND_SPADE,
|
||||
WOOD_HOE, GOLD_HOE, STONE_HOE, IRON_HOE, DIAMOND_HOE,
|
||||
BOW, FISHING_ROD, FLINT_AND_STEEL, SHEARS, CARROT_STICK, SHIELD
|
||||
WOODEN_SWORD, GOLDEN_SWORD, STONE_SWORD, IRON_SWORD, DIAMOND_SWORD,
|
||||
WOODEN_AXE, GOLDEN_AXE, STONE_AXE, IRON_AXE, DIAMOND_AXE,
|
||||
WOODEN_PICKAXE, GOLDEN_PICKAXE, STONE_PICKAXE, IRON_PICKAXE, DIAMOND_PICKAXE,
|
||||
WOODEN_SHOVEL, GOLDEN_SHOVEL, STONE_SHOVEL, IRON_SHOVEL, DIAMOND_SHOVEL,
|
||||
WOODEN_HOE, GOLDEN_HOE, STONE_HOE, IRON_HOE, DIAMOND_HOE,
|
||||
BOW, FISHING_ROD, FLINT_AND_STEEL, SHEARS, CARROT_ON_A_STICK, SHIELD
|
||||
);
|
||||
|
||||
/**
|
||||
@ -258,28 +258,28 @@ public class ArenaClass
|
||||
case CHAINMAIL_HELMET:
|
||||
case IRON_HELMET:
|
||||
case DIAMOND_HELMET:
|
||||
case GOLD_HELMET:
|
||||
case GOLDEN_HELMET:
|
||||
return HELMET;
|
||||
|
||||
case LEATHER_CHESTPLATE:
|
||||
case CHAINMAIL_CHESTPLATE:
|
||||
case IRON_CHESTPLATE:
|
||||
case DIAMOND_CHESTPLATE:
|
||||
case GOLD_CHESTPLATE:
|
||||
case GOLDEN_CHESTPLATE:
|
||||
return CHESTPLATE;
|
||||
|
||||
case LEATHER_LEGGINGS:
|
||||
case CHAINMAIL_LEGGINGS:
|
||||
case IRON_LEGGINGS:
|
||||
case DIAMOND_LEGGINGS:
|
||||
case GOLD_LEGGINGS:
|
||||
case GOLDEN_LEGGINGS:
|
||||
return LEGGINGS;
|
||||
|
||||
case LEATHER_BOOTS:
|
||||
case CHAINMAIL_BOOTS:
|
||||
case IRON_BOOTS:
|
||||
case DIAMOND_BOOTS:
|
||||
case GOLD_BOOTS:
|
||||
case GOLDEN_BOOTS:
|
||||
return BOOTS;
|
||||
|
||||
default:
|
||||
|
@ -989,9 +989,9 @@ public class ArenaImpl implements Arena
|
||||
|
||||
private Material bardingFromAmount(int amount) {
|
||||
switch ((amount >> 3) % 4) {
|
||||
case 1: return Material.IRON_BARDING;
|
||||
case 2: return Material.GOLD_BARDING;
|
||||
case 3: return Material.DIAMOND_BARDING;
|
||||
case 1: return Material.IRON_HORSE_ARMOR;
|
||||
case 2: return Material.GOLDEN_HORSE_ARMOR;
|
||||
case 3: return Material.DIAMOND_HORSE_ARMOR;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ public class ArenaListener
|
||||
// Otherwise, block was placed during a session.
|
||||
arena.addBlock(b);
|
||||
|
||||
if (b.getType() == Material.WOODEN_DOOR || b.getType() == Material.IRON_DOOR_BLOCK) {
|
||||
if (b.getType().name().endsWith("_DOOR")) {
|
||||
// For doors, add the block just above (so we get both halves)
|
||||
arena.addBlock(b.getRelative(0, 1, 0));
|
||||
}
|
||||
@ -393,7 +393,6 @@ public class ArenaListener
|
||||
private boolean isWater(Block block) {
|
||||
switch (block.getType()) {
|
||||
case WATER:
|
||||
case STATIONARY_WATER:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -534,7 +533,7 @@ public class ArenaListener
|
||||
|
||||
// Cakes and liquids should just get removed. If player-placed block, drop as item.
|
||||
Material mat = state.getType();
|
||||
if (mat == Material.CAKE_BLOCK || mat == Material.WATER || mat == Material.LAVA)
|
||||
if (mat == Material.CAKE || mat == Material.WATER || mat == Material.LAVA)
|
||||
arena.removeBlock(b);
|
||||
else if (arena.removeBlock(b))
|
||||
arena.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(state.getType(), 1));
|
||||
@ -852,19 +851,19 @@ public class ArenaListener
|
||||
|
||||
private static final EnumSet<Material> REPAIRABLE_TYPES = EnumSet.of(
|
||||
// Tools and swords
|
||||
Material.GOLD_AXE, Material.GOLD_HOE, Material.GOLD_PICKAXE, Material.GOLD_SPADE, Material.GOLD_SWORD,
|
||||
Material.WOOD_AXE, Material.WOOD_HOE, Material.WOOD_PICKAXE, Material.WOOD_SPADE, Material.WOOD_SWORD,
|
||||
Material.STONE_AXE, Material.STONE_HOE, Material.STONE_PICKAXE, Material.STONE_SPADE, Material.STONE_SWORD,
|
||||
Material.IRON_AXE, Material.IRON_HOE, Material.IRON_PICKAXE, Material.IRON_SPADE, Material.IRON_SWORD,
|
||||
Material.DIAMOND_AXE, Material.DIAMOND_HOE, Material.DIAMOND_PICKAXE, Material.DIAMOND_SPADE, Material.DIAMOND_SWORD,
|
||||
Material.GOLDEN_AXE, Material.GOLDEN_HOE, Material.GOLDEN_PICKAXE, Material.GOLDEN_SHOVEL, Material.GOLDEN_SWORD,
|
||||
Material.WOODEN_AXE, Material.WOODEN_HOE, Material.WOODEN_PICKAXE, Material.WOODEN_SHOVEL, Material.WOODEN_SWORD,
|
||||
Material.STONE_AXE, Material.STONE_HOE, Material.STONE_PICKAXE, Material.STONE_SHOVEL, Material.STONE_SWORD,
|
||||
Material.IRON_AXE, Material.IRON_HOE, Material.IRON_PICKAXE, Material.IRON_SHOVEL, Material.IRON_SWORD,
|
||||
Material.DIAMOND_AXE, Material.DIAMOND_HOE, Material.DIAMOND_PICKAXE, Material.DIAMOND_SHOVEL, Material.DIAMOND_SWORD,
|
||||
// Armor
|
||||
Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS,
|
||||
Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS,
|
||||
Material.GOLDEN_HELMET, Material.GOLDEN_CHESTPLATE, Material.GOLDEN_LEGGINGS, Material.GOLDEN_BOOTS,
|
||||
Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS,
|
||||
Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS,
|
||||
Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS,
|
||||
// Misc
|
||||
Material.BOW, Material.FLINT_AND_STEEL, Material.FISHING_ROD, Material.SHEARS, Material.CARROT_STICK, Material.SHIELD
|
||||
Material.BOW, Material.FLINT_AND_STEEL, Material.FISHING_ROD, Material.SHEARS, Material.CARROT_ON_A_STICK, Material.SHIELD
|
||||
);
|
||||
|
||||
private void repairWeapon(Player p) {
|
||||
|
@ -57,7 +57,7 @@ public class ArenaMasterImpl implements ArenaMaster
|
||||
this.classes = new HashMap<>();
|
||||
|
||||
this.allowedCommands = new HashSet<>();
|
||||
this.spawnsPets = new SpawnsPets(Material.BONE, Material.RAW_FISH);
|
||||
this.spawnsPets = new SpawnsPets(Material.BONE, Material.SALMON);
|
||||
|
||||
this.joinInterruptTimer = new JoinInterruptTimer();
|
||||
}
|
||||
|
@ -10,7 +10,9 @@ import com.garbagemule.MobArena.util.TextUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.data.Rotatable;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
@ -359,9 +361,11 @@ public class MAUtils
|
||||
// Place the hippie signs
|
||||
//Iterator<String> iterator = am.getClasses().iterator();
|
||||
Iterator<String> iterator = am.getClasses().keySet().iterator();
|
||||
Rotatable signData = (Rotatable) Material.SIGN.createBlockData();
|
||||
signData.setRotation(BlockFace.NORTH);
|
||||
for (int i = lx1+2; i <= lx2-2; i++) // Signs
|
||||
{
|
||||
world.getBlockAt(i,ly1+1,lz2-1).setTypeIdAndData(63, (byte)0x8, false);
|
||||
world.getBlockAt(i,ly1+1,lz2-1).setBlockData(signData);
|
||||
Sign sign = (Sign) world.getBlockAt(i,ly1+1,lz2-1).getState();
|
||||
sign.setLine(0, TextUtils.camelCase(iterator.next()));
|
||||
sign.update();
|
||||
|
@ -7,8 +7,8 @@ import java.util.StringJoiner;
|
||||
|
||||
class ServerVersionCheck {
|
||||
|
||||
private static final String[] EXACTS = {"1.11", "1.12"};
|
||||
private static final String[] PREFIXES = {"1.11.", "1.12."};
|
||||
private static final String[] EXACTS = {"1.13"};
|
||||
private static final String[] PREFIXES = {"1.13."};
|
||||
|
||||
static void check(Server server) {
|
||||
String version = getMinecraftVersion(server);
|
||||
|
@ -161,31 +161,31 @@ public class SetupCommand implements Command, Listener {
|
||||
private ItemStack[] getToolbox() {
|
||||
// Arena region tool
|
||||
ItemStack areg = makeTool(
|
||||
Material.GOLD_AXE, AREG_NAME,
|
||||
Material.GOLDEN_AXE, AREG_NAME,
|
||||
color("Set &ep1"),
|
||||
color("Set &ep2")
|
||||
);
|
||||
// Warps tool
|
||||
ItemStack warps = makeTool(
|
||||
Material.GOLD_HOE, WARPS_NAME,
|
||||
Material.GOLDEN_HOE, WARPS_NAME,
|
||||
color("&eSet &rselected warp"),
|
||||
color("&eCycle &rbetween warps")
|
||||
);
|
||||
// Spawns tool
|
||||
ItemStack spawns = makeTool(
|
||||
Material.GOLD_SWORD, SPAWNS_NAME,
|
||||
Material.GOLDEN_SWORD, SPAWNS_NAME,
|
||||
color("&eAdd &rspawnpoint on block"),
|
||||
color("&eRemove &rspawnpoint on block")
|
||||
);
|
||||
// Chests tool
|
||||
ItemStack chests = makeTool(
|
||||
Material.GOLD_SPADE, CHESTS_NAME,
|
||||
Material.GOLDEN_SHOVEL, CHESTS_NAME,
|
||||
color("&eAdd &rcontainer"),
|
||||
color("&eRemove &rcontainer")
|
||||
);
|
||||
// Lobby region tool
|
||||
ItemStack lreg = makeTool(
|
||||
Material.GOLD_AXE, LREG_NAME,
|
||||
Material.GOLDEN_AXE, LREG_NAME,
|
||||
color("Set &el1"),
|
||||
color("Set &el2")
|
||||
);
|
||||
@ -640,7 +640,7 @@ public class SetupCommand implements Command, Listener {
|
||||
toShow.equals("spec") ? region.getSpecWarp() :
|
||||
toShow.equals("spectator") ? region.getSpecWarp() :
|
||||
toShow.equals("exit") ? region.getExitWarp() : null;
|
||||
region.showBlock(player, loc, 35, (byte) 14);
|
||||
region.showBlock(player, loc);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -11,9 +11,11 @@ import com.garbagemule.MobArena.util.Enums;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
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.block.data.BlockData;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -650,18 +652,19 @@ public class ArenaRegion
|
||||
showBlocks(p, map.values());
|
||||
}
|
||||
|
||||
public void showBlock(final Player p, final Location loc, final int id, final byte data) {
|
||||
public void showBlock(final Player p, final Location loc) {
|
||||
BlockData wool = Material.RED_WOOL.createBlockData();
|
||||
arena.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
p.sendBlockChange(loc, id, data);
|
||||
p.sendBlockChange(loc, wool);
|
||||
arena.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!p.isOnline()) return;
|
||||
|
||||
Block b = loc.getBlock();
|
||||
p.sendBlockChange(loc, b.getTypeId(), b.getData());
|
||||
p.sendBlockChange(loc, b.getBlockData());
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
@ -669,6 +672,7 @@ public class ArenaRegion
|
||||
}
|
||||
|
||||
private void showBlocks(final Player p, final Collection<Location> points) {
|
||||
BlockData wool = Material.RED_WOOL.createBlockData();
|
||||
arena.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -677,7 +681,7 @@ public class ArenaRegion
|
||||
for (Location l : points) {
|
||||
Block b = l.getBlock();
|
||||
blocks.put(l, b.getState());
|
||||
p.sendBlockChange(l, 35, (byte) 14);
|
||||
p.sendBlockChange(l, wool);
|
||||
}
|
||||
arena.scheduleTask(new Runnable() {
|
||||
public void run() {
|
||||
@ -690,10 +694,9 @@ public class ArenaRegion
|
||||
for (Map.Entry<Location,BlockState> entry : blocks.entrySet()) {
|
||||
Location l = entry.getKey();
|
||||
BlockState b = entry.getValue();
|
||||
int id = b.getTypeId();
|
||||
byte data = b.getRawData();
|
||||
BlockData data = b.getBlockData();
|
||||
|
||||
p.sendBlockChange(l, id, data);
|
||||
p.sendBlockChange(l, data);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
|
@ -3,6 +3,7 @@ package com.garbagemule.MobArena.repairable;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public interface Repairable
|
||||
{
|
||||
@ -11,8 +12,7 @@ public interface Repairable
|
||||
BlockState getState();
|
||||
|
||||
Material getType();
|
||||
int getId();
|
||||
byte getData();
|
||||
BlockData getData();
|
||||
|
||||
World getWorld();
|
||||
int getX();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.garbagemule.MobArena.repairable;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -23,14 +24,14 @@ public class RepairableAttachable extends RepairableBlock
|
||||
y = attached.getY();
|
||||
z = attached.getZ();
|
||||
|
||||
state.getBlock().setTypeId(1);
|
||||
state.getBlock().setType(Material.STONE);
|
||||
}
|
||||
|
||||
public void repair()
|
||||
{
|
||||
Block b = getWorld().getBlockAt(x,y,z);
|
||||
if (b.getTypeId() == 0)
|
||||
b.setTypeId(1);
|
||||
if (b.getType() == Material.AIR)
|
||||
b.setType(Material.STONE);
|
||||
|
||||
super.repair();
|
||||
}
|
||||
|
@ -19,6 +19,6 @@ public class RepairableBed extends RepairableBlock
|
||||
return;
|
||||
|
||||
super.repair();
|
||||
other.getBlock().setTypeIdAndData(getId(), (byte) (getData() + 8), false);
|
||||
other.getBlock().setBlockData(other.getBlockData());
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,15 @@ package com.garbagemule.MobArena.repairable;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public class RepairableBlock implements Repairable
|
||||
{
|
||||
private BlockState state;
|
||||
private World world;
|
||||
private int id, x, y, z;
|
||||
private BlockData data;
|
||||
private int x, y, z;
|
||||
private Material type;
|
||||
private byte data;
|
||||
|
||||
public RepairableBlock(BlockState state)
|
||||
{
|
||||
@ -22,9 +23,8 @@ public class RepairableBlock implements Repairable
|
||||
y = state.getY();
|
||||
z = state.getZ();
|
||||
|
||||
id = state.getTypeId();
|
||||
data = state.getBlockData();
|
||||
type = state.getType();
|
||||
data = state.getRawData();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@ public class RepairableBlock implements Repairable
|
||||
*/
|
||||
public void repair()
|
||||
{
|
||||
world.getBlockAt(x,y,z).setTypeIdAndData(id, data, false);
|
||||
world.getBlockAt(x,y,z).setBlockData(data);
|
||||
}
|
||||
|
||||
public BlockState getState()
|
||||
@ -50,12 +50,7 @@ public class RepairableBlock implements Repairable
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public byte getData()
|
||||
public BlockData getData()
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package com.garbagemule.MobArena.repairable;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.material.Attachable;
|
||||
import org.bukkit.material.Bed;
|
||||
import org.bukkit.material.Door;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Redstone;
|
||||
import org.bukkit.block.data.Attachable;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Bed;
|
||||
import org.bukkit.block.data.type.Door;
|
||||
import org.bukkit.block.data.type.RedstoneWire;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
@ -28,8 +28,8 @@ public class RepairableComparator implements Comparator<Repairable>
|
||||
private boolean restoreLast(Repairable r)
|
||||
{
|
||||
Material t = r.getType();
|
||||
MaterialData m = r.getState().getData();
|
||||
BlockData data = r.getData();
|
||||
|
||||
return (m instanceof Attachable || m instanceof Redstone || m instanceof Door || m instanceof Bed || t == Material.STATIONARY_LAVA || t == Material.STATIONARY_WATER || t == Material.FIRE);
|
||||
return (data instanceof Attachable || data instanceof RedstoneWire || data instanceof Door || data instanceof Bed || t == Material.LAVA || t == Material.WATER || t == Material.FIRE);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.garbagemule.MobArena.repairable;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -27,10 +28,10 @@ public class RepairableDoor extends RepairableAttachable//RepairableBlock
|
||||
return;
|
||||
|
||||
Block b = getWorld().getBlockAt(x,y,z);
|
||||
if (b.getTypeId() == 0)
|
||||
b.setTypeId(1);
|
||||
if (b.getType() == Material.AIR)
|
||||
b.setType(Material.STONE);
|
||||
|
||||
super.repair();
|
||||
other.getBlock().setTypeIdAndData(getId(), (byte) (getData() + 8), false);
|
||||
other.getBlock().setBlockData(other.getBlockData());
|
||||
}
|
||||
}
|
||||
|
@ -15,28 +15,28 @@ class Equippable {
|
||||
Material.LEATHER_HELMET,
|
||||
Material.IRON_HELMET,
|
||||
Material.CHAINMAIL_HELMET,
|
||||
Material.GOLD_HELMET,
|
||||
Material.GOLDEN_HELMET,
|
||||
Material.DIAMOND_HELMET
|
||||
);
|
||||
private static EnumSet<Material> chestplates = EnumSet.of(
|
||||
Material.LEATHER_CHESTPLATE,
|
||||
Material.IRON_CHESTPLATE,
|
||||
Material.CHAINMAIL_CHESTPLATE,
|
||||
Material.GOLD_CHESTPLATE,
|
||||
Material.GOLDEN_CHESTPLATE,
|
||||
Material.DIAMOND_CHESTPLATE
|
||||
);
|
||||
private static EnumSet<Material> leggings = EnumSet.of(
|
||||
Material.LEATHER_LEGGINGS,
|
||||
Material.IRON_LEGGINGS,
|
||||
Material.CHAINMAIL_LEGGINGS,
|
||||
Material.GOLD_LEGGINGS,
|
||||
Material.GOLDEN_LEGGINGS,
|
||||
Material.DIAMOND_LEGGINGS
|
||||
);
|
||||
private static EnumSet<Material> boots = EnumSet.of(
|
||||
Material.LEATHER_BOOTS,
|
||||
Material.IRON_BOOTS,
|
||||
Material.CHAINMAIL_BOOTS,
|
||||
Material.GOLD_BOOTS,
|
||||
Material.GOLDEN_BOOTS,
|
||||
Material.DIAMOND_BOOTS
|
||||
);
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class ClassChests {
|
||||
Block blockBehind = blockBelow.getRelative(backwards);
|
||||
|
||||
// If the block below this sign is a class sign, swap the order
|
||||
if (blockBelow.getType() == Material.WALL_SIGN || blockBelow.getType() == Material.SIGN_POST) {
|
||||
if (blockBelow.getType() == Material.WALL_SIGN || blockBelow.getType() == Material.SIGN) {
|
||||
String className = ChatColor.stripColor(((Sign) blockBelow.getState()).getLine(0)).toLowerCase();
|
||||
if (arena.getClasses().containsKey(className)) {
|
||||
blockSign = blockBehind; // Use blockSign as a temp while swapping
|
||||
|
@ -1,43 +1,21 @@
|
||||
package com.garbagemule.MobArena.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.material.Dye;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.bukkit.potion.PotionData;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ItemParser
|
||||
{
|
||||
private static final Map<Short, PotionType> POTION_TYPE_MAP = new HashMap<>();
|
||||
static {
|
||||
POTION_TYPE_MAP.put((short) 8193, PotionType.REGEN);
|
||||
POTION_TYPE_MAP.put((short) 8194, PotionType.SPEED);
|
||||
POTION_TYPE_MAP.put((short) 8195, PotionType.FIRE_RESISTANCE);
|
||||
POTION_TYPE_MAP.put((short) 8196, PotionType.POISON);
|
||||
POTION_TYPE_MAP.put((short) 8197, PotionType.INSTANT_HEAL);
|
||||
POTION_TYPE_MAP.put((short) 8198, PotionType.NIGHT_VISION);
|
||||
POTION_TYPE_MAP.put((short) 8200, PotionType.WEAKNESS);
|
||||
POTION_TYPE_MAP.put((short) 8201, PotionType.STRENGTH);
|
||||
POTION_TYPE_MAP.put((short) 8202, PotionType.SLOWNESS);
|
||||
POTION_TYPE_MAP.put((short) 8203, PotionType.JUMP);
|
||||
POTION_TYPE_MAP.put((short) 8204, PotionType.INSTANT_DAMAGE);
|
||||
POTION_TYPE_MAP.put((short) 8205, PotionType.WATER_BREATHING);
|
||||
POTION_TYPE_MAP.put((short) 8206, PotionType.INVISIBILITY);
|
||||
}
|
||||
|
||||
public static List<ItemStack> parseItems(String s) {
|
||||
if (s == null) {
|
||||
return new ArrayList<>(1);
|
||||
@ -118,12 +96,7 @@ public class ItemParser
|
||||
return withPotionMeta(stack, data);
|
||||
}
|
||||
|
||||
MaterialData md = getData(data, type);
|
||||
if (md == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return md.toItemStack(stack.getAmount());
|
||||
return stack;
|
||||
}
|
||||
|
||||
private static ItemStack withPotionMeta(ItemStack stack, String data) {
|
||||
@ -138,29 +111,6 @@ public class ItemParser
|
||||
}
|
||||
|
||||
private static PotionType getPotionType(String data) {
|
||||
if (data.matches("[0-9]+")) {
|
||||
short d = Short.parseShort(data);
|
||||
|
||||
// Compensate for splash potions
|
||||
if (d > (2 * 8192)) {
|
||||
d -= 8192;
|
||||
}
|
||||
|
||||
boolean extended = (d & 64) > 0;
|
||||
boolean upgraded = (d & 32) > 0;
|
||||
if (extended) {
|
||||
d -= 64;
|
||||
}
|
||||
if (upgraded) {
|
||||
d -= 32;
|
||||
}
|
||||
|
||||
PotionType type = POTION_TYPE_MAP.get(d);
|
||||
if (type != null) {
|
||||
warn(type.name(), data);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
try {
|
||||
return PotionType.valueOf(data.toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
@ -169,65 +119,9 @@ public class ItemParser
|
||||
}
|
||||
|
||||
private static Optional<Material> getType(String item) {
|
||||
if (item.matches("(-)?[1-9][0-9]*")) {
|
||||
Material type = Material.getMaterial(Integer.parseInt(item));
|
||||
if (type == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
warn(type.name(), item);
|
||||
|
||||
return Optional.of(type);
|
||||
}
|
||||
return Optional.ofNullable(Material.getMaterial(item.toUpperCase()));
|
||||
}
|
||||
|
||||
private static MaterialData getData(String data, Material type) {
|
||||
if (type == Material.INK_SACK) {
|
||||
return getDyeData(data);
|
||||
}
|
||||
if (type == Material.WOOL) {
|
||||
return getWoolData(data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Wool getWoolData(String data) {
|
||||
if (data.matches("(-)?[1-9][0-9]*")) {
|
||||
DyeColor color = DyeColor.getByWoolData(Byte.parseByte(data));
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
warn(color.name(), data);
|
||||
|
||||
return new Wool(color);
|
||||
}
|
||||
try {
|
||||
return new Wool(DyeColor.valueOf(data.toUpperCase()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Dye getDyeData(String data) {
|
||||
if (data.matches("(-)?[1-9][0-9]*")) {
|
||||
DyeColor color = DyeColor.getByDyeData(Byte.parseByte(data));
|
||||
if (color == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
warn(color.name(), data);
|
||||
|
||||
return new Dye(color);
|
||||
}
|
||||
try {
|
||||
return new Dye(DyeColor.valueOf(data.toUpperCase()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getAmount(String amount) {
|
||||
if (amount.matches("(-)?[1-9][0-9]*")) {
|
||||
return Integer.parseInt(amount);
|
||||
@ -246,7 +140,7 @@ public class ItemParser
|
||||
|
||||
private static void addEnchantment(ItemStack stack, String ench) {
|
||||
String[] parts = ench.split(":");
|
||||
if (parts.length != 2 || !parts[1].matches("[0-9]*")) {
|
||||
if (parts.length != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -266,25 +160,6 @@ public class ItemParser
|
||||
}
|
||||
|
||||
private static Enchantment getEnchantment(String ench) {
|
||||
if (ench.matches("[1-9][0-9]*")) {
|
||||
Enchantment enchantment = Enchantment.getById(Integer.parseInt(ench));
|
||||
if (enchantment == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
warn(enchantment.getName(), ench);
|
||||
|
||||
return enchantment;
|
||||
}
|
||||
return Enchantment.getByName(ench.toUpperCase());
|
||||
}
|
||||
|
||||
private static void warn(String name, String value) {
|
||||
String msg = String.format(
|
||||
"Consider using '%s' instead of '%s'",
|
||||
name.toLowerCase(),
|
||||
value
|
||||
);
|
||||
Bukkit.getLogger().warning("[MobArena] " + msg);
|
||||
return Enchantment.getByKey(NamespacedKey.minecraft(ench));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ name: ${project.name}
|
||||
author: garbagemule
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: '${project.version}'
|
||||
api-version: 1.13
|
||||
softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault]
|
||||
commands:
|
||||
ma:
|
||||
|
@ -6,7 +6,7 @@ Tank:
|
||||
armor: diamond_helmet, diamond_chestplate, diamond_leggings, diamond_boots
|
||||
effects: slow, health_boost
|
||||
Archer:
|
||||
items: wood_sword, bow, arrow:256, potion:instant_heal:3, bone
|
||||
items: wooden_sword, bow, arrow:256, potion:instant_heal:3, bone
|
||||
armor: leather_helmet, leather_chestplate, leather_leggings, leather_boots
|
||||
effects: speed
|
||||
Chemist:
|
||||
|
@ -4,4 +4,4 @@ update-notification: true
|
||||
prefix: '&a[MobArena] '
|
||||
pet-items:
|
||||
wolf: bone
|
||||
ocelot: raw_fish
|
||||
ocelot: salmon
|
||||
|
@ -4,6 +4,6 @@ waves:
|
||||
'5': dirt:4, gravel:4, stone:4
|
||||
'10': iron_ingot:10, gold_ingot:8
|
||||
after:
|
||||
'7': minecart, storage_minecart, powered_minecart
|
||||
'13': iron_sword, iron_pickaxe, iron_spade
|
||||
'7': minecart, chest_minecart, furnace_minecart
|
||||
'13': iron_sword, iron_pickaxe, iron_shovel
|
||||
'16': diamond_sword
|
Loading…
Reference in New Issue
Block a user