more event server updates

This commit is contained in:
Cheese 2015-03-12 12:14:49 +11:00
parent e443b41e15
commit 8e77d1fc21
7 changed files with 257 additions and 48 deletions

View File

@ -0,0 +1,23 @@
package mineplex.core.common.util;
import java.util.Collection;
public class UtilText
{
public static <T> String listToString(Collection<T> inputList, boolean comma)
{
String out = "";
for (T cur : inputList)
{
out += cur.toString() + (comma ? ", " : " ");
}
if (out.length() > 0)
{
out = out.substring(0, out.length()-(comma ? 2 : 1));
}
return out;
}
}

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.command;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -12,6 +13,7 @@ import nautilus.game.arcade.game.Game.GameState;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
public class SetCommand extends CommandBase<ArcadeManager>
{
@ -35,7 +37,10 @@ public class SetCommand extends CommandBase<ArcadeManager>
String game = args[0].toLowerCase();
if (args.length > 1)
{
Plugin.GetGameCreationManager().MapPref = args[1];
UtilPlayer.message(caller, C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + args[1]);
}
//Parse Game
ArrayList<GameType> matches = new ArrayList<GameType>();

View File

@ -151,6 +151,7 @@ public abstract class Game implements Listener
public boolean DamagePvE = true;
public boolean DamageEvP = true;
public boolean DamageSelf = true;
public boolean DamageFall = true;
public boolean DamageTeamSelf = false;
public boolean DamageTeamOther = true;

View File

@ -1,8 +1,10 @@
package nautilus.game.arcade.game.games.event;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
@ -27,6 +29,8 @@ import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.Villager.Profession;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@ -46,6 +50,8 @@ import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.creature.event.CreatureKillEntitiesEvent;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBat;
import mineplex.core.disguise.disguises.DisguiseChicken;
@ -96,6 +102,11 @@ public class EventGame extends SoloGame
this.JoinInProgress = true;
this.DamageTeamSelf = true;
this.DamagePvP = false;
this.DamageEvP = false;
this.DamagePvE = false;
this.DeathMessages = false;
this.DeathOut = false;
@ -111,10 +122,16 @@ public class EventGame extends SoloGame
this.BlockPlaceCreative = true;
this.BlockBreakCreative = true;
this.InventoryClick = true;
this.InventoryOpenBlock = true;
this.InventoryOpenChest = true;
//Dont timeout
this.GameTimeout = -1;
_mps = manager.GetGameHostManager();
this.CreatureAllow = true;
}
//Before GamePlayerManager puts onto Spec!
@ -125,28 +142,8 @@ public class EventGame extends SoloGame
joinTeam(event.getPlayer());
}
// @EventHandler
// public void specToTeam(UpdateEvent event)
// {
// if (!InProgress())
// return;
//
// if (event.getType() != UpdateType.FAST)
// return;
//
// for (Player player : UtilServer.getPlayers())
// {
// if (!GetTeamList().get(0).HasPlayer(player))
// {
// joinTeam(player);
// }
// }
// }
public void joinTeam(Player player)
{
Announce(C.cRed + C.Bold + player.getName() + " joined " + GetTeamList().get(0).GetName());
//Set Team
SetPlayerTeam(player, GetTeamList().get(0), true);
@ -172,17 +169,19 @@ public class EventGame extends SoloGame
private void commandHelp(Player player)
{
UtilPlayer.message(player, F.main("Event", "Displaying Commands;"));
UtilPlayer.message(player, F.value("/e settings", "View Settings Help"));
UtilPlayer.message(player, F.value("/e tp <Player>", "Teleport to Target"));
UtilPlayer.message(player, F.value("/e tp here <Player>", "Teleport Target to Self"));
UtilPlayer.message(player, F.value("/e tp here all", "Teleport Everyone to Self"));
UtilPlayer.message(player, F.value("/e gadget", "Toggle Gadgets"));
UtilPlayer.message(player, F.value("/e silence [Time]", "Silence Chat"));
UtilPlayer.message(player, F.value("/e gamemode [Player]", "Toggle Creative Mode"));
UtilPlayer.message(player, F.value("/e gm [Player]", "Toggle Creative Mode"));
UtilPlayer.message(player, F.value("/e radius [Radius]", "Set Forcefield Radius"));
UtilPlayer.message(player, F.value(C.cRed + "/e give <Item> <Amount> [Player/\'All\']", "Give Item"));
UtilPlayer.message(player, F.value(C.cRed + "/e setting", "View Settings Help"));
UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump"));
UtilPlayer.message(player, F.value("/e scoreboard <Line #> [Text]", "Sets Scoreboard Text"));
UtilPlayer.message(player, F.value("/e mob <type> [#Amount] n[Name] s[Size] [true/false]", "Mobs"));
UtilPlayer.message(player, F.value("/e mob kill <type>", "Kill Mobs"));
}
private void commandHelpSettings(Player player)
@ -192,16 +191,17 @@ public class EventGame extends SoloGame
UtilPlayer.message(player, F.value("/e damage pvp", "Toggles PvP Damage"));
UtilPlayer.message(player, F.value("/e damage pve", "Toggles PvE Damage"));
UtilPlayer.message(player, F.value("/e damage pve", "Toggles EvP Damage"));
UtilPlayer.message(player, F.value("/e damage fall", "Toggles Fall Damage"));
UtilPlayer.message(player, F.value("/e health <-1 to 20>", "Locks Players Health"));
UtilPlayer.message(player, F.value("/e hunger <-1 to 20>", "Locks Players Hunger"));
UtilPlayer.message(player, F.value("/e item drop", "Toggles Item Drop"));
UtilPlayer.message(player, F.value("/e item pickup", "Toggles Item Pickup"));
UtilPlayer.message(player, F.value("/e blockplace", "Toggles Block Placing (On/Off)"));
UtilPlayer.message(player, F.value("/e blockplace whitelist <id>", "Whitelists Block Place"));
UtilPlayer.message(player, F.value("/e blockplace blacklist <id>", "Whitelists Block Place"));
UtilPlayer.message(player, F.value("/e blockplace whitelist <add/remove/list/clear> <id>", ""));
UtilPlayer.message(player, F.value("/e blockplace blacklist <add/remove/list/clear> <id>", ""));
UtilPlayer.message(player, F.value("/e blockbreak", "Toggles Block Breaking (On/Off)"));
UtilPlayer.message(player, F.value("/e blockbreak whitelist <id>", "Whitelists Block Break"));
UtilPlayer.message(player, F.value("/e blockbreak blacklist <id>", "Blacklists Block Break"));
UtilPlayer.message(player, F.value("/e blockbreak whitelist <add/remove/list/clear> <id>", ""));
UtilPlayer.message(player, F.value("/e blockbreak blacklist <add/remove/list/clear> <id>", ""));
}
//Command Handler
@ -228,7 +228,10 @@ public class EventGame extends SoloGame
}
else if (args[0].equalsIgnoreCase("settings"))
{
commandHelpSettings(event.getPlayer());
if (args.length >= 2 && args[1].equalsIgnoreCase("list"))
listSettings(event.getPlayer());
else
commandHelpSettings(event.getPlayer());
}
//XXX Commands
@ -244,7 +247,7 @@ public class EventGame extends SoloGame
{
commandSilence(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("gamemode"))
else if (args[0].equalsIgnoreCase("gm"))
{
commandGamemode(event.getPlayer(), args);
}
@ -264,6 +267,13 @@ public class EventGame extends SoloGame
{
commandWhitelist(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("mob"))
{
if (args.length >= 2 && args[1].equalsIgnoreCase("kill"))
commandMobKill(event.getPlayer(), args);
else
commandMob(event.getPlayer(), args);
}
//XXX Settings
@ -287,6 +297,11 @@ public class EventGame extends SoloGame
DamageEvP = !DamageEvP;
Announce(F.main("Event Settings", F.value("Damage EvP", F.tf(DamageEvP))));
}
else if (event.getMessage().toLowerCase().equals("/e damage fall"))
{
DamageFall = !DamageFall;
Announce(F.main("Event Settings", F.value("Damage Fall", F.tf(DamageFall))));
}
else if (args[0].equalsIgnoreCase("health"))
{
commandHealth(event.getPlayer(), args);
@ -311,10 +326,9 @@ public class EventGame extends SoloGame
Announce(F.main("Event Settings", F.value("Block Place", F.tf(BlockPlace))));
}
else if (args.length >= 4 && args[0].equalsIgnoreCase("blockplace")
&& (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))
&& (args[2].equalsIgnoreCase("add") || args[2].equalsIgnoreCase("remove")))
&& (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist")))
{
commandBlockPlace(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2].equalsIgnoreCase("add"));
commandBlockPlace(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2]);
}
else if (event.getMessage().toLowerCase().equals("/e blockbreak"))
{
@ -322,14 +336,32 @@ public class EventGame extends SoloGame
Announce(F.main("Event Settings", F.value("Block Break", F.tf(BlockBreak))));
}
else if (args.length >= 4 && args[0].equalsIgnoreCase("blockbreak")
&& (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist"))
&& (args[2].equalsIgnoreCase("add") || args[2].equalsIgnoreCase("remove")))
&& (args[1].equalsIgnoreCase("whitelist") || args[1].equalsIgnoreCase("blacklist")))
{
commandBlockBreak(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2].equalsIgnoreCase("add"));
commandBlockBreak(event.getPlayer(), args, args[1].equalsIgnoreCase("whitelist"), args[2]);
}
}
private void commandBlockPlace(Player player, String[] args, boolean whitelist, boolean add)
private void listSettings(Player player)
{
UtilPlayer.message(player, F.value("Damage All", F.tf(Damage)));
UtilPlayer.message(player, F.value("Damage PvP", F.tf(DamagePvP)));
UtilPlayer.message(player, F.value("Damage PvE", F.tf(DamagePvE)));
UtilPlayer.message(player, F.value("Damage EvP", F.tf(DamageEvP)));
UtilPlayer.message(player, F.value("Damage Fall", F.tf(DamageFall)));
UtilPlayer.message(player, F.value("Health Set", HealthSet+""));
UtilPlayer.message(player, F.value("Hunger Set", HungerSet+""));
UtilPlayer.message(player, F.value("Item Pickup", F.tf(ItemPickup)));
UtilPlayer.message(player, F.value("Item Drop", F.tf(ItemDrop)));
UtilPlayer.message(player, F.value("Block Place", F.tf(BlockPlace)));
UtilPlayer.message(player, F.value("Block Place Whitelist", UtilText.listToString(BlockPlaceAllow, true)));
UtilPlayer.message(player, F.value("Block Place Blacklist", UtilText.listToString(BlockPlaceDeny, true)));
UtilPlayer.message(player, F.value("Block Break", F.tf(BlockPlace)));
UtilPlayer.message(player, F.value("Block Break Whitelist", UtilText.listToString(BlockBreakAllow, true)));
UtilPlayer.message(player, F.value("Block Break Blacklist", UtilText.listToString(BlockBreakDeny, true)));
}
private void commandBlockPlace(Player player, String[] args, boolean whitelist, String command)
{
try
{
@ -337,29 +369,47 @@ public class EventGame extends SoloGame
if (whitelist)
{
if (add)
if (command.equalsIgnoreCase("add"))
{
BlockPlaceAllow.add(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Added " + blockId)));
}
else
else if (command.equalsIgnoreCase("remove"))
{
BlockPlaceAllow.remove(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Removed " + blockId)));
}
else if (command.equalsIgnoreCase("clear"))
{
BlockPlaceAllow.clear();
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", "Cleared")));
}
else if (command.equalsIgnoreCase("list"))
{
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Whitelist", UtilText.listToString(BlockPlaceAllow, true))));
}
}
else
{
if (add)
if (command.equalsIgnoreCase("add"))
{
BlockPlaceDeny.add(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Added " + blockId)));
}
else
else if (command.equalsIgnoreCase("remove"))
{
BlockPlaceDeny.remove(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Removed " + blockId)));
}
else if (command.equalsIgnoreCase("clear"))
{
BlockPlaceDeny.clear();
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", "Cleared")));
}
else if (command.equalsIgnoreCase("list"))
{
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Place Blacklist", UtilText.listToString(BlockPlaceDeny, true))));
}
}
return;
@ -372,7 +422,7 @@ public class EventGame extends SoloGame
commandHelpSettings(player);
}
private void commandBlockBreak(Player player, String[] args, boolean whitelist, boolean add)
private void commandBlockBreak(Player player, String[] args, boolean whitelist, String command)
{
try
{
@ -380,29 +430,47 @@ public class EventGame extends SoloGame
if (whitelist)
{
if (add)
if (command.equalsIgnoreCase("add"))
{
BlockBreakAllow.add(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Added " + blockId)));
}
else
else if (command.equalsIgnoreCase("remove"))
{
BlockBreakAllow.remove(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Removed " + blockId)));
}
else if (command.equalsIgnoreCase("clear"))
{
BlockBreakAllow.clear();
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", "Cleared")));
}
else if (command.equalsIgnoreCase("list"))
{
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Whitelist", UtilText.listToString(BlockBreakAllow, true))));
}
}
else
{
if (add)
if (command.equalsIgnoreCase("add"))
{
BlockBreakDeny.add(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Added " + blockId)));
}
else
else if (command.equalsIgnoreCase("remove"))
{
BlockBreakDeny.remove(blockId);
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Removed " + blockId)));
}
else if (command.equalsIgnoreCase("clear"))
{
BlockBreakDeny.clear();
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", "Cleared")));
}
else if (command.equalsIgnoreCase("list"))
{
UtilPlayer.message(player, F.main("Event Settings", F.value("Block Break Blacklist", UtilText.listToString(BlockBreakDeny, true))));
}
}
return;
@ -714,9 +782,11 @@ public class EventGame extends SoloGame
//On and Off
if (args.length >= 2)
{
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("of"))
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("off"))
{
UtilServer.getServer().setWhitelist(args[1].equalsIgnoreCase("on"));
Announce(F.main("Event Settings", F.value("Whitelist", F.tf(args[1].equalsIgnoreCase("on")))));
return;
}
}
@ -729,9 +799,15 @@ public class EventGame extends SoloGame
OfflinePlayer target = Bukkit.getOfflinePlayer(args[2]);
if (args[1].equalsIgnoreCase("add"))
{
UtilServer.getServer().getWhitelistedPlayers().add(target);
UtilPlayer.message(player, F.main("Whitelist", "Added " + args[1] + " to the whitelist."));
}
else
{
UtilServer.getServer().getWhitelistedPlayers().remove(target);
UtilPlayer.message(player, F.main("Whitelist", "Removed " + args[1] + " to the whitelist."));
}
return;
}
@ -957,6 +1033,52 @@ public class EventGame extends SoloGame
}
}
public void commandMobKill(Player caller, String[] args)
{
if (args.length < 3)
{
UtilPlayer.message(caller, F.main("Creature", "Missing Entity Type Parameter."));
return;
}
EntityType type = UtilEnt.searchEntity(caller, args[2], true);
if (type == null && !args[2].equalsIgnoreCase("all"))
return;
int count = 0;
List<Entity> killList = new ArrayList<Entity>();
for (World world : UtilServer.getServer().getWorlds())
{
for (Entity ent : world.getEntities())
{
if (ent.getType() == EntityType.PLAYER)
continue;
if (type == null || ent.getType() == type)
{
killList.add(ent);
}
}
}
CreatureKillEntitiesEvent event = new CreatureKillEntitiesEvent(killList);
UtilServer.getServer().getPluginManager().callEvent(event);
for (Entity entity : event.GetEntities())
{
entity.remove();
count++;
}
String target = "ALL";
if (type != null)
target = UtilEnt.getName(type);
UtilPlayer.message(caller, F.main("Creature", "Killed " + target + ". " + count + " Removed."));
}
@EventHandler
public void doubleJumpTrigger(PlayerToggleFlightEvent event)
{
@ -1143,9 +1265,9 @@ public class EventGame extends SoloGame
Scoreboard.Draw();
}
//This re-enables cosmetic hotbar, because MPS disables it
//This re-enables cosmetic hotbar, because MPS disables it - temp fix until i find out whats disabling it repeatedly
@EventHandler(priority = EventPriority.MONITOR)
public void fixHotbarItemTemp(GameStateChangeEvent event)
public void fixHotbarItemTemp(UpdateEvent event)
{
Manager.GetServerConfig().HotbarInventory = true;
}
@ -1161,4 +1283,11 @@ public class EventGame extends SoloGame
player.getInventory().addItem(new ItemStack(mat, amount));
}
}
@EventHandler
public void creatureNaturalRemove(CreatureSpawnEvent event)
{
if (event.getSpawnReason() != SpawnReason.CUSTOM)
event.setCancelled(true);
}
}

View File

@ -69,7 +69,7 @@ public class GameChatManager implements Listener
//Rank Prefix & MPS Host Prefix
if (Manager.GetGameHostManager().isHost(event.getPlayer()))
{
if (Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event)
if (Manager.GetGameHostManager().isEventServer())
rankStr = C.cDGreen + C.Bold + "Event Host ";
else
rankStr = C.cDGreen + C.Bold + "MPS Host ";

View File

@ -115,6 +115,12 @@ public class GameFlagManager implements Listener
return;
}
if (event.GetCause() == DamageCause.FALL && !game.DamageFall)
{
event.SetCancelled("Fall Damage Disabled");
return;
}
//Entity vs Entity
if (damagee != null && damager != null)
{

View File

@ -20,6 +20,7 @@ import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -55,6 +56,8 @@ public class GameHostManager implements Listener
private PrivateServerShop _shop;
private boolean _isEventServer = false;
public GameHostManager(ArcadeManager manager)
{
Manager = manager;
@ -109,6 +112,12 @@ public class GameHostManager implements Listener
if (Manager.GetHost() == null || Manager.GetHost().length() == 0)
return;
// Set as event server
if (Manager.GetGame() != null && Manager.GetGame().GetType() == GameType.Event)
{
setEventServer(true);
}
// Admins update
for (Player player : UtilServer.getPlayers())
{
@ -437,6 +446,8 @@ public class GameHostManager implements Listener
player.closeInventory();
}
UtilPlayer.message(player, F.main("Server", "Your admin privileges were removed."));
player.setGameMode(GameMode.SURVIVAL);
}
}
@ -494,6 +505,30 @@ public class GameHostManager implements Listener
event.setCancelled(true);
}
@EventHandler
public void setEventGame(PlayerCommandPreprocessEvent event)
{
if (!isEventServer() || Manager.GetGame() == null)
return;
if (!isAdmin(event.getPlayer(), false))
return;
if (!event.getMessage().toLowerCase().startsWith("/e set"))
return;
Manager.GetGame().setGame(GameType.Event, event.getPlayer(), true);
String[] args = event.getMessage().split(" ");
if (args.length >= 3)
{
Manager.GetGameCreationManager().MapPref = args[2];
UtilPlayer.message(event.getPlayer(), C.cAqua + C.Bold + "Map Preference: " + ChatColor.RESET + args[2]);
}
event.setCancelled(true);
}
@EventHandler
public void playerJoin(PlayerJoinEvent event)
{
@ -510,4 +545,14 @@ public class GameHostManager implements Listener
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);
}
public boolean isEventServer()
{
return _isEventServer;
}
public void setEventServer(boolean var)
{
_isEventServer = var;
}
}