Removed chat filtering.

Implemented user preferences in all required modules.
This commit is contained in:
Jonathan Williams 2014-05-30 13:34:55 -07:00
parent 57c3845df9
commit 6505819a4b
14 changed files with 130 additions and 369 deletions

View File

@ -10,6 +10,7 @@ import org.bukkit.plugin.java.JavaPlugin;
public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlugin
{
private static Object _clientDataLock = new Object();
private NautHashMap<String, DataType> _clientData = new NautHashMap<String, DataType>();
public MiniClientPlugin(String moduleName, JavaPlugin plugin)
@ -26,15 +27,21 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
@EventHandler
public void UnloadPlayer(ClientUnloadEvent event)
{
_clientData.remove(event.GetName());
synchronized (_clientDataLock)
{
_clientData.remove(event.GetName());
}
}
public DataType Get(String name)
{
if (!_clientData.containsKey(name))
_clientData.put(name, AddPlayer(name));
return _clientData.get(name);
synchronized (_clientDataLock)
{
if (!_clientData.containsKey(name))
_clientData.put(name, AddPlayer(name));
return _clientData.get(name);
}
}
public DataType Get(Player player)
@ -49,7 +56,10 @@ public abstract class MiniClientPlugin<DataType extends Object> extends MiniPlug
protected void Set(String name, DataType data)
{
_clientData.put(name, data);
synchronized (_clientDataLock)
{
_clientData.put(name, data);
}
}
protected abstract DataType AddPlayer(String player);

View File

@ -7,6 +7,7 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.security.cert.X509Certificate;
import java.util.Iterator;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
@ -15,15 +16,13 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import mineplex.core.MiniClientPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.chat.command.BroadcastCommand;
import mineplex.core.chat.command.FilterChatCommand;
import mineplex.core.chat.command.SilenceCommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
@ -34,7 +33,6 @@ import mineplex.core.common.util.UtilTime;
import org.apache.commons.codec.binary.Base64;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -46,7 +44,7 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class Chat extends MiniClientPlugin<ChatClient>
public class Chat extends MiniPlugin
{
private CoreClientManager _clientManager;
private PreferencesManager _preferences;
@ -83,14 +81,8 @@ public class Chat extends MiniClientPlugin<ChatClient>
{
AddCommand(new SilenceCommand(this));
AddCommand(new BroadcastCommand(this));
AddCommand(new FilterChatCommand(this));
}
/*
* @EventHandler public void
* retrieveClientInformation(RetrieveClientInformationEvent event) {
* _repository.loadClientInformation(event.getConnection()); }
*/
public void Silence(long duration, boolean inform)
{
// Set Silenced
@ -172,16 +164,23 @@ public class Chat extends MiniClientPlugin<ChatClient>
return true;
}
@EventHandler(priority = EventPriority.HIGHEST)
public void loadClientInformation(RetrieveClientInformationEvent event)
{
ChatClient chatClient = new ChatClient();
chatClient.SetFilterChat(_preferences.Get(event.getPlayerName()).FilterChat);
Set(event.getPlayerName(), chatClient);
}
@EventHandler
public void removeChat(AsyncPlayerChatEvent event)
{
if (event.isCancelled())
return;
if (event.isAsynchronous())
{
for (Iterator<Player> playerIterator = event.getRecipients().iterator(); playerIterator.hasNext();)
{
if (!_preferences.Get(playerIterator.next()).ShowChat)
playerIterator.remove();
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void filterChat(AsyncPlayerChatEvent event)
{
@ -227,20 +226,7 @@ public class Chat extends MiniClientPlugin<ChatClient>
for (Player onlinePlayer : event.getRecipients())
{
if (Get(onlinePlayer).GetFilterChat())
{
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage));
if (onlinePlayer == event.getPlayer())
{
onlinePlayer.playSound(onlinePlayer.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
onlinePlayer.sendMessage(F.main("Chat", "You have chat filtering turned on, type /filter to turn it off."));
}
}
else
{
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()));
}
onlinePlayer.sendMessage(String.format(event.getFormat(), event.getPlayer().getDisplayName(), filteredMessage));
}
event.setCancelled(true);
@ -301,6 +287,7 @@ public class Chat extends MiniClientPlugin<ChatClient>
return hasharray;
}
@SuppressWarnings("unchecked")
private JSONObject buildJsonChatObject(String filtertype, String name, String player, String msg, String server, int rule)
{
JSONObject message = new JSONObject();
@ -482,25 +469,4 @@ public class Chat extends MiniClientPlugin<ChatClient>
{
_playerLastMessage.remove(event.getPlayer().getName());
}
@Override
protected ChatClient AddPlayer(String player)
{
return new ChatClient();
}
public void toggleFilterChat(Player caller)
{
_preferences.Get(caller).FilterChat = !_preferences.Get(caller).FilterChat;
_preferences.savePreferences(caller);
Get(caller).SetFilterChat(!Get(caller).GetFilterChat());
if (Get(caller).GetFilterChat())
caller.playSound(caller.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
else
caller.playSound(caller.getLocation(), Sound.NOTE_PIANO, 1f, 1f);
caller.sendMessage(F.main("Chat", "You have turned chat filtering " + ChatColor.YELLOW + (Get(caller).GetFilterChat() ? "ON" : "OFF") + ChatColor.GRAY + "."));
}
}

View File

@ -1,16 +0,0 @@
package mineplex.core.chat;
public class ChatClient
{
private boolean _filterChat = false;
public void SetFilterChat(boolean filterChat)
{
_filterChat = filterChat;
}
public boolean GetFilterChat()
{
return _filterChat;
}
}

View File

@ -1,21 +0,0 @@
package mineplex.core.chat.command;
import org.bukkit.entity.Player;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
public class FilterChatCommand extends CommandBase<Chat>
{
public FilterChatCommand(Chat plugin)
{
super(plugin, Rank.ALL, "filter");
}
@Override
public void Execute(Player caller, String[] args)
{
Plugin.toggleFilterChat(caller);
}
}

View File

@ -17,18 +17,21 @@ import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.message.Commands.*;
import mineplex.core.preferences.PreferencesManager;
public class MessageManager extends MiniClientPlugin<ClientMessage>
{
private LinkedList<String> _randomMessage;
private CoreClientManager _clientManager;
private PreferencesManager _preferences;
public MessageManager(JavaPlugin plugin, CoreClientManager clientManager)
public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences)
{
super("Message", plugin);
_clientManager = clientManager;
_preferences = preferences;
}
//Module Functions
@ -115,6 +118,12 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
public void DoMessage(Player from, Player to, String message)
{
if (!_preferences.Get(to).PrivateMessaging)
{
UtilPlayer.message(from, C.cPurple + to.getName() + " has private messaging disabled.");
return;
}
//Inform
UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message);

View File

@ -2,8 +2,13 @@ package mineplex.core.preferences;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniClientPlugin;
@ -11,6 +16,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.RetrieveClientInformationEvent;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
@ -23,6 +29,8 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>();
public boolean GiveItem;
public PreferencesManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super("Preferences", plugin);
@ -83,6 +91,27 @@ public class PreferencesManager extends MiniClientPlugin<UserPreferences>
_repository.saveUserPreferences(bufferCopy);
}
@EventHandler
public void givePlayerItem(PlayerJoinEvent event)
{
if (!GiveItem)
return;
event.getPlayer().getInventory().setItem(9, ItemStackFactory.Instance.CreateStack(Material.REDSTONE_COMPARATOR.getId(), (byte)0, 1, ChatColor.GREEN + "/prefs"));
}
@EventHandler(priority = EventPriority.LOWEST)
public void playerInteract(PlayerInteractEvent event)
{
if (!GiveItem)
return;
if (event.getItem() != null && event.getItem().getType() == Material.REDSTONE_COMPARATOR)
{
_shop.attemptShopOpen(event.getPlayer());
}
}
public void openShop(Player caller)
{

View File

@ -80,17 +80,17 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
DonationManager donationManager = new DonationManager(this, GetWebServerAddress());
//Other Modules
Creature creature = new Creature(this);
new MessageManager(this, clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
preferenceManager.GiveItem = true;
new MessageManager(this, clientManager, preferenceManager);
Creature creature = new Creature(this);
NpcManager npcManager = new NpcManager(this, creature);
new PetManager(this, clientManager, donationManager, creature, GetWebServerAddress());
//Main Modules
PreferencesManager preferenceManager = new PreferencesManager(this, clientManager, donationManager);
PacketHandler packetHandler = new PacketHandler(this);
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager);
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager, preferenceManager);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
QueueManager queueManager = new QueueManager(this, clientManager, donationManager, new EloManager(this), partyManager);

View File

@ -1,13 +1,11 @@
package mineplex.hub;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R3.CraftWorld;
import org.bukkit.entity.Egg;
@ -16,15 +14,12 @@ import org.bukkit.entity.LivingEntity;
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.entity.EntityDamageEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -58,15 +53,14 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseSlime;
import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.logger.Logger;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.commands.ForcefieldToggle;
import mineplex.hub.commands.GadgetToggle;
import mineplex.hub.gadget.GadgetManager;
import mineplex.hub.modules.*;
@ -96,6 +90,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
private TutorialManager _tutorialManager;
private TextManager _textCreator;
private ParkourManager _parkour;
private PreferencesManager _preferences;
private Location _spawn;
private int _scoreboardTick = 0;
@ -108,14 +103,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
private HashMap<String, Long> _portalTime = new HashMap<String, Long>();
private int _slot = 7;
private HashSet<Player> _disabled = new HashSet<Player>();
//Admin
private boolean _gadgetsEnabled = true;
private HashSet<Player> _forcefield = new HashSet<Player>();
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager)
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences)
{
super("Hub Manager", plugin);
@ -141,6 +132,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
_gadgetManager = new GadgetManager(this, _mountManager);
_partyManager = partyManager;
_preferences = preferences;
_tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator);
_visibilityManager = new VisibilityManager(this);
@ -153,7 +145,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
public void AddCommands()
{
AddCommand(new GadgetToggle(this));
AddCommand(new ForcefieldToggle(this));
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -164,76 +155,18 @@ public class HubManager extends MiniClientPlugin<HubClient>
event.setMotd("Restarting soon");
}
}
@EventHandler
public void BumpJoin(PlayerJoinEvent event)
{
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
@EventHandler
public void BumpQuit(PlayerQuitEvent event)
{
_disabled.remove(event.getPlayer());
}
public boolean BumpDisabled(Entity ent)
{
if (ent == null)
return false;
return _disabled.contains(ent);
}
@EventHandler
public void BumpToggle(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
return;
Player player = event.getPlayer();
if (player.getInventory().getHeldItemSlot() != _slot)
return;
event.setCancelled(true);
if (_disabled.remove(player))
if (ent instanceof Player)
{
UtilPlayer.message(player, F.main("Hub Games", "You are back in the Hub Games!"));
player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
else
{
_disabled.add(player);
UtilPlayer.message(player, F.main("Hub Games", "You are no longer partaking in Hub Games."));
player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.MAGMA_CREAM, (byte)0, 1,
C.cYellow + "Stacker" + C.cWhite + " - " + C.cRed + "Disabled"));
}
}
@EventHandler
public void orderThatItem(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.REDSTONE_TORCH_OFF || event.getItemDrop().getItemStack().getType() == Material.REDSTONE_TORCH_ON)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(event.getItemDrop().getItemStack().getType());
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(event.getItemDrop().getItemStack().getType(), (byte)0, 1, ChatColor.RESET + C.cYellow + "Stacker" + C.cWhite + (_disabled.contains(event.getPlayer()) ? C.cWhite + " - " + C.cRed + "Disabled" : " - " + C.cGreen + "Enabled")));
event.getPlayer().updateInventory();
}
}
});
return !_preferences.Get((Player)ent).HubGames;
}
return true;
}
@EventHandler
@ -399,48 +332,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
throw ex;
}
}
/* XXX TOURNEY
@EventHandler(priority = EventPriority.HIGHEST)
public void TournamentWins(PlayerJoinEvent event)
{
for (Player player : Bukkit.getOnlinePlayers())
{
Scoreboard board = player.getScoreboard();
if (board == null)
continue;
Objective obj = board.getObjective(DisplaySlot.BELOW_NAME);
if (obj == null)
{
obj = board.registerNewObjective("SG Tourney Kills", "dummy");
obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
}
obj.getScore(event.getPlayer()).setScore(GetStats().getStat(event.getPlayer(), "Pvp", "Kills"));
}
if (event.getPlayer().getScoreboard() != null)
{
Scoreboard board = event.getPlayer().getScoreboard();
Objective obj = board.getObjective(DisplaySlot.BELOW_NAME);
if (obj == null)
{
obj = board.registerNewObjective("SG Tournament Kills", "dummy");
obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
}
for (Player player : Bukkit.getOnlinePlayers())
{
if (player.equals(event.getPlayer()))
continue;
obj.getScore(player).setScore(GetStats().getStat(player, "Pvp", "Kills"));
}
}
}
*/
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
@ -456,7 +347,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
_scoreboards.remove(event.getPlayer());
_portalTime.remove(event.getPlayer().getName());
_forcefield.remove(event.getPlayer());
}
@EventHandler
@ -752,6 +642,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
return _parkour;
}
public PreferencesManager getPreferences()
{
return _preferences;
}
public Location GetSpawn()
{
return _spawn.clone();
@ -799,7 +694,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
if (BumpDisabled(ent))
return false;
if (GetVisibility().IsHiding(ent))
if (!getPreferences().Get((Player)ent).ShowPlayers)
return false;
return true;
@ -855,38 +750,32 @@ public class HubManager extends MiniClientPlugin<HubClient>
this._gadgetsEnabled = _enabled;
}
public boolean ToggleForcefield(Player caller)
{
if (_forcefield.add(caller))
return true;
_forcefield.remove(caller);
return false;
}
@EventHandler
public void ForcefieldUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
return;
for (Player player : _forcefield)
for (Player player : UtilServer.getPlayers())
{
for (Player other : UtilServer.getPlayers())
if (_preferences.Get(player).HubForcefield)
{
if (player.equals(other))
continue;
if (UtilMath.offset(other, player) > 5)
continue;
if (GetClients().Get(other).GetRank().Has(Rank.ADMIN))
continue;
if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false))
for (Player other : UtilServer.getPlayers())
{
UtilAction.velocity(other, UtilAlg.getTrajectory2d(player, other), 1.6, true, 0.8, 0, 10, true);
other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f);
if (player.equals(other))
continue;
if (UtilMath.offset(other, player) > 5)
continue;
if (GetClients().Get(other).GetRank().Has(Rank.ADMIN))
continue;
if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false))
{
UtilAction.velocity(other, UtilAlg.getTrajectory2d(player, other), 1.6, true, 0.8, 0, 10, true);
other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f);
}
}
}
}

View File

@ -1,24 +0,0 @@
package mineplex.hub.commands;
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.hub.HubManager;
public class ForcefieldToggle extends CommandBase<HubManager>
{
public ForcefieldToggle(HubManager plugin)
{
super(plugin, Rank.ADMIN, new String[] {"forcefield", "ff"});
}
@Override
public void Execute(Player caller, String[] args)
{
UtilPlayer.message(caller, C.Bold + "Forcefield: " + F.tf(Plugin.ToggleForcefield(caller)));
}
}

View File

@ -1,35 +1,21 @@
package mineplex.hub.modules;
import java.util.HashMap;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -39,79 +25,12 @@ public class VisibilityManager extends MiniPlugin
{
public HubManager Manager;
private HashSet<Player> _hide = new HashSet<Player>();
private int _slot = 8;
public VisibilityManager(HubManager manager)
{
super("Visibility Manager", manager.GetPlugin());
Manager = manager;
}
@EventHandler
public void PlayerJoin(PlayerJoinEvent event)
{
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.EYE_OF_ENDER, (byte)0, 1,
C.cYellow + "Show Players" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
@EventHandler
public void PlayerQuit(PlayerQuitEvent event)
{
_hide.remove(event.getPlayer());
}
@EventHandler
public void orderThatItem(final PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.EYE_OF_ENDER || event.getItemDrop().getItemStack().getType() == Material.ENDER_PEARL)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
{
public void run()
{
if (event.getPlayer().isOnline())
{
event.getPlayer().getInventory().remove(event.getItemDrop().getItemStack().getType());
event.getPlayer().getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(event.getItemDrop().getItemStack().getType(), (byte)0, 1, ChatColor.RESET + C.cYellow + "Show Players" + C.cWhite + " - " + (_hide.contains(event.getPlayer()) ? C.cRed + "Disabled" : C.cGreen + "Enabled")));
event.getPlayer().updateInventory();
}
}
});
}
}
@EventHandler
public void ToggleVisibility(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
return;
Player player = event.getPlayer();
if (player.getInventory().getHeldItemSlot() != _slot)
return;
event.setCancelled(true);
if (_hide.remove(player))
{
UtilPlayer.message(player, F.main("Visibility", "All players are now visible."));
player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.EYE_OF_ENDER, (byte)0, 1,
C.cYellow + "Show Players" + C.cWhite + " - " + C.cGreen + "Enabled"));
}
else
{
_hide.add(player);
UtilPlayer.message(player, F.main("Visibility", "All players are now invisible."));
player.getInventory().setItem(_slot, ItemStackFactory.Instance.CreateStack(Material.ENDER_PEARL, (byte)0, 1,
C.cYellow + "Show Players" + C.cWhite + " - " + C.cRed + "Disabled"));
}
}
@EventHandler
public void UpdateVisibility(UpdateEvent event)
@ -121,12 +40,14 @@ public class VisibilityManager extends MiniPlugin
for (Player player : UtilServer.getPlayers())
{
boolean hideMe = Manager.getPreferences().Get(player).Invisibility;
for (Player other : UtilServer.getPlayers())
{
if (player.equals(other))
continue;
if (_hide.contains(other) || UtilMath.offset(player.getLocation(), Manager.GetSpawn()) < 4 ||
if (hideMe || !Manager.getPreferences().Get(other).ShowPlayers || UtilMath.offset(player.getLocation(), Manager.GetSpawn()) < 4 ||
Manager.GetTutorial().InTutorial(other) || Manager.GetTutorial().InTutorial(player) ||
(player.getOpenInventory().getType() != InventoryType.CRAFTING && player.getOpenInventory().getType() != InventoryType.CREATIVE))
{
@ -139,11 +60,6 @@ public class VisibilityManager extends MiniPlugin
}
}
}
public boolean IsHiding(LivingEntity ent)
{
return _hide.contains(ent);
}
public HashMap<Player, Integer> _particle = new HashMap<Player, Integer>();

View File

@ -43,6 +43,11 @@ public class PartyManager extends MiniPlugin
{
return _clientManager;
}
public PreferencesManager getPreferenceManager()
{
return _preferenceManager;
}
public Party CreateParty(Player player)
{

View File

@ -90,14 +90,11 @@ public class PartyCommand extends CommandBase<PartyManager>
return;
}
//YouTuber
if (Plugin.GetClients().Get(target).GetRank() == Rank.YOUTUBE)
// Preference check
if (!Plugin.getPreferenceManager().Get(target).PartyRequests)
{
if (Plugin.GetClients().Get(caller).GetRank().Has(Rank.YOUTUBE))
{
UtilPlayer.message(caller, F.main("Stacker", "You may not party with " + F.name(UtilEnt.getName(target)) + "! Leave him/her alone!"));
return;
}
UtilPlayer.message(caller, F.main("Party", "You may not party with " + F.name(UtilEnt.getName(target)) + "! They are not accepting party requests!"));
return;
}
//Invite or Suggest

View File

@ -27,6 +27,7 @@ import mineplex.core.monitor.LagMeter;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Punish;
import mineplex.core.recharge.Recharge;
import mineplex.core.spawn.Spawn;
@ -76,7 +77,8 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
_donationManager = new DonationManager(this, GetWebServerAddress());
new MessageManager(this, _clientManager);
PreferencesManager preferences = new PreferencesManager(this, _clientManager, _donationManager);
new MessageManager(this, _clientManager, preferences);
AntiStack antistack = new AntiStack(this);
@ -96,7 +98,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
AntiHack.Initialize(this, punish, portal);
//Arcade Manager
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, GetWebServerAddress());
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, preferences, GetWebServerAddress());
new MemoryFix(this);

View File

@ -121,7 +121,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
//Games
private Game _game;
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack, Portal portal, PacketHandler packetHandler, String webAddress)
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack, Portal portal, PacketHandler packetHandler, PreferencesManager preferences, String webAddress)
{
super("Game Manager", plugin);
@ -152,7 +152,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
_clientManager = clientManager;
PreferencesManager preferences = new PreferencesManager(plugin, clientManager, donationManager);
_chat = new Chat(plugin, _clientManager, preferences, serverStatusManager.getCurrentServerName());
_creature = creature;