diff --git a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/IllusionerWrapper.java b/NMS/API/src/main/java/com/willfp/illusioner/nms/api/IllusionerWrapper.java index ab341c0..80e7170 100644 --- a/NMS/API/src/main/java/com/willfp/illusioner/nms/api/IllusionerWrapper.java +++ b/NMS/API/src/main/java/com/willfp/illusioner/nms/api/IllusionerWrapper.java @@ -6,5 +6,5 @@ import org.bukkit.Location; * NMS Interface for managing illusioner bosses */ public interface IllusionerWrapper { - EntityIllusionerWrapper spawn(Location location, double maxHealth, double attackDamage); + EntityIllusionerWrapper spawn(Location location, double maxHealth, double attackDamage, String name); } \ No newline at end of file diff --git a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/EntityIllusioner.java b/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/EntityIllusioner.java index b20d2ea..c2ef225 100644 --- a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/EntityIllusioner.java +++ b/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/EntityIllusioner.java @@ -15,8 +15,11 @@ import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitRunnable; public class EntityIllusioner extends EntityIllagerIllusioner implements EntityIllusionerWrapper { - public EntityIllusioner(Location location, double maxHealth, double attackDamage) { + private final String displayName; + + public EntityIllusioner(Location location, double maxHealth, double attackDamage, String name) { super(EntityTypes.ILLUSIONER, ((CraftWorld) location.getWorld()).getHandle()); + this.displayName = name; this.setPosition(location.getX(), location.getY(), location.getZ()); @@ -43,7 +46,7 @@ public class EntityIllusioner extends EntityIllagerIllusioner implements EntityI @Override public void createBossbar(Plugin plugin, BarColor color, BarStyle style) { - String name = this.getName(); + String name = this.getDisplayName().getText(); BossBar bossBar = Bukkit.getServer().createBossBar(name, color, style, (BarFlag) null); Bukkit.getServer().getOnlinePlayers().forEach(bossBar::addPlayer); LivingEntity entity = (LivingEntity) this.getBukkitEntity(); diff --git a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/Illusioner.java b/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/Illusioner.java index 0d98190..6cc6425 100644 --- a/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/Illusioner.java +++ b/NMS/v1_16_R3/src/main/java/com/willfp/illusioner/v1_16_R3/Illusioner.java @@ -7,8 +7,8 @@ import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; public class Illusioner implements IllusionerWrapper { @Override - public EntityIllusionerWrapper spawn(Location location, double maxHealth, double attackDamage) { - EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage); + public EntityIllusionerWrapper spawn(Location location, double maxHealth, double attackDamage, String name) { + EntityIllusioner illusioner = new EntityIllusioner(location, maxHealth, attackDamage, name); ((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner); return illusioner; } diff --git a/Plugin/build.gradle b/Plugin/build.gradle index 5fd323a..39c86ca 100644 --- a/Plugin/build.gradle +++ b/Plugin/build.gradle @@ -13,20 +13,8 @@ dependencies { implementation 'org.bstats:bstats-bukkit:1.7' compileOnly 'org.spigotmc:spigot-api:1.16.3-R0.1-SNAPSHOT' compileOnly 'commons-io:commons-io:2.8.0' - compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT' - compileOnly 'com.github.TechFortress:GriefPrevention:16.14.0' - compileOnly 'com.massivecraft:Factions:1.6.9.5-U0.5.10' - compileOnly 'com.github.cryptomorin:kingdoms:1.10.3.1' - shadow files('../lib/SpartanAPI.jar') - compileOnly 'com.github.TownyAdvanced:Towny:0.96.2.0' - compileOnly 'com.github.angeschossen:LandsAPI:4.7.3' - compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT' - compileOnly 'de.janmm14:aac-api:4.2.0' - compileOnly 'com.github.jiangdashao:matrix-api-repo:317d4635fd' - compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT' - compileOnly 'com.destroystokyo.paper:paper-api:1.16.3-R0.1-SNAPSHOT' - compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.157' compileOnly 'me.clip:placeholderapi:2.10.9' + compileOnly 'com.willfp:EcoEnchants:5.3.1' } shadowJar { diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/AttackListeners.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/AttackListeners.java deleted file mode 100644 index b72e690..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/illusioner/AttackListeners.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.willfp.illusioner.illusioner; - -import com.willfp.illusioner.util.NumberUtils; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.ExperienceOrb; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class AttackListeners implements Listener { - @EventHandler - public void onIllusionerAttack(EntityDamageByEntityEvent event) { - if(!event.getDamager().getType().equals(EntityType.ILLUSIONER)) - return; - - if(!(event.getEntity() instanceof Player)) - return; - - Player player = (Player) event.getEntity(); - - player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 40, 1)); - player.playSound(player.getLocation(), Sound.ENTITY_ILLUSIONER_CAST_SPELL, 1, 1f); - if(!player.hasPotionEffect(PotionEffectType.CONFUSION)) { - player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 200, 10)); - player.playSound(player.getLocation(), Sound.ENTITY_ILLUSIONER_CAST_SPELL, 1, 2f); - } - if(NumberUtils.randInt(1, 10) <= 2) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 2)); - player.playSound(player.getLocation(), Sound.ENTITY_ILLUSIONER_CAST_SPELL, 1, 2f); - } - if(NumberUtils.randInt(1, 10) <= 2) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 40, 2)); - player.playSound(player.getLocation(), Sound.ENTITY_ILLUSIONER_CAST_SPELL, 1, 2f); - } - - if(NumberUtils.randInt(1, 20) == 1) { - List hotbar = new ArrayList<>(); - for(int i = 0; i<9; i++) { - hotbar.add(player.getInventory().getItem(i)); - } - Collections.shuffle(hotbar); - int i2 = 0; - for(ItemStack item : hotbar) { - player.getInventory().setItem(i2, item); - i2++; - } - player.playSound(player.getLocation(), Sound.ENTITY_ENDER_PEARL_THROW, 1, 0.5f); - } - } - - @EventHandler - public void onIllusionerDamageByPlayer(EntityDamageByEntityEvent event) { - if(!event.getEntity().getType().equals(EntityType.ILLUSIONER)) - return; - - if(!(event.getDamager() instanceof Player)) - return; - - Player player = (Player) event.getDamager(); - - if(NumberUtils.randInt(1, 10) == 1) { - Location loc = player.getLocation().add(NumberUtils.randInt(2,6), 0, NumberUtils.randInt(2,6)); - while(!loc.getBlock().getType().equals(Material.AIR)) { - loc.add(0, 1, 0); - } - player.getWorld().spawnEntity(loc, EntityType.EVOKER); - player.playSound(player.getLocation(), Sound.ENTITY_EVOKER_PREPARE_ATTACK, 1, 2f); - } - - if(NumberUtils.randInt(1, 10) == 1) { - Location loc = player.getLocation().add(NumberUtils.randInt(2,6), 0, NumberUtils.randInt(2,6)); - while(!loc.getBlock().getType().equals(Material.AIR)) { - loc.add(0, 1, 0); - } - player.getWorld().spawnEntity(loc, EntityType.VINDICATOR); - player.playSound(player.getLocation(), Sound.ENTITY_EVOKER_PREPARE_ATTACK, 1, 2f); - } - - ExperienceOrb experienceOrb = (ExperienceOrb) event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), EntityType.EXPERIENCE_ORB); - experienceOrb.setExperience(NumberUtils.randInt(5,20)); - } - - @EventHandler - public void onIllusionerDamage(EntityDamageEvent event) { - if(!event.getEntity().getType().equals(EntityType.ILLUSIONER)) - return; - - if(event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_EXPLOSION) - || event.getCause().equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) { - event.setCancelled(true); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/BlockStructure.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/BlockStructure.java new file mode 100644 index 0000000..cf86fb9 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/illusioner/BlockStructure.java @@ -0,0 +1,33 @@ +package com.willfp.illusioner.illusioner; + +import org.bukkit.Material; + +public class BlockStructure { + private final Material bottom; + private final Material middle; + private final Material top; + + public BlockStructure(Material bottom, Material middle, Material top) { + this.bottom = bottom; + this.middle = middle; + this.top = top; + } + + public Material getBottom() { + return bottom; + } + + public Material getMiddle() { + return middle; + } + + public Material getTop() { + return top; + } + + public static boolean matches(BlockStructure structure) { + return structure.getBottom().equals(IllusionerManager.OPTIONS.getSpawnStructure().getBottom()) + && structure.getMiddle().equals(IllusionerManager.OPTIONS.getSpawnStructure().getMiddle()) + && structure.getTop().equals(IllusionerManager.OPTIONS.getSpawnStructure().getTop()); + } +} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/DeathListeners.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/DeathListeners.java deleted file mode 100644 index 8924385..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/illusioner/DeathListeners.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.willfp.illusioner.illusioner; - -import com.willfp.illusioner.util.NumberUtils; -import org.bukkit.Sound; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.ExperienceOrb; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDeathEvent; - -public class DeathListeners implements Listener { - @EventHandler - public void onIllusionerDeath(EntityDeathEvent event) { - if(!event.getEntityType().equals(EntityType.ILLUSIONER)) - return; - - event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENTITY_EVOKER_PREPARE_WOLOLO, 50, 0.8f); - event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENTITY_ILLUSIONER_PREPARE_BLINDNESS, 50, 1f); - event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENTITY_WITHER_DEATH, 50, 2f); - - ExperienceOrb eo1 = (ExperienceOrb) event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), EntityType.EXPERIENCE_ORB); - eo1.setExperience(NumberUtils.randInt(20000,25000)); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/IllusionerManager.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/IllusionerManager.java new file mode 100644 index 0000000..027d3f9 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/illusioner/IllusionerManager.java @@ -0,0 +1,7 @@ +package com.willfp.illusioner.illusioner; + +import com.willfp.illusioner.illusioner.options.IllusionerOptions; + +public class IllusionerManager { + public static final IllusionerOptions OPTIONS = new IllusionerOptions(); +} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/SpawnListeners.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/SpawnListeners.java deleted file mode 100644 index 459e8cd..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/illusioner/SpawnListeners.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.willfp.illusioner.illusioner; - -import com.willfp.illusioner.IllusionerPlugin; -import com.willfp.illusioner.nms.NMSIllusioner; -import com.willfp.illusioner.nms.api.EntityIllusionerWrapper; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.boss.BarColor; -import org.bukkit.boss.BarStyle; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockPlaceEvent; - -public class SpawnListeners implements Listener { - @EventHandler - public void onSpawn(BlockPlaceEvent event) { - if(!event.getBlock().getType().equals(Material.DRAGON_HEAD)) - return; - if(!event.getBlock().getLocation().add(0,-1,0).getBlock().getType().equals(Material.BEACON)) - return; - if(!event.getBlock().getLocation().add(0,-2,0).getBlock().getType().equals(Material.DIAMOND_BLOCK)) - return; - - try { - event.getBlock().getLocation().getBlock().setType(Material.AIR); - event.getBlock().getLocation().add(0, -1, 0).getBlock().setType(Material.AIR); - event.getBlock().getLocation().add(0, -2, 0).getBlock().setType(Material.AIR); - - event.getBlock().getWorld().playSound(event.getBlock().getLocation(), Sound.ENTITY_ILLUSIONER_MIRROR_MOVE, 1000, 0.5f); - event.getBlock().getWorld().playSound(event.getBlock().getLocation(), Sound.ENTITY_WITHER_SPAWN, 1000, 2f); - - EntityIllusionerWrapper illusioner = NMSIllusioner.spawn(event.getBlock().getLocation(), 600, 50); - illusioner.createBossbar(IllusionerPlugin.getInstance(), BarColor.BLUE, BarStyle.SOLID); - } catch(Exception ignored) {} - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/AttackListeners.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/AttackListeners.java new file mode 100644 index 0000000..88ed8e4 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/AttackListeners.java @@ -0,0 +1,77 @@ +package com.willfp.illusioner.illusioner.listeners; + +import com.willfp.illusioner.illusioner.IllusionerManager; +import com.willfp.illusioner.util.NumberUtils; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class AttackListeners implements Listener { + @EventHandler(ignoreCancelled = true) + public void onIllusionerAttack(EntityDamageByEntityEvent event) { + if(!event.getDamager().getType().equals(EntityType.ILLUSIONER)) + return; + + if(!(event.getEntity() instanceof Player)) + return; + + Player player = (Player) event.getEntity(); + + IllusionerManager.OPTIONS.getGameplayOptions().getEffectOptions().forEach(effectOption -> { + if(NumberUtils.randFloat(0, 100) > effectOption.getChance()) + return; + + player.addPotionEffect(new PotionEffect(effectOption.getEffectType(), effectOption.getDuration(), effectOption.getLevel() - 1)); + }); + + if(IllusionerManager.OPTIONS.getGameplayOptions().isShuffle()) { + if(NumberUtils.randFloat(0, 100) < IllusionerManager.OPTIONS.getGameplayOptions().getShuffleChance()) { + List hotbar = new ArrayList<>(); + for(int i = 0; i<9; i++) { + hotbar.add(player.getInventory().getItem(i)); + } + Collections.shuffle(hotbar); + int i2 = 0; + for(ItemStack item : hotbar) { + player.getInventory().setItem(i2, item); + i2++; + } + player.playSound(player.getLocation(), Sound.ENTITY_ENDER_PEARL_THROW, 1, 0.5f); + } + } + + IllusionerManager.OPTIONS.getGameplayOptions().getSummonerOptions().forEach(summonerOption -> { + if(NumberUtils.randFloat(0, 100) > summonerOption.getChance()) + return; + + Location loc = player.getLocation().add(NumberUtils.randInt(2,6), 0, NumberUtils.randInt(2,6)); + while(!loc.getBlock().getType().equals(Material.AIR)) { + loc.add(0, 1, 0); + } + player.getWorld().spawnEntity(loc, summonerOption.getType()); + }); + } + + @EventHandler(ignoreCancelled = true) + public void onIllusionerDamage(EntityDamageEvent event) { + if(!event.getEntity().getType().equals(EntityType.ILLUSIONER)) + return; + + if(IllusionerManager.OPTIONS.getGameplayOptions().isIgnoreExplosionDamage()) { + if(event.getCause().equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION) || event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_EXPLOSION)) + event.setCancelled(true); + } + } +} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/DeathListeners.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/DeathListeners.java new file mode 100644 index 0000000..8531fa7 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/DeathListeners.java @@ -0,0 +1,28 @@ +package com.willfp.illusioner.illusioner.listeners; + +import com.willfp.illusioner.events.entitydeathbyentity.EntityDeathByEntityEvent; +import com.willfp.illusioner.illusioner.IllusionerManager; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class DeathListeners implements Listener { + @EventHandler + public void onIllusionerDeath(EntityDeathByEntityEvent event) { + if(!event.getDeathEvent().getEntityType().equals(EntityType.ILLUSIONER)) + return; + + IllusionerManager.OPTIONS.getDeathSounds().forEach(optionedSound -> { + if(optionedSound.isBroadcast()) { + event.getKiller().getWorld().playSound(event.getVictim().getLocation(), optionedSound.getSound(), optionedSound.getVolume(), optionedSound.getPitch()); + } else { + if(event.getKiller() instanceof Player) { + ((Player) event.getKiller()).playSound(event.getVictim().getLocation(), optionedSound.getSound(), optionedSound.getVolume(), optionedSound.getPitch()); + } + } + }); + + event.getDeathEvent().setDroppedExp(IllusionerManager.OPTIONS.generateXp()); + } +} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/SpawnListeners.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/SpawnListeners.java new file mode 100644 index 0000000..d71783d --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/illusioner/listeners/SpawnListeners.java @@ -0,0 +1,50 @@ +package com.willfp.illusioner.illusioner.listeners; + +import com.willfp.illusioner.IllusionerPlugin; +import com.willfp.illusioner.illusioner.BlockStructure; +import com.willfp.illusioner.illusioner.IllusionerManager; +import com.willfp.illusioner.nms.NMSIllusioner; +import com.willfp.illusioner.nms.api.EntityIllusionerWrapper; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockPlaceEvent; + +import java.util.HashSet; +import java.util.Set; + +public class SpawnListeners implements Listener { + @EventHandler + public void onSpawn(BlockPlaceEvent event) { + boolean matches = false; + Set match = new HashSet<>(); + for(int i = 0; i < 3; i++) { + Block block1 = event.getBlock().getRelative(0, i, 0); + Block block2 = event.getBlock().getRelative(0, -1 + i, 0); + Block block3 = event.getBlock().getRelative(0, -2 + i, 0); + matches = BlockStructure.matches(new BlockStructure(block1.getType(), block2.getType(), block3.getType())); + if(matches) { + match.add(block1); + match.add(block2); + match.add(block3); + break; + } + } + + if(!matches) + return; + + match.forEach(block -> block.setType(Material.AIR)); + IllusionerManager.OPTIONS.getSpawnSounds().forEach(optionedSound -> { + if(optionedSound.isBroadcast()) { + event.getBlock().getWorld().playSound(event.getBlock().getLocation(), optionedSound.getSound(), optionedSound.getVolume(), optionedSound.getPitch()); + } else { + event.getPlayer().playSound(event.getBlock().getLocation(), optionedSound.getSound(), optionedSound.getVolume(), optionedSound.getPitch()); + } + }); + + EntityIllusionerWrapper illusioner = NMSIllusioner.spawn(event.getBlock().getLocation(), IllusionerManager.OPTIONS.getMaxHealth(), IllusionerManager.OPTIONS.getAttackDamage(), IllusionerManager.OPTIONS.getName()); + illusioner.createBossbar(IllusionerPlugin.getInstance(), IllusionerManager.OPTIONS.getColor(), IllusionerManager.OPTIONS.getStyle()); + } +} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/options/GameplayOptions.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/options/GameplayOptions.java new file mode 100644 index 0000000..40d4128 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/illusioner/options/GameplayOptions.java @@ -0,0 +1,96 @@ +package com.willfp.illusioner.illusioner.options; + +import com.willfp.illusioner.util.internal.OptionedSound; +import org.bukkit.entity.EntityType; +import org.bukkit.potion.PotionEffectType; + +import java.util.HashSet; +import java.util.Set; + +public class GameplayOptions { + private OptionedSound hitSound; + + private final Set effectOptions = new HashSet<>(); + private final Set summonerOptions = new HashSet<>(); + + private boolean shuffle; + private double shuffleChance; + + private boolean ignoreExplosionDamage; + + public void reload() { + + } + + public OptionedSound getHitSound() { + return hitSound; + } + + public Set getEffectOptions() { + return effectOptions; + } + + public Set getSummonerOptions() { + return summonerOptions; + } + + public double getShuffleChance() { + return shuffleChance; + } + + public boolean isShuffle() { + return shuffle; + } + + public boolean isIgnoreExplosionDamage() { + return ignoreExplosionDamage; + } + + public static class EffectOption { + private final double chance; + private final int level; + private final PotionEffectType effectType; + private final int duration; + + public EffectOption(double chance, int level, int duration, PotionEffectType effectType) { + this.chance = chance; + this.level = level; + this.effectType = effectType; + this.duration = duration; + } + + public double getChance() { + return chance; + } + + public int getLevel() { + return level; + } + + public PotionEffectType getEffectType() { + return effectType; + } + + public int getDuration() { + return duration; + } + } + + public static class SummonerOption { + private final double chance; + private final EntityType type; + + public SummonerOption(double chance, EntityType type) { + this.chance = chance; + this.type = type; + } + + public double getChance() { + return chance; + } + + public EntityType getType() { + return type; + } + } +} diff --git a/Plugin/src/main/java/com/willfp/illusioner/illusioner/options/IllusionerOptions.java b/Plugin/src/main/java/com/willfp/illusioner/illusioner/options/IllusionerOptions.java new file mode 100644 index 0000000..71a0f2c --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/illusioner/options/IllusionerOptions.java @@ -0,0 +1,79 @@ +package com.willfp.illusioner.illusioner.options; + +import com.willfp.illusioner.illusioner.BlockStructure; +import com.willfp.illusioner.util.NumberUtils; +import com.willfp.illusioner.util.internal.OptionedSound; +import com.willfp.illusioner.util.tuplets.Pair; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BarStyle; +import org.bukkit.inventory.ItemStack; + +import java.util.Set; + +public class IllusionerOptions { + private BarColor color; + private BarStyle style; + private String name; + private Set spawnSounds; + private Set deathSounds; + private Pair xpBounds; + private BlockStructure spawnStructure; + private double maxHealth; + private double attackDamage; + private Set drops; + private GameplayOptions gameplayOptions; + + public IllusionerOptions() { + reload(); + } + + public void reload() { + + + gameplayOptions.reload(); + } + + public BarColor getColor() { + return color; + } + + public BarStyle getStyle() { + return style; + } + + public String getName() { + return name; + } + + public Set getSpawnSounds() { + return spawnSounds; + } + + public Set getDeathSounds() { + return deathSounds; + } + + public int generateXp() { + return NumberUtils.randInt(xpBounds.getFirst(), xpBounds.getSecond()); + } + + public BlockStructure getSpawnStructure() { + return spawnStructure; + } + + public double getMaxHealth() { + return maxHealth; + } + + public double getAttackDamage() { + return attackDamage; + } + + public Set getDrops() { + return drops; + } + + public GameplayOptions getGameplayOptions() { + return gameplayOptions; + } +} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/AnticheatManager.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/AnticheatManager.java deleted file mode 100644 index 92a6dbd..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/AnticheatManager.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.willfp.illusioner.integrations.anticheat; - -import com.willfp.illusioner.IllusionerPlugin; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.Listener; - -import java.util.HashSet; -import java.util.Set; - -/** - * Utility class for Anticheat Integrations - */ -public class AnticheatManager { - private static final Set anticheats = new HashSet<>(); - - /** - * Register a new anticheat - * - * @param anticheat The anticheat to register - */ - public static void register(AnticheatWrapper anticheat) { - if (anticheat instanceof Listener) { - Bukkit.getPluginManager().registerEvents((Listener) anticheat, IllusionerPlugin.getInstance()); - } - anticheats.add(anticheat); - } - - /** - * Exempt a player from triggering anticheats - * - * @param player The player to exempt - */ - public static void exemptPlayer(Player player) { - anticheats.forEach(anticheat -> anticheat.exempt(player)); - } - - /** - * Unexempt a player from triggering anticheats - * This is ran a tick after it is called to ensure that there are no event timing conflicts - * - * @param player The player to remove the exemption - */ - public static void unexemptPlayer(Player player) { - Bukkit.getScheduler().runTaskLater(IllusionerPlugin.getInstance(), () -> { - anticheats.forEach(anticheat -> anticheat.unexempt(player)); - }, 1); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/AnticheatWrapper.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/AnticheatWrapper.java deleted file mode 100644 index 4c4b0df..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/AnticheatWrapper.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.willfp.illusioner.integrations.anticheat; - -import com.willfp.illusioner.integrations.Integration; -import org.bukkit.entity.Player; - -/** - * Interface for anticheat integrations - */ -public interface AnticheatWrapper extends Integration { - /** - * Exempt a player from checks - * - * @param player The player to exempt - */ - void exempt(Player player); - - /** - * Unexempt a player from checks - * - * @param player The player to unexempt - */ - void unexempt(Player player); -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatAAC.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatAAC.java deleted file mode 100644 index a78ccc3..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatAAC.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.illusioner.integrations.anticheat.plugins; - -import com.willfp.illusioner.integrations.anticheat.AnticheatWrapper; -import me.konsolas.aac.api.PlayerViolationEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class AnticheatAAC implements AnticheatWrapper, Listener { - private final Set exempt = new HashSet<>(); - - @Override - public String getPluginName() { - return "AAC"; - } - - @Override - public void exempt(Player player) { - this.exempt.add(player.getUniqueId()); - } - - @Override - public void unexempt(Player player) { - this.exempt.remove(player.getUniqueId()); - } - - @EventHandler(priority = EventPriority.LOWEST) - private void onViolate(PlayerViolationEvent event) { - if (!exempt.contains(event.getPlayer().getUniqueId())) { - return; - } - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatMatrix.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatMatrix.java deleted file mode 100644 index 48e8aa4..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatMatrix.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.illusioner.integrations.anticheat.plugins; - -import com.willfp.illusioner.integrations.anticheat.AnticheatWrapper; -import me.rerere.matrix.api.events.PlayerViolationEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class AnticheatMatrix implements AnticheatWrapper, Listener { - private final Set exempt = new HashSet<>(); - - @Override - public String getPluginName() { - return "Matrix"; - } - - @Override - public void exempt(Player player) { - this.exempt.add(player.getUniqueId()); - } - - @Override - public void unexempt(Player player) { - this.exempt.remove(player.getUniqueId()); - } - - @EventHandler(priority = EventPriority.LOWEST) - private void onViolate(PlayerViolationEvent event) { - if (!exempt.contains(event.getPlayer().getUniqueId())) { - return; - } - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatNCP.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatNCP.java deleted file mode 100644 index e94a996..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatNCP.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.willfp.illusioner.integrations.anticheat.plugins; - -import com.willfp.illusioner.integrations.anticheat.AnticheatWrapper; -import fr.neatmonster.nocheatplus.checks.CheckType; -import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; -import org.bukkit.entity.Player; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class AnticheatNCP implements AnticheatWrapper { - private final Set exempt = new HashSet<>(); - - @Override - public String getPluginName() { - return "NCP"; - } - - @Override - public void exempt(Player player) { - if (!NCPExemptionManager.isExempted(player, CheckType.ALL)) { - return; - } - - if (exempt.add(player.getUniqueId())) { - NCPExemptionManager.exemptPermanently(player, CheckType.ALL); - } - } - - @Override - public void unexempt(Player player) { - if (exempt.remove(player.getUniqueId())) { - NCPExemptionManager.unexempt(player, CheckType.ALL); - } - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatSpartan.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatSpartan.java deleted file mode 100644 index 456eedf..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anticheat/plugins/AnticheatSpartan.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.willfp.illusioner.integrations.anticheat.plugins; - -import com.willfp.illusioner.integrations.anticheat.AnticheatWrapper; -import me.vagdedes.spartan.api.PlayerViolationEvent; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -public class AnticheatSpartan implements AnticheatWrapper, Listener { - private final Set exempt = new HashSet<>(); - - @Override - public String getPluginName() { - return "Spartan"; - } - - @Override - public void exempt(Player player) { - this.exempt.add(player.getUniqueId()); - } - - @Override - public void unexempt(Player player) { - this.exempt.remove(player.getUniqueId()); - } - - @EventHandler(priority = EventPriority.LOWEST) - private void onViolate(PlayerViolationEvent event) { - if (!exempt.contains(event.getPlayer().getUniqueId())) { - return; - } - - event.setCancelled(true); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/AntigriefManager.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/AntigriefManager.java deleted file mode 100644 index a7c32f6..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/AntigriefManager.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.willfp.illusioner.integrations.antigrief; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -import java.util.HashSet; -import java.util.Set; - -public class AntigriefManager { - private static final Set antigriefs = new HashSet<>(); - - /** - * Register a new AntiGrief/Land Management integration - * - * @param antigrief The integration to register - */ - public static void register(AntigriefWrapper antigrief) { - antigriefs.add(antigrief); - } - - /** - * Can player break block - * - * @param player The player - * @param block The block - * @return If player can break block - */ - public static boolean canBreakBlock(Player player, Block block) { - return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canBreakBlock(player, block)); - } - - /** - * Can player create explosion at location - * - * @param player The player - * @param location The location - * @return If player can create explosion - */ - public static boolean canCreateExplosion(Player player, Location location) { - return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canCreateExplosion(player, location)); - } - - /** - * Can player place block - * - * @param player The player - * @param block The block - * @return If player can place block - */ - public static boolean canPlaceBlock(Player player, Block block) { - return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canPlaceBlock(player, block)); - } - - /** - * Can player injure living entity - * - * @param player The player - * @param victim The victim - * @return If player can injure - */ - public static boolean canInjure(Player player, LivingEntity victim) { - return antigriefs.stream().allMatch(antigriefWrapper -> antigriefWrapper.canInjure(player, victim)); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/AntigriefWrapper.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/AntigriefWrapper.java deleted file mode 100644 index b9f9b92..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/AntigriefWrapper.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.illusioner.integrations.antigrief; - -import com.willfp.illusioner.integrations.Integration; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -/** - * Interface for Antigrief integrations - */ -public interface AntigriefWrapper extends Integration { - /** - * Can player break block - * - * @param player The player - * @param block The block - * @return If player cna break block - */ - boolean canBreakBlock(Player player, Block block); - - /** - * Can player create explosion at location - * - * @param player The player - * @param location The location - * @return If player can create explosion - */ - boolean canCreateExplosion(Player player, Location location); - - /** - * Can player place block - * - * @param player The player - * @param block The block - * @return If player can place block - */ - boolean canPlaceBlock(Player player, Block block); - - /** - * Can player injure living entity - * - * @param player The player - * @param victim The victim - * @return If player can injure - */ - boolean canInjure(Player player, LivingEntity victim); -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefFactionsUUID.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefFactionsUUID.java deleted file mode 100644 index 8b2e1f2..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefFactionsUUID.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.willfp.illusioner.integrations.antigrief.plugins; - -import com.massivecraft.factions.Board; -import com.massivecraft.factions.FLocation; -import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayers; -import com.massivecraft.factions.Faction; -import com.massivecraft.factions.perms.PermissibleAction; -import com.willfp.illusioner.integrations.antigrief.AntigriefWrapper; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefFactionsUUID implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - FLocation flocation = new FLocation(block.getLocation()); - Faction faction = Board.getInstance().getFactionAt(flocation); - - if (!faction.hasAccess(fplayer, PermissibleAction.DESTROY)) { - return fplayer.isAdminBypassing(); - } - return true; - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - FLocation flocation = new FLocation(location); - Faction faction = Board.getInstance().getFactionAt(flocation); - - return !faction.noExplosionsInTerritory(); - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - FLocation flocation = new FLocation(block.getLocation()); - Faction faction = Board.getInstance().getFactionAt(flocation); - - if (!faction.hasAccess(fplayer, PermissibleAction.BUILD)) { - return fplayer.isAdminBypassing(); - } - return true; - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - FPlayer fplayer = FPlayers.getInstance().getByPlayer(player); - FLocation flocation = new FLocation(victim.getLocation()); - Faction faction = Board.getInstance().getFactionAt(flocation); - - if(victim instanceof Player) { - if (faction.isPeaceful()) { - return fplayer.isAdminBypassing(); - } - } else { - if (faction.hasAccess(fplayer, PermissibleAction.DESTROY)) { - return fplayer.isAdminBypassing(); - } - } - return true; - } - - @Override - public String getPluginName() { - return "FactionsUUID"; - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefGriefPrevention.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefGriefPrevention.java deleted file mode 100644 index 21d8d0a..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefGriefPrevention.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.willfp.illusioner.integrations.antigrief.plugins; - -import com.willfp.illusioner.integrations.antigrief.AntigriefWrapper; -import me.ryanhamshire.GriefPrevention.Claim; -import me.ryanhamshire.GriefPrevention.GriefPrevention; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefGriefPrevention implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - Claim claim = GriefPrevention.instance.dataStore.getClaimAt(block.getLocation(), false, null); - if (claim != null) { - return claim.allowBreak(player, block.getType()) == null; - } - return true; - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null); - if (claim != null) { - return claim.areExplosivesAllowed; - } - return true; - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - Claim claim = GriefPrevention.instance.dataStore.getClaimAt(block.getLocation(), false, null); - if (claim != null) { - return claim.allowBuild(player, block.getType()) == null; - } - return true; - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - Claim claim = GriefPrevention.instance.dataStore.getClaimAt(victim.getLocation(), false, null); - if(victim instanceof Player) { - return claim == null; - } else { - if (claim != null && claim.ownerID != null) { - return claim.ownerID.equals(player.getUniqueId()); - } - return true; - } - } - - @Override - public String getPluginName() { - return "GriefPrevention"; - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefKingdoms.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefKingdoms.java deleted file mode 100644 index e00c379..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefKingdoms.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.willfp.illusioner.integrations.antigrief.plugins; - -import com.willfp.illusioner.integrations.antigrief.AntigriefWrapper; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockBreakEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.inventory.EquipmentSlot; -import org.kingdoms.constants.kingdom.Kingdom; -import org.kingdoms.constants.land.Land; -import org.kingdoms.managers.PvPManager; -import org.kingdoms.managers.land.LandManager; - -public class AntigriefKingdoms implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - BlockBreakEvent event = new BlockBreakEvent(block, player); - LandManager.onBreak(event); - return !event.isCancelled(); - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - Land land = Land.getLand(location); - if (land == null) return true; - if(!land.isClaimed()) return true; - - Kingdom kingdom = land.getKingdom(); - return kingdom.isMember(player); - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - Block placedOn = block.getRelative(0, -1, 0); - BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), placedOn, player.getInventory().getItemInMainHand(), player, true, EquipmentSlot.HAND); - LandManager.onPlace(event); - return !event.isCancelled(); - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - if(victim instanceof Player) { - return PvPManager.canFight(player, (Player) victim); - } else { - Land land = Land.getLand(victim.getLocation()); - if (land == null) return true; - if(!land.isClaimed()) return true; - - Kingdom kingdom = land.getKingdom(); - return kingdom.isMember(player); - } - } - - @Override - public String getPluginName() { - return "Kingdoms"; - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefLands.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefLands.java deleted file mode 100644 index 0259e24..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefLands.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.willfp.illusioner.integrations.antigrief.plugins; - -import com.willfp.illusioner.IllusionerPlugin; -import com.willfp.illusioner.integrations.antigrief.AntigriefWrapper; -import me.angeschossen.lands.api.integration.LandsIntegration; -import me.angeschossen.lands.api.land.Area; -import me.angeschossen.lands.api.role.enums.RoleSetting; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefLands implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - LandsIntegration landsIntegration = new LandsIntegration(IllusionerPlugin.getInstance()); - Area area = landsIntegration.getAreaByLoc(block.getLocation()); - if (area != null) { - return area.canSetting(player, RoleSetting.BLOCK_BREAK, false); - } - return true; - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - LandsIntegration landsIntegration = new LandsIntegration(IllusionerPlugin.getInstance()); - Area area = landsIntegration.getAreaByLoc(location); - if (area != null) { - return area.canSetting(player, RoleSetting.BLOCK_IGNITE, false); - } - return true; - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - LandsIntegration landsIntegration = new LandsIntegration(IllusionerPlugin.getInstance()); - Area area = landsIntegration.getAreaByLoc(block.getLocation()); - if (area != null) { - return area.canSetting(player, RoleSetting.BLOCK_PLACE, false); - } - return true; - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - LandsIntegration landsIntegration = new LandsIntegration(IllusionerPlugin.getInstance()); - Area area = landsIntegration.getAreaByLoc(victim.getLocation()); - if(victim instanceof Player) { - if (area != null) { - return area.canSetting(player, RoleSetting.ATTACK_PLAYER, false); - } - } else { - if (area != null) { - return area.canSetting(player, RoleSetting.ATTACK_ANIMAL, false); - } - } - return true; - } - - @Override - public String getPluginName() { - return "Lands"; - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefTowny.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefTowny.java deleted file mode 100644 index ce66567..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefTowny.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.willfp.illusioner.integrations.antigrief.plugins; - -import com.palmergames.bukkit.towny.object.Town; -import com.palmergames.bukkit.towny.object.TownyPermission; -import com.palmergames.bukkit.towny.object.WorldCoord; -import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; -import com.willfp.illusioner.integrations.antigrief.AntigriefWrapper; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefTowny implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.DESTROY); - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - return PlayerCacheUtil.getCachePermission(player, location, Material.TNT, TownyPermission.ActionType.ITEM_USE); - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - return PlayerCacheUtil.getCachePermission(player, block.getLocation(), block.getType(), TownyPermission.ActionType.BUILD); - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - if(victim instanceof Player) { - try { - Town town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown(); - return town.isPVP(); - } catch (Exception ignored) {} - } else { - try { - Town town = WorldCoord.parseWorldCoord(victim.getLocation()).getTownBlock().getTown(); - return town.hasMobs(); - } catch (Exception ignored) {} - } - return true; - } - - @Override - public String getPluginName() { - return "Towny"; - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefWorldGuard.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefWorldGuard.java deleted file mode 100644 index 73ca351..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/antigrief/plugins/AntigriefWorldGuard.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.willfp.illusioner.integrations.antigrief.plugins; - -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldguard.LocalPlayer; -import com.sk89q.worldguard.WorldGuard; -import com.sk89q.worldguard.bukkit.WorldGuardPlugin; -import com.sk89q.worldguard.protection.flags.Flags; -import com.sk89q.worldguard.protection.regions.RegionContainer; -import com.sk89q.worldguard.protection.regions.RegionQuery; -import com.willfp.illusioner.integrations.antigrief.AntigriefWrapper; -import org.apache.commons.lang.Validate; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Block; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; - -public class AntigriefWorldGuard implements AntigriefWrapper { - @Override - public boolean canBreakBlock(Player player, Block block) { - LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionQuery query = container.createQuery(); - - if (!query.testState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BUILD)) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld())); - } - return true; - } - - @Override - public boolean canCreateExplosion(Player player, Location location) { - LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionQuery query = container.createQuery(); - World world = location.getWorld(); - Validate.notNull(world, "World cannot be null!"); - - if (!query.testState(BukkitAdapter.adapt(location), localPlayer, Flags.OTHER_EXPLOSION)) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(world)); - } - return true; - } - - @Override - public boolean canPlaceBlock(Player player, Block block) { - LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionQuery query = container.createQuery(); - - if (!query.testState(BukkitAdapter.adapt(block.getLocation()), localPlayer, Flags.BLOCK_PLACE)) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(block.getWorld())); - } - return true; - } - - @Override - public boolean canInjure(Player player, LivingEntity victim) { - LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player); - RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer(); - RegionQuery query = container.createQuery(); - - if(victim instanceof Player) { - if (!query.testState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.PVP)) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld())); - } - } else { - if (!query.testState(BukkitAdapter.adapt(victim.getLocation()), localPlayer, Flags.DAMAGE_ANIMALS)) { - return WorldGuard.getInstance().getPlatform().getSessionManager().hasBypass(localPlayer, BukkitAdapter.adapt(player.getWorld())); - } - } - return true; - } - - @Override - public String getPluginName() { - return "WorldGuard"; - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/AnvilGUIIntegration.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/AnvilGUIIntegration.java deleted file mode 100644 index 077c41c..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/AnvilGUIIntegration.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.willfp.illusioner.integrations.anvilgui; - -import com.willfp.illusioner.integrations.Integration; - -/** - * Interface for AnvilGUI integrations - */ -public interface AnvilGUIIntegration extends Integration { - /** - * Get if the NMS inventory is an instance of an AnvilGUI - * - * @param object The NMS inventory to check - * @return If the object is an AnvilGUI - * @see com.willfp.illusioner.nms.OpenInventory - */ - boolean isInstance(Object object); -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/AnvilGUIManager.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/AnvilGUIManager.java deleted file mode 100644 index 9af7046..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/AnvilGUIManager.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.willfp.illusioner.integrations.anvilgui; - -import com.willfp.illusioner.nms.OpenInventory; -import org.bukkit.entity.Player; - -import java.util.HashSet; -import java.util.Set; - -/** - * Utility class for interfacing with plugins that use WesJD's AnvilGUI library - */ -public class AnvilGUIManager { - private static final Set integrations = new HashSet<>(); - - /** - * Register a new AnvilGUI integration - * - * @param integration The integration to register - */ - public static void registerIntegration(AnvilGUIIntegration integration) { - integrations.add(integration); - } - - /** - * Get if a player's open inventory is an AnvilGUI - * - * @param player The player to check - * @return If the player's open inventory is an AnvilGUI - */ - public static boolean hasAnvilGUIOpen(Player player) { - if (integrations.isEmpty()) - return false; - return integrations.stream().anyMatch(integration -> integration.isInstance(OpenInventory.getOpenInventory(player))); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/plugins/AnvilGUIImpl.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/plugins/AnvilGUIImpl.java deleted file mode 100644 index 3922a9a..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/anvilgui/plugins/AnvilGUIImpl.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.willfp.illusioner.integrations.anvilgui.plugins; - -import com.willfp.illusioner.IllusionerPlugin; -import com.willfp.illusioner.integrations.anvilgui.AnvilGUIIntegration; - -/** - * Concrete implementation of {@link AnvilGUIIntegration} - */ -public class AnvilGUIImpl implements AnvilGUIIntegration { - private static final String ANVIL_GUI_CLASS = "net.wesjd.anvilgui.version.Wrapper" + IllusionerPlugin.NMS_VERSION.substring(1) + "$AnvilContainer"; - - @Override - public boolean isInstance(Object object) { - return object.getClass().toString().equals(ANVIL_GUI_CLASS); - } - - @Override - public String getPluginName() { - return "AnvilGUI"; - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/drops/Drops.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/drops/Drops.java new file mode 100644 index 0000000..0a32649 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/integrations/drops/Drops.java @@ -0,0 +1,12 @@ +package com.willfp.illusioner.integrations.drops; + +import org.bukkit.Bukkit; +import org.bukkit.inventory.ItemStack; + +public class Drops { + public static boolean drop(ItemStack itemStack) { + if(Bukkit.getPluginManager().isPluginEnabled("EcoEnchants")) { + + } + } +} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/McmmoIntegration.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/McmmoIntegration.java deleted file mode 100644 index 3144712..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/McmmoIntegration.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.willfp.illusioner.integrations.mcmmo; - -import com.willfp.illusioner.integrations.Integration; -import org.bukkit.event.Event; - -/** - * Interface for mcMMO integrations - */ -public interface McmmoIntegration extends Integration { - /** - * @see McmmoManager#isFake(Event) - */ - boolean isFake(Event event); -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/McmmoManager.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/McmmoManager.java deleted file mode 100644 index a4d64ab..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/McmmoManager.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.willfp.illusioner.integrations.mcmmo; - -import com.willfp.illusioner.util.ClassUtils; -import org.bukkit.event.Event; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * Utility class for interfacing with mcMMO - */ -public class McmmoManager { - private static final Set integrations = new HashSet<>(); - - /** - * Register a new mcMMO integration - * - * @param integration The integration to register - */ - public static void registerIntegration(McmmoIntegration integration) { - if(!ClassUtils.exists("com.gmail.nossr50.events.fake.FakeEvent")) - return; - integrations.add(integration); - } - - /** - * Get if an event is fake - * - * @param event The event to check - * @return If the event is fake - */ - public static boolean isFake(Event event) { - AtomicBoolean isFake = new AtomicBoolean(false); - integrations.forEach(integration -> { - if (integration.isFake(event)) isFake.set(true); - }); - - return isFake.get(); - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/plugins/McmmoIntegrationImpl.java b/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/plugins/McmmoIntegrationImpl.java deleted file mode 100644 index c04f2db..0000000 --- a/Plugin/src/main/java/com/willfp/illusioner/integrations/mcmmo/plugins/McmmoIntegrationImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.willfp.illusioner.integrations.mcmmo.plugins; - -import com.gmail.nossr50.events.fake.FakeEvent; -import com.willfp.illusioner.integrations.mcmmo.McmmoIntegration; -import org.bukkit.event.Event; - -/** - * Concrete implementation of {@link McmmoIntegration} - */ -public class McmmoIntegrationImpl implements McmmoIntegration { - @Override - public boolean isFake(Event event) { - return event instanceof FakeEvent; - } - - @Override - public String getPluginName() { - return "mcMMO"; - } -} diff --git a/Plugin/src/main/java/com/willfp/illusioner/nms/NMSIllusioner.java b/Plugin/src/main/java/com/willfp/illusioner/nms/NMSIllusioner.java index 1475d7f..fb81cfd 100644 --- a/Plugin/src/main/java/com/willfp/illusioner/nms/NMSIllusioner.java +++ b/Plugin/src/main/java/com/willfp/illusioner/nms/NMSIllusioner.java @@ -32,10 +32,11 @@ public class NMSIllusioner { * @param location The location to spawn it at * @param maxHealth The max health for the illusioner to have * @param attackDamage The attack damage for the illusioner + * @param name The name of the illusioner * @return The illusioner */ - public static EntityIllusionerWrapper spawn(Location location, double maxHealth, double attackDamage) { + public static EntityIllusionerWrapper spawn(Location location, double maxHealth, double attackDamage, String name) { assert illusionerWrapper != null; - return illusionerWrapper.spawn(location, maxHealth, attackDamage); + return illusionerWrapper.spawn(location, maxHealth, attackDamage, name); } } diff --git a/Plugin/src/main/java/com/willfp/illusioner/util/internal/Loader.java b/Plugin/src/main/java/com/willfp/illusioner/util/internal/Loader.java index 7ab1ae4..d90f8e7 100644 --- a/Plugin/src/main/java/com/willfp/illusioner/util/internal/Loader.java +++ b/Plugin/src/main/java/com/willfp/illusioner/util/internal/Loader.java @@ -8,25 +8,9 @@ import com.willfp.illusioner.events.armorequip.ArmorListener; import com.willfp.illusioner.events.armorequip.DispenserArmorListener; import com.willfp.illusioner.events.entitydeathbyentity.EntityDeathByEntityListeners; import com.willfp.illusioner.events.naturalexpgainevent.NaturalExpGainListeners; -import com.willfp.illusioner.illusioner.AttackListeners; -import com.willfp.illusioner.illusioner.DeathListeners; -import com.willfp.illusioner.illusioner.SpawnListeners; -import com.willfp.illusioner.integrations.anticheat.AnticheatManager; -import com.willfp.illusioner.integrations.anticheat.plugins.AnticheatAAC; -import com.willfp.illusioner.integrations.anticheat.plugins.AnticheatMatrix; -import com.willfp.illusioner.integrations.anticheat.plugins.AnticheatNCP; -import com.willfp.illusioner.integrations.anticheat.plugins.AnticheatSpartan; -import com.willfp.illusioner.integrations.antigrief.AntigriefManager; -import com.willfp.illusioner.integrations.antigrief.plugins.AntigriefFactionsUUID; -import com.willfp.illusioner.integrations.antigrief.plugins.AntigriefGriefPrevention; -import com.willfp.illusioner.integrations.antigrief.plugins.AntigriefKingdoms; -import com.willfp.illusioner.integrations.antigrief.plugins.AntigriefLands; -import com.willfp.illusioner.integrations.antigrief.plugins.AntigriefTowny; -import com.willfp.illusioner.integrations.antigrief.plugins.AntigriefWorldGuard; -import com.willfp.illusioner.integrations.anvilgui.AnvilGUIManager; -import com.willfp.illusioner.integrations.anvilgui.plugins.AnvilGUIImpl; -import com.willfp.illusioner.integrations.mcmmo.McmmoManager; -import com.willfp.illusioner.integrations.mcmmo.plugins.McmmoIntegrationImpl; +import com.willfp.illusioner.illusioner.listeners.AttackListeners; +import com.willfp.illusioner.illusioner.listeners.DeathListeners; +import com.willfp.illusioner.illusioner.listeners.SpawnListeners; import com.willfp.illusioner.integrations.placeholder.PlaceholderManager; import com.willfp.illusioner.integrations.placeholder.plugins.PlaceholderIntegrationPAPI; import com.willfp.illusioner.nms.BlockBreak; @@ -142,23 +126,8 @@ public class Loader { Logger.info("Loading Integrations..."); final HashMap integrations = new HashMap() {{ - // AntiGrief - put("WorldGuard", () -> AntigriefManager.register(new AntigriefWorldGuard())); - put("GriefPrevention", () -> AntigriefManager.register(new AntigriefGriefPrevention())); - put("FactionsUUID", () -> AntigriefManager.register(new AntigriefFactionsUUID())); - put("Towny", () -> AntigriefManager.register(new AntigriefTowny())); - put("Lands", () -> AntigriefManager.register(new AntigriefLands())); - put("Kingdoms", () -> AntigriefManager.register(new AntigriefKingdoms())); - - // AntiCheat - put("AAC", () -> AnticheatManager.register(new AnticheatAAC())); - put("Matrix", () -> AnticheatManager.register(new AnticheatMatrix())); - put("NoCheatPlus", () -> AnticheatManager.register(new AnticheatNCP())); - put("Spartan", () -> AnticheatManager.register(new AnticheatSpartan())); - // MISC put("PlaceholderAPI", () -> PlaceholderManager.addIntegration(new PlaceholderIntegrationPAPI())); - put("mcMMO", () -> McmmoManager.registerIntegration(new McmmoIntegrationImpl())); }}; Set enabledPlugins = Arrays.stream(Bukkit.getPluginManager().getPlugins()).map(Plugin::getName).collect(Collectors.toSet()); @@ -176,7 +145,6 @@ public class Loader { })); Prerequisite.update(); - AnvilGUIManager.registerIntegration(new AnvilGUIImpl()); // No direct lib, can always register Logger.info(""); diff --git a/Plugin/src/main/java/com/willfp/illusioner/util/internal/OptionedSound.java b/Plugin/src/main/java/com/willfp/illusioner/util/internal/OptionedSound.java new file mode 100644 index 0000000..b907813 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/illusioner/util/internal/OptionedSound.java @@ -0,0 +1,33 @@ +package com.willfp.illusioner.util.internal; + +import org.bukkit.Sound; + +public class OptionedSound { + private final Sound sound; + private final float volume; + private final float pitch; + private final boolean broadcast; + + public OptionedSound(Sound sound, float volume, float pitch, boolean broadcast) { + this.sound = sound; + this.volume = volume; + this.pitch = pitch; + this.broadcast = broadcast; + } + + public Sound getSound() { + return sound; + } + + public float getVolume() { + return volume; + } + + public float getPitch() { + return pitch; + } + + public boolean isBroadcast() { + return broadcast; + } +} diff --git a/Plugin/src/main/resources/plugin.yml b/Plugin/src/main/resources/plugin.yml index 949591d..86b9e13 100644 --- a/Plugin/src/main/resources/plugin.yml +++ b/Plugin/src/main/resources/plugin.yml @@ -6,18 +6,7 @@ authors: [Auxilor] website: willfp.com load: STARTUP softdepend: - - WorldGuard - - GriefPrevention - - Towny - - FactionsUUID - - Lands - - Kingdoms - - NoCheatPlus - - AAC - - Matrix - - Spartan - PlaceholderAPI - - mcMMO commands: ilreload: diff --git a/lib/SpartanAPI.jar b/lib/SpartanAPI.jar deleted file mode 100644 index 1f2d578..0000000 Binary files a/lib/SpartanAPI.jar and /dev/null differ