From 3ed78c052086d7838fd8e5dd2b3acf50acb3ecf1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 3 Mar 2012 13:19:10 +1100 Subject: Move EssentialsSpawn into the main plugin, going to make it a component in the near future --- .../src/com/earth2me/essentials/Essentials.java | 4 + .../essentials/commands/Commandsetspawn.java | 17 + .../earth2me/essentials/commands/Commandspawn.java | 55 + .../earth2me/essentials/settings/SpawnsHolder.java | 307 ++++++ Essentials/src/plugin.yml | 8 + EssentialsSpawn/build.xml | 76 -- EssentialsSpawn/nbproject/build-impl.xml | 1092 -------------------- EssentialsSpawn/nbproject/genfiles.properties | 8 - EssentialsSpawn/nbproject/pmd.settings | 1 - EssentialsSpawn/nbproject/project.properties | 113 -- EssentialsSpawn/nbproject/project.xml | 28 - .../earth2me/essentials/spawn/Commandsetspawn.java | 17 - .../earth2me/essentials/spawn/Commandspawn.java | 56 - .../earth2me/essentials/spawn/EssentialsSpawn.java | 77 -- .../spawn/EssentialsSpawnPlayerListener.java | 128 --- .../earth2me/essentials/spawn/SpawnStorage.java | 164 --- EssentialsSpawn/src/plugin.yml | 16 - 17 files changed, 391 insertions(+), 1776 deletions(-) create mode 100644 Essentials/src/com/earth2me/essentials/commands/Commandsetspawn.java create mode 100644 Essentials/src/com/earth2me/essentials/commands/Commandspawn.java create mode 100644 Essentials/src/com/earth2me/essentials/settings/SpawnsHolder.java delete mode 100644 EssentialsSpawn/build.xml delete mode 100644 EssentialsSpawn/nbproject/build-impl.xml delete mode 100644 EssentialsSpawn/nbproject/genfiles.properties delete mode 100644 EssentialsSpawn/nbproject/pmd.settings delete mode 100644 EssentialsSpawn/nbproject/project.properties delete mode 100644 EssentialsSpawn/nbproject/project.xml delete mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java delete mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java delete mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java delete mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java delete mode 100644 EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java delete mode 100644 EssentialsSpawn/src/plugin.yml diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 04afabdba..59590f551 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -23,6 +23,7 @@ import com.earth2me.essentials.listener.*; import com.earth2me.essentials.register.payment.Methods; import com.earth2me.essentials.settings.GroupsHolder; import com.earth2me.essentials.settings.SettingsHolder; +import com.earth2me.essentials.settings.SpawnsHolder; import com.earth2me.essentials.user.UserMap; import java.io.File; import java.io.FileReader; @@ -64,6 +65,7 @@ public class Essentials extends JavaPlugin implements IEssentials private transient IBackup backup; private transient IItemDb itemDb; private transient IGroups groups; + private transient SpawnsHolder spawns; private transient final Methods paymentMethod = new Methods(); //private transient PermissionsHandler permissionsHandler; private transient IUserMap userMap; @@ -170,6 +172,8 @@ public class Essentials extends JavaPlugin implements IEssentials reloadList.add(commandHandler); economy = new Economy(this); reloadList.add(economy); + spawns = new SpawnsHolder(this); + reloadList.add(spawns); reload(); } catch (YAMLException exception) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetspawn.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetspawn.java new file mode 100644 index 000000000..3af7e711f --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetspawn.java @@ -0,0 +1,17 @@ +package com.earth2me.essentials.commands; + +import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.settings.SpawnsHolder; + + +public class Commandsetspawn extends EssentialsCommand +{ + @Override + public void run(final IUser user, final String commandLabel, final String[] args) throws Exception + { + final String group = args.length > 0 ? getFinalArg(args, 0) : "default"; + ((SpawnsHolder)module).setSpawn(user.getLocation(), group); + user.sendMessage(_("spawnSet", group)); + } +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawn.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawn.java new file mode 100644 index 000000000..0fb4d928e --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawn.java @@ -0,0 +1,55 @@ +package com.earth2me.essentials.commands; + +import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.Trade; +import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.perm.Permissions; +import com.earth2me.essentials.settings.SpawnsHolder; +import org.bukkit.Location; +import org.bukkit.command.CommandSender; +import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; + + +public class Commandspawn extends EssentialsCommand +{ + @Override + public void run(final IUser user, final String commandLabel, final String[] args) throws Exception + { + final Trade charge = new Trade(commandName, ess); + charge.isAffordableFor(user); + if (args.length > 0 && Permissions.SPAWN_OTHERS.isAuthorized(user)) + { + final IUser otherUser = getPlayer(args, 0); + respawn(otherUser, null); + if (!otherUser.equals(user)) + { + otherUser.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn")); + user.sendMessage(_("teleporting")); + } + } + else + { + respawn(user, null); + } + } + + @Override + protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { + if (args.length < 1) + { + throw new NotEnoughArgumentsException(); + } + final IUser user = getPlayer(args, 0); + respawn(user, null); + user.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn")); + sender.sendMessage(_("teleporting")); + } + + private void respawn(final IUser user, final Trade charge) throws Exception + { + final SpawnsHolder spawns = (SpawnsHolder)this.module; + final Location spawn = spawns.getSpawn(ess.getGroups().getMainGroup(user)); + user.getTeleport().teleport(spawn, charge, TeleportCause.COMMAND); + } +} diff --git a/Essentials/src/com/earth2me/essentials/settings/SpawnsHolder.java b/Essentials/src/com/earth2me/essentials/settings/SpawnsHolder.java new file mode 100644 index 000000000..7ca7b316d --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/settings/SpawnsHolder.java @@ -0,0 +1,307 @@ +package com.earth2me.essentials.settings; + +import static com.earth2me.essentials.I18n._; +import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.IEssentialsModule; +import com.earth2me.essentials.api.ISettings; +import com.earth2me.essentials.api.IUser; +import com.earth2me.essentials.storage.AsyncStorageObjectHolder; +import com.earth2me.essentials.storage.Location.WorldNotLoadedException; +import com.earth2me.essentials.textreader.IText; +import com.earth2me.essentials.textreader.KeywordReplacer; +import com.earth2me.essentials.textreader.SimpleTextInput; +import com.earth2me.essentials.textreader.SimpleTextPager; +import java.io.File; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.logging.Level; +import org.bukkit.*; +import org.bukkit.event.Event; +import org.bukkit.event.EventException; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerRespawnEvent; +import org.bukkit.event.player.PlayerTeleportEvent; +import org.bukkit.plugin.EventExecutor; + + +public class SpawnsHolder extends AsyncStorageObjectHolder implements IEssentialsModule +{ + public SpawnsHolder(final IEssentials ess) + { + super(ess, Spawns.class); + onReload(); + registerListeners(); + } + + @Override + public File getStorageFile() + { + return new File(ess.getDataFolder(), "spawn.yml"); + } + + public void setSpawn(final Location loc, final String group) + { + acquireWriteLock(); + try + { + if (getData().getSpawns() == null) + { + getData().setSpawns(new HashMap()); + } + getData().getSpawns().put(group.toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(loc)); + } + finally + { + unlock(); + } + + if ("default".equalsIgnoreCase(group)) + { + loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + } + } + + public Location getSpawn(final String group) + { + acquireReadLock(); + try + { + if (getData().getSpawns() == null || group == null) + { + return getWorldSpawn(); + } + final Map spawnMap = getData().getSpawns(); + String groupName = group.toLowerCase(Locale.ENGLISH); + if (!spawnMap.containsKey(groupName)) + { + groupName = "default"; + } + if (!spawnMap.containsKey(groupName)) + { + return getWorldSpawn(); + } + try + { + return spawnMap.get(groupName).getBukkitLocation(); + } + catch (WorldNotLoadedException ex) + { + return getWorldSpawn(); + } + } + finally + { + unlock(); + } + } + + private Location getWorldSpawn() + { + for (World world : ess.getServer().getWorlds()) + { + if (world.getEnvironment() != World.Environment.NORMAL) + { + continue; + } + return world.getSpawnLocation(); + } + return ess.getServer().getWorlds().get(0).getSpawnLocation(); + } + + public EventPriority getRespawnPriority() + { + acquireReadLock(); + try + { + for (EventPriority priority : EventPriority.values()) + { + if (priority.toString().equalsIgnoreCase(getData().getRespawnPriority())) + { + return priority; + } + } + return EventPriority.NORMAL; + } + finally + { + unlock(); + } + } + + public Location getNewbieSpawn() + { + acquireReadLock(); + try + { + if (getData().getNewbieSpawn() == null || getData().getNewbieSpawn().isEmpty() + || getData().getNewbieSpawn().equalsIgnoreCase("none")) + { + return null; + } + return getSpawn(getData().getNewbieSpawn()); + } + finally + { + unlock(); + } + } + + public boolean getAnnounceNewPlayers() + { + acquireReadLock(); + try + { + return getData().getNewPlayerAnnouncement() != null && !getData().getNewPlayerAnnouncement().isEmpty(); + } + finally + { + unlock(); + } + } + + public String getAnnounceNewPlayerFormat(IUser user) + { + acquireReadLock(); + try + { + return getData().getNewPlayerAnnouncement().replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", ess.getGroups().getMainGroup(user)).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString()); + } + finally + { + unlock(); + } + } + + private void registerListeners() + { + final SpawnPlayerListener playerListener = new SpawnPlayerListener(ess, this); + ess.getServer().getPluginManager().registerEvent(PlayerRespawnEvent.class, playerListener, getRespawnPriority(), new EventExecutor() + { + @Override + public void execute(final Listener ll, final Event event) throws EventException + { + ((SpawnPlayerListener)ll).onPlayerRespawn((PlayerRespawnEvent)event); + } + }, ess); + ess.getServer().getPluginManager().registerEvent(PlayerJoinEvent.class, playerListener, getRespawnPriority(), new EventExecutor() + { + @Override + public void execute(final Listener ll, final Event event) throws EventException + { + ((SpawnPlayerListener)ll).onPlayerJoin((PlayerJoinEvent)event); + } + }, ess); + } + + + private class SpawnPlayerListener implements Listener + { + private final transient IEssentials ess; + private final transient SpawnsHolder spawns; + + public SpawnPlayerListener(final IEssentials ess, final SpawnsHolder spawns) + { + super(); + this.ess = ess; + this.spawns = spawns; + } + + public void onPlayerRespawn(final PlayerRespawnEvent event) + { + final IUser user = ess.getUser(event.getPlayer()); + + boolean respawnAtHome = false; + final ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + try + { + respawnAtHome = ess.getSettings().getData().getCommands().getHome().isRespawnAtHome(); + } + finally + { + settings.unlock(); + } + if (respawnAtHome) + { + Location home; + final Location bed = user.getBedSpawnLocation(); + if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK) + { + home = bed; + } + else + { + home = user.getHome(user.getLocation()); + } + if (home != null) + { + event.setRespawnLocation(home); + return; + } + } + final Location spawn = spawns.getSpawn(ess.getGroups().getMainGroup(user)); + if (spawn != null) + { + event.setRespawnLocation(spawn); + } + } + + public void onPlayerJoin(final PlayerJoinEvent event) + { + final IUser user = ess.getUser(event.getPlayer()); + + if (user.hasPlayedBefore()) + { + return; + } + + if (spawns.getNewbieSpawn() != null) + { + ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L); + } + + if (spawns.getAnnounceNewPlayers()) + { + final IText output = new KeywordReplacer(new SimpleTextInput(spawns.getAnnounceNewPlayerFormat(user)), user, ess); + final SimpleTextPager pager = new SimpleTextPager(output); + ess.broadcastMessage(user, pager.getString(0)); + } + } + + + private class NewPlayerTeleport implements Runnable + { + private final transient IUser user; + + public NewPlayerTeleport(final IUser user) + { + this.user = user; + } + + @Override + public void run() + { + if (user.getBase() instanceof OfflinePlayer) + { + return; + } + + try + { + final Location spawn = spawns.getNewbieSpawn(); + if (spawn != null) + { + user.getTeleport().now(spawn, false, PlayerTeleportEvent.TeleportCause.PLUGIN); + } + } + catch (Exception ex) + { + Bukkit.getLogger().log(Level.WARNING, _("teleportNewPlayerError"), ex); + } + } + } + } +} diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 2a91cfe3f..dd92300a7 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -286,6 +286,10 @@ commands: description: Creates a jail where you specified named [jailname] usage: / aliases: [esetjail] + setspawn: + description: Set the spawnpoint to your current position. + usage: / + aliases: [esetspawn] setwarp: description: Creates a new warp. usage: / @@ -298,6 +302,10 @@ commands: description: Toggles if you can see msg/mail commands in chat. usage: / aliases: [esocialspy] + spawn: + description: Teleport to the spawnpoint. + usage: / [player] + aliases: [esetspawn] spawner: description: Change the mob type of a spawner usage: / diff --git a/EssentialsSpawn/build.xml b/EssentialsSpawn/build.xml deleted file mode 100644 index d44f2cc97..000000000 --- a/EssentialsSpawn/build.xml +++ /dev/null @@ -1,76 +0,0 @@ - - ]> - - - - - - - - - - Builds, tests, and runs the project EssentialsSpawn. - - &buildinc; - - diff --git a/EssentialsSpawn/nbproject/build-impl.xml b/EssentialsSpawn/nbproject/build-impl.xml deleted file mode 100644 index cf349590c..000000000 --- a/EssentialsSpawn/nbproject/build-impl.xml +++ /dev/null @@ -1,1092 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 deleted file mode 100644 index 15d04622b..000000000 --- a/EssentialsSpawn/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -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=f45f4172 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 diff --git a/EssentialsSpawn/nbproject/pmd.settings b/EssentialsSpawn/nbproject/pmd.settings deleted file mode 100644 index 6a34e356c..000000000 --- a/EssentialsSpawn/nbproject/pmd.settings +++ /dev/null @@ -1 +0,0 @@ -DoNotUseThreads diff --git a/EssentialsSpawn/nbproject/project.properties b/EssentialsSpawn/nbproject/project.properties deleted file mode 100644 index f78c2be3d..000000000 --- a/EssentialsSpawn/nbproject/project.properties +++ /dev/null @@ -1,113 +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=EssentialsSpawn -application.vendor= -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120 -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none -auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0 -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2 -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.importGroupsOrder=* -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4 -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.separateImportGroups=false -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4 -auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4 -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.bukkit.jar=../lib/bukkit.jar -includes=** -jar.compress=true -javac.classpath=\ - ${reference.Essentials.jar}:\ - ${file.reference.bukkit.jar} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.6 -javac.target=1.6 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit_4.10.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 -mkdist.disabled=true -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 deleted file mode 100644 index f4e7a570a..000000000 --- a/EssentialsSpawn/nbproject/project.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - 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 deleted file mode 100644 index d0383bd4a..000000000 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.earth2me.essentials.spawn; - -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.api.IUser; -import com.earth2me.essentials.commands.EssentialsCommand; - - -public class Commandsetspawn extends EssentialsCommand -{ - @Override - public void run(final IUser user, final String commandLabel, final String[] args) throws Exception - { - final String group = args.length > 0 ? getFinalArg(args, 0) : "default"; - ((SpawnStorage)module).setSpawn(user.getLocation(), group); - user.sendMessage(_("spawnSet", group)); - } -} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java deleted file mode 100644 index b817c854a..000000000 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.earth2me.essentials.spawn; - -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.Trade; -import com.earth2me.essentials.api.IUser; -import com.earth2me.essentials.commands.EssentialsCommand; -import com.earth2me.essentials.commands.NotEnoughArgumentsException; -import com.earth2me.essentials.perm.Permissions; -import org.bukkit.Location; -import org.bukkit.command.CommandSender; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - - -public class Commandspawn extends EssentialsCommand -{ - @Override - public void run(final IUser user, final String commandLabel, final String[] args) throws Exception - { - final Trade charge = new Trade(commandName, ess); - charge.isAffordableFor(user); - if (args.length > 0 && Permissions.SPAWN_OTHERS.isAuthorized(user)) - { - final IUser otherUser = getPlayer(args, 0); - respawn(otherUser, null); - if (!otherUser.equals(user)) - { - otherUser.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn")); - user.sendMessage(_("teleporting")); - } - } - else - { - respawn(user, null); - } - } - - @Override - protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception - { - if (args.length < 1) - { - throw new NotEnoughArgumentsException(); - } - final IUser user = getPlayer(args, 0); - respawn(user, null); - user.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn")); - sender.sendMessage(_("teleporting")); - } - - private void respawn(final IUser user, final Trade charge) throws Exception - { - final SpawnStorage spawns = (SpawnStorage)this.module; - final Location spawn = spawns.getSpawn(ess.getGroups().getMainGroup(user)); - user.getTeleport().teleport(spawn, charge, TeleportCause.COMMAND); - } -} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java deleted file mode 100644 index 666bb1614..000000000 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.earth2me.essentials.spawn; - -import com.earth2me.essentials.EssentialsCommandHandler; -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.api.ICommandHandler; -import com.earth2me.essentials.api.IEssentials; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.event.Event; -import org.bukkit.event.EventException; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.plugin.EventExecutor; -import org.bukkit.plugin.PluginManager; -import org.bukkit.plugin.java.JavaPlugin; - - -public class EssentialsSpawn extends JavaPlugin -{ - private static final Logger LOGGER = Bukkit.getLogger(); - private transient IEssentials ess; - private transient SpawnStorage spawns; - private transient ICommandHandler commandHandler; - - public void onEnable() - { - final PluginManager pluginManager = getServer().getPluginManager(); - ess = (IEssentials)pluginManager.getPlugin("Essentials3"); - if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) - { - LOGGER.log(Level.WARNING, _("versionMismatchAll")); - } - if (!ess.isEnabled()) - { - this.setEnabled(false); - return; - } - - spawns = new SpawnStorage(ess); - ess.addReloadListener(spawns); - - commandHandler = new EssentialsCommandHandler(EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials.", spawns, ess); - - final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns); - pluginManager.registerEvent(PlayerRespawnEvent.class, playerListener, spawns.getRespawnPriority(), new EventExecutor() - { - @Override - public void execute(final Listener ll, final Event event) throws EventException - { - ((EssentialsSpawnPlayerListener)ll).onPlayerRespawn((PlayerRespawnEvent)event); - } - }, this); - pluginManager.registerEvent(PlayerJoinEvent.class, playerListener, spawns.getRespawnPriority(), new EventExecutor() - { - @Override - public void execute(final Listener ll, final Event event) throws EventException - { - ((EssentialsSpawnPlayerListener)ll).onPlayerJoin((PlayerJoinEvent)event); - } - }, this); - } - - public void onDisable() - { - } - - @Override - public boolean onCommand(final CommandSender sender, final Command command, - final String commandLabel, final String[] args) - { - return commandHandler.handleCommand(sender, command, commandLabel, args); - } -} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java deleted file mode 100644 index 2ff14835f..000000000 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.earth2me.essentials.spawn; - -import static com.earth2me.essentials.I18n._; -import com.earth2me.essentials.api.IEssentials; -import com.earth2me.essentials.api.ISettings; -import com.earth2me.essentials.api.IUser; -import com.earth2me.essentials.textreader.IText; -import com.earth2me.essentials.textreader.KeywordReplacer; -import com.earth2me.essentials.textreader.SimpleTextInput; -import com.earth2me.essentials.textreader.SimpleTextPager; -import java.util.logging.Level; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - - -public class EssentialsSpawnPlayerListener implements Listener -{ - private final transient IEssentials ess; - private final transient SpawnStorage spawns; - - public EssentialsSpawnPlayerListener(final IEssentials ess, final SpawnStorage spawns) - { - super(); - this.ess = ess; - this.spawns = spawns; - } - - public void onPlayerRespawn(final PlayerRespawnEvent event) - { - final IUser user = ess.getUser(event.getPlayer()); - - boolean respawnAtHome = false; - final ISettings settings = ess.getSettings(); - settings.acquireReadLock(); - try - { - respawnAtHome = ess.getSettings().getData().getCommands().getHome().isRespawnAtHome(); - } - finally - { - settings.unlock(); - } - if (respawnAtHome) - { - Location home; - final Location bed = user.getBedSpawnLocation(); - if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK) - { - home = bed; - } - else - { - home = user.getHome(user.getLocation()); - } - if (home != null) - { - event.setRespawnLocation(home); - return; - } - } - final Location spawn = spawns.getSpawn(ess.getGroups().getMainGroup(user)); - if (spawn != null) - { - event.setRespawnLocation(spawn); - } - } - - public void onPlayerJoin(final PlayerJoinEvent event) - { - final IUser user = ess.getUser(event.getPlayer()); - - if (user.hasPlayedBefore()) - { - return; - } - - if (spawns.getNewbieSpawn() != null) - { - ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L); - } - - if (spawns.getAnnounceNewPlayers()) - { - final IText output = new KeywordReplacer(new SimpleTextInput(spawns.getAnnounceNewPlayerFormat(user)), user, ess); - final SimpleTextPager pager = new SimpleTextPager(output); - ess.broadcastMessage(user, pager.getString(0)); - } - } - - - private class NewPlayerTeleport implements Runnable - { - private final transient IUser user; - - public NewPlayerTeleport(final IUser user) - { - this.user = user; - } - - @Override - public void run() - { - if (user.getBase() instanceof OfflinePlayer) - { - return; - } - - try - { - final Location spawn = spawns.getNewbieSpawn(); - if (spawn != null) - { - user.getTeleport().now(spawn, false, TeleportCause.PLUGIN); - } - } - catch (Exception ex) - { - Bukkit.getLogger().log(Level.WARNING, _("teleportNewPlayerError"), ex); - } - } - } -} diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java deleted file mode 100644 index 6171ed7ac..000000000 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.earth2me.essentials.spawn; - -import com.earth2me.essentials.api.IEssentials; -import com.earth2me.essentials.api.IEssentialsModule; -import com.earth2me.essentials.api.IUser; -import com.earth2me.essentials.settings.Spawns; -import com.earth2me.essentials.storage.AsyncStorageObjectHolder; -import com.earth2me.essentials.storage.Location.WorldNotLoadedException; -import java.io.File; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.event.EventPriority; - - -public class SpawnStorage extends AsyncStorageObjectHolder implements IEssentialsModule -{ - public SpawnStorage(final IEssentials ess) - { - super(ess, Spawns.class); - onReload(); - } - - @Override - public File getStorageFile() - { - return new File(ess.getDataFolder(), "spawn.yml"); - } - - public void setSpawn(final Location loc, final String group) - { - acquireWriteLock(); - try - { - if (getData().getSpawns() == null) - { - getData().setSpawns(new HashMap()); - } - getData().getSpawns().put(group.toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(loc)); - } - finally - { - unlock(); - } - - if ("default".equalsIgnoreCase(group)) - { - loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); - } - } - - public Location getSpawn(final String group) - { - acquireReadLock(); - try - { - if (getData().getSpawns() == null || group == null) - { - return getWorldSpawn(); - } - final Map spawnMap = getData().getSpawns(); - String groupName = group.toLowerCase(Locale.ENGLISH); - if (!spawnMap.containsKey(groupName)) - { - groupName = "default"; - } - if (!spawnMap.containsKey(groupName)) - { - return getWorldSpawn(); - } - try - { - return spawnMap.get(groupName).getBukkitLocation(); - } - catch (WorldNotLoadedException ex) - { - return getWorldSpawn(); - } - } - finally - { - unlock(); - } - } - - private Location getWorldSpawn() - { - for (World world : ess.getServer().getWorlds()) - { - if (world.getEnvironment() != World.Environment.NORMAL) - { - continue; - } - return world.getSpawnLocation(); - } - return ess.getServer().getWorlds().get(0).getSpawnLocation(); - } - - public EventPriority getRespawnPriority() - { - acquireReadLock(); - try - { - for (EventPriority priority : EventPriority.values()) - { - if (priority.toString().equalsIgnoreCase(getData().getRespawnPriority())) - { - return priority; - } - } - return EventPriority.NORMAL; - } - finally - { - unlock(); - } - } - - public Location getNewbieSpawn() - { - acquireReadLock(); - try - { - if (getData().getNewbieSpawn() == null || getData().getNewbieSpawn().isEmpty() - || getData().getNewbieSpawn().equalsIgnoreCase("none")) - { - return null; - } - return getSpawn(getData().getNewbieSpawn()); - } - finally - { - unlock(); - } - } - - public boolean getAnnounceNewPlayers() - { - acquireReadLock(); - try - { - return getData().getNewPlayerAnnouncement() != null && !getData().getNewPlayerAnnouncement().isEmpty(); - } - finally - { - unlock(); - } - } - - public String getAnnounceNewPlayerFormat(IUser user) - { - acquireReadLock(); - try - { - return getData().getNewPlayerAnnouncement().replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", ess.getGroups().getMainGroup(user)).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString()); - } - finally - { - unlock(); - } - } -} diff --git a/EssentialsSpawn/src/plugin.yml b/EssentialsSpawn/src/plugin.yml deleted file mode 100644 index f2638aa2a..000000000 --- a/EssentialsSpawn/src/plugin.yml +++ /dev/null @@ -1,16 +0,0 @@ -# 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://tiny.cc/EssentialsWiki -description: Provides spawn control commands, utilizing Essentials. -authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits] -depend: [Essentials3] -commands: - setspawn: - description: Set the spawnpoint to your current position. - usage: / - spawn: - description: Teleport to the spawnpoint. - usage: / [player] \ No newline at end of file -- cgit v1.2.3