From cb21bc4d7a67f0974c2773fdd0f5376f177c068e Mon Sep 17 00:00:00 2001 From: Zenexer Date: Wed, 30 Mar 2011 04:03:21 +0000 Subject: 2.1 prerelease, part 2 of 3 git-svn-id: https://svn.java.net/svn/essentials~svn/trunk2.1@1015 e251c2fe-e539-e718-e476-b85c1f46cddb --- EssentialsSpawn/build.xml | 76 ++ EssentialsSpawn/nbproject/build-impl.xml | 1072 ++++++++++++++++++++ EssentialsSpawn/nbproject/genfiles.properties | 8 + .../nbproject/private/private.properties | 1 + EssentialsSpawn/nbproject/project.properties | 76 ++ EssentialsSpawn/nbproject/project.xml | 28 + .../earth2me/essentials/spawn/Commandsetspawn.java | 24 + .../earth2me/essentials/spawn/Commandspawn.java | 23 + .../earth2me/essentials/spawn/EssentialsSpawn.java | 65 ++ .../spawn/EssentialsSpawnPlayerListener.java | 51 + .../essentials/spawn/EssentialsSpawnWorker.java | 56 + EssentialsSpawn/src/plugin.yml | 15 + 12 files changed, 1495 insertions(+) create mode 100644 EssentialsSpawn/build.xml create mode 100644 EssentialsSpawn/nbproject/build-impl.xml create mode 100644 EssentialsSpawn/nbproject/genfiles.properties create mode 100644 EssentialsSpawn/nbproject/private/private.properties create mode 100644 EssentialsSpawn/nbproject/project.properties create mode 100644 EssentialsSpawn/nbproject/project.xml create mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java create mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java create mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java create mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java create mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java create mode 100644 EssentialsSpawn/src/plugin.yml (limited to 'EssentialsSpawn') diff --git a/EssentialsSpawn/build.xml b/EssentialsSpawn/build.xml new file mode 100644 index 000000000..7dfcbb707 --- /dev/null +++ b/EssentialsSpawn/build.xml @@ -0,0 +1,76 @@ + + ]> + + + + + + + + + + Builds, tests, and runs the project EssentialsSpawn. + + &buildinc; + + diff --git a/EssentialsSpawn/nbproject/build-impl.xml b/EssentialsSpawn/nbproject/build-impl.xml new file mode 100644 index 000000000..d343051e5 --- /dev/null +++ b/EssentialsSpawn/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/EssentialsSpawn/nbproject/genfiles.properties b/EssentialsSpawn/nbproject/genfiles.properties new file mode 100644 index 000000000..790af6977 --- /dev/null +++ b/EssentialsSpawn/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=45238b6c +build.xml.script.CRC32=46e3642f +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=e7b96939 +nbproject/build-impl.xml.script.CRC32=c9db80de +nbproject/build-impl.xml.stylesheet.CRC32=19debb58@1.42.1.45 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/nbproject/project.properties b/EssentialsSpawn/nbproject/project.properties new file mode 100644 index 000000000..1c4af9a9a --- /dev/null +++ b/EssentialsSpawn/nbproject/project.properties @@ -0,0 +1,76 @@ +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=EssentialsSpawn +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}/EssentialsSpawn.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 +includes=** +jar.compress=false +javac.classpath=\ + ${reference.Essentials.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= +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/EssentialsSpawn/nbproject/project.xml b/EssentialsSpawn/nbproject/project.xml new file mode 100644 index 000000000..8de247766 --- /dev/null +++ b/EssentialsSpawn/nbproject/project.xml @@ -0,0 +1,28 @@ + + + org.netbeans.modules.java.j2seproject + + + EssentialsSpawn + + + + + + + + + ../lib\nblibraries.properties + + + + Essentials + jar + + jar + clean + jar + + + + diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java new file mode 100644 index 000000000..e64985737 --- /dev/null +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java @@ -0,0 +1,24 @@ +package com.earth2me.essentials.spawn; + +import org.bukkit.Server; +import com.earth2me.essentials.Essentials; +import com.earth2me.essentials.User; +import com.earth2me.essentials.commands.EssentialsCommand; + + +public class Commandsetspawn extends EssentialsCommand +{ + public Commandsetspawn() + { + super("setspawn"); + } + + @Override + public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception + { + user.charge(this); + String group = args.length > 0 ? getFinalArg(args, 0) : "default"; + parent.spawn.setSpawn(user.getLocation(), group); + user.sendMessage("§7Spawn location set for group \"" + group + "\"."); + } +} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java new file mode 100644 index 000000000..c26cc9e37 --- /dev/null +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java @@ -0,0 +1,23 @@ +package com.earth2me.essentials.spawn; + +import org.bukkit.Server; +import com.earth2me.essentials.Essentials; +import com.earth2me.essentials.User; +import com.earth2me.essentials.commands.EssentialsCommand; + + +public class Commandspawn extends EssentialsCommand +{ + public Commandspawn() + { + super("spawn"); + } + + @Override + public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception + { + user.canAfford(this); + user.teleportCooldown(); + user.respawn(Essentials.getStatic().spawn, this.getName()); + } +} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java new file mode 100644 index 000000000..54e6bd198 --- /dev/null +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java @@ -0,0 +1,65 @@ +package com.earth2me.essentials.spawn; + +import java.io.*; +import java.util.logging.*; +import com.earth2me.essentials.*; +import org.bukkit.command.*; +import org.bukkit.event.Event.Priority; +import org.bukkit.event.Event.Type; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.*; + + +public class EssentialsSpawn extends JavaPlugin +{ + public static final String AUTHORS = Essentials.AUTHORS; + private static final Logger logger = Logger.getLogger("Minecraft"); + + public EssentialsSpawn() throws IOException + { + + } + + @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); + } + } + EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(); + getServer().getPluginManager().registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.Low, this); + getServer().getPluginManager().registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, 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("Loaded " + this.getDescription().getName() + " build " + this.getDescription().getVersion() + " maintained by " + AUTHORS); + } + + public void onDisable() + { + } + + @SuppressWarnings( + { + "LoggerStringConcat", "CallToThreadDumpStack" + }) + @Override + public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) + { + try + { + Essentials.loadClasses(); + Essentials.previewCommand(sender, command, commandLabel, args); + return EssentialsSpawnWorker.onCommand(sender, command, commandLabel, args); + } + catch (Throwable ex) + { + ex.printStackTrace(); + return true; + } + } +} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java new file mode 100644 index 000000000..697939daa --- /dev/null +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -0,0 +1,51 @@ +package com.earth2me.essentials.spawn; + +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.PlayerJoinEvent; +import org.bukkit.event.player.PlayerListener; +import org.bukkit.event.player.PlayerRespawnEvent; + + +public class EssentialsSpawnPlayerListener extends PlayerListener +{ + @Override + public void onPlayerRespawn(PlayerRespawnEvent event) + { + Essentials.loadClasses(); + User user = User.get(event.getPlayer()); + + try + { + if (Essentials.getSettings().getRespawnAtHome()) + { + event.setRespawnLocation(user.getHome()); + return; + } + } + catch (Throwable ex) + { + } + event.setRespawnLocation(Essentials.getStatic().spawn.getSpawn(user.getGroup())); + } + + @Override + public void onPlayerJoin(PlayerJoinEvent event) + { + Essentials.loadClasses(); + User user = User.get(event.getPlayer()); + + if (!user.isNew()) return; + user.clearNewFlag(); + try { + user.teleportToNow(Essentials.getStatic().spawn.getSpawn(Essentials.getSettings().getNewbieSpawn())); + } catch (Exception ex) { + Logger.getLogger("Minecraft").log(Level.WARNING, "Failed to teleport new player", ex); + } + + if (Essentials.getSettings().getAnnounceNewPlayers()) + Essentials.getStatic().getServer().broadcastMessage(Essentials.getSettings().getAnnounceNewPlayerFormat(user)); + } +} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java new file mode 100644 index 000000000..d6e34db55 --- /dev/null +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnWorker.java @@ -0,0 +1,56 @@ +package com.earth2me.essentials.spawn; + +import java.util.logging.*; +import com.earth2me.essentials.*; +import com.earth2me.essentials.commands.IEssentialsCommand; +import org.bukkit.command.*; + + +public class EssentialsSpawnWorker +{ + private static final Logger logger = Logger.getLogger("Minecraft"); + + @SuppressWarnings( + { + "LoggerStringConcat", "CallToThreadDumpStack" + }) + public static boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) + { + User user = User.get(sender); + + IEssentialsCommand cmd; + try + { + cmd = (IEssentialsCommand)EssentialsSpawn.class.getClassLoader().loadClass("com.earth2me.essentials.spawn.Command" + command.getName()).newInstance(); + } + catch (Exception ex) + { + sender.sendMessage("§cThat command is improperly loaded."); + ex.printStackTrace(); + return true; + } + + // Check authorization + if (user != null && !user.isAuthorized(cmd)) + { + logger.warning(user.getName() + " was denied access to command."); + user.sendMessage("§cYou do not have access to that command."); + return true; + } + + // Run the command + try + { + if (user == null) + cmd.run(Essentials.getStatic().getServer(), Essentials.getStatic(), sender, commandLabel, command, args); + else + cmd.run(Essentials.getStatic().getServer(), Essentials.getStatic(), user, commandLabel, command, args); + return true; + } + catch (Exception ex) + { + sender.sendMessage((user == null ? "" : "§c") + "Error: " + ex.getMessage()); + return true; + } + } +} diff --git a/EssentialsSpawn/src/plugin.yml b/EssentialsSpawn/src/plugin.yml new file mode 100644 index 000000000..de4e39b15 --- /dev/null +++ b/EssentialsSpawn/src/plugin.yml @@ -0,0 +1,15 @@ +# This determines the command prefix when there are conflicts (/name:home, /name:help, etc.) +name: EssentialsSpawn +main: com.earth2me.essentials.spawn.EssentialsSpawn +# 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 spawn control commands, utilizing Essentials. +authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo] +commands: + setspawn: + description: Set the spawnpoint to your current position. + usage: / + spawn: + description: Teleport to the spawnpoint. + usage: / \ No newline at end of file -- cgit v1.2.3