diff --git a/.classpath b/.classpath index 121fc2c..76d3582 100644 --- a/.classpath +++ b/.classpath @@ -6,6 +6,7 @@ + diff --git a/.project b/.project index 0277238..44beaf6 100644 --- a/.project +++ b/.project @@ -20,4 +20,11 @@ org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + + + resources + 2 + C:/Users/keoug/Documents/GitHub/NavyCraft/src/test/resources + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index 29abf99..839d647 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -2,5 +2,4 @@ eclipse.preferences.version=1 encoding//src/main/java=UTF-8 encoding//src/main/resources=UTF-8 encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 encoding/=UTF-8 diff --git a/src/main/java/com/maximuspayne/aimcannon/AimCannonPlayerListener.java b/src/main/java/com/maximuspayne/aimcannon/AimCannonPlayerListener.java index 76f32d7..96b79e7 100644 --- a/src/main/java/com/maximuspayne/aimcannon/AimCannonPlayerListener.java +++ b/src/main/java/com/maximuspayne/aimcannon/AimCannonPlayerListener.java @@ -11,13 +11,13 @@ import org.bukkit.inventory.EquipmentSlot; import com.maximuspayne.navycraft.NavyCraft; -import com.maximuspayne.navycraft.PermissionInterface; +import com.maximuspayne.navycraft.Utils; import net.md_5.bungee.api.ChatColor; public class AimCannonPlayerListener implements Listener { public static AimCannon plugin; - + public static void onPlayerInteract(PlayerInteractEvent event) { if (event.getHand() != EquipmentSlot.HAND) @@ -26,7 +26,6 @@ public static void onPlayerInteract(PlayerInteractEvent event) { ///////stone button if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK ) { if (event.getClickedBlock().getType() == Material.STONE_BUTTON) { - NavyCraft.instance.DebugMessage("Plugin found stone button!", 3); Block b = null; if (event.getClickedBlock().getRelative(BlockFace.NORTH_EAST).getType() == Material.DISPENSER) { b = event.getClickedBlock().getRelative(BlockFace.NORTH_EAST); @@ -104,7 +103,6 @@ else if(event.getAction() == Action.LEFT_CLICK_BLOCK) if( b != null ) { - NavyCraft.instance.DebugMessage("Block wasn't null!", 3); for (OneCannon onec : AimCannon.getCannons()) { if (onec.isThisCannon(b.getLocation(), false, false) && ( onec.cannonType == 3 || onec.cannonType == 7 || onec.cannonType == 8)) @@ -121,7 +119,6 @@ else if(event.getAction() == Action.LEFT_CLICK_BLOCK) } } } else { - NavyCraft.instance.DebugMessage("Got to dropper detection", 3); if( event.getClickedBlock().getRelative(BlockFace.NORTH).getType() == Material.DROPPER ) { b = event.getClickedBlock().getRelative(BlockFace.NORTH); @@ -137,12 +134,9 @@ else if(event.getAction() == Action.LEFT_CLICK_BLOCK) } if( b != null ) { - NavyCraft.instance.DebugMessage("Got to cannon detection method", 3); for (OneCannon onec : AimCannon.getCannons()) { - NavyCraft.instance.DebugMessage("Got to type detection", 3); if (onec.isThisCannon(b.getLocation(), false, true) && (onec.cannonType == 13 || onec.cannonType == 14 )) { - NavyCraft.instance.DebugMessage("Got to left click detection method", 3); if( event.getAction() == Action.LEFT_CLICK_BLOCK ) onec.fireMissileButton(event.getPlayer(), true); else @@ -350,8 +344,6 @@ else if(event.getAction() == Action.LEFT_CLICK_BLOCK) onec.turnCannon(false,event.getPlayer()); } event.getPlayer().sendMessage("Cannon turned.."); - event.setCancelled(true); - return; } } } @@ -359,7 +351,7 @@ else if(event.getAction() == Action.LEFT_CLICK_BLOCK) } }else { //b != null - if (PermissionInterface.CheckEnabledWorld(event.getPlayer().getLocation())) { + if (Utils.CheckEnabledWorld(event.getPlayer().getLocation())) { for (OneCannon onec : AimCannon.getCannons()) { if (onec.isThisCannon(b.getLocation(), false, false)) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) { @@ -384,7 +376,7 @@ else if(event.getAction() == Action.LEFT_CLICK_BLOCK) for (OneCannon onec : AimCannon.getCannons()) { if (onec.isThisCannon(event.getClickedBlock().getLocation(), false, false) || onec.isThisCannon(event.getClickedBlock().getLocation(), false, true)) { - if (PermissionInterface.CheckEnabledWorld(event.getClickedBlock().getLocation()) && !NavyCraft.checkSafeDockRegion(event.getClickedBlock().getLocation())) { + if (Utils.CheckEnabledWorld(event.getClickedBlock().getLocation()) && !NavyCraft.checkSafeDockRegion(event.getClickedBlock().getLocation())) { if( event.getAction() == Action.LEFT_CLICK_BLOCK ) onec.Charge(event.getPlayer(), true); else @@ -401,7 +393,7 @@ else if(event.getAction() == Action.LEFT_CLICK_BLOCK) // new Cannon OneCannon oc = new OneCannon(event.getClickedBlock().getLocation(), NavyCraft.instance); if ((oc.isValidCannon(event.getClickedBlock(), false) && event.getClickedBlock().getType() == Material.DISPENSER) || (oc.isValidCannon(event.getClickedBlock(), true) && event.getClickedBlock().getType() == Material.DROPPER)) { - if (PermissionInterface.CheckEnabledWorld(event.getClickedBlock().getLocation()) && !NavyCraft.checkSafeDockRegion(event.getClickedBlock().getLocation())) { + if (Utils.CheckEnabledWorld(event.getClickedBlock().getLocation()) && !NavyCraft.checkSafeDockRegion(event.getClickedBlock().getLocation())) { if( event.getAction() == Action.LEFT_CLICK_BLOCK ) oc.Charge(event.getPlayer(), true); else @@ -421,7 +413,7 @@ else if(event.getAction() == Action.LEFT_CLICK_BLOCK) @SuppressWarnings("deprecation") public static void onBlockDispense(BlockDispenseEvent event) { - if( event.getBlock() != null && event.getBlock().getTypeId() == 23 ) + if( event.getBlock() != null && (event.getBlock().getTypeId() == 23 || event.getBlock().getTypeId() == 158)) { for (OneCannon onec : AimCannon.getCannons()) { diff --git a/src/main/java/com/maximuspayne/aimcannon/OneCannon.java b/src/main/java/com/maximuspayne/aimcannon/OneCannon.java index f4b413f..a22c0cc 100644 --- a/src/main/java/com/maximuspayne/aimcannon/OneCannon.java +++ b/src/main/java/com/maximuspayne/aimcannon/OneCannon.java @@ -1,6 +1,7 @@ package com.maximuspayne.aimcannon; import java.math.BigDecimal; +import java.util.Arrays; import java.util.Date; import java.util.Iterator; @@ -27,7 +28,8 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion; import com.maximuspayne.navycraft.NavyCraft; import com.maximuspayne.navycraft.Periscope; -import com.maximuspayne.navycraft.PermissionInterface; +import com.maximuspayne.navycraft.Utils; +import com.maximuspayne.navycraft.blocks.BlocksInfo; import com.maximuspayne.navycraft.craft.Craft; import com.maximuspayne.navycraft.craft.CraftMover; @@ -226,7 +228,7 @@ public void Ignite(final Player p) { if( ignite ) { fireThreadNew(delay, p); - p.sendMessage("3 - Ready!"); + p.sendMessage(ChatColor.RED + "3 - Ready!"); } } @@ -255,7 +257,7 @@ public void fire1(final Player p) { // @Override public void run() { - p.sendMessage("2 - Aim!"); + p.sendMessage(ChatColor.YELLOW + "2 - Aim!"); } }); } @@ -265,7 +267,7 @@ public void fire2(final Player p) { // @Override public void run() { - p.sendMessage("1 - Fire!!!"); + p.sendMessage(ChatColor.GREEN + "1 - Fire!!!"); } }); } @@ -471,15 +473,15 @@ public void setDelay(Player p) if( delay >= 2000 ) { delay = 0; - p.sendMessage("Long Flight Fuse"); + p.sendMessage(ChatColor.RED + "Long Flight Fuse"); }else if( delay == 0 ) { delay = 1000; - p.sendMessage("Medium Flight Fuse"); + p.sendMessage(ChatColor.GOLD + "Medium Flight Fuse"); }else if( delay == 1000 ) { delay = 2000; - p.sendMessage("Short Flight Fuse"); + p.sendMessage(ChatColor.YELLOW + "Short Flight Fuse"); } } @@ -506,21 +508,6 @@ public void fireCannonButton(Player p, boolean leftClick) fireCannon(p, loc.getBlock()); charged = 0; - }else - { - if( leftClick ) - { - range = range - 10; - if( range < 10 ) - range = 10; - p.sendMessage("Range set to " + range + "m."); - }else - { - range = range + 10; - if( range > 200 ) - range = 200; - p.sendMessage("Range set to " + range + "m."); - } } } @@ -535,11 +522,11 @@ public void run() { //taskNum = -1; try{ sleep(500); - p.sendMessage("3 - Ready!"); + p.sendMessage(ChatColor.RED + "3 - Ready!"); sleep(500); - p.sendMessage("2 - Aim! "); + p.sendMessage(ChatColor.YELLOW + "2 - Aim! "); sleep(500); - p.sendMessage("1 - Fire!!!"); + p.sendMessage(ChatColor.GREEN + "1 - Fire!!!"); sleep(500); Vector look; look = p.getLocation().getDirection(); @@ -833,334 +820,462 @@ public boolean Charge(Player p, boolean leftClick) Dropper dropper = (Dropper) loc.getBlock().getState(); inventory = dropper.getInventory(); } - if (inventory != null) { - if( inventory.getItem(4) == null || inventory.getItem(4).getTypeId() != 388 ) - { - Essentials ess; - ess = (Essentials) nc.getServer().getPluginManager().getPlugin("Essentials"); - if( ess == null ) - { - p.sendMessage("Essentials Economy error"); - return false; - } - - int cost=0; - if( cannonType == 0 ) //single barrel - cost=100; - else if( cannonType == 1 )//double barrel - cost=250; - else if( cannonType == 3 )//torpedo mk 2 - cost=600; - else if( cannonType == 4 )//depth charge - cost=850; - else if( cannonType == 5 )//depth charge mk2 - cost=1250; - else if( cannonType == 6 )//triple barrel - cost=1250; - else if( cannonType == 7 )//torpedo mk 3 - cost=1250; - else if( cannonType == 8 )//torpedo mk 1 - cost=250; - else if( cannonType == 9 )//bombs mk1 - cost=250; - else if( cannonType == 10 )//bombs mk2 - cost=500; - else if( cannonType == 11 )//missiles mk1 - cost=600; - else if( cannonType == 12 )//missiles mk2 - cost=1250; - else if( cannonType == 13 )//vertical missiles mk1 - cost=600; - else if( cannonType == 14 )//vertical missiles mk2 - cost=1250; - - if( PermissionInterface.CheckEnabledWorld(p.getLocation()) ) - { - if( ess.getUser(p).canAfford(new BigDecimal(cost)) ) + if (inventory != null) { + if( inventory.getItem(4) == null || inventory.getItem(4).getTypeId() != 388 ) + { + Essentials ess; + ess = (Essentials) nc.getServer().getPluginManager().getPlugin("Essentials"); + if( ess == null ) { - p.sendMessage("Weapon purchased."); - - inventory.setItem(4, new ItemStack( 388, 1)); - ess.getUser(p).takeMoney(new BigDecimal(cost)); + p.sendMessage("Essentials Economy error"); + return false; + } + + int cost=0; + if( cannonType == 0 ) //single barrel + cost=100; + else if( cannonType == 1 )//double barrel + cost=250; + else if( cannonType == 3 )//torpedo mk 2 + cost=650; + else if( cannonType == 4 )//depth charge + cost=850; + else if( cannonType == 5 )//depth charge mk2 + cost=850; + else if( cannonType == 6 )//triple barrel + cost=850; + else if( cannonType == 7 )//torpedo mk 3 + cost=850; + else if( cannonType == 8 )//torpedo mk 1 + cost=250; + else if( cannonType == 9 )//bombs mk1 + cost=250; + else if( cannonType == 10 )//bombs mk2 + cost=500; + else if( cannonType == 11 )//missiles mk1 + cost=650; + else if( cannonType == 12 )//missiles mk2 + cost=850; + else if( cannonType == 13 )//vertical missiles mk1 + cost=650; + else if( cannonType == 14 )//vertical missiles mk2 + cost=850; + + if( Utils.CheckEnabledWorld(p.getLocation()) ) + { + if( ess.getUser(p).canAfford(new BigDecimal(cost)) ) + { + p.sendMessage(ChatColor.GREEN + "Weapon purchased."); + + inventory.setItem(4, new ItemStack( 388, 1)); + ess.getUser(p).takeMoney(new BigDecimal(cost)); + }else + { + p.sendMessage(ChatColor.RED + "You cannot afford this weapon."); + AimCannon.cannons.remove(this); + return false; + } }else { - p.sendMessage("You cannot afford this weapon."); - AimCannon.cannons.remove(this); - return false; + inventory.setItem(4, new ItemStack( 388, 1)); } - }else - { - inventory.setItem(4, new ItemStack( 388, 1)); - } - } - - //color wool for torpedoes - if( !leftClick && (cannonType == 3 || cannonType == 7 || cannonType == 8) ) - { - if (charged == 1) { - if(depth > 0 ) - depth = depth - 5; - else - depth = 0; - p.sendMessage("Torpedo System Active: Depth set to " + depth + " meters."); - colorTorpedoes(); - return true; - } else { - colorTorpedoes(); - return false; - } - } else if( !leftClick && (cannonType == 11 || cannonType == 12 || cannonType == 13 || cannonType == 14) ) - { - if (charged == 1) { - if(depth > 0 ) - depth = depth - 5; - else - depth = 0; - p.sendMessage("Missile System Active: Y axis set to " + depth + " meters."); - if (cannonType == 13 || cannonType == 14) { - colorMissiles(); - return true; - } else { - colorTorpedoes(); - return true; - } - } else { - if (cannonType == 13 || cannonType == 14) { - colorMissiles(); - return false; - } else { - colorTorpedoes(); - return false; - } - } - }else if( cannonType == 2 ) - { - if( leftClick ) - { - if ((p.getInventory().contains(46) || charged > 0) && p.getInventory().contains(289)) - { - if( charged == 0 ) - p.getInventory().removeItem(new ItemStack(46, 1)); - p.getInventory().removeItem(new ItemStack(289, 1)); - charged = 1; - p.sendMessage("Cannon Loaded!"); - return true; - - } else - { - p.sendMessage("You need 1xGunpowder and 1xTNT to Load the cannon!"); - return false; - } - }else + } + + //color wool for torpedoes + if( !leftClick && (cannonType == 3 || cannonType == 7 || cannonType == 8) ) { - range = 10; - p.sendMessage("Range Reset to 10m."); - return false; - } - }else if( charged < 4 ) - { - if( cannonType == 0 ) + if (charged == 1) { + if(depth > 0 ) + depth = depth - 5; + else + depth = 0; + p.sendMessage(ChatColor.GREEN + "Torpedo System Active: Depth set to " + ChatColor.YELLOW + depth + ChatColor.YELLOW + " meters."); + colorTorpedoes(); + return true; + } else { + colorTorpedoes(); + return false; + } + } else if( !leftClick && (cannonType == 11 || cannonType == 12 || cannonType == 13 || cannonType == 14) ) + { + if (charged == 1) { + if(depth > 0 ) + depth = depth - 5; + else + depth = 0; + p.sendMessage(ChatColor.GREEN + "Missile System Active: Y axis set to " + ChatColor.YELLOW + depth + ChatColor.YELLOW + "."); + if (cannonType == 13 || cannonType == 14) { + colorMissiles(); + return true; + } else { + colorTorpedoes(); + return true; + } + } else { + if (cannonType == 13 || cannonType == 14) { + colorMissiles(); + return false; + } else { + colorTorpedoes(); + return false; + } + } + }else if( charged < 4 ) { - - if( charged == 0 ) - { - if( ammunition > 0 ) - { - ammunition = ammunition - 1; - }else - { - p.sendMessage( ChatColor.RED + "Cannon out of ammo!"); - return false; - } - charged=1; - p.sendMessage("Cannon Loaded! " + ammunition + " shots remaining. Cannon Power X" + charged); - }else{ - charged++; - p.sendMessage("Cannon Power X" + charged); - } - - return true; + if( cannonType == 0 ) + { + + if( charged == 0 ) + { + if( ammunition > 0 ) + { + ammunition = ammunition - 1; + }else + { + Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); + Block block; + if (theCraft != null) { + for (int x = 0; x < theCraft.sizeX; x++) { + for (int z = 0; z < theCraft.sizeZ; z++) { + for (int y = 0; y < theCraft.sizeY; y++) { + + if( theCraft.matrix == null ) + return false; - } else if( cannonType == 1 ) - { - if( charged == 0 ) - { - if( ammunition > 0 ) - { - ammunition = ammunition - 1; - }else - { - p.sendMessage( ChatColor.RED + "Cannon out of ammo!"); - return false; - } - charged=1; - p.sendMessage("Cannon Loaded! " + ammunition + " shots remaining. Cannon Power X" + charged); - }else{ - charged++; - p.sendMessage("Cannon Power X" + charged); - } - - return true; - }else if( cannonType == 6 ) - { - if( charged == 0 ) - { - if( ammunition > 0 ) - { - ammunition = ammunition - 1; - }else - { - p.sendMessage( ChatColor.RED + "Cannon out of ammo!"); - return false; - } - charged=1; - p.sendMessage("Cannon Loaded! " + ammunition + " shots remaining. Cannon Power X" + charged); - }else{ - charged++; - p.sendMessage("Cannon Power X" + charged); - } - - return true; - }else if( cannonType == 3 || cannonType == 7 || cannonType == 8 ) - { - colorTorpedoes(); - charged=1; - if( depth < 5 ) - depth++; - else if( depth == 5 ) - depth = 10; - else if( depth >= 10 && depth < 50 ) - depth = depth + 5; - else - depth = 0; - p.sendMessage("Torpedo System Active: Depth set to " + depth + " meters."); - - return true; - }else if( cannonType == 11 || cannonType == 12 || cannonType == 13 || cannonType == 14) - { - if (cannonType == 13 || cannonType == 14) { - colorMissiles(); - } else { - colorTorpedoes(); - } - charged=1; - if(depth < 240 ) - depth = depth + 5; - else - depth = 0; - p.sendMessage("Missile System Active: Y axis set to " + depth + " meters."); - - return true; - } - else if( cannonType == 4 ) - { - if( charged == 0 ) - { - Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); - if (theCraft != null) { - if (theCraft.type.canFly || theCraft.type.isTerrestrial) { - p.sendMessage(ChatColor.RED + "You can't use Depth Charges on an aircraft!"); - return false; - } - } - if( ammunition > 0 && ammunition <= 10) - { - ammunition = ammunition - 1; - }else - { - p.sendMessage( ChatColor.RED + "Out of depth charges!"); - return false; - } - charged=1; - p.sendMessage("Depth charge dropper loaded! " + ammunition + " depth charges left."); - }else{ - p.sendMessage("Depth charge dropper already loaded! " + ammunition + " depth charges left."); - } - - return true; - }else if( cannonType == 5 ) - { - if( charged == 0 ) - { - Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); - if (theCraft != null) { - if (theCraft.type.canFly || theCraft.type.isTerrestrial) { - p.sendMessage(ChatColor.RED + "You can't use Depth Charges on an aircraft!"); - return false; - } - } - if( ammunition > 0 && ammunition <= 20) - { - ammunition = ammunition - 1; - }else - { - p.sendMessage( ChatColor.RED + "Out of depth charges!"); - return false; - } - charged=1; - p.sendMessage("Depth charge launcher loaded! " + ammunition + " depth charge launches left."); - }else{ - p.sendMessage("Depth charge launcher already loaded! " + ammunition + " depth charge launches left."); - } - - return true; - - }else if( cannonType == 9 ) - { - if( charged == 0 ) - { - if( ammunition > 0 && ammunition <= 2) - { - ammunition = ammunition - 1; - }else - { - p.sendMessage( ChatColor.RED + "Out of bombs!"); - return false; - } - charged=1; - p.sendMessage("Bomb dropper loaded! " + ammunition + " bombs left."); - }else{ - p.sendMessage("Bomb dropper already loaded! " + ammunition + " bombs left."); - } - - return true; - - }else if( cannonType == 10 ) - { - if( charged == 0 ) - { - if( ammunition > 0 && ammunition <= 6) - { - ammunition = ammunition - 1; - }else - { - p.sendMessage( ChatColor.RED + "Out of bombs!"); - return false; - } + block = theCraft.world.getBlockAt(theCraft.minX + x, theCraft.minY + y, theCraft.minZ + z); + if (block.getType() == Material.EMERALD_ORE && ammunition < 1) { + reload(p); + setBlock(0, block, theCraft); + break; + } + } + } + } + } + if (ammunition < 1) { + p.sendMessage( ChatColor.RED + "Cannon out of ammo!"); + return false; + } + } + charged=1; + p.sendMessage(ChatColor.GREEN + "Cannon Loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " shots remaining. Cannon Power X" + ChatColor.YELLOW + charged); + }else{ + charged++; + p.sendMessage(ChatColor.GREEN + "Cannon Power X" + ChatColor.YELLOW + charged); + } + + return true; + + } else if( cannonType == 1 ) + { + if( charged == 0 ) + { + if( ammunition > 0 ) + { + ammunition = ammunition - 1; + }else + { + Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); + Block block; + if (theCraft != null) { + for (int x = 0; x < theCraft.sizeX; x++) { + for (int z = 0; z < theCraft.sizeZ; z++) { + for (int y = 0; y < theCraft.sizeY; y++) { + + if( theCraft.matrix == null ) + return false; + + block = theCraft.world.getBlockAt(theCraft.minX + x, theCraft.minY + y, theCraft.minZ + z); + if (block.getType() == Material.EMERALD_ORE && ammunition < 1) { + reload(p); + setBlock(0, block, theCraft); + break; + } + } + } + } + } + if (ammunition < 1) { + p.sendMessage( ChatColor.RED + "Cannon out of ammo!"); + return false; + } + } + charged=1; + p.sendMessage(ChatColor.GREEN + "Cannon Loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " shots remaining. Cannon Power X" + ChatColor.YELLOW + charged); + }else{ + charged++; + p.sendMessage(ChatColor.GREEN + "Cannon Power X" + ChatColor.YELLOW + charged); + } + + return true; + }else if( cannonType == 6 ) + { + if( charged == 0 ) + { + if( ammunition > 0 ) + { + ammunition = ammunition - 1; + }else + { + Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); + Block block; + if (theCraft != null) { + for (int x = 0; x < theCraft.sizeX; x++) { + for (int z = 0; z < theCraft.sizeZ; z++) { + for (int y = 0; y < theCraft.sizeY; y++) { + + if( theCraft.matrix == null ) + return false; + + block = theCraft.world.getBlockAt(theCraft.minX + x, theCraft.minY + y, theCraft.minZ + z); + if (block.getType() == Material.EMERALD_ORE && ammunition < 1) { + reload(p); + setBlock(0, block, theCraft); + break; + } + } + } + } + } + if (ammunition < 1) { + p.sendMessage( ChatColor.RED + "Cannon out of ammo!"); + return false; + } + } + charged=1; + p.sendMessage(ChatColor.GREEN + "Cannon Loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " shots remaining. Cannon Power X" + ChatColor.YELLOW + charged); + }else{ + charged++; + p.sendMessage(ChatColor.GREEN + "Cannon Power X" + ChatColor.YELLOW + charged); + } + + return true; + }else if( cannonType == 3 || cannonType == 7 || cannonType == 8 ) + { + colorTorpedoes(); + charged=1; + if( depth < 5 ) + depth++; + else if( depth == 5 ) + depth = 10; + else if( depth >= 10 && depth < 50 ) + depth = depth + 5; + else + depth = 0; + p.sendMessage(ChatColor.GREEN + "Torpedo System Active: Depth set to " + ChatColor.YELLOW + depth + ChatColor.YELLOW + " meters."); + + return true; + }else if( cannonType == 11 || cannonType == 12 || cannonType == 13 || cannonType == 14) + { + if (cannonType == 13 || cannonType == 14) { + colorMissiles(); + } else { + colorTorpedoes(); + } + charged=1; + if(depth < 240 ) + depth = depth + 5; + else + depth = 0; + p.sendMessage(ChatColor.GREEN + "Missile System Active: Y axis set to " + ChatColor.YELLOW + depth + ChatColor.YELLOW + "."); + + return true; + } + else if( cannonType == 4 ) + { + if( charged == 0 ) + { + Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); + if (theCraft != null) { + if (theCraft.type.canFly || theCraft.type.isTerrestrial) { + p.sendMessage(ChatColor.RED + "You can't use Depth Charges on an aircraft!"); + return false; + } + } + if( ammunition > 0 && ammunition <= 10) + { + ammunition = ammunition - 1; + }else + { + Block block; + if (theCraft != null) { + for (int x = 0; x < theCraft.sizeX; x++) { + for (int z = 0; z < theCraft.sizeZ; z++) { + for (int y = 0; y < theCraft.sizeY; y++) { + + if( theCraft.matrix == null ) + return false; + + block = theCraft.world.getBlockAt(theCraft.minX + x, theCraft.minY + y, theCraft.minZ + z); + if (block.getType() == Material.EMERALD_ORE && ammunition < 1) { + reload(p); + setBlock(0, block, theCraft); + break; + } + } + } + } + } + if (ammunition < 1) { + p.sendMessage( ChatColor.RED + "Out of depth charges!"); + return false; + } + } + charged=1; + p.sendMessage(ChatColor.GREEN + "Depth charge dropper loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " depth charges left."); + }else{ + p.sendMessage(ChatColor.GREEN + "Depth charge dropper already loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " depth charges left."); + } + + return true; + }else if( cannonType == 5 ) + { + if( charged == 0 ) + { + Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); + if (theCraft != null) { + if (theCraft.type.canFly || theCraft.type.isTerrestrial) { + p.sendMessage(ChatColor.RED + "You can't use Depth Charges on an aircraft!"); + return false; + } + } + if( ammunition > 0 && ammunition <= 15) + { + ammunition = ammunition - 1; + }else + { + Block block; + if (theCraft != null) { + for (int x = 0; x < theCraft.sizeX; x++) { + for (int z = 0; z < theCraft.sizeZ; z++) { + for (int y = 0; y < theCraft.sizeY; y++) { + + if( theCraft.matrix == null ) + return false; + + block = theCraft.world.getBlockAt(theCraft.minX + x, theCraft.minY + y, theCraft.minZ + z); + if (block.getType() == Material.EMERALD_ORE && ammunition < 1) { + reload(p); + setBlock(0, block, theCraft); + break; + } + } + } + } + } + if (ammunition < 1) { + p.sendMessage( ChatColor.RED + "Out of depth charges!"); + return false; + } + } charged=1; - p.sendMessage("Bomb launcher loaded! " + ammunition + " bombs left."); + p.sendMessage(ChatColor.GREEN + "Depth charge launcher loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " depth charges left."); }else{ - p.sendMessage("Bomb launcher already loaded! " + ammunition + " bombs left."); + p.sendMessage(ChatColor.GREEN + "Depth charge launcher already loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " depth charges left."); } - - return true; - + + return true; + + }else if( cannonType == 9 ) + { + if( charged == 0 ) + { + if( ammunition > 0 && ammunition <= 2) + { + ammunition = ammunition - 1; + }else + { + Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); + Block block; + if (theCraft != null) { + for (int x = 0; x < theCraft.sizeX; x++) { + for (int z = 0; z < theCraft.sizeZ; z++) { + for (int y = 0; y < theCraft.sizeY; y++) { + + if( theCraft.matrix == null ) + return false; + + block = theCraft.world.getBlockAt(theCraft.minX + x, theCraft.minY + y, theCraft.minZ + z); + if (block.getType() == Material.EMERALD_ORE && ammunition < 1) { + reload(p); + setBlock(0, block, theCraft); + break; + } + } + } + } + } + if (ammunition < 1) { + p.sendMessage( ChatColor.RED + "Out of bombs!"); + return false; + } + } + charged=1; + p.sendMessage(ChatColor.GREEN + "Bomb dropper loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " bombs left."); + }else{ + p.sendMessage(ChatColor.GREEN + "Bomb dropper already loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " bombs left."); + } + + return true; + + }else if( cannonType == 10 ) + { + if( charged == 0 ) + { + if( ammunition > 0 && ammunition <= 6) + { + ammunition = ammunition - 1; + }else + { + Craft theCraft = Craft.getCraft(p.getTargetBlock(null, 100).getX(), p.getTargetBlock(null, 100).getY(), p.getTargetBlock(null, 100).getZ()); + Block block; + if (theCraft != null) { + for (int x = 0; x < theCraft.sizeX; x++) { + for (int z = 0; z < theCraft.sizeZ; z++) { + for (int y = 0; y < theCraft.sizeY; y++) { + + if( theCraft.matrix == null ) + return false; + + block = theCraft.world.getBlockAt(theCraft.minX + x, theCraft.minY + y, theCraft.minZ + z); + if (block.getType() == Material.EMERALD_ORE && ammunition < 1) { + reload(p); + setBlock(0, block, theCraft); + break; + } + } + } + } + } + if (ammunition < 1) { + p.sendMessage( ChatColor.RED + "Out of bombs!"); + return false; + } + } + charged=1; + p.sendMessage(ChatColor.GREEN + "Bomb launcher loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " bombs left."); + }else{ + p.sendMessage(ChatColor.GREEN + "Bomb launcher already loaded! " + ChatColor.YELLOW + ammunition + ChatColor.GREEN + " bombs left."); + } + + return true; + + }else + { + charged = 1; + return true; + } }else { - charged = 1; - return true; + charged=1; + p.sendMessage(ChatColor.GREEN + "Cannon Power X" + ChatColor.YELLOW + charged); + return false; } - }else - { - charged=1; - p.sendMessage("Cannon Power X" + charged); - return false; - } - - } else { - NavyCraft.instance.DebugMessage("Inventory was null", 3); - return false; - } + + } else { + NavyCraft.instance.DebugMessage("Inventory was null", 3); + return false; + } } private void setTimeout() { timeout = new Date().getTime(); @@ -1177,22 +1292,22 @@ public void loadTorpedoLever(boolean left, Player p) { if( loadTorpedo(left) ) { - p.sendMessage("Tube Loading!"); + p.sendMessage(ChatColor.GREEN + "Tube Loading!"); }else { - p.sendMessage("No torpedoes remaining for this tube!"); + p.sendMessage(ChatColor.RED + "No torpedoes remaining for this tube!"); } }else { - p.sendMessage("Open inner door before loading."); + p.sendMessage(ChatColor.YELLOW + "Open inner door before loading."); } }else { - p.sendMessage("Close outer doors first."); + p.sendMessage(ChatColor.YELLOW + "Close outer doors first."); } }else { - p.sendMessage("Tube already loaded."); + p.sendMessage(ChatColor.YELLOW + "Tube already loaded."); } } @@ -1564,7 +1679,7 @@ public void openTorpedoDoors(Player p, boolean inner, boolean leftInner) { if( checkProtectedRegion(p, p.getLocation()) ) { - p.sendMessage("You are in a protected region"); + p.sendMessage(ChatColor.RED + "You are in a protected region"); return; } @@ -1592,14 +1707,14 @@ public void openTorpedoDoors(Player p, boolean inner, boolean leftInner) { b.setType(Material.AIR); c.setType(Material.AIR); - p.sendMessage("Opening Outer Tube Doors!"); + p.sendMessage(ChatColor.GREEN + "Opening Outer Tube Doors!"); }else { - p.sendMessage("Close BOTH inner doors before opening outer doors."); + p.sendMessage(ChatColor.YELLOW + "Close BOTH inner doors before opening outer doors."); } }else { - p.sendMessage("Close BOTH inner doors before opening outer doors."); + p.sendMessage(ChatColor.YELLOW + "Close BOTH inner doors before opening outer doors."); } }else { @@ -1611,7 +1726,7 @@ public void openTorpedoDoors(Player p, boolean inner, boolean leftInner) testCraft.addBlock(b, true); testCraft.addBlock(c, true); } - p.sendMessage("Closing Outer Tube Doors!"); + p.sendMessage(ChatColor.GREEN + "Closing Outer Tube Doors!"); } }else ///inner doors { @@ -1653,7 +1768,7 @@ public void openTorpedoDoors(Player p, boolean inner, boolean leftInner) b.getRelative(direction,3).setType(Material.AIR); if( b.getRelative(direction,4).getTypeId() >= 8 && b.getRelative(direction,4).getTypeId() <= 11) b.getRelative(direction,4).setType(Material.AIR); - p.sendMessage("Opening Left Inner Tube Door!"); + p.sendMessage(ChatColor.GREEN + "Opening Left Inner Tube Door!"); } else { @@ -1666,11 +1781,11 @@ public void openTorpedoDoors(Player p, boolean inner, boolean leftInner) c.getRelative(direction,3).setType(Material.AIR); if( c.getRelative(direction,4).getTypeId() >= 8 && c.getRelative(direction,4).getTypeId() <= 11) c.getRelative(direction,4).setType(Material.AIR); - p.sendMessage("Opening Right Inner Tube Door!"); + p.sendMessage(ChatColor.GREEN + "Opening Right Inner Tube Door!"); } }else { - p.sendMessage("Close the OUTER doors before opening inner doors."); + p.sendMessage(ChatColor.YELLOW + "Close the OUTER doors before opening inner doors."); } }else { @@ -1681,7 +1796,7 @@ public void openTorpedoDoors(Player p, boolean inner, boolean leftInner) { testCraft.addBlock(b, true); } - p.sendMessage("Closing Left Inner Tube Door!"); + p.sendMessage(ChatColor.GREEN + "Closing Left Inner Tube Door!"); } else { @@ -1690,7 +1805,7 @@ public void openTorpedoDoors(Player p, boolean inner, boolean leftInner) { testCraft.addBlock(c, true); } - p.sendMessage("Closing Right Inner Tube Door!"); + p.sendMessage(ChatColor.GREEN + "Closing Right Inner Tube Door!"); } } } @@ -1703,13 +1818,13 @@ public void setTorpedoMode(Player p) switch( torpedoMode ) { case 0: - p.sendMessage("Firing Mode : Left Tube"); + p.sendMessage(ChatColor.GREEN + "Firing Mode : " + ChatColor.YELLOW + "Left Tube"); break; case 1: - p.sendMessage("Firing Mode : Right Tube"); + p.sendMessage(ChatColor.GREEN + "Firing Mode : " + ChatColor.YELLOW + "Right Tube"); break; case 2: - p.sendMessage("Firing Mode : Both"); + p.sendMessage(ChatColor.GREEN + "Firing Mode : " + ChatColor.YELLOW + "Both"); break; } } @@ -1718,7 +1833,7 @@ public void fireTorpedoButton(Player p) { if( checkProtectedRegion(p, p.getLocation()) ) { - p.sendMessage("You are in a protected region"); + p.sendMessage(ChatColor.RED + "You are in a protected region"); return; } @@ -1731,11 +1846,11 @@ public void fireTorpedoButton(Player p) fireLeft(p); }else { - p.sendMessage("Left Tube: Open Outer Doors and Close Left Inner Door"); + p.sendMessage(ChatColor.YELLOW + "Left Tube: Open Outer Doors and Close Left Inner Door"); } }else { - p.sendMessage("Left Tube: Tube Not Loaded"); + p.sendMessage(ChatColor.RED + "Left Tube: Tube Not Loaded"); } }else if( torpedoMode == 1) @@ -1747,12 +1862,12 @@ public void fireTorpedoButton(Player p) fireRight(p); }else { - p.sendMessage("Right Tube: Open Outer Doors and Close Right Inner Door"); + p.sendMessage(ChatColor.YELLOW + "Right Tube: Open Outer Doors and Close Right Inner Door"); } }else { - p.sendMessage("Right Tube: Tube Not Loaded"); + p.sendMessage(ChatColor.RED + "Right Tube: Tube Not Loaded"); } }else @@ -1764,12 +1879,12 @@ public void fireTorpedoButton(Player p) fireBoth(p); }else { - p.sendMessage("Both Tubes: Open Outer Doors and Close Both Inner Doors"); + p.sendMessage(ChatColor.YELLOW + "Both Tubes: Open Outer Doors and Close Both Inner Doors"); } }else { - p.sendMessage("Both Tubes: Both Tubes Not Loaded"); + p.sendMessage(ChatColor.RED + "Both Tubes: Both Tubes Not Loaded"); } } } @@ -1975,7 +2090,7 @@ public void run() torp.warhead.getRelative(torp.hdg, -2).setType(Material.WATER); torp.warhead.getRelative(torp.hdg, -3).setType(Material.WATER); } - p.sendMessage("Torpedo expired."); + p.sendMessage(ChatColor.RED + "Torpedo expired."); return; } @@ -2015,15 +2130,15 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Torpedo hit unknown object!"); + p.sendMessage(ChatColor.GREEN + "Torpedo hit unknown object!"); else - p.sendMessage("Torpedo hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Torpedo hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); }else { torp.dead = true; - p.sendMessage("Torpedo Dud (Too close)."); + p.sendMessage(ChatColor.RED + "Torpedo Dud (Too close)."); } @@ -2093,7 +2208,7 @@ public void run() if( !leftLoading && !rightLoading && !checkOuterDoorClosed() ) openTorpedoDoors(p, false, false); } - p.sendMessage("Dud Torpedo! Too close."); + p.sendMessage(ChatColor.RED + "Dud Torpedo! Too close."); torp.dead = true; } @@ -2112,7 +2227,7 @@ public void run() if( !torp.active ) { - p.sendMessage("Dud Torpedo! Too close."); + p.sendMessage(ChatColor.RED + "Dud Torpedo! Too close."); torp.dead = true; if( firingCraft != null ) { @@ -2158,9 +2273,9 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Torpedo detonated prematurely!"); + p.sendMessage(ChatColor.RED + "Torpedo detonated prematurely!"); else - p.sendMessage("Torpedo hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Torpedo hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); if( firingCraft != null ) @@ -2724,7 +2839,7 @@ public void run() torp.warhead.getRelative(torp.hdg, -2).setType(Material.WATER); torp.warhead.getRelative(torp.hdg, -3).setType(Material.WATER); } - p.sendMessage("Torpedo expired."); + p.sendMessage(ChatColor.RED + "Torpedo expired."); return; } @@ -2762,13 +2877,13 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Torpedo hit unknown object!"); + p.sendMessage(ChatColor.YELLOW + "Torpedo hit unknown object!"); else - p.sendMessage("Torpedo hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Torpedo hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); }else { - p.sendMessage("Torpedo Dud (Too close)."); + p.sendMessage(ChatColor.RED + "Torpedo Dud (Too close)."); torp.dead = true; } @@ -2842,7 +2957,7 @@ public void run() openTorpedoDoors(p, false, false); } torp.dead = true; - p.sendMessage("Dud Torpedo! Too close."); + p.sendMessage(ChatColor.RED + "Dud Torpedo! Too close."); } } @@ -2859,7 +2974,7 @@ public void run() if( !torp.active ) { - p.sendMessage("Dud Torpedo! Too close."); + p.sendMessage(ChatColor.RED + "Dud Torpedo! Too close."); torp.dead = true; if( firingCraft != null ) { @@ -2905,9 +3020,9 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Torpedo detonated prematurely!"); + p.sendMessage(ChatColor.RED + "Torpedo detonated prematurely!"); else - p.sendMessage("Torpedo hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Torpedo hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); if( firingCraft != null ) @@ -3486,7 +3601,7 @@ public void run() torp.warhead.getRelative(torp.hdg, -2).setType(Material.WATER); torp.warhead.getRelative(torp.hdg, -3).setType(Material.WATER); } - p.sendMessage("Torpedo expired."); + p.sendMessage(ChatColor.RED + "Torpedo expired."); if( firingCraft != null ) { firingCraft.tubeFiringMode.put(torp.tubeNum, -2); firingCraft.tubeFiringDepth.put(torp.tubeNum, 1); @@ -3544,9 +3659,9 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Torpedo hit unknown object!"); + p.sendMessage(ChatColor.YELLOW + "Torpedo hit unknown object!"); else - p.sendMessage("Torpedo hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Torpedo hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); if( firingCraft != null ) { firingCraft.tubeFiringMode.put(torp.tubeNum, -2); @@ -3561,7 +3676,7 @@ public void run() //cm.structureUpdate(null); }else { - p.sendMessage("Torpedo Dud (Inactive)."); + p.sendMessage(ChatColor.RED + "Torpedo Dud (Inactive)."); if( firingCraft != null ) { firingCraft.tubeFiringMode.put(torp.tubeNum, -2); firingCraft.tubeFiringDepth.put(torp.tubeNum, 1); @@ -3621,7 +3736,7 @@ public void run() torp.warhead.getRelative(torp.hdg, -3).setTypeIdAndData(35, (byte) 0x7, false); }else { - p.sendMessage("Dud Torpedo! Too close."); + p.sendMessage(ChatColor.RED + "Dud Torpedo! Too close."); torp.dead=true; if( firingCraft != null ) { firingCraft.tubeFiringMode.put(torp.tubeNum, -2); @@ -3656,7 +3771,7 @@ public void run() if( !torp.active ) { - p.sendMessage("Dud Torpedo! Too close."); + p.sendMessage(ChatColor.RED + "Dud Torpedo! Too close."); torp.dead = true; if( firingCraft != null ) { @@ -3701,9 +3816,9 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Torpedo detonated prematurely!"); + p.sendMessage(ChatColor.YELLOW + "Torpedo detonated prematurely!"); else - p.sendMessage("Torpedo hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Torpedo hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); if( firingCraft != null ) @@ -4038,7 +4153,7 @@ public void openMissileDoors(Player p) { if( checkProtectedRegion(p, p.getLocation()) ) { - p.sendMessage("You are in a protected region"); + p.sendMessage(ChatColor.RED + "You are in a protected region"); return; } @@ -4060,7 +4175,7 @@ public void openMissileDoors(Player p) { b.setType(Material.AIR); c.setType(Material.AIR); - p.sendMessage("Opening Outer Tube Doors!"); + p.sendMessage(ChatColor.GREEN + "Opening Outer Tube Doors!"); }else { b.setType(Material.CLAY); @@ -4071,7 +4186,7 @@ public void openMissileDoors(Player p) testCraft.addBlock(b, true); testCraft.addBlock(c, true); } - p.sendMessage("Closing Outer Tube Doors!"); + p.sendMessage(ChatColor.GREEN + "Closing Outer Tube Doors!"); } } @@ -4079,7 +4194,7 @@ public void openMissileDoorsV(Player p) { if( checkProtectedRegion(p, p.getLocation()) ) { - p.sendMessage("You are in a protected region"); + p.sendMessage(ChatColor.RED + "You are in a protected region"); return; } @@ -4089,7 +4204,7 @@ public void openMissileDoorsV(Player p) if( checkOuterDoorClosedV() ) { a.setType(Material.AIR); - p.sendMessage("Opening Outer Tube Doors!"); + p.sendMessage(ChatColor.GREEN + "Opening Outer Tube Doors!"); }else { a.setType(Material.CLAY); @@ -4098,7 +4213,7 @@ public void openMissileDoorsV(Player p) { testCraft.addBlock(a, true); } - p.sendMessage("Closing Outer Tube Doors!"); + p.sendMessage(ChatColor.GREEN + "Closing Outer Tube Doors!"); } } @@ -4109,13 +4224,13 @@ public void setMissileMode(Player p) switch( missileMode ) { case 0: - p.sendMessage("Firing Mode : Left Tube"); + p.sendMessage(ChatColor.GREEN + "Firing Mode : " + ChatColor.YELLOW + "Left Tube"); break; case 1: - p.sendMessage("Firing Mode : Right Tube"); + p.sendMessage(ChatColor.GREEN + "Firing Mode : " + ChatColor.YELLOW + "Right Tube"); break; case 2: - p.sendMessage("Firing Mode : Both"); + p.sendMessage(ChatColor.GREEN + "Firing Mode : " + ChatColor.YELLOW + "Both"); break; } } @@ -4126,15 +4241,14 @@ public void setMissileRange(Player p) range = range + 5; else range = 0; - p.sendMessage("Range set to " + range + "m."); + p.sendMessage(ChatColor.GREEN + "Range set to " + ChatColor.YELLOW + range + ChatColor.GREEN + "m."); } public void fireMissileButton(Player p, boolean isVertical) { - NavyCraft.instance.DebugMessage("Ran fire method, is vertical:" + isVertical, 3); if( checkProtectedRegion(p, p.getLocation()) ) { - p.sendMessage("You are in a protected region"); + p.sendMessage(ChatColor.RED + "You are in a protected region"); return; } @@ -4146,11 +4260,11 @@ public void fireMissileButton(Player p, boolean isVertical) fireVertical(p); }else { - p.sendMessage("Missile: Open Outer Doors"); + p.sendMessage(ChatColor.YELLOW + "Missile: Open Outer Doors"); } }else { - p.sendMessage("Missile: Tube Not Loaded"); + p.sendMessage(ChatColor.RED + "Missile: Tube Not Loaded"); } } else { @@ -4163,11 +4277,11 @@ public void fireMissileButton(Player p, boolean isVertical) fireLeft(p); }else { - p.sendMessage("Left Tube: Open Outer Doors"); + p.sendMessage(ChatColor.YELLOW + "Left Tube: Open Outer Doors"); } }else { - p.sendMessage("Left Tube: Tube Not Loaded"); + p.sendMessage(ChatColor.RED + "Left Tube: Tube Not Loaded"); } }else if( missileMode == 1) @@ -4179,12 +4293,12 @@ public void fireMissileButton(Player p, boolean isVertical) fireRight(p); }else { - p.sendMessage("Right Tube: Open Outer Doors"); + p.sendMessage(ChatColor.YELLOW + "Right Tube: Open Outer Doors"); } }else { - p.sendMessage("Right Tube: Tube Not Loaded"); + p.sendMessage(ChatColor.RED + "Right Tube: Tube Not Loaded"); } }else @@ -4196,12 +4310,12 @@ public void fireMissileButton(Player p, boolean isVertical) fireBoth(p); }else { - p.sendMessage("Both Tubes: Open Outer Doors"); + p.sendMessage(ChatColor.YELLOW + "Both Tubes: Open Outer Doors"); } }else { - p.sendMessage("Both Tubes: Both Tubes Not Loaded"); + p.sendMessage(ChatColor.RED + "Both Tubes: Both Tubes Not Loaded"); } } } @@ -4424,7 +4538,7 @@ public void run() torp.warhead.getRelative(torp.hdg, -2).setType(Material.WATER); torp.warhead.getRelative(torp.hdg, -3).setType(Material.WATER); } - p.sendMessage("Missile expired."); + p.sendMessage(ChatColor.YELLOW + "Missile expired."); return; } @@ -4464,15 +4578,16 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Missile hit unknown object!"); + p.sendMessage(ChatColor.YELLOW + "Missile hit unknown object!"); else - p.sendMessage("Missile hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Missile hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); }else { torp.dead = true; - p.sendMessage("Missile Dud (Too close)."); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); + } @@ -4526,7 +4641,7 @@ public void run() { firingCraft.waitTorpLoading--; } - p.sendMessage("Dud Missile! Too close."); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); torp.dead = true; } @@ -4540,12 +4655,13 @@ public void run() if( checkProtectedRegion(p, torp.warhead.getLocation()) ) { p.sendMessage(ChatColor.RED + "No missile explosions in dock area."); + torp.dead = true; return; } if( !torp.active ) { - p.sendMessage("Dud Missile! Too close."); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); torp.dead = true; if( firingCraft != null ) { @@ -4575,9 +4691,9 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Missile detonated prematurely!"); + p.sendMessage(ChatColor.RED + "Missile detonated prematurely!"); else - p.sendMessage("Missile hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Missile hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); if( firingCraft != null ) @@ -4606,7 +4722,7 @@ public void run() // @Override public void run() { - if( !torp.dead ) + if( !torp.dead ) { NavyCraft.instance.DebugMessage(Integer.toString(i), 3); int depthDifference = torp.setDepth - torp.warhead.getY(); @@ -4618,10 +4734,10 @@ public void run() torp.torpRotation = 3; NavyCraft.instance.DebugMessage(Integer.toString(torp.torpRotation) + ", tried to change to 3", 3); } - }else if ( depthDifference == 0) { - torp.hdg = direction; + }else if (torp.torpRotation == 4 && depthDifference <= 0) { + torp.hdg = torp.ohdg; } - if(( torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(direction, -1).getTypeId() == 35 && torp.warhead.getRelative(direction, -2).getTypeId() == 35 && torp.warhead.getRelative(direction, -3).getTypeId() == 35) || (torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -1).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -2).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -3).getTypeId() == 35) || (torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -1).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -2).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -3).getTypeId() == 35)) + if(( torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(torp.hdg, -1).getTypeId() == 35 && torp.warhead.getRelative(torp.hdg, -2).getTypeId() == 35 && torp.warhead.getRelative(torp.hdg, -3).getTypeId() == 35) || (torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -1).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -2).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -3).getTypeId() == 35) || (torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -1).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -2).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -3).getTypeId() == 35)) { CraftMover.playWeaponSound(torp.warhead.getLocation(), Sound.ENTITY_PLAYER_BREATH, 2.0f, 0.8f); if( i > 15 ) @@ -4671,13 +4787,15 @@ public void run() torp.torpRotation = -1; } - if (depthDifference < 0 && (torp.setRange - (i + 16) < 0)) { - torp.hdg = BlockFace.DOWN; - torp.torpRotation = 2; - if (depthDifference == -1) { - torp.torpRotation = 3; + if (depthDifference <= 0) torp.rangeCounter++; + + if (depthDifference < 0 && (torp.setRange - torp.rangeCounter < 0)) { + torp.hdg = BlockFace.DOWN; + torp.torpRotation = 2; + if (depthDifference == -1) { + torp.torpRotation = 3; + } } - } //new position torp.warhead = torp.warhead.getRelative(torp.hdg); @@ -4699,7 +4817,7 @@ public void run() torp.warhead.getRelative(torp.hdg, -2).setType(Material.WATER); torp.warhead.getRelative(torp.hdg, -3).setType(Material.WATER); } - p.sendMessage("Missile expired."); + p.sendMessage(ChatColor.YELLOW + "Missile expired."); return; } torp.warhead.setTypeIdAndData(35, (byte) 0xB, false); @@ -4738,15 +4856,15 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Missile hit unknown object!"); + p.sendMessage(ChatColor.YELLOW + "Missile hit unknown object!"); else - p.sendMessage("Missile hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Missile hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); }else { torp.dead = true; - p.sendMessage("Missile Dud (Too close).1"); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); } @@ -4817,7 +4935,7 @@ public void run() if( !leftLoading && !rightLoading && !checkOuterDoorClosedV() ) openMissileDoorsV(p); } - p.sendMessage("Dud Missile! Too close.2"); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); torp.dead = true; } @@ -4836,7 +4954,7 @@ public void run() if( !torp.active ) { - p.sendMessage("Dud Missile! Too close.3"); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); torp.dead = true; if( firingCraft != null ) { @@ -4882,9 +5000,9 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Missile detonated prematurely!1"); + p.sendMessage(ChatColor.RED + "Missile detonated prematurely!"); else - p.sendMessage("Missile hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Missile hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); if( firingCraft != null ) @@ -4977,7 +5095,6 @@ public void fireMissileMk2(final Player p, final Block b, final BlockFace torpHe if( testCraft != null && testCraft.tubeMk1FiringDisplay > -1 ) { - torp.setDepth = torpDepth; Player onScopePlayer=null; for( Periscope per: testCraft.periscopes ) { @@ -5007,21 +5124,25 @@ else if( testCraft.lastPeriscopeYaw != -9999 && testCraft.tubeMk1FiringMode == - else { rotation = (float) Math.PI * (torpRotation+180f) / 180f; - } + if( onScopePlayer != null && testCraft.tubeMk1FiringMode == -1 ) + torp.setDepth = (int) onScopePlayer.getTargetBlock(null, 250).getY(); + else if( testCraft.lastPeriscopeLookLoc != null && testCraft.tubeMk1FiringMode == -1 ) + torp.setDepth = (int) testCraft.lastPeriscopeLookLoc.getY(); + if( left ) rotation -= testCraft.tubeMk1FiringSpread*Math.PI/180f; else rotation += testCraft.tubeMk1FiringSpread*Math.PI/180f; + float nx = -(float) Math.sin(rotation); float nz = (float) Math.cos(rotation); ////north //p.sendMessage("torpRotation=" + torpRotation + " rotation=" + rotation); - if( torpRotation%360 == 0 ) { @@ -5445,7 +5566,6 @@ public void run() } - //check new position if( torp.warhead.getType() == Material.AIR ) { @@ -5464,7 +5584,7 @@ public void run() torp.warhead.getRelative(torp.hdg, -2).setType(Material.WATER); torp.warhead.getRelative(torp.hdg, -3).setType(Material.WATER); } - p.sendMessage("Missile expired."); + p.sendMessage(ChatColor.YELLOW + "Missile expired."); return; } @@ -5502,13 +5622,13 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Missile hit unknown object!"); + p.sendMessage(ChatColor.YELLOW +"Missile hit unknown object!"); else - p.sendMessage("Missile hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN +"Missile hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); }else { - p.sendMessage("Missile Dud (Too close)."); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); torp.dead = true; } @@ -5566,7 +5686,7 @@ public void run() firingCraft.waitTorpLoading--; } torp.dead = true; - p.sendMessage("Dud Missile! Too close."); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); } } @@ -5583,7 +5703,7 @@ public void run() if( !torp.active ) { - p.sendMessage("Dud Missile! Too close."); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); torp.dead = true; if( firingCraft != null ) { @@ -5613,9 +5733,9 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Missile detonated prematurely!"); + p.sendMessage(ChatColor.RED + "Missile detonated prematurely!"); else - p.sendMessage("Missile hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Missile hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); if( firingCraft != null ) @@ -5657,8 +5777,8 @@ public void run() torp.torpRotation = 3; NavyCraft.instance.DebugMessage(Integer.toString(torp.torpRotation) + ", tried to change to 3", 3); } - }else if (torp.torpRotation == 4 && depthDifference == 0) { - torp.hdg = direction; + }else if (torp.torpRotation == 4 && depthDifference <= 0) { + torp.hdg = torp.ohdg; } if(( torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(torp.hdg, -1).getTypeId() == 35 && torp.warhead.getRelative(torp.hdg, -2).getTypeId() == 35 && torp.warhead.getRelative(torp.hdg, -3).getTypeId() == 35) || (torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -1).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -2).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.UP, -3).getTypeId() == 35) || (torp.warhead.getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -1).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -2).getTypeId() == 35 && torp.warhead.getRelative(BlockFace.DOWN, -3).getTypeId() == 35)) { @@ -5710,7 +5830,9 @@ public void run() torp.torpRotation = -1; } - if (depthDifference < 0 && (torp.setRange - (i + 15) < 0)) { + if (depthDifference <= 0) torp.rangeCounter++; + + if (depthDifference < 0 && (torp.setRange - torp.rangeCounter < 0)) { torp.hdg = BlockFace.DOWN; torp.torpRotation = 2; if (depthDifference == -1) { @@ -5721,7 +5843,7 @@ public void run() //new position torp.warhead = torp.warhead.getRelative(torp.hdg); - if (depthDifference == 0) { + if (torp.torpRotation == 4) { if( torp.turnProgress > -1 ) { @@ -5805,7 +5927,7 @@ public void run() torp.warhead.getRelative(torp.hdg, -2).setType(Material.WATER); torp.warhead.getRelative(torp.hdg, -3).setType(Material.WATER); } - p.sendMessage("Missile expired."); + p.sendMessage(ChatColor.YELLOW +"Missile expired."); return; } torp.warhead.setTypeIdAndData(35, (byte) 0xE, false); @@ -5844,15 +5966,15 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Missile hit unknown object!"); + p.sendMessage(ChatColor.YELLOW + "Missile hit unknown object!"); else - p.sendMessage("Missile hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Missile hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); }else { torp.dead = true; - p.sendMessage("Missile Dud (Too close).1"); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); } @@ -5923,7 +6045,7 @@ public void run() if( !leftLoading && !rightLoading && !checkOuterDoorClosedV() ) openMissileDoorsV(p); } - p.sendMessage("Dud Missile! Too close.2"); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); torp.dead = true; } @@ -5942,7 +6064,7 @@ public void run() if( !torp.active ) { - p.sendMessage("Dud Missile! Too close.3"); + p.sendMessage(ChatColor.RED + "Dud Missile! Too close."); torp.dead = true; if( firingCraft != null ) { @@ -5988,9 +6110,9 @@ public void run() } if( checkCraft == null ) - p.sendMessage("Missile detonated prematurely!1"); + p.sendMessage(ChatColor.YELLOW + "Missile detonated prematurely!"); else - p.sendMessage("Missile hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Missile hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); if( firingCraft != null ) @@ -6146,7 +6268,7 @@ public boolean isValidCannon(Block b, boolean isDropper) { cannonType = 0; if( ammunition == -1 ) { - ammunition = 40; + ammunition = 15; initAmmo = ammunition; } if (b.getRelative(BlockFace.NORTH, 3).getType() == Material.PUMPKIN) @@ -6159,7 +6281,7 @@ public boolean isValidCannon(Block b, boolean isDropper) { cannonType = 6; if( ammunition == -1 ) { - ammunition = 20; + ammunition = 10; initAmmo = ammunition; } } @@ -6171,7 +6293,7 @@ public boolean isValidCannon(Block b, boolean isDropper) { cannonType = 0; if( ammunition == -1 ) { - ammunition = 40; + ammunition = 15; initAmmo = ammunition; } if (b.getRelative(BlockFace.EAST, 3).getType() == Material.PUMPKIN) @@ -6183,7 +6305,7 @@ public boolean isValidCannon(Block b, boolean isDropper) { cannonType = 6; if( ammunition == -1 ) { - ammunition = 20; + ammunition = 10; initAmmo = ammunition; } } @@ -6195,7 +6317,7 @@ public boolean isValidCannon(Block b, boolean isDropper) { cannonType = 0; if( ammunition == -1 ) { - ammunition = 40; + ammunition = 15; initAmmo = ammunition; } if (b.getRelative(BlockFace.SOUTH, 3).getType() == Material.PUMPKIN) @@ -6207,7 +6329,7 @@ public boolean isValidCannon(Block b, boolean isDropper) { { if( ammunition == -1 ) { - ammunition = 20; + ammunition = 10; initAmmo = ammunition; } cannonType = 6; @@ -6220,7 +6342,7 @@ public boolean isValidCannon(Block b, boolean isDropper) { cannonType = 0; if( ammunition == -1 ) { - ammunition = 40; + ammunition = 10; initAmmo = ammunition; } if (b.getRelative(BlockFace.WEST, 3).getType() == Material.PUMPKIN) @@ -6233,14 +6355,11 @@ public boolean isValidCannon(Block b, boolean isDropper) { cannonType = 6; if( ammunition == -1 ) { - ammunition = 20; + ammunition = 10; initAmmo = ammunition; } } } - //check for cannon type 2 (fireball) - if( direction != null && b.getRelative(BlockFace.DOWN, 1).getType() == Material.DIAMOND_BLOCK ) - cannonType = 2; @@ -6258,7 +6377,7 @@ else if(b.getRelative(BlockFace.NORTH_EAST, 1).getType() == Material.PUMPKIN cannonLength = 2; if( ammunition == -1 ) { - ammunition = 30; + ammunition = 10; initAmmo = ammunition; } } @@ -6275,7 +6394,7 @@ else if(b.getRelative(BlockFace.SOUTH_WEST, 1).getType() == Material.PUMPKIN cannonLength = 2; if( ammunition == -1 ) { - ammunition = 30; + ammunition = 10; initAmmo = ammunition; } } @@ -6397,7 +6516,7 @@ else if(b.getRelative(BlockFace.SOUTH_WEST, 1).getType() == Material.PUMPKIN cannonType = 5; if( ammunition == -1 ) { - ammunition = 20; + ammunition = 15; initAmmo = ammunition; } }else if(b.getRelative(BlockFace.SOUTH, 1).getType() == Material.GOLD_BLOCK && b.getRelative(BlockFace.DOWN, 1).getType() == Material.LAPIS_BLOCK) @@ -6406,7 +6525,7 @@ else if(b.getRelative(BlockFace.SOUTH_WEST, 1).getType() == Material.PUMPKIN cannonType = 5; if( ammunition == -1 ) { - ammunition = 20; + ammunition = 15; initAmmo = ammunition; } }else if(b.getRelative(BlockFace.EAST, 1).getType() == Material.GOLD_BLOCK && b.getRelative(BlockFace.DOWN, 1).getType() == Material.LAPIS_BLOCK) @@ -6415,7 +6534,7 @@ else if(b.getRelative(BlockFace.SOUTH_WEST, 1).getType() == Material.PUMPKIN cannonType = 5; if( ammunition == -1 ) { - ammunition = 20; + ammunition = 15; initAmmo = ammunition; } }else if(b.getRelative(BlockFace.WEST, 1).getType() == Material.GOLD_BLOCK && b.getRelative(BlockFace.DOWN, 1).getType() == Material.LAPIS_BLOCK) @@ -6424,7 +6543,7 @@ else if(b.getRelative(BlockFace.SOUTH_WEST, 1).getType() == Material.PUMPKIN cannonType = 5; if( ammunition == -1 ) { - ammunition = 20; + ammunition = 15; initAmmo = ammunition; } } @@ -6498,170 +6617,372 @@ public int[][] rotateLeft(int[][] arr) { public byte[][] rotateRightB(byte[][] arr, int[][] arro) { byte[][] result = new byte[arr.length][arr.length]; + byte[] cardinals; + int blockId; for (int x = 0; x < arr.length; x++) { for (int y = 0; y < arr.length; y++) { result[x][y] = arr[arr.length - 1 - y][x]; - if( arro[x][y] == 77 || arro[x][y] == 69 ) - { - switch (result[x][y]) { - case (byte) 0x3: - result[x][y] = (byte) 0x1; - break; - case (byte) 0x4: - result[x][y] = (byte) 0x2; - break; - case (byte) 0x2: - result[x][y] = (byte) 0x3; - break; - case (byte) 0x1: - result[x][y] = (byte) 0x4; - break; - case (byte) 0x9: - result[x][y] = (byte) 0x4; - break; - case (byte) 0xA: - result[x][y] = (byte) 0x3; - break; - case (byte) 0xB: - result[x][y] = (byte) 0x1; - break; - case (byte) 0xC: - result[x][y] = (byte) 0x2; - break; + blockId = arro[x][y]; + int dr = 270; + + //Block theBlock = craft.getWorldBlock(dataBlock.x, dataBlock.y, dataBlock.z); + + //logs + if( blockId == 17 && result[x][y] > 3 ) + { + if( result[x][y] < 8 ) + result[x][y] += 4; + else + result[x][y] -= 4; } - }else if( arro[x][y] == 86 ) - { - switch (result[x][y]) { - case (byte) 0x0: - result[x][y] = (byte) 0x3; - break; - case (byte) 0x1: - result[x][y] = (byte) 0x0; - break; - case (byte) 0x2: - result[x][y] = (byte) 0x1; - break; - case (byte) 0x3: - result[x][y] = (byte) 0x2; - break; + + //quartz block + if( blockId == 155 && result[x][y] > 2 ) + { + if( result[x][y] == 3) + result[x][y] = 4; + else + result[x][y] = 3; } - }else - { - switch (result[x][y]) { - case (byte) 0x3: - result[x][y] = (byte) 0x1; - break; - case (byte) 0x4: - result[x][y] = (byte) 0x2; - break; - case (byte) 0x2: - result[x][y] = (byte) 0x3; - break; - case (byte) 0x1: - result[x][y] = (byte) 0x4; - break; - case (byte) 0x9: - result[x][y] = (byte) 0x1; - break; - case (byte) 0xA: - result[x][y] = (byte) 0x2; - break; - case (byte) 0xB: - result[x][y] = (byte) 0x3; - break; - case (byte) 0xC: - result[x][y] = (byte) 0x4; - break; + + //hay bales + if( blockId == 170 && result[x][y] > 3 ) + { + if( result[x][y] < 8 ) + result[x][y] += 4; + else + result[x][y] -= 4; + } + + //torches, skip 'em if they're centered on the tile on the ground + if(blockId == 50 || blockId == 75 || blockId == 76) { + if(result[x][y] == 5) + continue; + } + + if( blockId == 33 || blockId == 29 || blockId == 34 ) + { + if( result[x][y] == 0 || result[x][y] == 1 || result[x][y] == 8 || result[x][y] == 9 ) + { + if( result[x][y] == 0 ) + result[x][y] = 1; + if( result[x][y] == 8 ) + result[x][y] = 9; + continue; + } } - } - } - } - return result; - } - public byte[][] rotateLeftB(byte[][] arr, int[][] arro) { - byte[][] result = new byte[arr.length][arr.length]; - for (int x = 0; x < arr.length; x++) { - for (int y = 0; y < arr.length; y++) { - result[x][y] = arr[y][arr.length - 1 - x]; - if( arro[x][y] == 77 || arro[x][y] == 69 ) - { - switch (result[x][y]) { - case (byte) 0x3: - result[x][y] = (byte) 0x2; - break; - case (byte) 0x4: - result[x][y] = (byte) 0x1; - break; - case (byte) 0x2: - result[x][y] = (byte) 0x4; - break; - case (byte) 0x1: - result[x][y] = (byte) 0x3; - break; - case (byte) 0x9: - result[x][y] = (byte) 0x3; - break; - case (byte) 0xA: - result[x][y] = (byte) 0x4; - break; - case (byte) 0xB: - result[x][y] = (byte) 0x2; - break; - case (byte) 0xC: - result[x][y] = (byte) 0x1; - break; + if(BlocksInfo.getCardinals(blockId) != null) + cardinals = Arrays.copyOf(BlocksInfo.getCardinals(blockId), 4); + else + cardinals = null; + + + ////stairs + if( blockId == 53 || blockId == 67 || blockId == 108 || blockId == 109 || blockId == 114 || blockId == 128 || blockId == 134 || blockId == 135 || blockId == 136 || blockId == 156 || blockId == 180 ) + { + if(result[x][y] > 3) + { //upside down + for(int c = 0; c < 4; c++) { + cardinals[c] += 4; + } + } } - }else if( arro[x][y] == 86 ) - { - switch (result[x][y]) { - case (byte) 0x0: - result[x][y] = (byte) 0x1; - break; - case (byte) 0x1: - result[x][y] = (byte) 0x2; - break; - case (byte) 0x2: - result[x][y] = (byte) 0x3; - break; - case (byte) 0x3: - result[x][y] = (byte) 0x0; - break; + + if(blockId == 26) { //bed + if(result[x][y] >= 8) { + for(int c = 0; c < 4; c++) + cardinals[c] += 8; + } } - }else - { - switch (result[x][y]) { - case (byte) 0x1: - result[x][y] = (byte) 0x3; - break; - case (byte) 0x2: - result[x][y] = (byte) 0x4; - break; - case (byte) 0x3: - result[x][y] = (byte) 0x2; - break; - case (byte) 0x4: - result[x][y] = (byte) 0x1; - break; - case (byte) 0x9: - result[x][y] = (byte) 0x3; - break; - case (byte) 0xA: - result[x][y] = (byte) 0x4; - break; - case (byte) 0xB: - result[x][y] = (byte) 0x2; - break; - case (byte) 0xC: - result[x][y] = (byte) 0x1; - break; + + if(blockId == 64 || blockId == 71 || blockId == 193 || blockId == 194 || blockId == 195 || blockId == 196 || blockId == 197//wooden or steel door + || blockId == 93 || blockId == 94) { //repeater + + if(result[x][y] >= 12) { //if the door is an open top + for(int c = 0; c < 4; c++) + cardinals[c] += 12; + } else if (result[x][y] >= 8) { //if the door is a top + for(int c = 0; c < 4; c++) + cardinals[c] += 8; + } else if (result[x][y] >= 4) { //not a top, but open + for(int c = 0; c < 4; c++) + cardinals[c] += 4; + } + } + + if (blockId == 66 ) { // rails + if(result[x][y] == 0) { + result[x][y] = 1; + continue; + } + if(result[x][y] == 1) { + result[x][y] = 0; + continue; + } + } + + if(blockId == 69) { //lever + + if(result[x][y] == 5 || result[x][y] == 6 || //if it's on the floor + result[x][y] == 13 || result[x][y] == 14) { + cardinals = new byte[]{6, 5, 14, 13}; + } + else if(result[x][y] > 4) { //switched on + for(int c = 0; c < 4; c++) { + cardinals[c] += 8; + } + } + } + + if(blockId == 77 || blockId == 143) { //button + + if(result[x][y] > 4) + { //switched on + for(int c = 0; c < 4; c++) { + cardinals[c] += 8; + } + } + } + + if(blockId == 96||blockId == 167) { //hatch + + if(result[x][y] > 4) + { //switched on + for(int c = 0; c < 4; c++) { + cardinals[c] += 4; + } + } + } + + if(blockId == 93 || blockId == 94) { //repeater + if(result[x][y] > 11) { + for(int c = 0; c < 4; c++) + cardinals[c] += 12; + } + else if(result[x][y] > 7) { + for(int c = 0; c < 4; c++) + cardinals[c] += 8; + } + else if(result[x][y] > 3) { + for(int c = 0; c < 4; c++) + cardinals[c] += 4; + } + } + + if(cardinals != null) { + NavyCraft.instance.DebugMessage(Material.getMaterial(blockId) + + " Cardinals are " + + cardinals[0] + ", " + + cardinals[1] + ", " + + cardinals[2] + ", " + + cardinals[3], 2); + + int i = 0; + for(i = 0; i < 3; i++) + if(result[x][y] == cardinals[i]) + break; + + NavyCraft.instance.DebugMessage("i starts as " + i + " which is " + cardinals[i], 2); + + i += (dr / 90); + + if(i > 3) + i = i - 4; + + NavyCraft.instance.DebugMessage("i ends as " + i + ", which is " + cardinals[i], 2); + + result[x][y] = cardinals[i]; } } - } } return result; } + public byte[][] rotateLeftB(byte[][] arr, int[][] arro) { + byte[][] result = new byte[arr.length][arr.length]; + byte[] cardinals; + int blockId; + for (int x = 0; x < arr.length; x++) { + for (int y = 0; y < arr.length; y++) { + result[x][y] = arr[y][arr.length - 1 - x]; + blockId = arro[x][y]; + int dr = 90; + + //Block theBlock = craft.getWorldBlock(dataBlock.x, dataBlock.y, dataBlock.z); + + //logs + if( blockId == 17 && result[x][y] > 3 ) + { + if( result[x][y] < 8 ) + result[x][y] += 4; + else + result[x][y] -= 4; + } + + //quartz block + if( blockId == 155 && result[x][y] > 2 ) + { + if( result[x][y] == 3) + result[x][y] = 4; + else + result[x][y] = 3; + } + + //hay bales + if( blockId == 170 && result[x][y] > 3 ) + { + if( result[x][y] < 8 ) + result[x][y] += 4; + else + result[x][y] -= 4; + } + + //torches, skip 'em if they're centered on the tile on the ground + if(blockId == 50 || blockId == 75 || blockId == 76) { + if(result[x][y] == 5) + continue; + } + + if( blockId == 33 || blockId == 29 || blockId == 34 ) + { + if( result[x][y] == 0 || result[x][y] == 1 || result[x][y] == 8 || result[x][y] == 9 ) + { + if( result[x][y] == 0 ) + result[x][y] = 1; + if( result[x][y] == 8 ) + result[x][y] = 9; + continue; + } + } + + if(BlocksInfo.getCardinals(blockId) != null) + cardinals = Arrays.copyOf(BlocksInfo.getCardinals(blockId), 4); + else + cardinals = null; + + + ////stairs + if( blockId == 53 || blockId == 67 || blockId == 108 || blockId == 109 || blockId == 114 || blockId == 128 || blockId == 134 || blockId == 135 || blockId == 136 || blockId == 156 || blockId == 180 ) + { + if(result[x][y] > 3) + { //upside down + for(int c = 0; c < 4; c++) { + cardinals[c] += 4; + } + } + } + + if(blockId == 26) { //bed + if(result[x][y] >= 8) { + for(int c = 0; c < 4; c++) + cardinals[c] += 8; + } + } + + if(blockId == 64 || blockId == 71 || blockId == 193 || blockId == 194 || blockId == 195 || blockId == 196 || blockId == 197//wooden or steel door + || blockId == 93 || blockId == 94) { //repeater + + if(result[x][y] >= 12) { //if the door is an open top + for(int c = 0; c < 4; c++) + cardinals[c] += 12; + } else if (result[x][y] >= 8) { //if the door is a top + for(int c = 0; c < 4; c++) + cardinals[c] += 8; + } else if (result[x][y] >= 4) { //not a top, but open + for(int c = 0; c < 4; c++) + cardinals[c] += 4; + } + } + + if (blockId == 66 ) { // rails + if(result[x][y] == 0) { + result[x][y] = 1; + continue; + } + if(result[x][y] == 1) { + result[x][y] = 0; + continue; + } + } + + if(blockId == 69) { //lever + + if(result[x][y] == 5 || result[x][y] == 6 || //if it's on the floor + result[x][y] == 13 || result[x][y] == 14) { + cardinals = new byte[]{6, 5, 14, 13}; + } + else if(result[x][y] > 4) { //switched on + for(int c = 0; c < 4; c++) { + cardinals[c] += 8; + } + } + } + + if(blockId == 77 || blockId == 143) { //button + + if(result[x][y] > 4) + { //switched on + for(int c = 0; c < 4; c++) { + cardinals[c] += 8; + } + } + } + + if(blockId == 96||blockId == 167) { //hatch + + if(result[x][y] > 4) + { //switched on + for(int c = 0; c < 4; c++) { + cardinals[c] += 4; + } + } + } + + if(blockId == 93 || blockId == 94) { //repeater + if(result[x][y] > 11) { + for(int c = 0; c < 4; c++) + cardinals[c] += 12; + } + else if(result[x][y] > 7) { + for(int c = 0; c < 4; c++) + cardinals[c] += 8; + } + else if(result[x][y] > 3) { + for(int c = 0; c < 4; c++) + cardinals[c] += 4; + } + } + + if(cardinals != null) { + NavyCraft.instance.DebugMessage(Material.getMaterial(blockId) + + " Cardinals are " + + cardinals[0] + ", " + + cardinals[1] + ", " + + cardinals[2] + ", " + + cardinals[3], 2); + + int i = 0; + for(i = 0; i < 3; i++) + if(result[x][y] == cardinals[i]) + break; + + NavyCraft.instance.DebugMessage("i starts as " + i + " which is " + cardinals[i], 2); + + i += (dr / 90); + + if(i > 3) + i = i - 4; + + NavyCraft.instance.DebugMessage("i ends as " + i + ", which is " + cardinals[i], 2); + + result[x][y] = cardinals[i]; + } + } + } + return result; + } + // 0x1: Facing south // 0x2: Facing north // 0x3: Facing west @@ -6674,14 +6995,18 @@ public void turnCannon(Boolean right, Player p) turnCannonLayer(right, p, 1); turnCannonLayer(right, p, 2); } + if ( cannonType == 3 || cannonType == 7 || cannonType == 8 || cannonType == 11 || cannonType == 12 ) { + turnTorpedoLayer(right, p, 1); + turnTorpedoLayer(right, p, 0); + } else { turnCannonLayer(right, p, 0); + } } - public void turnCannonLayer(Boolean right, Player p, int offsetY) { // Get data - if (PermissionInterface.CheckEnabledWorld(p.getLocation())) { + if (Utils.CheckEnabledWorld(p.getLocation())) { int[][] arr = new int[7][7]; byte[][] arrb = new byte[7][7]; for (int x = 0; x < 7; x++) { @@ -6693,7 +7018,7 @@ public void turnCannonLayer(Boolean right, Player p, int offsetY) { int[][] arro = new int[7][7]; byte[][] arrbo = new byte[7][7]; - // Rotate the shit + // Rotate if (right) { arro = rotateLeft(arr); arrbo = rotateLeftB(arrb,arro); @@ -6702,13 +7027,12 @@ public void turnCannonLayer(Boolean right, Player p, int offsetY) { arrbo = rotateRightB(arrb,arro); } - // Cleanup Cannon (button und lever first) + // Cleanup Cannon (support blocks first) for (int x = 0; x < 7; x++) { for (int z = 0; z < 7; z++) { - if (loc.getBlock().getRelative(x - 3, 0, z - 3).getRelative(BlockFace.UP, offsetY).getTypeId() == 69 - || loc.getBlock().getRelative(x - 3, 0, z - 3).getRelative(BlockFace.UP, offsetY).getTypeId() == 77) { + if (BlocksInfo.needsSupport(loc.getBlock().getRelative(x - 3, 0, z - 3).getRelative(BlockFace.UP, offsetY).getTypeId())) { loc.getBlock().getRelative(x - 3, 0, z - 3).getRelative(BlockFace.UP, offsetY).setTypeIdAndData(0, (byte) 0, false); - } + } } } @@ -6727,7 +7051,8 @@ public void turnCannonLayer(Boolean right, Player p, int offsetY) { for (int z = 0; z < 7; z++) { if ((arro[x][z] != 69) && (arro[x][z] != 77) && (arro[x][z] != 23)) { - loc.getBlock().getRelative(x - 3, 0, z - 3).getRelative(BlockFace.UP, offsetY).setTypeIdAndData(arro[x][z], arrbo[x][z], false); + if(arro[x][z] != -1 && !BlocksInfo.needsSupport(arro[x][z]) && arro[x][z] != 52 && arro[x][z] != 34 && arro[x][z] != 36 ) + loc.getBlock().getRelative(x - 3, 0, z - 3).getRelative(BlockFace.UP, offsetY).setTypeIdAndData(arro[x][z], arrbo[x][z], false); if( testCraft != null ) { testCraft.addBlock(loc.getBlock().getRelative(x - 3, 0, z - 3).getRelative(BlockFace.UP, offsetY), true); @@ -6743,8 +7068,7 @@ public void turnCannonLayer(Boolean right, Player p, int offsetY) { // Place rest for (int x = 0; x < 7; x++) { for (int z = 0; z < 7; z++) { - if ((arro[x][z] == 69) || (arro[x][z] == 77)) - { + if (BlocksInfo.needsSupport(arro[x][z]) && arro[x][z] != 63 && arro[x][z] != 68 && arro[x][z] != 65) { loc.getBlock().getRelative(x - 3, 0, z - 3).getRelative(BlockFace.UP, offsetY).setTypeIdAndData(arro[x][z], arrbo[x][z], false); if( testCraft != null ) { @@ -6829,11 +7153,160 @@ public void turnCannonLayer(Boolean right, Player p, int offsetY) { } } + public void turnTorpedoLayer(Boolean right, Player p, int offsetY) { + // Get data + if (Utils.CheckEnabledWorld(p.getLocation())) { + int[][] arr = new int[9][9]; + byte[][] arrb = new byte[9][9]; + for (int x = 0; x < 9; x++) { + for (int z = 0; z < 9; z++) { + arr[x][z] = loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY).getTypeId(); + arrb[x][z] = loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY).getData(); + } + } + + int[][] arro = new int[9][9]; + byte[][] arrbo = new byte[9][9]; + // Rotate + if (right) { + arro = rotateLeft(arr); + arrbo = rotateLeftB(arrb,arro); + } else { + arro = rotateRight(arr); + arrbo = rotateRightB(arrb,arro); + } + + // Cleanup Cannon (support blocks first) + for (int x = 0; x < 9; x++) { + for (int z = 0; z < 9; z++) { + if (BlocksInfo.needsSupport(loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY).getTypeId())) { + loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY).setTypeIdAndData(0, (byte) 0, false); + } + } + } + + // Cleanup Rest + for (int x = 0; x < 9; x++) { + for (int z = 0; z < 9; z++) { + if( !(x-4==0 && z-4==0 && offsetY==0) ) + loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY).setTypeIdAndData(0, (byte) 0, false); + } + } + + + Craft testCraft = Craft.getCraft(loc.getBlockX(),loc.getBlockY(),loc.getBlockZ()); + // Place cannon + for (int x = 0; x < 9; x++) { + for (int z = 0; z < 9; z++) { + if (!BlocksInfo.needsSupport(arro[x][z])) + { + if(arro[x][z] != -1 && arro[x][z] != 52 && arro[x][z] != 34 && arro[x][z] != 36 ) + loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY).setTypeIdAndData(arro[x][z], arrbo[x][z], false); + if( testCraft != null ) + { + testCraft.addBlock(loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY), true); + } + + }else if( (arro[x][z] == 23) ) + { + loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY).setData(arrbo[x][z]); + } + } + } + + // Place rest + for (int x = 0; x < 9; x++) { + for (int z = 0; z < 9; z++) { + if (BlocksInfo.needsSupport(arro[x][z]) && arro[x][z] != 63 && arro[x][z] != 68 && arro[x][z] != 65) { + loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY).setTypeIdAndData(arro[x][z], arrbo[x][z], false); + if( testCraft != null ) + { + testCraft.addBlock(loc.getBlock().getRelative(x - 4, 0, z - 4).getRelative(BlockFace.UP, offsetY), true); + } + } + } + } + + if( testCraft != null ) + { + //CraftMover cm = new CraftMover(testCraft, plugin); + //cm.structureUpdate(null); + } + // 0x2: Facing east + // 0x3: Facing west + // 0x4: Facing north + // 0x5: Facing south + + if( offsetY == 0 ) + { + if (right) { + if (direction == BlockFace.NORTH) + { + direction = BlockFace.EAST; + loc.getBlock().setData((byte) 0x3); + }else if (direction == BlockFace.EAST) + { + direction = BlockFace.SOUTH; + loc.getBlock().setData((byte) 0x4); + }else if (direction == BlockFace.SOUTH) + { + direction = BlockFace.WEST; + loc.getBlock().setData((byte) 0x2); + }else// if (direction == BlockFace.WEST) + { + direction = BlockFace.NORTH; + loc.getBlock().setData((byte) 0x5); + } + } else + { + if (direction == BlockFace.EAST) + { + direction = BlockFace.NORTH; + loc.getBlock().setData((byte) 0x5); + }else if (direction == BlockFace.SOUTH) + { + direction = BlockFace.EAST; + loc.getBlock().setData((byte) 0x3); + }else if (direction == BlockFace.WEST) + { + direction = BlockFace.SOUTH; + loc.getBlock().setData((byte) 0x4); + }else// if (direction == BlockFace.NORTH) + { + direction = BlockFace.WEST; + loc.getBlock().setData((byte) 0x2); + } + } + + Location teleLoc = new Location(p.getWorld(), loc.getBlock().getRelative(direction, -1).getX() + 0.5, (double)loc.getBlock().getRelative(direction, -1).getY(), loc.getBlock().getRelative(direction, -1).getZ() + 0.5); + //p.sendMessage("player yaw=" + p.getLocation().getYaw() ); + if( right ) + teleLoc.setYaw(p.getLocation().getYaw() + 90); + else + teleLoc.setYaw(p.getLocation().getYaw() - 90); + teleLoc.setPitch(p.getLocation().getPitch()); + p.teleport(teleLoc); + + + if( cannonTurnCounter < 4 && ((loc.getBlock().getRelative(direction, 1).getRelative(BlockFace.DOWN,1).getTypeId() == 5) + || ( cannonType == 6 && loc.getBlock().getRelative(direction, 1).getRelative(BlockFace.DOWN,2).getTypeId() == 5))) + { + cannonTurnCounter++; + turnCannon(right, p); + }else + { + cannonTurnCounter=0; + } + + } + } +} + public boolean checkProtectedRegion(Player player, Location loc) { if( wgp != null ) { - if( !PermissionInterface.CheckEnabledWorld(loc) ) + if( !Utils.CheckEnabledWorld(loc) ) { return true; } @@ -6865,7 +7338,7 @@ public void fireDCButton(Player p, boolean leftClick) { if( checkProtectedRegion(p, p.getLocation()) ) { - p.sendMessage("You are in a protected region"); + p.sendMessage(ChatColor.RED + "You are in a protected region"); return; } @@ -6881,14 +7354,14 @@ public void fireDCButton(Player p, boolean leftClick) loc.getBlock().getRelative(direction,4).setTypeIdAndData(35, (byte) 0x8, false); loc.getBlock().getRelative(direction,4).getRelative(BlockFace.DOWN).setTypeIdAndData(35, (byte) 0x8, false); fireDC(p, loc.getBlock().getRelative(direction,4), depth, loc.getBlockY(), 0, 2); - p.sendMessage("Depth Charge Away!"); + p.sendMessage(ChatColor.GREEN + "Depth Charge Away!"); }else if( cannonType == 9 || cannonType == 10 ) { loc.getBlock().getRelative(BlockFace.DOWN,5).setTypeIdAndData(35, (byte) 0x8, false); loc.getBlock().getRelative(BlockFace.DOWN,5).getRelative(BlockFace.DOWN).setTypeIdAndData(35, (byte) 0x7, false); fireDC(p, loc.getBlock().getRelative(BlockFace.DOWN,5), 0, loc.getBlock().getRelative(BlockFace.DOWN,5).getY(), 0, 2); - p.sendMessage("Bomb Away!"); + p.sendMessage(ChatColor.GREEN + "Bomb Away!"); }else { @@ -6913,18 +7386,18 @@ public void fireDCButton(Player p, boolean leftClick) loc.getBlock().getRelative(direction,6).getRelative(BlockFace.DOWN).getRelative(BlockFace.SOUTH,10).setTypeIdAndData(35, (byte) 0x8, false); fireDC(p, loc.getBlock().getRelative(direction,6).getRelative(BlockFace.SOUTH,10), depth, loc.getBlockY(), 1000, -1); } - p.sendMessage("Depth Charges Away!"); + p.sendMessage(ChatColor.GREEN + "Depth Charges Away!"); } charged = 0; }else { if( cannonType == 4 ) - p.sendMessage("Load Depth Charge Dropper first."); + p.sendMessage(ChatColor.YELLOW + "Load Depth Charge Dropper first."); else if( cannonType == 5 ) - p.sendMessage("Load Depth Charge Launcher first."); + p.sendMessage(ChatColor.YELLOW + "Load Depth Charge Launcher first."); else - p.sendMessage("Load Bomb Dropper first."); + p.sendMessage(ChatColor.YELLOW + "Load Bomb Dropper first."); } }else { @@ -6932,11 +7405,11 @@ else if( cannonType == 5 ) if( depth > 40 ) depth = 10; if( cannonType == 4 ) - p.sendMessage("Depth Charge Dropper set to " + depth + " meters."); + p.sendMessage(ChatColor.GREEN + "Depth Charge Dropper set to " + ChatColor.YELLOW + depth + ChatColor.GREEN + " meters."); else if( cannonType == 5 ) - p.sendMessage("Depth Charge Launcher set to " + depth + " meters."); + p.sendMessage(ChatColor.GREEN + "Depth Charge Launcher set to " + ChatColor.YELLOW + depth + ChatColor.GREEN + " meters."); else if( cannonType == 9 || cannonType == 10) - p.sendMessage("Left click to drop bomb."); + p.sendMessage(ChatColor.GREEN + "Left click to drop bomb."); } } @@ -7135,7 +7608,7 @@ public void run() } if( checkCraft != null ) - p.sendMessage("Depth Charge hit " + checkCraft.name + "!"); + p.sendMessage(ChatColor.GREEN + "Depth Charge hit " + ChatColor.YELLOW + checkCraft.name + ChatColor.GREEN + "!"); @@ -7261,4 +7734,36 @@ public void run() ); } + public void setBlock(int id, Block block, Craft craft) { + // if(y < 0 || y > 127 || id < 0 || id > 255){ + if ((id < 0) || (id > 255)) { + // + " x=" + x + " y=" + y + " z=" + z); + System.out.println("Invalid block type ID. Begin panic."); + return; + } + + + + if (block.getTypeId() == id) { + NavyCraft.instance.DebugMessage("Tried to change a " + id + " to itself.", 5); + return; + } + + NavyCraft.instance.DebugMessage("Attempting to set block at " + block.getX() + ", " + block.getY() + ", " + block.getZ() + " to " + id, 5); + + + try { + if (block.setTypeId(id) == false) { + if (craft.world.getBlockAt(block.getLocation()).setTypeId(id) == false) { + System.out.println("Could not set block of type " + block.getTypeId() + " to type " + id + ". I tried to fix it, but I couldn't."); + } else { + System.out.println("I hope to whatever God you believe in that this fix worked."); + } + } + } catch (ClassCastException cce) { + System.out.println("Routine cast exception."); + } + + + } } diff --git a/src/main/java/com/maximuspayne/aimcannon/Weapon.java b/src/main/java/com/maximuspayne/aimcannon/Weapon.java index 0652f80..6fd810e 100644 --- a/src/main/java/com/maximuspayne/aimcannon/Weapon.java +++ b/src/main/java/com/maximuspayne/aimcannon/Weapon.java @@ -8,6 +8,7 @@ public class Weapon { public Block warhead; BlockFace hdg; + BlockFace ohdg; int setDepth; int rudder=0; int rudderSetting=0; @@ -15,6 +16,7 @@ public class Weapon { int torpSetHeading=-1; int torpRotation; int setRange; + int rangeCounter; boolean doubleTurn=false; int tubeNum=0; boolean active=false; @@ -28,6 +30,7 @@ public Weapon(Block b, BlockFace bf, int depth, int range) weaponType = 0; warhead = b; hdg = bf; + ohdg = bf; setDepth = depth; torpRotation = 0; setRange = range; diff --git a/src/main/java/com/maximuspayne/aimcannon/ciwsFire.java b/src/main/java/com/maximuspayne/aimcannon/ciwsFire.java new file mode 100644 index 0000000..aa8087a --- /dev/null +++ b/src/main/java/com/maximuspayne/aimcannon/ciwsFire.java @@ -0,0 +1,90 @@ +package com.maximuspayne.aimcannon; + +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.entity.Egg; +import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import com.maximuspayne.navycraft.NavyCraft; +import com.maximuspayne.navycraft.craft.CraftMover; +@SuppressWarnings("deprecation") +public class ciwsFire extends BukkitRunnable +{ + private Player player; + + public ciwsFire(Player p) + { + player = p; + } + + @Override + public void run() + { + Egg newEgg = player.launchProjectile(Egg.class); + newEgg.setVelocity(newEgg.getVelocity().multiply(2.0f)); + NavyCraft.explosiveEggsList.add(newEgg); + player.getWorld().playEffect(player.getLocation(), Effect.SMOKE, 0); + CraftMover.playWeaponSound(player.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 5.0f,1.70f); + } + +public static void fireCIWS(Player player) + { + new Thread() { + @Override + public void run() + { + + setPriority(Thread.MIN_PRIORITY); + try + { + while(NavyCraft.ciwsFiringList.contains(player)) + { + int radius = 50; + long radiusSquared = radius * radius; + Location newLoc = player.getLocation(); + boolean change = false; + + for (Weapon torp: AimCannon.weapons) + { + if (!torp.dead) { + Location torpLoc = torp.warhead.getLocation(); + if (torpLoc.getWorld() != player.getWorld()) + { + continue; + } + + long delta = (long)torpLoc.distanceSquared(player.getLocation()); + if (delta < radiusSquared) + { + double dX = torpLoc.getX() - player.getLocation().getX(); + double dY = torpLoc.getY() - player.getLocation().getY(); + double dZ = torpLoc.getZ() - player.getLocation().getZ(); + + Vector playerLookDirection = new Vector(dX + 0.5, dY - 0.5, dZ + 0.5); + + change = true; + newLoc.setDirection(playerLookDirection.normalize()); + break; + } + } + } + if (change) + player.teleport(newLoc); + + newLoc = player.getLocation(); + change = false; + + NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new ciwsFire(player)); + sleep(50); + } + + } catch (InterruptedException e) + { + } + } + }.start(); + } +} \ No newline at end of file diff --git a/src/main/java/com/maximuspayne/navycraft/ConfigManager.java b/src/main/java/com/maximuspayne/navycraft/ConfigManager.java new file mode 100644 index 0000000..a13b072 --- /dev/null +++ b/src/main/java/com/maximuspayne/navycraft/ConfigManager.java @@ -0,0 +1,212 @@ +package com.maximuspayne.navycraft; + +import java.io.File; +import java.io.IOException; + +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; + +public class ConfigManager { + + private NavyCraft plugin = NavyCraft.getPlugin(NavyCraft.class); + + //files and configuration + File shipyarddata = new File(plugin.getDataFolder(),File.separator + "shipyarddata"); + public static FileConfiguration syConfig; + public static File syCFile; + public static FileConfiguration syData; + public static File syDFile; + + public void setupsyConfig() { + if (!plugin.getDataFolder().exists()) { + plugin.getDataFolder().mkdir(); + } + syCFile = new File(shipyarddata + File.separator , "config.yml"); + syConfig = YamlConfiguration.loadConfiguration(syCFile); + + if (!syCFile.exists()) { + try { + syConfig.set("Types.SHIP1.SZX", 13); + syConfig.set("Types.SHIP1.SZY", 28); + syConfig.set("Types.SHIP1.SZZ", 28); + syConfig.set("Types.SHIP1.OX", 0); + syConfig.set("Types.SHIP1.OY", -8); + syConfig.set("Types.SHIP1.OZ", 0); + syConfig.set("Types.SHIP1.BFR", 28); + syConfig.set("Types.SHIP1.doFix", false); + + syConfig.set("Types.SHIP2.SZX", 9); + syConfig.set("Types.SHIP2.SZY", 28); + syConfig.set("Types.SHIP2.SZZ", 43); + syConfig.set("Types.SHIP2.OX", 0); + syConfig.set("Types.SHIP2.OY", -8); + syConfig.set("Types.SHIP2.OZ", 0); + syConfig.set("Types.SHIP2.BFR", 43); + syConfig.set("Types.SHIP2.doFix", false); + + syConfig.set("Types.SHIP3.SZX", 11); + syConfig.set("Types.SHIP3.SZY", 28); + syConfig.set("Types.SHIP3.SZZ", 70); + syConfig.set("Types.SHIP3.OX", 0); + syConfig.set("Types.SHIP3.OY", -8); + syConfig.set("Types.SHIP3.OZ", 0); + syConfig.set("Types.SHIP3.BFR", 70); + syConfig.set("Types.SHIP3.doFix", false); + + syConfig.set("Types.SHIP4.SZX", 17); + syConfig.set("Types.SHIP4.SZY", 28); + syConfig.set("Types.SHIP4.SZZ", 55); + syConfig.set("Types.SHIP4.OX", 0); + syConfig.set("Types.SHIP4.OY", -8); + syConfig.set("Types.SHIP4.OZ", 0); + syConfig.set("Types.SHIP4.BFR", 55); + syConfig.set("Types.SHIP4.doFix", false); + + syConfig.set("Types.SHIP5.SZX", 17); + syConfig.set("Types.SHIP5.SZY", 28); + syConfig.set("Types.SHIP5.SZZ", 98); + syConfig.set("Types.SHIP5.OX", 0); + syConfig.set("Types.SHIP5.OY", -8); + syConfig.set("Types.SHIP5.OZ", 0); + syConfig.set("Types.SHIP5.BFR", 98); + syConfig.set("Types.SHIP5.doFix", false); + + syConfig.set("Types.HANGAR1.SZX", 17); + syConfig.set("Types.HANGAR1.SZY", 7); + syConfig.set("Types.HANGAR1.SZZ", 19); + syConfig.set("Types.HANGAR1.OX", 0); + syConfig.set("Types.HANGAR1.OY", -1); + syConfig.set("Types.HANGAR1.OZ", -18); + syConfig.set("Types.HANGAR1.BFR", 17); + syConfig.set("Types.HANGAR1.doFix", true); + + syConfig.set("Types.HANGAR2.SZX", 25); + syConfig.set("Types.HANGAR2.SZY", 7); + syConfig.set("Types.HANGAR2.SZZ", 32); + syConfig.set("Types.HANGAR2.OX", 0); + syConfig.set("Types.HANGAR2.OY", -1); + syConfig.set("Types.HANGAR2.OZ", -31); + syConfig.set("Types.HANGAR2.BFR", 25); + syConfig.set("Types.HANGAR2.doFix", true); + + syConfig.set("Types.TANK1.SZX", 12); + syConfig.set("Types.TANK1.SZY", 7); + syConfig.set("Types.TANK1.SZZ", 19); + syConfig.set("Types.TANK1.OX", 0); + syConfig.set("Types.TANK1.OY", -1); + syConfig.set("Types.TANK1.OZ", -18); + syConfig.set("Types.TANK1.BFR", 12); + syConfig.set("Types.TANK1.doFix", true); + + syConfig.set("Types.TANK2.SZX", 27); + syConfig.set("Types.TANK2.SZY", 9); + syConfig.set("Types.TANK2.SZZ", 33); + syConfig.set("Types.TANK2.OX", 0); + syConfig.set("Types.TANK2.OY", -1); + syConfig.set("Types.TANK2.OZ", -32); + syConfig.set("Types.TANK2.BFR", 27); + syConfig.set("Types.TANK2.doFix", true); + + syConfig.set("Types.MAP1.SZX", 100); + syConfig.set("Types.MAP1.SZY", 255); + syConfig.set("Types.MAP1.SZZ", 100); + syConfig.set("Types.MAP1.OX", 0); + syConfig.set("Types.MAP1.OY", -63); + syConfig.set("Types.MAP1.OZ", -99); + syConfig.set("Types.MAP1.BFR", 100); + syConfig.set("Types.MAP1.dontSelect", true); + + syConfig.set("Types.MAP2.SZX", 150); + syConfig.set("Types.MAP2.SZY", 255); + syConfig.set("Types.MAP2.SZZ", 150); + syConfig.set("Types.MAP2.OX", 0); + syConfig.set("Types.MAP2.OY", -63); + syConfig.set("Types.MAP2.OZ", -149); + syConfig.set("Types.MAP2.BFR", 150); + syConfig.set("Types.MAP2.dontSelect", true); + + syConfig.set("Types.MAP3.SZX", 200); + syConfig.set("Types.MAP3.SZY", 255); + syConfig.set("Types.MAP3.SZZ", 200); + syConfig.set("Types.MAP3.OX", 0); + syConfig.set("Types.MAP3.OY", -63); + syConfig.set("Types.MAP3.OZ", -199); + syConfig.set("Types.MAP3.BFR", 200); + syConfig.set("Types.MAP3.dontSelect", true); + + syConfig.set("Types.MAP4.SZX", 250); + syConfig.set("Types.MAP4.SZY", 255); + syConfig.set("Types.MAP4.SZZ", 250); + syConfig.set("Types.MAP4.OX", 0); + syConfig.set("Types.MAP4.OY", -63); + syConfig.set("Types.MAP4.OZ", -249); + syConfig.set("Types.MAP4.BFR", 250); + syConfig.set("Types.MAP4.dontSelect", true); + + syConfig.set("Types.MAP5.SZX", 500); + syConfig.set("Types.MAP5.SZY", 255); + syConfig.set("Types.MAP5.SZZ", 250); + syConfig.set("Types.MAP5.OX", 0); + syConfig.set("Types.MAP5.OY", -63); + syConfig.set("Types.MAP5.OZ", -499); + syConfig.set("Types.MAP5.BFR", 500); + syConfig.set("Types.MAP5.dontSelect", true); + + syConfig.save(syCFile); + } catch(IOException e) { + System.out.println("Could not create the shipyard config.yml file!"); + } + } + } + + public static FileConfiguration getsyConfig () { + return syConfig; + } + + public static void savesyConfig() { + try { + syConfig.save(syCFile); + } catch (IOException e) { + System.out.println("Could not save shipyard config.yml file"); + } + } + public static void reloadsyConfig() { + syConfig = YamlConfiguration.loadConfiguration(syCFile); + } + + + + public void setupsyData() { + if (!plugin.getDataFolder().exists()) { + plugin.getDataFolder().mkdir(); + } + syDFile = new File(shipyarddata + File.separator , "signs.yml"); + syData = YamlConfiguration.loadConfiguration(syDFile); + + if (!syDFile.exists()) { + try { + syData.createSection("Signs"); + syData.save(syDFile); + } catch(IOException e) { + System.out.println("Could not create the shipyard signs.yml file!"); + } + } + } + + public static FileConfiguration getsyData () { + return syData; + } + + public static void savesyData() { + try { + syData.save(syDFile); + } catch (IOException e) { + System.out.println("Could not save shipyard signs.yml file"); + e.printStackTrace(); + } + } + public static void reloadsyData() { + syData = YamlConfiguration.loadConfiguration(syDFile); + } + +} diff --git a/src/main/java/com/maximuspayne/navycraft/NavyCraft.java b/src/main/java/com/maximuspayne/navycraft/NavyCraft.java index bf060ad..20b4b09 100644 --- a/src/main/java/com/maximuspayne/navycraft/NavyCraft.java +++ b/src/main/java/com/maximuspayne/navycraft/NavyCraft.java @@ -5,7 +5,6 @@ import java.util.Iterator; import java.util.UUID; import java.util.logging.*; -import java.io.File; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.entity.Egg; @@ -28,11 +27,13 @@ import com.maximuspayne.navycraft.craft.CraftType; import com.maximuspayne.navycraft.listeners.NavyCraft_BlockListener; import com.maximuspayne.navycraft.listeners.NavyCraft_EntityListener; -import com.maximuspayne.navycraft.listeners.NavyCraft_FileListener; import com.maximuspayne.navycraft.listeners.NavyCraft_InventoryListener; import com.maximuspayne.navycraft.listeners.NavyCraft_PlayerListener; import com.maximuspayne.navycraft.PermissionInterface; import com.maximuspayne.navycraft.teleportfix.TeleportFix; +import com.maximuspayne.shipyard.Plot; +import com.maximuspayne.shipyard.PlotType; +import com.maximuspayne.shipyard.Reward; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.managers.RegionManager; @@ -64,9 +65,13 @@ public class NavyCraft extends JavaPlugin { public boolean DebugMode = false; public static ArrayList aaGunnersList = new ArrayList(); + public static ArrayList aaSkelesList = new ArrayList(); public static ArrayList flakGunnersList = new ArrayList(); public static ArrayList flakSkelesList = new ArrayList(); - public static ArrayList aaSkelesList = new ArrayList(); + public static ArrayList ciwsGunnersList = new ArrayList(); + public static ArrayList ciwsFiringList = new ArrayList(); + public static HashMap ciwsCooldown = new HashMap(); + public static ArrayList ciwsSkelesList = new ArrayList(); public static ArrayList explosiveEggsList = new ArrayList(); public static HashMap shotTNTList = new HashMap(); @@ -93,35 +98,9 @@ public class NavyCraft extends JavaPlugin { public static int spawnTime=10; - public static HashMap> playerSHIP1Signs = new HashMap>(); - public static HashMap> playerSHIP2Signs = new HashMap>(); - public static HashMap> playerSHIP3Signs = new HashMap>(); - public static HashMap> playerSHIP4Signs = new HashMap>(); - public static HashMap> playerSHIP5Signs = new HashMap>(); - public static HashMap> playerHANGAR1Signs = new HashMap>(); - public static HashMap> playerHANGAR2Signs = new HashMap>(); - public static HashMap> playerTANK1Signs = new HashMap>(); - public static HashMap> playerTANK2Signs = new HashMap>(); - public static HashMap> playerMAP1Signs = new HashMap>(); - public static HashMap> playerMAP2Signs = new HashMap>(); - public static HashMap> playerMAP3Signs = new HashMap>(); - public static HashMap> playerMAP4Signs = new HashMap>(); - public static HashMap> playerMAP5Signs = new HashMap>(); + public static HashMap> playerSigns = new HashMap>(); - public static HashMap playerSHIP1Rewards = new HashMap(); - public static HashMap playerSHIP2Rewards = new HashMap(); - public static HashMap playerSHIP3Rewards = new HashMap(); - public static HashMap playerSHIP4Rewards = new HashMap(); - public static HashMap playerSHIP5Rewards = new HashMap(); - public static HashMap playerHANGAR1Rewards = new HashMap(); - public static HashMap playerHANGAR2Rewards = new HashMap(); - public static HashMap playerTANK1Rewards = new HashMap(); - public static HashMap playerTANK2Rewards = new HashMap(); - public static HashMap playerMAP1Rewards = new HashMap(); - public static HashMap playerMAP2Rewards = new HashMap(); - public static HashMap playerMAP3Rewards = new HashMap(); - public static HashMap playerMAP4Rewards = new HashMap(); - public static HashMap playerMAP5Rewards = new HashMap(); + public static HashMap> playerRewards = new HashMap>(); public static HashMap playerSignIndex = new HashMap(); @@ -139,18 +118,26 @@ public class NavyCraft extends JavaPlugin { public static HashMap playerEngineVolumes = new HashMap(); public static HashMap playerWeaponVolumes = new HashMap(); public static HashMap playerOtherVolumes = new HashMap(); + + private ConfigManager cfgm; + public static HashMap> getRewards() { + return playerRewards; + } + public void loadProperties() { getConfig().options().copyDefaults(true); - File dir = getDataFolder(); - if (!dir.exists()) - dir.mkdir(); - NavyCraft_FileListener.loadShipyardData(); - NavyCraft_FileListener.loadShipyardConfig(); - CraftType.loadTypes(dir); - CraftType.saveTypes(dir); + loadConfigManager(); + PlotType.initialize(); + CraftType.setupCraftConfig(); + } + + public void loadConfigManager() { + cfgm = new ConfigManager(); + cfgm.setupsyConfig(); + cfgm.setupsyData(); } public void onEnable() { @@ -270,7 +257,7 @@ public static boolean checkRepairRegion(Location loc) wgp = (WorldGuardPlugin) instance.getServer().getPluginManager().getPlugin("WorldGuard"); if( wgp != null && loc != null) { - if( !!PermissionInterface.CheckEnabledWorld(loc) ) + if( !!Utils.CheckEnabledWorld(loc) ) { return false; } @@ -300,7 +287,7 @@ public static boolean checkSafeDockRegion(Location loc) wgp = (WorldGuardPlugin) instance.getServer().getPluginManager().getPlugin("WorldGuard"); if( wgp != null && loc != null) { - if( !!PermissionInterface.CheckEnabledWorld(loc) ) + if( !Utils.CheckEnabledWorld(loc) ) { return false; } @@ -330,7 +317,7 @@ public static boolean checkRecallRegion(Location loc) wgp = (WorldGuardPlugin) instance.getServer().getPluginManager().getPlugin("WorldGuard"); if( wgp != null && loc != null) { - if( !PermissionInterface.CheckEnabledWorld(loc) ) + if( !Utils.CheckEnabledWorld(loc) ) { return false; } @@ -360,7 +347,7 @@ public static boolean checkSpawnRegion(Location loc) wgp = (WorldGuardPlugin) instance.getServer().getPluginManager().getPlugin("WorldGuard"); if( wgp != null && loc != null) { - if( !PermissionInterface.CheckEnabledWorld(loc) ) + if( !Utils.CheckEnabledWorld(loc) ) { return false; } @@ -390,7 +377,7 @@ public static boolean checkNoDriveRegion(Location loc) wgp = (WorldGuardPlugin) instance.getServer().getPluginManager().getPlugin("WorldGuard"); if( wgp != null && loc != null) { - if( !PermissionInterface.CheckEnabledWorld(loc) ) + if( !Utils.CheckEnabledWorld(loc) ) { return false; } diff --git a/src/main/java/com/maximuspayne/navycraft/PermissionInterface.java b/src/main/java/com/maximuspayne/navycraft/PermissionInterface.java index 483e916..bc4dbd1 100644 --- a/src/main/java/com/maximuspayne/navycraft/PermissionInterface.java +++ b/src/main/java/com/maximuspayne/navycraft/PermissionInterface.java @@ -3,9 +3,7 @@ import com.maximuspayne.navycraft.NavyCraft; import com.maximuspayne.navycraft.craft.CraftType; - import org.bukkit.ChatColor; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.permissions.Permission; import org.bukkit.plugin.PluginManager; @@ -22,12 +20,53 @@ public static void setupPermissions(NavyCraft p) { plugin = p; PluginManager pm = NavyCraft.instance.getServer().getPluginManager(); if(pm != null) { + //basic permissions + pm.addPermission(new Permission("navycraft.basic")); + pm.addPermission(new Permission("navycraft.signcreate")); pm.addPermission(new Permission("navycraft.periscope.use")); pm.addPermission(new Permission("navycraft.aa-gun.use")); pm.addPermission(new Permission("navycraft.flak-gun.use")); - pm.addPermission(new Permission("navycraft.periscope.create")); - pm.addPermission(new Permission("navycraft.aa-gun.create")); - pm.addPermission(new Permission("navycraft.flak-gun.create")); + pm.addPermission(new Permission("navycraft.ciws.use")); + pm.addPermission(new Permission("navycraft.searchlight.use")); + pm.addPermission(new Permission("navycraft.volume.engine")); + pm.addPermission(new Permission("navycraft.volume.weapon")); + pm.addPermission(new Permission("navycraft.volume.other")); + pm.addPermission(new Permission("navycraft.volume.all")); + pm.addPermission(new Permission("navycraft.expview")); + pm.addPermission(new Permission("navycraft.dropchance")); + + //admin permissions + pm.addPermission(new Permission("navycraft.admin")); + pm.addPermission(new Permission("navycraft.pbes")); + pm.addPermission(new Permission("navycraft.bbes")); + pm.addPermission(new Permission("navycraft.admincraft")); + pm.addPermission(new Permission("navycraft.adminsigncreate")); + pm.addPermission(new Permission("navycraft.craftitems")); + pm.addPermission(new Permission("navycraft.list")); + pm.addPermission(new Permission("navycraft.reload")); + pm.addPermission(new Permission("navycraft.debug")); + pm.addPermission(new Permission("navycraft.loglevel")); + pm.addPermission(new Permission("navycraft.cleanup")); + pm.addPermission(new Permission("navycraft.weapons")); + pm.addPermission(new Permission("navycraft.cannons")); + pm.addPermission(new Permission("navycraft.destroyships")); + pm.addPermission(new Permission("navycraft.removeships")); + pm.addPermission(new Permission("navycraft.tpship")); + pm.addPermission(new Permission("navycraft.addsign")); + pm.addPermission(new Permission("navycraft.aunclaim")); + pm.addPermission(new Permission("navycraft.explode")); + pm.addPermission(new Permission("navycraft.explodesigns")); + pm.addPermission(new Permission("navycraft.expset")); + pm.addPermission(new Permission("navycraft.expadd")); + pm.addPermission(new Permission("navycraft.expremove")); + pm.addPermission(new Permission("navycraft.admindrive")); + pm.addPermission(new Permission("navycraft.takeover")); + pm.addPermission(new Permission("navycraft.remove")); + pm.addPermission(new Permission("navycraft.destroy")); + pm.addPermission(new Permission("navycraft.buoy")); + pm.addPermission(new Permission("navycraft.free")); + pm.addPermission(new Permission("navycraft.select")); + pm.addPermission(new Permission("navycraft.reward")); for (CraftType type : CraftType.craftTypes) { @@ -46,12 +85,52 @@ public static void removePermissions(NavyCraft p) { plugin = p; PluginManager pm = NavyCraft.instance.getServer().getPluginManager(); if(pm != null) { + //basic permissions + pm.removePermission(new Permission("navycraft.basic")); + pm.removePermission(new Permission("navycraft.signcreate")); pm.removePermission(new Permission("navycraft.periscope.use")); pm.removePermission(new Permission("navycraft.aa-gun.use")); pm.removePermission(new Permission("navycraft.flak-gun.use")); - pm.removePermission(new Permission("navycraft.periscope.create")); - pm.removePermission(new Permission("navycraft.aa-gun.create")); - pm.removePermission(new Permission("navycraft.flak-gun.create")); + pm.removePermission(new Permission("navycraft.ciws.use")); + pm.removePermission(new Permission("navycraft.searchlight.use")); + pm.removePermission(new Permission("navycraft.volume.engine")); + pm.removePermission(new Permission("navycraft.volume.weapon")); + pm.removePermission(new Permission("navycraft.volume.other")); + pm.removePermission(new Permission("navycraft.volume.all")); + pm.removePermission(new Permission("navycraft.expview")); + pm.removePermission(new Permission("navycraft.dropchance")); + //admin permissions + pm.removePermission(new Permission("navycraft.admin")); + pm.removePermission(new Permission("navycraft.pbes")); + pm.removePermission(new Permission("navycraft.bbes")); + pm.removePermission(new Permission("navycraft.admincraft")); + pm.removePermission(new Permission("navycraft.adminsigncreate")); + pm.removePermission(new Permission("navycraft.craftitems")); + pm.removePermission(new Permission("navycraft.list")); + pm.removePermission(new Permission("navycraft.reload")); + pm.removePermission(new Permission("navycraft.debug")); + pm.removePermission(new Permission("navycraft.loglevel")); + pm.removePermission(new Permission("navycraft.cleanup")); + pm.removePermission(new Permission("navycraft.weapons")); + pm.removePermission(new Permission("navycraft.cannons")); + pm.removePermission(new Permission("navycraft.destroyships")); + pm.removePermission(new Permission("navycraft.removeships")); + pm.removePermission(new Permission("navycraft.tpship")); + pm.removePermission(new Permission("navycraft.addsign")); + pm.removePermission(new Permission("navycraft.aunclaim")); + pm.removePermission(new Permission("navycraft.explode")); + pm.removePermission(new Permission("navycraft.explodesigns")); + pm.removePermission(new Permission("navycraft.expset")); + pm.removePermission(new Permission("navycraft.expadd")); + pm.removePermission(new Permission("navycraft.expremove")); + pm.removePermission(new Permission("navycraft.admindrive")); + pm.removePermission(new Permission("navycraft.takeover")); + pm.removePermission(new Permission("navycraft.remove")); + pm.removePermission(new Permission("navycraft.destroy")); + pm.removePermission(new Permission("navycraft.buoy")); + pm.removePermission(new Permission("navycraft.free")); + pm.removePermission(new Permission("navycraft.select")); + pm.removePermission(new Permission("navycraft.reward")); for (CraftType type : CraftType.craftTypes) { @@ -66,16 +145,6 @@ public static void removePermissions(NavyCraft p) { } } - @SuppressWarnings("deprecation") - public static String getUUIDfromPlayer(String player) { - String UUID = NavyCraft.instance.getServer().getOfflinePlayer(player).getUniqueId().toString(); - if(UUID == null) { - return null; - } else { - return UUID; - } -} - public static boolean CheckPerm(Player player, String command) { command = command.replace(" ", "."); NavyCraft.instance.DebugMessage("Checking if " + player.getName() + " can " + command, 3); @@ -111,33 +180,4 @@ public static boolean CheckQuietPerm(Player player, String command) { return false; } } - - public static boolean CheckEnabledWorld(Location loc) { - if(!NavyCraft.instance.getConfig().getString("EnabledWorlds").equalsIgnoreCase("null")) { - String[] worlds = NavyCraft.instance.getConfig().getString("EnabledWorlds").split(","); - for(int i = 0; i < worlds.length; i++) { - if( loc.getWorld().getName().equalsIgnoreCase(worlds[i]) ) - { - return true; - } - - } - return false; - } - return true; - } - public static boolean CheckBattleWorld(Location loc) { - if(!NavyCraft.instance.getConfig().getString("BattleWorld").equalsIgnoreCase("null")) { - String[] worlds = NavyCraft.instance.getConfig().getString("BattleWorld").split(","); - for(int i = 0; i < worlds.length; i++) { - if( loc.getWorld().getName().equalsIgnoreCase(worlds[i]) ) - { - return true; - } - - } - return false; - } - return true; - } } \ No newline at end of file diff --git a/src/main/java/com/maximuspayne/navycraft/Utils.java b/src/main/java/com/maximuspayne/navycraft/Utils.java new file mode 100644 index 0000000..2fb019b --- /dev/null +++ b/src/main/java/com/maximuspayne/navycraft/Utils.java @@ -0,0 +1,142 @@ +package com.maximuspayne.navycraft; + +import java.io.File; +import java.io.IOException; +import org.bukkit.Location; +import org.bukkit.OfflinePlayer; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import com.sk89q.worldedit.CuboidClipboard; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.Vector; +import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.BukkitUtil; +import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.data.DataException; +import com.sk89q.worldedit.schematic.SchematicFormat; +import com.sk89q.worldedit.world.World; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; + +@SuppressWarnings("deprecation") +public class Utils { + + public static void saveSchem(Player player, String schematicName, String customName, ProtectedRegion region, org.bukkit.World world){ + try { + File file = new File(NavyCraft.instance.getDataFolder(), "/schematics/" + schematicName + "-" + customName + ".schematic"); + File dir = new File(NavyCraft.instance.getDataFolder(), "/schematics/"); + if (!dir.exists()) + dir.mkdirs(); + for (File f : dir.listFiles()) { + if (f.getName().contains(customName)) { + file = f; + } + } + World weWorld = new BukkitWorld(world); + + Vector min = region.getMinimumPoint(); + Vector max = region.getMaximumPoint(); + + EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1); + CuboidClipboard clipboard = new CuboidClipboard(max.subtract(min).add(new Vector(1, 1, 1)), min);; + clipboard.copy(editSession); + SchematicFormat.MCEDIT.save(clipboard, file); + } catch (IOException | DataException ex) { + ex.printStackTrace(); + } + } + + + public static boolean pasteSchem(String schematicName, Location pasteLoc) { + try { + File dir = new File(NavyCraft.instance.getDataFolder(), "/schematics/" + schematicName + ".schematic"); + if (!dir.exists()) { + return false; + } + EditSession editSession = new EditSession(new BukkitWorld(pasteLoc.getWorld()), 999999999); + editSession.enableQueue(); + + SchematicFormat schematic = SchematicFormat.getFormat(dir); + CuboidClipboard clipboard = schematic.load(dir); + + clipboard.paste(editSession, BukkitUtil.toVector(pasteLoc), true); + editSession.flushQueue(); + return true; + } catch (DataException | IOException ex) { + return false; + } catch (MaxChangedBlocksException ex) { + return false; + } + } + + public static String getUUIDfromPlayer(String player) { + String UUID = NavyCraft.instance.getServer().getOfflinePlayer(player).getUniqueId().toString(); + return UUID; + } + public static String getNamefromUUID(String uuid) { + OfflinePlayer op = NavyCraft.instance.getServer().getOfflinePlayer(uuid); + if (op.hasPlayedBefore()) { + return op.getName(); + } else { + return null; + } + } + public static boolean CheckEnabledWorld(Location loc) { + if(!NavyCraft.instance.getConfig().getString("EnabledWorlds").equalsIgnoreCase("null")) { + String[] worlds = NavyCraft.instance.getConfig().getString("EnabledWorlds").split(","); + for(int i = 0; i < worlds.length; i++) { + if( loc.getWorld().getName().equalsIgnoreCase(worlds[i]) ) + { + return true; + } + + } + return false; + } + return true; + } + public static boolean CheckBattleWorld(Location loc) { + if(!NavyCraft.instance.getConfig().getString("BattleWorld").equalsIgnoreCase("null")) { + String[] worlds = NavyCraft.instance.getConfig().getString("BattleWorld").split(","); + for(int i = 0; i < worlds.length; i++) { + if( loc.getWorld().getName().equalsIgnoreCase(worlds[i]) ) + { + return true; + } + + } + return false; + } + return true; + } + + public static BlockFace getBlockFace(Block block) { + BlockFace bf; + bf = null; + // bf2 = null; + switch (block.getData()) { + case (byte) 0x8:// n + bf = BlockFace.SOUTH; + // bf2 = BlockFace.NORTH; + break; + case (byte) 0x0:// s + bf = BlockFace.NORTH; + // bf2 = BlockFace.SOUTH; + break; + case (byte) 0x4:// w + bf = BlockFace.EAST; + // bf2 = BlockFace.WEST; + break; + case (byte) 0xC:// e + bf = BlockFace.WEST; + // bf2 = BlockFace.EAST; + break; + default: + break; + } + return bf; + } +} + + diff --git a/src/main/java/com/maximuspayne/navycraft/craft/Craft.java b/src/main/java/com/maximuspayne/navycraft/craft/Craft.java index 1a2c2a7..0a99832 100644 --- a/src/main/java/com/maximuspayne/navycraft/craft/Craft.java +++ b/src/main/java/com/maximuspayne/navycraft/craft/Craft.java @@ -223,6 +223,7 @@ public class Craft { + public Location lastPeriscopeLookLoc=null; public float lastPeriscopeYaw=-9999; public HashMap engineIDTypes = new HashMap(); @@ -1618,10 +1619,10 @@ public void rudderChange(Player player, int order, boolean turn) return; } - if( this.setSpeed == 0 || this.gear <= 0 ) + if( this.setSpeed == 0) { if( player != null ) - player.sendMessage(ChatColor.RED + "You have to be moving forward to turn."); + player.sendMessage(ChatColor.RED + "You have to be moving to turn."); return; } diff --git a/src/main/java/com/maximuspayne/navycraft/craft/CraftMover.java b/src/main/java/com/maximuspayne/navycraft/craft/CraftMover.java index 790598e..6e5e581 100644 --- a/src/main/java/com/maximuspayne/navycraft/craft/CraftMover.java +++ b/src/main/java/com/maximuspayne/navycraft/craft/CraftMover.java @@ -35,6 +35,7 @@ import com.maximuspayne.navycraft.Periscope; import com.maximuspayne.navycraft.PermissionInterface; import com.maximuspayne.navycraft.Pump; +import com.maximuspayne.navycraft.Utils; import com.maximuspayne.navycraft.blocks.BlocksInfo; import com.maximuspayne.navycraft.blocks.DataBlock; import com.maximuspayne.navycraft.listeners.NavyCraft_BlockListener; @@ -218,7 +219,7 @@ public void restoreDataBlocks(int dx, int dy, int dz) { if (!stopSearch) { OneCannon oc = new OneCannon(theBlock.getLocation(), NavyCraft.instance); - if ((oc.isValidCannon(theBlock, false) && theBlock.getTypeId() == 23) || (oc.isValidCannon(theBlock, true) && theBlock.getTypeId() == 158)) { + if (oc.isValidCannon(theBlock, false) && (theBlock.getTypeId() == 23 || theBlock.getTypeId() == 158)) { for (OneCannon onec : AimCannon.getCannons()) { boolean oldCannonFound = onec.isThisCannon(new Location(craft.world, dataBlock.x + craft.minX, dataBlock.y + craft.minY, dataBlock.z + craft.minZ), true, true); @@ -1429,7 +1430,7 @@ public void structureUpdate(Player causer, boolean scheduled) { if (!craft.leftSafeDock && !NavyCraft.checkSpawnRegion(new Location(craft.world, craft.minX, craft.minY, craft.minZ)) && !NavyCraft.checkSpawnRegion(new Location(craft.world, craft.maxX, craft.maxY, craft.maxZ))) { craft.leftSafeDock = true; - if (PermissionInterface.CheckEnabledWorld(craft.getLocation()) && !craft.doCost) { + if (Utils.CheckEnabledWorld(craft.getLocation()) && !craft.doCost) { if (craft.captainName != null) { Player p = plugin.getServer().getPlayer(craft.captainName); if ((p != null) && craft.isNameOnBoard.get(craft.captainName)) { @@ -1693,15 +1694,15 @@ public void structureUpdate(Player causer, boolean scheduled) { } else if (oc.cannonType == 1) { cost = 250; } else if (oc.cannonType == 3) { - cost = 600; + cost = 650; } else if (oc.cannonType == 4) { - cost = 850; + cost = 650; } else if (oc.cannonType == 5) { - cost = 1250; + cost = 850; } else if (oc.cannonType == 6) { - cost = 1250; + cost = 850; } else if (oc.cannonType == 7) { - cost = 1250; + cost = 850; } else if (oc.cannonType == 8) { cost = 250; } else if (oc.cannonType == 9) { @@ -1709,13 +1710,13 @@ public void structureUpdate(Player causer, boolean scheduled) { } else if (oc.cannonType == 10) { cost = 500; } else if (oc.cannonType == 11) { - cost = 600; + cost = 650; } else if (oc.cannonType == 12) { - cost = 1250; + cost = 850; } else if (oc.cannonType == 13) { - cost = 600; + cost = 650; } else if (oc.cannonType == 14) { - cost = 1250; + cost = 850; } craft.vehicleCost += cost; initWeaponDispensers.add(newBlock); @@ -2214,7 +2215,7 @@ public void signUpdates(Block newBlock) { String line3 = "Fathometer:" + dukString; String line1 = "Grid: "; - if (PermissionInterface.CheckEnabledWorld(craft.getLocation())) { + if (Utils.CheckEnabledWorld(craft.getLocation())) { for (int i = 0; i < 2; i++) { int cord = 0; if (i == 0) { @@ -4795,6 +4796,8 @@ public void signUpdates(Block newBlock) { cost = 100; } else if (craftTypeName.equalsIgnoreCase("flak-gun")) { cost = 200; + } else if (craftTypeName.equalsIgnoreCase("ciws")) { + cost = 1250; } else if (craftTypeName.equalsIgnoreCase("radar")) { cost = 200; } else if (craftTypeName.equalsIgnoreCase("radio")) { @@ -5127,7 +5130,7 @@ public boolean checkProtectedRegion(Location loc) { wgp = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard"); if ((wgp != null) && (loc != null)) { - if ( !PermissionInterface.CheckEnabledWorld(loc) ) { return true; } + if ( !Utils.CheckEnabledWorld(loc) ) { return true; } RegionManager regionManager = wgp.getRegionManager(craft.world); ApplicableRegionSet set = regionManager.getApplicableRegions(loc); @@ -5646,7 +5649,7 @@ public void sinkBroadcast() { broadcastMsg = ""; int score = (int) (((float) uncrewedPlayers.get(p) / (float) totalDamage) * 100.0f); int damage = (int) (((float) uncrewedPlayers.get(p) / (float) totalDamage) * totalBlocks); - if (PermissionInterface.CheckEnabledWorld(craft.getLocation()) && (!craft.crewNames.isEmpty() || (((System.currentTimeMillis() - craft.abandonTime) / 1000) < 180))) { + if (Utils.CheckEnabledWorld(craft.getLocation()) && (!craft.crewNames.isEmpty() || (((System.currentTimeMillis() - craft.abandonTime) / 1000) < 180))) { if (craft.crewHistory.contains(p.getName()) && !p.isOp()) { return; } NavyCraft_BlockListener.rewardExpPlayer(damage, p); } @@ -5873,13 +5876,10 @@ public void soundUpdate(final Craft c, final int engineIndex, final int i) { }else if (engType == 3 || engType == 6 || engType == 7) // Boilers { float pitch = ((float) c.setSpeed / (float) 6.0f)*0.5f + 0.5f; - if( i%2 == 0 ) - playEngineSound(cLoc, Sound.ENTITY_IRONGOLEM_HURT, volume, pitch); - else - playEngineSound(cLoc, Sound.ENTITY_POLAR_BEAR_WARNING, volume, 0.5f); + playEngineSound(cLoc, Sound.ENTITY_POLAR_BEAR_WARNING, volume, pitch); }else if (engType == 5 || engType == 8) // Gasolines { - float pitch = ((float) c.setSpeed / (float) 6.0f)*1.0f + 1.0f; + float pitch = (((float) c.setSpeed / (float) 6.0f)*1.0f + 1.0f)/2; playEngineSound(cLoc, Sound.ENTITY_MINECART_RIDING, volume, pitch); }else if (engType == 9) // Nuclear { @@ -5887,12 +5887,8 @@ public void soundUpdate(final Craft c, final int engineIndex, final int i) { playEngineSound(cLoc, Sound.ENTITY_WITHER_SPAWN, volume, pitch); }else if ((engType >= 10) && (engType <= 17)) // Airplanes { - float pitch = 0.5f; - float pitch2 = ((float) c.setSpeed / (float) 6.0f)*1.5f + 0.5f; - if( i%4 == 0 ) - playEngineSound(cLoc, Sound.ENTITY_WOLF_GROWL, volume, pitch); - else - playEngineSound(cLoc, Sound.ENTITY_IRONGOLEM_HURT, volume, pitch2); + float pitch = (((float) c.setSpeed / (float) 6.0f)*1.5f + 0.5f)/2; + playEngineSound(cLoc, Sound.ENTITY_WOLF_GROWL, volume, pitch); if( c.type.canFly && !c.onGround && i%3 == 0) playEngineSound(c.getLocation(), Sound.ENTITY_WITHER_AMBIENT, 0.3f, 0.5f); }else if ((engType == 18) || (engType == 19)) // Tanks diff --git a/src/main/java/com/maximuspayne/navycraft/craft/CraftRotator.java b/src/main/java/com/maximuspayne/navycraft/craft/CraftRotator.java index b71d907..00f2125 100644 --- a/src/main/java/com/maximuspayne/navycraft/craft/CraftRotator.java +++ b/src/main/java/com/maximuspayne/navycraft/craft/CraftRotator.java @@ -463,7 +463,7 @@ public void moveBlocks(Vector moveBy, int dr){ if(dataBlock.locationMatches(newX, y, newZ)) { ///check if cannon - if( dataBlock.id == 23) + if( dataBlock.id == 23 ||dataBlock.id == 158) { Location cannonLoc = new Location(craft.world, dataBlock.x + craft.minX, dataBlock.y + craft.minY, dataBlock.z + craft.minZ); for (OneCannon onec : AimCannon.getCannons()) diff --git a/src/main/java/com/maximuspayne/navycraft/craft/CraftType.java b/src/main/java/com/maximuspayne/navycraft/craft/CraftType.java index c766685..8c6bd67 100644 --- a/src/main/java/com/maximuspayne/navycraft/craft/CraftType.java +++ b/src/main/java/com/maximuspayne/navycraft/craft/CraftType.java @@ -2,7 +2,10 @@ import java.io.*; import java.util.ArrayList; +import java.util.List; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import com.maximuspayne.navycraft.NavyCraft; @@ -16,6 +19,10 @@ */ public class CraftType { + public static FileConfiguration CraftConfig; + public static File CraftFile; + + public String name = ""; public String driveCommand = "drive"; @@ -103,152 +110,6 @@ public Boolean canUse(Player player){ else return false; } - - private static void loadDefaultCraftTypes() { - // if the default craft types are not loaded (first execution), then - // load them - if (CraftType.getCraftType("boat") == null) - craftTypes.add(CraftType.getDefaultCraftType("boat")); - if (CraftType.getCraftType("ship") == null) - craftTypes.add(CraftType.getDefaultCraftType("ship")); - if (CraftType.getCraftType("freeship") == null) - craftTypes.add(CraftType.getDefaultCraftType("freeship")); - if (CraftType.getCraftType("halfship") == null) - craftTypes.add(CraftType.getDefaultCraftType("halfship")); - if (CraftType.getCraftType("aircraft") == null) - craftTypes.add(CraftType.getDefaultCraftType("aircraft")); - if (CraftType.getCraftType("airship") == null) - craftTypes.add(CraftType.getDefaultCraftType("airship")); - if (CraftType.getCraftType("submarine") == null) - craftTypes.add(CraftType.getDefaultCraftType("submarine")); - if (CraftType.getCraftType("tank") == null) - craftTypes.add(CraftType.getDefaultCraftType("tank")); - } - - private static CraftType getDefaultCraftType(String name) { - - CraftType craftType = new CraftType(name); - - if (name.equalsIgnoreCase("ship")) { - setAttribute( - craftType, - "structureBlocks", - "4,5,14,15,16,17,19,20,21,22,23,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56," - + "57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91," - + "92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132," - + "133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163," - + "164,165,166,167,168,169,170,172,173,174,183,184,185,186,187,188,189,190,191,192,0"); - - craftType.driveCommand = "sail"; - craftType.canNavigate = true; - craftType.minBlocks = 50; - craftType.maxBlocks = 18000; - craftType.maxSpeed = 6; - craftType.doesCruise = true; - craftType.maxEngineSpeed = 8; - craftType.maxForwardGear = 2; - - } else if (name.equalsIgnoreCase("freeship")) { - setAttribute( - craftType, - "structureBlocks", - "4,5,14,15,16,17,19,20,21,22,23,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56," - + "57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91," - + "92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132," - + "133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163," - + "164,165,166,167,168,169,170,172,173,174,183,184,185,186,187,188,189,190,191,192,0"); - - craftType.driveCommand = "sail"; - craftType.canNavigate = true; - craftType.minBlocks = 50; - craftType.maxBlocks = 3000; - craftType.maxSpeed = 6; - craftType.doesCruise = true; - craftType.maxEngineSpeed = 8; - craftType.maxForwardGear = 3; - craftType.discount = 100; - craftType.adminBuild = true; - - } else if (name.equalsIgnoreCase("aircraft")) { - setAttribute( - craftType, - "structureBlocks", - "4,5,14,15,16,17,20,21,22,23,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56," - + "57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91," - + "92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132," - + "133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,160,162,163," - + "164,165,166,167,168,169,170,172,173,174,183,184,185,186,187,188,189,190,191,192,0"); - craftType.driveCommand = "pilot"; - craftType.canFly = true; - craftType.minBlocks = 20; - craftType.maxBlocks = 18000; - craftType.maxSpeed = 20; - craftType.doesCruise = true; - craftType.maxEngineSpeed = 8; - craftType.maxForwardGear = 3; - - } else if (name.equalsIgnoreCase("helicopter")) { - setAttribute( - craftType, - "structureBlocks", - "4,5,14,15,16,17,20,21,22,23,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56," - + "57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91," - + "92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132," - + "133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,160,162,163," - + "164,165,166,167,168,169,170,172,173,174,183,184,185,186,187,188,189,190,191,192,0"); - craftType.driveCommand = "pilot"; - craftType.canFly = true; - craftType.minBlocks = 9; - craftType.maxBlocks = 18000; - craftType.maxSpeed = 5; - craftType.doesCruise = false; - craftType.maxForwardGear = 3; - - } else if (name.equalsIgnoreCase("submarine")) { - setAttribute( - craftType, - "structureBlocks", - "4,5,14,15,16,17,19,20,21,22,23,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56," - + "57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91," - + "92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132," - + "133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163," - + "164,165,166,167,168,169,170,172,173,174,183,184,185,186,187,188,189,190,191,192,0"); - - craftType.driveCommand = "dive"; - craftType.canDive = true; - craftType.minBlocks = 20; - craftType.maxBlocks = 18000; - craftType.maxSpeed = 3; - craftType.doesCruise = true; - craftType.maxEngineSpeed = 6; - craftType.maxSubmergedSpeed = 3; - craftType.maxForwardGear = 2; - } else if (name.equalsIgnoreCase("tank")) { - setAttribute( - craftType, - "structureBlocks", - "4,5,14,15,16,17,20,21,22,23,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56," - + "57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91," - + "92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132," - + "133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163," - + "164,165,166,167,168,169,170,172,173,174,183,184,185,186,187,188,189,190,191,192,0"); - - craftType.driveCommand = "drive"; - craftType.canNavigate = false; - craftType.isTerrestrial = true; - craftType.obeysGravity = true; - craftType.minBlocks = 10; - craftType.maxBlocks = 2000; - craftType.maxSpeed = 3; - craftType.doesCruise = true; - craftType.maxEngineSpeed = 4; - craftType.maxForwardGear = 3; - - } - - return craftType; - } - // set the attributes of the craft type private static void setAttribute(CraftType craftType, String attribute, String value) { @@ -381,144 +242,139 @@ else if (attribute.equalsIgnoreCase("structureBlocks")) { } } - public static void saveType(File dir, CraftType craftType, boolean force) { - File craftFile = new File(dir + File.separator - + craftType.name + ".txt"); - - if (!craftFile.exists()) { + + public static void setupCraftConfig() { + if (!NavyCraft.instance.getDataFolder().exists()) { + NavyCraft.instance.getDataFolder().mkdir(); + } + CraftFile = new File(NavyCraft.instance.getDataFolder() + File.separator , "types.yml"); + CraftConfig = YamlConfiguration.loadConfiguration(CraftFile); + + if (!CraftFile.exists()) { try { - craftFile.createNewFile(); - } catch (IOException ex) { - return; - } - } else - // we don't overwrite existing files - return; - - try { - BufferedWriter writer = new BufferedWriter( - new FileWriter(craftFile)); - - writeAttribute(writer, "driveCommand", craftType.driveCommand, - force); - writeAttribute(writer, "minBlocks", craftType.minBlocks, true); - writeAttribute(writer, "maxBlocks", craftType.maxBlocks, force); - - // list of blocks that make the structure of the craft - if (craftType.structureBlocks != null) { - String line = "structureBlocks="; - for (short blockId : craftType.structureBlocks) { - - line += blockId + ","; - } - - writer.write(line.substring(0, line.length() - 1)); - writer.newLine(); + CraftConfig.createSection("Types"); + //Ship + CraftConfig.set("Types.ship.structureBlocks", "4,5,14,15,16,17,19,20,21,22,23,24,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91,92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132,133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163,164,165,166,167,168,169,170,172,173,174,179,183,184,185,186,187,188,189,190,191,192,251,0"); + CraftConfig.set("Types.ship.forbiddenBlocks", "29,33,416"); + CraftConfig.set("Types.ship.driveCommand", "sail"); + CraftConfig.set("Types.ship.canNavigate", "true"); + CraftConfig.set("Types.ship.minBlocks", "20"); + CraftConfig.set("Types.ship.maxBlocks", "50000"); + CraftConfig.set("Types.ship.maxSpeed", "6"); + CraftConfig.set("Types.ship.doesCruise", "true"); + CraftConfig.set("Types.ship.maxEngineSpeed", "8"); + CraftConfig.set("Types.ship.maxForwardGear", "2"); + CraftConfig.set("Types.ship.maxReverseGear", "-2"); + //Freeship + CraftConfig.set("Types.freeship.structureBlocks", "4,5,14,15,16,17,19,20,21,22,23,24,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91,92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132,133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163,164,165,166,167,168,169,170,172,173,174,179,183,184,185,186,187,188,189,190,191,192,251,0"); + CraftConfig.set("Types.freeship.forbiddenBlocks", "29,33,416"); + CraftConfig.set("Types.freeship.driveCommand", "sail"); + CraftConfig.set("Types.freeship.canNavigate", "true"); + CraftConfig.set("Types.freeship.minBlocks", "20"); + CraftConfig.set("Types.freeship.maxBlocks", "50000"); + CraftConfig.set("Types.freeship.maxSpeed", "6"); + CraftConfig.set("Types.freeship.doesCruise", "true"); + CraftConfig.set("Types.freeship.maxEngineSpeed", "8"); + CraftConfig.set("Types.freeship.maxForwardGear", "2"); + CraftConfig.set("Types.freeship.maxReverseGear", "-2"); + CraftConfig.set("Types.freeship.discount", "100"); + CraftConfig.set("Types.freeship.adminBuild", "true"); + //Submarine + CraftConfig.set("Types.submarine.structureBlocks", "4,5,14,15,16,17,19,20,21,22,23,24,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91,92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132,133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163,164,165,166,167,168,169,170,172,173,174,179,183,184,185,186,187,188,189,190,191,192,251,0"); + CraftConfig.set("Types.submarine.forbiddenBlocks", "29,33,416"); + CraftConfig.set("Types.submarine.driveCommand", "dive"); + CraftConfig.set("Types.submarine.canDive", "true"); + CraftConfig.set("Types.submarine.minBlocks", "20"); + CraftConfig.set("Types.submarine.maxBlocks", "50000"); + CraftConfig.set("Types.submarine.maxSpeed", "3"); + CraftConfig.set("Types.submarine.doesCruise", "true"); + CraftConfig.set("Types.submarine.maxEngineSpeed", "6"); + CraftConfig.set("Types.submarine.maxSubmergedSpeed", "3"); + CraftConfig.set("Types.submarine.maxForwardGear", "2"); + CraftConfig.set("Types.submarine.maxReverseGear", "-2"); + //Aircraft + CraftConfig.set("Types.aircraft.structureBlocks", "4,5,14,15,16,17,20,21,22,23,24,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91,92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132,133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163,164,165,166,167,168,169,170,172,173,174,179,183,184,185,186,187,188,189,190,191,192,0"); + CraftConfig.set("Types.aircraft.forbiddenBlocks", "29,33,251,416"); + CraftConfig.set("Types.aircraft.driveCommand", "pilot"); + CraftConfig.set("Types.aircraft.canFly", "true"); + CraftConfig.set("Types.aircraft.minBlocks", "20"); + CraftConfig.set("Types.aircraft.maxBlocks", "20000"); + CraftConfig.set("Types.aircraft.maxSpeed", "20"); + CraftConfig.set("Types.aircraft.doesCruise", "true"); + CraftConfig.set("Types.aircraft.maxEngineSpeed", "8"); + CraftConfig.set("Types.aircraft.maxForwardGear", "3"); + CraftConfig.set("Types.aircraft.maxReverseGear", "-2"); + + CraftConfig.set("Types.helicopter.structureBlocks", "4,5,14,15,16,17,20,21,22,23,24,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91,92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132,133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163,164,165,166,167,168,169,170,172,173,174,183,184,185,186,187,188,189,190,191,192,0"); + CraftConfig.set("Types.helicopter.forbiddenBlocks", "29,33,251,416"); + CraftConfig.set("Types.helicopter.driveCommand", "pilot"); + CraftConfig.set("Types.helicopter.canFly", "true"); + CraftConfig.set("Types.helicopter.minBlocks", "20"); + CraftConfig.set("Types.helicopter.maxBlocks", "20000"); + CraftConfig.set("Types.helicopter.maxSpeed", "5"); + CraftConfig.set("Types.helicopter.doesCruise", "false"); + CraftConfig.set("Types.helicopter.maxForwardGear", "3"); + CraftConfig.set("Types.helicopter.maxReverseGear", "-2"); + + CraftConfig.set("Types.tank.structureBlocks", "4,5,14,15,16,17,20,21,22,23,24,25,26,27,28,30,35,41,42,43,44,45,46,47,48,49,50,51,53,54,55,56,57,58,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,79,80,81,82,84,85,86,87,88,89,91,92,93,94,95,96,98,101,102,106,107,108,109,112,113,114,118,121,123,124,125,126,129,131,132,133,134,135,136,139,143,144,147,148,149,150,151,152,153,154,155,156,157,158,159,160,162,163,164,165,166,167,168,169,170,172,173,174,179,183,184,185,186,187,188,189,190,191,192,251,0"); + CraftConfig.set("Types.tank.forbiddenBlocks", "29,33,416"); + CraftConfig.set("Types.tank.driveCommand", "drive"); + CraftConfig.set("Types.tank.canNavigate", "false"); + CraftConfig.set("Types.tank.isTerrestrial", "true"); + CraftConfig.set("Types.tank.obeysGravity", "true"); + CraftConfig.set("Types.tank.minBlocks", "20"); + CraftConfig.set("Types.tank.maxBlocks", "10000"); + CraftConfig.set("Types.tank.maxSpeed", "3"); + CraftConfig.set("Types.tank.doesCruise", "true"); + CraftConfig.set("Types.tank.maxEngineSpeed", "5"); + CraftConfig.set("Types.tank.maxForwardGear", "3"); + CraftConfig.set("Types.tank.maxReverseGear", "-2"); + + CraftConfig.save(CraftFile); + } catch(IOException e) { + System.out.println("Could not create the types.yml file!"); } - - writeAttribute(writer, "maxSpeed", craftType.maxSpeed, force); - writeAttribute(writer, "discount", craftType.discount, force); - writeAttribute(writer, "adminBuild", craftType.adminBuild, force); - writeAttribute(writer, "digBlockId", craftType.digBlockId, force); - writeAttribute(writer, "digBlockDurability", craftType.digBlockDurability, force); - writeAttribute(writer, "canNavigate", craftType.canNavigate, force); - writeAttribute(writer, "isTerrestrial", craftType.isTerrestrial, force); - writeAttribute(writer, "canFly", craftType.canFly, force); - writeAttribute(writer, "canDive", craftType.canDive, force); - writeAttribute(writer, "canDig", craftType.canDig, force); - writeAttribute(writer, "obeysGravity", craftType.obeysGravity, force); - // writeAttribute(writer, "iceBreaker", craftType.iceBreaker); - writeAttribute(writer, "doesCruise", craftType.doesCruise, force); - writeAttribute(writer, "maxEngineSpeed", craftType.maxEngineSpeed, force); - writeAttribute(writer, "maxSubmergedSpeed", craftType.maxSubmergedSpeed, force); - writeAttribute(writer, "maxForwardGear", craftType.maxForwardGear, force); - writeAttribute(writer, "maxReverseGear", craftType.maxReverseGear, force); - - writer.close(); - - } catch (IOException ex) { - } - } - - public static void saveTypes(File dir) { - for (CraftType craftType : craftTypes) { - saveType(dir, craftType, false); } - - // the template is just a file that shows all parameters - saveType(dir, getDefaultCraftType("template"), true); - + loadTypes(); } - - private static void writeAttribute(BufferedWriter writer, String attribute, - String value, boolean force) throws IOException { - if ((value == null || value.trim().equals("")) && !force) - return; - writer.write(attribute + "=" + value); - writer.newLine(); + + public static FileConfiguration getCraftConfig () { + return CraftConfig; } - - private static void writeAttribute(BufferedWriter writer, String attribute, - int value, boolean force) throws IOException { - if (value == 0 && !force) - return; - writer.write(attribute + "=" + value); - writer.newLine(); + + public static void saveCraftConfig() { + try { + CraftConfig.save(CraftFile); + } catch (IOException e) { + System.out.println("Could not save types.yml file"); + } } - - private static void writeAttribute(BufferedWriter writer, String attribute, - boolean value, boolean force) throws IOException { - if (!value && !force) - return; - writer.write(attribute + "=" + value); - writer.newLine(); + public static void reloadCraftConfig() { + CraftConfig = YamlConfiguration.loadConfiguration(CraftFile); } - public static void loadTypes(File dir) { - File[] craftTypesList = dir.listFiles(); + public static void loadTypes() { + List list = new ArrayList(CraftConfig.getConfigurationSection("Types").getKeys(false)); + int size = list.size(); craftTypes.clear(); - for (File craftFile : craftTypesList) { - - if (craftFile.isFile() && craftFile.getName().endsWith(".txt")) { - - String craftName = craftFile.getName().split("\\.")[0]; - - // skip the template file - if (craftName.equalsIgnoreCase("template")) - continue; - - CraftType craftType = new CraftType(craftName); + if (size == 0) return; + for (String name : list) { + System.out.println("Found Type: " + name); + CraftType craftType = new CraftType(name); craftType.HelmControllerItem = Integer.parseInt(NavyCraft.instance.getConfig().getString("HelmID")); - try { - BufferedReader reader = new BufferedReader(new FileReader( - craftFile)); - - String line; - while ((line = reader.readLine()) != null) { + List info = new ArrayList(CraftConfig.getConfigurationSection("Types." + name).getKeys(false)); + int s = info.size(); - String[] split; - split = line.split("="); - - if (split.length >= 2) - setAttribute(craftType, split[0], split[1]); + if (s == 0) return; + + for (String attribute : info) { + setAttribute(craftType, attribute, CraftConfig.getString("Types." + name + "." + attribute)); } - reader.close(); - - } catch (IOException ex) { - - System.out.println("Warning, craft type " + craftType.name + " has an invalid engine block ID. " + - "Please use a block which has a facing direction (default is furnace, ID 61)."); - } - craftTypes.add(craftType); - } } - - if(NavyCraft.instance.getConfig().getString("WriteDefaultCraft").equalsIgnoreCase("true")) - loadDefaultCraftTypes(); } } diff --git a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_BlockListener.java b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_BlockListener.java index ad3b5ef..15c8138 100644 --- a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_BlockListener.java +++ b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_BlockListener.java @@ -1,10 +1,10 @@ package com.maximuspayne.navycraft.listeners; -import java.io.File; import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Random; import java.util.Set; import org.bukkit.ChatColor; @@ -15,8 +15,6 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -37,9 +35,14 @@ import com.maximuspayne.navycraft.NavyCraft; import com.maximuspayne.navycraft.Periscope; import com.maximuspayne.navycraft.PermissionInterface; +import com.maximuspayne.navycraft.Utils; import com.maximuspayne.navycraft.craft.Craft; import com.maximuspayne.navycraft.craft.CraftMover; import com.maximuspayne.navycraft.craft.CraftType; +import com.maximuspayne.shipyard.Plot; +import com.maximuspayne.shipyard.PlotType; +import com.maximuspayne.shipyard.Reward; +import com.maximuspayne.shipyard.Shipyard; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.MaxChangedBlocksException; @@ -81,7 +84,7 @@ public void onBlockPlace(BlockPlaceEvent event) { // System.out.println("Updated craft is " + updatedCraft.name + " of type " + updatedCraft.type.name); if (theCraft != null) { - if (theCraft.crewNames.contains(event.getPlayer().getName()) || event.getPlayer().isOp() || PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.admin")) { + if (theCraft.crewNames.contains(event.getPlayer().getName()) || event.getPlayer().isOp() || PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.pbes")) { theCraft.addBlock(event.getBlock(), false); } else { event.getPlayer().sendMessage(ChatColor.RED + "You can't place blocks on enemy ships!"); @@ -90,7 +93,7 @@ public void onBlockPlace(BlockPlaceEvent event) { } else { theCraft = Craft.getCraft(event.getBlock().getX(), event.getBlock().getY(), event.getBlock().getZ()); if (theCraft != null) { - if (theCraft.crewNames.contains(event.getPlayer().getName()) || event.getPlayer().isOp() || PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.admin")) { + if (theCraft.crewNames.contains(event.getPlayer().getName()) || event.getPlayer().isOp() || PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.pbes")) { theCraft.addBlock(event.getBlock(), false); } else { event.getPlayer().sendMessage(ChatColor.RED + "You can't place blocks on enemy ships!"); @@ -99,13 +102,8 @@ public void onBlockPlace(BlockPlaceEvent event) { } } } - + public static void ClickedASign(Player player, Block block, boolean leftClick) { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(f); // String world = block.getWorld().getName(); Craft playerCraft = Craft.getPlayerCraft(player); @@ -117,7 +115,6 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { // remove colors craftTypeName = craftTypeName.replaceAll(ChatColor.BLUE.toString(), ""); - int lotType = 0; /// 1=SHIP1, 2=SHIP2, 3=SHIP3, 4=SHIP4, 5=SHIP5, 6=hangar1, 7=hangar2 8=tank1 9=tank2 // remove brackets if (craftTypeName.startsWith("[")) { @@ -184,39 +181,6 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { player.sendMessage(ChatColor.DARK_RED + "Sign Error: Invalid Rank Requirement"); return; } - - if (lotStr.equalsIgnoreCase("SHIP1")) { - lotType = 1; - } else if (lotStr.equalsIgnoreCase("SHIP2")) { - lotType = 2; - } else if (lotStr.equalsIgnoreCase("SHIP3")) { - lotType = 3; - } else if (lotStr.equalsIgnoreCase("SHIP4")) { - lotType = 4; - } else if (lotStr.equalsIgnoreCase("SHIP5")) { - lotType = 5; - } else if (lotStr.equalsIgnoreCase("HANGAR1")) { - lotType = 6; - } else if (lotStr.equalsIgnoreCase("HANGAR2")) { - lotType = 7; - } else if (lotStr.equalsIgnoreCase("TANK1")) { - lotType = 8; - } else if (lotStr.equalsIgnoreCase("TANK2")) { - lotType = 9; - } else if (lotStr.equalsIgnoreCase("MAP1")) { - lotType = 10; - } else if (lotStr.equalsIgnoreCase("MAP2")) { - lotType = 11; - } else if (lotStr.equalsIgnoreCase("MAP3")) { - lotType = 12; - } else if (lotStr.equalsIgnoreCase("MAP4")) { - lotType = 13; - } else if (lotStr.equalsIgnoreCase("MAP5")) { - lotType = 14; - } else { - player.sendMessage(ChatColor.RED + "Sign error: lot type"); - return; - } String ownerName = null; if (!sign.getLine(1).isEmpty()) { ownerName = sign.getLine(1) + sign.getLine(2); @@ -231,16 +195,20 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { } if (tpId > -1) { - + NavyCraft_FileListener.loadSignData(); + NavyCraft_BlockListener.loadRewards(ownerName); Sign foundSign = null; foundSign = NavyCraft_BlockListener.findSign(ownerName, tpId); if ((foundSign != null) && foundSign.getLocation().equals(sign.getLocation())) { wgp = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard"); if (wgp != null) { RegionManager regionManager = wgp.getRegionManager(plugin.getServer().getWorld("shipyard")); - String regionName = "--" + ownerName + "-" + tpId; - - if ((regionManager.getRegion(regionName) != null) && !regionManager.getRegion(regionName).getMembers().contains(player.getName())) { + int x = foundSign.getX(); + int y = foundSign.getY(); + int z = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + ownerName + "-" + NavyCraft_FileListener.getSign(x, y, z, world); + if ((regionManager.getRegion(regionName) != null) && !regionManager.getRegion(regionName).getMembers().contains(player.getUniqueId())) { player.sendMessage("You are not allowed to select this plot."); return; } @@ -263,96 +231,42 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { EditSession es = wep.createEditSession(player); - Location loc; - int sizeX, sizeY, sizeZ, originX, originY, originZ; - if (lotType == 1) { - loc = block.getRelative(bf, syConfig.getInt("SHIP1BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP1SZX"); - sizeY = syConfig.getInt("SHIP1SZY"); - sizeZ = syConfig.getInt("SHIP1SZZ"); - originX = syConfig.getInt("SHIP1OX"); - originY = syConfig.getInt("SHIP1OY"); - originZ = syConfig.getInt("SHIP1OZ"); - } else if (lotType == 2) { - loc = block.getRelative(bf, syConfig.getInt("SHIP2BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP2SZX"); - sizeY = syConfig.getInt("SHIP2SZY"); - sizeZ = syConfig.getInt("SHIP2SZZ"); - originX = syConfig.getInt("SHIP2OX"); - originY = syConfig.getInt("SHIP2OY"); - originZ = syConfig.getInt("SHIP2OZ"); - } else if (lotType == 3) { - loc = block.getRelative(bf, syConfig.getInt("SHIP3BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP3SZX"); - sizeY = syConfig.getInt("SHIP3SZY"); - sizeZ = syConfig.getInt("SHIP3SZZ"); - originX = syConfig.getInt("SHIP3OX"); - originY = syConfig.getInt("SHIP3OY"); - originZ = syConfig.getInt("SHIP3OZ"); - } else if (lotType == 4) { - loc = block.getRelative(bf, syConfig.getInt("SHIP4BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP4SZX"); - sizeY = syConfig.getInt("SHIP4SZY"); - sizeZ = syConfig.getInt("SHIP4SZZ"); - originX = syConfig.getInt("SHIP4OX"); - originY = syConfig.getInt("SHIP4OY"); - originZ = syConfig.getInt("SHIP4OZ"); - } else if (lotType == 5) { - loc = block.getRelative(bf, syConfig.getInt("SHIP5BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP5SZX"); - sizeY = syConfig.getInt("SHIP5SZY"); - sizeZ = syConfig.getInt("SHIP5SZZ"); - originX = syConfig.getInt("SHIP5OX"); - originY = syConfig.getInt("SHIP5OY"); - originZ = syConfig.getInt("SHIP5OZ"); - } else if (lotType == 6) { - loc = block.getRelative(bf, syConfig.getInt("HANGAR1BFR")).getLocation(); - sizeX = syConfig.getInt("HANGAR1SZX"); - sizeY = syConfig.getInt("HANGAR1SZY"); - sizeZ = syConfig.getInt("HANGAR1SZZ"); - originX = syConfig.getInt("HANGAR1OX"); - originY = syConfig.getInt("HANGAR1OY"); - originZ = syConfig.getInt("HANGAR1OZ"); - } else if (lotType == 7) { - loc = block.getRelative(bf, syConfig.getInt("HANGAR2BFR")).getLocation(); - sizeX = syConfig.getInt("HANGAR2SZX"); - sizeY = syConfig.getInt("HANGAR2SZY"); - sizeZ = syConfig.getInt("HANGAR2SZZ"); - originX = syConfig.getInt("HANGAR2OX"); - originY = syConfig.getInt("HANGAR2OY"); - originZ = syConfig.getInt("HANGAR2OZ"); - } else if (lotType == 8) { - loc = block.getRelative(bf, syConfig.getInt("TANK1BFR")).getLocation(); - sizeX = syConfig.getInt("TANK1SZX"); - sizeY = syConfig.getInt("TANK1SZY"); - sizeZ = syConfig.getInt("TANK1SZZ"); - originX = syConfig.getInt("TANK1OX"); - originY = syConfig.getInt("TANK1OY"); - originZ = syConfig.getInt("TANK1OZ"); - } else if (lotType == 9) { - loc = block.getRelative(bf, syConfig.getInt("TANK2BFR")).getLocation(); - sizeX = syConfig.getInt("TANK2SZX"); - sizeY = syConfig.getInt("TANK2SZY"); - sizeZ = syConfig.getInt("TANK2SZZ"); - originX = syConfig.getInt("TANK2OX"); - originY = syConfig.getInt("TANK2OY"); - originZ = syConfig.getInt("TANK2OZ"); - } else if (lotType > 10 && lotType < 14) { - player.sendMessage(ChatColor.RED + "You can't select and spawn map plots!"); - return; - } else - - { + Location loc = null; + int sizeX= 0, sizeY = 0, sizeZ = 0, originX = 0, originY = 0, originZ = 0; + String name = null; + boolean doFix = false; + boolean dontSelect = false; + for (PlotType pt : Shipyard.getPlots()) { + if (pt.name.equalsIgnoreCase(lotStr)) { + name = pt.name; + doFix = pt.doFix; + dontSelect = pt.dontSelect; + sizeX = pt.sizeX; + sizeY = pt.sizeY; + sizeZ = pt.sizeZ; + originX= pt.originX; + originY = pt.originY; + originZ = pt.originZ; + loc = block.getRelative(bf, pt.bfr).getLocation(); + } + } + + if (name == null || sizeX == 0 || sizeY == 0 || sizeZ == 0 || loc == null){ player.sendMessage(ChatColor.DARK_RED + "Sign Error: Invalid Lot"); return; } + + if (dontSelect) { + player.sendMessage(ChatColor.RED + "You can't select this plot type!"); + return; + } CuboidRegion region = new CuboidRegion(new Vector(loc.getBlockX() + originX, loc.getBlockY() + originY, loc.getBlockZ() + originZ), new Vector((loc.getBlockX() + originX + sizeX) - 1, (loc.getBlockY() + originY + sizeY) - 1, (loc.getBlockZ() + originZ + sizeZ) - 1)); BlockArrayClipboard clipboard = new BlockArrayClipboard(region); try { - if ((lotType >= 6) && (lotType <= 14)) { + if (doFix) { clipboard.setOrigin(new Vector(block.getX() + 1, block.getY(), (block.getZ() - sizeZ) + 1)); } else { clipboard.setOrigin(new Vector(loc.getX(), loc.getY(), loc.getZ())); @@ -414,349 +328,56 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { String lotStr = sign2.getLine(3).trim().toLowerCase(); lotStr = lotStr.replaceAll(ChatColor.BLUE.toString(), ""); - if (lotStr.equalsIgnoreCase("SHIP1")) { - lotType = 1; - } else if (lotStr.equalsIgnoreCase("SHIP2")) { - lotType = 2; - } else if (lotStr.equalsIgnoreCase("SHIP3")) { - lotType = 3; - } else if (lotStr.equalsIgnoreCase("SHIP4")) { - lotType = 4; - } else if (lotStr.equalsIgnoreCase("SHIP5")) { - lotType = 5; - } else if (lotStr.equalsIgnoreCase("HANGAR1")) { - lotType = 6; - } else if (lotStr.equalsIgnoreCase("HANGAR2")) { - lotType = 7; - } else if (lotStr.equalsIgnoreCase("TANK1")) { - lotType = 8; - } else if (lotStr.equalsIgnoreCase("TANK2")) { - lotType = 9; - } else if (lotStr.equalsIgnoreCase("MAP1")) { - lotType = 10; - } else if (lotStr.equalsIgnoreCase("MAP2")) { - lotType = 11; - } else if (lotStr.equalsIgnoreCase("MAP3")) { - lotType = 12; - } else if (lotStr.equalsIgnoreCase("MAP4")) { - lotType = 13; - } else if (lotStr.equalsIgnoreCase("MAP5")) { - lotType = 14; - } else { - player.sendMessage(ChatColor.DARK_RED + "Sign Error: Lot Type"); - return; - } + NavyCraft_FileListener.loadSignData(); NavyCraft_BlockListener.loadRewards(player.getName()); - String UUID = PermissionInterface.getUUIDfromPlayer(player.getName()); - Location loc; - int sizeX, sizeY, sizeZ, originX, originY, originZ; - if (lotType == 1) { - loc = block.getRelative(bf, syConfig.getInt("SHIP1BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP1SZX"); - sizeY = syConfig.getInt("SHIP1SZY"); - sizeZ = syConfig.getInt("SHIP1SZZ"); - originX = syConfig.getInt("SHIP1OX"); - originY = syConfig.getInt("SHIP1OY"); - originZ = syConfig.getInt("SHIP1OZ"); - - int numSHIP1s = 0; - int numRewSHIP1s = 1; - if (NavyCraft.playerSHIP1Signs.containsKey(UUID)) { - numSHIP1s = NavyCraft.playerSHIP1Signs.get(UUID).size(); - } - if (NavyCraft.playerSHIP1Rewards.containsKey(UUID)) { - numRewSHIP1s = NavyCraft.playerSHIP1Rewards.get(UUID); - } - if (numSHIP1s >= numRewSHIP1s) { - player.sendMessage("You have no SHIP1 reward plots available."); - return; - } - - } else if (lotType == 2) { - loc = block.getRelative(bf, syConfig.getInt("SHIP2BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP2SZX"); - sizeY = syConfig.getInt("SHIP2SZY"); - sizeZ = syConfig.getInt("SHIP2SZZ"); - originX = syConfig.getInt("SHIP2OX"); - originY = syConfig.getInt("SHIP2OY"); - originZ = syConfig.getInt("SHIP2OZ"); - - int numSHIP2s = 0; - int numRewSHIP2s = 0; - if (NavyCraft.playerSHIP2Signs.containsKey(UUID)) { - numSHIP2s = NavyCraft.playerSHIP2Signs.get(UUID).size(); - } - if (NavyCraft.playerSHIP2Rewards.containsKey(UUID)) { - numRewSHIP2s = NavyCraft.playerSHIP2Rewards.get(UUID); - } - if (numSHIP2s >= numRewSHIP2s) { - player.sendMessage("You have no SHIP2 reward plots available."); - return; - } - } else if (lotType == 3) { - loc = block.getRelative(bf, syConfig.getInt("SHIP3BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP3SZX"); - sizeY = syConfig.getInt("SHIP3SZY"); - sizeZ = syConfig.getInt("SHIP3SZZ"); - originX = syConfig.getInt("SHIP3OX"); - originY = syConfig.getInt("SHIP3OY"); - originZ = syConfig.getInt("SHIP3OZ"); - - int numSHIP3s = 0; - int numRewSHIP3s = 0; - if (NavyCraft.playerSHIP3Signs.containsKey(UUID)) { - numSHIP3s = NavyCraft.playerSHIP3Signs.get(UUID).size(); - } - if (NavyCraft.playerSHIP3Rewards.containsKey(UUID)) { - numRewSHIP3s = NavyCraft.playerSHIP3Rewards.get(UUID); - } - if (numSHIP3s >= numRewSHIP3s) { - player.sendMessage("You have no SHIP3 reward plots available."); - return; - } - } else if (lotType == 4) { - loc = block.getRelative(bf, syConfig.getInt("SHIP4BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP4SZX"); - sizeY = syConfig.getInt("SHIP4SZY"); - sizeZ = syConfig.getInt("SHIP4SZZ"); - originX = syConfig.getInt("SHIP4OX"); - originY = syConfig.getInt("SHIP4OY"); - originZ = syConfig.getInt("SHIP4OZ"); - - int numSHIP4s = 0; - int numRewSHIP4s = 0; - if (NavyCraft.playerSHIP4Signs.containsKey(UUID)) { - numSHIP4s = NavyCraft.playerSHIP4Signs.get(UUID).size(); - } - if (NavyCraft.playerSHIP4Rewards.containsKey(UUID)) { - numRewSHIP4s = NavyCraft.playerSHIP4Rewards.get(UUID); - } - if (numSHIP4s >= numRewSHIP4s) { - player.sendMessage("You have no SHIP4 reward plots available."); - return; - } - } else if (lotType == 5) { - loc = block.getRelative(bf, syConfig.getInt("SHIP5BFR")).getLocation(); - sizeX = syConfig.getInt("SHIP5SZX"); - sizeY = syConfig.getInt("SHIP5SZY"); - sizeZ = syConfig.getInt("SHIP5SZZ"); - originX = syConfig.getInt("SHIP5OX"); - originY = syConfig.getInt("SHIP5OY"); - originZ = syConfig.getInt("SHIP5OZ"); - - int numSHIP5s = 0; - int numRewSHIP5s = 0; - if (NavyCraft.playerSHIP5Signs.containsKey(UUID)) { - numSHIP5s = NavyCraft.playerSHIP5Signs.get(UUID).size(); - } - if (NavyCraft.playerSHIP5Rewards.containsKey(UUID)) { - numRewSHIP5s = NavyCraft.playerSHIP5Rewards.get(UUID); - } - if (numSHIP5s >= numRewSHIP5s) { - player.sendMessage("You have no SHIP5 reward plots available."); - return; - } - } else if (lotType == 6) { - loc = block.getRelative(bf, syConfig.getInt("HANGAR1BFR")).getLocation(); - sizeX = syConfig.getInt("HANGAR1SZX"); - sizeY = syConfig.getInt("HANGAR1SZY"); - sizeZ = syConfig.getInt("HANGAR1SZZ"); - originX = syConfig.getInt("HANGAR1OX"); - originY = syConfig.getInt("HANGAR1OY"); - originZ = syConfig.getInt("HANGAR1OZ"); - - int numH1s = 0; - int numRewH1s = 0; - if (NavyCraft.playerHANGAR1Signs.containsKey(UUID)) { - numH1s = NavyCraft.playerHANGAR1Signs.get(UUID).size(); - } - if (NavyCraft.playerHANGAR1Rewards.containsKey(UUID)) { - numRewH1s = NavyCraft.playerHANGAR1Rewards.get(UUID); - } - if (numH1s >= numRewH1s) { - player.sendMessage("You have no HANGAR1 reward plots available."); - return; - } - } else if (lotType == 7) { - loc = block.getRelative(bf, syConfig.getInt("HANGAR2BFR")).getLocation(); - sizeX = syConfig.getInt("HANGAR2SZX"); - sizeY = syConfig.getInt("HANGAR2SZY"); - sizeZ = syConfig.getInt("HANGAR2SZZ"); - originX = syConfig.getInt("HANGAR2OX"); - originY = syConfig.getInt("HANGAR2OY"); - originZ = syConfig.getInt("HANGAR2OZ"); - - int numH2s = 0; - int numRewH2s = 0; - if (NavyCraft.playerHANGAR2Signs.containsKey(UUID)) { - numH2s = NavyCraft.playerHANGAR2Signs.get(UUID).size(); - } - if (NavyCraft.playerHANGAR2Rewards.containsKey(UUID)) { - numRewH2s = NavyCraft.playerHANGAR2Rewards.get(UUID); - } - if (numH2s >= numRewH2s) { - player.sendMessage("You have no HANGAR2 reward plots available."); - return; - } - } else if (lotType == 8) { - loc = block.getRelative(bf, syConfig.getInt("TANK1BFR")).getLocation(); - sizeX = syConfig.getInt("TANK1SZX"); - sizeY = syConfig.getInt("TANK1SZY"); - sizeZ = syConfig.getInt("TANK1SZZ"); - originX = syConfig.getInt("TANK1OX"); - originY = syConfig.getInt("TANK1OY"); - originZ = syConfig.getInt("TANK1OZ"); - - int numT1s = 0; - int numRewT1s = 0; - if (NavyCraft.playerTANK1Signs.containsKey(UUID)) { - numT1s = NavyCraft.playerTANK1Signs.get(UUID).size(); - } - if (NavyCraft.playerTANK1Rewards.containsKey(UUID)) { - numRewT1s = NavyCraft.playerTANK1Rewards.get(UUID); - } - if (numT1s >= numRewT1s) { - player.sendMessage("You have no TANK1 reward plots available."); - return; - } - } else if (lotType == 9) { - loc = block.getRelative(bf, syConfig.getInt("TANK2BFR")).getLocation(); - sizeX = syConfig.getInt("TANK2SZX"); - sizeY = syConfig.getInt("TANK2SZY"); - sizeZ = syConfig.getInt("TANK2SZZ"); - originX = syConfig.getInt("TANK2OX"); - originY = syConfig.getInt("TANK2OY"); - originZ = syConfig.getInt("TANK2OZ"); - - int numT2s = 0; - int numRewT2s = 0; - if (NavyCraft.playerTANK2Signs.containsKey(UUID)) { - numT2s = NavyCraft.playerTANK2Signs.get(UUID).size(); - } - if (NavyCraft.playerTANK2Rewards.containsKey(UUID)) { - numRewT2s = NavyCraft.playerTANK2Rewards.get(UUID); - } - if (numT2s >= numRewT2s) { - player.sendMessage("You have no TANK2 reward plots available."); - return; - } - } else if (lotType == 10) { - loc = block.getRelative(bf, syConfig.getInt("MAP1BFR")).getLocation(); - sizeX = syConfig.getInt("MAP1SZX"); - sizeY = syConfig.getInt("MAP1SZY"); - sizeZ = syConfig.getInt("MAP1SZZ"); - originX = syConfig.getInt("MAP1OX"); - originY = syConfig.getInt("MAP1OY"); - originZ = syConfig.getInt("MAP1OZ"); - - int numM1s = 0; - int numRewM1s = 0; - if (NavyCraft.playerMAP1Signs.containsKey(UUID)) { - numM1s = NavyCraft.playerMAP1Signs.get(UUID).size(); - } - if (NavyCraft.playerMAP1Rewards.containsKey(UUID)) { - numRewM1s = NavyCraft.playerMAP1Rewards.get(UUID); - } - if (numM1s >= numRewM1s) { - player.sendMessage("You have no MAP1 reward plots available."); - return; - } - } else if (lotType == 11) { - loc = block.getRelative(bf, syConfig.getInt("MAP2BFR")).getLocation(); - sizeX = syConfig.getInt("MAP2SZX"); - sizeY = syConfig.getInt("MAP2SZY"); - sizeZ = syConfig.getInt("MAP2SZZ"); - originX = syConfig.getInt("MAP2OX"); - originY = syConfig.getInt("MAP2OY"); - originZ = syConfig.getInt("MAP2OZ"); - - int numM2s = 0; - int numRewM2s = 0; - if (NavyCraft.playerMAP2Signs.containsKey(UUID)) { - numM2s = NavyCraft.playerMAP2Signs.get(UUID).size(); - } - if (NavyCraft.playerMAP2Rewards.containsKey(UUID)) { - numRewM2s = NavyCraft.playerMAP2Rewards.get(UUID); - } - if (numM2s >= numRewM2s) { - player.sendMessage("You have no MAP2 reward plots available."); - return; - } - } else if (lotType == 12) { - loc = block.getRelative(bf, syConfig.getInt("MAP3BFR")).getLocation(); - sizeX = syConfig.getInt("MAP3SZX"); - sizeY = syConfig.getInt("MAP3SZY"); - sizeZ = syConfig.getInt("MAP3SZZ"); - originX = syConfig.getInt("MAP3OX"); - originY = syConfig.getInt("MAP3OY"); - originZ = syConfig.getInt("MAP3OZ"); - - int numM3s = 0; - int numRewM3s = 0; - if (NavyCraft.playerMAP3Signs.containsKey(UUID)) { - numM3s = NavyCraft.playerMAP3Signs.get(UUID).size(); - } - if (NavyCraft.playerMAP3Rewards.containsKey(UUID)) { - numRewM3s = NavyCraft.playerMAP3Rewards.get(UUID); - } - if (numM3s >= numRewM3s) { - player.sendMessage("You have no MAP3 reward plots available."); - return; - } - } else if (lotType == 13) { - loc = block.getRelative(bf, syConfig.getInt("MAP4BFR")).getLocation(); - sizeX = syConfig.getInt("MAP4SZX"); - sizeY = syConfig.getInt("MAP4SZY"); - sizeZ = syConfig.getInt("MAP4SZZ"); - originX = syConfig.getInt("MAP4OX"); - originY = syConfig.getInt("MAP4OY"); - originZ = syConfig.getInt("MAP4OZ"); - - int numM4s = 0; - int numRewM4s = 0; - if (NavyCraft.playerMAP4Signs.containsKey(UUID)) { - numM4s = NavyCraft.playerMAP4Signs.get(UUID).size(); - } - if (NavyCraft.playerMAP4Rewards.containsKey(UUID)) { - numRewM4s = NavyCraft.playerMAP4Rewards.get(UUID); - } - if (numM4s >= numRewM4s) { - player.sendMessage("You have no MAP4 reward plots available."); - return; - } - } else if (lotType == 14) { - loc = block.getRelative(bf, syConfig.getInt("MAP5BFR")).getLocation(); - sizeX = syConfig.getInt("MAP5SZX"); - sizeY = syConfig.getInt("MAP5SZY"); - sizeZ = syConfig.getInt("MAP5SZZ"); - originX = syConfig.getInt("MAP5OX"); - originY = syConfig.getInt("MAP5OY"); - originZ = syConfig.getInt("MAP5OZ"); - - int numM5s = 0; - int numRewM5s = 0; - if (NavyCraft.playerMAP5Signs.containsKey(UUID)) { - numM5s = NavyCraft.playerMAP5Signs.get(UUID).size(); - } - if (NavyCraft.playerMAP5Rewards.containsKey(UUID)) { - numRewM5s = NavyCraft.playerMAP5Rewards.get(UUID); + String UUID = Utils.getUUIDfromPlayer(player.getName()); + Location loc = null; + int sizeX= 0, sizeY = 0, sizeZ = 0, originX = 0, originY = 0, originZ = 0; + String name = null; + int numPlots = 0; + int numRewPlots = 0; + for (PlotType pt : Shipyard.getPlots()) { + if (pt.name.equalsIgnoreCase(lotStr)) { + name = pt.name; + sizeX = pt.sizeX; + sizeY = pt.sizeY; + sizeZ = pt.sizeZ; + originX= pt.originX; + originY = pt.originY; + originZ = pt.originZ; + loc = block.getRelative(bf, pt.bfr).getLocation(); + if (NavyCraft.playerSigns.containsKey(UUID)) { + for (Plot p : NavyCraft.playerSigns.get(UUID)) { + if (p.name.equalsIgnoreCase(pt.name)) { + numPlots++; + } + } } - if (numM5s >= numRewM5s) { - player.sendMessage("You have no MAP5 reward plots available."); - return; + if (NavyCraft.playerRewards.containsKey(UUID)) { + for (Reward r : NavyCraft.playerRewards.get(UUID)) { + if (r.name.equalsIgnoreCase(pt.name)) { + numRewPlots = r.amount; + } + } } - } else + } + } + if (numPlots >= numRewPlots) { + player.sendMessage("You have no " + name + " reward plots available."); + return; + } - { + if (name == null || sizeX == 0 || sizeY == 0 || sizeZ == 0 || loc == null){ + NavyCraft.instance.DebugMessage(name, 3); + NavyCraft.instance.DebugMessage(String.valueOf(sizeX), 3); + NavyCraft.instance.DebugMessage(String.valueOf(sizeY), 3); + NavyCraft.instance.DebugMessage(String.valueOf(sizeZ), 3); + NavyCraft.instance.DebugMessage(loc.toString(), 3); player.sendMessage(ChatColor.DARK_RED + "Sign Error: Invalid Lot"); return; } - if (!NavyCraft_FileListener.checkSign(sign.getX(), sign.getY(), sign.getZ(), sign.getWorld())) { - NavyCraft_FileListener.saveSign(lotStr, sign.getWorld().getName(), sign.getX(), sign.getY(), sign.getZ()); - } - originX = loc.getBlockX() + originX; originY = loc.getBlockY() + originY; originZ = loc.getBlockZ() + originZ; @@ -767,20 +388,6 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { // ApplicableRegionSet set = regionManager.getApplicableRegions(loc); - String regionName = "--" + player.getName() + "-" + (maxId(player) + 1); - - regionManager.addRegion(new com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion(regionName, new com.sk89q.worldedit.BlockVector(originX, originY, originZ), new com.sk89q.worldedit.BlockVector((originX + sizeX) - 1, (originY + sizeY) - 1, (originZ + sizeZ) - 1))); - DefaultDomain owners = new DefaultDomain(); - com.sk89q.worldguard.LocalPlayer lp = wgp.wrapPlayer(player); - owners.addPlayer(lp); - regionManager.getRegion(regionName).setOwners(owners); - - try { - regionManager.save(); - } catch (StorageException e) { - e.printStackTrace(); - } - sign.setLine(0, "*Select*"); if (player.getName().length() > 15) { sign.setLine(1, player.getName().substring(0, 16)); @@ -799,7 +406,7 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { sign2.setLine(0, "Private"); sign2.setLine(1, "1"); sign2.setLine(2, "" + (maxId(player) + 1)); - sign2.setLine(3, lotStr); + sign2.setLine(3, lotStr.toUpperCase()); sign2.update(); player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + lotStr.toUpperCase() + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN + " Claimed!"); @@ -808,9 +415,20 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { int y = sign.getY(); int z = sign.getZ(); World world = sign.getWorld(); - NavyCraft_FileListener.saveClaimedSign(player.getName(), lotStr, world.getName(), x, y, z,Integer.valueOf(sign2.getLine(2))); + NavyCraft_FileListener.updateSign(UUID, lotStr, x, y, z, world, maxId(player) + 1, true); + String regionName = "--" + player.getName() + "-" + NavyCraft_FileListener.getSign(x, y, z, world); - NavyCraft_FileListener.loadSignData(); + regionManager.addRegion(new com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion(regionName, new com.sk89q.worldedit.BlockVector(originX, originY, originZ), new com.sk89q.worldedit.BlockVector((originX + sizeX) - 1, (originY + sizeY) - 1, (originZ + sizeZ) - 1))); + DefaultDomain owners = new DefaultDomain(); + com.sk89q.worldguard.LocalPlayer lp = wgp.wrapPlayer(player); + owners.addPlayer(lp); + regionManager.getRegion(regionName).setOwners(owners); + + try { + regionManager.save(); + } catch (StorageException e) { + e.printStackTrace(); + } } else { player.sendMessage("World Guard error"); } @@ -892,7 +510,7 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { String worldName = player.getWorld().getName(); for(String s:PermissionsEx.getUser(player).getPermissions(worldName)) { if( s.contains("navycraft") ) { - if( s.contains("rank") ) { + if( s.contains("spawn") ) { String[] split = s.split("\\."); try { playerRank = Integer.parseInt(split[2]); @@ -1044,8 +662,112 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { player.sendMessage("Max changed blocks error"); return; } + } else if (craftTypeName.equalsIgnoreCase("*clear*")) { + int rotate = -1; + BlockFace bf, bf2; + bf = null; + bf2 = null; + switch (block.getData()) { + case (byte) 0x2:// n + rotate = 180; + bf = BlockFace.SOUTH; + bf2 = BlockFace.WEST; + break; + case (byte) 0x3:// s + rotate = 0; + bf = BlockFace.NORTH; + bf2 = BlockFace.EAST; + break; + case (byte) 0x4:// w + rotate = 90; + bf = BlockFace.EAST; + bf2 = BlockFace.SOUTH; + break; + case (byte) 0x5:// e + rotate = 270; + bf = BlockFace.WEST; + bf2 = BlockFace.NORTH; + break; + default: + break; + } + + if (rotate == -1) { + player.sendMessage(ChatColor.DARK_RED + "Sign Error: Check Direction?"); + return; + } + if (block.getRelative(bf, 1).getTypeId() != 22) { + return; + } + + String typeString = sign.getLine(1).trim().toLowerCase(); + int shiftRight = 0; + int shiftForward = 0; + int shiftUp = 0; + int shiftDown = 0; + boolean typeFound = false; + for (PlotType pt : Shipyard.getPlots()) { + if (typeString.equalsIgnoreCase(pt.name)) { + if (!pt.doFix) { + shiftRight = pt.sizeX - 1; + shiftForward = pt.sizeZ; + shiftUp = 20; + shiftDown = 8; + } else { + shiftRight = -pt.sizeX - 1; + shiftForward = pt.sizeZ + 1; + shiftUp = pt.sizeY; + shiftDown = 0; + } + typeFound = true; + break; + } + } + + if (!typeFound) { + player.sendMessage(ChatColor.DARK_RED + "Sign Error: Lot Type"); + return; + } + Block rightLimit = block.getRelative(bf2, shiftRight).getRelative(bf, shiftForward + 2).getRelative(BlockFace.UP, shiftUp); + Block leftLimit = block.getRelative(bf, 2).getRelative(BlockFace.DOWN, shiftDown); + int rightX, rightY, rightZ; + int leftX, leftY, leftZ; + rightX = rightLimit.getX(); + rightY = rightLimit.getY(); + rightZ = rightLimit.getZ(); + leftX = leftLimit.getX(); + leftY = leftLimit.getY(); + leftZ = leftLimit.getZ(); + int startX, endX, startZ, endZ; + if (rightX < leftX) { + startX = rightX; + endX = leftX; + } else { + startX = leftX; + endX = rightX; + } + if (rightZ < leftZ) { + startZ = rightZ; + endZ = leftZ; + } else { + startZ = leftZ; + endZ = rightZ; + } + + for (int x = startX; x <= endX; x++) { + for (int y = leftY; y <= rightY; y++) { + for (int z = startZ; z <= endZ; z++) { + if (player.getWorld().getBlockAt(x, y, z).getY() < 63) { + player.getWorld().getBlockAt(x, y, z).setType(Material.WATER); + } else { + player.getWorld().getBlockAt(x, y, z).setType(Material.AIR); + } + } + } + } + player.sendMessage(ChatColor.GREEN + "Cleared Type: " + ChatColor.WHITE + typeString.toUpperCase()); } else if (craftTypeName.equalsIgnoreCase("periscope")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic")) { + if (!PermissionInterface.CheckPerm(player, "navycraft.periscope.use")) { player.sendMessage(ChatColor.RED + "You do not have permission to use this sign"); return; } @@ -1056,6 +778,16 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { } player.sendMessage(ChatColor.GOLD + "You get off the AA-Gun."); } + if (NavyCraft.ciwsGunnersList.contains(player)) { + NavyCraft.ciwsGunnersList.remove(player); + if (player.getInventory().contains(Material.BLAZE_ROD)) { + player.getInventory().remove(Material.BLAZE_ROD); + } + player.sendMessage(ChatColor.GOLD + "You get off the CIWS."); + } + if (NavyCraft.ciwsFiringList.contains(player)) { + NavyCraft.ciwsFiringList.remove(player); + } if (NavyCraft.flakGunnersList.contains(player)) { NavyCraft.flakGunnersList.remove(player); if (player.getInventory().contains(Material.BLAZE_ROD)) { @@ -1453,7 +1185,7 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { player.sendMessage(ChatColor.RED + "Start the vehicle before using this sign."); } } else if (craftTypeName.equalsIgnoreCase("flak-gun")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic")) { + if (!PermissionInterface.CheckPerm(player, "navycraft.flak-gun.use")) { player.sendMessage(ChatColor.RED + "You do not have permission to use this sign"); return; } @@ -1488,7 +1220,7 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { CraftMover.playOtherSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 0.5f, 1.0f); } else if (craftTypeName.equalsIgnoreCase("aa-gun")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic")) { + if (!PermissionInterface.CheckPerm(player, "navycraft.aa-gun.use")) { player.sendMessage(ChatColor.RED + "You do not have permission to use this sign"); return; } @@ -1523,6 +1255,42 @@ public static void ClickedASign(Player player, Block block, boolean leftClick) { CraftMover.playOtherSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 0.5f, 1.0f); + }else if (craftTypeName.equalsIgnoreCase("ciws")) { + if (!PermissionInterface.CheckPerm(player, "navycraft.ciws.use")) { + player.sendMessage(ChatColor.RED + "You do not have permission to use this sign"); + return; + } + BlockFace bf = BlockFace.NORTH; + + switch (block.getData()) { + case (byte) 0x2:// n + bf = BlockFace.SOUTH; + break; + case (byte) 0x3:// s + bf = BlockFace.NORTH; + break; + case (byte) 0x4:// w + bf = BlockFace.EAST; + break; + case (byte) 0x5:// e + bf = BlockFace.WEST; + break; + } + + if (player.getItemInHand().getTypeId() > 0) { + player.sendMessage(ChatColor.RED + "Have nothing in your hand before using this."); + return; + } + + Location newLoc = new Location(player.getWorld(), block.getRelative(bf).getRelative(BlockFace.UP).getLocation().getBlockX() + 0.5, block.getRelative(bf).getRelative(BlockFace.UP).getLocation().getBlockY(), block.getRelative(bf).getRelative(BlockFace.UP).getLocation().getBlockZ() + 0.5); + player.teleport(newLoc); + + player.setItemInHand(new ItemStack(369, 1)); + NavyCraft.ciwsGunnersList.add(player); + player.sendMessage(ChatColor.GOLD + "Manning CIWS! Left Click with Blaze Rod to fire!"); + CraftMover.playOtherSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 0.5f, 1.0f); + + } else if (craftTypeName.equalsIgnoreCase("launcher")) { Craft c = Craft.getCraft(block.getLocation().getBlockX(), block.getLocation().getBlockY(), block.getLocation().getBlockZ()); if ((c != null) && (Craft.getPlayerCraft(player) == c) && c.isDressed(player)) { @@ -1923,12 +1691,12 @@ public void onSignChange(SignChangeEvent event) { return; } - if (!player.isOp() && craftType != null && craftType.adminBuild && !PermissionInterface.CheckPerm(player, "navycraft.admin") ) { + if (!player.isOp() && craftType != null && craftType.adminBuild && !PermissionInterface.CheckPerm(player, "navycraft.admincraft") ) { player.sendMessage(ChatColor.RED + "You don't have permission to create this type of sign!"); event.setCancelled(true); return; } - if (!player.isOp() && ((craftTypeName.equalsIgnoreCase("claim") && craftTypeName.equalsIgnoreCase("select") || craftTypeName.equalsIgnoreCase("spawn") || craftTypeName.equalsIgnoreCase("recall") || craftTypeName.equalsIgnoreCase("target") ) && !PermissionInterface.CheckPerm(player, "navycraft.adminsigncreate"))) { + if (!player.isOp() && ((craftTypeName.equalsIgnoreCase("claim") && craftTypeName.equalsIgnoreCase("select") || craftTypeName.equalsIgnoreCase("spawn") || craftTypeName.equalsIgnoreCase("clear") || craftTypeName.equalsIgnoreCase("target") ) && !PermissionInterface.CheckPerm(player, "navycraft.adminsigncreate"))) { player.sendMessage(ChatColor.RED + "You don't have permission to create this type of sign!"); event.setCancelled(true); return; @@ -1939,7 +1707,7 @@ public void onSignChange(SignChangeEvent event) { theCraft = Craft.getCraft(event.getBlock().getX(), event.getBlock().getY(), event.getBlock().getZ()); if (theCraft != null) { - if (((craftTypeName.equalsIgnoreCase("flak-gun") || craftTypeName.equalsIgnoreCase("helm") || craftTypeName.equalsIgnoreCase("periscope") || craftTypeName.equalsIgnoreCase("nav") || craftTypeName.equalsIgnoreCase("aa-gun") || craftTypeName.equalsIgnoreCase("radar") || craftTypeName.equalsIgnoreCase("detector") || craftTypeName.equalsIgnoreCase("sonar") || craftTypeName.equalsIgnoreCase("hydrophone") || craftTypeName.equalsIgnoreCase("subdrive") || craftTypeName.equalsIgnoreCase("firecontrol") || craftTypeName.equalsIgnoreCase("passivesonar") || craftTypeName.equalsIgnoreCase("activesonar") || craftTypeName.equalsIgnoreCase("hfsonar") || craftTypeName.equalsIgnoreCase("launcher") || craftTypeName.equalsIgnoreCase("engine") || craftTypeName.equalsIgnoreCase("tdc") || craftTypeName.equalsIgnoreCase("radio")))) { + if (((craftTypeName.equalsIgnoreCase("flak-gun") || craftTypeName.equalsIgnoreCase("ciws") || craftTypeName.equalsIgnoreCase("helm") || craftTypeName.equalsIgnoreCase("periscope") || craftTypeName.equalsIgnoreCase("nav") || craftTypeName.equalsIgnoreCase("aa-gun") || craftTypeName.equalsIgnoreCase("radar") || craftTypeName.equalsIgnoreCase("detector") || craftTypeName.equalsIgnoreCase("sonar") || craftTypeName.equalsIgnoreCase("hydrophone") || craftTypeName.equalsIgnoreCase("subdrive") || craftTypeName.equalsIgnoreCase("firecontrol") || craftTypeName.equalsIgnoreCase("passivesonar") || craftTypeName.equalsIgnoreCase("activesonar") || craftTypeName.equalsIgnoreCase("hfsonar") || craftTypeName.equalsIgnoreCase("launcher") || craftTypeName.equalsIgnoreCase("engine") || craftTypeName.equalsIgnoreCase("tdc") || craftTypeName.equalsIgnoreCase("radio")))) { player.sendMessage(ChatColor.RED + "You cannot create this sign on a running vehicle"); event.setCancelled(true); return; @@ -1947,7 +1715,7 @@ public void onSignChange(SignChangeEvent event) { } // } - if (PermissionInterface.CheckEnabledWorld(player.getLocation()) && ((craftTypeName.equalsIgnoreCase("flak-gun") || craftTypeName.equalsIgnoreCase("helm") || craftTypeName.equalsIgnoreCase("nav") || craftTypeName.equalsIgnoreCase("periscope") || craftTypeName.equalsIgnoreCase("aa-gun") || craftTypeName.equalsIgnoreCase("radar") || craftTypeName.equalsIgnoreCase("detector") || craftTypeName.equalsIgnoreCase("sonar") || craftTypeName.equalsIgnoreCase("hydrophone") || craftTypeName.equalsIgnoreCase("subdrive") || craftTypeName.equalsIgnoreCase("firecontrol") || craftTypeName.equalsIgnoreCase("passivesonar") || craftTypeName.equalsIgnoreCase("activesonar") || craftTypeName.equalsIgnoreCase("hfsonar") || craftTypeName.equalsIgnoreCase("launcher") || craftTypeName.equalsIgnoreCase("engine") || craftTypeName.equalsIgnoreCase("tdc") || craftTypeName.equalsIgnoreCase("radio")))) { + if (Utils.CheckEnabledWorld(player.getLocation()) && ((craftTypeName.equalsIgnoreCase("flak-gun") || craftTypeName.equalsIgnoreCase("ciws") || craftTypeName.equalsIgnoreCase("helm") || craftTypeName.equalsIgnoreCase("nav") || craftTypeName.equalsIgnoreCase("periscope") || craftTypeName.equalsIgnoreCase("aa-gun") || craftTypeName.equalsIgnoreCase("radar") || craftTypeName.equalsIgnoreCase("detector") || craftTypeName.equalsIgnoreCase("sonar") || craftTypeName.equalsIgnoreCase("hydrophone") || craftTypeName.equalsIgnoreCase("subdrive") || craftTypeName.equalsIgnoreCase("firecontrol") || craftTypeName.equalsIgnoreCase("passivesonar") || craftTypeName.equalsIgnoreCase("activesonar") || craftTypeName.equalsIgnoreCase("hfsonar") || craftTypeName.equalsIgnoreCase("launcher") || craftTypeName.equalsIgnoreCase("engine") || craftTypeName.equalsIgnoreCase("tdc") || craftTypeName.equalsIgnoreCase("radio")))) { int cost = 0; if (craftTypeName.equalsIgnoreCase("helm")) { cost = 50; @@ -1959,6 +1727,8 @@ public void onSignChange(SignChangeEvent event) { cost = 100; } else if (craftTypeName.equalsIgnoreCase("flak-gun")) { cost = 200; + } else if (craftTypeName.equalsIgnoreCase("ciws")) { + cost = 1250; } else if (craftTypeName.equalsIgnoreCase("radio")) { cost = 50; } else if (craftTypeName.equalsIgnoreCase("radar")) { @@ -2133,11 +1903,20 @@ public void onBlockRedstoneChange(BlockRedstoneEvent event) { @EventHandler(priority = EventPriority.HIGH) public void on(BlockBreakEvent event) { + if (event.getBlock().getType() == Material.COAL_ORE && PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.dropchance")) { + Random pick = new Random(); + int chance = 0; + for (int counter = 1; counter <= 1; counter++) { + chance = 1 + pick.nextInt(10); + } + ItemStack item = new ItemStack(Material.SULPHUR, chance); + event.getBlock().getWorld().dropItem(event.getBlock().getLocation(), item); + } Craft theCraft = Craft.getPlayerCraft(event.getPlayer()); // System.out.println("Updated craft is " + updatedCraft.name + " of type " + updatedCraft.type.name); if (theCraft != null) { - if (theCraft.crewNames.contains(event.getPlayer().getName()) || event.getPlayer().isOp() || PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.admin")) { + if (theCraft.crewNames.contains(event.getPlayer().getName()) || event.getPlayer().isOp() || PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.bbes")) { return; } else { event.getPlayer().sendMessage(ChatColor.RED + "You can't break blocks on enemy ships!"); @@ -2146,7 +1925,7 @@ public void on(BlockBreakEvent event) { } else { theCraft = Craft.getCraft(event.getBlock().getX(), event.getBlock().getY(), event.getBlock().getZ()); if (theCraft != null) { - if (theCraft.crewNames.contains(event.getPlayer().getName()) || event.getPlayer().isOp() || PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.admin")) { + if (theCraft.crewNames.contains(event.getPlayer().getName()) || event.getPlayer().isOp() || PermissionInterface.CheckQuietPerm(event.getPlayer(), "navycraft.bbes")) { return; } else { event.getPlayer().sendMessage(ChatColor.RED + "You can't break blocks on enemy ships!"); @@ -2208,55 +1987,25 @@ public static boolean checkSpawnerClear(Player player, Block block, BlockFace bf int shiftForward = 0; int shiftUp = 0; int shiftDown = 0; - if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("SHIP1")) { - shiftRight = 12; - shiftForward = 28; - shiftUp = 20; - shiftDown = 8; - } else if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("SHIP2")) { - shiftRight = 8; - shiftForward = 43; - shiftUp = 20; - shiftDown = 8; - } else if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("SHIP3")) { - shiftRight = 10; - shiftForward = 70; - shiftUp = 20; - shiftDown = 8; - } else if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("SHIP4")) { - shiftRight = 16; - shiftForward = 55; - shiftUp = 20; - shiftDown = 8; - } else if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("SHIP5")) { - shiftRight = 16; - shiftForward = 98; + boolean typeFound = false; + for (PlotType pt : Shipyard.getPlots()) { + if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase(pt.name)) { + shiftRight = pt.sizeX - 1; + shiftForward = pt.sizeZ; + if (!pt.doFix) { shiftUp = 20; shiftDown = 8; - } else if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("HANGAR1")) { - shiftRight = 16; - shiftForward = 19; - shiftUp = 7; - shiftDown = 0; - } else if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("HANGAR2")) { - shiftRight = 24; - shiftForward = 32; - shiftUp = 14; - shiftDown = 0; - } else if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("TANK1")) { - shiftRight = 11; - shiftForward = 19; - shiftUp = 7; - shiftDown = 0; - } else if (Craft.playerClipboardsLot.get(player).equalsIgnoreCase("TANK2")) { - shiftRight = 25; - shiftForward = 33; - shiftUp = 9; - shiftDown = 0; - } else { + } else { + shiftUp = pt.sizeY; + shiftDown = 0; + } + typeFound = true; + break; + } + } + if (!typeFound) { player.sendMessage("Unknown lot type error2!"); } - Block rightLimit = block.getRelative(bf2, shiftRight).getRelative(bf, shiftForward).getRelative(BlockFace.UP, shiftUp); Block leftLimit = block.getRelative(bf, 1).getRelative(BlockFace.DOWN, shiftDown); int rightX, rightY, rightZ; @@ -2298,7 +2047,7 @@ public static boolean checkSpawnerClear(Player player, Block block, BlockFace bf @EventHandler(priority = EventPriority.HIGH) public void inventoryClickEvent(final InventoryClickEvent event) { if (!event.isCancelled()) { - if ( PermissionInterface.CheckEnabledWorld(event.getWhoClicked().getLocation()) ) { + if ( Utils.CheckEnabledWorld(event.getWhoClicked().getLocation()) ) { if ((event.getInventory().getType() == InventoryType.DISPENSER) && (event.getRawSlot() == 4) && ((event.getCurrentItem().getTypeId() == 388) || (event.getCursor().getTypeId() == 388))) { event.setCancelled(true); } @@ -2308,21 +2057,8 @@ public void inventoryClickEvent(final InventoryClickEvent event) { } public static void loadRewards(String player) { - String UUID = PermissionInterface.getUUIDfromPlayer(player); - NavyCraft.playerSHIP1Rewards.clear(); - NavyCraft.playerSHIP2Rewards.clear(); - NavyCraft.playerSHIP3Rewards.clear(); - NavyCraft.playerSHIP4Rewards.clear(); - NavyCraft.playerSHIP5Rewards.clear(); - NavyCraft.playerHANGAR1Rewards.clear(); - NavyCraft.playerHANGAR2Rewards.clear(); - NavyCraft.playerTANK1Rewards.clear(); - NavyCraft.playerTANK2Rewards.clear(); - NavyCraft.playerMAP1Rewards.clear(); - NavyCraft.playerMAP2Rewards.clear(); - NavyCraft.playerMAP3Rewards.clear(); - NavyCraft.playerMAP4Rewards.clear(); - NavyCraft.playerMAP5Rewards.clear(); + NavyCraft.playerRewards.clear(); + String UUID = Utils.getUUIDfromPlayer(player); String worldName = ""; if (NavyCraft.instance.getConfig().getString("EnabledWorlds") != "null") { @@ -2336,396 +2072,75 @@ public static void loadRewards(String player) { if (pex == null) return; + ArrayList list = new ArrayList(); for (String s : PermissionsEx.getUser(player).getPermissions(worldName)) { + for (PlotType pt : Shipyard.getPlots()) { if (s.contains("navycraft")) { - if (s.contains("ship1")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerSHIP1Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP1Rewards.put(UUID, NavyCraft.playerSHIP1Rewards.get(UUID) + num); - } else { - NavyCraft.playerSHIP1Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s + " " + s.split(".").length); - } - } else if (s.contains("ship2")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerSHIP2Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP2Rewards.put(UUID, NavyCraft.playerSHIP2Rewards.get(UUID) + num); - } else { - NavyCraft.playerSHIP2Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("ship3")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerSHIP3Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP3Rewards.put(UUID, NavyCraft.playerSHIP3Rewards.get(UUID) + num); - } else { - NavyCraft.playerSHIP3Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("ship4")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerSHIP4Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP4Rewards.put(UUID, NavyCraft.playerSHIP4Rewards.get(UUID) + num); - } else { - NavyCraft.playerSHIP4Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("ship5")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerSHIP5Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP5Rewards.put(UUID, NavyCraft.playerSHIP5Rewards.get(UUID) + num); - } else { - NavyCraft.playerSHIP5Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("hangar1")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerHANGAR1Rewards.containsKey(UUID)) { - NavyCraft.playerHANGAR1Rewards.put(UUID, NavyCraft.playerHANGAR1Rewards.get(UUID) + num); - } else { - NavyCraft.playerHANGAR1Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("hangar2")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerHANGAR2Rewards.containsKey(UUID)) { - NavyCraft.playerHANGAR2Rewards.put(UUID, NavyCraft.playerHANGAR2Rewards.get(UUID) + num); - } else { - NavyCraft.playerHANGAR2Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("tank1")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerTANK1Rewards.containsKey(UUID)) { - NavyCraft.playerTANK1Rewards.put(UUID, NavyCraft.playerTANK1Rewards.get(UUID) + num); - } else { - NavyCraft.playerTANK1Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("tank2")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerTANK2Rewards.containsKey(UUID)) { - NavyCraft.playerTANK2Rewards.put(UUID, NavyCraft.playerTANK2Rewards.get(UUID) + num); - } else { - NavyCraft.playerTANK2Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("map1")) { + if (s.contains(pt.name.toLowerCase())) { String[] split = s.split("\\."); try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerMAP1Rewards.containsKey(UUID)) { - NavyCraft.playerMAP1Rewards.put(UUID, NavyCraft.playerMAP1Rewards.get(UUID) + num); - } else { - NavyCraft.playerMAP1Rewards.put(UUID, num); + int num = Integer.parseInt(split[2]); + Reward r = new Reward(pt.name, num); + for (Reward r2 : list) { + if (r2.name.equalsIgnoreCase(r.name)) { + r = new Reward (pt.name, r2.amount + r.amount); } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s + " " + s.split(".").length); - } - } else if (s.contains("map2")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerMAP2Rewards.containsKey(UUID)) { - NavyCraft.playerMAP2Rewards.put(UUID, NavyCraft.playerMAP2Rewards.get(UUID) + num); - } else { - NavyCraft.playerMAP2Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("map3")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerMAP3Rewards.containsKey(UUID)) { - NavyCraft.playerMAP3Rewards.put(UUID, NavyCraft.playerMAP3Rewards.get(UUID) + num); - } else { - NavyCraft.playerMAP3Rewards.put(UUID, num); } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("map4")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerMAP4Rewards.containsKey(UUID)) { - NavyCraft.playerMAP4Rewards.put(UUID, NavyCraft.playerMAP4Rewards.get(UUID) + num); - } else { - NavyCraft.playerMAP4Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } - } else if (s.contains("map5")) { - String[] split = s.split("\\."); - try { - int num = Integer.parseInt(split[2]); - if (NavyCraft.playerMAP5Rewards.containsKey(UUID)) { - NavyCraft.playerMAP5Rewards.put(UUID, NavyCraft.playerMAP5Rewards.get(UUID) + num); - } else { - NavyCraft.playerMAP5Rewards.put(UUID, num); - } - } catch (Exception ex) { - System.out.println("Invalid perm-" + s); - } + list.add(r); + } catch (Exception ex) { + System.out.println("Invalid perm-" + s); + break; } } + } } - NavyCraft_FileListener.loadRewardsFile(player); - + } + NavyCraft.playerRewards.put(UUID, list); } public static Sign findSign(String player, int id) { - String UUID = PermissionInterface.getUUIDfromPlayer(player); + String UUID = Utils.getUUIDfromPlayer(player); + if (UUID != null) { Sign foundSign = null; - if (NavyCraft.playerSHIP1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP1Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerSHIP2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP2Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerSHIP3Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP3Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerSHIP4Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP4Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerSHIP5Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP5Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerHANGAR1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerHANGAR1Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerHANGAR2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerHANGAR2Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerTANK1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerTANK1Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerTANK2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerTANK2Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerMAP1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP1Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerMAP2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP2Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerMAP3Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP3Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerMAP4Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP4Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; - } - } - } - if ((foundSign == null) && NavyCraft.playerMAP5Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP5Signs.get(UUID)) { - if (id == NavyCraft.playerSignIndex.get(s)) { - foundSign = s; + if (NavyCraft.playerSigns.containsKey(UUID)) { + for (Plot p : NavyCraft.playerSigns.get(UUID)) { + if (id == NavyCraft.playerSignIndex.get(p.sign)) { + foundSign = p.sign; } } } return foundSign; + } else { + return null; } +} public static int maxId(Player player) { - String UUID = PermissionInterface.getUUIDfromPlayer(player.getName()); int foundHighest = -1; - if (NavyCraft.playerSHIP1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP1Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerSHIP2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP2Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerSHIP3Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP3Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerSHIP4Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP4Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerSHIP5Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP5Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerHANGAR1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerHANGAR1Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerHANGAR2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerHANGAR2Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerTANK1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerTANK1Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerTANK2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerTANK2Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerMAP1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP1Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerMAP2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP2Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerMAP3Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP3Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerMAP4Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP4Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); - } - } - } - if (NavyCraft.playerMAP5Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP5Signs.get(UUID)) { - if (foundHighest < NavyCraft.playerSignIndex.get(s)) { - foundHighest = NavyCraft.playerSignIndex.get(s); + String UUID = Utils.getUUIDfromPlayer(player.getName()); + if (UUID != null) { + NavyCraft.instance.DebugMessage("UUID check passed", 3); + if (NavyCraft.playerSigns.containsKey(UUID)) { + NavyCraft.instance.DebugMessage("Player signs contained player", 3); + for (Plot p : NavyCraft.playerSigns.get(UUID)) { + NavyCraft.instance.DebugMessage("Checking player plot:" + p.name, 3); + if (foundHighest < NavyCraft.playerSignIndex.get(p.sign)) { + foundHighest = NavyCraft.playerSignIndex.get(p.sign); + NavyCraft.instance.DebugMessage(String.valueOf(foundHighest), 3); } } } - return foundHighest; + } else { + player.sendMessage(ChatColor.RED + "Error UUID was null?"); } + return foundHighest; +} @EventHandler(priority = EventPriority.HIGH) public void onBlockDispense(final BlockDispenseEvent event) { if (!event.isCancelled()) { - if (PermissionInterface.CheckEnabledWorld(event.getBlock().getLocation()) && (event.getItem().getType() == Material.EMERALD)) { + if (Utils.CheckEnabledWorld(event.getBlock().getLocation()) && (event.getItem().getType() == Material.EMERALD)) { event.setCancelled(true); } @@ -2830,7 +2245,6 @@ public static void getRank(Player player) { } } } - public static void rewardExpPlayer(int newExp, Player player) { int cash = newExp / 2; int rewardedExp = newExp; @@ -2934,19 +2348,35 @@ public static void checkRankWorld(Player playerIn, int newExp, World world) { String[] split = s.split("\\."); try { int rankExp = Integer.parseInt(split[2]); - if( newExp >= rankExp ) { + String rankName = ""; + while( newExp >= rankExp ) { PermissionsEx.getUser(playerIn).promote(null, "navycraft"); - - String rankName = ""; - List groupNames = PermissionsEx.getUser(playerIn).getParentIdentifiers("navycraft"); - for( String group : groupNames ) { - if( PermissionsEx.getPermissionManager().getGroup(group).getRankLadder().equalsIgnoreCase("navycraft") ) { - rankName = group; - break; + for(String p:PermissionsEx.getUser(playerIn).getPermissions(worldName)) { + if( p.contains("navycraft") ) { + if( p.contains("exp") ) { + String[] split2 = p.split("\\."); + try { + rankExp = Integer.parseInt(split2[2]); + } catch (Exception ex) { + ex.printStackTrace(); + System.out.println("Invalid perm-" + p); + } + } + } + } + } + List groupNames = PermissionsEx.getUser(playerIn).getParentIdentifiers("navycraft"); + for( String group : groupNames ) { + if( PermissionsEx.getPermissionManager().getGroup(group).getRankLadder().equalsIgnoreCase("navycraft") ) { + if (rankName != group) { + rankName = group; + break; + } else { + return; } } - plugin.getServer().broadcastMessage(ChatColor.GREEN + playerIn.getName() + " has been promoted to the rank of " + ChatColor.YELLOW + rankName.toUpperCase() + ChatColor.GREEN + "!"); } + plugin.getServer().broadcastMessage(ChatColor.GREEN + playerIn.getName() + " has been promoted to the rank of " + ChatColor.YELLOW + rankName.toUpperCase() + ChatColor.GREEN + "!"); } catch (Exception ex) { diff --git a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_EntityListener.java b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_EntityListener.java index 0f6f9b6..7a08577 100644 --- a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_EntityListener.java +++ b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_EntityListener.java @@ -20,7 +20,7 @@ import com.maximuspayne.navycraft.NavyCraft; import com.maximuspayne.navycraft.Periscope; -import com.maximuspayne.navycraft.PermissionInterface; +import com.maximuspayne.navycraft.Utils; import com.maximuspayne.navycraft.craft.Craft; import com.maximuspayne.navycraft.craft.CraftMover; @@ -82,7 +82,7 @@ public Craft structureUpdate(Location loc, Player causer) public void onCreatureSpawn(CreatureSpawnEvent event) { - if( PermissionInterface.CheckEnabledWorld(event.getEntity().getLocation()) ) + if( Utils.CheckEnabledWorld(event.getEntity().getLocation()) ) { } @@ -91,7 +91,7 @@ public void onCreatureSpawn(CreatureSpawnEvent event) @EventHandler(priority = EventPriority.HIGH) public void onEntityTarget(EntityTargetEvent event) { - if( event.getEntity() instanceof Skeleton && NavyCraft.aaSkelesList.contains((Skeleton)event.getEntity()) ) + if( event.getEntity() instanceof Skeleton && (NavyCraft.aaSkelesList.contains((Skeleton)event.getEntity()) || NavyCraft.flakSkelesList.contains((Skeleton)event.getEntity()) || NavyCraft.ciwsSkelesList.contains((Skeleton)event.getEntity()) ) ) { if( event.getTarget() instanceof Player ) { diff --git a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_FileListener.java b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_FileListener.java index f8d5878..603a7ab 100644 --- a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_FileListener.java +++ b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_FileListener.java @@ -1,7 +1,6 @@ package com.maximuspayne.navycraft.listeners; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -13,478 +12,45 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.event.Listener; +import com.maximuspayne.navycraft.ConfigManager; import com.maximuspayne.navycraft.NavyCraft; -import com.maximuspayne.navycraft.PermissionInterface; +import com.maximuspayne.navycraft.Utils; +import com.maximuspayne.shipyard.Plot; +import ru.tehkode.permissions.bukkit.PermissionsEx; @SuppressWarnings("deprecation") public class NavyCraft_FileListener implements Listener { - + public NavyCraft_FileListener(NavyCraft p) { } - public static void loadShipyardData() { - File shipyarddata = new File(NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(),File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "signs.yml"); - FileConfiguration syData = YamlConfiguration.loadConfiguration(f); - - // When the file is created for the first time... - if (!f.exists()) { - try { - syData.createSection("Signs"); - syData.save(f); - } catch (IOException exception) { - exception.printStackTrace(); - } - } -} - public static void loadShipyardConfig() { - File shipyarddata = new File(NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(),File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - if (!c.exists()) { - try { - syConfig.set("SHIP1SZX", 13); - syConfig.set("SHIP1SZY", 28); - syConfig.set("SHIP1SZZ", 28); - syConfig.set("SHIP1OX", 0); - syConfig.set("SHIP1OY", -8); - syConfig.set("SHIP1OZ", 0); - syConfig.set("SHIP1BFR", 28); - - syConfig.set("SHIP2SZX", 9); - syConfig.set("SHIP2SZY", 28); - syConfig.set("SHIP2SZZ", 43); - syConfig.set("SHIP2OX", 0); - syConfig.set("SHIP2OY", -8); - syConfig.set("SHIP2OZ", 0); - syConfig.set("SHIP2BFR", 43); - - syConfig.set("SHIP3SZX", 11); - syConfig.set("SHIP3SZY", 28); - syConfig.set("SHIP3SZZ", 70); - syConfig.set("SHIP3OX", 0); - syConfig.set("SHIP3OY", -8); - syConfig.set("SHIP3OZ", 0); - syConfig.set("SHIP3BFR", 70); - - syConfig.set("SHIP4SZX", 17); - syConfig.set("SHIP4SZY", 28); - syConfig.set("SHIP4SZZ", 55); - syConfig.set("SHIP4OX", 0); - syConfig.set("SHIP4OY", -8); - syConfig.set("SHIP4OZ", 0); - syConfig.set("SHIP4BFR", 55); - - syConfig.set("SHIP5SZX", 17); - syConfig.set("SHIP5SZY", 28); - syConfig.set("SHIP5SZZ", 98); - syConfig.set("SHIP5OX", 0); - syConfig.set("SHIP5OY", -8); - syConfig.set("SHIP5OZ", 0); - syConfig.set("SHIP5BFR", 98); - - syConfig.set("HANGAR1SZX", 17); - syConfig.set("HANGAR1SZY", 7); - syConfig.set("HANGAR1SZZ", 19); - syConfig.set("HANGAR1OX", 0); - syConfig.set("HANGAR1OY", -1); - syConfig.set("HANGAR1OZ", -18); - syConfig.set("HANGAR1BFR", 17); - - syConfig.set("HANGAR2SZX", 25); - syConfig.set("HANGAR2SZY", 7); - syConfig.set("HANGAR2SZZ", 32); - syConfig.set("HANGAR2OX", 0); - syConfig.set("HANGAR2OY", -1); - syConfig.set("HANGAR2OZ", -31); - syConfig.set("HANGAR2BFR", 25); - - syConfig.set("TANK1SZX", 12); - syConfig.set("TANK1SZY", 7); - syConfig.set("TANK1SZZ", 19); - syConfig.set("TANK1OX", 0); - syConfig.set("TANK1OY", -1); - syConfig.set("TANK1OZ", -18); - syConfig.set("TANK1BFR", 12); - - syConfig.set("TANK2SZX", 27); - syConfig.set("TANK2SZY", 9); - syConfig.set("TANK2SZZ", 33); - syConfig.set("TANK2OX", 0); - syConfig.set("TANK2OY", -1); - syConfig.set("TANK2OZ", -32); - syConfig.set("TANK2BFR", 27); - - syConfig.set("MAP1SZX", 100); - syConfig.set("MAP1SZY", 255); - syConfig.set("MAP1SZZ", 100); - syConfig.set("MAP1OX", 0); - syConfig.set("MAP1OY", -63); - syConfig.set("MAP1OZ", -99); - syConfig.set("MAP1BFR", 100); - - syConfig.set("MAP2SZX", 150); - syConfig.set("MAP2SZY", 255); - syConfig.set("MAP2SZZ", 150); - syConfig.set("MAP2OX", 0); - syConfig.set("MAP2OY", -63); - syConfig.set("MAP2OZ", -149); - syConfig.set("MAP2BFR", 150); - - syConfig.set("MAP3SZX", 200); - syConfig.set("MAP3SZY", 255); - syConfig.set("MAP3SZZ", 200); - syConfig.set("MAP3OX", 0); - syConfig.set("MAP3OY", -63); - syConfig.set("MAP3OZ", -199); - syConfig.set("MAP3BFR", 200); - - syConfig.set("MAP4SZX", 250); - syConfig.set("MAP4SZY", 255); - syConfig.set("MAP4SZZ", 250); - syConfig.set("MAP4OX", 0); - syConfig.set("MAP4OY", -63); - syConfig.set("MAP4OZ", -249); - syConfig.set("MAP4BFR", 250); - - syConfig.set("MAP5SZX", 500); - syConfig.set("MAP5SZY", 255); - syConfig.set("MAP5SZZ", 250); - syConfig.set("MAP5OX", 0); - syConfig.set("MAP5OY", -63); - syConfig.set("MAP5OZ", -499); - syConfig.set("MAP5BFR", 500); - - syConfig.set("SHIP1World", "Shipyard"); - syConfig.set("SHIP1SX", 601); - syConfig.set("SHIP1EX", 1567); - syConfig.set("SHIP1WX", 14); - syConfig.set("SHIP1Y", 64); - syConfig.set("SHIP1SZ", -408); - syConfig.set("SHIP1EZ", -852); - syConfig.set("SHIP1WZ", 37); - - syConfig.set("SHIP2World", "Shipyard"); - syConfig.set("SHIP2SX", 601); - syConfig.set("SHIP2EX", 1421); - syConfig.set("SHIP2WX", 10); - syConfig.set("SHIP2Y", 64); - syConfig.set("SHIP2SZ", -356); - syConfig.set("SHIP2EZ", -148); - syConfig.set("SHIP2WZ", 52); - - syConfig.set("SHIP3World", "Shipyard"); - syConfig.set("SHIP3SX", 549); - syConfig.set("SHIP3EX", 21); - syConfig.set("SHIP3WX", 12); - syConfig.set("SHIP3Y", 64); - syConfig.set("SHIP3SZ", -329); - syConfig.set("SHIP3EZ", -92); - syConfig.set("SHIP3WZ", 79); - - syConfig.set("SHIP4World", "Shipyard"); - syConfig.set("SHIP4SX", 543); - syConfig.set("SHIP4EX", 21); - syConfig.set("SHIP4WX", 18); - syConfig.set("SHIP4Y", 64); - syConfig.set("SHIP4SZ", -408); - syConfig.set("SHIP4EZ", -600); - syConfig.set("SHIP4WZ", 64); - - syConfig.set("SHIP5World", "Shipyard"); - syConfig.set("SHIP5SX", 656); - syConfig.set("SHIP5EX", 1426); - syConfig.set("SHIP5WX", 18); - syConfig.set("SHIP5Y", 64); - syConfig.set("SHIP5SZ", 142); - syConfig.set("SHIP5EZ", 37); - syConfig.set("SHIP5WZ", 105); - - syConfig.set("HANGAR1World", "Shipyard"); - syConfig.set("HANGAR1SX", 553); - syConfig.set("HANGAR1EX", -137); - syConfig.set("HANGAR1WX", 23); - syConfig.set("HANGAR1Y", 65); - syConfig.set("HANGAR1SZ", -766); - syConfig.set("HANGAR1EZ", -1191); - syConfig.set("HANGAR1WZ", 25); - - syConfig.set("HANGAR2World", "Shipyard"); - syConfig.set("HANGAR2SX", -99); - syConfig.set("HANGAR2EX", -1177); - syConfig.set("HANGAR2WX", 49); - syConfig.set("HANGAR2Y", 65); - syConfig.set("HANGAR2SZ", 67); - syConfig.set("HANGAR2EZ", -117); - syConfig.set("HANGAR2WZ", 46); - - syConfig.set("TANK1World", "Shipyard"); - syConfig.set("TANK1SX", 602); - syConfig.set("TANK1EX", 926); - syConfig.set("TANK1WX", 18); - syConfig.set("TANK1Y", 65); - syConfig.set("TANK1SZ", -953); - syConfig.set("TANK1EZ", -1385); - syConfig.set("TANK1WZ", 24); - - syConfig.set("TANK2World", "Shipyard"); - syConfig.set("TANK2SX", 960); - syConfig.set("TANK2EX", 1436); - syConfig.set("TANK2WX", 34); - syConfig.set("TANK2Y", 65); - syConfig.set("TANK2SZ", -920); - syConfig.set("TANK2EZ", -1361); - syConfig.set("TANK2WZ", 44); - - syConfig.save(c); - } catch (IOException exception) { - exception.printStackTrace(); - } - } -} + public static PermissionsEx pex; public static void loadSignData() { - File shipyarddata = new File(NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(),File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "signs.yml"); - FileConfiguration syData = YamlConfiguration.loadConfiguration(f); - List list = new ArrayList(syData.getConfigurationSection("Signs").getKeys(false)); + List list = new ArrayList(ConfigManager.syData.getConfigurationSection("Signs").getKeys(false)); int size = list.size(); - for (String s : NavyCraft.playerSHIP1Signs.keySet()) { - NavyCraft.playerSHIP1Signs.get(s).clear(); - } - NavyCraft.playerSHIP1Signs.clear(); - for (String s : NavyCraft.playerSHIP2Signs.keySet()) { - NavyCraft.playerSHIP2Signs.get(s).clear(); - } - NavyCraft.playerSHIP2Signs.clear(); - for (String s : NavyCraft.playerSHIP3Signs.keySet()) { - NavyCraft.playerSHIP3Signs.get(s).clear(); - } - NavyCraft.playerSHIP3Signs.clear(); - for (String s : NavyCraft.playerSHIP4Signs.keySet()) { - NavyCraft.playerSHIP4Signs.get(s).clear(); - } - NavyCraft.playerSHIP4Signs.clear(); - for (String s : NavyCraft.playerSHIP5Signs.keySet()) { - NavyCraft.playerSHIP5Signs.get(s).clear(); - } - NavyCraft.playerSHIP5Signs.clear(); - for (String s : NavyCraft.playerHANGAR1Signs.keySet()) { - NavyCraft.playerHANGAR1Signs.get(s).clear(); - } - NavyCraft.playerHANGAR1Signs.clear(); - for (String s : NavyCraft.playerHANGAR2Signs.keySet()) { - NavyCraft.playerHANGAR2Signs.get(s).clear(); - } - NavyCraft.playerHANGAR2Signs.clear(); - for (String s : NavyCraft.playerTANK1Signs.keySet()) { - NavyCraft.playerTANK1Signs.get(s).clear(); - } - NavyCraft.playerTANK1Signs.clear(); - for (String s : NavyCraft.playerTANK2Signs.keySet()) { - NavyCraft.playerTANK2Signs.get(s).clear(); - } - NavyCraft.playerTANK2Signs.clear(); - for (String s : NavyCraft.playerSHIP1Signs.keySet()) { - NavyCraft.playerSHIP1Signs.get(s).clear(); - } - NavyCraft.playerMAP1Signs.clear(); - for (String s : NavyCraft.playerMAP2Signs.keySet()) { - NavyCraft.playerMAP2Signs.get(s).clear(); - } - NavyCraft.playerMAP2Signs.clear(); - for (String s : NavyCraft.playerMAP3Signs.keySet()) { - NavyCraft.playerMAP3Signs.get(s).clear(); - } - NavyCraft.playerMAP3Signs.clear(); - for (String s : NavyCraft.playerMAP4Signs.keySet()) { - NavyCraft.playerMAP4Signs.get(s).clear(); - } - NavyCraft.playerMAP4Signs.clear(); - for (String s : NavyCraft.playerMAP5Signs.keySet()) { - NavyCraft.playerMAP5Signs.get(s).clear(); - } - NavyCraft.playerMAP5Signs.clear(); + NavyCraft.playerSigns.clear(); if (size == 0) return; for (String num : list) { - if (syData.getString("Signs." + num + ".isClaimed").equalsIgnoreCase("true")) { - String type = syData.getString("Signs." + num + ".type"); - World world = NavyCraft.instance.getServer().getWorld(syData.getString("Signs." + num + "." + "world")); - int x = syData.getInt("Signs." + num + ".x"); - int y = syData.getInt("Signs." + num + ".y"); - int z = syData.getInt("Signs." + num + ".z"); - int id = syData.getInt("Signs." + num + ".id"); - String UUID = syData.getString("Signs." + num + ".uuid"); + if (ConfigManager.syData.getString("Signs." + num + ".isClaimed").equalsIgnoreCase("true")) { + String type = ConfigManager.syData.getString("Signs." + num + ".type"); + World world = NavyCraft.instance.getServer().getWorld(ConfigManager.syData.getString("Signs." + num + "." + "world")); + int x = ConfigManager.syData.getInt("Signs." + num + ".x"); + int y = ConfigManager.syData.getInt("Signs." + num + ".y"); + int z = ConfigManager.syData.getInt("Signs." + num + ".z"); + int id = ConfigManager.syData.getInt("Signs." + num + ".id"); + String UUID = ConfigManager.syData.getString("Signs." + num + ".uuid"); Block selectSignBlock = world.getBlockAt(x, y, z); if (selectSignBlock.getTypeId() == 63) { Sign selectSign = (Sign) selectSignBlock.getState(); - if (type.equalsIgnoreCase("SHIP1")) { - if (!NavyCraft.playerSHIP1Signs.containsKey(UUID)) { - NavyCraft.playerSHIP1Signs.put(UUID, new ArrayList()); - NavyCraft.playerSHIP1Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerSHIP1Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("SHIP2")) { - if (!NavyCraft.playerSHIP2Signs.containsKey(UUID)) { - NavyCraft.playerSHIP2Signs.put(UUID, new ArrayList()); - NavyCraft.playerSHIP2Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerSHIP2Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("SHIP3")) { - if (!NavyCraft.playerSHIP3Signs.containsKey(UUID)) { - NavyCraft.playerSHIP3Signs.put(UUID, new ArrayList()); - NavyCraft.playerSHIP3Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerSHIP3Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("SHIP4")) { - if (!NavyCraft.playerSHIP4Signs.containsKey(UUID)) { - NavyCraft.playerSHIP4Signs.put(UUID, new ArrayList()); - NavyCraft.playerSHIP4Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerSHIP4Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("SHIP5")) { - if (!NavyCraft.playerSHIP5Signs.containsKey(UUID)) { - NavyCraft.playerSHIP5Signs.put(UUID, new ArrayList()); - NavyCraft.playerSHIP5Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerSHIP5Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("HANGAR1")) { - if (!NavyCraft.playerHANGAR1Signs.containsKey(UUID)) { - NavyCraft.playerHANGAR1Signs.put(UUID, new ArrayList()); - NavyCraft.playerHANGAR1Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerHANGAR1Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("HANGAR2")) { - if (!NavyCraft.playerHANGAR2Signs.containsKey(UUID)) { - NavyCraft.playerHANGAR2Signs.put(UUID, new ArrayList()); - NavyCraft.playerHANGAR2Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerHANGAR2Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("TANK1")) { - if (!NavyCraft.playerTANK1Signs.containsKey(UUID)) { - NavyCraft.playerTANK1Signs.put(UUID, new ArrayList()); - NavyCraft.playerTANK1Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerTANK1Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("TANK2")) { - if (!NavyCraft.playerTANK2Signs.containsKey(UUID)) { - NavyCraft.playerTANK2Signs.put(UUID, new ArrayList()); - NavyCraft.playerTANK2Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerTANK2Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("MAP1")) { - if (!NavyCraft.playerMAP1Signs.containsKey(UUID)) { - NavyCraft.playerMAP1Signs.put(UUID, new ArrayList()); - NavyCraft.playerMAP1Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerMAP1Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("MAP2")) { - if (!NavyCraft.playerMAP2Signs.containsKey(UUID)) { - NavyCraft.playerMAP2Signs.put(UUID, new ArrayList()); - NavyCraft.playerMAP2Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerMAP2Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("MAP3")) { - if (!NavyCraft.playerMAP3Signs.containsKey(UUID)) { - NavyCraft.playerMAP3Signs.put(UUID, new ArrayList()); - NavyCraft.playerMAP3Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerMAP3Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("MAP4")) { - if (!NavyCraft.playerMAP4Signs.containsKey(UUID)) { - NavyCraft.playerMAP4Signs.put(UUID, new ArrayList()); - NavyCraft.playerMAP4Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerMAP4Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } - } - if (type.equalsIgnoreCase("MAP5")) { - if (!NavyCraft.playerMAP5Signs.containsKey(UUID)) { - NavyCraft.playerMAP5Signs.put(UUID, new ArrayList()); - NavyCraft.playerMAP5Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } else { - NavyCraft.playerMAP5Signs.get(UUID).add(selectSign); - NavyCraft.playerSignIndex.put(selectSign, id); - - } + Plot plot = new Plot(type, selectSign); + if (!NavyCraft.playerSigns.containsKey(UUID)) { + NavyCraft.playerSigns.put(UUID, new ArrayList()); + NavyCraft.playerSigns.get(UUID).add(plot); + NavyCraft.playerSignIndex.put(selectSign, id); + } else { + NavyCraft.playerSigns.get(UUID).add(plot); + NavyCraft.playerSignIndex.put(selectSign, id); } } } @@ -492,484 +58,151 @@ public static void loadSignData() { } public static Block findSignOpen(String type) { - File shipyarddata = new File(NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(),File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "signs.yml"); - FileConfiguration syData = YamlConfiguration.loadConfiguration(f); Block selectSignBlock = null; - List list = new ArrayList(syData.getConfigurationSection("Signs").getKeys(false)); + List list = new ArrayList(ConfigManager.syData.getConfigurationSection("Signs").getKeys(false)); + if (list.size() == 0) return selectSignBlock; for (String num : list) { - if (syData.getString("Signs." + num + ".isClaimed").equalsIgnoreCase("false")) { - String ptype = syData.getString("Signs." + num + "." + "type"); - World world = NavyCraft.instance.getServer().getWorld(syData.getString("Signs." + num + "." + "world")); - int x = syData.getInt("Signs." + num + "." + "x"); - int y = syData.getInt("Signs." + num + "." + "y"); - int z = syData.getInt("Signs." + num + "." + "z"); - if (type.equalsIgnoreCase("SHIP1")) { - if (ptype.equalsIgnoreCase("SHIP1")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("SHIP2")) { - if (ptype.equalsIgnoreCase("SHIP2")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("SHIP3")) { - if (ptype.equalsIgnoreCase("SHIP3")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("SHIP4")) { - if (ptype.equalsIgnoreCase("SHIP4")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("SHIP5")) { - if (ptype.equalsIgnoreCase("SHIP5")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("HANGAR1")) { - if (ptype.equalsIgnoreCase("HANGAR1")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("HANGAR2")) { - if (ptype.equalsIgnoreCase("HANGAR2")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("TANK1")) { - if (ptype.equalsIgnoreCase("TANK1")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("TANK2")) { - if (ptype.equalsIgnoreCase("TANK2")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("MAP1")) { - if (ptype.equalsIgnoreCase("MAP1")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("MAP2")) { - if (ptype.equalsIgnoreCase("MAP2")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("MAP3")) { - if (ptype.equalsIgnoreCase("MAP3")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("MAP4")) { - if (ptype.equalsIgnoreCase("MAP4")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } - } - } - if (type.equalsIgnoreCase("MAP5")) { - if (ptype.equalsIgnoreCase("MAP5")) { - selectSignBlock = world.getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - break; - } + if (ConfigManager.syData.getString("Signs." + num + ".isClaimed").equalsIgnoreCase("false")) { + String ptype = ConfigManager.syData.getString("Signs." + num + "." + "type"); + World world = NavyCraft.instance.getServer().getWorld(ConfigManager.syData.getString("Signs." + num + "." + "world")); + int x = ConfigManager.syData.getInt("Signs." + num + "." + "x"); + int y = ConfigManager.syData.getInt("Signs." + num + "." + "y"); + int z = ConfigManager.syData.getInt("Signs." + num + "." + "z"); + if (type.equalsIgnoreCase(ptype)) { + selectSignBlock = world.getBlockAt(x, y, z); + if (selectSignBlock.getTypeId() == 63) { + break; } } } } return selectSignBlock; } - - public static void saveClaimedSign(String player, String type, String world, int x, int y, int z, int id) { - Block selectSignBlock = NavyCraft.instance.getServer().getWorld(world).getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - File shipyarddata = new File( NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "signs.yml"); - FileConfiguration syData = YamlConfiguration.loadConfiguration(f); - Location loc = new Location(NavyCraft.instance.getServer().getWorld(world), x, y, z); - String UUID = PermissionInterface.getUUIDfromPlayer(player); - List list = new ArrayList(syData.getConfigurationSection("Signs").getKeys(false)); - for (String num : list) { - int x1 = syData.getInt("Signs." + num + "." + "x"); - int y1 = syData.getInt("Signs." + num + "." + "y"); - int z1 = syData.getInt("Signs." + num + "." + "z"); - String world1 = syData.getString("Signs." + num + "." + "world"); - Location loc1 = new Location(NavyCraft.instance.getServer().getWorld(world1), x1, y1, z1); - if (loc.equals(loc1)) { - syData.set("Signs." + num + "." + "type", type.toUpperCase()); - syData.set("Signs." + num + "." + "world", world); - syData.set("Signs." + num + "." + "x", x); - syData.set("Signs." + num + "." + "y", y); - syData.set("Signs." + num + "." + "z", z); - syData.set("Signs." + num + "." + "isClaimed", true); - syData.set("Signs." + num + "." + "uuid", UUID); - syData.set("Signs." + num + "." + "id", id); - break; - } - } - try { - syData.save(f); - } catch (IOException e) { - e.printStackTrace(); - System.out.println("SIGN NOT LOADED"); - return; - } - } -} - - public static void saveUnclaimedSign(String type, String world, int x, int y, int z) { - Block selectSignBlock = NavyCraft.instance.getServer().getWorld(world).getBlockAt(x, y, z); - if (selectSignBlock.getTypeId() == 63) { - File shipyarddata = new File(NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(),File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "signs.yml"); - FileConfiguration syData = YamlConfiguration.loadConfiguration(f); - Location loc = new Location(NavyCraft.instance.getServer().getWorld(world), x, y, z); - List list = new ArrayList(syData.getConfigurationSection("Signs").getKeys(false)); - for (String num : list) { - int x1 = syData.getInt("Signs." + num + "." + "x"); - int y1 = syData.getInt("Signs." + num + "." + "y"); - int z1 = syData.getInt("Signs." + num + "." + "z"); - String world1 = syData.getString("Signs." + num + "." + "world"); - Location loc1 = new Location(NavyCraft.instance.getServer().getWorld(world1), x1, y1, z1); - if (loc.equals(loc1)) { - syData.set("Signs." + num + "." + "type", type.toUpperCase()); - syData.set("Signs." + num + "." + "world", world); - syData.set("Signs." + num + "." + "x", x); - syData.set("Signs." + num + "." + "y", y); - syData.set("Signs." + num + "." + "z", z); - syData.set("Signs." + num + "." + "isClaimed", false); - syData.set("Signs." + num + "." + "uuid", null); - syData.set("Signs." + num + "." + "id", null); - break; - } - } - try { - syData.save(f); - } catch (IOException e) { - e.printStackTrace(); - System.out.println("SIGN NOT LOADED"); - return; - } - } -} - - public static void saveSign(String type, String world, int x, int y, int z) { - File shipyarddata = new File(NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(),File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "signs.yml"); - FileConfiguration syData = YamlConfiguration.loadConfiguration(f); - List list = new ArrayList(syData.getConfigurationSection("Signs").getKeys(false)); - int size = list.size(); - syData.set("Signs." + String.valueOf(size + 1) + "." + "type", type.toUpperCase()); - syData.set("Signs." + String.valueOf(size + 1) + "." + "world", world); - syData.set("Signs." + String.valueOf(size + 1) + "." + "x", x); - syData.set("Signs." + String.valueOf(size + 1) + "." + "y", y); - syData.set("Signs." + String.valueOf(size + 1) + "." + "z", z); - syData.set("Signs." + String.valueOf(size + 1) + "." + "isClaimed", false); - try { - syData.save(f); - } catch (IOException e) { - e.printStackTrace(); - System.out.println("SIGN NOT LOADED"); - } -} - public static boolean checkSign(int x, int y, int z, World world) { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "signs.yml"); - FileConfiguration syData = YamlConfiguration.loadConfiguration(f); - List list = new ArrayList(syData.getConfigurationSection("Signs").getKeys(false)); + public static String getSign(int x, int y, int z, World world) { + List list = new ArrayList(ConfigManager.syData.getConfigurationSection("Signs").getKeys(false)); for (String num : list) { - World world1 = NavyCraft.instance.getServer().getWorld(syData.getString("Signs." + num + "." + "world")); - int x1 = syData.getInt("Signs." + num + "." + "x"); - int y1 = syData.getInt("Signs." + num + "." + "y"); - int z1 = syData.getInt("Signs." + num + "." + "z"); + World world1 = NavyCraft.instance.getServer().getWorld(ConfigManager.syData.getString("Signs." + num + "." + "world")); + int x1 = ConfigManager.syData.getInt("Signs." + num + "." + "x"); + int y1 = ConfigManager.syData.getInt("Signs." + num + "." + "y"); + int z1 = ConfigManager.syData.getInt("Signs." + num + "." + "z"); Location loc1 = new Location(world1, x1, y1, z1); Location loc = new Location(world, x, y, z); if (loc.equals(loc1)) { - return true; + return num; } } - return false; + return null; } + public static void updateSign(String uuid, String type, int x, int y, int z, World world, Object id, boolean isClaimed) { + NavyCraft.instance.DebugMessage("UUID =" + uuid, 3); + Block selectSignBlock = world.getBlockAt(x, y, z); + if (selectSignBlock.getTypeId() == 63) { + String num = getSign(x, y, z, world); + List list = new ArrayList(ConfigManager.syData.getConfigurationSection("Signs").getKeys(false)); + if (num == null && !list.isEmpty()) { + num = String.valueOf(Integer.valueOf(list.get(list.size() - 1)) + 1); + } + ConfigManager.syData.set("Signs." + num + "." + "type", type.toUpperCase()); + ConfigManager.syData.set("Signs." + num + "." + "world", world.getName()); + ConfigManager.syData.set("Signs." + num + "." + "x", x); + ConfigManager.syData.set("Signs." + num + "." + "y", y); + ConfigManager.syData.set("Signs." + num + "." + "z", z); + ConfigManager.syData.set("Signs." + num + "." + "isClaimed", isClaimed); + ConfigManager.syData.set("Signs." + num + "." + "uuid", uuid); + ConfigManager.syData.set("Signs." + num + "." + "id", id); + ConfigManager.savesyData(); + } +} + public static void loadPlayerData(String player) { - String UUID = PermissionInterface.getUUIDfromPlayer(player); - File userdata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "userdata"); + String UUID = Utils.getUUIDfromPlayer(player); + File userdata = new File(NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), File.separator + "userdata"); File f = new File(userdata, File.separator + UUID + ".yml"); FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); + String worldName = ""; + if (NavyCraft.instance.getConfig().getString("EnabledWorlds") != "null") { + String[] worlds = NavyCraft.instance.getConfig().getString("EnabledWorlds").split(","); + worldName = worlds[0]; + } else { + worldName = NavyCraft.instance.getServer().getPlayer(player).getWorld().getName(); + } - // When the player file is created for the first time... - if (!f.exists()) { - try { - playerData.set("exp", 0); - playerData.set("SHIP1", 0); - playerData.set("SHIP2", 0); - playerData.set("SHIP3", 0); - playerData.set("SHIP4", 0); - playerData.set("SHIP5", 0); - playerData.set("HANGAR1", 0); - playerData.set("HANGAR2", 0); - playerData.set("TANK1", 0); - playerData.set("TANK2", 0); - playerData.set("MAP1", 0); - playerData.set("MAP2", 0); - playerData.set("MAP3", 0); - playerData.set("MAP4", 0); - playerData.set("MAP5", 0); - playerData.set("wepvolume", 5.0); - playerData.set("engvolume", 5.0); - playerData.set("othervolume", 5.0); - - playerData.save(f); - } catch (IOException exception) { - exception.printStackTrace(); + pex = (PermissionsEx) NavyCraft.instance.getServer().getPluginManager().getPlugin("PermissionsEx"); + if (pex == null) + return; + for (String s : PermissionsEx.getUser(player).getPermissions(worldName)) { + if (!s.contains("navycraft")) { + if (!s.contains("rank")) { + if (f != null) { + PermissionsEx.getUser(player).addPermission("navycraft.rank." + playerData.getInt("exp")); + f.delete(); + } else { + PermissionsEx.getUser(player).addPermission("navycraft.rank.0"); + } + } } } - // Put all the file data to hashmaps - loadExperience(player); - loadVolume(player); - } + loadExperience(player); +} public static void loadExperience(String player) { - String UUID = PermissionInterface.getUUIDfromPlayer(player); - File userdata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "userdata"); - File f = new File(userdata, File.separator + UUID + ".yml"); - FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); - NavyCraft.playerExp.put(player, playerData.getInt("exp")); - } - - public static void saveExperience(String player) { - String UUID = PermissionInterface.getUUIDfromPlayer(player); - File userdata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "userdata"); - File f = new File(userdata, File.separator + UUID + ".yml"); - FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); - if (NavyCraft.playerExp.containsKey(player)) { - playerData.set("exp", NavyCraft.playerExp.get(player)); + int exp = 0; + String worldName = ""; + if (NavyCraft.instance.getConfig().getString("EnabledWorlds") != "null") { + String[] worlds = NavyCraft.instance.getConfig().getString("EnabledWorlds").split(","); + worldName = worlds[0]; + } else { + worldName = NavyCraft.instance.getServer().getPlayer(player).getWorld().getName(); } - try { - playerData.save(f); - } catch (IOException e) { - loadPlayerData(player); + + pex = (PermissionsEx) NavyCraft.instance.getServer().getPluginManager().getPlugin("PermissionsEx"); + if (pex == null) + return; + + for (String s : PermissionsEx.getUser(player).getPermissions(worldName)) { + if (s.contains("navycraft")) { + if (s.contains("rank")) { + String[] split = s.split("\\."); + try { + exp = Integer.parseInt(split[2]); + } catch (Exception ex) { + System.out.println("Invalid perm-" + s); + break; + } + } + } } + NavyCraft.playerExp.put(player, exp); } - public static void loadVolume(String player) { - String UUID = PermissionInterface.getUUIDfromPlayer(player); - File userdata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "userdata"); - File f = new File(userdata, File.separator + UUID + ".yml"); - FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); - NavyCraft.playerEngineVolumes.put(NavyCraft.instance.getServer().getPlayer(player),Float.valueOf(playerData.get("engvolume").toString())); - NavyCraft.playerWeaponVolumes.put(NavyCraft.instance.getServer().getPlayer(player),Float.valueOf(playerData.get("wepvolume").toString())); - NavyCraft.playerOtherVolumes.put(NavyCraft.instance.getServer().getPlayer(player),Float.valueOf(playerData.get("othervolume").toString())); - NavyCraft.instance.DebugMessage("Engine V:" + NavyCraft.playerEngineVolumes.get(NavyCraft.instance.getServer().getPlayer(player)).toString(), 3); - NavyCraft.instance.DebugMessage("Weapon V:" + NavyCraft.playerWeaponVolumes.get(NavyCraft.instance.getServer().getPlayer(player)).toString(), 3); - NavyCraft.instance.DebugMessage("Other V:" + NavyCraft.playerOtherVolumes.get(NavyCraft.instance.getServer().getPlayer(player)).toString(), 3); - } - - public static void saveVolume(String player) { - String UUID = PermissionInterface.getUUIDfromPlayer(player); - File userdata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "userdata"); - File f = new File(userdata, File.separator + UUID + ".yml"); - FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); - if (NavyCraft.playerWeaponVolumes.containsKey(NavyCraft.instance.getServer().getPlayer(player))) { - playerData.set("wepvolume",NavyCraft.playerWeaponVolumes.get(NavyCraft.instance.getServer().getPlayer(player))); - } - if (NavyCraft.playerEngineVolumes.containsKey(NavyCraft.instance.getServer().getPlayer(player))) { - playerData.set("engvolume",NavyCraft.playerEngineVolumes.get(NavyCraft.instance.getServer().getPlayer(player))); - } - if (NavyCraft.playerOtherVolumes.containsKey(NavyCraft.instance.getServer().getPlayer(player))) { - playerData.set("othervolume",NavyCraft.playerOtherVolumes.get(NavyCraft.instance.getServer().getPlayer(player))); - } - try { - playerData.save(f); - } catch (IOException e) { - loadPlayerData(player); + public static void saveExperience(String player) { + String worldName = ""; + if (NavyCraft.instance.getConfig().getString("EnabledWorlds") != "null") { + String[] worlds = NavyCraft.instance.getConfig().getString("EnabledWorlds").split(","); + worldName = worlds[0]; + } else { + worldName = NavyCraft.instance.getServer().getPlayer(player).getWorld().getName(); } - } - - public static void loadRewardsFile(String player) { - String UUID = PermissionInterface.getUUIDfromPlayer(player); - File userdata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "userdata"); - File f = new File(userdata, File.separator + UUID + ".yml"); - FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); - if (playerData.getInt("SHIP1") > 0) { - if (NavyCraft.playerSHIP1Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP1Rewards.put(UUID, NavyCraft.playerSHIP1Rewards.get(UUID) + playerData.getInt("SHIP1")); - } else { - NavyCraft.playerSHIP1Rewards.put(UUID, playerData.getInt("SHIP1")); - } - } - if (playerData.getInt("SHIP2") > 0) { - if (NavyCraft.playerSHIP2Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP2Rewards.put(UUID, NavyCraft.playerSHIP2Rewards.get(UUID) + playerData.getInt("SHIP2")); - } else { - NavyCraft.playerSHIP2Rewards.put(UUID, playerData.getInt("SHIP2")); - } - } - if (playerData.getInt("SHIP3") > 0) { - if (NavyCraft.playerSHIP3Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP3Rewards.put(UUID, NavyCraft.playerSHIP3Rewards.get(UUID) + playerData.getInt("SHIP3")); - } else { - NavyCraft.playerSHIP3Rewards.put(UUID, playerData.getInt("SHIP3")); - } - } - if (playerData.getInt("SHIP4") > 0) { - if (NavyCraft.playerSHIP4Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP4Rewards.put(UUID, NavyCraft.playerSHIP4Rewards.get(UUID) + playerData.getInt("SHIP4")); - } else { - NavyCraft.playerSHIP4Rewards.put(UUID, playerData.getInt("SHIP4")); - } - } - if (playerData.getInt("SHIP5") > 0) { - if (NavyCraft.playerSHIP5Rewards.containsKey(UUID)) { - NavyCraft.playerSHIP5Rewards.put(UUID, NavyCraft.playerSHIP5Rewards.get(UUID) + playerData.getInt("SHIP5")); - } else { - NavyCraft.playerSHIP5Rewards.put(UUID, playerData.getInt("SHIP5")); - } - } - if (playerData.getInt("HANGAR1") > 0) { - if (NavyCraft.playerHANGAR1Rewards.containsKey(UUID)) { - NavyCraft.playerHANGAR1Rewards.put(UUID, NavyCraft.playerHANGAR1Rewards.get(UUID) + playerData.getInt("HANGAR1")); - } else { - NavyCraft.playerHANGAR1Rewards.put(UUID, playerData.getInt("HANGAR1")); - } - } - if (playerData.getInt("HANGAR2") > 0) { - if (NavyCraft.playerHANGAR2Rewards.containsKey(UUID)) { - NavyCraft.playerHANGAR2Rewards.put(UUID, NavyCraft.playerHANGAR2Rewards.get(UUID) + playerData.getInt("HANGAR2")); - } else { - NavyCraft.playerHANGAR2Rewards.put(UUID, playerData.getInt("HANGAR2")); - } - } - if (playerData.getInt("TANK1") > 0) { - if (NavyCraft.playerTANK1Rewards.containsKey(UUID)) { - NavyCraft.playerTANK1Rewards.put(UUID, NavyCraft.playerTANK1Rewards.get(UUID) + playerData.getInt("TANK1")); - } else { - NavyCraft.playerTANK1Rewards.put(UUID, playerData.getInt("TANK1")); - } - } - if (playerData.getInt("TANK2") > 0) { - if (NavyCraft.playerTANK2Rewards.containsKey(UUID)) { - NavyCraft.playerTANK2Rewards.put(UUID, NavyCraft.playerTANK2Rewards.get(UUID) + playerData.getInt("TANK2")); - } else { - NavyCraft.playerTANK2Rewards.put(UUID, playerData.getInt("TANK2")); - } - } - if (playerData.getInt("MAP1") > 0) { - if (NavyCraft.playerMAP1Rewards.containsKey(UUID)) { - NavyCraft.playerMAP1Rewards.put(UUID, NavyCraft.playerMAP1Rewards.get(UUID) + playerData.getInt("MAP1")); - } else { - NavyCraft.playerMAP1Rewards.put(UUID, playerData.getInt("MAP1")); - } - } - if (playerData.getInt("MAP2") > 0) { - if (NavyCraft.playerMAP2Rewards.containsKey(UUID)) { - NavyCraft.playerMAP2Rewards.put(UUID, NavyCraft.playerMAP2Rewards.get(UUID) + playerData.getInt("MAP2")); - } else { - NavyCraft.playerMAP2Rewards.put(UUID, playerData.getInt("MAP2")); - } - } - if (playerData.getInt("MAP3") > 0) { - if (NavyCraft.playerMAP3Rewards.containsKey(UUID)) { - NavyCraft.playerMAP3Rewards.put(UUID, NavyCraft.playerMAP3Rewards.get(UUID) + playerData.getInt("MAP3")); - } else { - NavyCraft.playerMAP3Rewards.put(UUID, playerData.getInt("MAP3")); - } - } - if (playerData.getInt("MAP4") > 0) { - if (NavyCraft.playerMAP4Rewards.containsKey(UUID)) { - NavyCraft.playerMAP4Rewards.put(UUID, NavyCraft.playerMAP4Rewards.get(UUID) + playerData.getInt("MAP4")); - } else { - NavyCraft.playerMAP4Rewards.put(UUID, playerData.getInt("MAP4")); - } - } - if (playerData.getInt("MAP5") > 0) { - if (NavyCraft.playerMAP5Rewards.containsKey(UUID)) { - NavyCraft.playerMAP5Rewards.put(UUID, NavyCraft.playerMAP5Rewards.get(UUID) + playerData.getInt("MAP5")); - } else { - NavyCraft.playerMAP5Rewards.put(UUID, playerData.getInt("MAP5")); - } - } - try { - playerData.save(f); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - return; - } - - public static void saveRewardsFile(String player, String type, int newRewNum) { - File userdata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "userdata"); - File f = new File(userdata, File.separator + player + ".yml"); - FileConfiguration playerData = YamlConfiguration.loadConfiguration(f); - if (type != null) { - playerData.set(type.toUpperCase(), Integer.valueOf(playerData.get(type.toUpperCase()).toString()) + newRewNum); - try { - playerData.save(f); - } catch (IOException e) { - loadPlayerData(player); - } + pex = (PermissionsEx) NavyCraft.instance.getServer().getPluginManager().getPlugin("PermissionsEx"); + if (pex == null) return; + + for (String s : PermissionsEx.getUser(player).getPermissions(worldName)) { + if (s.contains("navycraft")) { + if (s.contains("rank")) { + try { + PermissionsEx.getUser(player).removePermission(s); + } catch (Exception ex) { + System.out.println("Invalid perm-" + s); + break; + } + } + } } + PermissionsEx.getUser(player).addPermission("navycraft.rank." + NavyCraft.playerExp.get(player)); } } \ No newline at end of file diff --git a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_InventoryListener.java b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_InventoryListener.java index 2eb148f..d3f3ee1 100644 --- a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_InventoryListener.java +++ b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_InventoryListener.java @@ -49,7 +49,7 @@ public void onCraftItem(CraftItemEvent event) if( event.getWhoClicked().getType() == EntityType.PLAYER ) { Player p = (Player)event.getWhoClicked(); - if (p.isOp() && PermissionInterface.CheckPerm(p, "navycraft.admin")) { + if (p.isOp() && PermissionInterface.CheckPerm(p, "navycraft.craftitems")) { event.setCancelled(false); return; } else { @@ -60,5 +60,5 @@ public void onCraftItem(CraftItemEvent event) } } - } +} diff --git a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_PlayerListener.java b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_PlayerListener.java index 95cc4fa..761f2ca 100644 --- a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_PlayerListener.java +++ b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_PlayerListener.java @@ -7,18 +7,16 @@ import java.util.Iterator; import java.util.List; import java.util.Set; - import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Sign; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -47,16 +45,23 @@ import com.maximuspayne.aimcannon.AimCannonPlayerListener; import com.maximuspayne.aimcannon.OneCannon; import com.maximuspayne.aimcannon.Weapon; +import com.maximuspayne.aimcannon.ciwsFire; +import com.maximuspayne.navycraft.ConfigManager; import com.maximuspayne.navycraft.NavyCraft; import com.maximuspayne.navycraft.Periscope; import com.maximuspayne.navycraft.PermissionInterface; import com.maximuspayne.navycraft.Pump; +import com.maximuspayne.navycraft.Utils; import com.maximuspayne.navycraft.blocks.BlocksInfo; import com.maximuspayne.navycraft.blocks.DataBlock; import com.maximuspayne.navycraft.craft.Craft; import com.maximuspayne.navycraft.craft.CraftMover; import com.maximuspayne.navycraft.craft.CraftType; import com.maximuspayne.navycraft.teleportfix.TeleportFix; +import com.maximuspayne.shipyard.Plot; +import com.maximuspayne.shipyard.PlotType; +import com.maximuspayne.shipyard.Reward; +import com.maximuspayne.shipyard.Shipyard; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.domains.DefaultDomain; @@ -75,6 +80,7 @@ public class NavyCraft_PlayerListener implements Listener { public WorldGuardPlugin wgp; public static PermissionsEx pex; public WorldEditPlugin wep; + public static ConfigManager cfgm; Thread timerThread; @@ -129,7 +135,8 @@ public void onPlayerJoin(PlayerJoinEvent event) { try { NavyCraft_FileListener.loadPlayerData(player.getName()); } catch (Exception ex) { - System.out.println("Something is wrong with" + player.getName() + "'s playerdata!"); + System.out.println("Something is wrong with " + player.getName() + "'s playerdata!"); + ex.printStackTrace(); } if (Craft.reboardNames.containsKey(player.getName())) { if ((Craft.reboardNames.get(player.getName()) != null) @@ -206,7 +213,7 @@ public void onPlayerDeath(PlayerDeathEvent event) { if (msgWords.length == 5) { if (msgWords[1].equalsIgnoreCase("was") && msgWords[3].equalsIgnoreCase("by")) { Player p = plugin.getServer().getPlayer(msgWords[4]); - if ((p != null) && PermissionInterface.CheckEnabledWorld(p.getLocation())) { + if ((p != null) && Utils.CheckEnabledWorld(p.getLocation())) { int newExp = 100; plugin.getServer().broadcastMessage(ChatColor.GREEN + p.getName() + " receives " + ChatColor.YELLOW @@ -235,9 +242,7 @@ public void onPlayerMove(PlayerMoveEvent event) { player.getInventory().remove(Material.BLAZE_ROD); } player.sendMessage(ChatColor.GOLD + "You get off the Flak-Gun."); - } - - if (NavyCraft.aaGunnersList.contains(player) && ((event.getFrom().getBlockX() != event.getTo().getBlockX()) + } else if (NavyCraft.aaGunnersList.contains(player) && ((event.getFrom().getBlockX() != event.getTo().getBlockX()) || (event.getFrom().getBlockZ() != event.getTo().getBlockZ()))) { NavyCraft.aaGunnersList.remove(player); if (player.getInventory().contains(Material.BLAZE_ROD)) { @@ -245,6 +250,15 @@ public void onPlayerMove(PlayerMoveEvent event) { } player.sendMessage(ChatColor.GOLD + "You get off the AA-Gun."); + } else if ((NavyCraft.ciwsGunnersList.contains(player) || NavyCraft.ciwsFiringList.contains(player)) && ((event.getFrom().getBlockX() != event.getTo().getBlockX()) + || (event.getFrom().getBlockZ() != event.getTo().getBlockZ()))) { + NavyCraft.ciwsGunnersList.remove(player); + NavyCraft.ciwsFiringList.remove(player); + if (player.getInventory().contains(Material.BLAZE_ROD)) { + player.getInventory().remove(Material.BLAZE_ROD); + } + player.sendMessage(ChatColor.GOLD + "You get off the CIWS."); + } else if (NavyCraft.searchLightMap.containsKey(player) && ((event.getFrom().getBlockX() != event.getTo().getBlockX()) || (event.getFrom().getBlockZ() != event.getTo().getBlockZ()))) { @@ -335,6 +349,7 @@ public void onPlayerMove(PlayerMoveEvent event) { CraftMover cmer = new CraftMover(craft, plugin); cmer.structureUpdate(null, false); + craft.lastPeriscopeLookLoc = player.getTargetBlock(null, 250).getLocation(); craft.lastPeriscopeYaw = player.getLocation().getYaw(); Location newLoc = new Location(craft.world, playerScope.signLoc.getBlockX() + .5, playerScope.signLoc.getBlockY() - .5, playerScope.signLoc.getBlockZ() + .5); @@ -388,7 +403,7 @@ public void onPlayerInteract(PlayerInteractEvent event) { } if( block.getType() == Material.JACK_O_LANTERN && event.getHand() == EquipmentSlot.HAND ) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic")) { + if (!PermissionInterface.CheckPerm(player, "navycraft.searchlight.use")) { player.sendMessage(ChatColor.RED + "You do not have permission to use this."); return; } @@ -557,9 +572,7 @@ public void onPlayerInteract(PlayerInteractEvent event) { } else { event.getPlayer().sendMessage(ChatColor.RED + "You are out of ammunition!"); } - } - // Flak Gunner... - if ((action == Action.LEFT_CLICK_AIR) && NavyCraft.flakGunnersList.contains(player) + } else if ((action == Action.LEFT_CLICK_AIR) && NavyCraft.flakGunnersList.contains(player) && (player.getItemInHand().getType() == Material.BLAZE_ROD)&& event.getHand() == EquipmentSlot.HAND) { if (NavyCraft.instance.getConfig().getString("RequireAmmo").equalsIgnoreCase("false") || event.getPlayer().getInventory().contains(Material.EGG) || event.getPlayer().getGameMode().equals(GameMode.CREATIVE)) { if (NavyCraft.instance.getConfig().getString("RequireAmmo").equalsIgnoreCase("true")) { @@ -577,8 +590,16 @@ public void onPlayerInteract(PlayerInteractEvent event) { event.getPlayer().sendMessage(ChatColor.RED + "You are out of ammunition!"); } - //// else check for movement clicking - } else if ((action == Action.RIGHT_CLICK_AIR) && (playerCraft != null) + //// CIWS + } else if ((action == Action.LEFT_CLICK_AIR || action == Action.RIGHT_CLICK_AIR) && NavyCraft.ciwsGunnersList.contains(player) && (player.getItemInHand().getType() == Material.BLAZE_ROD)&& event.getHand() == EquipmentSlot.HAND) { + if (action == Action.LEFT_CLICK_AIR && !NavyCraft.ciwsFiringList.contains(player)) { + NavyCraft.ciwsFiringList.add(player); + ciwsFire.fireCIWS(player); + } + if (action == Action.RIGHT_CLICK_AIR && NavyCraft.ciwsFiringList.contains(player)) NavyCraft.ciwsFiringList.remove(player); + + //// else check for movement clicking + } else if ((action == Action.RIGHT_CLICK_AIR) && (playerCraft != null) && (playerCraft.driverName == player.getName()) && (playerCraft.type.listenItem == true)) { if ((NavyCraft.instance.getConfig().getString("RequireHelm") == "true") && (event.getItem().getTypeId() != playerCraft.type.HelmControllerItem)) { @@ -955,7 +976,7 @@ public void onPlayerAnimation(PlayerAnimationEvent event) { if ((player.getItemInHand().getType() == Material.FLINT_AND_STEEL) && NavyCraft.cleanupPlayers.contains(player.getName()) - && PermissionInterface.CheckEnabledWorld(player.getLocation() )) { + && Utils.CheckEnabledWorld(player.getLocation() )) { Set transp = new HashSet<>(); transp.add(Material.AIR); transp.add(Material.STATIONARY_WATER); @@ -1034,7 +1055,7 @@ public void onPlayerAnimation(PlayerAnimationEvent event) { } if ((player.getItemInHand().getType() == Material.SHEARS) && NavyCraft.cleanupPlayers.contains(player.getName()) - && PermissionInterface.CheckEnabledWorld(player.getLocation()) + && Utils.CheckEnabledWorld(player.getLocation()) && !NavyCraft.checkSafeDockRegion(player.getLocation())) { Set transp = new HashSet<>(); @@ -1069,7 +1090,7 @@ public void onPlayerAnimation(PlayerAnimationEvent event) { } if ((player.getItemInHand().getType() == Material.GOLD_PICKAXE) && NavyCraft.cleanupPlayers.contains(player.getName()) - && PermissionInterface.CheckEnabledWorld(player.getLocation()) + && Utils.CheckEnabledWorld(player.getLocation()) && !NavyCraft.checkSafeDockRegion(player.getLocation())) { Set transp = new HashSet<>(); transp.add(Material.AIR); @@ -1207,7 +1228,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { } } } else if (split[1].equalsIgnoreCase("list")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.list") ) return; if (Craft.craftList.isEmpty()) { player.sendMessage(ChatColor.RED + "No player controlled craft"); @@ -1220,24 +1241,25 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { + craft.blockCount + " blocks"); } } else if (split[1].equalsIgnoreCase("reload")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.reload") ) return; NavyCraft.instance.loadProperties(); player.sendMessage(ChatColor.GREEN + "NavyCraft configuration reloaded"); event.setCancelled(true); return; } else if (split[1].equalsIgnoreCase("debug")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.debug") ) return; NavyCraft.instance.ToggleDebug(); event.setCancelled(true); return; } else if (split[1].equalsIgnoreCase("loglevel")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.loglevel") ) return; try { Integer.parseInt(split[2]); NavyCraft.instance.getConfig().set("LogLevel", split[2]); + player.sendMessage(ChatColor.GREEN + "LogLevel" + split[2]); } catch (Exception ex) { player.sendMessage(ChatColor.RED + "Invalid loglevel."); } @@ -1246,7 +1268,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { // Cleanup command } else if (split[1].equalsIgnoreCase("cleanup")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.cleanup") ) return; if (NavyCraft.cleanupPlayers.contains(player.getName())) { NavyCraft.cleanupPlayers.remove(player.getName()); @@ -1260,7 +1282,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { event.setCancelled(true); return; } else if (split[1].equalsIgnoreCase("weapons")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.weapons") ) return; for (Weapon w : AimCannon.weapons) { player.sendMessage("weapon -" + w.weaponType); @@ -1268,7 +1290,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { event.setCancelled(true); return; } else if (split[1].equalsIgnoreCase("cannons")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.cannons") ) return; for (OneCannon c : AimCannon.cannons) { player.sendMessage("cannon -" + c.cannonType); @@ -1277,7 +1299,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { return; //admin ship commands } else if (split[1].equalsIgnoreCase("destroyShips")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.destroyships") ) return; for (Craft c : Craft.craftList) { c.doDestroy = true; @@ -1286,7 +1308,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { event.setCancelled(true); return; } else if (split[1].equalsIgnoreCase("removeships")) { - if( !PermissionInterface.CheckPerm(player, "navycraft.admin") ) + if( !PermissionInterface.CheckPerm(player, "navycraft.removeships") ) return; for (Craft c : Craft.craftList) { c.doRemove = true; @@ -1295,7 +1317,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { event.setCancelled(true); return; } else if (split[1].equalsIgnoreCase("tpShip") || split[1].equalsIgnoreCase("tp")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.admin")) + if (!PermissionInterface.CheckPerm(player, "navycraft.tpship")) return; int shipNum = -1; if (split.length == 3) { @@ -1580,328 +1602,75 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") // shipyard commands } else if (craftName.equalsIgnoreCase("shipyard") || craftName.equalsIgnoreCase("sy") || craftName.equalsIgnoreCase("yard")) { if (split.length > 1) { - if (split[1].equalsIgnoreCase("load")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.load") && !player.isOp()) { - player.sendMessage(ChatColor.RED + "You do not have permission to load plots."); + if (split[1].equalsIgnoreCase("addsign")) { + if (!PermissionInterface.CheckPerm(player, "navycraft.addsign") && !player.isOp()) { + player.sendMessage(ChatColor.RED + "You do not have permission to add signs."); event.setCancelled(true); return; } - if (split.length < 3) { - player.sendMessage(ChatColor.GOLD + "Usage - /shipyard load "); - player.sendMessage(ChatColor.YELLOW + "Example - /shipyard load "); - event.setCancelled(true); - return; - } - - String typeString = split[2]; - if (!typeString.equalsIgnoreCase("SHIP1") && - !typeString.equalsIgnoreCase("SHIP2") && - !typeString.equalsIgnoreCase("SHIP3") && - !typeString.equalsIgnoreCase("SHIP4") && - !typeString.equalsIgnoreCase("SHIP5") && - !typeString.equalsIgnoreCase("HANGAR1") && - !typeString.equalsIgnoreCase("HANGAR2") && - !typeString.equalsIgnoreCase("TANK1") && - !typeString.equalsIgnoreCase("TANK2") && - !typeString.equalsIgnoreCase("all")) { - player.sendMessage(ChatColor.RED + "Unknown lot type"); - event.setCancelled(true); + if (player.getTargetBlock(null, 5).getTypeId() == 63) { + Block selectSignBlock = player.getTargetBlock(null, 5); + Sign selectSign = (Sign) selectSignBlock.getState(); + BlockFace bf; + bf = null; + // bf2 = null; + switch (selectSignBlock.getData()) { + case (byte) 0x8:// n + bf = BlockFace.SOUTH; + // bf2 = BlockFace.NORTH; + break; + case (byte) 0x0:// s + bf = BlockFace.NORTH; + // bf2 = BlockFace.SOUTH; + break; + case (byte) 0x4:// w + bf = BlockFace.EAST; + // bf2 = BlockFace.WEST; + break; + case (byte) 0xC:// e + bf = BlockFace.WEST; + // bf2 = BlockFace.EAST; + break; + default: + break; + } + + if (bf == null) { + player.sendMessage(ChatColor.DARK_RED + "Sign Error: Check Direction?"); + return; + } + if (selectSignBlock.getRelative(BlockFace.DOWN).getRelative(bf, -1).getTypeId() == 68) { + Sign selectSign2 = (Sign) selectSignBlock.getRelative(BlockFace.DOWN).getRelative(bf, -1).getState(); + String signLine0 = selectSign.getLine(0); + String sign2Line3 = selectSign2.getLine(3); + + if (signLine0.equalsIgnoreCase("*claim*")) { + NavyCraft_FileListener.updateSign(null, selectSign2.getLine(3), selectSign.getX(), selectSign.getY(),selectSign.getZ(), selectSign.getWorld(), null, false); + } else { + player.sendMessage(ChatColor.RED + "That is not a valid shipyard sign! (Top sign isn't a claim sign)"); return; } - if (typeString.equalsIgnoreCase("SHIP1")) { - NavyCraft_Timer.loadSHIP1(); - } - if (typeString.equalsIgnoreCase("SHIP2")) { - NavyCraft_Timer.loadSHIP2(); - } - if (typeString.equalsIgnoreCase("SHIP3")) { - NavyCraft_Timer.loadSHIP3(); - } - if (typeString.equalsIgnoreCase("SHIP4")) { - NavyCraft_Timer.loadSHIP4(); - } - if (typeString.equalsIgnoreCase("SHIP5")) { - NavyCraft_Timer.loadSHIP5(); - } - if (typeString.equalsIgnoreCase("HANGAR1")) { - NavyCraft_Timer.loadHANGAR1(); - } - if (typeString.equalsIgnoreCase("HANGAR2")) { - NavyCraft_Timer.loadHANGAR2(); - } - if (typeString.equalsIgnoreCase("TANK1")) { - NavyCraft_Timer.loadTANK1(); - } - if (typeString.equalsIgnoreCase("TANK2")) { - NavyCraft_Timer.loadTANK2(); - } - if (typeString.equalsIgnoreCase("all")) { - NavyCraft_Timer.loadSHIP1(); - NavyCraft_Timer.loadSHIP2(); - NavyCraft_Timer.loadSHIP3(); - NavyCraft_Timer.loadSHIP4(); - NavyCraft_Timer.loadSHIP5(); - NavyCraft_Timer.loadHANGAR1(); - NavyCraft_Timer.loadHANGAR2(); - NavyCraft_Timer.loadTANK1(); - NavyCraft_Timer.loadTANK2(); - } - - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File f = new File(shipyarddata, File.separator + "signs.yml"); - FileConfiguration syData = YamlConfiguration.loadConfiguration(f); - List list = new ArrayList(syData.getConfigurationSection("Signs").getKeys(false)); - int size = list.size(); - int amount = size; player.sendMessage(ChatColor.GREEN + "Loaded: " + ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW - + amount + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN + " plots"); - event.setCancelled(true); + + "1" + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + sign2Line3 + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN + " plot"); return; - } else if (split[1].equalsIgnoreCase("reward")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.reward") && !player.isOp()) { - player.sendMessage(ChatColor.RED + "You do not have permission to reward plots."); - event.setCancelled(true); - return; - } - - if (split.length < 5) { - player.sendMessage(ChatColor.GOLD + "Usage - /shipyard reward "); - player.sendMessage(ChatColor.YELLOW + "Example - /shipyard reward Solmex SHIP5 1"); - event.setCancelled(true); - return; - } - - String typeString = split[3]; - if (!typeString.equalsIgnoreCase("SHIP1") && - !typeString.equalsIgnoreCase("SHIP2") && - !typeString.equalsIgnoreCase("SHIP3") && - !typeString.equalsIgnoreCase("SHIP4") && - !typeString.equalsIgnoreCase("SHIP5") && - !typeString.equalsIgnoreCase("HANGAR1") && - !typeString.equalsIgnoreCase("HANGAR2") && - !typeString.equalsIgnoreCase("TANK1") && - !typeString.equalsIgnoreCase("TANK2") && - !typeString.equalsIgnoreCase("MAP1") && - !typeString.equalsIgnoreCase("MAP2") && - !typeString.equalsIgnoreCase("MAP3") && - !typeString.equalsIgnoreCase("MAP4") && - !typeString.equalsIgnoreCase("MAP5")) { - player.sendMessage(ChatColor.RED + "Unknown lot type"); - event.setCancelled(true); - return; - } - - String playerString = split[2]; - if (plugin.getServer().getPlayer(playerString) == null || !plugin.getServer() - .getPlayer(playerString).getName().equalsIgnoreCase(playerString)) { - player.sendMessage(ChatColor.RED + "Player not found or not online."); - event.setCancelled(true); - return; - } - - int rewNum = 0; - try { - rewNum = Integer.parseInt(split[4]); - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.RED + "Invalid Number"); - event.setCancelled(true); - return; - } - - if (rewNum <= 0) { - player.sendMessage(ChatColor.RED + "Cannot revoke plots below 0!"); - event.setCancelled(true); - return; - } - String UUID = PermissionInterface.getUUIDfromPlayer(playerString); - if (UUID != null) { - NavyCraft_FileListener.saveRewardsFile(UUID, typeString, rewNum); - } else { - player.sendMessage(ChatColor.RED + playerString + "has never joined the server!"); - event.setCancelled(true); - return; - } - if (rewNum == 1) { - player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + Math.abs(rewNum) + ChatColor.DARK_GRAY - + " - " + ChatColor.GOLD + typeString + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN - + " Plot rewarded to " + ChatColor.YELLOW + playerString); - event.setCancelled(true); - return; - } else { - player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + Math.abs(rewNum) + ChatColor.DARK_GRAY - + " - " + ChatColor.GOLD + typeString + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN - + " Plot's rewarded to " + ChatColor.YELLOW + playerString); - event.setCancelled(true); - return; - } - } else if (split[1].equalsIgnoreCase("revoke")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.reward") && !player.isOp()) { - player.sendMessage(ChatColor.RED + "You do not have permission to revoke plots."); - event.setCancelled(true); - return; - } - - if (split.length < 5) { - player.sendMessage(ChatColor.GOLD + "Usage - /shipyard revoke "); - player.sendMessage(ChatColor.YELLOW + "Example - /shipyard revoke Solmex SHIP5 1"); - event.setCancelled(true); - return; - } - - String typeString = split[3]; - if (!typeString.equalsIgnoreCase("SHIP1") && - !typeString.equalsIgnoreCase("SHIP2") && - !typeString.equalsIgnoreCase("SHIP3") && - !typeString.equalsIgnoreCase("SHIP4") && - !typeString.equalsIgnoreCase("SHIP5") && - !typeString.equalsIgnoreCase("HANGAR1") && - !typeString.equalsIgnoreCase("HANGAR2") && - !typeString.equalsIgnoreCase("TANK1") && - !typeString.equalsIgnoreCase("TANK2") && - !typeString.equalsIgnoreCase("MAP1") && - !typeString.equalsIgnoreCase("MAP2") && - !typeString.equalsIgnoreCase("MAP3") && - !typeString.equalsIgnoreCase("MAP4") && - !typeString.equalsIgnoreCase("MAP5")) { - player.sendMessage(ChatColor.RED + "Unknown lot type"); - event.setCancelled(true); - return; - } - - String playerString = split[2]; - if (plugin.getServer().getPlayer(playerString) == null || !plugin.getServer() - .getPlayer(playerString).getName().equalsIgnoreCase(playerString)) { - player.sendMessage(ChatColor.RED + "Player not found or not online."); - event.setCancelled(true); - return; - } - - int rewNum = 0; - try { - rewNum = Math.abs(Integer.parseInt(split[4])) * -1; - } catch (NumberFormatException e) { - player.sendMessage(ChatColor.RED + "Invalid Number"); - event.setCancelled(true); - return; - } - - if (rewNum >= 0) { - player.sendMessage(ChatColor.RED + "Can't use a negative number!"); - event.setCancelled(true); - return; - } - String UUID = PermissionInterface.getUUIDfromPlayer(playerString); - if (UUID != null) { - NavyCraft_FileListener.saveRewardsFile(UUID, typeString, rewNum); - } else { - player.sendMessage(ChatColor.RED + playerString + "has never joined the server!"); - event.setCancelled(true); - return; - } - if (rewNum == 1) { - player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + Math.abs(rewNum) + ChatColor.DARK_GRAY - + " - " + ChatColor.GOLD + typeString + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN - + " Plot revoked from " + ChatColor.YELLOW + playerString); - event.setCancelled(true); - return; + } else { + player.sendMessage(ChatColor.RED + "That is not a valid shipyard sign! (Botom sign is null)"); + return; + } } else { - player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + Math.abs(rewNum) + ChatColor.DARK_GRAY - + " - " + ChatColor.GOLD + typeString + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN - + " Plot's revoked from " + ChatColor.YELLOW + playerString); - event.setCancelled(true); + player.sendMessage(ChatColor.RED + "That is not a valid shipyard sign! (Top sign is null)"); return; } } else if (split[1].equalsIgnoreCase("list")) { NavyCraft_FileListener.loadSignData(); NavyCraft_BlockListener.loadRewards(player.getName()); - String UUID = PermissionInterface.getUUIDfromPlayer(player.getName()); + String UUID = Utils.getUUIDfromPlayer(player.getName()); player.sendMessage(ChatColor.AQUA + "Your Shipyard Plots:"); player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "ID" + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TYPE"); - if (NavyCraft.playerSHIP1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP1Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP1"); - } - } - if (NavyCraft.playerSHIP2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP2Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP2"); - } - } - if (NavyCraft.playerSHIP3Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP3Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP3"); - } - } - if (NavyCraft.playerSHIP4Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP4Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP4"); - } - } - if (NavyCraft.playerSHIP5Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP5Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP5"); - } - } - if (NavyCraft.playerHANGAR1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerHANGAR1Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " HANGAR1"); - } - } - if (NavyCraft.playerHANGAR2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerHANGAR2Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " HANGAR2"); - } - } - if (NavyCraft.playerTANK1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerTANK1Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TANK1"); - } - } - if (NavyCraft.playerTANK2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerTANK2Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TANK2"); - } - } - if (NavyCraft.playerMAP1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP1Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP1"); - } - } - if (NavyCraft.playerMAP2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP2Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP2"); - } - } - if (NavyCraft.playerMAP3Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP3Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP3"); - } - } - if (NavyCraft.playerMAP4Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP4Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP4"); - } - } - if (NavyCraft.playerMAP5Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP5Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP5"); + if (NavyCraft.playerSigns.containsKey(UUID)) { + for (Plot p : NavyCraft.playerSigns.get(UUID)) { + player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(p.sign) + ChatColor.DARK_GRAY + "] " + ChatColor.GOLD + p.name); } } @@ -1933,75 +1702,46 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") player.sendMessage(ChatColor.RED + "Invalid Plot ID"); } } else { - player.sendMessage(ChatColor.YELLOW + "/shipyard tp " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "teleport to a plot id"); + player.sendMessage(ChatColor.YELLOW + "/shipyard tp " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "teleport to the given plot ID"); } } else if (split[1].equalsIgnoreCase("help")) { player.sendMessage(ChatColor.GOLD + "Shipyard v" + ChatColor.GREEN + NavyCraft.version + ChatColor.GOLD + " commands :"); player.sendMessage(ChatColor.AQUA + "/shipyard - Status message"); player.sendMessage(ChatColor.AQUA + "/shipyard list - List your current plots"); - player.sendMessage(ChatColor.AQUA + "/shipyard info - Information about plot"); + player.sendMessage(ChatColor.AQUA + "/shipyard info - Information about the given plot"); player.sendMessage(ChatColor.AQUA + "/shipyard open - Teleport to an unclaimed plot"); - player.sendMessage(ChatColor.AQUA + "/shipyard unclaim - Unclaimes a plot"); - player.sendMessage(ChatColor.AQUA + "/shipyard tp - Teleport to the plot id number"); - player.sendMessage(ChatColor.AQUA - + "/shipyard addmember - Gives player permission to that plot"); - player.sendMessage(ChatColor.AQUA - + "/shipyard remmember - Removes player permission to that plot"); + player.sendMessage(ChatColor.AQUA + "/shipyard unclaim - Clears and unclaims a plot"); + player.sendMessage(ChatColor.AQUA + "/shipyard tp - Teleport to the plot ID number"); + player.sendMessage(ChatColor.AQUA + "/shipyard addmember - Gives player permission to that plot"); + player.sendMessage(ChatColor.AQUA + "/shipyard remmember - Removes player permission to that plot"); player.sendMessage(ChatColor.AQUA + "/shipyard clear - Destroys all blocks within the plot"); player.sendMessage(ChatColor.AQUA + "/shipyard rename - Renames the plot"); - player.sendMessage( - ChatColor.AQUA + "/shipyard public - Allows any player to select your vehicle"); - player.sendMessage(ChatColor.AQUA - + "/shipyard private - Allows only you and your members to select your vehicle"); + player.sendMessage(ChatColor.AQUA + "/shipyard public - Allows any player to select your vehicle"); + player.sendMessage(ChatColor.AQUA + "/shipyard private - Allows only you and your members to select your vehicle"); player.sendMessage(ChatColor.AQUA + "/shipyard plist - List the given player's plots"); - player.sendMessage( - ChatColor.AQUA + "/shipyard ptp - Teleport to the player's plot id"); + player.sendMessage(ChatColor.AQUA + "/shipyard ptp - Teleport to the player's plot ID"); + player.sendMessage(ChatColor.AQUA + "/shipyard renumber - Renumbers the given plot ID to new ID"); + player.sendMessage(ChatColor.AQUA + "/shipyard schem list - List saved vehicles"); + player.sendMessage(ChatColor.AQUA + "/shipyard schem plist - List the given player's saved vehicles"); + player.sendMessage(ChatColor.AQUA + "/shipyard schem load - Load a saved vehicle into a plot"); + player.sendMessage(ChatColor.AQUA + "/shipyard schem save - Saves a vehicle in a plot to a schematic"); if (PermissionInterface.CheckQuietPerm(player, "navycraft.admin") || player.isOp()) { - player.sendMessage(ChatColor.RED + "Shipyard Admin v" + ChatColor.GREEN + NavyCraft.version - + ChatColor.RED + " commands :"); + player.sendMessage(ChatColor.RED + "Shipyard Admin v" + ChatColor.GREEN + NavyCraft.version + ChatColor.RED + " commands :"); player.sendMessage(ChatColor.BLUE + "/shipyard player - View a players plot status"); - player.sendMessage(ChatColor.BLUE - + "/shipyard reward - Rewards the specified plot type to the player"); + player.sendMessage(ChatColor.BLUE + "/shipyard reward - Rewards the specified plot type to the player"); } } else if (split[1].equalsIgnoreCase("open")) { if (split.length == 3) { String typeString = split[2]; Block tpBlock = null; - if (typeString.equalsIgnoreCase("SHIP1")) { - tpBlock = NavyCraft_FileListener.findSignOpen("SHIP1"); - } else if (typeString.equalsIgnoreCase("SHIP2")) { - tpBlock = NavyCraft_FileListener.findSignOpen("SHIP2"); - } else if (typeString.equalsIgnoreCase("SHIP3")) { - tpBlock = NavyCraft_FileListener.findSignOpen("SHIP3"); - } else if (typeString.equalsIgnoreCase("SHIP4")) { - tpBlock = NavyCraft_FileListener.findSignOpen("SHIP4"); - } else if (typeString.equalsIgnoreCase("SHIP5")) { - tpBlock = NavyCraft_FileListener.findSignOpen("SHIP5"); - } else if (typeString.equalsIgnoreCase("HANGAR1")) { - tpBlock = NavyCraft_FileListener.findSignOpen("HANGAR1"); - } else if (typeString.equalsIgnoreCase("HANGAR2")) { - tpBlock = NavyCraft_FileListener.findSignOpen("HANGAR2"); - } else if (typeString.equalsIgnoreCase("TANK1")) { - tpBlock = NavyCraft_FileListener.findSignOpen("TANK1"); - } else if (typeString.equalsIgnoreCase("TANK2")) { - tpBlock = NavyCraft_FileListener.findSignOpen("TANK2"); - } else if (typeString.equalsIgnoreCase("MAP1")) { - tpBlock = NavyCraft_FileListener.findSignOpen("MAP1"); - } else if (typeString.equalsIgnoreCase("MAP2")) { - tpBlock = NavyCraft_FileListener.findSignOpen("MAP2"); - } else if (typeString.equalsIgnoreCase("MAP3")) { - tpBlock = NavyCraft_FileListener.findSignOpen("MAP3"); - } else if (typeString.equalsIgnoreCase("MAP4")) { - tpBlock = NavyCraft_FileListener.findSignOpen("MAP4"); - } else if (typeString.equalsIgnoreCase("MAP5")) { - tpBlock = NavyCraft_FileListener.findSignOpen("MAP5"); - } else { - player.sendMessage(ChatColor.RED + "Unknown lot type"); - event.setCancelled(true); - return; + for (PlotType pt :Shipyard.getPlots()) { + if (typeString.equalsIgnoreCase(pt.name)) { + tpBlock = NavyCraft_FileListener.findSignOpen(pt.name); + break; } + } if (tpBlock != null) { player.teleport(tpBlock.getLocation().add(0.5, 0.5, 0.5)); @@ -2036,7 +1776,11 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (wgp != null) { RegionManager regionManager = wgp .getRegionManager(plugin.getServer().getWorld("shipyard")); - String regionName = "--" + player.getName() + "-" + tpId; + int x = foundSign.getX(); + int y = foundSign.getY(); + int z = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + player.getName() + "-" + NavyCraft_FileListener.getSign(x, y, z, world); DefaultDomain dd = regionManager.getRegion(regionName).getMembers(); @@ -2055,7 +1799,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") player.sendMessage(ChatColor.RED + "Invalid Plot ID"); } } else { - player.sendMessage(ChatColor.YELLOW + "/shipyard addmember " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "gives player permission to that plot"); + player.sendMessage(ChatColor.YELLOW + "/shipyard info " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "gives information on given plot ID"); } } else if (split[1].equalsIgnoreCase("addmember")) { if (split.length == 4) { @@ -2081,7 +1825,11 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (wgp != null) { RegionManager regionManager = wgp .getRegionManager(plugin.getServer().getWorld("shipyard")); - String regionName = "--" + player.getName() + "-" + tpId; + int x = foundSign.getX(); + int y = foundSign.getY(); + int z = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + player.getName() + "-" + NavyCraft_FileListener.getSign(x, y, z, world); String playerInName = split[3]; Player p = plugin.getServer().getPlayer(playerInName); @@ -2093,7 +1841,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") com.sk89q.worldguard.LocalPlayer lp = wgp.wrapPlayer(p); regionManager.getRegion(regionName).getMembers().addPlayer(lp); - + try { regionManager.save(); } catch (StorageException e) { @@ -2110,7 +1858,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") player.sendMessage(ChatColor.RED + "Invalid Plot ID"); } } else { - player.sendMessage(ChatColor.YELLOW + "/shipyard addmember "); + player.sendMessage(ChatColor.YELLOW + "/shipyard addmember " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "gives player permission to that plot"); } } else if (split[1].equalsIgnoreCase("remmember")) { if (split.length == 4) { @@ -2136,7 +1884,11 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (wgp != null) { RegionManager regionManager = wgp .getRegionManager(plugin.getServer().getWorld("shipyard")); - String regionName = "--" + player.getName() + "-" + tpId; + int x = foundSign.getX(); + int y = foundSign.getY(); + int z = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + player.getName() + "-" + NavyCraft_FileListener.getSign(x, y, z, world); String playerInName = split[3]; @@ -2147,7 +1899,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } regionManager.getRegion(regionName).getMembers().removePlayer(playerInName); - + try { regionManager.save(); } catch (StorageException e) { @@ -2190,7 +1942,11 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (wgp != null) { RegionManager regionManager = wgp .getRegionManager(plugin.getServer().getWorld("shipyard")); - String regionName = "--" + player.getName() + "-" + tpId; + int x1 = foundSign.getX(); + int y1 = foundSign.getY(); + int z1 = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + player.getName() + "-" + NavyCraft_FileListener.getSign(x1, y1, z1, world); int startX = regionManager.getRegion(regionName).getMinimumPoint().getBlockX(); int endX = regionManager.getRegion(regionName).getMaximumPoint().getBlockX(); @@ -2265,7 +2021,11 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (wgp != null) { RegionManager regionManager = wgp .getRegionManager(plugin.getServer().getWorld("shipyard")); - String regionName = "--" + player.getName() + "-" + tpId; + int x1 = foundSign.getX(); + int y1 = foundSign.getY(); + int z1 = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + player.getName() + "-" + NavyCraft_FileListener.getSign(x1, y1, z1, world); int startX = 0; int endX = 0; int startZ = 0; @@ -2305,14 +2065,17 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } } regionManager.removeRegion(regionName); - NavyCraft_FileListener.saveUnclaimedSign(foundSign2.getLine(3), - foundSign.getWorld().getName(), foundSign.getX(), foundSign.getY(), - foundSign.getZ()); + NavyCraft_FileListener.updateSign(null, foundSign2.getLine(3), foundSign.getX(), foundSign.getY(),foundSign.getZ(), foundSign.getWorld(), null, false); foundSign.setLine(0, "*Claim*"); foundSign.setLine(1, ""); foundSign.setLine(2, ""); foundSign.setLine(3, ""); foundSign.update(); + foundSign2.setLine(0, "Open"); + foundSign2.setLine(1, "1"); + foundSign2.setLine(2, "0"); + foundSign2.setLine(3, foundSign2.getLine(3).toUpperCase()); + foundSign2.update(); NavyCraft_FileListener.loadSignData(); NavyCraft_BlockListener.loadRewards(player.getName()); try { @@ -2335,12 +2098,11 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") player.sendMessage(ChatColor.RED + "Invalid Plot ID"); } } else { - player.sendMessage(ChatColor.YELLOW + "/shipyard unclaim " + ChatColor.DARK_GRAY + " - " - + ChatColor.GOLD + "destroys all blocks within the plot"); + player.sendMessage(ChatColor.YELLOW + "/shipyard unclaim " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "destroys all blocks within the plot and unclaims it"); } } else if (split[1].equalsIgnoreCase("aunclaim")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.admin")) { + if (!PermissionInterface.CheckPerm(player, "navycraft.aunclaim")) { event.setCancelled(true); return; } @@ -2376,7 +2138,11 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (wgp != null) { RegionManager regionManager = wgp .getRegionManager(plugin.getServer().getWorld("shipyard")); - String regionName = "--" + p + "-" + tpId; + int x1 = foundSign.getX(); + int y1 = foundSign.getY(); + int z1 = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + p + "-" + NavyCraft_FileListener.getSign(x1, y1, z1, world); int startX = 0; int endX = 0; int startZ = 0; @@ -2415,14 +2181,17 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } } regionManager.removeRegion(regionName); - NavyCraft_FileListener.saveUnclaimedSign(foundSign2.getLine(3), - foundSign.getWorld().getName(), foundSign.getX(), foundSign.getY(), - foundSign.getZ()); + NavyCraft_FileListener.updateSign(null, foundSign2.getLine(3), foundSign.getX(), foundSign.getY(),foundSign.getZ(), foundSign.getWorld(), null, false); foundSign.setLine(0, "*Claim*"); foundSign.setLine(1, ""); foundSign.setLine(2, ""); foundSign.setLine(3, ""); foundSign.update(); + foundSign2.setLine(0, "Open"); + foundSign2.setLine(1, "1"); + foundSign2.setLine(2, "0"); + foundSign2.setLine(3, foundSign2.getLine(3).toUpperCase()); + foundSign2.update(); NavyCraft_FileListener.loadSignData(); NavyCraft_BlockListener.loadRewards(player.getName()); try { @@ -2431,9 +2200,10 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") e.printStackTrace(); } player.sendMessage(ChatColor.GREEN + "Plot Unclaimed."); + } } else { player.sendMessage( - ChatColor.RED + "Error: There may be a problem with your plot signs."); + ChatColor.RED + "Error: There may be a problem with the plots signs."); } } else { player.sendMessage(ChatColor.RED + "ID not found, use " + ChatColor.YELLOW @@ -2443,9 +2213,171 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") player.sendMessage(ChatColor.RED + "Invalid Plot ID"); } } else { - player.sendMessage(ChatColor.YELLOW + "/shipyard unclaim " + ChatColor.DARK_GRAY + " - " - + ChatColor.GOLD + "destroys all blocks within the plot"); + player.sendMessage(ChatColor.YELLOW + "/shipyard aunclaim " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "destroys all blocks within the defined plot"); + } + } else if (split[1].equalsIgnoreCase("schem") || split[1].equalsIgnoreCase("schematic")) { + if (split.length > 2) { + if (split[2].equalsIgnoreCase("save")) { + if (split.length == 5) { + int tpId = -1; + try { + tpId = Integer.parseInt(split[3]); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.RED + "Invalid Plot ID"); + event.setCancelled(true); + return; + } + + String nameString = split[4]; + + if (tpId > -1) { + NavyCraft_FileListener.loadSignData(); + NavyCraft_BlockListener.loadRewards(player.getName()); + + Sign foundSign = null; + foundSign = NavyCraft_BlockListener.findSign(player.getName(), tpId); + + if (foundSign != null) { + wgp = (WorldGuardPlugin) plugin.getServer().getPluginManager() + .getPlugin("WorldGuard"); + if (wgp != null) { + RegionManager regionManager = wgp + .getRegionManager(plugin.getServer().getWorld("shipyard")); + int x = foundSign.getX(); + int y = foundSign.getY(); + int z = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + player.getName() + "-" + NavyCraft_FileListener.getSign(x, y, z, world); + + ProtectedRegion region = regionManager.getRegion(regionName); + + Sign sign2 = (Sign) foundSign.getBlock().getRelative(BlockFace.DOWN, 1).getRelative(Utils.getBlockFace(foundSign.getBlock()), -1).getState(); + + String name = player.getName() + "-" + sign2.getLine(3).trim().toUpperCase(); + + Utils.saveSchem(player, name, nameString, region, world); + + player.sendMessage(ChatColor.GREEN + "Plot Saved as " + ChatColor.DARK_GRAY + "[" + ChatColor.GOLD + name + "-" + nameString + ".schematic" + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN + "."); + } + } else { + player.sendMessage(ChatColor.RED + "ID not found, use " + ChatColor.YELLOW + "/shipyard list" + ChatColor.RED + " to see IDs"); + } + + } else { + player.sendMessage(ChatColor.RED + "Invalid Plot ID"); + } + } else { + player.sendMessage(ChatColor.YELLOW + "/shipyard schem save " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "saves the defined plot in a schematic" ); + } + } else if (split[2].equalsIgnoreCase("load")) { + if (split.length == 5) { + int tpId = -1; + try { + tpId = Integer.parseInt(split[4]); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.RED + "Invalid Plot ID"); + event.setCancelled(true); + return; + } + + String nameString = split[3]; + + if (tpId > -1) { + NavyCraft_FileListener.loadSignData(); + NavyCraft_BlockListener.loadRewards(player.getName()); + + Sign foundSign = null; + foundSign = NavyCraft_BlockListener.findSign(player.getName(), tpId); + + if (foundSign != null) { + wgp = (WorldGuardPlugin) plugin.getServer().getPluginManager() + .getPlugin("WorldGuard"); + if (wgp != null) { + RegionManager regionManager = wgp + .getRegionManager(plugin.getServer().getWorld("shipyard")); + int x = foundSign.getX(); + int y = foundSign.getY(); + int z = foundSign.getZ(); + World world = foundSign.getWorld(); + String regionName = "--" + player.getName() + "-" + NavyCraft_FileListener.getSign(x, y, z, world); + + ProtectedRegion region = regionManager.getRegion(regionName); + + Sign sign2 = (Sign) foundSign.getBlock().getRelative(BlockFace.DOWN, 1).getRelative(Utils.getBlockFace(foundSign.getBlock()), -1).getState(); + + String name = player.getName() + "-" + sign2.getLine(3).trim().toUpperCase() + "-" + nameString; + Location loc = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ()); + if (Utils.pasteSchem(name, loc)) { + player.sendMessage(ChatColor.GREEN + "Plot loaded " + ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "ID: " + ChatColor.GOLD + tpId + ChatColor.DARK_GRAY + " - " + ChatColor.YELLOW + "Name: "+ ChatColor.GOLD + name + ".schematic" + ChatColor.DARK_GRAY + "]" + ChatColor.GREEN + "."); + } else { + player.sendMessage(ChatColor.RED + "Plot name doesn't exist in database!"); + } + } + } else { + player.sendMessage(ChatColor.RED + "ID not found, use " + ChatColor.YELLOW + "/shipyard list" + ChatColor.RED + " to see IDs"); + } + + } else { + player.sendMessage(ChatColor.RED + "Invalid Plot ID"); + } + } else { + player.sendMessage(ChatColor.YELLOW + "/shipyard schem load " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "saves your plot in a schematic" ); + } + } else if (split[2].equalsIgnoreCase("plist")) { + if (split.length == 4) { + String p = split[3]; + NavyCraft_FileListener.loadSignData(); + NavyCraft_BlockListener.loadRewards(p); + player.sendMessage(ChatColor.AQUA + p + "'s" + " Shipyard Schematics:"); + player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "NAME" + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TYPE"); + File dir = new File(NavyCraft.instance.getDataFolder(), "/schematics/"); + for (File f : dir.listFiles()) { + String[] splits = f.getName().split("-"); + if (splits[0].equalsIgnoreCase(p)) { + player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + f.getName() + ChatColor.DARK_GRAY + "] " + ChatColor.GOLD + splits[1]); + } + } + event.setCancelled(true); + return; + } else { + player.sendMessage(ChatColor.YELLOW + "/shipyard schem plist " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "list the given player's schematics"); + event.setCancelled(true); + return; } + } else if (split[2].equalsIgnoreCase("list")) { + NavyCraft_FileListener.loadSignData(); + NavyCraft_BlockListener.loadRewards(player.getName()); + player.sendMessage(ChatColor.AQUA + "Your Shipyard Schematics:"); + player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "NAME" + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TYPE"); + File dir = new File(NavyCraft.instance.getDataFolder(), "/schematics/"); + for (File f : dir.listFiles()) { + String[] splits = f.getName().split("-"); + if (splits[0].equalsIgnoreCase(player.getName())) { + player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + f.getName() + ChatColor.DARK_GRAY + "] " + ChatColor.GOLD + splits[1]); + } + } + event.setCancelled(true); + return; + } else { + player.sendMessage("Unknown command. Type \"/shipyard help\" for help."); + event.setCancelled(true); + return; + } + + } else { + NavyCraft_FileListener.loadSignData(); + NavyCraft_BlockListener.loadRewards(player.getName()); + player.sendMessage(ChatColor.AQUA + "Your Shipyard Schematics:"); + player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "NAME" + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TYPE"); + File dir = new File(NavyCraft.instance.getDataFolder(), "/schematics/"); + for (File f : dir.listFiles()) { + String[] splits = f.getName().split("-"); + if (splits[0].equalsIgnoreCase(player.getName())) { + player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + f.getName() + ChatColor.DARK_GRAY + "] " + ChatColor.GOLD + splits[1]); + } + } + event.setCancelled(true); + return; } } else if (split[1].equalsIgnoreCase("rename")) { if (split.length > 3) { @@ -2485,6 +2417,89 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } else { player.sendMessage(ChatColor.YELLOW + "/shipyard rename " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "renames the plot"); } + } else if (split[1].equalsIgnoreCase("renumber")) { + if (split.length > 3) { + String UUID = Utils.getUUIDfromPlayer(player.getName()); + int tpId = -1; + try { + tpId = Integer.parseInt(split[2]); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.RED + "Invalid Plot ID"); + event.setCancelled(true); + return; + } + + int newId; + try { + newId = Integer.parseInt(split[3]); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.RED + "Invalid New ID"); + event.setCancelled(true); + return; + } + + if (tpId > -1 && newId > -1) { + NavyCraft_FileListener.loadSignData(); + NavyCraft_BlockListener.loadRewards(player.getName()); + + Sign foundSign = null; + foundSign = NavyCraft_BlockListener.findSign(player.getName(), tpId); + if (foundSign != null) { + Block block = foundSign.getBlock(); + if (NavyCraft.playerSigns.containsKey(UUID)) { + for (Plot p : NavyCraft.playerSigns.get(UUID)) { + if (newId == NavyCraft.playerSignIndex.get(p.sign)) { + player.sendMessage(ChatColor.RED + "ID already exists in database!"); + event.setCancelled(true); + return; + } + } + } + BlockFace bf = null; + if (block != null) { + // bf2 = null; + switch (block.getData()) { + case (byte) 0x8:// n + bf = BlockFace.SOUTH; + // bf2 = BlockFace.NORTH; + break; + case (byte) 0x0:// s + bf = BlockFace.NORTH; + // bf2 = BlockFace.SOUTH; + break; + case (byte) 0x4:// w + bf = BlockFace.EAST; + // bf2 = BlockFace.WEST; + break; + case (byte) 0xC:// e + bf = BlockFace.WEST; + // bf2 = BlockFace.EAST; + break; + default: + break; + } + + if (bf == null) { + player.sendMessage(ChatColor.DARK_RED + "Sign Error: Check Direction?"); + return; + } + } + Sign sign2 = (Sign) block.getRelative(BlockFace.DOWN, 1).getRelative(bf, -1).getState(); + sign2.setLine(2, String.valueOf(newId)); + sign2.update(); + NavyCraft_FileListener.updateSign(UUID, sign2.getLine(3), foundSign.getX(), foundSign.getY(), foundSign.getZ(), foundSign.getWorld(), newId, true); + player.sendMessage(ChatColor.GREEN + "Plot renumbered."); + NavyCraft_FileListener.loadSignData(); + } else { + player.sendMessage(ChatColor.RED + "ID not found, use " + ChatColor.YELLOW + "/shipyard list" + ChatColor.RED + " to see IDs"); + } + + } else { + player.sendMessage(ChatColor.RED + "Invalid Plot ID"); + } + } else { + player.sendMessage(ChatColor.YELLOW + "/shipyard renumber " + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "renames the plot"); + } } else if (split[1].equalsIgnoreCase("public")) { if (split.length == 3) { int tpId = -1; @@ -2574,221 +2589,32 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } else if (split[1].equalsIgnoreCase("player")) { if (split.length == 3) { String p = split[2]; - String UUID = PermissionInterface.getUUIDfromPlayer(p); + String UUID = Utils.getUUIDfromPlayer(p); NavyCraft_FileListener.loadSignData(); NavyCraft_BlockListener.loadRewards(p); if (UUID != null) { player.sendMessage(ChatColor.AQUA + p + "'s Shipyard Plots:"); - if (NavyCraft.playerSHIP1Signs.containsKey(UUID)) { - int numSHIP1s = NavyCraft.playerSHIP1Signs.get(UUID).size(); - if (NavyCraft.playerSHIP1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP1s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerSHIP2Signs.containsKey(UUID)) { - int numSHIP2s = NavyCraft.playerSHIP2Signs.get(UUID).size(); - if (NavyCraft.playerSHIP2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP2s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerSHIP3Signs.containsKey(UUID)) { - int numSHIP3s = NavyCraft.playerSHIP3Signs.get(UUID).size(); - if (NavyCraft.playerSHIP3Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP3s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP3Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP3s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP3s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP3Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP3Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerSHIP4Signs.containsKey(UUID)) { - int numSHIP4s = NavyCraft.playerSHIP4Signs.get(UUID).size(); - if (NavyCraft.playerSHIP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP4s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP4Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP4s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP4s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP4Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerSHIP5Signs.containsKey(UUID)) { - int numSHIP5s = NavyCraft.playerSHIP5Signs.get(UUID).size(); - if (NavyCraft.playerSHIP5Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP5s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP5Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP5s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP5s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP5Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP5Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerHANGAR1Signs.containsKey(UUID)) { - int numHANGAR1s = NavyCraft.playerHANGAR1Signs.get(UUID).size(); - if (NavyCraft.playerHANGAR1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "HANGAR1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numHANGAR1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerHANGAR1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "HANGAR1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numHANGAR1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numHANGAR1s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerHANGAR1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "HANGAR1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerHANGAR1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerHANGAR2Signs.containsKey(UUID)) { - int numHANGAR2s = NavyCraft.playerHANGAR2Signs.get(UUID).size(); - if (NavyCraft.playerHANGAR2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "HANGAR2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numHANGAR2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerHANGAR2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "HANGAR2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numHANGAR2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numHANGAR2s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerHANGAR2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "HANGAR2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerHANGAR2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerTANK1Signs.containsKey(UUID)) { - int numTANK1s = NavyCraft.playerTANK1Signs.get(UUID).size(); - if (NavyCraft.playerTANK1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "TANK1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numTANK1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerTANK1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "TANK1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numTANK1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numTANK1s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerTANK1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "TANK1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerTANK1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerTANK2Signs.containsKey(UUID)) { - int numTANK2s = NavyCraft.playerTANK2Signs.get(UUID).size(); - if (NavyCraft.playerTANK2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "TANK2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numTANK2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerTANK2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "TANK2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numTANK2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numTANK2s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerTANK2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "TANK2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerTANK2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP1Signs.containsKey(UUID)) { - int numMAP1s = NavyCraft.playerMAP1Signs.get(UUID).size(); - if (NavyCraft.playerMAP1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP1s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP2Signs.containsKey(UUID)) { - int numMAP2s = NavyCraft.playerMAP2Signs.get(UUID).size(); - if (NavyCraft.playerMAP2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP2s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP3Signs.containsKey(UUID)) { - int numMAP3s = NavyCraft.playerMAP3Signs.get(UUID).size(); - if (NavyCraft.playerMAP3Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP3s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP3Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP3s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP3s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP3Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP3Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP4Signs.containsKey(UUID)) { - int numMAP4s = NavyCraft.playerMAP4Signs.get(UUID).size(); - if (NavyCraft.playerMAP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP4s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP4Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP4s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP4s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP4Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP5Signs.containsKey(UUID)) { - int numMAP5s = NavyCraft.playerMAP5Signs.get(UUID).size(); - if (NavyCraft.playerMAP5Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP5s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP5Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP5s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP5s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP5Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP5Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); + for (PlotType pt : Shipyard.getPlots()) { + int numPlots = 0; + int numRewPlots = 0; + if (NavyCraft.playerSigns.containsKey(UUID)) { + for (Plot p1 : NavyCraft.playerSigns.get(UUID)) { + if (p1.name.equalsIgnoreCase(pt.name)) + numPlots++; + } + } + if (NavyCraft.playerRewards.containsKey(UUID)) { + for (Reward r : NavyCraft.playerRewards.get(UUID)) { + if (r.name.equalsIgnoreCase(pt.name)) { + numRewPlots = r.amount; + } } } + if (numPlots > 0 || numRewPlots > 0) { + player.sendMessage(ChatColor.GOLD + pt.name + ChatColor.DARK_GRAY + " [" + ChatColor.GREEN + numPlots + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" + + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numRewPlots + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); + } + } } else { player.sendMessage(ChatColor.RED + p + "has never joined the server!"); } @@ -2800,93 +2626,14 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") String p = split[2]; NavyCraft_FileListener.loadSignData(); NavyCraft_BlockListener.loadRewards(p); - String UUID = PermissionInterface.getUUIDfromPlayer(p); + String UUID = Utils.getUUIDfromPlayer(p); if (UUID != null) { player.sendMessage(ChatColor.AQUA + p + "'s" + " Shipyard Plots:"); player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "ID" + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TYPE"); - - if (NavyCraft.playerSHIP1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP1Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP1"); - } - } - if (NavyCraft.playerSHIP2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP2Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP2"); - } - } - if (NavyCraft.playerSHIP3Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP3Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP3"); - } - } - if ( NavyCraft.playerSHIP4Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP4Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP4"); - } - } - if (NavyCraft.playerSHIP5Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerSHIP5Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " SHIP5"); - } - } - if (NavyCraft.playerHANGAR1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerHANGAR1Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " HANGAR1"); - } - } - if (NavyCraft.playerHANGAR2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerHANGAR2Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " HANGAR2"); - } - } - if (NavyCraft.playerTANK1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerTANK1Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TANK1"); - } - } - if (NavyCraft.playerTANK2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerTANK2Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " TANK2"); - } - } - if (NavyCraft.playerMAP1Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP1Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP1"); - } - } - if (NavyCraft.playerMAP2Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP2Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP2"); - } - } - if (NavyCraft.playerMAP3Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP3Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP3"); - } - } - if ( NavyCraft.playerMAP4Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP4Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP4"); - } - } - if (NavyCraft.playerMAP5Signs.containsKey(UUID)) { - for (Sign s : NavyCraft.playerMAP5Signs.get(UUID)) { - player.sendMessage( - ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(s) + ChatColor.DARK_GRAY + "]" + ChatColor.GOLD + " MAP5"); + + if (NavyCraft.playerSigns.containsKey(UUID)) { + for (Plot p1 : NavyCraft.playerSigns.get(UUID)) { + player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + NavyCraft.playerSignIndex.get(p1.sign) + ChatColor.DARK_GRAY + "] " + ChatColor.GOLD + p1.name); } } event.setCancelled(true); @@ -2939,217 +2686,28 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } else { NavyCraft_FileListener.loadSignData(); NavyCraft_BlockListener.loadRewards(player.getName()); - String UUID = PermissionInterface.getUUIDfromPlayer(player.getName()); + String UUID = Utils.getUUIDfromPlayer(player.getName()); player.sendMessage(ChatColor.AQUA + "Your Shipyard Plots:"); - if (NavyCraft.playerSHIP1Signs.containsKey(UUID)) { - int numSHIP1s = NavyCraft.playerSHIP1Signs.get(UUID).size(); - if (NavyCraft.playerSHIP1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP1s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerSHIP2Signs.containsKey(UUID)) { - int numSHIP2s = NavyCraft.playerSHIP2Signs.get(UUID).size(); - if (NavyCraft.playerSHIP2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP2s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerSHIP3Signs.containsKey(UUID)) { - int numSHIP3s = NavyCraft.playerSHIP3Signs.get(UUID).size(); - if (NavyCraft.playerSHIP3Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP3s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP3Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP3s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP3s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP3Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP3Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerSHIP4Signs.containsKey(UUID)) { - int numSHIP4s = NavyCraft.playerSHIP4Signs.get(UUID).size(); - if (NavyCraft.playerSHIP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP4s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP4Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP4s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP4s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP4Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerSHIP5Signs.containsKey(UUID)) { - int numSHIP5s = NavyCraft.playerSHIP5Signs.get(UUID).size(); - if (NavyCraft.playerSHIP5Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP5s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP5Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "SHIP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numSHIP5s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numSHIP5s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerSHIP5Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "SHIP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerSHIP5Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerHANGAR1Signs.containsKey(UUID)) { - int numHANGAR1s = NavyCraft.playerHANGAR1Signs.get(UUID).size(); - if (NavyCraft.playerHANGAR1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "HANGAR1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numHANGAR1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerHANGAR1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "HANGAR1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numHANGAR1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerHANGAR1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "HANGAR1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerHANGAR1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerHANGAR2Signs.containsKey(UUID)) { - int numHANGAR2s = NavyCraft.playerHANGAR2Signs.get(UUID).size(); - if (NavyCraft.playerHANGAR2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "HANGAR2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numHANGAR2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerHANGAR2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "HANGAR2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numHANGAR2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerHANGAR2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "HANGAR2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerHANGAR2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerTANK1Signs.containsKey(UUID)) { - int numTANK1s = NavyCraft.playerTANK1Signs.get(UUID).size(); - if (NavyCraft.playerTANK1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "TANK1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numTANK1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerTANK1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "TANK1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numTANK1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerTANK1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "TANK1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerTANK1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerTANK2Signs.containsKey(UUID)) { - int numTANK2s = NavyCraft.playerTANK2Signs.get(UUID).size(); - if (NavyCraft.playerTANK2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "TANK2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numTANK2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerTANK2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "TANK2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numTANK2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerTANK2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "TANK2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerTANK2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP1Signs.containsKey(UUID)) { - int numMAP1s = NavyCraft.playerMAP1Signs.get(UUID).size(); - if (NavyCraft.playerMAP1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP1s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP1s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP1Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP1 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP1Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP2Signs.containsKey(UUID)) { - int numMAP2s = NavyCraft.playerMAP2Signs.get(UUID).size(); - if (NavyCraft.playerMAP2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP2s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP2s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP2Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP2 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP2Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP3Signs.containsKey(UUID)) { - int numMAP3s = NavyCraft.playerMAP3Signs.get(UUID).size(); - if (NavyCraft.playerMAP3Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP3s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP3Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP3s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP3s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP3Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP3 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP3Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } - if (NavyCraft.playerMAP4Signs.containsKey(UUID)) { - int numMAP4s = NavyCraft.playerMAP4Signs.get(UUID).size(); - if (NavyCraft.playerMAP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP4s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP4Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP4s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP4s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); + for (PlotType pt : Shipyard.getPlots()) { + int numPlots = 0; + int numRewPlots = 0; + if (NavyCraft.playerSigns.containsKey(UUID)) { + for (Plot p1 : NavyCraft.playerSigns.get(UUID)) { + if (p1.name.equalsIgnoreCase(pt.name)) + numPlots++; + } } - } else { - if (NavyCraft.playerMAP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP4 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP4Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); + if (NavyCraft.playerRewards.containsKey(UUID)) { + for (Reward r : NavyCraft.playerRewards.get(UUID)) { + if (r.name.equalsIgnoreCase(pt.name)) { + numRewPlots = r.amount; + } + } } + if (numPlots > 0 || numRewPlots > 0) { + player.sendMessage(ChatColor.GOLD + pt.name + ChatColor.DARK_GRAY + " [" + ChatColor.GREEN + numPlots + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" + + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numRewPlots + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); } - if (NavyCraft.playerMAP5Signs.containsKey(UUID)) { - int numMAP5s = NavyCraft.playerMAP5Signs.get(UUID).size(); - if (NavyCraft.playerMAP5Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP5s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP5Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } else { - player.sendMessage(ChatColor.GOLD + "MAP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + numMAP5s + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + numMAP5s + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } - } else { - if (NavyCraft.playerMAP4Rewards.containsKey(UUID)) { - player.sendMessage(ChatColor.GOLD + "MAP5 " + ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "0" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + "/" - + ChatColor.DARK_GRAY + "[" + ChatColor.RED + NavyCraft.playerMAP5Rewards.get(UUID) + ChatColor.DARK_GRAY + "]" + ChatColor.DARK_AQUA + " available"); - } } } event.setCancelled(true); @@ -3221,7 +2779,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") player.sendMessage(ChatColor.YELLOW + "Types: engine, weapons, other, all"); } if (split[1].equalsIgnoreCase("engine")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic") && !player.isOp()) { + if (!PermissionInterface.CheckPerm(player, "navycraft.volume.engine") && !player.isOp()) { player.sendMessage(ChatColor.RED + "You do not have permission to set engine volume."); event.setCancelled(true); return; @@ -3229,7 +2787,6 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (split[2].equalsIgnoreCase("mute")) { float inValue = 0.0f; NavyCraft.playerEngineVolumes.put(player, inValue); - NavyCraft_FileListener.saveVolume(player.getName()); player.sendMessage(ChatColor.GOLD + "Engine volume muted"); event.setCancelled(true); return; @@ -3241,7 +2798,6 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") inValue = Float.parseFloat(split[2]); if ((inValue >= 0) && (inValue <= 100.0f)) { NavyCraft.playerEngineVolumes.put(player, inValue); - NavyCraft_FileListener.saveVolume(player.getName()); player.sendMessage(ChatColor.GOLD + "Volume set for engines - " + ChatColor.GREEN + inValue + "%"); } else { player.sendMessage(ChatColor.RED + "Invalid volume percent, use a number from 0 to 100"); @@ -3257,7 +2813,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } } if (split[1].equalsIgnoreCase("weapon")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic") && !player.isOp()) { + if (!PermissionInterface.CheckPerm(player, "navycraft.volume.weapon") && !player.isOp()) { player.sendMessage(ChatColor.RED + "You do not have permission to set gun volume."); event.setCancelled(true); return; @@ -3265,7 +2821,6 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (split[2].equalsIgnoreCase("mute")) { float inValue = 0.0f; NavyCraft.playerWeaponVolumes.put(player, inValue); - NavyCraft_FileListener.saveVolume(player.getName()); player.sendMessage(ChatColor.GOLD + "Gun volume muted"); event.setCancelled(true); return; @@ -3277,7 +2832,6 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") inValue = Float.parseFloat(split[2]); if ((inValue >= 0) && (inValue <= 100.0f)) { NavyCraft.playerWeaponVolumes.put(player, inValue); - NavyCraft_FileListener.saveVolume(player.getName()); player.sendMessage(ChatColor.GOLD + "Volume set for weapons - " + ChatColor.GREEN + inValue + "%"); } else { player.sendMessage(ChatColor.RED + "Invalid volume percent, use a number from 0 to 100"); @@ -3293,7 +2847,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } } if (split[1].equalsIgnoreCase("other")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic") && !player.isOp()) { + if (!PermissionInterface.CheckPerm(player, "navycraft.volume.other") && !player.isOp()) { player.sendMessage(ChatColor.RED + "You do not have permission to set other volume."); event.setCancelled(true); return; @@ -3301,7 +2855,6 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") if (split[2].equalsIgnoreCase("mute")) { float inValue = 0.0f; NavyCraft.playerOtherVolumes.put(player, inValue); - NavyCraft_FileListener.saveVolume(player.getName()); player.sendMessage(ChatColor.GOLD + "Other volumes muted"); event.setCancelled(true); return; @@ -3313,7 +2866,6 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") inValue = Float.parseFloat(split[2]); if ((inValue >= 0) && (inValue <= 100.0f)) { NavyCraft.playerOtherVolumes.put(player, inValue); - NavyCraft_FileListener.saveVolume(player.getName()); player.sendMessage(ChatColor.GOLD + "Volume set for other - " + ChatColor.GREEN + inValue + "%"); } else { player.sendMessage(ChatColor.RED + "Invalid volume percent, use a number from 0 to 100"); @@ -3329,7 +2881,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } } if (split[1].equalsIgnoreCase("all")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic") && !player.isOp()) { + if (!PermissionInterface.CheckPerm(player, "navycraft.volume.all") && !player.isOp()) { player.sendMessage(ChatColor.RED + "You do not have permission to set other volume."); event.setCancelled(true); return; @@ -3339,7 +2891,6 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") NavyCraft.playerEngineVolumes.put(player, inValue); NavyCraft.playerWeaponVolumes.put(player, inValue); NavyCraft.playerOtherVolumes.put(player, inValue); - NavyCraft_FileListener.saveVolume(player.getName()); player.sendMessage(ChatColor.GOLD + "All volume muted"); event.setCancelled(true); return; @@ -3353,7 +2904,6 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") NavyCraft.playerOtherVolumes.put(player, inValue); NavyCraft.playerWeaponVolumes.put(player, inValue); NavyCraft.playerEngineVolumes.put(player, inValue); - NavyCraft_FileListener.saveVolume(player.getName()); player.sendMessage(ChatColor.GOLD + "Volume set for all - " + ChatColor.GREEN + inValue + "%"); } else { player.sendMessage(ChatColor.RED + "Invalid volume percent, use a number from 0 to 100"); @@ -3382,7 +2932,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } return; } else if (craftName.equalsIgnoreCase("explode")) { - if (PermissionInterface.CheckPerm(player, "navycraft.admin")) { + if (PermissionInterface.CheckPerm(player, "navycraft.explode")) { if (split.length == 2) { float inValue = 1.0f; try { @@ -3424,7 +2974,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") event.setCancelled(true); return; }else if (craftName.equalsIgnoreCase("explodesigns")) { - if (PermissionInterface.CheckPerm(player, "navycraft.admin")) { + if (PermissionInterface.CheckPerm(player, "navycraft.explodesigns")) { if (split.length == 2) { float inValue = 1.0f; try { @@ -3475,7 +3025,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") player.sendMessage(ChatColor.GOLD + "Admiral - 2000000"); } if (split[1].equalsIgnoreCase("view")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.basic") && !player.isOp()) { + if (!PermissionInterface.CheckPerm(player, "navycraft.expview") && !player.isOp()) { player.sendMessage(ChatColor.RED + "You do not have permission to view players ranks."); event.setCancelled(true); return; @@ -3493,7 +3043,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } } if (split[1].equalsIgnoreCase("set")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.admin") && !player.isOp()) { + if (!PermissionInterface.CheckPerm(player, "navycraft.expset") && !player.isOp()) { player.sendMessage(ChatColor.RED + "You do not have permission to set exp."); event.setCancelled(true); return; @@ -3515,7 +3065,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } } if (split[1].equalsIgnoreCase("add")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.admin") && !player.isOp()) { + if (!PermissionInterface.CheckPerm(player, "navycraft.expadd") && !player.isOp()) { player.sendMessage(ChatColor.RED + "You do not have permission to add exp."); event.setCancelled(true); return; @@ -3537,7 +3087,7 @@ else if (craftName.equalsIgnoreCase("radio") || craftName.equalsIgnoreCase("ra") } } if (split[1].equalsIgnoreCase("remove")) { - if (!PermissionInterface.CheckPerm(player, "navycraft.admin") && !player.isOp()) { + if (!PermissionInterface.CheckPerm(player, "navycraft.expremove") && !player.isOp()) { player.sendMessage(ChatColor.RED + "You do not have permission to remove exp."); event.setCancelled(true); return; @@ -3685,7 +3235,7 @@ public boolean processCommand(CraftType craftType, Player player, String[] split return true; }else if (split[1].equalsIgnoreCase("drive") - && (PermissionInterface.CheckPerm(player, "navycraft.admin"))) { + && (PermissionInterface.CheckPerm(player, "navycraft.admindrive"))) { if (player.getItemInHand().getTypeId() > 0) { player.sendMessage(ChatColor.RED + "Have nothing in your hand before using this."); return true; @@ -3743,7 +3293,7 @@ public boolean processCommand(CraftType craftType, Player player, String[] split return true; } else if (split[1].equalsIgnoreCase("command") - && (PermissionInterface.CheckPerm(player, "navycraft.admin"))) { + && (PermissionInterface.CheckPerm(player, "navycraft.takeover"))) { Craft testCraft = Craft.getCraft(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()); if (testCraft != null) { @@ -3766,7 +3316,7 @@ public boolean processCommand(CraftType craftType, Player player, String[] split } else if (split[1].equalsIgnoreCase("remove")) { if (craft != null) { if ((craft.captainName == player.getName()) || (player.isOnline() && player.isOp())) { - if (PermissionInterface.CheckPerm(player, "navycraft.admin")) { + if (PermissionInterface.CheckPerm(player, "navycraft.remove")) { craft.doRemove = true; if (player.getInventory().contains(Material.GOLD_SWORD)) { player.getInventory().remove(Material.GOLD_SWORD); @@ -3812,7 +3362,7 @@ public boolean processCommand(CraftType craftType, Player player, String[] split } else if (split[1].equalsIgnoreCase("destroy")) { if (craft != null) { if ((craft.captainName == player.getName()) || player.isOp()) { - if (checkProtectedRegion(player, craft.getLocation()) || PermissionInterface.CheckPerm(player, "navycraft.admin")) { + if (checkProtectedRegion(player, craft.getLocation()) || PermissionInterface.CheckPerm(player, "navycraft.destroy")) { craft.doDestroy = true; if (player.getInventory().contains(Material.GOLD_SWORD)) { player.getInventory().remove(Material.GOLD_SWORD); @@ -3976,7 +3526,7 @@ public boolean processCommand(CraftType craftType, Player player, String[] split player.sendMessage(ChatColor.RED + "You are not on a crew."); } return true; - } else if (split[1].equalsIgnoreCase("buoy") && PermissionInterface.CheckPerm(player, "navycraft.admin")) { + } else if (split[1].equalsIgnoreCase("buoy") && PermissionInterface.CheckPerm(player, "navycraft.buoy")) { if (craft != null) { if ((split.length > 3) && split[2].equalsIgnoreCase("block")) { float blockValue = 0.33f; @@ -4107,7 +3657,7 @@ public void onPlayerEggThrow(PlayerEggThrowEvent event) { if (NavyCraft.explosiveEggsList.contains(egg)) { if (checkProtectedRegion(event.getPlayer(), egg.getLocation())) { - event.getPlayer().sendMessage(ChatColor.RED + "No AA Allowed In Dock Area"); + event.getPlayer().sendMessage(ChatColor.RED + "No Bullets Allowed In Dock Area"); return; } @@ -4313,7 +3863,7 @@ public boolean checkProtectedRegion(Player player, Location loc) { if ((player != null) && (loc != null)) { wgp = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard"); if (wgp != null) { - if (!PermissionInterface.CheckEnabledWorld(loc)) { + if (!Utils.CheckEnabledWorld(loc)) { return true; } RegionManager regionManager = wgp.getRegionManager(player.getWorld()); diff --git a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_Timer.java b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_Timer.java index 2f75c41..d54d7bb 100644 --- a/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_Timer.java +++ b/src/main/java/com/maximuspayne/navycraft/listeners/NavyCraft_Timer.java @@ -1,27 +1,22 @@ package com.maximuspayne.navycraft.listeners; -import java.io.File; import java.util.HashMap; import java.util.Timer; import java.util.TimerTask; import org.bukkit.ChatColor; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.block.Sign; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; -import com.maximuspayne.navycraft.NavyCraft; +import com.maximuspayne.navycraft.ConfigManager; import com.maximuspayne.navycraft.craft.Craft; - +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import ru.tehkode.permissions.bukkit.PermissionsEx; -@SuppressWarnings("deprecation") public class NavyCraft_Timer extends BukkitRunnable { + public static WorldGuardPlugin wgp; + public static ConfigManager cfgm; Plugin plugin; Timer timer; Craft craft; @@ -145,336 +140,6 @@ public void run() } ); } - - //Shipyard initial Sign Loading - public static void loadSHIP1() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("SHIP1World")); - int startX = syConfig.getInt("SHIP1SX"); - int endX = syConfig.getInt("SHIP1EX"); - int widthX = syConfig.getInt("SHIP1WX"); - int y = syConfig.getInt("SHIP1Y"); - int startZ = syConfig.getInt("SHIP1SZ"); - int endZ = syConfig.getInt("SHIP1EZ"); - int widthZ = syConfig.getInt("SHIP1WZ"); - for (int x = startX; x <= endX; x += widthX) { - for (int z = startZ; z >= endZ; z -= widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x, y - 1, z + 1).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - - NavyCraft_FileListener.saveSign("SHIP1", "shipyard", x, y, z); - - } - } - } - } - } - } - ); - } - - public static void loadSHIP2() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("SHIP2World")); - int startX = syConfig.getInt("SHIP2SX"); - int endX = syConfig.getInt("SHIP2EX"); - int widthX = syConfig.getInt("SHIP2WX"); - int y = syConfig.getInt("SHIP2Y"); - int startZ = syConfig.getInt("SHIP2SZ"); - int endZ = syConfig.getInt("SHIP2EZ"); - int widthZ = syConfig.getInt("SHIP2WZ"); - for (int x = startX; x <= endX; x += widthX) { - for (int z = startZ; z <= endZ; z += widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x, y - 1, z + 1).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - NavyCraft_FileListener.saveSign("SHIP2", "shipyard", x, y, z); - } - } - } - } - } - } - ); - } - - public static void loadSHIP3() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("SHIP3World")); - int startX = syConfig.getInt("SHIP3SX"); - int endX = syConfig.getInt("SHIP3EX"); - int widthX = syConfig.getInt("SHIP3WX"); - int y = syConfig.getInt("SHIP3Y"); - int startZ = syConfig.getInt("SHIP3SZ"); - int endZ = syConfig.getInt("SHIP3EZ"); - int widthZ = syConfig.getInt("SHIP3WZ"); - for (int x = startX; x >= endX; x -= widthX) { - for (int z = startZ; z <= endZ; z += widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x, y - 1, z + 1).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - NavyCraft_FileListener.saveSign("SHIP3", "shipyard", x, y, z); - } - } - } - } - } -} -); - } - public static void loadSHIP4() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("SHIP4World")); - int startX = syConfig.getInt("SHIP4SX"); - int endX = syConfig.getInt("SHIP4EX"); - int widthX = syConfig.getInt("SHIP4WX"); - int y = syConfig.getInt("SHIP4Y"); - int startZ = syConfig.getInt("SHIP4SZ"); - int endZ = syConfig.getInt("SHIP4EZ"); - int widthZ = syConfig.getInt("SHIP4WZ"); - for (int x = startX; x >= endX; x -= widthX) { - for (int z = startZ; z >= endZ; z -= widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x, y - 1, z + 1).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - - NavyCraft_FileListener.saveSign("SHIP4", "shipyard", x, y, z); - } - - } - } - } - } -} -); - } - - public static void loadSHIP5() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("SHIP5World")); - int startX = syConfig.getInt("SHIP5SX"); - int endX = syConfig.getInt("SHIP5EX"); - int widthX = syConfig.getInt("SHIP5WX"); - int y = syConfig.getInt("SHIP5Y"); - int startZ = syConfig.getInt("SHIP5SZ"); - int endZ = syConfig.getInt("SHIP5EZ"); - int widthZ = syConfig.getInt("SHIP5WZ"); - for (int x = startX; x <= endX; x += widthX) { - for (int z = startZ; z >= endZ; z -= widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x, y - 1, z + 1).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - - NavyCraft_FileListener.saveSign("SHIP5", "shipyard", x, y, z); - } - } - } - } - } -} -); - } - - public static void loadHANGAR1() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("HANGAR1World")); - int startX = syConfig.getInt("HANGAR1SX"); - int endX = syConfig.getInt("HANGAR1EX"); - int widthX = syConfig.getInt("HANGAR1WX"); - int y = syConfig.getInt("HANGAR1Y"); - int startZ = syConfig.getInt("HANGAR1SZ"); - int endZ = syConfig.getInt("HANGAR1EZ"); - int widthZ = syConfig.getInt("HANGAR1WZ"); - for (int x = startX; x >= endX; x -= widthX) { - for (int z = startZ; z >= endZ; z -= widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x + 1, y - 1, z).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - NavyCraft_FileListener.saveSign("HANGAR1", "shipyard", x, y, z); - } - } - } - } - } -} -); - } - - public static void loadHANGAR2() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("HANGAR2World")); - int startX = syConfig.getInt("HANGAR2SX"); - int endX = syConfig.getInt("HANGAR2EX"); - int widthX = syConfig.getInt("HANGAR2WX"); - int y = syConfig.getInt("HANGAR2Y"); - int startZ = syConfig.getInt("HANGAR2SZ"); - int endZ = syConfig.getInt("HANGAR2EZ"); - int widthZ = syConfig.getInt("HANGAR2WZ"); - for (int x = startX; x >= endX; x -= widthX) { - for (int z = startZ; z >= endZ; z -= widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x + 1, y - 1, z).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - NavyCraft_FileListener.saveSign("HANGAR2", "shipyard", x, y, z); - } - } - } - } - } -} -); - } - - public static void loadTANK1() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("TANK1World")); - int startX = syConfig.getInt("TANK1SX"); - int endX = syConfig.getInt("TANK1EX"); - int widthX = syConfig.getInt("TANK1WX"); - int y = syConfig.getInt("TANK1Y"); - int startZ = syConfig.getInt("TANK1SZ"); - int endZ = syConfig.getInt("TANK1EZ"); - int widthZ = syConfig.getInt("TANK1WZ"); - for (int x = startX; x <= endX; x += widthX) { - for (int z = startZ; z >= endZ; z -= widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x + 1, y - 1, z).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - NavyCraft_FileListener.saveSign("TANK1", "shipyard", x, y, z); - } - } - } - } - } -} -); - } - - public static void loadTANK2() { - NavyCraft.instance.getServer().getScheduler().scheduleSyncDelayedTask(NavyCraft.instance, new Runnable(){ - public void run() - { - File shipyarddata = new File( - NavyCraft.instance.getServer().getPluginManager().getPlugin("NavyCraft").getDataFolder(), - File.separator + "shipyarddata"); - File c = new File(shipyarddata, File.separator + "config.yml"); - FileConfiguration syConfig = YamlConfiguration.loadConfiguration(c); - World syworld = NavyCraft.instance.getServer().getWorld(syConfig.getString("TANK2World")); - int startX = syConfig.getInt("TANK2SX"); - int endX = syConfig.getInt("TANK2EX"); - int widthX = syConfig.getInt("TANK2WX"); - int y = syConfig.getInt("TANK2Y"); - int startZ = syConfig.getInt("TANK2SZ"); - int endZ = syConfig.getInt("TANK2EZ"); - int widthZ = syConfig.getInt("TANK2WZ"); - for (int x = startX; x <= endX; x += widthX) { - for (int z = startZ; z >= endZ; z -= widthZ) { - if (syworld.getBlockAt(x, y, z).getTypeId() == 63 - && syworld.getBlockAt(x + 1, y - 1, z).getTypeId() == 68) { - Block selectSignBlock = syworld.getBlockAt(x, y, z); - Sign selectSign = (Sign) selectSignBlock.getState(); - String signLine0 = selectSign.getLine(0); - - if (signLine0.equalsIgnoreCase("*claim*")) { - NavyCraft_FileListener.saveSign("TANK2", "shipyard", x, y, z); - } - } - } - } - } -} -); - } - @Override public void run() { } diff --git a/src/main/java/com/maximuspayne/shipyard/Plot.java b/src/main/java/com/maximuspayne/shipyard/Plot.java new file mode 100644 index 0000000..9f2891d --- /dev/null +++ b/src/main/java/com/maximuspayne/shipyard/Plot.java @@ -0,0 +1,13 @@ +package com.maximuspayne.shipyard; + +import org.bukkit.block.Sign; + +public class Plot { + public String name; + public Sign sign; + + public Plot (String n, Sign s) { + name = n; + sign = s; + } +} diff --git a/src/main/java/com/maximuspayne/shipyard/PlotType.java b/src/main/java/com/maximuspayne/shipyard/PlotType.java new file mode 100644 index 0000000..64ce57f --- /dev/null +++ b/src/main/java/com/maximuspayne/shipyard/PlotType.java @@ -0,0 +1,39 @@ +package com.maximuspayne.shipyard; + +import com.maximuspayne.navycraft.ConfigManager; + +public class PlotType { + public int bfr; + public int sizeX; + public int sizeY; + public int sizeZ; + public int originX; + public int originY; + public int originZ; + public boolean doFix; + public boolean dontSelect; + public String name; + + public PlotType(String n) + { + name = n; + sizeX = ConfigManager.getsyConfig().getInt("Types." + n + ".SZX"); + sizeY = ConfigManager.getsyConfig().getInt("Types." + n + ".SZY"); + sizeZ = ConfigManager.getsyConfig().getInt("Types." + n + ".SZZ"); + originX= ConfigManager.getsyConfig().getInt("Types." + n + ".OX"); + originY = ConfigManager.getsyConfig().getInt("Types." + n + ".OY"); + originZ = ConfigManager.getsyConfig().getInt("Types." + n + ".OZ"); + bfr = ConfigManager.getsyConfig().getInt("Types." + n + ".BFR"); + doFix = ConfigManager.getsyConfig().getBoolean("Types." + n + ".doFix"); + dontSelect = ConfigManager.getsyConfig().getBoolean("Types." + n + ".dontSelect"); + } + + public static void initialize() { + Shipyard.plots.clear(); + for(String num : ConfigManager.getsyConfig().getConfigurationSection("Types").getKeys(false)){ + PlotType Plot = new PlotType(num); + Shipyard.plots.add(Plot); + System.out.println(Plot.name + "added to registry"); + } + } +} diff --git a/src/main/java/com/maximuspayne/shipyard/Reward.java b/src/main/java/com/maximuspayne/shipyard/Reward.java new file mode 100644 index 0000000..341db49 --- /dev/null +++ b/src/main/java/com/maximuspayne/shipyard/Reward.java @@ -0,0 +1,12 @@ +package com.maximuspayne.shipyard; + +public class Reward { + public String name; + public int amount; + + public Reward(String n, int num) + { + name = n; + amount = num; + } +} diff --git a/src/main/java/com/maximuspayne/shipyard/Shipyard.java b/src/main/java/com/maximuspayne/shipyard/Shipyard.java new file mode 100644 index 0000000..bcbc107 --- /dev/null +++ b/src/main/java/com/maximuspayne/shipyard/Shipyard.java @@ -0,0 +1,16 @@ +package com.maximuspayne.shipyard; + +import java.util.ArrayList; +import java.util.List; + + + + +public class Shipyard{ + public static List plots = new ArrayList(); + + public static List getPlots() { + return plots; + } + +} \ No newline at end of file diff --git a/src/main/resources/Cordinates.yml b/src/main/resources/Cordinates.yml deleted file mode 100644 index d664e9c..0000000 --- a/src/main/resources/Cordinates.yml +++ /dev/null @@ -1 +0,0 @@ -#Target Sign Cords for Battles \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 191f8b8..9f2a704 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ #NavyCraft Configuration File -#Thank you to solmex for the contribution +#Written by Solmex #Defines which worlds the plugin's weapons will funciton in. EnabledWorlds: WarWorld,BattleWorld,TankSpawn @@ -35,3 +35,6 @@ StructureBlocks: 4,5,14,15,16,17,19,20,21,22,23,25,26,27,28,30,35,41,42,43,44,45 #Whether or not to create the default craft type files on plugin enable. WriteDefaultCraft: true + +#Require eggs to fire aa guns? +RequireAmmo: false diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 15346f4..956bb07 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,9 +1,10 @@ -name: ${name} -main: ${groupId}.${artifactId}.${name} -version: ${version} -authors: [Maximuspayne, keough99, Pocketkid2] -depend: [WorldGuard, WorldEdit, Vault] - +name: NavyCraft +main: com.maximuspayne.navycraft.NavyCraft +version: ${project.version} +authors: [Maximuspayne, Solmex, Keough99, PocketKid2, Premejo, SycoPrime, Yogoda] +depend: [WorldGuard,WorldEdit,Essentials,PermissionsEx] +website: https://dabblecraft.com +description: NavyCraft - Reworked version of the Old NavyCraft plugin that was abandoned. commands: navycraft: aliases: [nc] @@ -25,3 +26,4 @@ commands: description: Displays volume status message. volume help: description: Shows help for volume. + diff --git a/src/test/java/com/maximuspayne/AppTest.java b/src/test/java/com/maximuspayne/AppTest.java new file mode 100644 index 0000000..f3a8edb --- /dev/null +++ b/src/test/java/com/maximuspayne/AppTest.java @@ -0,0 +1,38 @@ +package com.maximuspayne; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/target/classes/com/maximuspayne/aimcannon/OneCannon.class b/target/classes/com/maximuspayne/aimcannon/OneCannon.class index 18ae289..84f9478 100644 Binary files a/target/classes/com/maximuspayne/aimcannon/OneCannon.class and b/target/classes/com/maximuspayne/aimcannon/OneCannon.class differ diff --git a/target/classes/com/maximuspayne/navycraft/NavyCraft.class b/target/classes/com/maximuspayne/navycraft/NavyCraft.class index 9762448..ca79bbe 100644 Binary files a/target/classes/com/maximuspayne/navycraft/NavyCraft.class and b/target/classes/com/maximuspayne/navycraft/NavyCraft.class differ diff --git a/target/classes/com/maximuspayne/navycraft/craft/Craft.class b/target/classes/com/maximuspayne/navycraft/craft/Craft.class index 69049b3..79ed1cf 100644 Binary files a/target/classes/com/maximuspayne/navycraft/craft/Craft.class and b/target/classes/com/maximuspayne/navycraft/craft/Craft.class differ diff --git a/target/classes/com/maximuspayne/navycraft/craft/CraftMover.class b/target/classes/com/maximuspayne/navycraft/craft/CraftMover.class index 770bcb5..979fdc7 100644 Binary files a/target/classes/com/maximuspayne/navycraft/craft/CraftMover.class and b/target/classes/com/maximuspayne/navycraft/craft/CraftMover.class differ diff --git a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_BlockListener.class b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_BlockListener.class index 6697eae..6ee08c8 100644 Binary files a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_BlockListener.class and b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_BlockListener.class differ diff --git a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_PlayerListener.class b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_PlayerListener.class index 9bb22bb..0c8ebbf 100644 Binary files a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_PlayerListener.class and b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_PlayerListener.class differ diff --git a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$EngineTask.class b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$EngineTask.class index de7a81a..2dc5928 100644 Binary files a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$EngineTask.class and b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$EngineTask.class differ diff --git a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$ReleaseTask.class b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$ReleaseTask.class index c57fd5e..4602942 100644 Binary files a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$ReleaseTask.class and b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$ReleaseTask.class differ diff --git a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$TakeoverCaptainTask.class b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$TakeoverCaptainTask.class index ae66d90..7d15e39 100644 Binary files a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$TakeoverCaptainTask.class and b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$TakeoverCaptainTask.class differ diff --git a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$TakeoverTask.class b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$TakeoverTask.class index 1fd570f..9523cf5 100644 Binary files a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$TakeoverTask.class and b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer$TakeoverTask.class differ diff --git a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer.class b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer.class index 3f349d9..4a40654 100644 Binary files a/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer.class and b/target/classes/com/maximuspayne/navycraft/listeners/NavyCraft_Timer.class differ diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index e69de29..261fa4c 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,83 @@ +com\maximuspayne\navycraft\teleportfix\TeleportFix_1_13.class +com\maximuspayne\navycraft\NavyCraft.class +com\maximuspayne\navycraft\listeners\NavyCraft_Timer$2.class +com\maximuspayne\shipyard\Shipyard.class +com\maximuspayne\aimcannon\OneCannon$15.class +com\maximuspayne\aimcannon\OneCannon$25.class +com\maximuspayne\navycraft\blocks\BlocksInfo$1.class +com\maximuspayne\navycraft\craft\CraftRotator.class +com\maximuspayne\aimcannon\OneCannon$2.class +com\maximuspayne\aimcannon\OneCannon.class +com\maximuspayne\navycraft\blocks\BlocksInfo$BlockInfo.class +com\maximuspayne\navycraft\listeners\NavyCraft_BlockListener$1.class +com\maximuspayne\navycraft\craft\Craft$3.class +com\maximuspayne\aimcannon\ciwsFire$1.class +com\maximuspayne\aimcannon\Weapon.class +com\maximuspayne\aimcannon\OneCannon$18.class +com\maximuspayne\aimcannon\ciwsFire.class +com\maximuspayne\navycraft\listeners\NavyCraft_BlockListener.class +com\maximuspayne\shipyard\PlotType.class +com\maximuspayne\navycraft\listeners\NavyCraft_Timer$TakeoverCaptainTask.class +com\maximuspayne\navycraft\teleportfix\TeleportFix.class +com\maximuspayne\aimcannon\OneCannon$5.class +com\maximuspayne\aimcannon\OneCannon$24.class +com\maximuspayne\shipyard\Reward.class +com\maximuspayne\aimcannon\OneCannon$16.class +com\maximuspayne\navycraft\events\NavyCraftTurnEvent.class +com\maximuspayne\aimcannon\OneCannon$8.class +com\maximuspayne\navycraft\listeners\NavyCraft_FileListener.class +com\maximuspayne\shipyard\Plot.class +com\maximuspayne\navycraft\listeners\NavyCraft_BlockListener$2.class +com\maximuspayne\aimcannon\OneCannon$12.class +com\maximuspayne\navycraft\listeners\NavyCraft_Timer$EngineTask.class +com\maximuspayne\navycraft\teleportfix\TeleportFix_1_12.class +com\maximuspayne\aimcannon\OneCannon$21.class +com\maximuspayne\navycraft\craft\CraftMover$3.class +com\maximuspayne\aimcannon\OneCannon$1.class +com\maximuspayne\navycraft\Pump.class +com\maximuspayne\navycraft\teleportfix\TeleportFix$1.class +com\maximuspayne\navycraft\listeners\NavyCraft_PlayerListener$2.class +com\maximuspayne\navycraft\NavyCraft$1.class +com\maximuspayne\navycraft\craft\CraftMover.class +com\maximuspayne\aimcannon\OneCannon$19.class +com\maximuspayne\navycraft\listeners\NavyCraft_Timer.class +com\maximuspayne\navycraft\Periscope.class +com\maximuspayne\navycraft\ConfigManager.class +com\maximuspayne\navycraft\listeners\NavyCraft_Timer$1.class +com\maximuspayne\navycraft\Utils.class +com\maximuspayne\navycraft\craft\Craft$1.class +com\maximuspayne\aimcannon\OneCannon$13.class +com\maximuspayne\aimcannon\OneCannon$23.class +com\maximuspayne\aimcannon\OneCannon$4.class +com\maximuspayne\navycraft\listeners\NavyCraft_EntityListener.class +com\maximuspayne\aimcannon\AimCannonPlayerListener.class +com\maximuspayne\aimcannon\OneCannon$7.class +com\maximuspayne\navycraft\listeners\NavyCraft_InventoryListener.class +com\maximuspayne\navycraft\craft\CraftMover$4.class +com\maximuspayne\aimcannon\OneCannon$10.class +com\maximuspayne\navycraft\craft\CraftMover$1.class +com\maximuspayne\navycraft\PermissionInterface.class +com\maximuspayne\aimcannon\OneCannon$20.class +com\maximuspayne\navycraft\listeners\NavyCraft_Timer$TakeoverTask.class +com\maximuspayne\navycraft\craft\Craft.class +com\maximuspayne\navycraft\listeners\NavyCraft_PlayerListener$1.class +com\maximuspayne\navycraft\blocks\BlockLoc.class +com\maximuspayne\aimcannon\AimCannon.class +com\maximuspayne\navycraft\listeners\NavyCraft_PlayerListener.class +com\maximuspayne\navycraft\listeners\NavyCraft_Timer$3.class +com\maximuspayne\aimcannon\OneCannon$26.class +com\maximuspayne\navycraft\blocks\BlocksInfo.class +com\maximuspayne\navycraft\craft\Craft$2.class +com\maximuspayne\navycraft\listeners\NavyCraft_Timer$ReleaseTask.class +com\maximuspayne\aimcannon\OneCannon$3.class +com\maximuspayne\aimcannon\OneCannon$22.class +com\maximuspayne\aimcannon\OneCannon$17.class +com\maximuspayne\aimcannon\OneCannon$6.class +com\maximuspayne\navycraft\craft\CraftMover$2.class +com\maximuspayne\aimcannon\OneCannon$11.class +com\maximuspayne\navycraft\blocks\DataBlock.class +com\maximuspayne\aimcannon\OneCannon$9.class +com\maximuspayne\navycraft\events\NavyCraftMoveEvent.class +com\maximuspayne\navycraft\craft\CraftType.class +com\maximuspayne\aimcannon\OneCannon$14.class +com\maximuspayne\navycraft\craft\CraftBuilder.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 64187eb..46b445a 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,27 +1,34 @@ -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\events\NavyCraftTurnEvent.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\PermissionInterface.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\Periscope.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\aimcannon\AimCannonPlayerListener.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\Craft.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\NavyCraft.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\Pump.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\events\NavyCraftMoveEvent.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\CraftBuilder.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_BlockListener.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\teleportfix\TeleportFix.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_Timer.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\aimcannon\OneCannon.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_PlayerListener.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_FileListener.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\blocks\BlockLoc.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\CraftRotator.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\blocks\DataBlock.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_InventoryListener.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\CraftType.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\CraftMover.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_EntityListener.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\teleportfix\TeleportFix_1_12.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\aimcannon\AimCannon.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\teleportfix\TeleportFix_1_13.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\aimcannon\Weapon.java -C:\Users\Adam\Documents\eclipse-workspace\NavyCraft\src\main\java\com\maximuspayne\navycraft\blocks\BlocksInfo.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_EntityListener.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_FileListener.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\teleportfix\TeleportFix_1_12.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\Pump.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\aimcannon\AimCannonPlayerListener.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_PlayerListener.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\events\NavyCraftTurnEvent.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\CraftBuilder.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\aimcannon\ciwsFire.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\CraftType.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\shipyard\Plot.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\aimcannon\Weapon.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\Craft.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\CraftMover.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\teleportfix\TeleportFix_1_13.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\blocks\BlocksInfo.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\aimcannon\OneCannon.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\blocks\DataBlock.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\craft\CraftRotator.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\shipyard\PlotType.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\shipyard\Shipyard.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\teleportfix\TeleportFix.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\ConfigManager.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_BlockListener.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\blocks\BlockLoc.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\aimcannon\AimCannon.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_Timer.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\PermissionInterface.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\listeners\NavyCraft_InventoryListener.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\NavyCraft.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\Periscope.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\Utils.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\shipyard\Reward.java +C:\Users\keoug\Documents\GitHub\NavyCraft\src\main\java\com\maximuspayne\navycraft\events\NavyCraftMoveEvent.java