1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-01 10:42:41 +02:00
This commit is contained in:
Iaccidentally
2012-10-28 10:54:50 -04:00
35 changed files with 311 additions and 317 deletions

View File

@@ -10,6 +10,7 @@ import java.text.MessageFormat;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Pattern;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.II18n; import net.ess3.api.II18n;
@@ -97,6 +98,7 @@ public class I18n implements II18n
} }
return messageFormat.format(objects); return messageFormat.format(objects);
} }
private final Pattern partSplit = Pattern.compile("[_\\.]");
public void updateLocale(final String loc) public void updateLocale(final String loc)
{ {
@@ -104,7 +106,7 @@ public class I18n implements II18n
{ {
return; return;
} }
final String[] parts = loc.split("[_\\.]"); final String[] parts = partSplit.split(loc);
if (parts.length == 1) if (parts.length == 1)
{ {
currentLocale = new Locale(parts[0]); currentLocale = new Locale(parts[0]);

View File

@@ -84,31 +84,39 @@ public class ItemDb implements IItemDb
return stack; return stack;
} }
@Override
public ItemStack get(final String id, final int quantity) throws Exception public ItemStack get(final String id, final int quantity) throws Exception
{ {
final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH)); final ItemStack retval = get(id.toLowerCase(Locale.ENGLISH));
retval.setAmount(quantity); retval.setAmount(quantity);
return retval; return retval;
} }
private final Pattern idMatch = Pattern.compile("^\\d+[:+',;.]\\d+$");
private final Pattern metaSplit = Pattern.compile("[:+',;.]");
private final Pattern number = Pattern.compile("^\\d+$");
private final Pattern conjoined = Pattern.compile("^[^:+',;.]+[:+',;.]\\d+$");
@Override
public ItemStack get(final String id) throws Exception public ItemStack get(final String id) throws Exception
{ {
int itemid = 0; int itemid = 0;
String itemname = null; String itemname = null;
short metaData = 0; short metaData = 0;
if (id.matches("^\\d+[:+',;.]\\d+$")) if (idMatch.matcher(id).matches())
{ {
itemid = Integer.parseInt(id.split("[:+',;.]")[0]); String[] split = metaSplit.split(id);
metaData = Short.parseShort(id.split("[:+',;.]")[1]); itemid = Integer.parseInt(split[0]);
metaData = Short.parseShort(split[1]);
} }
else if (id.matches("^\\d+$")) else if (number.matcher(id).matches())
{ {
itemid = Integer.parseInt(id); itemid = Integer.parseInt(id);
} }
else if (id.matches("^[^:+',;.]+[:+',;.]\\d+$")) else if (conjoined.matcher(id).matches())
{ {
itemname = id.split("[:+',;.]")[0].toLowerCase(Locale.ENGLISH); String[] split = metaSplit.split(id);
metaData = Short.parseShort(id.split("[:+',;.]")[1]); itemname = split[0].toLowerCase(Locale.ENGLISH);
metaData = Short.parseShort(split[1]);
} }
else else
{ {

View File

@@ -102,16 +102,6 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
queueSave(); queueSave();
} }
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
@Override @Override
public int getCount() public int getCount()
{ {

View File

@@ -69,16 +69,6 @@ public class Kits extends AsyncStorageObjectHolder<net.ess3.settings.Kits> imple
return getData().getKits().isEmpty(); return getData().getKits().isEmpty();
} }
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
@Override @Override
public void checkTime(IUser user, Kit kit) throws NoChargeException public void checkTime(IUser user, Kit kit) throws NoChargeException
{ {

View File

@@ -13,6 +13,7 @@ import net.ess3.user.CooldownException;
import net.ess3.user.UserData.TimestampType; import net.ess3.user.UserData.TimestampType;
import net.ess3.utils.DateUtil; import net.ess3.utils.DateUtil;
import net.ess3.utils.LocationUtil; import net.ess3.utils.LocationUtil;
import net.ess3.utils.Target;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -22,37 +23,11 @@ public class Teleport implements Runnable, ITeleport
{ {
private static final double MOVE_CONSTANT = 0.3; private static final double MOVE_CONSTANT = 0.3;
private static class Target
{
private final Location location;
private final Entity entity;
Target(Location location)
{
this.location = location;
this.entity = null;
}
Target(Entity entity)
{
this.entity = entity;
this.location = null;
}
public Location getLocation()
{
if (this.entity != null)
{
return this.entity.getLocation();
}
return location;
}
}
private IUser user; private IUser user;
private IUser teleportUser;
private int teleTimer = -1; private int teleTimer = -1;
private long started; // time this task was initiated private long started; // time this task was initiated
private long delay; // how long to delay the teleport private long tpDelay; // how long to delay the teleport
private int health; private int health;
// note that I initially stored a clone of the location for reference, but... // note that I initially stored a clone of the location for reference, but...
// when comparing locations, I got incorrect mismatches (rounding errors, looked like) // when comparing locations, I got incorrect mismatches (rounding errors, looked like)
@@ -67,13 +42,19 @@ public class Teleport implements Runnable, ITeleport
private TeleportCause cause; private TeleportCause cause;
private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause) private void initTimer(long delay, Target target, Trade chargeFor, TeleportCause cause)
{
initTimer(delay, user, target, chargeFor, cause);
}
private void initTimer(long delay, IUser teleportUser, Target target, Trade chargeFor, TeleportCause cause)
{ {
this.started = System.currentTimeMillis(); this.started = System.currentTimeMillis();
this.delay = delay; this.tpDelay = delay;
this.health = user.getPlayer().getHealth(); this.health = teleportUser.getPlayer().getHealth();
this.initX = Math.round(user.getPlayer().getLocation().getX() * MOVE_CONSTANT); this.initX = Math.round(teleportUser.getPlayer().getLocation().getX() * MOVE_CONSTANT);
this.initY = Math.round(user.getPlayer().getLocation().getY() * MOVE_CONSTANT); this.initY = Math.round(teleportUser.getPlayer().getLocation().getY() * MOVE_CONSTANT);
this.initZ = Math.round(user.getPlayer().getLocation().getZ() * MOVE_CONSTANT); this.initZ = Math.round(teleportUser.getPlayer().getLocation().getZ() * MOVE_CONSTANT);
this.teleportUser = teleportUser;
this.teleportTarget = target; this.teleportTarget = target;
this.chargeFor = chargeFor; this.chargeFor = chargeFor;
this.cause = cause; this.cause = cause;
@@ -88,28 +69,36 @@ public class Teleport implements Runnable, ITeleport
cancel(); cancel();
return; return;
} }
if (Math.round(user.getPlayer().getLocation().getX() * MOVE_CONSTANT) != initX
|| Math.round(user.getPlayer().getLocation().getY() * MOVE_CONSTANT) != initY if (teleportUser == null || !teleportUser.isOnline() || teleportUser.getPlayer().getLocation() == null)
|| Math.round(user.getPlayer().getLocation().getZ() * MOVE_CONSTANT) != initZ {
|| user.getPlayer().getHealth() < health) cancel(false);
return;
}
if (!Permissions.TELEPORT_TIMER_MOVE.isAuthorized(user)
&&(Math.round(teleportUser.getPlayer().getLocation().getX() * MOVE_CONSTANT) != initX
|| Math.round(teleportUser.getPlayer().getLocation().getY() * MOVE_CONSTANT) != initY
|| Math.round(teleportUser.getPlayer().getLocation().getZ() * MOVE_CONSTANT) != initZ
|| teleportUser.getPlayer().getHealth() < health))
{ // user moved, cancel teleport { // user moved, cancel teleport
cancel(true); cancel(true);
return; return;
} }
health = user.getPlayer().getHealth(); // in case user healed, then later gets injured health = teleportUser.getPlayer().getHealth(); // in case user healed, then later gets injured
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
if (now > started + delay) if (now > started + tpDelay)
{ {
try try
{ {
cooldown(false); cooldown(false);
user.sendMessage(_("teleportationCommencing")); teleportUser.sendMessage(_("teleportationCommencing"));
try try
{ {
now(teleportTarget, cause); teleportUser.getTeleport().now(teleportTarget, cause);
if (chargeFor != null) if (chargeFor != null)
{ {
chargeFor.charge(user); chargeFor.charge(user);
@@ -123,6 +112,10 @@ public class Teleport implements Runnable, ITeleport
catch (Exception ex) catch (Exception ex)
{ {
user.sendMessage(_("cooldownWithMessage", ex.getMessage())); user.sendMessage(_("cooldownWithMessage", ex.getMessage()));
if (user != teleportUser)
{
teleportUser.sendMessage(_("cooldownWithMessage", ex.getMessage()));
}
} }
} }
} }
@@ -133,21 +126,7 @@ public class Teleport implements Runnable, ITeleport
this.ess = ess; this.ess = ess;
} }
@Override
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
{
final Location bed = user.getBedSpawnLocation();
final Location respawnLoc = ess.getPlugin().callRespawnEvent(user.getPlayer(), bed == null ? user.getPlayer().getWorld().getSpawnLocation() : bed, bed != null);
teleport(new Target(respawnLoc), chargeFor, cause);
}
@Override
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
{
final Location loc = ess.getWarps().getWarp(warp);
teleport(new Target(loc), chargeFor, cause);
user.sendMessage(_("warpingTo", warp));
}
public void cooldown(boolean check) throws Exception public void cooldown(boolean check) throws Exception
{ {
@@ -162,6 +141,7 @@ public class Teleport implements Runnable, ITeleport
} }
} }
//If we need to cancel a pending teleport call this method
public void cancel(boolean notifyUser) public void cancel(boolean notifyUser)
{ {
if (teleTimer == -1) if (teleTimer == -1)
@@ -174,6 +154,10 @@ public class Teleport implements Runnable, ITeleport
if (notifyUser) if (notifyUser)
{ {
user.sendMessage(_("pendingTeleportCancelled")); user.sendMessage(_("pendingTeleportCancelled"));
if (teleportUser != user)
{
teleportUser.sendMessage(_("pendingTeleportCancelled"));
}
} }
} }
finally finally
@@ -186,18 +170,14 @@ public class Teleport implements Runnable, ITeleport
{ {
cancel(false); cancel(false);
} }
public void teleport(Location loc, Trade chargeFor) throws Exception
{
teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
}
@Override @Override
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{ {
teleport(new Target(loc), chargeFor, cause); teleport(new Target(loc), chargeFor, cause);
} }
@Override
public void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception public void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception
{ {
teleport(new Target(entity), chargeFor, cause); teleport(new Target(entity), chargeFor, cause);
@@ -205,14 +185,14 @@ public class Teleport implements Runnable, ITeleport
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
{ {
double tDelay = ess.getRanks().getTeleportDelay(user); double delay = ess.getRanks().getTeleportDelay(user);
if (chargeFor != null) if (chargeFor != null)
{ {
chargeFor.isAffordableFor(user); chargeFor.isAffordableFor(user);
} }
cooldown(true); cooldown(true);
if (tDelay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user)) if (delay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user))
{ {
cooldown(false); cooldown(false);
now(target, cause); now(target, cause);
@@ -224,16 +204,14 @@ public class Teleport implements Runnable, ITeleport
} }
cancel(); cancel();
Calendar c = new GregorianCalendar(); warnUser(user, delay);
c.add(Calendar.SECOND, (int)tDelay); initTimer((long)(delay * 1000.0), target, chargeFor, cause);
c.add(Calendar.MILLISECOND, (int)((tDelay * 1000.0) % 1000.0));
user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
initTimer((long)(tDelay * 1000.0), target, chargeFor, cause);
teleTimer = ess.getPlugin().scheduleSyncRepeatingTask(this, 10, 10); teleTimer = ess.getPlugin().scheduleSyncRepeatingTask(this, 10, 10);
} }
private void now(final Target target, final TeleportCause cause) throws Exception @Override
public void now(final Target target, final TeleportCause cause) throws Exception
{ {
cancel(); cancel();
user.setLastLocation(); user.setLastLocation();
@@ -258,13 +236,9 @@ public class Teleport implements Runnable, ITeleport
now(new Target(loc), cause); now(new Target(loc), cause);
} }
public void now(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{ @Override
cooldown(false); //The now function is used when you want to skip tp delay when teleporting someone to a location or player.
chargeFor.charge(user);
now(new Target(loc), cause);
}
public void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception public void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception
{ {
if (cooldown) if (cooldown)
@@ -273,6 +247,66 @@ public class Teleport implements Runnable, ITeleport
} }
now(new Target(entity), cause); now(new Target(entity), cause);
} }
public void now(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
{
cooldown(false);
chargeFor.charge(user);
now(new Target(loc), cause);
}
//The teleportToMe function is a wrapper used to handle teleporting players to them, like /tphere
public void teleportToMe(IUser otherUser, Trade chargeFor, TeleportCause cause) throws Exception
{
Target target = new Target(user.getPlayer());
double delay = ess.getRanks().getTeleportDelay(user);
if (chargeFor != null)
{
chargeFor.isAffordableFor(user);
}
cooldown(true);
if (delay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user))
{
cooldown(false);
otherUser.getTeleport().now(target, cause);
if (chargeFor != null)
{
chargeFor.charge(user);
}
return; }
cancel(false);
warnUser(otherUser, delay);
initTimer((long)(delay * 1000.0), otherUser, target, chargeFor, cause);
teleTimer = ess.getPlugin().scheduleSyncRepeatingTask(this, 10, 10);
}
private void warnUser(final IUser user, final double delay)
{
Calendar c = new GregorianCalendar();
c.add(Calendar.SECOND, (int)delay);
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
}
@Override
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
{
final Location bed = user.getBedSpawnLocation();
final Location respawnLoc = ess.getPlugin().callRespawnEvent(user.getPlayer(), bed == null ? user.getPlayer().getWorld().getSpawnLocation() : bed, bed != null);
teleport(new Target(respawnLoc), chargeFor, cause);
}
@Override
public void warp(String warp, Trade chargeFor, TeleportCause cause) throws Exception
{
final Location loc = ess.getWarps().getWarp(warp);
user.sendMessage(_("warpingTo", warp));
teleport(new Target(loc), chargeFor, cause);
}
@Override @Override
public void back(Trade chargeFor) throws Exception public void back(Trade chargeFor) throws Exception

View File

@@ -1,6 +1,7 @@
package net.ess3.api; package net.ess3.api;
import net.ess3.economy.Trade; import net.ess3.economy.Trade;
import net.ess3.utils.Target;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
@@ -11,12 +12,16 @@ public interface ITeleport
void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception; void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception;
void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception; void now(Entity entity, boolean cooldown, TeleportCause cause) throws Exception;
void now(final Target target, final TeleportCause cause) throws Exception;
void back(Trade chargeFor) throws Exception; void back(Trade chargeFor) throws Exception;
void teleport(Location bed, Trade charge, TeleportCause teleportCause) throws Exception; void teleport(Location bed, Trade charge, TeleportCause teleportCause) throws Exception;
void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception; void teleport(Entity entity, Trade chargeFor, TeleportCause cause) throws Exception;
void teleportToMe(IUser otherUser, Trade chargeFor, TeleportCause cause) throws Exception;
void home(Location loc, Trade chargeFor) throws Exception; void home(Location loc, Trade chargeFor) throws Exception;

View File

@@ -1,6 +1,7 @@
package net.ess3.commands; package net.ess3.commands;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.permissions.Permissions; import net.ess3.permissions.Permissions;
@@ -9,6 +10,8 @@ import org.bukkit.command.CommandSender;
public class Commanddelhome extends EssentialsCommand public class Commanddelhome extends EssentialsCommand
{ {
private final transient Pattern colon = Pattern.compile(":");
@Override @Override
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{ {
@@ -22,7 +25,7 @@ public class Commanddelhome extends EssentialsCommand
String[] expandedArg; String[] expandedArg;
//Allowing both formats /sethome khobbits house | /sethome khobbits:house //Allowing both formats /sethome khobbits house | /sethome khobbits:house
final String[] nameParts = args[0].split(":"); final String[] nameParts = colon.split(args[0]);
if (nameParts[0].length() != args[0].length()) if (nameParts[0].length() != args[0].length())
{ {
expandedArg = nameParts; expandedArg = nameParts;

View File

@@ -1,6 +1,7 @@
package net.ess3.commands; package net.ess3.commands;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.permissions.Permissions; import net.ess3.permissions.Permissions;
@@ -13,6 +14,8 @@ import org.bukkit.inventory.ItemStack;
public class Commandgive extends EssentialsCommand public class Commandgive extends EssentialsCommand
{ {
private final transient Pattern data = Pattern.compile("[:+',;.]");
@Override @Override
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{ {
@@ -45,7 +48,7 @@ public class Commandgive extends EssentialsCommand
{ {
for (int i = Util.isInt(args[3]) ? 4 : 3; i < args.length; i++) for (int i = Util.isInt(args[3]) ? 4 : 3; i < args.length; i++)
{ {
final String[] split = args[i].split("[:+',;.]", 2); final String[] split = data.split(args[i], 2);
if (split.length < 1) if (split.length < 1)
{ {
continue; continue;

View File

@@ -2,6 +2,7 @@ package net.ess3.commands;
import java.util.Locale; import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.economy.Trade; import net.ess3.economy.Trade;
@@ -14,6 +15,8 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandhome extends EssentialsCommand public class Commandhome extends EssentialsCommand
{ {
private final transient Pattern colon = Pattern.compile(":");
@Override @Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{ {
@@ -24,7 +27,7 @@ public class Commandhome extends EssentialsCommand
String[] nameParts; String[] nameParts;
if (args.length > 0) if (args.length > 0)
{ {
nameParts = args[0].split(":"); nameParts = colon.split(args[0]);
if (nameParts[0].length() == args[0].length() || !Permissions.HOME_OTHERS.isAuthorized(user)) if (nameParts[0].length() == args[0].length() || !Permissions.HOME_OTHERS.isAuthorized(user))
{ {
homeName = nameParts[0]; homeName = nameParts[0];

View File

@@ -1,6 +1,7 @@
package net.ess3.commands; package net.ess3.commands;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.permissions.Permissions; import net.ess3.permissions.Permissions;
@@ -10,16 +11,18 @@ import org.bukkit.inventory.ItemStack;
public class Commanditem extends EssentialsCommand public class Commanditem extends EssentialsCommand
{ {
private final transient Pattern data = Pattern.compile("[:+',;.]");
@Override @Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{ {
if (args.length < 1) if (args.length < 1)
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (args.length > 1 && args[0].equals("love") && args[1].equals("you")) if (args.length > 1 && args[0].equals("love") && args[1].equals("you"))
{ {
user.sendMessage("What is love?"); user.sendMessage("What is love?");
user.sendMessage("Baby don't hurt me"); user.sendMessage("Baby don't hurt me");
return; return;
@@ -36,12 +39,12 @@ public class Commanditem extends EssentialsCommand
{ {
stack.setAmount(Integer.parseInt(args[1])); stack.setAmount(Integer.parseInt(args[1]));
} }
if (args.length > 2 && Permissions.ITEM_ENCHANTED.isAuthorized(user)) if (args.length > 2 && Permissions.ITEM_ENCHANTED.isAuthorized(user))
{ {
for (int i = 2; i < args.length; i++) for (int i = 2; i < args.length; i++)
{ {
final String[] split = args[i].split("[:+',;.]", 2); final String[] split = data.split(args[i], 2);
if (split.length < 1) if (split.length < 1)
{ {
continue; continue;
@@ -66,14 +69,14 @@ public class Commanditem extends EssentialsCommand
} }
} }
} }
if (stack.getTypeId() == 0) if (stack.getTypeId() == 0)
{ {
throw new Exception(_("cantSpawnItem", "Air")); throw new Exception(_("cantSpawnItem", "Air"));
} }
user.giveItems(stack, false); user.giveItems(stack, false);
final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' '); final String displayName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
user.sendMessage(_("itemSpawn", stack.getAmount(), displayName)); user.sendMessage(_("itemSpawn", stack.getAmount(), displayName));
} }

View File

@@ -1,6 +1,7 @@
package net.ess3.commands; package net.ess3.commands;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.permissions.Permissions; import net.ess3.permissions.Permissions;
@@ -8,13 +9,15 @@ import net.ess3.permissions.Permissions;
public class Commandsethome extends EssentialsCommand public class Commandsethome extends EssentialsCommand
{ {
private final transient Pattern colon = Pattern.compile(":");
@Override @Override
public void run(final IUser user, final String commandLabel, String[] args) throws Exception public void run(final IUser user, final String commandLabel, String[] args) throws Exception
{ {
if (args.length > 0) if (args.length > 0)
{ {
//Allowing both formats /sethome khobbits house | /sethome khobbits:house //Allowing both formats /sethome khobbits house | /sethome khobbits:house
final String[] nameParts = args[0].split(":"); final String[] nameParts = colon.split(args[0]);
if (nameParts[0].length() != args[0].length()) if (nameParts[0].length() != args[0].length())
{ {
args = nameParts; args = nameParts;

View File

@@ -4,6 +4,7 @@ import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.ISettings; import net.ess3.api.ISettings;
import net.ess3.api.IUser; import net.ess3.api.IUser;
@@ -22,6 +23,8 @@ import org.bukkit.material.Colorable;
public class Commandspawnmob extends EssentialsCommand public class Commandspawnmob extends EssentialsCommand
{ {
private final transient Pattern colon = Pattern.compile(":");
@Override @Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{ {
@@ -45,7 +48,7 @@ public class Commandspawnmob extends EssentialsCommand
final String[] mountparts = args[0].split(","); final String[] mountparts = args[0].split(",");
String[] parts = mountparts[0].split(":"); String[] parts = colon.split(mountparts[0]);
String mobType = parts[0]; String mobType = parts[0];
String mobData = null; String mobData = null;
if (parts.length == 2) if (parts.length == 2)
@@ -56,7 +59,7 @@ public class Commandspawnmob extends EssentialsCommand
String mountData = null; String mountData = null;
if (mountparts.length > 1) if (mountparts.length > 1)
{ {
parts = mountparts[1].split(":"); parts = colon.split(mountparts[1]);
mountType = parts[0]; mountType = parts[0];
if (parts.length == 2) if (parts.length == 2)
{ {

View File

@@ -56,12 +56,13 @@ public class Commandtpaccept extends EssentialsCommand
if (user.isTpRequestHere()) if (user.isTpRequestHere())
{ {
user.getTeleport().teleport(target.getPlayer(), charge, TeleportCause.COMMAND); target.getTeleport().teleportToMe(user, charge, TeleportCause.COMMAND);
} }
else else
{ {
target.getTeleport().teleport(user.getPlayer(), charge, TeleportCause.COMMAND); target.getTeleport().teleport(user.getPlayer(), charge, TeleportCause.COMMAND);
} }
user.requestTeleport(null, false); user.requestTeleport(null, false);
throw new NoChargeException();
} }
} }

View File

@@ -16,7 +16,8 @@ public class Commandtphere extends EssentialsCommand
{ {
throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName())); throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName()));
} }
player.getTeleport().teleport(user.getPlayer(), new Trade(commandName, ess), TeleportCause.COMMAND);
user.getTeleport().teleportToMe(player, new Trade(commandName, ess), TeleportCause.COMMAND);
user.sendMessage(_("teleporting")); user.sendMessage(_("teleporting"));
player.sendMessage(_("teleporting")); player.sendMessage(_("teleporting"));
throw new NoChargeException(); throw new NoChargeException();

View File

@@ -7,20 +7,6 @@ import net.ess3.storage.AsyncStorageObjectHolder;
public class MoneyHolder extends AsyncStorageObjectHolder<Money> public class MoneyHolder extends AsyncStorageObjectHolder<Money>
{ {
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
public MoneyHolder(IEssentials ess) public MoneyHolder(IEssentials ess)
{ {
super(ess, Money.class, new File(ess.getPlugin().getDataFolder(), "economy_npcs.yml")); super(ess, Money.class, new File(ess.getPlugin().getDataFolder(), "economy_npcs.yml"));

View File

@@ -14,16 +14,6 @@ import org.bukkit.material.MaterialData;
public class WorthHolder extends AsyncStorageObjectHolder<net.ess3.economy.Worth> implements IWorth public class WorthHolder extends AsyncStorageObjectHolder<net.ess3.economy.Worth> implements IWorth
{ {
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
public WorthHolder(final IEssentials ess) public WorthHolder(final IEssentials ess)
{ {
super(ess, net.ess3.economy.Worth.class, new File(ess.getPlugin().getDataFolder(), "worth.yml")); super(ess, net.ess3.economy.Worth.class, new File(ess.getPlugin().getDataFolder(), "worth.yml"));

View File

@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Pattern;
import static net.ess3.I18n._; import static net.ess3.I18n._;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.ISettings; import net.ess3.api.ISettings;
@@ -171,7 +172,7 @@ public class EssentialsPlayerListener implements Listener
{ {
event.setJoinMessage(joinMessage); event.setJoinMessage(joinMessage);
} }
final IUser user = ess.getUserMap().getUser(event.getPlayer()); final IUser user = ess.getUserMap().getUser(event.getPlayer());
user.updateDisplayName(); user.updateDisplayName();
@@ -243,7 +244,7 @@ public class EssentialsPlayerListener implements Listener
default: default:
return; return;
} }
ess.getUserMap().addPrejoinedPlayer(event.getPlayer()); ess.getUserMap().addPrejoinedPlayer(event.getPlayer());
final IUser user = ess.getUserMap().getUser(event.getPlayer()); final IUser user = ess.getUserMap().getUser(event.getPlayer());
ess.getUserMap().removePrejoinedPlayer(event.getPlayer()); ess.getUserMap().removePrejoinedPlayer(event.getPlayer());
@@ -318,12 +319,13 @@ public class EssentialsPlayerListener implements Listener
}); });
} }
} }
private final Pattern spaceSplit = Pattern.compile(" ");
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
{ {
final IUser user = ess.getUserMap().getUser(event.getPlayer()); final IUser user = ess.getUserMap().getUser(event.getPlayer());
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH); final String cmd = spaceSplit.split(event.getMessage().toLowerCase(Locale.ENGLISH))[0].replace("/", "").toLowerCase(Locale.ENGLISH);
if (ess.getSettings().getData().getCommands().getSocalspy().getSocialspyCommands().contains(cmd)) if (ess.getSettings().getData().getCommands().getSocalspy().getSocialspyCommands().contains(cmd))
{ {
for (Player player : ess.getServer().getOnlinePlayers()) for (Player player : ess.getServer().getOnlinePlayers())

View File

@@ -96,6 +96,7 @@ public enum Permissions implements IPermission
TELEPORT_HIDDEN, TELEPORT_HIDDEN,
TELEPORT_OTHERS, TELEPORT_OTHERS,
TELEPORT_TIMER_BYPASS, TELEPORT_TIMER_BYPASS,
TELEPORT_TIMER_MOVE,
TEMPBAN_EXEMPT, TEMPBAN_EXEMPT,
TEMPBAN_OFFLINE, TEMPBAN_OFFLINE,
TIME_SET, TIME_SET,

View File

@@ -26,16 +26,6 @@ public class RanksStorage extends AsyncStorageObjectHolder<Ranks> implements IRa
} }
}; };
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
public RanksStorage(final IEssentials ess) public RanksStorage(final IEssentials ess)
{ {
super(ess, Ranks.class, new File(ess.getPlugin().getDataFolder(), "ranks.yml")); super(ess, Ranks.class, new File(ess.getPlugin().getDataFolder(), "ranks.yml"));

View File

@@ -77,7 +77,7 @@ public class General implements StorageObject
{ {
return loginAttackDelay * 1000; return loginAttackDelay * 1000;
} }
public Boolean metricsEnabled = null; private Boolean metricsEnabled = null;
@Comment("The join message when players join the server") @Comment("The join message when players join the server")
private String joinMessage = "&e{PLAYER} has joined the game"; private String joinMessage = "&e{PLAYER} has joined the game";

View File

@@ -8,15 +8,6 @@ import net.ess3.storage.AsyncStorageObjectHolder;
public class SettingsHolder extends AsyncStorageObjectHolder<Settings> implements ISettings public class SettingsHolder extends AsyncStorageObjectHolder<Settings> implements ISettings
{ {
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
private transient volatile boolean debug = false; private transient volatile boolean debug = false;
public SettingsHolder(final IEssentials ess) public SettingsHolder(final IEssentials ess)

View File

@@ -28,16 +28,6 @@ import org.bukkit.plugin.EventExecutor;
public class SpawnsHolder extends AsyncStorageObjectHolder<Spawns> implements IEssentialsModule public class SpawnsHolder extends AsyncStorageObjectHolder<Spawns> implements IEssentialsModule
{ {
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
public SpawnsHolder(final IEssentials ess) public SpawnsHolder(final IEssentials ess)
{ {
super(ess, Spawns.class, new File(ess.getPlugin().getDataFolder(), "spawn.yml")); super(ess, Spawns.class, new File(ess.getPlugin().getDataFolder(), "spawn.yml"));

View File

@@ -8,15 +8,6 @@ import net.ess3.storage.AsyncStorageObjectHolder;
public class WarpHolder extends AsyncStorageObjectHolder<Warp> implements IWarp public class WarpHolder extends AsyncStorageObjectHolder<Warp> implements IWarp
{ {
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
private final String name; private final String name;
public WarpHolder(String name, IEssentials ess) throws InvalidNameException public WarpHolder(String name, IEssentials ess) throws InvalidNameException

View File

@@ -22,53 +22,59 @@ public class Alert implements StorageObject
@ListType(Material.class) @ListType(Material.class)
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
private Set<Material> alertOnPlacement = null; private Set<Material> alertOnPlacement = new HashSet<Material>();
@Comment("For which block types would you like to be alerted when used?") @Comment("For which block types would you like to be alerted when used?")
@ListType(Material.class) @ListType(Material.class)
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
private Set<Material> alertOnUse = null; private Set<Material> alertOnUse = new HashSet<Material>();
@Comment("For which block types would you like to be alerted when broken?") @Comment("For which block types would you like to be alerted when broken?")
@ListType(Material.class) @ListType(Material.class)
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
private Set<Material> alertOnBreak = null; private Set<Material> alertOnBreak = new HashSet<Material>();
public Alert() public Alert()
{ {
if (alertOnPlacement == null) if (alertOnPlacement.isEmpty())
{ {
Material[] mat = Material[] mat =
{ {
Material.LAVA, Material.STATIONARY_LAVA, Material.TNT, Material.LAVA_BUCKET Material.LAVA, Material.STATIONARY_LAVA, Material.TNT, Material.LAVA_BUCKET
}; };
alertOnPlacement = new HashSet<Material>();
alertOnPlacement.addAll(Arrays.asList(mat)); alertOnPlacement.addAll(Arrays.asList(mat));
} }
if (alertOnUse == null) if (alertOnUse.isEmpty())
{ {
alertOnUse = new HashSet<Material>();
alertOnUse.add(Material.LAVA_BUCKET); alertOnUse.add(Material.LAVA_BUCKET);
} }
}
public boolean getAlertOnPlacement(Material mat)
{
if (alertOnPlacement == null)
{
return false;
}
return alertOnPlacement.contains(mat);
}
public boolean getAlertOnUse(Material mat)
{
if (alertOnUse == null)
{
return false;
}
return alertOnUse.contains(mat);
}
public boolean getAlertOnBreak(Material mat)
{
if (alertOnBreak == null) if (alertOnBreak == null)
{ {
alertOnBreak = new HashSet<Material>(); return false;
} }
} return alertOnBreak.contains(mat);
public Set<Material> getAlertOnPlacement()
{
return alertOnPlacement;
}
public Set<Material> getAlertOnUse()
{
return alertOnUse;
}
public Set<Material> getAlertOnBreak()
{
return alertOnBreak;
} }
} }

View File

@@ -25,7 +25,7 @@ public class BlackList implements StorageObject
@ListType(Material.class) @ListType(Material.class)
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
private Set<Material> placement; private Set<Material> placement = new HashSet<Material>();
@Comment( @Comment(
{ {
"Which items should people be prevented from using" "Which items should people be prevented from using"
@@ -33,7 +33,7 @@ public class BlackList implements StorageObject
@ListType(Material.class) @ListType(Material.class)
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
private Set<Material> usage; private Set<Material> usage = new HashSet<Material>();
@Comment( @Comment(
{ {
"Which blocks should people be prevented from breaking" "Which blocks should people be prevented from breaking"
@@ -41,7 +41,7 @@ public class BlackList implements StorageObject
@ListType(Material.class) @ListType(Material.class)
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
private Set<Material> breaking; private Set<Material> breaking = new HashSet<Material>();
@Comment( @Comment(
{ {
"Which blocks should not be pushed by pistons" "Which blocks should not be pushed by pistons"
@@ -49,56 +49,60 @@ public class BlackList implements StorageObject
@ListType(Material.class) @ListType(Material.class)
@Getter(AccessLevel.NONE) @Getter(AccessLevel.NONE)
@Setter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
private Set<Material> piston; private Set<Material> piston = new HashSet<Material>();
public BlackList() public BlackList()
{ {
if (placement == null) if(placement.isEmpty())
{ {
Material[] mat = Material[] mat =
{ {
Material.LAVA, Material.STATIONARY_LAVA, Material.TNT, Material.LAVA_BUCKET Material.LAVA, Material.STATIONARY_LAVA, Material.TNT, Material.LAVA_BUCKET
}; };
placement = new HashSet<Material>();
placement.addAll(Arrays.asList(mat)); placement.addAll(Arrays.asList(mat));
} }
if (usage == null)
if (usage.isEmpty())
{ {
usage = new HashSet<Material>();
usage.add(Material.LAVA_BUCKET); usage.add(Material.LAVA_BUCKET);
} }
}
if (breaking == null)
public boolean getPlacement(Material mat)
{
if(placement == null)
{ {
breaking = new HashSet<Material>(); return false;
} }
return placement.contains(mat);
if (piston == null) }
public boolean getUsage(Material mat)
{
if(usage == null)
{ {
piston = new HashSet<Material>(); return false;
} }
return usage.contains(mat);
} }
public Set<Material> getPlacement() public boolean getBreaking(Material mat)
{ {
return placement; if(breaking == null)
{
return false;
}
return breaking.contains(mat);
} }
public Set<Material> getUsage() public boolean getPiston(Material mat)
{ {
return usage; if(piston == null)
} {
return false;
public Set<Material> getBreaking() }
{ return piston.contains(mat);
return breaking;
}
public Set<Material> getPiston()
{
return piston;
} }
} }

View File

@@ -2,10 +2,7 @@ package net.ess3.storage;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -78,9 +75,17 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
return file.getAbsolutePath(); return file.getAbsolutePath();
} }
public abstract void finishRead(); protected void finishRead()
{
}
public abstract void finishWrite(); protected void finishWrite()
{
}
protected void fillWithDefaults()
{
}
public StorageQueue.RequestState getRequestState(long timestamp) public StorageQueue.RequestState getRequestState(long timestamp)
{ {
@@ -108,6 +113,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
return writer; return writer;
} }
private class StorageObjectDataWriter extends AbstractDelayedYamlFileWriter private class StorageObjectDataWriter extends AbstractDelayedYamlFileWriter
{ {
public StorageObjectDataWriter() public StorageObjectDataWriter()
@@ -176,6 +182,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
loaded.set(true); loaded.set(true);
if (exception instanceof FileNotFoundException) if (exception instanceof FileNotFoundException)
{ {
fillWithDefaults();
writer.schedule(); writer.schedule();
} }
} }

View File

@@ -21,6 +21,8 @@ import org.yaml.snakeyaml.nodes.*;
public class BukkitConstructor extends Constructor public class BukkitConstructor extends Constructor
{ {
private final transient Pattern NUMPATTERN = Pattern.compile("\\d+"); private final transient Pattern NUMPATTERN = Pattern.compile("\\d+");
private final transient Pattern DATAPATTERN = Pattern.compile("[:+',;.]");
private final transient Pattern WORD = Pattern.compile("\\W");
private final transient IPlugin plugin; private final transient IPlugin plugin;
public BukkitConstructor(final Class clazz, final IPlugin plugin) public BukkitConstructor(final Class clazz, final IPlugin plugin)
@@ -59,7 +61,7 @@ public class BukkitConstructor extends Constructor
{ {
return null; return null;
} }
final String[] split = val.split("[:+',;.]", 2); final String[] split = DATAPATTERN.split(val, 2);
if (split.length == 0) if (split.length == 0)
{ {
return null; return null;
@@ -92,12 +94,12 @@ public class BukkitConstructor extends Constructor
{ {
return null; return null;
} }
final String[] split1 = val.split("\\W"); final String[] split1 = WORD.split(val);
if (split1.length == 0) if (split1.length == 0)
{ {
return null; return null;
} }
final String[] split2 = split1[0].split("[:+',;.]", 2); final String[] split2 = DATAPATTERN.split(split1[0], 2);
if (split2.length == 0) if (split2.length == 0)
{ {
return null; return null;
@@ -131,7 +133,7 @@ public class BukkitConstructor extends Constructor
{ {
for (int i = 2; i < split1.length; i++) for (int i = 2; i < split1.length; i++)
{ {
final String[] split3 = split1[0].split("[:+',;.]", 2); final String[] split3 = DATAPATTERN.split(split1[0], 2);
if (split3.length < 1) if (split3.length < 1)
{ {
continue; continue;
@@ -175,7 +177,7 @@ public class BukkitConstructor extends Constructor
{ {
return null; return null;
} }
final String[] split = val.split("[:+',;.]", 2); final String[] split = DATAPATTERN.split(val, 2);
if (split.length == 0) if (split.length == 0)
{ {
return null; return null;

View File

@@ -78,16 +78,6 @@ public class User extends UserBase implements IUser
return player; return player;
} }
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
@Override @Override
public void checkCooldown(final UserData.TimestampType cooldownType, final double cooldown, final boolean set, final IPermission bypassPermission) throws CooldownException public void checkCooldown(final UserData.TimestampType cooldownType, final double cooldown, final boolean set, final IPermission bypassPermission) throws CooldownException
{ {

View File

@@ -7,6 +7,7 @@ import java.util.LinkedHashSet;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.regex.Pattern;
import net.ess3.api.IEssentials; import net.ess3.api.IEssentials;
import net.ess3.api.IUser; import net.ess3.api.IUser;
import net.ess3.api.IUserMap; import net.ess3.api.IUserMap;
@@ -100,19 +101,19 @@ public class UserMap extends StorageObjectMap<IUser> implements IUserMap
{ {
return getObject(player.getName()); return getObject(player.getName());
} }
@Override @Override
public IUser matchUser(final String name, final boolean includeOffline) throws TooManyMatchesException, PlayerNotFoundException public IUser matchUser(final String name, final boolean includeOffline) throws TooManyMatchesException, PlayerNotFoundException
{ {
return matchUser(name, true, includeOffline, null); return matchUser(name, true, includeOffline, null);
} }
@Override @Override
public IUser matchUserExcludingHidden(final String name, final Player requester) throws TooManyMatchesException, PlayerNotFoundException public IUser matchUserExcludingHidden(final String name, final Player requester) throws TooManyMatchesException, PlayerNotFoundException
{ {
return matchUser(name, false, false, requester); return matchUser(name, false, false, requester);
} }
public IUser matchUser(final String name, final boolean includeHidden, final boolean includeOffline, final Player requester) throws TooManyMatchesException, PlayerNotFoundException public IUser matchUser(final String name, final boolean includeHidden, final boolean includeOffline, final Player requester) throws TooManyMatchesException, PlayerNotFoundException
{ {
final Set<IUser> users = matchUsers(name, includeHidden, includeOffline, requester); final Set<IUser> users = matchUsers(name, includeHidden, includeOffline, requester);
@@ -132,7 +133,7 @@ public class UserMap extends StorageObjectMap<IUser> implements IUserMap
} }
} }
} }
@Override @Override
public Set<IUser> matchUsers(final String name, final boolean includeOffline) public Set<IUser> matchUsers(final String name, final boolean includeOffline)
{ {
@@ -144,11 +145,12 @@ public class UserMap extends StorageObjectMap<IUser> implements IUserMap
{ {
return matchUsers(name, false, false, requester); return matchUsers(name, false, false, requester);
} }
private final Pattern comma = Pattern.compile(",");
public Set<IUser> matchUsers(final String name, final boolean includeHidden, final boolean includeOffline, final Player requester) public Set<IUser> matchUsers(final String name, final boolean includeHidden, final boolean includeOffline, final Player requester)
{ {
final String colorlessName = FormatUtil.stripColor(name); final String colorlessName = FormatUtil.stripColor(name);
final String[] search = colorlessName.split(","); final String[] search = comma.split(colorlessName);
final boolean multisearch = search.length > 1; final boolean multisearch = search.length > 1;
final Set<IUser> result = new LinkedHashSet<IUser>(); final Set<IUser> result = new LinkedHashSet<IUser>();
final String nicknamePrefix = FormatUtil.stripColor(getNickNamePrefix()); final String nicknamePrefix = FormatUtil.stripColor(getNickNamePrefix());

View File

@@ -0,0 +1,32 @@
package net.ess3.utils;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
public class Target
{
private final Location location;
private final Entity entity;
public Target(Location location)
{
this.location = location;
this.entity = null;
}
public Target(Entity entity)
{
this.entity = entity;
this.location = null;
}
public Location getLocation()
{
if (this.entity != null)
{
return this.entity.getLocation();
}
return location;
}
}

View File

@@ -5,6 +5,7 @@ import net.ess3.api.IEssentials;
import net.ess3.settings.antibuild.AntiBuild; import net.ess3.settings.antibuild.AntiBuild;
import net.ess3.storage.AsyncStorageObjectHolder; import net.ess3.storage.AsyncStorageObjectHolder;
public class AntiBuildHolder extends AsyncStorageObjectHolder<AntiBuild> public class AntiBuildHolder extends AsyncStorageObjectHolder<AntiBuild>
{ {
public AntiBuildHolder(final IEssentials ess) public AntiBuildHolder(final IEssentials ess)
@@ -12,14 +13,4 @@ public class AntiBuildHolder extends AsyncStorageObjectHolder<AntiBuild>
super(ess, AntiBuild.class, new File(ess.getPlugin().getDataFolder(), "antibuild.yml")); super(ess, AntiBuild.class, new File(ess.getPlugin().getDataFolder(), "antibuild.yml"));
onReload(); onReload();
} }
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
} }

View File

@@ -51,7 +51,7 @@ public class EssentialsAntiBuildListener implements Listener
return; return;
} }
if (antib.getSettings().getData().getBlacklist().getPlacement().contains(type) && !Permissions.BLACKLIST_ALLOWPLACEMENT.isAuthorized(user)) if (antib.getSettings().getData().getBlacklist().getPlacement(type) && !Permissions.BLACKLIST_ALLOWPLACEMENT.isAuthorized(user))
{ {
if (antib.getSettings().getData().isWarnOnBuildDisallow()) if (antib.getSettings().getData().isWarnOnBuildDisallow())
{ {
@@ -61,7 +61,7 @@ public class EssentialsAntiBuildListener implements Listener
return; return;
} }
if (antib.getSettings().getData().getAlert().getAlertOnPlacement().contains(type) if (antib.getSettings().getData().getAlert().getAlertOnPlacement(type)
&& !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
{ {
antib.getEssentialsConnect().alert(user, type.toString(), _("alertPlaced")); antib.getEssentialsConnect().alert(user, type.toString(), _("alertPlaced"));
@@ -88,7 +88,7 @@ public class EssentialsAntiBuildListener implements Listener
return; return;
} }
if (antib.getSettings().getData().getBlacklist().getBreaking().contains(type) && !Permissions.BLACKLIST_ALLOWBREAK.isAuthorized(user)) if (antib.getSettings().getData().getBlacklist().getBreaking(type) && !Permissions.BLACKLIST_ALLOWBREAK.isAuthorized(user))
{ {
if (antib.getSettings().getData().isWarnOnBuildDisallow()) if (antib.getSettings().getData().isWarnOnBuildDisallow())
{ {
@@ -98,7 +98,7 @@ public class EssentialsAntiBuildListener implements Listener
return; return;
} }
if (antib.getSettings().getData().getAlert().getAlertOnBreak().contains(type) if (antib.getSettings().getData().getAlert().getAlertOnBreak(type)
&& !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
{ {
antib.getEssentialsConnect().alert(user, type.toString(), _("alertBroke")); antib.getEssentialsConnect().alert(user, type.toString(), _("alertBroke"));
@@ -130,7 +130,7 @@ public class EssentialsAntiBuildListener implements Listener
{ {
for (Block block : event.getBlocks()) for (Block block : event.getBlocks())
{ {
if (antib.getSettings().getData().getBlacklist().getPiston().contains(block.getType())) if (antib.getSettings().getData().getBlacklist().getPiston(block.getType()))
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@@ -146,7 +146,7 @@ public class EssentialsAntiBuildListener implements Listener
return; return;
} }
final Block block = event.getRetractLocation().getBlock(); final Block block = event.getRetractLocation().getBlock();
if (antib.getSettings().getData().getBlacklist().getPiston().contains(block.getType())) if (antib.getSettings().getData().getBlacklist().getPiston(block.getType()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@@ -160,7 +160,7 @@ public class EssentialsAntiBuildListener implements Listener
final ItemStack item = event.getItem(); final ItemStack item = event.getItem();
if (item != null if (item != null
&& antib.getSettings().getData().getBlacklist().getUsage().contains(item.getType()) && antib.getSettings().getData().getBlacklist().getUsage(item.getType())
&& !Permissions.BLACKLIST_ALLOWUSAGE.isAuthorized(user)) && !Permissions.BLACKLIST_ALLOWUSAGE.isAuthorized(user))
{ {
if (antib.getSettings().getData().isWarnOnBuildDisallow()) if (antib.getSettings().getData().isWarnOnBuildDisallow())
@@ -172,7 +172,7 @@ public class EssentialsAntiBuildListener implements Listener
} }
if (item != null if (item != null
&& antib.getSettings().getData().getAlert().getAlertOnUse().contains(item.getType()) && antib.getSettings().getData().getAlert().getAlertOnUse(item.getType())
&& !Permissions.ALERTS_NOTRIGGER.isAuthorized(user)) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
{ {
antib.getEssentialsConnect().alert(user, item.getType().toString(), _("alertUsed")); antib.getEssentialsConnect().alert(user, item.getType().toString(), _("alertUsed"));

View File

@@ -17,14 +17,4 @@ public class ConfigHolder extends AsyncStorageObjectHolder<GeoIP>
this.geoip = geoip; this.geoip = geoip;
onReload(true); onReload(true);
} }
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
} }

View File

@@ -12,14 +12,4 @@ public class ProtectHolder extends AsyncStorageObjectHolder<Protect>
{ {
super(ess, Protect.class, new File(ess.getPlugin().getDataFolder(), "protect.yml")); super(ess, Protect.class, new File(ess.getPlugin().getDataFolder(), "protect.yml"));
} }
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
} }

View File

@@ -52,14 +52,4 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignConfig>
{ {
return !signsEnabled; return !signsEnabled;
} }
@Override
public void finishRead()
{
}
@Override
public void finishWrite()
{
}
} }