Added clearlag support.

This commit is contained in:
Brianna 2019-06-20 03:33:29 -04:00
parent 5d703e1168
commit 8775e9e370
4 changed files with 43 additions and 5 deletions

View File

@ -98,5 +98,10 @@
<artifactId>stackmob</artifactId>
<version>4</version>
</dependency>
<dependency>
<groupId>me.minebuilders</groupId>
<artifactId>Clearlag</artifactId>
<version>3.0.6</version>
</dependency>
</dependencies>
</project>

View File

@ -28,7 +28,6 @@ import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@ -37,7 +36,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class UltimateStacker extends JavaPlugin {
@ -171,6 +169,9 @@ public class UltimateStacker extends JavaPlugin {
pluginManager.registerEvents(new TameListeners(this), this);
pluginManager.registerEvents(new SheepDyeListeners(this), this);
if (Setting.CLEAR_LAG.getBoolean() && pluginManager.isPluginEnabled("ClearLag"))
pluginManager.registerEvents(new ClearLagListeners(this), this);
// Register Hologram Plugin
if (Setting.SPAWNER_HOLOGRAMS.getBoolean()) {
if (pluginManager.isPluginEnabled("HolographicDisplays"))
@ -226,8 +227,10 @@ public class UltimateStacker extends JavaPlugin {
return !this.getServer().getPluginManager().isPluginEnabled("EpicSpawners") && Setting.SPAWNERS_ENABLED.getBoolean();
}
public Hologram getHologram() { return hologram; }
public Hologram getHologram() {
return hologram;
}
public ServerVersion getServerVersion() {
return serverVersion;
}

View File

@ -0,0 +1,26 @@
package com.songoda.ultimatestacker.listeners;
import com.songoda.ultimatestacker.UltimateStacker;
import me.minebuilders.clearlag.events.EntityRemoveEvent;
import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class ClearLagListeners implements Listener {
private final UltimateStacker instance;
public ClearLagListeners(UltimateStacker instance) {
this.instance = instance;
}
@EventHandler
public void onClearLaggTask(EntityRemoveEvent event) {
for (Entity entity : event.getWorld().getEntities()) {
if (instance.getEntityStackManager().isStacked(entity)) {
instance.getEntityStackManager().removeStack(entity);
event.addEntity(entity);
}
}
}
}

View File

@ -17,7 +17,6 @@ public enum Setting {
DISABLED_WORLDS("Main.Disabled Worlds", Arrays.asList("World1", "World2", "World3"),
"Worlds that stacking doesn't happen in."),
STACK_ENTITIES("Entities.Enabled", true,
"Should entities be stacked?"),
@ -44,6 +43,11 @@ public enum Setting {
"Should killing a stack of entities kill the whole stack or",
"just one out of the stack?"),
CLEAR_LAG("Entities.Clear Lag", false,
"When enabled, the plugin will hook into ClearLag and extend the",
"clear task to include stacked entities from this plugin. If this is enabled",
"the built in task will not run."),
INSTANT_KILL("Entities.Instant Kill", Arrays.asList("FALL", "DROWNING", "LAVA", "VOID"),
"Events that will trigger an entire stack to be killed.",
"It should be noted that this is useless if the above setting is true.",