Fixes for Win Room (Players were able to see other players)

Added command to allow other players to run ranked commands
Fixes code styles
This commit is contained in:
LCastr0 2016-05-22 21:05:48 -03:00
parent 92b6abc884
commit ed68ef332b
32 changed files with 255 additions and 158 deletions

View File

@ -1,15 +1,6 @@
package mineplex.core.common.util;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
import java.util.*;
import net.minecraft.server.v1_8_R3.*;
import org.bukkit.ChatColor;
@ -37,11 +28,14 @@ public class UtilPlayer
private static Random RANDOM = new Random();
// A mapping of player names (Keys) to the system time when they last changed active Hotbar Slot
private static Map<String, Long> _hotbarUpdates = new HashMap<String, Long>();
private static Map<String, Long> _hotbarUpdates = new HashMap<>();
// A mapping of player UUIDs (Keys) to the world border they are using (if they are using)
private static final Map<UUID, WorldBorder> WORLD_BORDERS = new HashMap<>();
// A mapping of player UUIDs (Keys) to the list of command they're allowed
private static final Map<UUID, List<String>> ALLOWED_COMMANDS = new HashMap<>();
// A mapping of player names (Keys) to the world border they are using (if they are using)
private static final Map<UUID, WorldBorder> _worldBorders = new HashMap<UUID, WorldBorder>();
// The amount of time (in milliseconds) after changin hotbars that you can block
public static final long BLOCKING_HOTBAR_DELAY = 100;
@ -864,13 +858,13 @@ public class UtilPlayer
*/
public static void sendRedScreen(Player player, int warningDistance)
{
WorldBorder worldBorder = _worldBorders.computeIfAbsent(player.getUniqueId(), uuid -> new WorldBorder());
WorldBorder worldBorder = WORLD_BORDERS.computeIfAbsent(player.getUniqueId(), uuid -> new WorldBorder());
worldBorder.setCenter(player.getLocation().getX(), player.getLocation().getZ());
worldBorder.setSize(10000);
worldBorder.setWarningDistance(warningDistance);
PacketPlayOutWorldBorder packet = new PacketPlayOutWorldBorder(worldBorder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE);
sendPacket(player, packet);
_worldBorders.put(player.getUniqueId(), worldBorder);
WORLD_BORDERS.put(player.getUniqueId(), worldBorder);
}
/**
@ -880,7 +874,7 @@ public class UtilPlayer
*/
public static boolean hasWorldBorder(Player player)
{
return _worldBorders.containsKey(player.getUniqueId());
return WORLD_BORDERS.containsKey(player.getUniqueId());
}
/**
@ -892,7 +886,7 @@ public class UtilPlayer
if (hasWorldBorder(player))
{
sendRedScreen(player, 0);
_worldBorders.remove(player.getUniqueId());
WORLD_BORDERS.remove(player.getUniqueId());
}
}
@ -903,4 +897,44 @@ public class UtilPlayer
return MinecraftVersion.Version1_8;
}
/**
* Allows player to run specific command
* @param player The player to be allowed
* @param command The command that will be allowed
*/
public static void allowCommand(Player player, String command)
{
List<String> commandList = new ArrayList<>();
if (ALLOWED_COMMANDS.containsKey(player.getUniqueId()))
commandList = ALLOWED_COMMANDS.get(player.getUniqueId());
if (!commandList.contains(command))
commandList.add(command);
ALLOWED_COMMANDS.put(player.getUniqueId(), commandList);
}
/**
* Disallows player to run specific command
* @param player The player to be disallowed
* @param command The command that will be disallowed
* @return True if player had command allowed
*/
public static boolean disallowCommand(Player player, String command)
{
if (!isCommandAllowed(player, command))
return false;
List<String> commandList = ALLOWED_COMMANDS.get(player.getUniqueId());
commandList.remove(command);
ALLOWED_COMMANDS.put(player.getUniqueId(), commandList);
return true;
}
public static boolean isCommandAllowed(Player player, String command)
{
if (!ALLOWED_COMMANDS.containsKey(player.getUniqueId()))
return false;
if (!ALLOWED_COMMANDS.get(player.getUniqueId()).contains(command))
return false;
return true;
}
}

View File

@ -1,8 +1,5 @@
package mineplex.core;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
@ -99,12 +96,12 @@ public abstract class MiniPlugin implements Listener
public final void addCommand(ICommand command)
{
CommandCenter.Instance.AddCommand(command);
CommandCenter.Instance.addCommand(command);
}
public final void removeCommand(ICommand command)
{
CommandCenter.Instance.RemoveCommand(command);
CommandCenter.Instance.removeCommand(command);
}
public void log(String message)

View File

@ -38,7 +38,7 @@ public class TestRank extends CommandBase<CoreClientManager>
if (args == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + AliasUsed + " MODERATOR"));
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + _aliasUsed + " MODERATOR"));
}
else
{

View File

@ -30,7 +30,7 @@ public class UpdateRank extends CommandBase<CoreClientManager>
{
if (args == null)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + AliasUsed + " joeschmo MODERATOR"));
UtilPlayer.message(caller, F.main(Plugin.getName(), "/" + _aliasUsed + " joeschmo MODERATOR"));
}
else
{

View File

@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.bonuses.animations.AnimationCarl;
import mineplex.core.bonuses.commands.AllowCommand;
import mineplex.core.bonuses.commands.AnimationCommand;
import mineplex.core.bonuses.commands.GuiCommand;
import mineplex.core.bonuses.commands.TicketCommand;
@ -220,6 +221,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
addCommand(new GuiCommand(this));
addCommand(new AnimationCommand(this));
addCommand(new TicketCommand(this));
addCommand(new AllowCommand(this));
}
// Just keeping things up-to-date

View File

@ -0,0 +1,83 @@
package mineplex.core.bonuses.commands;
import java.util.Arrays;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.command.CommandBase;
import mineplex.core.command.CommandCenter;
import mineplex.core.command.ICommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.entity.Player;
/**
* Allows players to run rank-specific commands
* Found no better place to create it
*/
public class AllowCommand extends CommandBase<BonusManager>
{
private BonusManager _plugin;
public AllowCommand(BonusManager plugin)
{
super(plugin, Rank.MODERATOR, "allowCommand", "allowCmd");
_plugin = plugin;
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length < 2 || args.length > 3)
{
UtilPlayer.message(caller, F.main("Allow Command", "Usage: /allowCmd <player> <command> [disallow]"));
return;
}
NautHashMap<String, ICommand> commands = CommandCenter.getCommands();
if (!commands.containsKey(args[1].toLowerCase()))
{
UtilPlayer.message(caller, F.main("Allow Command", "Command not found!"));
return;
}
ICommand iCommand = commands.get(args[1]);
Rank playerRank = _plugin.getClientManager().Get(caller).GetRank();
if (playerRank.compareTo(iCommand.GetRequiredRank()) > 0
&& Arrays.asList(iCommand.GetSpecificRanks()).contains(playerRank))
{
UtilPlayer.message(caller, F.main("Allow Command", "You're not allowed to use that command!"));
return;
}
boolean disallow = false;
if (args.length == 3)
disallow = Boolean.parseBoolean(args[2]);
Player receiver = UtilPlayer.searchExact(args[0]);
if (receiver == null)
{
UtilPlayer.message(caller, F.main("Allow Command", "Could not find player " + F.name(args[0]) + "!"));
return;
}
if (receiver.getUniqueId().equals(caller.getUniqueId()))
{
UtilPlayer.message(caller, F.main("Allow Command", "You can't use that for yourself!"));
return;
}
if (disallow)
{
boolean canDisallow = UtilPlayer.disallowCommand(receiver, args[1].toLowerCase());
if (!canDisallow)
{
UtilPlayer.message(caller, F.main("Allow Command", "That command was not allowed for the player " + F.name(receiver.getName()) + "!"));
return;
}
UtilPlayer.message(caller, F.main("Allow Command", "You disallowed the player " + F.name(receiver.getName()) + " to use the command " + F.elem(args[1]) + "!"));
UtilPlayer.message(receiver, F.main("Allow Command", "The player " + F.name(caller.getName()) + " disallowed you to use the command " + F.elem(args[1]) + "!"));
return;
}
UtilPlayer.allowCommand(receiver, args[1].toLowerCase());
UtilPlayer.message(caller, F.main("Allow Command", "You allowed the player " + F.name(receiver.getName()) + " to use the command " + F.elem(args[1]) + "!"));
UtilPlayer.message(receiver, F.main("Allow Command", "The player " + F.name(caller.getName()) + " allowed you to use the command " + F.elem(args[1]) + "!"));
}
}

View File

@ -28,7 +28,7 @@ public class ChatCacheCommand extends CommandBase<SnapshotPlugin>
{
if (args.length != 1)
{
UtilPlayer.message(caller, F.main(Plugin.getName(), String.format("Invalid arguments, usage: /%s <player>", AliasUsed)));
UtilPlayer.message(caller, F.main(Plugin.getName(), String.format("Invalid arguments, usage: /%s <player>", _aliasUsed)));
return;
}

View File

@ -21,8 +21,8 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
private List<String> _aliases;
protected PluginType Plugin;
protected String AliasUsed;
protected CommandCenter CommandCenter;
protected String _aliasUsed;
protected CommandCenter _commandCenter;
public CommandBase(PluginType plugin, Rank requiredRank, String...aliases)
{
@ -47,7 +47,7 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
public void SetAliasUsed(String alias)
{
AliasUsed = alias;
_aliasUsed = alias;
}
public Rank GetRequiredRank()
@ -62,7 +62,7 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
public void SetCommandCenter(CommandCenter commandCenter)
{
CommandCenter = commandCenter;
_commandCenter = commandCenter;
}
protected void resetCommandCharge(Player caller)

View File

@ -1,10 +1,9 @@
package mineplex.core.command;
import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import org.bukkit.event.EventHandler;
@ -18,7 +17,7 @@ public class CommandCenter implements Listener
protected JavaPlugin Plugin;
protected CoreClientManager ClientManager;
protected NautHashMap<String, ICommand> Commands;
protected static NautHashMap<String, ICommand> Commands;
public static void Initialize(JavaPlugin plugin)
{
@ -34,7 +33,7 @@ public class CommandCenter implements Listener
private CommandCenter(JavaPlugin instance)
{
Plugin = instance;
Commands = new NautHashMap<String, ICommand>();
Commands = new NautHashMap<>();
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
}
@ -44,7 +43,7 @@ public class CommandCenter implements Listener
}
@EventHandler
public void OnPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
String commandName = event.getMessage().substring(1);
String[] args = new String[] {};
@ -61,7 +60,8 @@ public class CommandCenter implements Listener
{
event.setCancelled(true);
if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true))
if (ClientManager.Get(event.getPlayer()).GetRank().has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true)
|| UtilPlayer.isCommandAllowed(event.getPlayer(), commandName.toLowerCase()))
{
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
{
@ -76,7 +76,7 @@ public class CommandCenter implements Listener
}
public void AddCommand(ICommand command)
public void addCommand(ICommand command)
{
for (String commandRoot : command.Aliases())
{
@ -85,7 +85,7 @@ public class CommandCenter implements Listener
}
}
public void RemoveCommand(ICommand command)
public void removeCommand(ICommand command)
{
for (String commandRoot : command.Aliases())
{
@ -93,4 +93,9 @@ public class CommandCenter implements Listener
command.SetCommandCenter(null);
}
}
public static NautHashMap<String, ICommand> getCommands()
{
return Commands;
}
}

View File

@ -33,7 +33,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
for (String commandRoot : command.Aliases())
{
Commands.put(commandRoot, command);
command.SetCommandCenter(CommandCenter);
command.SetCommandCenter(_commandCenter);
}
}
@Override
@ -59,7 +59,7 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
ICommand command = Commands.get(commandName);
if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
if (command != null && _commandCenter.ClientManager.Get(caller).GetRank().has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
{
command.SetAliasUsed(commandName);

View File

@ -31,7 +31,7 @@ public class AddFriend extends CommandBase<FriendManager>
}
else
{
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
_commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
{
public void run(String result)
{

View File

@ -22,7 +22,7 @@ public class DeleteFriend extends CommandBase<FriendManager>
F.main(Plugin.getName(), "You need to include a player's name.");
else
{
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
_commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
{
public void run(String result)
{

View File

@ -32,7 +32,6 @@ import mineplex.core.friend.FriendManager;
import mineplex.core.friend.FriendStatusType;
import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendStatus;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.itemstack.ItemLayout;
import mineplex.core.shop.item.IButton;
@ -159,7 +158,7 @@ public class FriendsGUI implements Listener
{
if (clickType.isLeftClick())
{
CommandCenter.Instance.OnPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(player, "/unfriend "
CommandCenter.Instance.onPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(player, "/unfriend "
+ name));
}
}
@ -400,7 +399,7 @@ public class FriendsGUI implements Listener
{
_player.closeInventory();
CommandCenter.Instance.OnPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(_player, "/friendsdisplay"));
CommandCenter.Instance.onPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(_player, "/friendsdisplay"));
return;
}
@ -524,7 +523,7 @@ public class FriendsGUI implements Listener
if (isSender || clickType.isRightClick())
{
_plugin.removeFriend(_player, name);
// CommandCenter.Instance.OnPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(player, "/unfriend "
// _commandCenter.Instance.onPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(player, "/unfriend "
// + name));
_inventory.setItem(slot, new ItemStack(Material.AIR));
@ -533,7 +532,7 @@ public class FriendsGUI implements Listener
else if (!isSender && clickType.isLeftClick())
{
_plugin.addFriend(_player, name);
// CommandCenter.Instance.OnPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(player, "/friend "
// _commandCenter.Instance.onPlayerCommandPreprocess(new PlayerCommandPreprocessEvent(player, "/friend "
// + name));
_inventory.setItem(slot, new ItemStack(Material.AIR));

View File

@ -65,10 +65,10 @@ public class WinEffectBabyChicken extends WinEffectGadget
_tick = 0;
List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation(), team.size(), 3);
for(int i = 0; i < team.size(); i++)
List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation(), _team.size(), 3);
for(int i = 0; i < _team.size(); i++)
{
Player p = team.get(i);
Player p = _team.get(i);
Location l = circle.get(i);
l.setDirection(getBaseLocation().toVector().subtract(l.toVector()));
Chicken c = spawnChicken(p, l);
@ -181,7 +181,7 @@ public class WinEffectBabyChicken extends WinEffectGadget
UtilParticle.PlayParticleToAll(ParticleType.EXPLODE, _chicken.getLocation().add(0, 0.15, 0), 0.3f, 0.3f, 0.3f, 0.1f, 50, ViewDist.NORMAL);
_chicken = null;
_teamChickens.forEach(c -> c.remove());
team.forEach(p -> UtilPlayer.showForAll(p));
_team.forEach(p -> UtilPlayer.showForAll(p));
}
@Override

View File

@ -50,11 +50,11 @@ public class WinEffectLavaTrap extends WinEffectGadget
int maxPerRow = 6;
for(int index = 0; index < nonTeam.size(); index++)
for(int index = 0; index < _nonTeam.size(); index++)
{
int row = index/maxPerRow;
int inRow = index%maxPerRow;
int rowSize = Math.min(nonTeam.size()-(row*maxPerRow), maxPerRow);
int rowSize = Math.min(_nonTeam.size()-(row*maxPerRow), maxPerRow);
Vector f = forward.clone().multiply(2.5 + row);
Vector r = right.clone().multiply((-rowSize/2.0) + 0.5);
@ -63,14 +63,14 @@ public class WinEffectLavaTrap extends WinEffectGadget
Location loc = getBaseLocation().add(f).add(r);
loc.setDirection(getBaseLocation().subtract(loc).toVector());
((ArmorStand)getNPC(nonTeam.get(index), loc).GetEntity().getBukkitEntity()).setGravity(true);
((ArmorStand)getNPC(_nonTeam.get(index), loc).GetEntity().getBukkitEntity()).setGravity(true);
}
for(int index = 0; index < team.size(); index++)
for(int index = 0; index < _team.size(); index++)
{
int row = index/maxPerRow;
int inRow = index%maxPerRow;
int rowSize = Math.min(team.size()-(row*maxPerRow), maxPerRow);
int rowSize = Math.min(_team.size()-(row*maxPerRow), maxPerRow);
Vector f = forward.clone().multiply(3 + row).multiply(-1);
Vector r = right.clone().multiply((-rowSize/2.0) + 0.5);
@ -79,7 +79,7 @@ public class WinEffectLavaTrap extends WinEffectGadget
Location loc = getBaseLocation().add(f).add(r);
loc.setDirection(getBaseLocation().subtract(loc).toVector());
((ArmorStand)getNPC(team.get(index), loc).GetEntity().getBukkitEntity()).setGravity(true);
((ArmorStand)getNPC(_team.get(index), loc).GetEntity().getBukkitEntity()).setGravity(true);
}
}

View File

@ -39,13 +39,13 @@ public class WinEffectMrPunchMan extends WinEffectGadget
{
_npc = getNPC(_player, getBaseLocation());
List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation(), other.size(), 3);
List<Location> circle = UtilShapes.getPointsInCircle(getBaseLocation(), _other.size(), 3);
_playersLeft = new ArrayList<>();
for(int i = 0; i < other.size(); i++)
for(int i = 0; i < _other.size(); i++)
{
_playersLeft.add((ArmorStand) getNPC(other.get(i), circle.get(i)).GetEntity().getBukkitEntity());
_playersLeft.add((ArmorStand) getNPC(_other.get(i), circle.get(i)).GetEntity().getBukkitEntity());
}
_nextHit = getNextHit() + 1000;

View File

@ -6,9 +6,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.mysql.jdbc.Util;
import mineplex.core.common.util.*;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
@ -27,7 +26,6 @@ import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.gadget.GadgetManager;
import org.bukkit.scheduler.BukkitRunnable;
import org.jooq.util.derby.sys.Sys;
/**
* A wrapper for different win effects
@ -48,12 +46,12 @@ public abstract class WinEffectGadget extends Gadget
protected String _schematicName = "WinRoomPodium";
/** All the players on the winners team. Empty if solo game. */
protected List<Player> team;
protected List<Player> _team;
/** All the other players on the other teams that didn't win. */
protected List<Player> nonTeam;
protected List<Player> _nonTeam;
/** All players on the team that didn't win + spectators which were not in the game at all. */
protected List<Player> other;
protected List<Player> _other;
/**
* @param manager The normal GadgetManager
* @param name The display name of the WinEffect
@ -116,7 +114,6 @@ public abstract class WinEffectGadget extends Gadget
{
p.setWalkSpeed(0);
p.setFlySpeed(0);
p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 250, true, false), true);
}
/**
@ -127,7 +124,6 @@ public abstract class WinEffectGadget extends Gadget
{
p.setWalkSpeed(0.2f);
p.setFlySpeed(0.1f);
p.removePotionEffect(PotionEffectType.JUMP);
}
@EventHandler
@ -157,12 +153,12 @@ public abstract class WinEffectGadget extends Gadget
UtilServer.getPlayersCollection().forEach(p -> {unlockPlayer(p); UtilPlayer.showForAll(p); });
_player = null;
_baseLocation = null;
team.clear();
team = null;
nonTeam.clear();
nonTeam = null;
other.clear();
other = null;
_team.clear();
_team = null;
_nonTeam.clear();
_nonTeam = null;
_other.clear();
_other = null;
}
/**
@ -221,14 +217,14 @@ public abstract class WinEffectGadget extends Gadget
public void setup(Player player, List<Player> team, List<Player> nonTeam, Location loc)
{
this._player = player;
this.team = team;
this.nonTeam = nonTeam;
_player = player;
_team = team;
_nonTeam = nonTeam;
this.other = new ArrayList<>();
other.addAll(UtilServer.getPlayersCollection());
other.remove(player);
other.removeAll(team);
_other = new ArrayList<>();
_other.addAll(UtilServer.getPlayersCollection());
_other.remove(player);
_other.removeAll(team);
this._start = System.currentTimeMillis();
this._baseLocation = loc.clone();
@ -255,15 +251,21 @@ public abstract class WinEffectGadget extends Gadget
loc.getBlock().setType(Material.AIR);
loc.getBlock().getRelative(BlockFace.UP).setType(Material.AIR);
loc.getBlock().getRelative(BlockFace.DOWN).setType(Material.BARRIER);
loc.getBlock().getRelative(BlockFace.EAST).getRelative(BlockFace.UP).setType(Material.BARRIER);
loc.getBlock().getRelative(BlockFace.WEST).getRelative(BlockFace.UP).setType(Material.BARRIER);
loc.getBlock().getRelative(BlockFace.NORTH).getRelative(BlockFace.UP).setType(Material.BARRIER);
loc.getBlock().getRelative(BlockFace.SOUTH).getRelative(BlockFace.UP).setType(Material.BARRIER);
loc.clone().add(0, 2, 0).getBlock().setType(Material.BARRIER);
BukkitRunnable bRunnable = new BukkitRunnable() {
@Override
public void run() {
for(Player p : UtilServer.getPlayers()) {
lockPlayer(p);
UtilPlayer.hideFromAll(p);
p.getInventory().clear();
p.teleport(loc);
lockPlayer(p);
p.setAllowFlight(false);
UtilPlayer.hideFromAll(p);
}
}
};
@ -311,7 +313,8 @@ public abstract class WinEffectGadget extends Gadget
try
{
Schematic schematic = UtilSchematic.loadSchematic(new File("schematic" + File.separator + schematicName + ".schematic"));
schematic.paste(getBaseLocation(), false, true);
if (schematic != null)
schematic.paste(getBaseLocation(), false, true);
return schematic;
}
catch(IOException e)

View File

@ -23,7 +23,7 @@ public class Ignore extends CommandBase<IgnoreManager>
}
else
{
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
_commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
{
public void run(String result)
{

View File

@ -22,7 +22,7 @@ public class Unignore extends CommandBase<IgnoreManager>
caller.sendMessage(F.main(Plugin.getName(), "You need to include a player's name."));
else
{
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
_commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
{
public void run(String result)
{

View File

@ -25,10 +25,10 @@ public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
if (Plugin.toggle(caller))
{
UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem("/" + AliasUsed) + " again."));
UtilPlayer.message(caller, F.main("Incognito", "You are now incognito. Your status will only change when you run " + F.elem("/" + _aliasUsed) + " again."));
} else
{
UtilPlayer.message(caller, F.main("Incognito", "You are no longer incognito. Your status will only change when you run " + F.elem("/" + AliasUsed) + " again."));
UtilPlayer.message(caller, F.main("Incognito", "You are no longer incognito. Your status will only change when you run " + F.elem("/" + _aliasUsed) + " again."));
}
}
}

View File

@ -39,7 +39,7 @@ public class PollCommand extends CommandBase<PollManager>
return;
}
if (args[0].equalsIgnoreCase("list") && CommandCenter.GetClientManager().Get(caller).GetRank().has(Rank.MODERATOR))
if (args[0].equalsIgnoreCase("list") && _commandCenter.GetClientManager().Get(caller).GetRank().has(Rank.MODERATOR))
{
if (args.length == 1)
{

View File

@ -30,7 +30,7 @@ public class SendCommand extends CommandBase<Portal>
final String playerTarget = args[0];
final String serverTarget = args[1];
CommandCenter.GetClientManager().checkPlayerName(player, playerTarget, new Callback<String>()
_commandCenter.GetClientManager().checkPlayerName(player, playerTarget, new Callback<String>()
{
public void run(final String playerName)
{

View File

@ -20,7 +20,7 @@ public class ServerCommand extends CommandBase<Portal>
@Override
public void Execute(final Player player, final String[] args)
{
final Rank playerRank = CommandCenter.GetClientManager().Get(player).GetRank();
final Rank playerRank = _commandCenter.GetClientManager().Get(player).GetRank();
final String serverName = Plugin.getPlugin().getConfig().getString("serverstatus.name");
if (args == null || args.length == 0)

View File

@ -10,7 +10,6 @@ import java.util.UUID;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.chatsnap.Snapshot;
import mineplex.core.chatsnap.SnapshotManager;
@ -120,7 +119,7 @@ public class ReportManager
F.main(getReportPrefix(reportId), String.format("%s closed the report for: %s (%s).",
reportCloser.getName(), reason, result.toDisplayMessage() + C.mBody)));
CommandCenter.Instance.OnPlayerCommandPreprocess(
CommandCenter.Instance.onPlayerCommandPreprocess(
new PlayerCommandPreprocessEvent(reportCloser, "/punish " + suspectName + " " + reason));
}

View File

@ -21,7 +21,7 @@ public class ReportCommand extends CommandBase<ReportPlugin>
@Override
public void Execute(final Player player, final String[] args)
{
if (!CommandCenter.GetClientManager().hasRank(player, Rank.ULTRA))
if (!_commandCenter.GetClientManager().hasRank(player, Rank.ULTRA))
{
UtilPlayer.message(player, F.main(Plugin.getName(), C.cRed + "The report feature is currently in a trial phase for Ultra+ players"));
}

View File

@ -6,7 +6,6 @@ import mineplex.core.command.MultiCommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.teleport.Teleport;
public class TeleportCommand extends MultiCommandBase<Teleport>
@ -30,15 +29,15 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
}
//Caller to Player
if (args.length == 1 && CommandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.MODERATOR, true))
if (args.length == 1 && _commandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.MODERATOR, true))
Plugin.playerToPlayer(caller, caller.getName(), args[0]);
//Player to Player
else if (args.length == 2 && CommandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true))
else if (args.length == 2 && _commandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true))
Plugin.playerToPlayer(caller, args[0], args[1]);
//Caller to Loc
else if (args.length == 3 && CommandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true))
else if (args.length == 3 && _commandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true))
Plugin.playerToLoc(caller, caller.getName(), args[0], args[1], args[2]);
//Player to world
@ -46,7 +45,7 @@ public class TeleportCommand extends MultiCommandBase<Teleport>
Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3], args[4]);
//Player to Loc
else if (args.length == 4 && CommandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true))
else if (args.length == 4 && _commandCenter.GetClientManager().Get(caller).GetRank().has(caller, Rank.ADMIN, true))
Plugin.playerToLoc(caller, args[0], args[1], args[2], args[3]);
else
{

View File

@ -201,7 +201,6 @@ public class TreasureLocation implements Listener
private void chargeAccount(Player player, TreasureType treasureType, Callback<Boolean> callback)
{
int itemCount = _inventoryManager.Get(player).getItemCount(treasureType.getItemName());
player.sendMessage("COUNT: " + itemCount);
if (itemCount > 0)
{
// Should always handle the callback for us

View File

@ -147,7 +147,7 @@ public class Clans extends JavaPlugin
//SnapshotManager snapshotManager = new SnapshotManager(new SnapshotPublisher(this));
//new SnapshotPlugin(this, snapshotManager);
//new ReportPlugin(this, new ReportManager(this, preferenceManager, statsManager, snapshotManager, CommandCenter.Instance.GetClientManager(), serverStatusManager.getCurrentServerName()));
//new ReportPlugin(this, new ReportManager(this, preferenceManager, statsManager, snapshotManager, _commandCenter.Instance.GetClientManager(), serverStatusManager.getCurrentServerName()));
// Enable custom-gear related managers
new CustomTagFix(this, packetHandler);

View File

@ -14,7 +14,6 @@ import org.bukkit.Sound;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
@ -24,7 +23,6 @@ import mineplex.core.MiniPlugin;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilShapes;
@ -66,7 +64,7 @@ public class NewYearCountdown extends MiniPlugin
@Override
public void addCommands()
{
CommandCenter.Instance.AddCommand(new NewYearCommand(this));
CommandCenter.Instance.addCommand(new NewYearCommand(this));
}
public boolean isInProgress()

View File

@ -24,13 +24,13 @@ public class checkCommand extends CommandBase<CustomerSupport>
{
String playerName = args[0];
CommandCenter.GetClientManager().checkPlayerName(caller, playerName, new Callback<String>()
_commandCenter.GetClientManager().checkPlayerName(caller, playerName, new Callback<String>()
{
public void run(final String name)
{
if (name != null)
{
CommandCenter.GetClientManager().loadClientByName(name, new Runnable()
_commandCenter.GetClientManager().loadClientByName(name, new Runnable()
{
public void run()
{

View File

@ -149,7 +149,7 @@ public class Arcade extends JavaPlugin
Chat chat = new Chat(this, incognito, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, incognito, _clientManager, preferenceManager, ignoreManager, punish, friendManager, chat);
//SnapshotManager snapshotManager = new SnapshotManager(new SnapshotPublisher(this));
//ReportManager reportManager = new ReportManager(this, preferenceManager, statsManager, snapshotManager, CommandCenter.Instance.GetClientManager(), serverStatusManager.getCurrentServerName());
//ReportManager reportManager = new ReportManager(this, preferenceManager, statsManager, snapshotManager, _commandCenter.Instance.GetClientManager(), serverStatusManager.getCurrentServerName());
//new SnapshotPlugin(this, snapshotManager);
//new ReportPlugin(this, reportManager);

View File

@ -15,36 +15,31 @@ import mineplex.core.gadget.types.WinEffectGadget;
import nautilus.game.arcade.game.Game;
public class WinEffectManager
{
private Game game;
private Player winner;
private List<Player> team;
private List<Player> nonTeam;
{
private Game _game;
private Player _winner;
private List<Player> _team;
private List<Player> _nonTeam;
public void prePlay(Game game, Player winner, List<Player> team, List<Player> nonTeam)
{
this.winner = winner;
this.game = game;
this.team = team;
this.nonTeam = nonTeam;
_winner = winner;
_game = game;
_team = team;
_nonTeam = nonTeam;
}
public void playWinEffect(Location loc)
{
prepareSetup(loc);
UtilEnt.getAllInRadius(loc, 20).keySet().stream().filter(e-> !(e instanceof Player)).forEach(e->e.remove());
game.CreatureAllowOverride = true;
_game.CreatureAllowOverride = true;
for(Player p : UtilServer.getPlayers())
{
Gadget g = game.getArcadeManager().getCosmeticManager().getGadgetManager().getActive(p, GadgetType.Item);
Gadget g = _game.getArcadeManager().getCosmeticManager().getGadgetManager().getActive(p, GadgetType.Item);
if(g != null) g.Disable(p);
}
playEffect();
}
@ -54,50 +49,34 @@ public class WinEffectManager
protected void buildWinnerRoom(Location loc)
{
game.WorldTimeSet = 12000;
WinEffectGadget effect = getWinEffect(winner);
effect.setup(winner, team, nonTeam, loc);
_game.WorldTimeSet = 12000;
WinEffectGadget effect = getWinEffect();
effect.setup(_winner, _team, _nonTeam, loc);
effect.buildWinnerRoom();
}
protected void playEffect() {
game.getArcadeManager().getCosmeticManager().getGadgetManager().setHideParticles(true);
WinEffectGadget effect = getWinEffect(winner);
protected void playEffect()
{
_game.getArcadeManager().getCosmeticManager().getGadgetManager().setHideParticles(true);
WinEffectGadget effect = getWinEffect();
effect.teleport();
effect.runPlay();
/*
effect.teleport(winner, team, other, loc.clone().add(loc.getDirection().normalize().multiply(10)).add(0, 3, 0));
new BukkitRunnable() {
public void run() {
}
}.runTaskLater(game.getArcadeManager().getPlugin(), 30);
*/
}
}
public void end() {
WinEffectGadget effect = getWinEffect(winner);
public void end()
{
WinEffectGadget effect = getWinEffect();
effect.runFinish();
game.getArcadeManager().getCosmeticManager().getGadgetManager().setHideParticles(false);
game.CreatureAllowOverride = false;
_game.getArcadeManager().getCosmeticManager().getGadgetManager().setHideParticles(false);
_game.CreatureAllowOverride = false;
}
public WinEffectGadget getWinEffect(Player player)
public WinEffectGadget getWinEffect()
{
GadgetManager manager = game.getArcadeManager().getCosmeticManager().getGadgetManager();
Gadget gadget = manager.getActive(winner, GadgetType.WinEffect);
GadgetManager manager = _game.getArcadeManager().getCosmeticManager().getGadgetManager();
Gadget gadget = manager.getActive(_winner, GadgetType.WinEffect);
if(gadget == null) gadget = manager.getGadget(WinEffectPodium.class);
WinEffectGadget effect = (WinEffectGadget) gadget;
return effect;
return (WinEffectGadget) gadget;
}
}