From a3ebd254f2897951a2ce31fdd90b6944c582d82b Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 19 Mar 2011 22:39:51 +0000 Subject: Moving all files to trunk. git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@969 e251c2fe-e539-e718-e476-b85c1f46cddb --- EssentialsProtect/MANIFEST.MF | 2 + EssentialsProtect/build.xml | 86 ++ EssentialsProtect/nbproject/build-impl.xml | 1072 ++++++++++++++++++++ EssentialsProtect/nbproject/genfiles.properties | 8 + EssentialsProtect/nbproject/project.properties | 89 ++ EssentialsProtect/nbproject/project.xml | 28 + EssentialsProtect/src/README.TXT | 30 + .../essentials/protect/EssentialsProtect.java | 122 +++ .../protect/EssentialsProtectBlockListener.java | 274 +++++ .../essentials/protect/EssentialsProtectData.java | 533 ++++++++++ .../protect/EssentialsProtectEntityListener.java | 197 ++++ .../protect/EssentialsProtectPlayerListener.java | 73 ++ .../protect/EssentialsProtectRegions.java | 5 + .../protect/EssentialsProtectSqlProperties.java | 12 + EssentialsProtect/src/plugin.yml | 8 + 15 files changed, 2539 insertions(+) create mode 100644 EssentialsProtect/MANIFEST.MF create mode 100644 EssentialsProtect/build.xml create mode 100644 EssentialsProtect/nbproject/build-impl.xml create mode 100644 EssentialsProtect/nbproject/genfiles.properties create mode 100644 EssentialsProtect/nbproject/project.properties create mode 100644 EssentialsProtect/nbproject/project.xml create mode 100644 EssentialsProtect/src/README.TXT create mode 100644 EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java create mode 100644 EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java create mode 100644 EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectData.java create mode 100644 EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java create mode 100644 EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java create mode 100644 EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectRegions.java create mode 100644 EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectSqlProperties.java create mode 100644 EssentialsProtect/src/plugin.yml (limited to 'EssentialsProtect') diff --git a/EssentialsProtect/MANIFEST.MF b/EssentialsProtect/MANIFEST.MF new file mode 100644 index 000000000..b43aa699e --- /dev/null +++ b/EssentialsProtect/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +Class-Path: ../lib/mysql.jar ../lib/sqlite.jar diff --git a/EssentialsProtect/build.xml b/EssentialsProtect/build.xml new file mode 100644 index 000000000..e5e614e3e --- /dev/null +++ b/EssentialsProtect/build.xml @@ -0,0 +1,86 @@ + + ]> + + + + + + + + + + Builds, tests, and runs the project EssentialsProtect. + + + + + + + + + + + + + + diff --git a/EssentialsProtect/nbproject/build-impl.xml b/EssentialsProtect/nbproject/build-impl.xml new file mode 100644 index 000000000..d284d9279 --- /dev/null +++ b/EssentialsProtect/nbproject/build-impl.xml @@ -0,0 +1,1072 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + java -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + + + + + + + + Must select one file in the IDE or set profile.class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EssentialsProtect/nbproject/genfiles.properties b/EssentialsProtect/nbproject/genfiles.properties new file mode 100644 index 000000000..3f48945cc --- /dev/null +++ b/EssentialsProtect/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=ff207988 +build.xml.script.CRC32=1ed11cc3 +build.xml.stylesheet.CRC32=28e38971@1.38.3.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=40644caa +nbproject/build-impl.xml.script.CRC32=1d86f3b0 +nbproject/build-impl.xml.stylesheet.CRC32=19debb58@1.42.1.45 diff --git a/EssentialsProtect/nbproject/project.properties b/EssentialsProtect/nbproject/project.properties new file mode 100644 index 000000000..dcce6d152 --- /dev/null +++ b/EssentialsProtect/nbproject/project.properties @@ -0,0 +1,89 @@ +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=EssentialsProtect +application.vendor=devhome +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}/original-EssentialsProtect.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +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 +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=false +jar.index=${jnlp.enabled} +javac.classpath=\ + ${reference.Essentials.jar}:\ + ${file.reference.mysql.jar}:\ + ${file.reference.sqlite.jar}:\ + ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar} +# 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= +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=defaut +jnlp.offline-allowed=false +jnlp.signed=false +manifest.file=manifest.mf +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/EssentialsProtect/nbproject/project.xml b/EssentialsProtect/nbproject/project.xml new file mode 100644 index 000000000..821d66672 --- /dev/null +++ b/EssentialsProtect/nbproject/project.xml @@ -0,0 +1,28 @@ + + + org.netbeans.modules.java.j2seproject + + + EssentialsProtect + + + + + + + + + ../lib\nblibraries.properties + + + + Essentials + jar + + jar + clean + jar + + + + diff --git a/EssentialsProtect/src/README.TXT b/EssentialsProtect/src/README.TXT new file mode 100644 index 000000000..4bb1b5c05 --- /dev/null +++ b/EssentialsProtect/src/README.TXT @@ -0,0 +1,30 @@ +EssentialsProtect: + +REQUIRED : Essentials.jar. Also sqlite.jar, mysql.jar in the bukkit lib folder. + +Config Settings in plugins/Essentials/config.yml + +protect: + datatype: 'sqlite' type of db, options sqlite or mysql + username: 'root' mysql username + pasword: 'root' mysql password + mysqlDb: 'jdbc:mysql://localhost:3306/minecraft' mysql database location + protectSigns: true + protectRails: true + protectBlockBelow: true + preventBlockOnRail: false prevents block placement on protected rails + +On startup creates a sqlite database under /plugins/essentials called EssentialsProtect.db + +Permissions: + +"essentials.protect" - allows protection +"essentials.protect.admin" can delete protected blocks / query protection by right clicking a protected item. + +Usage: + +Place a sign or rail and they (plus optionally the block below) will be protected. Only the owners and those with admin permissions can destroy. + + + + diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java new file mode 100644 index 000000000..a2c577789 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -0,0 +1,122 @@ +package com.earth2me.essentials.protect; + +import com.earth2me.essentials.Essentials; +import com.earth2me.essentials.User; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.event.Event.Priority; +import org.bukkit.event.Event.Type; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; + + +public class EssentialsProtect extends JavaPlugin +{ + private EssentialsProtectBlockListener blockListener = null; + private EssentialsProtectPlayerListener playerListener = null; + private EssentialsProtectEntityListener entityListener = null; + public static final String AUTHORS = Essentials.AUTHORS; + private static final Logger logger = Logger.getLogger("Minecraft"); + public static HashMap genSettings = null; + public static HashMap dataSettings = null; + public static HashMap guardSettings = null; + public static HashMap playerSettings = null; + public static ArrayList usageList = null; + public static ArrayList blackListPlace = null; + public static ArrayList breakBlackList = null; + public static ArrayList onPlaceAlert = null; + public static ArrayList onUseAlert = null; + public static ArrayList onBreakAlert = null; + + + public EssentialsProtect() + { + } + + public void onEnable() + { + PluginManager pm = this.getServer().getPluginManager(); + Essentials ess = (Essentials)pm.getPlugin("Essentials"); + if (!ess.isEnabled()) + pm.enablePlugin(ess); + + 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.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.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."); + } + logger.info("Loaded " + this.getDescription().getName() + " build " + this.getDescription().getVersion() + " maintained by " + AUTHORS); + } + + public static boolean checkProtectionItems(ArrayList itemList, int id) + { + return !itemList.isEmpty() && itemList.contains(String.valueOf(id)); + } + + @Override + public void onDisable() + { + genSettings.clear(); + dataSettings.clear(); + + blockListener = null; + playerListener = null; + entityListener = null; + genSettings = null; + dataSettings = null; + guardSettings = null; + playerSettings = null; + usageList = null; + blackListPlace = null; + onPlaceAlert = null; + onUseAlert = null; + onBreakAlert = null; + } + + public static void loadSettings() + { + dataSettings = Essentials.getSettings().getEpDBSettings(); + genSettings = Essentials.getSettings().getEpSettings(); + guardSettings = Essentials.getSettings().getEpGuardSettings(); + usageList = Essentials.getSettings().epBlackListUsage(); + blackListPlace = Essentials.getSettings().epBlackListPlacement(); + breakBlackList = Essentials.getSettings().epBlockBreakingBlacklist(); + onPlaceAlert = Essentials.getSettings().getEpAlertOnPlacement(); + 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())); + } + } +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java new file mode 100644 index 000000000..43b508a58 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java @@ -0,0 +1,274 @@ +package com.earth2me.essentials.protect; + +import com.earth2me.essentials.Essentials; +import com.earth2me.essentials.User; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.block.Block; +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) + { + Essentials.loadClasses(); + 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()); + + if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild()) + { + event.setCancelled(true); + return; + } + + Block blockPlaced = event.getBlockAgainst(); + int id = event.getBlockPlaced().getTypeId(); + + if (EssentialsProtect.checkProtectionItems(EssentialsProtect.blackListPlace, id) && !user.isAuthorized("essentials.protect.exemptplacement")) + { + event.setCancelled(true); + return; + } + + if (!EssentialsProtect.onPlaceAlert.isEmpty() && EssentialsProtect.onPlaceAlert.contains(String.valueOf(item.getTypeId()))) + { + parent.alert(user, item.getType().toString(), "placed: "); + } + + if (spData.isBlockAboveProtectedRail(blockPlaced)) + { + if (EssentialsProtect.genSettings.get("protect.protect.prevent.block-on-rail")) + { + event.setCancelled(true); + return; + } + } + + if (item.getTypeId() == 66) + { + 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); + if (EssentialsProtect.genSettings.get("protect.protect.block-below")) + { + spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), railBlockX, railBlockY, railBlockZ); + } + } + } + } + } + + @Override + public void onBlockIgnite(BlockIgniteEvent event) + { + Block block = event.getBlock(); + if (block.getType() == Material.RAILS && EssentialsProtect.genSettings.get("protect.protect.rails")) + { + event.setCancelled(true); + return; + } + if ((block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) && EssentialsProtect.genSettings.get("protect.protect.signs")) + { + event.setCancelled(true); + return; + } + if ((event.getCause().equals(BlockIgniteEvent.IgniteCause.SPREAD))) + { + event.setCancelled(EssentialsProtect.guardSettings.get("protect.prevent.fire-spread")); + return; + } + + if (event.getCause().equals(BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL)) + { + event.setCancelled(EssentialsProtect.guardSettings.get("protect.prevent.flint-fire")); + return; + } + + if (event.getCause().equals(BlockIgniteEvent.IgniteCause.LAVA)) + { + event.setCancelled(EssentialsProtect.guardSettings.get("protect.prevent.lava-fire-spread")); + return; + } + } + + @Override + public void onBlockFlow(BlockFromToEvent event) + { + if (event.isCancelled()) return; + Block block = event.getBlock(); + Block toBlock = event.getToBlock(); + if (toBlock.getType() == Material.RAILS && EssentialsProtect.genSettings.get("protect.protect.rails")) + { + event.setCancelled(true); + return; + } + if ((toBlock.getType() == Material.WALL_SIGN || toBlock.getType() == Material.SIGN_POST) && EssentialsProtect.genSettings.get("protect.protect.signs")) + { + event.setCancelled(true); + return; + } + if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) + { + event.setCancelled(EssentialsProtect.guardSettings.get("protect.prevent.water-flow")); + return; + } + + if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) + { + event.setCancelled(EssentialsProtect.guardSettings.get("protect.prevent.lava-flow")); + return; + } + + if (block.getType() == Material.AIR) + { + event.setCancelled(EssentialsProtect.guardSettings.get("protect.prevent.water-bucket-flow")); + return; + } + } + + @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(); + if (block.getType() == Material.RAILS && EssentialsProtect.genSettings.get("protect.protect.rails")) + { + event.setCancelled(true); + return; + } + if ((block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST) && EssentialsProtect.genSettings.get("protect.protect.signs")) + { + event.setCancelled(true); + return; + } + if (EssentialsProtect.guardSettings.get("protect.prevent.fire-spread")) + { + event.setCancelled(true); + return; + } + } + + @Override + 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()) + { + event.setCancelled(true); + return; + } + + if(EssentialsProtect.breakBlackList.contains(String.valueOf(block.getTypeId())) && !user.isAuthorized("essentials.protect.exemptbreak")) + { + event.setCancelled(true); + return; + } + + if (!EssentialsProtect.onBreakAlert.isEmpty() && EssentialsProtect.onBreakAlert.contains(String.valueOf(block.getTypeId()))) + { + parent.alert(user, block.getType().toString(), "broke: "); + } + + if (user.isAuthorized("essentials.protect.admin")) + { + if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.RAILS) + { + spData.removeProtectionFromDB(block, true); + } + else + { + spData.removeProtectionFromDB(block); + } + return; + } + else + { + boolean canDestroy = spData.canDestroy(user.getWorld().getName(), user.getName(), block); + if (canDestroy) + { + if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.RAILS) + { + spData.removeProtectionFromDB(block, true); + } + else + { + spData.removeProtectionFromDB(block); + } + return; + } + event.setCancelled(true); + return; + } + } +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectData.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectData.java new file mode 100644 index 000000000..76b36d810 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectData.java @@ -0,0 +1,533 @@ +package com.earth2me.essentials.protect; + +import com.earth2me.essentials.Essentials; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.bukkit.block.Block; + + +public class EssentialsProtectData +{ + private static final Logger logger = Logger.getLogger("Minecraft"); + private static final String mysqlDriver = "com.mysql.jdbc.Driver"; + private static String mysqlUsername; + private static String mysqlPassword; + private static String mysqlDatabase; + private static String dataType; + private static final String sqlite = "jdbc:sqlite:plugins/Essentials/EssentialsProtect.db"; + private static final String mysqlTable; + private static final String sqliteTable; + private static final String insertQuery; + private static final String countByLocationQuery; + private static final String countByPlayerLocationQuery; + private static final String playerByLocationQuery; + private static final String deleteByLocationQuery; + + static + { + mysqlTable = EssentialsProtectSqlProperties.EssentialsProtect; + sqliteTable = EssentialsProtectSqlProperties.EssentialsProtect_sqlite; + insertQuery = EssentialsProtectSqlProperties.Insert; + countByLocationQuery = EssentialsProtectSqlProperties.CountByLocation; + countByPlayerLocationQuery = EssentialsProtectSqlProperties.CountByPLayerLocation; + playerByLocationQuery = EssentialsProtectSqlProperties.PlayerByLocation; + deleteByLocationQuery = EssentialsProtectSqlProperties.DeleteByLocation; + mysqlUsername = EssentialsProtect.dataSettings.get("protect.username"); + mysqlPassword = EssentialsProtect.dataSettings.get("protect.password"); + mysqlDatabase = EssentialsProtect.dataSettings.get("protect.mysqlDb"); + dataType = EssentialsProtect.dataSettings.get("protect.datatype"); + } + + public EssentialsProtectData() + { + } + + public static String formatCoords(int x, int y, int z) + { + return x + "," + y + "," + z; + } + + public void insertProtectionIntoDb(String worldname, String playerName, int x, int y, int z) + { + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs = null; + try + { + if (dataType.contentEquals("mysql")) + { + Class.forName(mysqlDriver); + conn = DriverManager.getConnection(mysqlDatabase, mysqlUsername, mysqlPassword); + } + else + { + Class.forName("org.sqlite.JDBC"); + conn = DriverManager.getConnection(sqlite); + } + ps = conn.prepareStatement(insertQuery); + ps.setString(1, worldname); + ps.setString(2, playerName); + ps.setInt(3, x); + ps.setInt(4, y); + ps.setInt(5, z); + ps.executeUpdate(); + + } + catch (SQLException ex) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unable to add protection into SQL", ex); + } + catch (ClassNotFoundException e) + { + // TODO Auto-generated catch block + logger.log(Level.SEVERE, "[EssentialsProtect] Class not found", e); + } + finally + { + try + { + if (ps != null) + { + ps.close(); + } + if (rs != null) + { + rs.close(); + } + if (conn != null) + { + conn.close(); + } + } + catch (SQLException ex) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Could not close connection to SQL", ex); + } + } + } + + public boolean canDestroy(String worldName, String playerName, Block block) + { + int x = block.getX(); + int y = block.getY(); + int z = block.getZ(); + + int rowCount = 0; + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs = null; + try + { + if (dataType.contentEquals("mysql")) + { + Class.forName(mysqlDriver); + conn = DriverManager.getConnection(mysqlDatabase, mysqlUsername, mysqlPassword); + } + else + { + Class.forName("org.sqlite.JDBC"); + conn = DriverManager.getConnection(sqlite); + } + conn.setAutoCommit(false); + ps = conn.prepareStatement(countByLocationQuery); + ps.setString(1, worldName); + ps.setInt(2, x); + ps.setInt(3, y); + ps.setInt(4, z); + rs = ps.executeQuery(); + rs.next(); + rowCount = rs.getInt(1); + rs.close(); + ps.close(); + + if (rowCount == 0) + { + return true; + } + else + { + ps = conn.prepareStatement(countByPlayerLocationQuery); + ps.setString(1, worldName); + ps.setString(2, playerName); + ps.setInt(3, x); + ps.setInt(4, y); + ps.setInt(5, z); + rs = ps.executeQuery(); + rs.next(); + rowCount = rs.getInt(1); + + if (rowCount == 0) + { + return false; + } + + } + + } + catch (SQLException ex) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unable to query Protection", ex); + } + catch (Throwable e) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unable to query Protection", e); + } + finally + { + try + { + if (ps != null) + { + ps.close(); + } + if (rs != null) + { + rs.close(); + } + if (conn != null) + { + conn.close(); + } + } + catch (SQLException ex) + { + logger.log(Level.SEVERE, "[EssentialsProtection] Could not close connection to SQL", ex); + } + } + return true; + } + + @SuppressWarnings("CallToThreadDumpStack") + public static void createSqlTable() + { + Connection conn = null; + Statement st = null; + + try + { + if (dataType.contentEquals("mysql")) + { + Class.forName(mysqlDriver); + conn = DriverManager.getConnection(mysqlDatabase, mysqlUsername, mysqlPassword); + } + else + { + Class.forName("org.sqlite.JDBC"); + conn = DriverManager.getConnection(sqlite); + } + + st = conn.createStatement(); + st.executeUpdate(dataType.contentEquals("mysql") ? mysqlTable : sqliteTable); + } + catch (SQLException s) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Could not create table for " + dataType, s); + + } + catch (ClassNotFoundException ex) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Could not find driver for " + dataType, ex); + + } + catch (Throwable e) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unexpected error occured whilst creating table ", e); + } + finally + { + try + { + if (conn != null && !conn.isClosed()) + { + try + { + conn.close(); + } + catch (SQLException e) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unexpected error occured whilst closing the connection", e); + } + } + } + catch (SQLException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + public String getBlockOwner(String worldName, String playerName, Block block) + { + String returnPlayerName = null; + int x = block.getX(); + int y = block.getY(); + int z = block.getZ(); + + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs = null; + try + { + if (dataType.contentEquals("mysql")) + { + Class.forName(mysqlDriver); + conn = DriverManager.getConnection(mysqlDatabase, mysqlUsername, mysqlPassword); + } + else + { + Class.forName("org.sqlite.JDBC"); + conn = DriverManager.getConnection(sqlite); + } + conn.setAutoCommit(false); + ps = conn.prepareStatement(playerByLocationQuery); + + ps.setString(1, worldName); + ps.setInt(2, x); + ps.setInt(3, y); + ps.setInt(4, z); + rs = ps.executeQuery(); + while (rs.next()) + { + returnPlayerName = rs.getString("playerName"); + } + rs.close(); + ps.close(); + + } + catch (SQLException ex) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unable to query EssentialsProtection", ex); + } + catch (Throwable e) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unable to query EssentialsProtection", e); + } + finally + { + try + { + if (ps != null) + { + ps.close(); + } + if (rs != null) + { + rs.close(); + } + if (conn != null) + { + conn.close(); + } + } + catch (SQLException ex) + { + logger.log(Level.SEVERE, "[EssentialsProtection] Could not close connection to SQL", ex); + } + + } + return returnPlayerName; + } + + + public void removeProtectionFromDB(Block block) + { + try + { + Connection conn = null; + if (dataType.contentEquals("mysql")) + { + Class.forName(mysqlDriver); + conn = DriverManager.getConnection(mysqlDatabase, mysqlUsername, + mysqlPassword); + } + else + { + Class.forName("org.sqlite.JDBC"); + conn = DriverManager.getConnection(sqlite); + } + PreparedStatement ps = null; + try + { + ps = conn.prepareStatement(deleteByLocationQuery); + ps.setString(1, block.getWorld().getName()); + ps.setInt(2, block.getX()); + ps.setInt(3, block.getY()); + ps.setInt(4, block.getZ()); + ps.executeUpdate(); + + } + catch (SQLException ex) + { + logger.log(Level.WARNING, + "[EssentialsProtect] Could not delete block data from database", + ex); + } + finally + { + if (conn != null && !conn.isClosed()) + { + conn.close(); + } + if (ps != null) + { + ps.close(); + } + } + + } + catch (Throwable e) + { + logger.log(Level.SEVERE, " [EssentialsProtect] Exception occured whilst trying to delete data from sql", e); + } + + } + + public void removeProtectionFromDB(Block block, boolean removeBelow) + { + try + { + Connection conn = null; + if (dataType.contentEquals("mysql")) + { + Class.forName(mysqlDriver); + conn = DriverManager.getConnection(mysqlDatabase, mysqlUsername, mysqlPassword); + } + else + { + Class.forName("org.sqlite.JDBC"); + conn = DriverManager.getConnection(sqlite); + } + PreparedStatement ps = null; + try + { + ps = conn.prepareStatement(deleteByLocationQuery); + ps.setString(1, block.getWorld().getName()); + ps.setInt(2, block.getX()); + ps.setInt(3, block.getY()); + ps.setInt(4, block.getZ()); + ps.executeUpdate(); + if (removeBelow) + { + ps = conn.prepareStatement(deleteByLocationQuery); + ps.setString(1, block.getWorld().getName()); + ps.setInt(2, block.getX()); + ps.setInt(3, block.getY() - 1); + ps.setInt(4, block.getZ()); + ps.executeUpdate(); + } + + } + catch (SQLException ex) + { + logger.log(Level.WARNING, "[EssentialsProtect] Could not delete block data from database", ex); + } + finally + { + if (conn != null && !conn.isClosed()) + { + conn.close(); + } + if (ps != null) + { + ps.close(); + } + } + + } + catch (Throwable e) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Exception occured whilst trying to delete data from sql", e); + } + + } + + public boolean isBlockAboveProtectedRail(Block block) + { + Connection conn = null; + PreparedStatement ps = null; + ResultSet rs = null; + if (block.getTypeId() == 66) + { + try + { + if (dataType.contentEquals("mysql")) + { + Class.forName(mysqlDriver); + conn = DriverManager.getConnection(mysqlDatabase, mysqlUsername, mysqlPassword); + } + else + { + Class.forName("org.sqlite.JDBC"); + conn = DriverManager.getConnection(sqlite); + } + int rowCount = 0; + conn.setAutoCommit(false); + ps = conn.prepareStatement(countByLocationQuery); + ps.setString(1, block.getWorld().getName()); + ps.setInt(2, block.getX()); + ps.setInt(3, block.getY()); + ps.setInt(4, block.getZ()); + rs = ps.executeQuery(); + rs.next(); + rowCount = rs.getInt(1); + rs.close(); + ps.close(); + + if (rowCount == 0) + { + + return false; + } + else + { + return true; + } + } + catch (SQLException s) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Could not query protection", s); + + } + catch (ClassNotFoundException ex) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Could not find driver for " + dataType, ex); + + } + catch (Throwable e) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unexpected error occured whilst creating table", e); + } + finally + { + try + { + if (conn != null && !conn.isClosed()) + { + try + { + conn.close(); + } + catch (SQLException e) + { + logger.log(Level.SEVERE, "[EssentialsProtect] Unexpected error occured whilst closing the connection", e); + } + + } + } + catch (SQLException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return false; + } +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java new file mode 100644 index 000000000..97b5c59e5 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java @@ -0,0 +1,197 @@ +package com.earth2me.essentials.protect; + +import com.earth2me.essentials.Essentials; +import com.earth2me.essentials.User; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import net.minecraft.server.ChunkPosition; +import net.minecraft.server.Packet60Explosion; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityDamageByBlockEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageByProjectileEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.entity.EntityListener; + + +public class EssentialsProtectEntityListener extends EntityListener +{ + private EssentialsProtect parent; + + public EssentialsProtectEntityListener(EssentialsProtect parent) + { + Essentials.loadClasses(); + this.parent = parent; + } + + @Override + public void onEntityDamage(EntityDamageEvent event) + { + if (event.isCancelled()) return; + if (event instanceof EntityDamageByBlockEvent) + { + DamageCause cause = event.getCause(); + + if (EssentialsProtect.playerSettings.get("protect.disable.contactdmg") && cause == DamageCause.CONTACT) + { + event.setCancelled(true); + return; + } + if (EssentialsProtect.playerSettings.get("protect.disable.lavadmg") && cause == DamageCause.LAVA) + { + event.setCancelled(true); + return; + } + if (EssentialsProtect.guardSettings.get("protect.prevent.tnt-explosion") && cause == DamageCause.BLOCK_EXPLOSION) + { + event.setCancelled(true); + return; + } + } + + if (event instanceof EntityDamageByEntityEvent) + { + EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event; + Entity eAttack = edEvent.getDamager(); + Entity eDefend = edEvent.getEntity(); + + // PVP Settings + if (eDefend instanceof Player && eAttack instanceof Player) + { + if (EssentialsProtect.playerSettings.get("protect.disable.pvp")) + { + User defender = User.get(eDefend); + User attacker = User.get(eAttack); + + if (!defender.isAuthorized("essentials.protect.pvp") || !attacker.isAuthorized("essentials.protect.pvp")) + { + event.setCancelled(true); + return; + } + } + } + //Creeper explode prevention + if (eAttack != null && eAttack instanceof Monster) + { + if (eAttack instanceof Creeper && EssentialsProtect.guardSettings.get("protect.prevent.creeper-explosion")) + { + event.setCancelled(true); + return; + } + + if (eAttack instanceof Creeper && EssentialsProtect.guardSettings.get("protect.prevent.creeper-playerdamage")) + { + event.setCancelled(true); + return; + } + } + } + + if (event instanceof EntityDamageByProjectileEvent) + { + if (event.getEntity() instanceof Player) + { + event.setCancelled(EssentialsProtect.playerSettings.get("protect.disable.projectiles")); + return; + } + } + + DamageCause cause = event.getCause(); + Entity casualty = event.getEntity(); + if (casualty instanceof Player) + { + if (EssentialsProtect.playerSettings.get("protect.disable.fall") && cause == DamageCause.FALL) + { + event.setCancelled(true); + return; + } + + if (EssentialsProtect.playerSettings.get("protect.disable.suffocate") && cause == DamageCause.SUFFOCATION) + { + event.setCancelled(true); + return; + } + if (EssentialsProtect.playerSettings.get("protect.disable.firedmg") && (cause == DamageCause.FIRE + || cause == DamageCause.FIRE_TICK)) + { + event.setCancelled(true); + return; + } + if (EssentialsProtect.playerSettings.get("protect.disable.drown") && cause == DamageCause.DROWNING) + { + event.setCancelled(true); + return; + } + } + } + + @Override + public void onEntityExplode(EntityExplodeEvent event) + { + if (event.isCancelled()) return; + if (event.getEntity() instanceof LivingEntity) + { + //Nicccccccccce plaaacccccccccce.. + int maxHeight = Essentials.getSettings().getEpCreeperMaxHeight(); + if ( EssentialsProtect.guardSettings.get("protect.prevent.creeper-explosion") || + EssentialsProtect.guardSettings.get("protect.prevent.creeper-blockdamage") || + (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight)) + { + HashSet set = new HashSet(event.blockList().size()); + Player[] players = parent.getServer().getOnlinePlayers(); + List blocksUnderPlayers = new ArrayList(players.length); + Location loc = event.getLocation(); + for (Player player : players) { + if (player.getWorld().equals(loc.getWorld())) { + blocksUnderPlayers.add( + new ChunkPosition( + player.getLocation().getBlockX(), + player.getLocation().getBlockY() - 1, + player.getLocation().getBlockZ())); + } + } + for (Block block : event.blockList()) { + ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ()); + if (!blocksUnderPlayers.contains(cp)) { + set.add(cp); + } + } + + ((CraftServer)parent.getServer()).getServer().f.a(loc.getX(), loc.getY(), loc.getZ(), 64.0D, + new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0f, set)); + event.setCancelled(true); + return; + } + } + else + { //OH NOES TNT + if (EssentialsProtect.guardSettings.get("protect.prevent.tnt-explosion")) + { + event.setCancelled(true); + return; + } + } + } + + @Override + public void onCreatureSpawn(CreatureSpawnEvent event) { + String creatureName = event.getCreatureType().toString().toLowerCase(); + if (creatureName == null || creatureName.isEmpty()) { + return; + } + if (EssentialsProtect.guardSettings.get("protect.prevent.spawn."+creatureName)) { + event.setCancelled(true); + } + } +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java new file mode 100644 index 000000000..61419f69a --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java @@ -0,0 +1,73 @@ +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.event.player.PlayerListener; +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() + { + if (spData != null) return; + spData = new EssentialsProtectData(); + } + + @Override + public void onPlayerItem(PlayerItemEvent event) + { + if(event.isCancelled()) return; + ItemStack item = event.getItem(); + 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); + return; + } + + if (EssentialsProtect.onUseAlert.contains(String.valueOf(item.getTypeId()))) + { + 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/EssentialsProtectRegions.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectRegions.java new file mode 100644 index 000000000..6a640f3e1 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectRegions.java @@ -0,0 +1,5 @@ +package com.earth2me.essentials.protect; + +public class EssentialsProtectRegions { + +} diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectSqlProperties.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectSqlProperties.java new file mode 100644 index 000000000..30b2a7032 --- /dev/null +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectSqlProperties.java @@ -0,0 +1,12 @@ +package com.earth2me.essentials.protect; + +public class EssentialsProtectSqlProperties { + + public static String EssentialsProtect="CREATE TABLE IF NOT EXISTS `EssentialsProtect` (`id` int(11) NOT NULL AUTO_INCREMENT, `worldName` varchar(150) NOT NULL, `playerName` varchar(150) NOT NULL, `x` int(11) NOT NULL, `y` int(11) NOT NULL, `z` int(11) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB AUTO_INCREMENT=205 DEFAULT CHARSET=latin1"; + public static String EssentialsProtect_sqlite = "CREATE TABLE IF NOT EXISTS EssentialsProtect (id INTEGER PRIMARY KEY, worldName TEXT ,playerName TEXT, x NUMERIC, y NUMERIC, z NUMERIC)"; + public static String CountByLocation="SELECT COUNT(*) from EssentialsProtect where worldName = ? and x = ? and y = ? and z = ? limit 10"; + public static String CountByPLayerLocation="SELECT COUNT(*) from EssentialsProtect where worldName = ? and playerName =? and x = ? and y = ? and z = ? limit 10"; + public static String DeleteByLocation="DELETE FROM EssentialsProtect WHERE worldName=? and x=? and y=? and z=?"; + public static String Insert="INSERT INTO EssentialsProtect (worldName, playerName, x, y, z) VALUES (?,?,?,?,?)"; + public static String PlayerByLocation="SELECT playerName FROM EssentialsProtect WHERE worldname = ? and x = ? and y = ? and z = ? LIMIT 10"; +} diff --git a/EssentialsProtect/src/plugin.yml b/EssentialsProtect/src/plugin.yml new file mode 100644 index 000000000..c6f7830c1 --- /dev/null +++ b/EssentialsProtect/src/plugin.yml @@ -0,0 +1,8 @@ +# This determines the command prefix when there are conflicts (/name:home, /name:help, etc.) +name: EssentialsProtect +main: com.earth2me.essentials.protect.EssentialsProtect +# Note to developers: This next line cannot change, or the automatic versioning system will break. +version: TeamCity +website: http://www.earth2me.net:8001/ +description: Provides protection for various parts of the world. +authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo] \ No newline at end of file -- cgit v1.2.3