Merge remote-tracking branch 'refs/remotes/origin/develop' into update/ssm

This commit is contained in:
Sam 2017-05-01 10:37:13 +01:00
commit 8c2b8935df
25 changed files with 1364 additions and 430 deletions

View File

@ -17,6 +17,7 @@ public enum Rank
JNR_DEV("Jr.Dev", "jrdev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", -1),
SUPPORT("Support", "spp", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service.", 47),
CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32),
EVENT_MODERATOR("Sr.Mod", "eventmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 44),
SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 44),
MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32),
HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 24),
@ -151,4 +152,4 @@ public enum Rank
{
return _forumId;
}
}
}

View File

@ -1,54 +0,0 @@
package mineplex.core;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import net.minecraft.server.v1_8_R3.PacketPlayInCustomPayload;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketHandler.ListenerPriority;
/**
* A temporary fix for book-related crashes. Adds a rate limit to book/sign edits.
* <p>
* See:
* https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/1c3428e534283395dd1b85641a96a6f16842fc1e
* https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/4acd0f49e07e0912096e79494472535baf0db2ab
*/
public class BookRateLimiter extends MiniPlugin
{
private final PacketHandler _packetHandler = require(PacketHandler.class);
private final Cache<UUID, Integer> _cache = CacheBuilder.newBuilder()
.expireAfterWrite(1, TimeUnit.SECONDS)
.build();
public BookRateLimiter()
{
super("PacketRateLimiter");
_packetHandler.addPacketHandler(info ->
{
PacketPlayInCustomPayload packet = (PacketPlayInCustomPayload) info.getPacket();
String s = packet.a();
if (!s.equals("MC|BEdit") && !s.equals("MC|BSign"))
{
return;
}
if (_cache.asMap().containsKey(info.getPlayer().getUniqueId()))
{
info.setCancelled(true);
return;
}
_cache.put(info.getPlayer().getUniqueId(), 0);
}, ListenerPriority.LOW, true, PacketPlayInCustomPayload.class);
}
}

View File

@ -89,12 +89,13 @@ public class CommandCenter implements Listener, IPacketHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
String commandName = event.getMessage().substring(1);
String argString = event.getMessage().substring(event.getMessage().indexOf(' ') + 1);
String[] args = new String[]{};
if (commandName.contains(" "))
{
commandName = commandName.split(" ")[0];
args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
args = argString.split(" ");
}
ICommand command = Commands.get(commandName.toLowerCase());
@ -113,6 +114,12 @@ public class CommandCenter implements Listener, IPacketHandler
}
command.SetAliasUsed(commandName.toLowerCase());
if (command instanceof LoggedCommand)
{
((LoggedCommand) command).execute(System.currentTimeMillis(), event.getPlayer().getName(), commandName, argString);
}
command.Execute(event.getPlayer(), args);
}
return;

View File

@ -0,0 +1,17 @@
package mineplex.core.command;
/**
* LoggedCommand
*
* @author xXVevzZXx
*/
public interface LoggedCommand
{
default void execute(long time, String username, String command, String args)
{
LoggingServerCommand cmd = new LoggingServerCommand(time, username, command, args);
cmd.publish();
}
}

View File

@ -0,0 +1,24 @@
package mineplex.core.command;
import mineplex.serverdata.commands.ServerCommand;
/**
* LoggingServerCommand
*
* @author xXVevzZXx
*/
public class LoggingServerCommand extends ServerCommand
{
private final long _time;
private final String _username;
private final String _command;
private final String _args;
public LoggingServerCommand(long time, String username, String command, String args)
{
_time = time;
_username = username;
_command = command;
_args = args;
}
}

View File

@ -3,16 +3,20 @@ package mineplex.core.personalServer;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.command.LoggedCommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
public class HostEventServerCommand extends CommandBase<PersonalServerManager>
public class HostEventServerCommand extends CommandBase<PersonalServerManager> implements LoggedCommand
{
public HostEventServerCommand(PersonalServerManager plugin)
{
super(plugin, Rank.ADMIN, "hostevent");
super(plugin, Rank.ADMIN, new Rank[]
{
Rank.EVENT_MODERATOR
}, "hostevent");
}
@Override
@ -26,6 +30,6 @@ public class HostEventServerCommand extends CommandBase<PersonalServerManager>
UtilPlayer.message(caller, F.main("Disguise", "You can't create a event server while you are disguised!"));
return;
}
Plugin.hostServer(caller, caller.getName(), true);
Plugin.hostServer(caller, caller.getName(), true);
}
}

View File

@ -0,0 +1,35 @@
package mineplex.core.personalServer;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.command.LoggedCommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
public class HostPersonalEventServer extends CommandBase<PersonalServerManager> implements LoggedCommand
{
public HostPersonalEventServer(PersonalServerManager plugin)
{
super(plugin, Rank.ADMIN, new Rank[]
{
Rank.EVENT_MODERATOR
}, "hostmes");
}
@Override
public void Execute(Player caller, String[] args)
{
if (!Recharge.Instance.use(caller, "Host Event", 30000, false, false))
return;
if(Plugin.getClients().Get(caller).isDisguised())
{
UtilPlayer.message(caller, F.main("Disguise", "You can't create a event server while you are disguised!"));
return;
}
Plugin.hostServer(caller, caller.getName(), false, true);
}
}

View File

@ -106,6 +106,7 @@ public class PersonalServerManager extends MiniPlugin
{
addCommand(new HostServerCommand(this));
addCommand(new HostEventServerCommand(this));
addCommand(new HostPersonalEventServer(this));
}
private void setupConfigValues()
@ -124,6 +125,11 @@ public class PersonalServerManager extends MiniPlugin
}
public void hostServer(Player player, String serverName, boolean eventServer)
{
hostServer(player, serverName, eventServer, false);
}
public void hostServer(Player player, String serverName, boolean eventServer, boolean eventgame)
{
int ram = 1024;
int cpu = 1;
@ -143,7 +149,16 @@ public class PersonalServerManager extends MiniPlugin
createGroup(player, "EVENT", ram, cpu, 40, 80, "Event", eventServer);
}
else
createGroup(player, serverName, ram, cpu, 40, 80, "Smash", eventServer);
{
if (eventgame)
{
createGroup(player, serverName, ram, cpu, 40, 80, "Event", eventServer);
}
else
{
createGroup(player, serverName, ram, cpu, 40, 80, "Smash", eventServer);
}
}
}
public void hostCommunityServer(Player host, Community community)

View File

@ -47,7 +47,9 @@ public class PreferenceMenu extends Menu<PreferencesManager>
if (rank.has(Rank.HELPER) && !rank.has(Rank.ADMIN))
{
preferences.remove(Preference.INVISIBILITY);
preferences.remove(Preference.FORCE_FIELD);
if (rank != Rank.EVENT_MODERATOR)
preferences.remove(Preference.FORCE_FIELD);
}
else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH)
{

View File

@ -1,55 +0,0 @@
package mineplex.game.clans;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import net.minecraft.server.v1_8_R3.PacketPlayInCustomPayload;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import mineplex.core.MiniPlugin;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.packethandler.PacketHandler.ListenerPriority;
/**
* A temporary fix for book-related crashes. Adds a rate limit to book/sign edits.
* <p>
* See:
* https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/1c3428e534283395dd1b85641a96a6f16842fc1e
* https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/4acd0f49e07e0912096e79494472535baf0db2ab
*/
public class BookRateLimiter extends MiniPlugin
{
private final PacketHandler _packetHandler = require(PacketHandler.class);
private final Cache<UUID, Integer> _cache = CacheBuilder.newBuilder()
.expireAfterWrite(1, TimeUnit.SECONDS)
.build();
public BookRateLimiter()
{
super("PacketRateLimiter");
_packetHandler.addPacketHandler(info ->
{
PacketPlayInCustomPayload packet = (PacketPlayInCustomPayload) info.getPacket();
String s = packet.a();
if (!s.equals("MC|BEdit") && !s.equals("MC|BSign"))
{
return;
}
if (_cache.asMap().containsKey(info.getPlayer().getUniqueId()))
{
info.setCancelled(true);
return;
}
_cache.put(info.getPlayer().getUniqueId(), 0);
}, ListenerPriority.LOW, true, PacketPlayInCustomPayload.class);
}
}

View File

@ -280,9 +280,6 @@ public class Clans extends JavaPlugin
MinecraftServer.getServer().getPropertyManager().setProperty("debug", false);
SpigotConfig.debug = false;
// TODO temporary fix for book related crashes.
new BookRateLimiter();
}
public static String prettifyName(Material material)

View File

@ -1,12 +1,9 @@
package mineplex.clanshub;
import static mineplex.core.Managers.require;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.BookRateLimiter;
import mineplex.core.CustomTagFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.account.CoreClientManager;
@ -68,6 +65,8 @@ import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import static mineplex.core.Managers.require;
/**
* Main class for clans hub
*/
@ -184,9 +183,6 @@ public class ClansHub extends JavaPlugin
require(Titles.class);
require(TwoFactorAuth.class);
new WebsiteLinkManager(this, clientManager);
// TODO temporary fix for book related crashes.
new BookRateLimiter();
}
@Override

View File

@ -2,13 +2,13 @@ package mineplex.hub;
import static mineplex.core.Managers.require;
import mineplex.hub.modules.AprilFoolsTreasureHunt;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
import mineplex.core.BookRateLimiter;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.TwitchIntegrationFix;
import mineplex.core.account.CoreClientManager;
@ -79,7 +79,6 @@ import mineplex.core.updater.Updater;
import mineplex.core.velocity.VelocityFix;
import mineplex.core.visibility.VisibilityManager;
import mineplex.core.website.WebsiteLinkManager;
import mineplex.hub.modules.AprilFoolsTreasureHunt;
import mineplex.hub.modules.BillboardManager;
import mineplex.hub.queue.QueueManager;
import mineplex.hub.server.ServerManager;
@ -245,9 +244,6 @@ public class Hub extends JavaPlugin implements IRelation
require(AprilFoolsTreasureHunt.class);
}
require(TwitchIntegrationFix.class);
// TODO temporary fix for book related crashes.
new BookRateLimiter();
}
@Override

View File

@ -1,10 +1,9 @@
package nautilus.game.arcade;
import static mineplex.core.Managers.require;
import java.io.File;
import java.util.HashMap;
import mineplex.core.aprilfools.AprilFoolsManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
@ -17,7 +16,6 @@ import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.BookRateLimiter;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.TimingsFix;
import mineplex.core.TwitchIntegrationFix;
@ -26,7 +24,6 @@ import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antihack.RelationProvider;
import mineplex.core.antihack.logging.AntihackLogger;
import mineplex.core.aprilfools.AprilFoolsManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blood.Blood;
import mineplex.core.boosters.BoosterManager;
@ -89,6 +86,7 @@ import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameServerConfig;
import static mineplex.core.Managers.require;
public class Arcade extends JavaPlugin
{
@ -239,9 +237,6 @@ public class Arcade extends JavaPlugin
MinecraftServer.getServer().getPropertyManager().setProperty("debug", false);
SpigotConfig.debug = false;
// TODO temporary fix for book related crashes.
new BookRateLimiter();
}
@Override

View File

@ -1641,7 +1641,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
// Disables gadgets if player count is greater than 40
int playerCount = UtilServer.getPlayers().length;
getCosmeticManager().getGadgetManager().setGadgetEnabled(playerCount <= 40);
getCosmeticManager().getGadgetManager().setGadgetEnabled(playerCount <= (GetGameHostManager().isEventServer() ? 120 : 40));
}
/*public void saveBasicStats(final Game game)

View File

@ -21,6 +21,8 @@ import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.bridge.animation.BridgeAnimation;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
public abstract class CustomBridgeAnimation extends BridgeAnimation
{
@ -198,7 +200,18 @@ public abstract class CustomBridgeAnimation extends BridgeAnimation
_maxDistance = dist;
}
_restore.add(block, Material.AIR.getId(), (byte) 0, Integer.MAX_VALUE);
int toSet = Material.AIR.getId();
for (Block surround : getNextBlocks(block))
{
if (surround.getType() == Material.WATER || surround.getType() == Material.STATIONARY_WATER)
{
toSet = Material.STATIONARY_WATER.getId();
break;
}
}
_restore.add(block, toSet, (byte) 0, Integer.MAX_VALUE);
_bridgeBlocks.put(block.getLocation(), dist);
}
}
@ -248,4 +261,16 @@ public abstract class CustomBridgeAnimation extends BridgeAnimation
return builder.toString();
}
private List<Block> getNextBlocks(Block block)
{
List<Block> blocks = new ArrayList<>(4);
blocks.add(block.getRelative(BlockFace.NORTH));
blocks.add(block.getRelative(BlockFace.EAST));
blocks.add(block.getRelative(BlockFace.SOUTH));
blocks.add(block.getRelative(BlockFace.WEST));
return blocks;
}
}

View File

@ -19,6 +19,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.event.kits.KitPlayer;
import nautilus.game.arcade.game.games.event.staffoscars.StaffOscarsModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.GameHostManager;
@ -125,7 +126,16 @@ public class EventGame extends Game
.setGiveCompassToAlive(false)
.register(this);
}
@Override
public void ParseData()
{
if (WorldData.MapName.equals("Staff Oscars"))
{
new StaffOscarsModule().register(this);
}
}
@EventHandler
public void registerSigns(GameStateChangeEvent event)
{

View File

@ -6,31 +6,6 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.creature.event.CreatureKillEntitiesEvent;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.give.Give;
import mineplex.core.mount.Mount;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.games.bridge.Bridge;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
@ -54,6 +29,7 @@ import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@ -62,6 +38,36 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.creature.event.CreatureKillEntitiesEvent;
import mineplex.core.event.StackerEvent;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.give.Give;
import mineplex.core.mount.Mount;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.bridge.Bridge;
import nautilus.game.arcade.game.games.smash.SuperSmash;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGames;
import nautilus.game.arcade.kit.Kit;
public class EventModule extends MiniPlugin
{
@ -78,6 +84,8 @@ public class EventModule extends MiniPlugin
private ArrayList<Player> _damage;
private boolean _allowStacker;
private boolean _keepInventory;
public EventModule(ArcadeManager manager, JavaPlugin plugin)
{
super("EventModule", plugin);
@ -159,7 +167,6 @@ public class EventModule extends MiniPlugin
UtilPlayer.message(player, F.value("/e doublejump", "Toggles Double Jump"));
UtilPlayer.message(player, F.value("/e bc", "Broadcast a message with colorcodes"));
UtilPlayer.message(player, F.value("/e tempgadget", "Activates gadget for all player"));
UtilPlayer.message(player, F.value("/e playerdamage", "Toggles damage fpr player"));
UtilPlayer.message(player, F.value("/e stacker [Player]", "toggles stacker global or for Players"));
UtilPlayer.message(player, F.value("/e kick", "Remove a player from the event"));
UtilPlayer.message(player, F.value("/e area PVP|ALL|PVE|EVP|Gadget|Effect / add", "Create and edit areas"));
@ -175,6 +182,18 @@ public class EventModule extends MiniPlugin
UtilPlayer.message(player, F.value("/e effect <player> <type> <mult> <seconds>", ""));
UtilPlayer.message(player, F.value("/e effect <player> clear", ""));
UtilPlayer.message(player, F.value("/e announce <text>", "Broadcasts a 1.8 announcement"));
UtilPlayer.message(player, F.value("/e clear <player>", "Clears players inventory"));
UtilPlayer.message(player, F.value("/e clear all", "Clears all inventories"));
UtilPlayer.message(player, F.value("/e bridge", "Forces Bridges countdown to 10 seconds"));
UtilPlayer.message(player, F.value("/e revive", "Revive a Player"));
UtilPlayer.message(player, F.value("/e keepinventory", ""));
UtilPlayer.message(player, F.value("/e gamekit", "Change kit of a Player"));
UtilPlayer.message(player, F.value("/e smash", "spawn smash Crystal in Smash"));
UtilPlayer.message(player, F.value("/e dm", "start dm in SG"));
UtilPlayer.message(player, F.value("/e supplydrop", "spawn supply Drop in SG"));
UtilPlayer.message(player, F.value("/ea", "Talk in event chat"));
}
public void commandHelpSettings(Player player)
@ -199,9 +218,6 @@ public class EventModule extends MiniPlugin
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>", ""));
UtilPlayer.message(player, F.value("/e time <-1 to 24000>", "Sets World Time"));
//UtilPlayer.message(player, F.value("/e joiningame", "toggles Join In Process for games"));
//UtilPlayer.message(player, F.value("/e deathout", "toggles Deathout in games"));
//UtilPlayer.message(player, F.value("/e quitout", "toggles Quitout in games"));
UtilPlayer.message(player, F.value("/e mobgriefing", "toggles mobgriefing in games"));
}
@ -209,24 +225,30 @@ public class EventModule extends MiniPlugin
@EventHandler(priority = EventPriority.LOWEST)
public void commandHandler(PlayerCommandPreprocessEvent event)
{
if (Manager.GetGame() == null || !Manager.GetGame().InProgress())
return;
if (!event.getMessage().toLowerCase().startsWith("/e "))
if (Manager.GetGame() == null)
return;
boolean eventTestServer = _plugin.getConfig().getString("serverstatus.name").equalsIgnoreCase("SMTestServer-1");
if(!Manager.GetGameHostManager().isEventServer() && !eventTestServer)
return;
//Trim off /e and split to args
String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" ");
if (event.getMessage().toLowerCase().startsWith("/ea"))
{
commandEventChat(event.getPlayer(), args);
event.setCancelled(true);
}
event.setCancelled(true);
if (!event.getMessage().toLowerCase().startsWith("/e "))
return;
if (!Manager.GetGameHostManager().isAdmin(event.getPlayer(), false))
return;
//Trim off /e and split to args
String[] args = event.getMessage().substring(3, event.getMessage().length()).split(" ");
event.setCancelled(true);
if (args.length == 0 || args[0].equalsIgnoreCase("help"))
{
@ -240,7 +262,6 @@ public class EventModule extends MiniPlugin
commandHelpSettings(event.getPlayer());
}
//XXX Commands
else if (args[0].equalsIgnoreCase("tp"))
{
commandTeleport(event.getPlayer(), args);
@ -257,9 +278,90 @@ public class EventModule extends MiniPlugin
{
commandAdmin(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("whitelist"))
{
commandWhitelist(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("give"))
{
commandGive(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("effect"))
{
commandEffect(event.getPlayer(), args, null);
}
else if (args[0].equalsIgnoreCase("mob"))
{
if (args.length >= 2 && args[1].equalsIgnoreCase("kill"))
commandMobKill(event.getPlayer(), args);
else
commandMob(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("bc"))
{
commandBC(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("kick"))
{
if(Bukkit.getPlayer(args[1]) == null)
{
UtilPlayer.message(event.getPlayer(), "No matches for: " + C.cYellow + args[1]);
return;
}
if (Manager.GetGameHostManager().getBlacklist().contains(Bukkit.getPlayer(args[1]).getName()))
{
Manager.GetGameHostManager().getBlacklist().remove(Bukkit.getPlayer(args[1]).getName());
}
else
{
Manager.GetGameHostManager().getBlacklist().add(Bukkit.getPlayer(args[1]).getName());
UtilPlayer.message(event.getPlayer(), F.main("Event", "You removed " + C.cYellow + Bukkit.getPlayer(args[1]).getName()));
}
}
else if(args[0].equalsIgnoreCase("tempgadget"))
{
String gadget = args[1];
for(int e = 2; e < args.length; e++)
gadget+= " " + args[e];
try
{
for(Player target : UtilServer.getPlayers())
Manager.GetDonation().Get(target).addOwnedUnknownSalesPackage(gadget);
}
catch (Exception e)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "Gadget is not vallid"));
}
UtilPlayer.message(event.getPlayer(), F.main("Event", "You gave the gadget " + F.item(gadget) + " to all Players!"));
}
else if (args[0].equalsIgnoreCase("announce"))
{
String text = args[1];
for (int i = 2; i < args.length; i++)
{
text += " " + args[i];
}
UtilTextMiddle.display(C.cDGreenB + "Announcement", text);
UtilServer.broadcast(F.main("Event Announcement", text));
}
if (!Manager.GetGame().InProgress())
return;
//XXX Commands
else if (args[0].equalsIgnoreCase("gm"))
{
commandGamemode(event.getPlayer(), args);
}else if (args[0].equalsIgnoreCase("gamekit"))
{
commandGameKit(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("keepinventory"))
{
commandKeepInventory(event.getPlayer());
}
else if (args[0].equalsIgnoreCase("radius"))
{
@ -273,28 +375,13 @@ public class EventModule extends MiniPlugin
{
commandScoreboard(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("whitelist"))
{
commandWhitelist(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("give"))
{
commandGive(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("effect"))
{
commandEffect(event.getPlayer(), args, null);
}
else if (args[0].equalsIgnoreCase("kit"))
{
commandKit(event.getPlayer(), args);
}
else if (args[0].equalsIgnoreCase("mob"))
else if (args[0].equalsIgnoreCase("revive"))
{
if (args.length >= 2 && args[1].equalsIgnoreCase("kill"))
commandMobKill(event.getPlayer(), args);
else
commandMob(event.getPlayer(), args);
commandRevive(event.getPlayer(), args);
}
@ -366,22 +453,14 @@ public class EventModule extends MiniPlugin
{
commandTime(event.getPlayer(), args);
}
/*else if(args[0].equalsIgnoreCase("joiningame"))
{
commandSpectators(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("deathout"))
{
commandDeathout(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("quitout"))
{
commandQuitOut(event.getPlayer(), args);
}*/
else if(args[0].equalsIgnoreCase("blockplacecreative"))
{
commandBlockPlaceInCreative(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("blockbreakcreative"))
{
commandBlockBreakInCreative(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("stacker"))
{
commandStacker(event.getPlayer(), args);
@ -405,10 +484,6 @@ public class EventModule extends MiniPlugin
else
_damage.add(Bukkit.getPlayer(args[1]));
}
else if(args[0].equalsIgnoreCase("bc"))
{
commandBC(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("area"))
{
if(!(Manager.GetGame() instanceof EventGame)) {
@ -422,46 +497,6 @@ public class EventModule extends MiniPlugin
{
commandMobGriefing(event.getPlayer(), args);
}
else if(args[0].equalsIgnoreCase("kick"))
{
if(Bukkit.getPlayer(args[1]) == null)
{
UtilPlayer.message(event.getPlayer(), "No matches for: " + C.cYellow + args[1]);
return;
}
//Bukkit.getPlayer(args[1]).kickPlayer("You where kicked from the event, probably you didn't stick to the Event Rules.");
Manager.GetGameHostManager().getBlacklist().add(Bukkit.getPlayer(args[1]).getName());
UtilPlayer.message(event.getPlayer(), F.main("Event", "You removed " + C.cYellow + Bukkit.getPlayer(args[1]).getName()));
}
else if(args[0].equalsIgnoreCase("tempgadget"))
{
String gadget = args[1];
for(int e = 2; e < args.length; e++)
gadget+= " " + args[e];
try
{
for(Player target : UtilServer.getPlayers())
Manager.GetDonation().Get(target).addOwnedUnknownSalesPackage(gadget);
}
catch (Exception e)
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "Gadget is not vallid"));
}
UtilPlayer.message(event.getPlayer(), F.main("Event", "You gave the gadget " + F.item(gadget) + " to all Players!"));
}
else if (args[0].equalsIgnoreCase("announce"))
{
String text = args[1];
for (int i = 2; i < args.length; i++)
{
text += " " + args[i];
}
UtilTextMiddle.display(C.cDGreenB + "Announcement", text);
UtilServer.broadcast(F.main("Event Announcement", text));
}
else if (args[0].equalsIgnoreCase("clear"))
{
String playerName = args[1];
@ -528,6 +563,50 @@ public class EventModule extends MiniPlugin
((Bridge) Manager.GetGame()).setBridgeTime((int) ((System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + seconds * 1000));
UtilPlayer.message(event.getPlayer(), F.main("Event", "Bridges will drop in " + F.elem(seconds + " Seconds") + "!"));
}
else if (args[0].equalsIgnoreCase("dm"))
{
if (!(Manager.GetGame() instanceof SurvivalGames))
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only start the deathmatch in SG!"));
return;
}
if (((SurvivalGames) Manager.GetGame()).isDeathMatchTeleported())
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "The Deathmatch has already began!"));
return;
}
Manager.GetGame().Announce(C.cGreen + C.Bold + event.getPlayer().getName()
+ " has initiated Deathmatch!");
Manager.GetGame().Announce(C.cGreen + C.Bold + "Deathmatch starting in 60 seconds...");
((SurvivalGames) Manager.GetGame()).setDeathMatchTime(60);
for (Player player : UtilServer.getPlayers())
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f,
1f);
}
else if (args[0].equalsIgnoreCase("supplydrop"))
{
if (!(Manager.GetGame() instanceof SurvivalGames))
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only start the Supply Srop in SG!"));
return;
}
Manager.GetGame().WorldData.World.setTime(18000);
}
else if (args[0].equalsIgnoreCase("smash"))
{
if (!(Manager.GetGame() instanceof SuperSmash))
{
UtilPlayer.message(event.getPlayer(), F.main("Event", "You can only add a Smash Crystal in Smash!"));
return;
}
((SuperSmash) Manager.GetGame()).setNextPowerupTime(100);
}
}
public void listSettings(Player player)
@ -560,6 +639,80 @@ public class EventModule extends MiniPlugin
UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(Manager.GetGame().BlockBreakCreative)));
}
public void commandKeepInventory(Player player)
{
_keepInventory = !_keepInventory;
UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(_keepInventory)));
}
public void commandGameKit(Player player, String[] args)
{
Player target = player;
String kitString = "";
if (args.length >= 3)
{
Player newTarget = UtilPlayer.searchOnline(player, args[1], true);
if (newTarget != null)
{
target = newTarget;
kitString = args[2];
}
else
return;
}
else
return;
Kit[] kits = Manager.GetGame().GetKits();
Kit kit = null;
for (Kit otherKit : kits)
if (otherKit.GetName().replace(" ", "").equalsIgnoreCase(kitString))
kit = otherKit;
if (kit == null)
{
UtilPlayer.message(player, F.main("Event", "No Kit found"));
return;
}
Manager.GetGame().SetKit(target, kit, true, true);
UtilPlayer.message(player, F.main("Event", "Kit [" + kit.GetName() + "] applied"));
}
public void commandEventChat(Player player, String[] args)
{
String message = ChatColor.BLUE + "[Event Chat] " + ChatColor.GREEN + player.getName() + ": " + F.combine(args, 1, null, false);
UtilPlayer.message(player, message);
for (Player other : UtilServer.getPlayers())
{
if (player == other)
continue;
if (Manager.GetGameHostManager().isAdmin(other, true))
UtilPlayer.message(other, message);
}
}
public void commandRevive(Player player, String[] args)
{
Player target = player;
if (args.length >= 2)
{
Player newTarget = UtilPlayer.searchOnline(player, args[1], true);
if (newTarget != null)
target = newTarget;
else
return;
}
Manager.GetGame().SetPlayerState(target, PlayerState.IN);
Manager.GetGame().RespawnPlayer(target);
UtilPlayer.message(target, F.main("Game", "You have been Respawned!"));
}
public void commandStacker(Player player, String[] args)
{
if(args.length == 1)
@ -861,7 +1014,8 @@ public class EventModule extends MiniPlugin
//Gadget Commands (Global & Individual)
public void commandGadget(Player player, String[] args)
{
if(!(Manager.GetGame() instanceof EventGame)) {
if(!(Manager.GetGame() instanceof EventGame))
{
UtilPlayer.message(player, F.main("Inventory", "You can only enable/disable gadgets in the Event game!"));
return;
}
@ -2003,6 +2157,33 @@ public class EventModule extends MiniPlugin
}
}
@EventHandler(priority=EventPriority.HIGHEST)
public void death(PlayerDeathEvent event)
{
if (Manager.GetGame() == null)
return;
if (!Manager.GetGame().InProgress())
return;
if (!_keepInventory)
return;
ArrayList<ItemStack> stacks = new ArrayList<>();
stacks.addAll(event.getDrops());
event.getDrops().clear();
Manager.runSyncLater(new Runnable()
{
@Override
public void run()
{
for (ItemStack item : stacks)
event.getEntity().getInventory().addItem(item);
}
}, 40);
}
public ArrayList<Player> getDamagePlayers()
{
return _damage;

View File

@ -0,0 +1,41 @@
package nautilus.game.arcade.game.games.event.staffoscars;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
public class ChairData
{
private Player _player;
private Block _block;
private ArmorStand _stand;
public ChairData(Player player, Block block)
{
_player = player;
_block = block;
_stand = block.getWorld().spawn(block.getLocation().add(0.5, -0.4, 0.5), ArmorStand.class);
_stand.setGravity(false);
_stand.setSmall(true);
_stand.setVisible(false);
_stand.setPassenger(player);
}
public Player getPlayer()
{
return _player;
}
public Block getBlock()
{
return _block;
}
public ArmorStand getStand()
{
return _stand;
}
}

View File

@ -0,0 +1,110 @@
package nautilus.game.arcade.game.games.event.staffoscars;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Color;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.util.Vector;
import java.util.HashSet;
import java.util.Set;
public class RainbowSheep implements Listener
{
private static final Color[] COLOURS = {
Color.RED, Color.ORANGE, Color.YELLOW, Color.LIME, Color.AQUA, Color.BLUE, Color.PURPLE
};
private final Set<Sheep> _sheep;
private Player _player;
private boolean _active;
private long _start;
public RainbowSheep()
{
_sheep = new HashSet<>();
}
@EventHandler
public void updateSpawn(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER || !_active)
{
return;
}
if (UtilTime.elapsed(_start, 5000))
{
for (Sheep sheep : _sheep)
{
sheep.remove();
}
_sheep.clear();
_active = false;
return;
}
Vector direction = _player.getLocation().getDirection();
Vector left = UtilAlg.getLeft(direction).add(direction.clone().multiply(1.5));
Vector right = UtilAlg.getRight(direction).add(direction.clone().multiply(1.5));
spawnSheep(_player, direction);
spawnSheep(_player, left);
spawnSheep(_player, right);
}
@EventHandler
public void updateParticles(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
{
return;
}
for (Sheep sheep : _sheep)
{
UtilParticle.playColoredParticleToAll(COLOURS[UtilMath.r(COLOURS.length)], UtilParticle.ParticleType.RED_DUST, sheep.getLocation().add(0, 0.75, 0), 2, UtilParticle.ViewDist.LONGER);
}
}
@EventHandler
public void entityDamage(EntityDamageEvent event)
{
if (_sheep.contains(event.getEntity()))
{
event.setCancelled(true);
}
}
private void spawnSheep(Player player, Vector vector)
{
Sheep sheep = player.getWorld().spawn(player.getEyeLocation(), Sheep.class);
sheep.setCustomName("jeb_");
sheep.setVelocity(vector);
_sheep.add(sheep);
}
public void setActive(Player player)
{
_player = player;
_active = true;
_start = System.currentTimeMillis();
}
public boolean isActive()
{
return _active;
}
}

View File

@ -0,0 +1,257 @@
package nautilus.game.arcade.game.games.event.staffoscars;
import mineplex.core.common.util.*;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.modules.Module;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class StaffOscarsModule extends Module
{
private static final int MAX_X = 18;
private List<Location> _blocks;
private boolean _open;
private boolean _animate;
private int _x;
private Location _center;
private Set<ChairData> _chairs;
private List<Location> _fireworks;
private RainbowSheep _sheep;
@Override
protected void setup()
{
_chairs = new HashSet<>();
_blocks = getGame().WorldData.GetCustomLocs(String.valueOf(Material.EMERALD_BLOCK.getId()));
_center = UtilAlg.getAverageLocation(_blocks);
_fireworks = getGame().WorldData.GetDataLocs("YELLOW");
_sheep = new RainbowSheep();
UtilServer.RegisterEvents(_sheep);
}
@Override
public void cleanup()
{
UtilServer.Unregister(_sheep);
}
@EventHandler
public void prepare(GameStateChangeEvent event)
{
if (event.GetState() != Game.GameState.Prepare)
{
return;
}
for (Location location : _blocks)
{
MapUtil.QuickChangeBlockAt(location, Material.WOOL, (byte) 14);
}
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !_animate)
{
return;
}
for (Location location : _blocks)
{
boolean in = UtilMath.offset2d(location, _center) < _x;
if (in && _open)
{
MapUtil.QuickChangeBlockAt(location, Material.AIR);
}
else if (!in && !_open)
{
MapUtil.QuickChangeBlockAt(location, Material.WOOL, (byte) 14);
}
}
if (_open)
{
_x++;
}
else
{
_x--;
}
if (_open && _x == MAX_X || !_open && _x == -1)
{
_animate = false;
}
}
@EventHandler
public void curtainCommand(PlayerCommandPreprocessEvent event)
{
String message = event.getMessage();
if (message.startsWith("/curtain") && getGame().getArcadeManager().GetGameHostManager().isAdmin(event.getPlayer(), false))
{
_open = !_open;
_animate = true;
event.setCancelled(true);
event.getPlayer().sendMessage(F.main("Event", "Curtain open state = " + _open + "."));
}
}
@EventHandler
public void chairInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
Block block = event.getClickedBlock();
if (block == null)
{
return;
}
if (UtilBlock.usable(block))
{
event.setCancelled(true);
}
if (block.getType() != Material.WOOD_STAIRS)
{
return;
}
for (ChairData data : _chairs)
{
if (data.getBlock().equals(block))
{
return;
}
if (data.getPlayer().equals(player))
{
handleDismount(player);
break;
}
}
_chairs.add(new ChairData(player, block));
}
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
handleDismount(event.getPlayer());
}
@EventHandler
public void updateDismount(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST)
{
return;
}
Iterator<ChairData> iterator = _chairs.iterator();
while (iterator.hasNext())
{
ChairData data = iterator.next();
if (data.getPlayer().isInsideVehicle())
{
continue;
}
data.getStand().remove();
iterator.remove();
}
}
private void handleDismount(Player player)
{
Iterator<ChairData> iterator = _chairs.iterator();
while (iterator.hasNext())
{
ChairData data = iterator.next();
if (!data.getPlayer().equals(player))
{
continue;
}
data.getStand().remove();
iterator.remove();
}
}
@EventHandler
public void armourStandEdit(PlayerArmorStandManipulateEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void fireworksCommand(PlayerCommandPreprocessEvent event)
{
String message = event.getMessage();
if (message.startsWith("/firework") && getGame().getArcadeManager().GetGameHostManager().isAdmin(event.getPlayer(), false))
{
event.setCancelled(true);
FireworkEffect fireworkEffect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.YELLOW).build();
for (Location location : _fireworks)
{
for (int i = 0; i < 4; i++)
{
UtilFirework.launchFirework(location, fireworkEffect, null, UtilMath.r(3) + 1);
}
}
}
}
@EventHandler
public void rainbowSheepCommand(PlayerCommandPreprocessEvent event)
{
String message = event.getMessage();
if (!message.startsWith("/deantm") || !getGame().getArcadeManager().GetGameHostManager().isAdmin(event.getPlayer(), false))
{
return;
}
if (_sheep.isActive())
{
return;
}
event.setCancelled(true);
_sheep.setActive(event.getPlayer());
}
}

View File

@ -731,4 +731,9 @@ public abstract class SuperSmash extends Game
{
return GetState() == GameState.Recruit;
}
public void setNextPowerupTime(long time)
{
_nextPowerup = time;
}
}

View File

@ -2184,5 +2184,10 @@ public abstract class SurvivalGames extends Game
{
return _spawn;
}
public void setDeathMatchTime(int time)
{
_deathMatchTime = time;
}
}

View File

@ -26,6 +26,9 @@ public class PlayerHeadButton implements IButton
int maxCap = _arcadeManager.GetGameHostManager().getMaxPlayerCap();
if (_arcadeManager.GetGameHostManager().isEventServer())
maxCap = 120;
if (clickType.isLeftClick())
newMax = ++maxPlayers > maxCap ? maxCap : maxPlayers;
else