Skywars and Kit Progression
This commit is contained in:
parent
ec8ed76270
commit
9454e1f409
@ -2,6 +2,7 @@ package mineplex.core.progression;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.progression.data.PlayerKit;
|
||||
import mineplex.core.progression.data.PlayerKitDataManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -16,16 +17,23 @@ public class KitProgressionManager extends MiniClientPlugin<PlayerKit>
|
||||
|
||||
private PlayerKitDataManager _dataManager;
|
||||
private KitProgressionRepository _kitProgressionRepository;
|
||||
private DonationManager _donationManager;
|
||||
private CoreClientManager _coreClientManager;
|
||||
|
||||
public KitProgressionManager(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
public KitProgressionManager(JavaPlugin plugin, DonationManager donationManager, CoreClientManager clientManager)
|
||||
{
|
||||
super("Kit Progression", plugin);
|
||||
_dataManager = new PlayerKitDataManager();
|
||||
_kitProgressionRepository = new KitProgressionRepository(this);
|
||||
_donationManager = donationManager;
|
||||
_coreClientManager = clientManager;
|
||||
}
|
||||
|
||||
public DonationManager getDonationManager()
|
||||
{
|
||||
return _donationManager;
|
||||
}
|
||||
|
||||
public CoreClientManager getClientManager()
|
||||
{
|
||||
return _coreClientManager;
|
||||
|
@ -0,0 +1,56 @@
|
||||
package mineplex.core.progression.data;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.progression.KitProgressionManager;
|
||||
import mineplex.core.progression.ProgressiveKit;
|
||||
import mineplex.core.progression.math.Calculations;
|
||||
import mineplex.core.shop.confirmation.ConfirmationCallback;
|
||||
import mineplex.core.shop.confirmation.ConfirmationProcessor;
|
||||
|
||||
public class KitUpgradeProcessor implements ConfirmationProcessor
|
||||
{
|
||||
private KitProgressionManager _manager;
|
||||
private Player _player;
|
||||
private ProgressiveKit _kit;
|
||||
private int _upgradeLevel;
|
||||
|
||||
public KitUpgradeProcessor(KitProgressionManager manager, Player player, ProgressiveKit kit, int upgradeLevel)
|
||||
{
|
||||
_manager = manager;
|
||||
_player = player;
|
||||
_kit = kit;
|
||||
_upgradeLevel = upgradeLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Inventory inventory)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ConfirmationCallback callback)
|
||||
{
|
||||
int gems = _manager.getDonationManager().Get(_player).getBalance(GlobalCurrency.GEM);
|
||||
int cost = Calculations.getGemsCost(_upgradeLevel);
|
||||
|
||||
if (gems >= cost)
|
||||
{
|
||||
_kit.upgrade(_upgradeLevel, _player.getUniqueId());
|
||||
|
||||
_player.playSound(_player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f);
|
||||
_player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + _kit.getDisplayName() + " level " + _upgradeLevel));
|
||||
|
||||
_manager.getDonationManager().Get(_player).DeductCost(cost, GlobalCurrency.GEM);
|
||||
callback.resolve("Success! You now own this upgrade!");
|
||||
return;
|
||||
}
|
||||
|
||||
callback.reject("Insufficient funds!");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package mineplex.core.progression.data;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.progression.KitProgressionManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
public class KitUpgradeShop extends ShopBase<KitProgressionManager>
|
||||
{
|
||||
|
||||
public KitUpgradeShop(KitProgressionManager plugin, CoreClientManager clientManager, DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, "Kit Upgrade");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<KitProgressionManager, ? extends ShopBase<KitProgressionManager>> buildPagesFor(Player player)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,19 @@
|
||||
package mineplex.core.progression.gui.buttons;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.menu.Menu;
|
||||
import mineplex.core.progression.ProgressiveKit;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.menu.Menu;
|
||||
import mineplex.core.progression.KitProgressionManager;
|
||||
import mineplex.core.progression.ProgressiveKit;
|
||||
import mineplex.core.progression.data.KitUpgradeProcessor;
|
||||
import mineplex.core.progression.data.KitUpgradeShop;
|
||||
import mineplex.core.shop.confirmation.ConfirmationPage;
|
||||
|
||||
/**
|
||||
* @author Timothy Andis (TadahTech) on 4/7/2016.
|
||||
@ -16,11 +21,13 @@ import java.util.UUID;
|
||||
public class KitUpgradeButton extends KitButton
|
||||
{
|
||||
|
||||
private KitProgressionManager _plugin;
|
||||
private int _upgradeLevel;
|
||||
|
||||
public KitUpgradeButton(ProgressiveKit kit, ItemStack itemStack, int upgradeLevel)
|
||||
public KitUpgradeButton(KitProgressionManager plugin, ProgressiveKit kit, ItemStack itemStack, int upgradeLevel)
|
||||
{
|
||||
super(kit, itemStack);
|
||||
_plugin = plugin;
|
||||
_upgradeLevel = upgradeLevel;
|
||||
}
|
||||
|
||||
@ -36,14 +43,14 @@ public class KitUpgradeButton extends KitButton
|
||||
return;
|
||||
}
|
||||
|
||||
getKit().upgrade(_upgradeLevel, uuid);
|
||||
KitUpgradeShop shop = new KitUpgradeShop(_plugin, _plugin.getClientManager(), _plugin.getDonationManager());
|
||||
KitUpgradeProcessor processor = new KitUpgradeProcessor(_plugin, player, getKit(), _upgradeLevel);
|
||||
ConfirmationPage<KitProgressionManager, KitUpgradeShop> page = new ConfirmationPage<KitProgressionManager, KitUpgradeShop>(player, _plugin, shop, _plugin.getClientManager(), _plugin.getDonationManager(), processor, getItemStack());
|
||||
|
||||
player.playSound(player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f);
|
||||
|
||||
player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + getKit().getDisplayName() + " level " + _upgradeLevel));
|
||||
shop.openPageForPlayer(player, page);
|
||||
|
||||
Menu.remove(uuid);
|
||||
|
||||
player.closeInventory();
|
||||
//player.closeInventory();
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.core.progression.gui.buttons;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.progression.KitProgressionManager;
|
||||
import mineplex.core.progression.ProgressiveKit;
|
||||
import mineplex.core.progression.gui.guis.KitInformationTrackerMenu;
|
||||
import mineplex.core.progression.gui.guis.KitMenu;
|
||||
@ -23,9 +24,9 @@ public class KitXPButton extends KitButton
|
||||
|
||||
private ItemStack _item;
|
||||
|
||||
public KitXPButton(ProgressiveKit kit, Player player)
|
||||
public KitXPButton(ProgressiveKit kit, Player player, KitProgressionManager plugin)
|
||||
{
|
||||
super(kit, null);
|
||||
super(kit, null, plugin);
|
||||
|
||||
ItemBuilder builder = new ItemBuilder(Material.EXP_BOTTLE);
|
||||
builder.setTitle(ChatColor.YELLOW + "XP and Level");
|
||||
|
@ -63,7 +63,7 @@ public class KitDisplayMenu extends KitMenu
|
||||
*/
|
||||
private void setUpNextMenuButtons(Button[] buttons, Player player)
|
||||
{
|
||||
buttons[48] = new KitXPButton(getKit(), player);
|
||||
buttons[48] = new KitXPButton(getKit(), player, getPlugin());
|
||||
buttons[50] = new KitUpgradeMenuButton(getKit(), player, getPlugin());
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,17 @@
|
||||
package mineplex.core.progression.gui.guis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.menu.Button;
|
||||
@ -11,15 +22,6 @@ import mineplex.core.progression.gui.buttons.KitUpgradeButton;
|
||||
import mineplex.core.progression.gui.buttons.KitUpgradeDetailsButton;
|
||||
import mineplex.core.progression.gui.buttons.misc.BackButton;
|
||||
import mineplex.core.progression.math.Calculations;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This is the secondary menu access by either the Enchantment table or XP Bottle
|
||||
@ -175,7 +177,7 @@ public class KitInformationTrackerMenu extends KitMenu
|
||||
itemStack.addLore(C.cRed + "You cannot purchase this upgrade!");
|
||||
}
|
||||
|
||||
KitUpgradeButton upgradeButton = new KitUpgradeButton(getKit(), itemStack.build(), index);
|
||||
KitUpgradeButton upgradeButton = new KitUpgradeButton(getPlugin(), getKit(), itemStack.build(), index);
|
||||
buttons[i] = upgradeButton;
|
||||
}
|
||||
return;
|
||||
|
@ -370,7 +370,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
_punishmentManager = punish;
|
||||
|
||||
_kitProgressionManager = new KitProgressionManager(getPlugin(), clientManager);
|
||||
_kitProgressionManager = new KitProgressionManager(getPlugin(), donationManager, clientManager);
|
||||
_progressionKitManager = new ProgressingKitManager(this);
|
||||
_serverUptimeManager = new ServerUptimeManager(this);
|
||||
|
||||
|
@ -301,16 +301,18 @@ public abstract class Skywars extends Game
|
||||
|
||||
private void parseCreateConnectorChests()
|
||||
{
|
||||
for (int i = 0; i < 4 && !WorldData.GetDataLocs("GRAY").isEmpty(); i++)
|
||||
{
|
||||
Location loc = UtilAlg.Random(WorldData.GetDataLocs("GRAY"));
|
||||
Iterator<Location> iterator = WorldData.GetDataLocs("GRAY").iterator();
|
||||
|
||||
WorldData.GetDataLocs("GRAY").remove(loc);
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Location loc = iterator.next();
|
||||
|
||||
loc.getBlock().setTypeIdAndData(Material.CHEST.getId(), (byte) UtilMath.r(4), true);
|
||||
|
||||
_connectorChests.add(loc.getBlock());
|
||||
_worldBlocks.add(loc.getBlock());
|
||||
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,15 +394,15 @@ public abstract class Skywars extends Game
|
||||
|
||||
private void setupBookEnchantments()
|
||||
{
|
||||
_commonBookEnchantments.put(Enchantment.DAMAGE_ALL, 3);
|
||||
_commonBookEnchantments.put(Enchantment.DAMAGE_ALL, 1);
|
||||
_commonBookEnchantments.put(Enchantment.FIRE_ASPECT, 1);
|
||||
_commonBookEnchantments.put(Enchantment.ARROW_DAMAGE, 3);
|
||||
_commonBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
|
||||
_commonBookEnchantments.put(Enchantment.ARROW_DAMAGE, 1);
|
||||
_commonBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
|
||||
|
||||
_rareBookEnchantments.put(Enchantment.DAMAGE_ALL, 4);
|
||||
_rareBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
|
||||
_rareBookEnchantments.put(Enchantment.DAMAGE_ALL, 2);
|
||||
_rareBookEnchantments.put(Enchantment.PROTECTION_ENVIRONMENTAL, 2);
|
||||
_rareBookEnchantments.put(Enchantment.ARROW_DAMAGE, 2);
|
||||
_rareBookEnchantments.put(Enchantment.ARROW_FIRE, 1);
|
||||
//_rareBookEnchantments.put(Enchantment.FIRE_ASPECT, 2);
|
||||
_rareBookEnchantments.put(Enchantment.ARROW_KNOCKBACK, 1);
|
||||
_rareBookEnchantments.put(Enchantment.KNOCKBACK, 2);
|
||||
_rareBookEnchantments.put(Enchantment.THORNS, 1);
|
||||
@ -1156,6 +1158,8 @@ public abstract class Skywars extends Game
|
||||
chest.getBlockInventory().setItem(getIndex(used), _middleBlock.getLoot());
|
||||
|
||||
// Books
|
||||
for (int i = 0; i < UtilMath.r(2); i++)
|
||||
{
|
||||
ItemStack itemStack = _middleBooks.getLoot();
|
||||
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) itemStack.getItemMeta();
|
||||
Enchantment enchantment = null;
|
||||
@ -1178,6 +1182,7 @@ public abstract class Skywars extends Game
|
||||
|
||||
itemStack.setItemMeta(meta);
|
||||
chest.getBlockInventory().setItem(getIndex(used), itemStack);
|
||||
}
|
||||
|
||||
// Misc
|
||||
chest.getBlockInventory().setItem(getIndex(used), _middleMisc.getLoot());
|
||||
|
@ -22,33 +22,33 @@ public class KitFire extends ProgressingKit
|
||||
"Start with " + C.cGreen + "Wood Sword" + C.cGray + " and " + C.cGreen + "Blaze Rod",
|
||||
"",
|
||||
C.cYellow + "Right Click" + C.cWhite + " with Blaze Rod to use " + C.cGreen + "Fire Burst",
|
||||
"Sends out a pulse of fire that deals " + C.cGreen + 3 + C.cWhite + " damage to",
|
||||
"Sends out a pulse of fire that deals " + C.cGreen + 5 + C.cWhite + " damage to",
|
||||
"all players within " + C.cGreen + 4 + C.cWhite + " blocks.",
|
||||
"Cooldown " + C.cGreen + UtilTime.convertString(45000, 0, TimeUnit.SECONDS) + C.cWhite + "."
|
||||
"Cooldown " + C.cGreen + UtilTime.convertString(40000, 0, TimeUnit.SECONDS) + C.cWhite + "."
|
||||
};
|
||||
|
||||
private static final String FIRE_BURST = "Fire Burst";
|
||||
|
||||
private static final Perk[][] PERKS =
|
||||
{
|
||||
{
|
||||
new PerkFireBurst(45000, 4, 3)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(44000, 4, 3)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(43000, 4, 3)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(42000, 4, 4)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(41000, 4, 4)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(40000, 4, 4)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(39000, 4, 4)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(38000, 4, 4)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(37000, 4, 5)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(36000, 4, 5)
|
||||
},
|
||||
{
|
||||
new PerkFireBurst(35000, 4, 5)
|
||||
},
|
||||
};
|
||||
|
||||
private static final String[][] UPGRADE_DETAILS =
|
||||
@ -61,7 +61,7 @@ public class KitFire extends ProgressingKit
|
||||
},
|
||||
{
|
||||
reduceCooldown(FIRE_BURST, 1),
|
||||
increase(FIRE_BURST, "Range", 20)
|
||||
increase(FIRE_BURST, "Damage", 25)
|
||||
},
|
||||
{
|
||||
reduceCooldown(FIRE_BURST, 1)
|
||||
|
@ -31,7 +31,7 @@ public class KitMetal extends ProgressingKit
|
||||
"Cooldown " + C.cGreen + UtilTime.convertString(15000, 0, TimeUnit.SECONDS) + C.cWhite + ".",
|
||||
"",
|
||||
"For each piece of metal armor you wear you gain",
|
||||
"a level of " + C.cGreen + "Damage Resistance" + C.cWhite + ".",
|
||||
"a " + C.cGreen + 7.5 + C.cWhite + "% damage resistance.",
|
||||
};
|
||||
|
||||
private static final String MAGNET = "Magnet";
|
||||
|
@ -1,34 +1,36 @@
|
||||
package nautilus.game.arcade.kit.perks;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
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.UtilServer;
|
||||
import mineplex.core.common.util.particles.effects.LineParticle;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
|
||||
public class PerkDash extends Perk
|
||||
{
|
||||
|
||||
private static final double DAMAGE_RADIUS = 2;
|
||||
private static final double DAMAGE_RADIUS = 2.5;
|
||||
|
||||
private long _cooldown;
|
||||
private double _damage;
|
||||
@ -78,65 +80,39 @@ public class PerkDash extends Perk
|
||||
return;
|
||||
}
|
||||
|
||||
// Particle Trail
|
||||
Block lastParticle = player.getLocation().getBlock();
|
||||
LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.8, _distance, Sets.newHashSet(Material.RAILS), ParticleType.FIREWORKS_SPARK,
|
||||
UtilServer.getPlayers());
|
||||
Set<UUID> hitPlayers = new HashSet<>();
|
||||
|
||||
double curRange = 0;
|
||||
while (curRange <= _distance)
|
||||
while (!lineParticle.update())
|
||||
{
|
||||
Location newTarget = player.getLocation().add(new Vector(0, 0.2, 0)).add(player.getLocation().getDirection().multiply(curRange));
|
||||
for (Player other : UtilPlayer.getNearby(lineParticle.getLastLocation(), DAMAGE_RADIUS))
|
||||
{
|
||||
if (hitPlayers.contains(other.getUniqueId()) || player.equals(other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!UtilBlock.airFoliage(newTarget.getBlock()) || !UtilBlock.airFoliage(newTarget.getBlock().getRelative(BlockFace.UP)))
|
||||
{
|
||||
if (newTarget.getBlock().getType() != Material.RAILS)
|
||||
{
|
||||
break;
|
||||
hitPlayers.add(other.getUniqueId());
|
||||
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damage, true, true, false, player.getName(), GetName());
|
||||
player.sendMessage(F.main("Game", "You hit " + F.elem(other.getName()) + " with " + F.skill(GetName()) + "."));
|
||||
}
|
||||
}
|
||||
|
||||
// Progress Forwards
|
||||
curRange += 0.2;
|
||||
Game game = Manager.GetGame();
|
||||
Location location = lineParticle.getDestination();
|
||||
|
||||
// Particles
|
||||
if (!lastParticle.equals(newTarget.getBlock()))
|
||||
{
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, lastParticle.getLocation(), 0, 0, 0, 0.001F, 1, ViewDist.NORMAL);
|
||||
}
|
||||
|
||||
//Damage Players
|
||||
for (Player other : UtilPlayer.getNearby(newTarget, DAMAGE_RADIUS))
|
||||
{
|
||||
Manager.GetDamage().NewDamageEvent(other, player, null, DamageCause.CUSTOM, _damage, true, false, false, player.getName(), GetName());
|
||||
}
|
||||
|
||||
lastParticle = newTarget.getBlock();
|
||||
}
|
||||
|
||||
// Modify Range
|
||||
curRange -= 0.4;
|
||||
if (curRange < 0)
|
||||
curRange = 0;
|
||||
|
||||
// Destination
|
||||
Location location = player.getLocation().add(player.getLocation().getDirection().multiply(curRange).add(new Vector(0, 0.4, 0)));
|
||||
|
||||
if (curRange > 0)
|
||||
{
|
||||
// Firework
|
||||
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.WHITE, false, false);
|
||||
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, game.GetTeam(player).GetColorBase(), false, false);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.SHOOT_ARROW, 1, 1);
|
||||
player.teleport(location);
|
||||
player.teleport(location.add(0, 0.5, 0));
|
||||
player.playSound(player.getLocation(), Sound.SHOOT_ARROW, 1, 1);
|
||||
|
||||
// Firework
|
||||
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL, Color.WHITE, false, false);
|
||||
}
|
||||
UtilFirework.playFirework(player.getEyeLocation(), Type.BALL_LARGE, game.GetTeam(player).GetColorBase(), false, false);
|
||||
|
||||
player.setFallDistance(0);
|
||||
|
||||
// Inform
|
||||
UtilPlayer.message(player, F.main("Game", "You used " + F.skill(GetName()) + "."));
|
||||
player.sendMessage(F.main("Game", "You used " + F.skill(GetName()) + "."));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,16 +25,19 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.TeamGame;
|
||||
import nautilus.game.arcade.game.games.skywars.TeamSkywars;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
|
||||
public class PerkDirtCannon extends Perk implements IThrown
|
||||
{
|
||||
|
||||
private static final int GIVE_DELAY = 20000;
|
||||
private static final int MAX_DIRT = 4;
|
||||
private static final long COOLDOWN = 500;
|
||||
|
||||
private static final ItemStack DIRT_ITEM = new ItemBuilder(Material.DIRT).setTitle(C.cGreen + "Throwable Dirt").setGlow(true).build();
|
||||
|
||||
@ -74,6 +77,11 @@ public class PerkDirtCannon extends Perk implements IThrown
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Recharge.Instance.use(player, GetName(), COOLDOWN, true, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int amount = player.getInventory().getItemInHand().getAmount() - 1;
|
||||
|
||||
if (amount == 0)
|
||||
@ -82,7 +90,7 @@ public class PerkDirtCannon extends Perk implements IThrown
|
||||
}
|
||||
else
|
||||
{
|
||||
player.getItemInHand().setAmount(amount);
|
||||
player.getItemInHand().setAmount(Math.min(MAX_DIRT - 1, amount));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -104,7 +112,7 @@ public class PerkDirtCannon extends Perk implements IThrown
|
||||
{
|
||||
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if (!hasPerk(player) || UtilInv.contains(player, "Throwable", Material.DIRT, (byte) 0, 4))
|
||||
if (!hasPerk(player) || UtilInv.contains(player, "Throwable", Material.DIRT, (byte) 0, MAX_DIRT))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -143,6 +151,11 @@ public class PerkDirtCannon extends Perk implements IThrown
|
||||
@EventHandler
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (!hasPerk(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (DIRT_ITEM.isSimilar(event.getItemDrop().getItemStack()))
|
||||
{
|
||||
event.getPlayer().sendMessage(F.main("Game", "You cannot drop this item."));
|
||||
@ -178,16 +191,11 @@ public class PerkDirtCannon extends Perk implements IThrown
|
||||
return;
|
||||
}
|
||||
|
||||
if (Manager.GetGame() instanceof TeamGame && target instanceof Player && data.getThrower() instanceof Player)
|
||||
if (Manager.GetGame() instanceof TeamSkywars && target instanceof Player && data.getThrower() instanceof Player)
|
||||
{
|
||||
Game game = Manager.GetGame();
|
||||
|
||||
if (!game.IsAlive(target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (game.GetTeam((Player) target).equals(game.GetTeam((Player) data.getThrower())))
|
||||
if (game.GetTeam((Player) target).equals(game.GetTeam((Player) data.getThrower())) || !game.IsAlive(target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -16,22 +16,19 @@ import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
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.UtilServer;
|
||||
import mineplex.core.common.util.particles.effects.LineParticle;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.games.skywars.TeamSkywars;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
@ -39,8 +36,6 @@ import nautilus.game.arcade.kit.Perk;
|
||||
public class PerkMagnetism extends Perk
|
||||
{
|
||||
|
||||
private static final int RESISTANCE_DURATION = 40;
|
||||
|
||||
private long _cooldown;
|
||||
private int _range;
|
||||
private double _magnituideFactor;
|
||||
@ -56,30 +51,23 @@ public class PerkMagnetism extends Perk
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
public void onCustomDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.FAST)
|
||||
if (!(event.GetDamageeEntity() instanceof Player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
Player player = event.GetDamageePlayer();
|
||||
|
||||
if (!hasPerk(player))
|
||||
{
|
||||
if (!hasPerk(player) || UtilPlayer.isSpectator(player))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
int magnituide = getAmountOfMetalArmor(player);
|
||||
int magnitude = getAmountOfMetalArmor(player);
|
||||
|
||||
if (magnituide == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, RESISTANCE_DURATION, magnituide - 1));
|
||||
}
|
||||
event.AddMod(GetName(), event.GetDamage() * (magnitude * -0.075));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -139,7 +127,12 @@ public class PerkMagnetism extends Perk
|
||||
}
|
||||
|
||||
Manager.GetDamage().NewDamageEvent(target, player, null, DamageCause.CUSTOM, 1, false, true, true, player.getName(), GetName());
|
||||
UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, player.getEyeLocation(), 1, 1, 1, 0.01F, 20, ViewDist.NORMAL);
|
||||
|
||||
LineParticle lineParticle = new LineParticle(player.getEyeLocation(), player.getLocation().getDirection(), 0.5, UtilMath.offset(player, target), null, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers());
|
||||
|
||||
while (!lineParticle.update())
|
||||
{
|
||||
}
|
||||
|
||||
Vector vector = UtilAlg.getTrajectory(target, player).multiply((.5 + magnitude / 4) * _magnituideFactor);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user