mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-20 07:29:21 +00:00
Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
746ab5d2b5 | ||
|
|
3f6f13a61f | ||
|
|
fd82811d2c | ||
|
|
950bfab5f3 | ||
|
|
3e4d3af215 | ||
|
|
9486903895 | ||
|
|
da7ee14787 | ||
|
|
36fa2e5138 | ||
|
|
31e3cb993e | ||
|
|
c7ea383115 | ||
|
|
1d800a52de | ||
|
|
1a78db6b07 | ||
|
|
9ab765edb6 | ||
|
|
c8054c209a | ||
|
|
8db8cca1c9 | ||
|
|
413d86c2d3 | ||
|
|
a335b5b52e | ||
|
|
d5dced49b3 | ||
|
|
4ac870f5c3 | ||
|
|
1a364615a3 | ||
|
|
890b034d4a | ||
|
|
22f59c7c5c | ||
|
|
8bc296f2f8 | ||
|
|
5fe7eb1318 | ||
|
|
36a3c7f70d | ||
|
|
6b3ff0c88d | ||
|
|
3e384dbeea | ||
|
|
b16444799a | ||
|
|
98faf823ba | ||
|
|
87095166d0 | ||
|
|
b4510233aa | ||
|
|
a31b0210ab | ||
|
|
3a480da078 | ||
|
|
efc56e1763 | ||
|
|
64f35b6338 | ||
|
|
ab6e990f0b | ||
|
|
fa8c5da31a | ||
|
|
730c259d19 | ||
|
|
7fbc39d4d1 | ||
|
|
5d69d0faee | ||
|
|
21ed4b09fd | ||
|
|
9eb3619c35 | ||
|
|
9abbfbf363 | ||
|
|
12abdcbf5e | ||
|
|
11d8d8d13f | ||
|
|
0932e68461 | ||
|
|
6975daaeaf | ||
|
|
663104bda0 | ||
|
|
83805215e9 | ||
|
|
0b1f4d4f6d | ||
|
|
86e414e108 |
23
build.gradle
23
build.gradle
@@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java-library'
|
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 'maven-publish'
|
||||||
id 'java'
|
id 'java'
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,6 @@ allprojects {
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
jcenter()
|
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://jitpack.io' }
|
||||||
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
||||||
@@ -47,15 +46,15 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'com.willfp:eco:5.0.0'
|
compileOnly 'com.willfp:eco:6.0.0'
|
||||||
|
|
||||||
compileOnly 'org.jetbrains:annotations:19.0.0'
|
compileOnly 'org.jetbrains:annotations:19.0.0'
|
||||||
|
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.16'
|
compileOnly 'org.projectlombok:lombok:1.18.20'
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.16'
|
annotationProcessor 'org.projectlombok:lombok:1.18.20'
|
||||||
|
|
||||||
testCompileOnly 'org.projectlombok:lombok:1.18.16'
|
testCompileOnly 'org.projectlombok:lombok:1.18.20'
|
||||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.16'
|
testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
@@ -92,16 +91,8 @@ jar {
|
|||||||
group = 'com.willfp'
|
group = 'com.willfp'
|
||||||
archivesBaseName = project.name
|
archivesBaseName = project.name
|
||||||
version = findProperty("version")
|
version = findProperty("version")
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
java.sourceCompatibility = JavaVersion.VERSION_16
|
||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
build.dependsOn shadowJar
|
build.dependsOn shadowJar
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
maven(MavenPublication) {
|
|
||||||
from(components.java)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
6
eco-core/core-nms/v1_17_R1/build.gradle
Normal file
6
eco-core/core-nms/v1_17_R1/build.gradle
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
group 'com.willfp'
|
||||||
|
version rootProject.version
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,26 +1,19 @@
|
|||||||
package com.willfp.ecobosses;
|
package com.willfp.ecobosses;
|
||||||
|
|
||||||
import com.willfp.eco.core.AbstractPacketAdapter;
|
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.command.AbstractCommand;
|
import com.willfp.eco.core.command.impl.PluginCommand;
|
||||||
import com.willfp.eco.core.integrations.IntegrationLoader;
|
import com.willfp.ecobosses.bosses.listeners.AttackListeners;
|
||||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
import com.willfp.ecobosses.bosses.listeners.AutoSpawnTimer;
|
||||||
import com.willfp.ecobosses.bosses.EcoBosses;
|
import com.willfp.ecobosses.bosses.listeners.DeathListeners;
|
||||||
import com.willfp.ecobosses.bosses.listeners.*;
|
import com.willfp.ecobosses.bosses.listeners.PassiveListeners;
|
||||||
import com.willfp.ecobosses.commands.CommandEbdrop;
|
import com.willfp.ecobosses.bosses.listeners.SpawnListeners;
|
||||||
import com.willfp.ecobosses.commands.CommandEbkillall;
|
import com.willfp.ecobosses.bosses.util.BossUtils;
|
||||||
import com.willfp.ecobosses.commands.CommandEbreload;
|
import com.willfp.ecobosses.commands.CommandEcobosses;
|
||||||
import com.willfp.ecobosses.commands.CommandEbspawn;
|
|
||||||
import com.willfp.ecobosses.commands.TabCompleterEbspawn;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class EcoBossesPlugin extends EcoPlugin {
|
public class EcoBossesPlugin extends EcoPlugin {
|
||||||
@@ -34,109 +27,29 @@ public class EcoBossesPlugin extends EcoPlugin {
|
|||||||
* Internal constructor called by bukkit on plugin load.
|
* Internal constructor called by bukkit on plugin load.
|
||||||
*/
|
*/
|
||||||
public EcoBossesPlugin() {
|
public EcoBossesPlugin() {
|
||||||
super("EcoBosses", 86576, 10635, "com.willfp.ecobosses.proxy", "&9");
|
super(86576, 10635, "com.willfp.ecobosses.proxy", "&9");
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Code executed on plugin enable.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void enable() {
|
protected void handleDisable() {
|
||||||
this.getExtensionLoader().loadExtensions();
|
BossUtils.killAllBosses();
|
||||||
|
}
|
||||||
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()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleReload() {
|
||||||
this.getScheduler().runTimer(new AutoSpawnTimer(), 5, 1);
|
this.getScheduler().runTimer(new AutoSpawnTimer(), 5, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Code executed on plugin disable.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void disable() {
|
protected List<PluginCommand> loadPluginCommands() {
|
||||||
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() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new CommandEbreload(this),
|
new CommandEcobosses(this)
|
||||||
new CommandEbdrop(this),
|
|
||||||
new CommandEbspawn(this),
|
|
||||||
new CommandEbkillall(this)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Packet Adapters for enchant display.
|
|
||||||
*
|
|
||||||
* @return A list of packet adapters.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public List<AbstractPacketAdapter> getPacketAdapters() {
|
protected List<Listener> loadListeners() {
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* EcoEnchants-specific listeners.
|
|
||||||
*
|
|
||||||
* @return A list of all listeners.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<Listener> getListeners() {
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new AttackListeners(this),
|
new AttackListeners(this),
|
||||||
new DeathListeners(this),
|
new DeathListeners(this),
|
||||||
@@ -144,12 +57,4 @@ public class EcoBossesPlugin extends EcoPlugin {
|
|||||||
new PassiveListeners(this)
|
new PassiveListeners(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Class<?>> getUpdatableClasses() {
|
|
||||||
return Arrays.asList(
|
|
||||||
EcoBosses.class,
|
|
||||||
TabCompleterEbspawn.class
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,17 +3,26 @@ package com.willfp.ecobosses.bosses;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.PluginDependent;
|
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.core.tuples.Pair;
|
||||||
import com.willfp.eco.util.StringUtils;
|
import com.willfp.eco.util.StringUtils;
|
||||||
import com.willfp.ecobosses.bosses.effects.Effect;
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
import com.willfp.ecobosses.bosses.effects.Effects;
|
import com.willfp.ecobosses.bosses.effects.Effects;
|
||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
|
import com.willfp.ecobosses.bosses.util.bosstype.BossEntityUtils;
|
||||||
import com.willfp.ecobosses.bosses.util.bosstype.BossType;
|
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.AccessLevel;
|
||||||
import lombok.Getter;
|
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.BarColor;
|
||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
@@ -22,11 +31,18 @@ import org.bukkit.entity.LivingEntity;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class EcoBoss extends PluginDependent {
|
public class EcoBoss extends PluginDependent<EcoPlugin> {
|
||||||
/**
|
/**
|
||||||
* The name of the boss.
|
* The name of the boss.
|
||||||
*/
|
*/
|
||||||
@@ -192,7 +208,7 @@ public class EcoBoss extends PluginDependent {
|
|||||||
/**
|
/**
|
||||||
* The currently living bosses of this type.
|
* The currently living bosses of this type.
|
||||||
*/
|
*/
|
||||||
private final Map<UUID, LivingEcoBoss> livingBosses;
|
private final Map<LivingEntity, LivingEcoBoss> livingBosses;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The effect names and arguments.
|
* The effect names and arguments.
|
||||||
@@ -361,18 +377,18 @@ public class EcoBoss extends PluginDependent {
|
|||||||
// Messages
|
// Messages
|
||||||
this.spawnMessages = new ArrayList<>();
|
this.spawnMessages = new ArrayList<>();
|
||||||
for (String string : this.getConfig().getStrings("broadcast.spawn")) {
|
for (String string : this.getConfig().getStrings("broadcast.spawn")) {
|
||||||
this.spawnMessages.add(StringUtils.translate(string));
|
this.spawnMessages.add(StringUtils.format(string));
|
||||||
}
|
}
|
||||||
this.deathMessages = new ArrayList<>();
|
this.deathMessages = new ArrayList<>();
|
||||||
for (String string : this.getConfig().getStrings("broadcast.death")) {
|
for (String string : this.getConfig().getStrings("broadcast.death")) {
|
||||||
this.deathMessages.add(StringUtils.translate(string));
|
this.deathMessages.add(StringUtils.format(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top Damager Commands
|
// Top Damager Commands
|
||||||
this.topDamagerCommands = new HashMap<>();
|
this.topDamagerCommands = new HashMap<>();
|
||||||
for (int i = 1; i <= 3; i++) {
|
for (int i = 1; i <= 3; i++) {
|
||||||
this.topDamagerCommands.put(i, new ArrayList<>());
|
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;
|
double chance = 100;
|
||||||
if (string.contains("::")) {
|
if (string.contains("::")) {
|
||||||
String[] split = string.split("::");
|
String[] split = string.split("::");
|
||||||
@@ -388,7 +404,7 @@ public class EcoBoss extends PluginDependent {
|
|||||||
// Nearby Rewards
|
// Nearby Rewards
|
||||||
this.nearbyRadius = this.getConfig().getDouble("rewards.nearby-player-commands.radius");
|
this.nearbyRadius = this.getConfig().getDouble("rewards.nearby-player-commands.radius");
|
||||||
this.nearbyPlayersCommands = new HashMap<>();
|
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;
|
double chance = 100;
|
||||||
if (string.contains("::")) {
|
if (string.contains("::")) {
|
||||||
String[] split = string.split("::");
|
String[] split = string.split("::");
|
||||||
@@ -442,8 +458,8 @@ public class EcoBoss extends PluginDependent {
|
|||||||
*
|
*
|
||||||
* @return The effects.
|
* @return The effects.
|
||||||
*/
|
*/
|
||||||
public Set<Effect> createEffects() {
|
public List<Effect> createEffects() {
|
||||||
Set<Effect> effects = new HashSet<>();
|
List<Effect> effects = new ArrayList<>();
|
||||||
this.effectNames.forEach((string, args) -> {
|
this.effectNames.forEach((string, args) -> {
|
||||||
effects.add(Effects.getEffect(string, args));
|
effects.add(Effects.getEffect(string, args));
|
||||||
});
|
});
|
||||||
@@ -457,8 +473,10 @@ public class EcoBoss extends PluginDependent {
|
|||||||
* @param location The location.
|
* @param location The location.
|
||||||
*/
|
*/
|
||||||
public void spawn(@NotNull final Location location) {
|
public void spawn(@NotNull final Location location) {
|
||||||
|
location.getChunk().load();
|
||||||
|
|
||||||
LivingEntity entity = bossType.spawnBossEntity(location);
|
LivingEntity entity = bossType.spawnBossEntity(location);
|
||||||
this.livingBosses.put(entity.getUniqueId(), new LivingEcoBoss(
|
this.livingBosses.put(entity, new LivingEcoBoss(
|
||||||
this.getPlugin(),
|
this.getPlugin(),
|
||||||
entity,
|
entity,
|
||||||
this
|
this
|
||||||
@@ -473,16 +491,16 @@ public class EcoBoss extends PluginDependent {
|
|||||||
* @return The living boss, or null if not a boss.
|
* @return The living boss, or null if not a boss.
|
||||||
*/
|
*/
|
||||||
public LivingEcoBoss getLivingBoss(@NotNull final LivingEntity entity) {
|
public LivingEcoBoss getLivingBoss(@NotNull final LivingEntity entity) {
|
||||||
return this.livingBosses.get(entity.getUniqueId());
|
return this.livingBosses.get(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove living boss.
|
* Remove living boss.
|
||||||
*
|
*
|
||||||
* @param uuid The entity UUID.
|
* @param entity The entity.
|
||||||
*/
|
*/
|
||||||
public void removeLivingBoss(@NotNull final UUID uuid) {
|
public void removeLivingBoss(@Nullable final LivingEntity entity) {
|
||||||
this.livingBosses.remove(uuid);
|
this.livingBosses.remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -490,7 +508,7 @@ public class EcoBoss extends PluginDependent {
|
|||||||
*
|
*
|
||||||
* @return The living bosses.
|
* @return The living bosses.
|
||||||
*/
|
*/
|
||||||
public Map<UUID, LivingEcoBoss> getLivingBosses() {
|
public Map<LivingEntity, LivingEcoBoss> getLivingBosses() {
|
||||||
return ImmutableMap.copyOf(this.livingBosses);
|
return ImmutableMap.copyOf(this.livingBosses);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,11 +518,10 @@ public class EcoBoss extends PluginDependent {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(o instanceof EcoBoss)) {
|
if (!(o instanceof EcoBoss boss)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
EcoBoss boss = (EcoBoss) o;
|
|
||||||
return this.getName().equals(boss.getName());
|
return this.getName().equals(boss.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.willfp.ecobosses.bosses;
|
|||||||
import com.google.common.collect.BiMap;
|
import com.google.common.collect.BiMap;
|
||||||
import com.google.common.collect.HashBiMap;
|
import com.google.common.collect.HashBiMap;
|
||||||
import com.google.common.collect.ImmutableList;
|
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.EcoBossesPlugin;
|
||||||
import com.willfp.ecobosses.config.BaseBossConfig;
|
import com.willfp.ecobosses.config.BaseBossConfig;
|
||||||
import com.willfp.ecobosses.config.CustomConfig;
|
import com.willfp.ecobosses.config.CustomConfig;
|
||||||
|
|||||||
@@ -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.HealthPlaceholderTicker;
|
||||||
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
|
import com.willfp.ecobosses.bosses.tick.tickers.TargetTicker;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
import com.willfp.ecobosses.bosses.util.obj.OptionedSound;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeInstance;
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
@@ -21,15 +22,16 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.ArrayList;
|
||||||
import java.util.Set;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
public class LivingEcoBoss extends PluginDependent {
|
public class LivingEcoBoss extends PluginDependent<EcoPlugin> {
|
||||||
/**
|
/**
|
||||||
* The entity.
|
* The entity.
|
||||||
*/
|
*/
|
||||||
private final LivingEntity entity;
|
@Getter
|
||||||
|
private LivingEntity entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The boss.
|
* The boss.
|
||||||
@@ -39,12 +41,12 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
/**
|
/**
|
||||||
* The boss tickers.
|
* The boss tickers.
|
||||||
*/
|
*/
|
||||||
private final Set<BossTicker> tickers;
|
private final List<BossTicker> tickers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The effects.
|
* The effects.
|
||||||
*/
|
*/
|
||||||
private final Set<Effect> effects;
|
private final List<Effect> effects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new living EcoBoss.
|
* Create new living EcoBoss.
|
||||||
@@ -63,7 +65,7 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
this.onSpawn();
|
this.onSpawn();
|
||||||
|
|
||||||
// Tickers
|
// Tickers
|
||||||
this.tickers = new HashSet<>();
|
this.tickers = new ArrayList<>();
|
||||||
this.tickers.add(new HealthPlaceholderTicker());
|
this.tickers.add(new HealthPlaceholderTicker());
|
||||||
this.tickers.add(new TargetTicker(boss.getTargetMode(), boss.getTargetDistance()));
|
this.tickers.add(new TargetTicker(boss.getTargetMode(), boss.getTargetDistance()));
|
||||||
if (boss.isBossbarEnabled()) {
|
if (boss.isBossbarEnabled()) {
|
||||||
@@ -72,8 +74,8 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
Bukkit.getServer().createBossBar(
|
Bukkit.getServer().createBossBar(
|
||||||
plugin.getNamespacedKeyFactory().create("boss_" + NumberUtils.randInt(0, 1000000)),
|
plugin.getNamespacedKeyFactory().create("boss_" + NumberUtils.randInt(0, 1000000)),
|
||||||
entity.getCustomName(),
|
entity.getCustomName(),
|
||||||
boss.getBossbarProperties().getColor(),
|
boss.getBossbarProperties().color(),
|
||||||
boss.getBossbarProperties().getStyle(),
|
boss.getBossbarProperties().style(),
|
||||||
(BarFlag) null
|
(BarFlag) null
|
||||||
),
|
),
|
||||||
this.getPlugin().getConfigYml().getInt("bossbar-radius")
|
this.getPlugin().getConfigYml().getInt("bossbar-radius")
|
||||||
@@ -82,7 +84,7 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Effects
|
// Effects
|
||||||
this.effects = new HashSet<>();
|
this.effects = new ArrayList<>();
|
||||||
this.effects.addAll(boss.createEffects());
|
this.effects.addAll(boss.createEffects());
|
||||||
|
|
||||||
AtomicLong currentTick = new AtomicLong(0);
|
AtomicLong currentTick = new AtomicLong(0);
|
||||||
@@ -92,6 +94,7 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
private void onSpawn() {
|
private void onSpawn() {
|
||||||
entity.getPersistentDataContainer().set(this.getPlugin().getNamespacedKeyFactory().create("boss"), PersistentDataType.STRING, boss.getName());
|
entity.getPersistentDataContainer().set(this.getPlugin().getNamespacedKeyFactory().create("boss"), PersistentDataType.STRING, boss.getName());
|
||||||
entity.setPersistent(true);
|
entity.setPersistent(true);
|
||||||
|
entity.setRemoveWhenFarAway(false);
|
||||||
|
|
||||||
entity.setCustomName(boss.getDisplayName());
|
entity.setCustomName(boss.getDisplayName());
|
||||||
entity.setCustomNameVisible(true);
|
entity.setCustomNameVisible(true);
|
||||||
@@ -115,7 +118,7 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
attackDamage.setBaseValue(boss.getAttackDamage());
|
attackDamage.setBaseValue(boss.getAttackDamage());
|
||||||
|
|
||||||
for (OptionedSound sound : boss.getSpawnSounds()) {
|
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()) {
|
for (String spawnMessage : boss.getSpawnMessages()) {
|
||||||
@@ -129,21 +132,23 @@ public class LivingEcoBoss extends PluginDependent {
|
|||||||
|
|
||||||
private void tick(final long tick,
|
private void tick(final long tick,
|
||||||
@NotNull final RunnableTask runnable) {
|
@NotNull final RunnableTask runnable) {
|
||||||
for (BossTicker ticker : tickers) {
|
if (entity == null || entity.isDead()) {
|
||||||
ticker.tick(boss, entity, tick);
|
|
||||||
}
|
|
||||||
for (Effect effect : effects) {
|
|
||||||
effect.tick(boss, entity, tick);
|
|
||||||
}
|
|
||||||
if (entity.isDead()) {
|
|
||||||
for (BossTicker ticker : tickers) {
|
for (BossTicker ticker : tickers) {
|
||||||
ticker.onDeath(boss, entity, tick);
|
ticker.onDeath(boss, entity, tick);
|
||||||
}
|
}
|
||||||
for (Effect effect : effects) {
|
for (Effect effect : effects) {
|
||||||
effect.onDeath(boss, entity, tick);
|
effect.onDeath(boss, entity, tick);
|
||||||
}
|
}
|
||||||
boss.removeLivingBoss(entity.getUniqueId());
|
boss.removeLivingBoss(entity);
|
||||||
runnable.cancel();
|
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) {
|
public void handleAttack(@NotNull final Player player) {
|
||||||
for (OptionedSound sound : boss.getInjureSounds()) {
|
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) {
|
for (Effect effect : effects) {
|
||||||
|
|||||||
@@ -7,8 +7,10 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public abstract class Effect implements BossTicker {
|
public abstract class Effect implements BossTicker {
|
||||||
/**
|
/**
|
||||||
@@ -79,8 +81,24 @@ public abstract class Effect implements BossTicker {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDeath(@NotNull final EcoBoss boss,
|
public void onDeath(@NotNull final EcoBoss boss,
|
||||||
@NotNull final LivingEntity entity,
|
@Nullable final LivingEntity entity,
|
||||||
final long tick) {
|
final long tick) {
|
||||||
// Override when needed.
|
// 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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class EffectSummon extends Effect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (OptionedSound sound : boss.getSummonSounds()) {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class AttackListeners extends PluginDependent implements Listener {
|
public class AttackListeners extends PluginDependent<EcoPlugin> implements Listener {
|
||||||
/**
|
/**
|
||||||
* Create new attack listeners.
|
* Create new attack listeners.
|
||||||
*
|
*
|
||||||
@@ -38,21 +38,11 @@ public class AttackListeners extends PluginDependent implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onAttackBoss(@NotNull final EntityDamageByEntityEvent event) {
|
public void onAttackBoss(@NotNull final EntityDamageByEntityEvent event) {
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity entity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
Player player = BossUtils.getPlayerFromEntity(event.getDamager());
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return;
|
return;
|
||||||
@@ -66,6 +56,8 @@ public class AttackListeners extends PluginDependent implements Listener {
|
|||||||
|
|
||||||
LivingEcoBoss livingEcoBoss = boss.getLivingBoss(entity);
|
LivingEcoBoss livingEcoBoss = boss.getLivingBoss(entity);
|
||||||
|
|
||||||
|
BossUtils.warnIfNull(livingEcoBoss);
|
||||||
|
|
||||||
if (boss.isAttackOnInjure()) {
|
if (boss.isAttackOnInjure()) {
|
||||||
livingEcoBoss.handleAttack(player);
|
livingEcoBoss.handleAttack(player);
|
||||||
}
|
}
|
||||||
@@ -78,28 +70,16 @@ public class AttackListeners extends PluginDependent implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||||
public void topDamageTracker(@NotNull final EntityDamageByEntityEvent event) {
|
public void topDamageTracker(@NotNull final EntityDamageByEntityEvent event) {
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity entity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
Player player = BossUtils.getPlayerFromEntity(event.getDamager());
|
||||||
|
|
||||||
Player temp = null;
|
if (player == 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) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = temp;
|
|
||||||
|
|
||||||
EcoBoss boss = BossUtils.getBoss(entity);
|
EcoBoss boss = BossUtils.getBoss(entity);
|
||||||
|
|
||||||
if (boss == null) {
|
if (boss == null) {
|
||||||
@@ -110,11 +90,11 @@ public class AttackListeners extends PluginDependent implements Listener {
|
|||||||
|
|
||||||
double playerDamage;
|
double playerDamage;
|
||||||
|
|
||||||
Optional<DamagerProperty> damager = topDamagers.stream().filter(damagerProperty -> damagerProperty.getPlayerUUID().equals(player.getUniqueId())).findFirst();
|
Optional<DamagerProperty> damager = topDamagers.stream().filter(damagerProperty -> damagerProperty.playerUUID().equals(player.getUniqueId())).findFirst();
|
||||||
playerDamage = damager.map(DamagerProperty::getDamage).orElse(0.0);
|
playerDamage = damager.map(DamagerProperty::damage).orElse(0.0);
|
||||||
|
|
||||||
playerDamage += event.getFinalDamage();
|
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));
|
topDamagers.add(new DamagerProperty(player.getUniqueId(), playerDamage));
|
||||||
|
|
||||||
entity.removeMetadata("ecobosses-top-damagers", this.getPlugin());
|
entity.removeMetadata("ecobosses-top-damagers", this.getPlugin());
|
||||||
@@ -128,18 +108,14 @@ public class AttackListeners extends PluginDependent implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onAttackPlayer(@NotNull final EntityDamageByEntityEvent event) {
|
public void onAttackPlayer(@NotNull final EntityDamageByEntityEvent event) {
|
||||||
if (!(event.getEntity() instanceof Player)) {
|
if (!(event.getEntity() instanceof Player player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(event.getDamager() instanceof LivingEntity)) {
|
if (!(event.getDamager() instanceof LivingEntity entity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) event.getDamager();
|
|
||||||
|
|
||||||
Player player = (Player) event.getEntity();
|
|
||||||
|
|
||||||
EcoBoss boss = BossUtils.getBoss(entity);
|
EcoBoss boss = BossUtils.getBoss(entity);
|
||||||
|
|
||||||
if (boss == null) {
|
if (boss == null) {
|
||||||
@@ -148,6 +124,8 @@ public class AttackListeners extends PluginDependent implements Listener {
|
|||||||
|
|
||||||
LivingEcoBoss livingEcoBoss = boss.getLivingBoss(entity);
|
LivingEcoBoss livingEcoBoss = boss.getLivingBoss(entity);
|
||||||
|
|
||||||
|
BossUtils.warnIfNull(livingEcoBoss);
|
||||||
|
|
||||||
livingEcoBoss.handleAttack(player);
|
livingEcoBoss.handleAttack(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,12 +136,10 @@ public class AttackListeners extends PluginDependent implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
||||||
public void defenceListener(@NotNull final EntityDamageEvent event) {
|
public void defenceListener(@NotNull final EntityDamageEvent event) {
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity entity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
|
||||||
|
|
||||||
EcoBoss boss = BossUtils.getBoss(entity);
|
EcoBoss boss = BossUtils.getBoss(entity);
|
||||||
|
|
||||||
if (boss == null) {
|
if (boss == null) {
|
||||||
@@ -172,22 +148,22 @@ public class AttackListeners extends PluginDependent implements Listener {
|
|||||||
|
|
||||||
ImmunityOptions immunities = boss.getImmunityOptions();
|
ImmunityOptions immunities = boss.getImmunityOptions();
|
||||||
|
|
||||||
if (immunities.isImmuneToFire()
|
if (immunities.immuneToFire()
|
||||||
&& (event.getCause() == EntityDamageEvent.DamageCause.FIRE
|
&& (event.getCause() == EntityDamageEvent.DamageCause.FIRE
|
||||||
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK
|
|| event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK
|
||||||
|| event.getCause() == EntityDamageEvent.DamageCause.HOT_FLOOR)) {
|
|| event.getCause() == EntityDamageEvent.DamageCause.HOT_FLOOR)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (immunities.isImmuneToSuffocation()&& event.getCause() == EntityDamageEvent.DamageCause.SUFFOCATION) {
|
if (immunities.immuneToSuffocation()&& event.getCause() == EntityDamageEvent.DamageCause.SUFFOCATION) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (immunities.isImmuneToDrowning() && event.getCause() == EntityDamageEvent.DamageCause.DROWNING) {
|
if (immunities.immuneToDrowning() && event.getCause() == EntityDamageEvent.DamageCause.DROWNING) {
|
||||||
event.setCancelled(true);
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (immunities.isImmuneToProjectiles() && (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE)) {
|
if (immunities.immuneToProjectiles() && (event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,15 @@ package com.willfp.ecobosses.bosses.listeners;
|
|||||||
import com.willfp.eco.util.NumberUtils;
|
import com.willfp.eco.util.NumberUtils;
|
||||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
import com.willfp.ecobosses.bosses.EcoBosses;
|
import com.willfp.ecobosses.bosses.EcoBosses;
|
||||||
|
import com.willfp.ecobosses.bosses.util.BossUtils;
|
||||||
import org.bukkit.Location;
|
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 {
|
public class AutoSpawnTimer implements Runnable {
|
||||||
private int tick = 0;
|
private int tick = 0;
|
||||||
@@ -21,8 +29,24 @@ public class AutoSpawnTimer implements Runnable {
|
|||||||
continue;
|
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) {
|
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);
|
boss.spawn(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DeathListeners extends PluginDependent implements Listener {
|
public class DeathListeners extends PluginDependent<EcoPlugin> implements Listener {
|
||||||
/**
|
/**
|
||||||
* Create new death listeners.
|
* Create new death listeners.
|
||||||
*
|
*
|
||||||
@@ -52,7 +52,7 @@ public class DeathListeners extends PluginDependent implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (OptionedSound sound : boss.getDeathSounds()) {
|
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 na = this.getPlugin().getLangYml().getString("na");
|
||||||
|
|
||||||
String topDamager = top == null ? na : Bukkit.getPlayer(top.getPlayerUUID()).getDisplayName();
|
String topDamager = top == null ? na : Bukkit.getPlayer(top.playerUUID()).getDisplayName();
|
||||||
String topDamage = top == null ? na : StringUtils.internalToString(top.getDamage());
|
String topDamage = top == null ? na : StringUtils.internalToString(top.damage());
|
||||||
|
|
||||||
String secondDamager = second == null ? na : Bukkit.getPlayer(second.getPlayerUUID()).getDisplayName();
|
String secondDamager = second == null ? na : Bukkit.getPlayer(second.playerUUID()).getDisplayName();
|
||||||
String secondDamage = second == null ? na : StringUtils.internalToString(second.getDamage());
|
String secondDamage = second == null ? na : StringUtils.internalToString(second.damage());
|
||||||
|
|
||||||
String thirdDamager = third == null ? na : Bukkit.getPlayer(third.getPlayerUUID()).getDisplayName();
|
String thirdDamager = third == null ? na : Bukkit.getPlayer(third.playerUUID()).getDisplayName();
|
||||||
String thirdDamage = third == null ? na : StringUtils.internalToString(third.getDamage());
|
String thirdDamage = third == null ? na : StringUtils.internalToString(third.damage());
|
||||||
|
|
||||||
for (String spawnMessage : boss.getDeathMessages()) {
|
for (String spawnMessage : boss.getDeathMessages()) {
|
||||||
Bukkit.broadcastMessage(spawnMessage
|
Bukkit.broadcastMessage(spawnMessage
|
||||||
@@ -114,17 +114,17 @@ public class DeathListeners extends PluginDependent implements Listener {
|
|||||||
for (Pair<Double, String> pair : topDamagerCommands) {
|
for (Pair<Double, String> pair : topDamagerCommands) {
|
||||||
if (top != null && i == 1) {
|
if (top != null && i == 1) {
|
||||||
if (NumberUtils.randFloat(0, 100) < pair.getFirst()) {
|
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 (second != null && i == 2) {
|
||||||
if (NumberUtils.randFloat(0, 100) < pair.getFirst()) {
|
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 (third != null && i == 3) {
|
||||||
if (NumberUtils.randFloat(0, 100) < pair.getFirst()) {
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.spigotmc.event.entity.EntityMountEvent;
|
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.
|
* Create new attack listeners.
|
||||||
*
|
*
|
||||||
@@ -29,7 +29,7 @@ public class PassiveListeners extends PluginDependent implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onAttackBoss(@NotNull final EntityMountEvent event) {
|
public void onAttackBoss(@NotNull final EntityMountEvent event) {
|
||||||
if (!(event.getEntity() instanceof LivingEntity)) {
|
if (!(event.getEntity() instanceof LivingEntity entity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +37,6 @@ public class PassiveListeners extends PluginDependent implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LivingEntity entity = (LivingEntity) event.getEntity();
|
|
||||||
|
|
||||||
EcoBoss boss = BossUtils.getBoss(entity);
|
EcoBoss boss = BossUtils.getBoss(entity);
|
||||||
|
|
||||||
if (boss == null) {
|
if (boss == null) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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.
|
* Create new spawn listeners and link them to a plugin.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.willfp.ecobosses.bosses.tick;
|
|||||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public interface BossTicker {
|
public interface BossTicker {
|
||||||
/**
|
/**
|
||||||
@@ -24,7 +25,7 @@ public interface BossTicker {
|
|||||||
* @param tick The current tick: counts up from zero.
|
* @param tick The current tick: counts up from zero.
|
||||||
*/
|
*/
|
||||||
default void onDeath(@NotNull EcoBoss boss,
|
default void onDeath(@NotNull EcoBoss boss,
|
||||||
@NotNull LivingEntity entity,
|
@Nullable LivingEntity entity,
|
||||||
long tick) {
|
long tick) {
|
||||||
// Can be overridden when needed.
|
// Can be overridden when needed.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,11 +2,14 @@ package com.willfp.ecobosses.bosses.tick.tickers;
|
|||||||
|
|
||||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
import com.willfp.ecobosses.bosses.tick.BossTicker;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.boss.BossBar;
|
import org.bukkit.boss.BossBar;
|
||||||
|
import org.bukkit.boss.KeyedBossBar;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class BossBarTicker implements BossTicker {
|
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());
|
bossBar.setProgress(entity.getHealth() / entity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||||
|
|
||||||
if (tick % 40 == 0) {
|
if (tick % 40 == 0) {
|
||||||
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
bossBar.removeAll();
|
||||||
entity.getNearbyEntities(radius, radius, radius).forEach(entity1 -> {
|
entity.getNearbyEntities(radius, radius, radius).forEach(entity1 -> {
|
||||||
if (entity1 instanceof Player) {
|
if (entity1 instanceof Player) {
|
||||||
bossBar.addPlayer((Player) entity1);
|
bossBar.addPlayer((Player) entity1);
|
||||||
@@ -49,9 +52,10 @@ public class BossBarTicker implements BossTicker {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeath(@NotNull final EcoBoss boss,
|
public void onDeath(@NotNull final EcoBoss boss,
|
||||||
@NotNull final LivingEntity entity,
|
@Nullable final LivingEntity entity,
|
||||||
final long tick) {
|
final long tick) {
|
||||||
bossBar.getPlayers().forEach(bossBar::removePlayer);
|
bossBar.removeAll();
|
||||||
bossBar.setVisible(false);
|
bossBar.setVisible(false);
|
||||||
|
Bukkit.removeBossBar(((KeyedBossBar) bossBar).getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,17 @@ package com.willfp.ecobosses.bosses.util;
|
|||||||
import com.willfp.ecobosses.EcoBossesPlugin;
|
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||||
import com.willfp.ecobosses.bosses.EcoBoss;
|
import com.willfp.ecobosses.bosses.EcoBoss;
|
||||||
import com.willfp.ecobosses.bosses.EcoBosses;
|
import com.willfp.ecobosses.bosses.EcoBosses;
|
||||||
|
import com.willfp.ecobosses.bosses.LivingEcoBoss;
|
||||||
import com.willfp.ecobosses.bosses.util.obj.DamagerProperty;
|
import com.willfp.ecobosses.bosses.util.obj.DamagerProperty;
|
||||||
import lombok.experimental.UtilityClass;
|
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.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@@ -63,9 +71,114 @@ public class BossUtils {
|
|||||||
}
|
}
|
||||||
assert topDamagers != null;
|
assert topDamagers != null;
|
||||||
|
|
||||||
topDamagers.sort(Comparator.comparingDouble(DamagerProperty::getDamage));
|
topDamagers.sort(Comparator.comparingDouble(DamagerProperty::damage));
|
||||||
Collections.reverse(topDamagers);
|
Collections.reverse(topDamagers);
|
||||||
|
|
||||||
return 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!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.bosstype;
|
package com.willfp.ecobosses.bosses.util.bosstype;
|
||||||
|
|
||||||
|
import com.willfp.ecobosses.EcoBossesPlugin;
|
||||||
import com.willfp.ecobosses.proxy.proxies.CustomEntitySpawnerProxy;
|
import com.willfp.ecobosses.proxy.proxies.CustomEntitySpawnerProxy;
|
||||||
import com.willfp.ecobosses.proxy.util.CustomEntity;
|
import com.willfp.ecobosses.proxy.util.CustomEntity;
|
||||||
import com.willfp.ecobosses.util.ProxyUtils;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -24,6 +24,6 @@ class CustomBossType extends BossType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LivingEntity spawnBossEntity(@NotNull final Location location) {
|
public LivingEntity spawnBossEntity(@NotNull final Location location) {
|
||||||
return ProxyUtils.getProxy(CustomEntitySpawnerProxy.class).spawnCustomEntity(entityClass, location);
|
return EcoBossesPlugin.getInstance().getProxy(CustomEntitySpawnerProxy.class).spawnCustomEntity(entityClass, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,6 @@ import lombok.Data;
|
|||||||
import org.bukkit.boss.BarColor;
|
import org.bukkit.boss.BarColor;
|
||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
|
|
||||||
@Data
|
public record BossbarProperties(BarColor color, BarStyle style) {
|
||||||
public class BossbarProperties {
|
|
||||||
/**
|
|
||||||
* The BossBar color.
|
|
||||||
*/
|
|
||||||
private final BarColor color;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The BossBar style.
|
|
||||||
*/
|
|
||||||
private final BarStyle style;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,7 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.obj;
|
package com.willfp.ecobosses.bosses.util.obj;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Data
|
public record DamagerProperty(UUID playerUUID, double damage) {
|
||||||
public class DamagerProperty {
|
|
||||||
/**
|
|
||||||
* The player.
|
|
||||||
*/
|
|
||||||
private final UUID playerUUID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The damage.
|
|
||||||
*/
|
|
||||||
private final double damage;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,29 +2,7 @@ package com.willfp.ecobosses.bosses.util.obj;
|
|||||||
|
|
||||||
import com.willfp.eco.util.NumberUtils;
|
import com.willfp.eco.util.NumberUtils;
|
||||||
|
|
||||||
public class ExperienceOptions {
|
public record ExperienceOptions(int minimum, int maximum) {
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate an exp amount.
|
* Generate an exp amount.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,31 +1,8 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.obj;
|
package com.willfp.ecobosses.bosses.util.obj;
|
||||||
|
|
||||||
import lombok.Data;
|
public record ImmunityOptions(boolean immuneToFire,
|
||||||
|
boolean immuneToSuffocation,
|
||||||
@Data
|
boolean immuneToDrowning,
|
||||||
public class ImmunityOptions {
|
boolean immuneToProjectiles,
|
||||||
/**
|
boolean immuneToExplosions) {
|
||||||
* 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;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,9 @@
|
|||||||
package com.willfp.ecobosses.bosses.util.obj;
|
package com.willfp.ecobosses.bosses.util.obj;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class OptionedSound {
|
public record OptionedSound(Sound sound,
|
||||||
/**
|
float volume,
|
||||||
* The sound.
|
float pitch) {
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
private final Sound sound;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,7 @@ package com.willfp.ecobosses.bosses.util.obj;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
@Data
|
public record SpawnTotem(Material bottom,
|
||||||
public class SpawnTotem {
|
Material middle,
|
||||||
/**
|
Material top) {
|
||||||
* The bottom block.
|
|
||||||
*/
|
|
||||||
private final Material bottom;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The middle block.
|
|
||||||
*/
|
|
||||||
private final Material middle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The top block.
|
|
||||||
*/
|
|
||||||
private final Material top;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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))));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.willfp.ecobosses.config;
|
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 com.willfp.ecobosses.EcoBossesPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class BaseBossConfig extends ExtendableConfig {
|
public class BaseBossConfig extends YamlExtendableConfig {
|
||||||
/**
|
/**
|
||||||
* Create new EcoBoss config.
|
* Create new EcoBoss config.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.willfp.ecobosses.config;
|
package com.willfp.ecobosses.config;
|
||||||
|
|
||||||
import com.willfp.eco.core.config.YamlConfig;
|
import com.willfp.eco.core.config.yaml.YamlTransientConfig;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class CustomConfig extends YamlConfig {
|
public class CustomConfig extends YamlTransientConfig {
|
||||||
/**
|
/**
|
||||||
* The name of the config.
|
* The name of the config.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,7 +38,7 @@ rewards:
|
|||||||
# Use %player% as the placeholder for the player name
|
# Use %player% as the placeholder for the player name
|
||||||
commands: []
|
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>
|
# To set the chance for a drop, put <chance>::<base64>
|
||||||
drops: []
|
drops: []
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ rewards:
|
|||||||
# Use %player% as the placeholder for the player name
|
# Use %player% as the placeholder for the player name
|
||||||
commands: []
|
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>
|
# To set the chance for a drop, put <chance>::<base64>
|
||||||
drops: []
|
drops: []
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ rewards:
|
|||||||
# Use %player% as the placeholder for the player name
|
# Use %player% as the placeholder for the player name
|
||||||
commands: []
|
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>
|
# To set the chance for a drop, put <chance>::<base64>
|
||||||
drops: []
|
drops: []
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ rewards:
|
|||||||
# Use %player% as the placeholder for the player name
|
# Use %player% as the placeholder for the player name
|
||||||
commands: []
|
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>
|
# To set the chance for a drop, put <chance>::<base64>
|
||||||
drops: []
|
drops: []
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
messages:
|
messages:
|
||||||
prefix: "&9&lEcoBosses &f» "
|
prefix: "&9&lEcoBosses &f» "
|
||||||
no-permission: "&cYou don't have permission to do this!"
|
no-permission: "&cYou don't have permission to do this!"
|
||||||
|
invalid-command: "&cUnknown subcommand!"
|
||||||
not-player: "&cThis command must be run by a player"
|
not-player: "&cThis command must be run by a player"
|
||||||
reloaded: "Reloaded!"
|
reloaded: "Reloaded!"
|
||||||
sent-drop: "Check console for the drop!"
|
sent-drop: "Check console for the drop!"
|
||||||
|
|||||||
@@ -9,41 +9,41 @@ depend:
|
|||||||
- eco
|
- eco
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
ebreload:
|
ecobosses:
|
||||||
description: Reloads config
|
description: Base command
|
||||||
permission: ecobosses.reload
|
permission: ecobosses.command.ecobosses
|
||||||
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
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
ecobosses.*:
|
ecobosses.*:
|
||||||
description: All ecobosses permissions
|
description: All ecobosses permissions
|
||||||
default: op
|
default: op
|
||||||
children:
|
children:
|
||||||
ecobosses.reload: true
|
ecobosses.command.*: true
|
||||||
ecobosses.ebdrop: true
|
ecobosses.command.*:
|
||||||
ecobosses.ebspawn: true
|
description: All ecobosses commands
|
||||||
ecobosses.killall: true
|
default: op
|
||||||
|
children:
|
||||||
|
ecobosses.command.ecobosses: true
|
||||||
|
ecobosses.command.reload: true
|
||||||
|
ecobosses.command.spawn: true
|
||||||
|
ecobosses.command.base64: true
|
||||||
|
|
||||||
ecobosses.reload:
|
ecobosses.command.ecobosses:
|
||||||
description: Allows reloading the config
|
description: Allows the use of /ecobosses
|
||||||
|
default: true
|
||||||
|
|
||||||
|
ecobosses.command.base64:
|
||||||
|
description: Allows the use of /ecobosses base64
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
ecobosses.ebdrop:
|
ecobosses.command.spawn:
|
||||||
description: Allows the use of /ebdrop
|
description: Allows the use of /ecobosses spawn
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
ecobosses.ebspawn:
|
ecobosses.command.killall:
|
||||||
description: Allows the use of /ebspawn
|
description: Allows the use of /ecobosses killall
|
||||||
default: op
|
default: op
|
||||||
|
|
||||||
ecobosses.killall:
|
ecobosses.command.reload:
|
||||||
description: Allows the use of /ebkillall
|
description: Allows the use of /ecobosses reload
|
||||||
default: op
|
default: op
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
version = 5.0.0
|
version = 6.0.0
|
||||||
plugin-name = EcoBosses
|
plugin-name = EcoBosses
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
21
gradlew.bat
vendored
21
gradlew.bat
vendored
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
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_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
@@ -64,21 +64,6 @@ echo location of your Java installation.
|
|||||||
|
|
||||||
goto fail
|
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
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
@@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@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
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
6
jitpack.yml
Normal file
6
jitpack.yml
Normal 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.
@@ -3,9 +3,9 @@ rootProject.name = 'EcoBosses'
|
|||||||
// Core
|
// Core
|
||||||
include ':eco-core'
|
include ':eco-core'
|
||||||
include ':eco-core:core-nms'
|
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_R1'
|
||||||
include ':eco-core:core-nms:v1_16_R2'
|
include ':eco-core:core-nms:v1_16_R2'
|
||||||
include ':eco-core:core-nms:v1_16_R3'
|
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-proxy'
|
||||||
include ':eco-core:core-plugin'
|
include ':eco-core:core-plugin'
|
||||||
Reference in New Issue
Block a user