diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java index 4b033077f..fa23d5f50 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/portal/Portal.java @@ -1,43 +1,17 @@ package mineplex.core.portal; -import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; import java.io.IOException; -import java.io.InputStreamReader; -import java.util.AbstractMap; import java.util.HashSet; -import java.util.Map.Entry; - import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.block.Action; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; - import mineplex.core.MiniPlugin; -import mineplex.core.arena.Region; -import mineplex.core.common.Rank; -import mineplex.core.common.util.F; -import mineplex.core.common.util.NautHashMap; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.portal.commands.PortalCommand; public class Portal extends MiniPlugin { - private NautHashMap _portalServerMap = new NautHashMap(); - private NautHashMap> _portalSetupMap = new NautHashMap>(); private HashSet _connectingPlayers = new HashSet(); public Portal(JavaPlugin plugin) @@ -45,51 +19,6 @@ public class Portal extends MiniPlugin super("Portal", plugin); Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord"); - - LoadPortals(); - } - - public void AddCommands() - { - AddCommand(new PortalCommand(this)); - } - - @EventHandler - public void OnPlayerMove(PlayerMoveEvent event) - { - for (Region region : _portalServerMap.keySet()) - { - if (region.Contains(event.getTo().toVector())) - { - SendPlayerToServer(event.getPlayer(), _portalServerMap.get(region)); - break; - } - } - } - - @EventHandler - public void OnPlayerInteract(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (player.isOp() && _portalSetupMap.containsKey(player.getName())) - { - if (player.getItemInHand() != null && player.getItemInHand().getType() == Material.BLAZE_ROD) - { - if (event.getAction() == Action.LEFT_CLICK_BLOCK) - { - _portalSetupMap.put(player.getName(), new AbstractMap.SimpleEntry(event.getClickedBlock().getLocation(), null)); - player.sendMessage(F.main(GetName(), "Set first point.")); - } - else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) - { - _portalSetupMap.get(player.getName()).setValue(event.getClickedBlock().getLocation()); - player.sendMessage(F.main(GetName(), "Set second point.")); - } - - event.setCancelled(true); - } - } } public void SendAllPlayers(String serverName) @@ -140,179 +69,4 @@ public class Portal extends MiniPlugin } }, 20L); } - - public void Help(Player caller, String message) - { - UtilPlayer.message(caller, F.main(_moduleName, "Commands List:")); - UtilPlayer.message(caller, F.help("/portal toggle", "Turn off and on Portal mode.", Rank.ADMIN)); - UtilPlayer.message(caller, F.help("/portal create ", "Creates portal to name server.", Rank.OWNER)); - - if (message != null) - UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message)); - } - - public void Help(Player caller) - { - Help(caller, null); - } - - public void LoadPortals() - { - FileInputStream fstream = null; - BufferedReader br = null; - - try - { - File portalsFile = new File("portals.dat"); - - if (portalsFile.exists()) - { - fstream = new FileInputStream(portalsFile); - br = new BufferedReader(new InputStreamReader(fstream)); - - String line = br.readLine(); - - while (line != null) - { - Region region = ParseRegion(line); - - _portalServerMap.put(region, region.GetName()); - - line = br.readLine(); - } - } - } - catch (Exception e) - { - System.out.println(F.main(GetName(), "Error parsing portals file.")); - } - finally - { - if (br != null) - { - try - { - br.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - if (fstream != null) - { - try - { - fstream.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - } - - public void SavePortals() - { - FileWriter fstream = null; - BufferedWriter out = null; - - try - { - fstream = new FileWriter("portals.dat"); - out = new BufferedWriter(fstream); - - for (Region region : _portalServerMap.keySet()) - { - out.write(region.GetMinimumPoint().getBlockX() + " " + region.GetMinimumPoint().getBlockY() + " " + region.GetMinimumPoint().getBlockZ() + ", " + region.GetMaximumPoint().getBlockX() + " " + region.GetMaximumPoint().getBlockY() + " " + region.GetMaximumPoint().getBlockZ() + ", " + region.GetName()); - out.newLine(); - } - - out.close(); - } - catch (Exception e) - { - System.err.println("Portals Save Error: " + e.getMessage()); - } - finally - { - if (out != null) - { - try - { - out.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - if (fstream != null) - { - try - { - fstream.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - } - - private Region ParseRegion(String value) - { - String [] parts = value.split(","); - - Vector pointOne = ParseVector(parts[0].trim()); - Vector pointTwo = ParseVector(parts[1].trim()); - - return new Region(parts.length == 3 ? parts[2].trim() : "Null", pointOne, pointTwo); - } - - private Vector ParseVector(String vectorString) - { - Vector vector = new Vector(); - - String [] parts = vectorString.split(" "); - - vector.setX(Double.parseDouble(parts[0])); - vector.setY(Double.parseDouble(parts[1])); - vector.setZ(Double.parseDouble(parts[2])); - - return vector; - } - - public void ToggleSetupAdmin(Player caller) - { - if (_portalSetupMap.containsKey(caller.getName())) - { - _portalSetupMap.remove(caller.getName()); - caller.sendMessage(F.main(GetName(), "Disabled Portal Setup.")); - } - else - { - _portalSetupMap.put(caller.getName(), new AbstractMap.SimpleEntry(null, null)); - caller.sendMessage(F.main(GetName(), "Enabled Portal Setup.")); - } - } - - public boolean IsAdminPortalValid(Player caller) - { - return _portalSetupMap.containsKey(caller.getName()) && _portalSetupMap.get(caller.getName()).getKey() != null && _portalSetupMap.get(caller.getName()).getValue() != null; - } - - public void CreatePortal(Player caller, String name) - { - Vector first = _portalSetupMap.get(caller.getName()).getKey().toVector(); - Vector second = _portalSetupMap.get(caller.getName()).getValue().toVector(); - - _portalServerMap.put(new Region(name, first, second), name); - caller.sendMessage(F.main(GetName(), "Created '" + name + "' portal at (" + first.toString() + ") and (" + second.toString() + ".")); - SavePortals(); - } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/CreateCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/CreateCommand.java deleted file mode 100644 index 18757786a..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/CreateCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package mineplex.core.portal.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.portal.Portal; - -public class CreateCommand extends CommandBase -{ - public CreateCommand(Portal plugin) - { - super(plugin, Rank.ADMIN, "create"); - } - - @Override - public void Execute(final Player caller, String[] args) - { - if (args == null) - { - Plugin.Help(caller); - } - else - { - if (!Plugin.IsAdminPortalValid(caller)) - { - Plugin.Help(caller, "You don't have two points set. Use Blaze rod to set them."); - } - else - { - String serverName = args[0]; - - Plugin.CreatePortal(caller, serverName); - } - } - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/PortalCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/PortalCommand.java deleted file mode 100644 index 22864f2f4..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/PortalCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -package mineplex.core.portal.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.MultiCommandBase; -import mineplex.core.common.Rank; -import mineplex.core.portal.Portal; - -public class PortalCommand extends MultiCommandBase -{ - public PortalCommand(Portal plugin) - { - super(plugin, Rank.ADMIN, "portal"); - - AddCommand(new CreateCommand(plugin)); - AddCommand(new ToggleCommand(plugin)); - } - - @Override - protected void Help(Player caller, String[] args) - { - Plugin.Help(caller); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ToggleCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ToggleCommand.java deleted file mode 100644 index 0334403ea..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/portal/commands/ToggleCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.core.portal.commands; - -import org.bukkit.entity.Player; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; -import mineplex.core.portal.Portal; - -public class ToggleCommand extends CommandBase -{ - public ToggleCommand(Portal plugin) - { - super(plugin, Rank.ADMIN, "toggle"); - } - - @Override - public void Execute(final Player caller, String[] args) - { - Plugin.ToggleSetupAdmin(caller); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java index 214906043..f1584c9b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/status/ServerStatusManager.java @@ -9,8 +9,6 @@ import java.util.Enumeration; import java.util.List; import org.bukkit.Bukkit; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.event.EventHandler; import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.plugin.java.JavaPlugin; @@ -27,6 +25,7 @@ public class ServerStatusManager extends MiniPlugin private LagMeter _lagMeter; private boolean _alternateSeconds; + private boolean _enabled = true; public ServerStatusManager(JavaPlugin plugin, LagMeter lagMeter) { @@ -34,6 +33,9 @@ public class ServerStatusManager extends MiniPlugin _lagMeter = lagMeter; + if (new File("IgnoreUpdates.dat").exists()) + _enabled = false; + ServerListPingEvent event = new ServerListPingEvent(null, plugin.getServer().getMotd(), plugin.getServer().getOnlinePlayers().length, plugin.getServer().getMaxPlayers()); GetPluginManager().callEvent(event); @@ -88,7 +90,9 @@ public class ServerStatusManager extends MiniPlugin plugin.getConfig().getString("serverstatus.group"), address + ":" + _plugin.getServer().getPort(), event.getMaxPlayers() ); - _repository.initialize(); + + if (_enabled) + _repository.initialize(); } catch (Exception ex) { @@ -143,6 +147,9 @@ public class ServerStatusManager extends MiniPlugin if (event.getType() != UpdateType.SEC) return; + if (!_enabled) + return; + _alternateSeconds = !_alternateSeconds; if (!_alternateSeconds) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index d6e06f473..8d524ab69 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -26,6 +26,7 @@ import mineplex.core.task.TaskManager; import mineplex.core.teleport.Teleport; import mineplex.core.updater.FileUpdater; import mineplex.core.updater.Updater; +import mineplex.hub.modules.StackerManager; import mineplex.hub.party.PartyManager; import mineplex.hub.server.ServerManager; import mineplex.minecraft.game.classcombat.Class.ClassManager; @@ -79,8 +80,8 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation PacketHandler packetHandler = new PacketHandler(this); Portal portal = new Portal(this); PartyManager partyManager = new PartyManager(this, clientManager); - new HubManager(this, clientManager, donationManager, new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager); - new ServerManager(this, clientManager, donationManager, portal, partyManager, new ServerStatusManager(this, new LagMeter(this, clientManager))); + HubManager hubManager = new HubManager(this, clientManager, donationManager, new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager); + new ServerManager(this, clientManager, donationManager, portal, partyManager, new ServerStatusManager(this, new LagMeter(this, clientManager)), hubManager, new StackerManager(hubManager)); new Chat(this, clientManager); new MemoryFix(this); new FileUpdater(this, portal); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java index 4e3a8a8c3..bd7d7bbd5 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/HubManager.java @@ -66,7 +66,6 @@ public class HubManager extends MiniClientPlugin private PartyManager _partyManager; private Portal _portal; - private TutorialManager _tutorialManager; private TextManager _textCreator; private ParkourManager _parkour; @@ -102,7 +101,6 @@ public class HubManager extends MiniClientPlugin new MapManager(this); new WorldManager(this); new JumpManager(this); - new StackerManager(this); _partyManager = partyManager; _tutorialManager = new TutorialManager(this, donationManager, taskManager, _textCreator); @@ -212,18 +210,10 @@ public class HubManager extends MiniClientPlugin { if (((LivingEntity)entity).isCustomNameVisible() && ((LivingEntity)entity).getCustomName() != null) { - if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("play minekart plz")) + if (ChatColor.stripColor(((LivingEntity)entity).getCustomName()).equalsIgnoreCase("Minekart")) { _disguiseManager.disguise(new DisguisePlayer(entity, ChatColor.YELLOW + "MineKart")); } - else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("defek7")) - _disguiseManager.disguise(new DisguisePlayer(entity, "defek7")); - else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("chiss")) - _disguiseManager.disguise(new DisguisePlayer(entity, "Chiss")); - else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("Sterling_")) - _disguiseManager.disguise(new DisguisePlayer(entity, "sterling_")); - else if (((LivingEntity)entity).getCustomName().equalsIgnoreCase("Spu_")) - _disguiseManager.disguise(new DisguisePlayer(entity, "Spu_")); } } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java index a16728243..5b278f455 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/ParkourManager.java @@ -12,6 +12,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.entity.EntityCombustEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.player.PlayerInteractEntityEvent; @@ -99,6 +100,15 @@ public class ParkourManager extends MiniPlugin } } + @EventHandler + public void combustPrevent(EntityCombustEvent event) + { + if (event.getEntity() instanceof Player) + { + event.setCancelled(true); + } + } + @EventHandler public void LavaReturn(EntityDamageEvent event) { @@ -108,7 +118,6 @@ public class ParkourManager extends MiniPlugin event.getEntity().eject(); event.getEntity().leaveVehicle(); event.getEntity().teleport(_lavaParkourReturn); - event.getEntity().setFireTicks(0); } else @@ -117,6 +126,27 @@ public class ParkourManager extends MiniPlugin event.setCancelled(true); } + @EventHandler + public void preventCarriers(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + return; + + for (Player player : UtilServer.getPlayers()) + { + if (InParkour(player)) + { + if (player.getVehicle() != null || player.getPassenger() != null) + { + player.eject(); + player.leaveVehicle(); + + UtilPlayer.message(player, F.main("Parkour", "You can't run parkours while stacked!")); + } + } + } + } + @EventHandler public void LavaBlockReturn(UpdateEvent event) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java index e02fb28f5..4dd239381 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/StackerManager.java @@ -245,6 +245,9 @@ public class StackerManager extends MiniPlugin implements IThrown { if (target == null) return; + + if (target.getCustomName() != null || (target.getPassenger() != null && target.getPassenger() instanceof LivingEntity && ((LivingEntity)target.getPassenger()).getCustomName() != null)) + return; //Velocity UtilAction.velocity(target, UtilAlg.getTrajectory2d(data.GetThrown(), target), 1, true, 0.8, 0, 10, true); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/TextManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/TextManager.java index 726b13eb2..bbddafa93 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/TextManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/TextManager.java @@ -51,7 +51,9 @@ public class TextManager extends MiniPlugin "DEATH TAG", "TURF WARS", "DRAGONS", - "RUNNER" + "RUNNER", + "BACON BRAWL", + "SQUID SAUCE" }; CreateText(); @@ -82,10 +84,10 @@ public class TextManager extends MiniPlugin UtilText.MakeText("THE BRIDGES", locSurvival.clone().add(-15, 14, 0), faceSurvival, 159, (byte)4, TextAlign.CENTER); UtilText.MakeText("THE BRIDGES", locSurvival.clone().add(-16, 14, 0), faceSurvival, 159, (byte)15, TextAlign.CENTER); - + /* UtilText.MakeText("SURVIVAL GAMES", locSurvival.clone().add(-15, 21, 0), faceSurvival, 159, (byte)1, TextAlign.CENTER); UtilText.MakeText("SURVIVAL GAMES", locSurvival.clone().add(-16, 21, 0), faceSurvival, 159, (byte)15, TextAlign.CENTER); - + */ //Other UtilText.MakeText("CLASSICS", locClassics, faceOther, 159, (byte)5, TextAlign.CENTER); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index cd08a5b10..5c5ec2bd3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -1,13 +1,13 @@ package mineplex.hub.server; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; -import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; +import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -17,9 +17,14 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityPortalEnterEvent; +import org.bukkit.event.entity.EntityPortalEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; @@ -28,16 +33,21 @@ import mineplex.core.common.util.C; import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime.TimeUnit; import mineplex.core.donation.DonationManager; import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.portal.Portal; +import mineplex.core.recharge.Recharge; import mineplex.core.status.ServerStatusData; import mineplex.core.status.ServerStatusManager; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.hub.HubManager; +import mineplex.hub.modules.StackerManager; import mineplex.hub.party.Party; import mineplex.hub.party.PartyManager; import mineplex.hub.server.command.ServerNpcCommand; @@ -51,19 +61,22 @@ public class ServerManager extends MiniPlugin private Portal _portal; private PartyManager _partyManager; private ServerStatusManager _statusManager; + private HubManager _hubManager; + private StackerManager _stackerManager; private NautHashMap> _serverNpcMap = new NautHashMap>(); + private NautHashMap _serverNpcTag = new NautHashMap(); private NautHashMap _serverNpcShopMap = new NautHashMap(); private NautHashMap _serverInfoMap = new NautHashMap(); private NautHashMap _serverUpdate = new NautHashMap(); + private NautHashMap _serverPortalLocations = new NautHashMap(); private ServerNpcShop _quickShop; - private boolean _loading = false; private boolean _alternateUpdateFire = false; private boolean _retrieving = false; - public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager) + public ServerManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, Portal portal, PartyManager partyManager, ServerStatusManager statusManager, HubManager hubManager, StackerManager stackerManager) { super("Server Manager", plugin); @@ -72,6 +85,8 @@ public class ServerManager extends MiniPlugin _portal = portal; _partyManager = partyManager; _statusManager = statusManager; + _hubManager = hubManager; + _stackerManager = stackerManager; plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord"); @@ -86,6 +101,78 @@ public class ServerManager extends MiniPlugin AddCommand(new ServerNpcCommand(this)); } + @EventHandler(priority = EventPriority.LOW) + public void playerPortalEvent(PlayerPortalEvent event) + { + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOW) + public void entityPortalEvent(EntityPortalEvent event) + { + event.setCancelled(true); + } + + @EventHandler(priority = EventPriority.LOW) + public void playerCheckPortalEvent(EntityPortalEnterEvent event) + { + if (!(event.getEntity() instanceof Player)) + { + UtilAction.velocity(event.getEntity(), UtilAlg.getTrajectory(event.getEntity().getLocation(), _hubManager.GetSpawn()), 1, true, 0.8, 0, 1, true); + return; + } + + Player player = (Player)event.getEntity(); + + if (!_stackerManager.CanPortal(player)) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), _hubManager.GetSpawn()), 1, true, 0.8, 0, 1, true); + return; + } + + if (!Recharge.Instance.use(player, "Portal Server", 1000, false)) + return; + + String serverName = _serverPortalLocations.get(player.getLocation().getBlock().getLocation().toVector()); + + if (serverName != null) + { + List serverList = new ArrayList(GetServerList(serverName)); + + int slots = 1; + + if (serverList.size() > 0) + { + slots = GetRequiredSlots(player, serverList.get(0).ServerType); + } + + try + { + Collections.sort(serverList, new ServerSorter(slots)); + + for (ServerInfo serverInfo : serverList) + { + if ((serverInfo.MOTD.contains("Starting") || serverInfo.MOTD.contains("Recruiting") || serverInfo.MOTD.contains("Waiting") || serverInfo.MOTD.contains("Cup")) && (serverInfo.MaxPlayers - serverInfo.CurrentPlayers) >= slots) + { + SelectServer(player, serverInfo); + return; + } + } + } + catch (Exception exception) + { + exception.printStackTrace(); + + for (ServerInfo serverInfo : serverList) + { + System.out.println(F.main("ServerManager", ChatColor.YELLOW + serverInfo.Name + ": " + serverInfo.MOTD + " " + serverInfo.CurrentPlayers + "/" + serverInfo.MaxPlayers)); + } + } + + player.sendMessage(F.main("Server Portal", "There are currently no joinable servers!")); + } + } + @EventHandler(priority = EventPriority.LOW) public void playerJoin(PlayerJoinEvent event) { @@ -101,24 +188,6 @@ public class ServerManager extends MiniPlugin } } - public void AddServer(String serverNpcName, String serverName) - { - ServerInfo serverInfo = new ServerInfo(); - serverInfo.Name = serverName; - - if (_serverInfoMap.containsKey(serverName)) - { - _serverInfoMap.remove(serverName); - _serverUpdate.remove(serverName); - } - - _serverNpcMap.get(serverNpcName).add(serverInfo); - _serverInfoMap.put(serverName, serverInfo); - _serverUpdate.put(serverName, System.currentTimeMillis()); - - SaveServers(); - } - public void RemoveServer(String serverName) { for (String key : _serverNpcMap.keySet()) @@ -220,38 +289,48 @@ public class ServerManager extends MiniPlugin { for (ServerStatusData serverStatus : serverStatusList) { - if (_serverInfoMap.containsKey(serverStatus.Name)) - { - String[] args = serverStatus.Motd.split("\\|"); - - ServerInfo serverInfo = _serverInfoMap.get(serverStatus.Name); - serverInfo.MOTD = args.length > 0 ? args[0] : serverStatus.Motd; - serverInfo.CurrentPlayers = serverStatus.Players; - serverInfo.MaxPlayers = serverStatus.MaxPlayers; - - if (args.length > 1) - serverInfo.ServerType = args[1]; - - if (args.length > 2) - serverInfo.Game = args[2]; - - if (args.length > 3) - serverInfo.Map = args[3]; - - _serverUpdate.put(serverStatus.Name, System.currentTimeMillis()); - } - - for (String name : _serverUpdate.keySet()) + if (!_serverInfoMap.containsKey(serverStatus.Name)) { - if (_serverUpdate.get(name) != -1L && System.currentTimeMillis() - _serverUpdate.get(name) > 5000) - { - ServerInfo serverInfo = _serverInfoMap.get(name); - serverInfo.MOTD = ChatColor.DARK_RED + "OFFLINE"; - serverInfo.CurrentPlayers = 0; - serverInfo.MaxPlayers = 0; - - _serverUpdate.put(name, -1L); - } + ServerInfo newServerInfo = new ServerInfo(); + newServerInfo.Name = serverStatus.Name; + _serverInfoMap.put(serverStatus.Name, newServerInfo); + } + + String[] args = serverStatus.Motd.split("\\|"); + String tag = (serverStatus.Name != null && serverStatus.Name.contains("-")) ? serverStatus.Name.split("-")[0] : "N/A"; + + ServerInfo serverInfo = _serverInfoMap.get(serverStatus.Name); + serverInfo.MOTD = args.length > 0 ? args[0] : serverStatus.Motd; + serverInfo.CurrentPlayers = serverStatus.Players; + serverInfo.MaxPlayers = serverStatus.MaxPlayers; + + if (args.length > 1) + serverInfo.ServerType = args[1]; + + if (args.length > 2) + serverInfo.Game = args[2]; + + if (args.length > 3) + serverInfo.Map = args[3]; + + _serverUpdate.put(serverStatus.Name, System.currentTimeMillis()); + + if (_serverNpcTag.containsKey(tag)) + { + _serverNpcMap.get(_serverNpcTag.get(tag)).add(serverInfo); + } + } + + for (String name : _serverUpdate.keySet()) + { + if (_serverUpdate.get(name) != -1L && System.currentTimeMillis() - _serverUpdate.get(name) > 5000) + { + ServerInfo serverInfo = _serverInfoMap.get(name); + serverInfo.MOTD = ChatColor.DARK_RED + "OFFLINE"; + serverInfo.CurrentPlayers = 0; + serverInfo.MaxPlayers = 0; + + _serverUpdate.put(name, -1L); } } @@ -369,63 +448,6 @@ public class ServerManager extends MiniPlugin } } - public void SaveServers() - { - if (_loading) - return; - - FileWriter fstream = null; - BufferedWriter out = null; - - try - { - fstream = new FileWriter("ServerManager.dat"); - out = new BufferedWriter(fstream); - - for (String key : _serverNpcMap.keySet()) - { - System.out.println("Saving serverinfos for " + key); - for (ServerInfo serverInfo : _serverNpcMap.get(key)) - { - out.write(key + " | " + serverInfo.Name); - out.newLine(); - } - } - - out.close(); - } - catch (Exception e) - { - System.err.println("ServerManager Save Error: " + e.getMessage()); - } - finally - { - if (out != null) - { - try - { - out.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - - if (fstream != null) - { - try - { - fstream.close(); - } - catch (IOException e) - { - e.printStackTrace(); - } - } - } - } - public void LoadServers() { _serverInfoMap.clear(); @@ -436,8 +458,8 @@ public class ServerManager extends MiniPlugin _serverNpcMap.get(npcName).clear(); } - _loading = true; - + _serverNpcTag.clear(); + FileInputStream fstream = null; BufferedReader br = null; @@ -457,14 +479,20 @@ public class ServerManager extends MiniPlugin while (line != null) { String serverNpcName = line.substring(0, line.indexOf('|')).trim(); - String server = line.substring(line.indexOf('|') + 1).trim(); + String serverTag = line.substring(line.indexOf('|') + 1, line.indexOf('|', line.indexOf('|') + 1)).trim(); + String[] locations = line.substring(line.indexOf('|', line.indexOf('|') + 1) + 1).trim().split(","); + + for (String location : locations) + { + _serverPortalLocations.put(ParseVector(location), serverNpcName); + } if (!HasServerNpc(serverNpcName)) { AddServerNpc(serverNpcName); } - AddServer(serverNpcName, server); + _serverNpcTag.put(serverTag, serverNpcName); npcNames.add(serverNpcName); line = br.readLine(); @@ -500,8 +528,6 @@ public class ServerManager extends MiniPlugin e.printStackTrace(); } } - - _loading = false; } for (String npcName : npcNames) @@ -549,7 +575,7 @@ public class ServerManager extends MiniPlugin public ServerNpcShop getMixedArcadeShop() { - return _serverNpcShopMap.get("Mixed Arcade Games"); + return _serverNpcShopMap.get("Mixed Arcade"); } public ServerNpcShop getSuperSmashMobsShop() @@ -559,7 +585,7 @@ public class ServerManager extends MiniPlugin public ServerNpcShop getDominateShop() { - return _serverNpcShopMap.get("Dominate Beta"); + return _serverNpcShopMap.get("Dominate"); } public ServerNpcShop getBridgesShop() @@ -569,6 +595,19 @@ public class ServerManager extends MiniPlugin public ServerNpcShop getMinekartShop() { - return _serverNpcShopMap.get("play minekart plz"); + return _serverNpcShopMap.get("Minekart"); + } + + private Vector ParseVector(String vectorString) + { + Vector vector = new Vector(); + + String [] parts = vectorString.trim().split(" "); + + vector.setX(Double.parseDouble(parts[0])); + vector.setY(Double.parseDouble(parts[1])); + vector.setZ(Double.parseDouble(parts[2])); + + return vector; } } diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/command/AddServerCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/command/AddServerCommand.java deleted file mode 100644 index 60d92bb0a..000000000 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/command/AddServerCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -package mineplex.hub.server.command; - -import org.bukkit.ChatColor; -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.hub.server.ServerManager; - -public class AddServerCommand extends CommandBase -{ - public AddServerCommand(ServerManager plugin) - { - super(plugin, Rank.OWNER, "addserver"); - } - - @Override - public void Execute(Player caller, String[] args) - { - if (args.length < 2) - { - Plugin.Help(caller, "Invalid arguments"); - return; - } - - String argsCombined = args[0]; - String serverNpcName = ""; - String serverName = ""; - - for (int i = 1; i < args.length; i++) - { - argsCombined += " " + args[i]; - } - - if (!argsCombined.contains("|")) - { - Plugin.Help(caller, "Invalid arguments"); - } - - serverNpcName = argsCombined.substring(0, argsCombined.indexOf("|")).trim(); - serverName = argsCombined.substring(argsCombined.indexOf("|") + 1).trim(); - - if (!Plugin.HasServerNpc(serverNpcName)) - { - UtilPlayer.message(caller, F.main(Plugin.GetName(), ChatColor.RED + "That ServerNpc doesn't exist.")); - } - else - { - Plugin.AddServer(serverNpcName, serverName); - UtilPlayer.message(caller, F.main(Plugin.GetName(), "Added '" + serverName + "' to '" + serverNpcName + "' server list.")); - } - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/command/ServerNpcCommand.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/command/ServerNpcCommand.java index ae69c4d6a..5c498f115 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/command/ServerNpcCommand.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/command/ServerNpcCommand.java @@ -14,7 +14,6 @@ public class ServerNpcCommand extends MultiCommandBase AddCommand(new CreateCommand(plugin)); AddCommand(new DeleteCommand(plugin)); - AddCommand(new AddServerCommand(plugin)); AddCommand(new RemoveServerCommand(plugin)); AddCommand(new ListNpcsCommand(plugin)); AddCommand(new ListServersCommand(plugin)); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 602b75dfb..f0167b07f 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -105,6 +105,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "A Barbarian's Life", ChatColor.RESET + "Turf Forts", ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.GOLD_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -121,6 +123,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "A Barbarian's Life", ChatColor.RESET + "Turf Forts", ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(122, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -137,6 +141,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "A Barbarian's Life", ChatColor.RESET + "Turf Forts", ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -153,6 +159,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "A Barbarian's Life", ChatColor.RESET + "Turf Forts", ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.LEATHER_BOOTS.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -169,6 +177,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "A Barbarian's Life", ChatColor.RESET + "Turf Forts", ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.MILK_BUCKET.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -185,6 +195,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "A Barbarian's Life", ChatColor.RESET + "Turf Forts", ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE.getId(), (byte)0, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -201,6 +213,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + C.Bold + ChatColor.GREEN + "A Barbarian's Life", ChatColor.RESET + "Turf Forts", ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(159, (byte)14, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -217,6 +231,8 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "A Barbarian's Life", ChatColor.RESET + C.Bold + ChatColor.GREEN + "Turf Forts", ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" })); _minigameCycle.add(ItemStackFactory.Instance.CreateStack(144, (byte)1, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] @@ -231,8 +247,46 @@ public class ServerGameMenu extends ShopPageBase ChatColor.RESET + "Dragon Escape", ChatColor.RESET + "Milk the Cow", ChatColor.RESET + "A Barbarian's Life", - ChatColor.RESET +"Turf Forts", + ChatColor.RESET + "Turf Forts", ChatColor.RESET + C.Bold + ChatColor.GREEN + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" + })); + + _minigameCycle.add(ItemStackFactory.Instance.CreateStack(144, (byte)1, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] + { + ChatColor.RESET + "", + ChatColor.RESET + "Play all of these fun minigames:", + ChatColor.RESET + "", + ChatColor.RESET + "Super Spleef", + ChatColor.RESET + "Runner", + ChatColor.RESET + "Dragons", + ChatColor.RESET + "One in the Quiver", + ChatColor.RESET + "Dragon Escape", + ChatColor.RESET + "Milk the Cow", + ChatColor.RESET + "A Barbarian's Life", + ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Death Tag", + ChatColor.RESET + C.Bold + ChatColor.GREEN + "Bacon Brawl", + ChatColor.RESET + "Squid Sauce" + })); + + _minigameCycle.add(ItemStackFactory.Instance.CreateStack(144, (byte)1, 1, ChatColor.RESET + C.Bold + ChatColor.YELLOW + "Arcade " + C.cGray + "Mixed Games", new String [] + { + ChatColor.RESET + "", + ChatColor.RESET + "Play all of these fun minigames:", + ChatColor.RESET + "", + ChatColor.RESET + "Super Spleef", + ChatColor.RESET + "Runner", + ChatColor.RESET + "Dragons", + ChatColor.RESET + "One in the Quiver", + ChatColor.RESET + "Dragon Escape", + ChatColor.RESET + "Milk the Cow", + ChatColor.RESET + "A Barbarian's Life", + ChatColor.RESET + "Turf Forts", + ChatColor.RESET + "Death Tag", + ChatColor.RESET + "Bacon Brawl", + ChatColor.RESET + C.Bold + ChatColor.GREEN + "Squid Sauce" })); }