Merge branch 'master' into release

This commit is contained in:
snowleo 2011-08-19 00:42:26 +02:00
commit a1ad512a80
93 changed files with 2843 additions and 933 deletions

View File

@ -931,11 +931,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.43.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=2bd2dd75
nbproject/build-impl.xml.script.CRC32=769e541b
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=89fb91fc
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -868,11 +868,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,8 +4,8 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=4b596d89
nbproject/build-impl.xml.script.CRC32=4926001b
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=dbc81ee1
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1

View File

@ -65,7 +65,9 @@ file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.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
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.PermissionsEx.jar=../lib/PermissionsEx.jar
includes=**
@ -77,6 +79,8 @@ javac.classpath=\
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.iCo4.jar}:\
${file.reference.iCo5.jar}:\
${file.reference.iCo6.jar}:\
${file.reference.MultiCurrency.jar}:\
${file.reference.BOSEconomy7.jar}:\
${file.reference.PermissionsEx.jar}
# Space-separated list of extra javac options

View File

@ -0,0 +1,305 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.Commandtime;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* This utility class is used for converting between the ingame
* time in ticks to ingame time as a friendly string.
* Note that the time is INGAME.
*
* http://www.minecraftwiki.net/wiki/Day/night_cycle
*
* @author Olof Larsson
*/
public final class DescParseTickFormat
{
// ============================================
// First some information vars. TODO: Should this be in a config file?
// --------------------------------------------
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
public static final Set<String> resetAliases = new HashSet<String>();
public static final int ticksAtMidnight = 18000;
public static final int ticksPerDay = 24000;
public static final int ticksPerHour = 1000;
public static final double ticksPerMinute = 1000d / 60d;
public static final double ticksPerSecond = 1000d / 60d / 60d;
private static final SimpleDateFormat SDFTwentyFour = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
private static final SimpleDateFormat SDFTwelve = new SimpleDateFormat("h:mmaa", Locale.ENGLISH);
static
{
SDFTwentyFour.setTimeZone(TimeZone.getTimeZone("GMT"));
SDFTwelve.setTimeZone(TimeZone.getTimeZone("GMT"));
nameToTicks.put("sunrise", 23000);
nameToTicks.put("rise", 23000);
nameToTicks.put("dawn", 23000);
nameToTicks.put("daystart", 0);
nameToTicks.put("day", 0);
nameToTicks.put("morning", 1000);
nameToTicks.put("midday", 6000);
nameToTicks.put("noon", 6000);
nameToTicks.put("afternoon", 9000);
nameToTicks.put("sunset", 12000);
nameToTicks.put("set", 12000);
nameToTicks.put("dusk", 12000);
nameToTicks.put("sundown", 12000);
nameToTicks.put("nightfall", 12000);
nameToTicks.put("nightstart", 14000);
nameToTicks.put("night", 14000);
nameToTicks.put("midnight", 18000);
resetAliases.add("reset");
resetAliases.add("normal");
resetAliases.add("default");
}
private DescParseTickFormat()
{
}
// ============================================
// PARSE. From describing String to int
// --------------------------------------------
public static long parse(String desc) throws NumberFormatException
{
// Only look at alphanumeric and lowercase and : for 24:00
desc = desc.toLowerCase().replaceAll("[^A-Za-z0-9:]", "");
// Detect ticks format
try
{
return parseTicks(desc);
}
catch (Exception e)
{
}
// Detect 24-hour format
try
{
return parse24(desc);
}
catch (Exception e)
{
}
// Detect 12-hour format
try
{
return parse12(desc);
}
catch (Exception e)
{
}
// Detect aliases
try
{
return parseAlias(desc);
}
catch (Exception e)
{
}
// Well we failed to understand...
throw new NumberFormatException();
}
public static long parseTicks(String desc) throws NumberFormatException
{
if (!desc.matches("^[0-9]+ti?c?k?s?$"))
{
throw new NumberFormatException();
}
desc = desc.replaceAll("[^0-9]", "");
return Long.parseLong(desc) % 24000;
}
public static long parse24(String desc) throws NumberFormatException
{
if (!desc.matches("^[0-9]{2}[^0-9]?[0-9]{2}$"))
{
throw new NumberFormatException();
}
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
if (desc.length() != 4)
{
throw new NumberFormatException();
}
final int hours = Integer.parseInt(desc.substring(0, 2));
final int minutes = Integer.parseInt(desc.substring(2, 4));
return hoursMinutesToTicks(hours, minutes);
}
public static long parse12(String desc) throws NumberFormatException
{
if (!desc.matches("^[0-9]{1,2}([^0-9]?[0-9]{2})?(pm|am)$"))
{
throw new NumberFormatException();
}
int hours = 0;
int minutes = 0;
if (desc.endsWith("pm"))
{
hours += 12;
}
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
if (desc.length() > 4)
{
throw new NumberFormatException();
}
if (desc.length() == 4)
{
hours += Integer.parseInt(desc.substring(0, 2));
minutes += Integer.parseInt(desc.substring(2, 4));
}
else if (desc.length() == 3)
{
hours += Integer.parseInt(desc.substring(0, 1));
minutes += Integer.parseInt(desc.substring(1, 3));
}
else if (desc.length() == 2)
{
hours += Integer.parseInt(desc.substring(0, 2));
}
else if (desc.length() == 1)
{
hours += Integer.parseInt(desc.substring(0, 1));
}
else
{
throw new NumberFormatException();
}
return hoursMinutesToTicks(hours, minutes);
}
public static long hoursMinutesToTicks(final int hours, final int minutes)
{
long ret = ticksAtMidnight;
ret += (hours) * ticksPerHour;
ret += (minutes / 60.0) * ticksPerHour;
ret %= ticksPerDay;
return ret;
}
public static long parseAlias(final String desc) throws NumberFormatException
{
final Integer ret = nameToTicks.get(desc);
if (ret == null)
{
throw new NumberFormatException();
}
return ret;
}
public static boolean meansReset(final String desc)
{
return resetAliases.contains(desc);
}
// ============================================
// FORMAT. From int to describing String
// --------------------------------------------
public static String format(final long ticks)
{
final StringBuilder msg = new StringBuilder();
msg.append(Commandtime.colorHighlight1);
msg.append(format24(ticks));
msg.append(Commandtime.colorDefault);
msg.append(" or ");
msg.append(Commandtime.colorHighlight1);
msg.append(format12(ticks));
msg.append(Commandtime.colorDefault);
msg.append(" or ");
msg.append(Commandtime.colorHighlight1);
msg.append(formatTicks(ticks));
return msg.toString();
}
public static String formatTicks(final long ticks)
{
return (ticks % ticksPerDay) + "ticks";
}
public static String format24(final long ticks)
{
synchronized (SDFTwentyFour)
{
return formatDateFormat(ticks, SDFTwentyFour);
}
}
public static String format12(final long ticks)
{
synchronized (SDFTwelve)
{
return formatDateFormat(ticks, SDFTwelve);
}
}
public static String formatDateFormat(final long ticks, final SimpleDateFormat format)
{
final Date date = ticksToDate(ticks);
return format.format(date);
}
public static Date ticksToDate(long ticks)
{
// Assume the server time starts at 0. It would start on a day.
// But we will simulate that the server started with 0 at midnight.
ticks = ticks - ticksAtMidnight + ticksPerDay;
// How many ingame days have passed since the server start?
final long days = ticks / ticksPerDay;
ticks = ticks - days * ticksPerDay;
// How many hours on the last day?
final long hours = ticks / ticksPerHour;
ticks = ticks - hours * ticksPerHour;
// How many minutes on the last day?
final long minutes = (long)Math.floor(ticks / ticksPerMinute);
final double dticks = ticks - minutes * ticksPerMinute;
// How many seconds on the last day?
final long seconds = (long)Math.floor(dticks / ticksPerSecond);
// Now we create an english GMT calendar (We wan't no daylight savings)
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
cal.setLenient(true);
// And we set the time to 0! And append the time that passed!
cal.set(0, Calendar.JANUARY, 1, 0, 0, 0);
cal.add(Calendar.DAY_OF_YEAR, (int)days);
cal.add(Calendar.HOUR_OF_DAY, (int)hours);
cal.add(Calendar.MINUTE, (int)minutes);
cal.add(Calendar.SECOND, (int)seconds + 1); // To solve rounding errors.
return cal.getTime();
}
}

View File

@ -35,18 +35,18 @@ import java.math.BigInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.command.PluginCommand;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.*;
import org.bukkit.plugin.java.*;
import org.bukkit.scheduler.BukkitScheduler;
public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 1000;
public static final int BUKKIT_VERSION = 1060;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
@ -64,7 +64,9 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient final static boolean enableErrorLogging = false;
private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
private transient IPermissionsHandler permissionsHandler;
private transient UserMap userMap;
@Override
public ISettings getSettings()
{
return settings;
@ -85,10 +87,12 @@ public class Essentials extends JavaPlugin implements IEssentials
LOGGER.log(Level.INFO, dataFolder.toString());
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
settings = new Settings(this);
userMap = new UserMap(this);
permissionsHandler = new ConfigPermissionsHandler(this);
Economy.setEss(this);
}
@Override
public void onEnable()
{
final String[] javaversion = System.getProperty("java.version").split("\\.", 3);
@ -100,13 +104,15 @@ public class Essentials extends JavaPlugin implements IEssentials
{
LOGGER.addHandler(errorHandler);
}
EssentialsUpgrade upgrade = new EssentialsUpgrade(this.getDescription().getVersion(), this);
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
upgrade.beforeSettings();
confList = new ArrayList<IConf>();
settings = new Settings(this);
confList.add(settings);
upgrade.afterSettings();
Util.updateLocale(settings.getLocale(), this);
userMap = new UserMap(this);
confList.add(userMap);
spawn = new Spawn(getServer(), this.getDataFolder());
confList.add(spawn);
warps = new Warps(getServer(), this.getDataFolder());
@ -212,12 +218,14 @@ public class Essentials extends JavaPlugin implements IEssentials
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
}
@Override
public void onDisable()
{
Trade.closeLog();
LOGGER.removeHandler(errorHandler);
}
@Override
public void reload()
{
Trade.closeLog();
@ -238,12 +246,14 @@ public class Essentials extends JavaPlugin implements IEssentials
getConfiguration().load();
}
public String[] getMotd(CommandSender sender, String def)
@Override
public String[] getMotd(final CommandSender sender, final String def)
{
return getLines(sender, "motd", def);
}
public String[] getLines(CommandSender sender, String node, String def)
@Override
public String[] getLines(final CommandSender sender, final String node, final String def)
{
List<String> lines = (List<String>)getConfiguration().getProperty(node);
if (lines == null)
@ -348,12 +358,13 @@ public class Essentials extends JavaPlugin implements IEssentials
}
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
{
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.");
}
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix)
@Override
public boolean onCommandEssentials(final CommandSender sender, final Command command, final String commandLabel, final String[] args, final ClassLoader classLoader, final String commandPath, final String permissionPrefix)
{
// Allow plugins to override the command via onCommand
if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e"))
@ -365,7 +376,7 @@ public class Essentials extends JavaPlugin implements IEssentials
continue;
}
PluginDescriptionFile desc = p.getDescription();
final PluginDescriptionFile desc = p.getDescription();
if (desc == null)
{
continue;
@ -376,7 +387,7 @@ public class Essentials extends JavaPlugin implements IEssentials
continue;
}
PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
final PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
if (pc != null)
{
return pc.execute(sender, commandLabel, args);
@ -462,6 +473,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
}
@Override
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
{
sender.sendMessage(Util.format("errorWithMessage", exception.getMessage()));
@ -481,46 +493,64 @@ public class Essentials extends JavaPlugin implements IEssentials
}
}
public CraftScheduler getScheduler()
@Override
public BukkitScheduler getScheduler()
{
return (CraftScheduler)this.getServer().getScheduler();
return this.getServer().getScheduler();
}
@Override
public Jail getJail()
{
return jail;
}
@Override
public Warps getWarps()
{
return warps;
}
@Override
public Worth getWorth()
{
return worth;
}
@Override
public Backup getBackup()
{
return backup;
}
@Override
public Spawn getSpawn()
{
return spawn;
}
public User getUser(Object base)
@Override
public User getUser(final Object base)
{
if (base instanceof Player)
{
return getUser((Player)base);
}
if (base instanceof String)
{
try
{
return userMap.getUser((String)base);
}
catch (NullPointerException ex)
{
return null;
}
}
return null;
}
private <T extends Player> User getUser(T base)
private <T extends Player> User getUser(final T base)
{
if (base == null)
{
@ -531,71 +561,64 @@ public class Essentials extends JavaPlugin implements IEssentials
{
return (User)base;
}
if (users.containsKey(base.getName().toLowerCase()))
try
{
return users.get(base.getName().toLowerCase()).update(base);
return userMap.getUser(base.getName()).update(base);
}
User u = new User(base, this);
users.put(u.getName().toLowerCase(), u);
return u;
}
public Map<String, User> getAllUsers()
{
return users;
}
public User getOfflineUser(String name)
{
// Don't create a new offline user, if we already have that user loaded.
User u = users.get(name.toLowerCase());
if (u != null)
catch (NullPointerException ex)
{
return u;
return null;
}
File userFolder = new File(getDataFolder(), "userdata");
File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
if (userFile.exists())
{ //Users do not get offline changes saved without being reproccessed as Users! ~ Xeology :)
return getUser((Player)new OfflinePlayer(name, this));
}
return null;
}
@Override
public User getOfflineUser(final String name)
{
try
{
return userMap.getUser(name);
}
catch (NullPointerException ex)
{
return null;
}
}
@Override
public World getWorld(final String name)
{
if (name.matches("[0-9]+"))
{
final int id = Integer.parseInt(name);
if (id < getServer().getWorlds().size())
final int worldId = Integer.parseInt(name);
if (worldId < getServer().getWorlds().size())
{
return getServer().getWorlds().get(id);
return getServer().getWorlds().get(worldId);
}
}
return getServer().getWorld(name);
}
@Override
public void addReloadListener(final IConf listener)
{
confList.add(listener);
}
@Override
public Methods getPaymentMethod()
{
return paymentMethod;
}
@Override
public int broadcastMessage(final String name, final String message)
{
Player[] players = getServer().getOnlinePlayers();
final Player[] players = getServer().getOnlinePlayers();
for (Player player : players)
{
User u = getUser(player);
if (!u.isIgnoredPlayer(name))
final User user = getUser(player);
if (!user.isIgnoredPlayer(name))
{
player.sendMessage(message);
}
@ -609,48 +632,63 @@ public class Essentials extends JavaPlugin implements IEssentials
return errorHandler.getErrors();
}
@Override
public int scheduleAsyncDelayedTask(final Runnable run)
{
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
}
@Override
public int scheduleSyncDelayedTask(final Runnable run)
{
return this.getScheduler().scheduleSyncDelayedTask(this, run);
}
@Override
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
{
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
}
@Override
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
{
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
}
@Override
public TNTExplodeListener getTNTListener()
{
return tntListener;
}
@Override
public IPermissionsHandler getPermissionsHandler()
{
return permissionsHandler;
}
public void setPermissionsHandler(IPermissionsHandler handler)
@Override
public void setPermissionsHandler(final IPermissionsHandler handler)
{
this.permissionsHandler = handler;
}
@Override
public BanWorkaround getBans()
{
return bans;
}
@Override
public ItemDb getItemDb()
{
return itemDb;
}
@Override
public UserMap getUserMap()
{
return userMap;
}
}

View File

@ -1,8 +1,6 @@
package com.earth2me.essentials;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
@ -301,13 +299,21 @@ public class EssentialsPlayerListener extends PlayerListener
@Override
public void onPlayerLogin(final PlayerLoginEvent event)
{
if (event.getResult() != Result.ALLOWED)
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL)
{
return;
}
final User user = ess.getUser(event.getPlayer());
User user = ess.getUser(event.getPlayer());
if (user == null) {
user = new User(event.getPlayer(), ess);
}
user.setNPC(false);
final long currentTime = System.currentTimeMillis();
user.checkBanTimeout(currentTime);
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
if (user.isBanned())
{
final String banReason = user.getBanReason();

View File

@ -1,79 +1,44 @@
package com.earth2me.essentials;
import java.io.File;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.entity.Player;
public class EssentialsTimer implements Runnable, IConf
public class EssentialsTimer implements Runnable
{
private final IEssentials ess;
private final Set<User> allUsers = new HashSet<User>();
EssentialsTimer(IEssentials ess)
private final transient IEssentials ess;
private final transient Set<User> onlineUsers = new HashSet<User>();
EssentialsTimer(final IEssentials ess)
{
this.ess = ess;
File userdir = new File(ess.getDataFolder(), "userdata");
if (!userdir.exists()) {
return;
}
for (String string : userdir.list())
{
if (!string.endsWith(".yml")) {
continue;
}
String name = string.substring(0, string.length()-4);
User u = ess.getUser(new OfflinePlayer(name, ess));
allUsers.add(u);
}
}
@Override
public void run()
{
long currentTime = System.currentTimeMillis();
final long currentTime = System.currentTimeMillis();
for (Player player : ess.getServer().getOnlinePlayers())
{
User u = ess.getUser(player);
allUsers.add(u);
u.setLastActivity(currentTime);
final User user = ess.getUser(player);
onlineUsers.add(user);
user.setLastActivity(currentTime);
}
for (User user: allUsers) {
if (user.getBanTimeout() > 0 && user.getBanTimeout() < currentTime) {
user.setBanTimeout(0);
ess.getBans().unbanByName(user.getName());
}
if (user.getMuteTimeout() > 0 && user.getMuteTimeout() < currentTime && user.isMuted()) {
user.setMuteTimeout(0);
user.sendMessage(Util.i18n("canTalkAgain"));
user.setMuted(false);
}
if (user.getJailTimeout() > 0 && user.getJailTimeout() < currentTime && user.isJailed()) {
user.setJailTimeout(0);
user.setJailed(false);
user.sendMessage(Util.i18n("haveBeenReleased"));
user.setJail(null);
try
{
user.getTeleport().back();
}
catch (Exception ex)
{
}
}
if (user.getLastActivity() < currentTime && user.getLastActivity() > user.getLastLogout()) {
user.setLastLogout(user.getLastActivity());
}
}
}
public void reloadConfig()
{
for (User user : allUsers)
final Iterator<User> iterator = onlineUsers.iterator();
while (iterator.hasNext())
{
user.reloadConfig();
final User user = iterator.next();
if (user.getLastActivity() < currentTime && user.getLastActivity() > user.getLastLogout())
{
user.setLastLogout(user.getLastActivity());
iterator.remove();
continue;
}
user.checkMuteTimeout(currentTime);
user.checkJailTimeout(currentTime);
}
}
}

View File

@ -16,63 +16,70 @@ import org.bukkit.inventory.ItemStack;
public class EssentialsUpgrade
{
private static boolean alreadyRun = false;
private final static Logger logger = Logger.getLogger("Minecraft");
private final IEssentials ess;
private final static Logger LOGGER = Logger.getLogger("Minecraft");
private final transient IEssentials ess;
private final transient EssentialsConf doneFile;
EssentialsUpgrade(String version, IEssentials essentials)
EssentialsUpgrade(final IEssentials essentials)
{
ess = essentials;
if (alreadyRun)
if (!ess.getDataFolder().exists())
{
return;
ess.getDataFolder().mkdirs();
}
alreadyRun = true;
doneFile = new EssentialsConf(new File(ess.getDataFolder(), "upgrades-done.yml"));
doneFile.load();
}
private void moveWorthValuesToWorthYml()
{
if (doneFile.getBoolean("moveWorthValuesToWorthYml", false))
{
return;
}
try
{
File configFile = new File(ess.getDataFolder(), "config.yml");
final File configFile = new File(ess.getDataFolder(), "config.yml");
if (!configFile.exists())
{
return;
}
EssentialsConf conf = new EssentialsConf(configFile);
final EssentialsConf conf = new EssentialsConf(configFile);
conf.load();
Worth w = new Worth(ess.getDataFolder());
final Worth worth = new Worth(ess.getDataFolder());
boolean found = false;
for (Material mat : Material.values())
{
int id = mat.getId();
double value = conf.getDouble("worth-" + id, Double.NaN);
final int id = mat.getId();
final double value = conf.getDouble("worth-" + id, Double.NaN);
if (!Double.isNaN(value))
{
found = true;
w.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
worth.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
}
}
if (found)
{
removeLinesFromConfig(configFile, "\\s*#?\\s*worth-[0-9]+.*", "# Worth values have been moved to worth.yml");
}
doneFile.setProperty("moveWorthValuesToWorthYml", true);
doneFile.save();
}
catch (Throwable e)
{
logger.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
LOGGER.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
}
}
private void removeLinesFromConfig(File file, String regex, String info) throws Exception
{
boolean needUpdate = false;
BufferedReader br = new BufferedReader(new FileReader(file));
File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile));
final BufferedReader bReader = new BufferedReader(new FileReader(file));
final File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
final BufferedWriter bWriter = new BufferedWriter(new FileWriter(tempFile));
do
{
String line = br.readLine();
final String line = bReader.readLine();
if (line == null)
{
break;
@ -81,8 +88,8 @@ public class EssentialsUpgrade
{
if (!needUpdate && info != null)
{
bw.write(info, 0, info.length());
bw.newLine();
bWriter.write(info, 0, info.length());
bWriter.newLine();
}
needUpdate = true;
}
@ -90,22 +97,22 @@ public class EssentialsUpgrade
{
if (line.endsWith("\r\n"))
{
bw.write(line, 0, line.length() - 2);
bWriter.write(line, 0, line.length() - 2);
}
else if (line.endsWith("\r") || line.endsWith("\n"))
{
bw.write(line, 0, line.length() - 1);
bWriter.write(line, 0, line.length() - 1);
}
else
{
bw.write(line, 0, line.length());
bWriter.write(line, 0, line.length());
}
bw.newLine();
bWriter.newLine();
}
}
while (true);
br.close();
bw.close();
bReader.close();
bWriter.close();
if (needUpdate)
{
if (!file.renameTo(new File(file.getParentFile(), file.getName().concat("." + System.currentTimeMillis() + ".upgradebackup"))))
@ -116,19 +123,25 @@ public class EssentialsUpgrade
{
throw new Exception(Util.i18n("configFileRenameError"));
}
} else {
}
else
{
tempFile.delete();
}
}
private void updateUsersToNewDefaultHome()
{
File userdataFolder = new File(ess.getDataFolder(), "userdata");
if (doneFile.getBoolean("updateUsersToNewDefaultHome", false))
{
return;
}
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
{
return;
}
File[] userFiles = userdataFolder.listFiles();
final File[] userFiles = userdataFolder.listFiles();
for (File file : userFiles)
{
@ -136,15 +149,16 @@ public class EssentialsUpgrade
{
continue;
}
EssentialsConf config = new EssentialsConf(file);
final EssentialsConf config = new EssentialsConf(file);
try
{
config.load();
if (config.hasProperty("home") && !config.hasProperty("home.default"))
{
@SuppressWarnings("unchecked")
List<Object> vals = (List<Object>)config.getProperty("home");
if (vals == null) {
final List<Object> vals = (List<Object>)config.getProperty("home");
if (vals == null)
{
continue;
}
World world = ess.getServer().getWorlds().get(0);
@ -154,7 +168,7 @@ public class EssentialsUpgrade
}
if (world != null)
{
Location loc = new Location(
final Location loc = new Location(
world,
((Number)vals.get(0)).doubleValue(),
((Number)vals.get(1)).doubleValue(),
@ -162,7 +176,7 @@ public class EssentialsUpgrade
((Number)vals.get(3)).floatValue(),
((Number)vals.get(4)).floatValue());
String worldName = world.getName().toLowerCase();
final String worldName = world.getName().toLowerCase();
if (worldName != null && !worldName.isEmpty())
{
config.removeProperty("home");
@ -175,30 +189,32 @@ public class EssentialsUpgrade
}
catch (RuntimeException ex)
{
logger.log(Level.INFO, "File: "+file.toString());
LOGGER.log(Level.INFO, "File: " + file.toString());
throw ex;
}
}
doneFile.setProperty("updateUsersToNewDefaultHome", true);
doneFile.save();
}
private void moveUsersDataToUserdataFolder()
{
File usersFile = new File(ess.getDataFolder(), "users.yml");
final File usersFile = new File(ess.getDataFolder(), "users.yml");
if (!usersFile.exists())
{
return;
}
EssentialsConf usersConfig = new EssentialsConf(usersFile);
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
usersConfig.load();
for (String username : usersConfig.getKeys(null))
{
User user = new User(new OfflinePlayer(username, ess), ess);
String nickname = usersConfig.getString(username + ".nickname");
final User user = new User(new OfflinePlayer(username, ess), ess);
final String nickname = usersConfig.getString(username + ".nickname");
if (nickname != null && !nickname.isEmpty() && !nickname.equals(username))
{
user.setNickname(nickname);
}
List<String> mails = usersConfig.getStringList(username + ".mail", null);
final List<String> mails = usersConfig.getStringList(username + ".mail", null);
if (mails != null && !mails.isEmpty())
{
user.setMails(mails);
@ -206,8 +222,9 @@ public class EssentialsUpgrade
if (!user.hasHome())
{
@SuppressWarnings("unchecked")
List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
if (vals != null) {
final List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
if (vals != null)
{
World world = ess.getServer().getWorlds().get(0);
if (vals.size() > 5)
{
@ -230,40 +247,56 @@ public class EssentialsUpgrade
private void convertWarps()
{
File warpsFolder = new File(ess.getDataFolder(), "warps");
final File warpsFolder = new File(ess.getDataFolder(), "warps");
if (!warpsFolder.exists())
{
warpsFolder.mkdirs();
}
File[] listOfFiles = warpsFolder.listFiles();
final File[] listOfFiles = warpsFolder.listFiles();
if (listOfFiles.length >= 1)
{
for (int i = 0; i < listOfFiles.length; i++)
{
String filename = listOfFiles[i].getName();
final String filename = listOfFiles[i].getName();
if (listOfFiles[i].isFile() && filename.endsWith(".dat"))
{
try
{
BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
final BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
double x, y, z;
float yaw, pitch;
String worldName;
try
{
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
x = Double.parseDouble(rx.readLine().trim());
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
y = Double.parseDouble(rx.readLine().trim());
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
z = Double.parseDouble(rx.readLine().trim());
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
yaw = Float.parseFloat(rx.readLine().trim());
if (!rx.ready()) continue;
if (!rx.ready())
{
continue;
}
pitch = Float.parseFloat(rx.readLine().trim());
worldName = rx.readLine();
}
finally {
finally
{
rx.close();
}
World w = null;
@ -285,7 +318,7 @@ public class EssentialsUpgrade
w = w1;
}
}
Location loc = new Location(w, x, y, z, yaw, pitch);
final Location loc = new Location(w, x, y, z, yaw, pitch);
ess.getWarps().setWarp(filename.substring(0, filename.length() - 4), loc);
if (!listOfFiles[i].renameTo(new File(warpsFolder, filename + ".old")))
{
@ -294,52 +327,52 @@ public class EssentialsUpgrade
}
catch (Exception ex)
{
logger.log(Level.SEVERE, null, ex);
LOGGER.log(Level.SEVERE, null, ex);
}
}
}
}
File warpFile = new File(ess.getDataFolder(), "warps.txt");
final File warpFile = new File(ess.getDataFolder(), "warps.txt");
if (warpFile.exists())
{
try
{
BufferedReader rx = new BufferedReader(new FileReader(warpFile));
try
final BufferedReader rx = new BufferedReader(new FileReader(warpFile));
try
{
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
{
if (parts.length < 6)
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
{
continue;
}
String name = parts[0];
double x = Double.parseDouble(parts[1].trim());
double y = Double.parseDouble(parts[2].trim());
double z = Double.parseDouble(parts[3].trim());
float yaw = Float.parseFloat(parts[4].trim());
float pitch = Float.parseFloat(parts[5].trim());
if (name.isEmpty())
{
continue;
}
World w = null;
for (World world : ess.getServer().getWorlds())
{
if (world.getEnvironment() != World.Environment.NETHER)
if (parts.length < 6)
{
w = world;
break;
continue;
}
final String name = parts[0];
final double x = Double.parseDouble(parts[1].trim());
final double y = Double.parseDouble(parts[2].trim());
final double z = Double.parseDouble(parts[3].trim());
final float yaw = Float.parseFloat(parts[4].trim());
final float pitch = Float.parseFloat(parts[5].trim());
if (name.isEmpty())
{
continue;
}
World w = null;
for (World world : ess.getServer().getWorlds())
{
if (world.getEnvironment() != World.Environment.NETHER)
{
w = world;
break;
}
}
final Location loc = new Location(w, x, y, z, yaw, pitch);
ess.getWarps().setWarp(name, loc);
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
{
throw new Exception(Util.format("fileRenameError", "warps.txt"));
}
}
Location loc = new Location(w, x, y, z, yaw, pitch);
ess.getWarps().setWarp(name, loc);
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
{
throw new Exception(Util.format("fileRenameError", "warps.txt"));
}
}
}
finally
{
@ -348,52 +381,60 @@ public class EssentialsUpgrade
}
catch (Exception ex)
{
logger.log(Level.SEVERE, null, ex);
LOGGER.log(Level.SEVERE, null, ex);
}
}
}
private void sanitizeAllUserFilenames()
{
File usersFolder = new File(ess.getDataFolder(), "userdata");
if (doneFile.getBoolean("sanitizeAllUserFilenames", false))
{
return;
}
final File usersFolder = new File(ess.getDataFolder(), "userdata");
if (!usersFolder.exists())
{
return;
}
File[] listOfFiles = usersFolder.listFiles();
final File[] listOfFiles = usersFolder.listFiles();
for (int i = 0; i < listOfFiles.length; i++)
{
String filename = listOfFiles[i].getName();
final String filename = listOfFiles[i].getName();
if (!listOfFiles[i].isFile() || !filename.endsWith(".yml"))
{
continue;
}
String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
if (sanitizedFilename.equals(filename))
{
continue;
}
File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
if (!listOfFiles[i].renameTo(tmpFile)) {
logger.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
final File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
if (!listOfFiles[i].renameTo(tmpFile))
{
LOGGER.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
continue;
}
if (newFile.exists())
{
logger.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
LOGGER.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
continue;
}
if (!tmpFile.renameTo(newFile)) {
logger.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
if (!tmpFile.renameTo(newFile))
{
LOGGER.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
}
}
doneFile.setProperty("sanitizeAllUserFilenames", true);
doneFile.save();
}
private World getFakeWorld(String name)
private World getFakeWorld(final String name)
{
File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
File worldDirectory = new File(bukkitDirectory, name);
final File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
final File worldDirectory = new File(bukkitDirectory, name);
if (worldDirectory.exists() && worldDirectory.isDirectory())
{
return new FakeWorld(worldDirectory.getName(), World.Environment.NORMAL);

View File

@ -12,16 +12,12 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Boat;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Player;
import org.bukkit.entity.PoweredMinecart;
import org.bukkit.entity.StorageMinecart;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.ItemStack;
@ -404,5 +400,29 @@ public class FakeWorld implements World
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean unloadChunk(Chunk chunk)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getMaxHeight()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean getKeepSpawnInMemory()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setKeepSpawnInMemory(boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -1,12 +1,11 @@
package com.earth2me.essentials;
import com.earth2me.essentials.register.payment.Methods;
import java.util.Map;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
public interface IEssentials extends Plugin
@ -27,7 +26,7 @@ public interface IEssentials extends Plugin
ISettings getSettings();
CraftScheduler getScheduler();
BukkitScheduler getScheduler();
String[] getMotd(CommandSender sender, String def);
@ -63,7 +62,7 @@ public interface IEssentials extends Plugin
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
Map<String, User> getAllUsers();
ItemDb getItemDb();
UserMap getUserMap();
}

View File

@ -163,6 +163,11 @@ public class ItemDb implements IConf
metaData = durabilities.get(itemname);
}
}
else if(Material.getMaterial(itemname) != null)
{
itemid = Material.getMaterial(itemname).getId();
metaData = 0;
}
else
{
throw new Exception(Util.format("unknownItemName", id));

View File

@ -31,7 +31,7 @@ public class Jail extends BlockListener implements IConf
public Location getJail(String jailName) throws Exception
{
if (config.getProperty(jailName.toLowerCase()) == null)
if (jailName == null || config.getProperty(jailName.toLowerCase()) == null)
{
throw new Exception(Util.i18n("jailNotExist"));
}

View File

@ -24,6 +24,7 @@ import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.map.MapView;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
@ -576,4 +577,10 @@ public class OfflinePlayer implements Player
public void setOp(boolean bln)
{
}
@Override
public void sendMap(MapView mv)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -7,6 +7,7 @@ import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.*;
import org.bukkit.map.MapView;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
@ -405,20 +406,6 @@ public class PlayerWrapper implements Player
return base.eject();
}
@Override
@Deprecated
public void teleportTo(Location lctn)
{
base.teleportTo(lctn);
}
@Override
@Deprecated
public void teleportTo(Entity entity)
{
base.teleportTo(entity);
}
public void saveData()
{
base.saveData();
@ -624,4 +611,10 @@ public class PlayerWrapper implements Player
{
base.setOp(bln);
}
@Override
public void sendMap(MapView mv)
{
base.sendMap(mv);
}
}

View File

@ -20,44 +20,44 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
private final Teleport teleport;
private long lastActivity;
private boolean hidden = false;
User(Player base, IEssentials ess)
{
super(base, ess);
teleport = new Teleport(this, ess);
}
User update(Player base)
{
setBase(base);
return this;
}
public boolean isAuthorized(IEssentialsCommand cmd)
{
return isAuthorized(cmd, "essentials.");
}
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
{
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
}
public boolean isAuthorized(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();
@ -75,12 +75,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
setLastHealTimestamp(now.getTimeInMillis());
}
public void giveMoney(double value)
{
giveMoney(value, null);
}
public void giveMoney(double value, CommandSender initiator)
{
if (value == 0)
@ -94,7 +94,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
}
}
public void payUser(User reciever, double value) throws Exception
{
if (value == 0)
@ -113,12 +113,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
}
}
public void takeMoney(double value)
{
takeMoney(value, null);
}
public void takeMoney(double value, CommandSender initiator)
{
if (value == 0)
@ -132,43 +132,43 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
}
}
public boolean canAfford(double cost)
{
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)
{
justPortaled = value;
}
public void setReplyTo(CommandSender user)
{
replyTo = user;
}
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)
{
@ -177,51 +177,51 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
return false;
}
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
}
@Override
public int hashCode()
{
return ChatColor.stripColor(this.getDisplayName()).hashCode();
}
public Boolean canSpawnItem(int itemId)
{
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
}
public void setHome()
{
setHome(getLocation(), true);
}
public void setHome(boolean defaultHome)
{
setHome(getLocation(), defaultHome);
}
public void setLastLocation()
{
setLastLocation(getLocation());
}
public void requestTeleport(User player, 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 +245,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 +258,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()
{
return lastActivity;
}
public void setLastActivity(long timestamp)
{
lastActivity = timestamp;
}
@Override
public double getMoney()
{
@ -298,7 +298,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
return super.getMoney();
}
@Override
public void setMoney(double value)
{
@ -320,14 +320,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
super.setMoney(value);
}
@Override
public void setAfk(boolean set)
{
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
super.setAfk(set);
}
@Override
public boolean toggleAfk()
{
@ -335,14 +335,51 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
return now;
}
public boolean isHidden()
{
return hidden;
}
public void setHidden(boolean hidden)
{
this.hidden = hidden;
}
public void checkJailTimeout(final long currentTime)
{
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
{
setJailTimeout(0);
setJailed(false);
sendMessage(Util.i18n("haveBeenReleased"));
setJail(null);
try
{
getTeleport().back();
}
catch (Exception ex)
{
}
}
}
public void checkMuteTimeout(final long currentTime)
{
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
{
setMuteTimeout(0);
sendMessage(Util.i18n("canTalkAgain"));
setMuted(false);
}
}
public void checkBanTimeout(final long currentTime)
{
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && ess.getBans().isNameBanned(getName()))
{
setBanTimeout(0);
ess.getBans().unbanByName(getName());
}
}
}

View File

@ -0,0 +1,107 @@
package com.earth2me.essentials;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
import java.io.File;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
import org.bukkit.entity.Player;
public class UserMap implements Function<String, User>, IConf
{
private final transient IEssentials ess;
private final transient ConcurrentMap<String, User> users = new MapMaker().softValues().makeComputingMap(this);
public UserMap(final IEssentials ess)
{
this.ess = ess;
loadAllUsersAsync(ess);
}
private void loadAllUsersAsync(final IEssentials ess)
{
ess.scheduleAsyncDelayedTask(new Runnable()
{
@Override
public void run()
{
final File userdir = new File(ess.getDataFolder(), "userdata");
if (!userdir.exists())
{
return;
}
for (String string : userdir.list())
{
if (!string.endsWith(".yml"))
{
continue;
}
final String name = string.substring(0, string.length() - 4);
try
{
users.get(name.toLowerCase());
}
catch (NullPointerException ex)
{
// Ignore these
}
}
}
});
}
public boolean userExists(final String name)
{
return users.containsKey(name.toLowerCase());
}
public User getUser(final String name) throws NullPointerException
{
return users.get(name.toLowerCase());
}
@Override
public User apply(final String name)
{
for (Player player : ess.getServer().getOnlinePlayers())
{
if (player.getName().equalsIgnoreCase(name))
{
return new User(player, ess);
}
}
final File userFolder = new File(ess.getDataFolder(), "userdata");
final File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
if (userFile.exists())
{
return new User(new OfflinePlayer(name, ess), ess);
}
return null;
}
@Override
public void reloadConfig()
{
for (User user : users.values())
{
user.reloadConfig();
}
}
public void removeUser(final String name)
{
users.remove(name.toLowerCase());
}
public Set<User> getAllUsers()
{
final Set<User> userSet = new HashSet<User>();
for (String name : users.keySet())
{
userSet.add(users.get(name));
}
return userSet;
}
}

View File

@ -226,13 +226,13 @@ public class Util
int x = loc.getBlockX();
int y = loc.getBlockY();
int z = loc.getBlockZ();
while (isBlockAboveAir(world, x, y, z))
{
y -= 1;
if (y < 0)
{
throw new Exception(Util.i18n("holeInFloor"));
break;
}
}
@ -252,6 +252,10 @@ public class Util
{
y = 127;
x += 1;
if (x - 32 > loc.getBlockX())
{
throw new Exception(Util.i18n("holeInFloor"));
}
}
}
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());

View File

@ -60,7 +60,7 @@ public final class Economy
{
logger.log(Level.WARNING, Util.format("deleteFileError", config));
}
ess.getAllUsers().remove(name.toLowerCase());
ess.getUserMap().removeUser(name);
}
}

View File

@ -39,7 +39,7 @@ public class Commandbalancetop extends EssentialsCommand
}
}
final Map<User, Double> balances = new HashMap<User, Double>();
for (User u : ess.getAllUsers().values())
for (User u : ess.getUserMap().getAllUsers())
{
balances.put(u, u.getMoney());
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -53,12 +54,14 @@ public class Commandban extends EssentialsCommand
}
player.kickPlayer(banReason);
ess.getBans().banByName(player.getName());
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if(u.isAuthorized("essentials.ban.notify"))
{
p.sendMessage(Util.format("playerBanned", player.getName(), banReason));
p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason));
}
}
}

View File

@ -20,6 +20,7 @@ public class Commandclearinventory extends EssentialsCommand
{
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
{
//TODO: Fix fringe user match case.
if (args[0].length() >= 3)
{
List<Player> online = server.matchPlayer(args[0]);

View File

@ -50,7 +50,7 @@ public class Commandgive extends EssentialsCommand
}
User giveTo = getPlayer(server, args, 0);
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
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);

View File

@ -117,52 +117,64 @@ public class Commandhelp extends EssentialsCommand
{
final PluginDescriptionFile desc = p.getDescription();
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
pluginName = p.getDescription().getName().toLowerCase();
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
{
if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match))
&& (!k.getValue().get("description").toLowerCase().contains(match)))
try
{
if ((!match.equalsIgnoreCase(""))
&& (!k.getKey().toLowerCase().contains(match))
&& (!k.getValue().get("description").toLowerCase().contains(match))
&& (!pluginName.contains(match)))
{
continue;
}
if (pluginName.contains("essentials"))
{
final String node = "essentials." + k.getKey();
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
{
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description"));
}
}
else
{
if (ess.getSettings().showNonEssCommandsInHelp())
{
final HashMap<String, String> value = k.getValue();
if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals("")))
{
if (user.isAuthorized(value.get("permission")))
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals("")))
{
if (user.isAuthorized(value.get("permissions")))
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
else if (user.isAuthorized("essentials.help." + pluginName))
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
else
{
if (!ess.getSettings().hidePermissionlessHelp())
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
}
}
}
catch (NullPointerException ex)
{
continue;
}
if (p.getDescription().getName().toLowerCase().contains("essentials"))
{
final String node = "essentials." + k.getKey();
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
{
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description"));
}
}
else
{
if (ess.getSettings().showNonEssCommandsInHelp())
{
pluginName = p.getDescription().getName();
final HashMap<String, String> value = k.getValue();
if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals("")))
{
if (user.isAuthorized(value.get("permission")))
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals("")))
{
if (user.isAuthorized(value.get("permissions")))
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
else
{
if (!ess.getSettings().hidePermissionlessHelp())
{
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
}
}
}
}
}
}
catch (NullPointerException ex)

View File

@ -46,7 +46,7 @@ public class Commanditem extends EssentialsCommand
return;
}
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
charge(user);
user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName));
user.getInventory().addItem(stack);

View File

@ -1,9 +1,11 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.entity.Player;
public class Commandkick extends EssentialsCommand
@ -21,15 +23,24 @@ public class Commandkick extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
User u = getPlayer(server, args, 0);
if (u.isAuthorized("essentials.kick.exempt"))
User player = getPlayer(server, args, 0);
if (player.isAuthorized("essentials.kick.exempt"))
{
sender.sendMessage(Util.i18n("kickExempt"));
return;
}
charge(sender);
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
u.kickPlayer(kickReason);
server.broadcastMessage(Util.format("playerKicked", u.getName(), kickReason));
player.kickPlayer(kickReason);
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if(u.isAuthorized("essentials.kick.notify"))
{
p.sendMessage(Util.format("playerKicked", senderName, player.getName(), kickReason));
}
}
}
}

View File

@ -25,6 +25,16 @@ public class Commandmsg extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
if (sender instanceof Player)
{
User user = ess.getUser(sender);
if (user.isMuted())
{
user.sendMessage(Util.i18n("voiceSilenced"));
return;
}
}
String message = getFinalArg(args, 1);
String translatedMe = Util.i18n("me");
@ -48,7 +58,7 @@ public class Commandmsg extends EssentialsCommand
sender.sendMessage(Util.i18n("playerNotFound"));
return;
}
int i = 0;
for (Player p : matches)
{

View File

@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandpay extends EssentialsCommand
@ -22,6 +23,7 @@ public class Commandpay extends EssentialsCommand
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
Boolean foundUser = false;
for (Player p : server.matchPlayer(args[0]))
{
User u = ess.getUser(p);
@ -30,6 +32,11 @@ public class Commandpay extends EssentialsCommand
continue;
}
user.payUser(u, amount);
foundUser = true;
}
if(foundUser == false) {
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
}
}

View File

@ -0,0 +1,275 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.DescParseTickFormat;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class Commandptime extends EssentialsCommand
{
// TODO: I suggest that the chat colors be centralized in the config file.
public static final ChatColor colorDefault = ChatColor.YELLOW;
public static final ChatColor colorChrome = ChatColor.GOLD;
public static final ChatColor colorLogo = ChatColor.GREEN;
public static final ChatColor colorHighlight1 = ChatColor.AQUA;
public static final ChatColor colorBad = ChatColor.RED;
public static final Set<String> getAliases = new HashSet<String>();
static
{
getAliases.add("get");
getAliases.add("list");
getAliases.add("show");
getAliases.add("display");
}
public Commandptime()
{
super("ptime");
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
// Which Players(s) / Users(s) are we interested in?
String userSelector = null;
if (args.length == 2)
{
userSelector = args[1];
}
Set<User> users = getUsers(server, sender, userSelector);
// If no arguments we are reading the time
if (args.length == 0)
{
getUsersTime(sender, users);
return;
}
User user = ess.getUser(sender);
if (user != null && !user.isAuthorized("essentials.ptime.others"))
{
// TODO should not be hardcoded !!
throw new Exception(colorBad + "You are not authorized to set others PlayerTime");
}
Long ticks;
// Parse the target time int ticks from args[0]
String timeParam = args[0];
Boolean relative = true;
if (timeParam.startsWith("@"))
{
relative = false;
timeParam = timeParam.substring(1);
}
if (getAliases.contains(timeParam))
{
getUsersTime(sender, users);
return;
}
else if (DescParseTickFormat.meansReset(timeParam))
{
ticks = null;
}
else
{
try
{
ticks = DescParseTickFormat.parse(timeParam);
}
catch (NumberFormatException e)
{
throw new NotEnoughArgumentsException();
}
}
setUsersTime(sender, users, ticks, relative);
}
/**
* Used to get the time and inform
*/
private void getUsersTime(final CommandSender sender, final Collection<User> users)
{
if (users.size() == 1)
{
final User user = users.iterator().next();
if (user.getPlayerTimeOffset() == 0)
{
sender.sendMessage(colorDefault + user.getName() + "'s time is normal. Time is the same as on the server.");
}
else
{
String time = DescParseTickFormat.format(user.getPlayerTime());
if (!user.isPlayerTimeRelative())
{
time = "fixed to " + time;
}
sender.sendMessage(colorDefault + user.getName() + "'s time is " + time);
}
return;
}
sender.sendMessage(colorDefault + "These players have their own time:");
for (User user : users)
{
//if (!user.isPlayerTimeRelative())
if (user.getPlayerTimeOffset() != 0)
{
String time = DescParseTickFormat.format(user.getPlayerTime());
if (!user.isPlayerTimeRelative())
{
time = "fixed to " + time;
}
sender.sendMessage(colorDefault + user.getName() + "'s time is " + time);
}
}
return;
}
/**
* Used to set the time and inform of the change
*/
private void setUsersTime(final CommandSender sender, final Collection<User> users, final Long ticks, Boolean relative)
{
// Update the time
if (ticks == null)
{
// Reset
for (User user : users)
{
user.resetPlayerTime();
}
}
else
{
// Set
for (User user : users)
{
final World world = user.getWorld();
long time = user.getPlayerTime();
time -= time % 24000;
time += 24000 + ticks;
if (relative)
{
time -= world.getTime();
}
user.setPlayerTime(time, relative);
}
}
// Inform the sender of the change
sender.sendMessage("");
final StringBuilder msg = new StringBuilder();
if (ticks == null)
{
sender.sendMessage(colorDefault + "The players time was reset for:");
}
else
{
String time = DescParseTickFormat.format(ticks);
if (!relative)
{
time = "fixed to " + time;
}
sender.sendMessage(colorDefault + "The players time is " + time);
msg.append(colorDefault);
msg.append("For: ");
}
boolean first = true;
for (User user : users)
{
if (!first)
{
msg.append(colorDefault);
msg.append(", ");
}
else
{
first = false;
}
msg.append(colorHighlight1);
msg.append(user.getName());
}
sender.sendMessage(msg.toString());
}
/**
* Used to parse an argument of the type "users(s) selector"
*/
private Set<User> getUsers(final Server server, final CommandSender sender, final String selector) throws Exception
{
final Set<User> users = new TreeSet<User>(new UserNameComparator());
// If there is no selector we want the sender itself. Or all users if sender isn't a user.
if (selector == null)
{
final User user = ess.getUser(sender);
if (user == null)
{
for (Player player : server.getOnlinePlayers())
{
users.add(ess.getUser(player));
}
}
else
{
users.add(user);
}
return users;
}
// Try to find the user with name = selector
User user = null;
final List<Player> matchedPlayers = server.matchPlayer(selector);
if (!matchedPlayers.isEmpty())
{
user = ess.getUser(matchedPlayers.get(0));
}
if (user != null)
{
users.add(user);
}
// If that fails, Is the argument something like "*" or "all"?
else if (selector.equalsIgnoreCase("*") || selector.equalsIgnoreCase("all"))
{
for (Player player : server.getOnlinePlayers())
{
users.add(ess.getUser(player));
}
}
// We failed to understand the world target...
else
{
throw new Exception("Could not find the player(s) \"" + selector + "\"");
}
return users;
}
}
class UserNameComparator implements Comparator<User>
{
public int compare(User a, User b)
{
return a.getName().compareTo(b.getName());
}
}

View File

@ -30,7 +30,7 @@ public class Commandseen extends EssentialsCommand
User u = ess.getOfflineUser(args[0]);
if (u == null)
{
return;
throw new Exception(Util.i18n("playerNotFound"));
}
sender.sendMessage(Util.format("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
}

View File

@ -30,6 +30,10 @@ public class Commandsethome extends EssentialsCommand
{
usersHome = ess.getOfflineUser(args[0]);
}
if (usersHome == null)
{
throw new Exception(Util.i18n("playerNotFound"));
}
usersHome.setHome(user.getLocation(), args[1].equalsIgnoreCase("default"));
}
}

View File

@ -33,7 +33,10 @@ public class Commandspawner extends EssentialsCommand
charge(user);
try
{
final String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase();
String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase();
if (name.equalsIgnoreCase("Pigzombie")) {
name = "PigZombie";
}
new CraftCreatureSpawner(target).setCreatureType(CreatureType.fromName(name));
}
catch (Throwable ex)

View File

@ -7,6 +7,7 @@ import com.earth2me.essentials.Mob;
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;
@ -207,7 +208,15 @@ public class Commandspawnmob extends EssentialsCommand
{
try
{
((CraftSheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase()));
if (data.equalsIgnoreCase("random"))
{
Random rand = new Random();
((CraftSheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
}
else
{
((CraftSheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase()));
}
}
catch (Exception e)
{

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.Console;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -48,6 +49,15 @@ public class Commandtempban extends EssentialsCommand
player.setBanTimeout(banTimestamp);
player.kickPlayer(banReason);
ess.getBans().banByName(player.getName());
server.broadcastMessage(Util.format("playerBanned", player.getName(), banReason));
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
for(Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if(u.isAuthorized("essentials.ban.notify"))
{
p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason));
}
}
}
}

View File

@ -1,113 +1,175 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.DescParseTickFormat;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.*;
import org.bukkit.ChatColor;
public class Commandtime extends EssentialsCommand
{
// TODO: I suggest that the chat colors be centralized in the config file.
public static final ChatColor colorDefault = ChatColor.YELLOW;
public static final ChatColor colorChrome = ChatColor.GOLD;
public static final ChatColor colorLogo = ChatColor.GREEN;
public static final ChatColor colorHighlight1 = ChatColor.AQUA;
public static final ChatColor colorBad = ChatColor.RED;
public Commandtime()
{
super("time");
}
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
// Which World(s) are we interested in?
String worldSelector = null;
if (args.length == 2)
{
worldSelector = args[1];
}
Set<World> worlds = getWorlds(server, sender, worldSelector);
// If no arguments we are reading the time
if (args.length == 0)
{
getWorldsTime(sender, worlds);
return;
}
User user = ess.getUser(sender);
if (user != null && !user.isAuthorized("essentials.time.set"))
{
// TODO should not be hardcoded !!
throw new Exception(colorBad + "You are not authorized to set the time");
}
// Parse the target time int ticks from args[0]
long ticks;
try
{
ticks = DescParseTickFormat.parse(args[0]);
}
catch (NumberFormatException e)
{
throw new NotEnoughArgumentsException();
}
if (args.length < 2)
{
if (user.isAuthorized("essentials.time.world"))
{
final World world = user.getWorld();
charge(user);
setWorldTime(world, args[0]);
setWorldsTime(sender, worlds, ticks);
}
/**
* Used to get the time and inform
*/
private void getWorldsTime(CommandSender sender, Collection<World> worlds)
{
// TODO do we need to check for the essentials.time permission? Or is that tested for us already.
if (worlds.size() == 1)
{
Iterator<World> iter = worlds.iterator();
sender.sendMessage(DescParseTickFormat.format(iter.next().getTime()));
return;
}
for (World world : worlds)
{
sender.sendMessage(colorDefault + world.getName() + ": " + DescParseTickFormat.format(world.getTime()));
}
return;
}
/**
* Used to set the time and inform of the change
*/
private void setWorldsTime(CommandSender sender, Collection<World> worlds, long ticks)
{
// Update the time
for (World world : worlds)
{
long time = world.getTime();
time -= time % 24000;
world.setTime(time + 24000 + ticks);
}
// Inform the sender of the change
sender.sendMessage("");
sender.sendMessage(colorDefault + "The time was set to " + DescParseTickFormat.format(ticks));
StringBuilder msg = new StringBuilder();
msg.append(colorDefault);
msg.append("In ");
boolean first = true;
for (World world : worlds)
{
if (!first)
{
msg.append(colorDefault);
msg.append(", ");
}
else
{
charge(user);
setPlayerTime(user, args[0]);
first = false;
}
msg.append(colorHighlight1);
msg.append(world.getName());
}
sender.sendMessage(msg.toString());
}
/**
* Used to parse an argument of the type "world(s) selector"
*/
private Set<World> getWorlds(Server server, CommandSender sender, String selector) throws Exception
{
Set<World> worlds = new TreeSet<World>(new WorldNameComparator());
// If there is no selector we want the world the user is currently in. Or all worlds if it isn't a user.
if (selector == null)
{
User user = ess.getUser(sender);
if (user == null)
{
worlds.addAll(server.getWorlds());
}
else
{
worlds.add(user.getWorld());
}
return worlds;
}
// Try to find the world with name = selector
World world = server.getWorld(selector);
if (world != null)
{
worlds.add(world);
}
// If that fails, Is the argument something like "*" or "all"?
else if (selector.equalsIgnoreCase("*") || selector.equalsIgnoreCase("all"))
{
worlds.addAll(server.getWorlds());
}
// We failed to understand the world target...
else
{
if (user.isAuthorized("essentials.time.others"))
{
User u = getPlayer(server, args, 1);
charge(user);
setPlayerTime(u, args[0]);
}
}
}
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
if (args.length < 2)
{
for (World world : server.getWorlds())
{
setWorldTime(world, args[0]);
}
}
else
{
User u = getPlayer(server, args, 1);
setPlayerTime(u, args[0]);
throw new Exception("Could not find the world(s) \"" + selector + "\"");
}
sender.sendMessage(Util.i18n("timeSet"));
}
private void setWorldTime(final World world, final String timeString) throws Exception
{
long time = world.getTime();
time -= time % 24000;
if ("day".equalsIgnoreCase(timeString))
{
world.setTime(time + 24000);
return;
}
if ("night".equalsIgnoreCase(timeString))
{
world.setTime(time + 37700);
return;
}
throw new Exception(Util.i18n("onlyDayNight"));
}
private void setPlayerTime(final User user, final String timeString) throws Exception
{
long time = user.getPlayerTime();
time -= time % 24000;
if ("day".equalsIgnoreCase(timeString))
{
final World world = user.getWorld();
user.setPlayerTime(time + 24000 - world.getTime(), true);
return;
}
if ("night".equalsIgnoreCase(timeString))
{
final World world = user.getWorld();
user.setPlayerTime(time + 37700 - world.getTime(), true);
return;
}
if ("reset".equalsIgnoreCase(timeString))
{
user.resetPlayerTime();
return;
}
throw new Exception(Util.i18n("onlyDayNight"));
return worlds;
}
}
class WorldNameComparator implements Comparator<World>
{
public int compare(World a, World b)
{
return a.getName().compareTo(b.getName());
}
}

View File

@ -71,7 +71,7 @@ public class Commandtogglejail extends EssentialsCommand
return;
}
if (args.length == 2 && p.isJailed() && !args[1].equalsIgnoreCase(p.getJail()))
if (args.length >= 2 && p.isJailed() && !args[1].equalsIgnoreCase(p.getJail()))
{
sender.sendMessage("§cPerson is already in jail " + p.getJail());
return;

View File

@ -0,0 +1,62 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandtpaall extends EssentialsCommand
{
public Commandtpaall()
{
super("tpaall");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
if (sender instanceof Player)
{
charge(sender);
teleportAAllPlayers(server, sender, ess.getUser(sender));
return;
}
throw new NotEnoughArgumentsException();
}
User p = getPlayer(server, args, 0);
charge(sender);
teleportAAllPlayers(server, sender, p);
}
private void teleportAAllPlayers(Server server, CommandSender sender, User p)
{
sender.sendMessage(Util.i18n("teleportAAll"));
for (Player player : server.getOnlinePlayers())
{
User u = ess.getUser(player);
if (p == u)
{
continue;
}
if (!u.isTeleportEnabled())
{
continue;
}
try
{
u.requestTeleport(p, true);
u.sendMessage(Util.format("teleportHereRequest", p.getDisplayName()));
u.sendMessage(Util.i18n("typeTpaccept"));
}
catch (Exception ex)
{
ess.showError(sender, ex, getName());
}
}
}
}

View File

@ -33,7 +33,7 @@ public class Commandtpaccept extends EssentialsCommand
charge.isAffordableFor(p);
}
user.sendMessage(Util.i18n("requestAccepted"));
p.sendMessage(Util.i18n("requestAccepted"));
p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
if (user.isTeleportRequestHere())
{

View File

@ -23,7 +23,7 @@ public class Commandtpdeny extends EssentialsCommand
charge(user);
user.sendMessage(Util.i18n("requestDenied"));
p.sendMessage(Util.i18n("requestDenied"));
p.sendMessage(Util.format("requestDeniedFrom", user.getDisplayName()));
user.requestTeleport(null, false);
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@ -21,9 +22,23 @@ public class Commandtpo extends EssentialsCommand
}
//Just basically the old tp command
User p = getPlayer(server, args, 0);
charge(user);
user.getTeleport().now(p, false);
user.sendMessage(Util.i18n("teleporting"));
User p = getPlayer(server, args, 0, true);
// Check if user is offline
if (p.getBase() instanceof OfflinePlayer)
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
// Verify permission
if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
{
charge(user);
user.getTeleport().now(p, false);
user.sendMessage(Util.i18n("teleporting"));
}
else
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
@ -21,9 +22,24 @@ public class Commandtpohere extends EssentialsCommand
}
//Just basically the old tphere command
User p = getPlayer(server, args, 0);
charge(user);
p.getTeleport().now(user, false);
user.sendMessage(Util.i18n("teleporting"));
User p = getPlayer(server, args, 0, true);
// Check if user is offline
if (p.getBase() instanceof OfflinePlayer)
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
// Verify permission
if (!p.isHidden() || user.isAuthorized("essentials.teleport.hidden"))
{
charge(user);
p.getTeleport().now(user, false);
user.sendMessage(Util.i18n("teleporting"));
}
else
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
}
}

View File

@ -20,9 +20,18 @@ public class Commandunban extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
User u = getPlayer(server, args, 0, true);
ess.getBans().unbanByName(u.getName());
String name;
try
{
User u = getPlayer(server, args, 0, true);
name = u.getName();
}
catch (NoSuchFieldException e)
{
name = args[0];
}
ess.getBans().unbanByName(name);
sender.sendMessage(Util.i18n("unbannedPlayer"));
}
}

View File

@ -33,63 +33,90 @@ public class Commandunlimited extends EssentialsCommand
if (args[0].equalsIgnoreCase("list"))
{
StringBuilder sb = new StringBuilder();
sb.append(Util.i18n("unlimitedItems")).append(" ");
boolean first = true;
List<Integer> items = target.getUnlimited();
if (items.isEmpty())
String list = getList(target);
user.sendMessage(list);
}
else if (args[0].equalsIgnoreCase("clear"))
{
List<Integer> itemList = target.getUnlimited();
int index = 0;
while (itemList.size() > index)
{
sb.append(Util.i18n("none"));
}
for (Integer integer : items)
{
if (!first)
Integer item = itemList.get(index);
if (toggleUnlimited(user, target, item.toString()) == false)
{
sb.append(", ");
index++;
}
first = false;
String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "");
sb.append(matname);
}
user.sendMessage(sb.toString());
return;
}
else
{
toggleUnlimited(user, target, args[0]);
}
}
private String getList(User target)
{
StringBuilder sb = new StringBuilder();
sb.append(Util.i18n("unlimitedItems")).append(" ");
boolean first = true;
List<Integer> items = target.getUnlimited();
if (items.isEmpty())
{
sb.append(Util.i18n("none"));
}
for (Integer integer : items)
{
if (!first)
{
sb.append(", ");
}
first = false;
String matname = Material.getMaterial(integer).toString().toLowerCase().replace("_", "");
sb.append(matname);
}
final ItemStack stack = ess.getItemDb().get(args[0], 1);
return sb.toString();
}
private Boolean toggleUnlimited(User user, User target, String item) throws Exception
{
ItemStack stack = ess.getItemDb().get(item, 1);
stack.setAmount(Math.min(stack.getType().getMaxStackSize(), 2));
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
if (!user.isAuthorized("essentials.unlimited.item-all")
&& !user.isAuthorized("essentials.unlimited.item-" + itemname)
&& !user.isAuthorized("essentials.unlimited.item-" + stack.getTypeId())
&& !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET)
&& user.isAuthorized("essentials.unlimited.item-bucket")))
if (ess.getSettings().permissionBasedItemSpawn()
&& (!user.isAuthorized("essentials.unlimited.item-all")
&& !user.isAuthorized("essentials.unlimited.item-" + itemname)
&& !user.isAuthorized("essentials.unlimited.item-" + stack.getTypeId())
&& !((stack.getType() == Material.WATER_BUCKET || stack.getType() == Material.LAVA_BUCKET)
&& user.isAuthorized("essentials.unlimited.item-bucket"))))
{
user.sendMessage(Util.format("unlimitedItemPermission", itemname));
return;
return false;
}
if (target.hasUnlimited(stack))
String message = "disableUnlimited";
Boolean enableUnlimited = false;
if (!target.hasUnlimited(stack))
{
if (user != target)
message = "enableUnlimited";
enableUnlimited = true;
charge(user);
if (!InventoryWorkaround.containsItem(target.getInventory(), true, stack))
{
user.sendMessage(Util.format("disableUnlimited", itemname, target.getDisplayName()));
target.getInventory().addItem(stack);
}
target.sendMessage(Util.format("disableUnlimited", itemname, target.getDisplayName()));
target.setUnlimited(stack, false);
return;
}
charge(user);
if (user != target)
{
user.sendMessage(Util.format("enableUnlimited", itemname, target.getDisplayName()));
user.sendMessage(Util.format(message, itemname, target.getDisplayName()));
}
target.sendMessage(Util.format("enableUnlimited", itemname, target.getDisplayName()));
if (!InventoryWorkaround.containsItem(target.getInventory(), true, stack))
{
target.getInventory().addItem(stack);
}
target.setUnlimited(stack, true);
target.sendMessage(Util.format(message, itemname, target.getDisplayName()));
target.setUnlimited(stack, enableUnlimited);
return true;
}
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.Trade;
import java.util.List;
import org.bukkit.Server;
@ -15,16 +16,16 @@ import java.util.logging.Logger;
public abstract class EssentialsCommand implements IEssentialsCommand
{
private final String name;
protected IEssentials ess;
private final transient String name;
protected transient IEssentials ess;
protected final static Logger logger = Logger.getLogger("Minecraft");
protected EssentialsCommand(String name)
protected EssentialsCommand(final String name)
{
this.name = name;
}
public void setEssentials(IEssentials ess)
public void setEssentials(final IEssentials ess)
{
this.ess = ess;
}
@ -34,74 +35,72 @@ public abstract class EssentialsCommand implements IEssentialsCommand
return name;
}
protected User getPlayer(Server server, String[] args, int pos) throws NoSuchFieldException, NotEnoughArgumentsException
protected User getPlayer(final Server server, final String[] args, final int pos) throws NoSuchFieldException, NotEnoughArgumentsException
{
return getPlayer(server, args, pos, false);
}
protected User getPlayer(Server server, String[] args, int pos, boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException
protected User getPlayer(final Server server, final String[] args, final int pos, final boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException
{
if (args.length <= pos) throw new NotEnoughArgumentsException();
User user = ess.getAllUsers().get(args[pos].toLowerCase());
if (args.length <= pos)
{
throw new NotEnoughArgumentsException();
}
final User user = ess.getUser(args[pos]);
if (user != null)
{
if(!getOffline && (user.getBase() instanceof OfflinePlayer || user.isHidden()))
if (!getOffline && (user.getBase() instanceof OfflinePlayer || user.isHidden()))
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
return user;
}
List<Player> matches = server.matchPlayer(args[pos]);
if (matches.size() < 1)
{
if (!getOffline) throw new NoSuchFieldException(Util.i18n("playerNotFound"));
User u = ess.getOfflineUser(args[pos]);
if (u == null) throw new NoSuchFieldException(Util.i18n("playerNotFound"));
return u;
}
final List<Player> matches = server.matchPlayer(args[pos]);
for (Player p : matches)
if (!matches.isEmpty())
{
final User u = ess.getUser(p);
if (u.getDisplayName().startsWith(args[pos]) && (getOffline || !u.isHidden()))
for (Player player : matches)
{
return u;
final User userMatch = ess.getUser(player);
if (userMatch.getDisplayName().startsWith(args[pos]) && (getOffline || !userMatch.isHidden()))
{
return userMatch;
}
}
final User userMatch = ess.getUser(matches.get(0));
if (getOffline || !userMatch.isHidden())
{
return userMatch;
}
}
final User u = ess.getUser(matches.get(0));
if (!getOffline && u.isHidden())
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
return u;
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
@Override
public final void run(Server server, User user, String commandLabel, Command cmd, String[] args) throws Exception
public final void run(final Server server, final User user, final String commandLabel, final Command cmd, final String[] args) throws Exception
{
run(server, user, commandLabel, args);
}
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
run(server, (CommandSender)user.getBase(), commandLabel, args);
}
@Override
public final void run(Server server, CommandSender sender, String commandLabel, Command cmd, String[] args) throws Exception
public final void run(final Server server, final CommandSender sender, final String commandLabel, final Command cmd, final String[] args) throws Exception
{
run(server, sender, commandLabel, args);
}
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
throw new Exception(Util.format("onlyPlayers", commandLabel));
}
public static String getFinalArg(String[] args, int start)
public static String getFinalArg(final String[] args, final int start)
{
StringBuilder bldr = new StringBuilder();
final StringBuilder bldr = new StringBuilder();
for (int i = start; i < args.length; i++)
{
if (i != start)
@ -113,11 +112,11 @@ public abstract class EssentialsCommand implements IEssentialsCommand
return bldr.toString();
}
protected void charge(CommandSender sender) throws Exception
protected void charge(final CommandSender sender) throws ChargeException
{
if (sender instanceof Player)
{
Trade charge = new Trade(this.getName(), ess);
final Trade charge = new Trade(this.getName(), ess);
charge.charge(ess.getUser((Player)sender));
}
}

View File

@ -2,61 +2,184 @@ package com.earth2me.essentials.register.payment;
import org.bukkit.plugin.Plugin;
/**
* Method.java
* Interface for all sub-methods for payment.
*
* @author: Nijikokun<nijikokun@gmail.com> (@nijikokun)
* @copyright: Copyright (C) 2011
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright Copyright (C) 2011
* @license AOL license <http://aol.nexua.org>
*/
public interface Method {
public Object getPlugin();
public String getName();
public String getVersion();
public String format(double amount);
public boolean hasBanks();
public boolean hasBank(String bank);
public boolean hasAccount(String name);
public boolean hasBankAccount(String bank, String name);
public MethodAccount getAccount(String name);
public MethodBankAccount getBankAccount(String bank, String name);
public boolean isCompatible(Plugin plugin);
public void setPlugin(Plugin plugin);
public interface Method
{
/**
* Encodes the Plugin into an Object disguised as the Plugin.
* If you want the original Plugin Class you must cast it to the correct
* Plugin, to do so you have to verify the name and or version then cast.
*
* <pre>
* if(method.getName().equalsIgnoreCase("iConomy"))
* iConomy plugin = ((iConomy)method.getPlugin());</pre>
*
* @return <code>Object</code>
* @see #getName()
* @see #getVersion()
*/
public Object getPlugin();
public interface MethodAccount {
public double balance();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
/**
* Returns the actual name of this method.
*
* @return <code>String</code> Plugin name.
*/
public String getName();
@Override
public String toString();
}
/**
* Returns the actual version of this method.
*
* @return <code>String</code> Plugin version.
*/
public String getVersion();
public interface MethodBankAccount {
public double balance();
public String getBankName();
public int getBankId();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
/**
* Formats amounts into this payment methods style of currency display.
*
* @param amount Double
* @return <code>String</code> - Formatted Currency Display.
*/
public String format(double amount);
@Override
public String toString();
}
/**
* Allows the verification of bank API existence in this payment method.
*
* @return <code>boolean</code>
*/
public boolean hasBanks();
/**
* Determines the existence of a bank via name.
*
* @param bank Bank name
* @return <code>boolean</code>
* @see #hasBanks
*/
public boolean hasBank(String bank);
/**
* Determines the existence of an account via name.
*
* @param name Account name
* @return <code>boolean</code>
*/
public boolean hasAccount(String name);
/**
* Check to see if an account <code>name</code> is tied to a <code>bank</code>.
*
* @param bank Bank name
* @param name Account name
* @return <code>boolean</code>
*/
public boolean hasBankAccount(String bank, String name);
/**
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
*
* @param name Account name
* @return <code>MethodAccount</code> <em>or</em> <code>Null</code>
*/
public MethodAccount getAccount(String name);
/**
* Returns a <code>MethodBankAccount</code> class for an account <code>name</code>.
*
* @param bank Bank name
* @param name Account name
* @return <code>MethodBankAccount</code> <em>or</em> <code>Null</code>
*/
public MethodBankAccount getBankAccount(String bank, String name);
/**
* Checks to verify the compatibility between this Method and a plugin.
* Internal usage only, for the most part.
*
* @param plugin Plugin
* @return <code>boolean</code>
*/
public boolean isCompatible(Plugin plugin);
/**
* Set Plugin data.
*
* @param plugin Plugin
*/
public void setPlugin(Plugin plugin);
/**
* Contains Calculator and Balance functions for Accounts.
*/
public interface MethodAccount
{
public double balance();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
@Override
public String toString();
}
/**
* Contains Calculator and Balance functions for Bank Accounts.
*/
public interface MethodBankAccount
{
public double balance();
public String getBankName();
public int getBankId();
public boolean set(double amount);
public boolean add(double amount);
public boolean subtract(double amount);
public boolean multiply(double amount);
public boolean divide(double amount);
public boolean hasEnough(double amount);
public boolean hasOver(double amount);
public boolean hasUnder(double amount);
public boolean isNegative();
public boolean remove();
@Override
public String toString();
}
}

View File

@ -1,137 +1,271 @@
package com.earth2me.essentials.register.payment;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import java.util.HashSet;
import java.util.Set;
/**
* Methods.java
* Controls the getting / setting of methods & the method of payment used.
* The <code>Methods</code> initializes Methods that utilize the Method interface
* based on a "first come, first served" basis.
*
* @author: Nijikokun<nijikokun@gmail.com> (@nijikokun)
* Allowing you to check whether a payment method exists or not.
*
* <blockquote><pre>
* Methods methods = new Methods();
* </pre></blockquote>
*
* Methods also allows you to set a preferred method of payment before it captures
* payment plugins in the initialization process.
*
* <blockquote><pre>
* Methods methods = new Methods("iConomy");
* </pre></blockquote>
*
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright: Copyright (C) 2011
* @license: GNUv3 Affero License <http://www.gnu.org/licenses/agpl-3.0.html>
* @license: AOL license <http://aol.nexua.org>
*/
public class Methods {
private boolean self = false;
private Method Method = null;
private String preferred = "";
private Set<Method> Methods = new HashSet<Method>();
private Set<String> Dependencies = new HashSet<String>();
private Set<Method> Attachables = new HashSet<Method>();
public class Methods
{
private boolean self = false;
private Method Method = null;
private String preferred = "";
private Set<Method> Methods = new HashSet<Method>();
private Set<String> Dependencies = new HashSet<String>();
private Set<Method> Attachables = new HashSet<Method>();
public Methods() {
this._init();
}
/**
* Initialize Method class
*/
public Methods()
{
this._init();
}
/**
* Allows you to set which economy plugin is most preferred.
*
* @param preferred - preferred economy plugin
*/
public Methods(String preferred) {
this._init();
/**
* Initializes <code>Methods</code> class utilizing a "preferred" payment method check before
* returning the first method that was initialized.
*
* @param preferred Payment method that is most preferred for this setup.
*/
public Methods(String preferred)
{
this._init();
if(this.Dependencies.contains(preferred)) {
this.preferred = preferred;
}
}
if (this.Dependencies.contains(preferred))
{
this.preferred = preferred;
}
}
private void _init() {
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
}
/**
* Implement all methods along with their respective name & class.
*
* @see #Methods()
* @see #Methods(java.lang.String)
*/
private void _init()
{
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
this.addMethod("MultiCurrency", new com.earth2me.essentials.register.payment.methods.MCUR());
}
public Set<String> getDependencies() {
return Dependencies;
}
/**
* Returns an array of payment method names that have been loaded
* through the <code>_init</code> method.
*
* @return <code>Set<String></code> - Array of payment methods that are loaded.
* @see #setMethod(org.bukkit.plugin.Plugin)
*/
public Set<String> getDependencies()
{
return Dependencies;
}
public Method createMethod(Plugin plugin) {
for (Method method: Methods) {
if (method.isCompatible(plugin)) {
method.setPlugin(plugin);
return method;
}
}
/**
* Interprets Plugin class data to verify whether it is compatible with an existing payment
* method to use for payments and other various economic activity.
*
* @param plugin Plugin data from bukkit, Internal Class file.
* @return Method <em>or</em> Null
*/
public Method createMethod(Plugin plugin)
{
for (Method method : Methods)
{
if (method.isCompatible(plugin))
{
method.setPlugin(plugin);
return method;
}
}
return null;
}
return null;
}
private void addMethod(String name, Method method) {
Dependencies.add(name);
Methods.add(method);
}
private void addMethod(String name, Method method)
{
Dependencies.add(name);
Methods.add(method);
}
public boolean hasMethod() {
return (Method != null);
}
/**
* Verifies if Register has set a payment method for usage yet.
*
* @return <code>boolean</code>
* @see #setMethod(org.bukkit.plugin.Plugin)
* @see #checkDisabled(org.bukkit.plugin.Plugin)
*/
public boolean hasMethod()
{
return (Method != null);
}
public boolean setMethod(Plugin method) {
if(hasMethod()) return true;
if(self) { self = false; return false; }
/**
* Checks Plugin Class against a multitude of checks to verify it's usability
* as a payment method.
*
* @param method Plugin data from bukkit, Internal Class file.
* @return <code>boolean</code> True on success, False on failure.
*/
public boolean setMethod(Plugin method)
{
if (hasMethod())
{
return true;
}
if (self)
{
self = false;
return false;
}
int count = 0;
boolean match = false;
Plugin plugin;
PluginManager manager = method.getServer().getPluginManager();
int count = 0;
boolean match = false;
Plugin plugin = null;
PluginManager manager = method.getServer().getPluginManager();
for(String name: this.getDependencies()) {
if(hasMethod()) break;
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
if(plugin == null) continue;
for (String name : this.getDependencies())
{
if (hasMethod())
{
break;
}
if (method.getDescription().getName().equals(name))
{
plugin = method;
}
else
{
plugin = manager.getPlugin(name);
}
if (plugin == null)
{
continue;
}
Method current = this.createMethod(plugin);
if(current == null) continue;
Method current = this.createMethod(plugin);
if (current == null)
{
continue;
}
if(this.preferred.isEmpty())
this.Method = current;
else {
this.Attachables.add(current);
}
}
if (this.preferred.isEmpty())
{
this.Method = current;
}
else
{
this.Attachables.add(current);
}
}
if(!this.preferred.isEmpty()) {
do {
if(hasMethod()) {
match = true;
} else {
for(Method attached: this.Attachables) {
if(attached == null) continue;
if (!this.preferred.isEmpty())
{
do
{
if (hasMethod())
{
match = true;
}
else
{
for (Method attached : this.Attachables)
{
if (attached == null)
{
continue;
}
if(hasMethod()) {
match = true;
break;
}
if (hasMethod())
{
match = true;
break;
}
if(this.preferred.isEmpty()) this.Method = attached;
if (this.preferred.isEmpty())
{
this.Method = attached;
}
if(count == 0) {
if(this.preferred.equalsIgnoreCase(attached.getName()))
this.Method = attached;
} else {
this.Method = attached;
}
}
if (count == 0)
{
if (this.preferred.equalsIgnoreCase(attached.getName()))
{
this.Method = attached;
}
}
else
{
this.Method = attached;
}
}
count++;
}
} while(!match);
}
count++;
}
}
while (!match);
}
return hasMethod();
}
return hasMethod();
}
public Method getMethod() {
return Method;
}
/**
* Grab the existing and initialized (hopefully) Method Class.
*
* @return <code>Method</code> <em>or</em> <code>Null</code>
*/
public Method getMethod()
{
return Method;
}
public boolean checkDisabled(Plugin method) {
if(!hasMethod()) return true;
if (Method.isCompatible(method)) Method = null;
return (Method == null);
}
/**
* Verify is a plugin is disabled, only does this if we there is an existing payment
* method initialized in Register.
*
* @param method Plugin data from bukkit, Internal Class file.
* @return <code>boolean</code>
*/
public boolean checkDisabled(Plugin method)
{
if (!hasMethod())
{
return true;
}
if (Method.isCompatible(method))
{
Method = null;
}
return (Method == null);
}
}

View File

@ -4,6 +4,13 @@ import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
/**
* BOSEconomy 6 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class BOSE6 implements Method {
private BOSEconomy BOSEconomy;
@ -69,7 +76,7 @@ public class BOSE6 implements Method {
}
public double balance() {
return Double.valueOf(this.BOSEconomy.getPlayerMoney(this.name));
return (double) this.BOSEconomy.getPlayerMoney(this.name);
}
public boolean set(double amount) {
@ -122,8 +129,8 @@ public class BOSE6 implements Method {
}
public class BOSEBankAccount implements MethodBankAccount {
private String bank;
private BOSEconomy BOSEconomy;
private final String bank;
private final BOSEconomy BOSEconomy;
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;
@ -139,7 +146,7 @@ public class BOSE6 implements Method {
}
public double balance() {
return Double.valueOf(this.BOSEconomy.getBankMoney(bank));
return (double) this.BOSEconomy.getBankMoney(bank);
}
public boolean set(double amount) {

View File

@ -5,7 +5,12 @@ import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
/**
* BOSEconomy 7 Implementation of Method
*
* @author Acrobot
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class BOSE7 implements Method {

View File

@ -0,0 +1,120 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import me.ashtheking.currency.Currency;
import me.ashtheking.currency.CurrencyList;
import org.bukkit.plugin.Plugin;
/**
* MultiCurrency Method implementation.
*
* @author Acrobot
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class MCUR implements Method {
private Currency currencyList;
public Object getPlugin() {
return this.currencyList;
}
public String getName() {
return "MultiCurrency";
}
public String getVersion() {
return "0.09";
}
public String format(double amount) {
return amount + " Currency";
}
public boolean hasBanks() {
return false;
}
public boolean hasBank(String bank) {
return false;
}
public boolean hasAccount(String name) {
return true;
}
public boolean hasBankAccount(String bank, String name) {
return false;
}
public MethodAccount getAccount(String name) {
return new MCurrencyAccount(name);
}
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency;
}
public void setPlugin(Plugin plugin) {
currencyList = (Currency) plugin;
}
public class MCurrencyAccount implements MethodAccount{
private String name;
public MCurrencyAccount(String name) {
this.name = name;
}
public double balance() {
return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name);
}
public boolean set(double amount) {
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount);
return true;
}
public boolean add(double amount) {
return CurrencyList.add(name, amount);
}
public boolean subtract(double amount) {
return CurrencyList.subtract(name, amount);
}
public boolean multiply(double amount) {
return CurrencyList.multiply(name, amount);
}
public boolean divide(double amount) {
return CurrencyList.divide(name, amount);
}
public boolean hasEnough(double amount) {
return CurrencyList.hasEnough(name, amount);
}
public boolean hasOver(double amount) {
return CurrencyList.hasOver(name, amount);
}
public boolean hasUnder(double amount) {
return CurrencyList.hasUnder(name, amount);
}
public boolean isNegative() {
return CurrencyList.isNegative(name);
}
public boolean remove() {
return CurrencyList.remove(name);
}
}
}

View File

@ -7,6 +7,13 @@ import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin;
/**
* iConomy 4 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class iCo4 implements Method {
private iConomy iConomy;
@ -51,7 +58,7 @@ public class iCo4 implements Method {
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && !plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") && plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {

View File

@ -10,202 +10,291 @@ import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin;
public class iCo5 implements Method {
private iConomy iConomy;
public iConomy getPlugin() {
return this.iConomy;
}
/**
* iConomy 5 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class iCo5 implements Method
{
private iConomy iConomy;
public String getName() {
return "iConomy";
}
public iConomy getPlugin()
{
return this.iConomy;
}
public String getVersion() {
return "5";
}
public String getName()
{
return "iConomy";
}
public String format(double amount) {
return this.iConomy.format(amount);
}
public String getVersion()
{
return "5";
}
public boolean hasBanks() {
return Constants.Banking;
}
public String format(double amount)
{
return this.iConomy.format(amount);
}
public boolean hasBank(String bank) {
return (!hasBanks()) ? false : this.iConomy.Banks.exists(bank);
}
public boolean hasBanks()
{
return Constants.Banking;
}
public boolean hasAccount(String name) {
return this.iConomy.hasAccount(name);
}
public boolean hasBank(String bank)
{
return (hasBanks()) && this.iConomy.Banks.exists(bank);
}
public boolean hasBankAccount(String bank, String name) {
return (!hasBank(bank)) ? false : this.iConomy.getBank(bank).hasAccount(name);
}
public boolean hasAccount(String name)
{
return this.iConomy.hasAccount(name);
}
public MethodAccount getAccount(String name) {
return new iCoAccount(this.iConomy.getAccount(name));
}
public boolean hasBankAccount(String bank, String name)
{
return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name);
}
public MethodBankAccount getBankAccount(String bank, String name) {
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
}
public MethodAccount getAccount(String name)
{
return new iCoAccount(this.iConomy.getAccount(name));
}
public void setPlugin(Plugin plugin) {
iConomy = (iConomy)plugin;
}
public MethodBankAccount getBankAccount(String bank, String name)
{
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
}
public class iCoAccount implements MethodAccount {
private Account account;
private Holdings holdings;
public boolean isCompatible(Plugin plugin)
{
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
}
public iCoAccount(Account account) {
this.account = account;
this.holdings = account.getHoldings();
}
public void setPlugin(Plugin plugin)
{
iConomy = (iConomy)plugin;
}
public Account getiCoAccount() {
return account;
}
public double balance() {
return this.holdings.balance();
}
public class iCoAccount implements MethodAccount
{
private Account account;
private Holdings holdings;
public boolean set(double amount) {
if(this.holdings == null) return false;
this.holdings.set(amount);
return true;
}
public iCoAccount(Account account)
{
this.account = account;
this.holdings = account.getHoldings();
}
public boolean add(double amount) {
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public Account getiCoAccount()
{
return account;
}
public boolean subtract(double amount) {
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public double balance()
{
return this.holdings.balance();
}
public boolean multiply(double amount) {
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean set(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.set(amount);
return true;
}
public boolean divide(double amount) {
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
public boolean add(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.add(amount);
return true;
}
public boolean hasEnough(double amount) {
return this.holdings.hasEnough(amount);
}
public boolean subtract(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.subtract(amount);
return true;
}
public boolean hasOver(double amount) {
return this.holdings.hasOver(amount);
}
public boolean multiply(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.multiply(amount);
return true;
}
public boolean hasUnder(double amount) {
return this.holdings.hasUnder(amount);
}
public boolean divide(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.divide(amount);
return true;
}
public boolean isNegative() {
return this.holdings.isNegative();
}
public boolean hasEnough(double amount)
{
return this.holdings.hasEnough(amount);
}
public boolean remove() {
if(this.account == null) return false;
this.account.remove();
return true;
}
}
public boolean hasOver(double amount)
{
return this.holdings.hasOver(amount);
}
public class iCoBankAccount implements MethodBankAccount {
private BankAccount account;
private Holdings holdings;
public boolean hasUnder(double amount)
{
return this.holdings.hasUnder(amount);
}
public iCoBankAccount(BankAccount account) {
this.account = account;
this.holdings = account.getHoldings();
}
public boolean isNegative()
{
return this.holdings.isNegative();
}
public BankAccount getiCoBankAccount() {
return account;
}
public boolean remove()
{
if (this.account == null)
{
return false;
}
this.account.remove();
return true;
}
}
public String getBankName() {
return this.account.getBankName();
}
public int getBankId() {
return this.account.getBankId();
}
public class iCoBankAccount implements MethodBankAccount
{
private BankAccount account;
private Holdings holdings;
public double balance() {
return this.holdings.balance();
}
public iCoBankAccount(BankAccount account)
{
this.account = account;
this.holdings = account.getHoldings();
}
public boolean set(double amount) {
if(this.holdings == null) return false;
this.holdings.set(amount);
return true;
}
public BankAccount getiCoBankAccount()
{
return account;
}
public boolean add(double amount) {
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public String getBankName()
{
return this.account.getBankName();
}
public boolean subtract(double amount) {
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public int getBankId()
{
return this.account.getBankId();
}
public boolean multiply(double amount) {
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public double balance()
{
return this.holdings.balance();
}
public boolean divide(double amount) {
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
public boolean set(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.set(amount);
return true;
}
public boolean hasEnough(double amount) {
return this.holdings.hasEnough(amount);
}
public boolean add(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.add(amount);
return true;
}
public boolean hasOver(double amount) {
return this.holdings.hasOver(amount);
}
public boolean subtract(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.subtract(amount);
return true;
}
public boolean hasUnder(double amount) {
return this.holdings.hasUnder(amount);
}
public boolean multiply(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.multiply(amount);
return true;
}
public boolean isNegative() {
return this.holdings.isNegative();
}
public boolean divide(double amount)
{
if (this.holdings == null)
{
return false;
}
this.holdings.divide(amount);
return true;
}
public boolean remove() {
if(this.account == null) return false;
this.account.remove();
return true;
}
}
}
public boolean hasEnough(double amount)
{
return this.holdings.hasEnough(amount);
}
public boolean hasOver(double amount)
{
return this.holdings.hasOver(amount);
}
public boolean hasUnder(double amount)
{
return this.holdings.hasUnder(amount);
}
public boolean isNegative()
{
return this.holdings.isNegative();
}
public boolean remove()
{
if (this.account == null)
{
return false;
}
this.account.remove();
return true;
}
}
}

View File

@ -0,0 +1,142 @@
package com.earth2me.essentials.register.payment.methods;
import com.iCo6.iConomy;
import com.iCo6.system.Account;
import com.iCo6.system.Accounts;
import com.iCo6.system.Holdings;
import com.earth2me.essentials.register.payment.Method;
import org.bukkit.plugin.Plugin;
/**
* iConomy 6 Implementation of Method
*
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
public class iCo6 implements Method {
private iConomy iConomy;
public iConomy getPlugin() {
return this.iConomy;
}
public String getName() {
return "iConomy";
}
public String getVersion() {
return "6";
}
public String format(double amount) {
return this.iConomy.format(amount);
}
public boolean hasBanks() {
return false;
}
public boolean hasBank(String bank) {
return false;
}
public boolean hasAccount(String name) {
return (new Accounts()).exists(name);
}
public boolean hasBankAccount(String bank, String name) {
return false;
}
public MethodAccount getAccount(String name) {
return new iCoAccount((new Accounts()).get(name));
}
public MethodBankAccount getBankAccount(String bank, String name) {
return null;
}
public boolean isCompatible(Plugin plugin) {
try { Class.forName("com.iCo6.IO"); }
catch(Exception e) { return false; }
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iCo6.iConomy") && plugin instanceof iConomy;
}
public void setPlugin(Plugin plugin) {
iConomy = (iConomy)plugin;
}
public class iCoAccount implements MethodAccount {
private Account account;
private Holdings holdings;
public iCoAccount(Account account) {
this.account = account;
this.holdings = account.getHoldings();
}
public Account getiCoAccount() {
return account;
}
public double balance() {
return this.holdings.getBalance();
}
public boolean set(double amount) {
if(this.holdings == null) return false;
this.holdings.setBalance(amount);
return true;
}
public boolean add(double amount) {
if(this.holdings == null) return false;
this.holdings.add(amount);
return true;
}
public boolean subtract(double amount) {
if(this.holdings == null) return false;
this.holdings.subtract(amount);
return true;
}
public boolean multiply(double amount) {
if(this.holdings == null) return false;
this.holdings.multiply(amount);
return true;
}
public boolean divide(double amount) {
if(this.holdings == null) return false;
this.holdings.divide(amount);
return true;
}
public boolean hasEnough(double amount) {
return this.holdings.hasEnough(amount);
}
public boolean hasOver(double amount) {
return this.holdings.hasOver(amount);
}
public boolean hasUnder(double amount) {
return this.holdings.hasUnder(amount);
}
public boolean isNegative() {
return this.holdings.isNegative();
}
public boolean remove() {
if(this.account == null) return false;
this.account.remove();
return true;
}
}
}

View File

@ -33,13 +33,15 @@ public class EssentialsSign
public final boolean onSignCreate(final SignChangeEvent event, final IEssentials ess)
{
final ISign sign = new EventSign(event);
sign.setLine(0, String.format(FORMAT_FAIL, this.signName));
final User user = ess.getUser(event.getPlayer());
if (!(user.isAuthorized("essentials.signs." + signName.toLowerCase() + ".create")
|| user.isAuthorized("essentials.signs.create." + signName.toLowerCase())))
{
return false;
// Return true, so other plugins can use the same sign title, just hope
// they won't change it to §1[Signname]
return true;
}
sign.setLine(0, String.format(FORMAT_FAIL, this.signName));
try
{
final boolean ret = onSignCreate(sign, user, getUsername(user), ess);
@ -57,7 +59,8 @@ public class EssentialsSign
{
ess.showError(user, ex, signName);
}
return false;
// Return true, so the player sees the wrong sign.
return true;
}
public String getSuccessName()
@ -72,7 +75,7 @@ public class EssentialsSign
private String getUsername(final User user)
{
return user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
return user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
}
public final boolean onSignInteract(final Block block, final Player player, final IEssentials ess)
@ -196,7 +199,8 @@ public class EssentialsSign
public static boolean checkIfBlockBreaksSigns(final Block block)
{
if (block.getRelative(BlockFace.UP).getType() == Material.SIGN_POST)
final Block sign = block.getRelative(BlockFace.UP);
if (sign.getType() == Material.SIGN_POST && isValidSign(new BlockSign(sign)))
{
return true;
}
@ -212,8 +216,8 @@ public class EssentialsSign
final Block signblock = block.getRelative(blockFace);
if (signblock.getType() == Material.WALL_SIGN)
{
final org.bukkit.material.Sign sign = (org.bukkit.material.Sign)signblock.getState().getData();
if (sign.getFacing() == blockFace)
final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData();
if (signMat.getFacing() == blockFace && isValidSign(new BlockSign(signblock)))
{
return true;
}
@ -222,6 +226,11 @@ public class EssentialsSign
return false;
}
public static boolean isValidSign(final ISign sign)
{
return sign.getLine(0).matches("§1\\[.*\\]");
}
protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
{
return true;

View File

@ -122,8 +122,9 @@ public class SignBlockListener extends BlockListener
}
final Block against = event.getBlockAgainst();
if (against.getType() == Material.WALL_SIGN
|| against.getType() == Material.SIGN_POST)
if ((against.getType() == Material.WALL_SIGN
|| against.getType() == Material.SIGN_POST)
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(against)))
{
event.setCancelled(true);
return;
@ -155,9 +156,10 @@ public class SignBlockListener extends BlockListener
}
final Block block = event.getBlock();
if ((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST
|| EssentialsSign.checkIfBlockBreaksSigns(block)))
if (((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST)
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|| EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;
@ -189,13 +191,14 @@ public class SignBlockListener extends BlockListener
}
@Override
public void onBlockPistonExtend(BlockPistonExtendEvent event)
public void onBlockPistonExtend(final BlockPistonExtendEvent event)
{
for (Block block : event.getBlocks())
{
if ((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST
|| EssentialsSign.checkIfBlockBreaksSigns(block)))
if (((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST)
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|| EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;
@ -214,14 +217,15 @@ public class SignBlockListener extends BlockListener
}
@Override
public void onBlockPistonRetract(BlockPistonRetractEvent event)
public void onBlockPistonRetract(final BlockPistonRetractEvent event)
{
if (event.isSticky())
{
final Block block = event.getBlock();
if ((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST
|| EssentialsSign.checkIfBlockBreaksSigns(block)))
if (((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST)
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|| EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;

View File

@ -11,20 +11,20 @@ public class SignEntityListener extends EntityListener
{
private final transient IEssentials ess;
public SignEntityListener(IEssentials ess)
public SignEntityListener(final IEssentials ess)
{
this.ess = ess;
}
@Override
public void onEntityExplode(EntityExplodeEvent event)
public void onEntityExplode(final EntityExplodeEvent event)
{
for (Block block : event.blockList())
{
if ((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST
|| EssentialsSign.checkIfBlockBreaksSigns(block)))
if (((block.getType() == Material.WALL_SIGN
|| block.getType() == Material.SIGN_POST)
&& EssentialsSign.isValidSign(new EssentialsSign.BlockSign(block)))
|| EssentialsSign.checkIfBlockBreaksSigns(block))
{
event.setCancelled(true);
return;

View File

@ -40,7 +40,9 @@ change-displayname: true
# Adds the prefix and suffix to the displayname of the player, so it will be displayed in messages and lists.
# The prefix/suffix can be set using Permissions, Group Manager or PermissionsEx.
# The value of change-displayname (above) has to be true.
add-prefix-suffix: false
# If you don't set this, it will default to true if essentials chat is installed.
# Don't forget to remove the # infront of the line
#add-prefix-suffix: false
# The delay, in seconds, required between /home, /tp, etc.
teleport-cooldown: 0
@ -284,6 +286,9 @@ economy-log-enabled: false
non-ess-in-help: true
#Hide plugins which dont give a permission
#You can override a true value here for a single plugin by adding a permission to a user/group.
#The indervidual permission is: essentials.help.<plugin>, anyone with essentials.* or '*' will see all help this setting reguardless.
#You can use negitive permissions to remove access to just a single plugins help if the following is enabled.
hide-permissionless-help: true
############################################################
@ -296,6 +301,7 @@ hide-permissionless-help: true
# Note that users with the "essentials.chat.spy" permission will hear everything, regardless of this setting.
# Users with essentials.chat.shout can override this by prefixing text with an exclamation mark (!)
# Or with essentials.chat.question can override this by prefixing text with a question mark (?)
# You can add command costs for shout/question by adding chat-shout and chat-question to the command costs section."
chat:
radius: 0
@ -481,6 +487,7 @@ newbies:
announce-format: '&dWelcome {DISPLAYNAME} to the server!'
# When we spawn for the first time, which spawnpoint do we use?
# Set to "none" if you want to use the spawn point of the world.
spawnpoint: newbies
# End of File <-- No seriously, you're done with configuration.

View File

@ -211,11 +211,11 @@ onlySunStorm = /weather only supports sun/storm.
parseError = Error parsing {0} on line {1}
pendingTeleportCancelled = \u00a7cPending teleportation request cancelled.
permissionsError = Missing Permissions/GroupManager; chat prefixes/suffixes will be disabled.
playerBanned = \u00a7cPlayer {0} banned: {1}
playerBanned = \u00a7cPlayer {0} banned {1} for {2}
playerInJail = \u00a7cPlayer is already in jail {0}.
playerJailed = \u00a77Player {0} jailed.
playerJailedFor = \u00a77Player {0} jailed for {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerKicked = \u00a7cPlayer {0} kicked {1} for {2}
playerMuted = \u00a77You have been muted
playerMutedFor = \u00a77You have been muted for {0}
playerNeverOnServer = \u00a7cPlayer {0} was never on this server.
@ -230,7 +230,9 @@ protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0}
questionFormat = \u00a77[Question]\u00a7f {0}
reloadAllPlugins = \u00a77Reloaded all plugins.
requestAccepted = \u00a77Teleport request accepted.
requestAcceptedFrom = \u00a77{0} accepted your teleport request.
requestDenied = \u00a77Teleport request denied.
requestDeniedFrom = \u00a77{0} denied your teleport request.
requestSent = \u00a77Request sent to {0}\u00a77.
returnPlayerToJailError = Error occured when trying to return player to jail.
second = second
@ -249,10 +251,11 @@ suicideMessage = \u00a77Goodbye Cruel World...
suicideSuccess = \u00a77{0} took their own life
takenFromAccount = \u00a7c{0} has been taken from your account.
takenFromOthersAccount = \u00a7c{0} has been taken from {1} account.
teleportAAll = \u00a77Teleporting request sent to all players...
teleportAll = \u00a77Teleporting all players...
teleportAtoB = \u00a77{0}\u00a77 teleported you to {1}\u00a77.
teleportDisabled = {0} has teleportation disabled.
teleportHereRequest = \u00a7c{0}\u00a7c has requested that you teleport to him/her.
teleportHereRequest = \u00a7c{0}\u00a7c has requested that you teleport to them.
teleportNewPlayerError = Failed to teleport new player
teleportRequest = \u00a7c{0}\u00a7c has requested to teleport to you.
teleportTop = \u00a77Teleporting to top.

View File

@ -213,11 +213,11 @@ onlySunStorm = /weather only supports sun/storm.
parseError = Fejl ved parsing {0} p\u00e5 linje {1}
pendingTeleportCancelled = \u00a7cVentende teleportations anmodning aflyst.
permissionsError = Mangler Permissions/GroupManager; chat pr\u00e6fikser/suffikser vil v\u00e6re sl\u00e5et fra.
playerBanned = \u00a7cSpiller {0} bannet: {1}
playerBanned = \u00a7cPlayer {0} banned {1} for {2}
playerInJail = \u00a7cSpiller er allerede i f\u00e6ngsel {0}.
playerJailed = \u00a77Spiller {0} f\u00e6ngslet.
playerJailedFor = \u00a77Spiller {0} f\u00e6ngslet for {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerKicked = \u00a7cPlayer {0} kicked {1} for {2}
playerMuted = \u00a77You have been muted
playerMutedFor = \u00a77You have been muted for {0}
playerNeverOnServer = \u00a7cSpiller {0} var aldrig p\u00e5 denne server.

View File

@ -211,11 +211,11 @@ onlySunStorm = /weather unterst\u00fctzt nur sun/storm.
parseError = Fehler beim Parsen von {0} in Zeile {1}
pendingTeleportCancelled = \u00a7cLaufende Teleportierung abgebrochen.
permissionsError = Permissions/GroupManager fehlt; Chat-Prefixe/-Suffixe sind ausgeschaltet.
playerBanned = \u00a7cSpieler {0} gesperrt: {1}
playerBanned = \u00a7cPlayer {0} banned {1} for {2}
playerInJail = \u00a7cSpieler ist bereits in Gef\u00e4ngnis {0}.
playerJailed = \u00a77Spieler {0} eingesperrt.
playerJailedFor = \u00a77Spieler {0} eingesperrt f\u00fcr {1}.
playerKicked = \u00a7cSpieler {0} rausgeworfen: {1}
playerKicked = \u00a7cPlayer {0} kicked {1} for {2}
playerMuted = \u00a77Du bist jetzt stumm.
playerMutedFor = \u00a77Du bist jetzt stumm f\u00fcr {0}.
playerNeverOnServer = \u00a7cSpieler {0} war niemals auf diesem Server.

View File

@ -211,11 +211,11 @@ onlySunStorm = /weather only supports sun/storm.
parseError = Error parsing {0} on line {1}
pendingTeleportCancelled = \u00a7cPending teleportation request cancelled.
permissionsError = Missing Permissions/GroupManager; chat prefixes/suffixes will be disabled.
playerBanned = \u00a7cPlayer {0} banned: {1}
playerBanned = \u00a7cPlayer {0} banned {1} for {2}
playerInJail = \u00a7cPlayer is already in jail {0}.
playerJailed = \u00a77Player {0} jailed.
playerJailedFor = \u00a77Player {0} jailed for {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerKicked = \u00a7cPlayer {0} kicked {1} for {2}
playerMuted = \u00a77You have been muted
playerMutedFor = \u00a77You have been muted for {0}
playerNeverOnServer = \u00a7cPlayer {0} was never on this server.
@ -230,7 +230,9 @@ protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0}
questionFormat = \u00a77[Question]\u00a7f {0}
reloadAllPlugins = \u00a77Reloaded all plugins.
requestAccepted = \u00a77Teleport request accepted.
requestAcceptedFrom = \u00a77{0} accepted your teleport request.
requestDenied = \u00a77Teleport request denied.
requestDeniedFrom = \u00a77{0} denied your teleport request
requestSent = \u00a77Request sent to {0}\u00a77.
returnPlayerToJailError = Error occured when trying to return player to jail.
second = second
@ -252,7 +254,7 @@ takenFromOthersAccount = \u00a7c{0} has been taken from {1} account.
teleportAll = \u00a77Teleporting all players...
teleportAtoB = \u00a77{0}\u00a77 teleported you to {1}\u00a77.
teleportDisabled = {0} has teleportation disabled.
teleportHereRequest = \u00a7c{0}\u00a7c has requested that you teleport to him/her.
teleportHereRequest = \u00a7c{0}\u00a7c has requested that you teleport to them.
teleportNewPlayerError = Failed to teleport new player
teleportRequest = \u00a7c{0}\u00a7c has requested to teleport to you.
teleportTop = \u00a77Teleporting to top.

View File

@ -211,11 +211,11 @@ onlySunStorm = /weather only supports sun/storm.
parseError = Erreur de conversion {0} \u00e0 la ligne {1}
pendingTeleportCancelled = \u00a7cRequete de t\u00e9l\u00e9portation annul\u00e9e.
permissionsError = Permissions/GroupManager manquant, les pr\u00e9fixes et suffixes ne seront pas affich\u00e9s.
playerBanned = \u00a7cLe joueur {0} a \u00e9t\u00e9 banni: {1}
playerBanned = \u00a7cPlayer {0} banned {1} for {2}
playerInJail = \u00a7cLe joueur est d\u00e9j\u00e0 dans la prison {0}.
playerJailed = \u00a77Le joueur {0} a \u00e9t\u00e9 emprisonn\u00e9.
playerJailedFor = \u00a77{0} a \u00e9t\u00e9 emprisonn\u00e9 pour {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerKicked = \u00a7cPlayer {0} kicked {1} for {2}
playerMuted = \u00a77You have been muted
playerMutedFor = \u00a77You have been muted for {0}
playerNeverOnServer = \u00a7cLe joueur {0} n''a jamais \u00e9t\u00e9 sur le serveur.

View File

@ -212,11 +212,11 @@ onlySunStorm = /weather only supports sun/storm.
parseError = Fout bij ontleding {0} op regel {1}
pendingTeleportCancelled = \u00a7cAangevraagde teleportatie afgelast.
permissionsError = Permissions/GroupManager ontbreekt; chat prefixes/suffixes worden uitgeschakeld.
playerBanned = \u00a7cSpeler {0} is geband: {1}
playerBanned = \u00a7cPlayer {0} banned {1} for {2}
playerInJail = \u00a7cSpeler zit al in de gevangenis {0}.
playerJailed = \u00a77Speler {0} is in de gevangenis gezet.
playerJailedFor = \u00a77Speler {0} is in de gevangenis gezet voor {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerKicked = \u00a7cPlayer {0} kicked {1} for {2}
playerMuted = \u00a77Je kreeg het zwijgen opgelegd.
playerMutedFor = \u00a77Je kreeg het zwijgen opgelegd voor {0}
playerNeverOnServer = \u00a7cSpeler {0} is nooit op deze server geweest.

View File

@ -20,7 +20,7 @@ commands:
usage: /<command>
aliases: [eback]
backup:
description: Runs the backup command
description: Runs the backup if configured.
usage: /<command>
aliases: [ebackup]
balance:
@ -74,7 +74,7 @@ commands:
eco:
description: Manages the server economy.
usage: /<command> [give|take|reset] [player] [amount]
aliases: economy
aliases: [economy,emoney]
essentials:
description: Reloads essentials.
usage: /<command>
@ -113,6 +113,7 @@ commands:
helpop:
description: Request help from online operators.
usage: /<command> [message]
aliases: [ehelpop]
home:
description: Teleport to your home.
usage: /<command> <player>
@ -164,7 +165,7 @@ commands:
lightning:
description: The power of Thor. Strike at cursor or player.
usage: /<command> [player]
aliases: [strike,elightning,estrike]
aliases: [strike,smite,elightning,estrike,esmite]
mail:
description: Manages inter-player, intra-server mail.
usage: /<command> [read|clear|send [to] [message]]
@ -205,6 +206,10 @@ commands:
description: Assigns a command to the item in hand, {player} will be replaced by the name of the player that you click.
usage: /<command> [command] <arguments>
aliases: [pt,epowertool,ept]
ptime:
description: Adjust player's client time. Add @ prefix to fix.
usage: /<command> [list|reset|day|night|dawn|17:30|4pm|4000ticks] <player|*>
aliases: [playertime, eptime, eplayertime]
r:
description: Quickly reply to the last player to message you.
usage: /<command> [message]
@ -270,9 +275,9 @@ commands:
usage: /<command> <true/false> [duration]
aliases: [ethunder]
time:
description: Change the time to day or night of the player (default) or world (essentials.time.world permission).
usage: /<command> [day|night|reset] <playername>
aliases: [etime]
description: Change the world time. Defaults tos current world.
usage: /<command> [day|night|dawn|17:30|4pm|4000ticks] [worldname|all]
aliases: [etime, day, night]
togglejail:
description: Prevents a player from interacting with the world and teleports him/her to the the jail specified
usage: /<command> [player] [jailname] <datediff>
@ -288,6 +293,9 @@ commands:
tpa:
description: Request to teleport to the specified player.
usage: /<command> <player>
tpaall:
description: Requests all players online to teleport to you.
usage: /<command> <player>
tpaccept:
description: Accepts a teleport request.
usage: /<command>
@ -333,7 +341,7 @@ commands:
unlimited:
description: Allows the unlimited placing of items.
usage: /<command> [list|item] <player>
aliases: [eunlimited,ul,eul]
aliases: [eunlimited,ul,unl,eul,eunl]
warp:
description: List all warps or warp to the specified location.
usage: /<command> <warp> <player>

View File

@ -5,6 +5,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Server;
@ -15,9 +17,13 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.inventory.Recipe;
import org.bukkit.map.MapView;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.ServicesManager;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.scheduler.BukkitWorker;
public class FakeServer implements Server
@ -118,7 +124,93 @@ public class FakeServer implements Server
public BukkitScheduler getScheduler()
{
throw new UnsupportedOperationException("Not supported yet.");
return new BukkitScheduler() {
@Override
public int scheduleSyncDelayedTask(Plugin plugin, Runnable r, long l)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int scheduleSyncDelayedTask(Plugin plugin, Runnable r)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int scheduleSyncRepeatingTask(Plugin plugin, Runnable r, long l, long l1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int scheduleAsyncDelayedTask(Plugin plugin, Runnable r, long l)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int scheduleAsyncDelayedTask(Plugin plugin, Runnable r)
{
r.run();
return 0;
}
@Override
public int scheduleAsyncRepeatingTask(Plugin plugin, Runnable r, long l, long l1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T> Future<T> callSyncMethod(Plugin plugin, Callable<T> clbl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void cancelTask(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void cancelTasks(Plugin plugin)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void cancelAllTasks()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isCurrentlyRunning(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean isQueued(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<BukkitWorker> getActiveWorkers()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public List<BukkitTask> getPendingTasks()
{
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
public ServicesManager getServicesManager()
@ -250,4 +342,40 @@ public class FakeServer implements Server
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getViewDistance()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean getAllowNether()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean hasWhitelist()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public MapView getMap(short s)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public MapView createMap(World world)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean getAllowFlight()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -33,6 +33,7 @@ public class UserTest extends TestCase
}
base1 = server.createPlayer("testPlayer1", ess);
server.addPlayer(base1);
ess.getUser(base1);
}
private void should(String what)

View File

@ -875,11 +875,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=7c7f517b
nbproject/build-impl.xml.script.CRC32=9d5d3374
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=2447bdf5
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -1,6 +1,8 @@
package com.earth2me.essentials.chat;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.Map;
@ -8,6 +10,7 @@ import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerListener;
@ -59,29 +62,38 @@ public class EssentialsChatPlayerListener extends PlayerListener
}
radius *= radius;
if (event.getMessage().startsWith("!") && event.getMessage().length() > 1)
{
if (user.isAuthorized("essentials.chat.shout"))
try {
if (event.getMessage().startsWith("!") && event.getMessage().length() > 1)
{
event.setMessage(event.getMessage().substring(1));
event.setFormat(Util.format("shoutFormat", event.getFormat()));
if (user.isAuthorized("essentials.chat.shout"))
{
charge(user,"chat-shout");
event.setMessage(event.getMessage().substring(1));
event.setFormat(Util.format("shoutFormat", event.getFormat()));
return;
}
user.sendMessage(Util.i18n("notAllowedToShout"));
event.setCancelled(true);
return;
}
user.sendMessage(Util.i18n("notAllowedToShout"));
event.setCancelled(true);
return;
}
if (event.getMessage().startsWith("?") && event.getMessage().length() > 1)
{
if (user.isAuthorized("essentials.chat.question"))
if (event.getMessage().startsWith("?") && event.getMessage().length() > 1)
{
event.setMessage(event.getMessage().substring(1));
event.setFormat(Util.format("questionFormat", event.getFormat()));
if (user.isAuthorized("essentials.chat.question"))
{
charge(user,"chat-question");
event.setMessage(event.getMessage().substring(1));
event.setFormat(Util.format("questionFormat", event.getFormat()));
return;
}
user.sendMessage(Util.i18n("notAllowedToQuestion"));
event.setCancelled(true);
return;
}
user.sendMessage(Util.i18n("notAllowedToQuestion"));
event.setCancelled(true);
}
catch (ChargeException ex)
{
ess.showError(user, ex, "Shout");
return;
}
@ -123,4 +135,12 @@ public class EssentialsChatPlayerListener extends PlayerListener
u.sendMessage(message);
}
}
protected void charge(final CommandSender sender, final String command) throws ChargeException
{
if (sender instanceof Player)
{
final Trade charge = new Trade(command, ess);
charge.charge(ess.getUser((Player)sender));
}
}
}

View File

@ -875,11 +875,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.43.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=cbf94f59
nbproject/build-impl.xml.script.CRC32=a87d6c0a
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=e7684555
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -850,11 +850,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=475c8f4d
nbproject/build-impl.xml.script.CRC32=a1a87e78
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=6ab1a006
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -843,11 +843,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=a6709b83
nbproject/build-impl.xml.script.CRC32=edda2837
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=4191e2b2
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -1,5 +1,5 @@
name: GroupManager
version: "1.0(alpha-5) [Zombie-Version, please switch to Permissions 3]"
version: "1.0(alpha-5) [Zombie-Version]"
main: org.anjocaido.groupmanager.GroupManager
website: http://www.anjocaido.info/
description: Provides on-the-fly system for Permission system created by Nijikokun. But all in memory, and with flat-file saving schedule.

View File

@ -875,11 +875,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.43.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=9c3a069f
nbproject/build-impl.xml.script.CRC32=dd030a92
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=2a10b0d4
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -875,11 +875,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.3.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=40644caa
nbproject/build-impl.xml.script.CRC32=0a5523ea
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=0e9dab07
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -875,11 +875,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=e7b96939
nbproject/build-impl.xml.script.CRC32=f7b05a7b
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=fd1c94f8
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -59,20 +59,23 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
return;
}
user.setNew(false);
ess.scheduleSyncDelayedTask(new Runnable()
if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn()))
{
public void run()
ess.scheduleSyncDelayedTask(new Runnable()
{
try
public void run()
{
user.getTeleport().now(ess.getSpawn().getSpawn(ess.getSettings().getNewbieSpawn()));
try
{
user.getTeleport().now(ess.getSpawn().getSpawn(ess.getSettings().getNewbieSpawn()));
}
catch (Exception ex)
{
Logger.getLogger("Minecraft").log(Level.WARNING, Util.i18n("teleportNewPlayerError"), ex);
}
}
catch (Exception ex)
{
Logger.getLogger("Minecraft").log(Level.WARNING, Util.i18n("teleportNewPlayerError"), ex);
}
}
});
});
}
if (ess.getSettings().getAnnounceNewPlayers())
{

View File

@ -875,11 +875,12 @@ is divided into following sections:
<classpath>
<path path="${javac.classpath}"/>
</classpath>
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
<filename name="**/*.java"/>
</fileset>
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
<include name="**/*.java"/>
<exclude name="*.java"/>
</fileset>
</javadoc>
<copy todir="${dist.javadoc.dir}">

View File

@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.42.1.45
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=1012a5dd
nbproject/build-impl.xml.script.CRC32=04f5fc92
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
nbproject/build-impl.xml.script.CRC32=6ad41b28
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45

View File

@ -1,6 +1,5 @@
package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Util;
import java.util.List;
@ -121,4 +120,21 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
{
return instance.users.getSpyUsers();
}
@Override
public void broadcastMessage(final String name, final String message)
{
ess.broadcastMessage(name, message);
try
{
for (String address : getSpyUsers())
{
sendMessage(address, message);
}
}
catch (Exception ex)
{
// Ignore exceptions
}
}
}

View File

@ -2,17 +2,17 @@ package com.earth2me.essentials.xmpp;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public interface IEssentialsXMPP
public interface IEssentialsXMPP extends Plugin
{
String getAddress(final Player user);
String getAddress(final String name);
List<String> getSpyUsers();
String getUserByAddress(final String address);
boolean sendMessage(final Player user, final String message);
@ -22,5 +22,6 @@ public interface IEssentialsXMPP
void setAddress(final Player user, final String address);
boolean toggleSpy(final Player user);
void broadcastMessage(final String name, final String message);
}

View File

@ -38,14 +38,14 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
private transient ChatManager chatManager;
private final transient Map<String, Chat> chats = Collections.synchronizedMap(new HashMap<String, Chat>());
private final transient Set<LogRecord> logrecords = Collections.synchronizedSet(new HashSet<LogRecord>());
private final transient JavaPlugin parent;
private final transient IEssentialsXMPP parent;
private transient List<String> logUsers;
private transient Level logLevel;
private transient boolean ignoreLagMessages = true;
private transient Thread loggerThread;
private transient boolean threadrunning = true;
public XMPPManager(final JavaPlugin parent)
public XMPPManager(final IEssentialsXMPP parent)
{
super();
this.parent = parent;
@ -68,6 +68,10 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
}
if (chat != null)
{
if (!connection.isConnected()) {
disconnect();
connect();
}
chat.sendMessage(message.replaceAll("§[0-9a-f]", ""));
return true;
}
@ -97,7 +101,8 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
sendCommand(chat, message);
break;
default:
parent.getServer().broadcastMessage("<X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + "> " + message);
final String name = parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant()));
parent.broadcastMessage(name, "="+name+": "+ message);
}
}
}
@ -346,7 +351,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
}
else
{
final String from = "[X:" + EssentialsXMPP.getInstance().getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">";
final String from = "[" + parent.getUserByAddress(StringUtils.parseBareAddress(chat.getParticipant())) + ">";
for (Player p : matches)
{
p.sendMessage(from + p.getDisplayName() + "] " + message);

BIN
lib/MultiCurrency.jar Normal file

Binary file not shown.

BIN
lib/Permissions3.jar Executable file → Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
lib/iCo6.jar Normal file

Binary file not shown.