Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2015-02-14 22:05:24 -08:00
commit c129deb201
31 changed files with 1200 additions and 433 deletions

View File

@ -305,6 +305,15 @@ public class Chat extends MiniPlugin
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast.")); UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
event.setCancelled(true); event.setCancelled(true);
} }
else if (!_clientManager.Get(sender).GetRank().Has(Rank.HELPER) &&
msgContainsHack(event.getMessage()))
{
UtilPlayer.message(sender, F.main("Chat",
"Accusing players of cheating in-game is against the rules."
+ "If you think someone is cheating, please gather evidence and report it at "
+ F.link("www.mineplex.com/supporthub/")));
event.setCancelled(true);
}
else if (_playerLastMessage.containsKey(sender.getUniqueId())) else if (_playerLastMessage.containsKey(sender.getUniqueId()))
{ {
MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId()); MessageData lastMessage = _playerLastMessage.get(sender.getUniqueId());
@ -327,6 +336,25 @@ public class Chat extends MiniPlugin
_playerLastMessage.put(sender.getUniqueId(), new MessageData(event.getMessage())); _playerLastMessage.put(sender.getUniqueId(), new MessageData(event.getMessage()));
} }
private boolean msgContainsHack(String msg)
{
msg = msg.toLowerCase();
return (msg.contains(" hack ") ||
msg.contains(" hacker ") ||
msg.contains(" hacking ") ||
msg.contains(" cheat ") ||
msg.contains(" cheater ") ||
msg.contains(" cheating ") ||
msg.contains(" forcefield ") ||
msg.contains(" flyhack ") ||
msg.contains(" flyhacker ") ||
msg.contains(" flyhacking ") ||
msg.contains(" autoclick ") ||
msg.contains(" flyhacking ") ||
msg.contains(" aimbot "));
}
public String hasher(JSONArray hasharray, String message) public String hasher(JSONArray hasharray, String message)
{ {
StringBuilder newmsg = new StringBuilder(message); StringBuilder newmsg = new StringBuilder(message);

View File

@ -375,16 +375,31 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
} }
ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + "======================"); ChildJsonMessage message = new JsonMessage("").extra(C.cAqua + C.Strike + "======================");
message.add(C.cDAqua + "Toggle GUI").click("run_command", "/friendsdisplay"); message.add(C.cDAqua + "Toggle GUI").click("run_command", "/friendsdisplay");
message.hover("show_text", C.cAqua + "Toggle friends to display in a inventory"); message.hover("show_text", C.cAqua + "Toggle friends to display in a inventory");
message.add(C.cAqua + C.Strike + "======================"); message.add(C.cAqua + C.Strike + "======================");
message.sendToPlayer(caller); message.sendToPlayer(caller);
} }
public boolean isFriends(Player player, String friend)
{
FriendData friendData = Get(player);
for (FriendStatus friendStatus : friendData.getFriends())
{
if (friendStatus.Name.equalsIgnoreCase(friend))
{
return true;
}
}
return false;
}
@Override @Override
public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException public void processLoginResultSet(String playerName, ResultSet resultSet) throws SQLException
{ {

View File

@ -111,7 +111,18 @@ public class FriendsGUI implements Listener
if (friendSlot >= friends.size()) if (friendSlot >= friends.size())
{ {
break; ItemStack item = _inventory.getItem(slot);
if (item == null || item.getType() == Material.AIR)
{
break;
}
else
{
_inventory.setItem(slot, new ItemStack(Material.AIR));
continue;
}
} }
FriendStatus friend = friends.get(friendSlot); FriendStatus friend = friends.get(friendSlot);
@ -119,7 +130,7 @@ public class FriendsGUI implements Listener
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name); builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name); builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
@ -245,7 +256,18 @@ public class FriendsGUI implements Listener
if (friendSlot >= friends.size()) if (friendSlot >= friends.size())
{ {
break; ItemStack item = _inventory.getItem(slot);
if (item == null || item.getType() == Material.AIR)
{
break;
}
else
{
_inventory.setItem(slot, new ItemStack(Material.AIR));
continue;
}
} }
FriendStatus friend = friends.get(friendSlot); FriendStatus friend = friends.get(friendSlot);
@ -253,7 +275,7 @@ public class FriendsGUI implements Listener
ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0)); ItemBuilder builder = new ItemBuilder(Material.SKULL_ITEM, 1, (short) (friend.Online ? 3 : 0));
builder.setTitle(C.cWhite + C.Bold + friend.Name); builder.setTitle(C.cWhite + C.Bold + friend.Name);
builder.setPlayerHead(friend.Name); builder.setPlayerHead(friend.Name);
builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline")); builder.addLore(C.cGray + C.Bold + "Status: " + (friend.Online ? C.cDGreen + "Online" : C.cRed + "Offline"));
@ -446,7 +468,18 @@ public class FriendsGUI implements Listener
if (friendSlot >= friends.size()) if (friendSlot >= friends.size())
{ {
break; ItemStack item = _inventory.getItem(slot);
if (item == null || item.getType() == Material.AIR)
{
break;
}
else
{
_inventory.setItem(slot, new ItemStack(Material.AIR));
continue;
}
} }
FriendStatus friend = friends.get(friendSlot); FriendStatus friend = friends.get(friendSlot);

View File

@ -19,7 +19,7 @@ public class Unignore extends CommandBase<IgnoreManager>
public void Execute(final Player caller, final String[] args) public void Execute(final Player caller, final String[] args)
{ {
if (args == null) if (args == null)
F.main(Plugin.getName(), "You need to include a player's name."); caller.sendMessage(F.main(Plugin.getName(), "You need to include a player's name."));
else else
{ {
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>() CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()

View File

@ -1,54 +0,0 @@
package mineplex.core.message.Commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class MessageAdminCommand extends CommandBase<MessageManager>
{
public MessageAdminCommand(MessageManager plugin)
{
super(plugin, Rank.ALL, "ma");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true))
return;
if (args.length == 0)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing."));
return;
}
//Parse To
Player to = UtilPlayer.searchOnline(caller, args[0], true);
if (to == null)
return;
//Parse Message
if (args.length < 2)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Message argument missing."));
return;
}
String message = F.combine(args, 1, null, false);
//Send
Plugin.DoMessageAdmin(caller, to, message);
}
}
}

View File

@ -1,53 +0,0 @@
package mineplex.core.message.Commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class MessageCommand extends CommandBase<MessageManager>
{
public MessageCommand(MessageManager plugin)
{
super(plugin, Rank.ALL, "m","msg","message","tell","t","w","whisper","MSG");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
if (args.length == 0)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing."));
return;
}
//Parse To
Player to = UtilPlayer.searchOnline(caller, args[0], true);
if (to == null)
return;
//Parse Message
String message = "Beep!";
if (args.length > 1)
{
message = F.combine(args, 1, null, false);
}
else
{
message = Plugin.GetRandomMessage();
}
//Send!
Plugin.DoMessage(caller, to, message);
}
}
}

View File

@ -1,57 +0,0 @@
package mineplex.core.message.Commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class ResendAdminCommand extends CommandBase<MessageManager>
{
public ResendAdminCommand(MessageManager plugin)
{
super(plugin, Rank.ALL, "ra");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true))
return;
//Get To
if (Plugin.Get(caller).LastAdminTo == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not admin messaged anyone recently."));
return;
}
Player to = UtilPlayer.searchOnline(caller, Plugin.Get(caller).LastAdminTo, false);
if (to == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), F.name(Plugin.Get(caller).LastAdminTo) + " is no longer online."));
return;
}
//Parse Message
if (args.length < 1)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Message argument missing."));
return;
}
String message = F.combine(args, 0, null, false);
//Send
Plugin.DoMessageAdmin(caller, to, message);
}
}
}

View File

@ -1,56 +0,0 @@
package mineplex.core.message.Commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class ResendCommand extends CommandBase<MessageManager>
{
public ResendCommand(MessageManager plugin)
{
super(plugin, Rank.ALL, "r");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
//Get To
if (Plugin.Get(caller).LastTo == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not messaged anyone recently."));
return;
}
Player to = UtilPlayer.searchOnline(caller, Plugin.Get(caller).LastTo, false);
if (to == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), F.name(Plugin.Get(caller).LastTo) + " is no longer online."));
return;
}
//Parse Message
String message = "Beep!";
if (args.length > 0)
{
message = F.combine(args, 0, null, false);
}
else
{
message = Plugin.GetRandomMessage();
}
//Send
Plugin.DoMessage(caller, to, message);
}
}
}

View File

@ -1,11 +1,15 @@
package mineplex.core.message; package mineplex.core.message;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import mineplex.core.MiniClientPlugin; import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
@ -17,8 +21,15 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.friend.FriendManager;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendStatus;
import mineplex.core.ignore.IgnoreManager; import mineplex.core.ignore.IgnoreManager;
import mineplex.core.message.Commands.*; import mineplex.core.message.commands.*;
import mineplex.core.message.redis.AnnouncementHandler;
import mineplex.core.message.redis.MessageHandler;
import mineplex.core.message.redis.RedisMessage;
import mineplex.core.message.redis.RedisMessageCallback;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Punish; import mineplex.core.punish.Punish;
import mineplex.core.punish.PunishClient; import mineplex.core.punish.PunishClient;
@ -29,237 +40,468 @@ import mineplex.serverdata.transfers.AnnouncementCommand;
public class MessageManager extends MiniClientPlugin<ClientMessage> public class MessageManager extends MiniClientPlugin<ClientMessage>
{ {
private LinkedList<String> _randomMessage; private CoreClientManager _clientManager;
private FriendManager _friendsManager;
private IgnoreManager _ignoreManager;
private HashMap<UUID, BukkitRunnable> _messageTimeouts = new HashMap<UUID, BukkitRunnable>();
private PreferencesManager _preferences;
private Punish _punish;
private LinkedList<String> _randomMessage;
private String _serverName;
private CoreClientManager _clientManager; public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences,
private PreferencesManager _preferences; IgnoreManager ignoreManager, Punish punish, FriendManager friendManager)
private IgnoreManager _ignoreManager; {
private Punish _punish; super("Message", plugin);
public MessageManager(JavaPlugin plugin, CoreClientManager clientManager, PreferencesManager preferences, _clientManager = clientManager;
IgnoreManager ignoreManager, Punish punish) _preferences = preferences;
{ _ignoreManager = ignoreManager;
super("Message", plugin); _punish = punish;
_friendsManager = friendManager;
_serverName = GetPlugin().getConfig().getString("serverstatus.name");
_clientManager = clientManager; ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class,
_preferences = preferences; new AnnouncementHandler());
_ignoreManager = ignoreManager;
_punish = punish;
ServerCommandManager.getInstance().registerCommandType("AnnouncementCommand", AnnouncementCommand.class, MessageHandler messageHandler = new MessageHandler(this);
new AnnouncementHandler());
}
// Module Functions ServerCommandManager.getInstance()
@Override .registerCommandType("RedisMessageCallback", RedisMessageCallback.class, messageHandler);
public void Enable() ServerCommandManager.getInstance().registerCommandType("RedisMessage", RedisMessage.class, messageHandler);
{ }
_randomMessage = new LinkedList<String>();
_randomMessage.clear();
_randomMessage.add("Hello, do you have any wild boars for purchase?");
_randomMessage.add("There's a snake in my boot!");
_randomMessage.add("Monk, I need a Monk!");
_randomMessage.add("Hi, I'm from planet minecraft, op me plz dooooood!");
_randomMessage.add("Somebody's poisoned the waterhole!");
_randomMessage.add("MORE ORBZ MORE ORBZ MORE ORBZ MORE ORBZ!");
_randomMessage.add("Chiss is a chiss and chiss chiss.");
_randomMessage.add("*_*");
_randomMessage.add("#swag");
_randomMessage.add("Everything went better then I thought.");
_randomMessage.add("HAVE A CHICKEN!");
_randomMessage.add("follow me, i have xrays");
_randomMessage.add("I'm making a java");
_randomMessage.add("Do you talk to strangers? I have candy if it helps.");
_randomMessage.add("Solid 2.9/10");
_randomMessage.add("close your eyes to sleep");
_randomMessage.add("I crashed because my internet ran out.");
_randomMessage.add("I saw morgan freeman on a breaking bad ad on a bus.");
_randomMessage.add("Where is the volume control?");
_randomMessage.add("I saw you playing on youtube with that guy and stuff.");
_randomMessage.add("Your worms must be worse than useless.");
_randomMessage.add("meow");
_randomMessage.add("7");
_randomMessage.add("Don't you wish your girlfriend was hot like me?");
_randomMessage.add("how do you play mindcrafts?");
_randomMessage.add("7 cats meow meow meow meow meow meow meow");
_randomMessage.add("For King Jonalon!!!!!");
_randomMessage.add("Do you like apples?");
_randomMessage.add("I'm Happy Happy Happy.");
_randomMessage.add("kthxbye");
_randomMessage.add("i like pie.");
_randomMessage.add("Do you play Clash of Clans?");
_randomMessage.add("Mmm...Steak!");
}
public void AddCommands() public void AddCommands()
{ {
addCommand(new MessageCommand(this)); addCommand(new MessageCommand(this));
addCommand(new ResendCommand(this)); addCommand(new ResendCommand(this));
addCommand(new MessageAdminCommand(this)); addCommand(new MessageAdminCommand(this));
addCommand(new ResendAdminCommand(this)); addCommand(new ResendAdminCommand(this));
addCommand(new AnnounceCommand(this)); addCommand(new AnnounceCommand(this));
addCommand(new GlobalCommand(this)); addCommand(new GlobalCommand(this));
addCommand(new AdminCommand(this)); addCommand(new AdminCommand(this));
} }
public void Help(Player caller, String message) @Override
{ protected ClientMessage AddPlayer(String player)
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + "Err...something went wrong?")); {
} Set(player, new ClientMessage());
return Get(player);
}
public void Help(Player caller) public boolean canMessage(Player from, Player to)
{ {
Help(caller, null); if (!canSenderMessageThem(from, to.getName()))
} {
return false;
}
/* XXX Incorporate this String canMessage = canReceiverMessageThem(from.getName(), to);
PunishChatEvent event = new PunishChatEvent(caller);
GetPlugin().getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
return;
*/
public boolean canMessage(Player from, Player to) if (canMessage != null)
{ {
PunishClient client = _punish.GetClient(from.getName()); from.sendMessage(canMessage);
if (client != null && client.IsMuted()) return false;
{ }
Punishment punishment = client.GetPunishment(PunishmentSentence.Mute);
from.sendMessage(F.main(_punish.getName(), "Shh, you're muted because " return true;
}
+ punishment.GetReason() public String canReceiverMessageThem(String sender, Player target)
{
+ " by " // If the receiver has turned off private messaging and the sender isn't a mod
if (!_friendsManager.isFriends(target, sender) && !_preferences.Get(target).PrivateMessaging)
{
return C.cPurple + target.getName() + " has private messaging disabled.";
+ punishment.GetAdmin() }
+ " for " // If the receiver is ignoring the sender, and the sender isn't a mod
if (_ignoreManager.isIgnoring(target, sender))
{
return F.main(_ignoreManager.getName(), ChatColor.GRAY + "That player is ignoring you");
}
+ C.cGreen return null;
}
+ UtilTime.convertString(punishment.GetRemaining(), 1, TimeUnit.FIT) + ".")); public boolean canSenderMessageThem(Player sender, String target)
return false; {
} PunishClient client = _punish.GetClient(sender.getName());
// If the receiver has turned off private messaging and the sender isn't a mod if (client != null && client.IsMuted())
if (!_preferences.Get(to).PrivateMessaging && !_clientManager.Get(from).GetRank().Has(Rank.HELPER)) {
{ Punishment punishment = client.GetPunishment(PunishmentSentence.Mute);
UtilPlayer.message(from, C.cPurple + to.getName() + " has private messaging disabled.");
return false;
}
if (_ignoreManager.isIgnoring(from, to)) sender.sendMessage(F.main(_punish.getName(), "Shh, you're muted because "
{
from.sendMessage(F.main(_ignoreManager.getName(), ChatColor.GRAY + "You are ignoring that player"));
return false; + punishment.GetReason()
}
// If the receiver is ignoring the sender, and the sender isn't a mod + " by "
if (_ignoreManager.isIgnoring(to, from) && !_clientManager.Get(from).GetRank().Has(Rank.HELPER))
{
from.sendMessage(F.main(_ignoreManager.getName(), ChatColor.GRAY + "That player is ignoring you"));
return false; + punishment.GetAdmin()
}
return true; + " for "
}
public void DoMessage(Player from, Player to, String message) + C.cGreen
{
if (!canMessage(from, to))
{
return;
}
// Inform + UtilTime.convertString(punishment.GetRemaining(), 1, TimeUnit.FIT) + "."));
UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message);
// Save return false;
Get(from).LastTo = to.getName(); }
// Chiss or defek7 if (_ignoreManager.isIgnoring(sender, target))
if (to.getName().equals("Chiss") || to.getName().equals("defek7")) {
{ sender.sendMessage(F.main(_ignoreManager.getName(), ChatColor.GRAY + "You are ignoring that player"));
UtilPlayer.message(from, C.cPurple + to.getName() + "is often AFK or minimized, due to plugin development.");
UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly.");
}
// Log return false;
// Logger().logChat("Private Message", from, to.getName(), message); }
// Ignored XXX return true;
// if (Get(to).Ignore().IsIgnored(from.getName())) }
// return;
// Sound public void DoMessage(Player from, Player to, String message)
from.playSound(to.getLocation(), Sound.NOTE_PIANO, 1f, 1f); {
to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); if (!canMessage(from, to))
{
return;
}
// Send // Inform
UtilPlayer.message(to, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message); UtilPlayer.message(from, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message);
}
public void DoMessageAdmin(Player from, Player to, String message) // Save
{ Get(from).LastTo = to.getName();
// Inform
UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " "
+ C.cPurple + message);
// Inform Admins // Chiss or defek7
for (Player staff : UtilServer.getPlayers()) if (to.getName().equals("Chiss") || to.getName().equals("defek7"))
if (!to.equals(staff)) {
if (!from.equals(staff)) UtilPlayer.message(from, C.cPurple + to.getName() + "is often AFK or minimized, due to plugin development.");
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER)) UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly.");
UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + C.cPurple }
+ " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple
+ message);
// Save // Log
Get(from).LastAdminTo = to.getName(); // Logger().logChat("Private Message", from, to.getName(), message);
// Send // Sound
UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + " " from.playSound(to.getLocation(), Sound.NOTE_PIANO, 1f, 1f);
+ C.cPurple + message); to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
// Sound // Send
from.playSound(to.getLocation(), Sound.NOTE_PIANO, 1f, 1f); UtilPlayer.message(to, C.cGold + "§l" + from.getName() + " > " + to.getName() + C.cYellow + " §l" + message);
to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f); }
// Log XXX public void DoMessageAdmin(Player from, Player to, String message)
// Logger().logChat("Staff Message", from, to.getName(), message); {
} // Inform
UtilPlayer.message(from, C.cPurple + "-> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " "
+ C.cPurple + message);
@Override // Inform Admins
protected ClientMessage AddPlayer(String player) for (Player staff : UtilServer.getPlayers())
{ {
Set(player, new ClientMessage()); if (!to.equals(staff) && !from.equals(staff))
return Get(player); {
} if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
{
UtilPlayer.message(staff, F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + C.cPurple
+ " -> " + F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple + message);
}
}
}
public LinkedList<String> GetRandomMessages() // Save
{ Get(from).LastAdminTo = to.getName();
return _randomMessage;
}
public String GetRandomMessage() // Send
{ UtilPlayer.message(to, C.cPurple + "<- " + F.rank(_clientManager.Get(from).GetRank()) + " " + from.getName() + " "
if (_randomMessage.isEmpty()) + C.cPurple + message);
return "meow";
return _randomMessage.get(UtilMath.r(_randomMessage.size())); // Sound
} from.playSound(to.getLocation(), Sound.NOTE_PIANO, 1f, 1f);
to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
public CoreClientManager GetClientManager() // Log XXX
{ // Logger().logChat("Staff Message", from, to.getName(), message);
return _clientManager; }
}
// Module Functions
@Override
public void Enable()
{
_randomMessage = new LinkedList<String>();
_randomMessage.clear();
_randomMessage.add("Hello, do you have any wild boars for purchase?");
_randomMessage.add("There's a snake in my boot!");
_randomMessage.add("Monk, I need a Monk!");
_randomMessage.add("Hi, I'm from planet minecraft, op me plz dooooood!");
_randomMessage.add("Somebody's poisoned the waterhole!");
_randomMessage.add("MORE ORBZ MORE ORBZ MORE ORBZ MORE ORBZ!");
_randomMessage.add("Chiss is a chiss and chiss chiss.");
_randomMessage.add("*_*");
_randomMessage.add("#swag");
_randomMessage.add("Everything went better then I thought.");
_randomMessage.add("HAVE A CHICKEN!");
_randomMessage.add("follow me, i have xrays");
_randomMessage.add("I'm making a java");
_randomMessage.add("Do you talk to strangers? I have candy if it helps.");
_randomMessage.add("Solid 2.9/10");
_randomMessage.add("close your eyes to sleep");
_randomMessage.add("I crashed because my internet ran out.");
_randomMessage.add("I saw morgan freeman on a breaking bad ad on a bus.");
_randomMessage.add("Where is the volume control?");
_randomMessage.add("I saw you playing on youtube with that guy and stuff.");
_randomMessage.add("Your worms must be worse than useless.");
_randomMessage.add("meow");
_randomMessage.add("7");
_randomMessage.add("Don't you wish your girlfriend was hot like me?");
_randomMessage.add("how do you play mindcrafts?");
_randomMessage.add("7 cats meow meow meow meow meow meow meow");
_randomMessage.add("For King Jonalon!!!!!");
_randomMessage.add("Do you like apples?");
_randomMessage.add("I'm Happy Happy Happy.");
_randomMessage.add("kthxbye");
_randomMessage.add("i like pie.");
_randomMessage.add("Do you play Clash of Clans?");
_randomMessage.add("Mmm...Steak!");
}
public CoreClientManager GetClientManager()
{
return _clientManager;
}
public String GetRandomMessage()
{
if (_randomMessage.isEmpty())
return "meow";
return _randomMessage.get(UtilMath.r(_randomMessage.size()));
}
public LinkedList<String> GetRandomMessages()
{
return _randomMessage;
}
public void Help(Player caller)
{
Help(caller, null);
}
public void Help(Player caller, String message)
{
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + "Err...something went wrong?"));
}
public void receiveMessage(Player to, RedisMessage globalMessage)
{
if (globalMessage.isStaffMessage())
{
// Message the receiver
UtilPlayer.message(to, C.cPurple + "<- " + globalMessage.getRank() + " " + globalMessage.getSender() + " "
+ C.cPurple + globalMessage.getMessage());
to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
// Inform Admins
for (Player staff : UtilServer.getPlayers())
{
if (!to.equals(staff))
{
if (_clientManager.Get(staff).GetRank().Has(Rank.HELPER))
{
UtilPlayer.message(staff,
globalMessage.getRank() + " " + globalMessage.getSender() + C.cPurple + " -> "
+ F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " "
+ C.cPurple + globalMessage.getMessage());
}
}
}
// Message the sender
RedisMessageCallback message = new RedisMessageCallback(globalMessage, C.cPurple + "-> "
+ F.rank(_clientManager.Get(to).GetRank()) + " " + to.getName() + " " + C.cPurple
+ globalMessage.getMessage(), to.getName());
message.publish();
}
else
{
String canMessage = canReceiverMessageThem(globalMessage.getSender(), to);
if (canMessage != null)
{
RedisMessageCallback message = new RedisMessageCallback(globalMessage, canMessage, null);
message.publish();
return;
}
// Message the receiver
UtilPlayer.message(to, C.cGold + "§l" + globalMessage.getSender() + " > " + to.getName() + C.cYellow + " §l"
+ globalMessage.getMessage());
to.playSound(to.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
// Message the sender
RedisMessageCallback message = new RedisMessageCallback(globalMessage, C.cGold + "§l" + globalMessage.getSender()
+ " > " + to.getName() + C.cYellow + " §l" + globalMessage.getMessage(), to.getName());
message.publish();
}
}
public void receiveMessageCallback(RedisMessageCallback message)
{
BukkitRunnable runnable = _messageTimeouts.remove(message.getUUID());
if (runnable != null)
{
runnable.cancel();
}
Player target = Bukkit.getPlayerExact(message.getTarget());
if (target != null)
{
target.sendMessage(message.getMessage());
target.playSound(target.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
if (message.getLastReplied() != null)
{
if (message.isStaffMessage())
{
Get(target).LastAdminTo = message.getLastReplied();
}
else
{
Get(target).LastTo = message.getLastReplied();
}
}
}
}
public void sendMessage(final Player sender, String target, String message, boolean isReply, final boolean adminMessage)
{
FriendData friends = _friendsManager.Get(sender);
FriendStatus friend = null;
if (!adminMessage)
{
for (FriendStatus friendInfo : friends.getFriends())
{
// We don't grab this guy even if name matches because he is offline. This way, we can get a free message without
// extra coding as we can't do anything extra with a offline friend..
if ((isReply || friendInfo.Online) && friendInfo.Name.equalsIgnoreCase(target))
{
friend = friendInfo;
break;
}
// If this isn't a reply, no other matches found, friend is online and name begins with param.. Our first guess.
if (!isReply && friend == null && friendInfo.Online
&& friendInfo.Name.toLowerCase().startsWith(target.toLowerCase()))
{
friend = friendInfo;
}
}
}
// We now have the friend object, if its not null. We are sending the message to that player.
// Only notify player if friend is null and its not a reply
Player to = UtilPlayer.searchOnline(sender, target, !adminMessage && friend == null && !isReply);
// If isn't admin message, friend is null and target is null. Return because location of receiver is unknown.
if (!adminMessage && (friend == null || !friend.Online) && to == null)
{
// We need to notify them that the player they are replying to is gone
if (isReply)
{
UtilPlayer.message(sender, F.main(getName(), F.name(target) + " is no longer online."));
}
return;
}
// If this is a message inside the server
if (to != null)
{
if (adminMessage)
{
DoMessageAdmin(sender, to, message);
}
else
{
DoMessage(sender, to, message);
}
}
else
{
// Looks like we will be using redis to send a message
// First get the full name of the player and make it a final String for use in a runnable
final String playerTarget = adminMessage ? target : friend.Name;
// If this is a admin message, or the sender isn't muted/ignoring the target
if (adminMessage || canSenderMessageThem(sender, playerTarget))
{
// Construct the command to send to redis
RedisMessage globalMessage = new RedisMessage(_serverName,
sender.getName(),
adminMessage ? null : friend.ServerName,
playerTarget,
message,
// Include the sender's rank if this is a admin message. So we can format the receivers chat.
adminMessage ? F.rank(_clientManager.Get(sender).GetRank()) : null);
final UUID uuid = globalMessage.getUUID();
// A backup for the rare case where the message fails to deliver. Server doesn't respond
BukkitRunnable runnable = new BukkitRunnable()
{
public void run()
{
_messageTimeouts.remove(uuid);
// Inform the player that the message failed to deliver
UtilPlayer.message(
sender,
F.main((adminMessage ? "Admin " : "") + "Message", C.mBody + " Failed to send message to ["
+ C.mElem + playerTarget + C.mBody + "]."));
}
};
// This will activate in 2 seconds
runnable.runTaskLater(GetPlugin(), 40);
// The key is the UUID its trading between servers
_messageTimeouts.put(uuid, runnable);
// Time to send the message!
globalMessage.publish();
}
}
}
} }

View File

@ -1,4 +1,4 @@
package mineplex.core.message.Commands; package mineplex.core.message.commands;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -0,0 +1,47 @@
package mineplex.core.message.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class AdminMessageCommand extends CommandBase<MessageManager>
{
public AdminMessageCommand(MessageManager plugin)
{
super(plugin, Rank.SNR_MODERATOR, "am");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
if (args.length == 0)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing."));
return;
}
// Parse Message
String message = "Beep!";
if (args.length > 1)
{
message = F.combine(args, 1, null, false);
}
else
{
message = Plugin.GetRandomMessage();
}
Plugin.sendMessage(caller, args[0], message, false, true);
}
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.message.Commands; package mineplex.core.message.commands;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;

View File

@ -1,4 +1,4 @@
package mineplex.core.message.Commands; package mineplex.core.message.commands;
import mineplex.core.command.CommandBase; import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;

View File

@ -0,0 +1,50 @@
package mineplex.core.message.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class MessageAdminCommand extends CommandBase<MessageManager>
{
public MessageAdminCommand(MessageManager plugin)
{
super(plugin, Rank.ALL, "ma");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true))
return;
if (args.length == 0)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing."));
return;
}
// Parse Message
String message = "Beep!";
if (args.length > 1)
{
message = F.combine(args, 1, null, false);
}
else
{
message = Plugin.GetRandomMessage();
}
Plugin.sendMessage(caller, args[0], message, false, true);
}
}
}

View File

@ -0,0 +1,47 @@
package mineplex.core.message.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class MessageCommand extends CommandBase<MessageManager>
{
public MessageCommand(MessageManager plugin)
{
super(plugin, Rank.ALL, "m", "msg", "message", "tell", "t", "w", "whisper", "MSG");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
if (args.length == 0)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "Player argument missing."));
return;
}
// Parse Message
String message = "Beep!";
if (args.length > 1)
{
message = F.combine(args, 1, null, false);
}
else
{
message = Plugin.GetRandomMessage();
}
Plugin.sendMessage(caller, args[0], message, false, false);
}
}
}

View File

@ -0,0 +1,53 @@
package mineplex.core.message.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class ResendAdminCommand extends CommandBase<MessageManager>
{
public ResendAdminCommand(MessageManager plugin)
{
super(plugin, Rank.ALL, "ra");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
if (!Plugin.GetClientManager().Get(caller).GetRank().Has(caller, Rank.HELPER, true))
return;
String lastTo = Plugin.Get(caller).LastAdminTo;
// Get To
if (lastTo == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not admin messaged anyone recently."));
return;
}
// Parse Message
String message = "Beep!";
if (args.length > 0)
{
message = F.combine(args, 0, null, false);
}
else
{
message = Plugin.GetRandomMessage();
}
Plugin.sendMessage(caller, lastTo, message, true, true);
}
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.message.commands;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.message.MessageManager;
public class ResendCommand extends CommandBase<MessageManager>
{
public ResendCommand(MessageManager plugin)
{
super(plugin, Rank.ALL, "r");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null)
{
Plugin.Help(caller);
}
else
{
String lastTo = Plugin.Get(caller).LastTo;
// Get To
if (lastTo == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "You have not messaged anyone recently."));
return;
}
// Parse Message
String message = "Beep!";
if (args.length > 0)
{
message = F.combine(args, 0, null, false);
}
else
{
message = Plugin.GetRandomMessage();
}
Plugin.sendMessage(caller, lastTo, message, true, false);
}
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.message; package mineplex.core.message.redis;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -15,7 +15,7 @@ public class AnnouncementHandler implements CommandCallback
{ {
public void run(ServerCommand command) public void run(ServerCommand command)
{ {
if (command instanceof ServerCommand) if (command instanceof AnnouncementCommand)
{ {
AnnouncementCommand announcementCommand = (AnnouncementCommand)command; AnnouncementCommand announcementCommand = (AnnouncementCommand)command;

View File

@ -0,0 +1,38 @@
package mineplex.core.message.redis;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.message.MessageManager;
import mineplex.serverdata.CommandCallback;
import mineplex.serverdata.ServerCommand;
public class MessageHandler implements CommandCallback
{
private MessageManager _messageManager;
public MessageHandler(MessageManager messageManager)
{
_messageManager = messageManager;
}
public void run(ServerCommand command)
{
if (command instanceof RedisMessage)
{
RedisMessage message = (RedisMessage) command;
Player target = Bukkit.getPlayerExact(message.getTarget());
if (target != null)
{
_messageManager.receiveMessage(target, message);
}
}
else if (command instanceof RedisMessageCallback)
{
_messageManager.receiveMessageCallback((RedisMessageCallback) command);
}
}
}

View File

@ -0,0 +1,73 @@
package mineplex.core.message.redis;
import java.util.UUID;
import mineplex.serverdata.ServerCommand;
/**
* Used to send a admin or normal message between servers
*/
public class RedisMessage extends ServerCommand
{
private String _message;
private String _sender;
private String _sendingServer;
private String _target;
private String _rank;
private UUID _uuid = UUID.randomUUID();
public RedisMessage(String sendingServer, String sender, String targetServer, String target, String message, String rank)
{
_sender = sender;
_target = target;
_message = message;
_sendingServer = sendingServer;
_rank = rank;
if (targetServer != null)
{
setTargetServers(targetServer);
}
}
public UUID getUUID()
{
return _uuid;
}
public String getRank()
{
return _rank;
}
public boolean isStaffMessage()
{
return getTargetServers().length == 0;
}
public String getMessage()
{
return _message;
}
public String getSender()
{
return _sender;
}
public String getSendingServer()
{
return _sendingServer;
}
public String getTarget()
{
return _target;
}
@Override
public void run()
{
// Utilitizes a callback functionality to seperate dependencies
}
}

View File

@ -0,0 +1,62 @@
package mineplex.core.message.redis;
import java.util.UUID;
import mineplex.serverdata.ServerCommand;
/**
* Used as a response in return to a admin or normal message between servers.
*/
public class RedisMessageCallback extends ServerCommand
{
private String _message;
private String _setLastMessage;
private String _target;
private UUID _uuid;
private boolean _staffMessage;
public RedisMessageCallback(RedisMessage globalMessage, String message, String setLastReplied)
{
_target = globalMessage.getSender();
_message = message;
_setLastMessage = setLastReplied;
_uuid = globalMessage.getUUID();
_staffMessage = globalMessage.isStaffMessage();
if (globalMessage.getSendingServer() != null)
{
setTargetServers(globalMessage.getSendingServer());
}
}
public boolean isStaffMessage()
{
return _staffMessage;
}
public String getLastReplied()
{
return _setLastMessage;
}
public String getMessage()
{
return _message;
}
public String getTarget()
{
return _target;
}
public UUID getUUID()
{
return _uuid;
}
@Override
public void run()
{
// Utilitizes a callback functionality to seperate dependencies
}
}

View File

@ -1,40 +1,118 @@
package mineplex.core.teleport; package mineplex.core.teleport;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.UUID;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.teleport.command.LocateCommand;
import mineplex.core.teleport.command.TeleportCommand; import mineplex.core.teleport.command.TeleportCommand;
import mineplex.core.teleport.event.MineplexTeleportEvent; import mineplex.core.teleport.event.MineplexTeleportEvent;
import mineplex.core.teleport.redis.RedisLocate;
import mineplex.core.teleport.redis.RedisLocateCallback;
import mineplex.core.teleport.redis.RedisLocateHandler;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.common.jsonchat.ChildJsonMessage;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.HoverEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
import mineplex.serverdata.ServerCommandManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class Teleport extends MiniPlugin public class Teleport extends MiniPlugin
{ {
private LinkedList<Teleporter> teleportList = new LinkedList<Teleporter>(); private LinkedList<Teleporter> teleportList = new LinkedList<Teleporter>();
private NautHashMap<String, LinkedList<Location>> _tpHistory = new NautHashMap<String, LinkedList<Location>>(); private NautHashMap<String, LinkedList<Location>> _tpHistory = new NautHashMap<String, LinkedList<Location>>();
private NautHashMap<UUID, BukkitRunnable> _failedRedisLocates = new NautHashMap<UUID, BukkitRunnable>();
private String _serverName;
public Teleport(JavaPlugin plugin) public Teleport(JavaPlugin plugin)
{ {
super("Teleport", plugin); super("Teleport", plugin);
_serverName = GetPlugin().getConfig().getString("serverstatus.name");
RedisLocateHandler locateHandler = new RedisLocateHandler(this);
ServerCommandManager.getInstance().registerCommandType("RedisLocate", RedisLocate.class, locateHandler);
ServerCommandManager.getInstance().registerCommandType("RedisLocateCallback", RedisLocateCallback.class, locateHandler);
} }
@Override @Override
public void AddCommands() public void AddCommands()
{ {
addCommand(new TeleportCommand(this)); addCommand(new TeleportCommand(this));
addCommand(new LocateCommand(this));
}
public void handleLocateCallback(RedisLocateCallback callback)
{
BukkitRunnable runnable = _failedRedisLocates.remove(callback.getUUID());
if (runnable != null)
{
runnable.cancel();
}
Player player = Bukkit.getPlayerExact(callback.getTarget());
if (player != null)
{
ChildJsonMessage message = new JsonMessage("").extra(C.mHead + "Locate" + "> " + C.mBody + "Located [" + C.mElem
+ callback.getPlayer() + C.mBody + "] at ");
message.add(C.cBlue + callback.getServer()).click(ClickEvent.RUN_COMMAND,
"/server " + callback.getServer());
message.hover(HoverEvent.SHOW_TEXT, "Teleport to " + callback.getServer());
message.sendToPlayer(player);
}
}
public void locatePlayer(final Player player, final String target)
{
Player targetPlayer = Bukkit.getPlayerExact(target);
if (targetPlayer != null)
{
UtilPlayer.message(player, F.main("Locate", C.mBody + " [" + C.mElem + target + C.mBody + "] is in the same server!"));
return;
}
RedisLocate locate = new RedisLocate(_serverName, player.getName(), target);
final UUID uuid = locate.getUUID();
BukkitRunnable runnable = new BukkitRunnable()
{
@Override
public void run()
{
_failedRedisLocates.remove(uuid);
UtilPlayer.message(player, F.main("Locate", C.mBody + "Failed to locate [" + C.mElem + target + C.mBody + "]."));
}
};
_failedRedisLocates.put(uuid, runnable);
runnable.runTaskLater(_plugin, 40);
locate.publish();
} }
@EventHandler @EventHandler

View File

@ -0,0 +1,29 @@
package mineplex.core.teleport.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.teleport.Teleport;
public class LocateCommand extends CommandBase<Teleport>
{
public LocateCommand(Teleport plugin)
{
super(plugin, Rank.MODERATOR, "locate", "where", "find");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null || args.length == 0)
{
UtilPlayer.message(caller, F.main("Locate", "Player argument missing."));
return;
}
Plugin.locatePlayer(caller, args[0]);
}
}

View File

@ -0,0 +1,40 @@
package mineplex.core.teleport.redis;
import java.util.UUID;
import mineplex.serverdata.ServerCommand;
public class RedisLocate extends ServerCommand
{
private String _sender;
private String _sendingServer;
private String _target;
private UUID _uuid = UUID.randomUUID();
public RedisLocate(String sendingServer, String sender, String target)
{
_sender = sender;
_target = target;
_sendingServer = sendingServer;
}
public String getSender()
{
return _sender;
}
public String getServer()
{
return _sendingServer;
}
public String getTarget()
{
return _target;
}
public UUID getUUID()
{
return _uuid;
}
}

View File

@ -0,0 +1,43 @@
package mineplex.core.teleport.redis;
import java.util.UUID;
import mineplex.serverdata.ServerCommand;
public class RedisLocateCallback extends ServerCommand
{
private String _player;
private String _server;
private String _target;
private UUID _uuid;
public RedisLocateCallback(RedisLocate command, String server)
{
_uuid = command.getUUID();
_target = command.getSender();
_player = command.getTarget();
_server = server;
setTargetServers(command.getServer());
}
public String getPlayer()
{
return _player;
}
public String getServer()
{
return _server;
}
public String getTarget()
{
return _target;
}
public UUID getUUID()
{
return _uuid;
}
}

View File

@ -0,0 +1,41 @@
package mineplex.core.teleport.redis;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.teleport.Teleport;
import mineplex.serverdata.CommandCallback;
import mineplex.serverdata.ServerCommand;
public class RedisLocateHandler implements CommandCallback
{
private Teleport _plugin;
private String _serverName;
public RedisLocateHandler(Teleport plugin)
{
_plugin = plugin;
_serverName = _plugin.GetPlugin().getConfig().getString("serverstatus.name");
}
@Override
public void run(ServerCommand command)
{
if (command instanceof RedisLocate)
{
RedisLocate locate = (RedisLocate) command;
Player target = Bukkit.getPlayerExact(locate.getTarget());
if (target != null)
{
RedisLocateCallback callback = new RedisLocateCallback(locate, _serverName);
callback.publish();
}
}
else if (command instanceof RedisLocateCallback)
{
_plugin.handleLocateCallback((RedisLocateCallback) command);
}
}
}

View File

@ -104,7 +104,9 @@ public class Hub extends JavaPlugin implements IRelation
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager); AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal); IgnoreManager ignoreManager = new IgnoreManager(this, clientManager, preferenceManager, portal);
new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish);
FriendManager friendManager = new FriendManager(this, clientManager, preferenceManager, portal);
new MessageManager(this, clientManager, preferenceManager, ignoreManager, punish, friendManager);
StatsManager statsManager = new StatsManager(this, clientManager); StatsManager statsManager = new StatsManager(this, clientManager);
AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager); AchievementManager achievementManager = new AchievementManager(statsManager, clientManager, donationManager);
@ -143,8 +145,6 @@ public class Hub extends JavaPlugin implements IRelation
new ClassCombatShop(shopManager, clientManager, donationManager, false, "Ranger", classManager.GetClass("Ranger")); new ClassCombatShop(shopManager, clientManager, donationManager, false, "Ranger", classManager.GetClass("Ranger"));
new ClassCombatShop(shopManager, clientManager, donationManager, false, "Knight", classManager.GetClass("Knight")); new ClassCombatShop(shopManager, clientManager, donationManager, false, "Knight", classManager.GetClass("Knight"));
new ClassCombatShop(shopManager, clientManager, donationManager, false, "Assassin", classManager.GetClass("Assassin")); new ClassCombatShop(shopManager, clientManager, donationManager, false, "Assassin", classManager.GetClass("Assassin"));
new FriendManager(this, clientManager, preferenceManager, portal);
//Updates //Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);

View File

@ -15,6 +15,21 @@ public abstract class ServerCommand
_targetServers = targetServers; _targetServers = targetServers;
} }
public void setTargetServers(String... targetServers)
{
_targetServers = targetServers;
}
public String[] getTargetServers()
{
if (_targetServers == null)
{
_targetServers = new String[0];
}
return _targetServers;
}
/** /**
* Run the command on it's destination target server. * Run the command on it's destination target server.
*/ */
@ -30,10 +45,10 @@ public abstract class ServerCommand
*/ */
public boolean isTargetServer(String serverName) public boolean isTargetServer(String serverName)
{ {
if (_targetServers == null || _targetServers.length == 0) // Targets all online servers if (getTargetServers().length == 0)
return true; return true;
for (String targetServer : _targetServers) for (String targetServer : getTargetServers())
{ {
if (targetServer.equalsIgnoreCase(serverName)) if (targetServer.equalsIgnoreCase(serverName))
{ {

View File

@ -113,6 +113,9 @@ public class ServerCommandManager
Class<? extends ServerCommand> commandClazz = _commandTypes.get(commandType).getCommandType(); Class<? extends ServerCommand> commandClazz = _commandTypes.get(commandType).getCommandType();
ServerCommand serverCommand = Utility.deserialize(serializedCommand, commandClazz); ServerCommand serverCommand = Utility.deserialize(serializedCommand, commandClazz);
if (!serverCommand.isTargetServer(_localServerName))
return;
// TODO: Run synchronously? // TODO: Run synchronously?
CommandCallback callback = _commandTypes.get(commandType).getCallback(); CommandCallback callback = _commandTypes.get(commandType).getCallback();
serverCommand.run(); // Run server command without callback serverCommand.run(); // Run server command without callback

View File

@ -106,7 +106,9 @@ public class Arcade extends JavaPlugin
AntiHack.Instance.setKick(false); AntiHack.Instance.setKick(false);
IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal);
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish);
FriendManager friendManager = new FriendManager(this, _clientManager, preferenceManager, portal);
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, friendManager);
BlockRestore blockRestore = new BlockRestore(this); BlockRestore blockRestore = new BlockRestore(this);
@ -127,8 +129,6 @@ public class Arcade extends JavaPlugin
new MemoryFix(this); new MemoryFix(this);
new CustomTagFix(this, packetHandler); new CustomTagFix(this, packetHandler);
new TablistFix(this); new TablistFix(this);
new FriendManager(this, _clientManager, preferenceManager, portal);
//Updates //Updates
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1); getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);

View File

@ -58,13 +58,13 @@ public class GameLootManager implements Listener
false); false);
//Chest //Chest
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Basic Chest", "Basic Chest", 1, 1, _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Old Chest", "Old Chest", 1, 1,
new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1000)); new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1000));
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Heroic Chest", "Heroic Chest", 1, 1, _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Ancient Chest", "Ancient Chest", 1, 1,
new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 40)); new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 40));
_rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Legendary Chest", "Legendary Chest", 1, 1, _rewardManager.addReward(new InventoryReward(Manager.getInventoryManager(), "Mythical Chest", "Mythical Chest", 1, 1,
new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1)); new ItemStack(Material.CHEST), RewardRarity.UNCOMMON, 1));
} }