mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 01:54:25 +02:00
Server-Layer Part 1
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IReplyTo;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
|
||||
|
||||
public final class Console implements IReplyTo
|
||||
{
|
||||
private static Console instance = new Console();
|
||||
private CommandSender replyTo;
|
||||
private ICommandSender replyTo;
|
||||
public final static String NAME = "Console";
|
||||
|
||||
private Console()
|
||||
@@ -15,13 +15,13 @@ public final class Console implements IReplyTo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
public void setReplyTo(final ICommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
public ICommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
@@ -17,50 +17,43 @@
|
||||
*/
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.commands.EssentialsCommandHandler;
|
||||
import com.earth2me.essentials.utils.ExecuteTimer;
|
||||
import com.earth2me.essentials.economy.WorthHolder;
|
||||
import com.earth2me.essentials.economy.Economy;
|
||||
import com.earth2me.essentials.backup.Backup;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.*;
|
||||
import com.earth2me.essentials.listener.*;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.api.server.IPlugin;
|
||||
import com.earth2me.essentials.api.server.IServer;
|
||||
import com.earth2me.essentials.api.server.IWorld;
|
||||
import com.earth2me.essentials.backup.Backup;
|
||||
import com.earth2me.essentials.commands.EssentialsCommandHandler;
|
||||
import com.earth2me.essentials.economy.Economy;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.economy.WorthHolder;
|
||||
import com.earth2me.essentials.economy.register.Methods;
|
||||
import com.earth2me.essentials.listener.*;
|
||||
import com.earth2me.essentials.ranks.RanksStorage;
|
||||
import com.earth2me.essentials.settings.SettingsHolder;
|
||||
import com.earth2me.essentials.settings.SpawnsHolder;
|
||||
import com.earth2me.essentials.user.UserMap;
|
||||
import com.earth2me.essentials.utils.ExecuteTimer;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.InvalidDescriptionException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
public class Essentials implements IEssentials
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 2015;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TntExplodeListener tntListener = new TntExplodeListener(this);
|
||||
private transient IJails jails;
|
||||
@@ -76,10 +69,26 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
//private transient PermissionsHandler permissionsHandler;
|
||||
private transient IUserMap userMap;
|
||||
private transient ExecuteTimer execTimer;
|
||||
private transient I18n i18n;
|
||||
@Getter
|
||||
private final I18n i18n;
|
||||
private transient ICommandHandler commandHandler;
|
||||
private transient Economy economy;
|
||||
public transient boolean testing;
|
||||
@Getter
|
||||
private final IServer server;
|
||||
@Getter
|
||||
private final Logger logger;
|
||||
@Getter
|
||||
private final IPlugin plugin;
|
||||
public static boolean testing;
|
||||
|
||||
public Essentials(final IServer server, final Logger logger, final IPlugin plugin)
|
||||
{
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.plugin = plugin;
|
||||
this.i18n = new I18n(this);
|
||||
i18n.onEnable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
@@ -99,11 +108,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
throw new IOException();
|
||||
}
|
||||
i18n = new I18n(this);
|
||||
i18n.onEnable();
|
||||
LOGGER.log(Level.INFO, _("usingTempFolderForTesting"));
|
||||
LOGGER.log(Level.INFO, dataFolder.toString());
|
||||
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
|
||||
|
||||
logger.log(Level.INFO, _("usingTempFolderForTesting"));
|
||||
logger.log(Level.INFO, dataFolder.toString());
|
||||
//this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
|
||||
settings = new SettingsHolder(this);
|
||||
i18n.updateLocale("en");
|
||||
userMap = new UserMap(this);
|
||||
@@ -116,36 +124,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
execTimer = new ExecuteTimer();
|
||||
execTimer.start();
|
||||
i18n = new I18n(this);
|
||||
i18n.onEnable();
|
||||
|
||||
execTimer.mark("I18n1");
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
for (Plugin plugin : pm.getPlugins())
|
||||
{
|
||||
if (plugin.getDescription().getName().startsWith("Essentials")
|
||||
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
}
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(1));
|
||||
if (versionNumber < BUKKIT_VERSION && versionNumber > 100)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
|
||||
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("bukkitFormatChanged"));
|
||||
LOGGER.log(Level.INFO, getServer().getVersion());
|
||||
LOGGER.log(Level.INFO, getServer().getBukkitVersion());
|
||||
}
|
||||
|
||||
execTimer.mark("BukkitCheck");
|
||||
try
|
||||
{
|
||||
@@ -180,19 +161,19 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
reloadList.add(economy);
|
||||
spawns = new SpawnsHolder(this);
|
||||
reloadList.add(spawns);
|
||||
reload();
|
||||
onReload();
|
||||
}
|
||||
catch (YAMLException exception)
|
||||
{
|
||||
if (pm.getPlugin("EssentialsUpdate") != null)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("essentialsHelp2"));
|
||||
logger.log(Level.SEVERE, _("essentialsHelp2"));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, _("essentialsHelp1"));
|
||||
logger.log(Level.SEVERE, _("essentialsHelp1"));
|
||||
}
|
||||
LOGGER.log(Level.SEVERE, exception.toString());
|
||||
logger.log(Level.SEVERE, exception.toString());
|
||||
pm.registerEvents(new Listener()
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
@@ -230,12 +211,12 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
getPlugin().scheduleSyncRepeatingTask(timer, 1, 100);
|
||||
execTimer.mark("RegListeners");
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials load {0}", timeroutput);
|
||||
logger.log(Level.INFO, "Essentials load {0}", timeroutput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,7 +228,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload()
|
||||
public void onReload()
|
||||
{
|
||||
Trade.closeLog();
|
||||
|
||||
@@ -260,13 +241,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
i18n.updateLocale(settings.getLocale());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||
{
|
||||
return commandHandler.handleCommand(sender, command, commandLabel, args);
|
||||
//return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IJails getJails()
|
||||
{
|
||||
@@ -297,12 +271,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return backup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUser getUser(final Player player)
|
||||
{
|
||||
return userMap.getUser(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUser getUser(final String playerName)
|
||||
{
|
||||
@@ -310,7 +278,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld(final String name)
|
||||
public IWorld getWorld(final String name)
|
||||
{
|
||||
if (name.matches("[0-9]+"))
|
||||
{
|
||||
@@ -346,42 +314,16 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
final Player[] players = getServer().getOnlinePlayers();
|
||||
|
||||
for (Player player : players)
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
final IUser user = getUser(player);
|
||||
final IUser user = player.getUser();
|
||||
if (!user.isIgnoringPlayer(sender.getName()))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
return players.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getServer().getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getServer().getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getServer().getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return this.getServer().getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
return getServer().getOnlinePlayers().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -404,13 +346,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return userMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public I18n getI18n()
|
||||
{
|
||||
return i18n;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IRanks getRanks()
|
||||
{
|
||||
|
@@ -4,6 +4,7 @@ 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.api.server.Player;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.HashSet;
|
||||
@@ -33,7 +34,7 @@ public class EssentialsTimer implements Runnable
|
||||
|
||||
try
|
||||
{
|
||||
final IUser user = ess.getUser(player);
|
||||
final IUser user = player.getUser();
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
|
@@ -137,7 +137,7 @@ public class I18n implements II18n
|
||||
public FileResClassLoader(final ClassLoader classLoader, final IEssentials ess)
|
||||
{
|
||||
super(classLoader);
|
||||
this.dataFolder = ess.getDataFolder();
|
||||
this.dataFolder = ess.getPlugin().getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -5,6 +5,8 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IItemDb;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
import com.earth2me.essentials.api.server.Material;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -12,8 +14,6 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class ItemDb implements IItemDb
|
||||
@@ -129,9 +129,9 @@ public class ItemDb implements IItemDb
|
||||
metaData = (short)((item >> 32) & 0xffffL);
|
||||
}
|
||||
}
|
||||
else if (Material.getMaterial(itemname) != null)
|
||||
else if (Material.get(itemname) != null)
|
||||
{
|
||||
itemid = Material.getMaterial(itemname).getId();
|
||||
itemid = Material.get(itemname).getId();
|
||||
metaData = 0;
|
||||
}
|
||||
else
|
||||
@@ -140,14 +140,12 @@ public class ItemDb implements IItemDb
|
||||
}
|
||||
}
|
||||
|
||||
final Material mat = Material.getMaterial(itemid);
|
||||
final Material mat = Material.get(itemid);
|
||||
if (mat == null)
|
||||
{
|
||||
throw new Exception(_("unknownItemId", itemid));
|
||||
}
|
||||
final ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(mat.getMaxStackSize());
|
||||
retval.setDurability(metaData);
|
||||
final ItemStack retval = ItemStack.create(mat, mat.getMaxStackSize(), metaData);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
@Override
|
||||
public File getStorageFile()
|
||||
{
|
||||
return new File(ess.getDataFolder(), "jail.yml");
|
||||
return new File(ess.getPlugin().getDataFolder(), "jail.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +63,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
}
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH)).getBukkitLocation();
|
||||
Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH)).getStoredLocation();
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(_("jailNotExist"));
|
||||
@@ -147,9 +147,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
{
|
||||
if (getData().getJails() == null)
|
||||
{
|
||||
getData().setJails(new HashMap<String, com.earth2me.essentials.storage.Location>());
|
||||
getData().setJails(new HashMap<String, com.earth2me.essentials.storage.StoredLocation>());
|
||||
}
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(loc));
|
||||
getData().getJails().put(jailName.toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.StoredLocation(loc));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -23,7 +23,7 @@ public class Kits extends AsyncStorageObjectHolder<com.earth2me.essentials.setti
|
||||
@Override
|
||||
public File getStorageFile() throws IOException
|
||||
{
|
||||
return new File(ess.getDataFolder(), "kits.yml");
|
||||
return new File(ess.getPlugin().getDataFolder(), "kits.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,12 +1,13 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.api.server.Location;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.CooldownException;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
@@ -15,10 +16,6 @@ import com.earth2me.essentials.utils.LocationUtil;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
|
||||
@@ -30,7 +27,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
private static class Target
|
||||
{
|
||||
private final Location location;
|
||||
private final Entity entity;
|
||||
private final Player entity;
|
||||
|
||||
public Target(Location location)
|
||||
{
|
||||
@@ -38,7 +35,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
this.entity = null;
|
||||
}
|
||||
|
||||
public Target(Entity entity)
|
||||
public Target(Player entity)
|
||||
{
|
||||
this.entity = entity;
|
||||
this.location = null;
|
||||
@@ -121,7 +118,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
ess.getCommandHandler().showCommandError(user.getBase(), "teleport", ex);
|
||||
ess.getCommandHandler().showCommandError(user, "teleport", ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -139,11 +136,9 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
final Player player = user.getBase();
|
||||
final Location bed = player.getBedSpawnLocation();
|
||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, bed == null ? player.getWorld().getSpawnLocation() : bed, bed != null);
|
||||
ess.getServer().getPluginManager().callEvent(pre);
|
||||
teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
|
||||
final Location bed = user.getBedSpawnLocation();
|
||||
final Location respawnLoc = ess.getPlugin().callRespawnEvent(user, bed == null ? user.getWorld().getSpawnLocation() : bed, bed != null);
|
||||
teleport(new Target(respawnLoc), chargeFor, cause);
|
||||
}
|
||||
|
||||
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
@@ -174,7 +169,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
}
|
||||
try
|
||||
{
|
||||
ess.getServer().getScheduler().cancelTask(teleTimer);
|
||||
ess.getPlugin().cancelTask(teleTimer);
|
||||
if (notifyUser)
|
||||
{
|
||||
user.sendMessage(_("pendingTeleportCancelled"));
|
||||
@@ -201,7 +196,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
teleport(new Target(loc), chargeFor, cause);
|
||||
}
|
||||
|
||||
public void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception
|
||||
{
|
||||
teleport(new Target(entity), chargeFor, cause);
|
||||
}
|
||||
@@ -233,7 +228,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
|
||||
initTimer((long)(delay * 1000.0), target, chargeFor, cause);
|
||||
|
||||
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
|
||||
teleTimer = ess.getPlugin().scheduleSyncRepeatingTask(this, 10, 10);
|
||||
}
|
||||
|
||||
private void now(Target target, TeleportCause cause) throws Exception
|
||||
@@ -259,7 +254,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
now(new Target(loc), cause);
|
||||
}
|
||||
|
||||
public void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception
|
||||
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
|
||||
{
|
||||
if (cooldown)
|
||||
{
|
||||
@@ -273,7 +268,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
teleport(new Target(user.getData().getLastLocation().getBukkitLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
teleport(new Target(user.getData().getLastLocation().getStoredLocation()), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -286,7 +281,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
user.acquireReadLock();
|
||||
try
|
||||
{
|
||||
now(new Target(user.getData().getLastLocation().getBukkitLocation()), TeleportCause.COMMAND);
|
||||
now(new Target(user.getData().getLastLocation().getStoredLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@@ -5,20 +5,17 @@ import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.IWarp;
|
||||
import com.earth2me.essentials.api.IWarps;
|
||||
import com.earth2me.essentials.api.InvalidNameException;
|
||||
import com.earth2me.essentials.api.server.Location;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import com.earth2me.essentials.settings.WarpHolder;
|
||||
import com.earth2me.essentials.storage.StorageObjectMap;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public class Warps extends StorageObjectMap<IWarp> implements IWarps
|
||||
{
|
||||
private static final Logger logger = Bukkit.getLogger();
|
||||
|
||||
public Warps(IEssentials ess)
|
||||
{
|
||||
super(ess, "warps");
|
||||
@@ -66,7 +63,7 @@ public class Warps extends StorageObjectMap<IWarp> implements IWarps
|
||||
warp.acquireReadLock();
|
||||
try
|
||||
{
|
||||
return warp.getData().getLocation().getBukkitLocation();
|
||||
return warp.getData().getLocation().getStoredLocation();
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -77,10 +74,10 @@ public class Warps extends StorageObjectMap<IWarp> implements IWarps
|
||||
@Override
|
||||
public void setWarp(final String name, final Location loc) throws Exception
|
||||
{
|
||||
setWarp(name, new com.earth2me.essentials.storage.Location(loc));
|
||||
setWarp(name, new com.earth2me.essentials.storage.StoredLocation(loc));
|
||||
}
|
||||
|
||||
public void setWarp(final String name, final com.earth2me.essentials.storage.Location loc) throws Exception
|
||||
public void setWarp(final String name, final com.earth2me.essentials.storage.StoredLocation loc) throws Exception
|
||||
{
|
||||
IWarp warp = getObject(name);
|
||||
if (warp == null)
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface ICommandHandler extends IReload
|
||||
|
||||
public void addPlugin(Plugin plugin);
|
||||
|
||||
boolean handleCommand(CommandSender sender, Command command, String commandLabel, String[] args);
|
||||
boolean handleCommand(ICommandSender sender, Command command, String commandLabel, String[] args);
|
||||
|
||||
void showCommandError(CommandSender sender, String commandLabel, Throwable exception);
|
||||
void showCommandError(ICommandSender sender, String commandLabel, Throwable exception);
|
||||
}
|
||||
|
13
Essentials/src/com/earth2me/essentials/api/IComponent.java
Normal file
13
Essentials/src/com/earth2me/essentials/api/IComponent.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
public interface IComponent extends IReload {
|
||||
/**
|
||||
* Enable the component.
|
||||
*/
|
||||
void onEnable();
|
||||
|
||||
/**
|
||||
* Disable the component.
|
||||
*/
|
||||
void onDisable();
|
||||
}
|
@@ -1,18 +1,18 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.listener.TntExplodeListener;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.api.server.IPlugin;
|
||||
import com.earth2me.essentials.api.server.IServer;
|
||||
import com.earth2me.essentials.api.server.IWorld;
|
||||
import com.earth2me.essentials.economy.register.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import com.earth2me.essentials.listener.TntExplodeListener;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin
|
||||
public interface IEssentials extends IComponent
|
||||
{
|
||||
void addReloadListener(IReload listener);
|
||||
|
||||
IUser getUser(Player player);
|
||||
|
||||
IUser getUser(String playerName);
|
||||
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
@@ -39,21 +39,16 @@ public interface IEssentials extends Plugin
|
||||
|
||||
ICommandHandler getCommandHandler();
|
||||
|
||||
World getWorld(String name);
|
||||
IWorld getWorld(String name);
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
|
||||
//int scheduleAsyncDelayedTask(Runnable run);
|
||||
//int scheduleSyncDelayedTask(Runnable run);
|
||||
//int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
//int scheduleSyncRepeatingTask(Runnable run, long delay, long period);
|
||||
//IPermissionsHandler getPermissionsHandler();
|
||||
void reload();
|
||||
|
||||
//void reload();
|
||||
TntExplodeListener getTNTListener();
|
||||
|
||||
void setRanks(IRanks groups);
|
||||
@@ -61,4 +56,10 @@ public interface IEssentials extends Plugin
|
||||
void removeReloadListener(IReload groups);
|
||||
|
||||
IEconomy getEconomy();
|
||||
|
||||
IServer getServer();
|
||||
|
||||
Logger getLogger();
|
||||
|
||||
IPlugin getPlugin();
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
|
||||
|
||||
public interface IItemDb extends IReload
|
||||
|
@@ -1,17 +1,16 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Permission;
|
||||
|
||||
|
||||
public interface IPermission
|
||||
{
|
||||
String getPermission();
|
||||
String getPermissionName();
|
||||
|
||||
boolean isAuthorized(CommandSender sender);
|
||||
boolean isAuthorized(ICommandSender sender);
|
||||
|
||||
Permission getBukkitPermission();
|
||||
Permission getPermission();
|
||||
|
||||
PermissionDefault getPermissionDefault();
|
||||
Permission.Default getPermissionDefault();
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
|
||||
|
||||
public interface IReplyTo
|
||||
{
|
||||
void setReplyTo(CommandSender user);
|
||||
void setReplyTo(ICommandSender user);
|
||||
|
||||
CommandSender getReplyTo();
|
||||
ICommandSender getReplyTo();
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
import com.earth2me.essentials.api.server.Location;
|
||||
import com.earth2me.essentials.storage.IStorageObjectHolder;
|
||||
import com.earth2me.essentials.user.CooldownException;
|
||||
import com.earth2me.essentials.user.UserData;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload, IReplyTo, Comparable<IUser>
|
||||
@@ -18,11 +18,11 @@ public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload,
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void takeMoney(double value, CommandSender initiator);
|
||||
void takeMoney(double value, ICommandSender initiator);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
void giveMoney(double value, CommandSender initiator);
|
||||
void giveMoney(double value, ICommandSender initiator);
|
||||
|
||||
void giveItems(ItemStack itemStack, Boolean canSpew) throws ChargeException;
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IUserMap extends IReload
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.api.server.Location;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public interface IWarps extends IReload
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
|
||||
|
||||
|
||||
public interface IWorth extends IReload
|
||||
|
@@ -0,0 +1,7 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public abstract class Enchantment {
|
||||
|
||||
public abstract int getMaxLevel();
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface ICommandSender {
|
||||
boolean isPlayer();
|
||||
|
||||
void sendMessage(String message);
|
||||
|
||||
boolean isOp();
|
||||
|
||||
boolean hasPermission(Permission bukkitPermission);
|
||||
|
||||
void sendMessage(String[] string);
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface IInventory {
|
||||
|
||||
public boolean containsItem(boolean b, boolean b0, ItemStack itemStack);
|
||||
|
||||
public Map<Integer, ItemStack> addItem(ItemStack itemStack);
|
||||
|
||||
public Map<Integer, ItemStack> addItem(boolean b, ItemStack itemStack);
|
||||
|
||||
public Map<Integer, ItemStack> addItem(boolean b, int oversizedStacksize, ItemStack itemStack);
|
||||
|
||||
public boolean addAllItems(boolean b, ItemStack itemStack);
|
||||
|
||||
public void removeItem(boolean b, boolean b0, ItemStack itemStack);
|
||||
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface IPermission {
|
||||
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface IPermissionsManager {
|
||||
|
||||
IPermission registerPermission();
|
||||
|
||||
boolean checkPermission(IPlayer player, IPermission perm);
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface IPlayer {
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
public interface IPlugin
|
||||
{
|
||||
int scheduleAsyncDelayedTask(final Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(final Runnable run);
|
||||
|
||||
int scheduleSyncDelayedTask(final Runnable run, final long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period);
|
||||
|
||||
File getRootFolder();
|
||||
|
||||
File getDataFolder();
|
||||
|
||||
void cancelTask(int taskId);
|
||||
|
||||
String getVersion();
|
||||
|
||||
Class getClassByName(String name);
|
||||
|
||||
InputStream getResource(String string);
|
||||
|
||||
Location callRespawnEvent(Player player, Location loc, boolean bedSpawn);
|
||||
|
||||
void callSuicideEvent(Player player);
|
||||
}
|
@@ -1,5 +1,28 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public interface IServer {
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface IServer
|
||||
{
|
||||
List<IWorld> getWorlds();
|
||||
|
||||
IWorld getWorld(String name);
|
||||
|
||||
int broadcastMessage(String message);
|
||||
|
||||
Collection<Player> getOnlinePlayers();
|
||||
|
||||
ICommandSender getConsoleSender();
|
||||
|
||||
void dispatchCommand(ICommandSender sender, String command);
|
||||
|
||||
void banIP(String ip);
|
||||
|
||||
<T> T getServiceProvider(Class<T> clazz);
|
||||
|
||||
String getVersion();
|
||||
|
||||
public void unbanIP(String string);
|
||||
}
|
||||
|
@@ -0,0 +1,24 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
public interface IWorld {
|
||||
String getName();
|
||||
|
||||
public boolean generateTree(Location safeLocation, TreeType tree);
|
||||
|
||||
public int getHighestBlockYAt(int topX, int topZ);
|
||||
|
||||
public ItemStack dropItem(Location loc, ItemStack stack);
|
||||
|
||||
public UUID getUID();
|
||||
|
||||
public Location getSpawnLocation();
|
||||
|
||||
public void dropItemNaturally(Location location, ItemStack overflowStack);
|
||||
|
||||
public void setStorm(boolean b);
|
||||
|
||||
public void setWeatherDuration(int i);
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
|
||||
public abstract class ItemStack implements Cloneable
|
||||
{
|
||||
public interface ItemStackFactory
|
||||
{
|
||||
ItemStack create(int id, int amount, int data);
|
||||
ItemStack clone(ItemStack stack);
|
||||
}
|
||||
private static ItemStackFactory factory;
|
||||
|
||||
public static void setFactory(final ItemStackFactory factory)
|
||||
{
|
||||
ItemStack.factory = factory;
|
||||
}
|
||||
|
||||
public static ItemStack create(int id, int amount, int data)
|
||||
{
|
||||
return factory.create(id, amount, data);
|
||||
}
|
||||
|
||||
public static ItemStack create(Material mat, int amount, int data)
|
||||
{
|
||||
return factory.create(mat.getId(), amount, data);
|
||||
}
|
||||
|
||||
public abstract Material getType();
|
||||
|
||||
public abstract int getAmount();
|
||||
|
||||
public abstract void setAmount(int value);
|
||||
|
||||
public abstract short getDurability();
|
||||
|
||||
public abstract int getMaxStackSize();
|
||||
|
||||
public abstract boolean isAir();
|
||||
|
||||
public abstract void addEnchantment(Enchantment enchantment, int level);
|
||||
|
||||
@Override
|
||||
public ItemStack clone()
|
||||
{
|
||||
return factory.clone(this);
|
||||
}
|
||||
}
|
@@ -0,0 +1,52 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
|
||||
public abstract class Location
|
||||
{
|
||||
public interface LocationFactory {
|
||||
Location create(String worldName, double x, double y, double z, double yaw, double pitch);
|
||||
Location create(IWorld world, double x, double y, double z, double yaw, double pitch);
|
||||
}
|
||||
private static LocationFactory factory;
|
||||
|
||||
public static void setFactory(final LocationFactory factory) {
|
||||
Location.factory = factory;
|
||||
}
|
||||
|
||||
public static Location create(String worldName, double x, double y, double z) {
|
||||
return factory.create(worldName, x, y, z, 0, 0);
|
||||
}
|
||||
|
||||
public static Location create(String worldName, double x, double y, double z, double yaw, double pitch) {
|
||||
return factory.create(worldName, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
public static Location create(IWorld world, double x, double y, double z) {
|
||||
return factory.create(world, x, y, z, 0, 0);
|
||||
}
|
||||
|
||||
public static Location create(IWorld world, double x, double y, double z, double yaw, double pitch) {
|
||||
return factory.create(world, x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
|
||||
public abstract double getX();
|
||||
|
||||
public abstract double getY();
|
||||
|
||||
public abstract double getZ();
|
||||
|
||||
public abstract float getYaw();
|
||||
|
||||
public abstract float getPitch();
|
||||
|
||||
public abstract int getBlockX();
|
||||
|
||||
public abstract int getBlockY();
|
||||
|
||||
public abstract int getBlockZ();
|
||||
|
||||
public abstract IWorld getWorld();
|
||||
|
||||
public abstract double distanceSquared(Location location);
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
public abstract class Material {
|
||||
|
||||
private static Material instance;
|
||||
|
||||
public static void setInstance(final Material instance) {
|
||||
Material.instance = instance;
|
||||
}
|
||||
|
||||
public static Material get(final int id) {
|
||||
return instance.getMaterialById(id);
|
||||
}
|
||||
|
||||
public static Material get(final String name) {
|
||||
return instance.getMaterialByName(name);
|
||||
}
|
||||
|
||||
public static Material match(String string)
|
||||
{
|
||||
return instance.matchMaterial(string);
|
||||
}
|
||||
|
||||
protected abstract Material getMaterialByName(String name);
|
||||
|
||||
protected abstract Material getMaterialById(int id);
|
||||
|
||||
public abstract int getId();
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract int getMaxStackSize();
|
||||
|
||||
public abstract int getMaxDurability();
|
||||
|
||||
protected abstract Material matchMaterial(String string);
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
|
||||
public abstract class Permission
|
||||
{
|
||||
public enum Default
|
||||
{
|
||||
TRUE, FALSE, OP, NOT_OP;
|
||||
}
|
||||
|
||||
|
||||
public interface PermissionFactory
|
||||
{
|
||||
Permission create(String name, Permission.Default defaultPermission);
|
||||
}
|
||||
private static PermissionFactory factory;
|
||||
|
||||
public static void setFactory(final PermissionFactory factory)
|
||||
{
|
||||
Permission.factory = factory;
|
||||
}
|
||||
|
||||
public static Permission create(final String name, Permission.Default defaultPermission)
|
||||
{
|
||||
return factory.create(name, defaultPermission);
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package com.earth2me.essentials.api.server;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
|
||||
|
||||
public interface Player extends ICommandSender
|
||||
{
|
||||
IUser getUser();
|
||||
|
||||
String getName();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
boolean isOnline();
|
||||
|
||||
void setBanned(boolean bool);
|
||||
|
||||
void kickPlayer(String reason);
|
||||
|
||||
IWorld getWorld();
|
||||
|
||||
Location getLocation();
|
||||
|
||||
Location getEyeLocation();
|
||||
|
||||
void setFireTicks(int value);
|
||||
|
||||
void setFoodLevel(int value);
|
||||
|
||||
void setSaturation(float value);
|
||||
|
||||
int getHealth();
|
||||
|
||||
void setHealth(int value);
|
||||
|
||||
void updateInventory();
|
||||
|
||||
ItemStack getItemInHand();
|
||||
|
||||
Location getBedSpawnLocation();
|
||||
|
||||
boolean hasPlayedBefore();
|
||||
|
||||
IInventory getInventory();
|
||||
|
||||
void setTotalExperience(final int exp);
|
||||
|
||||
int getTotalExperience();
|
||||
|
||||
void setDisplayName(String name);
|
||||
|
||||
void setPlayerListName(String name);
|
||||
|
||||
void setSleepingIgnored(boolean b);
|
||||
|
||||
boolean isBanned();
|
||||
|
||||
void setCompassTarget(Location loc);
|
||||
|
||||
void damage(int value);
|
||||
}
|
@@ -4,6 +4,8 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IBackup;
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.IServer;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -19,7 +21,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Backup implements Runnable, IBackup
|
||||
{
|
||||
private static final Logger LOGGER = Bukkit.getLogger();
|
||||
private transient final Server server;
|
||||
private transient final IServer server;
|
||||
private transient final IEssentials ess;
|
||||
private transient final AtomicBoolean running = new AtomicBoolean(false);
|
||||
private transient int taskId = -1;
|
||||
@@ -29,7 +31,7 @@ public class Backup implements Runnable, IBackup
|
||||
{
|
||||
this.ess = ess;
|
||||
server = ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
if (!server.getOnlinePlayers().isEmpty())
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
@@ -49,7 +51,7 @@ public class Backup implements Runnable, IBackup
|
||||
running.set(false);
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
taskId = ess.getPlugin().scheduleSyncRepeatingTask(this, interval, interval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,11 +71,11 @@ public class Backup implements Runnable, IBackup
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, _("backupStarted"));
|
||||
final CommandSender consoleSender = server.getConsoleSender();
|
||||
final ICommandSender consoleSender = server.getConsoleSender();
|
||||
server.dispatchCommand(consoleSender, "save-all");
|
||||
server.dispatchCommand(consoleSender, "save-off");
|
||||
|
||||
ess.scheduleAsyncDelayedTask(new BackupRunner(command));
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(new BackupRunner(command));
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +95,7 @@ public class Backup implements Runnable, IBackup
|
||||
{
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
childBuilder.directory(ess.getPlugin().getRootFolder());
|
||||
final Process child = childBuilder.start();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
@@ -125,7 +127,7 @@ public class Backup implements Runnable, IBackup
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(new EnableSavingRunner());
|
||||
ess.getPlugin().scheduleSyncDelayedTask(new EnableSavingRunner());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,12 +139,12 @@ public class Backup implements Runnable, IBackup
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(server.getConsoleSender(), "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
if (server.getOnlinePlayers().isEmpty())
|
||||
{
|
||||
running.set(false);
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
ess.getPlugin().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,62 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.Enchantment;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
import com.earth2me.essentials.api.server.Material;
|
||||
import lombok.Delegate;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
public class BukkitItemStack extends com.earth2me.essentials.api.server.ItemStack
|
||||
{
|
||||
public static class BukkitItemStackFactory implements ItemStackFactory
|
||||
{
|
||||
@Override
|
||||
public ItemStack create(int id, int amount, int data)
|
||||
{
|
||||
return new BukkitItemStack(new org.bukkit.inventory.ItemStack(id, amount, (short)data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack clone(final ItemStack stack)
|
||||
{
|
||||
return new BukkitItemStack(((BukkitItemStack)stack).getItemStack().clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private interface Excludes
|
||||
{
|
||||
org.bukkit.Material getType();
|
||||
}
|
||||
@Delegate(excludes =
|
||||
{
|
||||
Excludes.class
|
||||
})
|
||||
@Getter
|
||||
private final org.bukkit.inventory.ItemStack itemStack;
|
||||
|
||||
public BukkitItemStack(final org.bukkit.inventory.ItemStack itemStack)
|
||||
{
|
||||
super();
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEnchantment(Enchantment enchantment, int level)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getType()
|
||||
{
|
||||
return Material.get(itemStack.getTypeId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir()
|
||||
{
|
||||
return itemStack.getTypeId() == 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.IWorld;
|
||||
import com.earth2me.essentials.api.server.Location;
|
||||
import lombok.Delegate;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
public class BukkitLocation extends Location
|
||||
{
|
||||
public static class BukkitLocationFactory implements LocationFactory
|
||||
{
|
||||
private final org.bukkit.Server server;
|
||||
|
||||
public BukkitLocationFactory(org.bukkit.Server server)
|
||||
{
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location create(String worldName, double x, double y, double z, double yaw, double pitch)
|
||||
{
|
||||
org.bukkit.World world = server.getWorld(worldName);
|
||||
return new BukkitLocation(new org.bukkit.Location(world, x, y, z, (float)yaw, (float)pitch));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location create(IWorld world, double x, double y, double z, double yaw, double pitch)
|
||||
{
|
||||
return new BukkitLocation(new org.bukkit.Location(((World)world).getBukkitWorld(), x, y, z, (float)yaw, (float)pitch));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private interface Excludes
|
||||
{
|
||||
org.bukkit.World getWorld();
|
||||
}
|
||||
@Delegate(excludes =
|
||||
{
|
||||
Excludes.class
|
||||
})
|
||||
@Getter
|
||||
private final org.bukkit.Location bukkitLocation;
|
||||
|
||||
public BukkitLocation(org.bukkit.Location bukkitLocation)
|
||||
{
|
||||
this.bukkitLocation = bukkitLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorld getWorld()
|
||||
{
|
||||
return new World(bukkitLocation.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double distanceSquared(final Location location)
|
||||
{
|
||||
return bukkitLocation.distanceSquared(((BukkitLocation)location).getBukkitLocation());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.Material;
|
||||
import java.util.EnumMap;
|
||||
import lombok.Delegate;
|
||||
|
||||
|
||||
public class BukkitMaterial extends Material
|
||||
{
|
||||
private static EnumMap<org.bukkit.Material, BukkitMaterial> materials = new EnumMap<org.bukkit.Material, BukkitMaterial>(org.bukkit.Material.class);
|
||||
|
||||
static
|
||||
{
|
||||
for (org.bukkit.Material material : org.bukkit.Material.values())
|
||||
{
|
||||
materials.put(material, new BukkitMaterial(material));
|
||||
}
|
||||
}
|
||||
private interface Excludes {
|
||||
short getMaxDurability();
|
||||
}
|
||||
@Delegate(excludes={Excludes.class})
|
||||
private final org.bukkit.Material material;
|
||||
|
||||
private BukkitMaterial(final org.bukkit.Material material)
|
||||
{
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material getMaterialByName(final String name)
|
||||
{
|
||||
final org.bukkit.Material mat = org.bukkit.Material.getMaterial(name);
|
||||
return materials.get(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material getMaterialById(final int id)
|
||||
{
|
||||
final org.bukkit.Material mat = org.bukkit.Material.getMaterial(id);
|
||||
return materials.get(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Material matchMaterial(String string)
|
||||
{
|
||||
final org.bukkit.Material mat = org.bukkit.Material.matchMaterial(string);
|
||||
return materials.get(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.material.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxDurability()
|
||||
{
|
||||
return (short)this.material.getMaxDurability();
|
||||
}
|
||||
}
|
@@ -0,0 +1,82 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.Permission;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Delegate;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class BukkitPermission extends Permission
|
||||
{
|
||||
public static class BukkitPermissionFactory implements PermissionFactory
|
||||
{
|
||||
private static transient final Pattern DOT_PATTERN = Pattern.compile("\\.");
|
||||
|
||||
@Override
|
||||
public Permission create(String permission, Permission.Default defaultPerm)
|
||||
{
|
||||
final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
||||
final String[] parts = DOT_PATTERN.split(permission);
|
||||
final StringBuilder builder = new StringBuilder(permission.length());
|
||||
org.bukkit.permissions.Permission parent = null;
|
||||
for (int i = 0; i < parts.length - 1; i++)
|
||||
{
|
||||
builder.append(parts[i]).append(".*");
|
||||
String permString = builder.toString();
|
||||
org.bukkit.permissions.Permission perm = pluginManager.getPermission(permString);
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new org.bukkit.permissions.Permission(permString, PermissionDefault.FALSE);
|
||||
pluginManager.addPermission(perm);
|
||||
if (parent != null)
|
||||
{
|
||||
parent.getChildren().put(perm.getName(), Boolean.TRUE);
|
||||
}
|
||||
parent = perm;
|
||||
}
|
||||
builder.deleteCharAt(builder.length() - 1);
|
||||
}
|
||||
org.bukkit.permissions.Permission perm = pluginManager.getPermission(permission);
|
||||
if (perm == null)
|
||||
{
|
||||
perm = new org.bukkit.permissions.Permission(permission, getBukkitDefaultPermission(defaultPerm));
|
||||
pluginManager.addPermission(perm);
|
||||
if (parent != null)
|
||||
{
|
||||
parent.getChildren().put(perm.getName(), Boolean.TRUE);
|
||||
}
|
||||
parent = perm;
|
||||
}
|
||||
perm.recalculatePermissibles();
|
||||
return new BukkitPermission(perm);
|
||||
}
|
||||
}
|
||||
@Delegate
|
||||
@Getter
|
||||
private final org.bukkit.permissions.Permission bukkitPermission;
|
||||
|
||||
public BukkitPermission(org.bukkit.permissions.Permission bukkitPermission)
|
||||
{
|
||||
this.bukkitPermission = bukkitPermission;
|
||||
}
|
||||
|
||||
public static PermissionDefault getBukkitDefaultPermission(final Permission.Default defaultPerm)
|
||||
{
|
||||
switch (defaultPerm)
|
||||
{
|
||||
case TRUE:
|
||||
return PermissionDefault.TRUE;
|
||||
case OP:
|
||||
return PermissionDefault.OP;
|
||||
case NOT_OP:
|
||||
return PermissionDefault.NOT_OP;
|
||||
case FALSE:
|
||||
return PermissionDefault.FALSE;
|
||||
default:
|
||||
return PermissionDefault.FALSE;
|
||||
}
|
||||
}
|
||||
}
|
202
Essentials/src/com/earth2me/essentials/bukkit/BukkitPlayer.java
Normal file
202
Essentials/src/com/earth2me/essentials/bukkit/BukkitPlayer.java
Normal file
@@ -0,0 +1,202 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.*;
|
||||
import lombok.Delegate;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
|
||||
public class BukkitPlayer extends CommandSender implements Player
|
||||
{
|
||||
private interface Excludes
|
||||
{
|
||||
org.bukkit.World getWorld();
|
||||
|
||||
org.bukkit.Location getLocation();
|
||||
|
||||
org.bukkit.Location getEyeLocation();
|
||||
|
||||
org.bukkit.inventory.ItemStack getItemInHand();
|
||||
|
||||
org.bukkit.Location getBedSpawnLocation();
|
||||
|
||||
org.bukkit.inventory.Inventory getInventory();
|
||||
|
||||
void setTotalExperience(int i);
|
||||
|
||||
int getTotalExperience();
|
||||
}
|
||||
@Delegate(types =
|
||||
{
|
||||
org.bukkit.entity.Player.class, LivingEntity.class
|
||||
}, excludes =
|
||||
{
|
||||
OfflinePlayer.class, org.bukkit.command.CommandSender.class, Excludes.class
|
||||
})
|
||||
@Getter
|
||||
private transient org.bukkit.entity.Player onlinePlayer;
|
||||
/**
|
||||
* a set of data and methods common to both offline and online players.
|
||||
*/
|
||||
@Delegate(excludes =
|
||||
{
|
||||
Excludes.class
|
||||
})
|
||||
@Getter
|
||||
private transient OfflinePlayer safePlayer;
|
||||
private final transient IServer server;
|
||||
|
||||
public BukkitPlayer(final OfflinePlayer player, final IServer server)
|
||||
{
|
||||
super(player.getPlayer());
|
||||
this.server = server;
|
||||
if (player.isOnline())
|
||||
{
|
||||
|
||||
setOnlinePlayer(player.getPlayer());
|
||||
}
|
||||
else
|
||||
{
|
||||
setOfflinePlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public final void setOfflinePlayer(final OfflinePlayer offlinePlayer)
|
||||
{
|
||||
safePlayer = offlinePlayer;
|
||||
onlinePlayer = null;
|
||||
}
|
||||
|
||||
public final void setOnlinePlayer(final org.bukkit.entity.Player onlinePlayer)
|
||||
{
|
||||
safePlayer = this.onlinePlayer = onlinePlayer;
|
||||
}
|
||||
|
||||
public String getSafeDisplayName()
|
||||
{
|
||||
return onlinePlayer == null ? getName() : getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IUser getUser()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorld getWorld()
|
||||
{
|
||||
return server.getWorld(onlinePlayer.getWorld().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation()
|
||||
{
|
||||
return new BukkitLocation(onlinePlayer.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getEyeLocation()
|
||||
{
|
||||
return new BukkitLocation(onlinePlayer.getEyeLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BukkitItemStack getItemInHand()
|
||||
{
|
||||
return new BukkitItemStack(onlinePlayer.getItemInHand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
return new BukkitLocation(onlinePlayer.getBedSpawnLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory()
|
||||
{
|
||||
return new Inventory(onlinePlayer.getInventory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(final int exp)
|
||||
{
|
||||
if (exp < 0)
|
||||
{
|
||||
throw new IllegalArgumentException("Experience is negative!");
|
||||
}
|
||||
onlinePlayer.setExp(0);
|
||||
onlinePlayer.setLevel(0);
|
||||
onlinePlayer.setTotalExperience(0);
|
||||
int amount = exp;
|
||||
while (amount > 0)
|
||||
{
|
||||
final int expToLevel = getExpToLevel();
|
||||
amount -= expToLevel;
|
||||
if (amount >= 0)
|
||||
{
|
||||
// give until next level
|
||||
onlinePlayer.giveExp(expToLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
// give the rest
|
||||
amount += expToLevel;
|
||||
onlinePlayer.giveExp(amount);
|
||||
amount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getExpToLevel()
|
||||
{
|
||||
return getExpToLevel(onlinePlayer.getLevel());
|
||||
}
|
||||
|
||||
private static int getExpToLevel(final int level)
|
||||
{
|
||||
return 7 + (level * 7 >> 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalExperience()
|
||||
{
|
||||
int exp = (int) (getExpToLevel() * onlinePlayer.getExp());
|
||||
int currentLevel = onlinePlayer.getLevel();
|
||||
|
||||
while (currentLevel > 0) {
|
||||
currentLevel--;
|
||||
exp += getExpToLevel(currentLevel);
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String message)
|
||||
{
|
||||
onlinePlayer.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(final String[] string)
|
||||
{
|
||||
onlinePlayer.sendMessage(string);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(final Location loc)
|
||||
{
|
||||
onlinePlayer.setCompassTarget(((BukkitLocation)loc).getBukkitLocation());
|
||||
}
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Permission;
|
||||
import lombok.Delegate;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
public class CommandSender implements ICommandSender
|
||||
{
|
||||
@Delegate
|
||||
@Getter
|
||||
private org.bukkit.command.CommandSender commandSender;
|
||||
|
||||
public CommandSender(org.bukkit.command.CommandSender commandSender)
|
||||
{
|
||||
this.commandSender = commandSender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp()
|
||||
{
|
||||
return commandSender.isOp();
|
||||
}
|
||||
|
||||
public boolean hasPermission(Permission permission)
|
||||
{
|
||||
if (commandSender == null) {
|
||||
return false;
|
||||
} else {
|
||||
return commandSender.hasPermission(((BukkitPermission)permission).getBukkitPermission());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,95 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.*;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class EssentialsPlugin extends JavaPlugin {
|
||||
//TODO
|
||||
|
||||
public class EssentialsPlugin extends JavaPlugin
|
||||
{
|
||||
private transient Essentials ess;
|
||||
|
||||
public EssentialsPlugin()
|
||||
{
|
||||
Material.setInstance(BukkitMaterial.get(0));
|
||||
ItemStack.setFactory(new BukkitItemStack.BukkitItemStackFactory());
|
||||
Location.setFactory(new BukkitLocation.BukkitLocationFactory(getServer()));
|
||||
Permission.setFactory(new BukkitPermission.BukkitPermissionFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
|
||||
Server server = new Server(getServer());
|
||||
final PluginManager pm = this.getServer().getPluginManager();
|
||||
pm.registerEvents(server, this);
|
||||
ess = new Essentials(server, getLogger(), new Plugin(this));
|
||||
if (VersionCheck.checkVersion(this))
|
||||
{
|
||||
try
|
||||
{
|
||||
ess.onEnable();
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
if (pm.getPlugin("EssentialsUpdate") == null)
|
||||
{
|
||||
getLogger().log(Level.SEVERE, _("essentialsHelp1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().log(Level.SEVERE, _("essentialsHelp2"));
|
||||
}
|
||||
getLogger().log(Level.SEVERE, ex.toString());
|
||||
pm.registerEvents(new Listener()
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
event.getPlayer().sendMessage("Essentials failed to load, read the log file.");
|
||||
}
|
||||
}, this);
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
player.sendMessage("Essentials failed to load, read the log file.");
|
||||
}
|
||||
this.setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
if (ess != null)
|
||||
{
|
||||
ess.onDisable();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final org.bukkit.command.CommandSender sender, final Command command, final String label, final String[] args)
|
||||
{
|
||||
ICommandSender commandSender;
|
||||
if (sender instanceof org.bukkit.entity.Player) {
|
||||
commandSender = ((Server)ess.getServer()).getPlayer((org.bukkit.entity.Player)sender);
|
||||
} else {
|
||||
commandSender = new CommandSender(sender);
|
||||
}
|
||||
return ess.getCommandHandler().handleCommand(commandSender, command, label, args);
|
||||
}
|
||||
}
|
||||
|
48
Essentials/src/com/earth2me/essentials/bukkit/Inventory.java
Normal file
48
Essentials/src/com/earth2me/essentials/bukkit/Inventory.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.IInventory;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
import java.util.Map;
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class Inventory implements IInventory {
|
||||
@Delegate
|
||||
private org.bukkit.inventory.PlayerInventory inventory;
|
||||
|
||||
Inventory(PlayerInventory inventory)
|
||||
{
|
||||
this.inventory = inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsItem(boolean b, boolean b0, ItemStack itemStack)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemStack> addItem(boolean b, ItemStack itemStack)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAllItems(boolean b, ItemStack itemStack)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeItem(boolean b, boolean b0, ItemStack itemStack)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ItemStack> addItem(boolean b, int oversizedStacksize, ItemStack itemStack)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
}
|
87
Essentials/src/com/earth2me/essentials/bukkit/Plugin.java
Normal file
87
Essentials/src/com/earth2me/essentials/bukkit/Plugin.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.api.server.IPlugin;
|
||||
import com.earth2me.essentials.api.server.Location;
|
||||
import java.io.File;
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
|
||||
|
||||
public class Plugin implements IPlugin
|
||||
{
|
||||
@Delegate
|
||||
private final org.bukkit.plugin.Plugin plugin;
|
||||
|
||||
public Plugin(final org.bukkit.plugin.Plugin plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, run, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getRootFolder()
|
||||
{
|
||||
return plugin.getDataFolder().getParentFile().getParentFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask(final int taskId)
|
||||
{
|
||||
plugin.getServer().getScheduler().cancelTask(taskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion()
|
||||
{
|
||||
return plugin.getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getClassByName(final String name)
|
||||
{
|
||||
final JavaPluginLoader jpl = (JavaPluginLoader)plugin.getPluginLoader();
|
||||
return jpl.getClassByName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location callRespawnEvent(Player player, Location loc, boolean bedSpawn)
|
||||
{
|
||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(((BukkitPlayer)player).getOnlinePlayer(), ((BukkitLocation)loc).getBukkitLocation() , bedSpawn);
|
||||
getServer().getPluginManager().callEvent(pre);
|
||||
return new BukkitLocation(pre.getRespawnLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callSuicideEvent(Player player)
|
||||
{
|
||||
EntityDamageEvent ede = new EntityDamageEvent(((BukkitPlayer)player).getOnlinePlayer(), EntityDamageEvent.DamageCause.SUICIDE, 1000);
|
||||
getServer().getPluginManager().callEvent(ede);
|
||||
}
|
||||
|
||||
}
|
@@ -1,9 +1,126 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.IEssentials;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.api.server.IServer;
|
||||
import com.earth2me.essentials.api.server.IWorld;
|
||||
import java.util.*;
|
||||
import lombok.Delegate;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class Server implements IServer {
|
||||
@Delegate
|
||||
private org.bukkit.Server server;
|
||||
|
||||
public class Server implements IServer, Listener
|
||||
{
|
||||
private IEssentials ess;
|
||||
private interface Excludes
|
||||
{
|
||||
List<org.bukkit.World> getWorlds();
|
||||
|
||||
org.bukkit.World getWorld(String name);
|
||||
|
||||
org.bukkit.entity.Player[] getOnlinePlayers();
|
||||
|
||||
CommandSender getConsoleSender();
|
||||
}
|
||||
@Delegate(excludes = Excludes.class)
|
||||
private final org.bukkit.Server server;
|
||||
@Getter
|
||||
private List<IWorld> worlds;
|
||||
private Map<String, IWorld> worldsMap;
|
||||
@Getter
|
||||
private Collection<Player> onlinePlayers;
|
||||
private Map<org.bukkit.entity.Player, Player> onlinePlayersMap;
|
||||
@Getter
|
||||
private ICommandSender consoleSender;
|
||||
|
||||
public Server(final org.bukkit.Server server)
|
||||
{
|
||||
this.server = server;
|
||||
consoleSender = new CommandSender(server.getConsoleSender());
|
||||
updateWorlds();
|
||||
}
|
||||
|
||||
private void updateWorlds()
|
||||
{
|
||||
final ArrayList<IWorld> lworlds = new ArrayList<IWorld>(server.getWorlds().size());
|
||||
final HashMap<String, IWorld> lworldsMap = new HashMap<String, IWorld>();
|
||||
for (org.bukkit.World world : server.getWorlds())
|
||||
{
|
||||
final World w = new World(world);
|
||||
lworlds.add(w);
|
||||
lworldsMap.put(world.getName(), w);
|
||||
lworldsMap.put(world.getName().toLowerCase(Locale.ENGLISH), w);
|
||||
}
|
||||
this.worlds = Collections.unmodifiableList(lworlds);
|
||||
this.worldsMap = Collections.unmodifiableMap(lworldsMap);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public synchronized void onWorldLoadEvent(final WorldLoadEvent event)
|
||||
{
|
||||
updateWorlds();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public synchronized void onWorldUnloadEvent(final WorldUnloadEvent event)
|
||||
{
|
||||
updateWorlds();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public synchronized void onPlayerLoginEvent(final PlayerLoginEvent event)
|
||||
{
|
||||
final HashMap<org.bukkit.entity.Player, Player> oplayersMap = new HashMap<org.bukkit.entity.Player, Player>(onlinePlayersMap);
|
||||
BukkitPlayer p = new BukkitPlayer(event.getPlayer(), this);
|
||||
oplayersMap.put(event.getPlayer(), p);
|
||||
onlinePlayersMap = Collections.unmodifiableMap(oplayersMap);
|
||||
onlinePlayers = Collections.unmodifiableCollection(oplayersMap.values());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public synchronized void onPlayerQuitEvent(final PlayerQuitEvent event)
|
||||
{
|
||||
final ArrayList<Player> oplayers = new ArrayList<Player>(onlinePlayers);
|
||||
final HashMap<org.bukkit.entity.Player, Player> oplayersMap = new HashMap<org.bukkit.entity.Player, Player>(onlinePlayersMap);
|
||||
oplayersMap.remove(event.getPlayer());
|
||||
onlinePlayersMap = Collections.unmodifiableMap(oplayersMap);
|
||||
onlinePlayers = Collections.unmodifiableCollection(oplayersMap.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IWorld getWorld(final String name)
|
||||
{
|
||||
final IWorld world = worldsMap.get(name);
|
||||
if (world == null)
|
||||
{
|
||||
return worldsMap.get(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCommand(final ICommandSender sender, final String command)
|
||||
{
|
||||
server.dispatchCommand(((CommandSender)sender).getCommandSender(), command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getServiceProvider(final Class<T> clazz)
|
||||
{
|
||||
final RegisteredServiceProvider<T> rsp = server.getServicesManager().getRegistration(clazz);
|
||||
return rsp.getProvider();
|
||||
}
|
||||
|
||||
public Player getPlayer(final org.bukkit.entity.Player player) {
|
||||
return onlinePlayersMap.get(player);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,46 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class VersionCheck
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 2015;
|
||||
private static final Pattern bukkitVersionPattern = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*");
|
||||
|
||||
public static boolean checkVersion(final org.bukkit.plugin.Plugin plugin)
|
||||
{
|
||||
final PluginManager pm = plugin.getServer().getPluginManager();
|
||||
final String pluginVersion = plugin.getDescription().getVersion();
|
||||
for (org.bukkit.plugin.Plugin p : pm.getPlugins())
|
||||
{
|
||||
if (p.getDescription().getName().startsWith("Essentials")
|
||||
&& !p.getDescription().getVersion().equals(pluginVersion))
|
||||
{
|
||||
p.getLogger().log(Level.WARNING, _("versionMismatch", p.getDescription().getName()));
|
||||
}
|
||||
}
|
||||
final Matcher versionMatch = bukkitVersionPattern.matcher(plugin.getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(1));
|
||||
if (versionNumber < BUKKIT_VERSION && versionNumber > 100)
|
||||
{
|
||||
plugin.getLogger().log(Level.SEVERE, _("notRecommendedBukkit"));
|
||||
plugin.getLogger().log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin.getLogger().log(Level.INFO, _("bukkitFormatChanged"));
|
||||
plugin.getLogger().log(Level.INFO, plugin.getServer().getVersion());
|
||||
plugin.getLogger().log(Level.INFO, plugin.getServer().getBukkitVersion());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
44
Essentials/src/com/earth2me/essentials/bukkit/World.java
Normal file
44
Essentials/src/com/earth2me/essentials/bukkit/World.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.earth2me.essentials.bukkit;
|
||||
|
||||
import com.earth2me.essentials.api.server.IWorld;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
import com.earth2me.essentials.api.server.Location;
|
||||
import lombok.Delegate;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
public class World implements IWorld {
|
||||
@Delegate
|
||||
@Getter
|
||||
private final org.bukkit.World bukkitWorld;
|
||||
|
||||
public World(final org.bukkit.World world)
|
||||
{
|
||||
this.bukkitWorld = world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location safeLocation, TreeType tree)
|
||||
{
|
||||
return bukkitWorld.generateTree(((BukkitLocation)safeLocation).getBukkitLocation(), tree);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack dropItem(Location loc, ItemStack stack)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSpawnLocation()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropItemNaturally(Location location, ItemStack overflowStack)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
}
|
@@ -2,13 +2,14 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IBackup;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbackup extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final IBackup backup = ess.getBackup();
|
||||
backup.run();
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -10,7 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.utils.textreader.ArrayListInput;
|
||||
import com.earth2me.essentials.utils.textreader.TextPager;
|
||||
import java.text.DateFormat;
|
||||
@@ -21,7 +22,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page = 0;
|
||||
boolean force = false;
|
||||
@@ -58,7 +59,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(new Viewer(sender, page, force));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -66,12 +67,12 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage(_("orderBalances", ess.getUserMap().getUniqueUsers()));
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Viewer(sender, page, force));
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(new Viewer(sender, page, force));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void outputCache(final CommandSender sender, int page)
|
||||
private static void outputCache(final ICommandSender sender, int page)
|
||||
{
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(cacheage);
|
||||
@@ -139,18 +140,18 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(viewer);
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(viewer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class Viewer implements Runnable
|
||||
{
|
||||
private final transient CommandSender sender;
|
||||
private final transient ICommandSender sender;
|
||||
private final transient int page;
|
||||
private final transient boolean force;
|
||||
|
||||
public Viewer(final CommandSender sender, final int page, final boolean force)
|
||||
public Viewer(final ICommandSender sender, final int page, final boolean force)
|
||||
{
|
||||
this.sender = sender;
|
||||
this.page = page;
|
||||
@@ -173,7 +174,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new Calculator(new Viewer(sender, page, force), force));
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(new Calculator(new Viewer(sender, page, force), force));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.Ban;
|
||||
import lombok.Cleanup;
|
||||
@@ -13,7 +15,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandban extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -54,9 +56,9 @@ public class Commandban extends EssentialsCommand
|
||||
user.kickPlayer(banReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
for (IPlayer onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
final IUser player = onlinePlayer.getUser();
|
||||
if (Permissions.BAN_NOTIFY.isAuthorized(player))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerBanned", senderName, user.getName(), banReason));
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -9,7 +10,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandbanip extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -2,8 +2,8 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.Location;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
|
||||
|
@@ -1,13 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbroadcast extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,14 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandburn extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
|
@@ -2,9 +2,9 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.Locale;
|
||||
import lombok.Cleanup;
|
||||
@@ -12,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,13 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddeljail extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,13 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commanddelwarp extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import java.util.Locale;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,7 +14,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandeco extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
@@ -61,7 +63,7 @@ public class Commandeco extends EssentialsCommand
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
final IUser player = onlinePlayer.getUser();
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
@@ -8,7 +10,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandessentials extends EssentialsCommand
|
||||
@@ -17,7 +18,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
@@ -41,9 +42,9 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void run_disabled(final CommandSender sender, final String[] args) throws Exception
|
||||
private void run_disabled(final ICommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||
sender.sendMessage("Essentials " + ess.getPlugin().getVersion());
|
||||
sender.sendMessage("/<command> <reload/debug>");
|
||||
sender.sendMessage(_("blockList"));
|
||||
final StringBuilder disabledCommands = new StringBuilder();
|
||||
@@ -58,19 +59,19 @@ public class Commandessentials extends EssentialsCommand
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
}
|
||||
|
||||
private void run_debug(final CommandSender sender, final String[] args) throws Exception
|
||||
private void run_debug(final ICommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||
sender.sendMessage("Essentials " + ess.getPlugin().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||
}
|
||||
|
||||
private void run_reload(final CommandSender sender, final String[] args) throws Exception
|
||||
private void run_reload(final ICommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
ess.reload();
|
||||
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
|
||||
sender.sendMessage(_("essentialsReload", ess.getPlugin().getVersion()));
|
||||
}
|
||||
|
||||
private void run_nya(final CommandSender sender, final String[] args) throws Exception
|
||||
private void run_nya(final ICommandSender sender, final String[] args) throws Exception
|
||||
{
|
||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||
noteMap.put("1F#", (byte)0x0);
|
||||
@@ -117,7 +118,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
player.sendBlockChange(loc, Material.NOTE_BLOCK, (byte)0);
|
||||
}
|
||||
}
|
||||
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
|
||||
taskid = ess.getPlugin().scheduleSyncRepeatingTask(new Runnable()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -150,7 +151,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
|
||||
private void stopTune()
|
||||
{
|
||||
ess.getServer().getScheduler().cancelTask(taskid);
|
||||
ess.getPlugin().cancelTask(taskid);
|
||||
for (Block block : noteBlocks.values())
|
||||
{
|
||||
if (block.getType() == Material.NOTE_BLOCK)
|
||||
@@ -161,9 +162,9 @@ public class Commandessentials extends EssentialsCommand
|
||||
noteBlocks.clear();
|
||||
}
|
||||
|
||||
private void run_moo(final CommandSender sender, final String args[])
|
||||
private void run_moo(final ICommandSender sender, final String args[])
|
||||
{
|
||||
if(sender instanceof ConsoleCommandSender)
|
||||
if(sender == ess.getServer().getConsoleSender())
|
||||
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
|
||||
else
|
||||
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
|
||||
|
@@ -2,14 +2,14 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandext extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -32,7 +32,7 @@ public class Commandext extends EssentialsCommand
|
||||
extinguishPlayers(user, args[0]);
|
||||
}
|
||||
|
||||
private void extinguishPlayers(final CommandSender sender, final String name) throws Exception
|
||||
private void extinguishPlayers(final ICommandSender sender, final String name) throws Exception
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
{
|
||||
|
@@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -25,7 +24,7 @@ public class Commandfeed extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void feedOtherPlayers(final CommandSender sender, final String name)
|
||||
private void feedOtherPlayers(final ICommandSender sender, final String name)
|
||||
{
|
||||
final List<Player> players = server.matchPlayer(name);
|
||||
if (players.isEmpty())
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -12,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandgamemode extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -35,7 +36,7 @@ public class Commandgamemode extends EssentialsCommand
|
||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void gamemodeOtherPlayers(final CommandSender sender, final String name)
|
||||
private void gamemodeOtherPlayers(final ICommandSender sender, final String name)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
{
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.IWorld;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -8,13 +10,13 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandgc extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
|
||||
for (World w : server.getWorlds())
|
||||
for (IWorld w : server.getWorlds())
|
||||
{
|
||||
sender.sendMessage(
|
||||
(w.getEnvironment() == World.Environment.NETHER ? "Nether" : "World") + " \"" + w.getName() + "\": "
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -23,7 +24,7 @@ public class Commandgetpos extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.GivePermissions;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -16,7 +17,7 @@ public class Commandgive extends EssentialsCommand
|
||||
{
|
||||
//TODO: move these messages to message file
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -10,7 +11,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandgod extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -2,10 +2,10 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Commandheal extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ public class Commandheal extends EssentialsCommand
|
||||
healOtherPlayers(sender, args[0]);
|
||||
}
|
||||
|
||||
private void healOtherPlayers(final CommandSender sender, final String name)
|
||||
private void healOtherPlayers(final ICommandSender sender, final String name)
|
||||
{
|
||||
final List<Player> players = server.matchPlayer(name);
|
||||
if (players.isEmpty())
|
||||
|
@@ -8,6 +8,7 @@ import com.earth2me.essentials.utils.textreader.KeywordReplacer;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
@@ -43,7 +44,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage(_("helpConsole"));
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -22,7 +23,7 @@ public class Commandhelpop extends EssentialsCommand
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
final IUser player = onlinePlayer.getUser();
|
||||
if (!Permissions.HELPOP_RECEIVE.isAuthorized(player))
|
||||
{
|
||||
continue;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.utils.textreader.IText;
|
||||
import com.earth2me.essentials.utils.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.utils.textreader.TextInput;
|
||||
@@ -10,7 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandinfo extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final IText input = new TextInput(sender, "info", true, ess);
|
||||
final IText output = new KeywordReplacer(input, sender, ess);
|
||||
|
@@ -2,11 +2,10 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.Enchantment;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
import com.earth2me.essentials.permissions.ItemPermissions;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commanditem extends EssentialsCommand
|
||||
@@ -54,7 +53,7 @@ public class Commanditem extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
if (stack.isAir())
|
||||
{
|
||||
throw new Exception(_("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -8,7 +9,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
public class Commanditemdb extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
ItemStack itemStack = null;
|
||||
if (args.length < 1)
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -7,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandjails extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage("§7" + Util.joinList(" ", ess.getJails().getList()));
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ILocation;
|
||||
import com.earth2me.essentials.utils.LocationUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
@@ -14,7 +15,7 @@ public class Commandjump extends EssentialsCommand
|
||||
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
Location loc;
|
||||
final Location cloc = user.getLocation();
|
||||
final ILocation cloc = user.getLocation();
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -3,15 +3,16 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandkick extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -29,7 +30,7 @@ public class Commandkick extends EssentialsCommand
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final IUser player = ess.getUser(onlinePlayer);
|
||||
final IUser player = onlinePlayer.getUser();
|
||||
if (Permissions.KICK_NOTIFY.isAuthorized(player))
|
||||
{
|
||||
onlinePlayer.sendMessage(_("playerKicked", senderName, user.getName(), kickReason));
|
||||
|
@@ -1,18 +1,18 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
|
||||
|
||||
public class Commandkickall extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (sender instanceof Player && onlinePlayer.getName().equalsIgnoreCase(((Player)sender).getName()))
|
||||
if (sender.isPlayer() && onlinePlayer.getName().equalsIgnoreCase(((Player)sender).getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@@ -9,7 +10,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
public class Commandkill extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.bukkit.Mob;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
@@ -15,7 +16,7 @@ public class Commandkillall extends EssentialsCommand
|
||||
{
|
||||
//TODO: Tidy - missed this during command cleanup
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
String type = "all";
|
||||
int radius = -1;
|
||||
|
@@ -24,7 +24,7 @@ public class Commandkittycannon extends EssentialsCommand
|
||||
ocelot.setCatType(Ocelot.Type.values()[i]);
|
||||
ocelot.setTamed(true);
|
||||
ocelot.setVelocity(user.getEyeLocation().getDirection().multiply(2));
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
ess.getPlugin().scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -13,7 +14,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandlightning extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
|
||||
IUser user = null;
|
||||
|
@@ -4,6 +4,8 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.api.server.Player;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -13,7 +15,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
boolean showhidden = false;
|
||||
if (Permissions.LIST_HIDDEN.isAuthorized(sender))
|
||||
@@ -23,7 +25,7 @@ public class Commandlist extends EssentialsCommand
|
||||
int playerHidden = 0;
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (ess.getUser(onlinePlayer).isHidden())
|
||||
if (onlinePlayer.getUser().isHidden())
|
||||
{
|
||||
playerHidden++;
|
||||
}
|
||||
@@ -32,11 +34,11 @@ public class Commandlist extends EssentialsCommand
|
||||
String online;
|
||||
if (showhidden && playerHidden > 0)
|
||||
{
|
||||
online = _("listAmountHidden", server.getOnlinePlayers().length - playerHidden, playerHidden, server.getMaxPlayers());
|
||||
online = _("listAmountHidden", server.getOnlinePlayers().size() - playerHidden, playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
else
|
||||
{
|
||||
online = _("listAmount", server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
|
||||
online = _("listAmount", server.getOnlinePlayers().size() - playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
sender.sendMessage(online);
|
||||
|
||||
@@ -55,9 +57,9 @@ public class Commandlist extends EssentialsCommand
|
||||
if (sortListByGroups)
|
||||
{
|
||||
Map<String, List<IUser>> sort = new HashMap<String, List<IUser>>();
|
||||
for (Player OnlinePlayer : server.getOnlinePlayers())
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final IUser player = ess.getUser(OnlinePlayer);
|
||||
final IUser player = onlinePlayer.getUser();
|
||||
if (player.isHidden() && !showhidden)
|
||||
{
|
||||
continue;
|
||||
@@ -115,9 +117,9 @@ public class Commandlist extends EssentialsCommand
|
||||
else
|
||||
{
|
||||
final List<IUser> users = new ArrayList<IUser>();
|
||||
for (Player OnlinePlayer : server.getOnlinePlayers())
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
final IUser player = ess.getUser(OnlinePlayer);
|
||||
final IUser player =onlinePlayer.getUser();
|
||||
if (player.isHidden() && !showhidden)
|
||||
{
|
||||
continue;
|
||||
|
@@ -3,9 +3,9 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.mail.sendall"));
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
@@ -112,7 +112,7 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
else if (args.length >= 1 && "sendall".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new SendAll("Server: " + getFinalArg(args, 2)));
|
||||
ess.getPlugin().scheduleAsyncDelayedTask(new SendAll("Server: " + getFinalArg(args, 2)));
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ItemStack;
|
||||
import com.earth2me.essentials.permissions.ItemPermissions;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.Locale;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.utils.textreader.IText;
|
||||
import com.earth2me.essentials.utils.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.utils.textreader.TextInput;
|
||||
@@ -10,7 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandmotd extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final IText input = new TextInput(sender, "motd", true, ess);
|
||||
final IText output = new KeywordReplacer(input, sender, ess);
|
||||
|
@@ -5,6 +5,7 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IReplyTo;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.List;
|
||||
import lombok.Cleanup;
|
||||
@@ -15,7 +16,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandmsg extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2 || args[0].trim().isEmpty() || args[1].trim().isEmpty())
|
||||
{
|
||||
@@ -54,7 +55,7 @@ public class Commandmsg extends EssentialsCommand
|
||||
if (args[0].equalsIgnoreCase(Console.NAME))
|
||||
{
|
||||
sender.sendMessage(_("msgFormat", translatedMe, Console.NAME, message));
|
||||
CommandSender cs = server.getConsoleSender();
|
||||
ICommandSender cs = server.getConsoleSender();
|
||||
cs.sendMessage(_("msgFormat", senderName, translatedMe, message));
|
||||
replyTo.setReplyTo(cs);
|
||||
Console.getConsoleReplyTo().setReplyTo(sender);
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
@@ -13,7 +14,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandmute extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
@@ -56,7 +57,7 @@ public class Commandnear extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
|
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.Locale;
|
||||
import lombok.Cleanup;
|
||||
@@ -42,7 +43,7 @@ public class Commandnick extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -14,7 +15,7 @@ import org.bukkit.entity.TNTPrimed;
|
||||
public class Commandnuke extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||
{
|
||||
List<Player> targets;
|
||||
if (args.length > 0)
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.utils.DescParseTickFormat;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import java.util.*;
|
||||
import org.bukkit.World;
|
||||
@@ -23,7 +24,7 @@ public class Commandptime extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
// Which Players(s) / Users(s) are we interested in?
|
||||
String userSelector = null;
|
||||
|
@@ -5,6 +5,7 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IReplyTo;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -13,7 +14,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandr extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -45,7 +46,7 @@ public class Commandr extends EssentialsCommand
|
||||
senderName = Console.NAME;
|
||||
}
|
||||
|
||||
final CommandSender target = replyTo.getReplyTo();
|
||||
final ICommandSender target = replyTo.getReplyTo();
|
||||
final String targetName = target instanceof Player ? ((Player)target).getDisplayName() : Console.NAME;
|
||||
|
||||
if (target == null || ((target instanceof Player) && !((Player)target).isOnline()))
|
||||
@@ -78,7 +79,7 @@ public class Commandr extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission()
|
||||
public String getPermissionName()
|
||||
{
|
||||
return "essentials.msg";
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.ISettings;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import java.util.Locale;
|
||||
import lombok.Cleanup;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -13,7 +14,7 @@ import org.bukkit.entity.Player;
|
||||
public class Commandrealname extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
@@ -57,7 +58,7 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.utils.textreader.IText;
|
||||
import com.earth2me.essentials.utils.textreader.KeywordReplacer;
|
||||
import com.earth2me.essentials.utils.textreader.TextInput;
|
||||
@@ -10,7 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandrules extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final IText input = new TextInput(sender, "rules", true, ess);
|
||||
final IText output = new KeywordReplacer(input, sender, ess);
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.user.UserData.TimestampType;
|
||||
import com.earth2me.essentials.utils.DateUtil;
|
||||
@@ -13,7 +14,7 @@ import org.bukkit.command.CommandSender;
|
||||
public class Commandseen extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
seen(sender,args,true);
|
||||
}
|
||||
|
@@ -35,9 +35,9 @@ public class Commandsethome extends EssentialsCommand
|
||||
user.acquireWriteLock();
|
||||
if (user.getData().getHomes() == null)
|
||||
{
|
||||
user.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.Location>());
|
||||
user.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.StoredLocation>());
|
||||
}
|
||||
user.getData().getHomes().put(args[0].toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.Location(user.getLocation()));
|
||||
user.getData().getHomes().put(args[0].toLowerCase(Locale.ENGLISH), new com.earth2me.essentials.storage.StoredLocation(user.getLocation()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -72,9 +72,9 @@ public class Commandsethome extends EssentialsCommand
|
||||
usersHome.acquireWriteLock();
|
||||
if (usersHome.getData().getHomes() == null)
|
||||
{
|
||||
usersHome.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.Location>());
|
||||
usersHome.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.StoredLocation>());
|
||||
}
|
||||
usersHome.getData().getHomes().put(name, new com.earth2me.essentials.storage.Location(user.getLocation()));
|
||||
usersHome.getData().getHomes().put(name, new com.earth2me.essentials.storage.StoredLocation(user.getLocation()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,9 +83,9 @@ public class Commandsethome extends EssentialsCommand
|
||||
user.acquireWriteLock();
|
||||
if (user.getData().getHomes() == null)
|
||||
{
|
||||
user.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.Location>());
|
||||
user.getData().setHomes(new HashMap<String, com.earth2me.essentials.storage.StoredLocation>());
|
||||
}
|
||||
user.getData().getHomes().put("home", new com.earth2me.essentials.storage.Location(user.getLocation()));
|
||||
user.getData().getHomes().put("home", new com.earth2me.essentials.storage.StoredLocation(user.getLocation()));
|
||||
}
|
||||
user.sendMessage(_("homeSet"));
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class Commandsetworth extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.economy.Trade;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import com.earth2me.essentials.settings.SpawnsHolder;
|
||||
import org.bukkit.Location;
|
||||
@@ -34,7 +35,7 @@ public class Commandspawn extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
@@ -1,17 +1,15 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.utils.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import com.earth2me.essentials.api.IUser;
|
||||
import com.earth2me.essentials.api.server.ICommandSender;
|
||||
import com.earth2me.essentials.permissions.Permissions;
|
||||
|
||||
|
||||
public class Commandsudo extends EssentialsCommand
|
||||
{
|
||||
@Override
|
||||
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
protected void run(final ICommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
@@ -33,6 +31,7 @@ public class Commandsudo extends EssentialsCommand
|
||||
|
||||
sender.sendMessage(_("sudoRun", user.getDisplayName(), command, getFinalArg(arguments, 0)));
|
||||
|
||||
ess.getServer().dispatchCommand(user, command);
|
||||
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
|
||||
if (execCommand != null)
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user