Allowed commands to specify specific ranks

allowed youtube/build to start/set games
This commit is contained in:
Chiss 2014-08-22 17:05:14 +10:00
parent ac088e85b2
commit 97c087a28d
20 changed files with 239 additions and 60 deletions

View File

@ -35,11 +35,29 @@ public enum Rank
}
public boolean Has(Player player, Rank rank, boolean inform)
{
return Has(player, rank, null, inform);
}
public boolean Has(Player player, Rank rank, Rank[] specific, boolean inform)
{
if (player != null)
if (player.getName().equals("Chiss"))
return true;
//Specific Rank
if (specific != null)
{
for (Rank curRank : specific)
{
if (compareTo(curRank) == 0)
{
return true;
}
}
}
//
if (compareTo(rank) <= 0)
return true;

View File

@ -118,7 +118,7 @@ public class BlockRestore extends MiniPlugin
return;
//No Snow on Ice
if (block.getRelative(BlockFace.DOWN).getTypeId() == 79)
if (block.getRelative(BlockFace.DOWN).getTypeId() == 79 || block.getRelative(BlockFace.DOWN).getTypeId() == 174)
return;
//No Snow on Slabs
@ -130,8 +130,8 @@ public class BlockRestore extends MiniPlugin
return;
//No Snow on Fence or Walls
if (block.getRelative(BlockFace.DOWN).getTypeId() == 85 ||
block.getRelative(BlockFace.DOWN).getTypeId() == 139)
if (block.getRelative(BlockFace.DOWN).getType().name().toLowerCase().contains("fence") ||
block.getRelative(BlockFace.DOWN).getType().name().toLowerCase().contains("wall"))
return;
//Not Buildable

View File

@ -10,6 +10,8 @@ import mineplex.core.common.Rank;
public abstract class CommandBase<PluginType extends MiniPlugin> implements ICommand
{
private Rank _requiredRank;
private Rank[] _specificRank;
private List<String> _aliases;
protected PluginType Plugin;
@ -23,6 +25,15 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
_aliases = Arrays.asList(aliases);
}
public CommandBase(PluginType plugin, Rank requiredRank, Rank[] specificRank, String...aliases)
{
Plugin = plugin;
_requiredRank = requiredRank;
_specificRank = specificRank;
_aliases = Arrays.asList(aliases);
}
public Collection<String> Aliases()
{
return _aliases;
@ -38,6 +49,11 @@ public abstract class CommandBase<PluginType extends MiniPlugin> implements ICom
return _requiredRank;
}
public Rank[] GetSpecificRanks()
{
return _specificRank;
}
public void SetCommandCenter(CommandCenter commandCenter)
{
CommandCenter = commandCenter;

View File

@ -55,7 +55,7 @@ public class CommandCenter implements Listener
ICommand command = Commands.get(commandName.toLowerCase());
if (command != null && ClientManager.Get(event.getPlayer()).GetRank().Has(event.getPlayer(), command.GetRequiredRank(), true))
if (command != null && ClientManager.Get(event.getPlayer()).GetRank().Has(event.getPlayer(), command.GetRequiredRank(), command.GetSpecificRanks(), true))
{
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
{

View File

@ -16,4 +16,5 @@ public interface ICommand
void SetAliasUsed(String name);
Rank GetRequiredRank();
Rank[] GetSpecificRanks();
}

View File

@ -17,6 +17,13 @@ public abstract class MultiCommandBase<PluginType extends MiniPlugin> extends Co
Commands = new NautHashMap<String, ICommand>();
}
public MultiCommandBase(PluginType plugin, Rank rank, Rank[] specificRanks, String...aliases)
{
super(plugin, rank, specificRanks, aliases);
Commands = new NautHashMap<String, ICommand>();
}
public void AddCommand(ICommand command)
{
for (String commandRoot : command.Aliases())
@ -48,7 +55,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(), true))
if (command != null && CommandCenter.ClientManager.Get(caller).GetRank().Has(caller, command.GetRequiredRank(), command.GetSpecificRanks(), true))
{
command.SetAliasUsed(commandName);

View File

@ -40,7 +40,7 @@ public class AdminMountManager extends MiniPlugin
public void AddCommands()
{
AddCommand(new HorseSpawn(this));
}
}
@EventHandler
public void HorseInteract(PlayerInteractEntityEvent event)

View File

@ -89,6 +89,7 @@ public class ParkourManager extends MiniPlugin
}, 4000, new Location(Manager.GetSpawn().getWorld(), -93,67,38),
new Location(Manager.GetSpawn().getWorld(), -86,100,42), new Location(Manager.GetSpawn().getWorld(), -120,50,-17)));
/*
_parkour.add(new ParkourSnake("Snake Parkour", new String[]
{
"This parkour requires incredible timing",
@ -96,7 +97,7 @@ public class ParkourManager extends MiniPlugin
"by the devil as a cruel joke!"
}, 8000, new Location(Manager.GetSpawn().getWorld(), 22,70,-54),
new Location(Manager.GetSpawn().getWorld(), 28,-50,-88), new Location(Manager.GetSpawn().getWorld(), -24,90,-46)));
*/
_lavaParkourReturn = new Location(Manager.GetSpawn().getWorld(), -89.5,68,36.5);
_lavaParkourReturn.setYaw(90);

View File

@ -69,7 +69,7 @@ public class WorldManager extends MiniPlugin
Manager = manager;
}
@EventHandler
//@EventHandler
public void SpawnAnimals(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)

View File

@ -56,8 +56,6 @@ public class ParkourSnake extends ParkourData
{
e.printStackTrace();
}
System.out.println("Done");
}
public SnakePart loadSnake(String locString)
@ -207,6 +205,9 @@ public class ParkourSnake extends ParkourData
public void Update()
{
if (_snakes == null)
return;
for (SnakePart snake : _snakes)
snake.Update();
}

View File

@ -10,7 +10,7 @@ public class GameCommand extends MultiCommandBase<ArcadeManager>
{
public GameCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, "game");
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "game");
AddCommand(new StartCommand(Plugin));
AddCommand(new StopCommand(Plugin));

View File

@ -12,22 +12,22 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
public class SetCommand extends CommandBase<ArcadeManager>
{
{
public SetCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, "set");
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "set");
}
@Override
@Override
public void Execute(Player caller, String[] args)
{
{
if (Plugin.GetGame() == null)
return;
if (args.length == 0)
{
caller.sendMessage("/game set <GameType> (Map)");
return;
return;
}
String game = args[0].toLowerCase();

View File

@ -12,7 +12,7 @@ public class StartCommand extends CommandBase<ArcadeManager>
{
public StartCommand(ArcadeManager plugin)
{
super(plugin, Rank.ADMIN, "start");
super(plugin, Rank.ADMIN, new Rank[] {Rank.YOUTUBE, Rank.MAPDEV}, "start");
}
@Override
@ -30,7 +30,7 @@ public class StartCommand extends CommandBase<ArcadeManager>
int seconds;
if(args != null && args.length > 0)
seconds = Integer.parseInt(args[0]);
else
else
seconds = 10;
Plugin.GetGameManager().StateCountdown(Plugin.GetGame(), seconds, true);

View File

@ -1,10 +1,13 @@
package nautilus.game.arcade.game.games.deathtag;
import java.util.ArrayList;
import java.util.Collections;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
@ -25,6 +28,7 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.deathtag.kits.*;
import nautilus.game.arcade.game.games.sneakyassassins.powerups.PowerUpManager;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit;
@ -36,6 +40,8 @@ public class DeathTag extends SoloGame
private NautHashMap<Player, Location> _deathLocation = new NautHashMap<Player, Location>();
private int _currentSpeed = -1;
private ArrayList<Location> _lights = new ArrayList<Location>();
public DeathTag(ArcadeManager manager)
{
@ -65,6 +71,20 @@ public class DeathTag extends SoloGame
this.PrepareFreeze = false;
}
@Override
public void ParseData()
{
_lights = this.WorldData.GetCustomLocs("89");
for (Location loc : _lights)
{
if (Math.random() > 0.5)
loc.getBlock().setType(Material.GOLD_BLOCK);
else
loc.getBlock().setTypeIdAndData(35, (byte)15, false);
}
}
@Override
public void RestrictKits()
@ -110,6 +130,25 @@ public class DeathTag extends SoloGame
{
return _runners;
}
@EventHandler
public void UpdateLights(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.SEC)
return;
for (Location loc : _lights)
{
if (loc.getBlock().getType() == Material.GOLD_BLOCK)
loc.getBlock().setTypeIdAndData(35, (byte)15, false);
else
loc.getBlock().setType(Material.GOLD_BLOCK);
}
}
@EventHandler
public void UpdateSpeed(UpdateEvent event)

View File

@ -2,6 +2,8 @@ package nautilus.game.arcade.game.games.dragonescape;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -11,6 +13,8 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -171,18 +175,38 @@ public class DragonEscapeTeams extends TeamGame
@EventHandler
public void MoveDragon(UpdateEvent event)
{
{
if (event.getType() != UpdateType.TICK)
return;
if (_dragonData == null)
return;
_dragonData.Target = _waypoints.get(Math.min(_waypoints.size()-1, (GetWaypointIndex(_dragonData.Location) + 1)));
_dragonData.Move();
Set<Block> blocks = UtilBlock.getInRadius(_dragonData.Location, 10d).keySet();
Iterator<Block> blockIterator = blocks.iterator();
while (blockIterator.hasNext())
{
Block block = blockIterator.next();
if (block.isLiquid())
blockIterator.remove();
else if (block.getRelative(BlockFace.UP).isLiquid())
blockIterator.remove();
Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(_dragonData.Location, 10d).keySet(), _dragonData.Location, false);
else if (WorldData.MapName.contains("Hell") && block.getY() < 30)
blockIterator.remove();
else if (WorldData.MapName.contains("Pirate") && (block.getY() < 6))
blockIterator.remove();
}
Manager.GetExplosion().BlockExplosion(blocks, _dragonData.Location, false);
}
@EventHandler

View File

@ -62,8 +62,11 @@ public class Micro extends TeamGame
public void ParseData()
{
for (Location loc : WorldData.GetCustomLocs("20"))
{
_glass.add(loc.getBlock());
loc.getBlock().setType(Material.STAINED_GLASS);
}
for (int y= WorldData.MinY ; y < WorldData.MaxY ; y++)
for (int x= WorldData.MinX ; x < WorldData.MaxX ; x++)
for (int z= WorldData.MinZ ; z < WorldData.MaxZ ; z++)

View File

@ -32,10 +32,9 @@ import nautilus.game.arcade.kit.Kit;
public class QuiverTeams extends TeamGame
{
private HashMap<GameTeam, Integer> _teamKills = new HashMap<GameTeam, Integer>();
private ArrayList<String> _lastScoreboard = new ArrayList<String>();
private HashMap<Player, Long> _deathTime = new HashMap<Player, Long>();
private int _reqKills = 100;
private int _reqKills = 6;
public QuiverTeams(ArcadeManager manager)
{
@ -52,7 +51,7 @@ public class QuiverTeams extends TeamGame
"Bow and Arrow insta-kills.",
"You receive 1 Arrow per kill.",
"Glass blocks are breakable",
"First team to 100 kills wins."
"First team to 60 kills wins."
});
this.HungerSet = 20;
@ -195,6 +194,10 @@ public class QuiverTeams extends TeamGame
Scoreboard.Write(kills + "" + team.GetColor() + " Kills");
}
Scoreboard.WriteBlank();
Scoreboard.Write(C.Bold + "First To");
Scoreboard.Write(C.cGold + C.Bold + _reqKills + " Kills");
Scoreboard.Draw();
}

View File

@ -258,7 +258,7 @@ public class Spleef extends SoloGame
@EventHandler
public void Hunger(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
if (event.getType() != UpdateType.SLOW)
return;
if (!IsLive())
@ -275,7 +275,7 @@ public class Spleef extends SoloGame
UtilPlayer.message(player, F.main("Game", "Break blocks to restore hunger!"));
}
UtilPlayer.hunger(player, -1);
UtilPlayer.hunger(player, -2);
}
}
}

View File

@ -3,10 +3,13 @@ package nautilus.game.arcade.game.games.spleef;
import java.lang.reflect.Field;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockDamageEvent;
@ -16,7 +19,11 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
@ -56,14 +63,59 @@ public class SpleefTeams extends TeamGame
}
@EventHandler
public void ArrowDamage(ProjectileHitEvent event)
public void SnowballDamage(ProjectileHitEvent event)
{
final Arrow arrow = (Arrow)event.getEntity();
final double velocity = arrow.getVelocity().length();
if (!(event.getEntity() instanceof Snowball))
return;
Snowball ball = (Snowball)event.getEntity();
if (!(arrow.getShooter() instanceof Player))
if (ball.getShooter() == null || !(ball.getShooter() instanceof Player))
return;
Location loc = ball.getLocation().add(ball.getVelocity().multiply(0.8));
Block block = loc.getBlock();
//Find Nearest if hit nothing :O
if (block.getType() == Material.AIR)
{
Block closest = null;
double closestDist = 0;
for (Block other : UtilBlock.getSurrounding(block, true))
{
if (other.getType() == Material.AIR)
continue;
double dist = UtilMath.offset(loc, other.getLocation().add(0.5, 0.5, 0.5));
if (closest == null || dist < closestDist)
{
closest = other;
closestDist = dist;
}
}
if (closest != null)
block = closest;
}
BlockFade(block, (Player)ball.getShooter(), false);
}
@EventHandler
public void ArrowDamage(ProjectileHitEvent event)
{
if (!(event.getEntity() instanceof Arrow))
return;
final Arrow arrow = (Arrow)event.getEntity();
final double velocity = arrow.getVelocity().length();
if (!(arrow.getShooter() instanceof Player))
return;
final Player player = (Player)arrow.getShooter();
Manager.GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.GetPlugin(), new Runnable()
@ -89,14 +141,14 @@ public class SpleefTeams extends TeamGame
Block block = arrow.getWorld().getBlockAt(x, y, z);
double radius = 0.5 + velocity/1.6d;
BlockFade(block, player);
BlockFade(block, player, false);
for (Block other : UtilBlock.getInRadius(block.getLocation().add(0.5, 0.5, 0.5), radius).keySet())
{
BlockFade(other, player);
BlockFade(other, player, true);
}
arrow.remove();
}
catch (Exception e)
@ -106,25 +158,41 @@ public class SpleefTeams extends TeamGame
}
}, 0);
}
@EventHandler(priority = EventPriority.LOW)
public void BlockDamage(BlockDamageEvent event)
{
if (!this.IsLive())
return;
if (!this.IsAlive(event.getPlayer()))
return;
event.setCancelled(true);
BlockFade(event.getBlock(), event.getPlayer());
BlockFade(event.getBlock(), event.getPlayer(), false);
//Snowball
if (GetKit(event.getPlayer()) instanceof KitSnowballer)
if (!UtilInv.contains(event.getPlayer(), Material.SNOW_BALL, (byte)0, 16))
event.getPlayer().getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SNOW_BALL));
}
public void BlockFade(Block block, Player player)
public void BlockFade(Block block, Player player, boolean slowDamage)
{
UtilPlayer.hunger(player, 1);
AddStat(player, "BlocksBroken", 1, false, false);
//Prevent Super Hunger from Bow
if (Recharge.Instance.use(player, GetName() + " Hunger", 50, false, false))
if (block.getTypeId() != 7)
UtilPlayer.hunger(player, 1);
if (!slowDamage)
{
Break(block);
return;
}
//Wool and Stained Clay
if (block.getTypeId() == 35 || block.getTypeId() == 159)
{
@ -155,7 +223,7 @@ public class SpleefTeams extends TeamGame
else
Break(block);
}
//Grass
else if (block.getTypeId() == 2)
{
@ -170,7 +238,7 @@ public class SpleefTeams extends TeamGame
else if (block.getData() == 0)
block.setData((byte)2);
else
Break(block);
}
@ -181,25 +249,22 @@ public class SpleefTeams extends TeamGame
Break(block);
}
}
public void Break(Block block)
{
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getTypeId());
block.setTypeId(0);
}
@EventHandler
public void Hunger(UpdateEvent event)
{
if (Manager.IsTournamentServer())
if (event.getType() != UpdateType.SLOW)
return;
if (event.getType() != UpdateType.SEC)
return;
if (!IsLive())
return;
for (Player player : GetPlayers(true))
{
if (player.getFoodLevel() <= 0)
@ -207,11 +272,11 @@ public class SpleefTeams extends TeamGame
Manager.GetDamage().NewDamageEvent(player, null, null,
DamageCause.STARVATION, 1, false, true, false,
"Starvation", GetName());
UtilPlayer.message(player, F.main("Game", "Break blocks to restore hunger!"));
}
UtilPlayer.hunger(player, -1);
UtilPlayer.hunger(player, -2);
}
}
}

View File

@ -39,6 +39,7 @@ import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -921,7 +922,7 @@ public class GameFlagManager implements Listener
}
@EventHandler
public void WorldLeavesDecay(BlockFromToEvent event)
public void WorldLeavesDecay(LeavesDecayEvent event)
{
Game game = Manager.GetGame();
if (game == null) return;