Merge remote-tracking branch 'origin/develop' into project-cosmetics
Conflicts: Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java
This commit is contained in:
commit
17a4517e71
@ -0,0 +1,61 @@
|
||||
package mineplex.core.common.events;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Called just before UtilPlayer#message sends out a message to the specified Player.
|
||||
*/
|
||||
public class PlayerMessageEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private String _message;
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public PlayerMessageEvent(Player player, String message)
|
||||
{
|
||||
_player = player;
|
||||
_message = message;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
public String getUnformattedMessage()
|
||||
{
|
||||
return ChatColor.stripColor(_message);
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
@ -30,6 +30,7 @@ import org.bukkit.util.BlockIterator;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.MinecraftVersion;
|
||||
import mineplex.core.common.events.PlayerMessageEvent;
|
||||
|
||||
public class UtilPlayer
|
||||
{
|
||||
@ -311,6 +312,12 @@ public class UtilPlayer
|
||||
message = UtilWiki.link(message);
|
||||
*/
|
||||
|
||||
PlayerMessageEvent event = UtilServer.CallEvent(new PlayerMessageEvent((Player) client, message));
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
|
||||
((Player) client).sendMessage(message);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,12 @@ public class UtilServer
|
||||
|
||||
public static boolean IsOnline(String name)
|
||||
{
|
||||
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(player -> player.getName().equals(name)));
|
||||
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(name::equals));
|
||||
}
|
||||
|
||||
public static boolean IsOffline(String name)
|
||||
{
|
||||
return !UtilStreams.IsEmpty(getPlayersCollection().stream().filter(name::equals));
|
||||
}
|
||||
|
||||
public static Player GetPlayer(String name)
|
||||
|
@ -2,10 +2,13 @@ package mineplex.core.common.util;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class UtilStreams
|
||||
{
|
||||
public static boolean IsEmpty(Stream<?> stream)
|
||||
@ -55,4 +58,9 @@ public class UtilStreams
|
||||
return read;
|
||||
}
|
||||
|
||||
public static <T> List<T> ToList(Stream<T> filter)
|
||||
{
|
||||
return Lists.newArrayList((T[]) ToArray(filter));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
|
||||
public class ItemBuilder
|
||||
{
|
||||
@ -56,6 +57,7 @@ public class ItemBuilder
|
||||
private Material _mat;
|
||||
private String _title = null;
|
||||
private boolean _unbreakable;
|
||||
private boolean _dullEnchantment;
|
||||
private String _playerHeadName = null;
|
||||
private HashSet<ItemFlag> _itemFlags = new HashSet<ItemFlag>();
|
||||
|
||||
@ -268,6 +270,11 @@ public class ItemBuilder
|
||||
|
||||
item.addUnsafeEnchantments(_enchants);
|
||||
|
||||
if (_dullEnchantment)
|
||||
{
|
||||
UtilInv.addDullEnchantment(item);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -413,4 +420,11 @@ public class ItemBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addDullEnchantment(boolean dullEnchantment)
|
||||
{
|
||||
_dullEnchantment = dullEnchantment;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -41,6 +41,7 @@ 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;
|
||||
@ -112,7 +113,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);
|
||||
@ -135,8 +136,8 @@ public class Clans extends JavaPlugin
|
||||
ResourcePackManager resourcePackManager = new ResourcePackManager(this, portal);
|
||||
resourcePackManager.setResourcePack(new Pair[]
|
||||
{
|
||||
Pair.create(MinecraftVersion.Version1_8, "http://phinary.ca/ResClans.zip"),
|
||||
Pair.create(MinecraftVersion.Version1_9, "http://phinary.ca/ResClans19.zip")
|
||||
Pair.create(MinecraftVersion.Version1_8, "http://file.mineplex.com/ResClans.zip"),
|
||||
Pair.create(MinecraftVersion.Version1_9, "http://file.mineplex.com/ResClans19.zip")
|
||||
}, true);
|
||||
|
||||
// Enable custom-gear related managers
|
||||
@ -144,7 +145,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, clansBans, 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);
|
||||
|
@ -9,14 +9,11 @@ import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
@ -47,6 +44,7 @@ import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.events.PlayerMessageEvent;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
@ -73,6 +71,7 @@ import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.punish.PunishClient;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
@ -81,6 +80,7 @@ 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,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;
|
||||
|
||||
/*private ClansBanManager _clansBans;*/
|
||||
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, 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)
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
||||
_instance = this;
|
||||
|
||||
/*_clansBans = clansBans;*/
|
||||
_clansBans = clansBans;
|
||||
_punish = punish;
|
||||
|
||||
_incognitoManager = incognitoManager;
|
||||
@ -355,6 +355,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
loadClan(token);
|
||||
}
|
||||
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
|
||||
|
||||
|
||||
// new ClaimVisualizer(plugin, this);
|
||||
|
||||
// RedisDataRepository(ConnectionData writeConn, ConnectionData
|
||||
@ -407,7 +410,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
hologram.start();
|
||||
}
|
||||
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
|
||||
|
||||
_siegeManager = new SiegeManager(this);
|
||||
// _netherManager = new NetherManager(this);
|
||||
@ -603,21 +605,21 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
event.setJoinMessage(null);
|
||||
|
||||
/*if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
if (_incognitoManager.Get(event.getPlayer()).Status)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*_clansBans.runAfterLoad(event.getPlayer().getName(), () -> {
|
||||
_clansBans.runAfterLoad(event.getPlayer().getName(), () -> {
|
||||
if (_clansBans.Get(event.getPlayer().getName()).isBanned())
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
@ -629,7 +631,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
other.sendMessage(F.sys("Join", event.getPlayer().getName()));
|
||||
}
|
||||
/*});*/
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -642,10 +644,10 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
if (_clansBans.Get(event.getPlayer().getName()) != null && _clansBans.Get(event.getPlayer().getName()).isBanned())
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
{
|
||||
@ -655,7 +657,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
continue;
|
||||
}
|
||||
|
||||
other.sendMessage(F.sys("Quit", event.getPlayer().getName()));
|
||||
other.sendMessage(F.sys("Quit ", event.getPlayer().getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,12 +670,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
return;
|
||||
}
|
||||
|
||||
/*if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
if (_clansBans.willBeKicked(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
if (event.getReason().contains("You are banned from Clans"))
|
||||
if (event.getReason().contains("banned from Clans"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -853,7 +855,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
UtilServer.broadcast(String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), _chat.getFilteredMessage(event.getPlayer(), event.getMessage())));
|
||||
for (Player other : event.getRecipients())
|
||||
{
|
||||
if (_tutorial.inTutorial(other))
|
||||
continue;
|
||||
|
||||
UtilPlayer.message(other, String.format(rank + C.cYellow + "%s " + C.cWhite + "%s", event.getPlayer().getName(), event.getMessage()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -901,28 +909,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void handlePlayerChat(AsyncPlayerChatEvent event)
|
||||
{
|
||||
// PunishClient punishclient = _punish.GetClient(event.getPlayer().getName());
|
||||
//
|
||||
// if (punishclient != null && punishclient.IsMuted())
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (_chat.SilenceCheck(event.getPlayer()))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// MessageData lastMessage = _chat.lastMessage(event.getPlayer());
|
||||
// long chatSlowTime = 1000L * _chat.getChatSlow();
|
||||
// long timeDiff = System.currentTimeMillis() - lastMessage.getTimeSent();
|
||||
// if (timeDiff < chatSlowTime && !_clientManager.Get(event.getPlayer()).GetRank().has(Rank.HELPER))
|
||||
// {
|
||||
//
|
||||
// }
|
||||
|
||||
ClientClan client = Get(event.getPlayer());
|
||||
|
||||
if (client == null)
|
||||
@ -1302,17 +1288,23 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void message(PlayerMessageEvent event)
|
||||
{
|
||||
if(!_tutorial.inTutorial(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getMessage().startsWith(C.cBlue + "Death>"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void handleClansDeath(PlayerDeathEvent event)
|
||||
{
|
||||
event.setDeathMessage(null);
|
||||
|
||||
for(Player player : UtilServer.getPlayers())
|
||||
{
|
||||
if(!_tutorial.inTutorial(player))
|
||||
player.sendMessage(event.getDeathMessage());
|
||||
}
|
||||
|
||||
PlayerClan playerClan;
|
||||
PlayerClan killerClan = null;
|
||||
|
||||
|
@ -6,6 +6,9 @@ import java.util.UUID;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
/**
|
||||
* Stores the information about a ban in Clans.
|
||||
*/
|
||||
public class ClansBan
|
||||
{
|
||||
private int _id;
|
||||
@ -90,4 +93,9 @@ public class ClansBan
|
||||
{
|
||||
return _uuid;
|
||||
}
|
||||
|
||||
public void remove()
|
||||
{
|
||||
_removed = true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
/**
|
||||
* Stores the data provided through the /cban (Clans ban) command for use further in the plugin.
|
||||
*/
|
||||
public class ClansBanCache
|
||||
{
|
||||
private String _victim;
|
||||
private String _reason;
|
||||
|
||||
public ClansBanCache(String victim, String reason)
|
||||
{
|
||||
_victim = victim;
|
||||
_reason = reason;
|
||||
}
|
||||
|
||||
public String getVictim()
|
||||
{
|
||||
return _victim;
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return _reason;
|
||||
}
|
||||
}
|
@ -1,17 +1,22 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
|
||||
/**
|
||||
* Signifies a player on clans, and a Set of their current clan bans.
|
||||
*/
|
||||
public class ClansBanClient
|
||||
{
|
||||
public String Name;
|
||||
public String UUID;
|
||||
public List<ClansBan> Bans;
|
||||
public Set<ClansBan> Bans;
|
||||
|
||||
public ClansBanClient(String uuid, List<ClansBan> bans)
|
||||
public ClansBanClient(String name, String uuid, Set<ClansBan> bans)
|
||||
{
|
||||
Name = name;
|
||||
UUID = uuid;
|
||||
Bans = bans;
|
||||
}
|
||||
@ -75,7 +80,7 @@ public class ClansBanClient
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ban.getTimeLeft() > longest.getTimeLeft())
|
||||
if (ban.getTimeLeft() > longest.getTimeLeft() || ban.isPermanent())
|
||||
{
|
||||
longest = ban;
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -17,16 +16,15 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.ILoginProcessor;
|
||||
import mineplex.core.common.DefaultHashMap;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilStreams;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
@ -41,7 +39,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
private CoreClientManager _clientManager;
|
||||
private ClansBanRepository _repository;
|
||||
private Map<String, ClansBanClient> _clients;
|
||||
private Map<String, Pair<String, String>> _cache;
|
||||
private Map<String, ClansBanCache> _cache;
|
||||
private DefaultHashMap<String, List<Runnable>> _runAfterLoad;
|
||||
private ClansBanShop _shop;
|
||||
|
||||
@ -55,7 +53,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
|
||||
_clientManager = clientManager;
|
||||
|
||||
_repository = new ClansBanRepository(plugin, this);
|
||||
_repository = new ClansBanRepository(plugin);
|
||||
|
||||
_clients = new HashMap<>();
|
||||
_cache = new HashMap<>();
|
||||
@ -85,29 +83,30 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
}
|
||||
|
||||
player.kickPlayer(reason);
|
||||
|
||||
runSyncLater(() -> {
|
||||
_toKick.remove(name);
|
||||
}, 20l);
|
||||
});
|
||||
}
|
||||
|
||||
if (!event.getType().equals(UpdateType.MIN_01))
|
||||
if (event.getType().equals(UpdateType.MIN_01))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (_lock)
|
||||
{
|
||||
List<String> purge = Lists.newArrayList();
|
||||
|
||||
_clients.keySet().stream().filter(name -> Bukkit.getPlayer(name) == null).forEach(purge::add);
|
||||
|
||||
purge.forEach(this::UnloadClient);
|
||||
UtilStreams.ToList(_clients.keySet().stream().filter(UtilServer::IsOnline)).forEach(this::UnloadClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ban(ClansBanClient client, String name, String admin, long time, String reason, Callback<ClansBanClient> callback)
|
||||
public void ban(ClansBanClient client, String admin, long time, String reason, Callback<ClansBanClient> callback)
|
||||
{
|
||||
_repository.ban(UUID.fromString(client.UUID), admin, time, reason, time == -1);
|
||||
|
||||
LoadClient(name, callback);
|
||||
runAsync(() -> {
|
||||
_repository.ban(UUID.fromString(client.UUID), admin, time, reason, time == -1, ban -> {
|
||||
client.Bans.add(ban);
|
||||
callback.run(client);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
@ -154,21 +153,7 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
|
||||
public void UnloadClient(ClansBanClient client)
|
||||
{
|
||||
synchronized (_lock)
|
||||
{
|
||||
String name = "";
|
||||
|
||||
for (Entry<String, ClansBanClient> entry : _clients.entrySet())
|
||||
{
|
||||
if (entry.getValue().equals(client))
|
||||
{
|
||||
name = entry.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_clients.remove(name);
|
||||
}
|
||||
UnloadClient(client.Name);
|
||||
}
|
||||
|
||||
public void UnloadClient(String name)
|
||||
@ -179,17 +164,24 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadClient(final String name, Callback<ClansBanClient> callback)
|
||||
public void LoadClient(String name, Callback<ClansBanClient> callback)
|
||||
{
|
||||
if (_clients.containsKey(name))
|
||||
{
|
||||
System.out.println("Clans Bans> Soft Warning: Loading client even though client is already loaded.");
|
||||
_clients.remove(name);
|
||||
}
|
||||
|
||||
GetRepository().loadBans(name, client -> {
|
||||
GetRepository().loadClient(name, client -> {
|
||||
synchronized (_lock)
|
||||
{
|
||||
_clients.put(name, client);
|
||||
_clients.put(name.toLowerCase(), client);
|
||||
System.out.println("> CLIENTS: " + _clients);
|
||||
if (callback != null) callback.run(client);
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(client);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -207,12 +199,12 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
return _shop;
|
||||
}
|
||||
|
||||
public void cache(Player player, String playerName, String reason)
|
||||
public void cache(Player player, String victim, String reason)
|
||||
{
|
||||
_cache.put(player.getName(), Pair.create(playerName, reason));
|
||||
_cache.put(player.getName(), new ClansBanCache(victim, reason));
|
||||
}
|
||||
|
||||
public Pair<String, String> getCachedData(Player player)
|
||||
public ClansBanCache getCachedData(Player player)
|
||||
{
|
||||
return _cache.get(player.getName());
|
||||
}
|
||||
@ -222,16 +214,17 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
_cache.remove(name);
|
||||
}
|
||||
|
||||
public void unban(ClansBanClient target, ClansBan ban, String name, Callback<ClansBanClient> callback)
|
||||
public void unban(ClansBanClient target, ClansBan ban, Callback<ClansBanClient> callback)
|
||||
{
|
||||
if (!target.UUID.equals(ban.getUUID().toString()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ban.remove();
|
||||
_repository.removeBan(ban);
|
||||
|
||||
LoadClient(name, callback);
|
||||
callback.run(target);
|
||||
}
|
||||
|
||||
public boolean willBeKicked(Player player)
|
||||
@ -239,33 +232,27 @@ public class ClansBanManager extends MiniPlugin implements ILoginProcessor
|
||||
return _toKick.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void queueToKick(Player target, String reason)
|
||||
{
|
||||
_toKick.put(target.getName(), reason);
|
||||
}
|
||||
|
||||
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||
{
|
||||
_repository.loadBans(playerName, client -> {
|
||||
LoadClient(playerName, client -> {
|
||||
if (client.isBanned())
|
||||
{
|
||||
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
|
||||
|
||||
if (client.getLongestBan().isPermanent())
|
||||
{
|
||||
time = "Permanent";
|
||||
}
|
||||
|
||||
String reason = C.cRedB + "You are banned from Clans for " + time +
|
||||
"\n" + C.cWhite + client.getLongestBan().getReason();
|
||||
|
||||
_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);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
@ -20,39 +19,44 @@ import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class ClansBanRepository extends MinecraftRepository
|
||||
{
|
||||
private ClansBanManager _manager;
|
||||
|
||||
private static final String BAN_PLAYER = "INSERT INTO clanBans (uuid, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);";
|
||||
private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;";
|
||||
private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE uuid = ?;";
|
||||
|
||||
public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager)
|
||||
public ClansBanRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
public void ban(UUID uuid, String admin, long time, String reason, boolean permanent)
|
||||
public void ban(UUID uuid, String admin, long time, String reason, boolean permanent, Callback<ClansBan> callback)
|
||||
{
|
||||
executeInsert(BAN_PLAYER, null,
|
||||
Timestamp banTime = new Timestamp(System.currentTimeMillis());
|
||||
Timestamp unbanTime = new Timestamp(System.currentTimeMillis() + time);
|
||||
|
||||
executeInsert(BAN_PLAYER,
|
||||
generatedKeys -> {
|
||||
if (generatedKeys.next() && callback != null)
|
||||
{
|
||||
callback.run(new ClansBan(generatedKeys.getInt(1), uuid, admin, reason, banTime, unbanTime, permanent, false));
|
||||
}
|
||||
},
|
||||
|
||||
new ColumnVarChar("uuid", 36, uuid.toString()),
|
||||
new ColumnVarChar("admin", 16, admin),
|
||||
new ColumnVarChar("reason", 128, reason),
|
||||
new ColumnTimestamp("banTime", new Timestamp(System.currentTimeMillis())),
|
||||
new ColumnTimestamp("unbanTime", new Timestamp(System.currentTimeMillis() + time)),
|
||||
new ColumnTimestamp("banTime", banTime),
|
||||
new ColumnTimestamp("unbanTime", unbanTime),
|
||||
new ColumnBoolean("permanent", permanent),
|
||||
new ColumnBoolean("removed", false)
|
||||
);
|
||||
}
|
||||
|
||||
public void loadBans(final String name, final Callback<ClansBanClient> callback)
|
||||
public void loadClient(String name, final Callback<ClansBanClient> callback)
|
||||
{
|
||||
loadClientByName(name, client -> {
|
||||
String uuid = UUIDFetcher.getUUIDOf(client.GetPlayerName()).toString();
|
||||
String uuid = UUIDFetcher.getUUIDOf(name).toString();
|
||||
|
||||
executeQuery(GET_ALL_BANS, resultSet -> {
|
||||
final List<ClansBan> list = new ArrayList<ClansBan>();
|
||||
final Set<ClansBan> bans = Sets.newConcurrentHashSet();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
@ -65,58 +69,14 @@ public class ClansBanRepository extends MinecraftRepository
|
||||
boolean permanent = resultSet.getBoolean(7);
|
||||
boolean removed = resultSet.getBoolean(8);
|
||||
|
||||
list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
|
||||
bans.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
|
||||
}
|
||||
|
||||
callback.run(new ClansBanClient(uuid, list));
|
||||
|
||||
if (callback != null)
|
||||
{
|
||||
callback.run(new ClansBanClient(name, uuid, bans));
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 36, uuid));
|
||||
});
|
||||
}
|
||||
|
||||
public void loadBans(final String name, final String uuid, final ResultSet resultSet, final Callback<ClansBanClient> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
final List<ClansBan> list = new ArrayList<ClansBan>();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
int id = resultSet.getInt(1);
|
||||
String ruuid = resultSet.getString(2);
|
||||
String admin = resultSet.getString(3);
|
||||
String reason = resultSet.getString(4);
|
||||
Timestamp banTime = resultSet.getTimestamp(5);
|
||||
Timestamp unbanTime = resultSet.getTimestamp(6);
|
||||
boolean permanent = resultSet.getBoolean(7);
|
||||
boolean removed = resultSet.getBoolean(8);
|
||||
|
||||
list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
|
||||
|
||||
System.out.println("Got ban for " + name);
|
||||
}
|
||||
|
||||
callback.run(new ClansBanClient(uuid, list));
|
||||
|
||||
System.out.println("> Successfully handled result");
|
||||
System.out.println(">> FINISH");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadClientByName(String name, Callback<CoreClient> client)
|
||||
{
|
||||
if (_manager.getClientManager().Contains(name))
|
||||
{
|
||||
client.run(_manager.getClientManager().Get(name));
|
||||
}
|
||||
else
|
||||
{
|
||||
_manager.getClientManager().loadClientByName(name, () -> client.run(_manager.getClientManager().Get(name)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
|
||||
@ -21,7 +20,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
{
|
||||
if (args == null || args.length < 1)
|
||||
{
|
||||
UtilPlayer.message(caller, C.cGold + "/cb <username> <reason> - Displays the \"Clans Punish\" GUI, allowing you to ban the player, and ");
|
||||
UtilPlayer.message(caller, C.cBlue + "/cb <username> <reason>" + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans.");
|
||||
}
|
||||
else if (args.length > 1)
|
||||
{
|
||||
@ -36,18 +35,6 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
|
||||
final String finalReason = reason;
|
||||
|
||||
//Match exact online first
|
||||
Player target = UtilPlayer.searchExact(playerName);
|
||||
if (target != null)
|
||||
{
|
||||
Plugin.LoadClient(playerName, client -> {
|
||||
Plugin.cache(caller, playerName, finalReason);
|
||||
Plugin.getShop().attemptShopOpen(caller);
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.LoadClient(playerName, client -> {
|
||||
Plugin.cache(caller, playerName, finalReason);
|
||||
Plugin.getShop().attemptShopOpen(caller);
|
||||
@ -55,7 +42,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, C.cGold + "/cb <username> <reason> - Displays the \"Clans Punish\" GUI, allowing you to ban the player, and ");
|
||||
UtilPlayer.message(caller, C.cBlue + "/cb <username> <reason>" + C.cGray + " - " + C.cYellow + "Displays the \"Clans Punish\" GUI, allowing you to ban the player, and view thier past bans.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,163 +2,144 @@ package mineplex.game.clans.clans.ban.ui;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ban.ClansBan;
|
||||
import mineplex.game.clans.clans.ban.ClansBanClient;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
|
||||
public class ClansBanPage extends ShopPageBase<ClansBanManager, ClansBanShop>
|
||||
{
|
||||
private int _days;
|
||||
private int _hours;
|
||||
private long _time;
|
||||
private boolean _permanent;
|
||||
|
||||
private ClansBanClient _victimClient;
|
||||
|
||||
private String _victim;
|
||||
private String _reason;
|
||||
|
||||
public ClansBanPage(final ClansBanManager banManager, final ClansBanShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player)
|
||||
{
|
||||
super(banManager, shop, clientManager, donationManager, name, player);
|
||||
|
||||
_victim = getPlugin().getCachedData(player).getVictim();
|
||||
_reason = getPlugin().getCachedData(player).getReason();
|
||||
|
||||
_victimClient = getPlugin().Get(_victim);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
protected void buildPage()
|
||||
{
|
||||
getPlugin().runAsync(() -> {
|
||||
_days = Math.max(0, _days);
|
||||
_hours = Math.max(0, _hours);
|
||||
_time = Math.max(0, _time);
|
||||
|
||||
Pair<String, String> data = getPlugin().getCachedData(getPlayer());
|
||||
getPlugin().LoadClient(data.getLeft(), client -> {
|
||||
int slot = 27;
|
||||
|
||||
// Middle of first row
|
||||
addButton(4, new ItemBuilder(Material.COAL_BLOCK)
|
||||
.setTitle(C.cDGreenB + data.getLeft())
|
||||
addButton(4, new ItemBuilder(Material.SKULL_ITEM)
|
||||
.setData((short) 3)
|
||||
.setPlayerHead(_victim)
|
||||
.setTitle(C.cDGreenB + _victim)
|
||||
.addLore(" ")
|
||||
.addLore(C.cYellow + data.getRight()).build(), (player, click) -> {});
|
||||
.addLore(C.cYellow + _reason).build(), (player, click) -> {});
|
||||
|
||||
addButton((9 * 1) + 3, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cRed + "-1 Hour").build(),
|
||||
(player, click) -> {
|
||||
_hours--;
|
||||
refresh();
|
||||
});
|
||||
addTimeAdjuster((9 * 1 + 2), -(1000l * 60l * 60l));
|
||||
addTimeAdjuster((9 * 1 + 1), -(1000l * 60l * 60l * 24l));
|
||||
addTimeAdjuster((9 * 1 + 0), -(1000l * 60l * 60l * 24l * 30l));
|
||||
addTimeAdjuster((9 * 1 + 6), (1000l * 60l * 60l));
|
||||
addTimeAdjuster((9 * 1 + 7), (1000l * 60l * 60l * 24l));
|
||||
addTimeAdjuster((9 * 1 + 8), (1000l * 60l * 60l * 24l * 30l));
|
||||
|
||||
addButton((9 * 1) + 2, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cRed + "-1 Day").build(),
|
||||
(player, click) -> {
|
||||
_days--;
|
||||
refresh();
|
||||
});
|
||||
|
||||
addButton((9 * 1) + 1, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cRed + "-30 Days").build(),
|
||||
(player, click) -> {
|
||||
_days -= 30;
|
||||
refresh();
|
||||
});
|
||||
|
||||
|
||||
addButton((9 * 1) + 5, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cGreen + "+1 Hour").build(),
|
||||
(player, click) -> {
|
||||
_hours++;
|
||||
refresh();
|
||||
});
|
||||
|
||||
addButton((9 * 1) + 6, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cGreen + "+1 Day").build(),
|
||||
(player, click) -> {
|
||||
_days++;
|
||||
refresh();
|
||||
});
|
||||
|
||||
addButton((9 * 1) + 7, new ItemBuilder(Material.PAPER)
|
||||
.setTitle(C.cGreen + "+30 Days").build(),
|
||||
(player, click) -> {
|
||||
_days += 30;
|
||||
refresh();
|
||||
});
|
||||
|
||||
// Middle of second row
|
||||
addButton((9 * 1) + 4, new ItemBuilder(Material.WATCH)
|
||||
.setTitle(C.cGold + "Time Options")
|
||||
.addLore(" ")
|
||||
.addLore("Permanent: " + F.elem(_permanent ? "Yes" : "No"))
|
||||
.addLore("Days: " + F.elem(Integer.valueOf(_days)))
|
||||
.addLore("Hours: " + F.elem(Integer.valueOf(_hours)))
|
||||
.addLore(" ")
|
||||
.addLore("Right-Click this button")
|
||||
.addLore("to ban permanently.").build(),
|
||||
addButton((9 * 1) + 4,
|
||||
new ItemBuilder(Material.RECORD_5)
|
||||
.setTitle(C.cRedB + "Ban Player")
|
||||
.setLore(
|
||||
" ",
|
||||
C.cGray + "Player: " + F.elem(_victim),
|
||||
C.cGray + "Reason: " + F.elem(_reason),
|
||||
C.cGray + "Time: " + F.elem(_permanent ? "Permanent" : UtilTime.MakeStr(_time)),
|
||||
"",
|
||||
C.cRed + C.Italics + "Left-Click to BAN PLAYER",
|
||||
C.cGray + C.Italics + "Right-Click to toggle permanent ban setting"
|
||||
).build(),
|
||||
(player, click) -> {
|
||||
if (click == ClickType.RIGHT)
|
||||
{
|
||||
_permanent = !_permanent;
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
|
||||
// Middle of third row
|
||||
addButton((9 * 2) + 4, new ItemBuilder(Material.EMERALD_BLOCK)
|
||||
.setTitle(C.cRedB + "BAN PLAYER")
|
||||
.addLore(" ")
|
||||
.addLore("Player: " + F.elem(data.getLeft()))
|
||||
.addLore("Reason: " + F.elem(data.getRight())).build(),
|
||||
(player, click) -> {
|
||||
getPlugin().runAsync(() -> {
|
||||
double time = _days + ((1.f / 24.f) * _hours);
|
||||
getPlugin().ban(client, data.getLeft(), getPlayer().getName(), _permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), data.getRight(), c -> {
|
||||
UtilPlayer.message(getPlayer(), F.main("Clans", F.elem(data.getLeft()) + " is now banned " + c.getBanTimeFormatted() + "."));
|
||||
|
||||
getPlugin().runSync(() -> {
|
||||
Player target = Bukkit.getPlayer(data.getLeft());
|
||||
|
||||
if (target != null)
|
||||
target.kickPlayer(C.cRedB + "You have been banned from Clans " + c.getBanTimeFormatted() + ".");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
for (ClansBan ban : client.Bans)
|
||||
else
|
||||
{
|
||||
ItemStack item =
|
||||
new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK)
|
||||
performBan();
|
||||
}
|
||||
});
|
||||
|
||||
for (ClansBan ban : _victimClient.Bans)
|
||||
{
|
||||
ItemStack item = new ItemBuilder(ban.isActive() ? Material.EMERALD_BLOCK : Material.REDSTONE_BLOCK)
|
||||
.setTitle(ban.isActive() ? C.cGreenB + "Active" : C.cRedB + "Inactive")
|
||||
|
||||
.addLore(" ")
|
||||
.addLore("Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime()))
|
||||
.addLore("Admin: " + C.cYellow + ban.getAdmin())
|
||||
.addLore("Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
|
||||
.addLore("Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||
.addLore(C.cGray + "Date banned: " + C.cYellow + UtilTime.date(ban.getBanTime().getTime()))
|
||||
.addLore(C.cGray + "Admin: " + C.cYellow + ban.getAdmin())
|
||||
.addLore(C.cGray + "Time left: " + C.cYellow + (ban.isActive() ? ban.getBanTimeFormatted(false) : "None"))
|
||||
.addLore(C.cGray + "Permanent: " + C.cYellow + (ban.isPermanent() ? "Yes" : "No"))
|
||||
.addLore(C.cGray + "Reason: " + C.cYellow + ban.getReason(), 16)
|
||||
.addLore("Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||
.addLore(!ban.isActive() ? null : C.cDAqua + "Left-Click to disable ban")
|
||||
|
||||
.addLore(C.cGray + "Is Disabled: " + C.cYellow + (ban.isRemoved() ? "Yes" : "No"))
|
||||
.addLore(ban.isActive() ? " " : null)
|
||||
.addLore(ban.isActive() ? C.cDAqua + "Left-Click to disable ban" : null)
|
||||
.addDullEnchantment(ban.isActive())
|
||||
.build();
|
||||
|
||||
if (ban.isActive())
|
||||
UtilInv.addDullEnchantment(item);
|
||||
|
||||
addButton(slot++, item, (player, click) -> {
|
||||
if (ban.isActive())
|
||||
{
|
||||
getPlugin().runAsync(() -> getPlugin().unban(client, ban, data.getLeft(), c -> refresh()));
|
||||
}
|
||||
getPlugin().runAsync(() -> {
|
||||
getPlugin().unban(_victimClient, ban, client -> {
|
||||
refresh();
|
||||
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1f, 1f);
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void performBan()
|
||||
{
|
||||
getPlugin().runAsync(() -> {
|
||||
getPlugin().ban(_victimClient, getPlayer().getName(), _permanent ? -1 : _time, _reason, client -> {
|
||||
UtilPlayer.message(getPlayer(), F.main("Clans", F.elem(_victim) + " is now banned " + client.getBanTimeFormatted() + "."));
|
||||
|
||||
Player target = Bukkit.getPlayer(_victim);
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
getPlugin().queueToKick(target, C.cRedB + "You have been banned from Clans " + client.getBanTimeFormatted() + ".");
|
||||
}
|
||||
|
||||
refresh();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void addTimeAdjuster(int index, long time)
|
||||
{
|
||||
addButton(index, new ItemBuilder(Material.PAPER).setTitle(C.cRed + (time < 0 ? "-" : "") + UtilTime.MakeStr(Math.abs(time))).build(),
|
||||
(player, click) -> {
|
||||
_time += time;
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -423,8 +423,15 @@ public class ItemMapManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
Byte color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0);
|
||||
|
||||
Byte color;
|
||||
try
|
||||
{
|
||||
color = Iterables.getFirst(Multisets.copyHighestCountFirst(hashmultiset), (byte) 0);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
color = (byte) 0;
|
||||
}
|
||||
second[(x + _halfMapSize) / zoom][(z + _halfMapSize) / zoom] = color;
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,17 @@ public class ClansRegions extends MiniPlugin
|
||||
{
|
||||
int x = chunkX + xOffset;
|
||||
int z = chunkZ + zOffset;
|
||||
Chunk chunk = location.getWorld().getChunkAt(x, z);
|
||||
Chunk chunk;
|
||||
try
|
||||
{ //Corrupted chunk will hold up whole server
|
||||
chunk = location.getWorld().getChunkAt(x, z);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
System.out.println("UNABLE TO LOAD CHUNK AT " + x + " , " + z);
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
String chunkStr = UtilWorld.chunkToStr(chunk);
|
||||
|
||||
if (addNegative)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package mineplex.game.clans.clans.siege.weapon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -41,6 +43,7 @@ import mineplex.game.clans.clans.siege.weapon.projectile.WeaponProjectile;
|
||||
import mineplex.game.clans.clans.siege.weapon.util.AccessRule;
|
||||
import mineplex.game.clans.clans.siege.weapon.util.AccessType;
|
||||
import mineplex.game.clans.clans.siege.weapon.util.WeaponStateInfo;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
|
||||
public class Cannon extends SiegeWeapon
|
||||
{
|
||||
@ -425,32 +428,17 @@ public class Cannon extends SiegeWeapon
|
||||
@EventHandler
|
||||
public void explosionEffects(SiegeWeaponExplodeEvent event)
|
||||
{
|
||||
// for (int i = 0; i < 8; i++)
|
||||
// {
|
||||
// // Explosion particle effects.
|
||||
// Location point = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 5);
|
||||
// UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, point, 0, 0, 0, 1, 2, ViewDist.MAX);
|
||||
// }
|
||||
|
||||
// Block explosion.
|
||||
ArrayList<Block> blocks = new ArrayList<>();
|
||||
int attempts = 0;
|
||||
while (blocks.size() < 10 && (attempts < 30))
|
||||
List<Block> blocks = Stream.generate(() -> UtilAlg.getRandomLocation(event.getProjectile().getLocation(), 4 * getPowerLevel()).getBlock())
|
||||
.limit(30) // Generate up to 30
|
||||
.distinct() // distinct blocks,
|
||||
.filter(block -> block.getType() != Material.AIR) // filter for non-air
|
||||
.filter(block -> // and blocks whose locations aren't blacklisted,
|
||||
{
|
||||
Block block = UtilAlg.getRandomLocation(event.getProjectile().getLocation(), (4 * getPowerLevel())).getBlock();
|
||||
|
||||
if (_siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation()) != null && !_siegeManager.getClansManager().getBlacklist().allowed(_siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation()).Owner))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((block.getType() != Material.AIR) && (!blocks.contains(block)))
|
||||
{
|
||||
blocks.add(block);
|
||||
}
|
||||
|
||||
attempts++;
|
||||
}
|
||||
ClanTerritory claim = _siegeManager.getClansManager().getClanUtility().getClaim(block.getLocation());
|
||||
return claim == null || _siegeManager.getClansManager().getBlacklist().allowed(claim.Owner);
|
||||
})
|
||||
.limit(10) // and take up to 10 of them.
|
||||
.collect(Collectors.toList());
|
||||
|
||||
_clans.getExplosion().BlockExplosion(
|
||||
blocks,
|
||||
@ -459,5 +447,4 @@ public class Cannon extends SiegeWeapon
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,6 +121,8 @@ public abstract class SiegeWeapon implements Listener
|
||||
// Customizability
|
||||
private double[] _forcedVelocity;
|
||||
|
||||
private float[] _lockedYaw;
|
||||
|
||||
protected boolean _isRideable;
|
||||
protected boolean _invertRotation;
|
||||
protected AccessRule _mountAccess;
|
||||
@ -299,6 +301,22 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
double yaw = (float) ((float)standYaw + Math.min(dif / _rotSpeed, 4f));
|
||||
|
||||
if (_lockedYaw != null)
|
||||
{
|
||||
float min = _lockedYaw[0];
|
||||
float max = _lockedYaw[1];
|
||||
|
||||
if (yaw < min)
|
||||
{
|
||||
yaw = min;
|
||||
}
|
||||
|
||||
if (yaw > max)
|
||||
{
|
||||
yaw = max;
|
||||
}
|
||||
}
|
||||
|
||||
armorStand.setHeadPose(new EulerAngle(0, Math.toRadians(CustomRotate(_yaw = yaw)), 0));
|
||||
}
|
||||
}
|
||||
@ -313,6 +331,11 @@ public abstract class SiegeWeapon implements Listener
|
||||
_forcedVelocity = new double[] { vertical, horizontal };
|
||||
}
|
||||
|
||||
public void LockYaw(float minYaw, float maxYaw)
|
||||
{
|
||||
_lockedYaw = new float[] { minYaw, maxYaw };
|
||||
}
|
||||
|
||||
private void fire(Player player)
|
||||
{
|
||||
_lastFired = System.currentTimeMillis();
|
||||
@ -458,7 +481,7 @@ public abstract class SiegeWeapon implements Listener
|
||||
|
||||
private void dismount(Player player)
|
||||
{
|
||||
player.teleport(player.getLocation().add(0, 1, 0));
|
||||
_clans.runSync(() -> player.teleport(player.getLocation().add(0, 1, 0)));
|
||||
}
|
||||
|
||||
protected void handleLeftClick(Player player)
|
||||
@ -523,7 +546,12 @@ public abstract class SiegeWeapon implements Listener
|
||||
protected void CustomRightClick(Player player) { return; }
|
||||
protected void CustomCleanup() { return; }
|
||||
protected void CustomUpdateState(String state) { return; }
|
||||
protected double CustomRotate(double yaw) { return yaw; }
|
||||
|
||||
protected double CustomRotate(double yaw)
|
||||
{
|
||||
return yaw;
|
||||
}
|
||||
|
||||
protected boolean CustomDismount(Player player, Entity entity) { return false; }
|
||||
protected boolean CustomMount(Player player) { return false; }
|
||||
|
||||
|
@ -213,16 +213,6 @@ public class Spawn extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ignoreVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
if (_clansManager.getClanUtility().isSafe(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
System.out.println("cancelled");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSkill(SkillTriggerEvent event)
|
||||
{
|
||||
|
@ -62,8 +62,6 @@ public class BlowUpWallGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
|
||||
TutorialRegion region = getObjective().getPlugin().getRegion(shooter);
|
||||
|
||||
if (getObjective().getPlugin().isIn(center, region, ClansMainTutorial.Bounds.ENEMY_ATTACK_AREA))
|
||||
{
|
||||
double radius = 5.2;
|
||||
|
||||
HashMap<Block, Double> blockList = new HashMap<Block, Double>();
|
||||
@ -105,13 +103,6 @@ public class BlowUpWallGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
event.setCancelled(true);
|
||||
finish(shooter);
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(shooter, F.main("Clans", "You missed! Try to hit the enemy's front wall, that should make a nice big hole!"));
|
||||
UtilInv.give(shooter, Material.TNT);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customFinish(Player player)
|
||||
|
@ -36,9 +36,11 @@ public class MountCannonGoal extends ObjectiveGoal<AttackEnemyObjective>
|
||||
protected void customStart(Player player)
|
||||
{
|
||||
getObjective().getCannons().put(player.getName(), _clansManager.getSiegeManager().spawnCannon(player, getObjective().getPlugin().getPoint(getObjective().getPlugin().getRegion(player), Point.CANNON), false));
|
||||
getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.4, 2.45);
|
||||
getObjective().getCannons().get(player.getName()).SetForcedVelocity(0.44, 2.45);
|
||||
getObjective().getCannons().get(player.getName()).setInvincible(true);
|
||||
|
||||
getObjective().getCannons().get(player.getName()).LockYaw(-193, -173);
|
||||
|
||||
TutorialSession session = getObjective().getPlugin().getTutorialSession(player);
|
||||
session.setMapTargetLocation(getObjective().getPlugin().getPoint(session.getRegion(), ClansMainTutorial.Point.CANNON));
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ public class CombatManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void HandleDeath(PlayerDeathEvent event)
|
||||
{
|
||||
event.setDeathMessage(null);
|
||||
|
@ -936,6 +936,22 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
return _game.IsAlive(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player is participating in/has been participating in the current game
|
||||
* @param player The player to check
|
||||
* @return Whether they are/have been playing
|
||||
*/
|
||||
public boolean hasBeenPlaying(Player player)
|
||||
{
|
||||
if (_game == null)
|
||||
return false;
|
||||
|
||||
if (_game.GetTeam(player) == null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Clear(Player player)
|
||||
{
|
||||
if (player.getGameMode() == GameMode.SPECTATOR)
|
||||
|
@ -114,12 +114,12 @@ public abstract class RankedTeamGame extends TeamGame
|
||||
event.disallow(Result.KICK_OTHER, message);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (InProgress())
|
||||
{
|
||||
if (!Manager.IsObserver(event.getPlayer()))
|
||||
if (Manager.hasBeenPlaying(event.getPlayer()))
|
||||
{
|
||||
Manager.getEloManager().banFromRanked(getAccountId(event.getPlayer().getUniqueId()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user