diff options
author | Zenexer <Zenexer@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-03-30 04:04:57 +0000 |
---|---|---|
committer | Zenexer <Zenexer@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-03-30 04:04:57 +0000 |
commit | cbbe0d8beb749ea042283df347f6302f810b9e56 (patch) | |
tree | f1584fe391f77c648a1d7d25385ef16229b756de | |
parent | 063f5940695cd6d488d1113a90cee44acb30356c (diff) | |
parent | cb21bc4d7a67f0974c2773fdd0f5376f177c068e (diff) | |
download | Essentials-cbbe0d8beb749ea042283df347f6302f810b9e56.tar Essentials-cbbe0d8beb749ea042283df347f6302f810b9e56.tar.gz Essentials-cbbe0d8beb749ea042283df347f6302f810b9e56.tar.lz Essentials-cbbe0d8beb749ea042283df347f6302f810b9e56.tar.xz Essentials-cbbe0d8beb749ea042283df347f6302f810b9e56.zip |
Renamed 2.1 -> trunk
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1017 e251c2fe-e539-e718-e476-b85c1f46cddb
56 files changed, 1578 insertions, 2421 deletions
diff --git a/BuildAll/nbproject/build-impl.xml b/BuildAll/nbproject/build-impl.xml index dd0e3d5e1..09a0e0d9d 100644 --- a/BuildAll/nbproject/build-impl.xml +++ b/BuildAll/nbproject/build-impl.xml @@ -630,13 +630,6 @@ is divided into following sections: </antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-jar.properties}"/>
- <param location="${project.EssentialsServerlist}" name="call.subproject"/>
- <param location="${project.EssentialsServerlist}/build.xml" name="call.script"/>
- <param name="call.target" value="jar"/>
- <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
- </antcall>
- <antcall target="-maybe-call-dep">
- <param name="call.built.properties" value="${built-jar.properties}"/>
<param location="${project.EssentialsSpawn}" name="call.subproject"/>
<param location="${project.EssentialsSpawn}/build.xml" name="call.script"/>
<param name="call.target" value="jar"/>
@@ -1115,13 +1108,6 @@ is divided into following sections: </antcall>
<antcall target="-maybe-call-dep">
<param name="call.built.properties" value="${built-clean.properties}"/>
- <param location="${project.EssentialsServerlist}" name="call.subproject"/>
- <param location="${project.EssentialsServerlist}/build.xml" name="call.script"/>
- <param name="call.target" value="clean"/>
- <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
- </antcall>
- <antcall target="-maybe-call-dep">
- <param name="call.built.properties" value="${built-clean.properties}"/>
<param location="${project.EssentialsSpawn}" name="call.subproject"/>
<param location="${project.EssentialsSpawn}/build.xml" name="call.script"/>
<param name="call.target" value="clean"/>
diff --git a/BuildAll/nbproject/genfiles.properties b/BuildAll/nbproject/genfiles.properties index 7775180ad..55c9a217a 100644 --- a/BuildAll/nbproject/genfiles.properties +++ b/BuildAll/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=36e85771
+build.xml.data.CRC32=60061751
build.xml.script.CRC32=7a797370
build.xml.stylesheet.CRC32=28e38971@1.42.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=36e85771
-nbproject/build-impl.xml.script.CRC32=eaedfa13
+nbproject/build-impl.xml.data.CRC32=60061751
+nbproject/build-impl.xml.script.CRC32=5fce336c
nbproject/build-impl.xml.stylesheet.CRC32=19debb58@1.42.1.45
diff --git a/BuildAll/nbproject/private/config.properties b/BuildAll/nbproject/private/config.properties new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/BuildAll/nbproject/private/config.properties diff --git a/BuildAll/nbproject/private/private.properties b/BuildAll/nbproject/private/private.properties new file mode 100644 index 000000000..999794c06 --- /dev/null +++ b/BuildAll/nbproject/private/private.properties @@ -0,0 +1,6 @@ +compile.on.save=false
+do.depend=false
+do.jar=true
+javac.debug=true
+javadoc.preview=true
+user.properties.file=C:\\Users\\Paul\\.netbeans\\7.0beta2\\build.properties
diff --git a/BuildAll/nbproject/project.properties b/BuildAll/nbproject/project.properties index e598ad76c..6b8e235e1 100644 --- a/BuildAll/nbproject/project.properties +++ b/BuildAll/nbproject/project.properties @@ -34,7 +34,6 @@ javac.classpath=\ ${reference.EssentialsGroupBridge.jar}:\
${reference.EssentialsGroupManager.jar}:\
${reference.EssentialsProtect.jar}:\
- ${reference.EssentialsServerlist.jar}:\
${reference.EssentialsSpawn.jar}
# Space-separated list of extra javac options
javac.compilerargs=
@@ -69,14 +68,12 @@ project.EssentialsChat=../EssentialsChat project.EssentialsGroupBridge=../EssentialsGroupBridge
project.EssentialsGroupManager=../EssentialsGroupManager
project.EssentialsProtect=../EssentialsProtect
-project.EssentialsServerlist=../EssentialsServerlist
project.EssentialsSpawn=../EssentialsSpawn
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/original-EssentialsProtect.jar
-reference.EssentialsServerlist.jar=${project.EssentialsServerlist}/dist/EssentialsServerlist.jar
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
run.classpath=\
${javac.classpath}:\
diff --git a/BuildAll/nbproject/project.xml b/BuildAll/nbproject/project.xml index 8f87bed74..86e1cc4a7 100644 --- a/BuildAll/nbproject/project.xml +++ b/BuildAll/nbproject/project.xml @@ -56,14 +56,6 @@ <id>jar</id>
</reference>
<reference>
- <foreign-project>EssentialsServerlist</foreign-project>
- <artifact-type>jar</artifact-type>
- <script>build.xml</script>
- <target>jar</target>
- <clean-target>clean</clean-target>
- <id>jar</id>
- </reference>
- <reference>
<foreign-project>EssentialsSpawn</foreign-project>
<artifact-type>jar</artifact-type>
<script>build.xml</script>
diff --git a/Essentials/nbproject/private/private.properties b/Essentials/nbproject/private/private.properties new file mode 100644 index 000000000..94183418a --- /dev/null +++ b/Essentials/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=C:\\Users\\Paul\\.netbeans\\7.0beta2\\build.properties
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 73c6aade9..f9bd1d655 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -159,25 +159,23 @@ public class Essentials extends JavaPlugin pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this); + pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Monitor, this); blockListener = new EssentialsBlockListener(this); pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Monitor, this); - pm.registerEvent(Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Monitor, this); - pm.registerEvent(Type.BLOCK_INTERACT, blockListener, Priority.Monitor, this); pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Monitor, this); - pm.registerEvent(Type.BLOCK_PLACED, blockListener, Priority.Monitor, this); + pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Monitor, this); entityListener = new EssentialsEntityListener(this); - pm.registerEvent(Type.ENTITY_DAMAGED, entityListener, Priority.Lowest, this); + pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this); pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this); pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this); jail = new Jail(this.getDataFolder()); confList.add(jail); pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.High, this); - pm.registerEvent(Type.BLOCK_DAMAGED, jail, Priority.High, this); - pm.registerEvent(Type.BLOCK_INTERACT, jail, Priority.High, this); - pm.registerEvent(Type.BLOCK_PLACED, jail, Priority.High, this); + pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.High, this); + pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.High, this); attachEcoListeners(); @@ -665,8 +663,6 @@ public class Essentials extends JavaPlugin { PluginManager pm = getServer().getPluginManager(); EssentialsEcoBlockListener blockListener = new EssentialsEcoBlockListener(); - pm.registerEvent(Type.BLOCK_INTERACT, blockListener, Priority.Lowest, this); - pm.registerEvent(Type.BLOCK_RIGHTCLICKED, blockListener, Priority.High, this); pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.High, this); pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Monitor, this); } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java index 5873b3c1e..a52a6c225 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java @@ -1,21 +1,16 @@ package com.earth2me.essentials; import java.util.ArrayList; -import java.util.List; -import net.minecraft.server.InventoryPlayer; import org.bukkit.*; import org.bukkit.block.*; import org.bukkit.craftbukkit.block.CraftSign; -import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; -import org.bukkit.entity.Player; import org.bukkit.event.block.*; -import org.bukkit.inventory.ItemStack; public class EssentialsBlockListener extends BlockListener { private final Essentials parent; - private final static ArrayList<Material> protectedBlocks = new ArrayList<Material>(4); + public final static ArrayList<Material> protectedBlocks = new ArrayList<Material>(4); static { @@ -54,40 +49,6 @@ public class EssentialsBlockListener extends BlockListener } @Override - public void onBlockInteract(BlockInteractEvent event) - { - if (event.isCancelled()) return; - if (!(event.getEntity() instanceof Player)) return; - - User user = User.get((Player)event.getEntity()); - - if (!Essentials.getSettings().areSignsDisabled() && protectedBlocks.contains(event.getBlock().getType())) - { - if (!user.isAuthorized("essentials.signs.protection.override")) - { - if (isBlockProtected(event.getBlock(), user)) - { - event.setCancelled(true); - user.sendMessage("§cYou do not have permission to access that chest."); - return; - } - } - } - - if (Essentials.getSettings().getBedSetsHome() && event.getBlock().getType() == Material.BED_BLOCK) - { - try - { - user.setHome(); - user.sendMessage("§7Your home is now set to this bed."); - } - catch (Throwable ex) - { - } - } - } - - @Override public void onSignChange(SignChangeEvent event) { if (event.isCancelled()) return; @@ -147,60 +108,6 @@ public class EssentialsBlockListener extends BlockListener } @Override - public void onBlockRightClick(BlockRightClickEvent event) - { - User user = User.get(event.getPlayer()); - if (user.isJailed()) return; - if (Essentials.getSettings().areSignsDisabled()) return; - if (event.getBlock().getType() != Material.WALL_SIGN && event.getBlock().getType() != Material.SIGN_POST) - return; - Sign sign = new CraftSign(event.getBlock()); - - try - { - if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use")) - { - ItemStack item = ItemDb.get(sign.getLine(1)); - CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle())); - inv.clear(); - item.setAmount(9 * 4 * 64); - inv.addItem(item); - user.showInventory(inv); - return; - } - if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use")) - { - CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle())); - inv.clear(); - user.showInventory(inv); - return; - } - if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use")) - { - user.setHealth(20); - user.sendMessage("§7You have been healed."); - return; - } - if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail")) - { - List<String> mail = Essentials.readMail(user); - if (mail.isEmpty()) - { - user.sendMessage("§cYou do not have any mail!"); - return; - } - for (String s : mail) user.sendMessage(s); - user.sendMessage("§cTo mark your mail as read, type §c/mail clear"); - return; - } - } - catch (Throwable ex) - { - user.sendMessage("§cError: " + ex.getMessage()); - } - } - - @Override public void onBlockPlace(BlockPlaceEvent event) { Block signBlock = event.getBlockAgainst(); if (signBlock.getType() == Material.WALL_SIGN || signBlock.getType() == Material.SIGN_POST) { @@ -230,7 +137,7 @@ public class EssentialsBlockListener extends BlockListener private static final int ALLOWED = 1; private static final int NOSIGN = 2; - private int checkProtectionSign(Block block, User user) + private static int checkProtectionSign(Block block, User user) { if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) { @@ -255,7 +162,7 @@ public class EssentialsBlockListener extends BlockListener return NOSIGN; } - private Block[] getAdjacentBlocks(Block block) + private static Block[] getAdjacentBlocks(Block block) { return new Block[] { @@ -268,7 +175,7 @@ public class EssentialsBlockListener extends BlockListener }; } - private boolean isBlockProtected(Block block, User user) + public static boolean isBlockProtected(Block block, User user) { Block[] faces = getAdjacentBlocks(block); boolean protect = false; diff --git a/Essentials/src/com/earth2me/essentials/EssentialsConf.java b/Essentials/src/com/earth2me/essentials/EssentialsConf.java index 124dc6fd2..616f39a6c 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsConf.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsConf.java @@ -81,6 +81,7 @@ public class EssentialsConf extends Configuration ostr.write(buffer, 0, length); length = istr.read(buffer); } + ostr.close(); istr.close(); } catch (IOException ex) @@ -92,9 +93,7 @@ public class EssentialsConf extends Configuration { try { - if (ostr != null) { - ostr.close(); - } + ostr.close(); } catch (IOException ex) { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java index 907b836e2..885985ebc 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java @@ -1,15 +1,11 @@ package com.earth2me.essentials; -import com.earth2me.essentials.Essentials; -import com.earth2me.essentials.ItemDb; -import com.earth2me.essentials.User; import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.craftbukkit.block.CraftSign; import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockListener; -import org.bukkit.event.block.BlockRightClickEvent; import org.bukkit.event.block.SignChangeEvent; import org.bukkit.inventory.ItemStack; @@ -70,132 +66,6 @@ public class EssentialsEcoBlockListener extends BlockListener } @Override - public void onBlockRightClick(BlockRightClickEvent event) - { - if (Essentials.getSettings().areSignsDisabled()) return; - User user = User.get(event.getPlayer()); - if (event.getBlock().getType() != Material.WALL_SIGN && event.getBlock().getType() != Material.SIGN_POST) - return; - Sign sign = new CraftSign(event.getBlock()); - - if (sign.getLine(0).equals("§1[Buy]") && user.isAuthorized("essentials.signs.buy.use")) - { - try - { - int amount = Integer.parseInt(sign.getLine(1)); - ItemStack item = ItemDb.get(sign.getLine(2), amount); - int cost = Integer.parseInt(sign.getLine(3).substring(1)); - if (user.getMoney() < cost) throw new Exception("You do not have sufficient funds."); - user.takeMoney(cost); - user.getInventory().addItem(item); - user.updateInventory(); - } - catch (Throwable ex) - { - user.sendMessage("§cError: " + ex.getMessage()); - } - return; - } - - if (sign.getLine(0).equals("§1[Sell]") && user.isAuthorized("essentials.signs.sell.use")) - { - try - { - int amount = Integer.parseInt(sign.getLine(1)); - ItemStack item = ItemDb.get(sign.getLine(2), amount); - int cost = Integer.parseInt(sign.getLine(3).substring(1)); - if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, item)) throw new Exception("You do not have enough items to sell."); - user.giveMoney(cost); - InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, item); - user.updateInventory(); - } - catch (Throwable ex) - { - user.sendMessage("§cError: " + ex.getMessage()); - } - return; - } - - if (sign.getLine(0).equals("§1[Trade]") && user.isAuthorized("essentials.signs.trade.use")) - { - try - { - String[] l1 = sign.getLines()[1].split("[ :-]+"); - String[] l2 = sign.getLines()[2].split("[ :-]+"); - boolean m1 = l1[0].matches("\\$[0-9]+"); - boolean m2 = l2[0].matches("\\$[0-9]+"); - int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]); - int q2 = Integer.parseInt(m2 ? l2[0].substring(1) : l2[0]); - int r1 = Integer.parseInt(l1[m1 ? 1 : 2]); - int r2 = Integer.parseInt(l2[m2 ? 1 : 2]); - r1 = r1 - r1 % q1; - r2 = r2 - r2 % q2; - if (q1 < 1 || q2 < 1) throw new Exception("Quantities must be greater than 0."); - - ItemStack i1 = m1 || r1 <= 0? null : ItemDb.get(l1[1], r1); - ItemStack qi1 = m1 ? null : ItemDb.get(l1[1], q1); - ItemStack qi2 = m2 ? null : ItemDb.get(l2[1], q2); - - if (user.getName().equals(sign.getLines()[3].substring(2))) - { - if (m1) - { - user.giveMoney(r1); - } - else if (i1 != null) - { - user.getInventory().addItem(i1); - user.updateInventory(); - } - r1 = 0; - sign.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]) + ":" + r1); - } - else - { - if (m1) - { - if (user.getMoney() < q1) - throw new Exception("You do not have sufficient funds."); - } - else - { - if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, qi1)) - throw new Exception("You do not have " + q1 + "x " + l1[1] + "."); - } - - if (r2 < q2) throw new Exception("The trade sign does not have enough supply left."); - - if (m1) - user.takeMoney(q1); - else - InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, qi1); - - if (m2) - user.giveMoney(q2); - else - user.getInventory().addItem(qi2); - - user.updateInventory(); - - r1 += q1; - r2 -= q2; - - sign.setLine(0, "§1[Trade]"); - sign.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]) + ":" + r1); - sign.setLine(2, (m2 ? "$" + q2 : q2 + " " + l2[1]) + ":" + r2); - - user.sendMessage("§7Trade completed."); - } - } - catch (Throwable ex) - { - user.sendMessage("§cError: " + ex.getMessage()); - } - return; - } - } - - @Override public void onSignChange(SignChangeEvent event) { if (Essentials.getSettings().areSignsDisabled()) return; diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index e4f743ddd..58cddcacd 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -2,10 +2,16 @@ package com.earth2me.essentials; import java.util.List; import java.util.logging.Logger; +import net.minecraft.server.InventoryPlayer; import org.bukkit.*; import org.bukkit.block.Block; +import org.bukkit.block.Sign; +import org.bukkit.craftbukkit.block.CraftSign; +import org.bukkit.craftbukkit.inventory.CraftInventory; +import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.event.player.*; import org.bukkit.event.player.PlayerLoginEvent.Result; +import org.bukkit.inventory.ItemStack; public class EssentialsPlayerListener extends PlayerListener @@ -20,6 +26,224 @@ public class EssentialsPlayerListener extends PlayerListener this.server = parent.getServer(); } + private void onPlayerInteractEco(PlayerInteractEvent event) + { + if (Essentials.getSettings().areSignsDisabled()) return; + User user = User.get(event.getPlayer()); + if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST) + return; + Sign sign = new CraftSign(event.getClickedBlock()); + + if (sign.getLine(0).equals("§1[Buy]") && user.isAuthorized("essentials.signs.buy.use")) + { + try + { + int amount = Integer.parseInt(sign.getLine(1)); + ItemStack item = ItemDb.get(sign.getLine(2), amount); + int cost = Integer.parseInt(sign.getLine(3).substring(1)); + if (user.getMoney() < cost) throw new Exception("You do not have sufficient funds."); + user.takeMoney(cost); + user.getInventory().addItem(item); + user.updateInventory(); + } + catch (Throwable ex) + { + user.sendMessage("§cError: " + ex.getMessage()); + } + return; + } + + if (sign.getLine(0).equals("§1[Sell]") && user.isAuthorized("essentials.signs.sell.use")) + { + try + { + int amount = Integer.parseInt(sign.getLine(1)); + ItemStack item = ItemDb.get(sign.getLine(2), amount); + int cost = Integer.parseInt(sign.getLine(3).substring(1)); + if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, item)) throw new Exception("You do not have enough items to sell."); + user.giveMoney(cost); + InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, item); + user.updateInventory(); + } + catch (Throwable ex) + { + user.sendMessage("§cError: " + ex.getMessage()); + } + return; + } + + if (sign.getLine(0).equals("§1[Trade]") && user.isAuthorized("essentials.signs.trade.use")) + { + try + { + String[] l1 = sign.getLines()[1].split("[ :-]+"); + String[] l2 = sign.getLines()[2].split("[ :-]+"); + boolean m1 = l1[0].matches("\\$[0-9]+"); + boolean m2 = l2[0].matches("\\$[0-9]+"); + int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]); + int q2 = Integer.parseInt(m2 ? l2[0].substring(1) : l2[0]); + int r1 = Integer.parseInt(l1[m1 ? 1 : 2]); + int r2 = Integer.parseInt(l2[m2 ? 1 : 2]); + r1 = r1 - r1 % q1; + r2 = r2 - r2 % q2; + if (q1 < 1 || q2 < 1) throw new Exception("Quantities must be greater than 0."); + + ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], r1); + ItemStack qi1 = m1 ? null : ItemDb.get(l1[1], q1); + ItemStack qi2 = m2 ? null : ItemDb.get(l2[1], q2); + + if (user.getName().equals(sign.getLines()[3].substring(2))) + { + if (m1) + { + user.giveMoney(r1); + } + else if (i1 != null) + { + user.getInventory().addItem(i1); + user.updateInventory(); + } + r1 = 0; + sign.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]) + ":" + r1); + } + else + { + if (m1) + { + if (user.getMoney() < q1) + throw new Exception("You do not have sufficient funds."); + } + else + { + if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, qi1)) + throw new Exception("You do not have " + q1 + "x " + l1[1] + "."); + } + + if (r2 < q2) throw new Exception("The trade sign does not have enough supply left."); + + if (m1) + user.takeMoney(q1); + else + InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, qi1); + + if (m2) + user.giveMoney(q2); + else + user.getInventory().addItem(qi2); + + user.updateInventory(); + + r1 += q1; + r2 -= q2; + + sign.setLine(0, "§1[Trade]"); + sign.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]) + ":" + r1); + sign.setLine(2, (m2 ? "$" + q2 : q2 + " " + l2[1]) + ":" + r2); + + user.sendMessage("§7Trade completed."); + } + } + catch (Throwable ex) + { + user.sendMessage("§cError: " + ex.getMessage()); + } + return; + } + } + + @Override + public void onPlayerInteract(PlayerInteractEvent event) + { + if (event.isCancelled()) return; + User user = User.get(event.getPlayer()); + if (user.isJailed()) + { + event.setCancelled(true); + return; + } + + onPlayerInteractEco(event); + onPlayerInteractSigns(event); + + if (!Essentials.getSettings().areSignsDisabled() && EssentialsBlockListener.protectedBlocks.contains(event.getClickedBlock().getType())) + { + if (!user.isAuthorized("essentials.signs.protection.override")) + { + if (EssentialsBlockListener.isBlockProtected(event.getClickedBlock(), user)) + { + event.setCancelled(true); + user.sendMessage("§cYou do not have permission to access that chest."); + return; + } + } + } + + if (Essentials.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK) + { + try + { + user.setHome(); + user.sendMessage("§7Your home is now set to this bed."); + } + catch (Throwable ex) + { + } + } + } + + private void onPlayerInteractSigns(PlayerInteractEvent event) + { + User user = User.get(event.getPlayer()); + if (user.isJailed()) return; + if (Essentials.getSettings().areSignsDisabled()) return; + if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST) + return; + Sign sign = new CraftSign(event.getClickedBlock()); + + try + { + if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use")) + { + ItemStack item = ItemDb.get(sign.getLine(1)); + CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle())); + inv.clear(); + item.setAmount(9 * 4 * 64); + inv.addItem(item); + user.showInventory(inv); + return; + } + if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use")) + { + CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle())); + inv.clear(); + user.showInventory(inv); + return; + } + if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use")) + { + user.setHealth(20); + user.sendMessage("§7You have been healed."); + return; + } + if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail")) + { + List<String> mail = Essentials.readMail(user); + if (mail.isEmpty()) + { + user.sendMessage("§cYou do not have any mail!"); + return; + } + for (String s : mail) user.sendMessage(s); + user.sendMessage("§cTo mark your mail as read, type §c/mail clear"); + return; + } + } + catch (Throwable ex) + { + user.sendMessage("§cError: " + ex.getMessage()); + } + } + @Override public void onPlayerRespawn(PlayerRespawnEvent event) { @@ -99,9 +323,12 @@ public class EssentialsPlayerListener extends PlayerListener event.setFrom(loc); event.setTo(loc); - try { + try + { user.teleportToNow(loc); - } catch (Exception ex) { + } + catch (Exception ex) + { user.sendMessage(ex.getMessage()); } user.setJustPortaled(true); @@ -115,12 +342,11 @@ public class EssentialsPlayerListener extends PlayerListener } @Override - public void onPlayerQuit(PlayerEvent event) + public void onPlayerQuit(PlayerQuitEvent event) { if (!Essentials.getSettings().getReclaimSetting()) - { return; - } + User.get(event.getPlayer()).dispose(); Thread thread = new Thread(new Runnable() { @@ -149,7 +375,7 @@ public class EssentialsPlayerListener extends PlayerListener } @Override - public void onPlayerJoin(PlayerEvent event) + public void onPlayerJoin(PlayerJoinEvent event) { Essentials.getStatic().backup.onPlayerJoin(); User user = User.get(event.getPlayer()); @@ -186,7 +412,7 @@ public class EssentialsPlayerListener extends PlayerListener User user = User.get(event.getPlayer()); if (event.getResult() != Result.ALLOWED) return; - + if (user.isBanned()) { event.disallow(Result.KICK_BANNED, "The Ban Hammer has spoken!"); @@ -215,7 +441,7 @@ public class EssentialsPlayerListener extends PlayerListener } @Override - public void onPlayerTeleport(PlayerMoveEvent event) + public void onPlayerTeleport(PlayerTeleportEvent event) { User user = User.get(event.getPlayer()); if (user.currentJail == null || user.currentJail.isEmpty()) diff --git a/Essentials/src/com/earth2me/essentials/Jail.java b/Essentials/src/com/earth2me/essentials/Jail.java index 0ed2774e2..5e0dd87ee 100644 --- a/Essentials/src/com/earth2me/essentials/Jail.java +++ b/Essentials/src/com/earth2me/essentials/Jail.java @@ -7,23 +7,25 @@ import java.util.Map; import java.util.logging.Logger; import org.bukkit.Location; import org.bukkit.World; -import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockDamageEvent; -import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockPlaceEvent; -public class Jail extends BlockListener implements IConf { + +public class Jail extends BlockListener implements IConf +{ private static final Logger logger = Logger.getLogger("Minecraft"); private EssentialsConf config; - public Jail(File dataFolder) { + public Jail(File dataFolder) + { config = new EssentialsConf(new File(dataFolder, "jail.yml")); config.load(); } - public void setJail(Location loc, String jailName) throws Exception { + public void setJail(Location loc, String jailName) throws Exception + { Map<String, Object> map = new HashMap<String, Object>(); map.put("world", loc.getWorld().getName()); map.put("x", loc.getX()); @@ -35,8 +37,10 @@ public class Jail extends BlockListener implements IConf { config.save(); } - public Location getJail(String jailName) throws Exception { - if (config.getProperty(jailName.toLowerCase()) == null) { + public Location getJail(String jailName) throws Exception + { + if (config.getProperty(jailName.toLowerCase()) == null) + { throw new Exception("That jail does not exist"); } @@ -45,10 +49,12 @@ public class Jail extends BlockListener implements IConf { double x = config.getDouble(jailName + ".x", 0); // wh.spawnX double y = config.getDouble(jailName + ".y", 0); // wh.spawnY double z = config.getDouble(jailName + ".z", 0); // wh.spawnZ - float yaw = (float) config.getDouble(jailName + ".yaw", 0); - float pitch = (float) config.getDouble(jailName + ".pitch", 0); - for (World w : Essentials.getStatic().getServer().getWorlds()) { - if (w.getName().equalsIgnoreCase(world)) { + float yaw = (float)config.getDouble(jailName + ".yaw", 0); + float pitch = (float)config.getDouble(jailName + ".pitch", 0); + for (World w : Essentials.getStatic().getServer().getWorlds()) + { + if (w.getName().equalsIgnoreCase(world)) + { jWorld = w; break; } @@ -57,41 +63,34 @@ public class Jail extends BlockListener implements IConf { return new Location(jWorld, x, y, z, yaw, pitch); } - public void sendToJail(User user, String jail) throws Exception { - user.teleportTo(getJail(jail)); + public void sendToJail(User user, String jail) throws Exception + { + user.teleport(getJail(jail)); user.currentJail = jail; } - public void delJail(String jail) throws Exception { + public void delJail(String jail) throws Exception + { config.removeProperty(jail.toLowerCase()); config.save(); } - public List<String> getJails() throws Exception { + public List<String> getJails() throws Exception + { return config.getKeys(null); } - public void reloadConfig() { + public void reloadConfig() + { config.load(); } - + @Override public void onBlockBreak(BlockBreakEvent event) { User user = User.get(event.getPlayer()); - if (user.isJailed()) { - event.setCancelled(true); - } - } - - @Override - public void onBlockInteract(BlockInteractEvent event) - { - if (!event.isPlayer()) { - return; - } - User user = User.get((Player)event.getEntity()); - if (user.isJailed()) { + if (user.isJailed()) + { event.setCancelled(true); } } @@ -100,15 +99,18 @@ public class Jail extends BlockListener implements IConf { public void onBlockPlace(BlockPlaceEvent event) { User user = User.get(event.getPlayer()); - if (user.isJailed()) { + if (user.isJailed()) + { event.setCancelled(true); } } @Override - public void onBlockDamage(BlockDamageEvent event) { + public void onBlockDamage(BlockDamageEvent event) + { User user = User.get(event.getPlayer()); - if (user.isJailed()) { + if (user.isJailed()) + { event.setCancelled(true); } } diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index f1bac2ae4..5fffdfa99 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -283,4 +283,69 @@ public class OfflinePlayer implements Player public void sendRawMessage(String string) { throw new UnsupportedOperationException("Not supported yet."); } + + public Location getCompassTarget() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public int getMaximumNoDamageTicks() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void setMaximumNoDamageTicks(int i) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public int getLastDamage() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void setLastDamage(int i) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public int getNoDamageTicks() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void setNoDamageTicks(int i) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public boolean teleport(Location lctn) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public boolean teleport(Entity entity) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public Entity getPassenger() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public boolean setPassenger(Entity entity) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public boolean isEmpty() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + public boolean eject() + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java index cf3a6db58..0de6f669e 100644 --- a/Essentials/src/com/earth2me/essentials/PlayerWrapper.java +++ b/Essentials/src/com/earth2me/essentials/PlayerWrapper.java @@ -154,15 +154,15 @@ public class PlayerWrapper implements Player } @Override - public void teleportTo(Location lctn) + public boolean teleport(Location lctn) { - base.teleportTo(lctn); + return base.teleport(lctn); } @Override - public void teleportTo(Entity entity) + public boolean teleport(Entity entity) { - base.teleportTo(entity); + return base.teleport(entity); } @Override @@ -329,7 +329,88 @@ public class PlayerWrapper implements Player return base.getEyeLocation(); } + @Override public void sendRawMessage(String string) { base.sendRawMessage(string); } + + @Override + public Location getCompassTarget() + { + return base.getCompassTarget(); + } + + @Override + public int getMaximumNoDamageTicks() + { + return base.getMaximumNoDamageTicks(); + } + + @Override + public void setMaximumNoDamageTicks(int i) + { + base.setMaximumNoDamageTicks(i); + } + + @Override + public int getLastDamage() + { + return base.getLastDamage(); + } + + @Override + public void setLastDamage(int i) + { + base.setLastDamage(i); + } + + @Override + public int getNoDamageTicks() + { + return base.getNoDamageTicks(); + } + + @Override + public void setNoDamageTicks(int i) + { + base.setNoDamageTicks(i); + } + + @Override + public Entity getPassenger() + { + return base.getPassenger(); + } + + @Override + public boolean setPassenger(Entity entity) + { + return base.setPassenger(entity); + } + + @Override + public boolean isEmpty() + { + return base.isEmpty(); + } + + @Override + public boolean eject() + { + return base.eject(); + } + + @Override + @Deprecated + public void teleportTo(Location lctn) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + @Deprecated + public void teleportTo(Entity entity) + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 0853975ca..472015997 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -91,7 +91,7 @@ public class User extends PlayerExtension implements Comparable<User> public void respawn(Spawn spawn, final String chargeFor) throws Exception { - teleportTo(getSafeDestination(spawn.getSpawn(getGroup())), chargeFor); + teleport(getSafeDestination(spawn.getSpawn(getGroup())), chargeFor); } private User update(Player base) @@ -383,7 +383,7 @@ public class User extends PlayerExtension implements Comparable<User> cancelTeleport(false); } - public void teleportTo(final Location loc, final String chargeFor) + public boolean teleport(final Location loc, final String chargeFor) { final long delay = Essentials.getSettings().getTeleportDelay(); @@ -393,13 +393,13 @@ public class User extends PlayerExtension implements Comparable<User> { if (chargeFor != null) charge(chargeFor); teleportCooldown(false); - teleportToNow(loc); + return teleportToNow(loc); } catch (Throwable ex) { sendMessage("§cError: " + ex.getMessage()); + return false; } - return; } cancelTeleport(); @@ -424,15 +424,16 @@ public class User extends PlayerExtension implements Comparable<User> cancelTeleport(); } }, 10, 10); + return true; } @Override - public void teleportTo(final Location loc) + public boolean teleport(final Location loc) { - teleportTo(loc, null); + return teleport(loc, null); } - public void teleportTo(final Entity entity, final String chargeFor) + public boolean teleport(final Entity entity, final String chargeFor) { final long delay = Essentials.getSettings().getTeleportDelay(); @@ -442,13 +443,13 @@ public class User extends PlayerExtension implements Comparable<User> { if (chargeFor != null) charge(chargeFor); teleportCooldown(false); - teleportToNow(entity); + return teleportToNow(entity); } catch (Throwable ex) { sendMessage("§cError: " + ex.getMessage()); + return false; } - return; } cancelTeleport(); @@ -473,12 +474,13 @@ public class User extends PlayerExtension implements Comparable<User> cancelTeleport(); } }, 10, 10); + return true; } @Override - public void teleportTo(final Entity entity) + public boolean teleport(final Entity entity) { - teleportTo(entity, null); + return teleport(entity, null); } public Location getHome() throws Exception @@ -579,23 +581,23 @@ public class User extends PlayerExtension implements Comparable<User> teleportToHome(null); } - public void teleportToNow(Location loc) throws Exception + public boolean teleportToNow(Location loc) throws Exception { cancelTeleport(); lastLocation = getLocation(); - getBase().teleportTo(getSafeDestination(loc)); + return getBase().teleport(getSafeDestination(loc)); } - public void teleportToNow(Entity entity) + public boolean teleportToNow(Entity entity) { cancelTeleport(); lastLocation = getLocation(); - getBase().teleportTo(entity); + return getBase().teleport(entity); } public void teleportBack(final String chargeFor) { - teleportTo(lastLocation, chargeFor); + teleport(lastLocation, chargeFor); } public void teleportBack() @@ -667,7 +669,7 @@ public class User extends PlayerExtension implements Comparable<User> { lastLocation = getLocation(); Location loc = Essentials.getWarps().getWarp(warp); - teleportTo(loc, chargeFor); + teleport(loc, chargeFor); sendMessage("§7Warping to " + warp + "."); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java index b26ffd82a..b753fc4b3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java @@ -45,6 +45,6 @@ public class Commandjump extends EssentialsCommand } user.canAfford(this); - user.teleportTo(loc, this.getName()); + user.teleport(loc, this.getName()); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java index cd0a6b013..6b3deaf1d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java @@ -21,6 +21,11 @@ public class Commandme extends EssentialsCommand @Override public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception { + if (user.isMuted()) + { user.sendMessage("§7Your voice has been silenced"); + return; + } + if (args.length < 1) { user.sendMessage("§cUsage: /me [description]"); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java index 7776e7bcb..a928701a2 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java @@ -20,7 +20,7 @@ public class Commandtop extends EssentialsCommand int topZ = user.getLocation().getBlockZ(); int topY = user.getWorld().getHighestBlockYAt(topX, topZ); user.charge(this); - user.teleportTo(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), this.getName()); + user.teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), this.getName()); user.sendMessage("§7Teleporting to top."); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java index 82f8e8bd2..a36a7e415 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java @@ -28,7 +28,7 @@ public class Commandtp extends EssentialsCommand if (!p.isTeleEnabled()) throw new Exception(p.getDisplayName() + " has teleportation disabled."); user.sendMessage("§7Teleporting..."); user.canAfford(this); - user.teleportTo(p, this.getName()); + user.teleport(p, this.getName()); break; case 2: diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 03907fead..84acdf82c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -27,14 +27,14 @@ public class Commandtpaccept extends EssentialsCommand user.canAfford(this); user.sendMessage("§7Teleport request accepted."); p.sendMessage("§7Teleport request accepted."); - user.teleportTo(p, this.getName()); + user.teleport(p, this.getName()); } else { user.canAfford(this); user.sendMessage("§7Teleport request accepted."); p.sendMessage("§7Teleport request accepted."); - p.teleportTo(user, this.getName()); + p.teleport(user, this.getName()); } } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java index f352da37d..031735e9a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java @@ -37,6 +37,6 @@ public class Commandtppos extends EssentialsCommand user.canAfford(this); user.teleportCooldown(); user.sendMessage("§7Teleporting..."); - user.teleportTo(user.getSafeDestination(l), this.getName()); + user.teleport(user.getSafeDestination(l), this.getName()); } }
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java index 17a2c57b1..508e69a58 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java @@ -34,9 +34,9 @@ public class Commandwhois extends EssentialsCommand sender.sendMessage(""); sender.sendMessage(u.getDisplayName() + " is " + u.getName()); sender.sendMessage(ChatColor.BLUE + " - Health: " + u.getHealth() + "/20"); - sender.sendMessage(ChatColor.BLUE + " - Location: (" + u.getLocation().getWorld().getName() + ", " + u.getLocation().getBlockX() + ", " + u.getLocation().getBlockY() + ", " + u.getLocation().getBlockZ() + ")"); + sender.sendMessage(ChatColor.BLUE + " - Location: (" + u.getLocation().getBlockX() + ", " + u.getLocation().getBlockY() + ", " + u.getLocation().getBlockZ() + ")"); if (!parent.getConfiguration().getBoolean("disable-eco", false)) sender.sendMessage(ChatColor.BLUE + " - Money: $" + u.getMoney()); - sender.sendMessage(ChatColor.BLUE + " - Status: " + (parent.away.contains(u) ? "§cAway§f" : "Available")); + sender.sendMessage(ChatColor.BLUE + " - Status: " + (parent.away.contains(u) ? "§cAway" : "Available")); sender.sendMessage(ChatColor.BLUE + " - IP Address: " + u.getAddress().getAddress().toString()); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java index 41a2d270d..8f3ad45e7 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java @@ -62,6 +62,6 @@ public class Commandworld extends EssentialsCommand user.canAfford(this); user.teleportCooldown(); - user.teleportTo(loc, this.getName()); + user.teleport(loc, this.getName()); } } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 9872678a3..7da7426f6 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -268,7 +268,7 @@ protect: mysqlDb: 'jdbc:mysql://localhost:3306/minecraft' # For which block types would you like to be alerted? - # You can find a list of IDs in plugins/Essentials/Items.db after loading Essentials for the first time. + # You can find a list of IDs in plugins/Essentials/Items.csv after loading Essentials for the first time. alert: # 10: lava # 11: still lava @@ -347,7 +347,7 @@ protect: # Should damage via lava be disabled? Items that fall into lava will still burn to a crisp. ;) lavadmg: false - # Should arrows cause damage? + # Should arrow damage be disabled projectiles: false # This will disable damage from touching cacti. diff --git a/Essentials/src/items.csv b/Essentials/src/items.csv index a67ba6fa1..3bf204167 100644 --- a/Essentials/src/items.csv +++ b/Essentials/src/items.csv @@ -28,62 +28,14 @@ ironore,15,0 iore,15,0
coalore,16,0
core,16,0
-tree,17,0
log,17,0
trunk,17,0
wood,17,0
-redtree,17,1
-redlog,17,1
-redtrunk,17,1
-redwood,17,1
-darktree,17,1
-darklog,17,1
-darktrunk,17,1
-darkwood,17,1
-blacktree,17,1
-blacklog,17,1
-blacktrunk,17,1
-blackwood,17,1
-rtree,17,1
-rlog,17,1
-rtrunk,17,1
-rwood,17,1
-dtree,17,1
-dlog,17,1
-dtrunk,17,1
-dwood,17,1
-bltree,17,1
-bllog,17,1
-bltrunk,17,1
-blwood,17,1
-birchtree,17,2
-birchlog,17,2
-birchtrunk,17,2
-birchwood,17,2
-pandatree,17,2
-pandalog,17,2
-pandatrunk,17,2
-pandawood,17,2
-whitetree,17,2
-whitelog,17,2
-whitetrunk,17,2
-whitewood,17,2
-bitree,17,2
-bilog,17,2
-bitrunk,17,2
-biwood,17,2
-btree,17,2
-blog,17,2
-btrunk,17,2
-bwood,17,2
-ptree,17,2
-plog,17,2
-ptrunk,17,2
-pwood,17,2
-wtree,17,2
-wlog,17,2
-wtrunk,17,2
-wwood,17,2
+redwood,5,1
+rwood,5,1
+birchwood,5,2
+birch,5,2
+bwood,5,2
leaves,18,0
sponge,19,0
glass,20,0
diff --git a/EssentialsChat/nbproject/private/private.properties b/EssentialsChat/nbproject/private/private.properties new file mode 100644 index 000000000..94183418a --- /dev/null +++ b/EssentialsChat/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=C:\\Users\\Paul\\.netbeans\\7.0beta2\\build.properties
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java index 890187ee3..e351cc865 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java @@ -2,10 +2,7 @@ package com.earth2me.essentials.chat; import com.earth2me.essentials.Essentials; import org.bukkit.Server; -import org.bukkit.event.player.PlayerChatEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerListener; -import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.*; public class EssentialsChatPlayerListener extends PlayerListener @@ -19,7 +16,7 @@ public class EssentialsChatPlayerListener extends PlayerListener @Override @SuppressWarnings("CallToThreadDumpStack") - public void onPlayerJoin(PlayerEvent event) + public void onPlayerJoin(PlayerJoinEvent event) { try { diff --git a/EssentialsGroupBridge/nbproject/private/private.properties b/EssentialsGroupBridge/nbproject/private/private.properties new file mode 100644 index 000000000..94183418a --- /dev/null +++ b/EssentialsGroupBridge/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=C:\\Users\\Paul\\.netbeans\\7.0beta2\\build.properties
diff --git a/EssentialsGroupManager/nbproject/private/private.properties b/EssentialsGroupManager/nbproject/private/private.properties new file mode 100644 index 000000000..94183418a --- /dev/null +++ b/EssentialsGroupManager/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=C:\\Users\\Paul\\.netbeans\\7.0beta2\\build.properties
diff --git a/EssentialsGroupManager/src/groups.yml b/EssentialsGroupManager/src/groups.yml index e5650b54d..73c55b880 100644 --- a/EssentialsGroupManager/src/groups.yml +++ b/EssentialsGroupManager/src/groups.yml @@ -1,144 +1,172 @@ -# "For a more advanced configuration example utilizing the advanced features of GroupManager, se http://pastebin.com/MeCpqVZv" -groups: - Default: - default: true - permissions: - - essentials.help - - essentials.helpop - - essentials.list - - essentials.motd - - essentials.rules - - essentials.spawn - inheritance: [] - info: - prefix: '&e' - build: false - suffix: '' - SemiAdmin: - default: false - permissions: - - essentials.clearinventory - - essentials.cooldown.bypass - - essentials.deljail - - essentials.give - - essentials.god - - essentials.heal - - essentials.heal.others - - essentials.invsee - - essentials.item - - essentials.jails - - essentials.kit.* - - essentials.mute - - essentials.reloadall - - essentials.setjail - - essentials.signs.disposal.create - - essentials.spawmob - - essentials.togglejail - - groupmanager.* - inheritance: - - moderator - info: - prefix: '&1' - build: true - suffix: '' - Builder: - default: false - permissions: - - essentials.afk - - essentials.back.death - - essentials.balance - - essentials.chat.shout - - essentials.home - - essentials.kit - - essentials.kit.tools - - essentials.mail - - essentials.mail.send - - essentials.me - - essentials.msg - - essentials.nick - - essentials.pay - - essentials.portal - - essentials.protect - - essentials.sell - - essentials.sethome - - essentials.signs.buy.use - - essentials.signs.disposal.use - - essentials.signs.free.use - - essentials.signs.heal.use - - essentials.signs.mail.create - - essentials.signs.mail.use - - essentials.signs.protection.create - - essentials.signs.protection.use - - essentials.signs.sell.use - - essentials.signs.trade.create - - essentials.signs.trade.use - - essentials.tpa - - essentials.tpaccept - - essentials.tpahere - - essentials.tpdeny - - essentials.warp - - essentials.warp.list - - essentials.worth - inheritance: - - default - info: - prefix: '&5' - build: true - suffix: '' - Moderator: - default: false - permissions: - - essentials.back - - essentials.ban - - essentials.banip - - essentials.broadcast - - essentials.compass - - essentials.delwarp - - essentials.depth - - essentials.eco - - essentials.getpos - - essentials.jump - - essentials.kick - - essentials.kill - - essentials.setwarp - - essentials.time - - essentials.togglejail - - essentials.top - - essentials.tp - - essentials.tpa - - essentials.tpaaccept - - essentials.tpahere - - essentials.tpdeny - - essentials.tphere - - essentials.tpo - - essentials.tpohere - - essentials.tppos - - essentials.tptoggle - - essentials.unban - - essentials.unbanip - - essentials.whois - - essentials.world - - groupmanager.listgroups - - groupmanager.mandemote - - groupmanager.manload - - groupmanager.manpromote - - groupmanager.mansave - - groupmanager.manselect - - groupmanager.manuadd - - groupmanager.manudel - inheritance: - - builder - info: - prefix: '&9' - build: true - suffix: '' - Admin: - default: false - permissions: - - '*' - inheritance: - - semiadmin - info: - prefix: '&4' - build: true - suffix: '' +groups:
+ Default:
+ default: true
+ permissions:
+ - essentials.help
+ - essentials.home
+ - essentials.motd
+ - essentials.sethome
+ - essentials.spawn
+ inheritance: []
+ info:
+ prefix: ''
+ build: false
+ suffix: ''
+ SemiAdmin:
+ default: false
+ permissions:
+ - +groupmanager.mandemote
+ - +groupmanager.manpromote
+ - -groupmanager.*
+ - '*'
+ inheritance:
+ - moderator
+ info:
+ prefix: '&c'
+ build: true
+ suffix: SemiAdmin
+ RedFaction:
+ default: false
+ permissions: []
+ inheritance:
+ - peasant
+ info:
+ prefix: '&c'
+ roles-category: faction
+ build: true
+ suffix: Red
+ Farmer:
+ default: false
+ permissions:
+ - essentials.kit
+ - essentials.kit.farmer
+ - essentials.spawnmob
+ inheritance: []
+ info:
+ roles-requirement:
+ - BlueFaction
+ - RedFaction
+ prefix: ''
+ roles-category: job
+ build: false
+ suffix: ''
+ Healer:
+ default: false
+ permissions:
+ - essentials.kit
+ - essentials.kit.healer
+ - essentials.heal
+ inheritance: []
+ info:
+ roles-requirement:
+ - BlueFaction
+ - RedFaction
+ prefix: ''
+ roles-category: job
+ build: false
+ suffix: ''
+ Fighter:
+ default: false
+ permissions:
+ - essentials.kit
+ - essentials.kit.fighter
+ inheritance: []
+ info:
+ prefix: ''
+ roles-category: skill
+ build: false
+ suffix: ''
+ Admin:
+ default: false
+ permissions:
+ - '*'
+ inheritance:
+ - semiadmin
+ info:
+ prefix: ''
+ build: true
+ suffix: ''
+ Miner:
+ default: false
+ permissions:
+ - essentials.kit
+ - essentials.kit.miner
+ - flashlight.regular
+ inheritance: []
+ info:
+ roles-requirement:
+ - BlueFaction
+ - RedFaction
+ prefix: ''
+ roles-category: job
+ build: false
+ suffix: ''
+ FlyingMan:
+ default: false
+ permissions:
+ - nocheat.moving
+ inheritance: []
+ info:
+ roles-requirement: Fighter&SuperCart
+ prefix: ''
+ roles-category: skill
+ build: false
+ suffix: ''
+ Peasant:
+ default: false
+ permissions:
+ - roles.joinrole
+ - roles.leaverole
+ - roles.myroles
+ inheritance:
+ - default
+ info:
+ prefix: '&e'
+ build: true
+ suffix: Peasant
+ BlueFaction:
+ default: false
+ permissions: []
+ inheritance:
+ - peasant
+ info:
+ prefix: '&d'
+ roles-category: faction
+ build: true
+ suffix: Blue
+ Railer:
+ default: false
+ permissions:
+ - essentials.kit
+ - essentials.kit.railer
+ inheritance: []
+ info:
+ roles-requirement: Miner
+ prefix: ''
+ roles-category: subjob
+ build: false
+ suffix: ''
+ SuperCart:
+ default: false
+ permissions:
+ - minecartmania.*
+ inheritance: []
+ info:
+ roles-requirement: Railer
+ prefix: ''
+ roles-category: skill
+ build: false
+ suffix: ''
+ Moderator:
+ default: false
+ permissions:
+ - essentials.tp
+ - essentials.tphere
+ - essentials.item
+ - essentials.give
+ inheritance:
+ - default
+ info:
+ prefix: '&c'
+ build: true
+ suffix: Mod
\ No newline at end of file diff --git a/EssentialsGroupManager/src/users.yml b/EssentialsGroupManager/src/users.yml index c3324f0c0..5645c5d23 100644 --- a/EssentialsGroupManager/src/users.yml +++ b/EssentialsGroupManager/src/users.yml @@ -1,15 +1,59 @@ -# "For a more advanced configuration example utilizing the advanced features of GroupManager, see http://pastebin.com/a8ZA0j5G" -users: - kimkandor: - subgroups: [] - permissions: [] - group: Admin - mudzereli: - subgroups: [] - permissions: [] - group: Builder - zenexer: - subgroups: [] - permissions: [] - group: Admin - +users:
+ aMiner:
+ subgroups:
+ - Miner
+ permissions: []
+ group: BlueFaction
+ info:
+ prefix: '&d'
+ suffix: Miner
+ gmcouto:
+ subgroups: []
+ permissions: []
+ group: SemiAdmin
+ tempRailer:
+ subgroups:
+ - Miner
+ - Railer
+ permissions: []
+ group: BlueFaction
+ info:
+ prefix: '&d'
+ suffix: Miner
+ anjocaido:
+ subgroups: []
+ permissions: []
+ group: Admin
+ info:
+ prefix: '&c'
+ suffix: King
+ aFarmer:
+ subgroups:
+ - Farmer
+ permissions: []
+ group: RedFaction
+ info:
+ prefix: '&d'
+ suffix: Farmer
+ zenexer:
+ subgroups: []
+ permissions:
+ - essentials.god
+ group: Moderator
+ Teste:
+ subgroups:
+ - Miner
+ - Railer
+ - SuperCart
+ - Fighter
+ - FlyingMan
+ permissions: []
+ group: BlueFaction
+ aHealer:
+ subgroups:
+ - Healer
+ permissions: []
+ group: RedFaction
+ info:
+ prefix: '&d'
+ suffix: Healer
diff --git a/EssentialsProtect/nbproject/private/private.properties b/EssentialsProtect/nbproject/private/private.properties new file mode 100644 index 000000000..94183418a --- /dev/null +++ b/EssentialsProtect/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=C:\\Users\\Paul\\.netbeans\\7.0beta2\\build.properties
diff --git a/EssentialsProtect/nbproject/project.properties b/EssentialsProtect/nbproject/project.properties index dcce6d152..3f2895ed5 100644 --- a/EssentialsProtect/nbproject/project.properties +++ b/EssentialsProtect/nbproject/project.properties @@ -26,6 +26,7 @@ dist.jar=${dist.dir}/original-EssentialsProtect.jar dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
+file.reference.c3p0-0.9.1.2.jar=..\\lib\\c3p0-0.9.1.2.jar
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
file.reference.mysql.jar=..\\lib\\mysql.jar
file.reference.sqlite.jar=..\\lib\\sqlite.jar
@@ -37,7 +38,8 @@ javac.classpath=\ ${reference.Essentials.jar}:\
${file.reference.mysql.jar}:\
${file.reference.sqlite.jar}:\
- ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}
+ ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
+ ${file.reference.c3p0-0.9.1.2.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index a2c577789..d6869519b 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -1,7 +1,13 @@ package com.earth2me.essentials.protect; import com.earth2me.essentials.Essentials; +import com.earth2me.essentials.IConf; import com.earth2me.essentials.User; +import com.earth2me.essentials.protect.data.IProtectedBlock; +import com.earth2me.essentials.protect.data.ProtectedBlockMemory; +import com.earth2me.essentials.protect.data.ProtectedBlockMySQL; +import com.earth2me.essentials.protect.data.ProtectedBlockSQLite; +import java.beans.PropertyVetoException; import java.util.ArrayList; import java.util.HashMap; import java.util.logging.Level; @@ -15,7 +21,7 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; -public class EssentialsProtect extends JavaPlugin +public class EssentialsProtect extends JavaPlugin implements IConf { private EssentialsProtectBlockListener blockListener = null; private EssentialsProtectPlayerListener playerListener = null; @@ -33,6 +39,8 @@ public class EssentialsProtect extends JavaPlugin public static ArrayList onUseAlert = null; public static ArrayList onBreakAlert = null; + private IProtectedBlock storage = null; + private static EssentialsProtect instance = null; public EssentialsProtect() { @@ -42,27 +50,27 @@ public class EssentialsProtect extends JavaPlugin { PluginManager pm = this.getServer().getPluginManager(); Essentials ess = (Essentials)pm.getPlugin("Essentials"); - if (!ess.isEnabled()) + if (!ess.isEnabled()) { pm.enablePlugin(ess); + } + + instance = this; + reloadConfig(); playerListener = new EssentialsProtectPlayerListener(this); blockListener = new EssentialsProtectBlockListener(this); entityListener = new EssentialsProtectEntityListener(this); - pm.registerEvent(Type.PLAYER_ITEM, playerListener, Priority.Low, this); - // Why is this commented? - //pm.registerEvent(Type.BLOCK_DAMAGED, blockListener, Priority.High, this); - pm.registerEvent(Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Low, this); - pm.registerEvent(Type.BLOCK_PLACED, blockListener, Priority.Highest, this); - pm.registerEvent(Type.BLOCK_INTERACT, blockListener, Priority.Highest, this); - pm.registerEvent(Type.BLOCK_FLOW, blockListener, Priority.Highest, this); + pm.registerEvent(Type.PLAYER_PICKUP_ITEM, playerListener, Priority.Low, this); + pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, this); + pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Highest, this); + pm.registerEvent(Type.BLOCK_FROMTO, blockListener, Priority.Highest, this); pm.registerEvent(Type.BLOCK_IGNITE, blockListener, Priority.Highest, this); pm.registerEvent(Type.BLOCK_BURN, blockListener, Priority.Highest, this); pm.registerEvent(Type.ENTITY_EXPLODE, entityListener, Priority.Highest, this); - pm.registerEvent(Type.ENTITY_DAMAGED, entityListener, Priority.Highest, this); + pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Highest, this); pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Highest, this); pm.registerEvent(Type.CREATURE_SPAWN, entityListener, Priority.Highest, this); - loadSettings(); if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion())) { logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version."); } @@ -94,8 +102,23 @@ public class EssentialsProtect extends JavaPlugin onBreakAlert = null; } - public static void loadSettings() + public void alert(User user, String item, String type) { + Location loc = user.getLocation(); + for (Player p : this.getServer().getOnlinePlayers()) + { + User alertUser = User.get(p); + if (alertUser.isAuthorized("essentials.protect.alerts")) + alertUser.sendMessage(ChatColor.DARK_AQUA + "[" + user.getName() + "] " + ChatColor.WHITE + type + ChatColor.GOLD + item + " at: " + formatCoords(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + } + } + + public static String formatCoords(int x, int y, int z) + { + return x + "," + y + "," + z; + } + + public void reloadConfig() { dataSettings = Essentials.getSettings().getEpDBSettings(); genSettings = Essentials.getSettings().getEpSettings(); guardSettings = Essentials.getSettings().getEpGuardSettings(); @@ -106,17 +129,26 @@ public class EssentialsProtect extends JavaPlugin onUseAlert = Essentials.getSettings().getEpAlertOnUse(); onBreakAlert = Essentials.getSettings().getEpAlertOnBreak(); playerSettings = Essentials.getSettings().getEpPlayerSettings(); - EssentialsProtectData.createSqlTable(); - } - - public void alert(User user, String item, String type) - { - Location loc = user.getLocation(); - for (Player p : this.getServer().getOnlinePlayers()) - { - User alertUser = User.get(p); - if (alertUser.isAuthorized("essentials.protect.alerts")) - alertUser.sendMessage(ChatColor.DARK_AQUA + "[" + user.getName() + "] " + ChatColor.WHITE + type + ChatColor.GOLD + item + " at: " + EssentialsProtectData.formatCoords(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())); + + if (dataSettings.get("protect.datatype").equals("mysql")) { + try { + storage = new ProtectedBlockMySQL(dataSettings.get("protect.mysqlDb"), dataSettings.get("protect.username"), dataSettings.get("protect.password")); + } catch (PropertyVetoException ex) { + logger.log(Level.SEVERE, null, ex); + } + } else { + try { + storage = new ProtectedBlockSQLite("jdbc:sqlite:plugins/Essentials/EssentialsProtect.db"); + } catch (PropertyVetoException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (genSettings.get("protect.memstore")) { + storage = new ProtectedBlockMemory(storage); } } + + public static IProtectedBlock getStorage() { + return EssentialsProtect.instance.storage; + } } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java index 43b508a58..2028edf42 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java @@ -2,28 +2,24 @@ package com.earth2me.essentials.protect; import com.earth2me.essentials.Essentials; import com.earth2me.essentials.User; -import org.bukkit.ChatColor; +import java.util.ArrayList; +import java.util.List; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockIgniteEvent; -import org.bukkit.event.block.BlockInteractEvent; import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.BlockRightClickEvent; import org.bukkit.inventory.ItemStack; public class EssentialsProtectBlockListener extends BlockListener { private EssentialsProtect parent; - private int railBlockX; - private int railBlockY; - private int railBlockZ; - private EssentialsProtectData spData; public EssentialsProtectBlockListener(EssentialsProtect parent) { @@ -31,34 +27,10 @@ public class EssentialsProtectBlockListener extends BlockListener this.parent = parent; } - private void initialize() - { - if (spData != null) return; - spData = new EssentialsProtectData(); - } - - @Override - public void onBlockRightClick(BlockRightClickEvent event) - { - initialize(); - User user = User.get(event.getPlayer()); - if (user.isAuthorized("essentials.protect.admin")) - { - String ownerName = spData.getBlockOwner(user.getWorld().getName(), user.getName(), - event.getBlock()); - if (ownerName != null) - { - user.sendMessage(ChatColor.GOLD + "[EssentialsProtect] Protection owner: " - + ownerName); - } - } - } - @Override public void onBlockPlace(BlockPlaceEvent event) { if (event.isCancelled()) return; - initialize(); ItemStack item = event.getItemInHand(); User user = User.get(event.getPlayer()); @@ -68,7 +40,6 @@ public class EssentialsProtectBlockListener extends BlockListener return; } - Block blockPlaced = event.getBlockAgainst(); int id = event.getBlockPlaced().getTypeId(); if (EssentialsProtect.checkProtectionItems(EssentialsProtect.blackListPlace, id) && !user.isAuthorized("essentials.protect.exemptplacement")) @@ -82,33 +53,48 @@ public class EssentialsProtectBlockListener extends BlockListener parent.alert(user, item.getType().toString(), "placed: "); } - if (spData.isBlockAboveProtectedRail(blockPlaced)) - { + Block blockPlaced = event.getBlockPlaced(); + Block below = blockPlaced.getFace(BlockFace.DOWN); + if (below.getType() == Material.RAILS) { if (EssentialsProtect.genSettings.get("protect.protect.prevent.block-on-rail")) { - event.setCancelled(true); - return; + if (EssentialsProtect.getStorage().isProtected(below, user.getName())) { + event.setCancelled(true); + return; + } } } - if (item.getTypeId() == 66) - { + List<Block> protect = new ArrayList<Block>(); + if (blockPlaced.getType() == Material.RAILS) { if (EssentialsProtect.genSettings.get("protect.protect.rails")) { if (user.isAuthorized("essentials.protect")) { - railBlockX = blockPlaced.getX(); - railBlockY = blockPlaced.getY(); - railBlockZ = blockPlaced.getZ(); - - spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), railBlockX, railBlockY + 1, railBlockZ); + protect.add(blockPlaced); + if (EssentialsProtect.genSettings.get("protect.protect.block-below")) + { + protect.add(blockPlaced.getFace(BlockFace.DOWN)); + } + } + } + } + if (blockPlaced.getType() == Material.SIGN_POST || blockPlaced.getType() == Material.WALL_SIGN) { + if (EssentialsProtect.genSettings.get("protect.protect.signs")) + { + if (user.isAuthorized("essentials.protect")) + { + protect.add(blockPlaced); if (EssentialsProtect.genSettings.get("protect.protect.block-below")) { - spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), railBlockX, railBlockY, railBlockZ); + protect.add(event.getBlockAgainst()); } } } } + for (Block block : protect) { + EssentialsProtect.getStorage().protectBlock(block, user.getName()); + } } @Override @@ -145,7 +131,7 @@ public class EssentialsProtectBlockListener extends BlockListener } @Override - public void onBlockFlow(BlockFromToEvent event) + public void onBlockFromTo(BlockFromToEvent event) { if (event.isCancelled()) return; Block block = event.getBlock(); @@ -180,22 +166,6 @@ public class EssentialsProtectBlockListener extends BlockListener } @Override - public void onBlockInteract(BlockInteractEvent event) - { - if (event.isCancelled()) return; - if (!event.isPlayer()) return; - - User user = User.get((Player)event.getEntity()); - - if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild()) - { - event.setCancelled(true); - return; - } - - } - - @Override public void onBlockBurn(BlockBurnEvent event) { Block block = event.getBlock(); @@ -220,7 +190,6 @@ public class EssentialsProtectBlockListener extends BlockListener public void onBlockBreak(BlockBreakEvent event) { if (event.isCancelled()) return; - initialize(); User user = User.get(event.getPlayer()); Block block = event.getBlock(); if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild()) @@ -244,28 +213,57 @@ public class EssentialsProtectBlockListener extends BlockListener { if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.RAILS) { - spData.removeProtectionFromDB(block, true); + EssentialsProtect.getStorage().unprotectBlock(block); + if (block.getType() == Material.RAILS || block.getType() == Material.SIGN_POST) { + Block below = block.getFace(BlockFace.DOWN); + EssentialsProtect.getStorage().unprotectBlock(below); + } else { + BlockFace[] faces = new BlockFace[] { + BlockFace.NORTH, + BlockFace.EAST, + BlockFace.SOUTH, + BlockFace.WEST + }; + for (BlockFace blockFace : faces) { + Block against = block.getFace(blockFace); + EssentialsProtect.getStorage().unprotectBlock(against); + } + } } else { - spData.removeProtectionFromDB(block); + EssentialsProtect.getStorage().unprotectBlock(block); } return; } else { - boolean canDestroy = spData.canDestroy(user.getWorld().getName(), user.getName(), block); - if (canDestroy) - { + + boolean isProtected = EssentialsProtect.getStorage().isProtected(block, user.getName()); + if (!isProtected) { if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.RAILS) - { - spData.removeProtectionFromDB(block, true); + { + EssentialsProtect.getStorage().unprotectBlock(block); + if (block.getType() == Material.RAILS || block.getType() == Material.SIGN_POST) { + Block below = block.getFace(BlockFace.DOWN); + EssentialsProtect.getStorage().unprotectBlock(below); + } else { + BlockFace[] faces = new BlockFace[] { + BlockFace.NORTH, + BlockFace.EAST, + BlockFace.SOUTH, + BlockFace.WEST + }; + for (BlockFace blockFace : faces) { + Block against = block.getFace(blockFace); + EssentialsProtect.getStorage().unprotectBlock(against); + } + } } else { - spData.removeProtectionFromDB(block); + EssentialsProtect.getStorage().unprotectBlock(block); } - return; } event.setCancelled(true); return; diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java index 61419f69a..2497a733d 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java @@ -2,39 +2,60 @@ package com.earth2me.essentials.protect; import com.earth2me.essentials.Essentials; import com.earth2me.essentials.User; -import org.bukkit.block.Block; -import org.bukkit.event.player.PlayerItemEvent; +import org.bukkit.ChatColor; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerListener; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; public class EssentialsProtectPlayerListener extends PlayerListener { private EssentialsProtect parent; - private int signBlockX; - private int signBlockY; - private int signBlockZ; - private EssentialsProtectData spData = null; - + public EssentialsProtectPlayerListener(EssentialsProtect parent) { Essentials.loadClasses(); this.parent = parent; } - public void initialize() + @Override + public void onPlayerInteract(PlayerInteractEvent event) { - if (spData != null) return; - spData = new EssentialsProtectData(); + if (event.isCancelled()) return; + User user = User.get(event.getPlayer()); + + if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild()) + { + event.setCancelled(true); + return; + } + + if (user.isAuthorized("essentials.protect.admin")) + { + StringBuilder sb = new StringBuilder(); + boolean first = true; + for (String owner : EssentialsProtect.getStorage().getOwners(event.getClickedBlock())) { + if (!first) { + sb.append(", "); + } + first = false; + sb.append(owner); + } + String ownerNames = sb.toString(); + if (ownerNames != null) + { + user.sendMessage(ChatColor.GOLD + "[EssentialsProtect] Protection owners: " + ownerNames); + } + } } @Override - public void onPlayerItem(PlayerItemEvent event) + public void onPlayerPickupItem(PlayerPickupItemEvent event) { if(event.isCancelled()) return; - ItemStack item = event.getItem(); + ItemStack item = event.getItem().getItemStack(); User user = User.get(event.getPlayer()); - Block blockPlaced = event.getBlockClicked(); if (EssentialsProtect.checkProtectionItems(EssentialsProtect.usageList, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage")) { event.setCancelled(true); @@ -45,29 +66,5 @@ public class EssentialsProtectPlayerListener extends PlayerListener { parent.alert(user, item.getType().toString(), "used: "); } - - if (item.getTypeId() == 323) - { - if (EssentialsProtect.genSettings.get("protect.protect.signs")) - { - if (user.isAuthorized("essentials.protect")) - { - - signBlockX = blockPlaced.getX(); - signBlockY = blockPlaced.getY(); - signBlockZ = blockPlaced.getZ(); - - initialize(); - spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), signBlockX, - signBlockY + 1, signBlockZ); - - if (EssentialsProtect.genSettings.get("protect.protect.block-below")) - { - spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), signBlockX, - signBlockY, signBlockZ); - } - } - } - } } } diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/IProtectedBlock.java b/EssentialsProtect/src/com/earth2me/essentials/protect/data/IProtectedBlock.java new file mode 100644 index 000000000..28b7e425b --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/data/IProtectedBlock.java @@ -0,0 +1,15 @@ +package com.earth2me.essentials.protect.data; + +import java.util.List; +import java.util.Set; +import org.bukkit.block.Block; + +public interface IProtectedBlock { + public void clearProtections(); + public void importProtections(List<OwnedBlock> blocks); + public List<OwnedBlock> exportProtections(); + public void protectBlock(Block block, String playerName); + public boolean isProtected(Block block, String playerName); + public List<String> getOwners(Block block); + public int unprotectBlock(Block block); +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/OwnedBlock.java b/EssentialsProtect/src/com/earth2me/essentials/protect/data/OwnedBlock.java new file mode 100644 index 000000000..b9b036798 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/data/OwnedBlock.java @@ -0,0 +1,9 @@ +package com.earth2me.essentials.protect.data; + +public class OwnedBlock { + int x; + int y; + int z; + String world; + String playerName; +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockJDBC.java b/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockJDBC.java new file mode 100644 index 000000000..dec0231b9 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockJDBC.java @@ -0,0 +1,292 @@ +package com.earth2me.essentials.protect.data; + +import com.mchange.v2.c3p0.ComboPooledDataSource; +import java.beans.PropertyVetoException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.bukkit.block.Block; + +public abstract class ProtectedBlockJDBC implements IProtectedBlock { + protected static final Logger logger = Logger.getLogger("Minecraft"); + protected ComboPooledDataSource cpds; + + protected abstract PreparedStatement getStatementCreateTable(Connection conn) throws SQLException; + protected abstract PreparedStatement getStatementDeleteAll(Connection conn) throws SQLException; + protected abstract PreparedStatement getStatementInsert(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException; + protected abstract PreparedStatement getStatementPlayerCountByLocation(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException; + protected abstract PreparedStatement getStatementPlayersByLocation(Connection conn, String name, int x, int y, int z) throws SQLException; + protected abstract PreparedStatement getStatementDeleteByLocation(Connection conn, String world, int x, int y, int z) throws SQLException; + protected abstract PreparedStatement getStatementAllBlocks(Connection conn) throws SQLException; + + public ProtectedBlockJDBC(String driver, String url) throws PropertyVetoException { + this(driver, url, null, null); + } + + public ProtectedBlockJDBC(String driver, String url, String username, String password) throws PropertyVetoException { + cpds = new ComboPooledDataSource(); + cpds.setDriverClass(driver); + cpds.setJdbcUrl(url); + if (username != null) { + cpds.setUser(username); + cpds.setPassword(password); + } + cpds.setMaxStatements(20); + createAndConvertTable(); + } + + + private void createAndConvertTable() { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = cpds.getConnection(); + ps = getStatementCreateTable(conn); + ps.execute(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + } + } + + public void clearProtections() { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = cpds.getConnection(); + ps = getStatementDeleteAll(conn); + ps.executeUpdate(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + } + } + + public void importProtections(List<OwnedBlock> blocks) { + for (OwnedBlock ownedBlock : blocks) { + if (ownedBlock.playerName == null) { + continue; + } + protectBlock(ownedBlock.world, ownedBlock.x, ownedBlock.y, ownedBlock.z, ownedBlock.playerName); + } + } + + public List<OwnedBlock> exportProtections() { + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs = null; + List<OwnedBlock> blocks = new ArrayList<OwnedBlock>(); + try { + conn = cpds.getConnection(); + ps = getStatementAllBlocks(conn); + rs = ps.executeQuery(); + while (rs.next()) { + OwnedBlock ob = new OwnedBlock(); + ob.world = rs.getString(1); + ob.x = rs.getInt(2); + ob.y = rs.getInt(3); + ob.z = rs.getInt(4); + ob.playerName = rs.getString(5); + blocks.add(ob); + } + return blocks; + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + return blocks; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (ps != null) { + try { + ps.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + } + } + + public void protectBlock(Block block, String playerName) { + protectBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), playerName); + } + + private void protectBlock(String world, int x, int y, int z, String playerName) { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = cpds.getConnection(); + ps = getStatementInsert(conn, world, x, y, z, playerName); + ps.executeUpdate(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + } + } + + public boolean isProtected(Block block, String playerName) { + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs = null; + try { + conn = cpds.getConnection(); + ps = getStatementPlayerCountByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), playerName); + rs = ps.executeQuery(); + rs.next(); + return rs.getInt(1) > 0 && rs.getInt(2) == 0; + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + return true; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (ps != null) { + try { + ps.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + } + } + + public List<String> getOwners(Block block) { + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs = null; + List<String> owners = new ArrayList<String>(); + try { + conn = cpds.getConnection(); + ps = getStatementPlayersByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ()); + rs = ps.executeQuery(); + while (rs.next()) { + owners.add(rs.getString(1)); + } + return owners; + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + return owners; + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (ps != null) { + try { + ps.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + } + } + + public int unprotectBlock(Block block) { + Connection conn = null; + PreparedStatement ps = null; + try { + conn = cpds.getConnection(); + ps = getStatementDeleteByLocation(conn, block.getWorld().getName(), block.getX(), block.getY(), block.getZ()); + return ps.executeUpdate(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + return 0; + } finally { + if (ps != null) { + try { + ps.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + if (conn != null) { + try { + conn.close(); + } catch (SQLException ex) { + logger.log(Level.SEVERE, null, ex); + } + } + } + } + +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMemory.java b/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMemory.java new file mode 100644 index 000000000..53dee66d2 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMemory.java @@ -0,0 +1,205 @@ +package com.earth2me.essentials.protect.data; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.plugin.Plugin; + +public class ProtectedBlockMemory implements IProtectedBlock { + + List<String> worlds = new ArrayList<String>(); + List<String> playerNames = new ArrayList<String>(); + IProtectedBlock storage; + Plugin plugin; + + class ProtectedLocation { + + int x; + int y; + int z; + int w; + + private ProtectedLocation(Block block, int worldId) { + this.x = block.getX(); + this.y = block.getY(); + this.z = block.getZ(); + this.w = worldId; + } + + private ProtectedLocation(OwnedBlock ownedBlock, int worldId) { + this.x = ownedBlock.x; + this.y = ownedBlock.y; + this.z = ownedBlock.z; + this.w = worldId; + } + + @Override + public boolean equals(Object o) { + if (o instanceof ProtectedLocation) { + ProtectedLocation pl = (ProtectedLocation) o; + return x == pl.x && y == pl.y && z == pl.z && w == pl.w; + } + return false; + } + + @Override + public int hashCode() { + return x ^ y ^ z ^ w; + } + } + + class ProtectedBy { + + private int playerId = -1; + private Set<Integer> playerIds; + + private ProtectedBy() { + } + + private void add(int playerId) { + if (this.playerId == -1 || this.playerId == playerId) { + this.playerId = playerId; + } else { + if (playerIds == null) { + playerIds = new HashSet<Integer>(4); + playerIds.add(this.playerId); + } + playerIds.add(playerId); + } + } + + private boolean contains(int playerId) { + if (playerIds == null) { + return this.playerId == playerId; + } + return playerIds.contains(playerId); + } + + private List<String> getPlayers(List<String> playerNames) { + if (playerIds == null) { + List<String> list = new ArrayList<String>(2); + list.add(playerNames.get(playerId)); + return list; + } + List<String> list = new ArrayList<String>(playerIds.size()); + for (Integer integer : playerIds) { + list.add(playerNames.get(integer)); + } + return list; + } + + private int size() { + if (playerIds == null) { + return 1; + } + return playerIds.size(); + } + } + HashMap<ProtectedLocation, ProtectedBy> blocks = new HashMap<ProtectedLocation, ProtectedBy>(); + + public ProtectedBlockMemory(IProtectedBlock storage) { + this.storage = storage; + importProtections(storage.exportProtections()); + } + + public void clearProtections() { + blocks.clear(); + } + + public final void importProtections(List<OwnedBlock> blocks) { + for (OwnedBlock ownedBlock : blocks) { + ProtectedLocation pl = new ProtectedLocation(ownedBlock, getWorldId(ownedBlock.world)); + if (ownedBlock.playerName == null) { + continue; + } + protectBlock(pl, ownedBlock.playerName); + } + } + + public List<OwnedBlock> exportProtections() { + List<OwnedBlock> blockList = new ArrayList<OwnedBlock>(blocks.size()); + for (Entry<ProtectedLocation, ProtectedBy> entry : blocks.entrySet()) { + for (String name : entry.getValue().getPlayers(playerNames)) { + OwnedBlock ob = new OwnedBlock(); + ob.x = entry.getKey().x; + ob.y = entry.getKey().y; + ob.z = entry.getKey().z; + ob.world = worlds.get(entry.getKey().w); + ob.playerName = name; + blockList.add(ob); + } + } + return blockList; + } + + public void protectBlock(final Block block, final String playerName) { + ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld())); + protectBlock(pl, playerName); + plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() { + public void run() { + storage.protectBlock(block, playerName); + } + }); + } + + private void protectBlock(ProtectedLocation pl, String playerName) { + int playerId = getPlayerId(playerName); + ProtectedBy pb = blocks.get(pl); + if (pb == null) { + pb = new ProtectedBy(); + blocks.put(pl, pb); + } + pb.add(playerId); + } + + public boolean isProtected(Block block, String playerName) { + int playerId = getPlayerId(playerName); + ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld())); + ProtectedBy pb = blocks.get(pl); + return !pb.contains(playerId); + } + + public List<String> getOwners(Block block) { + ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld())); + ProtectedBy pb = blocks.get(pl); + return pb.getPlayers(playerNames); + } + + public int unprotectBlock(final Block block) { + ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld())); + ProtectedBy pb = blocks.remove(pl); + plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() { + public void run() { + storage.unprotectBlock(block); + } + }); + return pb.size(); + } + + private int getPlayerId(String playername) { + int id = playerNames.indexOf(playername); + if (id < 0) { + playerNames.add(playername); + id = playerNames.indexOf(playername); + } + return id; + } + + private int getWorldId(World world) { + return getWorldId(world.getName()); + } + + private int getWorldId(String name) { + int id = worlds.indexOf(name); + if (id < 0) { + worlds.add(name); + id = worlds.indexOf(name); + } + return id; + } +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMySQL.java b/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMySQL.java new file mode 100644 index 000000000..8824f4040 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMySQL.java @@ -0,0 +1,89 @@ +package com.earth2me.essentials.protect.data; + +import java.beans.PropertyVetoException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class ProtectedBlockMySQL extends ProtectedBlockJDBC { + + public ProtectedBlockMySQL(String url, String username, String password) throws PropertyVetoException { + super("com.mysql.jdbc.Driver", url, username, password); + } + + private static final String QueryCreateTable = + "CREATE TABLE IF NOT EXISTS `EssentialsProtectedBlocks` (" + + "`worldName` varchar(150) NOT NULL," + + "`x` int(11) NOT NULL, `y` int(11) NOT NULL, `z` int(11) NOT NULL," + + "`playerName` varchar(150) NOT NULL," + + ") ENGINE=MyISAM DEFAULT CHARSET=utf8"; + + @Override + protected PreparedStatement getStatementCreateTable(Connection conn) throws SQLException { + return conn.prepareStatement(QueryCreateTable); + } + private static final String QueryDeleteAll = "DELETE FROM EssentialsProtectedBlocks;"; + + @Override + protected PreparedStatement getStatementDeleteAll(Connection conn) throws SQLException { + return conn.prepareStatement(QueryDeleteAll); + } + private static final String QueryInsert = + "INSERT INTO EssentialsProtectedBlocks (worldName, x, y, z, playerName) VALUES (?, ?, ?, ?, ?);"; + + @Override + protected PreparedStatement getStatementInsert(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException { + PreparedStatement ps = conn.prepareStatement(QueryInsert); + ps.setString(1, world); + ps.setInt(2, x); + ps.setInt(3, y); + ps.setInt(4, z); + ps.setString(5, playerName); + return ps; + } + private static final String QueryCountByPlayer = + "SELECT COUNT(playerName), SUM(playerName = ?) FROM EssentialsProtectedBlocks " + + "WHERE worldName = ? AND x = ? AND y = ? AND z = ? GROUP BY x;"; + + @Override + protected PreparedStatement getStatementPlayerCountByLocation(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException { + PreparedStatement ps = conn.prepareStatement(QueryCountByPlayer); + ps.setString(1, playerName); + ps.setString(2, world); + ps.setInt(3, x); + ps.setInt(4, y); + ps.setInt(5, z); + return ps; + } + private static final String QueryPlayersByLocation = + "SELECT playerName FROM EssentialsProtectedBlocks WHERE worldname = ? AND x = ? AND y = ? AND z = ?;"; + + @Override + protected PreparedStatement getStatementPlayersByLocation(Connection conn, String world, int x, int y, int z) throws SQLException { + PreparedStatement ps = conn.prepareStatement(QueryPlayersByLocation); + ps.setString(1, world); + ps.setInt(2, x); + ps.setInt(3, y); + ps.setInt(4, z); + return ps; + } + private static final String QueryDeleteByLocation = + "DELETE FROM EssentialsProtectedBlocks WHERE worldName = ? AND x = ? AND y = ? AND z = ?;"; + + @Override + protected PreparedStatement getStatementDeleteByLocation(Connection conn, String world, int x, int y, int z) throws SQLException { + PreparedStatement ps = conn.prepareStatement(QueryDeleteByLocation); + ps.setString(1, world); + ps.setInt(2, x); + ps.setInt(3, y); + ps.setInt(4, z); + return ps; + } + private static final String QueryAllBlocks = + "SELECT worldName, x, y, z, playerName FROM EssentialsProtectedBlocks;"; + + @Override + protected PreparedStatement getStatementAllBlocks(Connection conn) throws SQLException { + return conn.prepareStatement(QueryAllBlocks); + } +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockSQLite.java b/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockSQLite.java new file mode 100644 index 000000000..ff96a8952 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockSQLite.java @@ -0,0 +1,87 @@ +package com.earth2me.essentials.protect.data; + +import java.beans.PropertyVetoException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public class ProtectedBlockSQLite extends ProtectedBlockJDBC { + + public ProtectedBlockSQLite(String url) throws PropertyVetoException { + super("org.sqlite.JDBC", url); + } + + private static final String QueryCreateTable = + "CREATE TABLE IF NOT EXISTS EssentialsProtect (" + + "worldName TEXT ,playerName TEXT, " + + "x NUMERIC, y NUMERIC, z NUMERIC)"; + + @Override + protected PreparedStatement getStatementCreateTable(Connection conn) throws SQLException { + return conn.prepareStatement(QueryCreateTable); + } + private static final String QueryDeleteAll = "DELETE FROM EssentialsProtectedBlocks;"; + + @Override + protected PreparedStatement getStatementDeleteAll(Connection conn) throws SQLException { + return conn.prepareStatement(QueryDeleteAll); + } + private static final String QueryInsert = + "INSERT INTO EssentialsProtectedBlocks (worldName, x, y, z, playerName) VALUES (?, ?, ?, ?, ?);"; + + @Override + protected PreparedStatement getStatementInsert(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException { + PreparedStatement ps = conn.prepareStatement(QueryInsert); + ps.setString(1, world); + ps.setInt(2, x); + ps.setInt(3, y); + ps.setInt(4, z); + ps.setString(5, playerName); + return ps; + } + private static final String QueryPlayerCountByLocation = + "SELECT COUNT(playerName), SUM(playerName = ?) FROM EssentialsProtectedBlocks " + + "WHERE worldName = ? AND x = ? AND y = ? AND z = ? GROUP BY x;"; + + @Override + protected PreparedStatement getStatementPlayerCountByLocation(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException { + PreparedStatement ps = conn.prepareStatement(QueryPlayerCountByLocation); + ps.setString(1, playerName); + ps.setString(2, world); + ps.setInt(3, x); + ps.setInt(4, y); + ps.setInt(5, z); + return ps; + } + private static final String QueryPlayersByLocation = + "SELECT playerName FROM EssentialsProtectedBlocks WHERE worldname = ? AND x = ? AND y = ? AND z = ?;"; + + @Override + protected PreparedStatement getStatementPlayersByLocation(Connection conn, String world, int x, int y, int z) throws SQLException { + PreparedStatement ps = conn.prepareStatement(QueryPlayersByLocation); + ps.setString(1, world); + ps.setInt(2, x); + ps.setInt(3, y); + ps.setInt(4, z); + return ps; + } + private static final String QueryDeleteByLocation = + "DELETE FROM EssentialsProtectedBlocks WHERE worldName = ? AND x = ? AND y = ? AND z = ?;"; + + @Override + protected PreparedStatement getStatementDeleteByLocation(Connection conn, String world, int x, int y, int z) throws SQLException { + PreparedStatement ps = conn.prepareStatement(QueryDeleteByLocation); + ps.setString(1, world); + ps.setInt(2, x); + ps.setInt(3, y); + ps.setInt(4, z); + return ps; + } + private static final String QueryAllBlocks = + "SELECT worldName, x, y, z, playerName FROM EssentialsProtectedBlocks;"; + + @Override + protected PreparedStatement getStatementAllBlocks(Connection conn) throws SQLException { + return conn.prepareStatement(QueryAllBlocks); + } +} diff --git a/EssentialsServerlist/build.xml b/EssentialsServerlist/build.xml deleted file mode 100644 index 7650691f1..000000000 --- a/EssentialsServerlist/build.xml +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE project [ <!ENTITY buildinc SYSTEM "../build.inc.xml"> ]>
-<!-- You may freely edit this file. See commented blocks below for -->
-<!-- some examples of how to customize the build. -->
-<!-- (If you delete it and reopen the project it will be recreated.) -->
-<!-- By default, only the Clean and Build commands use this build script. -->
-<!-- Commands such as Run, Debug, and Test only use this build script if -->
-<!-- the Compile on Save feature is turned off for the project. -->
-<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
-<!-- in the project's Project Properties dialog box.-->
-<project name="EssentialsServerlist" default="default" basedir=".">
- <description>Builds, tests, and runs the project EssentialsServerlist.</description>
- <import file="nbproject/build-impl.xml"/>
- &buildinc;
- <!--
-
- There exist several targets which are by default empty and which can be
- used for execution of your tasks. These targets are usually executed
- before and after some main targets. They are:
-
- -pre-init: called before initialization of project properties
- -post-init: called after initialization of project properties
- -pre-compile: called before javac compilation
- -post-compile: called after javac compilation
- -pre-compile-single: called before javac compilation of single file
- -post-compile-single: called after javac compilation of single file
- -pre-compile-test: called before javac compilation of JUnit tests
- -post-compile-test: called after javac compilation of JUnit tests
- -pre-compile-test-single: called before javac compilation of single JUnit test
- -post-compile-test-single: called after javac compilation of single JUunit test
- -pre-jar: called before JAR building
- -post-jar: called after JAR building
- -post-clean: called after cleaning build products
-
- (Targets beginning with '-' are not intended to be called on their own.)
-
- Example of inserting an obfuscator after compilation could look like this:
-
- <target name="-post-compile">
- <obfuscate>
- <fileset dir="${build.classes.dir}"/>
- </obfuscate>
- </target>
-
- For list of available properties check the imported
- nbproject/build-impl.xml file.
-
-
- Another way to customize the build is by overriding existing main targets.
- The targets of interest are:
-
- -init-macrodef-javac: defines macro for javac compilation
- -init-macrodef-junit: defines macro for junit execution
- -init-macrodef-debug: defines macro for class debugging
- -init-macrodef-java: defines macro for class execution
- -do-jar-with-manifest: JAR building (if you are using a manifest)
- -do-jar-without-manifest: JAR building (if you are not using a manifest)
- run: execution of project
- -javadoc-build: Javadoc generation
- test-report: JUnit report generation
-
- An example of overriding the target for project execution could look like this:
-
- <target name="run" depends="EssentialsServerlist-impl.jar">
- <exec dir="bin" executable="launcher.exe">
- <arg file="${dist.jar}"/>
- </exec>
- </target>
-
- Notice that the overridden target depends on the jar target and not only on
- the compile target as the regular run target does. Again, for a list of available
- properties which you can use, check the target you are overriding in the
- nbproject/build-impl.xml file.
-
- -->
-</project>
diff --git a/EssentialsServerlist/nbproject/build-impl.xml b/EssentialsServerlist/nbproject/build-impl.xml deleted file mode 100644 index ee4ae2895..000000000 --- a/EssentialsServerlist/nbproject/build-impl.xml +++ /dev/null @@ -1,1072 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
-*** GENERATED FROM project.xml - DO NOT EDIT ***
-*** EDIT ../build.xml INSTEAD ***
-
-For the purpose of easier reading the script
-is divided into following sections:
-
- - initialization
- - compilation
- - jar
- - execution
- - debugging
- - javadoc
- - junit compilation
- - junit execution
- - junit debugging
- - applet
- - cleanup
-
- -->
-<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="EssentialsServerlist-impl">
- <fail message="Please build using Ant 1.7.1 or higher.">
- <condition>
- <not>
- <antversion atleast="1.7.1"/>
- </not>
- </condition>
- </fail>
- <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
- <!--
- ======================
- INITIALIZATION SECTION
- ======================
- -->
- <target name="-pre-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="-pre-init" name="-init-private">
- <property file="nbproject/private/config.properties"/>
- <property file="nbproject/private/configs/${config}.properties"/>
- <property file="nbproject/private/private.properties"/>
- </target>
- <target name="-pre-init-libraries">
- <property location="../lib\nblibraries.properties" name="libraries.path"/>
- <dirname file="${libraries.path}" property="libraries.dir.nativedirsep"/>
- <pathconvert dirsep="/" property="libraries.dir">
- <path path="${libraries.dir.nativedirsep}"/>
- </pathconvert>
- <basename file="${libraries.path}" property="libraries.basename" suffix=".properties"/>
- <available file="${libraries.dir}/${libraries.basename}-private.properties" property="private.properties.available"/>
- </target>
- <target depends="-pre-init-libraries" if="private.properties.available" name="-init-private-libraries">
- <loadproperties encoding="ISO-8859-1" srcfile="${libraries.dir}/${libraries.basename}-private.properties">
- <filterchain>
- <replacestring from="$${base}" to="${libraries.dir}"/>
- <escapeunicode/>
- </filterchain>
- </loadproperties>
- </target>
- <target depends="-pre-init,-init-private,-init-private-libraries" name="-init-libraries">
- <loadproperties encoding="ISO-8859-1" srcfile="${libraries.path}">
- <filterchain>
- <replacestring from="$${base}" to="${libraries.dir}"/>
- <escapeunicode/>
- </filterchain>
- </loadproperties>
- </target>
- <target depends="-pre-init,-init-private,-init-libraries" name="-init-user">
- <property file="${user.properties.file}"/>
- <!-- The two properties below are usually overridden -->
- <!-- by the active platform. Just a fallback. -->
- <property name="default.javac.source" value="1.4"/>
- <property name="default.javac.target" value="1.4"/>
- </target>
- <target depends="-pre-init,-init-private,-init-libraries,-init-user" name="-init-project">
- <property file="nbproject/configs/${config}.properties"/>
- <property file="nbproject/project.properties"/>
- </target>
- <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-init-macrodef-property" name="-do-init">
- <available file="${manifest.file}" property="manifest.available"/>
- <condition property="splashscreen.available">
- <and>
- <not>
- <equals arg1="${application.splash}" arg2="" trim="true"/>
- </not>
- <available file="${application.splash}"/>
- </and>
- </condition>
- <condition property="main.class.available">
- <and>
- <isset property="main.class"/>
- <not>
- <equals arg1="${main.class}" arg2="" trim="true"/>
- </not>
- </and>
- </condition>
- <condition property="manifest.available+main.class">
- <and>
- <isset property="manifest.available"/>
- <isset property="main.class.available"/>
- </and>
- </condition>
- <condition property="do.archive">
- <not>
- <istrue value="${jar.archive.disabled}"/>
- </not>
- </condition>
- <condition property="do.mkdist">
- <and>
- <isset property="do.archive"/>
- <isset property="libs.CopyLibs.classpath"/>
- <not>
- <istrue value="${mkdist.disabled}"/>
- </not>
- </and>
- </condition>
- <condition property="manifest.available+main.class+mkdist.available">
- <and>
- <istrue value="${manifest.available+main.class}"/>
- <isset property="do.mkdist"/>
- </and>
- </condition>
- <condition property="do.archive+manifest.available">
- <and>
- <isset property="manifest.available"/>
- <istrue value="${do.archive}"/>
- </and>
- </condition>
- <condition property="do.archive+main.class.available">
- <and>
- <isset property="main.class.available"/>
- <istrue value="${do.archive}"/>
- </and>
- </condition>
- <condition property="do.archive+splashscreen.available">
- <and>
- <isset property="splashscreen.available"/>
- <istrue value="${do.archive}"/>
- </and>
- </condition>
- <condition property="do.archive+manifest.available+main.class">
- <and>
- <istrue value="${manifest.available+main.class}"/>
- <istrue value="${do.archive}"/>
- </and>
- </condition>
- <condition property="manifest.available-mkdist.available">
- <or>
- <istrue value="${manifest.available}"/>
- <isset property="do.mkdist"/>
- </or>
- </condition>
- <condition property="manifest.available+main.class-mkdist.available">
- <or>
- <istrue value="${manifest.available+main.class}"/>
- <isset property="do.mkdist"/>
- </or>
- </condition>
- <condition property="have.tests">
- <or>
- <available file="${test.src.dir}"/>
- </or>
- </condition>
- <condition property="have.sources">
- <or>
- <available file="${src.dir}"/>
- </or>
- </condition>
- <condition property="netbeans.home+have.tests">
- <and>
- <isset property="netbeans.home"/>
- <isset property="have.tests"/>
- </and>
- </condition>
- <condition property="no.javadoc.preview">
- <and>
- <isset property="javadoc.preview"/>
- <isfalse value="${javadoc.preview}"/>
- </and>
- </condition>
- <property name="run.jvmargs" value=""/>
- <property name="javac.compilerargs" value=""/>
- <property name="work.dir" value="${basedir}"/>
- <condition property="no.deps">
- <and>
- <istrue value="${no.dependencies}"/>
- </and>
- </condition>
- <property name="javac.debug" value="true"/>
- <property name="javadoc.preview" value="true"/>
- <property name="application.args" value=""/>
- <property name="source.encoding" value="${file.encoding}"/>
- <property name="runtime.encoding" value="${source.encoding}"/>
- <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
- <and>
- <isset property="javadoc.encoding"/>
- <not>
- <equals arg1="${javadoc.encoding}" arg2=""/>
- </not>
- </and>
- </condition>
- <property name="javadoc.encoding.used" value="${source.encoding}"/>
- <property name="includes" value="**"/>
- <property name="excludes" value=""/>
- <property name="do.depend" value="false"/>
- <condition property="do.depend.true">
- <istrue value="${do.depend}"/>
- </condition>
- <path id="endorsed.classpath.path" path="${endorsed.classpath}"/>
- <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">
- <length length="0" string="${endorsed.classpath}" when="greater"/>
- </condition>
- <property name="javac.fork" value="false"/>
- <property name="jar.index" value="false"/>
- <property name="jar.index.metainf" value="${jar.index}"/>
- <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>
- </target>
- <target name="-post-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init" name="-init-check">
- <fail unless="src.dir">Must set src.dir</fail>
- <fail unless="test.src.dir">Must set test.src.dir</fail>
- <fail unless="build.dir">Must set build.dir</fail>
- <fail unless="dist.dir">Must set dist.dir</fail>
- <fail unless="build.classes.dir">Must set build.classes.dir</fail>
- <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
- <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
- <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
- <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
- <fail unless="dist.jar">Must set dist.jar</fail>
- </target>
- <target name="-init-macrodef-property">
- <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="name"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{name}" value="${@{value}}"/>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
- <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${src.dir}" name="srcdir"/>
- <attribute default="${build.classes.dir}" name="destdir"/>
- <attribute default="${javac.classpath}" name="classpath"/>
- <attribute default="${javac.processorpath}" name="processorpath"/>
- <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="${javac.debug}" name="debug"/>
- <attribute default="${empty.dir}" name="sourcepath"/>
- <attribute default="${empty.dir}" name="gensrcdir"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property location="${build.dir}/empty" name="empty.dir"/>
- <mkdir dir="${empty.dir}"/>
- <mkdir dir="@{apgeneratedsrcdir}"/>
- <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
- <src>
- <dirset dir="@{gensrcdir}" erroronmissingdir="false">
- <include name="*"/>
- </dirset>
- </src>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
- <compilerarg line="${javac.compilerargs}"/>
- <compilerarg value="-processorpath"/>
- <compilerarg path="@{processorpath}:${empty.dir}"/>
- <compilerarg line="${ap.processors.internal}"/>
- <compilerarg line="${annotation.processing.processor.options}"/>
- <compilerarg value="-s"/>
- <compilerarg path="@{apgeneratedsrcdir}"/>
- <compilerarg line="${ap.proc.none.internal}"/>
- <customize/>
- </javac>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
- <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${src.dir}" name="srcdir"/>
- <attribute default="${build.classes.dir}" name="destdir"/>
- <attribute default="${javac.classpath}" name="classpath"/>
- <attribute default="${javac.processorpath}" name="processorpath"/>
- <attribute default="${build.generated.sources.dir}/ap-source-output" name="apgeneratedsrcdir"/>
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="${javac.debug}" name="debug"/>
- <attribute default="${empty.dir}" name="sourcepath"/>
- <attribute default="${empty.dir}" name="gensrcdir"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property location="${build.dir}/empty" name="empty.dir"/>
- <mkdir dir="${empty.dir}"/>
- <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">
- <src>
- <dirset dir="@{gensrcdir}" erroronmissingdir="false">
- <include name="*"/>
- </dirset>
- </src>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <compilerarg line="${endorsed.classpath.cmd.line.arg}"/>
- <compilerarg line="${javac.compilerargs}"/>
- <customize/>
- </javac>
- </sequential>
- </macrodef>
- </target>
- <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
- <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${src.dir}" name="srcdir"/>
- <attribute default="${build.classes.dir}" name="destdir"/>
- <attribute default="${javac.classpath}" name="classpath"/>
- <sequential>
- <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- </depend>
- </sequential>
- </macrodef>
- <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${build.classes.dir}" name="destdir"/>
- <sequential>
- <fail unless="javac.includes">Must set javac.includes</fail>
- <pathconvert pathsep="${line.separator}" property="javac.includes.binary">
- <path>
- <filelist dir="@{destdir}" files="${javac.includes}"/>
- </path>
- <globmapper from="*.java" to="*.class"/>
- </pathconvert>
- <tempfile deleteonexit="true" property="javac.includesfile.binary"/>
- <echo file="${javac.includesfile.binary}" message="${javac.includes.binary}"/>
- <delete>
- <files includesfile="${javac.includesfile.binary}"/>
- </delete>
- <delete>
- <fileset file="${javac.includesfile.binary}"/>
- </delete>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-junit">
- <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${includes}" name="includes"/>
- <attribute default="${excludes}" name="excludes"/>
- <attribute default="**" name="testincludes"/>
- <sequential>
- <property name="junit.forkmode" value="perTest"/>
- <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">
- <batchtest todir="${build.test.results.dir}">
- <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
- <filename name="@{testincludes}"/>
- </fileset>
- </batchtest>
- <classpath>
- <path path="${run.test.classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <formatter type="brief" usefile="false"/>
- <formatter type="xml"/>
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
- <jvmarg value="-ea"/>
- <jvmarg line="${run.jvmargs}"/>
- </junit>
- </sequential>
- </macrodef>
- </target>
- <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile, -profile-init-check" name="profile-init"/>
- <target name="-profile-pre-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-profile-post-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-profile-init-macrodef-profile">
- <macrodef name="resolve">
- <attribute name="name"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{name}" value="${env.@{value}}"/>
- </sequential>
- </macrodef>
- <macrodef name="profile">
- <attribute default="${main.class}" name="classname"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property environment="env"/>
- <resolve name="profiler.current.path" value="${profiler.info.pathvar}"/>
- <java classname="@{classname}" dir="${profiler.info.dir}" fork="true" jvm="${profiler.info.jvm}">
- <jvmarg value="${profiler.info.jvmargs.agent}"/>
- <jvmarg line="${profiler.info.jvmargs}"/>
- <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
- <arg line="${application.args}"/>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="run-sys-prop."/>
- <mapper from="run-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <customize/>
- </java>
- </sequential>
- </macrodef>
- </target>
- <target depends="-profile-pre-init, init, -profile-post-init, -profile-init-macrodef-profile" name="-profile-init-check">
- <fail unless="profiler.info.jvm">Must set JVM to use for profiling in profiler.info.jvm</fail>
- <fail unless="profiler.info.jvmargs.agent">Must set profiler agent JVM arguments in profiler.info.jvmargs.agent</fail>
- </target>
- <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
- <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute default="${main.class}" name="name"/>
- <attribute default="${debug.classpath}" name="classpath"/>
- <attribute default="" name="stopclassname"/>
- <sequential>
- <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- </nbjpdastart>
- </sequential>
- </macrodef>
- <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute default="${build.classes.dir}" name="dir"/>
- <sequential>
- <nbjpdareload>
- <fileset dir="@{dir}" includes="${fix.classes}">
- <include name="${fix.includes}*.class"/>
- </fileset>
- </nbjpdareload>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-debug-args">
- <property name="version-output" value="java version "${ant.java.version}"/>
- <condition property="have-jdk-older-than-1.4">
- <or>
- <contains string="${version-output}" substring="java version "1.0"/>
- <contains string="${version-output}" substring="java version "1.1"/>
- <contains string="${version-output}" substring="java version "1.2"/>
- <contains string="${version-output}" substring="java version "1.3"/>
- </or>
- </condition>
- <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
- <istrue value="${have-jdk-older-than-1.4}"/>
- </condition>
- <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
- <os family="windows"/>
- </condition>
- <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
- <isset property="debug.transport"/>
- </condition>
- </target>
- <target depends="-init-debug-args" name="-init-macrodef-debug">
- <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${main.class}" name="classname"/>
- <attribute default="${debug.classpath}" name="classpath"/>
- <element name="customize" optional="true"/>
- <sequential>
- <java classname="@{classname}" dir="${work.dir}" fork="true">
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
- <jvmarg line="${debug-args-line}"/>
- <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
- <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
- <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
- <jvmarg line="${run.jvmargs}"/>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="run-sys-prop."/>
- <mapper from="run-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <customize/>
- </java>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-java">
- <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute default="${main.class}" name="classname"/>
- <attribute default="${run.classpath}" name="classpath"/>
- <element name="customize" optional="true"/>
- <sequential>
- <java classname="@{classname}" dir="${work.dir}" fork="true">
- <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>
- <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>
- <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>
- <jvmarg line="${run.jvmargs}"/>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="run-sys-prop."/>
- <mapper from="run-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <customize/>
- </java>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-copylibs">
- <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute default="${manifest.file}" name="manifest"/>
- <element name="customize" optional="true"/>
- <sequential>
- <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
- <pathconvert property="run.classpath.without.build.classes.dir">
- <path path="${run.classpath}"/>
- <map from="${build.classes.dir.resolved}" to=""/>
- </pathconvert>
- <pathconvert pathsep=" " property="jar.classpath">
- <path path="${run.classpath.without.build.classes.dir}"/>
- <chainedmapper>
- <flattenmapper/>
- <globmapper from="*" to="lib/*"/>
- </chainedmapper>
- </pathconvert>
- <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
- <copylibs compress="${jar.compress}" index="${jar.index}" indexMetaInf="${jar.index.metainf}" jarfile="${dist.jar}" manifest="@{manifest}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
- <fileset dir="${build.classes.dir}"/>
- <manifest>
- <attribute name="Class-Path" value="${jar.classpath}"/>
- <customize/>
- </manifest>
- </copylibs>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-presetdef-jar">
- <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
- <jar compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}">
- <j2seproject1:fileset dir="${build.classes.dir}"/>
- </jar>
- </presetdef>
- </target>
- <target name="-init-ap-cmdline-properties">
- <property name="annotation.processing.enabled" value="true"/>
- <property name="annotation.processing.processors.list" value=""/>
- <property name="annotation.processing.processor.options" value=""/>
- <property name="annotation.processing.run.all.processors" value="true"/>
- <property name="javac.processorpath" value="${javac.classpath}"/>
- <property name="javac.test.processorpath" value="${javac.test.classpath}"/>
- <condition property="ap.supported.internal" value="true">
- <not>
- <matches pattern="1\.[0-5](\..*)?" string="${javac.source}"/>
- </not>
- </condition>
- </target>
- <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-ap-cmdline-supported">
- <condition else="" property="ap.processors.internal" value="-processor ${annotation.processing.processors.list}">
- <isfalse value="${annotation.processing.run.all.processors}"/>
- </condition>
- <condition else="" property="ap.proc.none.internal" value="-proc:none">
- <isfalse value="${annotation.processing.enabled}"/>
- </condition>
- </target>
- <target depends="-init-ap-cmdline-properties,-init-ap-cmdline-supported" name="-init-ap-cmdline">
- <property name="ap.cmd.line.internal" value=""/>
- </target>
- <target depends="-pre-init,-init-private,-init-libraries,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar,-init-ap-cmdline" name="init"/>
- <!--
- ===================
- COMPILATION SECTION
- ===================
- -->
- <target name="-deps-jar-init" unless="built-jar.properties">
- <property location="${build.dir}/built-jar.properties" name="built-jar.properties"/>
- <delete file="${built-jar.properties}" quiet="true"/>
- </target>
- <target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
- <echo level="warn" message="Cycle detected: EssentialsServerlist was already built"/>
- </target>
- <target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
- <mkdir dir="${build.dir}"/>
- <touch file="${built-jar.properties}" verbose="false"/>
- <property file="${built-jar.properties}" prefix="already.built.jar."/>
- <antcall target="-warn-already-built-jar"/>
- <propertyfile file="${built-jar.properties}">
- <entry key="${basedir}" value=""/>
- </propertyfile>
- <antcall target="-maybe-call-dep">
- <param name="call.built.properties" value="${built-jar.properties}"/>
- <param location="${project.Essentials}" name="call.subproject"/>
- <param location="${project.Essentials}/build.xml" name="call.script"/>
- <param name="call.target" value="jar"/>
- <param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
- </antcall>
- </target>
- <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
- <target depends="init" name="-check-automatic-build">
- <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
- </target>
- <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
- <antcall target="clean"/>
- </target>
- <target depends="init,deps-jar" name="-pre-pre-compile">
- <mkdir dir="${build.classes.dir}"/>
- </target>
- <target name="-pre-compile">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target if="do.depend.true" name="-compile-depend">
- <pathconvert property="build.generated.subdirs">
- <dirset dir="${build.generated.sources.dir}" erroronmissingdir="false">
- <include name="*"/>
- </dirset>
- </pathconvert>
- <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
- </target>
- <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
- <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
- <copy todir="${build.classes.dir}">
- <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
- </copy>
- </target>
- <target if="has.persistence.xml" name="-copy-persistence-xml">
- <mkdir dir="${build.classes.dir}/META-INF"/>
- <copy todir="${build.classes.dir}/META-INF">
- <fileset dir="${meta.inf.dir}" includes="persistence.xml"/>
- </copy>
- </target>
- <target name="-post-compile">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
- <target name="-pre-compile-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
- <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
- <j2seproject3:force-recompile/>
- <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
- </target>
- <target name="-post-compile-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
- <!--
- ====================
- JAR BUILDING SECTION
- ====================
- -->
- <target depends="init" name="-pre-pre-jar">
- <dirname file="${dist.jar}" property="dist.jar.dir"/>
- <mkdir dir="${dist.jar.dir}"/>
- </target>
- <target name="-pre-jar">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive" name="-do-jar-without-manifest" unless="manifest.available-mkdist.available">
- <j2seproject1:jar/>
- </target>
- <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class-mkdist.available">
- <j2seproject1:jar manifest="${manifest.file}"/>
- </target>
- <target depends="init,compile,-pre-pre-jar,-pre-jar" if="do.archive+manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
- <j2seproject1:jar manifest="${manifest.file}">
- <j2seproject1:manifest>
- <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
- </j2seproject1:manifest>
- </j2seproject1:jar>
- <echo level="info">To run this application from the command line without Ant, try:</echo>
- <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
- <property location="${dist.jar}" name="dist.jar.resolved"/>
- <pathconvert property="run.classpath.with.dist.jar">
- <path path="${run.classpath}"/>
- <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
- </pathconvert>
- <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
- </target>
- <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available">
- <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
- <touch file="${tmp.manifest.file}"/>
- </target>
- <target depends="init" if="do.archive+manifest.available" name="-do-jar-with-libraries-copy-manifest">
- <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>
- <copy file="${manifest.file}" tofile="${tmp.manifest.file}"/>
- </target>
- <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+main.class.available" name="-do-jar-with-libraries-set-main">
- <manifest file="${tmp.manifest.file}" mode="update">
- <attribute name="Main-Class" value="${main.class}"/>
- </manifest>
- </target>
- <target depends="init,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest" if="do.archive+splashscreen.available" name="-do-jar-with-libraries-set-splashscreen">
- <basename file="${application.splash}" property="splashscreen.basename"/>
- <mkdir dir="${build.classes.dir}/META-INF"/>
- <copy failonerror="false" file="${application.splash}" todir="${build.classes.dir}/META-INF"/>
- <manifest file="${tmp.manifest.file}" mode="update">
- <attribute name="SplashScreen-Image" value="META-INF/${splashscreen.basename}"/>
- </manifest>
- </target>
- <target depends="init,-init-macrodef-copylibs,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen" if="do.mkdist" name="-do-jar-with-libraries-pack">
- <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
- <echo level="info">To run this application from the command line without Ant, try:</echo>
- <property location="${dist.jar}" name="dist.jar.resolved"/>
- <echo level="info">java -jar "${dist.jar.resolved}"</echo>
- </target>
- <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest">
- <delete>
- <fileset file="${tmp.manifest.file}"/>
- </delete>
- </target>
- <target depends="init,compile,-pre-pre-jar,-pre-jar,-do-jar-with-libraries-create-manifest,-do-jar-with-libraries-copy-manifest,-do-jar-with-libraries-set-main,-do-jar-with-libraries-set-splashscreen,-do-jar-with-libraries-pack,-do-jar-with-libraries-delete-manifest" name="-do-jar-with-libraries"/>
- <target name="-post-jar">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
- <!--
- =================
- EXECUTION SECTION
- =================
- -->
- <target depends="init,compile" description="Run a main class." name="run">
- <j2seproject1:java>
- <customize>
- <arg line="${application.args}"/>
- </customize>
- </j2seproject1:java>
- </target>
- <target name="-do-not-recompile">
- <property name="javac.includes.binary" value=""/>
- </target>
- <target depends="init,compile-single" name="run-single">
- <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
- <j2seproject1:java classname="${run.class}"/>
- </target>
- <target depends="init,compile-test-single" name="run-test-with-main">
- <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
- <j2seproject1:java classname="${run.class}" classpath="${run.test.classpath}"/>
- </target>
- <!--
- =================
- DEBUGGING SECTION
- =================
- -->
- <target depends="init" if="netbeans.home" name="-debug-start-debugger">
- <j2seproject1:nbjpdastart name="${debug.class}"/>
- </target>
- <target depends="init" if="netbeans.home" name="-debug-start-debugger-main-test">
- <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${debug.class}"/>
- </target>
- <target depends="init,compile" name="-debug-start-debuggee">
- <j2seproject3:debug>
- <customize>
- <arg line="${application.args}"/>
- </customize>
- </j2seproject3:debug>
- </target>
- <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
- <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
- <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
- </target>
- <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
- <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
- <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
- <j2seproject3:debug classname="${debug.class}"/>
- </target>
- <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
- <target depends="init,compile-test-single" if="netbeans.home" name="-debug-start-debuggee-main-test">
- <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
- <j2seproject3:debug classname="${debug.class}" classpath="${debug.test.classpath}"/>
- </target>
- <target depends="init,compile-test-single,-debug-start-debugger-main-test,-debug-start-debuggee-main-test" if="netbeans.home" name="debug-test-with-main"/>
- <target depends="init" name="-pre-debug-fix">
- <fail unless="fix.includes">Must set fix.includes</fail>
- <property name="javac.includes" value="${fix.includes}.java"/>
- </target>
- <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
- <j2seproject1:nbjpdareload/>
- </target>
- <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
- <!--
- =================
- PROFILING SECTION
- =================
- -->
- <target depends="profile-init,compile" description="Profile a project in the IDE." if="netbeans.home" name="profile">
- <nbprofiledirect>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- </nbprofiledirect>
- <profile/>
- </target>
- <target depends="profile-init,compile-single" description="Profile a selected class in the IDE." if="netbeans.home" name="profile-single">
- <fail unless="profile.class">Must select one file in the IDE or set profile.class</fail>
- <nbprofiledirect>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- </nbprofiledirect>
- <profile classname="${profile.class}"/>
- </target>
- <!--
- =========================
- APPLET PROFILING SECTION
- =========================
- -->
- <target depends="profile-init,compile-single" if="netbeans.home" name="profile-applet">
- <nbprofiledirect>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- </nbprofiledirect>
- <profile classname="sun.applet.AppletViewer">
- <customize>
- <arg value="${applet.url}"/>
- </customize>
- </profile>
- </target>
- <!--
- =========================
- TESTS PROFILING SECTION
- =========================
- -->
- <target depends="profile-init,compile-test-single" if="netbeans.home" name="profile-test-single">
- <nbprofiledirect>
- <classpath>
- <path path="${run.test.classpath}"/>
- </classpath>
- </nbprofiledirect>
- <junit dir="${profiler.info.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${profiler.info.jvm}" showoutput="true">
- <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
- <jvmarg value="${profiler.info.jvmargs.agent}"/>
- <jvmarg line="${profiler.info.jvmargs}"/>
- <test name="${profile.class}"/>
- <classpath>
- <path path="${run.test.classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <formatter type="brief" usefile="false"/>
- <formatter type="xml"/>
- </junit>
- </target>
- <!--
- ===============
- JAVADOC SECTION
- ===============
- -->
- <target depends="init" if="have.sources" name="-javadoc-build">
- <mkdir dir="${dist.javadoc.dir}"/>
- <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
- <classpath>
- <path path="${javac.classpath}"/>
- </classpath>
- <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
- <filename name="**/*.java"/>
- </fileset>
- <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
- <include name="**/*.java"/>
- </fileset>
- </javadoc>
- <copy todir="${dist.javadoc.dir}">
- <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
- <filename name="**/doc-files/**"/>
- </fileset>
- <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
- <include name="**/doc-files/**"/>
- </fileset>
- </copy>
- </target>
- <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
- <nbbrowse file="${dist.javadoc.dir}/index.html"/>
- </target>
- <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
- <!--
- =========================
- JUNIT COMPILATION SECTION
- =========================
- -->
- <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
- <mkdir dir="${build.test.classes.dir}"/>
- </target>
- <target name="-pre-compile-test">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target if="do.depend.true" name="-compile-test-depend">
- <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
- </target>
- <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
- <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" processorpath="${javac.test.processorpath}" srcdir="${test.src.dir}"/>
- <copy todir="${build.test.classes.dir}">
- <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
- </copy>
- </target>
- <target name="-post-compile-test">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
- <target name="-pre-compile-test-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-jar,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
- <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
- <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
- <j2seproject3:javac apgeneratedsrcdir="${build.test.classes.dir}" classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" processorpath="${javac.test.processorpath}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
- <copy todir="${build.test.classes.dir}">
- <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
- </copy>
- </target>
- <target name="-post-compile-test-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
- <!--
- =======================
- JUNIT EXECUTION SECTION
- =======================
- -->
- <target depends="init" if="have.tests" name="-pre-test-run">
- <mkdir dir="${build.test.results.dir}"/>
- </target>
- <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
- <j2seproject3:junit testincludes="**/*Test.java"/>
- </target>
- <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
- <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
- </target>
- <target depends="init" if="have.tests" name="test-report"/>
- <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
- <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
- <target depends="init" if="have.tests" name="-pre-test-run-single">
- <mkdir dir="${build.test.results.dir}"/>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
- <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
- <j2seproject3:junit excludes="" includes="${test.includes}"/>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
- <fail if="tests.failed" unless="ignore.failing.tests">Some tests failed; see details above.</fail>
- </target>
- <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
- <!--
- =======================
- JUNIT DEBUGGING SECTION
- =======================
- -->
- <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
- <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
- <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
- <delete file="${test.report.file}"/>
- <mkdir dir="${build.test.results.dir}"/>
- <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
- <customize>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper from="test-sys-prop.*" to="*" type="glob"/>
- </syspropertyset>
- <arg value="${test.class}"/>
- <arg value="showoutput=true"/>
- <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
- <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
- </customize>
- </j2seproject3:debug>
- </target>
- <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
- <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
- </target>
- <target depends="init,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
- <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
- <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
- </target>
- <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
- <!--
- =========================
- APPLET EXECUTION SECTION
- =========================
- -->
- <target depends="init,compile-single" name="run-applet">
- <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
- <j2seproject1:java classname="sun.applet.AppletViewer">
- <customize>
- <arg value="${applet.url}"/>
- </customize>
- </j2seproject1:java>
- </target>
- <!--
- =========================
- APPLET DEBUGGING SECTION
- =========================
- -->
- <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
- <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
- <j2seproject3:debug classname="sun.applet.AppletViewer">
- <customize>
- <arg value="${applet.url}"/>
- </customize>
- </j2seproject3:debug>
- </target>
- <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
- <!--
- ===============
- CLEANUP SECTION
- ===============
- -->
- <target name="-deps-clean-init" unless="built-clean.properties">
- <property location="${build.dir}/built-clean.properties" name="built-clean.properties"/>
- <delete file="${built-clean.properties}" quiet="true"/>
- </target>
- <target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
- <echo level="warn" message="Cycle detected: EssentialsServerlist was already built"/>
- </target>
- <target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
- <mkdir dir="${build.dir}"/>
- <touch file="${built-clean.properties}" verbose="false"/>
- <property file="${built-clean.properties}" prefix="already.built.clean."/>
- <antcall target="-warn-already-built-clean"/>
- <propertyfile file="${built-clean.properties}">
- <entry key="${basedir}" value=""/>
- </propertyfile>
- <antcall target="-maybe-call-dep">
- <param name="call.built.properties" value="${built-clean.properties}"/>
- <param location="${project.Essentials}" name="call.subproject"/>
- <param location="${project.Essentials}/build.xml" name="call.script"/>
- <param name="call.target" value="clean"/>
- <param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
- </antcall>
- </target>
- <target depends="init" name="-do-clean">
- <delete dir="${build.dir}"/>
- <delete dir="${dist.dir}" followsymlinks="false" includeemptydirs="true"/>
- </target>
- <target name="-post-clean">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
- <target name="-check-call-dep">
- <property file="${call.built.properties}" prefix="already.built."/>
- <condition property="should.call.dep">
- <not>
- <isset property="already.built.${call.subproject}"/>
- </not>
- </condition>
- </target>
- <target depends="-check-call-dep" if="should.call.dep" name="-maybe-call-dep">
- <ant antfile="${call.script}" inheritall="false" target="${call.target}">
- <propertyset>
- <propertyref prefix="transfer."/>
- <mapper from="transfer.*" to="*" type="glob"/>
- </propertyset>
- </ant>
- </target>
-</project>
diff --git a/EssentialsServerlist/nbproject/genfiles.properties b/EssentialsServerlist/nbproject/genfiles.properties deleted file mode 100644 index 3255d99dc..000000000 --- a/EssentialsServerlist/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=b3f32d5a
-build.xml.script.CRC32=d07c143a
-build.xml.stylesheet.CRC32=28e38971@1.38.2.45
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=28f52c06
-nbproject/build-impl.xml.script.CRC32=bdef3982
-nbproject/build-impl.xml.stylesheet.CRC32=19debb58@1.42.1.45
diff --git a/EssentialsServerlist/nbproject/project.properties b/EssentialsServerlist/nbproject/project.properties deleted file mode 100644 index 535a1673b..000000000 --- a/EssentialsServerlist/nbproject/project.properties +++ /dev/null @@ -1,76 +0,0 @@ -annotation.processing.enabled=true
-annotation.processing.enabled.in.editor=false
-annotation.processing.run.all.processors=true
-annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
-application.title=EssentialsServerlist
-application.vendor=Paul
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-build.generated.sources.dir=${build.dir}/generated-sources
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-# Uncomment to specify the preferred debugger connection transport:
-#debug.transport=dt_socket
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/EssentialsServerlist.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-endorsed.classpath=
-excludes=
-file.reference.craftbukkit-0.0.1-SNAPSHOT.jar-1=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
-includes=**
-jar.compress=false
-javac.classpath=\
- ${reference.Essentials.jar}:\
- ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar-1}
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.processorpath=\
- ${javac.classpath}
-javac.source=1.5
-javac.target=1.5
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${libs.junit.classpath}:\
- ${libs.junit_4.classpath}
-javac.test.processorpath=\
- ${javac.test.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=${source.encoding}
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-meta.inf.dir=${src.dir}/META-INF
-platform.active=default_platform
-project.Essentials=../Essentials
-reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-source.encoding=UTF-8
-src.dir=src
-test.src.dir=test
diff --git a/EssentialsServerlist/nbproject/project.xml b/EssentialsServerlist/nbproject/project.xml deleted file mode 100644 index a65ec9af8..000000000 --- a/EssentialsServerlist/nbproject/project.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.netbeans.org/ns/project/1">
- <type>org.netbeans.modules.java.j2seproject</type>
- <configuration>
- <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
- <name>EssentialsServerlist</name>
- <source-roots>
- <root id="src.dir"/>
- </source-roots>
- <test-roots>
- <root id="test.src.dir"/>
- </test-roots>
- </data>
- <libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
- <definitions>../lib\nblibraries.properties</definitions>
- </libraries>
- <references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
- <reference>
- <foreign-project>Essentials</foreign-project>
- <artifact-type>jar</artifact-type>
- <script>build.xml</script>
- <target>jar</target>
- <clean-target>clean</clean-target>
- <id>jar</id>
- </reference>
- </references>
- </configuration>
-</project>
diff --git a/EssentialsServerlist/src/net/mcserverlist/bukkit/Mcsl.java b/EssentialsServerlist/src/net/mcserverlist/bukkit/Mcsl.java deleted file mode 100644 index c9b234fd7..000000000 --- a/EssentialsServerlist/src/net/mcserverlist/bukkit/Mcsl.java +++ /dev/null @@ -1,149 +0,0 @@ -package net.mcserverlist.bukkit; - -import com.earth2me.essentials.Essentials; -import java.io.*; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.event.Event; -import org.bukkit.event.Event.Priority; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.plugin.java.JavaPlugin; - - -public class Mcsl extends JavaPlugin -{ - private static final Logger logger = Logger.getLogger("Minecraft"); - private McslPlayerListener playerListener; - public final String author; - - public Mcsl() throws IOException - { - - PluginDescriptionFile desc = this.getDescription(); - - // Compile author list - List<String> authors = new ArrayList<String>(); - authors.add("Vimae Development"); - int alen = authors.size(); - if (alen == 1) - { - author = " by " + authors.get(0); - } - else if (alen > 1) - { - int i = 0; - StringBuilder bldr = new StringBuilder(); - for (String a : desc.getAuthors()) - { - if (i + 1 == alen) - { - if (alen > 2) bldr.append(","); - bldr.append(" and "); - } - else if (i++ > 0) - { - bldr.append(", "); - } - bldr.append(a); - } - bldr.insert(0, " by "); - author = bldr.toString(); - } - else - { - author = ""; - } - } - - @Override - public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) - { - McslCommands mcslCmd; - try - { - switch (McslCommands.valueOf(cmd.getName().toUpperCase())) - { - case WHITELIST: - whitelist(sender, WhitelistCommands.valueOf(args[0].toUpperCase()), args); - return true; - - default: - return false; - } - } - catch (IllegalArgumentException ex) - { - return false; - } - catch (Exception ex) - { - logger.log(Level.WARNING, "MCSL encountered an unknown error.", ex); - sender.sendMessage("MCSL encountered an unknown error."); - return true; - } - } - - @SuppressWarnings("LoggerStringConcat") - public void onEnable() - { - Plugin p = this.getServer().getPluginManager().getPlugin("Essentials"); - if (p != null) { - if (!this.getServer().getPluginManager().isPluginEnabled(p)) { - this.getServer().getPluginManager().enablePlugin(p); - } - } - playerListener = new McslPlayerListener(this); - getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Monitor, this); - getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this); - getServer().getPluginManager().registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Lowest, this); - - if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion())) { - logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version."); - } - logger.info(getDescription().getName() + " version " + getDescription().getVersion() + author + " enabled."); - } - - @SuppressWarnings("LoggerStringConcat") - public void onDisable() - { - logger.info(getDescription().getName() + " version " + getDescription().getVersion() + " disabled."); - } - - private void whitelist(CommandSender sender, WhitelistCommands cmd, String[] args) - { - if (!playerListener.isWhitelistEnabled()) - { - sender.sendMessage("§cThe whitelist is disabled."); - return; - } - - if (!sender.isOp()) - { - sender.sendMessage("§cYou must be an operator to manage the whitelist."); - return; - } - - switch (cmd) - { - case RELOAD: - playerListener.whitelistReload(); - sender.sendMessage("A whitelist updated has been queued."); - break; - } - } - - private enum McslCommands - { - WHITELIST - } - - private enum WhitelistCommands - { - RELOAD - } -} diff --git a/EssentialsServerlist/src/net/mcserverlist/bukkit/McslPlayerListener.java b/EssentialsServerlist/src/net/mcserverlist/bukkit/McslPlayerListener.java deleted file mode 100644 index 63e4343d2..000000000 --- a/EssentialsServerlist/src/net/mcserverlist/bukkit/McslPlayerListener.java +++ /dev/null @@ -1,209 +0,0 @@ -package net.mcserverlist.bukkit; - -import com.earth2me.essentials.Essentials; -import java.io.*; -import java.net.*; -import java.util.logging.*; -import org.bukkit.*; -import org.bukkit.entity.*; -import org.bukkit.event.player.*; - - -public class McslPlayerListener extends PlayerListener -{ - private final static Logger logger = Logger.getLogger("Minecraft"); - private boolean running = true; - private final Server server; - private Thread thread; - private Whitelist whitelist = null; - private volatile boolean updateNeeded = true; - - @SuppressWarnings("CallToThreadStartDuringObjectConstruction") - public McslPlayerListener(Mcsl parent) - { - this.server = parent.getServer(); - - // Get the data from the server.properties file as the server sees it, rather than reading it manually - try - { - this.whitelist = new Whitelist(server); - } - catch (Throwable ex) - { - // Disable the plugin - logger.log(Level.WARNING, "Error encountered while initializing MCServerlist plugin.", ex); - parent.getPluginLoader().disablePlugin(parent); - return; - } - - // Run Update on a set interval of 1 minute with an initial delay of 10 seconds - thread = new Thread(new UpdateRunnable()); - thread.setDaemon(true); - thread.start(); - } - - @Override - @SuppressWarnings("FinalizeDeclaration") - protected void finalize() throws Throwable - { - // Stop the timer - if (thread != null && thread.isAlive()) - { - running = false; - thread.join(); - } - - super.finalize(); - } - - @Override - public void onPlayerLogin(PlayerLoginEvent event) - { - if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) - return; - - Player player = event.getPlayer(); - - // Check the whitelist - if (!Essentials.getSettings().getWhitelistEnabled() || player.isOp() || whitelist == null || whitelist.isAllowed(player.getName())) - { - // Player is an op, there is no whitelist, or the player is whitelisted. - return; - } - - // Player is not whitelisted. - event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This server employs a whitelist."); - } - - @Override - public void onPlayerJoin(PlayerEvent event) - { - update(); - } - - @Override - public void onPlayerQuit(PlayerEvent event) - { - update(); - } - - public boolean isWhitelistEnabled() - { - return whitelist != null; - } - - public void whitelistReload() - { - whitelist.update(); - } - - public void update() - { - updateNeeded = true; - } - - - private class UpdateRunnable implements Runnable - { - @SuppressWarnings("SleepWhileInLoop") - public void run() - { - do - { - if (updateNeeded) - { - updateNeeded = false; - update(); - } - - try - { - Thread.sleep(60000); - } - catch (InterruptedException ex) - { - logger.info("Forcing MCServerlist update."); - } - } - while (running); - } - - @SuppressWarnings("CallToThreadDumpStack") - public void update() - { - // Check that we aren't receiving an event inappropriately - if (Essentials.getSettings().getMcslKey() == null || Essentials.getSettings().getMcslKey().equals("")) return; - // Compile a comma-space-delimted list of players - Player[] players = server.getOnlinePlayers(); - StringBuilder list = new StringBuilder(); - if (players.length > 0) - { - for (int i = 0; i < players.length; i++) - { - if (i > 0) list.append(", "); - list.append(players[i].getName()); - } - } - - try - { - // Compile POST data - StringBuilder data = new StringBuilder(); - data.append("key="); - data.append(URLEncoder.encode(Essentials.getSettings().getMcslKey(), "UTF-8")); - data.append("&player_count="); - data.append(Integer.toString(players.length)); - data.append("&max_players="); - data.append(Integer.toString(server.getMaxPlayers())); - data.append("&player_list="); - data.append(URLEncoder.encode(list.toString(), "UTF-8")); - - OutputStreamWriter tx = null; - BufferedReader rx = null; - try - { - // Send POST request - URL url = new URL("http://mcserverlist.net/api/update"); - // Swap line for testing purposes - //URL url = new URL("http://localhost/mcsl/update.php"); - HttpURLConnection http = (HttpURLConnection)url.openConnection(); - http.setRequestMethod("POST"); - http.setUseCaches(false); - http.setConnectTimeout(1000); - http.setAllowUserInteraction(false); - http.setInstanceFollowRedirects(true); - http.setRequestProperty("User-Agent", "Java;Mcsl"); - http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); - http.setRequestProperty("X-Mcsl-Key", Essentials.getSettings().getMcslKey()); - http.setRequestProperty("X-Minecraft-Name", URLEncoder.encode(server.getName(), "UTF-8")); - http.setRequestProperty("X-Minecraft-Version", server.getVersion()); - http.setDoInput(true); - http.setDoOutput(true); - tx = new OutputStreamWriter(http.getOutputStream()); - tx.write(data.toString()); - tx.flush(); - - // Get the HTTP response - rx = new BufferedReader(new InputStreamReader(http.getInputStream())); - for (String l = ""; rx.ready(); l = rx.readLine()) - { - if ("".equals(l)) continue; - else if (l.startsWith("i:")) logger.info(l.substring(2)); - else if (l.startsWith("w:")) logger.warning(l.substring(2)); - else System.out.println(l); - } - } - finally - { - if (tx != null) tx.close(); - if (rx != null) rx.close(); - } - } - catch (Exception ex) - { - logger.log(Level.WARNING, "Error communication with MCServerlist.", ex); - ex.printStackTrace(); - } - } - } -} diff --git a/EssentialsServerlist/src/net/mcserverlist/bukkit/Whitelist.java b/EssentialsServerlist/src/net/mcserverlist/bukkit/Whitelist.java deleted file mode 100644 index 96a96ecbc..000000000 --- a/EssentialsServerlist/src/net/mcserverlist/bukkit/Whitelist.java +++ /dev/null @@ -1,107 +0,0 @@ -package net.mcserverlist.bukkit; - -import com.earth2me.essentials.Essentials; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.bukkit.Server; - - -public class Whitelist -{ - private static final Logger logger = Logger.getLogger("Minecraft"); - private List<String> allowed = new ArrayList<String>(); - private final Object allowedLock = new Object(); - private Server server; - - public Whitelist(Server server) - { - this.server = server; - } - - public void update() - { - Thread thread = new Thread(new UpdateRunnable()); - thread.setDaemon(true); - thread.start(); - } - - public boolean isAllowed(String player) - { - String p = player.toLowerCase(); - synchronized (allowedLock) - { - return allowed.contains(p); - } - } - - private class UpdateRunnable implements Runnable - { - @SuppressWarnings("CallToThreadDumpStack") - public void run() - { - // Check that we aren't receiving an event inappropriately - if (Essentials.getSettings().getMcslKey() == null || Essentials.getSettings().getMcslKey().equals("")) return; - - try - { - OutputStreamWriter tx = null; - BufferedReader rx = null; - try - { - // Send GET request - URL url = new URL("http://mcserverlist.net/api/whitelist"); - // Swap line for testing purposes - //URL url = new URL("http://localhost/mcsl/whitelist.php"); - HttpURLConnection http = (HttpURLConnection)url.openConnection(); - http.setRequestMethod("POST"); - http.setUseCaches(false); - http.setConnectTimeout(1000); - http.setAllowUserInteraction(false); - http.setInstanceFollowRedirects(true); - http.setRequestProperty("User-Agent", "Java;Mcsl"); - http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); - http.setRequestProperty("X-Mcsl-Key", Essentials.getSettings().getMcslKey()); - http.setRequestProperty("X-Minecraft-Name", URLEncoder.encode(server.getName(), "UTF-8")); - http.setRequestProperty("X-Minecraft-Version", server.getVersion()); - http.setDoInput(true); - http.setDoOutput(false); - - // Get the HTTP response - rx = new BufferedReader(new InputStreamReader(http.getInputStream())); - List<String> allowed = new ArrayList<String>(); - for (String l = ""; rx.ready(); l = rx.readLine()) - { - if ("".equals(l)) continue; - else if (l.startsWith("i:")) logger.info(l.substring(2)); - else if (l.startsWith("w:")) logger.warning(l.substring(2)); - else allowed.add(l.toLowerCase()); // Add to whitelist - } - - synchronized (Whitelist.this.allowedLock) - { - Whitelist.this.allowed = allowed; - allowed = null; // Remove our reference so that we don't accidentally use it - } - } - finally - { - if (tx != null) tx.close(); - if (rx != null) rx.close(); - } - } - catch (Exception ex) - { - logger.log(Level.WARNING, "Error communication with MCServerlist.", ex); - ex.printStackTrace(); - } - } - } -} diff --git a/EssentialsServerlist/src/plugin.yml b/EssentialsServerlist/src/plugin.yml deleted file mode 100644 index cb6d7bddc..000000000 --- a/EssentialsServerlist/src/plugin.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: EssentialsServerlist
-main: net.mcserverlist.bukkit.Mcsl
-version: TeamCity
-website: http://mcserverlist.net/
-description: Official MCServerlist API implementation
\ No newline at end of file diff --git a/EssentialsSpawn/nbproject/private/private.properties b/EssentialsSpawn/nbproject/private/private.properties new file mode 100644 index 000000000..94183418a --- /dev/null +++ b/EssentialsSpawn/nbproject/private/private.properties @@ -0,0 +1 @@ +user.properties.file=C:\\Users\\Paul\\.netbeans\\7.0beta2\\build.properties
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java index 1891e87f4..697939daa 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -4,7 +4,7 @@ import com.earth2me.essentials.Essentials; import com.earth2me.essentials.User; import java.util.logging.Level; import java.util.logging.Logger; -import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerRespawnEvent; @@ -32,7 +32,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener } @Override - public void onPlayerJoin(PlayerEvent event) + public void onPlayerJoin(PlayerJoinEvent event) { Essentials.loadClasses(); User user = User.get(event.getPlayer()); diff --git a/lib/c3p0-0.9.1.2.jar b/lib/c3p0-0.9.1.2.jar Binary files differnew file mode 100644 index 000000000..0f42d60e3 --- /dev/null +++ b/lib/c3p0-0.9.1.2.jar diff --git a/lib/craftbukkit-0.0.1-SNAPSHOT.jar b/lib/craftbukkit-0.0.1-SNAPSHOT.jar Binary files differindex fd06a399e..747976e87 100644 --- a/lib/craftbukkit-0.0.1-SNAPSHOT.jar +++ b/lib/craftbukkit-0.0.1-SNAPSHOT.jar |