clansbans
This commit is contained in:
parent
8330ef560d
commit
14207c2073
@ -107,7 +107,7 @@ public class Clans extends JavaPlugin
|
|||||||
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
|
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
|
||||||
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
|
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());
|
||||||
|
|
||||||
// new ClansBanManager(this, _clientManager, _donationManager);
|
ClansBanManager clansBans = new ClansBanManager(this, _clientManager, _donationManager);
|
||||||
|
|
||||||
PacketHandler packetHandler = new PacketHandler(this);
|
PacketHandler packetHandler = new PacketHandler(this);
|
||||||
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
||||||
@ -137,7 +137,7 @@ public class Clans extends JavaPlugin
|
|||||||
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
|
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
|
||||||
|
|
||||||
HologramManager hologram = new HologramManager(this, packetHandler);
|
HologramManager hologram = new HologramManager(this, packetHandler);
|
||||||
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
|
_clansManager = new ClansManager(this, clansBans, serverStatusManager.getCurrentServerName(), packetHandler, punish, _clientManager, _donationManager, preferenceManager, blockRestore, statsManager, teleport, chat, customGear, hologram, webServerAddress);
|
||||||
new Recipes(this);
|
new Recipes(this);
|
||||||
new Farming(this);
|
new Farming(this);
|
||||||
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
new BuildingShop(_clansManager, _clientManager, _donationManager);
|
||||||
|
@ -74,6 +74,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
import mineplex.game.clans.Clans;
|
import mineplex.game.clans.Clans;
|
||||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||||
import mineplex.game.clans.clans.ClansUtility.ClanRelation;
|
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.ClanManagementCommand;
|
||||||
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
|
||||||
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
import mineplex.game.clans.clans.commands.ClansChatCommand;
|
||||||
@ -220,16 +221,19 @@ 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;
|
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;
|
public ClanTips ClanTips;
|
||||||
|
|
||||||
// Spawn area
|
// Spawn area
|
||||||
|
|
||||||
public ClansManager(JavaPlugin plugin, String serverName, 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, ClansBanManager clansBans, String serverName, 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);
|
super("Clans Manager", plugin);
|
||||||
|
|
||||||
_instance = this;
|
_instance = this;
|
||||||
|
|
||||||
|
_clansBans = clansBans;
|
||||||
_punish = punish;
|
_punish = punish;
|
||||||
|
|
||||||
_serverName = serverName;
|
_serverName = serverName;
|
||||||
@ -593,23 +597,34 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
public void Join(PlayerJoinEvent event)
|
public void Join(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
event.setJoinMessage(null);
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
|
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (IncognitoManager.Instance.Get(event.getPlayer()).Status)
|
if (IncognitoManager.Instance.Get(event.getPlayer()).Status)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_clansBans.runAfterLoad(event.getPlayer().getName(), () -> {
|
||||||
for (Player other : UtilServer.getPlayers())
|
if (_clansBans.Get(event.getPlayer().getName()).isBanned())
|
||||||
{
|
|
||||||
if (_tutorial.inTutorial(other))
|
|
||||||
{
|
{
|
||||||
// Don't display join message if player in tutorial.
|
return;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
other.sendMessage(F.sys("Join", event.getPlayer().getName()));
|
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)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -621,7 +636,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (Player other : UtilServer.getPlayers())
|
for (Player other : UtilServer.getPlayers())
|
||||||
{
|
{
|
||||||
@ -644,6 +663,16 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getReason().contains("You are banned from Clans"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.getLeaveMessage() != null)
|
if (event.getLeaveMessage() != null)
|
||||||
{
|
{
|
||||||
event.setLeaveMessage(null);
|
event.setLeaveMessage(null);
|
||||||
|
@ -2,6 +2,7 @@ package mineplex.game.clans.clans.ban;
|
|||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -12,8 +13,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
|
||||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
|
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -23,6 +22,7 @@ import com.google.common.collect.Lists;
|
|||||||
import mineplex.core.MiniPlugin;
|
import mineplex.core.MiniPlugin;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.account.ILoginProcessor;
|
import mineplex.core.account.ILoginProcessor;
|
||||||
|
import mineplex.core.common.DefaultHashMap;
|
||||||
import mineplex.core.common.Pair;
|
import mineplex.core.common.Pair;
|
||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.Callback;
|
import mineplex.core.common.util.Callback;
|
||||||
@ -32,6 +32,7 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
|
import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
|
||||||
import mineplex.game.clans.clans.ban.ui.ClansBanShop;
|
import mineplex.game.clans.clans.ban.ui.ClansBanShop;
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
|||||||
private ClansBanRepository _repository;
|
private ClansBanRepository _repository;
|
||||||
private Map<String, ClansBanClient> _clients;
|
private Map<String, ClansBanClient> _clients;
|
||||||
private Map<String, Pair<String, String>> _cache;
|
private Map<String, Pair<String, String>> _cache;
|
||||||
|
private DefaultHashMap<String, List<Runnable>> _runAfterLoad;
|
||||||
private ClansBanShop _shop;
|
private ClansBanShop _shop;
|
||||||
|
|
||||||
private Map<String, String> _toKick = new HashMap<>();
|
private Map<String, String> _toKick = new HashMap<>();
|
||||||
@ -57,7 +59,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
|||||||
|
|
||||||
_clients = new HashMap<>();
|
_clients = new HashMap<>();
|
||||||
_cache = new HashMap<>();
|
_cache = new HashMap<>();
|
||||||
|
_runAfterLoad = new DefaultHashMap<>(name -> new ArrayList<>());
|
||||||
_shop = new ClansBanShop(this, clientManager, donationManager);
|
_shop = new ClansBanShop(this, clientManager, donationManager);
|
||||||
|
|
||||||
clientManager.addStoredProcedureLoginProcessor(this);
|
clientManager.addStoredProcedureLoginProcessor(this);
|
||||||
@ -232,6 +234,11 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
|||||||
LoadClient(name, callback);
|
LoadClient(name, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean willBeKicked(Player player)
|
||||||
|
{
|
||||||
|
return _toKick.containsKey(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
{
|
{
|
||||||
_repository.loadBans(playerName, client -> {
|
_repository.loadBans(playerName, client -> {
|
||||||
@ -246,6 +253,19 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
|||||||
"\n" + C.cWhite + client.getLongestBan().getReason();
|
"\n" + C.cWhite + client.getLongestBan().getReason();
|
||||||
|
|
||||||
_toKick.put(playerName, reason);
|
_toKick.put(playerName, reason);
|
||||||
|
|
||||||
|
ClansManager.getInstance().runSyncLater(() -> {
|
||||||
|
if (Bukkit.getPlayer(playerName) != null)
|
||||||
|
{
|
||||||
|
Bukkit.getPlayer(playerName).kickPlayer(_toKick.remove(playerName));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_runAfterLoad.get(playerName).forEach(Runnable::run);
|
||||||
|
_runAfterLoad.get(playerName).clear();
|
||||||
|
}
|
||||||
|
}, 5L);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -254,4 +274,9 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
|||||||
{
|
{
|
||||||
return "SELECT * FROM clanBans WHERE uuid = '" + uuid + "';";
|
return "SELECT * FROM clanBans WHERE uuid = '" + uuid + "';";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runAfterLoad(String playerName, Runnable run)
|
||||||
|
{
|
||||||
|
_runAfterLoad.get(playerName).add(run);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,6 +210,7 @@ public class NetherManager extends MiniPlugin
|
|||||||
_clansManager.getItemMapManager().removeMap(player);
|
_clansManager.getItemMapManager().removeMap(player);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getType() == UpdateType.SLOW)
|
if (event.getType() == UpdateType.SLOW)
|
||||||
{
|
{
|
||||||
_portals.forEach(portal -> {
|
_portals.forEach(portal -> {
|
||||||
|
@ -39,10 +39,10 @@ public class Portal
|
|||||||
if (!isValidPortalBlock(from.getBlock()) || !isValidPortalBlock(to.getBlock()))
|
if (!isValidPortalBlock(from.getBlock()) || !isValidPortalBlock(to.getBlock()))
|
||||||
{
|
{
|
||||||
if (!isValidPortalBlock(from.getBlock()))
|
if (!isValidPortalBlock(from.getBlock()))
|
||||||
from = UtilBlock.getInRadius(from.getBlock(), 12).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation();
|
from = UtilBlock.getInRadius(from.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation();
|
||||||
|
|
||||||
if (!isValidPortalBlock(to.getBlock()))
|
if (!isValidPortalBlock(to.getBlock()))
|
||||||
to = UtilBlock.getInRadius(to.getBlock(), 9).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation();
|
to = UtilBlock.getInRadius(to.getBlock(), 4).keySet().stream().filter(this::isValidPortalBlock).limit(1).iterator().next().getLocation();
|
||||||
|
|
||||||
if (to == null || from == null)
|
if (to == null || from == null)
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ public class Portal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Block other : UtilBlock.getInRadius(from, 7.5d).keySet())
|
for (Block other : UtilBlock.getInRadius(from, 25).keySet())
|
||||||
{
|
{
|
||||||
if (other.getType() == Material.OBSIDIAN)
|
if (other.getType() == Material.OBSIDIAN)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user