Code style fixes

This commit is contained in:
Dan Mulloy 2018-02-14 14:50:45 -05:00 committed by Alexander Meech
parent ea276c5120
commit 8c07d34234
10 changed files with 37 additions and 21 deletions

View File

@ -143,8 +143,13 @@ public class Community
public void setFlag(String flag, boolean value) public void setFlag(String flag, boolean value)
{ {
if (value) flags.add(flag.toLowerCase()); if (value)
else flags.remove(flag.toLowerCase()); {
flags.add(flag.toLowerCase());
} else
{
flags.remove(flag.toLowerCase());
}
} }
public boolean getFlag(String flag) public boolean getFlag(String flag)

View File

@ -110,14 +110,11 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
private final CommunityRepository _repo; private final CommunityRepository _repo;
private final Map<Integer, Community> _loadedCommunities; private final Map<Integer, Community> _loadedCommunities;
private final Random rand = new Random(); private final Random _rand = new Random();
private final List<Integer> _browserIds = new LinkedList<>(); private final List<Integer> _browserIds = new LinkedList<>();
private final List<UUID> _creating = new ArrayList<>(); private final List<UUID> _creating = new ArrayList<>();
// private final DataRepository<PlayerStatus> StatusRepository;
// private ServerRepository _serverRepo;
private boolean _us; private boolean _us;
private final Set<Community> dirty = Collections.newSetFromMap(new ConcurrentHashMap<>()); // Communities with redis updates private final Set<Community> dirty = Collections.newSetFromMap(new ConcurrentHashMap<>()); // Communities with redis updates
@ -125,7 +122,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
private int _updateCycleCount; // The number of update cycles since we've updated all communities private int _updateCycleCount; // The number of update cycles since we've updated all communities
private volatile boolean _cycling = false; private volatile boolean _cycling = false;
private CoreClientManager _clientManager; private final CoreClientManager _clientManager;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public CommunityManager() public CommunityManager()
@ -141,7 +138,8 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
_loadedCommunities = new ConcurrentHashMap<>(); _loadedCommunities = new ConcurrentHashMap<>();
runAsync(() -> { runAsync(() ->
{
_repo.loadBrowserCommunities(_browserIds); _repo.loadBrowserCommunities(_browserIds);
log("Loaded " + _browserIds.size() + " communities to show in browser"); log("Loaded " + _browserIds.size() + " communities to show in browser");
}); });
@ -206,7 +204,8 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
}, 0L, 20 * UPDATE_CYCLE_SECONDS); }, 0L, 20 * UPDATE_CYCLE_SECONDS);
Bukkit.getScheduler().scheduleSyncRepeatingTask(_plugin, this::cycleBrowser, 0L, 20 * 30); Bukkit.getScheduler().scheduleSyncRepeatingTask(_plugin, this::cycleBrowser, 0L, 20 * 30);
// Handled in join events now
// _repo.handlePlayerJoin(_loadedCommunities); // _repo.handlePlayerJoin(_loadedCommunities);
addCommand(new CommunityCommand(this)); addCommand(new CommunityCommand(this));
@ -231,7 +230,9 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
int comId = Integer.parseInt(group.getName().split("-")[1]); int comId = Integer.parseInt(group.getName().split("-")[1]);
Community community = getLoadedCommunity(comId); Community community = getLoadedCommunity(comId);
if (community == null) if (community == null)
{
community = _repo.loadCommunity(_loadedCommunities, comId); community = _repo.loadCommunity(_loadedCommunities, comId);
}
community.setFlag("persist", true); community.setFlag("persist", true);
} }
@ -276,7 +277,7 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
_cycling = true; _cycling = true;
runAsync(() -> runAsync(() ->
{ {
Collections.shuffle(_browserIds, rand); Collections.shuffle(_browserIds, _rand);
runSync(() -> runSync(() ->
{ {
@ -300,7 +301,9 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
Community com = _loadedCommunities.get(id); Community com = _loadedCommunities.get(id);
if (com != null) if (com != null)
{
com.setFlag("display", true); com.setFlag("display", true);
}
} }
} }
@ -748,7 +751,9 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
_repo.updateCommunitySetting(setting, community.getId(), newValue); _repo.updateCommunitySetting(setting, community.getId(), newValue);
if (setting == CommunitySetting.PRIVACY) if (setting == CommunitySetting.PRIVACY)
{
updateBrowserStatus(community); updateBrowserStatus(community);
}
}); });
new CommunityUpdateSetting(community.getId(), sender.getName(), setting.toString(), newValue).publish(); new CommunityUpdateSetting(community.getId(), sender.getName(), setting.toString(), newValue).publish();
} }
@ -900,7 +905,10 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
Set<Integer> communityIds = Get(player).getCommunityIds(); Set<Integer> communityIds = Get(player).getCommunityIds();
final List<Integer> load = communityIds.stream().filter(id -> getLoadedCommunity(id) == null).collect(Collectors.toList()); final List<Integer> 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); final int accountId = _clientManager.getAccountId(player);
@ -921,7 +929,9 @@ public class CommunityManager extends MiniDbClientPlugin<CommunityMemberData>
{ {
if (community.getFlag("persist") if (community.getFlag("persist")
|| community.getMembers().keySet().stream().anyMatch(uuid -> !player.getUniqueId().equals(uuid) && Bukkit.getPlayer(uuid) != null)) || community.getMembers().keySet().stream().anyMatch(uuid -> !player.getUniqueId().equals(uuid) && Bukkit.getPlayer(uuid) != null))
{
continue; continue;
}
System.out.println("Unloading community: " + community.getId()); System.out.println("Unloading community: " + community.getId());

View File

@ -56,7 +56,9 @@ public class CommunityMemberData
{ {
Community community = Managers.get(CommunityManager.class).getLoadedCommunity(id); Community community = Managers.get(CommunityManager.class).getLoadedCommunity(id);
if (community != null) if (community != null)
{
ret.add(community); ret.add(community);
}
} }
return ret; return ret;

View File

@ -113,7 +113,7 @@ public class CommunityBrowserPage extends CommunitiesGUIPage
} }
} }
CommunityBrowserButton button = new CommunityBrowserButton(Viewer, getCommunityManager().getLoadedCommunity(manager.getBrowserIds().get(i))); 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); Buttons.put(slot, button);
Inv.setItem(slot, button.Button); Inv.setItem(slot, button.Button);

View File

@ -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.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.YELLOW + "MC Timings (5,10,15 min avg)"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + mcString.toString())); 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 + "Free-------" + ChatColor.YELLOW + (Runtime.getRuntime().freeMemory() / 1048576) + "MB"));
player.sendMessage(F.main(getName(), ChatColor.GRAY + "Max--------" + ChatColor.YELLOW + (Runtime.getRuntime().maxMemory() / 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(" ");
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")); player.sendMessage(F.main(getName(), ChatColor.YELLOW + String.valueOf(player.getWorld().getLoadedChunks().length) + ChatColor.GRAY + " chunks loaded"));

View File

@ -456,7 +456,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
_bannerManager.loadBanners(this); _bannerManager.loadBanners(this);
new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false); new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false);
new CommunityManager(); require(CommunityManager.class);
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict"); Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");

View File

@ -239,7 +239,7 @@ public class HubManager extends MiniPlugin implements IChatMessageFormatter
new SalesAnnouncementManager(plugin); new SalesAnnouncementManager(plugin);
new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false); new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false);
new CommunityManager(); require(CommunityManager.class);
require(TabListSorter.class); require(TabListSorter.class);
ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) ScoreboardManager scoreboardManager = new ScoreboardManager(plugin)
{ {

View File

@ -214,7 +214,7 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
new SalesAnnouncementManager(_plugin); new SalesAnnouncementManager(_plugin);
new CommunityManager(); require(CommunityManager.class);
_hologramManager = hologramManager; _hologramManager = hologramManager;

View File

@ -408,7 +408,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
addCommand(new TauntCommand(this)); addCommand(new TauntCommand(this));
new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false); new PersonalServerManager(plugin, _clientManager).setUseInterfaceItem(false);
new CommunityManager(); require(CommunityManager.class);
_scoreboardManager = new ScoreboardManager(_plugin) _scoreboardManager = new ScoreboardManager(_plugin)
{ {

View File

@ -217,7 +217,7 @@ public class GemHunters extends JavaPlugin
new PartyManager(); new PartyManager();
// Communities // Communities
new CommunityManager(); require(CommunityManager.class);
// Fixes // Fixes
new MemoryFix(this); new MemoryFix(this);