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

This commit is contained in:
Cheese 2015-11-20 08:34:19 +11:00
commit e14f5a36bd
10 changed files with 402 additions and 40 deletions

View File

@ -11,9 +11,19 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank; import mineplex.core.common.Rank;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.globalpacket.command.GlobalPacketCommand; import mineplex.core.globalpacket.command.GlobalPacketCommand;
import mineplex.core.globalpacket.listeners.GlobalGiveCoins;
import mineplex.core.globalpacket.listeners.GlobalGiveGems;
import mineplex.core.globalpacket.listeners.GlobalGiveItem;
import mineplex.core.globalpacket.listeners.GlobalRawr;
import mineplex.core.globalpacket.redis.GlobalPacketHandler; import mineplex.core.globalpacket.redis.GlobalPacketHandler;
import mineplex.core.globalpacket.redis.GlobalPacketMessage; import mineplex.core.globalpacket.redis.GlobalPacketMessage;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.RewardManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager; import mineplex.core.status.ServerStatusManager;
import mineplex.serverdata.commands.ServerCommandManager; import mineplex.serverdata.commands.ServerCommandManager;
@ -21,15 +31,32 @@ public class GlobalPacketManager extends MiniPlugin
{ {
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private ServerStatusManager _statusManager; private ServerStatusManager _statusManager;
private InventoryManager _inventoryManager;
private DonationManager _donationManager;
private RewardManager _rewardManager;
public GlobalPacketManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager) public GlobalPacketManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, InventoryManager inventoryManager, DonationManager donationManager, PetManager petManager, StatsManager statsManager, GiveawayManager giveawayManager)
{ {
super("Global Packet Manager", plugin); super("Global Packet Manager", plugin);
_clientManager = clientManager; _clientManager = clientManager;
_statusManager = statusManager; _statusManager = statusManager;
_inventoryManager = inventoryManager;
_donationManager = donationManager;
_rewardManager = new RewardManager(clientManager, statusManager, donationManager, inventoryManager, petManager, statsManager, giveawayManager,
100, 250,
500, 1000,
1500, 2500,
6000, 12000,
false, false);
ServerCommandManager.getInstance().registerCommandType("GlobalPacketMessage", GlobalPacketMessage.class, new GlobalPacketHandler(statusManager)); ServerCommandManager.getInstance().registerCommandType("GlobalPacketMessage", GlobalPacketMessage.class, new GlobalPacketHandler(statusManager));
getPluginManager().registerEvents(new GlobalGiveItem(inventoryManager, _rewardManager), getPlugin());
getPluginManager().registerEvents(new GlobalGiveGems(donationManager), getPlugin());
getPluginManager().registerEvents(new GlobalGiveCoins(donationManager, clientManager), getPlugin());
getPluginManager().registerEvents(new GlobalRawr(), getPlugin());
} }
public void callGlobalCommand(Player caller, String[] args) public void callGlobalCommand(Player caller, String[] args)

View File

@ -12,7 +12,7 @@ public class GlobalPacketCommand extends CommandBase<GlobalPacketManager>
{ {
public GlobalPacketCommand(GlobalPacketManager plugin) public GlobalPacketCommand(GlobalPacketManager plugin)
{ {
super(plugin, Rank.ADMIN, "globalpacket"); super(plugin, Rank.JNR_DEV, "global", "globalpacket");
} }
@Override @Override
@ -20,8 +20,8 @@ public class GlobalPacketCommand extends CommandBase<GlobalPacketManager>
{ {
if (args == null || args.length < 1) if (args == null || args.length < 1)
{ {
UtilPlayer.message(caller, F.main("Global", "Please call the globalpacket command with at least 1 argument")); UtilPlayer.message(caller, F.main("Global", "Please call the global command with at least 1 argument"));
UtilPlayer.message(caller, F.main("Global", "For help please see /globalpacket google doc")); UtilPlayer.message(caller, F.main("Global", "For help please see /global google doc"));
return; return;
} }

View File

@ -0,0 +1,82 @@
package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
/**
* Created by William (WilliamTiger).
* 17/11/15
*/
public class GlobalGiveCoins implements Listener
{
private DonationManager _donationManager;
private CoreClientManager _clientManager;
public GlobalGiveCoins(DonationManager donationManager, CoreClientManager coreClientManager)
{
_donationManager = donationManager;
_clientManager = coreClientManager;
}
@EventHandler
public void giveCoins(final GlobalPacketEvent e)
{
if (!e.getCallerRank().has(Rank.ADMIN))
return;
if (e.getParts() == null || e.getParts().length < 1)
return;
if (!e.getParts()[0].equalsIgnoreCase("givecoins"))
return;
if (e.getParts().length != 2)
{
if (e.getCaller() != null)
UtilPlayer.message(e.getCaller(), F.main("Global", "/global givecoins <amount>"));
return;
}
int amount = 1;
try
{
amount = Integer.parseInt(e.getParts()[1]);
}
catch (Exception ex)
{
// No number
if (e.getCaller() != null)
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount."));
return;
}
final int fAmount = amount;
for (final Player p : UtilServer.getPlayers())
{
_donationManager.RewardCoins(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " Coins") + "."));
UtilTextMiddle.display(C.cYellow + fAmount + " Coins", C.cGold + "received from " + e.getCallerName() + "!", p);
}
}, "Global Coins", p.getName(), _clientManager.getAccountId(p), amount);
}
}
}

View File

@ -0,0 +1,79 @@
package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
/**
* Created by William (WilliamTiger).
* 17/11/15
*/
public class GlobalGiveGems implements Listener
{
private DonationManager _donationManager;
public GlobalGiveGems(DonationManager donationManager)
{
_donationManager = donationManager;
}
@EventHandler
public void giveGems(final GlobalPacketEvent e)
{
if (!e.getCallerRank().has(Rank.ADMIN))
return;
if (e.getParts() == null || e.getParts().length < 1)
return;
if (!e.getParts()[0].equalsIgnoreCase("givegems"))
return;
if (e.getParts().length != 2)
{
if (e.getCaller() != null)
UtilPlayer.message(e.getCaller(), F.main("Global", "/global givegems <amount>"));
return;
}
int amount = 1;
try
{
amount = Integer.parseInt(e.getParts()[1]);
}
catch (Exception ex)
{
// No number
if (e.getCaller() != null)
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount."));
return;
}
final int fAmount = amount;
for (final Player p : UtilServer.getPlayers())
{
_donationManager.RewardGems(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " Gems") + "."));
UtilTextMiddle.display(C.cYellow + fAmount + " Gems", C.cGold + "received from " + e.getCallerName() + "!", p);
}
}, "Global Gems", p.getName(), p.getUniqueId(), amount);
}
}
}

View File

@ -0,0 +1,156 @@
package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardData;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardType;
/**
* Created by William (WilliamTiger).
* 17/11/15
*/
public class GlobalGiveItem implements Listener
{
private InventoryManager _inventoryManager;
private RewardManager _rewardManager;
public GlobalGiveItem(InventoryManager inventoryManager, RewardManager rewardManager)
{
_inventoryManager = inventoryManager;
_rewardManager = rewardManager;
}
public enum GlobalItem
{
OLD_CHEST("Old Chest"),
ANCIENT_CHEST("Ancient Chest"),
MYTHICAL_CHEST("Mythical Chest"),
GAME_LOOT("Game Loot");
private String _invName;
GlobalItem(String invName)
{
_invName = invName;
}
public String getInvName()
{
return _invName;
}
}
@EventHandler
public void giveItem(final GlobalPacketEvent e)
{
if (!e.getCallerRank().has(Rank.ADMIN))
return;
if (e.getParts() == null || e.getParts().length < 1)
return;
if (!e.getParts()[0].equalsIgnoreCase("giveitem"))
return;
if (e.getParts().length != 3)
{
if (e.getCaller() != null)
UtilPlayer.message(e.getCaller(), F.main("Global", "/global giveitem <item> <amount>"));
return;
}
GlobalItem item = null;
try
{
item = GlobalItem.valueOf(e.getParts()[1]);
}
catch (Exception ex)
{
// Wrong item
if (e.getCaller() != null)
{
UtilPlayer.message(e.getCaller(), F.main("Global", "That GlobalItem type can't be found. Types:"));
String list = "";
for (GlobalItem i : GlobalItem.values())
list += i.toString() + " ";
UtilPlayer.message(e.getCaller(), C.cYellow + list);
}
return;
}
int amount = 1; // Default, shouldn't happen anyway.
try
{
amount = Integer.parseInt(e.getParts()[2]);
}
catch (Exception ex)
{
// Not a number
if (e.getCaller() != null)
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(e.getParts()[2]) + "] is not a valid number."));
return;
}
if (item.toString().contains("CHEST"))
{
for (final Player p : UtilServer.getPlayers())
{
final int fAmount = amount;
final GlobalItem fItem = item;
_inventoryManager.addItemToInventory(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " " + fItem.getInvName() + "(s)") + " from " + F.name(e.getCallerName()) + "."));
UtilTextMiddle.display(C.cYellow + fAmount + " " + fItem.getInvName() + "(s)", C.cGold + "received from " + e.getCallerName() + "!", p);
}
}, p, item.getInvName(), amount);
}
return;
}
else if (item.toString().equalsIgnoreCase("GAME_LOOT"))
{
for (final Player p : UtilServer.getPlayers())
{
Reward reward = _rewardManager.nextReward(p, null, false, RewardType.GameLoot, true);
reward.giveReward(RewardType.GameLoot, p, new Callback<RewardData>()
{
@Override
public void run(RewardData data)
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem("Game Loot") + " from " + F.name(e.getCallerName()) + "."));
UtilPlayer.message(p, F.main("Global", "You won " + F.elem(data.getFriendlyName()) + "!"));
UtilTextMiddle.display(C.cYellow + data.getFriendlyName(), C.cGold + "received from " + e.getCallerName() + "!", p);
}
});
}
}
}
}

View File

@ -0,0 +1,50 @@
package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
/**
* Created by William (WilliamTiger).
* 18/11/15
*/
public class GlobalRawr implements Listener
{
@EventHandler
public void globalRawr(GlobalPacketEvent e)
{
if (e.getParts() == null || e.getParts().length < 1)
return;
if (!e.getParts()[0].equalsIgnoreCase("rawr"))
return;
if (e.getParts().length < 2)
{
if (e.getCaller() != null)
UtilPlayer.message(e.getCaller(), F.main("Global", "/global rawr <msg>"));
return;
}
String msg = "";
for (int i = 1; i < e.getParts().length; i++)
{
msg += e.getParts()[i] + " ";
}
msg = msg.trim();
for (Player p : UtilServer.getPlayers())
{
UtilTextMiddle.display("§6§lRAWR!", "§e" + msg, p);
}
}
}

View File

@ -83,7 +83,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
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));
} }

View File

@ -1,32 +0,0 @@
package mineplex.core.message.commands;
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;
import mineplex.serverdata.commands.AnnouncementCommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class GlobalCommand extends CommandBase<MessageManager>
{
public GlobalCommand(MessageManager plugin)
{
super(plugin, Rank.ADMIN, "global");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args == null || args.length == 0)
{
Plugin.Help(caller);
}
else
{
new AnnouncementCommand(false, F.combine(args, 0, null, false)).publish();
}
}
}

View File

@ -149,7 +149,7 @@ public class Hub extends JavaPlugin implements IRelation
return true; return true;
} }
}); });
new GlobalPacketManager(this, clientManager, serverStatusManager); new GlobalPacketManager(this, clientManager, serverStatusManager, inventoryManager, donationManager, petManager, statsManager, giveawayManager);
//new Replay(this, packetHandler); //new Replay(this, packetHandler);
AprilFoolsManager.Initialize(this, clientManager, disguiseManager); AprilFoolsManager.Initialize(this, clientManager, disguiseManager);

View File

@ -147,10 +147,10 @@ public class Arcade extends JavaPlugin
cosmeticManager.setInterfaceSlot(7); cosmeticManager.setInterfaceSlot(7);
cosmeticManager.disableTeamArmor(); cosmeticManager.disableTeamArmor();
new GlobalPacketManager(this, _clientManager, serverStatusManager);
GiveawayManager giveawayManager = new GiveawayManager(this, _clientManager, serverStatusManager); GiveawayManager giveawayManager = new GiveawayManager(this, _clientManager, serverStatusManager);
new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager, _donationManager, petManager, statsManager, giveawayManager);
//Arcade Manager //Arcade Manager
PollManager pollManager = new PollManager(this, _clientManager, _donationManager); PollManager pollManager = new PollManager(this, _clientManager, _donationManager);
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager); _gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, _damageManager, statsManager, achievementManager, disguiseManager, creature, teleport, new Blood(this), chat, portal, preferenceManager, inventoryManager, packetHandler, cosmeticManager, projectileManager, petManager, hologramManager, webServerAddress, pollManager, npcmanager, giveawayManager);