Started adding in all the different effects.
This commit is contained in:
parent
e11bbf6a8d
commit
e6f680d281
|
@ -0,0 +1,4 @@
|
|||
package com.songoda.epicenchants;
|
||||
|
||||
public class Effect {
|
||||
}
|
|
@ -10,7 +10,7 @@ import com.songoda.epicenchants.managers.EnchantManager;
|
|||
import com.songoda.epicenchants.managers.FileManager;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.utils.EnchantUtils;
|
||||
import com.songoda.epicenchants.utils.VersionDependentList;
|
||||
import com.songoda.epicenchants.utils.VersionDependent;
|
||||
import com.songoda.epicenchants.utils.parser.InventoryParser;
|
||||
import fr.minuskube.inv.InventoryManager;
|
||||
import fr.minuskube.inv.SmartInventory;
|
||||
|
@ -100,9 +100,9 @@ public class EpicEnchants extends JavaPlugin {
|
|||
int currentVersion = Integer.parseInt(getServer().getClass().getPackage().getName().split("\\.")[3].split("_")[1]);
|
||||
|
||||
if(currentVersion >= 13) {
|
||||
VersionDependentList.initDefault();
|
||||
VersionDependent.initDefault(currentVersion);
|
||||
} else {
|
||||
VersionDependentList.initLegacy();
|
||||
VersionDependent.initLegacy(currentVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.songoda.epicenchants.effect;
|
||||
|
||||
import com.songoda.epicenchants.objects.LeveledModifier;
|
||||
import com.songoda.epicenchants.utils.GeneralUtils;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class EffectExecutor {
|
||||
@Getter private final ConfigurationSection section;
|
||||
|
||||
public EffectExecutor(ConfigurationSection section) {
|
||||
this.section = section;
|
||||
}
|
||||
|
||||
public void testAndRun(Player wearer, Player opponent, int level) {
|
||||
if (!section.isString("chance")) {
|
||||
execute(wearer, opponent, level);
|
||||
return;
|
||||
}
|
||||
|
||||
if (GeneralUtils.chance(LeveledModifier.of(section.getString("chance")).get(level))) {
|
||||
execute(wearer, opponent, level);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void execute(Player wearer, Player opponent, int level);
|
||||
|
||||
public Optional<Who> who() {
|
||||
return Optional.ofNullable(section.getString("who").equalsIgnoreCase("player") ?
|
||||
Who.PLAYER : section.getString("who").equalsIgnoreCase("opponent") ?
|
||||
Who.OPPONENT : null);
|
||||
}
|
||||
|
||||
public enum Who {
|
||||
PLAYER, OPPONENT
|
||||
}
|
||||
|
||||
public Optional<Integer> getAmount() {
|
||||
return section.isInt("amount") ? Optional.of(section.getInt("amount")) : Optional.empty();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.songoda.epicenchants.effect;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.google.common.base.CaseFormat.UPPER_CAMEL;
|
||||
import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
|
||||
|
||||
public class EffectManager {
|
||||
|
||||
public Optional<EffectExecutor> getEffect(ConfigurationSection section) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(UPPER_UNDERSCORE.to(UPPER_CAMEL, section.getName().toLowerCase()));
|
||||
Constructor<?> constructor = clazz.getConstructor(ConfigurationSection.class);
|
||||
Object object = constructor.newInstance(section);
|
||||
return Optional.of((EffectExecutor) object);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException | ClassCastException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ConsoleCommand extends EffectExecutor {
|
||||
public ConsoleCommand(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
Bukkit.getConsoleSender().sendMessage(getSection().getString("command")
|
||||
.replace("{level}", "" + level)
|
||||
.replace("{wearer}", wearer.getName()
|
||||
.replace("{opponent}", opponent.getName())));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DropHead extends EffectExecutor {
|
||||
public DropHead(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.songoda.epicenchants.effect.EffectExecutor.Who.PLAYER;
|
||||
|
||||
public class Fly extends EffectExecutor {
|
||||
public Fly(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
who().ifPresent(who -> {
|
||||
if (who == PLAYER) wearer.setFlying(!wearer.isFlying());
|
||||
else opponent.setFlying(!opponent.isFlying());
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.songoda.epicenchants.effect.EffectExecutor.Who.PLAYER;
|
||||
|
||||
public class Lightning extends EffectExecutor {
|
||||
public Lightning(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
who().ifPresent(who -> {
|
||||
if (who == PLAYER) wearer.getWorld().strikeLightning(wearer.getLocation());
|
||||
else opponent.getWorld().strikeLightning(opponent.getLocation());
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.songoda.epicenchants.effect.EffectExecutor.Who.PLAYER;
|
||||
|
||||
public class Message extends EffectExecutor {
|
||||
public Message(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
String message = getSection().getString("message").replace("{level}", "" + level);
|
||||
|
||||
who().ifPresent(who -> {
|
||||
if (who == PLAYER) wearer.sendMessage(message);
|
||||
else opponent.sendMessage(message);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.songoda.epicenchants.effect.EffectExecutor.Who.PLAYER;
|
||||
|
||||
public class PlayerCommand extends EffectExecutor {
|
||||
public PlayerCommand(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
String command = getSection().getString("command").replace("{level}", "" + level);
|
||||
|
||||
who().ifPresent(who -> {
|
||||
if (who == PLAYER) wearer.performCommand(command);
|
||||
else opponent.performCommand(command);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.songoda.epicenchants.effect.EffectExecutor.Who.PLAYER;
|
||||
|
||||
public class Repair extends EffectExecutor {
|
||||
public Repair(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
who().ifPresent(who -> {
|
||||
if (who == PLAYER) wearer.getItemInHand().setDurability((short) 0);
|
||||
else opponent.getItemInHand().setDurability((short) 0);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class StealHealth extends EffectExecutor {
|
||||
public StealHealth(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
getAmount().ifPresent(amount -> {
|
||||
wearer.setHealth(wearer.getHealth() + amount);
|
||||
opponent.setHealth(opponent.getHealth() - amount);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.songoda.epicenchants.effect.effects;
|
||||
|
||||
import com.songoda.epicenchants.effect.EffectExecutor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static com.songoda.epicenchants.effect.EffectExecutor.Who.PLAYER;
|
||||
|
||||
public class Tnt extends EffectExecutor {
|
||||
public Tnt(ConfigurationSection section) {
|
||||
super(section);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Player wearer, Player opponent, int level) {
|
||||
getAmount().ifPresent(amount -> who().ifPresent(who -> {
|
||||
if (who == PLAYER) wearer.getWorld().spawnEntity(wearer.getLocation(), EntityType.PRIMED_TNT);
|
||||
else opponent.getWorld().spawnEntity(opponent.getLocation(), EntityType.PRIMED_TNT);
|
||||
}));
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ package com.songoda.epicenchants.listeners;
|
|||
import com.songoda.epicenchants.events.ArmorEquipEvent;
|
||||
import com.songoda.epicenchants.events.ArmorEquipEvent.ArmorType;
|
||||
import com.songoda.epicenchants.events.ArmorEquipEvent.EquipMethod;
|
||||
import com.songoda.epicenchants.utils.VersionDependentList;
|
||||
import com.songoda.epicenchants.utils.VersionDependent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -106,7 +106,7 @@ public class ArmorListener implements Listener {
|
|||
final Player player = e.getPlayer();
|
||||
if (e.getClickedBlock() != null && e.getAction() == Action.RIGHT_CLICK_BLOCK) {// Having both of these checks is useless, might as well do it though.
|
||||
// Some blocks have actions when you right click them which stops the client from equipping the armor in hand.
|
||||
if (VersionDependentList.getBlackList().stream().anyMatch(type -> e.getClickedBlock().getType().equals(type))) {
|
||||
if (VersionDependent.getBlackList().stream().anyMatch(type -> e.getClickedBlock().getType().equals(type))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.songoda.epicenchants.enums.EnchantProcType.*;
|
||||
import static com.songoda.epicenchants.enums.EnchantProcType.DAMAGED;
|
||||
import static com.songoda.epicenchants.enums.EnchantProcType.DEALT_DAMAGE;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
private final EpicEnchants instance;
|
||||
|
@ -32,7 +33,7 @@ public class PlayerListener implements Listener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if (event.getEntityType() != EntityType.PLAYER || (event.getDamager() instanceof Player)) {
|
||||
if (event.getEntityType() != EntityType.PLAYER || !(event.getDamager() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
|
|
|
@ -12,8 +12,10 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.songoda.epicenchants.enums.EnchantProcType.*;
|
||||
import static com.songoda.epicenchants.enums.MaterialType.*;
|
||||
import static com.songoda.epicenchants.enums.EnchantProcType.DAMAGED;
|
||||
import static com.songoda.epicenchants.enums.EnchantProcType.DEALT_DAMAGE;
|
||||
import static com.songoda.epicenchants.enums.MaterialType.ARMOR;
|
||||
import static com.songoda.epicenchants.enums.MaterialType.WEAPON;
|
||||
|
||||
@Builder
|
||||
public class ActionClass {
|
||||
|
@ -26,12 +28,12 @@ public class ActionClass {
|
|||
potionEffectsWearer.stream().filter(p -> p.test(level)).forEach(p -> p.perform(wearer, level));
|
||||
Optional.ofNullable(opponent).ifPresent(a -> potionEffectOpponent.stream().filter(p -> p.test(level)).forEach(p -> p.perform(opponent, level)));
|
||||
|
||||
mobs.forEach(mob -> mob.trySpawn(wearer.getLocation(), level));
|
||||
mobs.forEach(mob -> mob.trySpawn(wearer, opponent, level));
|
||||
|
||||
double percentage = 0;
|
||||
|
||||
if((procType == DAMAGED && type == ARMOR) || (procType == DEALT_DAMAGE && type == WEAPON)) {
|
||||
percentage = modifyDamage.get(level);
|
||||
if ((procType == DAMAGED && type == ARMOR) || (procType == DEALT_DAMAGE && type == WEAPON)) {
|
||||
percentage = modifyDamage.get(level) / 100.0;
|
||||
}
|
||||
|
||||
return damage + damage * percentage;
|
||||
|
|
|
@ -61,7 +61,7 @@ public class EnchantUtils {
|
|||
}
|
||||
|
||||
public void handlePlayer(Player player, Event event, EnchantProcType damageType) {
|
||||
List<ItemStack> stacks = Arrays.asList(player.getInventory().getArmorContents());
|
||||
List<ItemStack> stacks = new ArrayList<>(Arrays.asList(player.getInventory().getArmorContents()));
|
||||
stacks.add(player.getItemInHand());
|
||||
stacks.removeIf(Objects::isNull);
|
||||
|
||||
|
@ -69,8 +69,10 @@ public class EnchantUtils {
|
|||
switch (damageType) {
|
||||
case DAMAGED:
|
||||
enchant.onReceiveDamage((EntityDamageByEntityEvent) event, level);
|
||||
break;
|
||||
case DEALT_DAMAGE:
|
||||
enchant.onDealDamage((EntityDamageByEntityEvent) event, level);
|
||||
break;
|
||||
case MINED:
|
||||
enchant.onMine((BlockBreakEvent) event, level);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,221 @@
|
|||
package com.songoda.epicenchants.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.bukkit.Material.*;
|
||||
|
||||
public class VersionDependent {
|
||||
private static Set<Material> blacklistLegacy;
|
||||
private static Set<Material> blacklist;
|
||||
private static int version;
|
||||
|
||||
public static void initLegacy(int serverVersion) {
|
||||
version = serverVersion;
|
||||
blacklistLegacy = new HashSet<Material>() {
|
||||
{
|
||||
add(valueOf("FURNACE"));
|
||||
add(valueOf("CHEST"));
|
||||
add(valueOf("TRAPPED_CHEST"));
|
||||
add(valueOf("BEACON"));
|
||||
add(valueOf("DISPENSER"));
|
||||
add(valueOf("DROPPER"));
|
||||
add(valueOf("HOPPER"));
|
||||
add(valueOf("WORKBENCH"));
|
||||
add(valueOf("ENCHANTMENT_TABLE"));
|
||||
add(valueOf("ENDER_CHEST"));
|
||||
add(valueOf("ANVIL"));
|
||||
add(valueOf("BED_BLOCK"));
|
||||
add(valueOf("FENCE_GATE"));
|
||||
add(valueOf("SPRUCE_FENCE_GATE"));
|
||||
add(valueOf("BIRCH_FENCE_GATE"));
|
||||
add(valueOf("ACACIA_FENCE_GATE"));
|
||||
add(valueOf("JUNGLE_FENCE_GATE"));
|
||||
add(valueOf("DARK_OAK_FENCE_GATE"));
|
||||
add(valueOf("IRON_DOOR_BLOCK"));
|
||||
add(valueOf("WOODEN_DOOR"));
|
||||
add(valueOf("SPRUCE_DOOR"));
|
||||
add(valueOf("BIRCH_DOOR"));
|
||||
add(valueOf("JUNGLE_DOOR"));
|
||||
add(valueOf("ACACIA_DOOR"));
|
||||
add(valueOf("DARK_OAK_DOOR"));
|
||||
add(valueOf("WOOD_BUTTON"));
|
||||
add(valueOf("STONE_BUTTON"));
|
||||
add(valueOf("TRAP_DOOR"));
|
||||
add(valueOf("IRON_TRAPDOOR"));
|
||||
add(valueOf("DIODE_BLOCK_OFF"));
|
||||
add(valueOf("DIODE_BLOCK_ON"));
|
||||
add(valueOf("REDSTONE_COMPARATOR_OFF"));
|
||||
add(valueOf("REDSTONE_COMPARATOR_ON"));
|
||||
add(valueOf("FENCE"));
|
||||
add(valueOf("SPRUCE_FENCE"));
|
||||
add(valueOf("BIRCH_FENCE"));
|
||||
add(valueOf("JUNGLE_FENCE"));
|
||||
add(valueOf("DARK_OAK_FENCE"));
|
||||
add(valueOf("ACACIA_FENCE"));
|
||||
add(valueOf("NETHER_FENCE"));
|
||||
add(valueOf("BREWING_STAND"));
|
||||
add(valueOf("CAULDRON"));
|
||||
add(valueOf("SIGN_POST"));
|
||||
add(valueOf("WALL_SIGN"));
|
||||
add(valueOf("SIGN"));
|
||||
add(valueOf("LEVER"));
|
||||
add(valueOf("DAYLIGHT_DETECTOR_INVERTED"));
|
||||
add(valueOf("DAYLIGHT_DETECTOR"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void initDefault(int serverVersion) {
|
||||
version = serverVersion;
|
||||
blacklist = new HashSet<Material>() {
|
||||
{
|
||||
add(valueOf("FURNACE"));
|
||||
add(valueOf("CHEST"));
|
||||
add(valueOf("TRAPPED_CHEST"));
|
||||
add(valueOf("BEACON"));
|
||||
add(valueOf("DISPENSER"));
|
||||
add(valueOf("DROPPER"));
|
||||
add(valueOf("HOPPER"));
|
||||
add(valueOf("CRAFTING_TABLE"));
|
||||
add(valueOf("ENCHANTING_TABLE"));
|
||||
|
||||
add(valueOf("BLACK_BED"));
|
||||
add(valueOf("BLUE_BED"));
|
||||
add(valueOf("BROWN_BED"));
|
||||
add(valueOf("CYAN_BED"));
|
||||
add(valueOf("GRAY_BED"));
|
||||
add(valueOf("GREEN_BED"));
|
||||
add(valueOf("LIGHT_BLUE_BED"));
|
||||
add(valueOf("LIGHT_GRAY_BED"));
|
||||
add(valueOf("LIME_BED"));
|
||||
add(valueOf("MAGENTA_BED"));
|
||||
add(valueOf("ORANGE_BED"));
|
||||
add(valueOf("PINK_BED"));
|
||||
add(valueOf("PURPLE_BED"));
|
||||
add(valueOf("RED_BED"));
|
||||
add(valueOf("WHITE_BED"));
|
||||
add(valueOf("YELLOW_BED"));
|
||||
|
||||
add(valueOf("ENDER_CHEST"));
|
||||
add(valueOf("ANVIL"));
|
||||
|
||||
add(valueOf("ACACIA_FENCE_GATE"));
|
||||
add(valueOf("BIRCH_FENCE_GATE"));
|
||||
add(valueOf("DARK_OAK_FENCE_GATE"));
|
||||
add(valueOf("JUNGLE_FENCE_GATE"));
|
||||
add(valueOf("OAK_FENCE_GATE"));
|
||||
add(valueOf("SPRUCE_FENCE_GATE"));
|
||||
|
||||
add(valueOf("IRON_DOOR"));
|
||||
|
||||
add(valueOf("ACACIA_DOOR"));
|
||||
add(valueOf("BIRCH_DOOR"));
|
||||
add(valueOf("DARK_OAK_DOOR"));
|
||||
add(valueOf("JUNGLE_DOOR"));
|
||||
add(valueOf("OAK_DOOR"));
|
||||
add(valueOf("SPRUCE_DOOR"));
|
||||
|
||||
add(valueOf("ACACIA_TRAPDOOR"));
|
||||
add(valueOf("BIRCH_TRAPDOOR"));
|
||||
add(valueOf("DARK_OAK_TRAPDOOR"));
|
||||
add(valueOf("JUNGLE_TRAPDOOR"));
|
||||
add(valueOf("OAK_TRAPDOOR"));
|
||||
add(valueOf("SPRUCE_TRAPDOOR"));
|
||||
|
||||
add(valueOf("ACACIA_BUTTON"));
|
||||
add(valueOf("BIRCH_BUTTON"));
|
||||
add(valueOf("DARK_OAK_BUTTON"));
|
||||
add(valueOf("JUNGLE_BUTTON"));
|
||||
add(valueOf("OAK_BUTTON"));
|
||||
add(valueOf("SPRUCE_BUTTON"));
|
||||
|
||||
add(valueOf("ACACIA_FENCE"));
|
||||
add(valueOf("BIRCH_FENCE"));
|
||||
add(valueOf("DARK_OAK_FENCE"));
|
||||
add(valueOf("JUNGLE_FENCE"));
|
||||
add(valueOf("OAK_FENCE"));
|
||||
add(valueOf("SPRUCE_FENCE"));
|
||||
|
||||
add(valueOf("REPEATER"));
|
||||
add(valueOf("COMPARATOR"));
|
||||
|
||||
add(valueOf("BREWING_STAND"));
|
||||
add(valueOf("CAULDRON"));
|
||||
add(valueOf("WALL_SIGN"));
|
||||
add(valueOf("SIGN"));
|
||||
add(valueOf("LEVER"));
|
||||
add(valueOf("DAYLIGHT_DETECTOR"));
|
||||
|
||||
add(valueOf("SHULKER_BOX"));
|
||||
add(valueOf("BLACK_SHULKER_BOX"));
|
||||
add(valueOf("BLUE_SHULKER_BOX"));
|
||||
add(valueOf("BROWN_SHULKER_BOX"));
|
||||
add(valueOf("CYAN_SHULKER_BOX"));
|
||||
add(valueOf("GRAY_SHULKER_BOX"));
|
||||
add(valueOf("GREEN_SHULKER_BOX"));
|
||||
add(valueOf("LIGHT_BLUE_SHULKER_BOX"));
|
||||
add(valueOf("LIGHT_GRAY_SHULKER_BOX"));
|
||||
add(valueOf("LIME_SHULKER_BOX"));
|
||||
add(valueOf("MAGENTA_SHULKER_BOX"));
|
||||
add(valueOf("ORANGE_SHULKER_BOX"));
|
||||
add(valueOf("PINK_SHULKER_BOX"));
|
||||
add(valueOf("PURPLE_SHULKER_BOX"));
|
||||
add(valueOf("RED_SHULKER_BOX"));
|
||||
add(valueOf("WHITE_SHULKER_BOX"));
|
||||
add(valueOf("YELLOW_SHULKER_BOX"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Set<Material> getBlackList() {
|
||||
return !blacklist.isEmpty() ? blacklist : !blacklistLegacy.isEmpty() ? blacklistLegacy : null;
|
||||
}
|
||||
|
||||
public static ItemStack getStainedGlassPane(int data) {
|
||||
if (version >= 13) {
|
||||
switch (data) {
|
||||
case 0:
|
||||
return new ItemStack(WHITE_STAINED_GLASS_PANE);
|
||||
case 1:
|
||||
return new ItemStack(ORANGE_STAINED_GLASS_PANE);
|
||||
case 2:
|
||||
return new ItemStack(MAGENTA_STAINED_GLASS_PANE);
|
||||
case 3:
|
||||
return new ItemStack(LIGHT_BLUE_STAINED_GLASS_PANE);
|
||||
case 4:
|
||||
return new ItemStack(YELLOW_STAINED_GLASS_PANE);
|
||||
case 5:
|
||||
return new ItemStack(LIME_STAINED_GLASS_PANE);
|
||||
case 6:
|
||||
return new ItemStack(PINK_STAINED_GLASS);
|
||||
case 7:
|
||||
return new ItemStack(GRAY_STAINED_GLASS_PANE);
|
||||
case 8:
|
||||
return new ItemStack(LIGHT_GRAY_STAINED_GLASS_PANE);
|
||||
case 9:
|
||||
return new ItemStack(CYAN_STAINED_GLASS_PANE);
|
||||
case 10:
|
||||
return new ItemStack(PURPLE_STAINED_GLASS_PANE);
|
||||
case 11:
|
||||
return new ItemStack(BLUE_STAINED_GLASS_PANE);
|
||||
case 12:
|
||||
return new ItemStack(BROWN_STAINED_GLASS_PANE);
|
||||
case 13:
|
||||
return new ItemStack(GREEN_STAINED_GLASS_PANE);
|
||||
case 14:
|
||||
return new ItemStack(RED_STAINED_GLASS_PANE);
|
||||
case 15:
|
||||
return new ItemStack(BLACK_STAINED_GLASS_PANE);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) data);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
package com.songoda.epicenchants.utils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class VersionDependentList {
|
||||
private static Set<Material> blacklistLegacy;
|
||||
private static Set<Material> blacklist;
|
||||
|
||||
public static void initLegacy() {
|
||||
blacklistLegacy = new HashSet<Material>() {
|
||||
{
|
||||
add(Material.valueOf("FURNACE"));
|
||||
add(Material.valueOf("CHEST"));
|
||||
add(Material.valueOf("TRAPPED_CHEST"));
|
||||
add(Material.valueOf("BEACON"));
|
||||
add(Material.valueOf("DISPENSER"));
|
||||
add(Material.valueOf("DROPPER"));
|
||||
add(Material.valueOf("HOPPER"));
|
||||
add(Material.valueOf("WORKBENCH"));
|
||||
add(Material.valueOf("ENCHANTMENT_TABLE"));
|
||||
add(Material.valueOf("ENDER_CHEST"));
|
||||
add(Material.valueOf("ANVIL"));
|
||||
add(Material.valueOf("BED_BLOCK"));
|
||||
add(Material.valueOf("FENCE_GATE"));
|
||||
add(Material.valueOf("SPRUCE_FENCE_GATE"));
|
||||
add(Material.valueOf("BIRCH_FENCE_GATE"));
|
||||
add(Material.valueOf("ACACIA_FENCE_GATE"));
|
||||
add(Material.valueOf("JUNGLE_FENCE_GATE"));
|
||||
add(Material.valueOf("DARK_OAK_FENCE_GATE"));
|
||||
add(Material.valueOf("IRON_DOOR_BLOCK"));
|
||||
add(Material.valueOf("WOODEN_DOOR"));
|
||||
add(Material.valueOf("SPRUCE_DOOR"));
|
||||
add(Material.valueOf("BIRCH_DOOR"));
|
||||
add(Material.valueOf("JUNGLE_DOOR"));
|
||||
add(Material.valueOf("ACACIA_DOOR"));
|
||||
add(Material.valueOf("DARK_OAK_DOOR"));
|
||||
add(Material.valueOf("WOOD_BUTTON"));
|
||||
add(Material.valueOf("STONE_BUTTON"));
|
||||
add(Material.valueOf("TRAP_DOOR"));
|
||||
add(Material.valueOf("IRON_TRAPDOOR"));
|
||||
add(Material.valueOf("DIODE_BLOCK_OFF"));
|
||||
add(Material.valueOf("DIODE_BLOCK_ON"));
|
||||
add(Material.valueOf("REDSTONE_COMPARATOR_OFF"));
|
||||
add(Material.valueOf("REDSTONE_COMPARATOR_ON"));
|
||||
add(Material.valueOf("FENCE"));
|
||||
add(Material.valueOf("SPRUCE_FENCE"));
|
||||
add(Material.valueOf("BIRCH_FENCE"));
|
||||
add(Material.valueOf("JUNGLE_FENCE"));
|
||||
add(Material.valueOf("DARK_OAK_FENCE"));
|
||||
add(Material.valueOf("ACACIA_FENCE"));
|
||||
add(Material.valueOf("NETHER_FENCE"));
|
||||
add(Material.valueOf("BREWING_STAND"));
|
||||
add(Material.valueOf("CAULDRON"));
|
||||
add(Material.valueOf("SIGN_POST"));
|
||||
add(Material.valueOf("WALL_SIGN"));
|
||||
add(Material.valueOf("SIGN"));
|
||||
add(Material.valueOf("LEVER"));
|
||||
add(Material.valueOf("DAYLIGHT_DETECTOR_INVERTED"));
|
||||
add(Material.valueOf("DAYLIGHT_DETECTOR"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void initDefault() {
|
||||
blacklist = new HashSet<Material>() {
|
||||
{
|
||||
add(Material.valueOf("FURNACE"));
|
||||
add(Material.valueOf("CHEST"));
|
||||
add(Material.valueOf("TRAPPED_CHEST"));
|
||||
add(Material.valueOf("BEACON"));
|
||||
add(Material.valueOf("DISPENSER"));
|
||||
add(Material.valueOf("DROPPER"));
|
||||
add(Material.valueOf("HOPPER"));
|
||||
add(Material.valueOf("CRAFTING_TABLE"));
|
||||
add(Material.valueOf("ENCHANTING_TABLE"));
|
||||
|
||||
add(Material.valueOf("BLACK_BED"));
|
||||
add(Material.valueOf("BLUE_BED"));
|
||||
add(Material.valueOf("BROWN_BED"));
|
||||
add(Material.valueOf("CYAN_BED"));
|
||||
add(Material.valueOf("GRAY_BED"));
|
||||
add(Material.valueOf("GREEN_BED"));
|
||||
add(Material.valueOf("LIGHT_BLUE_BED"));
|
||||
add(Material.valueOf("LIGHT_GRAY_BED"));
|
||||
add(Material.valueOf("LIME_BED"));
|
||||
add(Material.valueOf("MAGENTA_BED"));
|
||||
add(Material.valueOf("ORANGE_BED"));
|
||||
add(Material.valueOf("PINK_BED"));
|
||||
add(Material.valueOf("PURPLE_BED"));
|
||||
add(Material.valueOf("RED_BED"));
|
||||
add(Material.valueOf("WHITE_BED"));
|
||||
add(Material.valueOf("YELLOW_BED"));
|
||||
|
||||
add(Material.valueOf("ENDER_CHEST"));
|
||||
add(Material.valueOf("ANVIL"));
|
||||
|
||||
add(Material.valueOf("ACACIA_FENCE_GATE"));
|
||||
add(Material.valueOf("BIRCH_FENCE_GATE"));
|
||||
add(Material.valueOf("DARK_OAK_FENCE_GATE"));
|
||||
add(Material.valueOf("JUNGLE_FENCE_GATE"));
|
||||
add(Material.valueOf("OAK_FENCE_GATE"));
|
||||
add(Material.valueOf("SPRUCE_FENCE_GATE"));
|
||||
|
||||
add(Material.valueOf("IRON_DOOR"));
|
||||
|
||||
add(Material.valueOf("ACACIA_DOOR"));
|
||||
add(Material.valueOf("BIRCH_DOOR"));
|
||||
add(Material.valueOf("DARK_OAK_DOOR"));
|
||||
add(Material.valueOf("JUNGLE_DOOR"));
|
||||
add(Material.valueOf("OAK_DOOR"));
|
||||
add(Material.valueOf("SPRUCE_DOOR"));
|
||||
|
||||
add(Material.valueOf("ACACIA_TRAPDOOR"));
|
||||
add(Material.valueOf("BIRCH_TRAPDOOR"));
|
||||
add(Material.valueOf("DARK_OAK_TRAPDOOR"));
|
||||
add(Material.valueOf("JUNGLE_TRAPDOOR"));
|
||||
add(Material.valueOf("OAK_TRAPDOOR"));
|
||||
add(Material.valueOf("SPRUCE_TRAPDOOR"));
|
||||
|
||||
add(Material.valueOf("ACACIA_BUTTON"));
|
||||
add(Material.valueOf("BIRCH_BUTTON"));
|
||||
add(Material.valueOf("DARK_OAK_BUTTON"));
|
||||
add(Material.valueOf("JUNGLE_BUTTON"));
|
||||
add(Material.valueOf("OAK_BUTTON"));
|
||||
add(Material.valueOf("SPRUCE_BUTTON"));
|
||||
|
||||
add(Material.valueOf("ACACIA_FENCE"));
|
||||
add(Material.valueOf("BIRCH_FENCE"));
|
||||
add(Material.valueOf("DARK_OAK_FENCE"));
|
||||
add(Material.valueOf("JUNGLE_FENCE"));
|
||||
add(Material.valueOf("OAK_FENCE"));
|
||||
add(Material.valueOf("SPRUCE_FENCE"));
|
||||
|
||||
add(Material.valueOf("REPEATER"));
|
||||
add(Material.valueOf("COMPARATOR"));
|
||||
|
||||
add(Material.valueOf("BREWING_STAND"));
|
||||
add(Material.valueOf("CAULDRON"));
|
||||
add(Material.valueOf("WALL_SIGN"));
|
||||
add(Material.valueOf("SIGN"));
|
||||
add(Material.valueOf("LEVER"));
|
||||
add(Material.valueOf("DAYLIGHT_DETECTOR"));
|
||||
|
||||
add(Material.valueOf("SHULKER_BOX"));
|
||||
add(Material.valueOf("BLACK_SHULKER_BOX"));
|
||||
add(Material.valueOf("BLUE_SHULKER_BOX"));
|
||||
add(Material.valueOf("BROWN_SHULKER_BOX"));
|
||||
add(Material.valueOf("CYAN_SHULKER_BOX"));
|
||||
add(Material.valueOf("GRAY_SHULKER_BOX"));
|
||||
add(Material.valueOf("GREEN_SHULKER_BOX"));
|
||||
add(Material.valueOf("LIGHT_BLUE_SHULKER_BOX"));
|
||||
add(Material.valueOf("LIGHT_GRAY_SHULKER_BOX"));
|
||||
add(Material.valueOf("LIME_SHULKER_BOX"));
|
||||
add(Material.valueOf("MAGENTA_SHULKER_BOX"));
|
||||
add(Material.valueOf("ORANGE_SHULKER_BOX"));
|
||||
add(Material.valueOf("PINK_SHULKER_BOX"));
|
||||
add(Material.valueOf("PURPLE_SHULKER_BOX"));
|
||||
add(Material.valueOf("RED_SHULKER_BOX"));
|
||||
add(Material.valueOf("WHITE_SHULKER_BOX"));
|
||||
add(Material.valueOf("YELLOW_SHULKER_BOX"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Set<Material> getBlackList() {
|
||||
return !blacklist.isEmpty() ? blacklist : !blacklistLegacy.isEmpty() ? blacklistLegacy : null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,24 @@
|
|||
package com.songoda.epicenchants.utils.parser;
|
||||
|
||||
import com.songoda.epicenchants.enums.MaterialType;
|
||||
import com.songoda.epicenchants.objects.*;
|
||||
import com.songoda.epicenchants.objects.ActionClass;
|
||||
import com.songoda.epicenchants.objects.BookItem;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.objects.LeveledModifier;
|
||||
import com.songoda.epicenchants.utils.Chat;
|
||||
import com.songoda.epicenchants.utils.ItemBuilder;
|
||||
import com.songoda.epicenchants.wrappers.*;
|
||||
import com.songoda.epicenchants.wrappers.EnchantmentWrapper;
|
||||
import com.songoda.epicenchants.wrappers.MobWrapper;
|
||||
import com.songoda.epicenchants.wrappers.PotionChanceWrapper;
|
||||
import com.songoda.epicenchants.wrappers.PotionEffectWrapper;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -24,66 +32,67 @@ public class ConfigParser {
|
|||
.materialType(MaterialType.of(config.getString("type")))
|
||||
.maxLevel(config.getInt("max-level"))
|
||||
.format(color(config.getString("applied-format")))
|
||||
.action(parseActionClass(config.getConfigurationSection("action")))
|
||||
.action(parseActions(config))
|
||||
.bookItem(parseBookItem(config.getConfigurationSection("book-item")))
|
||||
.itemWhitelist(config.getStringList("item-whitelist").stream().map(Material::valueOf).collect(Collectors.toSet()))
|
||||
.potionEffects(config.getConfigurationSection("potion-effects").getKeys(false).stream()
|
||||
.map(s -> "potion-effects." + s)
|
||||
.potionEffects(config.getConfigurationSection("potion-effect").getKeys(false).stream()
|
||||
.map(s -> "potion-effect." + s)
|
||||
.map(config::getConfigurationSection)
|
||||
.map(ConfigParser::parsePotionEffect)
|
||||
.collect(Collectors.toSet()))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static ActionClass parseActionClass(ConfigurationSection section) {
|
||||
return ActionClass.builder()
|
||||
public static ActionClass parseActions(ConfigurationSection section) {
|
||||
return section != null ? ActionClass.builder()
|
||||
.modifyDamage(LeveledModifier.of(section.getString("modify-damage")))
|
||||
.potionEffectsWearer(ConfigParser.getPotionChanceSet(section.getConfigurationSection("potion-effects-wearer")))
|
||||
.potionEffectOpponent(ConfigParser.getPotionChanceSet(section.getConfigurationSection("potion-effects-opponent")))
|
||||
.potionEffectsWearer(ConfigParser.getPotionChanceSet(section.getConfigurationSection("potion-effect-wearer")))
|
||||
.potionEffectOpponent(ConfigParser.getPotionChanceSet(section.getConfigurationSection("potion-effect-opponent")))
|
||||
.mobs(section.getConfigurationSection("mobs").getKeys(false).stream()
|
||||
.map(s -> "mobs." + s)
|
||||
.map(section::getConfigurationSection)
|
||||
.map(ConfigParser::parseMobWrapper).collect(Collectors.toSet()))
|
||||
.build();
|
||||
.build() : null;
|
||||
}
|
||||
|
||||
private static Set<PotionChanceWrapper> getPotionChanceSet(ConfigurationSection section) {
|
||||
return section.getKeys(false).stream()
|
||||
return section != null ? section.getKeys(false).stream()
|
||||
.map(section::getConfigurationSection)
|
||||
.map(ConfigParser::parsePotionChanceEffect)
|
||||
.collect(Collectors.toSet());
|
||||
.collect(Collectors.toSet()) : Collections.emptySet();
|
||||
}
|
||||
|
||||
public static PotionChanceWrapper parsePotionChanceEffect(ConfigurationSection section) {
|
||||
return PotionChanceWrapper.chanceBuilder()
|
||||
return section != null ? PotionChanceWrapper.chanceBuilder()
|
||||
.type(PotionEffectType.getByName(section.getName()))
|
||||
.amplifier(LeveledModifier.of(section.getString("amplifier")))
|
||||
.duration(LeveledModifier.of(section.getString("duration")))
|
||||
.chance(LeveledModifier.of(section.getString("chance")))
|
||||
.build();
|
||||
.build() : null;
|
||||
}
|
||||
|
||||
public static PotionEffectWrapper parsePotionEffect(ConfigurationSection section) {
|
||||
return PotionEffectWrapper.builder()
|
||||
return section != null ? PotionEffectWrapper.builder()
|
||||
.type(PotionEffectType.getByName(section.getName()))
|
||||
.amplifier(LeveledModifier.of(section.getString("amplifier")))
|
||||
.duration(LeveledModifier.of(section.getString("duration")))
|
||||
.build();
|
||||
.build() : null;
|
||||
}
|
||||
|
||||
public static MobWrapper parseMobWrapper(ConfigurationSection section) {
|
||||
return MobWrapper.builder()
|
||||
.amount(section.getInt("amount"))
|
||||
return section != null ? MobWrapper.builder()
|
||||
.entityType(EntityType.valueOf(section.getName()))
|
||||
.amount(section.getInt("max-amount"))
|
||||
.spawnPercentage(LeveledModifier.of(section.getString("spawn-percentage")))
|
||||
.health(section.getInt("health"))
|
||||
.attackDamage(section.getDouble("attack-damage"))
|
||||
.hostile(section.getBoolean("hostile"))
|
||||
.displayName(color(section.getString("display-name")))
|
||||
.helmet(new ItemBuilder(section.getConfigurationSection("armor.helmet")))
|
||||
.leggings(new ItemBuilder(section.getConfigurationSection("armor.chest-plate")))
|
||||
.chestPlate(new ItemBuilder(section.getConfigurationSection("armor.leggings")))
|
||||
.boots(new ItemBuilder(section.getConfigurationSection("armor.boots")))
|
||||
.build();
|
||||
.helmet(section.isConfigurationSection("equipment.helmet") ? new ItemBuilder(section.getConfigurationSection("equipment.helmet")) : null)
|
||||
.chestPlate(section.isConfigurationSection("equipment.chestplate") ? new ItemBuilder(section.getConfigurationSection("equipment.chestplate")) : null)
|
||||
.leggings(section.isConfigurationSection("equipment.leggings") ? new ItemBuilder(section.getConfigurationSection("equipment.leggings")) : null)
|
||||
.boots(section.isConfigurationSection("equipment.boots") ? new ItemBuilder(section.getConfigurationSection("equipment.boots")) : null)
|
||||
.build() : null;
|
||||
}
|
||||
|
||||
public static EnchantmentWrapper parseEnchantmentWrapper(String key) {
|
||||
|
@ -94,10 +103,10 @@ public class ConfigParser {
|
|||
}
|
||||
|
||||
public static BookItem parseBookItem(ConfigurationSection section) {
|
||||
return BookItem.builder()
|
||||
return section != null ? BookItem.builder()
|
||||
.material(Material.valueOf(section.getString("material")))
|
||||
.displayName(color(section.getString("display-name")))
|
||||
.lore(section.getStringList("lore").stream().map(Chat::color).collect(Collectors.toList()))
|
||||
.build();
|
||||
.build() : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,10 +3,14 @@ package com.songoda.epicenchants.wrappers;
|
|||
import com.songoda.epicenchants.objects.LeveledModifier;
|
||||
import com.songoda.epicenchants.utils.GeneralUtils;
|
||||
import com.songoda.epicenchants.utils.ItemBuilder;
|
||||
import de.tr7zw.itemnbtapi.NBTEntity;
|
||||
import de.tr7zw.itemnbtapi.NBTList;
|
||||
import de.tr7zw.itemnbtapi.NBTListCompound;
|
||||
import de.tr7zw.itemnbtapi.NBTType;
|
||||
import lombok.Builder;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static java.util.concurrent.ThreadLocalRandom.current;
|
||||
|
||||
|
@ -15,17 +19,21 @@ public class MobWrapper {
|
|||
private String displayName;
|
||||
private int amount;
|
||||
private int health;
|
||||
private int armorDropChance;
|
||||
private EntityType entityType;
|
||||
private LeveledModifier spawnPercentage;
|
||||
private double attackDamage;
|
||||
private boolean hostile;
|
||||
private ItemBuilder helmet, chestPlate, leggings, boots;
|
||||
|
||||
public boolean trySpawn(Location location, int level) {
|
||||
public boolean trySpawn(@NotNull Player player, Player opponent, int level) {
|
||||
if (!GeneralUtils.chance(spawnPercentage.get(level))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Location location = player.getLocation();
|
||||
|
||||
|
||||
for (int i = 0; i < current().nextInt(amount + 1); i++) {
|
||||
Location spawnLocation = location.clone().add(current().nextInt(-3, 3), 0, current().nextInt(-3, 3));
|
||||
int y = location.getWorld().getHighestBlockAt(spawnLocation).getY();
|
||||
|
@ -34,15 +42,41 @@ public class MobWrapper {
|
|||
continue;
|
||||
}
|
||||
|
||||
LivingEntity entity = (LivingEntity) location.getWorld().spawn(spawnLocation, entityType.getEntityClass());
|
||||
Entity entity = location.getWorld().spawnEntity(spawnLocation, entityType);
|
||||
|
||||
entity.setCustomName(displayName);
|
||||
entity.setCustomNameVisible(true);
|
||||
entity.setHealth(health);
|
||||
entity.getEquipment().setHelmet(helmet.buildWithWrappers(level));
|
||||
entity.getEquipment().setChestplate(chestPlate.buildWithWrappers(level));
|
||||
entity.getEquipment().setLeggings(leggings.buildWithWrappers(level));
|
||||
entity.getEquipment().setBoots(boots.buildWithWrappers(level));
|
||||
|
||||
if (entity instanceof LivingEntity) {
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
livingEntity.getEquipment().setHelmet(helmet.buildWithWrappers(level));
|
||||
livingEntity.getEquipment().setChestplate(chestPlate.buildWithWrappers(level));
|
||||
livingEntity.getEquipment().setLeggings(leggings.buildWithWrappers(level));
|
||||
livingEntity.getEquipment().setBoots(boots.buildWithWrappers(level));
|
||||
livingEntity.getEquipment().setHelmetDropChance(armorDropChance);
|
||||
livingEntity.getEquipment().setLeggingsDropChance(armorDropChance);
|
||||
livingEntity.getEquipment().setHelmetDropChance(armorDropChance);
|
||||
livingEntity.getEquipment().setChestplateDropChance(armorDropChance);
|
||||
}
|
||||
|
||||
if (entity instanceof Monster && opponent != null) {
|
||||
((Monster) entity).setTarget(opponent);
|
||||
}
|
||||
|
||||
NBTEntity nbtEntity = new NBTEntity(entity);
|
||||
NBTList list = nbtEntity.getList("Attributes", NBTType.NBTTagCompound);
|
||||
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
NBTListCompound lc = list.getCompound(j);
|
||||
if (lc.getString("Name").equals("generic.attackDamage")) {
|
||||
lc.setDouble("Base", attackDamage);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lc.getString("Name").equals("generic.maxHealth")) {
|
||||
lc.setDouble("Base", health);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -7,6 +7,9 @@ max-level: 3
|
|||
#The tier of this enchant
|
||||
tier: 1
|
||||
|
||||
#Type of material this enchant will be applied to (WEAPON/ARMOR/TOOL)
|
||||
type: ARMOR
|
||||
|
||||
#The book item
|
||||
book-item:
|
||||
material: BOOK
|
||||
|
@ -25,56 +28,71 @@ item-whitelist:
|
|||
- "IRON_HELMET"
|
||||
- "LEATHER_HELMET"
|
||||
|
||||
#Potion effects applied on equip
|
||||
#Potion effect applied on equip
|
||||
potion-effects:
|
||||
INCREASE_DAMAGE:
|
||||
amplifier: "{level}"
|
||||
duration: MAX
|
||||
|
||||
#Type of material this enchant will be applied to (WEAPON/ARMOR/TOOL)
|
||||
type: ARMOR
|
||||
#Custom effect:
|
||||
# FLY:
|
||||
# LIGHTNING:
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
effects:
|
||||
FLY:
|
||||
type: "STATIC_EFFECT"
|
||||
chance: 20
|
||||
who: OPPONENT
|
||||
|
||||
#On hit or deal damage
|
||||
action:
|
||||
#Percentage that will be added or subtracted from the total damage.
|
||||
modify-damage: 40
|
||||
potion-effects-wearer:
|
||||
STRENGTH:
|
||||
duration: 3
|
||||
chance: "20 * {level}"
|
||||
amplifier: 2
|
||||
potion-effects-opponent:
|
||||
STRENGTH:
|
||||
duration: 3
|
||||
chance: "20 * {level}"
|
||||
amplifier: 2
|
||||
#Spawned when hit or when you strike an enemy in case of tools
|
||||
mobs:
|
||||
IRON_GOLEM:
|
||||
amount: 3
|
||||
spawn-percentage: 20
|
||||
health: 80
|
||||
attack-damage: 2
|
||||
hostile: true
|
||||
display-name: "&cAngry guy"
|
||||
armor:
|
||||
helmet:
|
||||
material: DIAMOND_HELMET
|
||||
enchants:
|
||||
- "DURABILITY:3"
|
||||
- "THORNS:2"
|
||||
chest-plate:
|
||||
material: DIAMOND_CHESTPLATE
|
||||
enchants:
|
||||
- "DURABILITY:3"
|
||||
- "THORNS:2"
|
||||
leggings:
|
||||
material: DIAMOND_LEGGINGS
|
||||
enchants:
|
||||
- "DURABILITY:3"
|
||||
- "THORNS:2"
|
||||
boots:
|
||||
material: DIAMOND_BOOTS
|
||||
enchants:
|
||||
- "DURABILITY:3"
|
||||
- "THORNS:2"
|
||||
#Percentage that will be added or subtracted from the total damage.
|
||||
modify-damage: 40
|
||||
|
||||
#Potion effect that will given to the wearer on damage
|
||||
potion-effects-wearer:
|
||||
SPEED:
|
||||
duration: 3
|
||||
chance: "20 * {level}"
|
||||
amplifier: 2
|
||||
|
||||
#Potion effect that will given to the opponent on damage
|
||||
potion-effects-opponent:
|
||||
SPEED:
|
||||
duration: 3
|
||||
chance: "20 * {level}"
|
||||
amplifier: 2
|
||||
|
||||
#Spawned when hit or when you strike an enemy in case of tools
|
||||
mobs:
|
||||
ZOMBIE:
|
||||
max-amount: 3
|
||||
spawn-percentage: 20
|
||||
armor-drop-chance: 0
|
||||
health: 20
|
||||
attack-damage: 2
|
||||
hostile: true
|
||||
display-name: "&cAngry guy"
|
||||
equipment:
|
||||
helmet:
|
||||
material: DIAMOND_HELMET
|
||||
enchants:
|
||||
- "DURABILITY:3"
|
||||
- "THORNS:2"
|
||||
chestplate:
|
||||
material: DIAMOND_CHESTPLATE
|
||||
enchants:
|
||||
- "DURABILITY:3"
|
||||
- "THORNS:2"
|
||||
leggings:
|
||||
material: DIAMOND_LEGGINGS
|
||||
enchants:
|
||||
- "DURABILITY:3"
|
||||
- "THORNS:2"
|
||||
boots:
|
||||
material: DIAMOND_BOOTS
|
||||
enchants:
|
||||
- "DURABILITY:3"
|
||||
- "THORNS:2"
|
|
@ -1,10 +1,11 @@
|
|||
title: "Books"
|
||||
rows: 3
|
||||
rows: 1
|
||||
|
||||
fill:
|
||||
material: "STAINED_GLASS_PANE"
|
||||
display-name: "&r"
|
||||
data: 7
|
||||
#You can choose to fill the entire inventory witht this material
|
||||
#fill:
|
||||
# material: "MATERIAL_HERE"
|
||||
# display-name: "&r"
|
||||
# data: 7
|
||||
|
||||
contents:
|
||||
1:
|
||||
|
|
Loading…
Reference in New Issue