mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-27 04:55:25 +01:00
Add classchest command.
The classchest command can be used to link a chest to a class directly (although still in the same world) without having to position them in a specific pillar under the signs.
This commit is contained in:
parent
c24f9f8ccc
commit
1673078df5
@ -1,7 +1,7 @@
|
|||||||
name: MobArena
|
name: MobArena
|
||||||
author: garbagemule
|
author: garbagemule
|
||||||
main: com.garbagemule.MobArena.MobArena
|
main: com.garbagemule.MobArena.MobArena
|
||||||
version: 0.95.5.15
|
version: 0.95.5.16
|
||||||
softdepend: [Spout,Towny,Heroes,MagicSpells,Vault]
|
softdepend: [Spout,Towny,Heroes,MagicSpells,Vault]
|
||||||
commands:
|
commands:
|
||||||
ma:
|
ma:
|
||||||
|
@ -3,6 +3,7 @@ package com.garbagemule.MobArena;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -17,7 +18,8 @@ public class ArenaClass
|
|||||||
private Map<String,Boolean> perms;
|
private Map<String,Boolean> perms;
|
||||||
private Map<String,Boolean> lobbyperms;
|
private Map<String,Boolean> lobbyperms;
|
||||||
private boolean unbreakableWeapons, unbreakableArmor;
|
private boolean unbreakableWeapons, unbreakableArmor;
|
||||||
|
private Location classchest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new, empty arena class with the given name.
|
* Create a new, empty arena class with the given name.
|
||||||
* @param name the class name as it appears in the config-file
|
* @param name the class name as it appears in the config-file
|
||||||
@ -243,6 +245,14 @@ public class ArenaClass
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getClassChest() {
|
||||||
|
return classchest;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClassChest(Location loc) {
|
||||||
|
classchest = loc;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasUnbreakableWeapons() {
|
public boolean hasUnbreakableWeapons() {
|
||||||
return unbreakableWeapons;
|
return unbreakableWeapons;
|
||||||
}
|
}
|
||||||
@ -267,7 +277,7 @@ public class ArenaClass
|
|||||||
if (stack == null) return false;
|
if (stack == null) return false;
|
||||||
return Arrays.binarySearch(weaponTypes, stack.getTypeId()) > -1;
|
return Arrays.binarySearch(weaponTypes, stack.getTypeId()) > -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by the grantItems() method to determine the armor type of a given
|
* Used by the grantItems() method to determine the armor type of a given
|
||||||
* ItemStack. Armor pieces are auto-equipped.
|
* ItemStack. Armor pieces are auto-equipped.
|
||||||
|
@ -942,28 +942,37 @@ public class ArenaListener
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (!className.equalsIgnoreCase("random")) {
|
if (!className.equalsIgnoreCase("random")) {
|
||||||
if (useClassChests) {
|
if (useClassChests) {
|
||||||
BlockFace backwards = ((org.bukkit.material.Sign) sign.getData()).getFacing().getOppositeFace();
|
// Check for stored class chests first
|
||||||
Block blockSign = sign.getBlock();
|
ArenaClass ac = plugin.getArenaMaster().getClasses().get(className.toLowerCase());
|
||||||
Block blockBelow = blockSign.getRelative(BlockFace.DOWN);
|
Location loc = ac.getClassChest();
|
||||||
Block blockBehind = blockBelow.getRelative(backwards);
|
Block blockChest;
|
||||||
|
if (loc != null) {
|
||||||
// If the block below this sign is a class sign, swap the order
|
blockChest = loc.getBlock();
|
||||||
if (blockBelow.getType() == Material.WALL_SIGN || blockBelow.getType() == Material.SIGN_POST) {
|
} else {
|
||||||
String className = ChatColor.stripColor(((Sign) blockBelow.getState()).getLine(0)).toLowerCase();
|
// Otherwise, start the search
|
||||||
if (arena.getClasses().containsKey(className)) {
|
BlockFace backwards = ((org.bukkit.material.Sign) sign.getData()).getFacing().getOppositeFace();
|
||||||
blockSign = blockBehind; // Use blockSign as a temp while swapping
|
Block blockSign = sign.getBlock();
|
||||||
blockBehind = blockBelow;
|
Block blockBelow = blockSign.getRelative(BlockFace.DOWN);
|
||||||
blockBelow = blockSign;
|
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) {
|
||||||
|
String className = ChatColor.stripColor(((Sign) blockBelow.getState()).getLine(0)).toLowerCase();
|
||||||
|
if (arena.getClasses().containsKey(className)) {
|
||||||
|
blockSign = blockBehind; // Use blockSign as a temp while swapping
|
||||||
|
blockBehind = blockBelow;
|
||||||
|
blockBelow = blockSign;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make number of searches configurable
|
||||||
|
// First check the pillar below the sign
|
||||||
|
blockChest = findChestBelow(blockBelow, 6);
|
||||||
|
|
||||||
|
// Then, if no chest was found, check the pillar behind the sign
|
||||||
|
if (blockChest == null) blockChest = findChestBelow(blockBehind, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make number of searches configurable
|
|
||||||
// First check the pillar below the sign
|
|
||||||
Block blockChest = findChestBelow(blockBelow, 6);
|
|
||||||
|
|
||||||
// Then, if no chest was found, check the pillar behind the sign
|
|
||||||
if (blockChest == null) blockChest = findChestBelow(blockBehind, 6);
|
|
||||||
|
|
||||||
// If a chest was found, get the contents
|
// If a chest was found, get the contents
|
||||||
if (blockChest != null) {
|
if (blockChest != null) {
|
||||||
InventoryHolder holder = (InventoryHolder) blockChest.getState();
|
InventoryHolder holder = (InventoryHolder) blockChest.getState();
|
||||||
@ -971,9 +980,7 @@ public class ArenaListener
|
|||||||
// Guard against double-chests for now
|
// Guard against double-chests for now
|
||||||
if (contents.length > 36) {
|
if (contents.length > 36) {
|
||||||
ItemStack[] newContents = new ItemStack[36];
|
ItemStack[] newContents = new ItemStack[36];
|
||||||
for (int i = 0; i < 36; i++) {
|
System.arraycopy(contents, 0, newContents, 0, 36);
|
||||||
newContents[i] = contents[i];
|
|
||||||
}
|
|
||||||
contents = newContents;
|
contents = newContents;
|
||||||
}
|
}
|
||||||
arena.assignClassGiveInv(p, className, contents);
|
arena.assignClassGiveInv(p, className, contents);
|
||||||
|
@ -358,6 +358,10 @@ public class ArenaMasterImpl implements ArenaMaster
|
|||||||
// Register the permission.
|
// Register the permission.
|
||||||
registerPermission("mobarena.classes." + lowercase, PermissionDefault.TRUE).addParent("mobarena.classes", true);
|
registerPermission("mobarena.classes." + lowercase, PermissionDefault.TRUE).addParent("mobarena.classes", true);
|
||||||
|
|
||||||
|
// Check for class chests
|
||||||
|
Location cc = section.getLocation("classchest", null);
|
||||||
|
arenaClass.setClassChest(cc);
|
||||||
|
|
||||||
// Finally add the class to the classes map.
|
// Finally add the class to the classes map.
|
||||||
classes.put(lowercase, arenaClass);
|
classes.put(lowercase, arenaClass);
|
||||||
return arenaClass;
|
return arenaClass;
|
||||||
|
@ -198,6 +198,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
register(SpawnpointsCommand.class);
|
register(SpawnpointsCommand.class);
|
||||||
register(AutoGenerateCommand.class);
|
register(AutoGenerateCommand.class);
|
||||||
register(AutoDegenerateCommand.class);
|
register(AutoDegenerateCommand.class);
|
||||||
|
register(ClassChestCommand.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user