Merge pull request #57 from Mineplex-LLC/clans/beta
Latest clans/beta changes
This commit is contained in:
commit
39c3833b47
@ -46,7 +46,6 @@ import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.items.GearManager;
|
||||
import mineplex.game.clans.shop.building.BuildingShop;
|
||||
import mineplex.game.clans.shop.farming.FarmingShop;
|
||||
@ -118,7 +117,7 @@ public class Clans extends JavaPlugin
|
||||
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
|
||||
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
|
||||
|
||||
ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
|
||||
//ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
|
||||
|
||||
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
||||
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
|
||||
@ -154,7 +153,7 @@ public class Clans extends JavaPlugin
|
||||
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
|
||||
|
||||
HologramManager hologram = new HologramManager(this, packetHandler);
|
||||
_clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
|
||||
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), incognito, packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
|
||||
new Recipes(this);
|
||||
new Farming(this);
|
||||
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@ -80,7 +81,6 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.Clans;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.commands.ClanManagementCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||
@ -226,19 +226,16 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
public String UserDataDir = UtilServer.getServer().getWorlds().get(0).getWorldFolder().getPath() + File.separator + ".." + File.separator + "CLANS_USER_DATA" + File.separator;
|
||||
|
||||
private ClansBanManager _clansBans;
|
||||
|
||||
public ClanTips ClanTips;
|
||||
|
||||
// Spawn area
|
||||
|
||||
public ClansManager(JavaPlugin plugin, ClansBanManager clansBans, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
|
||||
public ClansManager(JavaPlugin plugin, String serverName, IncognitoManager incognitoManager, PacketHandler packetHandler, Punish punish, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, StatsManager statsManager, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
_instance = this;
|
||||
|
||||
_clansBans = clansBans;
|
||||
_punish = punish;
|
||||
|
||||
_incognitoManager = incognitoManager;
|
||||
@ -605,33 +602,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
event.setJoinMessage(null);
|
||||
|
||||
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_incognitoManager.Get(event.getPlayer()).Status)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_clansBans.runAfterLoad(event.getPlayer().getName(), () -> {
|
||||
if (_clansBans.Get(event.getPlayer().getName()).isBanned())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if (_tutorial.inTutorial(other))
|
||||
{
|
||||
// Don't display join message if player in tutorial.
|
||||
continue;
|
||||
}
|
||||
|
||||
other.sendMessage(F.sys("Join", event.getPlayer().getName()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -644,11 +618,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clansBans.Get(event.getPlayer().getName()) != null && _clansBans.Get(event.getPlayer().getName()).isBanned())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
if (_tutorial.inTutorial(other))
|
||||
@ -670,11 +639,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getReason().contains("banned from Clans"))
|
||||
{
|
||||
return;
|
||||
@ -892,6 +856,16 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
recipients.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableObsidian(BlockBreakEvent event)
|
||||
{
|
||||
if(event.getBlock().getType().equals(Material.OBSIDIAN))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
event.getBlock().setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
|
@ -2,11 +2,9 @@ package mineplex.game.clans.clans.ban;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -38,15 +36,13 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
{
|
||||
private CoreClientManager _clientManager;
|
||||
private ClansBanRepository _repository;
|
||||
private Map<String, ClansBanClient> _clients;
|
||||
private final Map<String, ClansBanClient> _clients = new ConcurrentHashMap<>();
|
||||
private Map<String, ClansBanCache> _cache;
|
||||
private DefaultHashMap<String, List<Runnable>> _runAfterLoad;
|
||||
private ClansBanShop _shop;
|
||||
|
||||
private Map<String, String> _toKick = new HashMap<>();
|
||||
|
||||
private Object _lock = new Object();
|
||||
|
||||
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super("Blacklist", plugin);
|
||||
@ -55,7 +51,6 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
|
||||
_repository = new ClansBanRepository(plugin);
|
||||
|
||||
_clients = new HashMap<>();
|
||||
_cache = new HashMap<>();
|
||||
_runAfterLoad = new DefaultHashMap<>(name -> new ArrayList<>());
|
||||
_shop = new ClansBanShop(this, clientManager, donationManager);
|
||||
@ -92,10 +87,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
|
||||
if (event.getType().equals(UpdateType.MIN_01))
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
UtilStreams.ToList(_clients.keySet().stream().filter(UtilServer::IsOnline)).forEach(this::UnloadClient);
|
||||
}
|
||||
_clients.keySet().stream().filter(UtilServer::IsOnline).forEach(this::UnloadClient);
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,10 +150,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
|
||||
public void UnloadClient(String name)
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
_clients.remove(name);
|
||||
}
|
||||
_clients.remove(name);
|
||||
}
|
||||
|
||||
public void LoadClient(String name, Callback<ClansBanClient> callback)
|
||||
@ -173,25 +162,19 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
}
|
||||
|
||||
GetRepository().loadClient(name, client -> {
|
||||
synchronized (_lock)
|
||||
{
|
||||
_clients.put(name.toLowerCase(), client);
|
||||
System.out.println("> CLIENTS: " + _clients);
|
||||
_clients.put(name.toLowerCase(), client);
|
||||
System.out.println("> CLIENTS: " + _clients);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(client);
|
||||
}
|
||||
}
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(client);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ClansBanClient Get(String name)
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
return _clients.get(name.toLowerCase());
|
||||
}
|
||||
return _clients.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public ClansBanShop getShop()
|
||||
|
Loading…
Reference in New Issue
Block a user