mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 14:38:56 +00:00
Move damage gear to Helper
This commit is contained in:
1 parent
8c413ba158
commit
4a4bcc02cd
2 files changed
+126
-113
No files matched your search
@@ -2,6 +2,12 @@ package me.ShermansWorld.AlathraWar;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.Damageable;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class Helper
|
public class Helper
|
||||||
{
|
{
|
||||||
@@ -16,4 +22,119 @@ public class Helper
|
|||||||
public static void testMsg() {
|
public static void testMsg() {
|
||||||
Bukkit.broadcastMessage("test message");
|
Bukkit.broadcastMessage("test message");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void damageAllGear(Player p) {
|
||||||
|
final Inventory inv = p.getInventory();
|
||||||
|
for (int i = 0; i < inv.getSize(); ++i) {
|
||||||
|
final ItemStack is = inv.getItem(i);
|
||||||
|
if (is != null && (is.getType() == Material.NETHERITE_AXE || is.getType() == Material.NETHERITE_SWORD || is.getType() == Material.DIAMOND_AXE || is.getType() == Material.DIAMOND_SWORD || is.getType() == Material.IRON_AXE || is.getType() == Material.IRON_SWORD)) {
|
||||||
|
ItemMeta meta = is.getItemMeta();
|
||||||
|
final Damageable damageable = (Damageable)meta;
|
||||||
|
if (is.getType() == Material.NETHERITE_SWORD || is.getType() == Material.NETHERITE_AXE) {
|
||||||
|
damageable.setDamage(damageable.getDamage() + 507);
|
||||||
|
if (damageable.getDamage() > 2000) {
|
||||||
|
damageable.setDamage(2030);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is.getType() == Material.DIAMOND_SWORD || is.getType() == Material.DIAMOND_AXE) {
|
||||||
|
damageable.setDamage(damageable.getDamage() + 390);
|
||||||
|
if (damageable.getDamage() > 1500) {
|
||||||
|
damageable.setDamage(1560);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is.getType() == Material.IRON_SWORD || is.getType() == Material.IRON_AXE) {
|
||||||
|
damageable.setDamage(damageable.getDamage() + 62);
|
||||||
|
if (damageable.getDamage() > 200) {
|
||||||
|
damageable.setDamage(249);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
meta = (ItemMeta)damageable;
|
||||||
|
is.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final ItemStack[] armor = p.getInventory().getArmorContents();
|
||||||
|
for (int j = 0; j < armor.length; ++j) {
|
||||||
|
if (armor[j] != null) {
|
||||||
|
final ItemStack is2 = armor[j];
|
||||||
|
if (is2.getType() == Material.NETHERITE_HELMET || is2.getType() == Material.NETHERITE_CHESTPLATE || is2.getType() == Material.NETHERITE_LEGGINGS || is2.getType() == Material.NETHERITE_BOOTS || is2.getType() == Material.DIAMOND_HELMET || is2.getType() == Material.DIAMOND_CHESTPLATE || is2.getType() == Material.DIAMOND_LEGGINGS || is2.getType() == Material.NETHERITE_BOOTS || is2.getType() == Material.IRON_HELMET || is2.getType() == Material.IRON_CHESTPLATE || is2.getType() == Material.IRON_LEGGINGS || is2.getType() == Material.IRON_BOOTS) {
|
||||||
|
ItemMeta meta2 = is2.getItemMeta();
|
||||||
|
final Damageable damageable2 = (Damageable)meta2;
|
||||||
|
if (is2.getType() == Material.NETHERITE_HELMET) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 101);
|
||||||
|
if (damageable2.getDamage() > 400) {
|
||||||
|
damageable2.setDamage(406);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.NETHERITE_CHESTPLATE) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 148);
|
||||||
|
if (damageable2.getDamage() > 450) {
|
||||||
|
damageable2.setDamage(591);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.NETHERITE_LEGGINGS) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 138);
|
||||||
|
if (damageable2.getDamage() > 420) {
|
||||||
|
damageable2.setDamage(554);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.NETHERITE_BOOTS) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 120);
|
||||||
|
if (damageable2.getDamage() > 370) {
|
||||||
|
damageable2.setDamage(480);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.DIAMOND_HELMET) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 90);
|
||||||
|
if (damageable2.getDamage() > 280) {
|
||||||
|
damageable2.setDamage(362);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.DIAMOND_CHESTPLATE) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 132);
|
||||||
|
if (damageable2.getDamage() > 410) {
|
||||||
|
damageable2.setDamage(527);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.DIAMOND_LEGGINGS) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 123);
|
||||||
|
if (damageable2.getDamage() > 380) {
|
||||||
|
damageable2.setDamage(494);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.DIAMOND_BOOTS) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 107);
|
||||||
|
if (damageable2.getDamage() > 330) {
|
||||||
|
damageable2.setDamage(428);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.IRON_HELMET) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 41);
|
||||||
|
if (damageable2.getDamage() > 125) {
|
||||||
|
damageable2.setDamage(164);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.IRON_CHESTPLATE) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 60);
|
||||||
|
if (damageable2.getDamage() > 190) {
|
||||||
|
damageable2.setDamage(239);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.IRON_LEGGINGS) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 56);
|
||||||
|
if (damageable2.getDamage() > 180) {
|
||||||
|
damageable2.setDamage(224);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (is2.getType() == Material.IRON_BOOTS) {
|
||||||
|
damageable2.setDamage(damageable2.getDamage() + 48);
|
||||||
|
if (damageable2.getDamage() > 150) {
|
||||||
|
damageable2.setDamage(194);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
meta2 = (ItemMeta)damageable2;
|
||||||
|
is2.setItemMeta(meta2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -137,124 +137,16 @@ public final class KillsListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Damage all gear held by the player, and then send them to spawn
|
* Damage all gear held by the player (and then send them to spawn?)
|
||||||
* They don't lose items from death.
|
* They don't lose items from death.
|
||||||
* @param killed
|
* @param killed
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
private void siegeKill(final Player killed, final PlayerDeathEvent event) {
|
private void siegeKill(final Player killed, final PlayerDeathEvent event) {
|
||||||
final Inventory inv = (Inventory)killed.getInventory();
|
//Helper
|
||||||
for (int i = 0; i < inv.getSize(); ++i) {
|
Helper.damageAllGear(killed);
|
||||||
final ItemStack is = inv.getItem(i);
|
|
||||||
if (is != null && (is.getType() == Material.NETHERITE_AXE || is.getType() == Material.NETHERITE_SWORD || is.getType() == Material.DIAMOND_AXE || is.getType() == Material.DIAMOND_SWORD || is.getType() == Material.IRON_AXE || is.getType() == Material.IRON_SWORD)) {
|
//Siege specific
|
||||||
ItemMeta meta = is.getItemMeta();
|
|
||||||
final Damageable damageable = (Damageable)meta;
|
|
||||||
if (is.getType() == Material.NETHERITE_SWORD || is.getType() == Material.NETHERITE_AXE) {
|
|
||||||
damageable.setDamage(damageable.getDamage() + 507);
|
|
||||||
if (damageable.getDamage() > 2000) {
|
|
||||||
damageable.setDamage(2030);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (is.getType() == Material.DIAMOND_SWORD || is.getType() == Material.DIAMOND_AXE) {
|
|
||||||
damageable.setDamage(damageable.getDamage() + 390);
|
|
||||||
if (damageable.getDamage() > 1500) {
|
|
||||||
damageable.setDamage(1560);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (is.getType() == Material.IRON_SWORD || is.getType() == Material.IRON_AXE) {
|
|
||||||
damageable.setDamage(damageable.getDamage() + 62);
|
|
||||||
if (damageable.getDamage() > 200) {
|
|
||||||
damageable.setDamage(249);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
meta = (ItemMeta)damageable;
|
|
||||||
is.setItemMeta(meta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final ItemStack[] armor = killed.getInventory().getArmorContents();
|
|
||||||
for (int j = 0; j < armor.length; ++j) {
|
|
||||||
if (armor[j] != null) {
|
|
||||||
final ItemStack is2 = armor[j];
|
|
||||||
if (is2.getType() == Material.NETHERITE_HELMET || is2.getType() == Material.NETHERITE_CHESTPLATE || is2.getType() == Material.NETHERITE_LEGGINGS || is2.getType() == Material.NETHERITE_BOOTS || is2.getType() == Material.DIAMOND_HELMET || is2.getType() == Material.DIAMOND_CHESTPLATE || is2.getType() == Material.DIAMOND_LEGGINGS || is2.getType() == Material.NETHERITE_BOOTS || is2.getType() == Material.IRON_HELMET || is2.getType() == Material.IRON_CHESTPLATE || is2.getType() == Material.IRON_LEGGINGS || is2.getType() == Material.IRON_BOOTS) {
|
|
||||||
ItemMeta meta2 = is2.getItemMeta();
|
|
||||||
final Damageable damageable2 = (Damageable)meta2;
|
|
||||||
if (is2.getType() == Material.NETHERITE_HELMET) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 101);
|
|
||||||
if (damageable2.getDamage() > 400) {
|
|
||||||
damageable2.setDamage(406);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.NETHERITE_CHESTPLATE) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 148);
|
|
||||||
if (damageable2.getDamage() > 450) {
|
|
||||||
damageable2.setDamage(591);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.NETHERITE_LEGGINGS) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 138);
|
|
||||||
if (damageable2.getDamage() > 420) {
|
|
||||||
damageable2.setDamage(554);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.NETHERITE_BOOTS) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 120);
|
|
||||||
if (damageable2.getDamage() > 370) {
|
|
||||||
damageable2.setDamage(480);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.DIAMOND_HELMET) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 90);
|
|
||||||
if (damageable2.getDamage() > 280) {
|
|
||||||
damageable2.setDamage(362);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.DIAMOND_CHESTPLATE) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 132);
|
|
||||||
if (damageable2.getDamage() > 410) {
|
|
||||||
damageable2.setDamage(527);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.DIAMOND_LEGGINGS) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 123);
|
|
||||||
if (damageable2.getDamage() > 380) {
|
|
||||||
damageable2.setDamage(494);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.DIAMOND_BOOTS) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 107);
|
|
||||||
if (damageable2.getDamage() > 330) {
|
|
||||||
damageable2.setDamage(428);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.IRON_HELMET) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 41);
|
|
||||||
if (damageable2.getDamage() > 125) {
|
|
||||||
damageable2.setDamage(164);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.IRON_CHESTPLATE) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 60);
|
|
||||||
if (damageable2.getDamage() > 190) {
|
|
||||||
damageable2.setDamage(239);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.IRON_LEGGINGS) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 56);
|
|
||||||
if (damageable2.getDamage() > 180) {
|
|
||||||
damageable2.setDamage(224);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (is2.getType() == Material.IRON_BOOTS) {
|
|
||||||
damageable2.setDamage(damageable2.getDamage() + 48);
|
|
||||||
if (damageable2.getDamage() > 150) {
|
|
||||||
damageable2.setDamage(194);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
meta2 = (ItemMeta)damageable2;
|
|
||||||
is2.setItemMeta(meta2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "spawn " + killed.getName());
|
Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "spawn " + killed.getName());
|
||||||
event.setKeepInventory(true);
|
event.setKeepInventory(true);
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
|
|||||||
Reference in new issue
Block a user