9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-19 15:09:17 +00:00

Compare commits

..

51 Commits
5.0.0 ... 6.0.0

Author SHA1 Message Date
Auxilor
746ab5d2b5 jitpack.yml 2021-07-21 19:09:49 +01:00
Auxilor
3f6f13a61f Updated to eco 6 2021-07-21 18:49:15 +01:00
Auxilor
fd82811d2c Updated to eco 6 2021-07-21 18:29:15 +01:00
Auxilor
950bfab5f3 Updated to eco 6 2021-07-21 18:28:42 +01:00
Auxilor
3e4d3af215 Updated to eco 6 2021-07-21 18:28:17 +01:00
Auxilor
9486903895 Updated to 5.3.0 2021-07-20 15:27:57 +01:00
Auxilor
da7ee14787 Removed legacy code 2021-07-20 15:25:49 +01:00
Auxilor
36fa2e5138 Removed UUID tracking 2021-07-20 15:22:53 +01:00
Auxilor
31e3cb993e Removed 10tick delay on timer 2021-07-20 14:43:01 +01:00
Auxilor
c7ea383115 Updated to 5.2.1 2021-07-15 23:31:12 +02:00
Auxilor
1d800a52de Fixed /ecobosses only being able to be ran as a player 2021-07-15 23:31:04 +02:00
Auxilor
1a78db6b07 Fixed permissions 2021-07-12 14:00:57 +02:00
Auxilor
9ab765edb6 Fixed type paramets 2021-07-12 13:57:34 +02:00
Auxilor
c8054c209a Updated to new eco command system and 5.2.0 2021-07-12 13:57:07 +02:00
Auxilor
8db8cca1c9 Updated to 5.1.4 2021-07-09 22:38:32 +02:00
Auxilor
413d86c2d3 Updated to eco 5.7.1x 2021-07-09 22:38:24 +02:00
Auxilor
a335b5b52e Fixed %player% bug 2021-07-09 22:37:28 +02:00
Auxilor
d5dced49b3 Updated to 5.1.3 2021-06-30 19:43:05 +01:00
Auxilor
4ac870f5c3 Chunks with bosses in them should not unload 2021-06-30 19:42:31 +01:00
Auxilor
1a364615a3 Updated to 5.1.2 2021-06-29 18:29:18 +01:00
Auxilor
890b034d4a Bosses should now load the chunk they're in on autospawn 2021-06-29 18:29:08 +01:00
Auxilor
22f59c7c5c Fixed record migration 2021-06-24 08:58:24 +01:00
Auxilor
8bc296f2f8 Updated to 5.1.1 2021-06-24 08:57:19 +01:00
Auxilor
5fe7eb1318 Java 16 migration, more null checks, record conversion 2021-06-24 08:57:11 +01:00
Auxilor
36a3c7f70d Updated to 5.1.0 2021-06-11 12:29:46 +01:00
Auxilor
6b3ff0c88d Updated to 1.17 and Java 16 2021-06-11 12:29:35 +01:00
Auxilor
3e384dbeea Updated to 5.0.7 2021-06-10 11:05:18 +01:00
Auxilor
b16444799a Updated to 5.0.8 2021-06-10 11:04:41 +01:00
Auxilor
98faf823ba Fixed 2 NPE errors 2021-06-10 11:04:28 +01:00
Auxilor
87095166d0 Updated to 5.0.7 2021-05-20 11:40:40 +01:00
Auxilor
b4510233aa Fixed potential NPE 2021-05-20 11:40:08 +01:00
Auxilor
a31b0210ab Updated to use UUID's on backend and update entity object on tick 2021-05-20 11:39:35 +01:00
Auxilor
3a480da078 Updated to 5.0.6 2021-05-20 09:02:15 +01:00
Auxilor
efc56e1763 Fixed several bugs 2021-05-20 09:02:06 +01:00
Auxilor
64f35b6338 Updated to 5.0.5 2021-05-19 11:31:48 +01:00
Auxilor
ab6e990f0b More fixes 2021-05-19 11:31:03 +01:00
Auxilor
fa8c5da31a Fixed 2 effects of the same type not working 2021-05-19 11:30:03 +01:00
Auxilor
730c259d19 Moved autospawn checks to by world 2021-05-02 10:29:04 +01:00
Auxilor
7fbc39d4d1 Updated to 5.0.4 2021-05-02 10:24:46 +01:00
Auxilor
5d69d0faee Added check for living bosses 2021-05-02 10:24:33 +01:00
Auxilor
21ed4b09fd Added extra check to boss bars 2021-04-24 17:55:57 +01:00
Auxilor
9eb3619c35 Fixed lingering boss bars 2021-04-24 17:54:40 +01:00
Auxilor
9abbfbf363 Updated to 5.0.3 2021-04-24 17:49:46 +01:00
Auxilor
12abdcbf5e Fixed Autospawn 2021-04-24 17:49:35 +01:00
Auxilor
11d8d8d13f Updated to 5.0.2 2021-04-18 21:06:43 +01:00
Auxilor
0932e68461 Merge remote-tracking branch 'origin/master' 2021-04-18 21:06:31 +01:00
Auxilor
6975daaeaf Fixed potential issues in boss ticking 2021-04-18 21:06:19 +01:00
Auxilor
663104bda0 Cleaned up /killall leaving lingering boss bars 2021-04-18 21:05:51 +01:00
Auxilor
83805215e9 Updated to 5.0.1 2021-04-17 15:12:24 +01:00
Auxilor
0b1f4d4f6d Removed unused 1.15 code 2021-04-17 15:12:09 +01:00
Auxilor
86e414e108 Updated to eco 5.2.0 2021-04-17 15:11:53 +01:00
54 changed files with 777 additions and 865 deletions

View File

@@ -1,6 +1,6 @@
plugins {
id 'java-library'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'maven-publish'
id 'java'
}
@@ -16,7 +16,6 @@ allprojects {
repositories {
mavenCentral()
jcenter()
mavenLocal()
maven { url 'https://jitpack.io' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
@@ -47,15 +46,15 @@ allprojects {
}
dependencies {
compileOnly 'com.willfp:eco:5.0.0'
compileOnly 'com.willfp:eco:6.0.0'
compileOnly 'org.jetbrains:annotations:19.0.0'
compileOnly 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
compileOnly 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testCompileOnly 'org.projectlombok:lombok:1.18.16'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.16'
testCompileOnly 'org.projectlombok:lombok:1.18.20'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
}
tasks.withType(JavaCompile) {
@@ -92,16 +91,8 @@ jar {
group = 'com.willfp'
archivesBaseName = project.name
version = findProperty("version")
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.sourceCompatibility = JavaVersion.VERSION_16
compileJava.options.encoding = 'UTF-8'
build.dependsOn shadowJar
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}

View File

@@ -0,0 +1,6 @@
group 'com.willfp'
version rootProject.version
dependencies {
compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
}

View File

@@ -0,0 +1,22 @@
package com.willfp.ecobosses.proxy.v1_17_R1;
import com.willfp.ecobosses.proxy.proxies.CustomEntitySpawnerProxy;
import com.willfp.ecobosses.proxy.proxies.CustomIllusionerProxy;
import com.willfp.ecobosses.proxy.util.CustomEntity;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@SuppressWarnings("unchecked")
public class CustomEntitySpawner implements CustomEntitySpawnerProxy {
@Override
public <T extends LivingEntity> @Nullable T spawnCustomEntity(final Class<? extends CustomEntity<? extends LivingEntity>> entityClass,
@NotNull final Location location) {
if (entityClass.equals(CustomIllusionerProxy.class)) {
return (T) CustomIllusioner.spawn(location);
}
return null;
}
}

View File

@@ -0,0 +1,62 @@
package com.willfp.ecobosses.proxy.v1_17_R1;
import com.willfp.ecobosses.proxy.proxies.CustomIllusionerProxy;
import net.minecraft.world.entity.EntityInsentient;
import net.minecraft.world.entity.EntityTypes;
import net.minecraft.world.entity.ai.goal.PathfinderGoalBowShoot;
import net.minecraft.world.entity.ai.goal.PathfinderGoalFloat;
import net.minecraft.world.entity.ai.goal.PathfinderGoalLookAtPlayer;
import net.minecraft.world.entity.ai.goal.PathfinderGoalMeleeAttack;
import net.minecraft.world.entity.ai.goal.PathfinderGoalRandomStroll;
import net.minecraft.world.entity.ai.goal.target.PathfinderGoalHurtByTarget;
import net.minecraft.world.entity.ai.goal.target.PathfinderGoalNearestAttackableTarget;
import net.minecraft.world.entity.animal.EntityIronGolem;
import net.minecraft.world.entity.monster.EntityIllagerIllusioner;
import net.minecraft.world.entity.monster.EntityIllagerWizard;
import net.minecraft.world.entity.npc.EntityVillagerAbstract;
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.entity.raid.EntityRaider;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.entity.Illusioner;
import org.jetbrains.annotations.NotNull;
public class CustomIllusioner extends EntityIllagerIllusioner implements CustomIllusionerProxy {
/**
* Instantiate a new custom illusioner entity.
*
* @param location The location to spawn it at.
*/
public CustomIllusioner(@NotNull final Location location) {
super(EntityTypes.O, ((CraftWorld) location.getWorld()).getHandle());
this.setPosition(location.getX(), location.getY(), location.getZ());
this.bO.a(0, new PathfinderGoalFloat(this));
this.bO.a(1, new EntityIllagerWizard.b());
this.bO.a(2, new PathfinderGoalMeleeAttack(this, 1.0D, false));
this.bO.a(2, new PathfinderGoalBowShoot<>(this, 1.0D, 20, 15.0F));
this.bO.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
this.bO.a(0, new PathfinderGoalFloat(this));
this.bO.a(6, new PathfinderGoalBowShoot<>(this, 0.5D, 20, 15.0F));
this.bO.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
this.bO.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
this.bO.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
this.bP.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0]));
this.bP.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300));
this.bP.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300));
this.bP.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300));
}
/**
* Spawn illusioner.
*
* @param location The location.
* @return The illusioner.
*/
public static Illusioner spawn(@NotNull final Location location) {
CustomIllusioner illusioner = new CustomIllusioner(location);
((CraftWorld) location.getWorld()).getHandle().addEntity(illusioner);
return (Illusioner) illusioner.getBukkitEntity();
}
}

View File

@@ -1,26 +1,19 @@
package com.willfp.ecobosses;
import com.willfp.eco.core.AbstractPacketAdapter;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.command.AbstractCommand;
import com.willfp.eco.core.integrations.IntegrationLoader;
import com.willfp.ecobosses.bosses.EcoBoss;
import com.willfp.ecobosses.bosses.EcoBosses;
import com.willfp.ecobosses.bosses.listeners.*;
import com.willfp.ecobosses.commands.CommandEbdrop;
import com.willfp.ecobosses.commands.CommandEbkillall;
import com.willfp.ecobosses.commands.CommandEbreload;
import com.willfp.ecobosses.commands.CommandEbspawn;
import com.willfp.ecobosses.commands.TabCompleterEbspawn;
import com.willfp.eco.core.command.impl.PluginCommand;
import com.willfp.ecobosses.bosses.listeners.AttackListeners;
import com.willfp.ecobosses.bosses.listeners.AutoSpawnTimer;
import com.willfp.ecobosses.bosses.listeners.DeathListeners;
import com.willfp.ecobosses.bosses.listeners.PassiveListeners;
import com.willfp.ecobosses.bosses.listeners.SpawnListeners;
import com.willfp.ecobosses.bosses.util.BossUtils;
import com.willfp.ecobosses.commands.CommandEcobosses;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.Listener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@SuppressWarnings("unused")
public class EcoBossesPlugin extends EcoPlugin {
@@ -34,109 +27,29 @@ public class EcoBossesPlugin extends EcoPlugin {
* Internal constructor called by bukkit on plugin load.
*/
public EcoBossesPlugin() {
super("EcoBosses", 86576, 10635, "com.willfp.ecobosses.proxy", "&9");
super(86576, 10635, "com.willfp.ecobosses.proxy", "&9");
instance = this;
}
/**
* Code executed on plugin enable.
*/
@Override
public void enable() {
this.getExtensionLoader().loadExtensions();
if (this.getExtensionLoader().getLoadedExtensions().isEmpty()) {
this.getLogger().info("&cNo extensions found");
} else {
this.getLogger().info("Extensions Loaded:");
this.getExtensionLoader().getLoadedExtensions().forEach(extension -> this.getLogger().info("- " + extension.getName() + " v" + extension.getVersion()));
}
protected void handleDisable() {
BossUtils.killAllBosses();
}
@Override
protected void handleReload() {
this.getScheduler().runTimer(new AutoSpawnTimer(), 5, 1);
}
/**
* Code executed on plugin disable.
*/
@Override
public void disable() {
this.getExtensionLoader().unloadExtensions();
for (EcoBoss boss : EcoBosses.values()) {
for (UUID uuid : boss.getLivingBosses().keySet()) {
LivingEntity entity = (LivingEntity) Bukkit.getEntity(uuid);
assert entity != null;
entity.damage(10000000);
}
}
}
/**
* Nothing is called on plugin load.
*/
@Override
public void load() {
// Nothing needs to be called on load
}
/**
* Code executed on reload.
*/
@Override
public void onReload() {
}
/**
* Code executed after server is up.
*/
@Override
public void postLoad() {
// Nothing is executed post-load.
}
/**
* EcoEnchants-specific integrations.
*
* @return A list of all integrations.
*/
@Override
public List<IntegrationLoader> getIntegrationLoaders() {
return new ArrayList<>();
}
/**
* EcoEnchants-specific commands.
*
* @return A list of all commands.
*/
@Override
public List<AbstractCommand> getCommands() {
protected List<PluginCommand> loadPluginCommands() {
return Arrays.asList(
new CommandEbreload(this),
new CommandEbdrop(this),
new CommandEbspawn(this),
new CommandEbkillall(this)
new CommandEcobosses(this)
);
}
/**
* Packet Adapters for enchant display.
*
* @return A list of packet adapters.
*/
@Override
public List<AbstractPacketAdapter> getPacketAdapters() {
return new ArrayList<>();
}
/**
* EcoEnchants-specific listeners.
*
* @return A list of all listeners.
*/
@Override
public List<Listener> getListeners() {
protected List<Listener> loadListeners() {
return Arrays.asList(
new AttackListeners(this),
new DeathListeners(this),
@@ -144,12 +57,4 @@ public class EcoBossesPlugin extends EcoPlugin {
new PassiveListeners(this)
);
}
@Override
public List<Class<?>> getUpdatableClasses() {
return Arrays.asList(
EcoBosses.class,
TabCompleterEbspawn.class
);
}
}

View File

@@ -3,17 +3,26 @@ package com.willfp.ecobosses.bosses;
import com.google.common.collect.ImmutableMap;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.config.Config;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.tuples.Pair;
import com.willfp.eco.util.StringUtils;
import com.willfp.ecobosses.bosses.effects.Effect;
import com.willfp.ecobosses.bosses.effects.Effects;
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
import com.willfp.ecobosses.bosses.util.obj.*;
import com.willfp.ecobosses.bosses.util.obj.BossbarProperties;
import com.willfp.ecobosses.bosses.util.obj.ExperienceOptions;
import com.willfp.ecobosses.bosses.util.obj.ImmunityOptions;
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
import com.willfp.ecobosses.bosses.util.obj.SpawnTotem;
import com.willfp.ecobosses.bosses.util.obj.TargetMode;
import lombok.AccessLevel;
import lombok.Getter;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.configuration.InvalidConfigurationException;
@@ -22,11 +31,18 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
public class EcoBoss extends PluginDependent {
public class EcoBoss extends PluginDependent<EcoPlugin> {
/**
* The name of the boss.
*/
@@ -192,7 +208,7 @@ public class EcoBoss extends PluginDependent {
/**
* The currently living bosses of this type.
*/
private final Map<UUID, LivingEcoBoss> livingBosses;
private final Map<LivingEntity, LivingEcoBoss> livingBosses;
/**
* The effect names and arguments.
@@ -361,18 +377,18 @@ public class EcoBoss extends PluginDependent {
// Messages
this.spawnMessages = new ArrayList<>();
for (String string : this.getConfig().getStrings("broadcast.spawn")) {
this.spawnMessages.add(StringUtils.translate(string));
this.spawnMessages.add(StringUtils.format(string));
}
this.deathMessages = new ArrayList<>();
for (String string : this.getConfig().getStrings("broadcast.death")) {
this.deathMessages.add(StringUtils.translate(string));
this.deathMessages.add(StringUtils.format(string));
}
// Top Damager Commands
this.topDamagerCommands = new HashMap<>();
for (int i = 1; i <= 3; i++) {
this.topDamagerCommands.put(i, new ArrayList<>());
for (String string : this.getConfig().getStrings("rewards.top-damager-commands." + i)) {
for (String string : this.getConfig().getStrings("rewards.top-damager-commands." + i, false)) {
double chance = 100;
if (string.contains("::")) {
String[] split = string.split("::");
@@ -388,7 +404,7 @@ public class EcoBoss extends PluginDependent {
// Nearby Rewards
this.nearbyRadius = this.getConfig().getDouble("rewards.nearby-player-commands.radius");
this.nearbyPlayersCommands = new HashMap<>();
for (String string : this.getConfig().getStrings("rewards.nearby-player-commands.commands")) {
for (String string : this.getConfig().getStrings("rewards.nearby-player-commands.commands", false)) {
double chance = 100;
if (string.contains("::")) {
String[] split = string.split("::");
@@ -442,8 +458,8 @@ public class EcoBoss extends PluginDependent {
*
* @return The effects.
*/
public Set<Effect> createEffects() {
Set<Effect> effects = new HashSet<>();
public List<Effect> createEffects() {
List<Effect> effects = new ArrayList<>();
this.effectNames.forEach((string, args) -> {
effects.add(Effects.getEffect(string, args));
});
@@ -457,8 +473,10 @@ public class EcoBoss extends PluginDependent {
* @param location The location.
*/
public void spawn(@NotNull final Location location) {
location.getChunk().load();
LivingEntity entity = bossType.spawnBossEntity(location);
this.livingBosses.put(entity.getUniqueId(), new LivingEcoBoss(
this.livingBosses.put(entity, new LivingEcoBoss(
this.getPlugin(),
entity,
this
@@ -473,16 +491,16 @@ public class EcoBoss extends PluginDependent {
* @return The living boss, or null if not a boss.
*/
public LivingEcoBoss getLivingBoss(@NotNull final LivingEntity entity) {
return this.livingBosses.get(entity.getUniqueId());
return this.livingBosses.get(entity);
}
/**
* Remove living boss.
*
* @param uuid The entity UUID.
* @param entity The entity.
*/
public void removeLivingBoss(@NotNull final UUID uuid) {
this.livingBosses.remove(uuid);
public void removeLivingBoss(@Nullable final LivingEntity entity) {
this.livingBosses.remove(entity);
}
/**
@@ -490,7 +508,7 @@ public class EcoBoss extends PluginDependent {
*
* @return The living bosses.
*/
public Map<UUID, LivingEcoBoss> getLivingBosses() {
public Map<LivingEntity, LivingEcoBoss> getLivingBosses() {
return ImmutableMap.copyOf(this.livingBosses);
}
@@ -500,11 +518,10 @@ public class EcoBoss extends PluginDependent {
return true;
}
if (!(o instanceof EcoBoss)) {
if (!(o instanceof EcoBoss boss)) {
return false;
}
EcoBoss boss = (EcoBoss) o;
return this.getName().equals(boss.getName());
}

View File

@@ -3,7 +3,7 @@ package com.willfp.ecobosses.bosses;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList;
import com.willfp.eco.core.config.ConfigUpdater;
import com.willfp.eco.core.config.updating.ConfigUpdater;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.config.BaseBossConfig;
import com.willfp.ecobosses.config.CustomConfig;

View File

@@ -11,6 +11,7 @@ import com.willfp.ecobosses.bosses.tick.tickers.BossBarTicker;
import com.willfp.ecobosses.bosses.tick.tickers.HealthPlaceholderTicker;
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
@@ -21,15 +22,16 @@ import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
public class LivingEcoBoss extends PluginDependent {
public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
/**
* The entity.
*/
private final LivingEntity entity;
@Getter
private LivingEntity entity;
/**
* The boss.
@@ -39,12 +41,12 @@ public class LivingEcoBoss extends PluginDependent {
/**
* The boss tickers.
*/
private final Set<BossTicker> tickers;
private final List<BossTicker> tickers;
/**
* The effects.
*/
private final Set<Effect> effects;
private final List<Effect> effects;
/**
* Create new living EcoBoss.
@@ -63,7 +65,7 @@ public class LivingEcoBoss extends PluginDependent {
this.onSpawn();
// Tickers
this.tickers = new HashSet<>();
this.tickers = new ArrayList<>();
this.tickers.add(new HealthPlaceholderTicker());
this.tickers.add(new TargetTicker(boss.getTargetMode(), boss.getTargetDistance()));
if (boss.isBossbarEnabled()) {
@@ -72,8 +74,8 @@ public class LivingEcoBoss extends PluginDependent {
Bukkit.getServer().createBossBar(
plugin.getNamespacedKeyFactory().create("boss_" + NumberUtils.randInt(0, 1000000)),
entity.getCustomName(),
boss.getBossbarProperties().getColor(),
boss.getBossbarProperties().getStyle(),
boss.getBossbarProperties().color(),
boss.getBossbarProperties().style(),
(BarFlag) null
),
this.getPlugin().getConfigYml().getInt("bossbar-radius")
@@ -82,7 +84,7 @@ public class LivingEcoBoss extends PluginDependent {
}
// Effects
this.effects = new HashSet<>();
this.effects = new ArrayList<>();
this.effects.addAll(boss.createEffects());
AtomicLong currentTick = new AtomicLong(0);
@@ -92,6 +94,7 @@ public class LivingEcoBoss extends PluginDependent {
private void onSpawn() {
entity.getPersistentDataContainer().set(this.getPlugin().getNamespacedKeyFactory().create("boss"), PersistentDataType.STRING, boss.getName());
entity.setPersistent(true);
entity.setRemoveWhenFarAway(false);
entity.setCustomName(boss.getDisplayName());
entity.setCustomNameVisible(true);
@@ -115,7 +118,7 @@ public class LivingEcoBoss extends PluginDependent {
attackDamage.setBaseValue(boss.getAttackDamage());
for (OptionedSound sound : boss.getSpawnSounds()) {
entity.getWorld().playSound(entity.getLocation(), sound.getSound(), sound.getVolume(), sound.getPitch());
entity.getWorld().playSound(entity.getLocation(), sound.sound(), sound.volume(), sound.pitch());
}
for (String spawnMessage : boss.getSpawnMessages()) {
@@ -129,21 +132,23 @@ public class LivingEcoBoss extends PluginDependent {
private void tick(final long tick,
@NotNull final RunnableTask runnable) {
for (BossTicker ticker : tickers) {
ticker.tick(boss, entity, tick);
}
for (Effect effect : effects) {
effect.tick(boss, entity, tick);
}
if (entity.isDead()) {
if (entity == null || entity.isDead()) {
for (BossTicker ticker : tickers) {
ticker.onDeath(boss, entity, tick);
}
for (Effect effect : effects) {
effect.onDeath(boss, entity, tick);
}
boss.removeLivingBoss(entity.getUniqueId());
boss.removeLivingBoss(entity);
runnable.cancel();
return;
}
for (BossTicker ticker : tickers) {
ticker.tick(boss, entity, tick);
}
for (Effect effect : effects) {
effect.tick(boss, entity, tick);
}
}
@@ -154,7 +159,7 @@ public class LivingEcoBoss extends PluginDependent {
*/
public void handleAttack(@NotNull final Player player) {
for (OptionedSound sound : boss.getInjureSounds()) {
player.getWorld().playSound(entity.getLocation(), sound.getSound(), sound.getVolume(), sound.getPitch());
player.getWorld().playSound(entity.getLocation(), sound.sound(), sound.volume(), sound.pitch());
}
for (Effect effect : effects) {

View File

@@ -7,8 +7,10 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Objects;
public abstract class Effect implements BossTicker {
/**
@@ -79,8 +81,24 @@ public abstract class Effect implements BossTicker {
*/
@Override
public void onDeath(@NotNull final EcoBoss boss,
@NotNull final LivingEntity entity,
@Nullable final LivingEntity entity,
final long tick) {
// Override when needed.
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Effect effect)) {
return false;
}
return Objects.equals(getArgs(), effect.getArgs());
}
@Override
public int hashCode() {
return Objects.hash(getArgs());
}
}

View File

@@ -59,7 +59,7 @@ public class EffectSummon extends Effect {
}
for (OptionedSound sound : boss.getSummonSounds()) {
player.getWorld().playSound(entity.getLocation(), sound.getSound(), sound.getVolume(), sound.getPitch());
player.getWorld().playSound(entity.getLocation(), sound.sound(), sound.volume(), sound.pitch());
}
}
}

View File

@@ -21,7 +21,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
public class AttackListeners extends PluginDependent implements Listener {
public class AttackListeners extends PluginDependent<EcoPlugin> implements Listener {
/**
* Create new attack listeners.
*
@@ -38,21 +38,11 @@ public class AttackListeners extends PluginDependent implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onAttackBoss(@NotNull final EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof LivingEntity)) {
if (!(event.getEntity() instanceof LivingEntity entity)) {
return;
}
LivingEntity entity = (LivingEntity) event.getEntity();
Player player = null;
if (event.getDamager() instanceof Player) {
player = (Player) event.getDamager();
} else if (event.getDamager() instanceof Projectile) {
if (((Projectile) event.getDamager()).getShooter() instanceof Player) {
player = (Player) ((Projectile) event.getDamager()).getShooter();
}
}
Player player = BossUtils.getPlayerFromEntity(event.getDamager());
if (player == null) {
return;
@@ -66,6 +56,8 @@ public class AttackListeners extends PluginDependent implements Listener {
LivingEcoBoss livingEcoBoss = boss.getLivingBoss(entity);
BossUtils.warnIfNull(livingEcoBoss);
if (boss.isAttackOnInjure()) {
livingEcoBoss.handleAttack(player);
}
@@ -78,28 +70,16 @@ public class AttackListeners extends PluginDependent implements Listener {
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void topDamageTracker(@NotNull final EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof LivingEntity)) {
if (!(event.getEntity() instanceof LivingEntity entity)) {
return;
}
LivingEntity entity = (LivingEntity) event.getEntity();
Player player = BossUtils.getPlayerFromEntity(event.getDamager());
Player temp = null;
if (event.getDamager() instanceof Player) {
temp = (Player) event.getDamager();
} else if (event.getDamager() instanceof Projectile) {
if (((Projectile) event.getDamager()).getShooter() instanceof Player) {
temp = (Player) ((Projectile) event.getDamager()).getShooter();
}
}
if (temp == null) {
if (player == null) {
return;
}
Player player = temp;
EcoBoss boss = BossUtils.getBoss(entity);
if (boss == null) {
@@ -110,11 +90,11 @@ public class AttackListeners extends PluginDependent implements Listener {
double playerDamage;
Optional<DamagerProperty> damager = topDamagers.stream().filter(damagerProperty -> damagerProperty.getPlayerUUID().equals(player.getUniqueId())).findFirst();
playerDamage = damager.map(DamagerProperty::getDamage).orElse(0.0);
Optional<DamagerProperty> damager = topDamagers.stream().filter(damagerProperty -> damagerProperty.playerUUID().equals(player.getUniqueId())).findFirst();
playerDamage = damager.map(DamagerProperty::damage).orElse(0.0);
playerDamage += event.getFinalDamage();
topDamagers.removeIf(damagerProperty -> damagerProperty.getPlayerUUID().equals(player.getUniqueId()));
topDamagers.removeIf(damagerProperty -> damagerProperty.playerUUID().equals(player.getUniqueId()));
topDamagers.add(new DamagerProperty(player.getUniqueId(), playerDamage));
entity.removeMetadata("ecobosses-top-damagers", this.getPlugin());
@@ -128,18 +108,14 @@ public class AttackListeners extends PluginDependent implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onAttackPlayer(@NotNull final EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof Player)) {
if (!(event.getEntity() instanceof Player player)) {
return;
}
if (!(event.getDamager() instanceof LivingEntity)) {
if (!(event.getDamager() instanceof LivingEntity entity)) {
return;
}
LivingEntity entity = (LivingEntity) event.getDamager();
Player player = (Player) event.getEntity();
EcoBoss boss = BossUtils.getBoss(entity);
if (boss == null) {
@@ -148,6 +124,8 @@ public class AttackListeners extends PluginDependent implements Listener {
LivingEcoBoss livingEcoBoss = boss.getLivingBoss(entity);
BossUtils.warnIfNull(livingEcoBoss);
livingEcoBoss.handleAttack(player);
}
@@ -158,12 +136,10 @@ public class AttackListeners extends PluginDependent implements Listener {
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void defenceListener(@NotNull final EntityDamageEvent event) {
if (!(event.getEntity() instanceof LivingEntity)) {
if (!(event.getEntity() instanceof LivingEntity entity)) {
return;
}
LivingEntity entity = (LivingEntity) event.getEntity();
EcoBoss boss = BossUtils.getBoss(entity);
if (boss == null) {
@@ -172,22 +148,22 @@ public class AttackListeners extends PluginDependent implements Listener {
ImmunityOptions immunities = boss.getImmunityOptions();
if (immunities.isImmuneToFire()
if (immunities.immuneToFire()
&& (event.getCause() == EntityDamageEvent.DamageCause.FIRE
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK
|| event.getCause() == EntityDamageEvent.DamageCause.HOT_FLOOR)) {
event.setCancelled(true);
}
if (immunities.isImmuneToSuffocation()&& event.getCause() == EntityDamageEvent.DamageCause.SUFFOCATION) {
if (immunities.immuneToSuffocation()&& event.getCause() == EntityDamageEvent.DamageCause.SUFFOCATION) {
event.setCancelled(true);
}
if (immunities.isImmuneToDrowning() && event.getCause() == EntityDamageEvent.DamageCause.DROWNING) {
if (immunities.immuneToDrowning() && event.getCause() == EntityDamageEvent.DamageCause.DROWNING) {
event.setCancelled(true);
}
if (immunities.isImmuneToExplosions() && (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION || event.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) {
if (immunities.immuneToExplosions() && (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION || event.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION)) {
event.setCancelled(true);
}
if (immunities.isImmuneToProjectiles() && (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE)) {
if (immunities.immuneToProjectiles() && (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE)) {
event.setCancelled(true);
}

View File

@@ -3,7 +3,15 @@ package com.willfp.ecobosses.bosses.listeners;
import com.willfp.eco.util.NumberUtils;
import com.willfp.ecobosses.bosses.EcoBoss;
import com.willfp.ecobosses.bosses.EcoBosses;
import com.willfp.ecobosses.bosses.util.BossUtils;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class AutoSpawnTimer implements Runnable {
private int tick = 0;
@@ -21,8 +29,24 @@ public class AutoSpawnTimer implements Runnable {
continue;
}
Set<World> worlds = new HashSet<>();
for (Entity entity : boss.getLivingBosses().keySet()) {
BossUtils.warnIfNull(entity);
assert entity != null;
worlds.add(entity.getWorld());
}
List<Location> locations = new ArrayList<>(boss.getAutoSpawnLocations());
locations.removeIf(location -> worlds.contains(location.getWorld()));
if (locations.isEmpty()) {
continue;
}
if (tick % boss.getAutoSpawnInterval() == 0) {
Location location = boss.getAutoSpawnLocations().get(NumberUtils.randInt(0, boss.getAutoSpawnLocations().size() - 1));
Location location = locations.get(NumberUtils.randInt(0, locations.size() - 1));
boss.spawn(location);
}
}

View File

@@ -26,7 +26,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class DeathListeners extends PluginDependent implements Listener {
public class DeathListeners extends PluginDependent<EcoPlugin> implements Listener {
/**
* Create new death listeners.
*
@@ -52,7 +52,7 @@ public class DeathListeners extends PluginDependent implements Listener {
}
for (OptionedSound sound : boss.getDeathSounds()) {
entity.getWorld().playSound(entity.getLocation(), sound.getSound(), sound.getVolume(), sound.getPitch());
entity.getWorld().playSound(entity.getLocation(), sound.sound(), sound.volume(), sound.pitch());
}
}
@@ -89,14 +89,14 @@ public class DeathListeners extends PluginDependent implements Listener {
String na = this.getPlugin().getLangYml().getString("na");
String topDamager = top == null ? na : Bukkit.getPlayer(top.getPlayerUUID()).getDisplayName();
String topDamage = top == null ? na : StringUtils.internalToString(top.getDamage());
String topDamager = top == null ? na : Bukkit.getPlayer(top.playerUUID()).getDisplayName();
String topDamage = top == null ? na : StringUtils.internalToString(top.damage());
String secondDamager = second == null ? na : Bukkit.getPlayer(second.getPlayerUUID()).getDisplayName();
String secondDamage = second == null ? na : StringUtils.internalToString(second.getDamage());
String secondDamager = second == null ? na : Bukkit.getPlayer(second.playerUUID()).getDisplayName();
String secondDamage = second == null ? na : StringUtils.internalToString(second.damage());
String thirdDamager = third == null ? na : Bukkit.getPlayer(third.getPlayerUUID()).getDisplayName();
String thirdDamage = third == null ? na : StringUtils.internalToString(third.getDamage());
String thirdDamager = third == null ? na : Bukkit.getPlayer(third.playerUUID()).getDisplayName();
String thirdDamage = third == null ? na : StringUtils.internalToString(third.damage());
for (String spawnMessage : boss.getDeathMessages()) {
Bukkit.broadcastMessage(spawnMessage
@@ -114,17 +114,17 @@ public class DeathListeners extends PluginDependent implements Listener {
for (Pair<Double, String> pair : topDamagerCommands) {
if (top != null && i == 1) {
if (NumberUtils.randFloat(0, 100) < pair.getFirst()) {
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), pair.getSecond().replace("%player%", Bukkit.getOfflinePlayer(top.getPlayerUUID()).getName()));
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), pair.getSecond().replace("%player%", Bukkit.getOfflinePlayer(top.playerUUID()).getName()));
}
}
if (second != null && i == 2) {
if (NumberUtils.randFloat(0, 100) < pair.getFirst()) {
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), pair.getSecond().replace("%player%", Bukkit.getOfflinePlayer(second.getPlayerUUID()).getName()));
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), pair.getSecond().replace("%player%", Bukkit.getOfflinePlayer(second.playerUUID()).getName()));
}
}
if (third != null && i == 3) {
if (NumberUtils.randFloat(0, 100) < pair.getFirst()) {
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), pair.getSecond().replace("%player%", Bukkit.getOfflinePlayer(third.getPlayerUUID()).getName()));
Bukkit.dispatchCommand(Bukkit.getServer().getConsoleSender(), pair.getSecond().replace("%player%", Bukkit.getOfflinePlayer(third.playerUUID()).getName()));
}
}
}

View File

@@ -12,7 +12,7 @@ import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
import org.spigotmc.event.entity.EntityMountEvent;
public class PassiveListeners extends PluginDependent implements Listener {
public class PassiveListeners extends PluginDependent<EcoPlugin> implements Listener {
/**
* Create new attack listeners.
*
@@ -29,7 +29,7 @@ public class PassiveListeners extends PluginDependent implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onAttackBoss(@NotNull final EntityMountEvent event) {
if (!(event.getEntity() instanceof LivingEntity)) {
if (!(event.getEntity() instanceof LivingEntity entity)) {
return;
}
@@ -37,8 +37,6 @@ public class PassiveListeners extends PluginDependent implements Listener {
return;
}
LivingEntity entity = (LivingEntity) event.getEntity();
EcoBoss boss = BossUtils.getBoss(entity);
if (boss == null) {

View File

@@ -12,7 +12,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.jetbrains.annotations.NotNull;
public class SpawnListeners extends PluginDependent implements Listener {
public class SpawnListeners extends PluginDependent<EcoPlugin> implements Listener {
/**
* Create new spawn listeners and link them to a plugin.
*

View File

@@ -3,6 +3,7 @@ package com.willfp.ecobosses.bosses.tick;
import com.willfp.ecobosses.bosses.EcoBoss;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface BossTicker {
/**
@@ -24,7 +25,7 @@ public interface BossTicker {
* @param tick The current tick: counts up from zero.
*/
default void onDeath(@NotNull EcoBoss boss,
@NotNull LivingEntity entity,
@Nullable LivingEntity entity,
long tick) {
// Can be overridden when needed.
}

View File

@@ -2,11 +2,14 @@ package com.willfp.ecobosses.bosses.tick.tickers;
import com.willfp.ecobosses.bosses.EcoBoss;
import com.willfp.ecobosses.bosses.tick.BossTicker;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute;
import org.bukkit.boss.BossBar;
import org.bukkit.boss.KeyedBossBar;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class BossBarTicker implements BossTicker {
/**
@@ -38,7 +41,7 @@ public class BossBarTicker implements BossTicker {
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
if (tick % 40 == 0) {
bossBar.getPlayers().forEach(bossBar::removePlayer);
bossBar.removeAll();
entity.getNearbyEntities(radius, radius, radius).forEach(entity1 -> {
if (entity1 instanceof Player) {
bossBar.addPlayer((Player) entity1);
@@ -49,9 +52,10 @@ public class BossBarTicker implements BossTicker {
@Override
public void onDeath(@NotNull final EcoBoss boss,
@NotNull final LivingEntity entity,
@Nullable final LivingEntity entity,
final long tick) {
bossBar.getPlayers().forEach(bossBar::removePlayer);
bossBar.removeAll();
bossBar.setVisible(false);
Bukkit.removeBossBar(((KeyedBossBar) bossBar).getKey());
}
}

View File

@@ -3,9 +3,17 @@ package com.willfp.ecobosses.bosses.util;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.bosses.EcoBoss;
import com.willfp.ecobosses.bosses.EcoBosses;
import com.willfp.ecobosses.bosses.LivingEcoBoss;
import com.willfp.ecobosses.bosses.util.obj.DamagerProperty;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.boss.BossBar;
import org.bukkit.boss.KeyedBossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -63,9 +71,114 @@ public class BossUtils {
}
assert topDamagers != null;
topDamagers.sort(Comparator.comparingDouble(DamagerProperty::getDamage));
topDamagers.sort(Comparator.comparingDouble(DamagerProperty::damage));
Collections.reverse(topDamagers);
return topDamagers;
}
/**
* Kill all bosses.
*
* @return The amount of bosses killed.
*/
public int killAllBosses() {
return killAllBosses(false);
}
/**
* Kill all bosses.
*
* @param force If all entities should be checked for being bosses.
* @return The amount of bosses killed.
*/
public int killAllBosses(final boolean force) {
int amount = 0;
for (EcoBoss boss : EcoBosses.values()) {
for (LivingEntity entity : boss.getLivingBosses().keySet()) {
assert entity != null;
entity.damage(10000000);
amount++;
}
}
if (force) {
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getEntities()) {
if (!(entity instanceof LivingEntity)) {
continue;
}
if (BossUtils.getBoss((LivingEntity) entity) == null) {
continue;
}
entity.remove();
}
}
}
List<KeyedBossBar> bars = new ArrayList<>();
Bukkit.getBossBars().forEachRemaining(bars::add);
for (KeyedBossBar bar : bars) {
if (bar.getKey().toString().startsWith("ecobosses:boss")) {
BossBar bossBar = Bukkit.getBossBar(bar.getKey());
assert bossBar != null;
bossBar.removeAll();
bossBar.setVisible(false);
Bukkit.removeBossBar(bar.getKey());
}
}
return amount;
}
/**
* Get player from entity if player or projectile.
*
* @param entity The entity.
* @return The player, or null if not a player.
*/
@Nullable
public Player getPlayerFromEntity(@NotNull final Entity entity) {
Player player = null;
if (entity instanceof Player) {
player = (Player) entity;
} else if (entity instanceof Projectile) {
if (((Projectile) entity).getShooter() instanceof Player) {
player = (Player) ((Projectile) entity).getShooter();
}
}
return player;
}
/**
* Warn if a boss is null.
*
* @param boss The boss.
*/
public void warnIfNull(@Nullable final LivingEcoBoss boss) {
if (boss != null) {
return;
}
PLUGIN.getLogger().severe("Boss is null! Report this to Auxilor (https://discord.gg/ZcwpSsE)");
PLUGIN.getLogger().severe("Send this stack-trace in the relevant channel.");
throw new NullPointerException("Boss is null!");
}
/**
* Warn if an entity is null.
*/
public void warnIfNull(@Nullable final Entity entity) {
if (entity != null) {
return;
}
PLUGIN.getLogger().severe("Entity is null! Report this to Auxilor (https://discord.gg/ZcwpSsE)");
PLUGIN.getLogger().severe("Send this stack-trace in the relevant channel.");
throw new NullPointerException("Entity is null!");
}
}

View File

@@ -1,8 +1,8 @@
package com.willfp.ecobosses.bosses.util.bosstype;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.proxy.proxies.CustomEntitySpawnerProxy;
import com.willfp.ecobosses.proxy.util.CustomEntity;
import com.willfp.ecobosses.util.ProxyUtils;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
@@ -24,6 +24,6 @@ class CustomBossType extends BossType {
@Override
public LivingEntity spawnBossEntity(@NotNull final Location location) {
return ProxyUtils.getProxy(CustomEntitySpawnerProxy.class).spawnCustomEntity(entityClass, location);
return EcoBossesPlugin.getInstance().getProxy(CustomEntitySpawnerProxy.class).spawnCustomEntity(entityClass, location);
}
}

View File

@@ -4,15 +4,6 @@ import lombok.Data;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
@Data
public class BossbarProperties {
/**
* The BossBar color.
*/
private final BarColor color;
public record BossbarProperties(BarColor color, BarStyle style) {
/**
* The BossBar style.
*/
private final BarStyle style;
}

View File

@@ -1,18 +1,7 @@
package com.willfp.ecobosses.bosses.util.obj;
import lombok.Data;
import java.util.UUID;
@Data
public class DamagerProperty {
/**
* The player.
*/
private final UUID playerUUID;
public record DamagerProperty(UUID playerUUID, double damage) {
/**
* The damage.
*/
private final double damage;
}

View File

@@ -2,29 +2,7 @@ package com.willfp.ecobosses.bosses.util.obj;
import com.willfp.eco.util.NumberUtils;
public class ExperienceOptions {
/**
* The minimum xp to drop.
*/
private final int minimum;
/**
* The maximum xp to drop.
*/
private final int maximum;
/**
* Create new experience options.
*
* @param minimum Minimum xp.
* @param maximum Maximum xp.
*/
public ExperienceOptions(final int minimum,
final int maximum) {
this.minimum = minimum;
this.maximum = maximum;
}
public record ExperienceOptions(int minimum, int maximum) {
/**
* Generate an exp amount.
*

View File

@@ -1,31 +1,8 @@
package com.willfp.ecobosses.bosses.util.obj;
import lombok.Data;
@Data
public class ImmunityOptions {
/**
* If is immune to fire.
*/
private final boolean immuneToFire;
/**
* If is immune to suffocation.
*/
private final boolean immuneToSuffocation;
/**
* If is immune to drowning.
*/
private final boolean immuneToDrowning;
/**
* If is immune to projectiles.
*/
private final boolean immuneToProjectiles;
/**
* If is immune to explosions.
*/
private final boolean immuneToExplosions;
public record ImmunityOptions(boolean immuneToFire,
boolean immuneToSuffocation,
boolean immuneToDrowning,
boolean immuneToProjectiles,
boolean immuneToExplosions) {
}

View File

@@ -1,40 +1,9 @@
package com.willfp.ecobosses.bosses.util.obj;
import lombok.Getter;
import org.bukkit.Sound;
import org.jetbrains.annotations.NotNull;
public class OptionedSound {
/**
* The sound.
*/
@Getter
private final Sound sound;
public record OptionedSound(Sound sound,
float volume,
float pitch) {
/**
* The volume.
*/
@Getter
private final float volume;
/**
* The pitch, from 0.5 to 2.
*/
@Getter
private final float pitch;
/**
* Create a new optioned sound.
*
* @param sound The sound.
* @param volume The volume.
* @param pitch The pitch, from 0.5 to 2.
*/
public OptionedSound(@NotNull final Sound sound,
final float volume,
final float pitch) {
this.sound = sound;
this.volume = volume;
this.pitch = pitch;
}
}

View File

@@ -3,20 +3,7 @@ package com.willfp.ecobosses.bosses.util.obj;
import lombok.Data;
import org.bukkit.Material;
@Data
public class SpawnTotem {
/**
* The bottom block.
*/
private final Material bottom;
/**
* The middle block.
*/
private final Material middle;
/**
* The top block.
*/
private final Material top;
public record SpawnTotem(Material bottom,
Material middle,
Material top) {
}

View File

@@ -0,0 +1,41 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.CommandHandler;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.ecobosses.EcoBossesPlugin;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.Base64;
public class CommandBase64 extends Subcommand {
/**
* Instantiate a new executor for /ebdrop.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandBase64(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "base64", "ecobosses.command.base64", true);
}
@Override
public CommandHandler getHandler() {
return (sender, args) -> {
Player player = (Player) sender;
ItemStack itemStack = player.getInventory().getItemInMainHand();
String key = "drop-key";
YamlConfiguration jank = new YamlConfiguration();
jank.set(key, itemStack);
String configString = jank.saveToString();
String dropString = Base64.getEncoder().encodeToString(configString.getBytes());
Bukkit.getLogger().info("Copy this into the drops section of your boss yml!");
Bukkit.getLogger().info("\n" + dropString);
player.sendMessage(this.getPlugin().getLangYml().getMessage("sent-drop"));
};
}
}

View File

@@ -1,42 +0,0 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.AbstractCommand;
import com.willfp.ecobosses.EcoBossesPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.List;
public class CommandEbdrop extends AbstractCommand {
/**
* Instantiate a new executor for /ebdrop.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandEbdrop(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "ebdrop", "ecobosses.ebdrop", true);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
Player player = (Player) sender;
ItemStack itemStack = player.getInventory().getItemInMainHand();
String key = "drop-key";
YamlConfiguration jank = new YamlConfiguration();
jank.set(key, itemStack);
String configString = jank.saveToString();
String dropString = Base64.getEncoder().encodeToString(configString.getBytes(StandardCharsets.UTF_8));
Bukkit.getLogger().info("Copy this into the drops section of your boss yml!");
Bukkit.getLogger().info("\n" + dropString);
player.sendMessage(this.getPlugin().getLangYml().getMessage("sent-drop"));
}
}

View File

@@ -1,40 +0,0 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.AbstractCommand;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.bosses.EcoBoss;
import com.willfp.ecobosses.bosses.EcoBosses;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.UUID;
public class CommandEbkillall extends AbstractCommand {
/**
* Instantiate a new executor for /ebspawn.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandEbkillall(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "ebkillall", "ecobosses.killall", false);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
int amount = 0;
for (EcoBoss boss : EcoBosses.values()) {
for (UUID uuid : boss.getLivingBosses().keySet()) {
LivingEntity entity = (LivingEntity) Bukkit.getEntity(uuid);
assert entity != null;
entity.damage(10000000);
amount++;
}
}
sender.sendMessage(this.getPlugin().getLangYml().getMessage("killall").replace("%amount%", String.valueOf(amount)));
}
}

View File

@@ -1,27 +0,0 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.AbstractCommand;
import com.willfp.ecobosses.EcoBossesPlugin;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandEbreload extends AbstractCommand {
/**
* Instantiate a new executor for /ebreload.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandEbreload(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "ebreload", "ecobosses.reload", false);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
this.getPlugin().reload();
this.getPlugin().reload();
sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded"));
}
}

View File

@@ -1,138 +0,0 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.AbstractCommand;
import com.willfp.eco.core.command.AbstractTabCompleter;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.bosses.EcoBoss;
import com.willfp.ecobosses.bosses.EcoBosses;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class CommandEbspawn extends AbstractCommand {
/**
* Instantiate a new executor for /ebspawn.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandEbspawn(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "ebspawn", "ecobosses.ebspawn", false);
}
@Override
@Nullable
public AbstractTabCompleter getTab() {
return new TabCompleterEbspawn(this);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
if (args.isEmpty()) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss"));
return;
}
String bossName = args.get(0);
EcoBoss boss = EcoBosses.getByName(bossName.toLowerCase());
if (boss == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss"));
return;
}
Location location = null;
if (sender instanceof Player) {
location = ((Player) sender).getLocation();
}
if (args.size() >= 4) {
String xString = args.get(1);
String yString = args.get(2);
String zString = args.get(3);
double xPos;
double yPos;
double zPos;
if (xString.startsWith("~") && sender instanceof Player) {
String xDiff = xString.replace("~", "");
String yDiff = yString.replace("~", "");
String zDiff = zString.replace("~", "");
if (xDiff.isEmpty()) {
xPos = ((Player) sender).getLocation().getX();
} else {
try {
xPos = ((Player) sender).getLocation().getX() + Double.parseDouble(xDiff);
} catch (NumberFormatException e) {
xPos = ((Player) sender).getLocation().getX();
}
}
if (yDiff.isEmpty()) {
yPos = ((Player) sender).getLocation().getY();
} else {
try {
yPos = ((Player) sender).getLocation().getY() + Double.parseDouble(yDiff);
} catch (NumberFormatException e) {
yPos = ((Player) sender).getLocation().getY();
}
}
if (zDiff.isEmpty()) {
zPos = ((Player) sender).getLocation().getZ();
} else {
try {
zPos = ((Player) sender).getLocation().getZ() + Double.parseDouble(yDiff);
} catch (NumberFormatException e) {
zPos = ((Player) sender).getLocation().getZ();
}
}
} else {
try {
xPos = Double.parseDouble(xString);
yPos = Double.parseDouble(yString);
zPos = Double.parseDouble(zString);
} catch (NumberFormatException e) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location"));
return;
}
}
location = new Location(null, xPos, yPos, zPos);
}
World world = null;
if (sender instanceof Player) {
world = ((Player) sender).getWorld();
}
if (args.size() >= 5) {
world = Bukkit.getWorld(args.get(4));
}
if (location == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location"));
return;
}
location.setWorld(world);
if (world == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-world"));
return;
}
boss.spawn(location);
sender.sendMessage(this.getPlugin().getLangYml().getMessage("spawned"));
}
}

View File

@@ -0,0 +1,28 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.CommandHandler;
import com.willfp.eco.core.command.impl.PluginCommand;
import com.willfp.ecobosses.EcoBossesPlugin;
import org.jetbrains.annotations.NotNull;
public class CommandEcobosses extends PluginCommand {
/**
* Instantiate a new executor for /ebdrop.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandEcobosses(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "ecobosses", "ecobosses.command.ecobosses", false);
this.addSubcommand(new CommandReload(plugin))
.addSubcommand(new CommandKillall(plugin))
.addSubcommand(new CommandSpawn(plugin))
.addSubcommand(new CommandBase64(plugin));
}
@Override
public CommandHandler getHandler() {
return (sender, args) -> {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-command"));
};
}
}

View File

@@ -0,0 +1,30 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.CommandHandler;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.bosses.util.BossUtils;
import org.jetbrains.annotations.NotNull;
public class CommandKillall extends Subcommand {
/**
* Instantiate a new executor for /ebspawn.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandKillall(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "killall", "ecobosses.command.killall", false);
}
@Override
public CommandHandler getHandler() {
return (sender, args) -> {
boolean force = false;
if (args.size() == 1) {
force = args.get(0).equalsIgnoreCase("force");
}
sender.sendMessage(this.getPlugin().getLangYml().getMessage("killall").replace("%amount%", String.valueOf(BossUtils.killAllBosses(force))));
};
}
}

View File

@@ -0,0 +1,26 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.CommandHandler;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.ecobosses.EcoBossesPlugin;
import org.jetbrains.annotations.NotNull;
public class CommandReload extends Subcommand {
/**
* Instantiate a new executor for /ebreload.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandReload(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "reload", "ecobosses.command.reload", false);
}
@Override
public CommandHandler getHandler() {
return (sender, args) -> {
this.getPlugin().reload();
this.getPlugin().reload();
sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded"));
};
}
}

View File

@@ -0,0 +1,210 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.CommandHandler;
import com.willfp.eco.core.command.TabCompleteHandler;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.config.updating.ConfigUpdater;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.bosses.EcoBoss;
import com.willfp.ecobosses.bosses.EcoBosses;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class CommandSpawn extends Subcommand {
/**
* The cached names.
*/
private static final List<String> BOSS_NAMES = new ArrayList<>();
/**
* The cached numbers.
*/
private static final List<String> TILDE = Arrays.asList(
"~"
);
/**
* Instantiate a new executor for /ebspawn.
*
* @param plugin The plugin to manage the execution for.
*/
public CommandSpawn(@NotNull final EcoBossesPlugin plugin) {
super(plugin, "spawn", "ecobosses.command.spawn", false);
reload();
}
/**
* Called on reload.
*/
@ConfigUpdater
public static void reload() {
BOSS_NAMES.clear();
BOSS_NAMES.addAll(EcoBosses.values().stream().map(EcoBoss::getName).collect(Collectors.toList()));
}
@Override
public CommandHandler getHandler() {
return (sender, args) -> {
if (args.isEmpty()) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss"));
return;
}
String bossName = args.get(0);
EcoBoss boss = EcoBosses.getByName(bossName.toLowerCase());
if (boss == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-boss"));
return;
}
Location location = null;
if (sender instanceof Player) {
location = ((Player) sender).getLocation();
}
if (args.size() >= 4) {
String xString = args.get(1);
String yString = args.get(2);
String zString = args.get(3);
double xPos;
double yPos;
double zPos;
if (xString.startsWith("~") && sender instanceof Player) {
String xDiff = xString.replace("~", "");
String yDiff = yString.replace("~", "");
String zDiff = zString.replace("~", "");
if (xDiff.isEmpty()) {
xPos = ((Player) sender).getLocation().getX();
} else {
try {
xPos = ((Player) sender).getLocation().getX() + Double.parseDouble(xDiff);
} catch (NumberFormatException e) {
xPos = ((Player) sender).getLocation().getX();
}
}
if (yDiff.isEmpty()) {
yPos = ((Player) sender).getLocation().getY();
} else {
try {
yPos = ((Player) sender).getLocation().getY() + Double.parseDouble(yDiff);
} catch (NumberFormatException e) {
yPos = ((Player) sender).getLocation().getY();
}
}
if (zDiff.isEmpty()) {
zPos = ((Player) sender).getLocation().getZ();
} else {
try {
zPos = ((Player) sender).getLocation().getZ() + Double.parseDouble(yDiff);
} catch (NumberFormatException e) {
zPos = ((Player) sender).getLocation().getZ();
}
}
} else {
try {
xPos = Double.parseDouble(xString);
yPos = Double.parseDouble(yString);
zPos = Double.parseDouble(zString);
} catch (NumberFormatException e) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location"));
return;
}
}
location = new Location(null, xPos, yPos, zPos);
}
World world = null;
if (sender instanceof Player) {
world = ((Player) sender).getWorld();
}
if (args.size() >= 5) {
world = Bukkit.getWorld(args.get(4));
}
if (location == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-location"));
return;
}
location.setWorld(world);
if (world == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-world"));
return;
}
boss.spawn(location);
sender.sendMessage(this.getPlugin().getLangYml().getMessage("spawned"));
};
}
@Override
public TabCompleteHandler getTabCompleter() {
return (sender, args) -> {
List<String> completions = new ArrayList<>();
if (args.isEmpty()) {
// Currently, this case is not ever reached
return new ArrayList<>();
}
if (args.size() == 1) {
StringUtil.copyPartialMatches(args.get(0), BOSS_NAMES, completions);
Collections.sort(completions);
return completions;
}
if (args.size() == 2) {
StringUtil.copyPartialMatches(args.get(1), TILDE, completions);
Collections.sort(completions);
return completions;
}
if (args.size() == 3) {
StringUtil.copyPartialMatches(args.get(2), TILDE, completions);
Collections.sort(completions);
return completions;
}
if (args.size() == 4) {
StringUtil.copyPartialMatches(args.get(3), TILDE, completions);
Collections.sort(completions);
return completions;
}
if (args.size() == 5) {
StringUtil.copyPartialMatches(args.get(4), Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), completions);
Collections.sort(completions);
return completions;
}
return new ArrayList<>(0);
};
}
}

View File

@@ -1,105 +0,0 @@
package com.willfp.ecobosses.commands;
import com.willfp.eco.core.command.AbstractTabCompleter;
import com.willfp.eco.core.config.ConfigUpdater;
import com.willfp.ecobosses.bosses.EcoBoss;
import com.willfp.ecobosses.bosses.EcoBosses;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class TabCompleterEbspawn extends AbstractTabCompleter {
/**
* The cached names.
*/
private static final List<String> BOSS_NAMES = new ArrayList<>();
/**
* The cached numbers.
*/
private static final List<String> TILDE = Arrays.asList(
"~"
);
/**
* Instantiate a new tab-completer for /ebspawn.
*
* @param command Instance of /ebspawn.
*/
public TabCompleterEbspawn(@NotNull final CommandEbspawn command) {
super(command);
reload();
}
/**
* Called on reload.
*/
@ConfigUpdater
public static void reload() {
BOSS_NAMES.clear();
BOSS_NAMES.addAll(EcoBosses.values().stream().map(EcoBoss::getName).collect(Collectors.toList()));
}
/**
* The execution of the tabcompleter.
*
* @param sender The sender of the command.
* @param args The arguments of the command.
* @return A list of tab-completions.
*/
@Override
public List<String> onTab(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
List<String> completions = new ArrayList<>();
if (args.isEmpty()) {
// Currently, this case is not ever reached
return new ArrayList<>();
}
if (args.size() == 1) {
StringUtil.copyPartialMatches(args.get(0), BOSS_NAMES, completions);
Collections.sort(completions);
return completions;
}
if (args.size() == 2) {
StringUtil.copyPartialMatches(args.get(1), TILDE, completions);
Collections.sort(completions);
return completions;
}
if (args.size() == 3) {
StringUtil.copyPartialMatches(args.get(2), TILDE, completions);
Collections.sort(completions);
return completions;
}
if (args.size() == 4) {
StringUtil.copyPartialMatches(args.get(3), TILDE, completions);
Collections.sort(completions);
return completions;
}
if (args.size() == 5) {
StringUtil.copyPartialMatches(args.get(4), Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList()), completions);
Collections.sort(completions);
return completions;
}
return new ArrayList<>(0);
}
}

View File

@@ -1,10 +1,10 @@
package com.willfp.ecobosses.config;
import com.willfp.eco.core.config.ExtendableConfig;
import com.willfp.eco.core.config.yaml.YamlExtendableConfig;
import com.willfp.ecobosses.EcoBossesPlugin;
import org.jetbrains.annotations.NotNull;
public class BaseBossConfig extends ExtendableConfig {
public class BaseBossConfig extends YamlExtendableConfig {
/**
* Create new EcoBoss config.
*

View File

@@ -1,11 +1,11 @@
package com.willfp.ecobosses.config;
import com.willfp.eco.core.config.YamlConfig;
import com.willfp.eco.core.config.yaml.YamlTransientConfig;
import lombok.Getter;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
public class CustomConfig extends YamlConfig {
public class CustomConfig extends YamlTransientConfig {
/**
* The name of the config.
*/

View File

@@ -1,21 +0,0 @@
package com.willfp.ecobosses.util;
import com.willfp.eco.core.proxy.AbstractProxy;
import com.willfp.ecobosses.EcoBossesPlugin;
import com.willfp.ecobosses.proxy.util.ProxyFactory;
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;
@UtilityClass
public class ProxyUtils {
/**
* Get the implementation of a specified proxy.
*
* @param proxyClass The proxy interface.
* @param <T> The type of the proxy.
* @return The proxy implementation.
*/
public @NotNull <T extends AbstractProxy> T getProxy(@NotNull final Class<T> proxyClass) {
return new ProxyFactory<>(EcoBossesPlugin.getInstance(), proxyClass).getProxy();
}
}

View File

@@ -38,7 +38,7 @@ rewards:
# Use %player% as the placeholder for the player name
commands: []
# Get items to add here by copying the console output for /ebdrop
# Get items to add here by copying the console output for /ecobosses base64
# To set the chance for a drop, put <chance>::<base64>
drops: []

View File

@@ -38,7 +38,7 @@ rewards:
# Use %player% as the placeholder for the player name
commands: []
# Get items to add here by copying the console output for /ebdrop
# Get items to add here by copying the console output for /ecobosses base64
# To set the chance for a drop, put <chance>::<base64>
drops: []

View File

@@ -38,7 +38,7 @@ rewards:
# Use %player% as the placeholder for the player name
commands: []
# Get items to add here by copying the console output for /ebdrop
# Get items to add here by copying the console output for /ecobosses base64
# To set the chance for a drop, put <chance>::<base64>
drops: []

View File

@@ -38,7 +38,7 @@ rewards:
# Use %player% as the placeholder for the player name
commands: []
# Get items to add here by copying the console output for /ebdrop
# Get items to add here by copying the console output for /ecobosses base64
# To set the chance for a drop, put <chance>::<base64>
drops: []

View File

@@ -1,6 +1,7 @@
messages:
prefix: "&9&lEcoBosses &f» "
no-permission: "&cYou don't have permission to do this!"
invalid-command: "&cUnknown subcommand!"
not-player: "&cThis command must be run by a player"
reloaded: "Reloaded!"
sent-drop: "Check console for the drop!"

View File

@@ -9,41 +9,41 @@ depend:
- eco
commands:
ebreload:
description: Reloads config
permission: ecobosses.reload
ebdrop:
description: Sends the held item to console to be added as a drop
permission: ecobosses.ebdrop
ebspawn:
description: Spawns a boss
permission: ecobosses.ebspawn
ebkillall:
description: Kill all bosses
permission: ecobosses.killall
ecobosses:
description: Base command
permission: ecobosses.command.ecobosses
permissions:
ecobosses.*:
description: All ecobosses permissions
default: op
children:
ecobosses.reload: true
ecobosses.ebdrop: true
ecobosses.ebspawn: true
ecobosses.killall: true
ecobosses.command.*: true
ecobosses.command.*:
description: All ecobosses commands
default: op
children:
ecobosses.command.ecobosses: true
ecobosses.command.reload: true
ecobosses.command.spawn: true
ecobosses.command.base64: true
ecobosses.reload:
description: Allows reloading the config
ecobosses.command.ecobosses:
description: Allows the use of /ecobosses
default: true
ecobosses.command.base64:
description: Allows the use of /ecobosses base64
default: op
ecobosses.ebdrop:
description: Allows the use of /ebdrop
ecobosses.command.spawn:
description: Allows the use of /ecobosses spawn
default: op
ecobosses.ebspawn:
description: Allows the use of /ebspawn
ecobosses.command.killall:
description: Allows the use of /ecobosses killall
default: op
ecobosses.killall:
description: Allows the use of /ebkillall
ecobosses.command.reload:
description: Allows the use of /ecobosses reload
default: op

View File

@@ -1,75 +0,0 @@
package com.willfp.ecobosses.proxy.util;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.proxy.AbstractProxy;
import com.willfp.eco.core.proxy.ProxyConstants;
import com.willfp.eco.core.proxy.UnsupportedVersionException;
import org.jetbrains.annotations.NotNull;
import java.util.IdentityHashMap;
import java.util.Map;
public class ProxyFactory<T extends AbstractProxy> extends PluginDependent {
/**
* Cached proxy implementations in order to not perform expensive reflective class-finding.
*/
private static final Map<Class<? extends AbstractProxy>, AbstractProxy> CACHE = new IdentityHashMap<>();
/**
* The class of the proxy interface.
*/
private final Class<T> proxyClass;
/**
* Create a new Proxy Factory for a specific type.
*
* @param plugin The plugin to create proxies for.
* @param proxyClass The class of the proxy interface.
*/
public ProxyFactory(@NotNull final EcoPlugin plugin,
@NotNull final Class<T> proxyClass) {
super(plugin);
this.proxyClass = proxyClass;
}
/**
* Get the implementation of a proxy.
*
* @return The proxy implementation.
*/
public @NotNull T getProxy() {
try {
T cachedProxy = attemptCache();
if (cachedProxy != null) {
return cachedProxy;
}
String className = this.getPlugin().getProxyPackage() + "." + ProxyConstants.NMS_VERSION + "." + proxyClass.getSimpleName().replace("Proxy", "");
final Class<?> class2 = Class.forName(className);
Object instance = class2.getConstructor().newInstance();
if (proxyClass.isAssignableFrom(class2) && proxyClass.isInstance(instance)) {
T proxy = proxyClass.cast(instance);
CACHE.put(proxyClass, proxy);
return proxy;
}
} catch (Exception e) {
// If not returned, then throw error
}
throw new UnsupportedVersionException("You're running an unsupported server version: " + ProxyConstants.NMS_VERSION);
}
private T attemptCache() {
Object proxy = CACHE.get(proxyClass);
if (proxy == null) {
return null;
}
if (proxyClass.isInstance(proxy)) {
return proxyClass.cast(proxy);
}
return null;
}
}

View File

@@ -1,2 +1,2 @@
version = 5.0.0
version = 6.0.0
plugin-name = EcoBosses

Binary file not shown.

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored Normal file → Executable file
View File

@@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath

21
gradlew.bat vendored
View File

@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
@@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

6
jitpack.yml Normal file
View File

@@ -0,0 +1,6 @@
jdk: openjdk16
before_install:
- source "$HOME/.sdkman/bin/sdkman-init.sh"
- sdk update
- sdk install java 16.0.1-open
- sdk use java 16.0.1-open

Binary file not shown.

Binary file not shown.

View File

@@ -3,9 +3,9 @@ rootProject.name = 'EcoBosses'
// Core
include ':eco-core'
include ':eco-core:core-nms'
include ':eco-core:core-nms:v1_15_R1'
include ':eco-core:core-nms:v1_16_R1'
include ':eco-core:core-nms:v1_16_R2'
include ':eco-core:core-nms:v1_16_R3'
include ':eco-core:core-nms:v1_17_R1'
include ':eco-core:core-proxy'
include ':eco-core:core-plugin'