Patch Frozen players in clans spawning CombatLog NPCs when leaving, patch ClansCommandExecutedEvent not always being called, clean up ClanBanner code, and make Freeze System and Nether Manager effectively block Clans Commands (particularly teleportation)
This commit is contained in:
parent
c2de8c35e2
commit
18992efa5a
@ -1,8 +1,24 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
@ -25,28 +41,13 @@ import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class ClansBanManager extends MiniPlugin
|
||||
{
|
||||
private static final long FREEZE_MESSAGE_INTERVAL = 10000;
|
||||
private final CoreClientManager _clientManager;
|
||||
private final DonationManager _donationManager;
|
||||
private final ClansBanRepository _repository;
|
||||
private final HashMap<UUID, Float> _frozen = new HashMap<>();
|
||||
private final Map<UUID, Float> _frozen = new HashMap<>();
|
||||
|
||||
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
@ -106,7 +107,7 @@ public class ClansBanManager extends MiniPlugin
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Float walkSpeed = _frozen.remove(event.getPlayer().getUniqueId());
|
||||
@ -116,7 +117,7 @@ public class ClansBanManager extends MiniPlugin
|
||||
event.getPlayer().removePotionEffect(PotionEffectType.JUMP);
|
||||
for (Player staff : UtilServer.GetPlayers())
|
||||
{
|
||||
if (_clientManager.hasRank(staff, Rank.HELPER))
|
||||
if (_clientManager.hasRank(staff, Rank.CMOD))
|
||||
{
|
||||
UtilPlayer.message(staff, F.main(getName(), F.elem(event.getPlayer().getName()) + " has logged out while frozen!"));
|
||||
}
|
||||
@ -236,13 +237,10 @@ public class ClansBanManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onTpHome(ClansCommandExecutedEvent event)
|
||||
{
|
||||
if (event.getCommand().equalsIgnoreCase("tphome"))
|
||||
if (isFrozen(event.getPlayer()))
|
||||
{
|
||||
if (isFrozen(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while frozen!"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot use that command while frozen!"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,7 +266,7 @@ public class ClansBanManager extends MiniPlugin
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 999999, -10));
|
||||
for (Player alert : UtilServer.GetPlayers())
|
||||
{
|
||||
if (_clientManager.hasRank(alert, Rank.HELPER))
|
||||
if (_clientManager.hasRank(alert, Rank.CMOD))
|
||||
{
|
||||
UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been frozen by " + F.elem(staff.getName()) + "!"));
|
||||
}
|
||||
@ -289,7 +287,7 @@ public class ClansBanManager extends MiniPlugin
|
||||
player.removePotionEffect(PotionEffectType.JUMP);
|
||||
for (Player alert : UtilServer.GetPlayers())
|
||||
{
|
||||
if (_clientManager.hasRank(alert, Rank.HELPER))
|
||||
if (_clientManager.hasRank(alert, Rank.CMOD))
|
||||
{
|
||||
UtilPlayer.message(alert, F.main(getName(), F.elem(player.getName()) + " has been unfrozen by " + F.elem(staff.getName()) + "!"));
|
||||
continue;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.clans.banners;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -38,7 +39,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
*/
|
||||
public class BannerManager extends MiniPlugin
|
||||
{
|
||||
public final HashMap<String, ClanBanner> LoadedBanners = new HashMap<>();
|
||||
public final Map<String, ClanBanner> LoadedBanners = new HashMap<>();
|
||||
private final BlockFace[] _radial = { BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST };
|
||||
private BannerRepository _repo;
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
package mineplex.game.clans.clans.banners;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
@ -12,10 +16,6 @@ import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Database repository class for banners
|
||||
*/
|
||||
@ -44,7 +44,7 @@ public class BannerRepository extends MinecraftRepository
|
||||
* @param map The hashmap to load the banner into
|
||||
* @param clan The clan whose banner to fetch
|
||||
*/
|
||||
public void loadBanner(final HashMap<String, ClanBanner> map, ClanInfo clan)
|
||||
public void loadBanner(final Map<String, ClanBanner> map, ClanInfo clan)
|
||||
{
|
||||
_bannerManager.runAsync(() ->
|
||||
{
|
||||
@ -89,7 +89,7 @@ public class BannerRepository extends MinecraftRepository
|
||||
* @param map The hashmap to load the banner into
|
||||
* @param clan The clan whose banner to fetch
|
||||
*/
|
||||
public void loadBanners(final HashMap<String, ClanBanner> map, ClansManager clanManager)
|
||||
public void loadBanners(final Map<String, ClanBanner> map, ClansManager clanManager)
|
||||
{
|
||||
_bannerManager.runAsync(() ->
|
||||
{
|
||||
|
@ -28,7 +28,6 @@ import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.delayedtask.DelayedTask;
|
||||
import mineplex.core.delayedtask.DelayedTaskClient;
|
||||
import mineplex.core.incognito.IncognitoManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanRole;
|
||||
@ -138,6 +137,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
private void forceJoin(Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "forcejoin", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Plugin.getClientManager().hasRank(caller, Rank.ADMIN))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "This requires ADMIN+ permission."));
|
||||
@ -243,7 +250,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void create(final Player caller, final String[] args)
|
||||
{
|
||||
System.out.println("CREATE COMMAND");
|
||||
// System.out.println("CREATE COMMAND");
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "create", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClientClan client = Plugin.Get(caller);
|
||||
|
||||
@ -336,11 +350,27 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void delete(final Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "disband", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getClanUtility().delete(caller);
|
||||
}
|
||||
|
||||
public void invite(Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "invite", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
@ -375,6 +405,13 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "stuck");
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (DelayedTask.Instance.HasTask(caller, "Spawn Teleport"))
|
||||
{
|
||||
@ -460,6 +497,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void join(final Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent cevent = new ClansCommandExecutedEvent(caller, "join", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(cevent);
|
||||
|
||||
if (cevent.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are already in a Clan."));
|
||||
@ -532,6 +577,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void leave(final Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "leave");
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
@ -569,6 +622,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void kick(final Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "kick", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
@ -590,6 +651,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void promote(Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "promote", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
@ -611,6 +680,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void demote(Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "demote", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
if (clan == null)
|
||||
@ -632,6 +709,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void ally(Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "ally", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClanInfo cA = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
|
||||
if (cA == null)
|
||||
@ -761,6 +846,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void neutral(Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "neutral", args);
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ClanInfo cA = Plugin.getClanMemberUuidMap().get(caller.getUniqueId());
|
||||
|
||||
if (cA == null)
|
||||
@ -843,6 +936,14 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
}
|
||||
}
|
||||
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "unclaim");
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getClanUtility().unclaim(caller, caller.getLocation().getChunk());
|
||||
}
|
||||
|
||||
@ -867,11 +968,27 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void unclaimall(Player caller)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "unclaimall");
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getClanUtility().unclaimAll(caller);
|
||||
}
|
||||
|
||||
public void map(Player caller, String[] args)
|
||||
{
|
||||
ClansCommandExecutedEvent event = new ClansCommandExecutedEvent(caller, "map");
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.getItemMapManager().setMap(caller);
|
||||
}
|
||||
|
||||
@ -1048,7 +1165,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
public void infoClan(Player caller, String search)
|
||||
{
|
||||
System.out.println(search);
|
||||
// System.out.println(search);
|
||||
|
||||
if (search == null)
|
||||
{
|
||||
@ -1089,12 +1206,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
|
||||
if (clan == null) return;
|
||||
|
||||
// if (_clansManager.getNetherManager().isInNether(caller))
|
||||
// {
|
||||
// _clansManager.message(caller, "You are currently in " + F.clansNether("The Nether") + ".");
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
if (_clansManager.getNetherManager().isInNether(caller))
|
||||
{
|
||||
_clansManager.message(caller, "You are currently in " + F.clansNether("The Nether") + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
UtilPlayer.message(caller, clan.mTerritory());
|
||||
}
|
||||
|
@ -493,12 +493,12 @@ public class NetherManager extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onTpHome(ClansCommandExecutedEvent event)
|
||||
{
|
||||
if (event.getCommand().equalsIgnoreCase("tphome"))
|
||||
if (event.getCommand().equalsIgnoreCase("tphome") || event.getCommand().equalsIgnoreCase("stuck"))
|
||||
{
|
||||
if (isInNether(event.getPlayer()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport to your Clan home while in " + F.clansNether("The Nether") + "!"));
|
||||
UtilPlayer.message(event.getPlayer(), F.main(getName(), "You cannot teleport while in " + F.clansNether("The Nether") + "!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -22,6 +23,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.gameplay.safelog.npc.NPCManager;
|
||||
|
||||
@ -62,6 +64,11 @@ public class SafeLog extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (Managers.get(ClansBanManager.class).isFrozen(player))
|
||||
{
|
||||
isSafeLog = true;
|
||||
}
|
||||
|
||||
if (!isSafeLog)
|
||||
{
|
||||
if (!_clansManager.getIncognitoManager().Get(player).Status)
|
||||
|
Loading…
Reference in New Issue
Block a user