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