mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 10:04:51 +02:00
Move EssentialsSpawn into the main plugin, going to make it a component in the near future
This commit is contained in:
@@ -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)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.spawn;
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import com.earth2me.essentials.settings.SpawnsHolder;
|
||||
|
||||
|
||||
public class Commandsetspawn extends EssentialsCommand
|
||||
@@ -11,7 +11,7 @@ public class Commandsetspawn extends EssentialsCommand
|
||||
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);
|
||||
((SpawnsHolder)module).setSpawn(user.getLocation(), group);
|
||||
user.sendMessage(_("spawnSet", group));
|
||||
}
|
||||
}
|
@@ -1,11 +1,10 @@
|
||||
package com.earth2me.essentials.spawn;
|
||||
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.commands.EssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
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;
|
||||
@@ -49,7 +48,7 @@ public class Commandspawn extends EssentialsCommand
|
||||
|
||||
private void respawn(final IUser user, final Trade charge) throws Exception
|
||||
{
|
||||
final SpawnStorage spawns = (SpawnStorage)this.module;
|
||||
final SpawnsHolder spawns = (SpawnsHolder)this.module;
|
||||
final Location spawn = spawns.getSpawn(ess.getGroups().getMainGroup(user));
|
||||
user.getTeleport().teleport(spawn, charge, TeleportCause.COMMAND);
|
||||
}
|
@@ -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<Spawns> 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<String, com.earth2me.essentials.storage.Location>());
|
||||
}
|
||||
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<String, com.earth2me.essentials.storage.Location> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -286,6 +286,10 @@ commands:
|
||||
description: Creates a jail where you specified named [jailname]
|
||||
usage: /<command> <jailname>
|
||||
aliases: [esetjail]
|
||||
setspawn:
|
||||
description: Set the spawnpoint to your current position.
|
||||
usage: /<command> <group>
|
||||
aliases: [esetspawn]
|
||||
setwarp:
|
||||
description: Creates a new warp.
|
||||
usage: /<command> <warp>
|
||||
@@ -298,6 +302,10 @@ commands:
|
||||
description: Toggles if you can see msg/mail commands in chat.
|
||||
usage: /<command>
|
||||
aliases: [esocialspy]
|
||||
spawn:
|
||||
description: Teleport to the spawnpoint.
|
||||
usage: /<command> [player]
|
||||
aliases: [esetspawn]
|
||||
spawner:
|
||||
description: Change the mob type of a spawner
|
||||
usage: /<command> <mob>
|
||||
|
@@ -1,76 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project [ <!ENTITY buildinc SYSTEM "../build.inc.xml"> ]>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="EssentialsSpawn" default="default" basedir=".">
|
||||
<description>Builds, tests, and runs the project EssentialsSpawn.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
&buildinc;
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="EssentialsSpawn-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
</project>
|
File diff suppressed because it is too large
Load Diff
@@ -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
|
@@ -1 +0,0 @@
|
||||
DoNotUseThreads
|
@@ -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
|
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.java.j2seproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||
<name>EssentialsSpawn</name>
|
||||
<source-roots>
|
||||
<root id="src.dir"/>
|
||||
</source-roots>
|
||||
<test-roots>
|
||||
<root id="test.src.dir"/>
|
||||
</test-roots>
|
||||
</data>
|
||||
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||
<definitions>../lib\nblibraries.properties</definitions>
|
||||
</libraries>
|
||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
||||
<reference>
|
||||
<foreign-project>Essentials</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
</references>
|
||||
</configuration>
|
||||
</project>
|
@@ -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);
|
||||
}
|
||||
}
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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<Spawns> 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<String, com.earth2me.essentials.storage.Location>());
|
||||
}
|
||||
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<String, com.earth2me.essentials.storage.Location> 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();
|
||||
}
|
||||
}
|
||||
}
|
@@ -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: /<command> <group>
|
||||
spawn:
|
||||
description: Teleport to the spawnpoint.
|
||||
usage: /<command> [player]
|
Reference in New Issue
Block a user