diff --git a/Plugins/.idea/modules.xml b/Plugins/.idea/modules.xml index ea2ba738a..c3a2035a7 100644 --- a/Plugins/.idea/modules.xml +++ b/Plugins/.idea/modules.xml @@ -3,6 +3,7 @@ + diff --git a/Plugins/JedisTest/JedisTest.iml b/Plugins/JedisTest/JedisTest.iml new file mode 100644 index 000000000..c47b983ea --- /dev/null +++ b/Plugins/JedisTest/JedisTest.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/Main.java b/Plugins/JedisTest/src/ca/phinary/jedistest/Main.java new file mode 100644 index 000000000..de4481d4b --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/Main.java @@ -0,0 +1,93 @@ +package ca.phinary.jedistest; + +import javax.swing.*; + +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +import ca.phinary.jedistest.gui.ChatFrame; +import ca.phinary.jedistest.model.JedisChat; + +public class Main +{ + public static void main(String[] args) + { + SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + try + { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + catch (ClassNotFoundException e) + { + e.printStackTrace(); + } + catch (InstantiationException e) + { + e.printStackTrace(); + } + catch (IllegalAccessException e) + { + e.printStackTrace(); + } + catch (UnsupportedLookAndFeelException e) + { + e.printStackTrace(); + } + + ChatFrame chatFrame = new ChatFrame(); + final JedisChat jedisChat = new JedisChat(chatFrame, "phinaryTest", "10.33.53.16", 6379); + + chatFrame.addWindowListener(new WindowListener() + { + @Override + public void windowOpened(WindowEvent e) + { + + } + + @Override + public void windowClosing(WindowEvent e) + { + + } + + @Override + public void windowClosed(WindowEvent e) + { + jedisChat.close(); + } + + @Override + public void windowIconified(WindowEvent e) + { + + } + + @Override + public void windowDeiconified(WindowEvent e) + { + + } + + @Override + public void windowActivated(WindowEvent e) + { + + } + + @Override + public void windowDeactivated(WindowEvent e) + { + + } + }); + } + }); + + } + +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Chat.java b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Chat.java new file mode 100644 index 000000000..adfee2df0 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Chat.java @@ -0,0 +1,8 @@ +package ca.phinary.jedistest.api; + +public interface Chat +{ + public void addListener(ChatListener chatListener); + + public void clearListeners(); +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/api/ChatListener.java b/Plugins/JedisTest/src/ca/phinary/jedistest/api/ChatListener.java new file mode 100644 index 000000000..d650ac563 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/api/ChatListener.java @@ -0,0 +1,6 @@ +package ca.phinary.jedistest.api; + +public interface ChatListener +{ + public void onChat(String message); +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Console.java b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Console.java new file mode 100644 index 000000000..fa899383f --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Console.java @@ -0,0 +1,6 @@ +package ca.phinary.jedistest.api; + +public interface Console +{ + public void println(String line); +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/api/Messenger.java b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Messenger.java new file mode 100644 index 000000000..bf94b9e42 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/api/Messenger.java @@ -0,0 +1,9 @@ +package ca.phinary.jedistest.api; + +public interface Messenger +{ + public Chat getChat(); + + public Console getConsole(); + +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatFrame.java b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatFrame.java new file mode 100644 index 000000000..7ae888aa6 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatFrame.java @@ -0,0 +1,42 @@ +package ca.phinary.jedistest.gui; + +import javax.swing.*; + +import java.awt.*; + +import ca.phinary.jedistest.api.Chat; +import ca.phinary.jedistest.api.Console; +import ca.phinary.jedistest.api.Messenger; + +public class ChatFrame extends JFrame implements Messenger +{ + private ConsolePane _console; + private ChatPane _chat; + + public ChatFrame() + { + setLayout(new BorderLayout()); + + _console = new ConsolePane(); + _chat = new ChatPane(this); + + add(_console, BorderLayout.CENTER); + add(_chat, BorderLayout.SOUTH); + + setTitle("Phinary's Redis Chat"); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + pack(); + setLocationRelativeTo(null); + setVisible(true); + } + + public Console getConsole() + { + return _console; + } + + public Chat getChat() + { + return _chat; + } +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatPane.java b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatPane.java new file mode 100644 index 000000000..8234bff85 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ChatPane.java @@ -0,0 +1,60 @@ +package ca.phinary.jedistest.gui; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +import ca.phinary.jedistest.api.Chat; +import ca.phinary.jedistest.api.ChatListener; + +public class ChatPane extends JPanel implements ActionListener, Chat +{ + private ArrayList _chatListeners; + + private JTextField _textField; + private JButton _sendButton; + + public ChatPane(JFrame frame) + { + _chatListeners = new ArrayList(); + + _textField = new JTextField(); + _sendButton = new JButton("Send"); + + setBorder(new EmptyBorder(5, 10, 5, 10)); + setLayout(new BorderLayout()); + + add(_textField, BorderLayout.CENTER); + add(_sendButton, BorderLayout.EAST); + + _sendButton.addActionListener(this); + frame.getRootPane().setDefaultButton(_sendButton); + } + + @Override + public void actionPerformed(ActionEvent e) + { + String text = _textField.getText(); + for (ChatListener listener : _chatListeners) + { + listener.onChat(text); + } + _textField.setText(""); + } + + @Override + public void addListener(ChatListener chatListener) + { + _chatListeners.add(chatListener); + } + + @Override + public void clearListeners() + { + _chatListeners.clear(); + } +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ConsolePane.java b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ConsolePane.java new file mode 100644 index 000000000..2fb0293c3 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/gui/ConsolePane.java @@ -0,0 +1,33 @@ +package ca.phinary.jedistest.gui; + +import javax.swing.*; +import javax.swing.border.TitledBorder; +import java.awt.*; + +import ca.phinary.jedistest.api.Console; + +public class ConsolePane extends JPanel implements Console +{ + private JScrollPane _scrollPane; + private JTextArea _textArea; + + public ConsolePane() + { + _textArea = new JTextArea(); + _textArea.setEditable(false); + _textArea.setPreferredSize(new Dimension(800, 400)); + _scrollPane = new JScrollPane(_textArea); + _scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + + setLayout(new BorderLayout()); + setBorder(new TitledBorder("Console")); + + add(_scrollPane, BorderLayout.CENTER); + } + + public synchronized void println(String line) + { + _textArea.append(line + "\n"); + } + +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisChat.java b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisChat.java new file mode 100644 index 000000000..ff37cdf67 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisChat.java @@ -0,0 +1,51 @@ +package ca.phinary.jedistest.model; + +import ca.phinary.jedistest.api.Messenger; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; + +public class JedisChat +{ + private JedisPool _jedisPool; + private String _channel; + + private Messenger _messenger; + private JedisPublisher _publisher; + + public JedisChat(Messenger messenger, final String channel, String host, int port) + { + _jedisPool = new JedisPool(new JedisPoolConfig(), host, port); + _channel = channel; + _messenger = messenger; + + _publisher = new JedisPublisher(messenger.getConsole(), _jedisPool, channel); + _messenger.getChat().addListener(_publisher); + + startListen(); + } + + public void startListen() + { + _messenger.getConsole().println("Attempting to connect to redis server..."); + try + { + final Jedis jedis = _jedisPool.getResource(); + + _messenger.getConsole().println("Successfully connected!"); + + SubscribeWorker worker = new SubscribeWorker(_messenger.getConsole(), _jedisPool, _channel); + worker.execute(); + + } catch (Exception e) + { + _messenger.getConsole().println("Failed to connect to redis server!"); + } + } + + public void close() + { + System.out.println("close"); + _publisher.close(); + } +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisPublisher.java b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisPublisher.java new file mode 100644 index 000000000..445c338f3 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisPublisher.java @@ -0,0 +1,93 @@ +package ca.phinary.jedistest.model; + +import javax.swing.*; +import java.net.InetAddress; +import java.util.List; + +import ca.phinary.jedistest.api.ChatListener; +import ca.phinary.jedistest.api.Console; +import redis.clients.jedis.JedisPool; + +public class JedisPublisher implements ChatListener +{ + private Console _console; + private JedisPool _jedisPool; + private String _channelName; + + public JedisPublisher(Console console, JedisPool jedisPool, String channelName) + { + _console = console; + _jedisPool = jedisPool; + _channelName = channelName; + + sendConnectMessage(); + } + + @Override + public void onChat(String message) + { + String hostName = "Unknown"; + + try + { + hostName = InetAddress.getLocalHost().toString(); + } + catch(Exception e) { }; + + message(hostName + " > " + message); + } + + private void sendConnectMessage() + { + String hostName = "Unknown"; + + try + { + hostName = InetAddress.getLocalHost().toString(); + } + catch(Exception e) { }; + + message(hostName + " has connected to the channel"); + } + + public void close() + { + String hostName = "Unknown"; + + try + { + hostName = InetAddress.getLocalHost().toString(); + } + catch(Exception e) { }; + + + message(hostName + " has disconnected from the channel"); + } + + private void message(final String text) + { + new SwingWorker() + { + @Override + protected Void doInBackground() throws Exception + { + try + { + _jedisPool.getResource().publish(_channelName, text); + } + catch (Exception e) + { + publish("Failed to send message: " + e.getMessage()); + } + return null; + } + + @Override + protected void process(List chunks) + { + for (String s : chunks) + _console.println(s); + } + }.execute(); + } +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisSubscriber.java b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisSubscriber.java new file mode 100644 index 000000000..a1df8dedd --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/model/JedisSubscriber.java @@ -0,0 +1,49 @@ +package ca.phinary.jedistest.model; + +import redis.clients.jedis.JedisPubSub; + +public class JedisSubscriber extends JedisPubSub +{ + private SubscribeWorker _jedisWorker; + + public JedisSubscriber(SubscribeWorker jedisWorker) + { + _jedisWorker = jedisWorker; + } + + @Override + public void onMessage(String channel, String message) + { + _jedisWorker.onMessage(message); + } + + @Override + public void onPMessage(String s, String s1, String s2) + { + System.out.println("Pmessage:" + s + " " + s1 + " " + s2); + } + + @Override + public void onSubscribe(String s, int i) + { + System.out.println("Subcribe: s " + i); + } + + @Override + public void onUnsubscribe(String s, int i) + { + System.out.println("UnSubcribe: s " + i); + } + + @Override + public void onPUnsubscribe(String s, int i) + { + System.out.println("PUnSubcribe: s " + i); + } + + @Override + public void onPSubscribe(String s, int i) + { + System.out.println("Subcribe: s " + i); + } +} diff --git a/Plugins/JedisTest/src/ca/phinary/jedistest/model/SubscribeWorker.java b/Plugins/JedisTest/src/ca/phinary/jedistest/model/SubscribeWorker.java new file mode 100644 index 000000000..27b159657 --- /dev/null +++ b/Plugins/JedisTest/src/ca/phinary/jedistest/model/SubscribeWorker.java @@ -0,0 +1,56 @@ +package ca.phinary.jedistest.model; + +import javax.swing.*; + +import java.util.List; + +import ca.phinary.jedistest.api.Console; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; + +public class SubscribeWorker extends SwingWorker +{ + private Console _console; + private JedisPool _jedisPool; + private JedisSubscriber _jedisSubscriber; + private String _channel; + + public SubscribeWorker(Console console, JedisPool jedisPool, String channel) + { + _console = console; + _jedisPool = jedisPool; + _jedisSubscriber = new JedisSubscriber(this); + _channel = channel; + } + + @Override + protected Void doInBackground() throws Exception + { + publish("Attempting to connect to channel: " + _channel); + try + { + Jedis j = _jedisPool.getResource(); + publish("Successfully connected to channel!"); + _jedisPool.getResource().subscribe(_jedisSubscriber, _channel); + } catch (Exception e) + { + publish("Connection to channel failed:" + e.getMessage()); + } + + return null; + } + + public void onMessage(String s) + { + publish(s); + } + + @Override + protected void process(List chunks) + { + for (String s : chunks) + { + _console.println(s); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java index 36dbb45ba..bb59e7b50 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementManager.java @@ -7,6 +7,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -159,9 +161,14 @@ public class AchievementManager extends MiniPlugin public void giveInterfaceItem(Player player) { - if (!UtilGear.isMat(player.getInventory().getItem(_interfaceSlot), Material.CHEST)) + if (!UtilGear.isMat(player.getInventory().getItem(_interfaceSlot), Material.SKULL_ITEM)) { - player.getInventory().setItem(_interfaceSlot, ItemStackFactory.Instance.CreateStack(Material.PAPER, (byte)0, 1, ChatColor.RESET + C.cGreen + "/stats")); + ItemStack item = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte) 3, 1, ChatColor.RESET + C.cGreen + "/stats"); + SkullMeta meta = ((SkullMeta) item.getItemMeta()); + meta.setOwner(player.getName()); + item.setItemMeta(meta); + + player.getInventory().setItem(_interfaceSlot, item); UtilInv.Update(player); } @@ -170,7 +177,7 @@ public class AchievementManager extends MiniPlugin @EventHandler public void openShop(PlayerInteractEvent event) { - if (event.hasItem() && event.getItem().getType() == Material.PAPER) + if (event.hasItem() && event.getItem().getType() == Material.SKULL_ITEM) { event.setCancelled(true); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index cfb9a167e..747a48aa1 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -91,6 +91,7 @@ import mineplex.hub.modules.JumpManager; import mineplex.hub.modules.MapManager; import mineplex.hub.modules.NewsManager; import mineplex.hub.modules.ParkourManager; +import mineplex.hub.modules.PrivateServerManager; import mineplex.hub.modules.TextManager; import mineplex.hub.modules.UHCManager; import mineplex.hub.modules.VisibilityManager; @@ -201,6 +202,8 @@ public class HubManager extends MiniClientPlugin // NotificationManager notificationManager = new NotificationManager(plugin, clientManager, donationManager); // new MailManager(_plugin, notificationManager); + + new PrivateServerManager(_plugin); _ruleBook = ItemStackFactory.Instance.CreateStack(Material.WRITTEN_BOOK, (byte)0, 1, ChatColor.GREEN + "Rule Book", new String[] { }); BookMeta meta = (BookMeta)_ruleBook.getItemMeta(); @@ -544,7 +547,7 @@ public class HubManager extends MiniClientPlugin player.setHealth(20); //Rules - player.getInventory().setItem(6, _ruleBook); + player.getInventory().setItem(2, _ruleBook); //Scoreboard Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard(); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HostServerCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HostServerCommand.java new file mode 100644 index 000000000..ce26e1297 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/commands/HostServerCommand.java @@ -0,0 +1,22 @@ +package mineplex.hub.commands; + +import org.bukkit.entity.Player; + +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.hub.modules.PrivateServerManager; + +public class HostServerCommand extends CommandBase +{ + public HostServerCommand(PrivateServerManager plugin) + { + super(plugin, Rank.HERO, "hostserver"); + } + + @Override + public void Execute(Player caller, String[] args) + { + // TODO + Plugin.hostServer(caller); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/PrivateServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/PrivateServerManager.java new file mode 100644 index 000000000..12fc31c9a --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/PrivateServerManager.java @@ -0,0 +1,57 @@ +package mineplex.hub.modules; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.MiniPlugin; +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.hub.commands.HostServerCommand; + +public class PrivateServerManager extends MiniPlugin +{ + private int _interfaceSlot = 6; + private ItemStack _interfaceItem; + private boolean _giveInterfaceItem = true; + + public PrivateServerManager(JavaPlugin plugin) + { + super("Private Server", plugin); + + _interfaceItem = ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + "/hostserver"); + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + if (_giveInterfaceItem) + { + event.getPlayer().getInventory().setItem(_interfaceSlot, _interfaceItem); + } + } + + @EventHandler + public void openServer(PlayerInteractEvent event) + { + if (_interfaceItem.equals(event.getPlayer().getItemInHand())) + { + hostServer(event.getPlayer()); + } + } + + public void hostServer(Player player) + { + //do stuff???? + } + + @Override + public void AddCommands() + { + addCommand(new HostServerCommand(this)); + } +} diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java index d5a5773b4..5af129cd9 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerNpcPage.java @@ -247,7 +247,7 @@ public class ServerNpcPage extends ShopPageBase im } } - AddButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount + " Game" + (yellowCount == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 1 : yellowCount, false), new IButton() + AddButton(40, new ShopItem(Material.GOLD_BLOCK, C.cAqua + yellowCount + " Game" + (yellowCount == 1 ? "" : "s") + " In Progress", new String[]{MESSAGE_SPECTATE}, yellowCount > 64 ? 64 : yellowCount, false), new IButton() { @Override public void onClick(Player player, ClickType clickType) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitManager.java index 4ac084fd9..71be0fd63 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/KitManager.java @@ -92,7 +92,7 @@ public class KitManager } - /* { // Register rogue kits + { // Register rogue kits ArrayList children1 = new ArrayList(); ArrayList children2 = new ArrayList(); ArrayList children3 = new ArrayList(); @@ -118,7 +118,7 @@ public class KitManager children3.add(rogue6); children3.add(rogue7); - }*/ + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java index cbce7167b..04987424e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/SearchAndDestroy.java @@ -54,7 +54,9 @@ public class SearchAndDestroy extends TeamGame { super(manager, GameType.SearchAndDestroy, new Kit[0], new String[] { - "A test game of", "Search and Destroy" + "Detonate the enemies TNT", + "No respawns", + "Last team alive wins!" }); setKits(_kitManager.get_kits()); @@ -80,8 +82,8 @@ public class SearchAndDestroy extends TeamGame public boolean canEvolve(Player player) { - return true;// (!_evolves.containsKey(player.getName()) || _evolves.get(player.getName()) < 2) - // && _kills.containsKey(player.getName()) && _kills.get(player.getName()) >= 2; + return true;//(!_evolves.containsKey(player.getName()) || _evolves.get(player.getName()) < 2) + // && _kills.containsKey(player.getName()) && _kills.get(player.getName()) >= 2; } public void onEvolve(Player player) @@ -120,8 +122,11 @@ public class SearchAndDestroy extends TeamGame } } }.runTaskTimer(Manager.GetPlugin(), 0, 0); + _evolves.put(player.getName(), newTier); - _kills.put(player.getName(), _kills.get(player.getName()) - 2); + + if (_kills.containsKey(player.getName())) + _kills.put(player.getName(), _kills.get(player.getName()) - 2); } @EventHandler @@ -306,7 +311,10 @@ public class SearchAndDestroy extends TeamGame Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); if (player == null) return; + + addKill(player, 1); + for (CombatComponent log : event.GetLog().GetAttackers()) { if (event.GetLog().GetKiller() != null && log.equals(event.GetLog().GetKiller())) @@ -323,10 +331,14 @@ public class SearchAndDestroy extends TeamGame private void addKill(Player player, float amount) { boolean canEvolve = this.canEvolve(player); + this._kills.put(player.getName(), (_kills.containsKey(player.getName()) ? _kills.get(player.getName()) : 0) + 1); + if (canEvolve(player) != canEvolve) { - UtilTextMiddle.display(ChatColor.GREEN + "Evolution Available", null); + UtilTextMiddle.display(null, ChatColor.GREEN + "Evolution Available", 10, 60, 10, player); + UtilPlayer.message(player, ChatColor.GREEN + "Evolution Available"); + player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitEvade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitEvade.java index d84930dff..9ed8e2425 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitEvade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitEvade.java @@ -28,7 +28,7 @@ public class KitEvade extends Kit }, new Perk[] { new PerkSpeed(1), new PerkShadowmeld(), new PerkEvade() - }, EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + }, EntityType.ZOMBIE, new ItemStack(Material.DIAMOND_SWORD)); } @Override @@ -36,7 +36,7 @@ public class KitEvade extends Kit { PlayerInventory inv = player.getInventory(); inv.setItem(2, new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); - inv.addItem(new ItemBuilder(Material.IRON_SWORD) + inv.addItem(new ItemBuilder(Material.DIAMOND_SWORD) .setTitle(C.cGreen + "Hold Block" + C.cWhite + " - " + C.cYellow + "Evade").setUnbreakable(true).build()); inv.setArmorContents(new ItemStack[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitFlash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitFlash.java index 946729b18..bc0143f68 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitFlash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitFlash.java @@ -28,7 +28,7 @@ public class KitFlash extends Kit }, new Perk[] { new PerkSpeed(1), new PerkShadowmeld(), new PerkFlash(1, false) - }, EntityType.ZOMBIE, new ItemStack(Material.IRON_AXE)); + }, EntityType.ZOMBIE, new ItemStack(Material.DIAMOND_AXE)); } @Override @@ -36,7 +36,7 @@ public class KitFlash extends Kit { PlayerInventory inv = player.getInventory(); inv.setItem(2, new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); - inv.addItem(new ItemBuilder(Material.IRON_AXE) + inv.addItem(new ItemBuilder(Material.DIAMOND_AXE) .setTitle(C.cGreen + "Right-Click" + C.cWhite + " - " + C.cYellow + "Flash").setUnbreakable(true).build()); inv.setArmorContents(new ItemStack[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitMultiFlash.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitMultiFlash.java index 9ba218d8d..891b0736f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitMultiFlash.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitMultiFlash.java @@ -28,7 +28,7 @@ public class KitMultiFlash extends Kit }, new Perk[] { new PerkSpeed(1), new PerkShadowmeld(), new PerkFlash(4, false) - }, EntityType.ZOMBIE, new ItemStack(Material.IRON_AXE)); + }, EntityType.ZOMBIE, new ItemStack(Material.DIAMOND_AXE)); } @Override @@ -36,7 +36,7 @@ public class KitMultiFlash extends Kit { PlayerInventory inv = player.getInventory(); inv.setItem(2, new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); - inv.addItem(new ItemBuilder(Material.IRON_AXE) + inv.addItem(new ItemBuilder(Material.DIAMOND_AXE) .setTitle(C.cGreen + "Right-Click" + C.cWhite + " - " + C.cYellow + "Flash").setUnbreakable(true).build()); inv.setArmorContents(new ItemStack[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitPhaseBlast.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitPhaseBlast.java index f8f6e9d68..73c7ea3d7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitPhaseBlast.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitPhaseBlast.java @@ -28,7 +28,7 @@ public class KitPhaseBlast extends Kit }, new Perk[] { new PerkSpeed(1), new PerkShadowmeld(), new PerkFlash(1, true) - }, EntityType.ZOMBIE, new ItemStack(Material.IRON_AXE)); + }, EntityType.ZOMBIE, new ItemStack(Material.DIAMOND_AXE)); } @Override @@ -36,7 +36,7 @@ public class KitPhaseBlast extends Kit { PlayerInventory inv = player.getInventory(); inv.setItem(2, new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); - inv.addItem(new ItemBuilder(Material.IRON_AXE) + inv.addItem(new ItemBuilder(Material.DIAMOND_AXE) .setTitle(C.cGreen + "Right-Click" + C.cWhite + " - " + C.cYellow + "Flash").setUnbreakable(true).build()); inv.setArmorContents(new ItemStack[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRewind.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRewind.java index 638316330..c07fe9193 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRewind.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRewind.java @@ -31,7 +31,7 @@ public class KitRewind extends Kit { new PerkSpeed(1), new PerkShadowmeld(), new PerkEvade(), new PerkRewind() - }, EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + }, EntityType.ZOMBIE, new ItemStack(Material.DIAMOND_SWORD)); } @Override @@ -39,7 +39,7 @@ public class KitRewind extends Kit { PlayerInventory inv = player.getInventory(); inv.setItem(2, new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); - inv.addItem(new ItemBuilder(Material.IRON_SWORD) + inv.addItem(new ItemBuilder(Material.DIAMOND_SWORD) .setTitle(C.cGreen + "Hold Block" + C.cWhite + " - " + C.cYellow + "Evade").setUnbreakable(true).build()); inv.addItem(new ItemBuilder(Material.NETHER_STAR) .setTitle(C.cGreen + "Right-Click" + C.cWhite + " - " + C.cYellow + "Rewind").setUnbreakable(true).build()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRogue.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRogue.java index 832b7f77c..4fd266413 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRogue.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitRogue.java @@ -29,7 +29,7 @@ public class KitRogue extends Kit { new PerkSpeed(1), new PerkShadowmeld(), - }, EntityType.ZOMBIE, new ItemStack(Material.IRON_AXE)); + }, EntityType.ZOMBIE, new ItemStack(Material.DIAMOND_AXE)); } @Override @@ -37,7 +37,7 @@ public class KitRogue extends Kit { PlayerInventory inv = player.getInventory(); inv.setItem(2, new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); - inv.addItem(new ItemBuilder(Material.IRON_AXE).setTitle(C.cGray + "No Ability").setUnbreakable(true).build()); + inv.addItem(new ItemBuilder(Material.DIAMOND_AXE).setTitle(C.cGray + "No Ability").setUnbreakable(true).build()); inv.setItem(9, new ItemStack(Material.ARROW, 1)); inv.setArmorContents(new ItemStack[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitWraith.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitWraith.java index 7735c15d3..d2e6f4d7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitWraith.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/rogue/KitWraith.java @@ -28,7 +28,7 @@ public class KitWraith extends Kit { new PerkSpeed(1), new PerkWraith(), new PerkEvade() - }, EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); + }, EntityType.ZOMBIE, new ItemStack(Material.DIAMOND_SWORD)); } @Override @@ -36,7 +36,7 @@ public class KitWraith extends Kit { PlayerInventory inv = player.getInventory(); inv.setItem(2, new ItemBuilder(Material.BLAZE_POWDER).setTitle(ChatColor.GOLD + "Fuse").build()); - inv.addItem(new ItemBuilder(Material.IRON_SWORD) + inv.addItem(new ItemBuilder(Material.DIAMOND_SWORD) .setTitle(C.cGreen + "Hold Block" + C.cWhite + " - " + C.cYellow + "Evade").setUnbreakable(true).build()); inv.setItem(8, new ItemBuilder(Material.LEATHER_CHESTPLATE).setColor(this.Manager.GetGame().GetTeam(player).GetColorBase()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitBreaker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitBreaker.java index 8ce4ad072..6fbd3b36f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitBreaker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/searchanddestroy/kits/trooper/KitBreaker.java @@ -22,7 +22,8 @@ public class KitBreaker extends Kit { super(manager, "Breaker", KitAvailability.Hide, new String[] { - "Takedown - You leap forwards.", "If you collide with anyone midair, they take damage and knockback." + "Takedown - You leap forwards.", + "If you collide with anyone midair, they take damage and knockback." }, new Perk[] { new PerkTakedown() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/PlayerHeadButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/PlayerHeadButton.java new file mode 100644 index 000000000..a9f6a2283 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/button/PlayerHeadButton.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.gui.privateServer.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.gui.privateServer.page.MenuPage; + +public class PlayerHeadButton implements IButton +{ + private ArcadeManager _arcadeManager; + private MenuPage _menuPage; + + public PlayerHeadButton(ArcadeManager arcadeManager, MenuPage menuPage) + { + _arcadeManager = arcadeManager; + _menuPage = menuPage; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + int maxPlayers = _arcadeManager.GetServerConfig().MaxPlayers; + int newMax; + + int maxCap = _arcadeManager.GetGameHostManager().getMaxPlayerCap(); + + if (clickType.isLeftClick()) + newMax = ++maxPlayers > maxCap ? maxCap : maxPlayers; + else + newMax = --maxPlayers < 2 ? 2 : maxPlayers; + + _arcadeManager.GetServerConfig().MaxPlayers = newMax; + _menuPage.Refresh(); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java index 29af5f378..19831dffa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gui/privateServer/page/MenuPage.java @@ -1,11 +1,15 @@ package nautilus.game.arcade.gui.privateServer.page; +import java.util.ArrayList; + import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; import mineplex.core.shop.item.ShopItem; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; @@ -13,6 +17,7 @@ import nautilus.game.arcade.gui.privateServer.button.BanButton; import nautilus.game.arcade.gui.privateServer.button.EditRotationButton; import nautilus.game.arcade.gui.privateServer.button.GiveAdminButton; import nautilus.game.arcade.gui.privateServer.button.KillButton; +import nautilus.game.arcade.gui.privateServer.button.PlayerHeadButton; import nautilus.game.arcade.gui.privateServer.button.RemoveAdminButton; import nautilus.game.arcade.gui.privateServer.button.SetGameButton; import nautilus.game.arcade.gui.privateServer.button.OptionsButton; @@ -32,7 +37,7 @@ public class MenuPage extends BasePage protected void BuildPage() { ItemStack ownerHead = getOwnerHead(); - setItem(4, ownerHead); + AddButton(4, getOwnerHead(), new PlayerHeadButton(Plugin, this)); boolean host = _manager.isHost(Player); @@ -71,8 +76,22 @@ public class MenuPage extends BasePage AddButton(host ? 6 + 18 : 7 + 18, new ShopItem(Material.WATER_BUCKET, "Un-Remove Player", new String[] {}, 1, false), unbanButton); } - private ItemStack getOwnerHead() + private ShopItem getOwnerHead() { - return getPlayerHead(Plugin.GetHost(), ChatColor.RESET + "Host: " + ChatColor.YELLOW + Plugin.GetHost()); + String title = C.cGreen + C.Bold + Plugin.GetHost() + "'s Mineplex Private Server"; + ItemStack head = getPlayerHead(Plugin.GetHost(), ChatColor.RESET + title); + ArrayList lore = new ArrayList(); + lore.add(" "); + lore.add(ChatColor.RESET + C.cYellow + "Server Name: " + C.cWhite + Plugin.GetPlugin().getConfig().getString("serverstatus.name")); + lore.add(ChatColor.RESET + C.cYellow + "Players Online: " + C.cWhite + UtilServer.getPlayers().length); + lore.add(ChatColor.RESET + C.cYellow + "Players Max: " + C.cWhite + Plugin.GetServerConfig().MaxPlayers); + lore.add(" "); + lore.add(ChatColor.RESET + "Left-Click to increase Max Players"); + lore.add(ChatColor.RESET + "Right-Click to decrease Max Players"); + ItemMeta meta = head.getItemMeta(); + meta.setLore(lore); + head.setItemMeta(meta); + + return new ShopItem(head, title, title, 1, false, false); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java index ac81a43aa..2fb215aed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameHostManager.java @@ -21,6 +21,7 @@ import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.gui.privateServer.PrivateServerShop; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -175,15 +176,15 @@ public class GameHostManager implements Listener if (Manager.GetGame() == null) return; - if (UtilGear.isMat(player.getInventory().getItem(5), Material.BOOK_AND_QUILL)) + if (UtilGear.isMat(player.getInventory().getItem(5), Material.SPECKLED_MELON)) return; - player.getInventory().setItem(7, ItemStackFactory.Instance.CreateStack(Material.BLAZE_POWDER, (byte)0, 1, C.cGreen + C.Bold + "/menu")); + player.getInventory().setItem(7, ItemStackFactory.Instance.CreateStack(Material.SPECKLED_MELON, (byte)0, 1, C.cGreen + C.Bold + "/menu")); } private void removeAdminItem(Player player) { - if (player.getInventory().getItem(7).getType() == Material.BLAZE_POWDER) + if (player.getInventory().getItem(7).getType() == Material.SPECKLED_MELON) { player.getInventory().setItem(7, null); } @@ -222,7 +223,7 @@ public class GameHostManager implements Listener if (!isAdmin(event.getPlayer(), true)) return; - if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.BLAZE_POWDER)) + if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.SPECKLED_MELON)) return; openMenu(event.getPlayer()); @@ -403,6 +404,16 @@ public class GameHostManager implements Listener Manager.GetServerConfig().PlayerKickIdle = true; Manager.GetServerConfig().TeamForceBalance = true; } + + public int getMaxPlayerCap() + { + if (hasRank(Rank.LEGEND)) + return 40; + else if (hasRank(Rank.HERO)) + return 12; + else + return 4; + } @EventHandler public void setHostDebug(PlayerCommandPreprocessEvent event) @@ -425,4 +436,12 @@ public class GameHostManager implements Listener event.setCancelled(true); } + + @EventHandler + public void playerJoin(PlayerJoinEvent event) + { + String serverName = Manager.GetPlugin().getConfig().getString("serverstatus.name"); + UtilPlayer.message(event.getPlayer(), ChatColor.BOLD + "Welcome to Mineplex Private Servers!"); + UtilPlayer.message(event.getPlayer(), C.Bold + "Friends can connect with " + C.cGreen + C.Bold + "/server " + serverName); + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java index 1d8aed81c..f63c1d54c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameLobbyManager.java @@ -108,6 +108,7 @@ public class GameLobbyManager implements Listener, IPacketHandler private NautHashMap _kitMap = new NautHashMap(); private int _oldPlayerCount = 0; + private int _oldMaxPlayerCount = 0; // Used for scoreboard when max player count changes private boolean _handlingPacket = false; @@ -965,8 +966,8 @@ public class GameLobbyManager implements Listener, IPacketHandler objective.getScore(C.cYellow + "Players").setScore(line--); - // Remove old - entry.getValue().resetScores(_oldPlayerCount + "/" + Manager.GetPlayerFull()); + // Remove Old + entry.getValue().resetScores(_oldPlayerCount + "/" + _oldMaxPlayerCount); // Set new objective.getScore(UtilServer.getPlayers().length + "/" + Manager.GetPlayerFull()).setScore(line--); @@ -1027,6 +1028,7 @@ public class GameLobbyManager implements Listener, IPacketHandler } _oldPlayerCount = UtilServer.getPlayers().length; + _oldMaxPlayerCount = Manager.GetPlayerFull(); } private String GetKitCustomName(Player player, Game game, LobbyEnt ent)