mirror of
https://github.com/craftaro/EpicSpawners.git
synced 2025-01-09 03:57:40 +08:00
Better mcmmo support.
This commit is contained in:
parent
c84660da16
commit
e580485760
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "EpicSpawners"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "6.0.2"
|
||||
version: "6.0.3"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
5
pom.xml
5
pom.xml
@ -90,5 +90,10 @@
|
||||
<artifactId>playerpoints</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateStacker</artifactId>
|
||||
<version>1.5.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -44,6 +44,8 @@ public class SpawnOptionEntity_1_12 implements SpawnOption {
|
||||
|
||||
private boolean stackPlugin;
|
||||
|
||||
private boolean mcmmo;
|
||||
|
||||
private Map<String, Integer> cache = new HashMap<>();
|
||||
private Class<?> clazzEntityTypes, clazzMobSpawnerData, clazzNBTTagCompound, clazzNBTTagList, clazzCraftWorld, clazzWorld, clazzChunkRegionLoader, clazzEntity, clazzCraftEntity, clazzEntityInsentient, clazzGroupDataEntity, clazzDifficultyDamageScaler, clazzBlockPosition, clazzAxisAlignedBB;
|
||||
private Method methodAddEntity, methodCreateEntityByName, methodSetPositionRotation, methodB, methodSetString, methodNTBTagListSize, methodGetHandle, methodTBNTagListK, methodEntityInsentientPrepare, methodChunkRegionLoaderA, methodEntityGetBukkitEntity, methodCraftEntityTeleport, methodEntityInsentientCanSpawn, methodChunkRegionLoaderA2, methodGetDamageScaler, methodGetCubes, methodGetBoundingBox;
|
||||
@ -53,7 +55,6 @@ public class SpawnOptionEntity_1_12 implements SpawnOption {
|
||||
this.types = types;
|
||||
this.mgr = new ScriptEngineManager();
|
||||
this.engine = mgr.getEngineByName("JavaScript");
|
||||
this.stackPlugin = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker") || Bukkit.getPluginManager().isPluginEnabled("StackMob");
|
||||
init();
|
||||
}
|
||||
|
||||
@ -110,9 +111,12 @@ public class SpawnOptionEntity_1_12 implements SpawnOption {
|
||||
|
||||
fieldWorldRandom = clazzWorld.getDeclaredField("random");
|
||||
fieldWorldRandom.setAccessible(true);
|
||||
|
||||
} catch (NoSuchFieldException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.mcmmo = Bukkit.getPluginManager().isPluginEnabled("mcMMO");
|
||||
this.stackPlugin = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker") || Bukkit.getPluginManager().isPluginEnabled("StackMob");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -240,6 +244,9 @@ public class SpawnOptionEntity_1_12 implements SpawnOption {
|
||||
|
||||
craftEntity.setMetadata("ES", new FixedMetadataValue(plugin, data.getIdentifyingName()));
|
||||
|
||||
if (mcmmo)
|
||||
craftEntity.setMetadata( "mcMMO: Spawned Entity", new FixedMetadataValue(plugin, true));
|
||||
|
||||
if (Setting.NO_AI.getBoolean() && plugin.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
((LivingEntity) craftEntity).setAI(false);
|
||||
|
||||
|
@ -38,12 +38,14 @@ public class SpawnOptionEntity_1_13 implements SpawnOption {
|
||||
|
||||
private final ScriptEngine engine;
|
||||
|
||||
private EpicSpawners instance = EpicSpawners.getInstance();
|
||||
private EpicSpawners plugin = EpicSpawners.getInstance();
|
||||
|
||||
private Enum<?> SpawnerEnum;
|
||||
|
||||
private boolean stackPlugin;
|
||||
|
||||
private boolean mcmmo;
|
||||
|
||||
private Map<String, Integer> cache = new HashMap<>();
|
||||
private Class<?> clazzMobSpawnerData, clazzEnumMobSpawn, clazzWorldServer, clazzGeneratorAccess, clazzEntityTypes, clazzNBTTagCompound, clazzCraftWorld, clazzWorld, clazzChunkRegionLoader, clazzEntity, clazzCraftEntity, clazzEntityInsentient, clazzGroupDataEntity, clazzDifficultyDamageScaler, clazzBlockPosition, clazzIWorldReader, clazzAxisAlignedBB;
|
||||
private Method methodGetEntity, methodSetString, methodSetPosition, methodA, methodAddEntity, methodGetHandle, methodChunkRegionLoaderA, methodEntityGetBukkitEntity, methodCraftEntityTeleport, methodEntityInsentientPrepare, methodChunkRegionLoaderA2, methodGetDamageScaler, methodGetCubes, methodGetBoundingBox;
|
||||
@ -53,7 +55,6 @@ public class SpawnOptionEntity_1_13 implements SpawnOption {
|
||||
this.types = types;
|
||||
this.mgr = new ScriptEngineManager();
|
||||
this.engine = mgr.getEngineByName("JavaScript");
|
||||
this.stackPlugin = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker") || Bukkit.getPluginManager().isPluginEnabled("StackMob");
|
||||
init();
|
||||
}
|
||||
|
||||
@ -124,6 +125,8 @@ public class SpawnOptionEntity_1_13 implements SpawnOption {
|
||||
} catch (NoSuchFieldException | NoSuchMethodException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.mcmmo = Bukkit.getPluginManager().isPluginEnabled("mcMMO");
|
||||
this.stackPlugin = Bukkit.getPluginManager().isPluginEnabled("UltimateStacker") || Bukkit.getPluginManager().isPluginEnabled("StackMob");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -132,11 +135,11 @@ public class SpawnOptionEntity_1_13 implements SpawnOption {
|
||||
location.add(.5, .5, .5);
|
||||
if (location.getWorld() == null) return;
|
||||
|
||||
String[] randomLowHigh = instance.getConfig().getString("Main.Random Amount Added To Each Spawn").split(":");
|
||||
String[] randomLowHigh = plugin.getConfig().getString("Main.Random Amount Added To Each Spawn").split(":");
|
||||
|
||||
int randomAmt = ThreadLocalRandom.current().nextInt(Integer.valueOf(randomLowHigh[0]), Integer.valueOf(randomLowHigh[1]));
|
||||
|
||||
String equation = instance.getConfig().getString("Main.Equations.Mobs Spawned Per Spawn");
|
||||
String equation = plugin.getConfig().getString("Main.Equations.Mobs Spawned Per Spawn");
|
||||
equation = equation.replace("{RAND}", Integer.toString(randomAmt));
|
||||
equation = equation.replace("{MULTI}", Integer.toString(stack.getStackSize()));
|
||||
|
||||
@ -167,7 +170,7 @@ public class SpawnOptionEntity_1_13 implements SpawnOption {
|
||||
|
||||
|
||||
if (amt.size() == limit && spawnerBoost == 0) return;
|
||||
spawnCount = (stackPlugin ? spawnCount : Math.min(limit - amt.size(), spawnCount)) + spawner.getBoost();
|
||||
spawnCount = Math.min(limit - amt.size(), spawnCount) + spawner.getBoost();
|
||||
|
||||
while (spawnCount-- > 0) {
|
||||
EntityType type = types[ThreadLocalRandom.current().nextInt(types.length)];
|
||||
@ -239,15 +242,12 @@ public class SpawnOptionEntity_1_13 implements SpawnOption {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return false;
|
||||
|
||||
if (methodChunkRegionLoaderA != null) {
|
||||
methodChunkRegionLoaderA2.invoke(null, objEntity, objWorld, CreatureSpawnEvent.SpawnReason.SPAWNER);
|
||||
} else {
|
||||
methodAddEntity.invoke(clazzWorldServer.cast(objWorld), objEntity, CreatureSpawnEvent.SpawnReason.SPAWNER);
|
||||
}
|
||||
|
||||
if (data.isSpawnOnFire()) craftEntity.setFireTicks(160);
|
||||
|
||||
craftEntity.setMetadata("ES", new FixedMetadataValue(instance, data.getIdentifyingName()));
|
||||
craftEntity.setMetadata("ES", new FixedMetadataValue(plugin, data.getIdentifyingName()));
|
||||
|
||||
if (mcmmo)
|
||||
craftEntity.setMetadata( "mcMMO: Spawned Entity", new FixedMetadataValue(plugin, true));
|
||||
|
||||
if (Setting.NO_AI.getBoolean())
|
||||
((LivingEntity) craftEntity).setAI(false);
|
||||
@ -256,6 +256,12 @@ public class SpawnOptionEntity_1_13 implements SpawnOption {
|
||||
spot.setYaw(random.nextFloat() * 360.0F);
|
||||
methodCraftEntityTeleport.invoke(objBukkitEntity, spot);
|
||||
|
||||
if (methodChunkRegionLoaderA != null) {
|
||||
methodChunkRegionLoaderA2.invoke(null, objEntity, objWorld, CreatureSpawnEvent.SpawnReason.SPAWNER);
|
||||
} else {
|
||||
methodAddEntity.invoke(clazzWorldServer.cast(objWorld), objEntity, CreatureSpawnEvent.SpawnReason.SPAWNER);
|
||||
}
|
||||
|
||||
EpicSpawners.getInstance().getSpawnManager().addUnnaturalSpawn(craftEntity.getUniqueId());
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user