summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-10-06 16:49:40 +0200
committersnowleo <schneeleo@gmail.com>2012-10-06 16:49:40 +0200
commitfabd88dc2585bf6798658f34a7ee122225316fe8 (patch)
treecdda3fad01567f042d5afbaa189ac12ef94f2b7e
parent463c4ff62db553fc980545665a332ef7bbecdcc6 (diff)
downloadEssentials-fabd88dc2585bf6798658f34a7ee122225316fe8.tar
Essentials-fabd88dc2585bf6798658f34a7ee122225316fe8.tar.gz
Essentials-fabd88dc2585bf6798658f34a7ee122225316fe8.tar.lz
Essentials-fabd88dc2585bf6798658f34a7ee122225316fe8.tar.xz
Essentials-fabd88dc2585bf6798658f34a7ee122225316fe8.zip
Less locks please
-rw-r--r--Essentials/src/net/ess3/EssentialsTimer.java15
-rw-r--r--Essentials/src/net/ess3/ItemDb.java3
-rw-r--r--Essentials/src/net/ess3/Jails.java105
-rw-r--r--Essentials/src/net/ess3/Kits.java42
-rw-r--r--Essentials/src/net/ess3/Teleport.java24
-rw-r--r--Essentials/src/net/ess3/Warps.java31
-rw-r--r--Essentials/src/net/ess3/api/IUser.java2
-rw-r--r--Essentials/src/net/ess3/backup/Backup.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandban.java4
-rw-r--r--Essentials/src/net/ess3/commands/Commandbanip.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commanddelhome.java4
-rw-r--r--Essentials/src/net/ess3/commands/Commandeco.java10
-rw-r--r--Essentials/src/net/ess3/commands/Commandignore.java2
-rw-r--r--Essentials/src/net/ess3/commands/Commandinvsee.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandlightning.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandlist.java44
-rw-r--r--Essentials/src/net/ess3/commands/Commandmail.java2
-rw-r--r--Essentials/src/net/ess3/commands/Commandmore.java16
-rw-r--r--Essentials/src/net/ess3/commands/Commandmsg.java7
-rw-r--r--Essentials/src/net/ess3/commands/Commandmute.java4
-rw-r--r--Essentials/src/net/ess3/commands/Commandnick.java6
-rw-r--r--Essentials/src/net/ess3/commands/Commandpowertool.java19
-rw-r--r--Essentials/src/net/ess3/commands/Commandpowertooltoggle.java2
-rw-r--r--Essentials/src/net/ess3/commands/Commandrealname.java4
-rw-r--r--Essentials/src/net/ess3/commands/Commandseen.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandsethome.java9
-rw-r--r--Essentials/src/net/ess3/commands/Commandspawnmob.java14
-rw-r--r--Essentials/src/net/ess3/commands/Commandtempban.java2
-rw-r--r--Essentials/src/net/ess3/commands/Commandtogglejail.java9
-rw-r--r--Essentials/src/net/ess3/commands/Commandtp.java11
-rw-r--r--Essentials/src/net/ess3/commands/Commandtpa.java7
-rw-r--r--Essentials/src/net/ess3/commands/Commandtpaall.java7
-rw-r--r--Essentials/src/net/ess3/commands/Commandtpaccept.java16
-rw-r--r--Essentials/src/net/ess3/commands/Commandtpahere.java7
-rw-r--r--Essentials/src/net/ess3/commands/Commandtpall.java4
-rw-r--r--Essentials/src/net/ess3/commands/Commandtphere.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandtpohere.java4
-rw-r--r--Essentials/src/net/ess3/commands/Commandunban.java5
-rw-r--r--Essentials/src/net/ess3/commands/Commandunbanip.java3
-rw-r--r--Essentials/src/net/ess3/commands/Commandunlimited.java6
-rw-r--r--Essentials/src/net/ess3/commands/Commandwhois.java9
-rw-r--r--Essentials/src/net/ess3/commands/EssentialsCommandHandler.java23
-rw-r--r--Essentials/src/net/ess3/economy/Economy.java81
-rw-r--r--Essentials/src/net/ess3/economy/Money.java30
-rw-r--r--Essentials/src/net/ess3/economy/Trade.java11
-rw-r--r--Essentials/src/net/ess3/economy/WorthHolder.java68
-rw-r--r--Essentials/src/net/ess3/listener/EssentialsBlockListener.java4
-rw-r--r--Essentials/src/net/ess3/listener/EssentialsEntityListener.java33
-rw-r--r--Essentials/src/net/ess3/listener/EssentialsPlayerListener.java50
-rw-r--r--Essentials/src/net/ess3/listener/EssentialsPluginListener.java12
-rw-r--r--Essentials/src/net/ess3/metrics/MetricsListener.java6
-rw-r--r--Essentials/src/net/ess3/metrics/MetricsStarter.java6
-rw-r--r--Essentials/src/net/ess3/ranks/GMGroups.java34
-rw-r--r--Essentials/src/net/ess3/ranks/RanksStorage.java34
-rw-r--r--Essentials/src/net/ess3/ranks/VaultGroups.java3
-rw-r--r--Essentials/src/net/ess3/settings/Jails.java7
-rw-r--r--Essentials/src/net/ess3/settings/SettingsHolder.java35
-rw-r--r--Essentials/src/net/ess3/settings/SpawnsHolder.java124
-rw-r--r--Essentials/src/net/ess3/storage/AsyncStorageObjectHolder.java28
-rw-r--r--Essentials/src/net/ess3/storage/IStorageObjectHolder.java8
-rw-r--r--Essentials/src/net/ess3/user/User.java277
-rw-r--r--Essentials/src/net/ess3/user/UserBase.java329
-rw-r--r--Essentials/src/net/ess3/user/UserMap.java15
-rw-r--r--Essentials/src/net/ess3/utils/FormatUtil.java5
-rw-r--r--Essentials/src/net/ess3/utils/textreader/HelpInput.java3
-rw-r--r--Essentials/src/net/ess3/utils/textreader/KeywordReplacer.java3
-rw-r--r--EssentialsChat/src/net/ess3/chat/EssentialsChatPlayer.java19
-rw-r--r--EssentialsGeoIP/src/net/ess3/geoip/EssentialsGeoIPPlayerListener.java135
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtectBlockListener.java99
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java288
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtectWeatherListener.java49
-rw-r--r--EssentialsSigns/src/net/ess3/signs/SignBlockListener.java6
-rw-r--r--EssentialsSigns/src/net/ess3/signs/SignMail.java11
-rw-r--r--EssentialsSigns/src/net/ess3/signs/SignsConfig.java14
-rw-r--r--EssentialsSigns/src/net/ess3/signs/SignsConfigHolder.java44
75 files changed, 781 insertions, 1594 deletions
diff --git a/Essentials/src/net/ess3/EssentialsTimer.java b/Essentials/src/net/ess3/EssentialsTimer.java
index 8382b6290..0bd902b17 100644
--- a/Essentials/src/net/ess3/EssentialsTimer.java
+++ b/Essentials/src/net/ess3/EssentialsTimer.java
@@ -47,7 +47,8 @@ public class EssentialsTimer implements Runnable
try
{
final IUser user = ess.getUserMap().getUser(player);
- if (user == null) {
+ if (user == null)
+ {
continue;
}
onlineUsers.add(user);
@@ -56,15 +57,9 @@ public class EssentialsTimer implements Runnable
boolean mailDisabled = false;
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- mailDisabled = settings.getData().getCommands().isDisabled("mail");
- }
- finally
- {
- settings.unlock();
- }
+
+ mailDisabled = settings.getData().getCommands().isDisabled("mail");
+
// New mail notification
if (!mailDisabled && Permissions.MAIL.isAuthorized(user) && !user.gotMailInfo())
{
diff --git a/Essentials/src/net/ess3/ItemDb.java b/Essentials/src/net/ess3/ItemDb.java
index 2127dd93e..a34531dcd 100644
--- a/Essentials/src/net/ess3/ItemDb.java
+++ b/Essentials/src/net/ess3/ItemDb.java
@@ -5,7 +5,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
import net.ess3.api.IItemDb;
@@ -66,9 +65,7 @@ public class ItemDb implements IItemDb
{
final ItemStack stack = get(id.toLowerCase(Locale.ENGLISH));
- @Cleanup
net.ess3.api.ISettings settings = ess.getSettings();
- settings.acquireReadLock();
final int defaultStackSize = settings.getData().getGeneral().getDefaultStacksize();
diff --git a/Essentials/src/net/ess3/Jails.java b/Essentials/src/net/ess3/Jails.java
index f2de376ca..93daa0cdb 100644
--- a/Essentials/src/net/ess3/Jails.java
+++ b/Essentials/src/net/ess3/Jails.java
@@ -4,7 +4,6 @@ import java.io.File;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
import net.ess3.api.IJails;
@@ -55,114 +54,68 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@Override
public Location getJail(final String jailName) throws Exception
{
- acquireReadLock();
- try
+ if (getData().getJails() == null || jailName == null
+ || !getData().getJails().containsKey(jailName.toLowerCase(Locale.ENGLISH)))
{
- if (getData().getJails() == null || jailName == null
- || !getData().getJails().containsKey(jailName.toLowerCase(Locale.ENGLISH)))
- {
- throw new Exception(_("jailNotExist"));
- }
- Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH)).getStoredLocation();
- if (loc == null || loc.getWorld() == null)
- {
- throw new Exception(_("jailNotExist"));
- }
- return loc;
+ throw new Exception(_("jailNotExist"));
}
- finally
+ Location loc = getData().getJails().get(jailName.toLowerCase(Locale.ENGLISH)).getStoredLocation();
+ if (loc == null || loc.getWorld() == null)
{
- unlock();
+ throw new Exception(_("jailNotExist"));
}
+ return loc;
}
@Override
public Collection<String> getList() throws Exception
{
- acquireReadLock();
- try
- {
- if (getData().getJails() == null)
- {
- return Collections.emptyList();
- }
- return new ArrayList<String>(getData().getJails().keySet());
- }
- finally
+ if (getData().getJails() == null)
{
- unlock();
+ return Collections.emptyList();
}
+ return new ArrayList<String>(getData().getJails().keySet());
}
@Override
public void removeJail(final String jail) throws Exception
{
- acquireWriteLock();
- try
+ if (getData().getJails() == null)
{
- if (getData().getJails() == null)
- {
- return;
- }
- getData().getJails().remove(jail.toLowerCase(Locale.ENGLISH));
- }
- finally
- {
- unlock();
+ return;
}
+ getData().removeJail(jail.toLowerCase(Locale.ENGLISH));
+ queueSave();
}
@Override
public void sendToJail(final IUser user, final String jail) throws Exception
{
- acquireReadLock();
- try
+ if (user.isOnline())
{
- if (user.isOnline())
- {
- Location loc = getJail(jail);
- user.getTeleport().now(loc, false, TeleportCause.COMMAND);
- }
- user.acquireWriteLock();
- try
- {
- user.getData().setJail(jail);
- }
- finally
- {
- unlock();
- }
- }
- finally
- {
- unlock();
+ Location loc = getJail(jail);
+ user.getTeleport().now(loc, false, TeleportCause.COMMAND);
}
+
+ user.getData().setJail(jail);
+ user.queueSave();
}
@Override
public void setJail(final String jailName, final Location loc) throws Exception
{
- acquireWriteLock();
- try
- {
- getData().addJail(jailName.toLowerCase(Locale.ENGLISH), loc);
- }
- finally
- {
- unlock();
- }
+ getData().addJail(jailName.toLowerCase(Locale.ENGLISH), loc);
+ queueSave();
}
@Override
public void finishRead()
{
-
}
@Override
public void finishWrite()
{
-
}
@Override
@@ -177,9 +130,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (user.getData().isJailed())
{
event.setCancelled(true);
@@ -189,9 +140,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (user.getData().isJailed())
{
event.setCancelled(true);
@@ -201,9 +150,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockDamage(final BlockDamageEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (user.getData().isJailed())
{
event.setCancelled(true);
@@ -217,9 +164,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerInteract(final PlayerInteractEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (user.getData().isJailed())
{
event.setCancelled(true);
@@ -229,9 +174,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
{
return;
@@ -257,9 +200,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
{
return;
@@ -286,9 +227,7 @@ public class Jails extends AsyncStorageObjectHolder<net.ess3.settings.Jails> imp
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(final PlayerJoinEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (!user.getData().isJailed() || user.getData().getJail() == null || user.getData().getJail().isEmpty())
{
return;
diff --git a/Essentials/src/net/ess3/Kits.java b/Essentials/src/net/ess3/Kits.java
index 24d7cdf5f..4e8e15226 100644
--- a/Essentials/src/net/ess3/Kits.java
+++ b/Essentials/src/net/ess3/Kits.java
@@ -32,25 +32,17 @@ public class Kits extends AsyncStorageObjectHolder<net.ess3.settings.Kits> imple
@Override
public Kit getKit(String kitName) throws Exception
{
- acquireReadLock();
- try
+ if (getData().getKits() == null || kitName == null
+ || !getData().getKits().containsKey(kitName.toLowerCase(Locale.ENGLISH)))
{
- if (getData().getKits() == null || kitName == null
- || !getData().getKits().containsKey(kitName.toLowerCase(Locale.ENGLISH)))
- {
- throw new Exception(_("kitError2"));
- }
- final Kit kit = getData().getKits().get(kitName.toLowerCase(Locale.ENGLISH));
- if (kit == null)
- {
- throw new Exception(_("kitError2"));
- }
- return kit;
+ throw new Exception(_("kitError2"));
}
- finally
+ final Kit kit = getData().getKits().get(kitName.toLowerCase(Locale.ENGLISH));
+ if (kit == null)
{
- unlock();
+ throw new Exception(_("kitError2"));
}
+ return kit;
}
@Override
@@ -63,26 +55,18 @@ public class Kits extends AsyncStorageObjectHolder<net.ess3.settings.Kits> imple
@Override
public void sendKit(IUser user, Kit kit) throws Exception
{
- final List<ItemStack> itemList = kit.getItems();
- user.giveItems(itemList, true);
+ final List<ItemStack> itemList = kit.getItems();
+ user.giveItems(itemList, true);
}
@Override
public Collection<String> getList() throws Exception
{
- acquireReadLock();
- try
+ if (getData().getKits() == null)
{
- if (getData().getKits() == null)
- {
- return Collections.emptyList();
- }
- return new ArrayList<String>(getData().getKits().keySet());
- }
- finally
- {
- unlock();
+ return Collections.emptyList();
}
+ return new ArrayList<String>(getData().getKits().keySet());
}
@Override
@@ -94,13 +78,11 @@ public class Kits extends AsyncStorageObjectHolder<net.ess3.settings.Kits> imple
@Override
public void finishRead()
{
-
}
@Override
public void finishWrite()
{
-
}
@Override
diff --git a/Essentials/src/net/ess3/Teleport.java b/Essentials/src/net/ess3/Teleport.java
index 39d6bf8a3..2573f2442 100644
--- a/Essentials/src/net/ess3/Teleport.java
+++ b/Essentials/src/net/ess3/Teleport.java
@@ -20,9 +20,9 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Teleport implements Runnable, ITeleport
{
-
private static final double MOVE_CONSTANT = 0.3;
+
private static class Target
{
private final Location location;
@@ -269,31 +269,15 @@ public class Teleport implements Runnable, ITeleport
@Override
public void back(Trade chargeFor) throws Exception
{
- user.acquireReadLock();
- try
- {
- teleport(new Target(user.getData().getLastLocation().getStoredLocation()), chargeFor, TeleportCause.COMMAND);
- }
- finally
- {
- user.unlock();
- }
+ teleport(new Target(user.getData().getLastLocation().getStoredLocation()), chargeFor, TeleportCause.COMMAND);
}
@Override
public void back() throws Exception
{
- user.acquireReadLock();
- try
- {
- now(new Target(user.getData().getLastLocation().getStoredLocation()), TeleportCause.COMMAND);
- }
- finally
- {
- user.unlock();
- }
+ now(new Target(user.getData().getLastLocation().getStoredLocation()), TeleportCause.COMMAND);
}
-
+
@Override
public void home(Location loc, Trade chargeFor) throws Exception
{
diff --git a/Essentials/src/net/ess3/Warps.java b/Essentials/src/net/ess3/Warps.java
index 04663f6bd..72ffc857f 100644
--- a/Essentials/src/net/ess3/Warps.java
+++ b/Essentials/src/net/ess3/Warps.java
@@ -37,15 +37,7 @@ public class Warps extends StorageObjectMap<IWarp> implements IWarps
{
continue;
}
- warp.acquireReadLock();
- try
- {
- names.add(warp.getData().getName());
- }
- finally
- {
- warp.unlock();
- }
+ names.add(warp.getData().getName());
}
Collections.sort(names, String.CASE_INSENSITIVE_ORDER);
return names;
@@ -59,15 +51,7 @@ public class Warps extends StorageObjectMap<IWarp> implements IWarps
{
throw new WarpNotFoundException(_("warpNotExist"));
}
- warp.acquireReadLock();
- try
- {
- return warp.getData().getLocation().getStoredLocation();
- }
- finally
- {
- warp.unlock();
- }
+ return warp.getData().getLocation().getStoredLocation();
}
@Override
@@ -83,15 +67,8 @@ public class Warps extends StorageObjectMap<IWarp> implements IWarps
{
warp = new WarpHolder(name, ess);
}
- warp.acquireWriteLock();
- try
- {
- warp.getData().setLocation(loc);
- }
- finally
- {
- warp.unlock();
- }
+ warp.getData().setLocation(loc);
+ warp.queueSave();
}
@Override
diff --git a/Essentials/src/net/ess3/api/IUser.java b/Essentials/src/net/ess3/api/IUser.java
index 1f93aaaa3..38af8ee58 100644
--- a/Essentials/src/net/ess3/api/IUser.java
+++ b/Essentials/src/net/ess3/api/IUser.java
@@ -128,7 +128,7 @@ public interface IUser extends OfflinePlayer, CommandSender, IStorageObjectHolde
/**
* Since the Player object should not be stored for a long time, this method should be called again with a null
- * value or the close() method should be called.
+ * value.
*
* @param player
*/
diff --git a/Essentials/src/net/ess3/backup/Backup.java b/Essentials/src/net/ess3/backup/Backup.java
index adb24e924..9b11749e2 100644
--- a/Essentials/src/net/ess3/backup/Backup.java
+++ b/Essentials/src/net/ess3/backup/Backup.java
@@ -5,7 +5,6 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IBackup;
import net.ess3.api.IEssentials;
@@ -37,9 +36,7 @@ public class Backup implements Runnable, IBackup
{
if (running.compareAndSet(false, true))
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
final long interval = settings.getData().getGeneral().getBackup().getInterval() * 1200; // minutes -> ticks
if (interval < 1200)
{
@@ -57,9 +54,7 @@ public class Backup implements Runnable, IBackup
{
return;
}
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
final String command = settings.getData().getGeneral().getBackup().getCommand();
if (command == null || command.isEmpty())
{
diff --git a/Essentials/src/net/ess3/commands/Commandban.java b/Essentials/src/net/ess3/commands/Commandban.java
index f244fecaa..a6a517fa8 100644
--- a/Essentials/src/net/ess3/commands/Commandban.java
+++ b/Essentials/src/net/ess3/commands/Commandban.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import net.ess3.Console;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
@@ -19,7 +18,6 @@ public class Commandban extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- @Cleanup
final IUser user = ess.getUserMap().matchUser(args[0], false, true);
if (!user.isOnline())
{
@@ -38,7 +36,6 @@ public class Commandban extends EssentialsCommand
}
}
- user.acquireWriteLock();
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
String banReason;
user.getData().setBan(new Ban());
@@ -55,6 +52,7 @@ public class Commandban extends EssentialsCommand
}
user.setBanned(true);
+ user.queueSave();
user.getPlayer().kickPlayer(banReason);
for (Player player : server.getOnlinePlayers())
{
diff --git a/Essentials/src/net/ess3/commands/Commandbanip.java b/Essentials/src/net/ess3/commands/Commandbanip.java
index ff9eca5fe..4bcdaa0f0 100644
--- a/Essentials/src/net/ess3/commands/Commandbanip.java
+++ b/Essentials/src/net/ess3/commands/Commandbanip.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import org.bukkit.command.CommandSender;
@@ -16,9 +15,7 @@ public class Commandbanip extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- @Cleanup
final IUser player = ess.getUserMap().getUser(args[0]);
- player.acquireReadLock();
if (player == null)
{
diff --git a/Essentials/src/net/ess3/commands/Commanddelhome.java b/Essentials/src/net/ess3/commands/Commanddelhome.java
index 7cb078537..2bebe25a8 100644
--- a/Essentials/src/net/ess3/commands/Commanddelhome.java
+++ b/Essentials/src/net/ess3/commands/Commanddelhome.java
@@ -1,7 +1,6 @@
package net.ess3.commands;
import java.util.Locale;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
@@ -18,7 +17,6 @@ public class Commanddelhome extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- @Cleanup
IUser user = sender instanceof IUser ? (IUser)sender : null;
String name;
String[] expandedArg;
@@ -51,8 +49,8 @@ public class Commanddelhome extends EssentialsCommand
/*
* if (name.equalsIgnoreCase("bed")) { throw new Exception("You cannot remove the vanilla home point"); }
*/
- user.acquireWriteLock();
user.getData().removeHome(name.toLowerCase(Locale.ENGLISH));
+ user.queueSave();
sender.sendMessage(_("deleteHome", name));
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandeco.java b/Essentials/src/net/ess3/commands/Commandeco.java
index 4b73517f2..f5bc325c0 100644
--- a/Essentials/src/net/ess3/commands/Commandeco.java
+++ b/Essentials/src/net/ess3/commands/Commandeco.java
@@ -1,7 +1,6 @@
package net.ess3.commands;
import java.util.Locale;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -45,13 +44,11 @@ public class Commandeco extends EssentialsCommand
if (player.canAfford(amount, false))
{
player.takeMoney(amount);
- }
+ }
break;
case RESET:
- @Cleanup
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
break;
}
@@ -77,9 +74,7 @@ public class Commandeco extends EssentialsCommand
break;
case RESET:
- @Cleanup
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
break;
}
@@ -103,8 +98,7 @@ public class Commandeco extends EssentialsCommand
break;
case RESET:
- @Cleanup ISettings settings = ess.getSettings();
- settings.acquireReadLock();
+ ISettings settings = ess.getSettings();
player.setMoney(amount == 0 ? settings.getData().getEconomy().getStartingBalance() : amount);
break;
}
diff --git a/Essentials/src/net/ess3/commands/Commandignore.java b/Essentials/src/net/ess3/commands/Commandignore.java
index 14dae478a..bc9dbd283 100644
--- a/Essentials/src/net/ess3/commands/Commandignore.java
+++ b/Essentials/src/net/ess3/commands/Commandignore.java
@@ -15,7 +15,6 @@ public class Commandignore extends EssentialsCommand
}
IUser player = ess.getUserMap().matchUser(args[0], false, false);
- user.acquireWriteLock();
if (user.isIgnoringPlayer(player))
{
user.setIgnoredPlayer(player, false);
@@ -26,5 +25,6 @@ public class Commandignore extends EssentialsCommand
user.setIgnoredPlayer(player, true);
user.sendMessage(_("ignorePlayer", player.getName()));
}
+ user.queueSave();
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandinvsee.java b/Essentials/src/net/ess3/commands/Commandinvsee.java
index f20ac8142..64e52e55d 100644
--- a/Essentials/src/net/ess3/commands/Commandinvsee.java
+++ b/Essentials/src/net/ess3/commands/Commandinvsee.java
@@ -23,17 +23,18 @@ public class Commandinvsee extends EssentialsCommand
{
invUser = ess.getUserMap().matchUser(args[0], false, false);
}
- user.acquireWriteLock();
if (invUser == user && user.getData().getInventory() != null)
{
invUser.getPlayer().getInventory().setContents(user.getData().getInventory().getBukkitInventory());
user.getData().setInventory(null);
+ user.queueSave();
user.sendMessage(_("invRestored"));
throw new NoChargeException();
}
if (user.getData().getInventory() == null)
{
user.getData().setInventory(new Inventory(user.getPlayer().getInventory().getContents()));
+ user.queueSave();
}
ItemStack[] invUserStack = invUser.getPlayer().getInventory().getContents();
final int userStackLength = user.getPlayer().getInventory().getContents().length;
diff --git a/Essentials/src/net/ess3/commands/Commandlightning.java b/Essentials/src/net/ess3/commands/Commandlightning.java
index 56a7122a4..a3cbf8038 100644
--- a/Essentials/src/net/ess3/commands/Commandlightning.java
+++ b/Essentials/src/net/ess3/commands/Commandlightning.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -51,9 +50,7 @@ public class Commandlightning extends EssentialsCommand
{
matchPlayer.getPlayer().damage(power, strike);
}
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (settings.getData().getCommands().getLightning().isWarnPlayer())
{
matchPlayer.sendMessage(_("lightningSmited"));
diff --git a/Essentials/src/net/ess3/commands/Commandlist.java b/Essentials/src/net/ess3/commands/Commandlist.java
index 826dc12d2..c04418a3b 100644
--- a/Essentials/src/net/ess3/commands/Commandlist.java
+++ b/Essentials/src/net/ess3/commands/Commandlist.java
@@ -6,10 +6,10 @@ import net.ess3.api.ISettings;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
import net.ess3.utils.FormatUtil;
-import net.ess3.utils.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
+
public class Commandlist extends EssentialsCommand
{
@Override
@@ -40,17 +40,9 @@ public class Commandlist extends EssentialsCommand
}
sender.sendMessage(online);
- boolean sortListByGroups = false;
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- sortListByGroups = settings.getData().getCommands().getList().isSortByGroups();
- }
- finally
- {
- settings.unlock();
- }
+
+ boolean sortListByGroups = sortListByGroups = settings.getData().getCommands().getList().isSortByGroups();
if (sortListByGroups)
{
@@ -76,7 +68,7 @@ public class Commandlist extends EssentialsCommand
for (String group : groups)
{
final StringBuilder groupString = new StringBuilder();
- groupString.append(_("listGroupTag",FormatUtil.replaceFormat(group)));
+ groupString.append(_("listGroupTag", FormatUtil.replaceFormat(group)));
final List<IUser> users = sort.get(group);
Collections.sort(users);
boolean first = true;
@@ -90,18 +82,12 @@ public class Commandlist extends EssentialsCommand
{
first = false;
}
- user.acquireReadLock();
- try
- {
- if (user.getData().isAfk())
- {
- groupString.append(_("listAfkTag"));
- }
- }
- finally
+
+ if (user.getData().isAfk())
{
- user.unlock();
+ groupString.append(_("listAfkTag"));
}
+
if (user.isHidden())
{
groupString.append(_("listHiddenTag"));
@@ -140,18 +126,12 @@ public class Commandlist extends EssentialsCommand
{
first = false;
}
- user.acquireReadLock();
- try
- {
- if (user.getData().isAfk())
- {
- onlineUsers.append(_("listAfkTag"));
- }
- }
- finally
+
+ if (user.getData().isAfk())
{
- user.unlock();
+ onlineUsers.append(_("listAfkTag"));
}
+
if (user.isHidden())
{
onlineUsers.append(_("listHiddenTag"));
diff --git a/Essentials/src/net/ess3/commands/Commandmail.java b/Essentials/src/net/ess3/commands/Commandmail.java
index d9d341e09..3ee10cccb 100644
--- a/Essentials/src/net/ess3/commands/Commandmail.java
+++ b/Essentials/src/net/ess3/commands/Commandmail.java
@@ -62,8 +62,8 @@ public class Commandmail extends EssentialsCommand
}
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
- user.acquireWriteLock();
user.getData().clearMails();
+ user.queueSave();
user.sendMessage(_("mailCleared"));
return;
}
diff --git a/Essentials/src/net/ess3/commands/Commandmore.java b/Essentials/src/net/ess3/commands/Commandmore.java
index 804305073..9b5a8b8ae 100644
--- a/Essentials/src/net/ess3/commands/Commandmore.java
+++ b/Essentials/src/net/ess3/commands/Commandmore.java
@@ -18,19 +18,11 @@ public class Commandmore extends EssentialsCommand
{
throw new Exception(_("cantSpawnItem", "Air"));
}
- int defaultStackSize = 0;
- int oversizedStackSize = 0;
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- defaultStackSize = settings.getData().getGeneral().getDefaultStacksize();
- oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize();
- }
- finally
- {
- settings.unlock();
- }
+
+ int defaultStackSize = settings.getData().getGeneral().getDefaultStacksize();
+ int oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize();
+
if (stack.getAmount() >= (Permissions.OVERSIZEDSTACKS.isAuthorized(user)
? oversizedStackSize
: defaultStackSize > 0 ? defaultStackSize : stack.getMaxStackSize()))
diff --git a/Essentials/src/net/ess3/commands/Commandmsg.java b/Essentials/src/net/ess3/commands/Commandmsg.java
index 35b01bcf6..dcc76c185 100644
--- a/Essentials/src/net/ess3/commands/Commandmsg.java
+++ b/Essentials/src/net/ess3/commands/Commandmsg.java
@@ -1,15 +1,12 @@
package net.ess3.commands;
-import java.util.List;
import java.util.Set;
-import lombok.Cleanup;
import net.ess3.Console;
import static net.ess3.I18n._;
import net.ess3.api.IReplyTo;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
import net.ess3.utils.FormatUtil;
-import net.ess3.utils.Util;
import org.bukkit.command.CommandSender;
@@ -27,9 +24,7 @@ public class Commandmsg extends EssentialsCommand
String message = getFinalArg(args, 1);
if (isUser(sender))
{
- @Cleanup
- IUser user = getUser(sender);
- user.acquireReadLock();
+ IUser user = getUser(sender);;
if (user.getData().isMuted())
{
throw new Exception(_("voiceSilenced"));
diff --git a/Essentials/src/net/ess3/commands/Commandmute.java b/Essentials/src/net/ess3/commands/Commandmute.java
index 2fffc300c..5cbba493b 100644
--- a/Essentials/src/net/ess3/commands/Commandmute.java
+++ b/Essentials/src/net/ess3/commands/Commandmute.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
@@ -8,6 +7,7 @@ import net.ess3.user.UserData.TimestampType;
import net.ess3.utils.DateUtil;
import org.bukkit.command.CommandSender;
+
public class Commandmute extends EssentialsCommand
{
@Override
@@ -18,9 +18,7 @@ public class Commandmute extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- @Cleanup
final IUser player = ess.getUserMap().matchUser(args[0], false, true);
- player.acquireReadLock();
if (!player.getData().isMuted() && Permissions.MUTE_EXEMPT.isAuthorized(player))
{
throw new Exception(_("muteExempt"));
diff --git a/Essentials/src/net/ess3/commands/Commandnick.java b/Essentials/src/net/ess3/commands/Commandnick.java
index 8dda9fa99..86cc8113e 100644
--- a/Essentials/src/net/ess3/commands/Commandnick.java
+++ b/Essentials/src/net/ess3/commands/Commandnick.java
@@ -1,13 +1,11 @@
package net.ess3.commands;
import java.util.Locale;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
import net.ess3.utils.FormatUtil;
-import net.ess3.utils.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -22,9 +20,7 @@ public class Commandnick extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (!settings.getData().getChat().getChangeDisplayname())
{
throw new Exception(_("nickDisplayName"));
@@ -49,9 +45,7 @@ public class Commandnick extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (!settings.getData().getChat().getChangeDisplayname())
{
throw new Exception(_("nickDisplayName"));
diff --git a/Essentials/src/net/ess3/commands/Commandpowertool.java b/Essentials/src/net/ess3/commands/Commandpowertool.java
index 00187a4a6..b1b6cae20 100644
--- a/Essentials/src/net/ess3/commands/Commandpowertool.java
+++ b/Essentials/src/net/ess3/commands/Commandpowertool.java
@@ -21,8 +21,8 @@ public class Commandpowertool extends EssentialsCommand
// check to see if this is a clear all command
if (command != null && command.equalsIgnoreCase("d:"))
{
- user.acquireWriteLock();
user.getData().clearAllPowertools();
+ user.queueSave();
user.sendMessage(_("powerToolClearAll"));
return;
}
@@ -34,7 +34,6 @@ public class Commandpowertool extends EssentialsCommand
}
final String itemName = itemStack.getType().toString().toLowerCase(Locale.ENGLISH).replaceAll("_", " ");
- user.acquireReadLock();
List<String> powertools = user.getData().getPowertool(itemStack.getType());
if (command != null && !command.isEmpty())
{
@@ -57,7 +56,8 @@ public class Commandpowertool extends EssentialsCommand
{
throw new Exception(_("powerToolNoSuchCommandAssigned", command, itemName));
}
-
+
+ powertools = new ArrayList<String>(powertools);
powertools.remove(command);
user.sendMessage(_("powerToolRemove", command, itemName));
}
@@ -74,11 +74,7 @@ public class Commandpowertool extends EssentialsCommand
{
throw new Exception(_("powerToolAlreadySet", command, itemName));
}
- }
- else if (powertools != null && !powertools.isEmpty())
- {
- // Replace all commands with this one
- powertools.clear();
+ powertools = new ArrayList<String>(powertools);
}
else
{
@@ -91,10 +87,7 @@ public class Commandpowertool extends EssentialsCommand
}
else
{
- if (powertools != null)
- {
- powertools.clear();
- }
+ powertools = new ArrayList<String>();
user.sendMessage(_("powerToolRemoveAll", itemName));
}
@@ -103,7 +96,7 @@ public class Commandpowertool extends EssentialsCommand
user.getData().setPowerToolsEnabled(true);
user.sendMessage(_("powerToolsEnabled"));
}
- user.acquireWriteLock();
user.getData().setPowertool(itemStack.getType(), powertools);
+ user.queueSave();
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandpowertooltoggle.java b/Essentials/src/net/ess3/commands/Commandpowertooltoggle.java
index a7875e1b7..0455104ed 100644
--- a/Essentials/src/net/ess3/commands/Commandpowertooltoggle.java
+++ b/Essentials/src/net/ess3/commands/Commandpowertooltoggle.java
@@ -14,8 +14,8 @@ public class Commandpowertooltoggle extends EssentialsCommand
user.sendMessage(_("noPowerTools"));
return;
}
- user.acquireWriteLock();
user.getData().setPowerToolsEnabled(!user.getData().isPowerToolsEnabled());
+ user.queueSave();
user.sendMessage(user.getData().isPowerToolsEnabled()
? _("powerToolsEnabled")
: _("powerToolsDisabled"));
diff --git a/Essentials/src/net/ess3/commands/Commandrealname.java b/Essentials/src/net/ess3/commands/Commandrealname.java
index a5b5e933c..40c6b3003 100644
--- a/Essentials/src/net/ess3/commands/Commandrealname.java
+++ b/Essentials/src/net/ess3/commands/Commandrealname.java
@@ -1,12 +1,10 @@
package net.ess3.commands;
import java.util.Locale;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
import net.ess3.utils.FormatUtil;
-import net.ess3.utils.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -20,7 +18,6 @@ public class Commandrealname extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- @Cleanup
final ISettings settings = ess.getSettings();
final String whois = args[0].toLowerCase(Locale.ENGLISH);
for (Player onlinePlayer : server.getOnlinePlayers())
@@ -32,7 +29,6 @@ public class Commandrealname extends EssentialsCommand
}
u.setDisplayNick();
final String displayName = FormatUtil.stripFormat(u.getPlayer().getDisplayName()).toLowerCase(Locale.ENGLISH);
- settings.acquireReadLock();
if (!whois.equals(displayName)
&& !displayName.equals(FormatUtil.stripFormat(settings.getData().getChat().getNicknamePrefix()) + whois)
&& !whois.equalsIgnoreCase(u.getName()))
diff --git a/Essentials/src/net/ess3/commands/Commandseen.java b/Essentials/src/net/ess3/commands/Commandseen.java
index 830a34ef4..4cc3ba1eb 100644
--- a/Essentials/src/net/ess3/commands/Commandseen.java
+++ b/Essentials/src/net/ess3/commands/Commandseen.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
@@ -36,13 +35,11 @@ public class Commandseen extends EssentialsCommand
}
catch (PlayerNotFoundException e)
{
- @Cleanup
IUser u = ess.getUserMap().getUser(args[0]);
if (u == null)
{
throw new Exception(_("playerNotFound"));
}
- u.acquireReadLock();
sender.sendMessage(_("seenOffline", u.getPlayer().getDisplayName(), DateUtil.formatDateDiff(u.getTimestamp(TimestampType.LOGOUT))));
if (u.isBanned())
{
diff --git a/Essentials/src/net/ess3/commands/Commandsethome.java b/Essentials/src/net/ess3/commands/Commandsethome.java
index e9dba7e57..6b46106f3 100644
--- a/Essentials/src/net/ess3/commands/Commandsethome.java
+++ b/Essentials/src/net/ess3/commands/Commandsethome.java
@@ -1,8 +1,6 @@
package net.ess3.commands;
-import java.util.HashMap;
import java.util.Locale;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
@@ -33,8 +31,8 @@ public class Commandsethome extends EssentialsCommand
if ((user.getHomes().size() < ess.getRanks().getHomeLimit(user))
|| (user.getHomes().contains(args[0].toLowerCase(Locale.ENGLISH))))
{
- user.acquireWriteLock();
user.getData().addHome(args[0].toLowerCase(Locale.ENGLISH), user.getPlayer().getLocation());
+ user.queueSave();
}
else
{
@@ -51,7 +49,6 @@ public class Commandsethome extends EssentialsCommand
{
if (Permissions.SETHOME_OTHERS.isAuthorized(user))
{
- @Cleanup
IUser usersHome = ess.getUserMap().getUser(ess.getServer().getPlayer(args[0]));
if (usersHome == null)
{
@@ -67,15 +64,15 @@ public class Commandsethome extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- usersHome.acquireWriteLock();
usersHome.getData().addHome(name, user.getPlayer().getLocation());
+ usersHome.queueSave();
}
}
}
else
{
- user.acquireWriteLock();
user.getData().addHome("home", user.getPlayer().getLocation());
+ user.queueSave();
}
user.sendMessage(_("homeSet", user.getPlayer().getLocation().getWorld().getName(), user.getPlayer().getLocation().getBlockX(), user.getPlayer().getLocation().getBlockY(), user.getPlayer().getLocation().getBlockZ()));
diff --git a/Essentials/src/net/ess3/commands/Commandspawnmob.java b/Essentials/src/net/ess3/commands/Commandspawnmob.java
index 300cb198f..2fe07e450 100644
--- a/Essentials/src/net/ess3/commands/Commandspawnmob.java
+++ b/Essentials/src/net/ess3/commands/Commandspawnmob.java
@@ -136,17 +136,11 @@ public class Commandspawnmob extends EssentialsCommand
if (args.length >= 2)
{
int mobCount = Integer.parseInt(args[1]);
- int serverLimit = 1;
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- serverLimit = settings.getData().getCommands().getSpawnmob().getLimit();
- }
- finally
- {
- settings.unlock();
- }
+
+ int serverLimit = settings.getData().getCommands().getSpawnmob().getLimit();
+
if (mobCount > serverLimit)
{
mobCount = serverLimit;
diff --git a/Essentials/src/net/ess3/commands/Commandtempban.java b/Essentials/src/net/ess3/commands/Commandtempban.java
index 28febd4e6..a687cbb0d 100644
--- a/Essentials/src/net/ess3/commands/Commandtempban.java
+++ b/Essentials/src/net/ess3/commands/Commandtempban.java
@@ -40,11 +40,11 @@ public class Commandtempban extends EssentialsCommand
final long banTimestamp = DateUtil.parseDateDiff(time, true);
final String banReason = _("tempBanned", DateUtil.formatDateDiff(banTimestamp));
- user.acquireWriteLock();
user.getData().setBan(new Ban());
user.getData().getBan().setReason(banReason);
user.getData().getBan().setTimeout(banTimestamp);
user.setBanned(true);
+ user.queueSave();
user.getPlayer().kickPlayer(banReason);
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
diff --git a/Essentials/src/net/ess3/commands/Commandtogglejail.java b/Essentials/src/net/ess3/commands/Commandtogglejail.java
index 059197e93..cf033aa12 100644
--- a/Essentials/src/net/ess3/commands/Commandtogglejail.java
+++ b/Essentials/src/net/ess3/commands/Commandtogglejail.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.permissions.Permissions;
@@ -19,9 +18,7 @@ public class Commandtogglejail extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- @Cleanup
final IUser player = ess.getUserMap().matchUser(args[0], false, true);
- player.acquireReadLock();
if (args.length >= 2 && !player.getData().isJailed())
{
@@ -50,7 +47,6 @@ public class Commandtogglejail extends EssentialsCommand
// Check if jail exists
ess.getJails().getJail(args[1]);
}
- player.acquireWriteLock();
player.getData().setJailed(true);
player.sendMessage(_("userJailed"));
player.getData().setJail(args[1]);
@@ -61,6 +57,7 @@ public class Commandtogglejail extends EssentialsCommand
timeDiff = DateUtil.parseDateDiff(time, true);
player.setTimestamp(TimestampType.JAIL, timeDiff);
}
+ player.queueSave();
sender.sendMessage((timeDiff > 0
? _("playerJailedFor", player.getName(), DateUtil.formatDateDiff(timeDiff))
: _("playerJailed", player.getName())));
@@ -77,8 +74,8 @@ public class Commandtogglejail extends EssentialsCommand
{
final String time = getFinalArg(args, 2);
final long timeDiff = DateUtil.parseDateDiff(time, true);
- player.acquireWriteLock();
player.setTimestamp(TimestampType.JAIL, timeDiff);
+ player.queueSave();
sender.sendMessage(_("jailSentenceExtended", DateUtil.formatDateDiff(timeDiff)));
return;
}
@@ -89,7 +86,6 @@ public class Commandtogglejail extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
- player.acquireWriteLock();
player.getData().setJailed(false);
player.setTimestamp(TimestampType.JAIL, 0);
player.sendMessage(_("jailReleasedPlayerNotify"));
@@ -98,6 +94,7 @@ public class Commandtogglejail extends EssentialsCommand
{
player.getTeleport().back();
}
+ player.queueSave();
sender.sendMessage(_("jailReleased", player.getName()));
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandtp.java b/Essentials/src/net/ess3/commands/Commandtp.java
index d63e0e34e..5a3acb3bc 100644
--- a/Essentials/src/net/ess3/commands/Commandtp.java
+++ b/Essentials/src/net/ess3/commands/Commandtp.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import net.ess3.Console;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
@@ -16,18 +15,14 @@ public class Commandtp extends EssentialsCommand
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
- @Cleanup
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
switch (args.length)
{
case 0:
throw new NotEnoughArgumentsException();
case 1:
- @Cleanup
final IUser player = ess.getUserMap().matchUser(args[0], false, false);
- player.acquireReadLock();
if (!player.getData().isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName()));
@@ -49,12 +44,10 @@ public class Commandtp extends EssentialsCommand
throw new Exception(_("needTpohere"));
}
user.sendMessage(_("teleporting"));
- @Cleanup
+
final IUser target = ess.getUserMap().matchUser(args[0], false, false);
- @Cleanup
+
final IUser toPlayer = ess.getUserMap().matchUser(args[1], false, false);
- target.acquireReadLock();
- toPlayer.acquireReadLock();
if (!target.getData().isTeleportEnabled())
{
diff --git a/Essentials/src/net/ess3/commands/Commandtpa.java b/Essentials/src/net/ess3/commands/Commandtpa.java
index 7e895c0ce..214a07f44 100644
--- a/Essentials/src/net/ess3/commands/Commandtpa.java
+++ b/Essentials/src/net/ess3/commands/Commandtpa.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -17,16 +16,14 @@ public class Commandtpa extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- @Cleanup
+
IUser player = ess.getUserMap().matchUser(args[0], false, false);
- player.acquireReadLock();
if (!player.getData().isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName()));
}
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions()
&& !Permissions.WORLD.isAuthorized(user, user.getPlayer().getWorld().getName()))
{
diff --git a/Essentials/src/net/ess3/commands/Commandtpaall.java b/Essentials/src/net/ess3/commands/Commandtpaall.java
index b78834c9b..6629a4929 100644
--- a/Essentials/src/net/ess3/commands/Commandtpaall.java
+++ b/Essentials/src/net/ess3/commands/Commandtpaall.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -33,9 +32,8 @@ public class Commandtpaall extends EssentialsCommand
sender.sendMessage(_("teleportAAll"));
for (Player onlinePlayer : server.getOnlinePlayers())
{
- @Cleanup
+
final IUser player = ess.getUserMap().getUser(onlinePlayer);
- player.acquireReadLock();
if (user == player)
{
continue;
@@ -44,9 +42,8 @@ public class Commandtpaall extends EssentialsCommand
{
continue;
}
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
&& !Permissions.WORLD.isAuthorized(user, user.getPlayer().getWorld().getName()))
{
diff --git a/Essentials/src/net/ess3/commands/Commandtpaccept.java b/Essentials/src/net/ess3/commands/Commandtpaccept.java
index 59b909958..a33d216ad 100644
--- a/Essentials/src/net/ess3/commands/Commandtpaccept.java
+++ b/Essentials/src/net/ess3/commands/Commandtpaccept.java
@@ -19,30 +19,22 @@ public class Commandtpaccept extends EssentialsCommand
}
final IUser target = user.getTeleportRequester();
- if (target == null
+ if (target == null
|| !target.isOnline()
|| (user.isTpRequestHere() && !Permissions.TPAHERE.isAuthorized(target))
|| (!user.isTpRequestHere() && !Permissions.TPA.isAuthorized(target) && !Permissions.TPAALL.isAuthorized(target)))
{
throw new Exception(_("noPendingRequest"));
}
-
+
if (args.length > 0 && !target.getName().contains(args[0]))
{
throw new Exception(_("noPendingRequest"));
}
- int tpaAcceptCancellation = 0;
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout();
- }
- finally
- {
- settings.unlock();
- }
+ int tpaAcceptCancellation = settings.getData().getCommands().getTpa().getTimeout();
if (tpaAcceptCancellation != 0 && (System.currentTimeMillis() - user.getTeleportRequestTime()) / 1000 > tpaAcceptCancellation)
{
diff --git a/Essentials/src/net/ess3/commands/Commandtpahere.java b/Essentials/src/net/ess3/commands/Commandtpahere.java
index 866e6158b..00cc6171d 100644
--- a/Essentials/src/net/ess3/commands/Commandtpahere.java
+++ b/Essentials/src/net/ess3/commands/Commandtpahere.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -17,16 +16,14 @@ public class Commandtpahere extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- @Cleanup
+
final IUser player = ess.getUserMap().matchUser(args[0], false, false);
- player.acquireReadLock();
if (!player.getData().isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName()));
}
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
&& !Permissions.WORLD.isAuthorized(user, user.getPlayer().getWorld().getName()))
{
diff --git a/Essentials/src/net/ess3/commands/Commandtpall.java b/Essentials/src/net/ess3/commands/Commandtpall.java
index b5a4425f3..fc07a1610 100644
--- a/Essentials/src/net/ess3/commands/Commandtpall.java
+++ b/Essentials/src/net/ess3/commands/Commandtpall.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -39,9 +38,8 @@ public class Commandtpall extends EssentialsCommand
{
continue;
}
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
&& !Permissions.WORLD.isAuthorized(user, user.getPlayer().getWorld().getName()))
diff --git a/Essentials/src/net/ess3/commands/Commandtphere.java b/Essentials/src/net/ess3/commands/Commandtphere.java
index 31af0192e..a47f28edd 100644
--- a/Essentials/src/net/ess3/commands/Commandtphere.java
+++ b/Essentials/src/net/ess3/commands/Commandtphere.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.economy.Trade;
@@ -11,10 +10,8 @@ public class Commandtphere extends EssentialsCommand
{
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
- {
- @Cleanup
+ {
final IUser player = ess.getUserMap().matchUser(args[0], false, false);
- player.acquireReadLock();
if (!player.getData().isTeleportEnabled())
{
throw new Exception(_("teleportDisabled", player.getPlayer().getDisplayName()));
diff --git a/Essentials/src/net/ess3/commands/Commandtpohere.java b/Essentials/src/net/ess3/commands/Commandtpohere.java
index abb79d6c0..7bf25dac7 100644
--- a/Essentials/src/net/ess3/commands/Commandtpohere.java
+++ b/Essentials/src/net/ess3/commands/Commandtpohere.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -26,9 +25,8 @@ public class Commandtpohere extends EssentialsCommand
{
throw new NoSuchFieldException(_("playerNotFound"));
}
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
//todo - common method
if (user.getPlayer().getWorld() != player.getPlayer().getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
&& !Permissions.WORLD.isAuthorized(player, user.getPlayer().getWorld().getName()))
diff --git a/Essentials/src/net/ess3/commands/Commandunban.java b/Essentials/src/net/ess3/commands/Commandunban.java
index 9144887d3..5693454ad 100644
--- a/Essentials/src/net/ess3/commands/Commandunban.java
+++ b/Essentials/src/net/ess3/commands/Commandunban.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import org.bukkit.command.CommandSender;
@@ -16,11 +15,11 @@ public class Commandunban extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- @Cleanup
+
final IUser player = ess.getUserMap().matchUser(args[0], false, true);
- player.acquireWriteLock();
player.getData().setBan(null);
player.setBanned(false);
+ player.queueSave();
sender.sendMessage(_("unbannedPlayer"));
}
}
diff --git a/Essentials/src/net/ess3/commands/Commandunbanip.java b/Essentials/src/net/ess3/commands/Commandunbanip.java
index 2feaa2e5a..1fd07f09b 100644
--- a/Essentials/src/net/ess3/commands/Commandunbanip.java
+++ b/Essentials/src/net/ess3/commands/Commandunbanip.java
@@ -1,6 +1,5 @@
package net.ess3.commands;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import org.bukkit.command.CommandSender;
@@ -17,9 +16,7 @@ public class Commandunbanip extends EssentialsCommand
}
try
{
- @Cleanup
final IUser user = ess.getUserMap().matchUser(args[0], false, true);
- user.acquireReadLock();
ess.getServer().unbanIP(user.getData().getIpAddress());
}
catch (Exception ex)
diff --git a/Essentials/src/net/ess3/commands/Commandunlimited.java b/Essentials/src/net/ess3/commands/Commandunlimited.java
index d9eb8cb51..91483a62a 100644
--- a/Essentials/src/net/ess3/commands/Commandunlimited.java
+++ b/Essentials/src/net/ess3/commands/Commandunlimited.java
@@ -2,7 +2,6 @@ package net.ess3.commands;
import java.util.Locale;
import java.util.Set;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IUser;
import net.ess3.craftbukkit.InventoryWorkaround;
@@ -21,13 +20,12 @@ public class Commandunlimited extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
- @Cleanup
+
IUser target = user;
if (args.length > 1 && Permissions.UNLIMITED_OTHERS.isAuthorized(user))
{
target = ess.getUserMap().matchUser(args[1], false, false);
- target.acquireReadLock();
}
if (args[0].equalsIgnoreCase("list"))
@@ -103,8 +101,8 @@ public class Commandunlimited extends EssentialsCommand
user.sendMessage(_(message, itemname, target.getPlayer().getDisplayName()));
}
target.sendMessage(_(message, itemname, target.getPlayer().getDisplayName()));
- target.acquireWriteLock();
target.getData().setUnlimited(stack.getType(), enableUnlimited);
+ target.queueSave();
return true;
}
diff --git a/Essentials/src/net/ess3/commands/Commandwhois.java b/Essentials/src/net/ess3/commands/Commandwhois.java
index 1b4d8fae4..c6d314787 100644
--- a/Essentials/src/net/ess3/commands/Commandwhois.java
+++ b/Essentials/src/net/ess3/commands/Commandwhois.java
@@ -1,7 +1,6 @@
package net.ess3.commands;
import java.util.Locale;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -15,7 +14,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-
public class Commandwhois extends EssentialsCommand
{
@Override
@@ -38,21 +36,18 @@ public class Commandwhois extends EssentialsCommand
showhidden = true;
}
final String whois = args[0].toLowerCase(Locale.ENGLISH);
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
final int prefixLength = FormatUtil.stripColor(settings.getData().getChat().getNicknamePrefix()).length();
boolean foundPlayer = false;
for (Player onlinePlayer : server.getOnlinePlayers())
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(onlinePlayer);
if (user.isHidden() && !showhidden)
{
continue;
}
- user.acquireReadLock();
final String nickName = FormatUtil.stripFormat(user.getData().getNickname());
if (!whois.equalsIgnoreCase(nickName)
&& !whois.substring(prefixLength).equalsIgnoreCase(nickName)
@@ -90,7 +85,7 @@ public class Commandwhois extends EssentialsCommand
? DateUtil.formatDateDiff(user.getTimestamp(UserData.TimestampType.MUTE))
: _("true")
: _("false"))));
-
+
if (!foundPlayer)
{
throw new NoSuchFieldException(_("playerNotFound"));
diff --git a/Essentials/src/net/ess3/commands/EssentialsCommandHandler.java b/Essentials/src/net/ess3/commands/EssentialsCommandHandler.java
index 231f7b756..e5d54a33f 100644
--- a/Essentials/src/net/ess3/commands/EssentialsCommandHandler.java
+++ b/Essentials/src/net/ess3/commands/EssentialsCommandHandler.java
@@ -51,19 +51,11 @@ public class EssentialsCommandHandler implements ICommandHandler
@Override
public boolean handleCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
{
- boolean disabled = false;
- boolean overridden = false;
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- disabled = settings.getData().getCommands().isDisabled(command.getName());
- overridden = !disabled || settings.getData().getCommands().isOverridden(command.getName());
- }
- finally
- {
- settings.unlock();
- }
+
+ boolean disabled = settings.getData().getCommands().isDisabled(command.getName());
+ boolean overridden = !disabled || settings.getData().getCommands().isOverridden(command.getName());
+
// TODO: Move this stuff to bukkit workarounds
// Allow plugins to override the command via onCommand
if (!overridden && (!commandLabel.startsWith("e") || commandLabel.equalsIgnoreCase(command.getName())))
@@ -71,7 +63,7 @@ public class EssentialsCommandHandler implements ICommandHandler
final PluginCommand pc = getAlternative(commandLabel);
if (pc != null)
{
-
+
executed(commandLabel, pc.getLabel());
try
{
@@ -133,7 +125,7 @@ public class EssentialsCommandHandler implements ICommandHandler
sender.sendMessage(_("noAccessCommand"));
return true;
}
-
+
IUser user = null;
if (sender instanceof Player)
{
@@ -150,7 +142,6 @@ public class EssentialsCommandHandler implements ICommandHandler
}
else
{
- user.acquireReadLock();
user.setPlayerCache((Player)sender);
try
{
@@ -158,7 +149,7 @@ public class EssentialsCommandHandler implements ICommandHandler
}
finally
{
- user.unlock();
+ user.setPlayerCache(null);
}
}
return true;
diff --git a/Essentials/src/net/ess3/economy/Economy.java b/Essentials/src/net/ess3/economy/Economy.java
index 0eef9e99a..a2a25738b 100644
--- a/Essentials/src/net/ess3/economy/Economy.java
+++ b/Essentials/src/net/ess3/economy/Economy.java
@@ -1,12 +1,10 @@
package net.ess3.economy;
-import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import net.ess3.api.*;
import net.ess3.permissions.Permissions;
import net.ess3.utils.FormatUtil;
-import net.ess3.utils.Util;
public class Economy implements IEconomy
@@ -22,64 +20,27 @@ public class Economy implements IEconomy
private double getNPCBalance(String name) throws UserDoesNotExistException
{
- npcs.acquireReadLock();
- try
- {
- Map<String, Double> balances = npcs.getData().getBalances();
- if (balances == null)
- {
- throw new UserDoesNotExistException(name);
- }
- Double balance = npcs.getData().getBalances().get(name.toLowerCase(Locale.ENGLISH));
- if (balance == null)
- {
- throw new UserDoesNotExistException(name);
- }
- return balance;
- }
- finally
+ Double balance = npcs.getData().getBalances().get(name.toLowerCase(Locale.ENGLISH));
+ if (balance == null)
{
- npcs.unlock();
+ throw new UserDoesNotExistException(name);
}
+ return balance;
}
private void setNPCBalance(String name, double balance, boolean checkExistance) throws UserDoesNotExistException
{
- npcs.acquireWriteLock();
- try
- {
- Map<String, Double> balances = npcs.getData().getBalances();
- if (balances == null)
- {
- balances = new HashMap<String, Double>();
- npcs.getData().setBalances(balances);
- }
- if (checkExistance && !balances.containsKey(name.toLowerCase(Locale.ENGLISH)))
- {
- throw new UserDoesNotExistException(name);
- }
- balances.put(name.toLowerCase(Locale.ENGLISH), balance);
- }
- finally
+ Map<String, Double> balances = npcs.getData().getBalances();
+ if (checkExistance && !balances.containsKey(name.toLowerCase(Locale.ENGLISH)))
{
- npcs.unlock();
+ throw new UserDoesNotExistException(name);
}
+ npcs.getData().setBalance(name.toLowerCase(Locale.ENGLISH), balance);
}
private double getStartingBalance()
{
- double startingBalance = 0;
- ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- startingBalance = settings.getData().getEconomy().getStartingBalance();
- }
- finally
- {
- settings.unlock();
- }
- return startingBalance;
+ return ess.getSettings().getData().getEconomy().getStartingBalance();
}
@Override
@@ -182,27 +143,15 @@ public class Economy implements IEconomy
@Override
public void removeNPC(String name) throws UserDoesNotExistException
{
- npcs.acquireWriteLock();
- try
+ Map<String, Double> balances = npcs.getData().getBalances();
+
+ if (balances.containsKey(name.toLowerCase(Locale.ENGLISH)))
{
- Map<String, Double> balances = npcs.getData().getBalances();
- if (balances == null)
- {
- balances = new HashMap<String, Double>();
- npcs.getData().setBalances(balances);
- }
- if (balances.containsKey(name.toLowerCase(Locale.ENGLISH)))
- {
- balances.remove(name.toLowerCase(Locale.ENGLISH));
- }
- else
- {
- throw new UserDoesNotExistException(name);
- }
+ npcs.getData().removeBalance(name.toLowerCase(Locale.ENGLISH));
}
- finally
+ else
{
- npcs.unlock();
+ throw new UserDoesNotExistException(name);
}
}
}
diff --git a/Essentials/src/net/ess3/economy/Money.java b/Essentials/src/net/ess3/economy/Money.java
index 01da6d5ce..2eb9d1a6e 100644
--- a/Essentials/src/net/ess3/economy/Money.java
+++ b/Essentials/src/net/ess3/economy/Money.java
@@ -1,9 +1,13 @@
package net.ess3.economy;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
import net.ess3.storage.MapValueType;
import net.ess3.storage.StorageObject;
@@ -13,5 +17,29 @@ import net.ess3.storage.StorageObject;
public class Money implements StorageObject
{
@MapValueType(Double.class)
- private Map<String, Double> balances = new HashMap<String, Double>();
+ @Getter(AccessLevel.NONE)
+ @Setter(AccessLevel.NONE)
+ private Map<String, Double> balances;
+
+ public Map<String, Double> getBalances()
+ {
+ return balances == null
+ ? Collections.<String, Double>emptyMap()
+ : Collections.unmodifiableMap(balances);
+ }
+
+ public void setBalance(String name, Double value) {
+ Map<String, Double> balanceMap = new HashMap<String, Double>(getBalances());
+ balanceMap.put(name, value);
+ balances = balanceMap;
+ }
+
+ void removeBalance(String name)
+ {
+ Map<String, Double> balanceMap = new HashMap<String, Double>(getBalances());
+ balanceMap.remove(name);
+ balances = balanceMap;
+ }
+
+
}
diff --git a/Essentials/src/net/ess3/economy/Trade.java b/Essentials/src/net/ess3/economy/Trade.java
index b912af304..380f98af4 100644
--- a/Essentials/src/net/ess3/economy/Trade.java
+++ b/Essentials/src/net/ess3/economy/Trade.java
@@ -9,7 +9,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.ChargeException;
import net.ess3.api.IEssentials;
@@ -81,9 +80,8 @@ public class Trade
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
- @Cleanup
+
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
double money;
if (command != null && !command.isEmpty()
@@ -167,15 +165,14 @@ public class Trade
{
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
}
- InventoryWorkaround.removeItem(user.getPlayer().getInventory() , true, true, getItemStack());
+ InventoryWorkaround.removeItem(user.getPlayer().getInventory(), true, true, getItemStack());
user.getPlayer().updateInventory();
}
if (command != null && !command.isEmpty()
&& !Permissions.NOCOMMANDCOST.isAuthorized(user, command))
{
- @Cleanup
+
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
final double cost = settings.getData().getEconomy().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
if (!user.canAfford(cost) && cost > 0)
{
@@ -227,9 +224,7 @@ public class Trade
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (!settings.getData().getEconomy().isLogEnabled())
{
return;
diff --git a/Essentials/src/net/ess3/economy/WorthHolder.java b/Essentials/src/net/ess3/economy/WorthHolder.java
index 736629f98..fec53cd43 100644
--- a/Essentials/src/net/ess3/economy/WorthHolder.java
+++ b/Essentials/src/net/ess3/economy/WorthHolder.java
@@ -2,7 +2,6 @@ package net.ess3.economy;
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
import java.util.Map;
import net.ess3.api.IEssentials;
import net.ess3.api.IWorth;
@@ -15,20 +14,16 @@ import org.bukkit.material.MaterialData;
public class WorthHolder extends AsyncStorageObjectHolder<net.ess3.economy.Worth> implements IWorth
{
-
@Override
public void finishRead()
{
-
}
@Override
public void finishWrite()
{
-
}
-
-
+
public WorthHolder(final IEssentials ess)
{
super(ess, net.ess3.economy.Worth.class);
@@ -38,55 +33,44 @@ public class WorthHolder extends AsyncStorageObjectHolder<net.ess3.economy.Worth
@Override
public double getPrice(final ItemStack itemStack)
{
- this.acquireReadLock();
- try
+ final Map<MaterialData, Double> prices = this.getData().getSell();
+ if (prices == null || itemStack == null)
{
- final Map<MaterialData, Double> prices = this.getData().getSell();
- if (prices == null || itemStack == null)
- {
- return Double.NaN;
- }
- final Double basePrice = prices.get(itemStack.getData());
- if (basePrice == null || Double.isNaN(basePrice))
- {
- return Double.NaN;
- }
- double multiplier = 1.0;
- if (itemStack.getType().getMaxDurability() > 0) {
- multiplier *= (double)itemStack.getDurability() / (double)itemStack.getType().getMaxDurability();
- }
- if (itemStack.getEnchantments() != null && !itemStack.getEnchantments().isEmpty())
+ return Double.NaN;
+ }
+ final Double basePrice = prices.get(itemStack.getData());
+ if (basePrice == null || Double.isNaN(basePrice))
+ {
+ return Double.NaN;
+ }
+ double multiplier = 1.0;
+ if (itemStack.getType().getMaxDurability() > 0)
+ {
+ multiplier *= (double)itemStack.getDurability() / (double)itemStack.getType().getMaxDurability();
+ }
+ if (itemStack.getEnchantments() != null && !itemStack.getEnchantments().isEmpty())
+ {
+ final Map<EnchantmentLevel, Double> enchantmentMultipliers = this.getData().getEnchantmentMultiplier();
+ if (enchantmentMultipliers != null)
{
- final Map<EnchantmentLevel, Double> enchantmentMultipliers = this.getData().getEnchantmentMultiplier();
- if (enchantmentMultipliers != null)
+ for (Map.Entry<Enchantment, Integer> entry : itemStack.getEnchantments().entrySet())
{
- for (Map.Entry<Enchantment, Integer> entry : itemStack.getEnchantments().entrySet())
+ final Double enchMult = enchantmentMultipliers.get(new EnchantmentLevel(entry.getKey(), entry.getValue()));
+ if (enchMult != null)
{
- final Double enchMult = enchantmentMultipliers.get(new EnchantmentLevel(entry.getKey(), entry.getValue()));
- if (enchMult != null)
- {
- multiplier *= enchMult;
- }
+ multiplier *= enchMult;
}
}
}
- return basePrice * multiplier;
- }
- finally
- {
- this.unlock();
}
+ return basePrice * multiplier;
}
@Override
public void setPrice(final ItemStack itemStack, final double price)
{
- acquireWriteLock();
- try {
- getData().setSellPrice(itemStack.getData(), price);
- } finally {
- unlock();
- }
+ getData().setSellPrice(itemStack.getData(), price);
+ queueSave();
}
@Override
diff --git a/Essentials/src/net/ess3/listener/EssentialsBlockListener.java b/Essentials/src/net/ess3/listener/EssentialsBlockListener.java
index 2ef258fb0..61e9c5b25 100644
--- a/Essentials/src/net/ess3/listener/EssentialsBlockListener.java
+++ b/Essentials/src/net/ess3/listener/EssentialsBlockListener.java
@@ -1,6 +1,5 @@
package net.ess3.listener;
-import lombok.Cleanup;
import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import net.ess3.bukkit.BukkitMaterial;
@@ -33,9 +32,8 @@ public class EssentialsBlockListener implements Listener
return;
}
- @Cleanup
+
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
final boolean unlimitedForUser = user.getData().hasUnlimited(itemstack.getType());
if (unlimitedForUser && user.getPlayer().getGameMode() != GameMode.CREATIVE)
diff --git a/Essentials/src/net/ess3/listener/EssentialsEntityListener.java b/Essentials/src/net/ess3/listener/EssentialsEntityListener.java
index c56660d17..dad113f08 100644
--- a/Essentials/src/net/ess3/listener/EssentialsEntityListener.java
+++ b/Essentials/src/net/ess3/listener/EssentialsEntityListener.java
@@ -1,7 +1,6 @@
package net.ess3.listener;
import java.util.List;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
import net.ess3.api.ISettings;
@@ -38,15 +37,12 @@ public class EssentialsEntityListener implements Listener
if (eDefend instanceof Player && eAttack instanceof Player)
{
- @Cleanup
+
final IUser attacker = ess.getUserMap().getUser((Player)eAttack);
- @Cleanup
+
final IUser defender = ess.getUserMap().getUser((Player)eDefend);
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- attacker.acquireReadLock();
- defender.acquireReadLock();
attacker.updateActivity(true);
if (settings.getData().getGeneral().getLoginAttackDelay() > 0 && !Permissions.PVPDELAY_EXEMPT.isAuthorized(attacker)
@@ -121,9 +117,8 @@ public class EssentialsEntityListener implements Listener
public void onPlayerDeathEvent(final PlayerDeathEvent event)
{
final IUser user = ess.getUserMap().getUser((Player)event.getEntity());
- @Cleanup
+
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (Permissions.BACK_ONDEATH.isAuthorized(user) && !settings.getData().getCommands().isDisabled("back"))
{
user.setLastLocation();
@@ -161,12 +156,10 @@ public class EssentialsEntityListener implements Listener
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player)
{
- @Cleanup
+
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- @Cleanup
+
final IUser user = ess.getUserMap().getUser((Player)event.getEntity());
- user.acquireReadLock();
if (user.getData().isAfk() && settings.getData().getCommands().getAfk().isFreezeAFKPlayers())
{
event.setCancelled(true);
@@ -187,18 +180,10 @@ public class EssentialsEntityListener implements Listener
return;
}
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
+ final Boolean prevent = settings.getData().getWorldOptions(event.getLocation().getWorld().getName()).getPreventSpawn(creature);
+ if (prevent != null && prevent)
{
- final Boolean prevent = settings.getData().getWorldOptions(event.getLocation().getWorld().getName()).getPreventSpawn(creature);
- if (prevent != null && prevent)
- {
- event.setCancelled(true);
- }
- }
- finally
- {
- settings.unlock();
+ event.setCancelled(true);
}
}
}
diff --git a/Essentials/src/net/ess3/listener/EssentialsPlayerListener.java b/Essentials/src/net/ess3/listener/EssentialsPlayerListener.java
index c2712f599..b14ce9f10 100644
--- a/Essentials/src/net/ess3/listener/EssentialsPlayerListener.java
+++ b/Essentials/src/net/ess3/listener/EssentialsPlayerListener.java
@@ -7,7 +7,6 @@ import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
import net.ess3.api.ISettings;
@@ -60,9 +59,7 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChat(final PlayerChatEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (user.getData().isMuted())
{
event.setCancelled(true);
@@ -85,12 +82,9 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
- @Cleanup
+
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (user.getData().isAfk() && settings.getData().getCommands().getAfk().isFreezeAFKPlayers())
{
@@ -120,12 +114,9 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(final PlayerQuitEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
- @Cleanup
+
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (settings.getData().getCommands().getGod().isRemoveOnDisconnect() && user.isGodModeEnabled())
{
user.setGodModeEnabled(false);
@@ -151,9 +142,8 @@ public class EssentialsPlayerListener implements Listener
return;
}
ess.getBackup().startTask();
- @Cleanup
+
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireWriteLock();
user.updateDisplayName();
user.getData().setIpAddress(user.getPlayer().getAddress().getAddress().getHostAddress());
@@ -171,10 +161,10 @@ public class EssentialsPlayerListener implements Listener
{
user.getPlayer().setSleepingIgnored(true);
}
+ user.queueSave();
+
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (!settings.getData().getCommands().isDisabled("motd") && Permissions.MOTD.isAuthorized(user))
{
@@ -224,9 +214,8 @@ public class EssentialsPlayerListener implements Listener
default:
return;
}
- @Cleanup
+
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireWriteLock();
user.getData().setNpc(false);
final long currentTime = System.currentTimeMillis();
@@ -250,14 +239,14 @@ public class EssentialsPlayerListener implements Listener
user.setTimestamp(TimestampType.LOGIN, System.currentTimeMillis());
user.updateCompass();
+ user.queueSave();
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event)
{
- @Cleanup
+
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && settings.getData().getCommands().getBack().isRegisterBackInListener())
{
@@ -270,9 +259,8 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
{
- @Cleanup
+
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
final ItemStack hand = new ItemStack(Material.EGG, 1);
if (user.getData().hasUnlimited(hand.getType()))
{
@@ -284,9 +272,8 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
{
- @Cleanup
+
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (user.getData().hasUnlimited(event.getBucket()))
{
event.getItemStack().setType(event.getBucket());
@@ -311,9 +298,7 @@ public class EssentialsPlayerListener implements Listener
{
for (Player player : ess.getServer().getOnlinePlayers())
{
- @Cleanup
IUser spyer = ess.getUserMap().getUser(player);
- spyer.acquireReadLock();
if (spyer.getData().isSocialspy() && !user.equals(spyer))
{
player.sendMessage(user.getPlayer().getDisplayName() + " : " + event.getMessage());
@@ -329,12 +314,9 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- @Cleanup
+
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (settings.getData().getChat().getChangeDisplayname())
{
user.updateDisplayName();
@@ -359,9 +341,7 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteract(final PlayerInteractEvent event)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
user.updateActivity(true);
switch (event.getAction())
{
@@ -370,9 +350,8 @@ public class EssentialsPlayerListener implements Listener
{
return;
}
- @Cleanup
+
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (settings.getData().getCommands().getHome().isUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
{
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
@@ -441,16 +420,13 @@ public class EssentialsPlayerListener implements Listener
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerPickupItem(final PlayerPickupItemEvent event)
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (!settings.getData().getCommands().getAfk().isDisableItemPickupWhileAfk())
{
return;
}
- @Cleanup
+
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- user.acquireReadLock();
if (user.getData().isAfk())
{
event.setCancelled(true);
diff --git a/Essentials/src/net/ess3/listener/EssentialsPluginListener.java b/Essentials/src/net/ess3/listener/EssentialsPluginListener.java
index 46b87a28c..3d51e1ff7 100644
--- a/Essentials/src/net/ess3/listener/EssentialsPluginListener.java
+++ b/Essentials/src/net/ess3/listener/EssentialsPluginListener.java
@@ -65,16 +65,8 @@ public class EssentialsPluginListener implements Listener, IReload
private void checkGroups()
{
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- General.GroupStorage storage = General.GroupStorage.FILE;
- try
- {
- storage = settings.getData().getGeneral().getGroupStorage();
- }
- finally
- {
- settings.unlock();
- }
+ General.GroupStorage storage = settings.getData().getGeneral().getGroupStorage();
+
if (storage == General.GroupStorage.GROUPMANAGER)
{
Plugin groupManager = ess.getServer().getPluginManager().getPlugin("GroupManager");
diff --git a/Essentials/src/net/ess3/metrics/MetricsListener.java b/Essentials/src/net/ess3/metrics/MetricsListener.java
index f499af028..5054b2349 100644
--- a/Essentials/src/net/ess3/metrics/MetricsListener.java
+++ b/Essentials/src/net/ess3/metrics/MetricsListener.java
@@ -1,7 +1,6 @@
package net.ess3.metrics;
import java.util.logging.Level;
-import lombok.Cleanup;
import net.ess3.api.IEssentials;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
@@ -30,16 +29,15 @@ public class MetricsListener implements Listener
public void onPlayerJoin(final PlayerJoinEvent event)
{
final IUser player = ess.getUserMap().getUser(event.getPlayer());
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (settings.getData().getGeneral().getMetricsEnabled() == null && (Permissions.ESSENTIALS.isAuthorized(event.getPlayer()) || event.getPlayer().hasPermission("bukkit.broadcast.admin")))
{
player.sendMessage("PluginMetrics collects minimal statistic data, starting in about 5 minutes.");
player.sendMessage("To opt out, run /essentials opt-out");
ess.getLogger().log(Level.INFO, "[Metrics] Admin join - Starting 5 minute opt-out period.");
- settings.acquireWriteLock();
settings.getData().getGeneral().setMetricsEnabled(true);
+ settings.queueSave();
ess.getPlugin().scheduleAsyncDelayedTask(starter, 5 * 1200);
}
}
diff --git a/Essentials/src/net/ess3/metrics/MetricsStarter.java b/Essentials/src/net/ess3/metrics/MetricsStarter.java
index d93ff1642..a6caec3d9 100644
--- a/Essentials/src/net/ess3/metrics/MetricsStarter.java
+++ b/Essentials/src/net/ess3/metrics/MetricsStarter.java
@@ -2,7 +2,6 @@ package net.ess3.metrics;
import java.util.Locale;
import java.util.logging.Level;
-import lombok.Cleanup;
import net.ess3.api.IEssentials;
import net.ess3.api.ISettings;
import net.ess3.economy.register.Method;
@@ -38,9 +37,7 @@ public class MetricsStarter implements Runnable
final Metrics metrics = new Metrics(ess.getPlugin());
ess.setMetrics(metrics);
- @Cleanup
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (!metrics.isOptOut())
{
if (settings.getData().getGeneral().getMetricsEnabled() == true)
@@ -128,9 +125,8 @@ public class MetricsStarter implements Runnable
final Graph enabledGraph = metrics.createGraph("EnabledFeatures");
enabledGraph.addPlotter(new SimplePlotter("Total"));
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
final String BKcommand = settings.getData().getGeneral().getBackup().getCommand();;
if (BKcommand != null && !"".equals(BKcommand))
{
diff --git a/Essentials/src/net/ess3/ranks/GMGroups.java b/Essentials/src/net/ess3/ranks/GMGroups.java
index a4da105bf..3e12476f1 100644
--- a/Essentials/src/net/ess3/ranks/GMGroups.java
+++ b/Essentials/src/net/ess3/ranks/GMGroups.java
@@ -1,7 +1,6 @@
package net.ess3.ranks;
import java.text.MessageFormat;
-import lombok.Cleanup;
import net.ess3.api.IEssentials;
import net.ess3.api.IRanks;
import net.ess3.api.ISettings;
@@ -11,7 +10,9 @@ import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
import org.bukkit.plugin.Plugin;
-public class GMGroups implements IRanks {
+
+public class GMGroups implements IRanks
+{
private final transient IEssentials ess;
private final transient GroupManager groupManager;
@@ -90,32 +91,31 @@ public class GMGroups implements IRanks {
@Override
public MessageFormat getChatFormat(final IUser player)
{
- String format = getRawChatFormat(player);
- format = FormatUtil.replaceFormat(format);
- format = format.replace("{DISPLAYNAME}", "%1$s");
- format = format.replace("{GROUP}", "{0}");
- format = format.replace("{MESSAGE}", "%2$s");
- format = format.replace("{WORLDNAME}", "{1}");
- format = format.replace("{SHORTWORLDNAME}", "{2}");
- format = format.replaceAll("\\{(\\D*)\\}", "\\[$1\\]");
- MessageFormat mFormat = new MessageFormat(format);
- return mFormat;
+ String format = getRawChatFormat(player);
+ format = FormatUtil.replaceFormat(format);
+ format = format.replace("{DISPLAYNAME}", "%1$s");
+ format = format.replace("{GROUP}", "{0}");
+ format = format.replace("{MESSAGE}", "%2$s");
+ format = format.replace("{WORLDNAME}", "{1}");
+ format = format.replace("{SHORTWORLDNAME}", "{2}");
+ format = format.replaceAll("\\{(\\D*)\\}", "\\[$1\\]");
+ MessageFormat mFormat = new MessageFormat(format);
+ return mFormat;
}
-
+
private String getRawChatFormat(final IUser player)
{
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(player.getPlayer());
if (handler != null)
{
String chatformat = handler.getPermissionString(player.getName(), "chatformat");
- if (chatformat != null && !chatformat.isEmpty()) {
+ if (chatformat != null && !chatformat.isEmpty())
+ {
return chatformat;
}
}
-
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
return settings.getData().getChat().getDefaultFormat();
}
diff --git a/Essentials/src/net/ess3/ranks/RanksStorage.java b/Essentials/src/net/ess3/ranks/RanksStorage.java
index 1d7964cfc..b0a8bc1e2 100644
--- a/Essentials/src/net/ess3/ranks/RanksStorage.java
+++ b/Essentials/src/net/ess3/ranks/RanksStorage.java
@@ -7,7 +7,6 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
-import lombok.Cleanup;
import net.ess3.api.IEssentials;
import net.ess3.api.IRanks;
import net.ess3.api.ISettings;
@@ -43,31 +42,23 @@ public class RanksStorage extends AsyncStorageObjectHolder<Ranks> implements IRa
public Collection<Entry<String, RankOptions>> getGroups(final IUser player)
{
- acquireReadLock();
- try
+ final Map<String, RankOptions> groups = getData().getRanks();
+ if (groups == null || groups.isEmpty())
{
- final Map<String, RankOptions> groups = getData().getRanks();
- if (groups == null || groups.isEmpty())
- {
- return Collections.emptyList();
- }
- final ArrayList<Entry<String, RankOptions>> list = new ArrayList();
- for (Entry<String, RankOptions> entry : groups.entrySet())
+ return Collections.emptyList();
+ }
+ final ArrayList<Entry<String, RankOptions>> list = new ArrayList();
+ for (Entry<String, RankOptions> entry : groups.entrySet())
+ {
+ if (Permissions.RANKS.isAuthorized(player, entry.getKey()))
{
- if (Permissions.RANKS.isAuthorized(player, entry.getKey()))
+ if (entry.getValue() != null)
{
- if (entry.getValue() != null)
- {
- list.add(entry);
- }
+ list.add(entry);
}
}
- return list;
- }
- finally
- {
- unlock();
}
+ return list;
}
@Override
@@ -173,9 +164,8 @@ public class RanksStorage extends AsyncStorageObjectHolder<Ranks> implements IRa
return groupOptions.getValue().getMessageFormat();
}
}
- @Cleanup
+
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
return settings.getData().getChat().getDefaultFormat();
}
diff --git a/Essentials/src/net/ess3/ranks/VaultGroups.java b/Essentials/src/net/ess3/ranks/VaultGroups.java
index d6cc35d10..f8fd7ff2e 100644
--- a/Essentials/src/net/ess3/ranks/VaultGroups.java
+++ b/Essentials/src/net/ess3/ranks/VaultGroups.java
@@ -1,7 +1,6 @@
package net.ess3.ranks;
import java.text.MessageFormat;
-import lombok.Cleanup;
import net.ess3.api.IEssentials;
import net.ess3.api.IRanks;
import net.ess3.api.ISettings;
@@ -92,9 +91,7 @@ public class VaultGroups implements IRanks
return chatformat;
}
- @Cleanup
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
return settings.getData().getChat().getDefaultFormat();
}
diff --git a/Essentials/src/net/ess3/settings/Jails.java b/Essentials/src/net/ess3/settings/Jails.java
index db8f5f9bc..394a1d437 100644
--- a/Essentials/src/net/ess3/settings/Jails.java
+++ b/Essentials/src/net/ess3/settings/Jails.java
@@ -35,4 +35,11 @@ public class Jails implements StorageObject
jailMap.put(name, new StoredLocation(loc));
jails = jailMap;
}
+
+ public void removeJail(String name)
+ {
+ Map<String, StoredLocation> jailMap = new HashMap<String, StoredLocation>(getJails());
+ jailMap.remove(name);
+ jails = jailMap;
+ }
}
diff --git a/Essentials/src/net/ess3/settings/SettingsHolder.java b/Essentials/src/net/ess3/settings/SettingsHolder.java
index f161c2580..0f4746f49 100644
--- a/Essentials/src/net/ess3/settings/SettingsHolder.java
+++ b/Essentials/src/net/ess3/settings/SettingsHolder.java
@@ -9,19 +9,17 @@ import net.ess3.storage.AsyncStorageObjectHolder;
public class SettingsHolder extends AsyncStorageObjectHolder<Settings> implements ISettings
{
-
@Override
public void finishRead()
{
-
}
@Override
public void finishWrite()
{
-
}
- private final transient AtomicBoolean debug = new AtomicBoolean(false);
+ private transient volatile boolean debug = false;
+
public SettingsHolder(final IEssentials ess)
{
super(ess, Settings.class);
@@ -32,12 +30,8 @@ public class SettingsHolder extends AsyncStorageObjectHolder<Settings> implement
public final void onReload()
{
super.onReload();
- acquireReadLock();
- try {
- debug.set(getData().getGeneral().isDebug());
- } finally {
- unlock();
- }
+
+ debug = getData().getGeneral().isDebug();
}
@Override
@@ -49,29 +43,20 @@ public class SettingsHolder extends AsyncStorageObjectHolder<Settings> implement
@Override
public String getLocale()
{
- acquireReadLock();
- try {
- return getData().getGeneral().getLocale();
- } finally {
- unlock();
- }
+ return getData().getGeneral().getLocale();
}
@Override
public boolean isDebug()
{
- return debug.get();
+ return debug;
}
-
+
@Override
public void setDebug(final boolean set)
{
- debug.set(set);
- acquireWriteLock();
- try {
- getData().getGeneral().setDebug(set);
- } finally {
- unlock();
- }
+ debug = set;
+ getData().getGeneral().setDebug(set);
+ queueSave();
}
}
diff --git a/Essentials/src/net/ess3/settings/SpawnsHolder.java b/Essentials/src/net/ess3/settings/SpawnsHolder.java
index 0adc733c6..8686ae46e 100644
--- a/Essentials/src/net/ess3/settings/SpawnsHolder.java
+++ b/Essentials/src/net/ess3/settings/SpawnsHolder.java
@@ -29,19 +29,16 @@ import org.bukkit.plugin.EventExecutor;
public class SpawnsHolder extends AsyncStorageObjectHolder<Spawns> implements IEssentialsModule
{
-
@Override
public void finishRead()
{
-
}
@Override
public void finishWrite()
{
-
}
-
+
public SpawnsHolder(final IEssentials ess)
{
super(ess, Spawns.class);
@@ -57,15 +54,8 @@ public class SpawnsHolder extends AsyncStorageObjectHolder<Spawns> implements IE
public void setSpawn(final Location loc, final String group)
{
- acquireWriteLock();
- try
- {
- getData().addSpawn(group, loc);
- }
- finally
- {
- unlock();
- }
+ getData().addSpawn(group, loc);
+ queueSave();
if ("default".equalsIgnoreCase(group))
{
@@ -75,35 +65,27 @@ public class SpawnsHolder extends AsyncStorageObjectHolder<Spawns> implements IE
public Location getSpawn(final String group)
{
- acquireReadLock();
+ if (getData().getSpawns() == null || group == null)
+ {
+ return getWorldSpawn();
+ }
+ final Map<String, net.ess3.storage.StoredLocation> spawnMap = getData().getSpawns();
+ String groupName = group.toLowerCase(Locale.ENGLISH);
+ if (!spawnMap.containsKey(groupName))
+ {
+ groupName = "default";
+ }
+ if (!spawnMap.containsKey(groupName))
+ {
+ return getWorldSpawn();
+ }
try
{
- if (getData().getSpawns() == null || group == null)
- {
- return getWorldSpawn();
- }
- final Map<String, net.ess3.storage.StoredLocation> spawnMap = getData().getSpawns();
- String groupName = group.toLowerCase(Locale.ENGLISH);
- if (!spawnMap.containsKey(groupName))
- {
- groupName = "default";
- }
- if (!spawnMap.containsKey(groupName))
- {
- return getWorldSpawn();
- }
- try
- {
- return spawnMap.get(groupName).getStoredLocation();
- }
- catch (WorldNotLoadedException ex)
- {
- return getWorldSpawn();
- }
+ return spawnMap.get(groupName).getStoredLocation();
}
- finally
+ catch (WorldNotLoadedException ex)
{
- unlock();
+ return getWorldSpawn();
}
}
@@ -122,70 +104,37 @@ public class SpawnsHolder extends AsyncStorageObjectHolder<Spawns> implements IE
public EventPriority getRespawnPriority()
{
- acquireReadLock();
- try
+ for (EventPriority priority : EventPriority.values())
{
- for (EventPriority priority : EventPriority.values())
+ if (priority.toString().equalsIgnoreCase(getData().getRespawnPriority()))
{
- if (priority.toString().equalsIgnoreCase(getData().getRespawnPriority()))
- {
- return priority;
- }
+ return priority;
}
- return EventPriority.NORMAL;
- }
- finally
- {
- unlock();
}
+ return EventPriority.NORMAL;
}
public Location getNewbieSpawn()
{
- acquireReadLock();
- try
- {
- if (getData().getNewbieSpawn() == null || getData().getNewbieSpawn().isEmpty()
- || getData().getNewbieSpawn().equalsIgnoreCase("none"))
- {
- return null;
- }
- return getSpawn(getData().getNewbieSpawn());
- }
- finally
+ if (getData().getNewbieSpawn() == null || getData().getNewbieSpawn().isEmpty()
+ || getData().getNewbieSpawn().equalsIgnoreCase("none"))
{
- unlock();
+ return null;
}
+ return getSpawn(getData().getNewbieSpawn());
}
public boolean getAnnounceNewPlayers()
{
- acquireReadLock();
- try
- {
- return getData().getNewPlayerAnnouncement() != null && !getData().getNewPlayerAnnouncement().isEmpty();
- }
- finally
- {
- unlock();
- }
+ return getData().getNewPlayerAnnouncement() != null && !getData().getNewPlayerAnnouncement().isEmpty();
}
public String getAnnounceNewPlayerFormat(IUser user)
{
- acquireReadLock();
- try
- {
- return getData().getNewPlayerAnnouncement().replace('&', '\u00a7').replace("\u00a7\u00a7", "&").replace("{PLAYER}", user.getPlayer().getDisplayName()).replace("{DISPLAYNAME}", user.getPlayer().getDisplayName()).replace("{GROUP}", ess.getRanks().getMainGroup(user)).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getPlayer().getAddress().toString());
- }
- finally
- {
- unlock();
- }
+ return getData().getNewPlayerAnnouncement().replace('&', '\u00a7').replace("\u00a7\u00a7", "&").replace("{PLAYER}", user.getPlayer().getDisplayName()).replace("{DISPLAYNAME}", user.getPlayer().getDisplayName()).replace("{GROUP}", ess.getRanks().getMainGroup(user)).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getPlayer().getAddress().toString());
}
-
- //TODO: Why is this stuff here in the settings folder?
+ //TODO: Why is this stuff here in the settings folder?
private void registerListeners()
{
final SpawnPlayerListener playerListener = new SpawnPlayerListener(ess, this);
@@ -224,17 +173,8 @@ public class SpawnsHolder extends AsyncStorageObjectHolder<Spawns> implements IE
{
final IUser user = ess.getUserMap().getUser(event.getPlayer());
- boolean respawnAtHome = false;
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- respawnAtHome = ess.getSettings().getData().getCommands().getHome().isRespawnAtHome();
- }
- finally
- {
- settings.unlock();
- }
+ boolean respawnAtHome = ess.getSettings().getData().getCommands().getHome().isRespawnAtHome();
if (respawnAtHome)
{
Location home;
diff --git a/Essentials/src/net/ess3/storage/AsyncStorageObjectHolder.java b/Essentials/src/net/ess3/storage/AsyncStorageObjectHolder.java
index c6c32f134..d5f63ed7e 100644
--- a/Essentials/src/net/ess3/storage/AsyncStorageObjectHolder.java
+++ b/Essentials/src/net/ess3/storage/AsyncStorageObjectHolder.java
@@ -13,7 +13,7 @@ import org.bukkit.Bukkit;
public abstract class AsyncStorageObjectHolder<T extends StorageObject> implements IStorageObjectHolder<T>
{
private transient T data;
- private final transient ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
+ //private final transient ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
private final transient Class<T> clazz;
protected final transient IEssentials ess;
private final transient StorageObjectDataWriter writer;
@@ -52,7 +52,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
return data;
}
- @Override
+ /*@Override
public void acquireReadLock()
{
rwl.readLock().lock();
@@ -67,9 +67,9 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
}
rwl.writeLock().lock();
rwl.readLock().lock();
- }
+ }*/
- @Override
+ /*@Override
public void close()
{
unlock();
@@ -87,7 +87,15 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
{
rwl.readLock().unlock();
}
+ }*/
+
+ @Override
+ public void queueSave()
+ {
+ writer.schedule();
}
+
+
@Override
public void onReload()
@@ -123,14 +131,14 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
@Override
public StorageObject getObject()
{
- acquireReadLock();
+ //acquireReadLock();
return getData();
}
@Override
public void onFinish()
{
- unlock();
+ //unlock();
finishWrite();
}
}
@@ -147,11 +155,11 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
public File onStart() throws IOException
{
final File file = getStorageFile();
- while (rwl.getReadHoldCount() > 0)
+ /*while (rwl.getReadHoldCount() > 0)
{
rwl.readLock().unlock();
}
- rwl.writeLock().lock();
+ rwl.writeLock().lock();*/
return file;
}
@@ -162,7 +170,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
{
data = object;
}
- rwl.writeLock().unlock();
+ //rwl.writeLock().unlock();
loaded.set(true);
}
@@ -180,7 +188,7 @@ public abstract class AsyncStorageObjectHolder<T extends StorageObject> implemen
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
}
}
- rwl.writeLock().unlock();
+ //rwl.writeLock().unlock();
loaded.set(true);
if (exception instanceof FileNotFoundException)
{
diff --git a/Essentials/src/net/ess3/storage/IStorageObjectHolder.java b/Essentials/src/net/ess3/storage/IStorageObjectHolder.java
index da5e24c49..53cc9f924 100644
--- a/Essentials/src/net/ess3/storage/IStorageObjectHolder.java
+++ b/Essentials/src/net/ess3/storage/IStorageObjectHolder.java
@@ -7,11 +7,11 @@ public interface IStorageObjectHolder<T extends StorageObject> extends IReload
{
T getData();
- void acquireReadLock();
+ //void acquireReadLock();
- void acquireWriteLock();
+ //void acquireWriteLock();
- void close();
+ void queueSave();
- void unlock();
+ //void unlock();
}
diff --git a/Essentials/src/net/ess3/user/User.java b/Essentials/src/net/ess3/user/User.java
index 1928c3ca3..61090780e 100644
--- a/Essentials/src/net/ess3/user/User.java
+++ b/Essentials/src/net/ess3/user/User.java
@@ -6,7 +6,6 @@ import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
-import lombok.Cleanup;
import lombok.Getter;
import lombok.Setter;
import net.ess3.Console;
@@ -67,18 +66,6 @@ public class User extends UserBase implements IUser
playerCache = new WeakReference<Player>(player);
}
- private void destroyPlayerCache()
- {
- playerCache = null;
- }
-
- @Override
- public void close()
- {
- super.close();
- destroyPlayerCache();
- }
-
@Override
public Player getPlayer()
{
@@ -90,21 +77,6 @@ public class User extends UserBase implements IUser
return player;
}
- public void example()
- {
- // Cleanup will call close at the end of the function
- @Cleanup
- final User user = this;
-
- // read lock allows to read data from the user
- user.acquireReadLock();
- final double money = user.getData().getMoney();
-
- // write lock allows only one thread to modify the data
- user.acquireWriteLock();
- user.getData().setMoney(10 + money);
- }
-
@Override
public void finishRead()
{
@@ -150,20 +122,13 @@ public class User extends UserBase implements IUser
{
return;
}
- acquireWriteLock();
- try
- {
- setMoney(getMoney() + value);
- sendMessage(_("addedToAccount", FormatUtil.displayCurrency(value, ess)));
- if (initiator != null)
- {
- initiator.sendMessage(_("addedToOthersAccount", FormatUtil.displayCurrency(value, ess), this.getPlayer().getDisplayName()));
- }
- }
- finally
+ setMoney(getMoney() + value);
+ sendMessage(_("addedToAccount", FormatUtil.displayCurrency(value, ess)));
+ if (initiator != null)
{
- unlock();
+ initiator.sendMessage(_("addedToOthersAccount", FormatUtil.displayCurrency(value, ess), this.getPlayer().getDisplayName()));
}
+ queueSave();
}
@Override
@@ -220,58 +185,42 @@ public class User extends UserBase implements IUser
@Override
public void setLastLocation()
{
- acquireWriteLock();
- try
- {
- getData().setLastLocation(new net.ess3.storage.StoredLocation(getPlayer().getLocation()));
- }
- finally
- {
- unlock();
- }
+ getData().setLastLocation(new net.ess3.storage.StoredLocation(getPlayer().getLocation()));
+ queueSave();
}
public String getNick(boolean addprefixsuffix)
{
- acquireReadLock();
- try
- {
- final String nick = getData().getNickname();
- @Cleanup
- final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- final IRanks groups = ess.getRanks();
- // default: {PREFIX}{NICKNAMEPREFIX}{NAME}{SUFFIX}
- String displayname = settings.getData().getChat().getDisplaynameFormat();
- if (settings.getData().getCommands().isDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
- {
- displayname = displayname.replace("{NAME}", getName());
- displayname = displayname.replace("{NICKNAMEPREFIX}", "");
- }
- else
- {
- displayname = displayname.replace("{NAME}", nick);
- displayname = displayname.replace("{NICKNAMEPREFIX}", settings.getData().getChat().getNicknamePrefix());
- }
- if (displayname.contains("{PREFIX}"))
- {
- displayname = displayname.replace("{PREFIX}", groups.getPrefix(this));
- }
- if (displayname.contains("{SUFFIX}"))
- {
- displayname = displayname.replace("{SUFFIX}", groups.getSuffix(this));
- }
- displayname = displayname.replace("{WORLDNAME}", this.getPlayer().getWorld().getName());
- displayname = displayname.replace('&', '\u00a7');
- displayname = displayname.concat("\u00a7f");
+ final String nick = getData().getNickname();
+ final ISettings settings = ess.getSettings();
+ final IRanks groups = ess.getRanks();
+ // default: {PREFIX}{NICKNAMEPREFIX}{NAME}{SUFFIX}
+ String displayname = settings.getData().getChat().getDisplaynameFormat();
+ if (settings.getData().getCommands().isDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
+ {
+ displayname = displayname.replace("{NAME}", getName());
+ displayname = displayname.replace("{NICKNAMEPREFIX}", "");
+ }
+ else
+ {
+ displayname = displayname.replace("{NAME}", nick);
+ displayname = displayname.replace("{NICKNAMEPREFIX}", settings.getData().getChat().getNicknamePrefix());
+ }
- return displayname;
+ if (displayname.contains("{PREFIX}"))
+ {
+ displayname = displayname.replace("{PREFIX}", groups.getPrefix(this));
}
- finally
+ if (displayname.contains("{SUFFIX}"))
{
- unlock();
+ displayname = displayname.replace("{SUFFIX}", groups.getSuffix(this));
}
+ displayname = displayname.replace("{WORLDNAME}", this.getPlayer().getWorld().getName());
+ displayname = displayname.replace('&', '\u00a7');
+ displayname = displayname.concat("\u00a7f");
+
+ return displayname;
}
@Override
@@ -300,9 +249,7 @@ public class User extends UserBase implements IUser
@Override
public void updateDisplayName()
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (isOnline() && settings.getData().getChat().getChangeDisplayname())
{
setDisplayNick();
@@ -355,20 +302,14 @@ public class User extends UserBase implements IUser
public void setAfk(final boolean set)
{
- acquireWriteLock();
- try
- {
- this.getPlayer().setSleepingIgnored(Permissions.SLEEPINGIGNORED.isAuthorized(this) ? true : set);
- if (set && !getData().isAfk())
- {
- afkPosition = getPlayer().getLocation();
- }
- getData().setAfk(set);
- }
- finally
+
+ this.getPlayer().setSleepingIgnored(Permissions.SLEEPINGIGNORED.isAuthorized(this) ? true : set);
+ if (set && !getData().isAfk())
{
- unlock();
+ afkPosition = getPlayer().getLocation();
}
+ getData().setAfk(set);
+ queueSave();
}
@Override
@@ -383,109 +324,76 @@ public class User extends UserBase implements IUser
@Override
public boolean checkJailTimeout(final long currentTime)
{
- acquireReadLock();
- try
+ if (getTimestamp(UserData.TimestampType.JAIL) > 0 && getTimestamp(UserData.TimestampType.JAIL) < currentTime && getData().isJailed())
{
- if (getTimestamp(UserData.TimestampType.JAIL) > 0 && getTimestamp(UserData.TimestampType.JAIL) < currentTime && getData().isJailed())
- {
- acquireWriteLock();
- setTimestamp(UserData.TimestampType.JAIL, 0);
- getData().setJailed(false);
- sendMessage(_("haveBeenReleased"));
- getData().setJail(null);
- try
- {
- teleport.back();
- }
- catch (Exception ex)
- {
- }
- return true;
+ setTimestamp(UserData.TimestampType.JAIL, 0);
+ getData().setJailed(false);
+ sendMessage(_("haveBeenReleased"));
+ getData().setJail(null);
+ queueSave();
+
+ try
+ {
+ teleport.back();
}
- return false;
- }
- finally
- {
- unlock();
+ catch (Exception ex)
+ {
+ }
+ return true;
}
+ return false;
}
//Returns true if status expired during this check
@Override
public boolean checkMuteTimeout(final long currentTime)
{
- acquireReadLock();
- try
+ if (getTimestamp(UserData.TimestampType.MUTE) > 0 && getTimestamp(UserData.TimestampType.MUTE) < currentTime && getData().isMuted())
{
- if (getTimestamp(UserData.TimestampType.MUTE) > 0 && getTimestamp(UserData.TimestampType.MUTE) < currentTime && getData().isMuted())
- {
- acquireWriteLock();
- setTimestamp(UserData.TimestampType.MUTE, 0);
- sendMessage(_("canTalkAgain"));
- getData().setMuted(false);
- return true;
- }
- return false;
- }
- finally
- {
- unlock();
+ setTimestamp(UserData.TimestampType.MUTE, 0);
+ sendMessage(_("canTalkAgain"));
+ getData().setMuted(false);
+ queueSave();
+ return true;
}
+ return false;
}
//Returns true if status expired during this check
@Override
public boolean checkBanTimeout(final long currentTime)
{
- acquireReadLock();
- try
+ if (getData().getBan() != null && getData().getBan().getTimeout() > 0 && getData().getBan().getTimeout() < currentTime && isBanned())
{
- if (getData().getBan() != null && getData().getBan().getTimeout() > 0 && getData().getBan().getTimeout() < currentTime && isBanned())
- {
- acquireWriteLock();
- getData().setBan(null);
- setBanned(false);
- return true;
- }
- return false;
- }
- finally
- {
- unlock();
+ getData().setBan(null);
+ setBanned(false);
+ queueSave();
+ return true;
}
+ return false;
}
@Override
public void updateActivity(final boolean broadcast)
{
- acquireReadLock();
- try
+ if (getData().isAfk())
{
- if (getData().isAfk())
+ getData().setAfk(false);
+ queueSave();
+ if (broadcast && !hidden)
{
- acquireWriteLock();
- getData().setAfk(false);
- if (broadcast && !hidden)
- {
- ess.broadcastMessage(this, _("userIsNotAway", getPlayer().getDisplayName()));
- }
+ ess.broadcastMessage(this, _("userIsNotAway", getPlayer().getDisplayName()));
}
- lastActivity = System.currentTimeMillis();
- }
- finally
- {
- unlock();
}
+ lastActivity = System.currentTimeMillis();
}
@Override
public void checkActivity()
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
final long autoafkkick = settings.getData().getCommands().getAfk().getAutoAFKKick();
if (autoafkkick > 0 && lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis()
&& !hidden
@@ -506,22 +414,15 @@ public class User extends UserBase implements IUser
}
}
final long autoafk = settings.getData().getCommands().getAfk().getAutoAFK();
- acquireReadLock();
- try
+
+ if (!getData().isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && Permissions.AFK.isAuthorized(this))
{
- if (!getData().isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && Permissions.AFK.isAuthorized(this))
+ setAfk(true);
+ if (!hidden)
{
- setAfk(true);
- if (!hidden)
- {
- ess.broadcastMessage(this, _("userIsAway", getPlayer().getDisplayName()));
- }
+ ess.broadcastMessage(this, _("userIsAway", getPlayer().getDisplayName()));
}
}
- finally
- {
- unlock();
- }
}
@Override
@@ -533,20 +434,10 @@ public class User extends UserBase implements IUser
@Override
public boolean isGodModeEnabled()
{
- acquireReadLock();
- try
- {
- @Cleanup
- final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- return (getData().isGodmode()
- && !settings.getData().getWorldOptions(getPlayer().getLocation().getWorld().getName()).isGodmode())
- || (getData().isAfk() && settings.getData().getCommands().getAfk().isFreezeAFKPlayers());
- }
- finally
- {
- unlock();
- }
+ final ISettings settings = ess.getSettings();
+ return (getData().isGodmode()
+ && !settings.getData().getWorldOptions(getPlayer().getLocation().getWorld().getName()).isGodmode())
+ || (getData().isAfk() && settings.getData().getCommands().getAfk().isFreezeAFKPlayers());
}
@Override
@@ -649,9 +540,7 @@ public class User extends UserBase implements IUser
final Map<Integer, ItemStack> overfilled;
if (Permissions.OVERSIZEDSTACKS.isAuthorized(this))
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
int oversizedStackSize = settings.getData().getGeneral().getOversizedStacksize();
overfilled = InventoryWorkaround.addItem(getPlayer().getInventory(), true, oversizedStackSize, itemStack);
@@ -684,9 +573,7 @@ public class User extends UserBase implements IUser
final double mon = getMoney();
if (Permissions.ECO_LOAN.isAuthorized(this))
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
return (mon - cost) >= settings.getData().getEconomy().getMinMoney();
}
return cost <= mon;
@@ -710,9 +597,7 @@ public class User extends UserBase implements IUser
public void enableInvulnerabilityAfterTeleport()
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
final long time = settings.getData().getGeneral().getTeleportInvulnerability();
if (time > 0)
diff --git a/Essentials/src/net/ess3/user/UserBase.java b/Essentials/src/net/ess3/user/UserBase.java
index fb84119d2..bb46ab10d 100644
--- a/Essentials/src/net/ess3/user/UserBase.java
+++ b/Essentials/src/net/ess3/user/UserBase.java
@@ -3,7 +3,6 @@ package net.ess3.user;
import java.io.File;
import java.io.IOException;
import java.util.*;
-import lombok.Cleanup;
import lombok.Delegate;
import net.ess3.api.IEssentials;
import net.ess3.api.ISettings;
@@ -36,12 +35,13 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
this.offlinePlayer = base;
onReload();
}
-
+
@Override
public void sendMessage(String string)
{
Player player = offlinePlayer.getPlayer();
- if (player != null) {
+ if (player != null)
+ {
player.sendMessage(string);
}
}
@@ -50,7 +50,8 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
public void sendMessage(String[] strings)
{
Player player = offlinePlayer.getPlayer();
- if (player != null) {
+ if (player != null)
+ {
player.sendMessage(strings);
}
}
@@ -65,9 +66,12 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
public boolean isPermissionSet(String string)
{
Player player = offlinePlayer.getPlayer();
- if (player != null) {
+ if (player != null)
+ {
return player.isPermissionSet(string);
- } else {
+ }
+ else
+ {
return false;
}
}
@@ -76,9 +80,12 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
public boolean isPermissionSet(Permission prmsn)
{
Player player = offlinePlayer.getPlayer();
- if (player != null) {
+ if (player != null)
+ {
return player.isPermissionSet(prmsn);
- } else {
+ }
+ else
+ {
return false;
}
}
@@ -87,9 +94,12 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
public boolean hasPermission(String string)
{
Player player = offlinePlayer.getPlayer();
- if (player != null) {
+ if (player != null)
+ {
return player.hasPermission(string);
- } else {
+ }
+ else
+ {
return false;
}
}
@@ -98,9 +108,12 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
public boolean hasPermission(Permission prmsn)
{
Player player = offlinePlayer.getPlayer();
- if (player != null) {
+ if (player != null)
+ {
return player.hasPermission(prmsn);
- } else {
+ }
+ else
+ {
return false;
}
}
@@ -162,300 +175,174 @@ public abstract class UserBase extends AsyncStorageObjectHolder<UserData> implem
public long getTimestamp(final UserData.TimestampType name)
{
- acquireReadLock();
- try
- {
- return getData().getTimestamp(name);
- }
- finally
- {
- unlock();
- }
+ return getData().getTimestamp(name);
}
public void setTimestamp(final UserData.TimestampType name, final long value)
{
- acquireWriteLock();
- try
- {
- getData().setTimestamp(name, value);
- }
- finally
- {
- unlock();
- }
+ getData().setTimestamp(name, value);
+ queueSave();
}
public void setMoney(final double value)
{
- acquireWriteLock();
- try
+
+ final ISettings settings = ess.getSettings();
+
+ if (Math.abs(value) > settings.getData().getEconomy().getMaxMoney())
{
- @Cleanup
- final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- if (Math.abs(value) > settings.getData().getEconomy().getMaxMoney())
- {
- getData().setMoney(value < 0 ? -settings.getData().getEconomy().getMaxMoney() : settings.getData().getEconomy().getMaxMoney());
- }
- else
- {
- getData().setMoney(value);
- }
+ getData().setMoney(value < 0 ? -settings.getData().getEconomy().getMaxMoney() : settings.getData().getEconomy().getMaxMoney());
}
- finally
+ else
{
- unlock();
+ getData().setMoney(value);
}
+ queueSave();
}
public double getMoney()
{
- acquireReadLock();
- try
+ Double money = getData().getMoney();
+
+ final ISettings settings = ess.getSettings();
+
+ if (money == null)
{
- Double money = getData().getMoney();
- @Cleanup
- final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- if (money == null)
- {
- money = (double)settings.getData().getEconomy().getStartingBalance();
- }
- if (Math.abs(money) > settings.getData().getEconomy().getMaxMoney())
- {
- money = money < 0 ? -settings.getData().getEconomy().getMaxMoney() : settings.getData().getEconomy().getMaxMoney();
- }
- return money;
+ money = (double)settings.getData().getEconomy().getStartingBalance();
}
- finally
+ if (Math.abs(money) > settings.getData().getEconomy().getMaxMoney())
{
- unlock();
+ money = money < 0 ? -settings.getData().getEconomy().getMaxMoney() : settings.getData().getEconomy().getMaxMoney();
}
+ return money;
}
public void setHome(String name, Location loc)
{
- acquireWriteLock();
- try
- {
- getData().addHome(Util.sanitizeKey(name), loc);
- }
- finally
- {
- unlock();
- }
+ getData().addHome(Util.sanitizeKey(name), loc);
+ queueSave();
}
public boolean toggleAfk()
{
- acquireWriteLock();
- try
- {
- boolean ret = !getData().isAfk();
- getData().setAfk(ret);
- return ret;
- }
- finally
- {
- unlock();
- }
+ boolean ret = !getData().isAfk();
+ getData().setAfk(ret);
+ queueSave();
+ return ret;
}
public void setGodModeEnabled(boolean set)
{
- acquireWriteLock();
- try
- {
- getData().setGodmode(set);
- }
- finally
- {
- unlock();
- }
+ getData().setGodmode(set);
+ queueSave();
}
public void setMuted(boolean mute)
{
- acquireWriteLock();
- try
- {
- getData().setMuted(mute);
- }
- finally
- {
- unlock();
- }
+ getData().setMuted(mute);
+ queueSave();
}
public boolean toggleSocialSpy()
{
- acquireWriteLock();
- try
- {
- boolean ret = !getData().isSocialspy();
- getData().setSocialspy(ret);
- return ret;
- }
- finally
- {
- unlock();
- }
+ boolean ret = !getData().isSocialspy();
+ getData().setSocialspy(ret);
+ queueSave();
+ return ret;
}
public boolean toggleTeleportEnabled()
{
- acquireWriteLock();
- try
- {
- boolean ret = !getData().isTeleportEnabled();
- getData().setTeleportEnabled(ret);
- return ret;
- }
- finally
- {
- unlock();
- }
+ boolean ret = !getData().isTeleportEnabled();
+ getData().setTeleportEnabled(ret);
+ queueSave();
+ return ret;
}
public boolean isIgnoringPlayer(final IUser user)
{
- acquireReadLock();
- try
- {
- return getData().getIgnore() == null ? false : getData().getIgnore().contains(user.getName().toLowerCase(Locale.ENGLISH)) && Permissions.CHAT_IGNORE_EXEMPT.isAuthorized(user);
- }
- finally
- {
- unlock();
- }
+ return getData().getIgnore() == null ? false : getData().getIgnore().contains(user.getName().toLowerCase(Locale.ENGLISH)) && Permissions.CHAT_IGNORE_EXEMPT.isAuthorized(user);
}
public void setIgnoredPlayer(final IUser user, final boolean set)
{
- acquireWriteLock();
- try
- {
- getData().setIgnore(user.getName().toLowerCase(Locale.ENGLISH), set);
- }
- finally
- {
- unlock();
- }
+ getData().setIgnore(user.getName().toLowerCase(Locale.ENGLISH), set);
+ queueSave();
}
public void addMail(String string)
{
- acquireWriteLock();
- try
- {
- getData().addMail(string);
- }
- finally
- {
- unlock();
- }
+ getData().addMail(string);
+ queueSave();
}
public List<String> getMails()
{
- acquireReadLock();
- try
- {
- return getData().getMails();
- }
- finally
- {
- unlock();
- }
+
+ return getData().getMails();
}
public Location getHome(String name) throws Exception
{
- acquireReadLock();
+ if (getData().getHomes() == null)
+ {
+ return null;
+ }
try
{
- if (getData().getHomes() == null)
- {
- return null;
- }
- try
- {
- return getData().getHomes().get(Util.sanitizeKey(name)).getStoredLocation();
- }
- catch (WorldNotLoadedException ex)
- {
- return null;
- }
+ return getData().getHomes().get(Util.sanitizeKey(name)).getStoredLocation();
}
- finally
+ catch (WorldNotLoadedException ex)
{
- unlock();
+ return null;
}
}
public Location getHome(Location loc)
{
-
- acquireReadLock();
- try
+ if (getData().getHomes() == null)
{
- if (getData().getHomes() == null)
- {
- return null;
- }
- ArrayList<Location> worldHomes = new ArrayList<Location>();
- for (net.ess3.storage.StoredLocation location : getData().getHomes().values())
+ return null;
+ }
+ ArrayList<Location> worldHomes = new ArrayList<Location>();
+ for (net.ess3.storage.StoredLocation location : getData().getHomes().values())
+ {
+ if (location.getWorldName().equals(loc.getWorld().getName()))
{
- if (location.getWorldName().equals(loc.getWorld().getName()))
+ try
{
- try
- {
- worldHomes.add(location.getStoredLocation());
- }
- catch (WorldNotLoadedException ex)
- {
- continue;
- }
+ worldHomes.add(location.getStoredLocation());
}
- }
- if (worldHomes.isEmpty())
- {
- return null;
- }
- if (worldHomes.size() == 1)
- {
- return worldHomes.get(0);
- }
- double distance = Double.MAX_VALUE;
- Location target = null;
- for (Location location : worldHomes)
- {
- final double d = loc.distanceSquared(location);
- if (d < distance)
+ catch (WorldNotLoadedException ex)
{
- target = location;
- distance = d;
+ continue;
}
}
- return target;
}
- finally
+ if (worldHomes.isEmpty())
{
- unlock();
+ return null;
}
- }
-
- public Set<String> getHomes()
- {
- acquireReadLock();
- try
- {
- return getData().getHomes().keySet();
+ if (worldHomes.size() == 1)
+ {
+ return worldHomes.get(0);
}
- finally
+ double distance = Double.MAX_VALUE;
+ Location target = null;
+ for (Location location : worldHomes)
{
- unlock();
+ final double d = loc.distanceSquared(location);
+ if (d < distance)
+ {
+ target = location;
+ distance = d;
+ }
}
+ return target;
+ }
+
+ public Set<String> getHomes()
+ {
+ return getData().getHomes().keySet();
}
}
diff --git a/Essentials/src/net/ess3/user/UserMap.java b/Essentials/src/net/ess3/user/UserMap.java
index 011ee578e..0217ff7bc 100644
--- a/Essentials/src/net/ess3/user/UserMap.java
+++ b/Essentials/src/net/ess3/user/UserMap.java
@@ -51,7 +51,8 @@ public class UserMap extends StorageObjectMap<IUser> implements IUserMap
}
}
Player player = ess.getServer().getPlayerExact(name);
- if (player != null) {
+ if (player != null)
+ {
return new User(ess.getServer().getOfflinePlayer(player.getName()), ess);
}
final File userFile = getUserFile(name);
@@ -97,7 +98,7 @@ public class UserMap extends StorageObjectMap<IUser> implements IUserMap
}
return user;
}
-
+
@Override
public IUser matchUser(final String name, final boolean includeHidden, final boolean includeOffline) throws TooManyMatchesException, PlayerNotFoundException
{
@@ -242,14 +243,6 @@ public class UserMap extends StorageObjectMap<IUser> implements IUserMap
private String getNickNamePrefix()
{
- ess.getSettings().acquireReadLock();
- try
- {
- return ess.getSettings().getData().getChat().getNicknamePrefix();
- }
- finally
- {
- ess.getSettings().unlock();
- }
+ return ess.getSettings().getData().getChat().getNicknamePrefix();
}
}
diff --git a/Essentials/src/net/ess3/utils/FormatUtil.java b/Essentials/src/net/ess3/utils/FormatUtil.java
index a00e43a47..4cba2a71b 100644
--- a/Essentials/src/net/ess3/utils/FormatUtil.java
+++ b/Essentials/src/net/ess3/utils/FormatUtil.java
@@ -4,7 +4,6 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import java.util.regex.Pattern;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
import net.ess3.api.ISettings;
@@ -126,17 +125,13 @@ public class FormatUtil
public static String shortCurrency(final double value, final IEssentials ess)
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
return settings.getData().getEconomy().getCurrencySymbol() + formatAsCurrency(value);
}
public static String displayCurrency(final double value, final IEssentials ess)
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
return _("currency", settings.getData().getEconomy().getCurrencySymbol(), formatAsCurrency(value));
}
diff --git a/Essentials/src/net/ess3/utils/textreader/HelpInput.java b/Essentials/src/net/ess3/utils/textreader/HelpInput.java
index 7f22bf3d0..f082913e1 100644
--- a/Essentials/src/net/ess3/utils/textreader/HelpInput.java
+++ b/Essentials/src/net/ess3/utils/textreader/HelpInput.java
@@ -4,7 +4,6 @@ import java.io.IOException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
-import lombok.Cleanup;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
import net.ess3.api.ISettings;
@@ -26,9 +25,7 @@ public class HelpInput implements IText
public HelpInput(final IUser user, final String match, final IEssentials ess) throws IOException
{
- @Cleanup
final ISettings settings = ess.getSettings();
- settings.acquireReadLock();
boolean reported = false;
final List<String> newLines = new ArrayList<String>();
String pluginName = "";
diff --git a/Essentials/src/net/ess3/utils/textreader/KeywordReplacer.java b/Essentials/src/net/ess3/utils/textreader/KeywordReplacer.java
index cd55511ca..0a9180966 100644
--- a/Essentials/src/net/ess3/utils/textreader/KeywordReplacer.java
+++ b/Essentials/src/net/ess3/utils/textreader/KeywordReplacer.java
@@ -5,7 +5,6 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
-import lombok.Cleanup;
import net.ess3.api.IEssentials;
import net.ess3.api.IUser;
import net.ess3.utils.DescParseTickFormat;
@@ -37,9 +36,7 @@ public class KeywordReplacer implements IText
String userName, address, version;
if (sender instanceof Player)
{
- @Cleanup
final IUser user = ess.getUserMap().getUser((Player)sender);
- user.acquireReadLock();
user.setDisplayNick();
displayName = user.getPlayer().getDisplayName();
userName = user.getPlayer().getName();
diff --git a/EssentialsChat/src/net/ess3/chat/EssentialsChatPlayer.java b/EssentialsChat/src/net/ess3/chat/EssentialsChatPlayer.java
index 9bf791372..20019b179 100644
--- a/EssentialsChat/src/net/ess3/chat/EssentialsChatPlayer.java
+++ b/EssentialsChat/src/net/ess3/chat/EssentialsChatPlayer.java
@@ -1,5 +1,8 @@
package net.ess3.chat;
+import java.util.Locale;
+import java.util.Map;
+import java.util.logging.Logger;
import static net.ess3.I18n._;
import net.ess3.api.ChargeException;
import net.ess3.api.IEssentials;
@@ -8,10 +11,6 @@ import net.ess3.api.ISettings;
import net.ess3.api.IUser;
import net.ess3.economy.Trade;
import net.ess3.permissions.Permissions;
-import net.ess3.utils.Util;
-import java.util.Locale;
-import java.util.Map;
-import java.util.logging.Logger;
import net.ess3.utils.FormatUtil;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -112,18 +111,8 @@ public abstract class EssentialsChatPlayer implements Listener
protected void handleLocalChat(final PlayerChatEvent event, final ChatStore chatStore)
{
-
- long radius = 0;
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
- try
- {
- radius = settings.getData().getChat().getLocalRadius();
- }
- finally
- {
- settings.unlock();
- }
+ long radius = settings.getData().getChat().getLocalRadius();
if (radius < 1)
{
diff --git a/EssentialsGeoIP/src/net/ess3/geoip/EssentialsGeoIPPlayerListener.java b/EssentialsGeoIP/src/net/ess3/geoip/EssentialsGeoIPPlayerListener.java
index d2a30dbd8..5ccb5487a 100644
--- a/EssentialsGeoIP/src/net/ess3/geoip/EssentialsGeoIPPlayerListener.java
+++ b/EssentialsGeoIP/src/net/ess3/geoip/EssentialsGeoIPPlayerListener.java
@@ -50,113 +50,91 @@ public class EssentialsGeoIPPlayerListener implements Listener, IReload
{
return;
}
- config.acquireReadLock();
- try
+ if (event.getPlayer().getAddress() == null || event.getPlayer().getAddress().getAddress() == null)
{
- if (event.getPlayer().getAddress() == null || event.getPlayer().getAddress().getAddress() == null) {
- return;
- }
- final InetAddress address = event.getPlayer().getAddress().getAddress();
-
- final StringBuilder builder = new StringBuilder();
- if (config.getData().getDatabase().isShowCities())
+ return;
+ }
+ final InetAddress address = event.getPlayer().getAddress().getAddress();
+
+ final StringBuilder builder = new StringBuilder();
+ if (config.getData().getDatabase().isShowCities())
+ {
+ final Location loc = ls.getLocation(address);
+ if (loc == null)
{
- final Location loc = ls.getLocation(address);
- if (loc == null)
- {
- return;
- }
- if (loc.city != null)
- {
- builder.append(loc.city).append(", ");
- }
- final String region = regionName.regionNameByCode(loc.countryCode, loc.region);
- if (region != null)
- {
- builder.append(region).append(", ");
- }
- builder.append(loc.countryName);
+ return;
}
- else
+ if (loc.city != null)
{
- builder.append(ls.getCountry(address).getName());
+ builder.append(loc.city).append(", ");
}
- if (config.getData().isShowOnWhois())
+ final String region = regionName.regionNameByCode(loc.countryCode, loc.region);
+ if (region != null)
{
- u.acquireWriteLock();
- try
- {
- u.getData().setGeolocation(builder.toString());
- }
- finally
- {
- u.unlock();
- }
+ builder.append(region).append(", ");
}
- if (config.getData().isShowOnLogin() && !u.isHidden())
+ builder.append(loc.countryName);
+ }
+ else
+ {
+ builder.append(ls.getCountry(address).getName());
+ }
+ if (config.getData().isShowOnWhois())
+ {
+ u.getData().setGeolocation(builder.toString());
+ u.queueSave();
+ }
+ if (config.getData().isShowOnLogin() && !u.isHidden())
+ {
+ for (Player player : event.getPlayer().getServer().getOnlinePlayers())
{
- for (Player player : event.getPlayer().getServer().getOnlinePlayers())
+ final IUser user = ess.getUserMap().getUser(player);
+ if (Permissions.GEOIP_SHOW.isAuthorized(user))
{
- final IUser user = ess.getUserMap().getUser(player);
- if (Permissions.GEOIP_SHOW.isAuthorized(user))
- {
- user.sendMessage(_("geoipJoinFormat", user.getPlayer().getDisplayName(), builder.toString()));
- }
+ user.sendMessage(_("geoipJoinFormat", user.getPlayer().getDisplayName(), builder.toString()));
}
}
}
- finally
- {
- config.unlock();
- }
}
@Override
public final void onReload()
{
config.onReload();
- config.acquireReadLock();
- try
+ if (config.getData().getDatabase().isShowCities())
{
- if (config.getData().getDatabase().isShowCities())
- {
- databaseFile = new File(geoip.getDataFolder(), "GeoIPCity.dat");
- }
- else
- {
- databaseFile = new File(geoip.getDataFolder(), "GeoIP.dat");
- }
- if (!databaseFile.exists())
+ databaseFile = new File(geoip.getDataFolder(), "GeoIPCity.dat");
+ }
+ else
+ {
+ databaseFile = new File(geoip.getDataFolder(), "GeoIP.dat");
+ }
+ if (!databaseFile.exists())
+ {
+ if (config.getData().getDatabase().isDownloadIfMissing())
{
- if (config.getData().getDatabase().isDownloadIfMissing())
+ if (config.getData().getDatabase().isShowCities())
{
- if (config.getData().getDatabase().isShowCities())
- {
- downloadDatabase(config.getData().getDatabase().getDownloadUrlCity());
- }
- else
- {
- downloadDatabase(config.getData().getDatabase().getDownloadUrl());
- }
+ downloadDatabase(config.getData().getDatabase().getDownloadUrlCity());
}
else
{
- LOGGER.log(Level.SEVERE, _("cantFindGeoIpDB"));
- return;
+ downloadDatabase(config.getData().getDatabase().getDownloadUrl());
}
}
- try
- {
- ls = new LookupService(databaseFile);
- }
- catch (IOException ex)
+ else
{
- LOGGER.log(Level.SEVERE, _("cantReadGeoIpDB"), ex);
+ LOGGER.log(Level.SEVERE, _("cantFindGeoIpDB"));
+ return;
}
}
- finally
+ try
+ {
+ ls = new LookupService(databaseFile);
+ }
+ catch (IOException ex)
{
- config.unlock();
+ LOGGER.log(Level.SEVERE, _("cantReadGeoIpDB"), ex);
}
}
@@ -167,7 +145,8 @@ public class EssentialsGeoIPPlayerListener implements Listener, IReload
LOGGER.log(Level.SEVERE, _("geoIpUrlEmpty"));
return;
}
- if (!databaseFile.getAbsoluteFile().getParentFile().exists()) {
+ if (!databaseFile.getAbsoluteFile().getParentFile().exists())
+ {
databaseFile.getAbsoluteFile().getParentFile().mkdirs();
}
InputStream input = null;
diff --git a/EssentialsProtect/src/net/ess3/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectBlockListener.java
index 6649469b9..b77e49177 100644
--- a/EssentialsProtect/src/net/ess3/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectBlockListener.java
@@ -16,48 +16,40 @@ public class EssentialsProtectBlockListener implements Listener
public EssentialsProtectBlockListener(final IProtect parent)
{
this.prot = parent;
- }
+ }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
+ final Block block = event.getBlock();
+ if (event.getBlock().getType() == Material.OBSIDIAN
+ || event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.OBSIDIAN)
{
- final Block block = event.getBlock();
- if (event.getBlock().getType() == Material.OBSIDIAN
- || event.getBlock().getRelative(BlockFace.DOWN).getType() == Material.OBSIDIAN)
- {
- event.setCancelled(settings.getData().getPrevent().isPortalCreation());
- return;
- }
+ event.setCancelled(settings.getData().getPrevent().isPortalCreation());
+ return;
+ }
- if (event.getCause().equals(BlockIgniteEvent.IgniteCause.SPREAD))
- {
- event.setCancelled(settings.getData().getPrevent().isFirespread());
- return;
- }
+ if (event.getCause().equals(BlockIgniteEvent.IgniteCause.SPREAD))
+ {
+ event.setCancelled(settings.getData().getPrevent().isFirespread());
+ return;
+ }
- if (event.getCause().equals(BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) && event.getPlayer() != null)
- {
- event.setCancelled(Permissions.USEFLINTSTEEL.isAuthorized(event.getPlayer()));
- return;
- }
+ if (event.getCause().equals(BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) && event.getPlayer() != null)
+ {
+ event.setCancelled(Permissions.USEFLINTSTEEL.isAuthorized(event.getPlayer()));
+ return;
+ }
- if (event.getCause().equals(BlockIgniteEvent.IgniteCause.LAVA))
- {
- event.setCancelled(settings.getData().getPrevent().isLavaFirespread());
- return;
- }
- if (event.getCause().equals(BlockIgniteEvent.IgniteCause.LIGHTNING))
- {
- event.setCancelled(settings.getData().getPrevent().isLightningFirespread());
- }
+ if (event.getCause().equals(BlockIgniteEvent.IgniteCause.LAVA))
+ {
+ event.setCancelled(settings.getData().getPrevent().isLavaFirespread());
+ return;
}
- finally
+ if (event.getCause().equals(BlockIgniteEvent.IgniteCause.LIGHTNING))
{
- settings.unlock();
+ event.setCancelled(settings.getData().getPrevent().isLightningFirespread());
}
}
@@ -65,47 +57,32 @@ public class EssentialsProtectBlockListener implements Listener
public void onBlockFromTo(final BlockFromToEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
+ final Block block = event.getBlock();
+ if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)
{
- final Block block = event.getBlock();
- if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)
- {
- event.setCancelled(settings.getData().getPrevent().isWaterFlow());
- return;
- }
-
- if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA)
- {
- event.setCancelled(settings.getData().getPrevent().isLavaFlow());
- }
- // TODO: Test if this still works
- /*
- * if (block.getType() == Material.AIR) {
- * event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_water_bucket_flow)); return; }
- */
+ event.setCancelled(settings.getData().getPrevent().isWaterFlow());
+ return;
}
- finally
+
+ if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA)
{
- settings.unlock();
+ event.setCancelled(settings.getData().getPrevent().isLavaFlow());
}
+ // TODO: Test if this still works
+ /*
+ * if (block.getType() == Material.AIR) {
+ * event.setCancelled(prot.getSettingBool(ProtectConfig.prevent_water_bucket_flow)); return; }
+ */
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBurn(final BlockBurnEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
- {
- if (settings.getData().getPrevent().isFirespread())
- {
- event.setCancelled(true);
- }
- }
- finally
+
+ if (settings.getData().getPrevent().isFirespread())
{
- settings.unlock();
+ event.setCancelled(true);
}
}
} \ No newline at end of file
diff --git a/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java
index e6858483d..5bde19973 100644
--- a/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java
@@ -23,183 +23,167 @@ public class EssentialsProtectEntityListener implements Listener
public void onEntityDamage(final EntityDamageEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
+ final Entity target = event.getEntity();
+
+ if (target instanceof Villager && settings.getData().getPrevent().isVillagerDeath())
{
- final Entity target = event.getEntity();
+ event.setCancelled(true);
+ return;
+ }
+
+ final Player user = target instanceof Player ? (Player)target : null;
+ if (target instanceof Player && event instanceof EntityDamageByBlockEvent)
+ {
+ final DamageCause cause = event.getCause();
- if (target instanceof Villager && settings.getData().getPrevent().isVillagerDeath())
+ if (cause == DamageCause.CONTACT
+ && (Permissions.PREVENTDAMAGE_CONTACT.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
{
event.setCancelled(true);
return;
}
-
- final Player user = target instanceof Player ? (Player)target : null;
- if (target instanceof Player && event instanceof EntityDamageByBlockEvent)
+ if (cause == DamageCause.LAVA
+ && (Permissions.PREVENTDAMAGE_LAVADAMAGE.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
{
- final DamageCause cause = event.getCause();
-
- if (cause == DamageCause.CONTACT
- && (Permissions.PREVENTDAMAGE_CONTACT.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
- if (cause == DamageCause.LAVA
- && (Permissions.PREVENTDAMAGE_LAVADAMAGE.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
- if (cause == DamageCause.BLOCK_EXPLOSION
- && (Permissions.PREVENTDAMAGE_TNT.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
+ event.setCancelled(true);
+ return;
}
-
- if (target instanceof Player && event instanceof EntityDamageByEntityEvent)
+ if (cause == DamageCause.BLOCK_EXPLOSION
+ && (Permissions.PREVENTDAMAGE_TNT.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
{
- final EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
- final Entity eAttack = edEvent.getDamager();
- final Player attacker = eAttack instanceof Player ? (Player)eAttack : null;
-
- // PVP Settings
- if (target instanceof Player && eAttack instanceof Player
- && (!Permissions.PVP.isAuthorized(user) || !Permissions.PVP.isAuthorized(attacker)))
- {
- event.setCancelled(true);
- return;
- }
+ event.setCancelled(true);
+ return;
+ }
+ }
- //Creeper explode prevention
- if (eAttack instanceof Creeper && settings.getData().getPrevent().isCreeperExplosion()
- || (Permissions.PREVENTDAMAGE_CREEPER.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
+ if (target instanceof Player && event instanceof EntityDamageByEntityEvent)
+ {
+ final EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
+ final Entity eAttack = edEvent.getDamager();
+ final Player attacker = eAttack instanceof Player ? (Player)eAttack : null;
- if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
- && (Permissions.PREVENTDAMAGE_FIREBALL.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
+ // PVP Settings
+ if (target instanceof Player && eAttack instanceof Player
+ && (!Permissions.PVP.isAuthorized(user) || !Permissions.PVP.isAuthorized(attacker)))
+ {
+ event.setCancelled(true);
+ return;
+ }
- if (eAttack instanceof TNTPrimed
- && (Permissions.PREVENTDAMAGE_TNT.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
+ //Creeper explode prevention
+ if (eAttack instanceof Creeper && settings.getData().getPrevent().isCreeperExplosion()
+ || (Permissions.PREVENTDAMAGE_CREEPER.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
+ {
+ event.setCancelled(true);
+ return;
+ }
- if (edEvent.getDamager() instanceof Projectile
- && ((Permissions.PREVENTDAMAGE_PROJECTILES.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user))
- || (((Projectile)edEvent.getDamager()).getShooter() instanceof Player
- && (!Permissions.PVP.isAuthorized(user)
- || !Permissions.PVP.isAuthorized((Player)((Projectile)edEvent.getDamager()).getShooter())))))
- {
- event.setCancelled(true);
- return;
- }
+ if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
+ && (Permissions.PREVENTDAMAGE_FIREBALL.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
+ {
+ event.setCancelled(true);
+ return;
}
- final DamageCause cause = event.getCause();
- if (target instanceof Player)
+ if (eAttack instanceof TNTPrimed
+ && (Permissions.PREVENTDAMAGE_TNT.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
{
- if (cause == DamageCause.FALL
- && (Permissions.PREVENTDAMAGE_FALL.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
+ event.setCancelled(true);
+ return;
+ }
- if (cause == DamageCause.SUFFOCATION
- && (Permissions.PREVENTDAMAGE_SUFFOCATION.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
- if ((cause == DamageCause.FIRE
- || cause == DamageCause.FIRE_TICK)
- && (Permissions.PREVENTDAMAGE_FIRE.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
- if (cause == DamageCause.DROWNING
- && (Permissions.PREVENTDAMAGE_DROWNING.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- return;
- }
- if (cause == DamageCause.LIGHTNING
- && (Permissions.PREVENTDAMAGE_LIGHTNING.isAuthorized(user)
- && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
- {
- event.setCancelled(true);
- }
+ if (edEvent.getDamager() instanceof Projectile
+ && ((Permissions.PREVENTDAMAGE_PROJECTILES.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user))
+ || (((Projectile)edEvent.getDamager()).getShooter() instanceof Player
+ && (!Permissions.PVP.isAuthorized(user)
+ || !Permissions.PVP.isAuthorized((Player)((Projectile)edEvent.getDamager()).getShooter())))))
+ {
+ event.setCancelled(true);
+ return;
}
}
- finally
- {
- settings.unlock();
- }
- }
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void onEntityExplode(final EntityExplodeEvent event)
- {
- final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
+ final DamageCause cause = event.getCause();
+ if (target instanceof Player)
{
- final int maxHeight = settings.getData().getCreeperMaxHeight();
-
- if (event.getEntity() instanceof EnderDragon
- && settings.getData().getPrevent().isEnderdragonBlockdamage())
+ if (cause == DamageCause.FALL
+ && (Permissions.PREVENTDAMAGE_FALL.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
{
event.setCancelled(true);
return;
}
- else if (event.getEntity() instanceof Creeper
- && (settings.getData().getPrevent().isCreeperExplosion()
- || settings.getData().getPrevent().isCreeperBlockdamage()
- || (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight)))
+
+ if (cause == DamageCause.SUFFOCATION
+ && (Permissions.PREVENTDAMAGE_SUFFOCATION.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
{
event.setCancelled(true);
- event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
return;
}
- else if (event.getEntity() instanceof TNTPrimed
- && settings.getData().getPrevent().isTntExplosion())
+ if ((cause == DamageCause.FIRE
+ || cause == DamageCause.FIRE_TICK)
+ && (Permissions.PREVENTDAMAGE_FIRE.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
{
event.setCancelled(true);
return;
}
- else if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
- && settings.getData().getPrevent().isFireballExplosion())
+ if (cause == DamageCause.DROWNING
+ && (Permissions.PREVENTDAMAGE_DROWNING.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
{
event.setCancelled(true);
return;
- }
+ }
+ if (cause == DamageCause.LIGHTNING
+ && (Permissions.PREVENTDAMAGE_LIGHTNING.isAuthorized(user)
+ && !Permissions.PREVENTDAMAGE_NONE.isAuthorized(user)))
+ {
+ event.setCancelled(true);
+ }
}
- finally
+ }
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onEntityExplode(final EntityExplodeEvent event)
+ {
+ final ProtectHolder settings = prot.getSettings();
+ final int maxHeight = settings.getData().getCreeperMaxHeight();
+
+ if (event.getEntity() instanceof EnderDragon
+ && settings.getData().getPrevent().isEnderdragonBlockdamage())
+ {
+ event.setCancelled(true);
+ return;
+ }
+ else if (event.getEntity() instanceof Creeper
+ && (settings.getData().getPrevent().isCreeperExplosion()
+ || settings.getData().getPrevent().isCreeperBlockdamage()
+ || (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight)))
+ {
+ event.setCancelled(true);
+ event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
+ return;
+ }
+ else if (event.getEntity() instanceof TNTPrimed
+ && settings.getData().getPrevent().isTntExplosion())
{
- settings.unlock();
+ event.setCancelled(true);
+ return;
+ }
+ else if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
+ && settings.getData().getPrevent().isFireballExplosion())
+ {
+ event.setCancelled(true);
+ return;
}
}
@@ -226,18 +210,10 @@ public class EssentialsProtectEntityListener implements Listener
public void onExplosionPrime(final ExplosionPrimeEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
+ if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
+ && settings.getData().getPrevent().isFireballFire())
{
- if ((event.getEntity() instanceof Fireball || event.getEntity() instanceof SmallFireball)
- && settings.getData().getPrevent().isFireballFire())
- {
- event.setFire(false);
- }
- }
- finally
- {
- settings.unlock();
+ event.setFire(false);
}
}
@@ -245,17 +221,9 @@ public class EssentialsProtectEntityListener implements Listener
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
- {
- if (event.getEntityType() == EntityType.ENDERMAN && settings.getData().getPrevent().isEndermanPickup())
- {
- event.setCancelled(true);
- }
- }
- finally
+ if (event.getEntityType() == EntityType.ENDERMAN && settings.getData().getPrevent().isEndermanPickup())
{
- settings.unlock();
+ event.setCancelled(true);
}
}
}
diff --git a/EssentialsProtect/src/net/ess3/protect/EssentialsProtectWeatherListener.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectWeatherListener.java
index 6f08bdd13..1f71944a0 100644
--- a/EssentialsProtect/src/net/ess3/protect/EssentialsProtectWeatherListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectWeatherListener.java
@@ -21,19 +21,12 @@ public class EssentialsProtectWeatherListener implements Listener
public void onWeatherChange(final WeatherChangeEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
- {
- if (!event.isCancelled()
- && settings.getData().isDisableStorm()
- && event.toWeatherState())
- {
- event.setCancelled(true);
- }
- }
- finally
+
+ if (!event.isCancelled()
+ && settings.getData().isDisableStorm()
+ && event.toWeatherState())
{
- settings.unlock();
+ event.setCancelled(true);
}
}
@@ -41,18 +34,11 @@ public class EssentialsProtectWeatherListener implements Listener
public void onLightningStrike(final LightningStrikeEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
- {
- if (!event.isCancelled()
- && settings.getData().isDisableLighting())
- {
- event.setCancelled(true);
- }
- }
- finally
+
+ if (!event.isCancelled()
+ && settings.getData().isDisableLighting())
{
- settings.unlock();
+ event.setCancelled(true);
}
}
@@ -60,19 +46,12 @@ public class EssentialsProtectWeatherListener implements Listener
public void onThunderChange(final ThunderChangeEvent event)
{
final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
- {
- if (!event.isCancelled()
- && settings.getData().isDisableThunder()
- && event.toThunderState())
- {
- event.setCancelled(true);
- }
- }
- finally
+
+ if (!event.isCancelled()
+ && settings.getData().isDisableThunder()
+ && event.toThunderState())
{
- settings.unlock();
+ event.setCancelled(true);
}
}
}
diff --git a/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java b/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java
index ba528006f..d5cf4ff14 100644
--- a/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java
+++ b/EssentialsSigns/src/net/ess3/signs/SignBlockListener.java
@@ -1,11 +1,10 @@
package net.ess3.signs;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import net.ess3.api.IEssentials;
import net.ess3.api.ISettings;
import net.ess3.api.IUser;
-import net.ess3.utils.Util;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import net.ess3.permissions.Permissions;
import net.ess3.utils.FormatUtil;
import org.bukkit.Material;
@@ -36,7 +35,6 @@ public class SignBlockListener implements Listener
public void onBlockBreak(final BlockBreakEvent event)
{
ISettings settings = ess.getSettings();
- settings.acquireReadLock();
if (plugin.getSettings().areSignsDisabled())
{
return;
diff --git a/EssentialsSigns/src/net/ess3/signs/SignMail.java b/EssentialsSigns/src/net/ess3/signs/SignMail.java
index 6acf14bb1..5b1c810ac 100644
--- a/EssentialsSigns/src/net/ess3/signs/SignMail.java
+++ b/EssentialsSigns/src/net/ess3/signs/SignMail.java
@@ -16,16 +16,7 @@ public class SignMail extends EssentialsSign
@Override
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
{
- final List<String> mail;
- player.acquireReadLock();
- try
- {
- mail = player.getData().getMails();
- }
- finally
- {
- player.unlock();
- }
+ final List<String> mail = player.getData().getMails();
if (mail == null || mail.isEmpty())
{
player.sendMessage(_("noNewMail"));
diff --git a/EssentialsSigns/src/net/ess3/signs/SignsConfig.java b/EssentialsSigns/src/net/ess3/signs/SignsConfig.java
index 70b606962..2db26f9c0 100644
--- a/EssentialsSigns/src/net/ess3/signs/SignsConfig.java
+++ b/EssentialsSigns/src/net/ess3/signs/SignsConfig.java
@@ -1,19 +1,21 @@
package net.ess3.signs;
-import net.ess3.storage.StorageObject;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.Map;
+import net.ess3.storage.StorageObject;
public class SignsConfig implements StorageObject
{
- private Map<String, Boolean> signs = new HashMap<String, Boolean>();
-
+ private Map<String, Boolean> signs;
+
public Map<String, Boolean> getSigns()
{
- return signs;
+ return signs == null
+ ? Collections.<String, Boolean>emptyMap()
+ : Collections.unmodifiableMap(signs);
}
-
+
public void setSigns(final Map<String, Boolean> signs)
{
this.signs = signs;
diff --git a/EssentialsSigns/src/net/ess3/signs/SignsConfigHolder.java b/EssentialsSigns/src/net/ess3/signs/SignsConfigHolder.java
index fce56906d..49cf15647 100644
--- a/EssentialsSigns/src/net/ess3/signs/SignsConfigHolder.java
+++ b/EssentialsSigns/src/net/ess3/signs/SignsConfigHolder.java
@@ -19,43 +19,29 @@ public class SignsConfigHolder extends AsyncStorageObjectHolder<SignsConfig>
super(ess, SignsConfig.class);
this.plugin = plugin;
onReload();
- acquireReadLock();
- try
+ final Map<String, Boolean> signs = getData().getSigns();
+ for (Map.Entry<String, Boolean> entry : signs.entrySet())
{
- final Map<String, Boolean> signs = getData().getSigns();
- for (Map.Entry<String, Boolean> entry : signs.entrySet())
+ if (entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOR") || entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOUR"))
{
- if (entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOR") || entry.getKey().trim().toUpperCase(Locale.ENGLISH).equals("COLOUR"))
- {
- signsEnabled = true;
- continue;
- }
- final Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH));
- if (sign != null && entry.getValue())
- {
- enabledSigns.add(sign.getSign());
- signsEnabled = true;
- }
+ signsEnabled = true;
+ continue;
}
- }
- finally
- {
- unlock();
- }
- acquireWriteLock();
- try
- {
- final Map<String, Boolean> signs = new HashMap<String, Boolean>();
- for (Signs sign : Signs.values())
+ final Signs sign = Signs.valueOf(entry.getKey().toUpperCase(Locale.ENGLISH));
+ if (sign != null && entry.getValue())
{
- signs.put(sign.toString(), enabledSigns.contains(sign.getSign()));
+ enabledSigns.add(sign.getSign());
+ signsEnabled = true;
}
- getData().setSigns(signs);
}
- finally
+
+ final Map<String, Boolean> signs2 = new HashMap<String, Boolean>();
+ for (Signs sign : Signs.values())
{
- unlock();
+ signs2.put(sign.toString(), enabledSigns.contains(sign.getSign()));
}
+ getData().setSigns(signs2);
+ queueSave();
}
@Override