diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index c88356492..9933cde6a 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -4,12 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import net.minecraft.server.v1_8_R3.BlockPosition; -import net.minecraft.server.v1_8_R3.Blocks; -import net.minecraft.server.v1_8_R3.EnumDirection; -import net.minecraft.server.v1_8_R3.MathHelper; -import net.minecraft.server.v1_8_R3.WorldServer; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -18,58 +12,70 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Bed; + +import net.minecraft.server.v1_8_R3.BlockPosition; +import net.minecraft.server.v1_8_R3.Blocks; +import net.minecraft.server.v1_8_R3.EnumDirection; +import net.minecraft.server.v1_8_R3.MathHelper; +import net.minecraft.server.v1_8_R3.WorldServer; public class UtilBlock { - public static void main(String[] args) { - - for (Material m : Material.values()) { + public static void main(String[] args) + { + for (Material m : Material.values()) + { + boolean thisSolid = fullSolid(m.getId()); boolean solid = m.isSolid(); - if (thisSolid != solid) { + if (thisSolid != solid) + { StringBuilder sb = new StringBuilder(); sb.append("Failed: "); sb.append(m.name()); int amount = 40 - sb.length(); - for (int i = 0; i < amount; i++) { + for (int i = 0; i < amount; i++) + { sb.append(" "); } sb.append(thisSolid); System.out.println(sb); } - + } System.out.println("done!"); } + /** + * A list of blocks that are usable + */ + public static HashSet blockUseSet = new HashSet(); + /** + * A list of blocks that are always solid and can be stood on + */ + public static HashSet fullSolid = new HashSet(); + /** + * A list of blocks that are non-solid, but can't be moved through. Eg lily, + * fence gate, portal + */ + public static HashSet blockPassSet = new HashSet(); + /** + * A list of blocks that offer zero resistance (long grass, torch, flower) + */ + public static HashSet blockAirFoliageSet = new HashSet(); - /** - * A list of blocks that are usable - */ - public static HashSet blockUseSet = new HashSet(); - /** - * A list of blocks that are always solid and can be stood on - */ - public static HashSet fullSolid = new HashSet(); - /** - * A list of blocks that are non-solid, but can't be moved through. Eg lily, fence gate, portal - */ - public static HashSet blockPassSet = new HashSet(); - /** - * A list of blocks that offer zero resistance (long grass, torch, flower) - */ - public static HashSet blockAirFoliageSet = new HashSet(); - - /** - * All horizontal diections [north, east, south, west] - */ - public static HashSet horizontals = new HashSet<>(); - - static { - + /** + * All horizontal diections [north, east, south, west] + */ + public static HashSet horizontals = new HashSet<>(); + + static + { + blockAirFoliageSet.add((byte) Material.AIR.getId()); blockAirFoliageSet.add((byte) Material.SAPLING.getId()); blockAirFoliageSet.add((byte) Material.LONG_GRASS.getId()); @@ -90,7 +96,7 @@ public class UtilBlock blockAirFoliageSet.add((byte) Material.DOUBLE_PLANT.getId()); blockAirFoliageSet.add((byte) Material.STANDING_BANNER.getId()); blockAirFoliageSet.add((byte) Material.WALL_BANNER.getId()); - + blockPassSet.add((byte) Material.AIR.getId()); blockPassSet.add((byte) Material.SAPLING.getId()); blockPassSet.add((byte) Material.WATER.getId()); @@ -148,7 +154,7 @@ public class UtilBlock blockPassSet.add((byte) Material.STAINED_GLASS_PANE.getId()); blockPassSet.add((byte) Material.IRON_TRAPDOOR.getId()); blockPassSet.add((byte) Material.DAYLIGHT_DETECTOR_INVERTED.getId()); - + blockPassSet.add((byte) Material.BIRCH_FENCE_GATE.getId()); blockPassSet.add((byte) Material.JUNGLE_FENCE_GATE.getId()); blockPassSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId()); @@ -158,13 +164,13 @@ public class UtilBlock blockPassSet.add((byte) Material.JUNGLE_FENCE.getId()); blockPassSet.add((byte) Material.DARK_OAK_FENCE.getId()); blockPassSet.add((byte) Material.ACACIA_FENCE.getId()); - + blockPassSet.add((byte) Material.SPRUCE_DOOR.getId()); blockPassSet.add((byte) Material.BIRCH_DOOR.getId()); blockPassSet.add((byte) Material.JUNGLE_DOOR.getId()); blockPassSet.add((byte) Material.ACACIA_DOOR.getId()); blockPassSet.add((byte) Material.DARK_OAK_DOOR.getId()); - + fullSolid.add((byte) Material.STONE.getId()); fullSolid.add((byte) Material.GRASS.getId()); fullSolid.add((byte) Material.DIRT.getId()); @@ -246,7 +252,7 @@ public class UtilBlock fullSolid.add((byte) Material.PACKED_ICE.getId()); fullSolid.add((byte) Material.RED_SANDSTONE.getId()); fullSolid.add((byte) Material.DOUBLE_STONE_SLAB2.getId()); - + blockUseSet.add((byte) Material.DISPENSER.getId()); blockUseSet.add((byte) Material.BED_BLOCK.getId()); blockUseSet.add((byte) Material.PISTON_BASE.getId()); @@ -272,7 +278,7 @@ public class UtilBlock blockUseSet.add((byte) Material.TRAPPED_CHEST.getId()); blockUseSet.add((byte) Material.HOPPER.getId()); blockUseSet.add((byte) Material.DROPPER.getId()); - + blockUseSet.add((byte) Material.BIRCH_FENCE_GATE.getId()); blockUseSet.add((byte) Material.JUNGLE_FENCE_GATE.getId()); blockUseSet.add((byte) Material.DARK_OAK_FENCE_GATE.getId()); @@ -282,195 +288,192 @@ public class UtilBlock blockUseSet.add((byte) Material.JUNGLE_FENCE.getId()); blockUseSet.add((byte) Material.DARK_OAK_FENCE.getId()); blockUseSet.add((byte) Material.ACACIA_FENCE.getId()); - + blockUseSet.add((byte) Material.SPRUCE_DOOR.getId()); blockUseSet.add((byte) Material.BIRCH_DOOR.getId()); blockUseSet.add((byte) Material.JUNGLE_DOOR.getId()); blockUseSet.add((byte) Material.ACACIA_DOOR.getId()); blockUseSet.add((byte) Material.DARK_OAK_DOOR.getId()); - horizontals.add(EnumDirection.NORTH); - horizontals.add(EnumDirection.EAST); - horizontals.add(EnumDirection.SOUTH); - horizontals.add(EnumDirection.WEST); - } + horizontals.add(BlockFace.NORTH); + horizontals.add(BlockFace.EAST); + horizontals.add(BlockFace.SOUTH); + horizontals.add(BlockFace.WEST); + } public static boolean solid(Block block) { - if (block == null) return false; + if (block == null) return false; return solid(block.getTypeId()); } + public static boolean solid(int block) { - return solid((byte)block); + return solid((byte) block); } + public static boolean solid(byte block) { return !blockPassSet.contains(block); } - + public static boolean airFoliage(Block block) { - if (block == null) return false; + if (block == null) return false; return airFoliage(block.getTypeId()); } + public static boolean airFoliage(int block) { - return airFoliage((byte)block); + return airFoliage((byte) block); } + public static boolean airFoliage(byte block) { return blockAirFoliageSet.contains(block); } - + public static boolean fullSolid(Block block) { - if (block == null) - return false; - + if (block == null) return false; + return fullSolid(block.getTypeId()); } + public static boolean fullSolid(int block) { - return fullSolid((byte)block); + return fullSolid((byte) block); } + public static boolean fullSolid(byte block) { return fullSolid.contains(block); } - + public static boolean usable(Block block) { - if (block == null) - return false; - + if (block == null) return false; + return usable(block.getTypeId()); } + public static boolean usable(int block) { - return usable((byte)block); + return usable((byte) block); } + public static boolean usable(byte block) { return blockUseSet.contains(block); } - + public static HashMap getInRadius(Location loc, double dR) { return getInRadius(loc, dR, 9999); } - + public static HashMap getInRadius(Location loc, double dR, double maxHeight) { HashMap blockList = new HashMap(); - int iR = (int)dR + 1; - - for (int x=-iR ; x <= iR ; x++) - for (int z=-iR ; z <= iR ; z++) - for (int y=-iR ; y <= iR ; y++) + int iR = (int) dR + 1; + + for (int x = -iR; x <= iR; x++) + for (int z = -iR; z <= iR; z++) + for (int y = -iR; y <= iR; y++) { - if (Math.abs(y) > maxHeight) - continue; - - Block curBlock = loc.getWorld().getBlockAt((int)(loc.getX()+x), (int)(loc.getY()+y), (int)(loc.getZ()+z)); - + if (Math.abs(y) > maxHeight) continue; + + Block curBlock = loc.getWorld().getBlockAt((int) (loc.getX() + x), (int) (loc.getY() + y), (int) (loc.getZ() + z)); + double offset = UtilMath.offset(loc, curBlock.getLocation().add(0.5, 0.5, 0.5));; - - if (offset <= dR) - blockList.put(curBlock, 1 - (offset/dR)); + + if (offset <= dR) blockList.put(curBlock, 1 - (offset / dR)); } - + return blockList; } - - + public static HashMap getInRadius(Block block, double dR) { return getInRadius(block, dR, false); } - + public static HashMap getInRadius(Block block, double dR, boolean hollow) { HashMap blockList = new HashMap(); - int iR = (int)dR + 1; - - for (int x=-iR ; x <= iR ; x++) - for (int z=-iR ; z <= iR ; z++) - for (int y=-iR ; y <= iR ; y++) + int iR = (int) dR + 1; + + for (int x = -iR; x <= iR; x++) + for (int z = -iR; z <= iR; z++) + for (int y = -iR; y <= iR; y++) { Block curBlock = block.getRelative(x, y, z); - + double offset = UtilMath.offset(block.getLocation(), curBlock.getLocation()); - + if (offset <= dR && !(hollow && offset < dR - 1)) { blockList.put(curBlock, 1 - (offset / dR)); } } - + return blockList; } - + public static ArrayList getInSquare(Block block, double dR) { ArrayList blockList = new ArrayList(); - int iR = (int)dR + 1; - - for (int x=-iR ; x <= iR ; x++) - for (int z=-iR ; z <= iR ; z++) - for (int y=-iR ; y <= iR ; y++) + int iR = (int) dR + 1; + + for (int x = -iR; x <= iR; x++) + for (int z = -iR; z <= iR; z++) + for (int y = -iR; y <= iR; y++) { blockList.add(block.getRelative(x, y, z)); } - + return blockList; } - - public static boolean isBlock(ItemStack item) + + public static boolean isBlock(ItemStack item) { - if (item == null) - return false; - + if (item == null) return false; + return item.getTypeId() > 0 && item.getTypeId() < 256; } - + public static Block getHighest(World world, int x, int z) { return getHighest(world, x, z, null); } - + public static Block getHighest(World world, int x, int z, HashSet ignore) { Block block = world.getHighestBlockAt(x, z); - - //Shuffle Down - while (block.getY() > 0 && - ( - airFoliage(block) || - block.getType() == Material.LEAVES || - block.getType() == Material.LEAVES_2 || - (ignore != null && ignore.contains(block.getType())) - )) + + // Shuffle Down + while (block.getY() > 0 && (airFoliage(block) || block.getType() == Material.LEAVES || block.getType() == Material.LEAVES_2 || (ignore != null && ignore.contains(block.getType())))) { block = block.getRelative(BlockFace.DOWN); } - - return block.getRelative(BlockFace.UP); + + return block.getRelative(BlockFace.UP); } - + /** * * @param location of explosion * @param strength of explosion * @param damageBlocksEqually - Treat all blocks as durability of dirt - * @param ensureDestruction - Ensure that the closest blocks are destroyed at least + * @param ensureDestruction - Ensure that the closest blocks are destroyed + * at least * @return */ public static ArrayList getExplosionBlocks(Location location, float strength, boolean damageBlocksEqually) { ArrayList toExplode = new ArrayList(); WorldServer world = ((CraftWorld) location.getWorld()).getHandle(); - + for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) @@ -483,37 +486,36 @@ public class UtilBlock double d4 = j / (16 - 1.0F) * 2.0F - 1.0F; double d5 = k / (16 - 1.0F) * 2.0F - 1.0F; double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5); - + d3 /= d6; d4 /= d6; d5 /= d6; float f1 = strength * (0.7F + UtilMath.random.nextFloat() * 0.6F); - + double d0 = location.getX(); double d1 = location.getY(); double d2 = location.getZ(); - + for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F) { int l = MathHelper.floor(d0); int i1 = MathHelper.floor(d1); int j1 = MathHelper.floor(d2); Block block = location.getWorld().getBlockAt(l, i1, j1); - + if (block.getType() != Material.AIR) { Blocks.DIRT.a((net.minecraft.server.v1_8_R3.Entity) null); - float f3 = (damageBlocksEqually ? Blocks.DIRT : world.getType(new BlockPosition(block.getX(), block.getY(), - block.getZ())).getBlock()).a((net.minecraft.server.v1_8_R3.Entity) null); - + float f3 = (damageBlocksEqually ? Blocks.DIRT : world.getType(new BlockPosition(block.getX(), block.getY(), block.getZ())).getBlock()).a((net.minecraft.server.v1_8_R3.Entity) null); + f1 -= (f3 + 0.3F) * f2; } - + if ((f1 > 0.0F) && (i1 < 256) && (i1 >= 0)) { toExplode.add(block); } - + d0 += d3 * f2; d1 += d4 * f2; d2 += d5 * f2; @@ -525,20 +527,19 @@ public class UtilBlock return toExplode; } - - public static ArrayList getSurrounding(Block block, boolean diagonals) + + public static ArrayList getSurrounding(Block block, boolean diagonals) { ArrayList blocks = new ArrayList(); - + if (diagonals) { - for (int x=-1 ; x<= 1 ; x++) - for (int y=-1 ; y<= 1 ; y++) - for (int z=-1 ; z<= 1 ; z++) + for (int x = -1; x <= 1; x++) + for (int y = -1; y <= 1; y++) + for (int z = -1; z <= 1; z++) { - if (x == 0 && y == 0 && z == 0) - continue; - + if (x == 0 && y == 0 && z == 0) continue; + blocks.add(block.getRelative(x, y, z)); } } @@ -551,23 +552,24 @@ public class UtilBlock blocks.add(block.getRelative(BlockFace.EAST)); blocks.add(block.getRelative(BlockFace.WEST)); } - + return blocks; } - + public static boolean isVisible(Block block) { for (Block other : UtilBlock.getSurrounding(block, false)) { - if (!other.getType().isOccluding()) + if (!other.getType().isOccluding()) { return true; } } - + return false; } - public static ArrayList getInBoundingBox(Location a, Location b) + + public static ArrayList getInBoundingBox(Location a, Location b) { return getInBoundingBox(a, b, true); } @@ -576,84 +578,93 @@ public class UtilBlock { ArrayList blocks = new ArrayList(); - for (int x=Math.min(a.getBlockX(), b.getBlockX()) ; x<=Math.max(a.getBlockX(), b.getBlockX()) ; x++) - for (int y=Math.min(a.getBlockY(), b.getBlockY()) ; y<=Math.max(a.getBlockY(), b.getBlockY()) ; y++) - for (int z=Math.min(a.getBlockZ(), b.getBlockZ()) ; z<=Math.max(a.getBlockZ(), b.getBlockZ()) ; z++) + for (int x = Math.min(a.getBlockX(), b.getBlockX()); x <= Math.max(a.getBlockX(), b.getBlockX()); x++) + for (int y = Math.min(a.getBlockY(), b.getBlockY()); y <= Math.max(a.getBlockY(), b.getBlockY()); y++) + for (int z = Math.min(a.getBlockZ(), b.getBlockZ()); z <= Math.max(a.getBlockZ(), b.getBlockZ()); z++) { - Block block = a.getWorld().getBlockAt(x,y,z); + Block block = a.getWorld().getBlockAt(x, y, z); - if(ignoreAir) + if (ignoreAir) { - if (block.getType() != Material.AIR) - blocks.add(block); + if (block.getType() != Material.AIR) blocks.add(block); } - else blocks.add(block); + else + blocks.add(block); } - + return blocks; } public static int getStepSoundId(Block block) { - if (block.getTypeId() != 35 && block.getTypeId() != 159 && block.getTypeId() != 160) - return block.getTypeId(); + if (block.getTypeId() != 35 && block.getTypeId() != 159 && block.getTypeId() != 160) return block.getTypeId(); switch (block.getData()) { - case 0: - return block.getTypeId(); - case 1: - return 172; - case 2: - return 87; - case 3: - return 79; - case 4: - return 41; - case 5: - return 133; - case 6: - return 45; - case 7: - return 16; - case 8: - return 13; - case 9: - return 56; - case 10: - return 110; - case 11: - return 22; - case 12: - return 3; - case 13: - return 31; - case 14: - return 152; - case 15: - return 173; - - default: - return block.getTypeId(); + case 0: + return block.getTypeId(); + case 1: + return 172; + case 2: + return 87; + case 3: + return 79; + case 4: + return 41; + case 5: + return 133; + case 6: + return 45; + case 7: + return 16; + case 8: + return 13; + case 9: + return 56; + case 10: + return 110; + case 11: + return 22; + case 12: + return 3; + case 13: + return 31; + case 14: + return 152; + case 15: + return 173; + + default: + return block.getTypeId(); } } /** - * The location specified is the location of the foot block of the bed.

- * ex:

- * placeBed(location[0,0,0], NORTH);

- * will result in two blocks appearing, at location[0,0,0](foot block) and location[0,0,-1](head block (pillow))

- * allowFloating defines whether or not the bed is allowed to float (over water, lava, air, and anything other blocks that do not have bounds)

- * if force is set to true, then the bed will be placed even if there are blocks obstructing it, on the other hand, if force is false, then the bed will only be placed if there is air in the location specified. + * The location specified is the location of the foot block of the bed. + *

+ * ex: + *

+ * placeBed(location[0,0,0], NORTH); + *

+ * will result in two blocks appearing, at location[0,0,0](foot block) and + * location[0,0,-1](head block (pillow)) + *

+ * allowFloating defines whether or not the bed is allowed to float (over + * water, lava, air, and anything other blocks that do not have bounds) + *

+ * if force is set to true, then the bed will be placed even if there are + * blocks obstructing it, on the other hand, if force is false, then the bed + * will only be placed if there is air in the location specified. */ - public static boolean placeBed(Location location, EnumDirection direction, boolean allowFloating, boolean force) + public static boolean placeBed(Location location, BlockFace direction, boolean allowFloating, boolean force) { if (!horizontals.contains(direction)) { return false; } - if (location == null){ + if (location == null) + { return false; } @@ -667,61 +678,127 @@ public class UtilBlock return false; } - int xModif = 0; - int zModif = 0; - byte dirFlag = 0x0; - - if (direction == EnumDirection.NORTH) - { - zModif = -1; - dirFlag = 0x2; - } + BlockState head = location.getBlock().getRelative(direction).getState(); + BlockState foot = location.getBlock().getState(); - if (direction == EnumDirection.EAST) - { - xModif = 1; - dirFlag = 0x3; - } - - if (direction == EnumDirection.SOUTH) - { - zModif = 1; - dirFlag = 0x0; - } - - if (direction == EnumDirection.WEST) - { - xModif = -1; - dirFlag = 0x1; - } - - if (xModif == 0 && zModif == 0) + if (!force && (!head.getType().equals(Material.AIR) || !foot.getType().equals(Material.AIR))) { return false; } - BlockState pillowBlock = location.clone().add(xModif, 0, zModif).getBlock().getState(); - BlockState footBlock = location.getBlock().getState(); + System.out.println("<-bed-> head & foot are air"); - if (!force && (!pillowBlock.getType().equals(Material.AIR) || !footBlock.getType().equals(Material.AIR))) - { - return false; - } + head.setType(Material.BED_BLOCK); + foot.setType(Material.BED_BLOCK); - pillowBlock.setType(Material.BED_BLOCK); - pillowBlock.setRawData((byte) (0x8 | dirFlag)); + Bed bedHead = (Bed) head.getData(); + Bed bedFoot = (Bed) foot.getData(); - footBlock.setType(Material.BED_BLOCK); - footBlock.setRawData(dirFlag); + bedHead.setHeadOfBed(true); + bedFoot.setHeadOfBed(false); - pillowBlock.update(true, false); - footBlock.update(true, false); + bedHead.setFacingDirection(direction); + bedFoot.setFacingDirection(direction); - return pillowBlock.getBlock().getType().equals(Material.BED_BLOCK) && footBlock.getBlock().getType().equals(Material.BED_BLOCK); + head.setData(bedHead); + foot.setData(bedFoot); + head.update(true, false); + foot.update(true, false); + + System.out.println("<-bed-> alls guude"); + + return head.getBlock().getType().equals(Material.BED_BLOCK) && foot.getBlock().getType().equals(Material.BED_BLOCK); } - - public static boolean deleteBed(Location bed) + public static boolean deleteBed(Location loc) + { + if (loc == null) + { + return false; + } + + if (loc.getY() <= 0) + { + return false; + } + + if (!loc.getBlock().getType().equals(Material.BED_BLOCK)) + { + return false; + } + + BlockState head = getBedHead(loc.getBlock()).getState(); + BlockState foot = getBedFoot(loc.getBlock()).getState(); + + head.setType(Material.AIR); + head.setRawData((byte) 0); + + foot.setType(Material.AIR); + foot.setRawData((byte) 0); + + return head.update(true, false) && foot.update(true, false); + } + + private static Block getBedHead(Block bed) + { + if (bed == null) + { + return null; + } + + if (!bed.getType().equals(Material.BED_BLOCK)) + { + return null; + } + + if (getBed(bed).isHeadOfBed()) + { + return bed; + } + else + { + return bed.getRelative(getBed(bed).getFacing()).getType().equals(Material.BED_BLOCK) ? bed.getRelative(getBed(bed).getFacing()) : null; + } + } + + private static Block getBedFoot(Block bed) + { + if (bed == null) + { + return null; + } + + if (!bed.getType().equals(Material.BED_BLOCK)) + { + return null; + } + + if (!getBed(bed).isHeadOfBed()) + { + return bed; + } + else + { + return bed.getRelative(getBed(bed).getFacing().getOppositeFace()).getType().equals(Material.BED_BLOCK) ? bed.getRelative(getBed(bed).getFacing().getOppositeFace()) : null; + } + } + + private static Bed getBed(Block bed) + { + if (bed == null) + { + return null; + } + + if (!bed.getType().equals(Material.BED_BLOCK)) + { + return null; + } + + return (Bed) bed.getState().getData(); + } + + public static boolean isValidBed(Location bed) { if (bed == null) { @@ -738,157 +815,6 @@ public class UtilBlock return false; } - int xModif = 0; - int zModif = 0; - byte data = bed.getBlock().getData(); - - boolean isSpecifiedHead = (data & 0x8) != 0; - Location head = isSpecifiedHead ? bed : null; - Location foot = isSpecifiedHead ? null : bed; - - EnumDirection direction = null; - - if ((data & 0x2) != 0) - { - zModif = -1; - direction = EnumDirection.NORTH; - } - - if ((data & 0x3) != 0) - { - xModif = 1; - direction = EnumDirection.EAST; - } - - if ((data & 0x0) != 0) - { - zModif = 1; - direction = EnumDirection.SOUTH; - } - - if ((data & 0x1) != 0) - { - xModif = -1; - direction = EnumDirection.WEST; - } - - if (xModif == 0 && zModif == 0) - { - return false; - } - - if (head == null) - { - head = foot.clone().add(xModif, 0, zModif); - } - else - { - foot = head.clone().add(xModif, 0, zModif); - } - - if (foot == null && head == null) - { - return false; - } - - head.getBlock().setType(Material.AIR); - head.getBlock().setData((byte) 0); - - foot.getBlock().setType(Material.AIR); - foot.getBlock().setData((byte) 0); - - return true; - } - - /** - * hingeSide: 0 = left, 1 = right

- * open: true if the door should be placed open, false for it to be closed.

- * allowFloating defines whether or not the bed is allowed to float (over water, lava, air, and anything other blocks that do not have bounds)

- * if force is set to true, then the bed will be placed even if there are blocks obstructing it, on the other hand, if force is false, then the bed will only be placed if there is air in the location specified. - */ - public static boolean placeDoor(Location location, EnumDirection direction, DoorType type, int hingeSide, boolean open, boolean allowFloating, boolean force) - { - if (!horizontals.contains(direction)) - { - return false; - } - - if (location.getY() <= 0) - { - return false; - } - - if (!allowFloating && UtilItem.isBoundless(location.getBlock().getType())) - { - return false; - } - - byte topData = 0x8; - byte bottomData = 0; - - if (hingeSide == 1) - { - topData |= 0x1; - } - - switch(direction) - { - case WEST: - bottomData = 0b00; - break; - case NORTH: - bottomData = 0b01; - break; - case EAST: - bottomData = 0b10; - break; - case SOUTH: - bottomData = 0b11; - break; - } - - if (open) - { - bottomData |= 0x4; - } - - BlockState bottom = location.getBlock().getState(); - BlockState top = location.clone().add(0, 1, 0).getBlock().getState(); - - if (force && (!bottom.getType().equals(Material.AIR) && !top.getType().equals(Material.AIR))) - { - return false; - } - - bottom.setType(type.getMaterial()); - top.setType(type.getMaterial()); - - bottom.setRawData(bottomData); - top.setRawData(topData); - - return top.update(true, true) && bottom.update(true, true); - } - - public static enum DoorType - { - OAK(Material.WOOD_DOOR), - SPRUCE(Material.SPRUCE_DOOR), - BIRCH(Material.BIRCH_DOOR), - JUNGLE(Material.JUNGLE_DOOR), - ACACIA(Material.ACACIA_DOOR), - DARK_OAK(Material.DARK_OAK_DOOR), - IRON(Material.IRON_DOOR); - - private Material _material; - - DoorType(Material material) - { - _material = material; - } - - public Material getMaterial() - { - return _material; - } + return getBedHead(bed.getBlock()) != null && getBedFoot(bed.getBlock()) != null; } } diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java index 8f90d8ad1..0a7a56bdc 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilItem.java @@ -41,8 +41,8 @@ public class UtilItem _materials.put(Material.IRON_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON)); _materials.put(Material.IRON_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON)); _materials.put(Material.COAL_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE, ItemCategory.IRON)); - _materials.put(Material.LOG, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD)); - _materials.put(Material.LEAVES, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); + _materials.put(Material.LOG, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD, ItemCategory.LOG)); + _materials.put(Material.LEAVES, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LEAVES)); _materials.put(Material.SPONGE, EnumSet.of(ItemCategory.BLOCK)); _materials.put(Material.GLASS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS)); _materials.put(Material.LAPIS_ORE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.ORE)); @@ -185,8 +185,8 @@ public class UtilItem _materials.put(Material.DROPPER, EnumSet.of(ItemCategory.BLOCK, ItemCategory.GUI)); _materials.put(Material.STAINED_CLAY, EnumSet.of(ItemCategory.BLOCK)); _materials.put(Material.STAINED_GLASS_PANE, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.GLASS)); - _materials.put(Material.LEAVES_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); - _materials.put(Material.LOG_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD)); + _materials.put(Material.LEAVES_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT, ItemCategory.LEAVES)); + _materials.put(Material.LOG_2, EnumSet.of(ItemCategory.BLOCK, ItemCategory.WOOD, ItemCategory.LOG)); _materials.put(Material.ACACIA_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); _materials.put(Material.DARK_OAK_STAIRS, EnumSet.of(ItemCategory.BLOCK, ItemCategory.TRANSLUCENT)); _materials.put(Material.HAY_BLOCK, EnumSet.of(ItemCategory.BLOCK)); @@ -808,6 +808,26 @@ public class UtilItem return isItem(stack == null ? null : stack.getType()); } + public static boolean isLog(Material material) + { + return material == null ? false : (_materials.get(material).contains(ItemCategory.LOG)); + } + + public static boolean isLog(ItemStack stack) + { + return isLog(stack == null ? null : stack.getType()); + } + + public static boolean isLeaf(Material material) + { + return material == null ? false : (_materials.get(material).contains(ItemCategory.LEAVES)); + } + + public static boolean isLeaf(ItemStack stack) + { + return isLeaf(stack == null ? null : stack.getType()); + } + public static boolean isTool(Material material) { return material == null ? false : (_materials.get(material).contains(ItemCategory.TOOL)); @@ -970,7 +990,9 @@ public class UtilItem HOE, ITEM, BLOCK, - ITEM_BLOCK; + ITEM_BLOCK, + LOG, + LEAVES; } public enum ArmorMaterial diff --git a/Plugins/Mineplex.Core/src/mineplex/core/updater/UpdateType.java b/Plugins/Mineplex.Core/src/mineplex/core/updater/UpdateType.java index fd79fc1d2..713d76e92 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/updater/UpdateType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/updater/UpdateType.java @@ -17,6 +17,7 @@ public enum UpdateType MIN_01(60000), SLOWEST(32000), SLOWER(16000), + SEC_08(8000), SLOW(4000), TWOSEC(2000), SEC(1000), diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 24b49ae89..e84d2de09 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -49,65 +49,64 @@ public class Clans extends JavaPlugin { public static final String VERSION = "0.12"; private String WEB_CONFIG = "webServer"; - - //Modules + + // Modules private CoreClientManager _clientManager; private DonationManager _donationManager; private ClansManager _clansManager; - - @Override - public void onEnable() + @Override + public void onEnable() { - //Configs + // Configs getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/"); getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); saveConfig(); String webServerAddress = getConfig().getString(WEB_CONFIG); - - //Logger.initialize(this); - - //Static Modules - CommandCenter.Initialize(this); + + // Logger.initialize(this); + + // Static Modules + CommandCenter.Initialize(this); _clientManager = new CoreClientManager(this, webServerAddress); CommandCenter.Instance.setClientManager(_clientManager); - - ItemStackFactory.Initialize(this, false); + + ItemStackFactory.Initialize(this, false); Recharge.Initialize(this); VisibilityManager.Initialize(this); -// new ProfileCacheManager(this); - + // new ProfileCacheManager(this); + _donationManager = new DonationManager(this, _clientManager, webServerAddress); new ServerConfiguration(this, _clientManager); PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager); - + ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager)); // TODO: Add spawn locations to a configuration file of some sort? new Spawn(this, serverStatusManager.getCurrentServerName()); Give.Initialize(this); - + Teleport teleport = new Teleport(this); Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName()); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion()); - + Punish punish = new Punish(this, webServerAddress, _clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager); AntiHack.Instance.setKick(false); - + BlockRestore blockRestore = new BlockRestore(this); - + IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); - + StatsManager statsManager = new StatsManager(this, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, _donationManager); Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName()); new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); - + new MemoryFix(this); new FoodDupeFix(this); new Explosion(this, blockRestore); @@ -117,7 +116,7 @@ public class Clans extends JavaPlugin // Enable custom-gear related managers PacketHandler packetHandler = new PacketHandler(this); GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager); - + HologramManager hologram = new HologramManager(this); _clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, _clientManager, _donationManager, preferenceManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress); new Recipes(this); @@ -135,14 +134,14 @@ public class Clans extends JavaPlugin ((CraftWorld) world).getHandle().spigotConfig.itemMerge = 0; } - //Updates + // Updates getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); MinecraftServer.getServer().getPropertyManager().setProperty("debug", true); getServer().setWhitelist(false); // TODO: remove } - + public static String prettifyName(Material material) { String name = ""; @@ -156,11 +155,12 @@ public class Clans extends JavaPlugin return name; } - + @Override public void onDisable() { - // Need to notify WorldEventManager of server shutdown, this seemed like the only decent way to do it + // Need to notify WorldEventManager of server shutdown, this seemed like + // the only decent way to do it _clansManager.onDisable(); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java index 838b78202..36aa20305 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClanEnergyTracker.java @@ -12,6 +12,7 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.game.clans.tutorials.types.ClanTips.TipType; public class ClanEnergyTracker extends MiniPlugin { @@ -63,7 +64,7 @@ public class ClanEnergyTracker extends MiniPlugin if (energyBounds != null && energyRemaining > energyBounds.getLeft() && energyRemaining < energyBounds.getMiddle()) { _clans.middleTextClan(clan, energyBounds.getRight()[0], energyBounds.getRight()[1], 20, 200, 80); - _clans.messageClan(clan, F.main("Energy", "To top up your Clan's Energy, head to the shop and go to the Energy Shop!")); + _clans.sendTipToClan(clan, TipType.ENERGY); } } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java index 5c2ea4ad4..b5c775cb4 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAdmin.java @@ -721,7 +721,7 @@ public class ClansAdmin } //Task - Clans.getClanDataAccess().home(clan, caller.getLocation(), caller.getName()); + Clans.getClanDataAccess().setHome(clan, caller.getLocation(), caller.getName()); //Inform UtilPlayer.message(caller, F.main("Clans Admin", "You set Clan Home to " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAlphaManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAlphaManager.java index d5ea39765..df206e60e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAlphaManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansAlphaManager.java @@ -30,7 +30,7 @@ public class ClansAlphaManager extends MiniPlugin private static final int SET_ANNOUNCEMENT = 0; private static final LinkedList FIRST_JOIN_MESSAGES = new LinkedList<>(ANNOUNCEMENTS.getFirst()); - private static final UpdateType ANNOUNCEMENT_DELAY = UpdateType.MIN_30; + private static final UpdateType ANNOUNCEMENT_DELAY = UpdateType.MIN_16; private TaskManager _taskManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java index c26029214..eb627c0ab 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansDataAccessLayer.java @@ -591,7 +591,7 @@ public class ClansDataAccessLayer return unclaim(chunk, null, sql); } - public void home(final ClanInfo clan, Location loc, String player) + public void setHome(final ClanInfo clan, Location loc, String player) { // Memory clan.setHome(loc); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java index 4b8caabaa..d9e8693dd 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansGame.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans; import java.sql.Timestamp; +import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Location; @@ -22,11 +23,13 @@ import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin; @@ -38,13 +41,17 @@ import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.core.repository.ClanTerritory; +import mineplex.game.clans.spawn.Spawn; import mineplex.minecraft.game.core.damage.CustomDamageEvent; import net.minecraft.server.v1_8_R3.EnumDirection; @@ -235,6 +242,11 @@ public class ClansGame extends MiniPlugin UtilPlayer.message(event.getPlayer(), F.main("Clans", "You can not break blocks in " + _clans.getClanUtility().getOwnerStringRel(event.getBlock().getLocation(), event.getPlayer()) + "'s Territory." + mimic)); } + @EventHandler + public void respawn(PlayerRespawnEvent event){ + _clans.getItemMapManager().setMap(event.getPlayer()); + } + @EventHandler(priority = EventPriority.LOW) public void Damage(CustomDamageEvent event) { @@ -482,10 +494,12 @@ public class ClansGame extends MiniPlugin } @EventHandler - public void TURTLEZ(PlayerCommandPreprocessEvent event){ - if (event.getPlayer().getName().equals("SamitoD") && event.getMessage().equals("/gear")){ + public void TURTLEZ(PlayerCommandPreprocessEvent event) + { + if (event.getPlayer().getName().equals("SamitoD") && event.getMessage().equals("/gear")) + { UtilPlayer.message(event.getPlayer(), "UR SPECIAL!!!"); - _clans.getGearManager().openShop(event.getPlayer()); + _clans.getGearManager().openShop(event.getPlayer()); } } @@ -705,4 +719,21 @@ public class ClansGame extends MiniPlugin UtilPlayer.message(player, F.main("Clans", "Only the Clan Leader and Admins can remove the Clan Home.")); } } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.FAST) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + if (player.getGameMode() == GameMode.CREATIVE) + { + return; + } + + UtilInv.removeAll(player, Material.BED, (byte) 0); + } + } + } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index fd44a86bd..3a7e60260 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -35,7 +35,6 @@ import mineplex.core.blockrestore.BlockRestore; import mineplex.core.chat.Chat; import mineplex.core.common.Rank; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayer; @@ -68,7 +67,6 @@ import mineplex.game.clans.clans.event.ClansPlayerDeathEvent; import mineplex.game.clans.clans.gui.ClanShop; import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.map.ItemMapManager; -import mineplex.game.clans.clans.murder.MurderManager; import mineplex.game.clans.clans.observer.ObserverManager; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; @@ -91,7 +89,10 @@ import mineplex.game.clans.gameplay.safelog.SafeLog; import mineplex.game.clans.gameplay.safelog.npc.NPCManager; import mineplex.game.clans.items.GearManager; import mineplex.game.clans.spawn.Spawn; +import mineplex.game.clans.spawn.travel.TravelShop; import mineplex.game.clans.tutorials.TutorialManager; +import mineplex.game.clans.tutorials.types.ClanTips; +import mineplex.game.clans.tutorials.types.ClanTips.TipType; import mineplex.minecraft.game.classcombat.Class.ClassManager; import mineplex.minecraft.game.classcombat.Class.ClientClass; import mineplex.minecraft.game.classcombat.Class.IPvpClass; @@ -109,16 +110,20 @@ import mineplex.minecraft.game.core.fire.Fire; import mineplex.minecraft.game.core.mechanics.Weapon; import mineplex.serverdata.commands.ServerCommandManager; -public class ClansManager extends MiniClientPlugin implements IRelation +public class ClansManager extends MiniClientPluginimplements IRelation { public static final int CLAIMABLE_RADIUS = 800; public static final int WORLD_RADIUS = 1200; private static final TimeZone TIME_ZONE = TimeZone.getDefault(); private static ClansManager _instance; - public static ClansManager getInstance() { return _instance; } - + + public static ClansManager getInstance() + { + return _instance; + } + private String _serverName; - + private CoreClientManager _clientManager; private CombatManager _combatManager; private ClansUtility _clanUtility; @@ -136,12 +141,17 @@ public class ClansManager extends MiniClientPlugin implements IRelat private HologramManager _hologramManager; private GearManager _gearManager; private LootManager _lootManager; + private DonationManager _donationManager; private TutorialManager _tutorialManager; private ClassManager _classManager; - public ClassManager getClassManager() { return _classManager; } - + + public ClassManager getClassManager() + { + return _classManager; + } + private WarManager _warManager; private ProjectileManager _projectileManager; private WorldEventManager _worldEvent; @@ -151,42 +161,48 @@ public class ClansManager extends MiniClientPlugin implements IRelat private NpcManager _npcManager; private Explosion _explosion; private GoldManager _goldManager; - + private int _inviteExpire = 2; private int _nameMin = 3; private int _nameMax = 10; private long _reclaimTime = 1800000; private long _onlineTime = 1200000; - + // Command Shop private ClanShop _clanShop; - - //Clans + + // Clans private NautHashMap _clanMap = new NautHashMap(); - // private NautHashMap _clanMemberNameMap = new NautHashMap(); + // private NautHashMap _clanMemberNameMap = new + // NautHashMap(); private NautHashMap _clanMemberUuidMap = new NautHashMap(); private NautHashMap _claimMap = new NautHashMap(); private NautHashMap _unclaimMap = new NautHashMap(); public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator; - + + public ClanTips ClanTips; + // Spawn area - + public ClansManager(JavaPlugin plugin, String serverName, PacketHandler packetHandler, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress) { super("Clans Manager", plugin); - + _instance = this; + _serverName = serverName; _clientManager = clientManager; _combatManager = new CombatManager(plugin); _hologramManager = hologramManager; - + _chat = chat; _blockRestore = blockRestore; _teleport = teleport; _warManager = new WarManager(plugin, this); - + + _donationManager = donationManager; + _goldManager = new GoldManager(this, _clientManager, donationManager); _gearManager = gearManager; _lootManager = new LootManager(gearManager, _goldManager); @@ -201,8 +217,10 @@ public class ClansManager extends MiniClientPlugin implements IRelat _tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, preferencesManager, this); + ClanTips = new ClanTips(plugin, this, preferencesManager); + _scoreboard = new ClansScoreboardManager(plugin, _tutorialManager, this, _warManager, _worldEvent, clientManager, donationManager); -// new MurderManager(plugin, this); + // new MurderManager(plugin, this); _clanAdmin = new ClansAdmin(this); _clanBlocks = new ClansBlocks(); @@ -213,19 +231,19 @@ public class ClansManager extends MiniClientPlugin implements IRelat _itemMapManager = new ItemMapManager(this, _worldEvent); new TntGeneratorManager(plugin, this); new SupplyDropManager(plugin, this); - + _explosion = new Explosion(plugin, blockRestore); - -// new ClansLoginManager(getPlugin(), clientManager, _serverName); - + + // new ClansLoginManager(getPlugin(), clientManager, _serverName); + _clanShop = new ClanShop(this, clientManager, donationManager); - + Energy energy = new Energy(plugin); // TODO: Re-enable customtagfix with NCP update? - //new CustomTagFix(plugin, packetHandler); - + // new CustomTagFix(plugin, packetHandler); + new Field(plugin, creature, _condition, this, energy, serverName); - + // Required managers to be initialized new Spawn(plugin, this); new NPCManager(this, _hologramManager); @@ -240,11 +258,11 @@ public class ClansManager extends MiniClientPlugin implements IRelat new Gameplay(plugin, this, blockRestore, damageManager); _projectileManager = new ProjectileManager(plugin); Fire fire = new Fire(plugin, _condition, damageManager); - + HashSet itemIgnore = new HashSet(); itemIgnore.add("Proximity Explosive"); itemIgnore.add("Proximity Zapper"); - + ItemFactory itemFactory = new ItemFactory(plugin, blockRestore, _condition, damageManager, energy, fire, _projectileManager, webServerAddress, itemIgnore); SkillFactory skillManager = new SkillFactory(plugin, damageManager, this, _combatManager, _condition, _projectileManager, _disguiseManager, blockRestore, fire, new Movement(plugin), teleport, energy, webServerAddress); skillManager.RemoveSkill("Dwarf Toss", "Block Toss"); @@ -257,37 +275,39 @@ public class ClansManager extends MiniClientPlugin implements IRelat // Register redis based server commands ServerCommandManager.getInstance().registerCommandType(ClanDeleteCommand.class, new ClanDeleteCommandHandler()); ServerCommandManager.getInstance().registerCommandType(ClanLoadCommand.class, new ClanLoadCommandHandler()); - + StatsManager statsManager = new StatsManager(plugin, _clientManager); AchievementManager achievementManager = new AchievementManager(statsManager, _clientManager, donationManager); ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); - + ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager); - + for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) { loadClan(token); } - - //RedisDataRepository(ConnectionData writeConn, ConnectionData readConn, Region region, Class elementType, String elementLabel) - // Initialize default region factions and territory (spawn/fields/borderlands) + + // RedisDataRepository(ConnectionData writeConn, ConnectionData + // readConn, Region region, Class elementType, String elementLabel) + // Initialize default region factions and territory + // (spawn/fields/borderlands) _clanRegions = new ClansRegions(plugin, this); _clanRegions.initializeRegions(); // Disables beds from being crafted Iterator it = _plugin.getServer().recipeIterator(); - Recipe recipe; - while(it.hasNext()) - { - recipe = it.next(); - if (recipe != null && recipe.getResult().getType() == Material.BED) - { - it.remove(); - } - } + Recipe recipe; + while (it.hasNext()) + { + recipe = it.next(); + if (recipe != null && recipe.getResult().getType() == Material.BED) + { + it.remove(); + } + } } - + @Override public void addCommands() { @@ -298,136 +318,140 @@ public class ClansManager extends MiniClientPlugin implements IRelat addCommand(new ClanManagementCommand(this)); addCommand(new MapCommand(this)); } - + public void loadClan(ClanToken clanToken) { ClanInfo clan = new ClanInfo(this, clanToken); _clanMap.put(clanToken.Name, clan); - + for (ClanMemberToken memberToken : clanToken.Members) { _clanMemberUuidMap.put(memberToken.PlayerUUID, clan); -// _clanMemberMap.put(memberToken.Name, clan); + // _clanMemberMap.put(memberToken.Name, clan); } - + for (ClanTerritoryToken territoryToken : clanToken.Territories) _claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken)); } - + public DisguiseManager getDisguiseManager() { return _disguiseManager; } - + public NpcManager getNPCManager() { return _npcManager; } - + public ClansRegions getClanRegions() { return _clanRegions; } - + + public DonationManager getDonationManager() + { + return _donationManager; + } + public ItemMapManager getItemMapManager() { return _itemMapManager; } - + public Explosion getExplosion() { return _explosion; } - + public int getInviteExpire() { return _inviteExpire; } - + public NautHashMap getClanMap() { return _clanMap; } - + public Set getClanNameSet() { return _clanMap.keySet(); } - + public NautHashMap getClanMemberUuidMap() { return _clanMemberUuidMap; } - + public static boolean isClaimable(Location location) { int x = Math.abs(location.getBlockX()); int z = Math.abs(location.getBlockZ()); - - return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS) - && !Spawn.getInstance().isInSpawn(location); + + return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS) && !Spawn.getInstance().isInSpawn(location); } - + public boolean isFields(Location location) { return getClanUtility().isSpecial(location, "Fields"); } - + public boolean canUnclaimChunk(ClanInfo stealer, ClanInfo owner) { - return owner.getClaims() > owner.getClaimsMax() - && !owner.isAdmin() && !owner.isAlly(stealer); + return owner.getClaims() > owner.getClaimsMax() && !owner.isAdmin() && !owner.isAlly(stealer); } - + public ClanInfo getClan(Player player) { return _clanMemberUuidMap.get(player.getUniqueId()); } - + public boolean isInClan(Player player) { return _clanMemberUuidMap.containsKey(player.getUniqueId()); } - + public ClanInfo getClan(String clan) { return _clanMap.get(clan); } - + /** * @param clanName - * @return true, if a Clan with matching {@code clanName} exists, false otherwise. + * @return true, if a Clan with matching {@code clanName} exists, false + * otherwise. */ public boolean clanExists(String clanName) { return getClan(clanName) != null; } - + public NautHashMap getClaimMap() { return _claimMap; } - + public long lastPower = System.currentTimeMillis(); - + @EventHandler public void savePlayerActiveBuild(PlayerQuitEvent event) { if (_classManager.Get(event.getPlayer()) != null && _classManager.Get(event.getPlayer()).GetGameClass() != null) { CustomBuildToken activeBuild = _classManager.Get(event.getPlayer()).GetActiveCustomBuild(_classManager.Get(event.getPlayer()).GetGameClass()); - - if (activeBuild == null) - return; - + + if (activeBuild == null) return; + activeBuild.PlayerName = event.getPlayer().getName(); - - // 0 is set aside for active build so we just dupe build to this row whenever we update it. + + // 0 is set aside for active build so we just dupe build to this row + // whenever we update it. activeBuild.CustomBuildNumber = 0; _classManager.GetRepository().SaveCustomBuild(activeBuild); } } - + @EventHandler public void onPlayerKick(PlayerKickEvent event) { @@ -447,29 +471,27 @@ public class ClansManager extends MiniClientPlugin implements IRelat if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { ItemStack item = event.getPlayer().getItemInHand(); - if (item != null && item.getType() == Material.ENDER_PEARL) - event.setCancelled(true); + if (item != null && item.getType() == Material.ENDER_PEARL) event.setCancelled(true); } } - + @EventHandler(priority = EventPriority.HIGHEST) public void BlockCreatureSpawn(CreatureSpawnCustomEvent event) { ClanInfo clan = _clanUtility.getOwner(event.GetLocation()); - - if (clan != null && !clan.isAdmin() - && !clan.getName().equals("Spawn") && event.getReason() != SpawnReason.CUSTOM) + + if (clan != null && !clan.isAdmin() && !clan.getName().equals("Spawn") && event.getReason() != SpawnReason.CUSTOM) { event.setCancelled(true); } } - + @EventHandler(priority = EventPriority.LOWEST) public void Interact(PlayerInteractEvent event) { getClanGame().Interact(event); } - + @EventHandler public void join(PlayerJoinEvent event) { @@ -480,7 +502,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat clanInfo.playerOnline(player); } } - + @EventHandler public void denyBow(EntityShootBowEvent event) { @@ -495,7 +517,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat } } } - + @EventHandler public void quit(PlayerQuitEvent event) { @@ -506,32 +528,29 @@ public class ClansManager extends MiniClientPlugin implements IRelat clanInfo.playerOffline(player); } } - + @EventHandler public void handlePlayerChat(AsyncPlayerChatEvent event) { - if (event.isCancelled()) - return; - - ClientClan client = Get(event.getPlayer()); - - if (client == null) - return; - + if (event.isCancelled()) return; + + ClientClan client = Get(event.getPlayer()); + + if (client == null) return; + ClanInfo clan = _clanUtility.getClanByPlayer(event.getPlayer()); - + if (client.isClanChat() && clan != null) { event.setFormat(C.cAqua + "%1$s " + C.cDAqua + "%2$s"); event.getRecipients().clear(); - + for (ClansPlayer cur : clan.getMembers().values()) { Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) - continue; - + + if (player == null) continue; + event.getRecipients().add(player); } } @@ -539,29 +558,27 @@ public class ClansManager extends MiniClientPlugin implements IRelat { event.setFormat(C.cDGreen + clan.getName() + " " + C.cDGreen + "%1$s " + C.cGreen + "%2$s"); event.getRecipients().clear(); - + for (ClansPlayer cur : clan.getMembers().values()) { Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) - continue; - + + if (player == null) continue; + event.getRecipients().add(player); } - + for (String allyName : clan.getAllyMap().keySet()) { ClanInfo ally = _clanUtility.getClanByClanName(allyName); - if (ally == null) continue; - + if (ally == null) continue; + for (ClansPlayer cur : ally.getMembers().values()) { Player player = UtilPlayer.searchExact(cur.getUuid()); - - if (player == null) - continue; - + + if (player == null) continue; + event.getRecipients().add(player); } } @@ -573,14 +590,14 @@ public class ClansManager extends MiniClientPlugin implements IRelat event.setFormat(C.cYellow + "%1$s " + C.cWhite + "%2$s"); return; } - + event.getRecipients().clear(); event.setFormat(C.cGold + clan.getName() + " " + C.cYellow + "%1$s " + C.cWhite + "%2$s"); - + for (Player other : UtilServer.getPlayers()) { ClanInfo otherClan = _clanUtility.getClanByPlayer(other); - + if (otherClan == null) { event.getRecipients().add(other); @@ -590,243 +607,255 @@ public class ClansManager extends MiniClientPlugin implements IRelat String message = event.getMessage(); message = _chat.getFilteredMessage(event.getPlayer(), message); ClanRelation rel = _clanUtility.rel(clan, otherClan); - String formatted = rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message; + String formatted = rel.getColor(true) + clan.getName() + " " + _clientManager.Get(event.getPlayer()).GetRank().getTag(true, false) + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message; other.sendMessage(formatted); } } } + + System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).GetRank().getTag(true, false) + " " + event.getPlayer().getName() + " " + event.getMessage()); } - + public void messageClan(ClanInfo clan, String message) { for (Player player : clan.getOnlinePlayers()) + { UtilPlayer.message(player, message); + } } - + + public void sendTipToClan(ClanInfo clan, TipType tip) + { + for (Player player : clan.getOnlinePlayers()) + { + ClanTips.displayTip(tip, player); + } + } + public void middleTextClan(ClanInfo clan, String header, String footer) { middleTextClan(clan, header, footer, 20, 60, 20); } - + public void middleTextClan(ClanInfo clan, String header, String footer, int fadeInTicks, int stayTicks, int fadeOutTicks) { UtilTextMiddle.display(header, footer, fadeInTicks, stayTicks, fadeOutTicks, clan.getOnlinePlayersArray()); } - + public void chatClan(ClanInfo clan, Player caller, String message) { messageClan(clan, C.cAqua + caller.getName() + " " + C.cDAqua + message); } - + public void chatAlly(ClanInfo clan, Player caller, String message) { String sendMessage = C.cDGreen + clan.getName() + " " + C.cDGreen + caller.getName() + " " + C.cGreen + message; - + messageClan(clan, sendMessage); - + for (String allyName : clan.getAllyMap().keySet()) { ClanInfo ally = _clanUtility.getClanByClanName(allyName); - if (ally == null) continue; - + if (ally == null) continue; + messageClan(ally, sendMessage); } } - + public int getNameMin() { return _nameMin; } - + public int getNameMax() { return _nameMax; } - + public long getReclaimTime() { return _reclaimTime; } - + public boolean canHurt(Player a, Player b) { - if (a.equals(b)) - return false; - + if (a.equals(b)) return false; + return _clanUtility.canHurt(a, b); } - + public boolean canHurt(String a, String b) { - if (a.equals(b)) - return false; - + if (a.equals(b)) return false; + return _clanUtility.canHurt(UtilPlayer.searchExact(a), UtilPlayer.searchExact(b)); } - + public boolean isSafe(Player a) { return _clanUtility.isSafe(a); } - -// public ClanRelation getRelation(String playerA, String playerB) -// { -// return getClanUtility().rel(_clanMemberMap.get(playerA), _clanMemberMap.get(playerB)); -// } - + + // public ClanRelation getRelation(String playerA, String playerB) + // { + // return getClanUtility().rel(_clanMemberMap.get(playerA), + // _clanMemberMap.get(playerB)); + // } + public ClanRelation getRelation(Player playerA, Player playerB) { return getRelation(playerA.getUniqueId(), playerB.getUniqueId()); } - + public ClanRelation getRelation(UUID playerA, UUID playerB) { return getClanUtility().rel(getClanMemberUuidMap().get(playerA), getClanMemberUuidMap().get(playerB)); } - - + public long getOnlineTime() { return _onlineTime; } - + public CombatManager getCombatManager() { return _combatManager; } - + public ClansUtility getClanUtility() { return _clanUtility; } - + @Override protected ClientClan AddPlayer(String player) { return new ClientClan(); } - + public BlockRestore getBlockRestore() { return _blockRestore; } - + public ClansDataAccessLayer getClanDataAccess() { return _clanDataAccess; } - + public Teleport getTeleport() { return _teleport; } - + public ClansDisplay getClanDisplay() { return _clanDisplay; } - + public NautHashMap getUnclaimMap() { return _unclaimMap; } - + public ClansAdmin getClanAdmin() { return _clanAdmin; } - + public ClansGame getClanGame() { return _clanGame; } - + public ClansBlocks getClanBlocks() { return _clanBlocks; } - + public String getServerName() { return _serverName; } - + public CoreClientManager getClientManager() { return _clientManager; } - + public ConditionManager getCondition() { return _condition; } - + public ClassCombatShop getClassShop() { return _classShop; } - + public ClanShop getClanShop() { return _clanShop; } - + public WarManager getWarManager() { return _warManager; } - + public ProjectileManager getProjectile() { return _projectileManager; } - + public WorldEventManager getWorldEvent() { return _worldEvent; } - + public HologramManager getHologramManager() { return _hologramManager; } - + public GearManager getGearManager() { return _gearManager; } - + public LootManager getLootManager() { return _lootManager; } - + public Chat getChat() { return _chat; } - + /** - * Get the timezone for this server. - * This may be used in the future if we have - * clans servers with varying timezones. + * Get the timezone for this server. This may be used in the future if we + * have clans servers with varying timezones. + * * @return {@link java.util.TimeZone} that this server should run at */ public TimeZone getServerTimeZone() { return TIME_ZONE; } - + @Override public void disable() { - // Kind of confusing, Clans.java calls this so that we can pass the disable event to WorldEventManager - // This is so that we can prevent any permanent world changes with events + // Kind of confusing, Clans.java calls this so that we can pass the + // disable event to WorldEventManager + // This is so that we can prevent any permanent world changes with + // events _blockRestore.onDisable(); _worldEvent.onDisable(); _goldManager.onDisable(); } - + @EventHandler(priority = EventPriority.HIGHEST) public void onJoin(PlayerLoginEvent event) { @@ -834,7 +863,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat if (!rank.has(Rank.EVENT) && !event.getPlayer().isWhitelisted()) { event.setResult(PlayerLoginEvent.Result.KICK_OTHER); -// event.setKickMessage("This server is whitelisted!"); + // event.setKickMessage("This server is whitelisted!"); event.setKickMessage("Clans is currently in staff only Pre-Alpha!"); } else if (UtilServer.getPlayers().length >= UtilServer.getServer().getMaxPlayers() && !rank.has(Rank.ADMIN) && !event.getPlayer().isWhitelisted()) @@ -843,7 +872,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat event.setKickMessage("Clans Pre-Alpha is full! Try again soon"); } } - + @EventHandler public void openShop(PlayerCommandPreprocessEvent event) { @@ -853,24 +882,24 @@ public class ClansManager extends MiniClientPlugin implements IRelat event.setCancelled(true); } } - + @EventHandler(priority = EventPriority.HIGH) public void handleClansDeath(PlayerDeathEvent event) { PlayerClan playerClan; PlayerClan killerClan = null; - + Player player = event.getEntity(); ClanInfo pClan = _clanMemberUuidMap.get(player.getUniqueId()); playerClan = new PlayerClan(player, pClan); - + if (player.getKiller() != null) { Player killer = player.getKiller(); ClanInfo kClan = _clanMemberUuidMap.get(killer.getUniqueId()); killerClan = new PlayerClan(killer, kClan); } - + ClansPlayerDeathEvent clansPlayerDeathEvent = new ClansPlayerDeathEvent(event, playerClan, killerClan); Bukkit.getServer().getPluginManager().callEvent(clansPlayerDeathEvent); } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java index 520bb7802..070e4dcbb 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansUtility.java @@ -1,13 +1,10 @@ package mineplex.game.clans.clans; -import java.awt.Color; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import java.util.Map.Entry; import java.util.UUID; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Chunk; import org.bukkit.Location; @@ -17,8 +14,6 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilInput; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; @@ -28,10 +23,8 @@ import mineplex.core.recharge.Recharge; import mineplex.game.clans.clans.event.ClanDisbandedEvent; import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; import mineplex.game.clans.core.repository.ClanTerritory; -import mineplex.game.clans.tutorials.TutorialManager; -import mineplex.game.clans.tutorials.types.TutorialGettingStarted; -public class ClansUtility +public class ClansUtility { private ClansManager Clans; @@ -39,7 +32,7 @@ public class ClansUtility { Clans = clans; } - + public enum ClanRelation { SELF(C.xSelf, C.xdSelf), @@ -50,21 +43,21 @@ public class ClansUtility NEUTRAL(C.xNeutral, C.xdNeutral), ADMIN(C.xAdmin, C.xAdmin), SAFE(C.xSafe, C.xSafe); - + private ChatColor _light; private ChatColor _dark; - + ClanRelation(ChatColor light, ChatColor dark) { _light = light; _dark = dark; } - + public String getPrefix() { return _light.toString(); } - + public ChatColor getColor(boolean dark) { return dark ? _dark : _light; @@ -75,8 +68,10 @@ public class ClansUtility * * @param location * @param radius - * @return a 2D array of {@link ClanTerritory} with uniform dimension of ({@code radius} * 2 + 1). The region represented by - * the array of territories is centered on {@code location} chunk with a given chunk {@code radius}. + * @return a 2D array of {@link ClanTerritory} with uniform dimension of ( + * {@code radius} * 2 + 1). The region represented by the array of + * territories is centered on {@code location} chunk with a given + * chunk {@code radius}. */ public List getTerritory(Location location, int radius, ClanInfo surveyorClan) { @@ -84,7 +79,7 @@ public class ClansUtility Chunk chunk = location.getChunk(); int chunkX = chunk.getX(); int chunkZ = chunk.getZ(); - int width = radius*2 + 1; + int width = radius * 2 + 1; List chunks = new ArrayList(); @@ -115,139 +110,119 @@ public class ClansUtility public ClanInfo searchClanPlayer(Player caller, String name, boolean inform) { - //CLAN + // CLAN LinkedList clanMatchList = new LinkedList(); - + for (ClanInfo cur : Clans.getClanMap().values()) { - if (cur.getName().equalsIgnoreCase(name)) - return cur; - - if (cur.getName().toLowerCase().contains(name.toLowerCase())) - clanMatchList.add(cur); + if (cur.getName().equalsIgnoreCase(name)) return cur; + + if (cur.getName().toLowerCase().contains(name.toLowerCase())) clanMatchList.add(cur); } - - if (clanMatchList.size() == 1) - return clanMatchList.get(0); - - //No / Non-Unique + + if (clanMatchList.size() == 1) return clanMatchList.get(0); + + // No / Non-Unique String clanMatchString = "None"; if (clanMatchList.size() > 1) { for (ClanInfo cur : clanMatchList) clanMatchString += cur.getName() + " "; } - - //PLAYER + + // PLAYER LinkedList playerMatchList = new LinkedList(); - + for (ClanInfo clanInfo : Clans.getClanMap().values()) { for (ClansPlayer player : clanInfo.getMembers().values()) { - if (player.getPlayerName().equalsIgnoreCase(name)) - return clanInfo; - - if (player.getPlayerName().toLowerCase().contains(name.toLowerCase())) - playerMatchList.add(clanInfo); - + if (player.getPlayerName().equalsIgnoreCase(name)) return clanInfo; + + if (player.getPlayerName().toLowerCase().contains(name.toLowerCase())) playerMatchList.add(clanInfo); + } } - - if (playerMatchList.size() == 1) - return playerMatchList.get(0); - - //No / Non-Unique + + if (playerMatchList.size() == 1) return playerMatchList.get(0); + + // No / Non-Unique String playerMatchString = "None"; if (playerMatchList.size() > 1) { for (ClanInfo cur : playerMatchList) playerMatchString += cur.getName() + " "; } - + if (inform) { - UtilPlayer.message(caller, F.main("Clan Search", "" + - C.mCount + (clanMatchList.size() + playerMatchList.size()) + - C.mBody + " matches for [" + - C.mElem + name + - C.mBody + "]."), false); - + UtilPlayer.message(caller, F.main("Clan Search", "" + C.mCount + (clanMatchList.size() + playerMatchList.size()) + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."), false); + UtilPlayer.message(caller, F.desc("Matches via Clan", clanMatchString), false); UtilPlayer.message(caller, F.desc("Matches via Player", playerMatchString), false);; } - + return null; } - + public ClanInfo searchClan(Player caller, String name, boolean inform) { LinkedList matchList = new LinkedList(); - + for (ClanInfo cur : Clans.getClanMap().values()) { - if (cur.getName().equalsIgnoreCase(name)) - return cur; - - if (cur.getName().toLowerCase().contains(name.toLowerCase())) - matchList.add(cur); + if (cur.getName().equalsIgnoreCase(name)) return cur; + + if (cur.getName().toLowerCase().contains(name.toLowerCase())) matchList.add(cur); } - - //No / Non-Unique + + // No / Non-Unique if (matchList.size() != 1) { - if (!inform) - return null; - - //Inform - UtilPlayer.message(caller, F.main("Clan Search", "" + - C.mCount + matchList.size() + - C.mBody + " matches for [" + - C.mElem + name + - C.mBody + "]."), false); - + if (!inform) return null; + + // Inform + UtilPlayer.message(caller, F.main("Clan Search", "" + C.mCount + matchList.size() + C.mBody + " matches for [" + C.mElem + name + C.mBody + "]."), false); + if (matchList.size() > 0) { String matchString = ""; for (ClanInfo cur : matchList) matchString += cur.getName() + " "; - - UtilPlayer.message(caller, F.main("Clan Search", "" + - C.mBody + " Matches [" + - C.mElem + matchString + - C.mBody + "]."), false); + + UtilPlayer.message(caller, F.main("Clan Search", "" + C.mBody + " Matches [" + C.mElem + matchString + C.mBody + "]."), false); } - + return null; } - + return matchList.get(0); } - + public ClanInfo getClanByClanName(String clan) { return Clans.getClan(clan); } - + public ClanInfo getClanByPlayer(Player player) { return getClanByUUID(player.getUniqueId()); } - + public ClanInfo getClanByUUID(UUID uuid) { return Clans.getClanMemberUuidMap().get(uuid); } - -// @Deprecated -// public ClanInfo getClanByPlayer(String name) -// { -// if (!Clans.getClanMemberMap().containsKey(name)) -// return null; -// -// return Clans.getClanMemberMap().get(name); -// } - + + // @Deprecated + // public ClanInfo getClanByPlayer(String name) + // { + // if (!Clans.getClanMemberMap().containsKey(name)) + // return null; + // + // return Clans.getClanMemberMap().get(name); + // } + public ClanRole getRole(Player player) { try @@ -257,33 +232,29 @@ public class ClansUtility catch (Exception e) { return ClanRole.NONE; - } + } } - + public boolean isSafe(Player player) { - if (!UtilTime.elapsed(Clans.getCombatManager().Get(player).GetLastDamaged(), 15000)) - return false; - + if (!UtilTime.elapsed(Clans.getCombatManager().Get(player).GetLastDamaged(), 15000)) return false; + return isSafe(player.getLocation()); } - + public boolean isSafe(Location loc) { - if (!Clans.getClaimMap().containsKey(UtilWorld.chunkToStr(loc.getChunk()))) - return false; - + if (!Clans.getClaimMap().containsKey(UtilWorld.chunkToStr(loc.getChunk()))) return false; + return Clans.getClaimMap().get(UtilWorld.chunkToStr(loc.getChunk())).Safe; } - + public boolean isChunkHome(ClanInfo clan, Chunk chunk) { - if (clan == null) - return false; - - if (clan.getHome() == null) - return false; - + if (clan == null) return false; + + if (clan.getHome() == null) return false; + return clan.getHome().getChunk().equals(chunk); } @@ -292,7 +263,7 @@ public class ClansUtility String chunkTag = UtilWorld.chunkToStr(chunk); return Clans.getClaimMap().get(chunkTag); } - + /** * Get formatted name of display as shown for clanB */ @@ -305,32 +276,30 @@ public class ClansUtility { return getClaim(loc.getChunk()); } - + public ClanTerritory getClaim(String chunk) { return Clans.getClaimMap().get(chunk); } - + public ClanInfo getOwner(String chunk) { ClanTerritory claim = getClaim(chunk); - - if (claim == null) - return null; - + + if (claim == null) return null; + return getOwner(claim); } - + public ClanInfo getOwner(Location loc) { ClanTerritory claim = getClaim(loc); - - if (claim != null) - return getOwner(claim); - + + if (claim != null) return getOwner(claim); + return null; } - + public boolean isNearAdminClaim(Location location) { for (int xOffset = -1; xOffset <= 1; xOffset++) @@ -339,9 +308,8 @@ public class ClansUtility { if (xOffset == 0 && zOffset == 0) continue; - String other = UtilWorld.chunkToStr(location.getWorld().getChunkAt( - location.getChunk().getX()+xOffset, location.getChunk().getZ()+zOffset)); - + String other = UtilWorld.chunkToStr(location.getWorld().getChunkAt(location.getChunk().getX() + xOffset, location.getChunk().getZ() + zOffset)); + ClanInfo adjClan = getOwner(other); if (adjClan != null && adjClan.isAdmin() && !adjClan.getName().equalsIgnoreCase("Wilderness")) @@ -358,131 +326,119 @@ public class ClansUtility { return getClanByClanName(claim.Owner); } - + public String getOwnerString(Location loc) { ClanInfo owner = getOwner(loc); - - if (owner == null) - return "Wilderness"; - + + if (owner == null) return "Wilderness"; + return owner.getName(); } - + public String getOwnerStringRel(Location loc, Player player) { ClanRelation rel = relPT(player, UtilWorld.chunkToStr(loc.getChunk())); return mRel(rel, getOwnerString(loc), true); } - + public boolean isClaimed(Location loc) { String chunk = UtilWorld.chunkToStr(loc.getChunk()); - + return Clans.getClaimMap().containsKey(chunk); } - -// public boolean isAlliance(String player, Location loc) -// { -// if (!Clans.getClanMemberMap().containsKey(player)) -// return false; -// -// if (!isClaimed(loc)) -// return false; -// -// return getOwner(getClaim(loc)).isAlly(Clans.getClanMemberMap().get(player).getName()); -// } - + + // public boolean isAlliance(String player, Location loc) + // { + // if (!Clans.getClanMemberMap().containsKey(player)) + // return false; + // + // if (!isClaimed(loc)) + // return false; + // + // return + // getOwner(getClaim(loc)).isAlly(Clans.getClanMemberMap().get(player).getName()); + // } + public boolean isSelf(Player player, Location loc) { ClanInfo clan = Clans.getClan(player); - - if (clan == null) - return false; - - if (!isClaimed(loc)) - return false; - + + if (clan == null) return false; + + if (!isClaimed(loc)) return false; + return getOwner(getClaim(loc)).isSelf(clan.getName()); } - + public boolean isAdmin(Location loc) { - if (!isClaimed(loc)) - return false; - + if (!isClaimed(loc)) return false; + return getOwner(getClaim(loc)).isAdmin(); } - + public boolean isSpecial(Location loc, String special) { - if (!isClaimed(loc)) - return false; - - if (!isAdmin(loc)) - return false; - + if (!isClaimed(loc)) return false; + + if (!isAdmin(loc)) return false; + return getOwner(getClaim(loc)).getName().toLowerCase().contains(special.toLowerCase()); } - + public ClanRelation getAccess(Player player, Location loc) { ClanInfo owner = getOwner(loc); ClanInfo clan = getClanByPlayer(player); - + String mimic = Clans.Get(player).getMimic(); - if (mimic.length() != 0) - clan = Clans.getClanUtility().searchClanPlayer(player, mimic, false); + if (mimic.length() != 0) clan = Clans.getClanUtility().searchClanPlayer(player, mimic, false); + + if (owner == null) return ClanRelation.SELF; + + if (owner.equals(clan)) return ClanRelation.SELF; + + if (clan != null) if (owner.getTrust(clan.getName())) return ClanRelation.ALLY_TRUST; + + if (clan != null) if (owner.isAlly(clan.getName())) return ClanRelation.ALLY; - if (owner == null) - return ClanRelation.SELF; - - if (owner.equals(clan)) - return ClanRelation.SELF; - - if (clan != null) - if (owner.getTrust(clan.getName())) - return ClanRelation.ALLY_TRUST; - - if (clan != null) - if (owner.isAlly(clan.getName())) - return ClanRelation.ALLY; - return ClanRelation.NEUTRAL; } - - //Player Player + + // Player Player public ClanRelation relPP(Player pA, Player pB) { return rel(getClanByPlayer(pA), getClanByPlayer(pB)); } - - //Clan Clan - public ClanRelation relCC(String cA, String cB) + + // Clan Clan + public ClanRelation relCC(String cA, String cB) { return rel(searchClan(null, cA, false), searchClan(null, cB, false)); } - - //Territory Territory - public ClanRelation relTT(String tA, String tB) + + // Territory Territory + public ClanRelation relTT(String tA, String tB) { return rel(getOwner(tA), getOwner(tB)); } - - //Player Clan + + // Player Clan public ClanRelation relPC(Player pA, String cB) { return rel(getClanByPlayer(pA), searchClan(null, cB, false)); } - - //Player Clan (Object) + + // Player Clan (Object) public ClanRelation relPC(Player pA, ClanInfo cB) { return rel(getClanByPlayer(pA), cB); } - - //Player Territory + + // Player Territory public ClanRelation relPT(Player pA, String tB) { ClanTerritory claim = getClaim(tB); @@ -490,124 +446,109 @@ public class ClansUtility { return ClanRelation.SAFE; } - + return rel(getClanByPlayer(pA), getOwner(tB)); } - - //Clan Territory - public ClanRelation relCT(String cA, String tB) + + // Clan Territory + public ClanRelation relCT(String cA, String tB) { ClanTerritory claim = getClaim(tB); - if (claim != null) - if (claim.Safe) - return ClanRelation.SAFE; - + if (claim != null) if (claim.Safe) return ClanRelation.SAFE; + return rel(searchClan(null, cA, false), getOwner(tB)); } - - public ClanRelation rel(ClanInfo cA, ClanInfo cB) + + public ClanRelation rel(ClanInfo cA, ClanInfo cB) { - if (cA == null || cB == null) - return ClanRelation.NEUTRAL; - - //Self - if (cA.isAdmin() || cB.isAdmin()) - return ClanRelation.ADMIN; - - if (cA.getName().equals(cB.getName())) - return ClanRelation.SELF; - - //Ally - if (cA.getTrust(cB.getName())) - return ClanRelation.ALLY_TRUST; - - if (cA.isAlly(cB.getName())) - return ClanRelation.ALLY; - + if (cA == null || cB == null) return ClanRelation.NEUTRAL; + + // Self + if (cA.isAdmin() || cB.isAdmin()) return ClanRelation.ADMIN; + + if (cA.getName().equals(cB.getName())) return ClanRelation.SELF; + + // Ally + if (cA.getTrust(cB.getName())) return ClanRelation.ALLY_TRUST; + + if (cA.isAlly(cB.getName())) return ClanRelation.ALLY; + // War int warPoints = cA.getWarPoints(cB); if (warPoints >= 10) return ClanRelation.WAR_WINNING; - else if (warPoints <= -10) - return ClanRelation.WAR_LOSING; - + else if (warPoints <= -10) return ClanRelation.WAR_LOSING; + return ClanRelation.NEUTRAL; } - + public ChatColor relChatColor(ClanRelation relation, boolean dark) { return relation.getColor(dark); } - + public String relColor(ClanRelation relation, boolean dark) { - if (relation == ClanRelation.SAFE) return C.xAdmin + "(" + C.xSafe + "SAFE" + C.xAdmin + ") "; - + if (relation == ClanRelation.SAFE) return C.xAdmin + "(" + C.xSafe + "SAFE" + C.xAdmin + ") "; + return relChatColor(relation, dark) + ""; } - + public String mRel(ClanRelation relation, String message, boolean dark) { return relColor(relation, dark) + message + C.mChat; } - + public boolean playerSelf(Player pA, Player pB) { ClanInfo cA = getClanByPlayer(pA); ClanInfo cB = getClanByPlayer(pB); - - if (cA == null || cB == null) - return false; - + + if (cA == null || cB == null) return false; + return cA.isSelf(cB.getName()); } - + public boolean playerAlly(Player pA, Player pB) { ClanInfo cA = getClanByPlayer(pA); ClanInfo cB = getClanByPlayer(pB); - - if (cA == null || cB == null) - return false; - + + if (cA == null || cB == null) return false; + return cA.isAlly(cB.getName()); } - + public boolean playerEnemy(Player pA, Player pB) { ClanInfo cA = getClanByPlayer(pA); ClanInfo cB = getClanByPlayer(pB); - - if (cA == null || cB == null) - return true; - + + if (cA == null || cB == null) return true; + return !(cA.isAlly(cB.getName()) || cA.isSelf(cB.getName())); } - + public boolean canHurt(Player damagee, Player damager) { - if (damagee == null || damager == null) - return false; - + if (damagee == null || damager == null) return false; + ClanRelation rel = relPP(damagee, damager); - - if (rel == ClanRelation.ALLY || rel == ClanRelation.ALLY_TRUST || rel == ClanRelation.SELF) - return false; - + + if (rel == ClanRelation.ALLY || rel == ClanRelation.ALLY_TRUST || rel == ClanRelation.SELF) return false; + return true; } - public boolean isBorderlands(Location loc) { return Math.abs(loc.getBlockX()) > ClansManager.CLAIMABLE_RADIUS || Math.abs(loc.getBlockZ()) > ClansManager.CLAIMABLE_RADIUS; } - - + /** * Used for commands */ - + public void join(final Player caller, final ClanInfo clanInfo) { if (Clans.getClanMemberUuidMap().containsKey(caller.getUniqueId())) @@ -615,31 +556,31 @@ public class ClansUtility UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan.")); return; } - + if (!Clans.Get(caller).canJoin()) { UtilPlayer.message(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Clans.Get(caller).getDelay(), 1, UtilTime.TimeUnit.FIT) + C.mBody + ".")); return; } - + if (clanInfo == null) { UtilPlayer.message(caller, F.main("Clans", "Error: Clan does not exist")); return; } - + if (!clanInfo.isInvited(caller.getName())) { UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clanInfo.getName()) + ".")); return; } - + if (clanInfo.getSize() >= clanInfo.getMaxSize()) { UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clanInfo.getName()) + " is full and cannot be joined!")); return; } - + // Task Clans.getClanDataAccess().join(clanInfo, caller, ClanRole.RECRUIT, new Callback() { @@ -658,25 +599,25 @@ public class ClansUtility } } }); - + } - + public void leave(final Player caller) { final ClanInfo clan = getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return; } - + if (clan.getMembers().get(caller.getUniqueId()).getRole() == ClanRole.LEADER && clan.getMembers().size() > 1) { UtilPlayer.message(caller, F.main("Clans", "You must pass on " + F.elem("Leadership") + " before leaving.")); return; } - + // Leave or Delete if (clan.getMembers().size() > 1) { @@ -697,32 +638,32 @@ public class ClansUtility delete(caller); } } - + public void delete(final Player caller) { final ClanInfo clan = getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return; } - + if (getRole(caller) != ClanRole.LEADER) { UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can disband the Clan.")); return; } - + // Event ClanDisbandedEvent event = new ClanDisbandedEvent(clan, caller); UtilServer.getServer().getPluginManager().callEvent(event); - + if (event.isCancelled()) { return; } - + // Task Clans.getClanDataAccess().delete(clan, new Callback() { @@ -741,38 +682,38 @@ public class ClansUtility } }); } - + public boolean claim(Player caller) { ClanInfo clan = getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return false; } - + if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can claim Territory.")); return false; } - + if (!ClansManager.isClaimable(caller.getLocation())) { UtilPlayer.message(caller, F.main("Clans", "You cannot claim territory at this location!")); return false; } - + if (clan.getEnergy() == 0) { UtilPlayer.message(caller, F.main("Clans", "You must purchase energy at a shop before you can claim land.")); return false; } - + String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk()); ClanInfo ownerClan = getOwner(caller.getLocation()); - + // Try to Steal if (ownerClan != null && !ownerClan.equals(clan)) if (unclaimSteal(caller, clan, ownerClan)) { @@ -783,13 +724,14 @@ public class ClansUtility UtilPlayer.message(caller, F.main("Clans", "This Territory is owned by " + mRel(Clans.getClanUtility().relPC(caller, ownerClan), ownerClan.getName(), true) + ".")); return false; } - -// if (clan.getClaims() >= clan.getClaimsMax()) -// { -// UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim more Territory.")); -// return false; -// } - + + // if (clan.getClaims() >= clan.getClaimsMax()) + // { + // UtilPlayer.message(caller, F.main("Clans", "Your Clan cannot claim + // more Territory.")); + // return false; + // } + // Boxed if (checkBox(caller.getLocation().getChunk(), 4)) { @@ -797,27 +739,27 @@ public class ClansUtility UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed.")); return false; } - + // Adjacent boolean selfAdj = false; for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) { if (x == 0 && z == 0) continue; - + String other = UtilWorld.chunkToStr(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z)); - + ClanInfo adjClan = getOwner(other); - + if (adjClan == null) continue; - + if (checkBox(caller.getWorld().getChunkAt(caller.getLocation().getChunk().getX() + x, caller.getLocation().getChunk().getZ() + z), 3)) { UtilPlayer.message(caller, F.main("Clans", "You cannot claim this Territory, it causes a box.")); UtilPlayer.message(caller, F.main("Clans", "This means a Territory has all sides claimed.")); return false; } - + if (rel(clan, adjClan) == ClanRelation.SELF) { selfAdj = true; @@ -828,27 +770,27 @@ public class ClansUtility return false; } } - + if (isNearAdminClaim(caller.getLocation())) { UtilPlayer.message(caller, F.main("Clans", "You cannot claim so close to administrative territory!")); return false; } - + // Not Next to Self if (!selfAdj && !clan.getClaimSet().isEmpty()) { UtilPlayer.message(caller, F.main("Clans", "You must claim next to your other Territory.")); return false; } - + // Claim Timer if (Clans.getUnclaimMap().containsKey(chunk)) { if (!UtilTime.elapsed(Clans.getUnclaimMap().get(chunk), Clans.getReclaimTime())) { UtilPlayer.message(caller, F.main("Clans", "This Territory cannot be claimed for " + F.time(UtilTime.convertString(Clans.getReclaimTime() - (System.currentTimeMillis() - Clans.getUnclaimMap().get(chunk)), 1, UtilTime.TimeUnit.FIT)) + ".")); - + return false; } else @@ -856,31 +798,33 @@ public class ClansUtility Clans.getUnclaimMap().remove(chunk); } } - + // Enemies in Land for (Player cur : UtilServer.getPlayers()) + { if (UtilMath.offset(cur, caller) < 16) if (playerEnemy(caller, cur)) { UtilPlayer.message(caller, F.main("Clans", "You cannot claim while enemies are nearby.")); return false; } - + } + // Recharge if (!Recharge.Instance.use(caller, "Territory Claim", 60000, true, false)) return false; - + // Event - PlayerClaimTerritoryEvent event = new PlayerClaimTerritoryEvent(caller, caller.getLocation().getChunk()); - + PlayerClaimTerritoryEvent event = new PlayerClaimTerritoryEvent(caller, caller.getLocation().getChunk(), clan); + // Task Clans.getClanDataAccess().claim(clan.getName(), chunk, caller.getName(), false); - + // Inform UtilPlayer.message(caller, F.main("Clans", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); clan.inform(F.name(caller.getName()) + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName()); - + return true; } - + public boolean checkBox(Chunk chunk, int req) { int boxed = 0; @@ -888,65 +832,65 @@ public class ClansUtility for (int z = -1; z <= 1; z++) { if (x == 0 && z == 0 || x != 0 && z != 0) continue; - + String other = UtilWorld.chunkToStr(chunk.getWorld().getChunkAt(chunk.getX() + x, chunk.getZ() + z)); - + ClanInfo adjClan = getOwner(other); - + if (adjClan == null) continue; - + boxed++; } - + return (boxed >= req); } - + public boolean unclaimSteal(Player caller, ClanInfo clientClan, ClanInfo ownerClan) { if (!Clans.canUnclaimChunk(clientClan, ownerClan)) { return false; } - + // Change Inform UtilPlayer.message(caller, F.main("Clans", "You can no longer 'steal' territory. " + "You simply unclaim it and it can not be reclaimed by anyone for 30 mintes." + "This was done to improve gameplay. Enjoy!")); - + // Inform UtilServer.broadcast(F.main("Clans", F.elem(clientClan.getName()) + " unclaimed from " + F.elem(ownerClan.getName()) + " at " + F.elem(UtilWorld.locToStrClean(caller.getLocation())) + ".")); - + // Unclaim Clans.getClanDataAccess().unclaim(UtilWorld.chunkToStr(caller.getLocation().getChunk()), caller.getName(), true); - + return true; } - + public void promote(Player caller, String other) { ClanInfo clan = getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return; } - + ClansPlayer self = clan.getMembers().get(caller.getUniqueId()); ClansPlayer target = clan.getClansPlayerFromName(other); - + if (target == null) return; - + if (target.equals(caller.getName())) { UtilPlayer.message(caller, F.main("Clans", "You cannot promote yourself.")); return; } - + if (self.getRole().ordinal() <= target.getRole().ordinal()) { UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } - + // Task String newRank = "?"; if (target.getRole() == ClanRole.RECRUIT) @@ -963,48 +907,48 @@ public class ClansUtility { Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.LEADER); newRank = "Leader"; - + // Give Leader Clans.getClanDataAccess().role(clan, caller.getUniqueId(), ClanRole.ADMIN); } - + // Inform clan.inform(F.name(caller.getName()) + " promoted " + F.name(other) + " to " + F.elem(newRank) + ".", null); } - + public void demote(Player caller, String other) { ClanInfo clan = getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return; } - + ClansPlayer self = clan.getMembers().get(caller.getUniqueId()); ClansPlayer target = clan.getClansPlayerFromName(other); - + if (target == null) return; - + if (target.equals(caller.getName())) { UtilPlayer.message(caller, F.main("Clans", "You cannot demote yourself.")); return; } - + if (self.getRole().ordinal() <= target.getRole().ordinal()) { UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } - + if (target.getRole() == ClanRole.RECRUIT) { UtilPlayer.message(caller, F.main("Clans", "You cannot demote " + F.name(other) + " any further.")); return; } - + // Task String newRank = "?"; if (target.getRole() == ClanRole.MEMBER) @@ -1017,47 +961,47 @@ public class ClansUtility Clans.getClanDataAccess().role(clan, target.getUuid(), ClanRole.MEMBER); newRank = "Member"; } - + // Inform clan.inform(F.main("Clans", F.name(caller.getName()) + " demoted " + F.name(other) + " to " + F.elem(newRank) + "."), null); } - + public void kick(final Player caller, final String other) { final ClanInfo clan = getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return; } - + ClansPlayer self = clan.getMembers().get(caller.getUniqueId()); ClansPlayer clansPlayer = clan.getClansPlayerFromName(other); - + if (self == null || clansPlayer == null) return; - + if (self.getRole() != ClanRole.LEADER && self.getRole() != ClanRole.ADMIN) { UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can kick members.")); return; } - + if (clansPlayer.getRole() == ClanRole.LEADER) { UtilPlayer.message(caller, F.main("Clans", "Clan leaders cannot be kicked.")); UtilPlayer.message(caller, F.main("Clans", "To disband a clan, use /c disband")); return; } - + if ((clansPlayer.getRole() == ClanRole.LEADER && self.getRole() == ClanRole.ADMIN) || (clansPlayer.getRole() == ClanRole.ADMIN && self.getRole() == ClanRole.ADMIN)) { UtilPlayer.message(caller, F.main("Clans", "You do not outrank " + F.name(other) + ".")); return; } - + final Player player = UtilPlayer.searchOnline(null, other, false); - + Callback callback = new Callback() { @Override @@ -1069,73 +1013,73 @@ public class ClansUtility clan.inform(F.main("Clans", F.name(caller.getName()) + " kicked " + F.name(other) + " from your Clan."), caller.getName()); } }; - + // Task if (player != null) Clans.getClanDataAccess().leave(clan, player, callback); else Clans.getClanDataAccess().leave(clan, clansPlayer, callback); } - + public boolean unclaim(final Player caller, final Chunk c) { ClanInfo clan = getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return false; } - + String chunk = UtilWorld.chunkToStr(c); ClanInfo ownerClan = getOwner(caller.getLocation()); - + // Try to Steal if (ownerClan != null && !ownerClan.equals(clan)) if (unclaimSteal(caller, clan, ownerClan)) return true; - + // Role if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER && clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.ADMIN) { UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader and Admins can unclaim Territory.")); return false; } - + // Not Claimed if (ownerClan == null || !ownerClan.equals(clan)) { UtilPlayer.message(caller, F.main("Clans", "This Territory is not owned by you.")); return false; } - + // Task Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true); // Inform UtilPlayer.message(caller, F.main("Clans", "You unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".")); clan.inform(F.name(caller.getName()) + " unclaimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName()); - + return true; } - + public boolean unclaimAll(final Player caller) { ClanInfo clan = getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return false; } - + if (clan.getMembers().get(caller.getUniqueId()).getRole() != ClanRole.LEADER) { UtilPlayer.message(caller, F.main("Clans", "Only the Clan Leader can unclaim all Territory.")); return false; } - + // Unclaim ArrayList toUnclaim = new ArrayList(); - + for (String chunk : clan.getClaimSet()) { toUnclaim.add(chunk); @@ -1149,8 +1093,8 @@ public class ClansUtility // Inform UtilPlayer.message(caller, F.main("Clans", "You unclaimed all your Clans Territory.")); clan.inform(F.name(caller.getName()) + " unclaimed all your Clans Territory.", caller.getName()); - + return true; } - + } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java index 3f7859644..895b2230e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/commands/ClansCommand.java @@ -2,6 +2,7 @@ package mineplex.game.clans.clans.commands; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import mineplex.core.command.CommandBase; @@ -15,7 +16,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; -import mineplex.core.recharge.Recharge; import mineplex.core.common.util.UtilWorld; import mineplex.game.clans.clans.ClanInfo; import mineplex.game.clans.clans.ClanRole; @@ -24,6 +24,7 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClientClan; import mineplex.game.clans.clans.event.ClansCommandExecutedEvent; import mineplex.game.clans.tutorials.TutorialManager; +import mineplex.game.clans.tutorials.types.ClanTips.TipType; import net.minecraft.server.v1_8_R3.EnumDirection; public class ClansCommand extends CommandBase @@ -445,28 +446,28 @@ public class ClansCommand extends CommandBase } final String target = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true); - + _manager.getClanUtility().kick(caller, target); } public void promote(Player caller, String[] args) { ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller); - + if (clan == null) { UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan.")); return; } - + if (args.length < 2) { UtilPlayer.message(caller, F.main("Clans", "You did not input player to promote.")); return; } - + final String targetName = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true); - + _manager.getClanUtility().promote(caller, targetName); } @@ -487,7 +488,7 @@ public class ClansCommand extends CommandBase } final String targetName = UtilPlayer.searchCollection(caller, args[1], clan.getMemberNameSet(), "Clan Member", true); - + _manager.getClanUtility().demote(caller, targetName); } @@ -735,7 +736,7 @@ public class ClansCommand extends CommandBase if (clan.getHome() == null) { - UtilPlayer.message(caller, F.main("Clans", "Your Clan has not set a Home.")); + UtilPlayer.message(caller, F.main("Clans", "Your Clan has not set a Home")); return; } @@ -759,7 +760,7 @@ public class ClansCommand extends CommandBase Location home = clan.getHome(); - if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0,1,0).getBlock().getType().equals(Material.AIR))) + if (!(home.getBlock().getType().equals(Material.BED_BLOCK) && home.add(0, 1, 0).getBlock().getType().equals(Material.AIR)) && home.add(0, 2, 0).getBlock().getType().equals(Material.AIR)) { UtilPlayer.message(caller, F.main("Clans", "Your Clan's bed has been destroyed, or is obstructed.")); return; @@ -775,10 +776,11 @@ public class ClansCommand extends CommandBase * } */ -// if (!Recharge.Instance.use(caller, "Clans Teleport", "Clans Teleport", 300000, true, false, false, false)) return; + // if (!Recharge.Instance.use(caller, "Clans Teleport", "Clans + // Teleport", 300000, true, false, false, false)) return; // Do - Plugin.getTeleport().TP(caller, clan.getHome()); + Plugin.getTeleport().TP(caller, clan.getHome().add(0, 1, 0)); // Inform UtilPlayer.message(caller, F.main("Clans", "You teleported to your Clan Home " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); @@ -812,8 +814,14 @@ public class ClansCommand extends CommandBase return; } + if (!(caller.getLocation().add(0, 1, 0).getBlock().getType().equals(Material.AIR) && caller.getLocation().add(0, 2, 0).getBlock().getType().equals(Material.AIR))) + { + UtilPlayer.message(caller, F.main("Clans", "This is not a suitable place for a bed.")); + return; + } + // Place New - boolean bedPlaced = UtilBlock.placeBed(caller.getLocation(), EnumDirection.fromAngle(caller.getLocation().getYaw()), false, false); + boolean bedPlaced = UtilBlock.placeBed(caller.getLocation(), BlockFace.valueOf(EnumDirection.fromAngle(caller.getLocation().getYaw()).name()), false, false); if (!bedPlaced) { @@ -824,11 +832,13 @@ public class ClansCommand extends CommandBase // Cleanup old if (clan.getHome() != null) { - System.out.println("OLD CLEANUP: " + UtilBlock.deleteBed(clan.getHome())); + System.out.println("<-old bed cleanup-> <--> " + UtilBlock.deleteBed(clan.getHome())); } // Task - Plugin.getClanDataAccess().home(clan, caller.getLocation(), caller.getName()); + Plugin.getClanDataAccess().setHome(clan, caller.getLocation(), caller.getName()); + + Plugin.ClanTips.displayTip(TipType.SETHOME, caller); // Inform UtilPlayer.message(caller, F.main("Clans", "You set Clan Home to " + UtilWorld.locToStrClean(caller.getLocation()) + ".")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/DominanceChangeData.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/DominanceChangeData.java deleted file mode 100644 index 482e1da8f..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/DominanceChangeData.java +++ /dev/null @@ -1,33 +0,0 @@ -package mineplex.game.clans.clans.event; - -import org.bukkit.entity.Player; - -public class DominanceChangeData -{ - public Player _player; - public int _oldDominance; - public int _newDominance; - - public DominanceChangeData(Player player, int oldDominance, int newDominance) - { - _player = player; - _oldDominance = oldDominance; - _newDominance = newDominance; - } - - public int getOldDominance() - { - return _oldDominance; - } - - public int getNewDominance() - { - return _newDominance; - } - - public Player getPlayer() - { - return _player; - } - -} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/DominanceChangeEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/DominanceChangeEvent.java deleted file mode 100644 index ca0c9e80a..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/DominanceChangeEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -package mineplex.game.clans.clans.event; - -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; - -public class DominanceChangeEvent extends Event -{ - private static final HandlerList handlers = new HandlerList(); - - private DominanceChangeData _victimData; - private DominanceChangeData _killerData; - - public DominanceChangeEvent(DominanceChangeData victimData, DominanceChangeData killerData) - { - _victimData = victimData; - _killerData = killerData; - } - - public DominanceChangeData getVictimData() - { - return _victimData; - } - - public DominanceChangeData getKillerData() - { - return _killerData; - } - - public HandlerList getHandlers() - { - return handlers; - } - - public static HandlerList getHandlerList() - { - return handlers; - } - -} \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerClaimTerritoryEvent.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerClaimTerritoryEvent.java index f198fa14c..35fc5eaf5 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerClaimTerritoryEvent.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/event/PlayerClaimTerritoryEvent.java @@ -5,6 +5,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; +import mineplex.game.clans.clans.ClanInfo; + public class PlayerClaimTerritoryEvent extends Event { private static final HandlerList handlers = new HandlerList(); @@ -13,11 +15,14 @@ public class PlayerClaimTerritoryEvent extends Event private Chunk _claimedChunk; private boolean _cancelled; + + private ClanInfo _clan; - public PlayerClaimTerritoryEvent(Player claimer, Chunk claimedChunk) + public PlayerClaimTerritoryEvent(Player claimer, Chunk claimedChunk, ClanInfo clan) { _claimer = claimer; _claimedChunk = claimedChunk; + _clan = clan; } public Player getClaimer() @@ -25,6 +30,11 @@ public class PlayerClaimTerritoryEvent extends Event return _claimer; } + public ClanInfo getClan() + { + return _clan; + } + public Chunk getClaimedChunk() { return _claimedChunk; @@ -49,5 +59,5 @@ public class PlayerClaimTerritoryEvent extends Event { return handlers; } - + } \ No newline at end of file diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java index 244866b41..cf44fc3ff 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/gui/page/ClanMainPage.java @@ -304,6 +304,7 @@ public class ClanMainPage extends ClanPageBase private void addPlayerButton(int slot, ClansPlayer clansPlayer, ClanInfo guiInfo, ClanRole guiRole) { + ClanRole playerRole = clansPlayer.getRole(); String itemName = (clansPlayer.isOnline() ? C.cGreenB : C.cRedB) + clansPlayer.getPlayerName(); ArrayList lore = new ArrayList(5); lore.add(" "); @@ -323,9 +324,21 @@ public class ClanMainPage extends ClanPageBase if (guiRole.has(ClanRole.ADMIN)) { lore.add(" "); - lore.add(ChatColor.RESET + C.cYellow + "Left Click " + C.cWhite + "Promote"); - lore.add(ChatColor.RESET + C.cYellow + "Right Click " + C.cWhite + "Demote"); - lore.add(ChatColor.RESET + C.cYellow + "Shift-Right Click " + C.cWhite + "Kick"); + + if (!playerRole.has(ClanRole.LEADER) && guiRole.has(playerRole)) + { + lore.add(ChatColor.RESET + C.cYellow + "Left Click " + C.cWhite + "Promote"); + } + + if (!playerRole.has(ClanRole.LEADER) && guiRole.has(playerRole)) + { + lore.add(ChatColor.RESET + C.cYellow + "Right Click " + C.cWhite + "Demote"); + } + + if (!playerRole.has(ClanRole.LEADER)) + { + lore.add(ChatColor.RESET + C.cYellow + "Shift-Right Click " + C.cWhite + "Kick"); + } } ItemStack item = UtilSkull.getPlayerHead(clansPlayer.isOnline() ? clansPlayer.getPlayerName() : "", itemName, lore); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java index bf05cbf1f..f8db3fac2 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/war/WarManager.java @@ -33,7 +33,7 @@ import mineplex.game.clans.clans.war.command.WarPointsCommand; import mineplex.game.clans.clans.war.event.WarInvasionEndEvent; import mineplex.game.clans.clans.war.event.WarInvasionStartEvent; import mineplex.game.clans.core.war.ClanWarData; -import org.omg.CORBA.DynAnyPackage.InvalidSeq; +import mineplex.game.clans.tutorials.types.ClanTips.TipType; public class WarManager extends MiniPlugin implements ScoreboardElement { @@ -139,6 +139,9 @@ public class WarManager extends MiniPlugin implements ScoreboardElement ClanInfo clanA = clan.getName().equals(war.getClanA()) ? clan : killerClan; ClanInfo clanB = clan.equals(clanA) ? killerClan : clan; _clansManager.getClanDataAccess().updateWar(clanA, clanB, war, null); + + _clansManager.ClanTips.displayTip(TipType.DOMINANCE_RIP, event.getPlayer().getPlayer()); + _clansManager.ClanTips.displayTip(TipType.DOMINANCE_NOOICE, event.getKiller().getPlayer()); } else { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java index 7d87361c1..e6a8d6ca1 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/worldevent/undead/CampSize.java @@ -4,11 +4,11 @@ import mineplex.core.common.util.UtilMath; public enum CampSize { - SMALL("Small Camp", 15, 0, 1), + SMALL("Undead Outpost", 15, 0, 1), - MEDIUM("Medium Camp", 20, 10, 2), + MEDIUM("Undead Village", 20, 10, 2), - LARGE("Large Camp", 30, 20, 3); + LARGE("Undead City", 30, 20, 3); // Base Values private static final int HUT_MIN = 4; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java index ad8a9d59e..afb91ab7d 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/gameplay/Gameplay.java @@ -43,10 +43,12 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.MiniPlugin; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; @@ -68,14 +70,15 @@ public class Gameplay extends MiniPlugin private ClansManager _clansManager; private BlockRestore _blockRestore; private DamageManager _damageManager; - private WeightSet _foodDecrease; // Weighted probability sets for food decrease event outcomes + private WeightSet _foodDecrease; // Weighted probability sets for + // food decrease event outcomes private Map _bucketWater = new HashMap(); - - public Gameplay(JavaPlugin plugin, ClansManager clansManager, BlockRestore blockRestore, DamageManager damageManager) + + public Gameplay(JavaPlugin plugin, ClansManager clansManager, BlockRestore blockRestore, DamageManager damageManager) { super("PvP Gameplay", plugin); - + _clansManager = clansManager; _blockRestore = blockRestore; _damageManager = damageManager; @@ -93,7 +96,7 @@ public class Gameplay extends MiniPlugin if (state == State.CAUGHT_ENTITY || state == State.CAUGHT_FISH) { event.setCancelled(true); - notify(event.getPlayer(), "Fishing is disabled!"); + notify(event.getPlayer(), "Fishing is disabled!"); } } @@ -127,37 +130,40 @@ public class Gameplay extends MiniPlugin public void BucketEmpty(PlayerBucketEmptyEvent event) { event.setCancelled(true); - + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - + if (event.getBucket() == Material.WATER_BUCKET) { - block.setTypeIdAndData(8, (byte)1, true); + block.setTypeIdAndData(8, (byte) 1, true); _blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 8, (byte) 0, 1000); _bucketWater.put(block, System.currentTimeMillis()); } - + if (event.getBucket() == Material.LAVA_BUCKET) { - block.setTypeIdAndData(10, (byte)6, true); + block.setTypeIdAndData(10, (byte) 6, true); _blockRestore.add(event.getBlockClicked().getRelative(event.getBlockFace()), 10, (byte) 0, 2000); } - - - event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.BUCKET)); + + event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.BUCKET)); UtilInv.Update(event.getPlayer()); } - + /** - * Decreases the hunger rate decrease speed by arbitrarily canceling a portion of decrease events. + * Decreases the hunger rate decrease speed by arbitrarily canceling a + * portion of decrease events. + * * @param event */ - @EventHandler(ignoreCancelled=true) + @EventHandler(ignoreCancelled = true) public void foodChangeLevel(FoodLevelChangeEvent event) { Player player = (Player) event.getEntity(); - if (event.getFoodLevel() < player.getFoodLevel()) // Hunger is decreasing for player + if (event.getFoodLevel() < player.getFoodLevel()) // Hunger is + // decreasing for + // player { event.setCancelled(_foodDecrease.generateRandom()); } @@ -167,30 +173,26 @@ public class Gameplay extends MiniPlugin public void BucketFill(PlayerBucketFillEvent event) { event.setCancelled(true); - - if (event.getItemStack().getType() == Material.WATER_BUCKET) - if (!_bucketWater.containsKey(event.getBlockClicked())) - event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.WATER_BUCKET)); - + + if (event.getItemStack().getType() == Material.WATER_BUCKET) if (!_bucketWater.containsKey(event.getBlockClicked())) event.getPlayer().setItemInHand(ItemStackFactory.Instance.CreateStack(Material.WATER_BUCKET)); + UtilInv.Update(event.getPlayer()); } - + @EventHandler public void BucketWaterExpire(UpdateEvent event) { - if (event.getType() != UpdateType.FAST) - return; - + if (event.getType() != UpdateType.FAST) return; + HashSet remove = new HashSet(); - + for (Block cur : _bucketWater.keySet()) - if (UtilTime.elapsed(_bucketWater.get(cur), 2000)) - remove.add(cur); - + if (UtilTime.elapsed(_bucketWater.get(cur), 2000)) remove.add(cur); + for (Block cur : remove) _bucketWater.remove(cur); } - + @EventHandler(priority = EventPriority.LOWEST) public void ObsidianCancel(BlockPlaceEvent event) { @@ -204,9 +206,7 @@ public class Gameplay extends MiniPlugin @EventHandler(priority = EventPriority.LOWEST) public void CommandPlace(BlockPlaceEvent event) { - if (event.getBlock().getType() == Material.COMMAND || - event.getBlock().getType() == Material.NOTE_BLOCK || - event.getBlock().getType() == Material.REDSTONE_LAMP_ON) + if (event.getBlock().getType() == Material.COMMAND || event.getBlock().getType() == Material.NOTE_BLOCK || event.getBlock().getType() == Material.REDSTONE_LAMP_ON) { UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.item("Proximity Devices") + ".")); event.setCancelled(true); @@ -225,20 +225,22 @@ public class Gameplay extends MiniPlugin /** * Disable all Piston related events in Clans + * * @param event */ @EventHandler - public void onPistonExtend(BlockPistonExtendEvent event) + public void onPistonExtend(BlockPistonExtendEvent event) { event.setCancelled(true); } /** * Disable all Piston related events in Clans + * * @param event */ @EventHandler - public void onPistonRetract(BlockPistonRetractEvent event) + public void onPistonRetract(BlockPistonRetractEvent event) { event.setCancelled(true); } @@ -248,8 +250,7 @@ public class Gameplay extends MiniPlugin { Material material = event.getItem().getType(); - if (material == Material.LAVA_BUCKET || material == Material.LAVA - || material == Material.WATER_BUCKET || material == Material.WATER) + if (material == Material.LAVA_BUCKET || material == Material.LAVA || material == Material.WATER_BUCKET || material == Material.WATER) { event.setCancelled(true); } @@ -258,25 +259,21 @@ public class Gameplay extends MiniPlugin @EventHandler public void WebBreak(BlockDamageEvent event) { - if (event.isCancelled()) - return; - - if (event.getBlock().getType() == Material.WEB) - event.setInstaBreak(true); + if (event.isCancelled()) return; + + if (event.getBlock().getType() == Material.WEB) event.setInstaBreak(true); } - + @EventHandler public void LapisPlace(BlockPlaceEvent event) { - if (event.isCancelled()) - return; - - if (event.getBlock().getType() != Material.LAPIS_BLOCK) - return; + if (event.isCancelled()) return; - event.setCancelled(true); + if (event.getBlock().getType() != Material.LAPIS_BLOCK) return; - UtilInv.remove(event.getPlayer(), Material.LAPIS_BLOCK, (byte)0, 1); + event.setCancelled(true); + + UtilInv.remove(event.getPlayer(), Material.LAPIS_BLOCK, (byte) 0, 1); final Block block = event.getBlock(); @@ -285,7 +282,7 @@ public class Gameplay extends MiniPlugin public void run() { block.setType(Material.WATER); - block.setData((byte)0); + block.setData((byte) 0); block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, 8); block.getWorld().playSound(block.getLocation(), Sound.SPLASH, 2f, 1f); } @@ -295,23 +292,20 @@ public class Gameplay extends MiniPlugin @EventHandler public void EnderChestBreak(BlockBreakEvent event) { - if (event.isCancelled()) - return; + if (event.isCancelled()) return; + + if (event.getBlock().getType() != Material.ENDER_CHEST) return; - if (event.getBlock().getType() != Material.ENDER_CHEST) - return; - event.setCancelled(true); event.getBlock().setTypeId(0); event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation().add(0.5, 0.5, 0.5), ItemStackFactory.Instance.CreateStack(Material.ENDER_CHEST)); } - + @EventHandler public void disableEnderPearls(PlayerInteractEvent event) { - if (!isRightClick(event.getAction())) - return; + if (!isRightClick(event.getAction())) return; if (event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) { @@ -323,8 +317,7 @@ public class Gameplay extends MiniPlugin @EventHandler public void disableFlintNSteel(PlayerInteractEvent event) { - if (!isRightClick(event.getAction())) - return; + if (!isRightClick(event.getAction())) return; if (event.hasItem() && event.getItem().getType() == Material.FLINT_AND_STEEL) { @@ -335,52 +328,48 @@ public class Gameplay extends MiniPlugin private static boolean isRightClick(Action action) { - return action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK; + return action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK; } @EventHandler public void IronDoor(PlayerInteractEvent event) { - if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) - return; - - if (event.getClickedBlock().getTypeId() != 71) - return; - + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return; + + if (event.getClickedBlock().getTypeId() != 71) return; + Block block = event.getClickedBlock(); - - //Knock + + // Knock if (event.isCancelled()) { - if (!Recharge.Instance.use(event.getPlayer(), "Door Knock", 500, false, false)) - return; - + if (!Recharge.Instance.use(event.getPlayer(), "Door Knock", 500, false, false)) return; + block.getWorld().playEffect(block.getLocation(), Effect.ZOMBIE_CHEW_WOODEN_DOOR, 0); } - - //Open + + // Open else { - if (block.getData() >= 8) - block = block.getRelative(BlockFace.DOWN); - - if (block.getData() < 4) block.setData((byte)(block.getData()+4), true); - else block.setData((byte)(block.getData()-4), true); - - //Effect + if (block.getData() >= 8) block = block.getRelative(BlockFace.DOWN); + + if (block.getData() < 4) + block.setData((byte) (block.getData() + 4), true); + else + block.setData((byte) (block.getData() - 4), true); + + // Effect block.getWorld().playEffect(block.getLocation(), Effect.DOOR_TOGGLE, 0); } } - + @EventHandler public void BrewingDisable(PlayerInteractEvent event) { - if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) - return; - - if (event.getClickedBlock().getTypeId() != 117) - return; - + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return; + + if (event.getClickedBlock().getTypeId() != 117) return; + event.setCancelled(true); } @@ -389,172 +378,183 @@ public class Gameplay extends MiniPlugin { Player player = event.getPlayer(); - if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return; - else if (event.getClickedBlock().getType() != Material.ANVIL) return; + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + return; + else if (event.getClickedBlock().getType() != Material.ANVIL) + return; else if (player.isSneaking() && player.getItemInHand().getType() != Material.AIR) return; event.setCancelled(true); } - + @EventHandler public void BonemealCancel(PlayerInteractEvent event) - { - if (!UtilEvent.isAction(event, ActionType.R)) - return; - + { + if (!UtilEvent.isAction(event, ActionType.R)) return; + Player player = event.getPlayer(); - - if (player.getItemInHand() == null) - return; - - if (player.getItemInHand().getType() != Material.INK_SACK) - return; - - if (player.getItemInHand().getData() == null) - return; - - if (player.getItemInHand().getData().getData() != 15) - return; - + + if (player.getItemInHand() == null) return; + + if (player.getItemInHand().getType() != Material.INK_SACK) return; + + if (player.getItemInHand().getData() == null) return; + + if (player.getItemInHand().getData().getData() != 15) return; + event.setCancelled(true); } + @EventHandler(priority = EventPriority.LOWEST) + public void replantTree(BlockBreakEvent event) + { + Block block = event.getBlock(); + + if (!UtilItem.isLog(block.getType())) + { + return; + } + + if (UtilItem.isLog(block.getRelative(BlockFace.DOWN).getType())) + { + return; + } + + if (UtilItem.isLeaf(block.getRelative(BlockFace.DOWN).getType())) + { + return; + } + + if (block.getRelative(BlockFace.DOWN).getType() != Material.DIRT && block.getRelative(BlockFace.DOWN).getType() != Material.GRASS) + { + return; + } + + Location saplingArea = null; + + for (Block otherBlock : UtilBlock.getInRadius(event.getBlock().getLocation(), 4.5).keySet()) + { + if (!otherBlock.equals(UtilBlock.getHighest(otherBlock.getLocation().getWorld(), otherBlock.getX(), otherBlock.getZ()))) + { + saplingArea = otherBlock.getLocation(); + if (Math.random() > .75) + { + break; + } + } + } + + saplingArea.add(0, 1, 0).getBlock().setType(Material.SAPLING); + saplingArea.getBlock().setData(block.getData()); + } + @EventHandler public void WildfireSpread(BlockBurnEvent event) { - if (event.isCancelled()) - return; + if (event.isCancelled()) return; event.setCancelled(true); - for (int x=-1 ; x<=1 ; x++) - for (int y=-1 ; y<=1 ; y++) - for (int z=-1 ; z<=1 ; z++) + for (int x = -1; x <= 1; x++) + for (int y = -1; y <= 1; y++) + for (int z = -1; z <= 1; z++) { - //Self + // Self if (x == 0 && y == 0 && z == 0) { event.getBlock().setType(Material.FIRE); - if (event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.GRASS) - event.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT); + if (event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.GRASS) event.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT); return; } Block block = event.getBlock().getRelative(x, y, z); - if (block.getRelative(BlockFace.DOWN).getType() == Material.GRASS) - block.getRelative(BlockFace.DOWN).setType(Material.DIRT); + if (block.getRelative(BlockFace.DOWN).getType() == Material.GRASS) block.getRelative(BlockFace.DOWN).setType(Material.DIRT); - //Surroundings - if (!( - (x == 0 && y == 0) || - (x == 0 && z == 0) || - (y == 0 && z == 0) - )) - continue; - - if (block.getTypeId() == 0) - block.setType(Material.FIRE); + // Surroundings + if (!((x == 0 && y == 0) || (x == 0 && z == 0) || (y == 0 && z == 0))) continue; + + if (block.getTypeId() == 0) block.setType(Material.FIRE); } } @EventHandler public void WildfireDirt(BlockIgniteEvent event) { - if (event.isCancelled()) - return; + if (event.isCancelled()) return; - if (event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.GRASS) - event.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT); + if (event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.GRASS) event.getBlock().getRelative(BlockFace.DOWN).setType(Material.DIRT); } @EventHandler(priority = EventPriority.LOW) public void WildfireCancel(BlockIgniteEvent event) { - if (event.isCancelled()) - return; + if (event.isCancelled()) return; - if (event.getBlock().getBiome() == Biome.JUNGLE || event.getBlock().getBiome() == Biome.JUNGLE_HILLS) - if (event.getCause() == IgniteCause.SPREAD) - event.setCancelled(true); + if (event.getBlock().getBiome() == Biome.JUNGLE || event.getBlock().getBiome() == Biome.JUNGLE_HILLS) if (event.getCause() == IgniteCause.SPREAD) event.setCancelled(true); } -// @EventHandler -// public void onBlockPlace(BlockPlaceEvent event) -// { -// Location location = event.getBlock().getLocation(); -// -// if (_clansManager.getClanUtility().isNearAdminClaim(location)) -// { -// event.setCancelled(true); -// UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot place blocks near admin territories!")); -// } -// } -// -// @EventHandler -// public void onBlockBreak(BlockBreakEvent event) -// { -// Location location = event.getBlock().getLocation(); -// -// if (_clansManager.getClanUtility().isNearAdminClaim(location)) -// { -// event.setCancelled(true); -// UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot break blocks near admin territories!")); -// } -// } + // @EventHandler + // public void onBlockPlace(BlockPlaceEvent event) + // { + // Location location = event.getBlock().getLocation(); + // + // if (_clansManager.getClanUtility().isNearAdminClaim(location)) + // { + // event.setCancelled(true); + // UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot place + // blocks near admin territories!")); + // } + // } + // + // @EventHandler + // public void onBlockBreak(BlockBreakEvent event) + // { + // Location location = event.getBlock().getLocation(); + // + // if (_clansManager.getClanUtility().isNearAdminClaim(location)) + // { + // event.setCancelled(true); + // UtilPlayer.message(event.getPlayer(), F.main("Admin", "You cannot break + // blocks near admin territories!")); + // } + // } /* - @EventHandler (priority = EventPriority.HIGHEST) - public void MoneyLossSteal(CombatDeathEvent event) - { - if (!(event.GetEvent().getEntity() instanceof Player)) - return; - - Player player = (Player)event.GetEvent().getEntity(); - - int balance = Clients().Get(player).Game().GetEconomyBalance(); - - int lose = (int) (0.04 * balance); - - //Balance - Clients().Get(player).Game().SetEconomyBalance(balance - lose); - - CombatLog log = event.GetLog(); - if (log.GetKiller() != null) - { - //Inform - UtilPlayer.message(UtilPlayer.searchExact(log.GetKiller().getName()), F.main("Death", "You stole " + F.count((lose) + " Coins") + " from " + F.name(player.getName()) + ".")); - - //Inform - UtilPlayer.message(player, F.main("Death", "You lost " + F.count((lose) + " Coins") + " to " + F.name(log.GetKiller().getName()) + ".")); - } - else - { - //Inform - UtilPlayer.message(player, F.main("Death", "You lost " + F.count((lose) + " Coins") + " for dying.")); - } - } - */ + * @EventHandler (priority = EventPriority.HIGHEST) public void + * MoneyLossSteal(CombatDeathEvent event) { if + * (!(event.GetEvent().getEntity() instanceof Player)) return; Player player + * = (Player)event.GetEvent().getEntity(); int balance = + * Clients().Get(player).Game().GetEconomyBalance(); int lose = (int) (0.04 + * * balance); //Balance + * Clients().Get(player).Game().SetEconomyBalance(balance - lose); CombatLog + * log = event.GetLog(); if (log.GetKiller() != null) { //Inform + * UtilPlayer.message(UtilPlayer.searchExact(log.GetKiller().getName()), + * F.main("Death", "You stole " + F.count((lose) + " Coins") + " from " + + * F.name(player.getName()) + ".")); //Inform UtilPlayer.message(player, + * F.main("Death", "You lost " + F.count((lose) + " Coins") + " to " + + * F.name(log.GetKiller().getName()) + ".")); } else { //Inform + * UtilPlayer.message(player, F.main("Death", "You lost " + F.count((lose) + + * " Coins") + " for dying.")); } } + */ @EventHandler public void SpawnDamage(CustomDamageEvent event) { - if (event.IsCancelled()) - return; - - if (event.GetCause() != DamageCause.FALL) - return; - - if (!_clansManager.getClanUtility().isSpecial(event.GetDamageeEntity().getLocation(), "Spawn")) - return; - + if (event.IsCancelled()) return; + + if (event.GetCause() != DamageCause.FALL) return; + + if (!_clansManager.getClanUtility().isSpecial(event.GetDamageeEntity().getLocation(), "Spawn")) return; + event.SetCancelled("Spawn Fall"); } - + /** * Cancel the spawning of all Witches. + * * @param event */ @EventHandler @@ -571,11 +571,7 @@ public class Gameplay extends MiniPlugin { Player player = event.getPlayer(); - if (event.getClickedBlock() == null - || event.getClickedBlock().getType() != Material.ANVIL - || !UtilEvent.isAction(event, ActionType.R_BLOCK) - || player.isSneaking() - || player.getItemInHand().getType() == Material.AIR) + if (event.getClickedBlock() == null || event.getClickedBlock().getType() != Material.ANVIL || !UtilEvent.isAction(event, ActionType.R_BLOCK) || player.isSneaking() || player.getItemInHand().getType() == Material.AIR) { return; } @@ -585,7 +581,7 @@ public class Gameplay extends MiniPlugin UtilPlayer.message(player, F.main("Repair", "You are too far from the " + F.item("Anvil") + ".")); return; } - + ItemStack item = player.getItemInHand(); if (item.getDurability() <= 0) @@ -599,46 +595,44 @@ public class Gameplay extends MiniPlugin UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + ".")); return; } - + int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0); boolean canRepair = canRepair(item); - + if (!canRepair) { UtilPlayer.message(player, F.main("Repair", "This item cannot be repaired anymore.")); return; } - - String creator = ItemStackFactory.Instance.GetLoreVar(item, "Owner"); - + + String creator = ItemStackFactory.Instance.GetLoreVar(item, "Owner"); + if (creator != null) { - if (creator.length() > 2) - creator = creator.substring(2, creator.length()); + if (creator.length() > 2) creator = creator.substring(2, creator.length()); if (!creator.equals(player.getName())) { - UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + " by " + F.name(creator) + ".")); + UtilPlayer.message(player, F.main("Repair", "You cannot repair " + F.item(item.getItemMeta().getDisplayName()) + " by " + F.name(creator) + ".")); return; } } - - //Repair! + + // Repair! UtilPlayer.message(player, F.main("Repair", "You repaired " + F.item(item.getItemMeta().getDisplayName()) + ".")); - item.setDurability((short)0); + item.setDurability((short) 0); UtilInv.Update(player); - - //Break - if (Math.random() > 0.85) - event.getClickedBlock().setData((byte) (event.getClickedBlock().getData() + 4)); + + // Break + if (Math.random() > 0.85) event.getClickedBlock().setData((byte) (event.getClickedBlock().getData() + 4)); if (event.getClickedBlock().getData() >= 12) { player.getWorld().playEffect(event.getClickedBlock().getLocation(), Effect.STEP_SOUND, 145); - event.getClickedBlock().setTypeIdAndData(0, (byte)0, true); + event.getClickedBlock().setTypeIdAndData(0, (byte) 0, true); } - - //Record + + // Record ItemStackFactory.Instance.SetLoreVar(item, "Repaired", (repairs + 1) + ""); if (!canRepair(item)) { @@ -647,24 +641,23 @@ public class Gameplay extends MiniPlugin item.setItemMeta(meta); } - //Effect + // Effect player.playSound(player.getLocation(), Sound.ANVIL_USE, 1f, 1f); } - + private boolean canRepair(ItemStack item) { int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0); boolean gold = UtilGear.isGold(item); boolean canRepair = true; - + if (repairs >= 3 && gold) canRepair = false; - else if (repairs >= 2 && !gold) - canRepair = false; - + else if (repairs >= 2 && !gold) canRepair = false; + return canRepair; } - + public DamageManager getDamageManager() { return _damageManager; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java index ad654b33e..7482dde82 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/PvpItem.java @@ -16,20 +16,7 @@ public class PvpItem extends ShopItem public PvpItem(Material type, byte data, int displayAmount, String name, int price, int bulkCount) { - super(type, data, name, new String[] - { - C.cWhite + " ", - LEFT_CLICK_BUY, - C.cWhite + "Costs " + C.cGreen + "$" + price, - C.cWhite + " ", - C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, - C.cWhite + "Costs " + C.cGreen + "$" + (price * bulkCount), - C.cWhite + " ", - RIGHT_CLICK_SELL, - C.cWhite + "Earns " + C.cGreen + "$" + (int)(price / 2), - C.cWhite + " ", - C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", - }, 0, false, false); + super(type, data, name, new String[] { C.cWhite + " ", LEFT_CLICK_BUY, C.cWhite + "Costs " + C.cGreen + price + "g", C.cWhite + " ", C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, C.cWhite + "Costs " + C.cGreen + (price * bulkCount) + "g", C.cWhite + " ", RIGHT_CLICK_SELL, C.cWhite + "Earns " + C.cGreen + (int) (price / 2) + "g", C.cWhite + " ", C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", }, 0, false, false); _price = price; _sellPrice = (int) (price / 2); @@ -38,20 +25,7 @@ public class PvpItem extends ShopItem public PvpItem(Material type, byte data, int displayAmount, String name, int buyPrice, int sellPrice, int bulkCount) { - super(type, data, name, new String[] - { - C.cWhite + " ", - LEFT_CLICK_BUY, - C.cWhite + "Costs " + C.cGreen + "$" + buyPrice, - C.cWhite + " ", - C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, - C.cWhite + "Costs " + C.cGreen + "$" + (buyPrice * bulkCount), - C.cWhite + " ", - RIGHT_CLICK_SELL, - C.cWhite + "Earns " + C.cGreen + "$" + sellPrice, - C.cWhite + " ", - C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", - }, 0, false, false); + super(type, data, name, new String[] { C.cWhite + " ", LEFT_CLICK_BUY, C.cWhite + "Costs " + C.cGreen + buyPrice + "g", C.cWhite + " ", C.cYellow + "Shift Left-Click" + C.cWhite + " to Buy " + C.cGreen + bulkCount, C.cWhite + "Costs " + C.cGreen + (buyPrice * bulkCount) + "g", C.cWhite + " ", RIGHT_CLICK_SELL, C.cWhite + "Earns " + C.cGreen + sellPrice + "g", C.cWhite + " ", C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", }, 0, false, false); _price = buyPrice; _sellPrice = sellPrice; @@ -60,17 +34,7 @@ public class PvpItem extends ShopItem public PvpItem(Material type, byte data, int displayAmount, String name, int price) { - super(type, data, name, new String[] - { - C.cWhite + " ", - LEFT_CLICK_BUY, - C.cWhite + "Costs " + C.cGreen + "$" + price, - C.cWhite + " ", - RIGHT_CLICK_SELL, - C.cWhite + "Earns " + C.cGreen + "$" + (int)(price / 2), - C.cWhite + " ", - C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", - }, 0, false, false); + super(type, data, name, new String[] { C.cWhite + " ", LEFT_CLICK_BUY, C.cWhite + "Costs " + C.cGreen + price + "g", C.cWhite + " ", RIGHT_CLICK_SELL, C.cWhite + "Earns " + C.cGreen + (int) (price / 2) + "g", C.cWhite + " ", C.cYellow + "Shift Right-Click" + C.cWhite + " to Sell " + C.cGreen + "All", }, 0, false, false); _price = price; _bulkCount = -1; @@ -80,7 +44,7 @@ public class PvpItem extends ShopItem { return _price; } - + public int getSellPrice() { return _sellPrice; diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java index 838e2a7b4..6dce1b82b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/shop/energy/EnergyPage.java @@ -22,7 +22,7 @@ public class EnergyPage extends ShopPageBase super(plugin, shop, clientManager, donationManager, "Energy Shop", player, 18); buildPage(); } - + @Override protected void buildPage() { @@ -35,20 +35,20 @@ public class EnergyPage extends ShopPageBase buildPurchase(clanInfo); } } - + private void buildPurchase(ClanInfo clanInfo) { int energyPerMin = Math.max(1, clanInfo.getEnergyCostPerMinute()); - + int oneHourEnergy = energyPerMin * 60; int oneDayEnergy = oneHourEnergy * 24; int maxEnergy = clanInfo.getEnergyPurchasable(); - - addButton(clanInfo, 11, oneHourEnergy, Material.REDSTONE, (byte) 0, " ", ChatColor.RESET + "1 Hour of Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + "$" + getPlugin().convertEnergyToGold(oneHourEnergy)); - addButton(clanInfo, 13, oneDayEnergy, Material.REDSTONE_BLOCK, (byte) 0, " ", ChatColor.RESET + "1 Day of Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + "$" + getPlugin().convertEnergyToGold(oneDayEnergy)); - addButton(clanInfo, 15, maxEnergy, Material.FURNACE, (byte) 0, " ", ChatColor.RESET + "Maxed Out Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + "$" + getPlugin().convertEnergyToGold(maxEnergy)); + + addButton(clanInfo, 11, oneHourEnergy, Material.REDSTONE, (byte) 0, " ", ChatColor.RESET + "1 Hour of Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneHourEnergy) + "g"); + addButton(clanInfo, 13, oneDayEnergy, Material.REDSTONE_BLOCK, (byte) 0, " ", ChatColor.RESET + "1 Day of Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(oneDayEnergy) + "g"); + addButton(clanInfo, 15, maxEnergy, Material.FURNACE, (byte) 0, " ", ChatColor.RESET + "Maxed Out Energy", " ", ChatColor.RESET + "Costs " + C.cGreen + getPlugin().convertEnergyToGold(maxEnergy) + "g"); } - + private void addInfo(ClanInfo clanInfo, int slot) { String itemName = clanInfo.getName(); @@ -57,29 +57,28 @@ public class EnergyPage extends ShopPageBase lore.add(C.cYellow + "Energy: " + ChatColor.RESET + clanInfo.getEnergy()); lore.add(C.cYellow + "Drain: " + ChatColor.RESET + clanInfo.getEnergyCostPerMinute() * 60 + " per Hour"); lore.add(C.cYellow + "Max Energy: " + ChatColor.RESET + clanInfo.getEnergyMax()); - if (clanInfo.getEnergyCostPerMinute() > 0) - lore.add(C.cYellow + "Time Left: " + ChatColor.RESET + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT)); - + if (clanInfo.getEnergyCostPerMinute() > 0) lore.add(C.cYellow + "Time Left: " + ChatColor.RESET + UtilTime.convertString((clanInfo.getEnergy() / clanInfo.getEnergyCostPerMinute()) * 60000L, 1, UtilTime.TimeUnit.FIT)); + ShopItem shopItem = new ShopItem(Material.DIAMOND, itemName, lore.toArray(new String[0]), 1, false, false); setItem(slot, shopItem); } - + private void addButton(ClanInfo clanInfo, int slot, int energyAmount, Material material, byte data, String... lore) { boolean locked = energyAmount > clanInfo.getEnergyPurchasable() || energyAmount == 0; String itemName = "Purchase " + energyAmount + " Energy"; - + ShopItem shopItem = new ShopItem(material, itemName, lore, 1, locked, false); - + if (locked) setItem(slot, shopItem); else addButton(slot, shopItem, new EnergyShopButton(getPlugin(), this, energyAmount, clanInfo)); } - + private void buildNoClan() { - ShopItem shopItem = new ShopItem(Material.BEDROCK, "No Clan!", new String[] {" ", ChatColor.RESET + "You need to be in a", ChatColor.RESET + "clan to purchase energy!"}, 1, false, false); + ShopItem shopItem = new ShopItem(Material.BEDROCK, "No Clan!", new String[] { " ", ChatColor.RESET + "You need to be in a", ChatColor.RESET + "clan to purchase energy!" }, 1, false, false); setItem(4, shopItem); } } diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelButton.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelButton.java index 8d7af2cd4..207057250 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelButton.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelButton.java @@ -58,7 +58,7 @@ public class TravelButton implements IButton { C.cWhite + " ", LEFT_CLICK_TRAVEL, - C.cWhite + "Costs " + C.cGreen + "$0", + C.cWhite + "Costs " + C.cGreen + "0g", C.cWhite + "Travel to " + C.cGreen + _name + C.cWhite + "!", C.cWhite + " ", }, 0, false, false); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java index c4ed0470a..98e90582b 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelPage.java @@ -1,11 +1,23 @@ package mineplex.game.clans.spawn.travel; +import java.util.Arrays; + +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilBlock; import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.IButton; import mineplex.core.shop.page.ShopPageBase; +import mineplex.game.clans.clans.ClanInfo; +import mineplex.game.clans.clans.ClanRole; import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.spawn.Spawn; @@ -13,18 +25,67 @@ public class TravelPage extends ShopPageBase { public TravelPage(ClansManager plugin, TravelShop shop, CoreClientManager clientManager, DonationManager donationManager, org.bukkit.entity.Player player) { - super(plugin, shop, clientManager, donationManager, "Travel", player, 27); + super(plugin, shop, clientManager, donationManager, "Travel", player, 45); buildPage(); } - + @Override protected void buildPage() { - addTravelLocation(Spawn.getEastSpawn(), Material.IRON_SWORD, "East Spawn", 14); - addTravelLocation(Spawn.getWestSpawn(), Material.IRON_SWORD, "West Spawn", 12); + addTravelLocation(Spawn.getEastSpawn(), Material.IRON_SWORD, "East Spawn", 14 + 10); + addTravelLocation(Spawn.getWestSpawn(), Material.IRON_SWORD, "West Spawn", 12 + 8); addTravelLocation(Spawn.getNorthTown(), Material.EMERALD, "North Town", 4); - addTravelLocation(Spawn.getSouthTown(), Material.EMERALD, "South Town", 22); + + final ClanInfo clan = getPlugin().getClan(getPlayer()); + + final ItemStack item = new ItemStack(Material.BED, 1); + ItemMeta meta = item.getItemMeta(); + + if (meta == null) + { + meta = Bukkit.getItemFactory().getItemMeta(item.getType()); + } + + if (clan == null) + { + meta.setDisplayName(C.cRed + "Clan Home"); + meta.setLore(Arrays.asList(C.cGray + "You are not in a Clan.")); + } + else if (clan.getHome() == null) + { + meta.setDisplayName(C.cRed + "Clan Home"); + meta.setLore(Arrays.asList(C.cGray + "Your Clan does not have a Home. " + (clan.getMembers().get(getPlayer().getUniqueId()).getRole().equals(ClanRole.ADMIN) || clan.getMembers().get(getPlayer().getUniqueId()).getRole().equals(ClanRole.LEADER) ? C.cGray + "Type /c sethome to set a home" : "Ask your Clan's Leader to set a home."))); + } + else + { + if (UtilBlock.isValidBed(clan.getHome()) && clan.getHome().clone().add(0, 1, 0).getBlock().getType().equals(Material.AIR) && clan.getHome().clone().add(0, 2, 0).getBlock().getType().equals(Material.AIR)) + { + meta.setDisplayName(C.cGreen + "Clan Home"); + meta.setLore(Arrays.asList(C.cGray + "Teleport to your Clan Home.")); + } + else + { + meta.setDisplayName(C.cRed + "Clan Home"); + meta.setLore(Arrays.asList(C.cGray + "Your Clan's Home Bed has been destroyed, or is obstructed.")); + } + } + + item.setItemMeta(meta); + + addButton(22, item, new IButton() + { + public void onClick(Player player, ClickType clickType) + { + if (item.getItemMeta().getDisplayName().startsWith(C.cGreen)) + { + player.closeInventory(); + player.teleport(clan.getHome().add(0, 1, 0)); + } + } + }); + + addTravelLocation(Spawn.getSouthTown(), Material.EMERALD, "South Town", 22 + 9 + 9); } public void addTravelLocation(Location location, Material material, String name, int slot) diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelShop.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelShop.java index 38f1d27c5..34e98535e 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelShop.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/spawn/travel/TravelShop.java @@ -19,13 +19,13 @@ import mineplex.game.clans.spawn.Spawn; public class TravelShop extends ShopBase { - public static final String[] TRAVEL_LOCATIONS = {"North Shop", "South Shop", "East Spawn", "West Spawn"}; + public static final String[] TRAVEL_LOCATIONS = { "North Shop", "South Shop", "East Spawn", "West Spawn" }; public TravelShop(ClansManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager) { super(plugin, clientManager, donationManager, "Travel Hub"); } - + @Override protected ShopPageBase> buildPagesFor(Player player) { @@ -45,16 +45,19 @@ public class TravelShop extends ShopBase } /** - * Destroy lone instances of Travel buttons that are fetched into a non-shop inventory (via lag) + * Destroy lone instances of Travel buttons that are fetched into a non-shop + * inventory (via lag) + * * @param event */ @EventHandler public void onInventoryClickedd(InventoryClickEvent event) { ItemStack item = event.getCurrentItem(); - if (item == null || item.getItemMeta() == null || item.getItemMeta().getDisplayName() == null) return; + if (item == null || item.getItemMeta() == null || item.getItemMeta().getDisplayName() == null) + return; else if (isPlayerInShop(event.getWhoClicked())) return; - + String displayName = event.getCurrentItem().getItemMeta().getDisplayName(); for (String travelLocation : TRAVEL_LOCATIONS) { diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java index d9ad386a7..0ccba926a 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/TutorialManager.java @@ -21,7 +21,6 @@ import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.tutorials.commands.SkipTutorialCommand; import mineplex.game.clans.tutorials.commands.TaskInfoCommand; -import mineplex.game.clans.tutorials.types.ClansTips; import mineplex.game.clans.tutorials.types.TutorialGettingStarted; public class TutorialManager extends MiniPlugin @@ -42,8 +41,6 @@ public class TutorialManager extends MiniPlugin _taskManager = taskManager; _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, goldManager, taskManager)); - - new ClansTips(this, preferencesManager); } public void addCommands() diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java new file mode 100644 index 000000000..28ec3463e --- /dev/null +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClanTips.java @@ -0,0 +1,232 @@ +package mineplex.game.clans.tutorials.types; + +import java.util.LinkedList; + +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.preferences.PreferencesManager; +import mineplex.game.clans.clans.ClansManager; +import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; +import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; +import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; +import net.minecraft.server.v1_8_R3.EnumDirection; + +public class ClanTips extends MiniPlugin +{ + private PreferencesManager _preferences; + private ClansManager _clans; + + public ClanTips(final JavaPlugin plugin, final ClansManager clans, final PreferencesManager preferences) + { + super("Clans Tips", plugin); + + _clans = clans; + _preferences = preferences; + } + + @EventHandler + public void onEnterTerritory(final PlayerEnterTerritoryEvent event) + { + if (event.getLastTerritory().equals(event.getNewTerritory())) + { + return; + } + + final Player player = event.getPlayer(); + final String newTerritory = event.getNewTerritory(); + + if (_preferences.Get(player).ClanTips) + { + if (newTerritory.equals("Fields")) + { + displayTip(TipType.ENTER_FIELDS, player); + } + else if (newTerritory.equals("Shop")) + { + displayTip(TipType.ENTER_SHOP, player); + } + else if (newTerritory.equals("Borderlands")) + { + displayTip(TipType.ENTER_BORDERLANDS, player); + } + else if (newTerritory.equals("Spawn")) + { + displayTip(TipType.ENTER_SPAWN, player); + } + } + } + + @EventHandler + public void onClaimTerritory(final PlayerClaimTerritoryEvent event) + { + if (event.getClan().getClaimCount() == 0){ + displayTip(TipType.FIRST_CLAIM_SETHOME, event.getClaimer()); + + // Place New + boolean bedPlaced = UtilBlock.placeBed(event.getClaimer().getLocation(), BlockFace.valueOf(EnumDirection.fromAngle(event.getClaimer().getLocation().getYaw()).name()), false, false); + + if (!bedPlaced) + { + UtilPlayer.message(event.getClaimer(), F.main("Clans", "This is not a suitable place for a bed.")); + return; + } + + // Cleanup old + if (event.getClan().getHome() != null) + { + System.out.println("<-old bed cleanup-> <--> " + UtilBlock.deleteBed(event.getClan().getHome())); + } + + // Task + _clans.getClanDataAccess().setHome(event.getClan(), event.getClaimer().getLocation(), event.getClaimer().getName()); + + return; + } + displayTip(TipType.CLAIM, event.getClaimer()); + } + + @EventHandler + public void onUnClaimTerritory(final PlayerUnClaimTerritoryEvent event) + { + displayTip(TipType.UNCLAIM, event.getUnClaimer()); + } + + public void displayTip(TipType tip, Player player) + { + if (tip == null) + { + return; + } + + if (player == null) + { + return; + } + + if (!_preferences.Get(player).ClanTips) + { + return; + } + + UtilPlayer.message(player, tip._messages); + + if (!tip._ignorePreferences) + { + UtilPlayer.message(player, C.cGray + "(You can disable these Clans Tips in the " + F.elem("/prefs") + " menu.)"); + } + } + + public static enum TipType + { + SETHOME( + new String[] { + C.cDAquaB + "You have set your Clan's Home.", + C.cAqua + "You can return to your Clan Home by using " + F.elem("/c home") + ", but remember, you must be in a Safe Spawn location to do this.", + C.cAqua + "When you die and respawn, you are also given an option to spawn at your Clan Home." + }), + + UNCLAIM( + new String[] { + C.cDAquaB + "You unclaimed some Clan Territory!", + C.cAqua + "When territory is unclaimed, it cannot be reclaimed by anyone for 30 minutes." + }), + + CLAIM( + new String[] { + C.cDAquaB + "You claimed some Clan Territory!", + C.cAqua + "Clan Territory is an area of the map that only your Clan is allowed to edit! This means that you can build a base and stash your loot safely inside.", + C.cAqua + "Each territory is a 16x16 area, which extends from bedrock to the sky!", C.cGreen + "The borders are marked with glowstone." + }), + + ENTER_FIELDS( + new String[] { + C.cDRedB + "Fields", + C.cRed + "Fields is a very lucrative area, filled with ores that periodically respawn over time. This is a great place to get a large amount of resources for your clan; however, be aware of other clans who may also be after the riches buried within the fields." + }), + + ENTER_SHOP( + new String[] { + C.cDGreenB + "Shops", + C.cGreen + "Shops is a safe area where combat is disabled between players! Use this safety to purchase food, building blocks, armor, weapons, and other valuable resources. Be careful when leaving though, others may be hiding just outside the gates, eager to steal your recent purchases." + }), + + ENTER_BORDERLANDS( + new String[] { + C.cDRedB + "Borderlands", + C.cRed + "The Borderlands are the very outer reaches of the map, out here you can not edit the terrain. Be careful as very powerful boss monsters will periodically spawn out here! Don't try to fight them alone! If you do manage to slay one of these powerful beasts, you'll be handsomely rewarded with powerful gear or legendary weapons." + }), + + ENTER_SPAWN( + new String[] { + C.cDGreenB + "Spawn", + C.cGreen + "Spawn is a Safe Zone where you spawn after dying. No one can attack you here, and you cannot attack anyone else. If you have set your Clan Home, you are able to teleport to it from Spawns." + }), + + FIRST_CLAIM_SETHOME( + new String[] { + C.cDAquaB + "First Claim", + C.cAqua + "Congratulations on your first Clan Claim.", + C.cAqua + "We have automatically placed your Clan Home where you are currently standing.", + C.cAqua + "In the future, to set your Clan Home elsewhere, use the " + F.elem("/c sethome") + " command.", + C.cAqua + "You can return to your Clan Home by using " + F.elem("/c home") + C.cAqua + ", but remember, you must be in a Safe Spawn location to do this.", + C.cAqua + "When you die and respawn, you are also given an option to spawn at your Clan Home." + }), + + DOMINANCE_RIP( + new String[] { + C.cDAquaB + "You died in War!", + C.cAqua + "You have just died to a Clan that you are at War with.", + C.cAqua + "This means that they have gained a War point.", + C.cAqua + "War points indicate how many kills a clan has over you! If it reaches +30 then an invasion starts!", + C.cAqua + "During an invasion the clan with +30 has full block access for 15 minutes!", + }), + + DOMINANCE_NOOICE( + new String[] { + C.cDAquaB + "You killed someone at War!", + C.cAqua + "You have just killed someone in a Clan that you are at War with.", + C.cAqua + "This means that your Clan has gained a War point.", + C.cAqua + "War points indicate how many kills you have against a Clan! If it reaches +30 then an invasion starts!", + C.cAqua + "During an invasion the clan with +30 has full block access for 15 minutes!", + }), + + ENERGY( + new String[] { + C.cDAquaB + "Energy", + C.cAqua + "To top up your energy, go to the Shop and buy some in the Energy Shop.", + C.cAqua + "To find the Shop, look at your map (use " + F.elem("/map") + " if you don't have one) and go to either the top-most highlighted area, or the bottom-most highlighted area.", + }), + + ; + + // this is only LinkedList because UtilPlayer.message wants it + private LinkedList _messages; + private boolean _ignorePreferences; + + TipType(String[] messages) + { + this(messages, false); + } + + TipType(String[] messages, boolean ignorePreferences) + { + _messages = new LinkedList(); + + for (String message : messages) + { + _messages.add(message); + } + + _ignorePreferences = ignorePreferences; + } + } + +} diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClansTips.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClansTips.java deleted file mode 100644 index 92fffdde7..000000000 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/tutorials/types/ClansTips.java +++ /dev/null @@ -1,102 +0,0 @@ -package mineplex.game.clans.tutorials.types; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; - -import mineplex.core.MiniPlugin; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.preferences.PreferencesManager; -import mineplex.game.clans.clans.event.DominanceChangeEvent; -import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent; -import mineplex.game.clans.clans.event.PlayerEnterTerritoryEvent; -import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; -import mineplex.game.clans.tutorials.TutorialManager; - -public class ClansTips extends MiniPlugin -{ - private PreferencesManager _preferences; - - public ClansTips(final TutorialManager manager, final PreferencesManager preferences) - { - super("Clans Tips", manager.getPlugin()); - - _preferences = preferences; - } - - @EventHandler - public void onEnterTerritory(final PlayerEnterTerritoryEvent event) - { - if (event.getLastTerritory().equals(event.getNewTerritory())) - { - return; - } - - final Player player = event.getPlayer(); - final String newTerritory = event.getNewTerritory(); - - if (_preferences.Get(player).ClanTips) - { - if (newTerritory.equals("Fields")) - { - UtilPlayer.message(player, C.cDRedB + "Fields"); - UtilPlayer.message(player, C.cRed + "Fields is a very lucrative area, filled with ores that periodically respawn over time. This is a great place to get a large amount of resources for your clan; however, be aware of other clans who may also be after the riches buried within the fields."); - UtilPlayer.message(player, C.cGray + "(You can disable these Clans Tips in the " + F.elem("/prefs") + " menu.)"); - } - else if (newTerritory.equals("Shop")) - { - UtilPlayer.message(player, C.cDGreenB + "Shops"); - UtilPlayer.message(player, C.cGreen + "Shops is a safe area where combat is disabled between players! Use this safety to purchase food, building blocks, armor, weapons, and other valuable resources. Be careful when leaving though, others may be hiding just outside the gates, eager to steal your recent purchases."); - UtilPlayer.message(player, C.cGray + "(You can disable these Clans Tips in the " + F.elem("/prefs") + " menu.)"); - } - else if (newTerritory.equals("Borderlands")) - { - UtilPlayer.message(player, C.cDRedB + "Borderlands"); - UtilPlayer.message(player, C.cRed + "The Borderlands are the very outer reaches of the map, out here you can not edit the terrain. Be careful as very powerful boss monsters will periodically spawn out here! Don't try to fight them alone! If you do manage to slay one of these powerful beasts, you'll be handsomely rewarded with powerful gear or legendary weapons."); - UtilPlayer.message(player, C.cGray + "(You can disable these Clans Tips in the " + F.elem("/prefs") + " menu.)"); - } - else if (newTerritory.equals("Spawn")) - { - UtilPlayer.message(player, C.cDGreenB + "Spawn"); - UtilPlayer.message(player, C.cGreen + "Spawn is a Safe Zone where you spawn after dying. No one can attack you here, and you cannot attack anyone else. If you have set your Clan Home, you are able to teleport to it from Spawns."); - UtilPlayer.message(player, C.cGray + "(You can disable these Clans Tips in the " + F.elem("/prefs") + " menu.)"); - } - } - } - - @EventHandler - public void onClaimTerritory(final PlayerClaimTerritoryEvent event) - { - final Player player = event.getClaimer(); - - if (_preferences.Get(player).ClanTips) - { - UtilPlayer.message(player, C.cDGreenB + "You claimed some Clan Territory!"); - UtilPlayer.message(player, C.cGreen + "Clan Territory is an area of the map that only your Clan is allowed to edit! This means that you can build a base and stash your loot safely inside."); - UtilPlayer.message(player, C.cGreen + "Each territory is a 16x16 area, which extends from bedrock to the sky!"); - UtilPlayer.message(player, C.cGreen + "The borders are marked with glowstone."); - UtilPlayer.message(player, C.cGray + "(You can disable these Clans Tips in the " + F.elem("/prefs") + " menu.)"); - } - } - - @EventHandler - public void onUnClaimTerritory(final PlayerUnClaimTerritoryEvent event) - { - final Player player = event.getUnClaimer(); - - if (_preferences.Get(player).ClanTips) - { - UtilPlayer.message(player, C.cDGreenB + "You unclaimed some Clan Territory!"); - UtilPlayer.message(player, C.cGreen + "When territory is unclaimed, it cannot be reclaimed by anyone for 30 minutes."); - UtilPlayer.message(player, C.cGray + "(You can disable these Clans Tips in the " + F.elem("/prefs") + " menu.)"); - } - } - - @EventHandler - public void onDominanceChange(final DominanceChangeEvent event) - { - // TODO: pls remember ben - } - -}