From 8c07d34234739e3b4b0c6f591acf7f051af202a2 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Wed, 14 Feb 2018 14:50:45 -0500 Subject: [PATCH] Code style fixes --- .../mineplex/core/communities/Community.java | 9 ++++-- .../core/communities/CommunityManager.java | 30 ++++++++++++------- .../core/communities/CommunityMemberData.java | 2 ++ .../gui/browser/CommunityBrowserPage.java | 2 +- .../src/mineplex/core/monitor/LagMeter.java | 5 ++-- .../game/clans/clans/ClansManager.java | 2 +- .../src/mineplex/clanshub/HubManager.java | 2 +- .../src/mineplex/hub/HubManager.java | 2 +- .../nautilus/game/arcade/ArcadeManager.java | 2 +- .../src/mineplex/gemhunters/GemHunters.java | 2 +- 10 files changed, 37 insertions(+), 21 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/Community.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/Community.java index 048ee7210..a2152f759 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/Community.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/Community.java @@ -143,8 +143,13 @@ public class Community public void setFlag(String flag, boolean value) { - if (value) flags.add(flag.toLowerCase()); - else flags.remove(flag.toLowerCase()); + if (value) + { + flags.add(flag.toLowerCase()); + } else + { + flags.remove(flag.toLowerCase()); + } } public boolean getFlag(String flag) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java index 0a86d8e35..e1f04ab53 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityManager.java @@ -110,14 +110,11 @@ public class CommunityManager extends MiniDbClientPlugin private final CommunityRepository _repo; private final Map _loadedCommunities; - private final Random rand = new Random(); + private final Random _rand = new Random(); private final List _browserIds = new LinkedList<>(); private final List _creating = new ArrayList<>(); - - // private final DataRepository StatusRepository; - - // private ServerRepository _serverRepo; + private boolean _us; private final Set dirty = Collections.newSetFromMap(new ConcurrentHashMap<>()); // Communities with redis updates @@ -125,7 +122,7 @@ public class CommunityManager extends MiniDbClientPlugin private int _updateCycleCount; // The number of update cycles since we've updated all communities private volatile boolean _cycling = false; - private CoreClientManager _clientManager; + private final CoreClientManager _clientManager; @SuppressWarnings("deprecation") public CommunityManager() @@ -141,7 +138,8 @@ public class CommunityManager extends MiniDbClientPlugin _loadedCommunities = new ConcurrentHashMap<>(); - runAsync(() -> { + runAsync(() -> + { _repo.loadBrowserCommunities(_browserIds); log("Loaded " + _browserIds.size() + " communities to show in browser"); }); @@ -206,7 +204,8 @@ public class CommunityManager extends MiniDbClientPlugin }, 0L, 20 * UPDATE_CYCLE_SECONDS); Bukkit.getScheduler().scheduleSyncRepeatingTask(_plugin, this::cycleBrowser, 0L, 20 * 30); - + + // Handled in join events now // _repo.handlePlayerJoin(_loadedCommunities); addCommand(new CommunityCommand(this)); @@ -231,7 +230,9 @@ public class CommunityManager extends MiniDbClientPlugin int comId = Integer.parseInt(group.getName().split("-")[1]); Community community = getLoadedCommunity(comId); if (community == null) + { community = _repo.loadCommunity(_loadedCommunities, comId); + } community.setFlag("persist", true); } @@ -276,7 +277,7 @@ public class CommunityManager extends MiniDbClientPlugin _cycling = true; runAsync(() -> { - Collections.shuffle(_browserIds, rand); + Collections.shuffle(_browserIds, _rand); runSync(() -> { @@ -300,7 +301,9 @@ public class CommunityManager extends MiniDbClientPlugin { Community com = _loadedCommunities.get(id); if (com != null) + { com.setFlag("display", true); + } } } @@ -748,7 +751,9 @@ public class CommunityManager extends MiniDbClientPlugin { _repo.updateCommunitySetting(setting, community.getId(), newValue); if (setting == CommunitySetting.PRIVACY) + { updateBrowserStatus(community); + } }); new CommunityUpdateSetting(community.getId(), sender.getName(), setting.toString(), newValue).publish(); } @@ -900,7 +905,10 @@ public class CommunityManager extends MiniDbClientPlugin Set communityIds = Get(player).getCommunityIds(); final List load = communityIds.stream().filter(id -> getLoadedCommunity(id) == null).collect(Collectors.toList()); - if (load.isEmpty()) return; + if (load.isEmpty()) + { + return; + } final int accountId = _clientManager.getAccountId(player); @@ -921,7 +929,9 @@ public class CommunityManager extends MiniDbClientPlugin { if (community.getFlag("persist") || community.getMembers().keySet().stream().anyMatch(uuid -> !player.getUniqueId().equals(uuid) && Bukkit.getPlayer(uuid) != null)) + { continue; + } System.out.println("Unloading community: " + community.getId()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberData.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberData.java index aa1fe39b8..99a1de9e4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/CommunityMemberData.java @@ -56,7 +56,9 @@ public class CommunityMemberData { Community community = Managers.get(CommunityManager.class).getLoadedCommunity(id); if (community != null) + { ret.add(community); + } } return ret; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/browser/CommunityBrowserPage.java b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/browser/CommunityBrowserPage.java index 0f3a7ee54..df8668add 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/browser/CommunityBrowserPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/communities/gui/browser/CommunityBrowserPage.java @@ -113,7 +113,7 @@ public class CommunityBrowserPage extends CommunitiesGUIPage } } CommunityBrowserButton button = new CommunityBrowserButton(Viewer, getCommunityManager().getLoadedCommunity(manager.getBrowserIds().get(i))); - // _displaying.add(manager.getBrowserIds().get(i)); + // _displaying.add(manager.getBrowserIds().get(i)); -- moved up Buttons.put(slot, button); Inv.setItem(slot, button.Button); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java index 061b902de..5f542bc90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/monitor/LagMeter.java @@ -167,13 +167,12 @@ public class LagMeter extends MiniPlugin player.sendMessage(F.main(getName(), ChatColor.GRAY + "Avg--------" + ChatColor.YELLOW + String.format("%.00f", _ticksPerSecondAverage * 20))); player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MC Timings (5,10,15 min avg)")); player.sendMessage(F.main(getName(), ChatColor.GRAY + mcString.toString())); - player.sendMessage(F.main(getName(), ChatColor.YELLOW + "MEM")); + player.sendMessage(F.main(getName(), ChatColor.YELLOW + "Memory")); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB")); player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 1048576)) + "MB"); - // Statistics for Dan, ideally this'll be temporary player.sendMessage(" "); - player.sendMessage(F.main(getName(), ChatColor.GRAY + "Temp Stats -----")); + player.sendMessage(F.main(getName(), ChatColor.GRAY + "In Memory -----")); player.sendMessage(F.main(getName(), ChatColor.YELLOW + String.valueOf(player.getWorld().getLoadedChunks().length) + ChatColor.GRAY + " chunks loaded")); diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java index 757831758..35287bc67 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/clans/ClansManager.java @@ -456,7 +456,7 @@ public class ClansManager extends MiniClientPlugin implements IRelat _bannerManager.loadBanners(this); new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false); - new CommunityManager(); + require(CommunityManager.class); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict"); diff --git a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java index df34cc2e8..c6e56720e 100644 --- a/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java +++ b/Plugins/Mineplex.Hub.Clans/src/mineplex/clanshub/HubManager.java @@ -239,7 +239,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter new SalesAnnouncementManager(plugin); new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false); - new CommunityManager(); + require(CommunityManager.class); require(TabListSorter.class); ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 01b96d08f..eb90eae7d 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -214,7 +214,7 @@ public class HubManager extends MiniClientPlugin implements IChatMess new SalesAnnouncementManager(_plugin); - new CommunityManager(); + require(CommunityManager.class); _hologramManager = hologramManager; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index aa5949c86..5520e0089 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -408,7 +408,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation addCommand(new TauntCommand(this)); new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false); - new CommunityManager(); + require(CommunityManager.class); _scoreboardManager = new ScoreboardManager(_plugin) { diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java index 5e483022d..f57d0ce29 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/GemHunters.java @@ -217,7 +217,7 @@ public class GemHunters extends JavaPlugin new PartyManager(); // Communities - new CommunityManager(); + require(CommunityManager.class); // Fixes new MemoryFix(this);