SG post patch

This commit is contained in:
Sam 2018-02-26 15:40:59 +00:00 committed by Alexander Meech
parent 467b9f7f11
commit 84c1991321
19 changed files with 204 additions and 57 deletions

View File

@ -1429,7 +1429,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed
@EventHandler @EventHandler
public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event) public final void onFoodLevelChangeEvent(FoodLevelChangeEvent event)
{ {
((Player) event.getEntity()).setSaturation(3.8F); // While not entirely accurate, this is a pretty good guess at original ((Player) event.getEntity()).setSaturation(5); // While not entirely accurate, this is a pretty good guess at original
// food level changes // food level changes
} }

View File

@ -4,7 +4,10 @@ import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.bukkit.Color;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -41,6 +44,7 @@ import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
@ -93,7 +97,8 @@ public abstract class SurvivalGamesNew extends Game
private static final long PREPARE_TIME = TimeUnit.SECONDS.toMillis(15); private static final long PREPARE_TIME = TimeUnit.SECONDS.toMillis(15);
private static final long REFILL_TIME = TimeUnit.MINUTES.toMillis(7); private static final long REFILL_TIME = TimeUnit.MINUTES.toMillis(7);
private static final long REFILL_INFORM_TIME = TimeUnit.MINUTES.toMillis(3); private static final long REFILL_INFORM_TIME = TimeUnit.MINUTES.toMillis(3);
private static final long KIT_COOLDOWN = TimeUnit.SECONDS.toMillis(30); private static final long KIT_COOLDOWN = TimeUnit.SECONDS.toMillis(20);
private static final long END_DAMAGE_TIME = TimeUnit.MINUTES.toMillis(15);
private static final int MAX_ITEM_SPAWN_DISTANCE_SQUARED = 36; private static final int MAX_ITEM_SPAWN_DISTANCE_SQUARED = 36;
private static final String START_EFFECT_REASON = "Start Effect"; private static final String START_EFFECT_REASON = "Start Effect";
private static final int START_EFFECT_DURATION = 30; private static final int START_EFFECT_DURATION = 30;
@ -101,6 +106,10 @@ public abstract class SurvivalGamesNew extends Game
private static final int CRAFTING_TABLES = 10; private static final int CRAFTING_TABLES = 10;
private static final int DISTANCE_NON_ASSASSIN = 576; private static final int DISTANCE_NON_ASSASSIN = 576;
private static final int DISTANCE_ASSASSIN = 64; private static final int DISTANCE_ASSASSIN = 64;
private static final FireworkEffect DEATH_EFFECT = FireworkEffect.builder()
.with(Type.BALL)
.withColor(Color.RED)
.build();
private List<Location> _chests; private List<Location> _chests;
private SupplyDropModule _supplyDrop; private SupplyDropModule _supplyDrop;
@ -483,7 +492,7 @@ public abstract class SurvivalGamesNew extends Game
new ChestLootPool() new ChestLootPool()
.addItem(new ItemStack(Material.FISHING_ROD)) .addItem(new ItemStack(Material.FISHING_ROD))
.addItem(new ItemStack(Material.BOW), 60) .addItem(new ItemStack(Material.BOW), 60)
.addItem(new ItemStack(Material.ARROW), 1, 3) .addItem(new ItemStack(Material.ARROW), 1, 3, 50)
.addItem(new ItemStack(Material.SNOW_BALL), 1, 2) .addItem(new ItemStack(Material.SNOW_BALL), 1, 2)
.addItem(new ItemStack(Material.EGG), 1, 2) .addItem(new ItemStack(Material.EGG), 1, 2)
.setUnbreakable(true) .setUnbreakable(true)
@ -504,8 +513,8 @@ public abstract class SurvivalGamesNew extends Game
.addItem(new ItemStack(Material.EXP_BOTTLE), 1, 2) .addItem(new ItemStack(Material.EXP_BOTTLE), 1, 2)
.addItem(new ItemStack(Material.STICK), 1, 2) .addItem(new ItemStack(Material.STICK), 1, 2)
.addItem(new ItemStack(Material.BOAT), 50) .addItem(new ItemStack(Material.BOAT), 50)
.addItem(new ItemStack(Material.FLINT), 1, 2) .addItem(new ItemStack(Material.FLINT), 1, 2, 70)
.addItem(new ItemStack(Material.FEATHER), 1, 2) .addItem(new ItemStack(Material.FEATHER), 1, 2, 70)
.addItem(new ItemStack(Material.GOLD_INGOT), 1, 1, 80) .addItem(new ItemStack(Material.GOLD_INGOT), 1, 1, 80)
.addItem(compassModule.getCompass(5)) .addItem(compassModule.getCompass(5))
.addItem(tnt, 50) .addItem(tnt, 50)
@ -546,7 +555,7 @@ public abstract class SurvivalGamesNew extends Game
new ChestLootPool() new ChestLootPool()
.addItem(new ItemStack(Material.FISHING_ROD)) .addItem(new ItemStack(Material.FISHING_ROD))
.addItem(new ItemStack(Material.BOW), 50) .addItem(new ItemStack(Material.BOW), 50)
.addItem(new ItemStack(Material.ARROW), 1, 3) .addItem(new ItemStack(Material.ARROW), 1, 3, 50)
.addItem(new ItemStack(Material.SNOW_BALL), 1, 2) .addItem(new ItemStack(Material.SNOW_BALL), 1, 2)
.addItem(new ItemStack(Material.EGG), 1, 2) .addItem(new ItemStack(Material.EGG), 1, 2)
.setUnbreakable(true) .setUnbreakable(true)
@ -568,9 +577,8 @@ public abstract class SurvivalGamesNew extends Game
.addItem(new ItemStack(Material.EXP_BOTTLE), 1, 2) .addItem(new ItemStack(Material.EXP_BOTTLE), 1, 2)
.addItem(new ItemStack(Material.STICK), 1, 2) .addItem(new ItemStack(Material.STICK), 1, 2)
.addItem(new ItemStack(Material.BOAT), 50) .addItem(new ItemStack(Material.BOAT), 50)
.addItem(new ItemStack(Material.FLINT), 1, 2) .addItem(new ItemStack(Material.FLINT), 1, 2, 70)
.addItem(new ItemStack(Material.STRING), 1, 2) .addItem(new ItemStack(Material.FEATHER), 1, 2, 70)
.addItem(new ItemStack(Material.FEATHER), 1, 2)
.addItem(new ItemStack(Material.GOLD_INGOT), 1, 1, 80) .addItem(new ItemStack(Material.GOLD_INGOT), 1, 1, 80)
.addItem(compassModule.getCompass(5)) .addItem(compassModule.getCompass(5))
.addItem(new ItemStack(Material.DIAMOND), 50) .addItem(new ItemStack(Material.DIAMOND), 50)
@ -677,9 +685,7 @@ public abstract class SurvivalGamesNew extends Game
return; return;
} }
ItemStack mapItem = getModule(WorldMapModule.class).getMapItem() ItemStack mapItem = getModule(WorldMapModule.class).getMapItem();
.setTitle(C.cGreenB + "World Map")
.build();
for (Player player : GetPlayers(true)) for (Player player : GetPlayers(true))
{ {
@ -866,14 +872,17 @@ public abstract class SurvivalGamesNew extends Game
block.setType(Material.AIR); block.setType(Material.AIR);
} }
if (event.getBlock().getType() == Material.LEAVES && Math.random() < 0.05) if (event.getBlock().getType() == Material.LEAVES)
{ {
Location location = block.getLocation().add(0.5, 0.5, 0.5); Location location = block.getLocation().add(0.5, 0.5, 0.5);
event.setCancelled(true); event.setCancelled(true);
location.getWorld().playEffect(location, Effect.STEP_SOUND, block.getType());
block.setType(Material.AIR); block.setType(Material.AIR);
location.getWorld().dropItemNaturally(location, new ItemStack(Material.STICK));
if (Math.random() < 0.05)
{
location.getWorld().dropItemNaturally(location, new ItemStack(Material.STICK));
}
} }
} }
@ -887,7 +896,7 @@ public abstract class SurvivalGamesNew extends Game
return; return;
} }
event.AddMod("Water Explosion", -event.GetDamage() / 2D); event.AddMod("Water Explosion", -event.GetDamage() * 0.4);
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
@ -895,6 +904,13 @@ public abstract class SurvivalGamesNew extends Game
{ {
if (event.getEntity() instanceof Player) if (event.getEntity() instanceof Player)
{ {
Location location = event.getEntity().getLocation();
for (int i = 1; i <= 3; i++)
{
UtilFirework.launchFirework(location, DEATH_EFFECT, null, i);
}
return; return;
} }
@ -902,6 +918,20 @@ public abstract class SurvivalGamesNew extends Game
event.getDrops().clear(); event.getDrops().clear();
} }
@EventHandler
public void updateEndDamage(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !IsLive() || !UtilTime.elapsed(GetStateTime(), END_DAMAGE_TIME))
{
return;
}
for (Player player : GetPlayers(true))
{
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.CUSTOM, 2, false, true, true, GetName(), "End Game");
}
}
@Override @Override
public double GetKillsGems(Player killer, Player killed, boolean assist) public double GetKillsGems(Player killer, Player killed, boolean assist)
{ {

View File

@ -29,9 +29,9 @@ public class KitArcher extends Kit
new PerkQuickshot("Quick Shot", 2, 30000, true) new PerkQuickshot("Quick Shot", 2, 30000, true)
}; };
private static final ItemStack IN_HAND = new ItemStack(Material.BOW);
public static final ItemStack BOW = new ItemBuilder(Material.BOW) public static final ItemStack BOW = new ItemBuilder(Material.BOW)
.setTitle(C.cYellow + "Archer's Bow") .setTitle(C.cYellow + "Archer's Bow")
.setUnbreakable(true)
.build(); .build();
public KitArcher(ArcadeManager manager) public KitArcher(ArcadeManager manager)
@ -53,6 +53,6 @@ public class KitArcher extends Kit
return; return;
} }
event.getDrops().removeIf(itemStack -> itemStack.isSimilar(BOW)); event.getDrops().removeIf(itemStack -> itemStack.equals(BOW));
} }
} }

View File

@ -1,6 +1,10 @@
package nautilus.game.arcade.game.games.survivalgames.kit; package nautilus.game.arcade.game.games.survivalgames.kit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.game.kit.GameKit; import mineplex.core.game.kit.GameKit;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
@ -30,4 +34,17 @@ public class KitBarbarian extends Kit
{ {
Recharge.Instance.useForce(player, GetName(), 45000); Recharge.Instance.useForce(player, GetName(), 45000);
} }
@EventHandler
public void playerDeath(PlayerDeathEvent event)
{
Player killer = event.getEntity().getKiller();
if (killer == null || !HasKit(killer))
{
return;
}
killer.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 0));
}
} }

View File

@ -13,6 +13,8 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
@ -120,4 +122,23 @@ public class BorderModule extends Module
getGame().getArcadeManager().GetDamage().NewDamageEvent(event.GetDamageeEntity(), null, null, DamageCause.CUSTOM, 2, false, true, true, getGame().GetName(), "World Border"); getGame().getArcadeManager().GetDamage().NewDamageEvent(event.GetDamageeEntity(), null, null, DamageCause.CUSTOM, 2, false, true, true, getGame().GetName(), "World Border");
} }
} }
@EventHandler
public void updateEndGame(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || !getGame().IsLive() || _deathmatchSize != getGame().WorldData.World.getWorldBorder().getSize())
{
return;
}
double maxY = getGame().GetSpectatorLocation().getY() - 6;
for (Player player : getGame().GetPlayers(true))
{
if (player.getLocation().getY() > maxY)
{
getGame().GetTeam(player).SpawnTeleport(player);
}
}
}
} }

View File

@ -72,7 +72,7 @@ public class FurnaceLootModule extends Module
} }
FurnaceInventory inventory = furnace.getInventory(); FurnaceInventory inventory = furnace.getInventory();
int random = UtilMath.r(9); int random = UtilMath.r(6);
if (random == 0) if (random == 0)
{ {

View File

@ -41,6 +41,9 @@ import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilFirework; import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.treasure.util.TreasureUtil; import mineplex.core.treasure.util.TreasureUtil;
@ -57,6 +60,7 @@ public class SupplyDropModule extends Module
private static final int HEIGHT = 40; private static final int HEIGHT = 40;
private static final int RADIUS = 8; private static final int RADIUS = 8;
private static final int POINTS = 80; private static final int POINTS = 80;
private static final int MAX_DROPS = 3;
private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder() private static final FireworkEffect FIREWORK_EFFECT = FireworkEffect.builder()
.with(Type.BURST) .with(Type.BURST)
.withColor(Color.YELLOW) .withColor(Color.YELLOW)
@ -85,6 +89,7 @@ public class SupplyDropModule extends Module
private SupplyDrop _supplyDrop; private SupplyDrop _supplyDrop;
private Block _lastBlock; private Block _lastBlock;
private boolean _firstOpening; private boolean _firstOpening;
private int _totalDrops;
public SupplyDropModule() public SupplyDropModule()
{ {
@ -131,7 +136,7 @@ public class SupplyDropModule extends Module
if (_supplyDrop == null) if (_supplyDrop == null)
{ {
if (getGame().WorldTimeSet > TIME && getGame().WorldTimeSet < TIME + 1000) if (_totalDrops < MAX_DROPS && getGame().WorldTimeSet > TIME && getGame().WorldTimeSet < TIME + 1000)
{ {
Location location = getRandom(); Location location = getRandom();
@ -161,6 +166,7 @@ public class SupplyDropModule extends Module
getGame().Announce(C.cRedB + "A Supply Drop has appeared at " + C.cWhite + "(" + location.getBlockX() + ", " + location.getBlockZ() + ")."); getGame().Announce(C.cRedB + "A Supply Drop has appeared at " + C.cWhite + "(" + location.getBlockX() + ", " + location.getBlockZ() + ").");
_supplyDrop = new SupplyDrop(location, entity); _supplyDrop = new SupplyDrop(location, entity);
_totalDrops++;
} }
} }
else if (!_supplyDrop.Dropped) else if (!_supplyDrop.Dropped)
@ -187,7 +193,6 @@ public class SupplyDropModule extends Module
block = block.getRelative(BlockFace.UP); block = block.getRelative(BlockFace.UP);
done = true; done = true;
_supplyDrop.Dragon.remove(); _supplyDrop.Dragon.remove();
_supplyDrop = null;
_firstOpening = true; _firstOpening = true;
cancel(); cancel();
} }
@ -197,13 +202,14 @@ public class SupplyDropModule extends Module
if (done) if (done)
{ {
_supplyDrop.ChestSpawned = true;
_lastBlock = block; _lastBlock = block;
populateChest(); populateChest();
} }
} }
}, 0, 5); }, 0, 5);
} }
else else if (!_supplyDrop.ChestSpawned)
{ {
Location center = _supplyDrop.Drop; Location center = _supplyDrop.Drop;
double theta = Math.PI * 2 / POINTS * _supplyDrop.Point; double theta = Math.PI * 2 / POINTS * _supplyDrop.Point;
@ -241,11 +247,23 @@ public class SupplyDropModule extends Module
if (_firstOpening) if (_firstOpening)
{ {
_supplyDrop = null;
_firstOpening = false; _firstOpening = false;
getGame().AddStat(player, "SupplyDropsOpened", 1, false, false); getGame().AddStat(player, "SupplyDropsOpened", 1, false, false);
} }
} }
@EventHandler
public void updateParticles(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST || _supplyDrop == null || !_supplyDrop.ChestSpawned)
{
return;
}
UtilParticle.PlayParticleToAll(ParticleType.SPELL, _lastBlock.getLocation().add(0.5, 0.5, 0.5), 1, 1, 1, 0, 5, ViewDist.NORMAL);
}
private void populateChest() private void populateChest()
{ {
List<Integer> slots = new ArrayList<>(_chestInventory.getSize()); List<Integer> slots = new ArrayList<>(_chestInventory.getSize());
@ -328,7 +346,7 @@ public class SupplyDropModule extends Module
private class SupplyDrop private class SupplyDrop
{ {
Location Drop; Location Drop;
boolean Dropped; boolean Dropped, ChestSpawned;
long Start; long Start;
Entity Dragon; Entity Dragon;
int Point; int Point;

View File

@ -68,8 +68,8 @@ public class TrackingCompassModule extends Module
player.setCompassTarget(nearby.getLocation()); player.setCompassTarget(nearby.getLocation());
player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1); player.playSound(player.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1);
player.sendMessage(F.main("Game", F.name(nearby.getName()) + " is " + F.count((int) UtilMath.offset(player, nearby)) + " blocks away."));
player.setItemInHand(getCompass(--uses)); player.setItemInHand(getCompass(--uses));
player.sendMessage(F.main("Game", F.name(nearby.getName()) + " is " + F.count((int) UtilMath.offset(player, nearby)) + " blocks away. Your compass has " + F.count(uses) + " use" + (uses == 1 ? "": "s") + " left."));
return; return;
} }
} }

View File

@ -52,7 +52,7 @@ public class ThrowableTNTModule extends Module
} }
else else
{ {
builder.setTitle(C.cYellowB + "Throwable TNT"); builder.setTitle(C.cYellow + "Throwable TNT");
} }
_tntItem = builder.build(); _tntItem = builder.build();

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
public class Generator public class Generator
@ -53,6 +54,7 @@ public class Generator
_holder.remove(); _holder.remove();
_holder = null; _holder = null;
setLastCollect(); setLastCollect();
UtilServer.CallEvent(new GeneratorCollectEvent(player, this));
} }
public void checkSpawn() public void checkSpawn()

View File

@ -24,6 +24,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapRenderer; import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView; import org.bukkit.map.MapView;
@ -32,6 +33,9 @@ import com.google.common.collect.HashMultiset;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multisets; import com.google.common.collect.Multisets;
import mineplex.core.account.permissions.Permission;
import mineplex.core.account.permissions.PermissionGroup;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilMath;
@ -46,6 +50,11 @@ import nautilus.game.arcade.world.WorldData;
public class WorldMapModule extends Module public class WorldMapModule extends Module
{ {
public enum Perm implements Permission
{
MAP_COMMAND
}
private static final int BLOCK_SCAN_INTERVAL = 16; private static final int BLOCK_SCAN_INTERVAL = 16;
private int _halfMapSize; private int _halfMapSize;
@ -175,6 +184,18 @@ public class WorldMapModule extends Module
rebuildScan(); rebuildScan();
} }
@Override
protected void setup()
{
getGame().registerDebugCommand("map", Perm.MAP_COMMAND, PermissionGroup.PLAYER, (player, args) ->
{
Inventory inventory = player.getInventory();
inventory.remove(Material.MAP);
inventory.addItem(getMapItem());
player.sendMessage(F.main("Game", "Here, have a " + F.name("Map") + "."));
});
}
private void setupRenderer(MapView view) private void setupRenderer(MapView view)
{ {
for (MapRenderer renderer : view.getRenderers()) for (MapRenderer renderer : view.getRenderers())
@ -511,18 +532,6 @@ public class WorldMapModule extends Module
} }
} }
@EventHandler
public void dropItem(PlayerDropItemEvent event)
{
ItemStack itemStack = event.getItemDrop().getItemStack();
if (itemStack.getType() == Material.MAP)
{
event.setCancelled(true);
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this map."));
}
}
@EventHandler @EventHandler
public void inventoryClick(InventoryClickEvent event) public void inventoryClick(InventoryClickEvent event)
{ {
@ -539,8 +548,10 @@ public class WorldMapModule extends Module
} }
} }
public ItemBuilder getMapItem() public ItemStack getMapItem()
{ {
return new ItemBuilder(Material.MAP, 1, _mapId); return new ItemBuilder(Material.MAP, 1, _mapId)
.setTitle(C.cGreenB + "World Map")
.build();
} }
} }

View File

@ -1,6 +1,8 @@
package nautilus.game.arcade.kit.perks; package nautilus.game.arcade.kit.perks;
import org.bukkit.Material; import java.util.HashMap;
import java.util.Map;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
@ -9,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -19,6 +22,7 @@ import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem; import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.projectile.IThrown; import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser; import mineplex.core.projectile.ProjectileUser;
@ -28,12 +32,23 @@ import nautilus.game.arcade.kit.Perk;
public class PerkAxeThrower extends Perk implements IThrown public class PerkAxeThrower extends Perk implements IThrown
{ {
private final Map<LivingEntity, Long> _lastAxe;
public PerkAxeThrower() public PerkAxeThrower()
{ {
super("Axe Thrower", new String[] super("Axe Thrower", new String[]
{ {
C.cYellow + "Right-Click" + C.cGray + " with Axes to " + C.cGreen + "Throw Axe", C.cYellow + "Right-Click" + C.cGray + " with Axes to " + C.cGreen + "Throw Axe",
}); });
_lastAxe = new HashMap<>();
}
@Override
public void unregisteredEvents()
{
_lastAxe.clear();
} }
@EventHandler @EventHandler
@ -47,7 +62,7 @@ public class PerkAxeThrower extends Perk implements IThrown
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UtilItem.isAxe(player.getItemInHand()) || !Kit.HasKit(player) || !Recharge.Instance.use(player, GetName(), 1000, false, true)) if (!UtilItem.isAxe(player.getItemInHand()) || !Kit.HasKit(player) || !Recharge.Instance.usable(player, GetName(), true))
{ {
return; return;
} }
@ -70,16 +85,39 @@ public class PerkAxeThrower extends Perk implements IThrown
return; return;
Item item = (Item) data.getThrown(); Item item = (Item) data.getThrown();
LivingEntity thrower = data.getThrower();
int damage = 4; int damage = 4;
if (item.getItemStack().getType() == Material.STONE_AXE) damage = 5;
else if (item.getItemStack().getType() == Material.IRON_AXE) damage = 6; switch (item.getItemStack().getType())
else if (item.getItemStack().getType() == Material.DIAMOND_AXE) damage = 7; {
case STONE_AXE:
damage = 5;
break;
case IRON_AXE:
damage = 6;
break;
case DIAMOND_AXE:
damage = 7;
break;
}
Long last = _lastAxe.get(thrower);
if (last == null)
{
_lastAxe.put(thrower, System.currentTimeMillis());
}
else
{
long delta = System.currentTimeMillis() - last;
damage /= Math.max(1, (2000 - delta) / 500);
}
//Damage Event //Damage Event
Manager.GetDamage().NewDamageEvent(target, data.getThrower(), null, Manager.GetDamage().NewDamageEvent(target, thrower, null,
DamageCause.CUSTOM, damage, true, true, false, DamageCause.CUSTOM, damage, true, true, false,
UtilEnt.getName(data.getThrower()), GetName()); UtilEnt.getName(thrower), GetName());
//Effect //Effect
data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.ZOMBIE_WOOD, 1f, 1.6f); data.getThrown().getWorld().playSound(data.getThrown().getLocation(), Sound.ZOMBIE_WOOD, 1f, 1.6f);
@ -112,4 +150,10 @@ public class PerkAxeThrower extends Perk implements IThrown
{ {
data.getThrown().remove(); data.getThrown().remove();
} }
@EventHandler
public void playerQuit(PlayerQuitEvent event)
{
_lastAxe.remove(event.getPlayer());
}
} }

View File

@ -71,7 +71,7 @@ public class PerkBomberHG extends Perk
continue; continue;
//Add //Add
cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item(C.Bold + "Throwable TNT"))); cur.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, F.item("Throwable TNT")));
cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f); cur.playSound(cur.getLocation(), Sound.ITEM_PICKUP, 2f, 1f);
} }

View File

@ -66,7 +66,7 @@ public class PerkCleave extends Perk
event.AddMod(damager.getName(), GetName(), 0, false); event.AddMod(damager.getName(), GetName(), 0, false);
//Splash //Splash
for (Player other : UtilPlayer.getNearby(damagee.getLocation(), 3)) for (Player other : UtilPlayer.getNearby(damagee.getLocation(), 4))
{ {
if (other.equals(damagee)) if (other.equals(damagee))
continue; continue;

View File

@ -74,7 +74,7 @@ public class PerkHiltSmash extends Perk
//Damage Event //Damage Event
Manager.GetDamage().NewDamageEvent((LivingEntity)ent, player, null, Manager.GetDamage().NewDamageEvent((LivingEntity)ent, player, null,
DamageCause.ENTITY_ATTACK, 2, false, true, true, DamageCause.ENTITY_ATTACK, 1, false, true, true,
player.getName(), GetName()); player.getName(), GetName());
} }

View File

@ -55,7 +55,10 @@ public class PerkHorsePet extends Perk
@Override @Override
public void Apply(Player player) public void Apply(Player player)
{ {
Manager.runSyncLater(() -> spawnHorse(player, false), 45 * 20); if (Manager.GetGame().InProgress())
{
Manager.runSyncLater(() -> spawnHorse(player, false), 45 * 20);
}
} }
@Override @Override

View File

@ -183,7 +183,7 @@ public class PerkSkeletons extends Perk
UtilEnt.removeGoalSelectors(skel); UtilEnt.removeGoalSelectors(skel);
skel.setMaxHealth(30); skel.setMaxHealth(36);
skel.setHealth(skel.getMaxHealth()); skel.setHealth(skel.getMaxHealth());
ItemStack inHand = killed.getItemInHand(); ItemStack inHand = killed.getItemInHand();

View File

@ -106,7 +106,7 @@ public class PerkTNTArrow extends Perk
Player player = (Player)event.getEntity(); Player player = (Player)event.getEntity();
if (!_active.remove(player) || !Recharge.Instance.use(player, GetName(), 8000, true, true)) if (!_active.remove(player) || !Recharge.Instance.use(player, GetName(), 6000, true, true))
{ {
return; return;
} }

View File

@ -243,7 +243,7 @@ public class PerkWolfPet extends Perk
return; return;
} }
if (!Recharge.Instance.use(player, "Cub Strike", 10000, true, true)) if (!Recharge.Instance.use(player, "Cub Strike", 8000, true, true))
return; return;
Wolf wolf = _petMap.get(player).get(UtilMath.r(_petMap.get(player).size())); Wolf wolf = _petMap.get(player).get(UtilMath.r(_petMap.get(player).size()));
@ -398,11 +398,12 @@ public class PerkWolfPet extends Perk
} }
else if (damager != null && isMinion(damager)) else if (damager != null && isMinion(damager))
{ {
double damage = 3; if (event.GetDamageePlayer() != null)
{
event.GetDamageePlayer().playSound(event.GetDamageeEntity().getLocation(), Sound.SUCCESSFUL_HIT, 1, 1);
}
event.GetDamageeEntity().getWorld().playSound(event.GetDamageeEntity().getLocation(), Sound.SUCCESSFUL_HIT, 1, 1); event.AddMod("Wolf Minion", "Damage", -event.GetDamageInitial() + 3, false);
event.AddMod("Wolf Minion", "Negate", -event.GetDamageInitial(), false);
event.AddMod("Wolf Minion", "Damage", damage, false);
} }
} }
} }