mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-13 11:41:24 +01:00
Merge branch 'master' of github.com:essentials/Essentials
This commit is contained in:
commit
8d6e3e7c18
6
.gitignore
vendored
6
.gitignore
vendored
@ -28,4 +28,8 @@
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/
|
@ -62,6 +62,7 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
@ -69,6 +70,7 @@ file.reference.iCo6.jar=../lib/iCo6.jar
|
||||
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
||||
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
@ -82,7 +84,9 @@ javac.classpath=\
|
||||
${file.reference.iCo6.jar}:\
|
||||
${file.reference.MultiCurrency.jar}:\
|
||||
${file.reference.BOSEconomy7.jar}:\
|
||||
${file.reference.PermissionsEx.jar}
|
||||
${file.reference.PermissionsEx.jar}:\
|
||||
${file.reference.bPermissions.jar}:\
|
||||
${file.reference.PermissionsBukkit-1.2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
@ -1,35 +1,45 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
public class Backup implements Runnable {
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final CraftServer server;
|
||||
private final IEssentials ess;
|
||||
private boolean running = false;
|
||||
private int taskId = -1;
|
||||
private boolean active = false;
|
||||
|
||||
public Backup(IEssentials ess) {
|
||||
public class Backup implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient final CraftServer server;
|
||||
private transient final IEssentials ess;
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
private transient boolean active = false;
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
server = (CraftServer)ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0) {
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onPlayerJoin() {
|
||||
void onPlayerJoin()
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
|
||||
private void startTask() {
|
||||
if (!running) {
|
||||
long interval = ess.getSettings().getBackupInterval()*1200; // minutes -> ticks
|
||||
if (interval < 1200) {
|
||||
|
||||
private void startTask()
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
@ -37,48 +47,84 @@ public class Backup implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (active) return;
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command)) {
|
||||
public void run()
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
logger.log(Level.INFO, Util.i18n("backupStarted"));
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, Util.i18n("backupStarted"));
|
||||
final CommandSender cs = server.getServer().console;
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
|
||||
ess.scheduleAsyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Process child = Runtime.getRuntime().exec(command);
|
||||
child.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0) {
|
||||
running = false;
|
||||
if (taskId != -1) {
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
{
|
||||
child.waitFor();
|
||||
String line;
|
||||
do
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
active = false;
|
||||
logger.log(Level.INFO, Util.i18n("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
running = false;
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
active = false;
|
||||
LOGGER.log(Level.INFO, Util.i18n("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class BukkitPermissionsHandler implements IPermissionsHandler
|
||||
{
|
||||
public String getGroup(Player base)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
|
||||
public boolean canBuild(Player base, String group)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean inGroup(Player base, String group)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player base, String node)
|
||||
{
|
||||
if (base.hasPermission("-" + node))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final String[] parts = node.split("\\.");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String part : parts)
|
||||
{
|
||||
if (base.hasPermission(sb.toString() + "*"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
sb.append(part).append(".");
|
||||
}
|
||||
return base.hasPermission(node);
|
||||
}
|
||||
|
||||
public String getPrefix(Player base)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getSuffix(Player base)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
@ -26,7 +26,9 @@ import org.bukkit.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.signs.SignBlockListener;
|
||||
import com.earth2me.essentials.signs.SignEntityListener;
|
||||
@ -38,7 +40,6 @@ import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.*;
|
||||
import org.bukkit.plugin.java.*;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
@ -62,7 +63,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
private transient final Methods paymentMethod = new Methods();
|
||||
private transient final static boolean enableErrorLogging = false;
|
||||
private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
|
||||
private transient IPermissionsHandler permissionsHandler;
|
||||
private transient PermissionsHandler permissionsHandler;
|
||||
private transient UserMap userMap;
|
||||
|
||||
@Override
|
||||
@ -87,7 +88,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
|
||||
settings = new Settings(this);
|
||||
userMap = new UserMap(this);
|
||||
permissionsHandler = new ConfigPermissionsHandler(this);
|
||||
permissionsHandler = new PermissionsHandler(this, false);
|
||||
Economy.setEss(this);
|
||||
}
|
||||
|
||||
@ -148,9 +149,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
|
||||
}
|
||||
|
||||
final ServerListener serverListener = new EssentialsPluginListener(this);
|
||||
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
|
||||
confList.add(serverListener);
|
||||
|
||||
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
@ -207,12 +210,12 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
Economy.setEss(this);
|
||||
if (getSettings().isUpdateEnabled())
|
||||
{
|
||||
updateTimer = new EssentialsUpdateTimer(this);
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60, 20 * 3600 * 6);
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60 * 10, 20 * 3600 * 6);
|
||||
}
|
||||
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
|
||||
}
|
||||
@ -448,6 +451,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
@ -561,7 +568,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
return null;
|
||||
return new User(base, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -605,14 +612,20 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public int broadcastMessage(final String name, final String message)
|
||||
public int broadcastMessage(final IUser sender, final String message)
|
||||
{
|
||||
if (sender == null) {
|
||||
return getServer().broadcastMessage(message);
|
||||
}
|
||||
if (sender.isHidden()) {
|
||||
return 0;
|
||||
}
|
||||
final Player[] players = getServer().getOnlinePlayers();
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
final User user = getUser(player);
|
||||
if (!user.isIgnoredPlayer(name))
|
||||
if (!user.isIgnoredPlayer(sender.getName()))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
@ -657,17 +670,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPermissionsHandler getPermissionsHandler()
|
||||
public PermissionsHandler getPermissionsHandler()
|
||||
{
|
||||
return permissionsHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPermissionsHandler(final IPermissionsHandler handler)
|
||||
{
|
||||
this.permissionsHandler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BanWorkaround getBans()
|
||||
{
|
||||
|
@ -47,11 +47,6 @@ public class EssentialsConf extends Configuration
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
if (configFile.exists() && configFile.length() == 0 && !configFile.delete())
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, "Could not delete file " + configFile.toString());
|
||||
}
|
||||
|
||||
// This will delete files where the first character is 0. In most cases they are broken.
|
||||
if (configFile.exists() && configFile.length() != 0)
|
||||
{
|
||||
|
@ -1,13 +1,10 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
@ -52,16 +49,12 @@ public class EssentialsEntityListener extends EntityListener
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event instanceof EntityDamageEvent || event instanceof EntityDamageByBlockEvent || event instanceof EntityDamageByProjectileEvent)
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
CraftPlayer player = (CraftPlayer)event.getEntity();
|
||||
player.getHandle().fireTicks = 0;
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
final Player player = (Player)event.getEntity();
|
||||
player.setFireTicks(0);
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
user.updateActivity();
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
@ -107,7 +107,10 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
return;
|
||||
}
|
||||
|
||||
user.updateActivity();
|
||||
Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) {
|
||||
user.updateActivity(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().getNetherPortalsEnabled())
|
||||
{
|
||||
@ -226,7 +229,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
}
|
||||
user.updateActivity();
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
if (!ess.getSettings().getReclaimSetting())
|
||||
{
|
||||
@ -275,7 +278,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
user.setAfk(false);
|
||||
user.updateActivity(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
@ -310,15 +313,11 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
@Override
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL)
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user == null)
|
||||
{
|
||||
user = new User(event.getPlayer(), ess);
|
||||
}
|
||||
user.setNPC(false);
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
@ -466,7 +465,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(user, command);
|
||||
user.getServer().dispatchCommand(event.getPlayer(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -493,7 +492,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
user.updateActivity();
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class EssentialsPluginListener extends ServerListener
|
||||
public class EssentialsPluginListener extends ServerListener implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
@ -23,7 +20,7 @@ public class EssentialsPluginListener extends ServerListener
|
||||
@Override
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
checkPermissions();
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin()))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
@ -32,50 +29,20 @@ public class EssentialsPluginListener extends ServerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
checkPermissions();
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPermissions()
|
||||
{
|
||||
final PluginManager pm = ess.getServer().getPluginManager();
|
||||
final Plugin permissionsExPlugin = pm.getPlugin("PermissionsEx");
|
||||
|
||||
if (permissionsExPlugin == null || !permissionsExPlugin.isEnabled())
|
||||
{
|
||||
final Plugin permissionsPlugin = pm.getPlugin("Permissions");
|
||||
if (permissionsPlugin == null || !permissionsPlugin.isEnabled())
|
||||
{
|
||||
if (ess.getSettings().useBukkitPermissions())
|
||||
{
|
||||
ess.setPermissionsHandler(new BukkitPermissionsHandler());
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new ConfigPermissionsHandler(ess));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3')
|
||||
{
|
||||
ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin));
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new PermissionsExHandler());
|
||||
}
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
@ -22,7 +23,7 @@ public interface IEssentials extends Plugin
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(String name, String message);
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
@ -56,9 +57,7 @@ public interface IEssentials extends Plugin
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
IPermissionsHandler getPermissionsHandler();
|
||||
|
||||
void setPermissionsHandler(IPermissionsHandler handler);
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
|
||||
|
||||
|
@ -54,4 +54,6 @@ public interface IUser
|
||||
InetSocketAddress getAddress();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
boolean isHidden();
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.earth2me.essentials;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -130,7 +129,7 @@ public final class InventoryWorkaround
|
||||
// More than a single stack!
|
||||
if (item.getAmount() > item.getType().getMaxStackSize())
|
||||
{
|
||||
cinventory.setItem(firstFree, new CraftItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
|
||||
cinventory.setItem(firstFree, new ItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
|
||||
item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
|
||||
}
|
||||
else
|
||||
|
@ -483,7 +483,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean isUpdateEnabled()
|
||||
{
|
||||
return config.getBoolean("update-check", true);
|
||||
return config.getBoolean("update-check", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
@ -52,6 +54,7 @@ public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final Player[] players = ess.getServer().getOnlinePlayers();
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
@ -72,6 +75,9 @@ public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
}
|
||||
}
|
||||
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -264,14 +264,7 @@ public class Teleport implements Runnable
|
||||
final Location loc = user.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
if (ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
respawn(ess.getSpawn(), chargeFor);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
teleport(new Target(loc), chargeFor);
|
||||
}
|
||||
|
@ -17,16 +17,18 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient final Teleport teleport;
|
||||
private transient long lastOnlineActivity = System.currentTimeMillis();;
|
||||
private transient long lastActivity;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient boolean godStateBeforeAfk;
|
||||
private transient Location afkPosition;
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
|
||||
User update(final Player base)
|
||||
@ -50,6 +52,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
@ -60,7 +67,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return false;
|
||||
}
|
||||
|
||||
return ess.getPermissionsHandler().hasPermission(this, node);
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
@ -264,8 +271,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
|
||||
nickname.insert(0, prefix);
|
||||
nickname.append(suffix);
|
||||
@ -341,13 +348,18 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
|
||||
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
setGodModeEnabled(true);
|
||||
}
|
||||
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
|
||||
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
setGodModeEnabled(godStateBeforeAfk);
|
||||
}
|
||||
if (set && !isAfk()) {
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
@ -406,13 +418,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
}
|
||||
|
||||
public void updateActivity()
|
||||
public void updateActivity(final boolean broadcast)
|
||||
{
|
||||
if (isAfk())
|
||||
{
|
||||
setAfk(false);
|
||||
ess.broadcastMessage(getName(), Util.format("userIsNotAway", getDisplayName()));
|
||||
return;
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
ess.broadcastMessage(this, Util.format("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
@ -421,9 +435,9 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
||||
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
|
||||
&& !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
{
|
||||
final String kickReason = Util.format("autoAfkKickReason", autoafkkick/60.0);
|
||||
final String kickReason = Util.format("autoAfkKickReason", autoafkkick / 60.0);
|
||||
kickPlayer(kickReason);
|
||||
|
||||
|
||||
@ -440,7 +454,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
|
||||
{
|
||||
setAfk(true);
|
||||
ess.broadcastMessage(getName(), Util.format("userIsAway", getDisplayName()));
|
||||
if (!isHidden()) {
|
||||
ess.broadcastMessage(this, Util.format("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getAfkPosition()
|
||||
{
|
||||
return afkPosition;
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,6 @@ public class Commandafk extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
{
|
||||
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
|
||||
@ -35,13 +33,20 @@ public class Commandafk extends EssentialsCommand
|
||||
{
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
//user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
user.updateActivity(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
|
||||
//user.sendMessage(Util.i18n("markedAsAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, Util.format("userIsAway", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,8 @@ public class Commandantioch extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
ess.broadcastMessage(user.getName(), "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user.getName(), "who being naughty in My sight, shall snuff it.");
|
||||
ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
|
||||
|
||||
final Location loc = new TargetBlock(user).getTargetBlock().getLocation();
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
|
@ -19,9 +19,8 @@ public class Commandbackup extends EssentialsCommand
|
||||
Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
{
|
||||
return;
|
||||
throw new Exception();
|
||||
}
|
||||
charge(sender);
|
||||
backup.run();
|
||||
sender.sendMessage(Util.i18n("backupStarted"));
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ public class Commandbalance extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
double bal = (args.length < 1
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
|
@ -41,12 +41,11 @@ public class Commandbigtree extends EssentialsCommand
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
if (success)
|
||||
{
|
||||
charge(user);
|
||||
user.sendMessage(Util.i18n("bigTreeSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("bigTreeFailure"));
|
||||
throw new Exception(Util.i18n("bigTreeFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -15,15 +14,14 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
ess.broadcastMessage(sender instanceof Player ? ((Player)sender).getName() : Console.NAME,
|
||||
ess.broadcastMessage(null,
|
||||
Util.format("broadcast", getFinalArg(args, 0)));
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ public class Commandburn extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
p.setFireTicks(Integer.parseInt(args[1]) * 20);
|
||||
|
@ -27,7 +27,6 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
|
||||
if (!online.isEmpty())
|
||||
{
|
||||
charge(user);
|
||||
for (Player p : online)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
@ -42,7 +41,6 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
Player p = server.getPlayer(args[0]);
|
||||
if (p != null)
|
||||
{
|
||||
charge(user);
|
||||
p.getInventory().clear();
|
||||
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
@ -54,7 +52,6 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
charge(user);
|
||||
user.getInventory().clear();
|
||||
user.sendMessage(Util.i18n("inventoryCleared"));
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ public class Commandcompass extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
int r = (int)user.getCorrectedYaw();
|
||||
String dir;
|
||||
if (r < 23) dir = "N";
|
||||
|
@ -16,7 +16,6 @@ public class Commanddeljail extends EssentialsCommand {
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(sender);
|
||||
ess.getJail().delJail(args[0]);
|
||||
sender.sendMessage(Util.format("deleteJail", args[0]));
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ public class Commanddelwarp extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(sender);
|
||||
ess.getWarps().delWarp(args[0]);
|
||||
sender.sendMessage(Util.format("deleteWarp", args[0]));
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ public class Commanddepth extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
int y = user.getLocation().getBlockY() - 63;
|
||||
if (y > 0)
|
||||
{
|
||||
|
@ -102,7 +102,6 @@ public class Commandessentials extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
ess.reload();
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,6 @@ public class Commandext extends EssentialsCommand
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
charge(user);
|
||||
user.setFireTicks(0);
|
||||
user.sendMessage(Util.i18n("extinguish"));
|
||||
return;
|
||||
@ -43,7 +42,6 @@ public class Commandext extends EssentialsCommand
|
||||
{
|
||||
for (Player p : server.matchPlayer(name))
|
||||
{
|
||||
charge(sender);
|
||||
p.setFireTicks(0);
|
||||
sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName()));
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ public class Commandfireball extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
|
||||
user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Fireball.class);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ public class Commandgc extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
|
@ -15,7 +15,6 @@ public class Commandgetpos extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
Location coords = user.getLocation();
|
||||
user.sendMessage("§7X: " + coords.getBlockX() + " (-North <-> +South)");
|
||||
user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
|
||||
|
@ -36,8 +36,7 @@ public class Commandgive extends EssentialsCommand
|
||||
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
return;
|
||||
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
}
|
||||
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
{
|
||||
@ -46,13 +45,11 @@ public class Commandgive extends EssentialsCommand
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't give air.");
|
||||
return;
|
||||
throw new Exception(ChatColor.RED + "You can't give air.");
|
||||
}
|
||||
|
||||
User giveTo = getPlayer(server, args, 0);
|
||||
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
|
||||
charge(sender);
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
giveTo.getInventory().addItem(stack);
|
||||
giveTo.updateInventory();
|
||||
|
@ -28,7 +28,6 @@ public class Commandgod extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
if (args.length > 0 && user.isAuthorized("essentials.god.others"))
|
||||
{
|
||||
godOtherPlayers(server, user, args[0]);
|
||||
|
@ -25,7 +25,6 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
charge(user);
|
||||
healOtherPlayers(server, user, args[0]);
|
||||
return;
|
||||
}
|
||||
@ -34,7 +33,6 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
charge(user);
|
||||
user.setHealth(20);
|
||||
user.sendMessage(Util.i18n("heal"));
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ import java.util.logging.Level;
|
||||
|
||||
public class Commandhelp extends EssentialsCommand
|
||||
{
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String PERMISSION = "permission";
|
||||
private static final String PERMISSIONS = "permissions";
|
||||
public final Yaml yaml = new Yaml(new SafeConstructor());
|
||||
|
||||
public Commandhelp()
|
||||
@ -28,7 +31,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page = 1;
|
||||
String match = "";
|
||||
@ -53,34 +56,32 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
List<String> lines = getHelpLines(user, match);
|
||||
if (lines.size() > 0)
|
||||
final List<String> lines = getHelpLines(user, match);
|
||||
if (lines.isEmpty())
|
||||
{
|
||||
int start = (page - 1) * 9;
|
||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
user.sendMessage(Util.format("helpPages", page, pages));
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
{
|
||||
user.sendMessage(lines.get(i));
|
||||
}
|
||||
throw new Exception(Util.i18n("noHelpFound"));
|
||||
}
|
||||
else
|
||||
|
||||
final int start = (page - 1) * 9;
|
||||
final int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
user.sendMessage(Util.format("helpPages", page, pages));
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
{
|
||||
user.sendMessage(Util.i18n("noHelpFound"));
|
||||
user.sendMessage(lines.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage(Util.i18n("helpConsole"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("CallToThreadDumpStack")
|
||||
private List<String> getHelpLines(User user, String match) throws Exception
|
||||
private List<String> getHelpLines(final User user, final String match) throws Exception
|
||||
{
|
||||
List<String> retval = new ArrayList<String>();
|
||||
final List<String> retval = new ArrayList<String>();
|
||||
File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt");
|
||||
if (!helpFile.exists())
|
||||
{
|
||||
@ -116,15 +117,16 @@ public class Commandhelp extends EssentialsCommand
|
||||
try
|
||||
{
|
||||
final PluginDescriptionFile desc = p.getDescription();
|
||||
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
|
||||
final HashMap<String, HashMap<String, Object>> cmds = (HashMap<String, HashMap<String, Object>>)desc.getCommands();
|
||||
pluginName = p.getDescription().getName().toLowerCase();
|
||||
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
|
||||
for (Entry<String, HashMap<String, Object>> k : cmds.entrySet())
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((!match.equalsIgnoreCase(""))
|
||||
&& (!k.getKey().toLowerCase().contains(match))
|
||||
&& (!k.getValue().get("description").toLowerCase().contains(match))
|
||||
&& (!(k.getValue().get(DESCRIPTION) instanceof String
|
||||
&& ((String)k.getValue().get(DESCRIPTION)).toLowerCase().contains(match)))
|
||||
&& (!pluginName.contains(match)))
|
||||
{
|
||||
continue;
|
||||
@ -135,37 +137,69 @@ public class Commandhelp extends EssentialsCommand
|
||||
final String node = "essentials." + k.getKey();
|
||||
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description"));
|
||||
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getSettings().showNonEssCommandsInHelp())
|
||||
{
|
||||
final HashMap<String, String> value = k.getValue();
|
||||
if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals("")))
|
||||
final HashMap<String, Object> value = k.getValue();
|
||||
if (value.containsKey(PERMISSION) && value.get(PERMISSION) instanceof String && !(value.get(PERMISSION).equals("")))
|
||||
{
|
||||
if (user.isAuthorized(value.get("permission")))
|
||||
if (user.isAuthorized((String)value.get(PERMISSION)))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals("")))
|
||||
else if (value.containsKey(PERMISSION) && value.get(PERMISSION) instanceof List && !((List<Object>)value.get(PERMISSION)).isEmpty())
|
||||
{
|
||||
if (user.isAuthorized(value.get("permissions")))
|
||||
boolean enabled = false;
|
||||
for (Object o : (List<Object>)value.get(PERMISSION))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
if (o instanceof String && user.isAuthorized((String)o))
|
||||
{
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey(PERMISSIONS) && value.get(PERMISSIONS) instanceof String && !(value.get(PERMISSIONS).equals("")))
|
||||
{
|
||||
if (user.isAuthorized((String)value.get(PERMISSIONS)))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey(PERMISSIONS) && value.get(PERMISSIONS) instanceof List && !((List<Object>)value.get(PERMISSIONS)).isEmpty())
|
||||
{
|
||||
boolean enabled = false;
|
||||
for (Object o : (List<Object>)value.get(PERMISSIONS))
|
||||
{
|
||||
if (o instanceof String && user.isAuthorized((String)o))
|
||||
{
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (user.isAuthorized("essentials.help." + pluginName))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ess.getSettings().hidePermissionlessHelp())
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ public class Commandhelpop extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(user);
|
||||
final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
|
@ -53,10 +53,15 @@ public class Commandhome extends EssentialsCommand
|
||||
{
|
||||
user.getTeleport().home(u, homes.get(0), charge);
|
||||
}
|
||||
else if (ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
user.getTeleport().respawn(ess.getSpawn(), charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("homes", Util.joinList(homes)));
|
||||
}
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@ -68,9 +68,8 @@ public class Commandinfo extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.i18n("infoFileDoesNotExist"));
|
||||
file.createNewFile();
|
||||
return;
|
||||
throw new Exception(Util.i18n("infoFileDoesNotExist"));
|
||||
}
|
||||
|
||||
if (bookmarks.isEmpty())
|
||||
@ -88,7 +87,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
int start = (page - 1) * 9;
|
||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoPages", page, pages ));
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
{
|
||||
@ -140,7 +138,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
}
|
||||
int pages = end / 9 + (end % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoPages", page, pages ));
|
||||
for (int i = start; i < end && i < start + 9; i++)
|
||||
{
|
||||
@ -182,7 +179,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
int page = chapterpage + 1;
|
||||
int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoChapterPages", pageStr, page , pages));
|
||||
for (int i = start; i < chapterend && i < start + 9; i++)
|
||||
{
|
||||
|
@ -31,11 +31,9 @@ public class Commandinvsee extends EssentialsCommand
|
||||
{
|
||||
invUser.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
user.sendMessage(Util.i18n("invRestored"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("invRestored"));
|
||||
}
|
||||
|
||||
charge(user);
|
||||
if (user.getSavedInventory() == null)
|
||||
{
|
||||
user.setSavedInventory(user.getInventory().getContents());
|
||||
|
@ -31,8 +31,7 @@ public class Commanditem extends EssentialsCommand
|
||||
: (!user.isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !user.canSpawnItem(stack.getTypeId())))
|
||||
{
|
||||
user.sendMessage(Util.format("cantSpawnItem", itemname));
|
||||
return;
|
||||
throw new Exception(Util.format("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
||||
@ -42,12 +41,10 @@ public class Commanditem extends EssentialsCommand
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
user.sendMessage(Util.format("cantSpawnItem", "Air"));
|
||||
return;
|
||||
throw new Exception(Util.format("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
|
||||
charge(user);
|
||||
user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName));
|
||||
user.getInventory().addItem(stack);
|
||||
user.updateInventory();
|
||||
|
@ -26,10 +26,8 @@ public class Commandkick extends EssentialsCommand
|
||||
User player = getPlayer(server, args, 0);
|
||||
if (player.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("kickExempt"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("kickExempt"));
|
||||
}
|
||||
charge(sender);
|
||||
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
|
||||
player.kickPlayer(kickReason);
|
||||
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
@ -16,8 +16,6 @@ public class Commandkickall extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (sender instanceof Player && p.getName().equalsIgnoreCase(((Player)sender).getName()))
|
||||
|
@ -21,7 +21,6 @@ public class Commandkill extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
p.setHealth(0);
|
||||
|
@ -141,7 +141,6 @@ public class Commandkit extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
charge(user);
|
||||
charge.charge(user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -26,20 +26,14 @@ public class Commandlightning extends EssentialsCommand
|
||||
if (args.length < 1 & user != null)
|
||||
{
|
||||
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
|
||||
charge(user);
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.matchPlayer(args[0]).isEmpty())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
charge(user);
|
||||
}
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
sender.sendMessage(Util.format("lightningUse", p.getDisplayName()));
|
||||
|
@ -44,7 +44,6 @@ public class Commandlist extends EssentialsCommand
|
||||
playerHidden++;
|
||||
}
|
||||
}
|
||||
charge(sender);
|
||||
//TODO: move these to messages file
|
||||
StringBuilder online = new StringBuilder();
|
||||
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
|
||||
|
@ -23,22 +23,19 @@ public class Commandmail extends EssentialsCommand
|
||||
List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noMail"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("noMail"));
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
user.sendMessage(s);
|
||||
}
|
||||
user.sendMessage(Util.i18n("mailClear"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("mailClear"));
|
||||
}
|
||||
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
if (!user.isAuthorized("essentials.mail.send"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("noMailSendPerm"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("noMailSendPerm"));
|
||||
}
|
||||
|
||||
Player player = server.getPlayer(args[1]);
|
||||
@ -53,10 +50,8 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
user.sendMessage(Util.format("playerNeverOnServer", args[1]));
|
||||
return;
|
||||
throw new Exception(Util.format("playerNeverOnServer", args[1]));
|
||||
}
|
||||
charge(user);
|
||||
if (!u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
u.addMail(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2));
|
||||
@ -67,8 +62,7 @@ public class Commandmail extends EssentialsCommand
|
||||
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
user.setMails(null);
|
||||
user.sendMessage(Util.i18n("mailCleared"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("mailCleared"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
@ -17,21 +17,22 @@ public class Commandme extends EssentialsCommand
|
||||
{
|
||||
if (user.isMuted())
|
||||
{
|
||||
user.sendMessage(Util.i18n("voiceSilenced"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("voiceSilenced"));
|
||||
}
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
StringBuilder message = new StringBuilder();
|
||||
final StringBuilder message = new StringBuilder();
|
||||
message.append("* ");
|
||||
message.append(user.getDisplayName());
|
||||
message.append(' ');
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
message.append(args[i]);
|
||||
message.append(' ');
|
||||
}
|
||||
charge(user);
|
||||
ess.broadcastMessage(user.getName(), "* " + user.getDisplayName() + " " + message);
|
||||
ess.broadcastMessage(user, message.toString());
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ public class Commandmotd extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
for (String m : ess.getMotd(sender, Util.i18n("noMotd")))
|
||||
{
|
||||
sender.sendMessage(m);
|
||||
|
@ -30,8 +30,7 @@ public class Commandmsg extends EssentialsCommand
|
||||
User user = ess.getUser(sender);
|
||||
if (user.isMuted())
|
||||
{
|
||||
user.sendMessage(Util.i18n("voiceSilenced"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("voiceSilenced"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,8 +54,7 @@ public class Commandmsg extends EssentialsCommand
|
||||
|
||||
if (matches.isEmpty())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
@ -70,11 +68,9 @@ public class Commandmsg extends EssentialsCommand
|
||||
}
|
||||
if (i == matches.size())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : matches)
|
||||
{
|
||||
sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message));
|
||||
|
@ -24,8 +24,7 @@ public class Commandmute extends EssentialsCommand
|
||||
User p = getPlayer(server, args, 0, true);
|
||||
if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("muteExempt"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("muteExempt"));
|
||||
}
|
||||
long muteTimestamp = 0;
|
||||
if (args.length > 1)
|
||||
@ -34,7 +33,6 @@ public class Commandmute extends EssentialsCommand
|
||||
muteTimestamp = Util.parseDateDiff(time, true);
|
||||
}
|
||||
p.setMuteTimeout(muteTimestamp);
|
||||
charge(sender);
|
||||
boolean muted = p.toggleMuted();
|
||||
sender.sendMessage(
|
||||
muted
|
||||
|
@ -23,16 +23,14 @@ public class Commandnick extends EssentialsCommand
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
user.sendMessage(Util.i18n("nickDisplayName"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickDisplayName"));
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (!user.isAuthorized("essentials.nick.others"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickOthersPermission"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickOthersPermission"));
|
||||
}
|
||||
|
||||
setOthersNickname(server, user, args);
|
||||
@ -51,8 +49,7 @@ public class Commandnick extends EssentialsCommand
|
||||
|
||||
if (nick.matches("[^a-zA-Z_0-9]"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickNamesAlpha"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickNamesAlpha"));
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
@ -66,12 +63,10 @@ public class Commandnick extends EssentialsCommand
|
||||
String nk = nick.toLowerCase();
|
||||
if (nk.equals(dn) || nk.equals(n))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickInUse"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickInUse"));
|
||||
}
|
||||
}
|
||||
|
||||
charge(user);
|
||||
user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
|
||||
user.setNickname(nick);
|
||||
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
|
||||
|
@ -1,173 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import java.io.File;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class Commandplugin extends EssentialsCommand
|
||||
{
|
||||
private Server server;
|
||||
|
||||
public Commandplugin()
|
||||
{
|
||||
super("plugin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
this.server = server;
|
||||
|
||||
PluginCommands sub = null;
|
||||
try
|
||||
{
|
||||
sub = PluginCommands.valueOf(args[0].toUpperCase());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /plugin [load|reload|enable|disable|list] [PluginName]");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (sub)
|
||||
{
|
||||
case LOAD: // All disable functions are broken until
|
||||
// http://leaky.bukkit.org/issues/641 is fixed.
|
||||
sender.sendMessage("This function is broken. Performing /reload now.");
|
||||
server.reload();
|
||||
/*if (args.length < 2) return;
|
||||
User.charge(sender, this);
|
||||
loadPlugin(args[1], sender);*/
|
||||
return;
|
||||
|
||||
case RELOAD:
|
||||
sender.sendMessage("This function is broken. Performing /reload now.");
|
||||
server.reload();
|
||||
/*if (args.length < 2) return;
|
||||
User.charge(sender, this);
|
||||
reloadPlugin(args[1], sender);*/
|
||||
return;
|
||||
|
||||
case ENABLE:
|
||||
sender.sendMessage("This function is broken. Performing /reload now.");
|
||||
server.reload();
|
||||
/*if (args.length < 2) return;
|
||||
User.charge(sender, this);
|
||||
enablePlugin(args[1], sender);*/
|
||||
return;
|
||||
|
||||
case DISABLE:
|
||||
sender.sendMessage("This function is broken.");
|
||||
/*if (args.length < 2) return;
|
||||
User.charge(sender, this);
|
||||
disablePlugin(args[1], sender);*/
|
||||
return;
|
||||
|
||||
case LIST:
|
||||
charge(sender);
|
||||
listPlugins(sender);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void listPlugins(CommandSender player)
|
||||
{
|
||||
StringBuilder plugins = new StringBuilder();
|
||||
for (Plugin p : server.getPluginManager().getPlugins())
|
||||
{
|
||||
plugins.append(p.isEnabled() ? " §a" : " §c");
|
||||
plugins.append(p.getDescription().getName());
|
||||
}
|
||||
|
||||
plugins.insert(0, "§7Plugins:§f");
|
||||
player.sendMessage(plugins.toString());
|
||||
}
|
||||
|
||||
private boolean reloadPlugin(String name, CommandSender player)
|
||||
{
|
||||
return disablePlugin(name, player) && enablePlugin(name, player);
|
||||
}
|
||||
|
||||
private boolean loadPlugin(String name, CommandSender sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginManager pm = server.getPluginManager();
|
||||
pm.loadPlugin(new File("plugins", name + ".jar"));
|
||||
sender.sendMessage("§7Plugin loaded.");
|
||||
return enablePlugin(name, sender);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
sender.sendMessage("§cCould not load plugin. Is the file named properly?");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean enablePlugin(String name, CommandSender sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
final PluginManager pm = server.getPluginManager();
|
||||
final Plugin plugin = pm.getPlugin(name);
|
||||
if (!plugin.isEnabled())
|
||||
{
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (pm)
|
||||
{
|
||||
pm.enablePlugin(plugin);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
sender.sendMessage("§7Plugin enabled.");
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
listPlugins(sender);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean disablePlugin(String name, CommandSender sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
final PluginManager pm = server.getPluginManager();
|
||||
final Plugin plugin = pm.getPlugin(name);
|
||||
if (plugin.isEnabled())
|
||||
{
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (pm)
|
||||
{
|
||||
pm.disablePlugin(plugin);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
sender.sendMessage("§7Plugin disabled.");
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
listPlugins(sender);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum PluginCommands
|
||||
{
|
||||
LOAD, RELOAD, LIST, ENABLE, DISABLE
|
||||
}
|
||||
}
|
@ -17,25 +17,24 @@ public class Commandpowertool extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
ItemStack is = user.getItemInHand();
|
||||
List<String> powertools = user.getPowertool(is);
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
final ItemStack itemStack = user.getItemInHand();
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR)
|
||||
{
|
||||
user.sendMessage(Util.i18n("powerToolAir"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("powerToolAir"));
|
||||
}
|
||||
|
||||
String itemName = is.getType().toString().toLowerCase().replaceAll("_", " ");
|
||||
final String itemName = itemStack.getType().toString().toLowerCase().replaceAll("_", " ");
|
||||
String command = getFinalArg(args, 0);
|
||||
List<String> powertools = user.getPowertool(itemStack);
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
if (command.equalsIgnoreCase("l:"))
|
||||
{
|
||||
if (powertools == null || powertools.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolListEmpty", itemName));
|
||||
throw new Exception(Util.format("powerToolListEmpty", itemName));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -50,8 +49,7 @@ public class Commandpowertool extends EssentialsCommand
|
||||
command = command.substring(2);
|
||||
if (!powertools.contains(command))
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolNoSuchCommandAssigned", command, itemName));
|
||||
return;
|
||||
throw new Exception(Util.format("powerToolNoSuchCommandAssigned", command, itemName));
|
||||
}
|
||||
|
||||
powertools.remove(command);
|
||||
@ -68,10 +66,9 @@ public class Commandpowertool extends EssentialsCommand
|
||||
if (command.startsWith("a:"))
|
||||
{
|
||||
command = command.substring(2);
|
||||
if(powertools.contains(command))
|
||||
if (powertools.contains(command))
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolAlreadySet", command, itemName));
|
||||
return;
|
||||
throw new Exception(Util.format("powerToolAlreadySet", command, itemName));
|
||||
}
|
||||
}
|
||||
else if (powertools != null && !powertools.isEmpty())
|
||||
@ -90,11 +87,13 @@ public class Commandpowertool extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.clear();
|
||||
if (powertools != null)
|
||||
{
|
||||
powertools.clear();
|
||||
}
|
||||
user.sendMessage(Util.format("powerToolRemoveAll", itemName));
|
||||
}
|
||||
|
||||
charge(user);
|
||||
user.setPowertool(is, powertools);
|
||||
user.setPowertool(itemStack, powertools);
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,9 @@ public class Commandr extends EssentialsCommand
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
sender.sendMessage(Util.i18n("foreverAlone"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("foreverAlone"));
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("msgFormat", Util.i18n("me"), targetName, message));
|
||||
if (target instanceof Player)
|
||||
{
|
||||
|
@ -22,7 +22,6 @@ public class Commandrealname extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final String whois = args[0].toLowerCase();
|
||||
charge(user);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
final User u = ess.getUser(p);
|
||||
|
@ -15,7 +15,6 @@ public class Commandreloadall extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
server.reload();
|
||||
sender.sendMessage(Util.i18n("reloadAllPlugins"));
|
||||
}
|
||||
|
@ -33,28 +33,12 @@ public class Commandrepair extends EssentialsCommand
|
||||
final String itemName = item.getType().toString().toLowerCase();
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
user.sendMessage(ex.getMessage());
|
||||
return;
|
||||
}
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
repairItem(item);
|
||||
|
||||
try
|
||||
{
|
||||
repairItem(item);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(e.getMessage());
|
||||
return;
|
||||
}
|
||||
charge.charge(user);
|
||||
|
||||
charge(user);
|
||||
user.sendMessage(Util.format("repair", itemName.replace('_', ' ')));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("all"))
|
||||
@ -66,11 +50,10 @@ public class Commandrepair extends EssentialsCommand
|
||||
|
||||
if (repaired.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.format("repairNone"));
|
||||
throw new Exception(Util.format("repairNone"));
|
||||
}
|
||||
else
|
||||
{
|
||||
charge(user);
|
||||
user.sendMessage(Util.format("repair", Util.joinList(repaired)));
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ public class Commandrules extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
for (String m : ess.getLines(sender, "rules", Util.i18n("noRules")))
|
||||
{
|
||||
sender.sendMessage(m);
|
||||
|
@ -145,11 +145,9 @@ public class Commandsell extends EssentialsCommand
|
||||
{
|
||||
user.sendMessage(Util.i18n("itemNotEnough1"));
|
||||
user.sendMessage(Util.i18n("itemNotEnough2"));
|
||||
user.sendMessage(Util.i18n("itemNotEnough3"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("itemNotEnough3"));
|
||||
}
|
||||
|
||||
charge(user);
|
||||
final ItemStack ris = new ItemStack(is.getType(), amount, is.getDurability());
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, ris);
|
||||
user.updateInventory();
|
||||
|
@ -39,6 +39,9 @@ public class Commandsethome extends EssentialsCommand
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
throw new Exception(Util.format("maxHomes", 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -66,7 +69,6 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
user.setHome();
|
||||
}
|
||||
charge(user);
|
||||
user.sendMessage(Util.i18n("homeSet"));
|
||||
|
||||
}
|
||||
|
@ -15,12 +15,10 @@ public class Commandsetjail extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(user);
|
||||
ess.getJail().setJail(user.getLocation(), args[0]);
|
||||
user.sendMessage(Util.format("jailSet",args[0]));
|
||||
|
||||
|
@ -21,7 +21,6 @@ public class Commandsetwarp extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(user);
|
||||
Location loc = user.getLocation();
|
||||
ess.getWarps().setWarp(args[0], loc);
|
||||
user.sendMessage(Util.format("warpSet", args[0]));
|
||||
|
@ -22,7 +22,6 @@ public class Commandsetworth extends EssentialsCommand
|
||||
}
|
||||
|
||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
charge(user);
|
||||
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
|
||||
user.sendMessage(Util.i18n("worthSet"));
|
||||
}
|
||||
|
@ -15,9 +15,6 @@ public class Commandsocialspy extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
|
||||
charge(user);
|
||||
user.sendMessage("§7SocialSpy " + (user.toggleSocialSpy() ? Util.i18n("enabled") : Util.i18n("disabled")));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
|
||||
|
||||
public class Commandspawner extends EssentialsCommand
|
||||
@ -32,7 +31,6 @@ public class Commandspawner extends EssentialsCommand
|
||||
throw new Exception(Util.i18n("mobSpawnTarget"));
|
||||
}
|
||||
|
||||
charge(user);
|
||||
try
|
||||
{
|
||||
String name = args[0];
|
||||
@ -45,7 +43,7 @@ public class Commandspawner extends EssentialsCommand
|
||||
user.sendMessage(Util.i18n("invalidMob"));
|
||||
return;
|
||||
}
|
||||
new CraftCreatureSpawner(target).setCreatureType(mob.getType());
|
||||
((CreatureSpawner)target.getState()).setCreatureType(mob.getType());
|
||||
user.sendMessage(Util.format("setSpawner", mob.name));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
|
@ -8,16 +8,13 @@ import com.earth2me.essentials.Mob.MobException;
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Random;
|
||||
import net.minecraft.server.EntityWolf;
|
||||
import net.minecraft.server.PathEntity;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.entity.CraftCreeper;
|
||||
import org.bukkit.craftbukkit.entity.CraftSheep;
|
||||
import org.bukkit.craftbukkit.entity.CraftSlime;
|
||||
import org.bukkit.craftbukkit.entity.CraftWolf;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Wolf;
|
||||
|
||||
|
||||
public class Commandspawnmob extends EssentialsCommand
|
||||
@ -62,8 +59,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase())
|
||||
|| (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase())))
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
|
||||
Entity spawnedMob = null;
|
||||
@ -74,10 +70,8 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
mob = Mob.fromName(mobType);
|
||||
if (mob == null)
|
||||
{
|
||||
user.sendMessage(Util.i18n("invalidMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("invalidMob"));
|
||||
}
|
||||
charge(user);
|
||||
int[] ignore =
|
||||
{
|
||||
8, 9
|
||||
@ -190,7 +184,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
{
|
||||
try
|
||||
{
|
||||
((CraftSlime)spawned).setSize(Integer.parseInt(data));
|
||||
((Slime)spawned).setSize(Integer.parseInt(data));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -204,11 +198,11 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
if (data.equalsIgnoreCase("random"))
|
||||
{
|
||||
Random rand = new Random();
|
||||
((CraftSheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
((Sheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
((CraftSheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase()));
|
||||
((Sheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase()));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -218,21 +212,18 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed"))
|
||||
{
|
||||
EntityWolf wolf = ((CraftWolf)spawned).getHandle();
|
||||
Wolf wolf = ((Wolf)spawned);
|
||||
wolf.setTamed(true);
|
||||
wolf.setPathEntity((PathEntity)null);
|
||||
wolf.setOwner(user);
|
||||
wolf.setSitting(true);
|
||||
wolf.health = 20;
|
||||
wolf.setOwnerName(user.getName());
|
||||
wolf.world.a(wolf, (byte)7);
|
||||
}
|
||||
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("angry"))
|
||||
{
|
||||
((CraftWolf)spawned).setAngry(true);
|
||||
((Wolf)spawned).setAngry(true);
|
||||
}
|
||||
if ("Creeper".equalsIgnoreCase(type) && data.equalsIgnoreCase("powered"))
|
||||
{
|
||||
((CraftCreeper)spawned).setPowered(true);
|
||||
((Creeper)spawned).setPowered(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,9 @@ public class Commandsuicide extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
user.setHealth(0);
|
||||
user.sendMessage(Util.i18n("suicideMessage"));
|
||||
ess.broadcastMessage(user.getName(),
|
||||
ess.broadcastMessage(user,
|
||||
Util.format("suicideSuccess",user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,11 @@ public class Commandthunder extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(user);
|
||||
World world = user.getWorld();
|
||||
boolean setThunder = args[0].equalsIgnoreCase("true");
|
||||
if (args.length > 1)
|
||||
|
@ -44,7 +44,6 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
}
|
||||
charge(sender);
|
||||
if (!(p.getBase() instanceof OfflinePlayer))
|
||||
{
|
||||
ess.getJail().sendToJail(p, args[1]);
|
||||
|
@ -20,7 +20,6 @@ public class Commandtop extends EssentialsCommand
|
||||
int topX = user.getLocation().getBlockX();
|
||||
int topZ = user.getLocation().getBlockZ();
|
||||
int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
|
||||
charge(user);
|
||||
user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess));
|
||||
user.sendMessage(Util.i18n("teleportTop"));
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class Commandtp extends EssentialsCommand
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(p, charge);
|
||||
break;
|
||||
throw new NoChargeException();
|
||||
|
||||
case 2:
|
||||
if (!user.isAuthorized("essentials.tpohere"))
|
||||
@ -41,13 +41,12 @@ public class Commandtp extends EssentialsCommand
|
||||
throw new Exception("You need access to /tpohere to teleport other players.");
|
||||
}
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
charge(user);
|
||||
User target = getPlayer(server, args, 0);
|
||||
User toPlayer = getPlayer(server, args, 1);
|
||||
target.getTeleport().now(toPlayer, false);
|
||||
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,5 +62,6 @@ public class Commandtp extends EssentialsCommand
|
||||
User toPlayer = getPlayer(server, args, 1);
|
||||
target.getTeleport().now(toPlayer, false);
|
||||
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ public class Commandtpa extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
|
||||
}
|
||||
charge(user);
|
||||
if (!p.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
p.requestTeleport(user, false);
|
||||
|
@ -21,7 +21,6 @@ public class Commandtpaall extends EssentialsCommand
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
charge(sender);
|
||||
teleportAAllPlayers(server, sender, ess.getUser(sender));
|
||||
return;
|
||||
}
|
||||
@ -29,7 +28,6 @@ public class Commandtpaall extends EssentialsCommand
|
||||
}
|
||||
|
||||
User p = getPlayer(server, args, 0);
|
||||
charge(sender);
|
||||
teleportAAllPlayers(server, sender, p);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,6 @@ public class Commandtpahere extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
|
||||
}
|
||||
charge(user);
|
||||
p.requestTeleport(user, true);
|
||||
p.sendMessage(Util.format("teleportHereRequest", user.getDisplayName()));
|
||||
p.sendMessage(Util.i18n("typeTpaccept"));
|
||||
|
@ -21,7 +21,6 @@ public class Commandtpall extends EssentialsCommand
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
charge(sender);
|
||||
teleportAllPlayers(server, sender, ess.getUser(sender));
|
||||
return;
|
||||
}
|
||||
@ -29,7 +28,6 @@ public class Commandtpall extends EssentialsCommand
|
||||
}
|
||||
|
||||
User p = getPlayer(server, args, 0);
|
||||
charge(sender);
|
||||
teleportAllPlayers(server, sender, p);
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ public class Commandtpdeny extends EssentialsCommand
|
||||
throw new Exception(Util.i18n("noPendingRequest"));
|
||||
}
|
||||
|
||||
charge(user);
|
||||
user.sendMessage(Util.i18n("requestDenied"));
|
||||
p.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName()));
|
||||
user.requestTeleport(null, false);
|
||||
|
@ -24,5 +24,6 @@ public class Commandtphere extends EssentialsCommand
|
||||
p.getTeleport().teleport(user, new Trade(this.getName(), ess));
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
p.sendMessage(Util.i18n("teleporting"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ public class Commandtpo extends EssentialsCommand
|
||||
// Verify permission
|
||||
if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
|
||||
{
|
||||
charge(user);
|
||||
user.getTeleport().now(p, false);
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ public class Commandtpohere extends EssentialsCommand
|
||||
// Verify permission
|
||||
if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
|
||||
{
|
||||
charge(user);
|
||||
p.getTeleport().now(user, false);
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
}
|
||||
|
@ -30,5 +30,6 @@ public class Commandtppos extends EssentialsCommand
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
user.getTeleport().teleport(l, charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
@ -15,7 +15,6 @@ public class Commandtptoggle extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
user.sendMessage(user.toggleTeleportEnabled()
|
||||
? Util.i18n("teleportationEnabled")
|
||||
: Util.i18n("teleportationDisabled"));
|
||||
|
@ -51,7 +51,6 @@ public class Commandtree extends EssentialsCommand
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
if (success)
|
||||
{
|
||||
charge(user);
|
||||
user.sendMessage(Util.i18n("treeSpawned"));
|
||||
}
|
||||
else
|
||||
|
@ -93,8 +93,7 @@ public class Commandunlimited extends EssentialsCommand
|
||||
&& !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET)
|
||||
&& user.isAuthorized("essentials.unlimited.item-bucket"))))
|
||||
{
|
||||
user.sendMessage(Util.format("unlimitedItemPermission", itemname));
|
||||
return false;
|
||||
throw new Exception(Util.format("unlimitedItemPermission", itemname));
|
||||
}
|
||||
|
||||
String message = "disableUnlimited";
|
||||
@ -103,7 +102,6 @@ public class Commandunlimited extends EssentialsCommand
|
||||
{
|
||||
message = "enableUnlimited";
|
||||
enableUnlimited = true;
|
||||
charge(user);
|
||||
if (!InventoryWorkaround.containsItem(target.getInventory(), true, stack))
|
||||
{
|
||||
target.getInventory().addItem(stack);
|
||||
|
@ -26,8 +26,7 @@ public class Commandwarp extends EssentialsCommand
|
||||
{
|
||||
if (!user.isAuthorized("essentials.warp.list"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("warpListPermission"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("warpListPermission"));
|
||||
}
|
||||
|
||||
Warps warps = ess.getWarps();
|
||||
@ -56,7 +55,7 @@ public class Commandwarp extends EssentialsCommand
|
||||
}
|
||||
final int warpPage = (page - 1) * WARPS_PER_PAGE;
|
||||
user.sendMessage(Util.joinList(warpNameList.subList(warpPage, warpPage+Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE))));
|
||||
return;
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (args.length > 0)
|
||||
{
|
||||
@ -66,13 +65,13 @@ public class Commandwarp extends EssentialsCommand
|
||||
otherUser = ess.getUser(server.getPlayer(args[1]));
|
||||
if (otherUser == null)
|
||||
{
|
||||
user.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
warpUser(otherUser, args[0]);
|
||||
return;
|
||||
throw new NoChargeException();
|
||||
}
|
||||
warpUser(user, args[0]);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,8 +86,7 @@ public class Commandwarp extends EssentialsCommand
|
||||
user.getTeleport().warp(name, charge);
|
||||
return;
|
||||
}
|
||||
user.sendMessage(Util.i18n("warpUsePermission"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("warpUsePermission"));
|
||||
}
|
||||
user.getTeleport().warp(name, charge);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ public class Commandweather extends EssentialsCommand
|
||||
|
||||
boolean isStorm = args[0].equalsIgnoreCase("storm");
|
||||
World world = user.getWorld();
|
||||
charge(user);
|
||||
if (args.length > 1)
|
||||
{
|
||||
|
||||
|
@ -35,7 +35,6 @@ public class Commandwhois extends EssentialsCommand
|
||||
showhidden = true;
|
||||
}
|
||||
String whois = args[0].toLowerCase();
|
||||
charge(sender);
|
||||
int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length();
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ public class Commandworld extends EssentialsCommand
|
||||
user.sendMessage(Util.i18n("invalidWorld"));
|
||||
user.sendMessage(Util.format("possibleWorlds", server.getWorlds().size() - 1));
|
||||
user.sendMessage(Util.i18n("typeWorldName"));
|
||||
return;
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,5 +71,6 @@ public class Commandworld extends EssentialsCommand
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(loc, charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ public class Commandworth extends EssentialsCommand
|
||||
throw new Exception(Util.i18n("itemCannotBeSold"));
|
||||
}
|
||||
|
||||
charge(user);
|
||||
user.sendMessage(is.getDurability() != 0
|
||||
? Util.format("worthMeta",
|
||||
is.getType().toString().toLowerCase().replace("_", ""),
|
||||
|
@ -79,7 +79,10 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||
@Override
|
||||
public final void run(final Server server, final User user, final String commandLabel, final Command cmd, final String[] args) throws Exception
|
||||
{
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
run(server, user, commandLabel, args);
|
||||
charge.charge(user);
|
||||
}
|
||||
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
@ -111,13 +114,4 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||
}
|
||||
return bldr.toString();
|
||||
}
|
||||
|
||||
protected void charge(final CommandSender sender) throws ChargeException
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.charge(ess.getUser((Player)sender));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
|
||||
public class NoChargeException extends Exception
|
||||
{
|
||||
public NoChargeException()
|
||||
{
|
||||
super("Will charge later");
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import de.bananaco.permissions.Permissions;
|
||||
import de.bananaco.permissions.interfaces.PermissionSet;
|
||||
import de.bananaco.permissions.worlds.WorldPermissionsManager;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class BPermissionsHandler extends SuperpermsHandler
|
||||
{
|
||||
private final transient WorldPermissionsManager wpm;
|
||||
|
||||
public BPermissionsHandler()
|
||||
{
|
||||
wpm = Permissions.getWorldPermissionsManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
final List<String> groups = getGroups(base);
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return groups.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
final PermissionSet pset = wpm.getPermissionSet(base.getWorld());
|
||||
if (pset == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return pset.getGroups(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
final List<String> groups = getGroups(base);
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return groups.contains(group);
|
||||
}
|
||||
}
|
@ -1,46 +1,61 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class ConfigPermissionsHandler implements IPermissionsHandler
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public ConfigPermissionsHandler(final IEssentials ess)
|
||||
public ConfigPermissionsHandler(final Plugin ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
this.ess = (IEssentials)ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return "default";
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
final String[] cmds = node.split("\\.", 2);
|
||||
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1])
|
||||
&& ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]);
|
||||
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1])
|
||||
&& ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IPermissionsHandler
|
||||
{
|
||||
|
||||
String getGroup(Player base);
|
||||
|
||||
List<String> getGroups(Player base);
|
||||
|
||||
boolean canBuild(Player base, String group);
|
||||
|
||||
boolean inGroup(Player base, String group);
|
||||
@ -17,5 +19,4 @@ public interface IPermissionsHandler
|
||||
String getPrefix(Player base);
|
||||
|
||||
String getSuffix(Player base);
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class NullPermissionsHandler implements IPermissionsHandler
|
||||
{
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -10,41 +12,50 @@ public class Permissions2Handler implements IPermissionsHandler
|
||||
{
|
||||
private final transient PermissionHandler permissionHandler;
|
||||
|
||||
Permissions2Handler(final Plugin permissionsPlugin)
|
||||
public Permissions2Handler(final Plugin permissionsPlugin)
|
||||
{
|
||||
permissionHandler = ((Permissions)permissionsPlugin).getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
final String group = permissionHandler.getGroup(base.getWorld().getName(), base.getName());
|
||||
return group == null ? "default" : group;
|
||||
return permissionHandler.getGroup(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
return Arrays.asList(permissionHandler.getGroups(base.getWorld().getName(), base.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.canGroupBuild(base.getWorld().getName(), getGroup(base));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
return permissionHandler.permission(base, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
final String prefix = permissionHandler.getGroupPrefix(base.getWorld().getName(), getGroup(base));
|
||||
return prefix == null ? "" : prefix;
|
||||
return permissionHandler.getGroupPrefix(base.getWorld().getName(), getGroup(base));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
final String suffix = permissionHandler.getGroupSuffix(base.getWorld().getName(), getGroup(base));
|
||||
return suffix == null ? "" : suffix;
|
||||
return permissionHandler.getGroupSuffix(base.getWorld().getName(), getGroup(base));
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -9,40 +11,51 @@ import org.bukkit.plugin.Plugin;
|
||||
public class Permissions3Handler implements IPermissionsHandler
|
||||
{
|
||||
private final transient PermissionHandler permissionHandler;
|
||||
|
||||
Permissions3Handler(final Plugin permissionsPlugin)
|
||||
|
||||
public Permissions3Handler(final Plugin permissionsPlugin)
|
||||
{
|
||||
permissionHandler = ((Permissions)permissionsPlugin).getHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return permissionHandler.getPrimaryGroup(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
return Arrays.asList(permissionHandler.getGroups(base.getWorld().getName(), base.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.canUserBuild(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
return permissionHandler.has(base, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
return permissionHandler.getUserPrefix(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return permissionHandler.getUserSuffix(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.platymuus.bukkit.permissions.Group;
|
||||
import com.platymuus.bukkit.permissions.PermissionInfo;
|
||||
import com.platymuus.bukkit.permissions.PermissionsPlugin;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class PermissionsBukkitHandler extends SuperpermsHandler
|
||||
{
|
||||
private final transient PermissionsPlugin plugin;
|
||||
|
||||
public PermissionsBukkitHandler(final Plugin plugin)
|
||||
{
|
||||
this.plugin = (PermissionsPlugin)plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
final List<Group> groups = getPBGroups(base);
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return groups.get(0).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
final List<Group> groups = getPBGroups(base);
|
||||
if (groups.size() == 1)
|
||||
{
|
||||
return Collections.singletonList(groups.get(0).getName());
|
||||
}
|
||||
final List<String> groupNames = new ArrayList<String>(groups.size());
|
||||
for (Group group : groups)
|
||||
{
|
||||
groupNames.add(group.getName());
|
||||
}
|
||||
return groupNames;
|
||||
}
|
||||
|
||||
private List<Group> getPBGroups(final Player base)
|
||||
{
|
||||
final PermissionInfo info = plugin.getPlayerInfo(base.getName());
|
||||
if (info == null)
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final List<Group> groups = info.getGroups();
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
final List<Group> groups = getPBGroups(base);
|
||||
for (Group group1 : groups)
|
||||
{
|
||||
if (group1.getName().equalsIgnoreCase(group))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user