Merge branch 'master' of ssh://dev.mineplex.com:7999/min/Mineplex
This commit is contained in:
commit
483f8ffde3
210
Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java
Normal file
210
Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java
Normal file
@ -0,0 +1,210 @@
|
|||||||
|
package mineplex.core.antihack;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import mineplex.core.common.util.UtilGear;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.common.util.UtilServer;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class AntiHack extends MiniPlugin
|
||||||
|
{
|
||||||
|
public static AntiHack Instance;
|
||||||
|
|
||||||
|
//Record Offesnes
|
||||||
|
private HashMap<Player, HashMap<String, Integer>> _offenses = new HashMap<Player, HashMap<String, Integer>>();
|
||||||
|
|
||||||
|
//Ignore Player
|
||||||
|
private HashMap<Player, Long> _ignore = new HashMap<Player, Long>();
|
||||||
|
|
||||||
|
//Hack Data
|
||||||
|
private HashMap<Player, Entry<Integer, Double>> _floatTicks = new HashMap<Player, Entry<Integer, Double>>(); //Ticks, PrevY
|
||||||
|
private HashMap<Player, Entry<Integer, Double>> _hoverTicks = new HashMap<Player, Entry<Integer, Double>>(); //Ticks, PrevY
|
||||||
|
private HashMap<Player, Entry<Integer, Double>> _riseTicks = new HashMap<Player, Entry<Integer, Double>>(); //Ticks, PrevY
|
||||||
|
private HashMap<Player, Entry<Double, Double>> _momentum = new HashMap<Player, Entry<Double, Double>>(); //Momentum, PrevY
|
||||||
|
|
||||||
|
//Hack Requirements
|
||||||
|
private int _floatHackTicks = 20;
|
||||||
|
private int _hoverHackTicks = 20;
|
||||||
|
private int _riseHackTicks = 20;
|
||||||
|
|
||||||
|
protected AntiHack(JavaPlugin plugin)
|
||||||
|
{
|
||||||
|
super("Recharge", plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Initialize(JavaPlugin plugin)
|
||||||
|
{
|
||||||
|
Instance = new AntiHack(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void PlayerVelocity(PlayerVelocityEvent event)
|
||||||
|
{
|
||||||
|
_ignore.put(event.getPlayer(), System.currentTimeMillis() + 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void PlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
Reset(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void Update(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
//Allowed 'cheaty' movement
|
||||||
|
if (UtilEnt.isGrounded(player) || player.getLocation().getBlock().getType() != Material.AIR || //Grounded + Swimming/Ladder/etc
|
||||||
|
player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL || //Flying + Vehicle + Gamemode
|
||||||
|
(_ignore.containsKey(player) && System.currentTimeMillis() < _ignore.get(player))) //Ignore
|
||||||
|
{
|
||||||
|
Reset(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Not actually moved, just looking around
|
||||||
|
if (UtilMath.offset(event.getFrom(), event.getTo()) <= 0)
|
||||||
|
{
|
||||||
|
UpdateFloat(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateHover(player);
|
||||||
|
UpdateRise(player);
|
||||||
|
UpdateMomentum(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateFloat(Player player)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (_floatTicks.containsKey(player))
|
||||||
|
{
|
||||||
|
if (player.getLocation().getY() == _floatTicks.get(player).getValue())
|
||||||
|
{
|
||||||
|
count = _floatTicks.get(player).getKey() + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > _floatHackTicks)
|
||||||
|
{
|
||||||
|
AddOffense(player, "Float");
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_floatTicks.put(player, new AbstractMap.SimpleEntry<Integer, Double>(count, player.getLocation().getY()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateHover(Player player)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (_hoverTicks.containsKey(player))
|
||||||
|
{
|
||||||
|
if (player.getLocation().getY() == _hoverTicks.get(player).getValue())
|
||||||
|
{
|
||||||
|
count = _hoverTicks.get(player).getKey() + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > _hoverHackTicks)
|
||||||
|
{
|
||||||
|
AddOffense(player, "Hover");
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hoverTicks.put(player, new AbstractMap.SimpleEntry<Integer, Double>(count, player.getLocation().getY()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateRise(Player player)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
if (_riseTicks.containsKey(player))
|
||||||
|
{
|
||||||
|
if (player.getLocation().getY() > _riseTicks.get(player).getValue())
|
||||||
|
{
|
||||||
|
count = _riseTicks.get(player).getKey() + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > _riseHackTicks)
|
||||||
|
{
|
||||||
|
AddOffense(player, "Rise");
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
_riseTicks.put(player, new AbstractMap.SimpleEntry<Integer, Double>(count, player.getLocation().getY()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateMomentum(Player player)
|
||||||
|
{
|
||||||
|
double newMomentum = 0;
|
||||||
|
|
||||||
|
if (_momentum.containsKey(player))
|
||||||
|
{
|
||||||
|
newMomentum = player.getLocation().getY() - _riseTicks.get(player).getValue();
|
||||||
|
double oldMomentum = _riseTicks.get(player).getKey();
|
||||||
|
|
||||||
|
if (oldMomentum < 0 && newMomentum > 0)
|
||||||
|
{
|
||||||
|
AddOffense(player, "Momentum");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_momentum.put(player, new AbstractMap.SimpleEntry<Double, Double>(newMomentum, player.getLocation().getY()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddOffense(Player player, String type)
|
||||||
|
{
|
||||||
|
if (!_offenses.containsKey(player))
|
||||||
|
_offenses.put(player, new HashMap<String, Integer>());
|
||||||
|
|
||||||
|
int previous = 0;
|
||||||
|
if (_offenses.get(player).containsKey(type))
|
||||||
|
previous = _offenses.get(player).get(type);
|
||||||
|
|
||||||
|
_offenses.get(player).put(type, previous + 1);
|
||||||
|
|
||||||
|
//Report (Debug)
|
||||||
|
for (Player admin : UtilServer.getPlayers())
|
||||||
|
if (admin.isOp() && UtilGear.isMat(admin.getItemInHand(), Material.BOOK_AND_QUILL))
|
||||||
|
UtilPlayer.message(admin, F.main("Anti-Hack", F.elem(player.getName()) + " fired offense for " + F.elem(type) + "."));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Reset(Player player)
|
||||||
|
{
|
||||||
|
_hoverTicks.remove(player);
|
||||||
|
_riseTicks.remove(player);
|
||||||
|
_momentum.remove(player);
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,18 @@
|
|||||||
package mineplex.core.antistack;
|
package mineplex.core.antistack;
|
||||||
|
|
||||||
import mineplex.core.MiniPlugin;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import mineplex.core.MiniPlugin;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||||
@ -16,10 +23,30 @@ public class AntiStack extends MiniPlugin
|
|||||||
{
|
{
|
||||||
private boolean _enabled = true;
|
private boolean _enabled = true;
|
||||||
|
|
||||||
|
private HashSet<Location> _ignoreAround = new HashSet<Location>();
|
||||||
|
|
||||||
public AntiStack(JavaPlugin plugin)
|
public AntiStack(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
super("AntiStack", plugin);
|
super("AntiStack", plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void BlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_ignoreAround.add(event.getBlock().getLocation().add(0.5, 0.5, 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void ClearIgnoreAround(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_ignoreAround.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler (priority=EventPriority.HIGHEST)
|
@EventHandler (priority=EventPriority.HIGHEST)
|
||||||
public void ItemSpawn(ItemSpawnEvent event)
|
public void ItemSpawn(ItemSpawnEvent event)
|
||||||
@ -29,9 +56,13 @@ public class AntiStack extends MiniPlugin
|
|||||||
|
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Item item = event.getEntity();
|
Item item = event.getEntity();
|
||||||
|
|
||||||
|
for (Location loc : _ignoreAround)
|
||||||
|
if (UtilMath.offset(loc, event.getLocation()) < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
//ItemName()
|
//ItemName()
|
||||||
if (item.getLocation().getY() < -10)
|
if (item.getLocation().getY() < -10)
|
||||||
return;
|
return;
|
||||||
|
@ -11,6 +11,7 @@ import nautilus.game.arcade.game.games.bridge.Bridge;
|
|||||||
import nautilus.game.arcade.game.games.castlesiege.CastleSiege;
|
import nautilus.game.arcade.game.games.castlesiege.CastleSiege;
|
||||||
import nautilus.game.arcade.game.games.deathtag.DeathTag;
|
import nautilus.game.arcade.game.games.deathtag.DeathTag;
|
||||||
import nautilus.game.arcade.game.games.dragonescape.DragonEscape;
|
import nautilus.game.arcade.game.games.dragonescape.DragonEscape;
|
||||||
|
import nautilus.game.arcade.game.games.dragonriders.DragonRiders;
|
||||||
import nautilus.game.arcade.game.games.dragons.Dragons;
|
import nautilus.game.arcade.game.games.dragons.Dragons;
|
||||||
import nautilus.game.arcade.game.games.evolution.Evolution;
|
import nautilus.game.arcade.game.games.evolution.Evolution;
|
||||||
import nautilus.game.arcade.game.games.hungergames.HungerGames;
|
import nautilus.game.arcade.game.games.hungergames.HungerGames;
|
||||||
@ -47,6 +48,7 @@ public class GameFactory
|
|||||||
else if (gameType == GameType.DeathTag) return new DeathTag(_manager);
|
else if (gameType == GameType.DeathTag) return new DeathTag(_manager);
|
||||||
else if (gameType == GameType.Dragons) return new Dragons(_manager);
|
else if (gameType == GameType.Dragons) return new Dragons(_manager);
|
||||||
else if (gameType == GameType.DragonEscape) return new DragonEscape(_manager);
|
else if (gameType == GameType.DragonEscape) return new DragonEscape(_manager);
|
||||||
|
else if (gameType == GameType.DragonRiders) return new DragonRiders(_manager);
|
||||||
else if (gameType == GameType.Evolution) return new Evolution(_manager);
|
else if (gameType == GameType.Evolution) return new Evolution(_manager);
|
||||||
else if (gameType == GameType.HungerGames) return new HungerGames(_manager);
|
else if (gameType == GameType.HungerGames) return new HungerGames(_manager);
|
||||||
else if (gameType == GameType.MineWare) return new MineWare(_manager);
|
else if (gameType == GameType.MineWare) return new MineWare(_manager);
|
||||||
|
@ -9,6 +9,7 @@ public enum GameType
|
|||||||
CastleSiege("Castle Siege"),
|
CastleSiege("Castle Siege"),
|
||||||
DeathTag("Death Tag"),
|
DeathTag("Death Tag"),
|
||||||
DragonEscape("Dragon Escape"),
|
DragonEscape("Dragon Escape"),
|
||||||
|
DragonRiders("Dragon Riders"),
|
||||||
Dragons("Dragons"),
|
Dragons("Dragons"),
|
||||||
Evolution("Evolution"),
|
Evolution("Evolution"),
|
||||||
Horse("Horseback"),
|
Horse("Horseback"),
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package nautilus.game.arcade.game.games.dragonriders;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.UtilAlg;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEnderDragon;
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class DragonData
|
||||||
|
{
|
||||||
|
ArcadeManager Manager;
|
||||||
|
|
||||||
|
public EnderDragon Dragon;
|
||||||
|
public Player Rider;
|
||||||
|
|
||||||
|
public Entity TargetEntity = null;
|
||||||
|
|
||||||
|
public Location Location = null;
|
||||||
|
|
||||||
|
public float Pitch = 0;
|
||||||
|
public Vector Velocity = new Vector(0,0,0);
|
||||||
|
|
||||||
|
public DragonData(ArcadeManager manager, Player rider)
|
||||||
|
{
|
||||||
|
Manager = manager;
|
||||||
|
|
||||||
|
Rider = rider;
|
||||||
|
|
||||||
|
Velocity = rider.getLocation().getDirection().setY(0).normalize();
|
||||||
|
Pitch = UtilAlg.GetPitch(rider.getLocation().getDirection());
|
||||||
|
|
||||||
|
Location = rider.getLocation();
|
||||||
|
|
||||||
|
//Spawn Dragon
|
||||||
|
manager.GetGame().CreatureAllowOverride = true;
|
||||||
|
Dragon = rider.getWorld().spawn(rider.getLocation(), EnderDragon.class);
|
||||||
|
UtilEnt.Vegetate(Dragon);
|
||||||
|
manager.GetGame().CreatureAllowOverride = false;
|
||||||
|
|
||||||
|
rider.getWorld().playSound(rider.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f);
|
||||||
|
|
||||||
|
Dragon.setPassenger(Rider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Move()
|
||||||
|
{
|
||||||
|
((CraftEnderDragon)Dragon).getHandle().setTargetBlock(GetTarget().getBlockX(), GetTarget().getBlockY(), GetTarget().getBlockZ());
|
||||||
|
|
||||||
|
Manager.GetExplosion().BlockExplosion(UtilBlock.getInRadius(Dragon.getLocation(), 10d).keySet(), Dragon.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location GetTarget()
|
||||||
|
{
|
||||||
|
return Rider.getLocation().add(Rider.getLocation().getDirection().multiply(40));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package nautilus.game.arcade.game.games.dragonriders;
|
||||||
|
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.GameType;
|
||||||
|
import nautilus.game.arcade.game.SoloGame;
|
||||||
|
import nautilus.game.arcade.game.games.dragonriders.kits.KitRider;
|
||||||
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
|
||||||
|
public class DragonRiders extends SoloGame
|
||||||
|
{
|
||||||
|
public DragonRiders(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager, GameType.DragonRiders,
|
||||||
|
|
||||||
|
new Kit[]
|
||||||
|
{
|
||||||
|
new KitRider(manager)
|
||||||
|
},
|
||||||
|
|
||||||
|
new String[]
|
||||||
|
{
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
this.Damage = false;
|
||||||
|
this.HungerSet = 20;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package nautilus.game.arcade.game.games.dragonriders.kits;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import mineplex.core.itemstack.ItemStackFactory;
|
||||||
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
|
import nautilus.game.arcade.kit.Kit;
|
||||||
|
import nautilus.game.arcade.kit.KitAvailability;
|
||||||
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
import nautilus.game.arcade.kit.perks.PerkDragonRider;
|
||||||
|
|
||||||
|
public class KitRider extends Kit
|
||||||
|
{
|
||||||
|
public KitRider(ArcadeManager manager)
|
||||||
|
{
|
||||||
|
super(manager, "Dragon Rider", KitAvailability.Free,
|
||||||
|
new String[]
|
||||||
|
{
|
||||||
|
"woosh"
|
||||||
|
},
|
||||||
|
new Perk[]
|
||||||
|
{
|
||||||
|
new PerkDragonRider()
|
||||||
|
},
|
||||||
|
EntityType.ZOMBIE,
|
||||||
|
new ItemStack(Material.BOW));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void GiveItems(Player player)
|
||||||
|
{
|
||||||
|
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
|
||||||
|
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.ARROW, 64));
|
||||||
|
|
||||||
|
player.getInventory().setHelmet(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_HELMET));
|
||||||
|
player.getInventory().setChestplate(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_CHESTPLATE));
|
||||||
|
player.getInventory().setLeggings(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_LEGGINGS));
|
||||||
|
player.getInventory().setBoots(ItemStackFactory.Instance.CreateStack(Material.CHAINMAIL_BOOTS));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void SpawnCustom(LivingEntity ent)
|
||||||
|
{
|
||||||
|
ent.getEquipment().setHelmet(new ItemStack(Material.CHAINMAIL_HELMET));
|
||||||
|
ent.getEquipment().setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
|
||||||
|
ent.getEquipment().setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS));
|
||||||
|
ent.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
|
||||||
|
}
|
||||||
|
}
|
@ -36,6 +36,7 @@ import mineplex.core.common.util.UtilMath;
|
|||||||
import mineplex.core.common.util.UtilTime;
|
import mineplex.core.common.util.UtilTime;
|
||||||
import mineplex.core.disguise.disguises.DisguiseBase;
|
import mineplex.core.disguise.disguises.DisguiseBase;
|
||||||
import mineplex.core.disguise.disguises.DisguiseSheep;
|
import mineplex.core.disguise.disguises.DisguiseSheep;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||||
@ -429,6 +430,9 @@ public class Snake extends SoloGame
|
|||||||
|
|
||||||
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.WOOL))
|
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.WOOL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!Recharge.Instance.use(player, "Snake Item", 1000, false))
|
||||||
|
return;
|
||||||
|
|
||||||
UtilInv.remove(player, Material.WOOL, (byte)0, 1);
|
UtilInv.remove(player, Material.WOOL, (byte)0, 1);
|
||||||
|
|
||||||
@ -505,6 +509,9 @@ public class Snake extends SoloGame
|
|||||||
|
|
||||||
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.FEATHER))
|
if (!UtilGear.isMat(event.getPlayer().getItemInHand(), Material.FEATHER))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!Recharge.Instance.use(player, "Snake Item", 1000, false))
|
||||||
|
return;
|
||||||
|
|
||||||
UtilInv.remove(player, Material.FEATHER, (byte)0, 1);
|
UtilInv.remove(player, Material.FEATHER, (byte)0, 1);
|
||||||
|
|
||||||
|
@ -0,0 +1,114 @@
|
|||||||
|
package nautilus.game.arcade.kit.perks;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Fireball;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilInv;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
|
import mineplex.core.recharge.Recharge;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
import nautilus.game.arcade.game.Game.GameState;
|
||||||
|
import nautilus.game.arcade.game.games.dragonriders.DragonData;
|
||||||
|
import nautilus.game.arcade.kit.Perk;
|
||||||
|
|
||||||
|
public class PerkDragonRider extends Perk
|
||||||
|
{
|
||||||
|
public HashMap<Player, DragonData> _dragons = new HashMap<Player, DragonData>();
|
||||||
|
|
||||||
|
public PerkDragonRider()
|
||||||
|
{
|
||||||
|
super("Dragon Rider", new String[]
|
||||||
|
{
|
||||||
|
C.cGray + "You ride a dragon!",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void DragonSpawn(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SLOW)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Manager.GetGame().GetState() != GameState.Live)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||||
|
{
|
||||||
|
if (!Kit.HasKit(player))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!_dragons.containsKey(player))
|
||||||
|
_dragons.put(player, new DragonData(Manager, player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void DragonLocation(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.TICK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (Manager.GetGame().GetState() != GameState.Live)
|
||||||
|
return;
|
||||||
|
|
||||||
|
//Dragon Update!
|
||||||
|
for (DragonData data : _dragons.values())
|
||||||
|
data.Move();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void DragonTargetCancel(EntityTargetEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void ShootWeb(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (UtilBlock.usable(event.getClickedBlock()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (event.getPlayer().getItemInHand() == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!event.getPlayer().getItemInHand().getType().toString().contains("BOW"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (!Kit.HasKit(player))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!Recharge.Instance.use(player, GetName(), 1000, true))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
UtilInv.Update(player);
|
||||||
|
|
||||||
|
Fireball ball = _dragons.get(player).Dragon.launchProjectile(Fireball.class);
|
||||||
|
|
||||||
|
//Inform
|
||||||
|
UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Dragon Blast") + "."));
|
||||||
|
|
||||||
|
//Effect
|
||||||
|
player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 2f, 1f);
|
||||||
|
}
|
||||||
|
}
|
@ -172,7 +172,7 @@ public class GameGemManager implements Listener
|
|||||||
if (amount > 0)
|
if (amount > 0)
|
||||||
amountStr = amount + " ";
|
amountStr = amount + " ";
|
||||||
|
|
||||||
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (gemCount * game.GemMultiplier) + " Gems") + " for " + F.elem(amountStr + type));
|
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(gemCount * game.GemMultiplier) + " Gems") + " for " + F.elem(amountStr + type));
|
||||||
}
|
}
|
||||||
|
|
||||||
earnedGems = (int) (earnedGems * game.GemMultiplier);
|
earnedGems = (int) (earnedGems * game.GemMultiplier);
|
||||||
@ -194,8 +194,7 @@ public class GameGemManager implements Listener
|
|||||||
UtilPlayer.message(player, F.elem(C.cWhite + "§lGame is still in progress..."));
|
UtilPlayer.message(player, F.elem(C.cWhite + "§lGame is still in progress..."));
|
||||||
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + C.cGreen + C.Bold + "Gems" + C.cWhite + C.Bold + " when its completed."));
|
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + C.cGreen + C.Bold + "Gems" + C.cWhite + C.Bold + " when its completed."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UtilPlayer.message(player, ArcadeFormat.Line);
|
UtilPlayer.message(player, ArcadeFormat.Line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user