mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-03-18 01:29:44 +01:00
Merge branch 'master' into release
This commit is contained in:
commit
7039d613ee
.gitignore
Essentials
nbproject
src/com/earth2me/essentials
Backup.javaBukkitPermissionsHandler.javaDescParseTickFormat.javaEssentials.javaEssentialsConf.javaEssentialsEntityListener.javaEssentialsPlayerListener.javaEssentialsPluginListener.javaEssentialsTimer.javaEssentialsUpdateTimer.javaEssentialsUpgrade.javaIEssentials.javaISettings.javaIUser.javaInventoryWorkaround.javaSettings.javaTNTExplodeListener.javaTeleport.javaUser.javaUserData.javaUtil.java
commands
Commandafk.javaCommandantioch.javaCommandbackup.javaCommandbalance.javaCommandbigtree.javaCommandbroadcast.javaCommandburn.javaCommandclearinventory.javaCommandcompass.javaCommanddelhome.javaCommanddeljail.javaCommanddelwarp.javaCommanddepth.javaCommandessentials.javaCommandext.javaCommandfireball.javaCommandgc.javaCommandgetpos.javaCommandgive.javaCommandgod.javaCommandheal.javaCommandhelpop.javaCommandhome.javaCommandinfo.javaCommandinvsee.javaCommanditem.javaCommandjails.javaCommandkick.javaCommandkickall.javaCommandkill.javaCommandkit.javaCommandlightning.javaCommandlist.javaCommandmail.javaCommandme.javaCommandmotd.javaCommandmsg.javaCommandmute.javaCommandnick.javaCommandplugin.javaCommandpowertool.javaCommandr.javaCommandrealname.javaCommandreloadall.javaCommandrepair.javaCommandrules.javaCommandsell.javaCommandsethome.javaCommandsetjail.javaCommandsetwarp.javaCommandsetworth.javaCommandsocialspy.javaCommandspawner.javaCommandspawnmob.javaCommandsuicide.javaCommandthunder.javaCommandtogglejail.javaCommandtop.javaCommandtp.javaCommandtpa.javaCommandtpaall.javaCommandtpahere.javaCommandtpall.javaCommandtpdeny.javaCommandtpo.javaCommandtpohere.javaCommandtptoggle.javaCommandtree.javaCommandunlimited.javaCommandwarp.javaCommandweather.javaCommandwhois.javaCommandworth.javaEssentialsCommand.java
perm
3
.gitignore
vendored
3
.gitignore
vendored
@ -28,4 +28,5 @@
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
@ -1 +1,2 @@
|
||||
DoNotUseThreads
|
||||
SignatureDeclareThrowsException
|
||||
|
@ -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 "";
|
||||
}
|
||||
}
|
@ -155,10 +155,6 @@ public final class DescParseTickFormat
|
||||
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
if (desc.endsWith("pm"))
|
||||
{
|
||||
hours += 12;
|
||||
}
|
||||
|
||||
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
|
||||
|
||||
@ -189,6 +185,16 @@ public final class DescParseTickFormat
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.endsWith("pm") && hours != 12)
|
||||
{
|
||||
hours += 12;
|
||||
}
|
||||
|
||||
if (desc.endsWith("am") && hours == 12)
|
||||
{
|
||||
hours -= 12;
|
||||
}
|
||||
|
||||
return hoursMinutesToTicks(hours, minutes);
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
*/
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||
import com.earth2me.essentials.perm.ConfigPermissionsHandler;
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import java.io.*;
|
||||
@ -148,9 +150,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
|
||||
}
|
||||
|
||||
final ServerListener serverListener = new EssentialsPluginListener(this);
|
||||
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);
|
||||
@ -209,10 +212,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
|
||||
Economy.setEss(this);
|
||||
if (enableErrorLogging)
|
||||
if (getSettings().isUpdateEnabled())
|
||||
{
|
||||
updateTimer = new EssentialsUpdateTimer(this);
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360));
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60, 20 * 3600 * 6);
|
||||
}
|
||||
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
|
||||
}
|
||||
@ -561,7 +564,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
return null;
|
||||
return new User(base, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -19,12 +21,12 @@ import org.bukkit.util.config.Configuration;
|
||||
|
||||
public class EssentialsConf extends Configuration
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private File configFile;
|
||||
private String templateName = null;
|
||||
private Class<?> resourceClass = EssentialsConf.class;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient File configFile;
|
||||
private transient String templateName = null;
|
||||
private transient Class<?> resourceClass = EssentialsConf.class;
|
||||
|
||||
public EssentialsConf(File configFile)
|
||||
public EssentialsConf(final File configFile)
|
||||
{
|
||||
super(configFile);
|
||||
this.configFile = configFile;
|
||||
@ -42,33 +44,79 @@ public class EssentialsConf extends Configuration
|
||||
{
|
||||
if (!configFile.getParentFile().mkdirs())
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
// This will delete files where the first character is 0. In most cases they are broken.
|
||||
if (configFile.exists() && configFile.length() != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
final InputStream input = new FileInputStream(configFile);
|
||||
try
|
||||
{
|
||||
if (input.read() == 0)
|
||||
{
|
||||
input.close();
|
||||
configFile.delete();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
input.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!configFile.exists())
|
||||
{
|
||||
if (templateName != null)
|
||||
{
|
||||
logger.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
|
||||
LOGGER.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
|
||||
createFromTemplate();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
|
||||
LOGGER.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
|
||||
if (!configFile.createNewFile())
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.load();
|
||||
|
||||
try
|
||||
{
|
||||
super.load();
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + configFile.toString());
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
@ -84,7 +132,7 @@ public class EssentialsConf extends Configuration
|
||||
istr = resourceClass.getResourceAsStream(templateName);
|
||||
if (istr == null)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
|
||||
LOGGER.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
|
||||
return;
|
||||
}
|
||||
ostr = new FileOutputStream(configFile);
|
||||
@ -99,7 +147,7 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
@ -124,12 +172,12 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName)
|
||||
public void setTemplateName(final String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
@ -139,48 +187,48 @@ public class EssentialsConf extends Configuration
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName, Class<?> resClass)
|
||||
public void setTemplateName(final String templateName, final Class<?> resClass)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
this.resourceClass = resClass;
|
||||
}
|
||||
|
||||
public boolean hasProperty(String path)
|
||||
public boolean hasProperty(final String path)
|
||||
{
|
||||
return getProperty(path) != null;
|
||||
}
|
||||
|
||||
public Location getLocation(String path, Server server)
|
||||
public Location getLocation(final String path, final Server server) throws Exception
|
||||
{
|
||||
String worldName = getString((path != null ? path + "." : "") + "world");
|
||||
final String worldName = getString((path == null ? "" : path + ".") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = server.getWorld(worldName);
|
||||
final World world = server.getWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
throw new Exception(Util.i18n("invalidWorld"));
|
||||
}
|
||||
return new Location(world,
|
||||
getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
(float)getDouble((path != null ? path + "." : "") + "yaw", 0),
|
||||
(float)getDouble((path != null ? path + "." : "") + "pitch", 0));
|
||||
getDouble((path == null ? "" : path + ".") + "x", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "y", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "z", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "yaw", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "pitch", 0));
|
||||
}
|
||||
|
||||
public void setProperty(String path, Location loc)
|
||||
public void setProperty(final String path, final Location loc)
|
||||
{
|
||||
setProperty((path != null ? path + "." : "") + "world", loc.getWorld().getName());
|
||||
setProperty((path != null ? path + "." : "") + "x", loc.getX());
|
||||
setProperty((path != null ? path + "." : "") + "y", loc.getY());
|
||||
setProperty((path != null ? path + "." : "") + "z", loc.getZ());
|
||||
setProperty((path != null ? path + "." : "") + "yaw", loc.getYaw());
|
||||
setProperty((path != null ? path + "." : "") + "pitch", loc.getPitch());
|
||||
setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
|
||||
setProperty((path == null ? "" : path + ".") + "x", loc.getX());
|
||||
setProperty((path == null ? "" : path + ".") + "y", loc.getY());
|
||||
setProperty((path == null ? "" : path + ".") + "z", loc.getZ());
|
||||
setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw());
|
||||
setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch());
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(String path)
|
||||
public ItemStack getItemStack(final String path)
|
||||
{
|
||||
return new ItemStack(
|
||||
Material.valueOf(getString(path + ".type", "AIR")),
|
||||
@ -189,9 +237,9 @@ public class EssentialsConf extends Configuration
|
||||
(byte)getInt(path + ".data", 0)*/);
|
||||
}
|
||||
|
||||
public void setProperty(String path, ItemStack stack)
|
||||
public void setProperty(final String path, final ItemStack stack)
|
||||
{
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("type", stack.getType().toString());
|
||||
map.put("amount", stack.getAmount());
|
||||
map.put("damage", stack.getDurability());
|
||||
@ -200,40 +248,30 @@ public class EssentialsConf extends Configuration
|
||||
setProperty(path, map);
|
||||
}
|
||||
|
||||
public long getLong(String path, long def)
|
||||
public long getLong(final String path, final long def)
|
||||
{
|
||||
Number num;
|
||||
try
|
||||
{
|
||||
num = (Number)getProperty(path);
|
||||
final Number num = (Number)getProperty(path);
|
||||
return num == null ? def : num.longValue();
|
||||
}
|
||||
catch(ClassCastException ex)
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
if (num == null)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return num.longValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path, double def)
|
||||
public double getDouble(final String path, final double def)
|
||||
{
|
||||
Number num;
|
||||
try
|
||||
{
|
||||
num = (Number)getProperty(path);
|
||||
Number num = (Number)getProperty(path);
|
||||
return num == null ? def : num.doubleValue();
|
||||
}
|
||||
catch(ClassCastException ex)
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
if (num == null)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return num.doubleValue();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import java.util.List;
|
||||
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;
|
||||
@ -35,25 +33,28 @@ public class EssentialsEntityListener extends EntityListener
|
||||
User defender = ess.getUser(eDefend);
|
||||
User attacker = ess.getUser(eAttack);
|
||||
ItemStack is = attacker.getItemInHand();
|
||||
String command = attacker.getPowertool(is);
|
||||
if (command != null && !command.isEmpty())
|
||||
List<String> commandList = attacker.getPowertool(is);
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
for (String command : commandList)
|
||||
{
|
||||
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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,11 +73,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if (user.isAfk())
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
user.updateActivity();
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
@ -93,12 +89,26 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (user.isAfk())
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
try
|
||||
{
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.setTo(to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
user.updateActivity();
|
||||
|
||||
if (!ess.getSettings().getNetherPortalsEnabled())
|
||||
{
|
||||
return;
|
||||
@ -216,6 +226,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
}
|
||||
user.updateActivity();
|
||||
user.dispose();
|
||||
if (!ess.getSettings().getReclaimSetting())
|
||||
{
|
||||
@ -304,9 +315,6 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user == null) {
|
||||
user = new User(event.getPlayer(), ess);
|
||||
}
|
||||
user.setNPC(false);
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
@ -326,6 +334,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
event.disallow(Result.KICK_FULL, Util.i18n("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
updateCompass(user);
|
||||
@ -430,26 +439,31 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String command = user.getPowertool(is);
|
||||
if (command == null || command.isEmpty())
|
||||
final List<String> commandList = user.getPowertool(is);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
|
||||
// We need to loop through each command and execute
|
||||
for (String command : commandList)
|
||||
{
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("c:"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
{
|
||||
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(user, command);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(user, command);
|
||||
}
|
||||
}
|
||||
|
||||
@ -473,10 +487,9 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
}
|
||||
}
|
||||
if (user.isAfk())
|
||||
if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
user.updateActivity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,12 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.perm.BPermissionsHandler;
|
||||
import com.earth2me.essentials.perm.ConfigPermissionsHandler;
|
||||
import com.earth2me.essentials.perm.Permissions3Handler;
|
||||
import com.earth2me.essentials.perm.Permissions2Handler;
|
||||
import com.earth2me.essentials.perm.PermissionsBukkitHandler;
|
||||
import com.earth2me.essentials.perm.PermissionsExHandler;
|
||||
import com.earth2me.essentials.perm.SuperpermsHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
@ -10,7 +16,7 @@ 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");
|
||||
@ -41,7 +47,7 @@ public class EssentialsPluginListener extends ServerListener
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkPermissions()
|
||||
{
|
||||
final PluginManager pm = ess.getServer().getPluginManager();
|
||||
@ -52,30 +58,74 @@ public class EssentialsPluginListener extends ServerListener
|
||||
final Plugin permissionsPlugin = pm.getPlugin("Permissions");
|
||||
if (permissionsPlugin == null || !permissionsPlugin.isEnabled())
|
||||
{
|
||||
if (ess.getSettings().useBukkitPermissions())
|
||||
final Plugin permissionsBukkitPlugin = pm.getPlugin("PermissionsBukkit");
|
||||
final Plugin bPermissionsPlugin = pm.getPlugin("bPermissions");
|
||||
if (permissionsBukkitPlugin != null && permissionsBukkitPlugin.isEnabled())
|
||||
{
|
||||
ess.setPermissionsHandler(new BukkitPermissionsHandler());
|
||||
if (!(ess.getPermissionsHandler() instanceof PermissionsBukkitHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
|
||||
ess.setPermissionsHandler(new PermissionsBukkitHandler(permissionsBukkitPlugin));
|
||||
}
|
||||
}
|
||||
else if (bPermissionsPlugin != null && bPermissionsPlugin.isEnabled())
|
||||
{
|
||||
if (!(ess.getPermissionsHandler() instanceof BPermissionsHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using bPermissions based permissions.");
|
||||
ess.setPermissionsHandler(new BPermissionsHandler());
|
||||
}
|
||||
}
|
||||
else if (ess.getSettings().useBukkitPermissions())
|
||||
{
|
||||
if (!(ess.getPermissionsHandler() instanceof SuperpermsHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using superperms based permissions.");
|
||||
ess.setPermissionsHandler(new SuperpermsHandler());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new ConfigPermissionsHandler(ess));
|
||||
if (!(ess.getPermissionsHandler() instanceof ConfigPermissionsHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using config based permissions. Enable superperms in config.");
|
||||
ess.setPermissionsHandler(new ConfigPermissionsHandler(ess));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3')
|
||||
{
|
||||
ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin));
|
||||
if (!(ess.getPermissionsHandler() instanceof Permissions3Handler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using Permissions 3 based permissions.");
|
||||
ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin));
|
||||
if (!(ess.getPermissionsHandler() instanceof Permissions2Handler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using Permissions 2 based permissions.");
|
||||
ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new PermissionsExHandler());
|
||||
if (!(ess.getPermissionsHandler() instanceof PermissionsExHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using PermissionsEx based permissions.");
|
||||
ess.setPermissionsHandler(new PermissionsExHandler());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
checkPermissions();
|
||||
}
|
||||
}
|
||||
|
@ -24,16 +24,17 @@ public class EssentialsTimer implements Runnable
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastActivity(currentTime);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
}
|
||||
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final User user = iterator.next();
|
||||
if (user.getLastActivity() < currentTime && user.getLastActivity() > user.getLastLogout())
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
|
||||
{
|
||||
user.setLastLogout(user.getLastActivity());
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
@ -4,65 +4,81 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
class EssentialsUpdateTimer implements Runnable
|
||||
{
|
||||
private URL url;
|
||||
private final Essentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsUpdateTimer(Essentials ess)
|
||||
private transient URL url;
|
||||
private final transient IEssentials ess;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*");
|
||||
|
||||
public EssentialsUpdateTimer(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
try
|
||||
{
|
||||
url = new URL("http://127.0.0.1:8080/check");
|
||||
url = new URL("http://essentialsupdate.appspot.com/check");
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Invalid url!", ex);
|
||||
LOGGER.log(Level.SEVERE, "Invalid url!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(),"UTF-8"));
|
||||
sb.append("&b=").append(URLEncoder.encode(ess.getServer().getVersion(),"UTF-8"));
|
||||
sb.append("&jv=").append(URLEncoder.encode(System.getProperty("java.version"),"UTF-8"));
|
||||
sb.append("&l=").append(URLEncoder.encode(Util.getCurrentLocale().toString(),"UTF-8"));
|
||||
sb.append("&on=").append(URLEncoder.encode(System.getProperty("os.name"),"UTF-8"));
|
||||
sb.append("&ov=").append(URLEncoder.encode(System.getProperty("os.version"),"UTF-8"));
|
||||
for (BigInteger bigInteger : ess.getErrors().keySet())
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
String bukkitVersion = ess.getServer().getVersion();
|
||||
final Matcher versionMatch = pattern.matcher(bukkitVersion);
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
sb.append("&e[]=").append(bigInteger.toString(36));
|
||||
bukkitVersion = versionMatch.group(4);
|
||||
}
|
||||
URLConnection conn = url.openConnection();
|
||||
builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8"));
|
||||
builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8"));
|
||||
final URLConnection conn = url.openConnection();
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setDoOutput(true);
|
||||
conn.connect();
|
||||
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
wr.write(sb.toString());
|
||||
wr.flush();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String ret = br.readLine();
|
||||
wr.close();
|
||||
br.close();
|
||||
logger.log(Level.INFO, ret);
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
|
||||
writer.write(builder.toString());
|
||||
writer.flush();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
final String ret = reader.readLine();
|
||||
writer.close();
|
||||
reader.close();
|
||||
if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK"))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret);
|
||||
if (ret.startsWith("New Version"))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.admin.notices.update"))
|
||||
{
|
||||
user.sendMessage(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Failed to open connection", ex);
|
||||
LOGGER.log(Level.SEVERE, "Failed to open connection", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
@ -197,6 +199,133 @@ public class EssentialsUpgrade
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateUsersPowerToolsFormat()
|
||||
{
|
||||
if (doneFile.getBoolean("updateUsersPowerToolsFormat", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (config.hasProperty("powertools"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<Integer, Object> powertools = (Map<Integer, Object>)config.getProperty("powertools");
|
||||
if (powertools == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<Integer, Object> entry : powertools.entrySet())
|
||||
{
|
||||
if (entry.getValue() instanceof String)
|
||||
{
|
||||
List<String> temp = new ArrayList<String>();
|
||||
temp.add((String)entry.getValue());
|
||||
((Map<Integer, Object>)powertools).put(entry.getKey(), temp);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersPowerToolsFormat", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateUsersHomesFormat()
|
||||
{
|
||||
if (doneFile.getBoolean("updateUsersHomesFormat", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
|
||||
config.load();
|
||||
if (config.hasProperty("home") && config.hasProperty("home.default"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final String defworld = (String)config.getProperty("home.default");
|
||||
final Location defloc = getFakeLocation(config,"home.worlds." + defworld);
|
||||
if (defloc != null)
|
||||
{
|
||||
config.setProperty("homes.home", defloc);
|
||||
}
|
||||
|
||||
List<String> worlds = config.getKeys("home.worlds");
|
||||
Location loc;
|
||||
String worldName;
|
||||
|
||||
if (worlds == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String world : worlds)
|
||||
{
|
||||
if (defworld.equalsIgnoreCase(world))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
loc = getFakeLocation(config, "home.worlds." + world);
|
||||
if (loc == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
worldName = loc.getWorld().getName().toLowerCase();
|
||||
if (worldName != null && !worldName.isEmpty())
|
||||
{
|
||||
config.setProperty("homes." + worldName, loc);
|
||||
}
|
||||
}
|
||||
config.removeProperty("home");
|
||||
config.save();
|
||||
}
|
||||
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersHomesFormat", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void moveUsersDataToUserdataFolder()
|
||||
{
|
||||
final File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
@ -232,12 +361,12 @@ public class EssentialsUpgrade
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
user.setHome(new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()), true);
|
||||
user.setHome("home", new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -441,6 +570,25 @@ public class EssentialsUpgrade
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Location getFakeLocation(EssentialsConf config, String path)
|
||||
{
|
||||
String worldName = config.getString((path != null ? path + "." : "") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = getFakeWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Location(world,
|
||||
config.getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
(float)config.getDouble((path != null ? path + "." : "") + "yaw", 0),
|
||||
(float)config.getDouble((path != null ? path + "." : "") + "pitch", 0));
|
||||
}
|
||||
|
||||
public void beforeSettings()
|
||||
{
|
||||
@ -457,5 +605,7 @@ public class EssentialsUpgrade
|
||||
updateUsersToNewDefaultHome();
|
||||
moveUsersDataToUserdataFolder();
|
||||
convertWarps();
|
||||
updateUsersPowerToolsFormat();
|
||||
updateUsersHomesFormat();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.perm.IPermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -72,6 +72,8 @@ public interface ISettings extends IConf
|
||||
boolean getReclaimSetting();
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
int getMultipleHomes();
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
@ -107,8 +109,6 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
void reloadConfig();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
@ -129,7 +129,15 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
public boolean useBukkitPermissions();
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
public boolean addPrefixSuffix();
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
boolean isUpdateEnabled();
|
||||
|
||||
long getAutoAfk();
|
||||
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public interface IUser
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
@ -45,7 +45,9 @@ public interface IUser
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(Location location);
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
String getName();
|
||||
|
||||
|
@ -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
|
||||
|
@ -30,6 +30,12 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultipleHomes()
|
||||
{
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBedSetsHome()
|
||||
@ -473,4 +479,28 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpdateEnabled()
|
||||
{
|
||||
return config.getBoolean("update-check", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfk()
|
||||
{
|
||||
return config.getLong("auto-afk", 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfkKick()
|
||||
{
|
||||
return config.getLong("auto-afk-kick", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFreezeAfkPlayers()
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
@ -10,6 +11,8 @@ import org.bukkit.entity.Entity;
|
||||
public class Teleport implements Runnable
|
||||
{
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
|
||||
|
||||
private static class Target
|
||||
{
|
||||
private final Location location;
|
||||
@ -57,9 +60,9 @@ public class Teleport implements Runnable
|
||||
this.started = System.currentTimeMillis();
|
||||
this.delay = delay;
|
||||
this.health = user.getHealth();
|
||||
this.initX = Math.round(user.getLocation().getX()*MOVE_CONSTANT);
|
||||
this.initY = Math.round(user.getLocation().getY()*MOVE_CONSTANT);
|
||||
this.initZ = Math.round(user.getLocation().getZ()*MOVE_CONSTANT);
|
||||
this.initX = Math.round(user.getLocation().getX() * MOVE_CONSTANT);
|
||||
this.initY = Math.round(user.getLocation().getY() * MOVE_CONSTANT);
|
||||
this.initZ = Math.round(user.getLocation().getZ() * MOVE_CONSTANT);
|
||||
this.teleportTarget = target;
|
||||
this.chargeFor = chargeFor;
|
||||
}
|
||||
@ -72,9 +75,9 @@ public class Teleport implements Runnable
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (Math.round(user.getLocation().getX()*MOVE_CONSTANT) != initX
|
||||
|| Math.round(user.getLocation().getY()*MOVE_CONSTANT) != initY
|
||||
|| Math.round(user.getLocation().getZ()*MOVE_CONSTANT) != initZ
|
||||
if (Math.round(user.getLocation().getX() * MOVE_CONSTANT) != initX
|
||||
|| Math.round(user.getLocation().getY() * MOVE_CONSTANT) != initY
|
||||
|| Math.round(user.getLocation().getZ() * MOVE_CONSTANT) != initZ
|
||||
|| user.getHealth() < health)
|
||||
{ // user moved, cancel teleport
|
||||
cancel(true);
|
||||
@ -92,7 +95,7 @@ public class Teleport implements Runnable
|
||||
user.sendMessage(Util.i18n("teleportationCommencing"));
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
now(teleportTarget);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
@ -229,7 +232,7 @@ public class Teleport implements Runnable
|
||||
cooldown(false);
|
||||
now(new Target(loc));
|
||||
}
|
||||
|
||||
|
||||
public void now(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
@ -256,14 +259,9 @@ public class Teleport implements Runnable
|
||||
back(null);
|
||||
}
|
||||
|
||||
public void home(Trade chargeFor) throws Exception
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
{
|
||||
home(user, chargeFor);
|
||||
}
|
||||
|
||||
public void home(IUser user, Trade chargeFor) throws Exception
|
||||
{
|
||||
Location loc = user.getHome(this.user.getLocation());
|
||||
final Location loc = user.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
if (ess.getSettings().spawnIfNoHome())
|
||||
@ -272,7 +270,7 @@ public class Teleport implements Runnable
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(user == this.user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
teleport(new Target(loc), chargeFor);
|
||||
|
@ -4,67 +4,72 @@ import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private boolean justPortaled = false;
|
||||
private CommandSender replyTo = null;
|
||||
private User teleportRequester;
|
||||
private boolean teleportRequestHere;
|
||||
private final Teleport teleport;
|
||||
private long lastActivity;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient final Teleport teleport;
|
||||
private transient long lastOnlineActivity ;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
|
||||
User(Player base, IEssentials ess)
|
||||
private transient boolean godStateBeforeAfk;
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
}
|
||||
|
||||
User update(Player base)
|
||||
|
||||
User update(final Player base)
|
||||
{
|
||||
setBase(base);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAuthorized(IEssentialsCommand cmd)
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isAuthorized(cmd, "essentials.");
|
||||
}
|
||||
|
||||
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
||||
{
|
||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
}
|
||||
|
||||
public boolean isAuthorized(String node)
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (isJailed())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return ess.getPermissionsHandler().hasPermission(this, node);
|
||||
}
|
||||
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
{
|
||||
Calendar now = new GregorianCalendar();
|
||||
final Calendar now = new GregorianCalendar();
|
||||
if (getLastHealTimestamp() > 0)
|
||||
{
|
||||
double cooldown = ess.getSettings().getHealCooldown();
|
||||
Calendar cooldownTime = new GregorianCalendar();
|
||||
final double cooldown = ess.getSettings().getHealCooldown();
|
||||
final Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(getLastHealTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
@ -75,13 +80,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
}
|
||||
|
||||
public void giveMoney(double value)
|
||||
|
||||
@Override
|
||||
public void giveMoney(final double value)
|
||||
{
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
public void giveMoney(double value, CommandSender initiator)
|
||||
|
||||
public void giveMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
@ -91,35 +97,36 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
|
||||
initiator.sendMessage(Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void payUser(User reciever, double value) throws Exception
|
||||
|
||||
public void payUser(final User reciever, final double value) throws Exception
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!canAfford(value))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
else
|
||||
if (canAfford(value))
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
public void takeMoney(double value)
|
||||
|
||||
@Override
|
||||
public void takeMoney(final double value)
|
||||
{
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
public void takeMoney(double value, CommandSender initiator)
|
||||
|
||||
public void takeMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
@ -129,99 +136,108 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
|
||||
initiator.sendMessage(Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canAfford(double cost)
|
||||
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
double mon = getMoney();
|
||||
final double mon = getMoney();
|
||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||
}
|
||||
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
this.base = new OfflinePlayer(getName(), ess);
|
||||
}
|
||||
|
||||
|
||||
public boolean getJustPortaled()
|
||||
{
|
||||
return justPortaled;
|
||||
}
|
||||
|
||||
public void setJustPortaled(boolean value)
|
||||
|
||||
public void setJustPortaled(final boolean value)
|
||||
{
|
||||
justPortaled = value;
|
||||
}
|
||||
|
||||
public void setReplyTo(CommandSender user)
|
||||
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
public int compareTo(User t)
|
||||
{
|
||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
if (!(o instanceof User))
|
||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object)
|
||||
{
|
||||
if (!(object instanceof User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
|
||||
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)object).getDisplayName()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
||||
}
|
||||
|
||||
public Boolean canSpawnItem(int itemId)
|
||||
|
||||
public Boolean canSpawnItem(final int itemId)
|
||||
{
|
||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||
}
|
||||
|
||||
|
||||
public Location getHome() throws Exception
|
||||
{
|
||||
return getHome(getHomes().get(0));
|
||||
}
|
||||
|
||||
public void setHome()
|
||||
{
|
||||
setHome(getLocation(), true);
|
||||
setHome("home", getLocation());
|
||||
}
|
||||
|
||||
public void setHome(boolean defaultHome)
|
||||
|
||||
public void setHome(final String name)
|
||||
{
|
||||
setHome(getLocation(), defaultHome);
|
||||
setHome(name, getLocation());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
setLastLocation(getLocation());
|
||||
}
|
||||
|
||||
public void requestTeleport(User player, boolean here)
|
||||
|
||||
public void requestTeleport(final User player, final boolean here)
|
||||
{
|
||||
teleportRequester = player;
|
||||
teleportRequestHere = here;
|
||||
}
|
||||
|
||||
|
||||
public User getTeleportRequest()
|
||||
{
|
||||
return teleportRequester;
|
||||
}
|
||||
|
||||
|
||||
public boolean isTeleportRequestHere()
|
||||
{
|
||||
return teleportRequestHere;
|
||||
}
|
||||
|
||||
|
||||
public String getNick()
|
||||
{
|
||||
final StringBuilder nickname = new StringBuilder();
|
||||
@ -245,12 +261,12 @@ 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());
|
||||
|
||||
|
||||
nickname.insert(0, prefix);
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
@ -258,25 +274,25 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return nickname.toString();
|
||||
}
|
||||
|
||||
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
return teleport;
|
||||
}
|
||||
|
||||
public long getLastActivity()
|
||||
|
||||
public long getLastOnlineActivity()
|
||||
{
|
||||
return lastActivity;
|
||||
return lastOnlineActivity;
|
||||
}
|
||||
|
||||
public void setLastActivity(long timestamp)
|
||||
|
||||
public void setLastOnlineActivity(final long timestamp)
|
||||
{
|
||||
lastActivity = timestamp;
|
||||
lastOnlineActivity = timestamp;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getMoney()
|
||||
{
|
||||
@ -284,12 +300,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
return account.balance();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@ -298,20 +314,20 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
return super.getMoney();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setMoney(double value)
|
||||
public void setMoney(final double value)
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
account.set(value);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@ -320,32 +336,39 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
super.setMoney(value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAfk(boolean set)
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
setGodModeEnabled(true);
|
||||
}
|
||||
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
|
||||
setGodModeEnabled(godStateBeforeAfk);
|
||||
}
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
boolean now = super.toggleAfk();
|
||||
final boolean now = super.toggleAfk();
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||
return now;
|
||||
}
|
||||
|
||||
|
||||
public boolean isHidden()
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden)
|
||||
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
|
||||
public void checkJailTimeout(final long currentTime)
|
||||
{
|
||||
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
||||
@ -363,7 +386,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkMuteTimeout(final long currentTime)
|
||||
{
|
||||
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
||||
@ -373,7 +396,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
setMuted(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void checkBanTimeout(final long currentTime)
|
||||
{
|
||||
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && ess.getBans().isNameBanned(getName()))
|
||||
@ -382,4 +405,42 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
ess.getBans().unbanByName(getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateActivity()
|
||||
{
|
||||
if (isAfk())
|
||||
{
|
||||
setAfk(false);
|
||||
ess.broadcastMessage(getName(), Util.format("userIsNotAway", getDisplayName()));
|
||||
return;
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void checkActivity()
|
||||
{
|
||||
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
||||
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
|
||||
&& !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
{
|
||||
final String kickReason = Util.format("autoAfkKickReason", autoafkkick/60.0);
|
||||
kickPlayer(kickReason);
|
||||
|
||||
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
player.sendMessage(Util.format("playerKicked", Console.NAME, getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
|
||||
{
|
||||
setAfk(true);
|
||||
ess.broadcastMessage(getName(), Util.format("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -36,7 +35,8 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.load();
|
||||
money = _getMoney();
|
||||
unlimited = _getUnlimited();
|
||||
powertools = getPowertools();
|
||||
powertools = _getPowertools();
|
||||
homes = _getHomes();
|
||||
lastLocation = _getLastLocation();
|
||||
lastTeleportTimestamp = _getLastTeleportTimestamp();
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
@ -89,6 +89,89 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> homes;
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
Object o = config.getProperty("homes");
|
||||
|
||||
if (o instanceof Map)
|
||||
{
|
||||
return (Map<String, Object>)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
Location loc = config.getLocation("homes." + name, getServer());
|
||||
if (loc == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Location getHome(Location world) throws Exception
|
||||
{
|
||||
Location loc;
|
||||
for (String home : getHomes())
|
||||
{
|
||||
loc = config.getLocation("homes." + home, getServer());
|
||||
if (world.getWorld() == loc.getWorld())
|
||||
{
|
||||
return loc;
|
||||
}
|
||||
|
||||
}
|
||||
loc = config.getLocation("homes." + getHomes().get(0), getServer());
|
||||
return loc;
|
||||
}
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
List<String> list = new ArrayList(homes.keySet());
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
if (getHome(name) != null)
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
config.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: move this message to messages file
|
||||
throw new Exception("Home " + name + " doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHome()
|
||||
{
|
||||
@ -99,40 +182,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return false;
|
||||
}
|
||||
|
||||
public Location getHome(Location location)
|
||||
{
|
||||
if (!hasHome())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = location.getWorld();
|
||||
String worldHome = "home.worlds." + world.getName().toLowerCase();
|
||||
if (!config.hasProperty(worldHome))
|
||||
{
|
||||
String defaultWorld = config.getString("home.default");
|
||||
worldHome = "home.worlds." + defaultWorld;
|
||||
}
|
||||
Location loc = config.getLocation(worldHome, getServer());
|
||||
return loc;
|
||||
}
|
||||
|
||||
public void setHome(Location loc, boolean b)
|
||||
{
|
||||
String worldName = loc.getWorld().getName().toLowerCase();
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("emptyWorldName"));
|
||||
return;
|
||||
}
|
||||
if (b || !config.hasProperty("home.default"))
|
||||
{
|
||||
config.setProperty("home.default", worldName);
|
||||
}
|
||||
|
||||
config.setProperty("home.worlds." + worldName, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
{
|
||||
return config.getString("nickname");
|
||||
@ -173,37 +222,38 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<Integer, String> powertools;
|
||||
private Map<Integer, Object> powertools;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Integer, String> getPowertools()
|
||||
private Map<Integer, Object> _getPowertools()
|
||||
{
|
||||
Object o = config.getProperty("powertools");
|
||||
|
||||
if (o instanceof Map)
|
||||
{
|
||||
return (Map<Integer, String>)o;
|
||||
return (Map<Integer, Object>)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<Integer, String>();
|
||||
return new HashMap<Integer, Object>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getPowertool(ItemStack stack)
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return powertools.get(stack.getTypeId());
|
||||
return (List<String>)powertools.get(stack.getTypeId());
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, String command)
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (command == null || command.isEmpty())
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove(stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put(stack.getTypeId(), command);
|
||||
powertools.put(stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
@ -212,7 +262,14 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private Location _getLastLocation()
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
try
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLastLocation()
|
||||
|
@ -14,6 +14,7 @@ import java.text.MessageFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Enumeration;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
@ -469,17 +470,34 @@ public class Util
|
||||
|
||||
public static String joinList(Object... list)
|
||||
{
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
boolean first = true;
|
||||
return joinList(", ", list);
|
||||
}
|
||||
|
||||
public static String joinList(String seperator, Object... list)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (Object each : list)
|
||||
{
|
||||
if (!first)
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
buf.append(", ");
|
||||
|
||||
buf.append(seperator);
|
||||
}
|
||||
|
||||
if(each instanceof List)
|
||||
{
|
||||
buf.append(joinList(seperator, ((List)each).toArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
buf.append(each);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
@ -487,5 +505,5 @@ public class Util
|
||||
public static String capitalCase(String s)
|
||||
{
|
||||
return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,12 +33,13 @@ public class Commandafk extends EssentialsCommand
|
||||
{
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
//user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
user.updateActivity();
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsAway"));
|
||||
//user.sendMessage(Util.i18n("markedAsAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ 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.");
|
||||
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
ess.broadcastMessage(sender instanceof Player ? ((Player)sender).getName() : Console.NAME,
|
||||
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";
|
||||
|
@ -0,0 +1,48 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
public Commanddelhome()
|
||||
{
|
||||
super("delhome");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
//Allowing both formats /delhome khobbits house | /delhome khobbits:house
|
||||
final String[] nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() != args[0].length())
|
||||
{
|
||||
args = nameParts;
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
String name;
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
{
|
||||
user = getPlayer(server, args, 0);
|
||||
name = args[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
name = args[0];
|
||||
}
|
||||
user.delHome(name.toLowerCase());
|
||||
sender.sendMessage(Util.format("deleteHome", name));
|
||||
}
|
||||
}
|
@ -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"));
|
||||
}
|
||||
|
@ -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())
|
||||
|
@ -4,6 +4,7 @@ import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Commandhome extends EssentialsCommand
|
||||
@ -18,24 +19,44 @@ public class Commandhome extends EssentialsCommand
|
||||
{
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
if(args.length > 0 && user.isAuthorized("essentials.home.others"))
|
||||
User u = user;
|
||||
String homeName = "";
|
||||
String[] nameParts;
|
||||
if (args.length > 0)
|
||||
{
|
||||
User u;
|
||||
try
|
||||
nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() == args[0].length() || !user.isAuthorized("essentials.home.others"))
|
||||
{
|
||||
u = getPlayer(server, args, 0);
|
||||
homeName = nameParts[0];
|
||||
}
|
||||
catch(NoSuchFieldException ex)
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[0]);
|
||||
u = getPlayer(server, nameParts[0].split(" "), 0, true);
|
||||
if (nameParts.length > 1)
|
||||
{
|
||||
homeName = nameParts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
user.getTeleport().home(u, homeName.toLowerCase(), charge);
|
||||
}
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
List<String> homes = u.getHomes();
|
||||
if (homes.isEmpty())
|
||||
{
|
||||
throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
}
|
||||
else if ((homes.size() == 1) && u == user)
|
||||
{
|
||||
user.getTeleport().home(u, homes.get(0), charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("homes", Util.joinList(homes)));
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
user.getTeleport().home(u, charge);
|
||||
return;
|
||||
}
|
||||
user.getTeleport().home(charge);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -14,12 +15,6 @@ public class Commandjails extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
StringBuilder jailList = new StringBuilder();
|
||||
for (String j : ess.getJail().getJails())
|
||||
{
|
||||
jailList.append(j);
|
||||
jailList.append(' ');
|
||||
}
|
||||
sender.sendMessage("§7" + jailList);
|
||||
sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails()));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.GregorianCalendar;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@ -124,7 +125,7 @@ public class Commandkit extends EssentialsCommand
|
||||
for (String d : items)
|
||||
{
|
||||
String[] parts = d.split("[^0-9]+", 3);
|
||||
int id = Integer.parseInt(parts[0]);
|
||||
int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
|
||||
@ -140,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,8 +17,7 @@ public class Commandme extends EssentialsCommand
|
||||
{
|
||||
if (user.isMuted())
|
||||
{
|
||||
user.sendMessage(Util.i18n("voiceSilenced"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("voiceSilenced"));
|
||||
}
|
||||
|
||||
if (args.length < 1)
|
||||
@ -31,7 +30,6 @@ public class Commandme extends EssentialsCommand
|
||||
message.append(args[i]);
|
||||
message.append(' ');
|
||||
}
|
||||
charge(user);
|
||||
ess.broadcastMessage(user.getName(), "* " + user.getDisplayName() + " " + message);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -21,13 +21,16 @@ public class Commandnick extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
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);
|
||||
@ -46,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())
|
||||
@ -61,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."));
|
||||
@ -80,6 +80,11 @@ public class Commandnick extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
sender.sendMessage(Util.i18n("nickDisplayName"));
|
||||
return;
|
||||
}
|
||||
|
||||
setOthersNickname(server, sender, args);
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
@ -2,6 +2,8 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -17,23 +19,78 @@ public class Commandpowertool extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
|
||||
ItemStack is = user.getItemInHand();
|
||||
List<String> powertools = user.getPowertool(is);
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
{
|
||||
user.sendMessage(Util.i18n("powerToolAir"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("powerToolAir"));
|
||||
}
|
||||
|
||||
String itemName = is.getType().toString().toLowerCase().replaceAll("_", " ");
|
||||
String command = getFinalArg(args, 0);
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolAttach",is.getType().toString().toLowerCase().replaceAll("_", " ")));
|
||||
if (command.equalsIgnoreCase("l:"))
|
||||
{
|
||||
if (powertools == null || powertools.isEmpty())
|
||||
{
|
||||
throw new Exception(Util.format("powerToolListEmpty", itemName));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolList", Util.joinList(powertools), itemName));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("r:"))
|
||||
{
|
||||
try
|
||||
{
|
||||
command = command.substring(2);
|
||||
if (!powertools.contains(command))
|
||||
{
|
||||
throw new Exception(Util.format("powerToolNoSuchCommandAssigned", command, itemName));
|
||||
}
|
||||
|
||||
powertools.remove(command);
|
||||
user.sendMessage(Util.format("powerToolRemove", command, itemName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (command.startsWith("a:"))
|
||||
{
|
||||
command = command.substring(2);
|
||||
if(powertools.contains(command))
|
||||
{
|
||||
throw new Exception(Util.format("powerToolAlreadySet", command, itemName));
|
||||
}
|
||||
}
|
||||
else if (powertools != null && !powertools.isEmpty())
|
||||
{
|
||||
// Replace all commands with this one
|
||||
powertools.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools = new ArrayList<String>();
|
||||
}
|
||||
|
||||
powertools.add(command);
|
||||
user.sendMessage(Util.format("powerToolAttach", Util.joinList(powertools), itemName));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolRemove", is.getType().toString().toLowerCase().replaceAll("_", " ")));
|
||||
powertools.clear();
|
||||
user.sendMessage(Util.format("powerToolRemoveAll", itemName));
|
||||
}
|
||||
charge(user);
|
||||
user.setPowertool(is, command);
|
||||
|
||||
user.setPowertool(is, 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"));
|
||||
}
|
||||
|
@ -1,21 +1,17 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Seiji
|
||||
*/
|
||||
public class Commandrepair extends EssentialsCommand
|
||||
{
|
||||
public Commandrepair()
|
||||
@ -24,7 +20,7 @@ public class Commandrepair extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@ -33,46 +29,32 @@ public class Commandrepair extends EssentialsCommand
|
||||
|
||||
if (args[0].equalsIgnoreCase("hand"))
|
||||
{
|
||||
ItemStack item = user.getItemInHand();
|
||||
try
|
||||
{
|
||||
repairItem(item);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(e.getMessage());
|
||||
return;
|
||||
}
|
||||
final ItemStack item = user.getItemInHand();
|
||||
final String itemName = item.getType().toString().toLowerCase();
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
|
||||
String itemName = item.getType().toString().toLowerCase().replace('_', ' ');
|
||||
charge(user);
|
||||
user.sendMessage(Util.format("repair", itemName));
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
repairItem(item);
|
||||
|
||||
charge.charge(user);
|
||||
|
||||
user.sendMessage(Util.format("repair", itemName.replace('_', ' ')));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("all"))
|
||||
{
|
||||
StringBuilder itemList = new StringBuilder();
|
||||
itemList.append(repairItems(user.getInventory().getContents()));
|
||||
final List<String> repaired = new ArrayList<String>();
|
||||
repairItems(user.getInventory().getContents(), user, repaired);
|
||||
|
||||
String armor = repairItems(user.getInventory().getArmorContents());
|
||||
repairItems(user.getInventory().getArmorContents(), user, repaired);
|
||||
|
||||
if (armor.length() > 0)
|
||||
if (repaired.isEmpty())
|
||||
{
|
||||
if (itemList.length() > 0)
|
||||
{
|
||||
itemList.append(", ");
|
||||
}
|
||||
|
||||
itemList.append(armor);
|
||||
}
|
||||
|
||||
if (itemList.length() == 0)
|
||||
{
|
||||
user.sendMessage(Util.format("repairNone"));
|
||||
throw new Exception(Util.format("repairNone"));
|
||||
}
|
||||
else
|
||||
{
|
||||
charge(user);
|
||||
user.sendMessage(Util.format("repair", itemList.toString()));
|
||||
user.sendMessage(Util.format("repair", Util.joinList(repaired)));
|
||||
}
|
||||
|
||||
}
|
||||
@ -82,10 +64,9 @@ public class Commandrepair extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void repairItem(ItemStack item) throws Exception
|
||||
private void repairItem(final ItemStack item) throws Exception
|
||||
{
|
||||
Material material = Material.getMaterial(item.getTypeId());
|
||||
String error = null;
|
||||
final Material material = Material.getMaterial(item.getTypeId());
|
||||
if (material.isBlock() || material.getMaxDurability() < 0)
|
||||
{
|
||||
throw new Exception(Util.i18n("repairInvalidType"));
|
||||
@ -99,28 +80,39 @@ public class Commandrepair extends EssentialsCommand
|
||||
item.setDurability((short)0);
|
||||
}
|
||||
|
||||
private String repairItems(ItemStack[] items)
|
||||
private void repairItems(final ItemStack[] items, final IUser user, final List<String> repaired)
|
||||
{
|
||||
StringBuilder itemList = new StringBuilder();
|
||||
for (ItemStack item : items)
|
||||
{
|
||||
final String itemName = item.getType().toString().toLowerCase();
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
}
|
||||
catch (ChargeException ex)
|
||||
{
|
||||
user.sendMessage(ex.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
repairItem(item);
|
||||
if (itemList.length() > 0)
|
||||
{
|
||||
itemList.append(", ");
|
||||
}
|
||||
|
||||
String itemName = item.getType().toString().toLowerCase().replace('_', ' ');
|
||||
itemList.append(itemName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
charge.charge(user);
|
||||
}
|
||||
catch (ChargeException ex)
|
||||
{
|
||||
user.sendMessage(ex.getMessage());
|
||||
}
|
||||
repaired.add(itemName.replace('_', ' '));
|
||||
}
|
||||
|
||||
return itemList.toString();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -17,16 +17,35 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
if (args.length > 0)
|
||||
{
|
||||
//Allowing both formats /sethome khobbits house | /sethome khobbits:house
|
||||
final String[] nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() != args[0].length())
|
||||
{
|
||||
args = nameParts;
|
||||
}
|
||||
|
||||
if (args.length < 2)
|
||||
{
|
||||
user.setHome(args[0].equalsIgnoreCase("default"));
|
||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes())
|
||||
|| (user.getHomes().contains(args[0].toLowerCase())))
|
||||
{
|
||||
user.setHome(args[0].toLowerCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.others"))
|
||||
{
|
||||
User usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
|
||||
if(usersHome == null)
|
||||
if (usersHome == null)
|
||||
{
|
||||
usersHome = ess.getOfflineUser(args[0]);
|
||||
}
|
||||
@ -34,15 +53,19 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
usersHome.setHome(user.getLocation(), args[1].equalsIgnoreCase("default"));
|
||||
String name = args[1].toLowerCase();
|
||||
if (!user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
name = "home";
|
||||
}
|
||||
usersHome.setHome(name, user.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.setHome(false);
|
||||
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,15 +70,18 @@ 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
|
||||
};
|
||||
Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
|
||||
Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock();
|
||||
if(block == null) {
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
Location loc = block.getLocation();
|
||||
Location sloc = Util.getSafeDestination(loc);
|
||||
try
|
||||
{
|
||||
@ -185,7 +184,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
{
|
||||
try
|
||||
{
|
||||
((CraftSlime)spawned).setSize(Integer.parseInt(data));
|
||||
((Slime)spawned).setSize(Integer.parseInt(data));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -199,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)
|
||||
@ -213,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,7 +15,6 @@ 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(),
|
||||
|
@ -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)
|
||||
|
@ -45,7 +45,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"));
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ 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);
|
||||
|
@ -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);
|
||||
|
@ -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"));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -55,16 +55,7 @@ public class Commandwarp extends EssentialsCommand
|
||||
user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
|
||||
}
|
||||
final int warpPage = (page - 1) * WARPS_PER_PAGE;
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE); i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(warpNameList.get(i + warpPage));
|
||||
}
|
||||
user.sendMessage(sb.toString());
|
||||
user.sendMessage(Util.joinList(warpNameList.subList(warpPage, warpPage+Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE))));
|
||||
return;
|
||||
}
|
||||
if (args.length > 0)
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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,50 @@
|
||||
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 PermissionSet pset = wpm.getPermissionSet(base.getWorld());
|
||||
if (pset == null)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
final List<String> groups = pset.getGroups(base);
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
return groups.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
final PermissionSet pset = wpm.getPermissionSet(base.getWorld());
|
||||
if (pset == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final List<String> groups = pset.getGroups(base);
|
||||
if (groups == null || groups.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return groups.contains(group);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@ -12,33 +13,39 @@ public class ConfigPermissionsHandler implements IPermissionsHandler
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
|
||||
@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 "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return "";
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user