Added method to disable taunts in certain games

This commit is contained in:
LCastr0 2016-12-14 00:04:59 -02:00 committed by cnr
parent f9c71c481f
commit 36801283d7
6 changed files with 124 additions and 3 deletions

View File

@ -1278,6 +1278,9 @@ public class GadgetManager extends MiniPlugin
if (!event.isGameInProgress() && event.getState().equals(TauntCommandEvent.TauntState.NONE))
event.setState(TauntCommandEvent.TauntState.NOT_IN_GAME);
if (taunt.isGameDisabled(event.getGameType()) && event.getState().equals(TauntCommandEvent.TauntState.NONE))
event.setState(TauntCommandEvent.TauntState.GAME_DISABLED);
if (!event.isAlive() && event.getState().equals(TauntCommandEvent.TauntState.NONE))
event.setState(TauntCommandEvent.TauntState.NOT_ALIVE);

View File

@ -5,6 +5,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.gadgets.taunts.GameType;
public class TauntCommandEvent extends Event
{
@ -17,14 +18,16 @@ public class TauntCommandEvent extends Event
private boolean _spectator;
private long _lastPvp;
private TauntState _state = TauntState.NONE;
private GameType _gameType;
public TauntCommandEvent(Player player, boolean gameInProgress, boolean alive, boolean spectator, long lastPvp)
public TauntCommandEvent(Player player, boolean gameInProgress, boolean alive, boolean spectator, long lastPvp, GameType gameType)
{
_player = player;
_gameInProgress = gameInProgress;
_alive = alive;
_spectator = spectator;
_lastPvp = lastPvp;
_gameType = gameType;
}
public Player getPlayer()
@ -57,6 +60,11 @@ public class TauntCommandEvent extends Event
return _state;
}
public GameType getGameType()
{
return _gameType;
}
public void setState(TauntState state)
{
_state = state;
@ -80,7 +88,7 @@ public class TauntCommandEvent extends Event
NOT_ALIVE("You are not playing the game!"),
SPECTATOR("You can't run this as a spectator!"),
PVP("You can't run this while in pvp!"),
COMPLETED("");
GAME_DISABLED("Taunts are disabled in this game!");
private String _message;

View File

@ -38,6 +38,7 @@ public class EternalTaunt extends TauntGadget
setPvpCooldown(5000);
setShouldPlay(true);
setEventType(UpdateType.TICK);
addDisabledGames(GameType.SMASH, GameType.SMASHTEAMS, GameType.SMASHDOMINATION);
}
@Override

View File

@ -0,0 +1,84 @@
package mineplex.core.gadget.gadgets.taunts;
public enum GameType
{
BACONBRAWL,
BARBARIANS,
BASKETBALL,
BOSSBATTLES,
BRIDGE,
CASTLESIEGE,
CHAMPIONSCTF,
CHAMPIONSDOMINATE,
CHAMPIONSTDM,
CHRISTMAS,
DEATHTAG,
DRAGONESCAPE,
DRAGONESCAPETEAMS,
DRAGONRIDERS,
DRAGONS,
DRAGONSTEAMS,
DRAW,
ELYTRARINGS,
EVOLUTION,
GRAVITY,
HALLOWEEN,
HALLOWEEN2016,
HIDESEEK,
HOLEINTHEWALL,
HORSE,
LOBBERS,
MICRO,
MILKCOW,
MINESTRIKE,
BAWKBAWKBATTLES,
MINECRAFTLEAGUE,
OLDMINEWARE,
PAINTBALL,
QUIVER,
QUIVERPAYLOAD,
QUIVERTEAMS,
RUNNER,
SEARCHANDDESTROY,
SHEEP,
TYPEWARS,
SMASH,
SMASHDOMINATION,
SMASHTEAMS,
SNAKE,
SNEAKYASSASSINS,
SNOWFIGHT,
SPEEDBUILDERS,
SPLEEF,
SPLEEFTEAMS,
SQUIDSHOOTER,
STACKER,
SURVIVALGAMES,
SURVIVALGAMESTEAMS,
TUG,
TURFWARS,
UHC,
UHCSOLO,
UHCSOLOSPEED,
UHCTEAMSSPEED,
WITHERASSAULT,
WIZARDS,
ZOMBIESURVIVAL,
BUILD,
BUILDMAVERICKS,
CARDS,
SKYWARS,
SKYWARSTEAMS,
MONSTERMAZE,
MONSTERLEAGUE,
GLADIATORS,
SKYFALL,
SKYFALLTEAMS,
BOUNCYBALLS,
VALENTINES,
EVENT,
BRAWL,
NONE
}

View File

@ -1,12 +1,16 @@
package mineplex.core.gadget.types;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.taunts.GameType;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -24,6 +28,8 @@ public abstract class TauntGadget extends Gadget
private boolean _shouldPlay = false;
/** Sets when the taunt will run, if set above */
private UpdateType _updateType = UpdateType.TICK;
/** List of games where this item is disabled */
private List<GameType> _disabledGames = new ArrayList<>();
/**
* @param manager The normal GadgetManager
@ -82,11 +88,21 @@ public abstract class TauntGadget extends Gadget
_updateType = updateType;
}
public void addDisabledGames(GameType... disabledGames)
{
_disabledGames.addAll(Arrays.asList(disabledGames));
}
public boolean canPlayWithPvp()
{
return _canPlayWithPvp;
}
public boolean isGameDisabled(GameType gameType)
{
return _disabledGames.contains(gameType);
}
public long getPvpCooldown()
{
return _pvpCooldown;

View File

@ -9,9 +9,11 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.gadget.event.TauntCommandEvent;
import mineplex.core.gadget.gadgets.taunts.GameType;
import mineplex.minecraft.game.core.combat.CombatManager;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.Game;
public class TauntCommand extends CommandBase<ArcadeManager>
{
@ -33,8 +35,15 @@ public class TauntCommand extends CommandBase<ArcadeManager>
{
pvp = UtilTime.elapsed(combatManager.Get(player).GetLastCombatEngaged(), 5000 * 60);
}
Game game = _arcadeManager.GetGame();
GameType gameType = GameType.NONE;
if (game != null)
{
gameType = GameType.valueOf(game.GetType().toString().toUpperCase());
}
TauntCommandEvent event = new TauntCommandEvent(player, _arcadeManager.isGameInProgress(),
_arcadeManager.GetGame().IsAlive(player), UtilPlayer.isSpectator(player), combatManager.Get(player).GetLastCombatEngaged());
_arcadeManager.GetGame().IsAlive(player), UtilPlayer.isSpectator(player), combatManager.Get(player).GetLastCombatEngaged(),
gameType);
Bukkit.getPluginManager().callEvent(event);
}