Merge moduled trait code and discontinue building of 1.10

This commit is contained in:
fullwall 2019-12-12 00:13:54 +08:00
parent ff9c920df3
commit 688f78ea6f
65 changed files with 377 additions and 1533 deletions

11
dist/pom.xml vendored
View File

@ -18,7 +18,7 @@
<finalName>Citizens-${CITIZENS_VERSION}-b${BUILD_NUMBER}</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<version>3.1.1</version>
<version>3.2.0</version>
<executions>
<execution>
<id>package-all</id>
@ -51,14 +51,7 @@
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>citizens-v1_10_R1</artifactId>
<version>${project.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>citizens-v1_11_R1</artifactId>

View File

@ -116,7 +116,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -126,7 +126,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
</plugin>
<plugin>
@ -168,7 +168,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<version>3.2.0</version>
<configuration>
<source>8</source>
<author>false</author>

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.Bee;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
package net.citizensnpcs.trait.versioned;
import java.util.Collection;
import java.util.List;
@ -14,7 +14,7 @@ import com.google.common.collect.Lists;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
import net.citizensnpcs.util.NMS;
@TraitName("bossbar")
public class BossBarTrait extends Trait {
@ -40,7 +40,7 @@ public class BossBarTrait extends Trait {
public void run() {
if (!npc.isSpawned() || !isBoss(npc.getEntity()))
return;
BossBar bar = NMSImpl.getBossBar(npc.getEntity());
BossBar bar = (BossBar) NMS.getBossBar(npc.getEntity());
if (bar == null) {
return;
}

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.DyeColor;
import org.bukkit.entity.Cat;
@ -6,7 +6,7 @@ import org.bukkit.entity.Cat;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
import net.citizensnpcs.util.NMS;
@TraitName("cattrait")
public class CatTrait extends Trait {
@ -36,7 +36,7 @@ public class CatTrait extends Trait {
if (collarColor != null) {
cat.setCollarColor(collarColor);
}
NMSImpl.setLyingDown(cat, lying);
NMS.setLyingDown(cat, lying);
}
}

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.Fox;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_13_R2.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Llama.Color;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.MushroomCow.Variant;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.Panda;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_13_R2.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.Parrot;
import org.bukkit.entity.Parrot.Variant;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.Phantom;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.PufferFish;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_11_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.DyeColor;
import org.bukkit.entity.Shulker;
@ -6,7 +6,6 @@ import org.bukkit.entity.Shulker;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
import net.citizensnpcs.util.NMS;
@TraitName("shulkertrait")
@ -36,7 +35,7 @@ public class ShulkerTrait extends Trait {
NMS.setPeekShulker(npc.getEntity(), peek);
lastPeekSet = peek;
}
NMSImpl.setShulkerColor((Shulker) npc.getEntity(), color);
NMS.setShulkerColor((Shulker) npc.getEntity(), color);
}
}

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.DyeColor;
import org.bukkit.entity.TropicalFish;

View File

@ -1,4 +1,4 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
package net.citizensnpcs.trait.versioned;
import org.bukkit.entity.Villager;

View File

@ -8,6 +8,7 @@ import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
@ -65,6 +66,10 @@ public class NMS {
return BRIDGE.getBlockBreaker(entity, targetBlock, config);
}
public static Object getBossBar(Entity entity) {
return BRIDGE.getBossBar(entity);
}
public static BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
return BRIDGE.getBoundingBox(handle);
}
@ -369,6 +374,10 @@ public class NMS {
BRIDGE.setKnockbackResistance(entity, d);
}
public static void setLyingDown(Entity cat, boolean lying) {
BRIDGE.setLyingDown(cat, lying);
}
public static void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target,
float speed) {
BRIDGE.setNavigationTarget(handle, target, speed);
@ -389,6 +398,10 @@ public class NMS {
BRIDGE.setShouldJump(entity);
}
public static void setShulkerColor(Entity entity, DyeColor color) {
BRIDGE.setShulkerColor(entity, color);
}
public static void setSitting(Ocelot ocelot, boolean sitting) {
BRIDGE.setSitting(ocelot, sitting);
}

View File

@ -3,6 +3,7 @@ package net.citizensnpcs.util;
import java.util.Collection;
import java.util.List;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
@ -42,6 +43,8 @@ public interface NMSBridge {
public BlockBreaker getBlockBreaker(Entity entity, Block targetBlock, BlockBreakerConfiguration config);
public Object getBossBar(Entity entity);
public BoundingBox getBoundingBox(Entity handle);
public GameProfileRepository getGameProfileRepository();
@ -120,6 +123,8 @@ public interface NMSBridge {
public void setKnockbackResistance(LivingEntity entity, double d);
public void setLyingDown(Entity cat, boolean lying);
public void setNavigationTarget(Entity handle, Entity target, float speed);
public void setPeekShulker(Entity entity, int peek);
@ -128,6 +133,8 @@ public interface NMSBridge {
public void setShouldJump(Entity entity);
public void setShulkerColor(Entity entity, DyeColor color);
public void setSitting(Ocelot ocelot, boolean sitting);
public void setSitting(Tameable tameable, boolean sitting);

View File

@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -57,13 +57,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>

View File

@ -1,74 +0,0 @@
package net.citizensnpcs.nms.v1_10_R1.trait;
import java.util.Collection;
import java.util.List;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import com.google.common.collect.Lists;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
@TraitName("bossbar")
public class BossBarTrait extends Trait {
@Persist("color")
private BarColor color = null;
@Persist("flags")
private List<BarFlag> flags = Lists.newArrayList();
@Persist("title")
private String title = null;
@Persist("visible")
private boolean visible = true;
public BossBarTrait() {
super("bossbar");
}
private boolean isBoss(Entity entity) {
return entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|| entity.getType() == EntityType.GUARDIAN;
}
@Override
public void run() {
if (!npc.isSpawned() || !isBoss(npc.getEntity()))
return;
BossBar bar = NMSImpl.getBossBar(npc.getEntity());
bar.setVisible(visible);
if (color != null) {
bar.setColor(color);
}
if (title != null) {
bar.setTitle(title);
}
for (BarFlag flag : BarFlag.values()) {
bar.removeFlag(flag);
}
for (BarFlag flag : flags) {
bar.addFlag(flag);
}
}
public void setColor(BarColor color) {
this.color = color;
}
public void setFlags(Collection<BarFlag> flags) {
this.flags = Lists.newArrayList(flags);
}
public void setTitle(String title) {
this.title = title;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
}

View File

@ -19,6 +19,8 @@ import net.citizensnpcs.api.command.exception.CommandUsageException;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;

View File

@ -1,51 +0,0 @@
package net.citizensnpcs.nms.v1_10_R1.trait;
import org.bukkit.DyeColor;
import org.bukkit.entity.Shulker;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_10_R1.util.NMSImpl;
import net.citizensnpcs.util.NMS;
@TraitName("shulkertrait")
public class ShulkerTrait extends Trait {
@Persist("color")
private DyeColor color = DyeColor.PURPLE;
private int lastPeekSet = 0;
@Persist("peek")
private int peek = 0;
public ShulkerTrait() {
super("shulkertrait");
}
@Override
public void onSpawn() {
setPeek(peek);
}
@Override
public void run() {
if (color == null) {
color = DyeColor.PURPLE;
}
if (npc.getEntity() instanceof Shulker) {
if (peek != lastPeekSet) {
NMS.setPeekShulker((Shulker) npc.getEntity(), peek);
lastPeekSet = peek;
}
NMSImpl.setShulkerColor((Shulker) npc.getEntity(), color);
}
}
public void setColor(DyeColor color) {
this.color = color;
}
public void setPeek(int peek) {
this.peek = peek;
lastPeekSet = -1;
}
}

View File

@ -137,14 +137,14 @@ import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.ThrownPotionController;
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_10_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.nms.v1_10_R1.network.EmptyChannel;
import net.citizensnpcs.nms.v1_10_R1.trait.BossBarTrait;
import net.citizensnpcs.nms.v1_10_R1.trait.Commands;
import net.citizensnpcs.nms.v1_10_R1.trait.ShulkerTrait;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.util.BoundingBox;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@ -301,6 +301,29 @@ public class NMSImpl implements NMSBridge {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD
.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
}
} catch (Exception e) {
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
} catch (Exception e) {
}
return ret;
}
@Override
public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
AxisAlignedBB bb = NMSImpl.getHandle(handle).getBoundingBox();
@ -850,6 +873,10 @@ public class NMSImpl implements NMSBridge {
handle.getAttributeInstance(GenericAttributes.c).setValue(d);
}
@Override
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
}
@Override
public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) {
NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed);
@ -889,6 +916,10 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
@ -1274,28 +1305,6 @@ public class NMSImpl implements NMSBridge {
entity.aI += entity.aH;
}
public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD
.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
}
} catch (Exception e) {
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
} catch (Exception e) {
}
return ret;
}
private static EntityLiving getHandle(LivingEntity entity) {
return (EntityLiving) NMSImpl.getHandle((org.bukkit.entity.Entity) entity);
}
@ -1464,6 +1473,7 @@ public class NMSImpl implements NMSBridge {
private static Field SKULL_PROFILE_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
private static final Field WITHER_BOSS_BAR_FIELD = NMS.getField(EntityWither.class, "bG");
static {
try {
Field field = NMS.getField(EntityTypes.class, "f");

View File

@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -57,13 +57,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>

View File

@ -1,74 +0,0 @@
package net.citizensnpcs.nms.v1_11_R1.trait;
import java.util.Collection;
import java.util.List;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import com.google.common.collect.Lists;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_11_R1.util.NMSImpl;
@TraitName("bossbar")
public class BossBarTrait extends Trait {
@Persist("color")
private BarColor color = null;
@Persist("flags")
private List<BarFlag> flags = Lists.newArrayList();
@Persist("title")
private String title = null;
@Persist("visible")
private boolean visible = true;
public BossBarTrait() {
super("bossbar");
}
private boolean isBoss(Entity entity) {
return entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|| entity.getType() == EntityType.GUARDIAN;
}
@Override
public void run() {
if (!npc.isSpawned() || !isBoss(npc.getEntity()))
return;
BossBar bar = NMSImpl.getBossBar(npc.getEntity());
bar.setVisible(visible);
if (color != null) {
bar.setColor(color);
}
if (title != null) {
bar.setTitle(title);
}
for (BarFlag flag : BarFlag.values()) {
bar.removeFlag(flag);
}
for (BarFlag flag : flags) {
bar.addFlag(flag);
}
}
public void setColor(BarColor color) {
this.color = color;
}
public void setFlags(Collection<BarFlag> flags) {
this.flags = Lists.newArrayList(flags);
}
public void setTitle(String title) {
this.title = title;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
}

View File

@ -20,6 +20,9 @@ import net.citizensnpcs.api.command.exception.CommandUsageException;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;

View File

@ -1,37 +0,0 @@
package net.citizensnpcs.nms.v1_11_R1.trait;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Llama.Color;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("llamatrait")
public class LlamaTrait extends Trait {
@Persist
private Color color = Color.BROWN;
@Persist
private int strength = 3;
public LlamaTrait() {
super("llamatrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Llama) {
Llama llama = (Llama) npc.getEntity();
llama.setColor(color);
llama.setStrength(strength);
}
}
public void setColor(Llama.Color color) {
this.color = color;
}
public void setStrength(int strength) {
this.strength = strength;
}
}

View File

@ -153,15 +153,15 @@ import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.ThrownPotionController;
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_11_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.nms.v1_11_R1.network.EmptyChannel;
import net.citizensnpcs.nms.v1_11_R1.trait.BossBarTrait;
import net.citizensnpcs.nms.v1_11_R1.trait.Commands;
import net.citizensnpcs.nms.v1_11_R1.trait.LlamaTrait;
import net.citizensnpcs.nms.v1_11_R1.trait.ShulkerTrait;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.util.BoundingBox;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@ -322,6 +322,29 @@ public class NMSImpl implements NMSBridge {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD
.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
}
} catch (Exception e) {
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
} catch (Exception e) {
}
return ret;
}
@Override
public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
AxisAlignedBB bb = NMSImpl.getHandle(handle).getBoundingBox();
@ -909,6 +932,10 @@ public class NMSImpl implements NMSBridge {
handle.getAttributeInstance(GenericAttributes.c).setValue(d);
}
@Override
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
}
@Override
public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) {
NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed);
@ -948,6 +975,10 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
@ -1339,28 +1370,6 @@ public class NMSImpl implements NMSBridge {
entity.aH += entity.aG;
}
public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD
.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
}
} catch (Exception e) {
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
} catch (Exception e) {
}
return ret;
}
private static EntityLiving getHandle(LivingEntity entity) {
return (EntityLiving) NMSImpl.getHandle((org.bukkit.entity.Entity) entity);
}
@ -1526,8 +1535,11 @@ public class NMSImpl implements NMSBridge {
private static Field PATHFINDING_RANGE = NMS.getField(NavigationAbstract.class, "f");
private static final Field RABBIT_FIELD = NMS.getField(EntityRabbit.class, "bw");
private static final Random RANDOM = Util.getFastRandom();
private static Field SKULL_PROFILE_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
private static final Field WITHER_BOSS_BAR_FIELD = NMS.getField(EntityWither.class, "bF");
static {

View File

@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -57,7 +57,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
</plugin>
<plugin>

View File

@ -1,74 +0,0 @@
package net.citizensnpcs.nms.v1_12_R1.trait;
import java.util.Collection;
import java.util.List;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import com.google.common.collect.Lists;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
@TraitName("bossbar")
public class BossBarTrait extends Trait {
@Persist("color")
private BarColor color = null;
@Persist("flags")
private List<BarFlag> flags = Lists.newArrayList();
@Persist("title")
private String title = null;
@Persist("visible")
private boolean visible = true;
public BossBarTrait() {
super("bossbar");
}
private boolean isBoss(Entity entity) {
return entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|| entity.getType() == EntityType.GUARDIAN;
}
@Override
public void run() {
if (!npc.isSpawned() || !isBoss(npc.getEntity()))
return;
BossBar bar = NMSImpl.getBossBar(npc.getEntity());
bar.setVisible(visible);
if (color != null) {
bar.setColor(color);
}
if (title != null) {
bar.setTitle(title);
}
for (BarFlag flag : BarFlag.values()) {
bar.removeFlag(flag);
}
for (BarFlag flag : flags) {
bar.addFlag(flag);
}
}
public void setColor(BarColor color) {
this.color = color;
}
public void setFlags(Collection<BarFlag> flags) {
this.flags = Lists.newArrayList(flags);
}
public void setTitle(String title) {
this.title = title;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
}

View File

@ -21,6 +21,10 @@ import net.citizensnpcs.api.command.exception.CommandUsageException;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;

View File

@ -1,37 +0,0 @@
package net.citizensnpcs.nms.v1_12_R1.trait;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Llama.Color;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("llamatrait")
public class LlamaTrait extends Trait {
@Persist
private Color color = Color.BROWN;
@Persist
private int strength = 3;
public LlamaTrait() {
super("llamatrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Llama) {
Llama llama = (Llama) npc.getEntity();
llama.setColor(color);
llama.setStrength(strength);
}
}
public void setColor(Llama.Color color) {
this.color = color;
}
public void setStrength(int strength) {
this.strength = strength;
}
}

View File

@ -1,30 +0,0 @@
package net.citizensnpcs.nms.v1_12_R1.trait;
import org.bukkit.entity.Parrot;
import org.bukkit.entity.Parrot.Variant;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("parrottrait")
public class ParrotTrait extends Trait {
@Persist
private Variant variant = Variant.BLUE;
public ParrotTrait() {
super("parrottrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Parrot) {
Parrot parrot = (Parrot) npc.getEntity();
parrot.setVariant(variant);
}
}
public void setVariant(Parrot.Variant variant) {
this.variant = variant;
}
}

View File

@ -1,51 +0,0 @@
package net.citizensnpcs.nms.v1_12_R1.trait;
import org.bukkit.DyeColor;
import org.bukkit.entity.Shulker;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_12_R1.util.NMSImpl;
import net.citizensnpcs.util.NMS;
@TraitName("shulkertrait")
public class ShulkerTrait extends Trait {
@Persist("color")
private DyeColor color = DyeColor.PURPLE;
private int lastPeekSet = 0;
@Persist("peek")
private int peek = 0;
public ShulkerTrait() {
super("shulkertrait");
}
@Override
public void onSpawn() {
setPeek(peek);
}
@Override
public void run() {
if (color == null) {
color = DyeColor.PURPLE;
}
if (npc.getEntity() instanceof Shulker) {
if (peek != lastPeekSet) {
NMS.setPeekShulker((Shulker) npc.getEntity(), peek);
lastPeekSet = peek;
}
NMSImpl.setShulkerColor((Shulker) npc.getEntity(), color);
}
}
public void setColor(DyeColor color) {
this.color = color;
}
public void setPeek(int peek) {
this.peek = peek;
lastPeekSet = -1;
}
}

View File

@ -154,16 +154,16 @@ import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.ThrownPotionController;
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_12_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.nms.v1_12_R1.network.EmptyChannel;
import net.citizensnpcs.nms.v1_12_R1.trait.BossBarTrait;
import net.citizensnpcs.nms.v1_12_R1.trait.Commands;
import net.citizensnpcs.nms.v1_12_R1.trait.LlamaTrait;
import net.citizensnpcs.nms.v1_12_R1.trait.ParrotTrait;
import net.citizensnpcs.nms.v1_12_R1.trait.ShulkerTrait;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.util.BoundingBox;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@ -325,6 +325,29 @@ public class NMSImpl implements NMSBridge {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD
.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
}
} catch (Exception e) {
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
} catch (Exception e) {
}
return ret;
}
@Override
public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
AxisAlignedBB bb = NMSImpl.getHandle(handle).getBoundingBox();
@ -921,6 +944,10 @@ public class NMSImpl implements NMSBridge {
handle.getAttributeInstance(GenericAttributes.c).setValue(d);
}
@Override
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
}
@Override
public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) {
NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed);
@ -960,6 +987,10 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
@ -1351,28 +1382,6 @@ public class NMSImpl implements NMSBridge {
entity.aH += entity.aG;
}
public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD
.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
}
} catch (Exception e) {
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
} catch (Exception e) {
}
return ret;
}
private static EntityLiving getHandle(LivingEntity entity) {
return (EntityLiving) NMSImpl.getHandle((org.bukkit.entity.Entity) entity);
}
@ -1497,7 +1506,7 @@ public class NMSImpl implements NMSBridge {
if ((entity.width > f2) && (!justCreated) && (!entity.world.isClientSide))
entity.move(EnumMoveType.SELF, (f2 - entity.width) / 2, 0.0D, (f2 - entity.width) / 2);
}
}
};
public static void stopNavigation(NavigationAbstract navigation) {
navigation.p();
@ -1518,7 +1527,7 @@ public class NMSImpl implements NMSBridge {
public static void updateNavigation(NavigationAbstract navigation) {
navigation.d();
};
}
private static MethodHandle ADVANCEMENT_PLAYER_FIELD = NMS.getFinalSetter(EntityPlayer.class, "bY");
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
@ -1539,8 +1548,11 @@ public class NMSImpl implements NMSBridge {
private static Field PATHFINDING_RANGE = NMS.getField(NavigationAbstract.class, "i");
private static final Field RABBIT_FIELD = NMS.getField(EntityRabbit.class, "bx");
private static final Random RANDOM = Util.getFastRandom();
private static Field SKULL_PROFILE_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
private static final Field WITHER_BOSS_BAR_FIELD = NMS.getField(EntityWither.class, "bG");
static {

View File

@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
@ -57,7 +57,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
</plugin>
<plugin>

View File

@ -1,74 +0,0 @@
package net.citizensnpcs.nms.v1_13_R2.trait;
import java.util.Collection;
import java.util.List;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import com.google.common.collect.Lists;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
@TraitName("bossbar")
public class BossBarTrait extends Trait {
@Persist("color")
private BarColor color = null;
@Persist("flags")
private List<BarFlag> flags = Lists.newArrayList();
@Persist("title")
private String title = null;
@Persist("visible")
private boolean visible = true;
public BossBarTrait() {
super("bossbar");
}
private boolean isBoss(Entity entity) {
return entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|| entity.getType() == EntityType.GUARDIAN;
}
@Override
public void run() {
if (!npc.isSpawned() || !isBoss(npc.getEntity()))
return;
BossBar bar = NMSImpl.getBossBar(npc.getEntity());
bar.setVisible(visible);
if (color != null) {
bar.setColor(color);
}
if (title != null) {
bar.setTitle(title);
}
for (BarFlag flag : BarFlag.values()) {
bar.removeFlag(flag);
}
for (BarFlag flag : flags) {
bar.addFlag(flag);
}
}
public void setColor(BarColor color) {
this.color = color;
}
public void setFlags(Collection<BarFlag> flags) {
this.flags = Lists.newArrayList(flags);
}
public void setTitle(String title) {
this.title = title;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
}

View File

@ -22,6 +22,13 @@ import net.citizensnpcs.api.command.exception.CommandUsageException;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.PhantomTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;

View File

@ -1,29 +0,0 @@
package net.citizensnpcs.nms.v1_13_R2.trait;
import org.bukkit.entity.Phantom;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("phantomtrait")
public class PhantomTrait extends Trait {
@Persist
private int size = 1;
public PhantomTrait() {
super("phantomtrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Phantom) {
Phantom phantom = (Phantom) npc.getEntity();
phantom.setSize(size);
}
}
public void setSize(int size) {
this.size = size;
}
}

View File

@ -1,29 +0,0 @@
package net.citizensnpcs.nms.v1_13_R2.trait;
import org.bukkit.entity.PufferFish;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("pufferfishtrait")
public class PufferFishTrait extends Trait {
@Persist
private int puffState = 1;
public PufferFishTrait() {
super("pufferfishtrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof PufferFish) {
PufferFish puffer = (PufferFish) npc.getEntity();
puffer.setPuffState(puffState);
}
}
public void setPuffState(int state) {
this.puffState = state;
}
}

View File

@ -1,51 +0,0 @@
package net.citizensnpcs.nms.v1_13_R2.trait;
import org.bukkit.DyeColor;
import org.bukkit.entity.Shulker;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_13_R2.util.NMSImpl;
import net.citizensnpcs.util.NMS;
@TraitName("shulkertrait")
public class ShulkerTrait extends Trait {
@Persist("color")
private DyeColor color = DyeColor.PURPLE;
private int lastPeekSet = 0;
@Persist("peek")
private int peek = 0;
public ShulkerTrait() {
super("shulkertrait");
}
@Override
public void onSpawn() {
setPeek(peek);
}
@Override
public void run() {
if (color == null) {
color = DyeColor.PURPLE;
}
if (npc.getEntity() instanceof Shulker) {
if (peek != lastPeekSet) {
NMS.setPeekShulker((Shulker) npc.getEntity(), peek);
lastPeekSet = peek;
}
NMSImpl.setShulkerColor((Shulker) npc.getEntity(), color);
}
}
public void setColor(DyeColor color) {
this.color = color;
}
public void setPeek(int peek) {
this.peek = peek;
lastPeekSet = -1;
}
}

View File

@ -1,45 +0,0 @@
package net.citizensnpcs.nms.v1_13_R2.trait;
import org.bukkit.DyeColor;
import org.bukkit.entity.TropicalFish;
import org.bukkit.entity.TropicalFish.Pattern;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("tropicalfishtrait")
public class TropicalFishTrait extends Trait {
@Persist
private DyeColor bodyColor = DyeColor.BLUE;
@Persist
private Pattern pattern = Pattern.BRINELY;
@Persist
private DyeColor patternColor = DyeColor.BLUE;
public TropicalFishTrait() {
super("tropicalfishtrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof TropicalFish) {
TropicalFish fish = (TropicalFish) npc.getEntity();
fish.setBodyColor(bodyColor);
fish.setPatternColor(patternColor);
fish.setPattern(pattern);
}
}
public void setBodyColor(DyeColor color) {
this.bodyColor = color;
}
public void setPattern(Pattern pattern) {
this.pattern = pattern;
}
public void setPatternColor(DyeColor color) {
this.patternColor = color;
}
}

View File

@ -164,19 +164,19 @@ import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.ThrownTridentController;
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_13_R2.entity.nonliving.WitherSkullController;
import net.citizensnpcs.nms.v1_13_R2.network.EmptyChannel;
import net.citizensnpcs.nms.v1_13_R2.trait.BossBarTrait;
import net.citizensnpcs.nms.v1_13_R2.trait.Commands;
import net.citizensnpcs.nms.v1_13_R2.trait.LlamaTrait;
import net.citizensnpcs.nms.v1_13_R2.trait.ParrotTrait;
import net.citizensnpcs.nms.v1_13_R2.trait.PhantomTrait;
import net.citizensnpcs.nms.v1_13_R2.trait.PufferFishTrait;
import net.citizensnpcs.nms.v1_13_R2.trait.ShulkerTrait;
import net.citizensnpcs.nms.v1_13_R2.trait.TropicalFishTrait;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.PhantomTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.util.BoundingBox;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@ -340,6 +340,37 @@ public class NMSImpl implements NMSBridge {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
try {
bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
} catch (NoSuchFieldError ex) {
bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
}
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
try {
bserver = ((EnderDragonBattle) ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity))).bossBattle;
} catch (NoSuchFieldError ex) {
bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD
.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
}
}
} catch (Exception e) {
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
} catch (Exception e) {
}
return ret;
}
@Override
public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
return NMSBoundingBox.wrap(NMSImpl.getHandle(handle).getBoundingBox());
@ -948,6 +979,10 @@ public class NMSImpl implements NMSBridge {
handle.getAttributeInstance(GenericAttributes.c).setValue(d);
}
@Override
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
}
@Override
public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) {
NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed);
@ -987,6 +1022,10 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
@ -1433,36 +1472,6 @@ public class NMSImpl implements NMSBridge {
}
}
public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
try {
bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
} catch (NoSuchFieldError ex) {
bserver = (BossBattleServer) WITHER_BOSS_BAR_FIELD.get(NMSImpl.getHandle(entity));
}
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
try {
bserver = ((EnderDragonBattle) ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity))).bossBattle;
} catch (NoSuchFieldError ex) {
bserver = (BossBattleServer) ENDERDRAGON_BATTLE_BAR_FIELD
.get(ENDERDRAGON_BATTLE_FIELD.get(NMSImpl.getHandle(entity)));
}
}
} catch (Exception e) {
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.set(ret, bserver);
} catch (Exception e) {
}
return ret;
}
private static EntityLiving getHandle(LivingEntity entity) {
return (EntityLiving) NMSImpl.getHandle((org.bukkit.entity.Entity) entity);
}
@ -1591,7 +1600,7 @@ public class NMSImpl implements NMSBridge {
public static void setShulkerColor(Shulker shulker, DyeColor color) {
((EntityShulker) getHandle(shulker)).getDataWatcher().set(EntityShulker.COLOR, color.getWoolData());
}
};
public static void setSize(Entity entity, float f, float f1, boolean justCreated) {
if ((f != entity.width) || (f1 != entity.length)) {
@ -1609,7 +1618,7 @@ public class NMSImpl implements NMSBridge {
public static void stopNavigation(NavigationAbstract navigation) {
navigation.q();
};
}
public static void updateAI(EntityLiving entity) {
if (entity instanceof EntityInsentient) {
@ -1655,6 +1664,7 @@ public class NMSImpl implements NMSBridge {
private static Field SKULL_PROFILE_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
private static final Field WITHER_BOSS_BAR_FIELD = NMS.getField(EntityWither.class, "bL", false);
static {
try {
ENTITY_FISH_NUM_IN_SCHOOL = NMS.getField(Class.forName("net.minecraft.server.v1_13_R2.EntityFishSchool"),

View File

@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<version>3.8.1</version>
<configuration>
<compilerId>eclipse</compilerId>
<source>1.8</source>
@ -65,7 +65,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
</plugin>
<plugin>

View File

@ -30,6 +30,18 @@ import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.trait.VillagerProfession;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.CatTrait;
import net.citizensnpcs.trait.versioned.FoxTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
import net.citizensnpcs.trait.versioned.PandaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.PhantomTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;

View File

@ -1,50 +0,0 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
import org.bukkit.entity.Fox;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("foxtrait")
public class FoxTrait extends Trait {
@Persist
private boolean crouching = false;
@Persist
private boolean sitting = false;
@Persist
private boolean sleeping = false;
@Persist
private Fox.Type type = Fox.Type.RED;
public FoxTrait() {
super("foxtrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Fox) {
Fox fox = (Fox) npc.getEntity();
fox.setSitting(sitting);
fox.setCrouching(crouching);
fox.setSleeping(sleeping);
fox.setFoxType(type);
}
}
public void setCrouching(boolean crouching) {
this.crouching = crouching;
}
public void setSitting(boolean sitting) {
this.sitting = sitting;
}
public void setSleeping(boolean sleeping) {
this.sleeping = sleeping;
}
public void setType(Fox.Type type) {
this.type = type;
}
}

View File

@ -1,37 +0,0 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Llama.Color;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("llamatrait")
public class LlamaTrait extends Trait {
@Persist
private Color color = Color.BROWN;
@Persist
private int strength = 3;
public LlamaTrait() {
super("llamatrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Llama) {
Llama llama = (Llama) npc.getEntity();
llama.setColor(color);
llama.setStrength(strength);
}
}
public void setColor(Llama.Color color) {
this.color = color;
}
public void setStrength(int strength) {
this.strength = strength;
}
}

View File

@ -1,34 +0,0 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
import org.bukkit.entity.MushroomCow;
import org.bukkit.entity.MushroomCow.Variant;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("mushroomcowtrait")
public class MushroomCowTrait extends Trait {
@Persist("variant")
private Variant variant;
public MushroomCowTrait() {
super("mushroomcowtrait");
}
@Override
public void onSpawn() {
setVariant(variant);
}
@Override
public void run() {
if (variant != null && npc.getEntity() instanceof MushroomCow) {
((MushroomCow) npc.getEntity()).setVariant(variant);
}
}
public void setVariant(Variant variant) {
this.variant = variant;
}
}

View File

@ -1,30 +0,0 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
import org.bukkit.entity.Parrot;
import org.bukkit.entity.Parrot.Variant;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("parrottrait")
public class ParrotTrait extends Trait {
@Persist
private Variant variant = Variant.BLUE;
public ParrotTrait() {
super("parrottrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Parrot) {
Parrot parrot = (Parrot) npc.getEntity();
parrot.setVariant(variant);
}
}
public void setVariant(Parrot.Variant variant) {
this.variant = variant;
}
}

View File

@ -1,29 +0,0 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
import org.bukkit.entity.PufferFish;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("pufferfishtrait")
public class PufferFishTrait extends Trait {
@Persist
private int puffState = 1;
public PufferFishTrait() {
super("pufferfishtrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof PufferFish) {
PufferFish puffer = (PufferFish) npc.getEntity();
puffer.setPuffState(puffState);
}
}
public void setPuffState(int state) {
this.puffState = state;
}
}

View File

@ -1,51 +0,0 @@
package net.citizensnpcs.nms.v1_14_R1.trait;
import org.bukkit.DyeColor;
import org.bukkit.entity.Shulker;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_14_R1.util.NMSImpl;
import net.citizensnpcs.util.NMS;
@TraitName("shulkertrait")
public class ShulkerTrait extends Trait {
@Persist("color")
private DyeColor color = DyeColor.PURPLE;
private int lastPeekSet = 0;
@Persist("peek")
private int peek = 0;
public ShulkerTrait() {
super("shulkertrait");
}
@Override
public void onSpawn() {
setPeek(peek);
}
@Override
public void run() {
if (color == null) {
color = DyeColor.PURPLE;
}
if (npc.getEntity() instanceof Shulker) {
if (peek != lastPeekSet) {
NMS.setPeekShulker((Shulker) npc.getEntity(), peek);
lastPeekSet = peek;
}
NMSImpl.setShulkerColor((Shulker) npc.getEntity(), color);
}
}
public void setColor(DyeColor color) {
this.color = color;
}
public void setPeek(int peek) {
this.peek = peek;
lastPeekSet = -1;
}
}

View File

@ -174,24 +174,24 @@ import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.ThrownTridentController;
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_14_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.nms.v1_14_R1.network.EmptyChannel;
import net.citizensnpcs.nms.v1_14_R1.trait.BossBarTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.CatTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.Commands;
import net.citizensnpcs.nms.v1_14_R1.trait.FoxTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.LlamaTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.MushroomCowTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.PandaTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.ParrotTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.PhantomTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.PufferFishTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.ShulkerTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.TropicalFishTrait;
import net.citizensnpcs.nms.v1_14_R1.trait.VillagerTrait;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.CatTrait;
import net.citizensnpcs.trait.versioned.FoxTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
import net.citizensnpcs.trait.versioned.PandaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.PhantomTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.BoundingBox;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@ -380,6 +380,34 @@ public class NMSImpl implements NMSBridge {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
Object battleObject = ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity));
if (battleObject == null) {
return null;
}
bserver = ((EnderDragonBattle) battleObject).bossBattle;
}
} catch (Throwable e) {
e.printStackTrace();
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
} catch (Throwable e) {
e.printStackTrace();
}
return ret;
}
@Override
public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
return NMSBoundingBox.wrap(NMSImpl.getHandle(handle).getBoundingBox());
@ -1000,6 +1028,10 @@ public class NMSImpl implements NMSBridge {
handle.getAttributeInstance(GenericAttributes.KNOCKBACK_RESISTANCE).setValue(d);
}
@Override
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
}
@Override
public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) {
NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed);
@ -1037,6 +1069,10 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
// sitting removed
@ -1491,33 +1527,6 @@ public class NMSImpl implements NMSBridge {
}
}
public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
Object battleObject = ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity));
if (battleObject == null) {
return null;
}
bserver = ((EnderDragonBattle) battleObject).bossBattle;
}
} catch (Throwable e) {
e.printStackTrace();
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
} catch (Throwable e) {
e.printStackTrace();
}
return ret;
}
public static <T extends Entity> EntityTypes<T> getEntityType(Class<?> clazz) {
return (EntityTypes<T>) CITIZENS_ENTITY_TYPES.get(clazz);
}
@ -1754,6 +1763,7 @@ public class NMSImpl implements NMSBridge {
private static final MethodHandle SIZE_FIELD_GETTER = NMS.getGetter(Entity.class, "size");
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getSetter(Entity.class, "size");
private static Field SKULL_PROFILE_FIELD;
static {
try {
ENTITY_REGISTRY = new CustomEntityRegistry(

View File

@ -65,7 +65,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.0</version>
</plugin>
<plugin>

View File

@ -1,77 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import java.util.Collection;
import java.util.List;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarFlag;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import com.google.common.collect.Lists;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
@TraitName("bossbar")
public class BossBarTrait extends Trait {
@Persist("color")
private BarColor color = null;
@Persist("flags")
private List<BarFlag> flags = Lists.newArrayList();
@Persist("title")
private String title = null;
@Persist("visible")
private boolean visible = true;
public BossBarTrait() {
super("bossbar");
}
private boolean isBoss(Entity entity) {
return entity.getType() == EntityType.ENDER_DRAGON || entity.getType() == EntityType.WITHER
|| entity.getType() == EntityType.GUARDIAN;
}
@Override
public void run() {
if (!npc.isSpawned() || !isBoss(npc.getEntity()))
return;
BossBar bar = NMSImpl.getBossBar(npc.getEntity());
if (bar == null) {
return;
}
bar.setVisible(visible);
if (color != null) {
bar.setColor(color);
}
if (title != null) {
bar.setTitle(title);
}
for (BarFlag flag : BarFlag.values()) {
bar.removeFlag(flag);
}
for (BarFlag flag : flags) {
bar.addFlag(flag);
}
}
public void setColor(BarColor color) {
this.color = color;
}
public void setFlags(Collection<BarFlag> flags) {
this.flags = Lists.newArrayList(flags);
}
public void setTitle(String title) {
this.title = title;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
}

View File

@ -1,58 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import org.bukkit.DyeColor;
import org.bukkit.entity.Cat;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
@TraitName("cattrait")
public class CatTrait extends Trait {
@Persist
private DyeColor collarColor = null;
@Persist
private boolean lying = false;
@Persist
private boolean sitting = false;
@Persist
private Cat.Type type = Cat.Type.BLACK;
public CatTrait() {
super("cattrait");
}
public boolean isLyingDown() {
return lying;
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Cat) {
Cat cat = (Cat) npc.getEntity();
cat.setSitting(sitting);
cat.setCatType(type);
if (collarColor != null) {
cat.setCollarColor(collarColor);
}
NMSImpl.setLyingDown(cat, lying);
}
}
public void setCollarColor(DyeColor color) {
this.collarColor = color;
}
public void setLyingDown(boolean lying) {
this.lying = lying;
}
public void setSitting(boolean sitting) {
this.sitting = sitting;
}
public void setType(Cat.Type type) {
this.type = type;
}
}

View File

@ -30,6 +30,19 @@ import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.trait.VillagerProfession;
import net.citizensnpcs.trait.versioned.BeeTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.CatTrait;
import net.citizensnpcs.trait.versioned.FoxTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
import net.citizensnpcs.trait.versioned.PandaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.PhantomTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.Util;

View File

@ -1,37 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Llama.Color;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("llamatrait")
public class LlamaTrait extends Trait {
@Persist
private Color color = Color.BROWN;
@Persist
private int strength = 3;
public LlamaTrait() {
super("llamatrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Llama) {
Llama llama = (Llama) npc.getEntity();
llama.setColor(color);
llama.setStrength(strength);
}
}
public void setColor(Llama.Color color) {
this.color = color;
}
public void setStrength(int strength) {
this.strength = strength;
}
}

View File

@ -1,39 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import org.bukkit.entity.Panda;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("pandatrait")
public class PandaTrait extends Trait {
@Persist
private Panda.Gene hiddenGene;
@Persist
private Panda.Gene mainGene = Panda.Gene.NORMAL;
public PandaTrait() {
super("pandatrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Panda) {
Panda panda = (Panda) npc.getEntity();
panda.setMainGene(mainGene);
if (hiddenGene != null) {
panda.setHiddenGene(hiddenGene);
}
}
}
public void setHiddenGene(Panda.Gene gene) {
this.hiddenGene = gene;
}
public void setMainGene(Panda.Gene gene) {
this.mainGene = gene;
}
}

View File

@ -1,30 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import org.bukkit.entity.Parrot;
import org.bukkit.entity.Parrot.Variant;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("parrottrait")
public class ParrotTrait extends Trait {
@Persist
private Variant variant = Variant.BLUE;
public ParrotTrait() {
super("parrottrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Parrot) {
Parrot parrot = (Parrot) npc.getEntity();
parrot.setVariant(variant);
}
}
public void setVariant(Parrot.Variant variant) {
this.variant = variant;
}
}

View File

@ -1,29 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import org.bukkit.entity.Phantom;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("phantomtrait")
public class PhantomTrait extends Trait {
@Persist
private int size = 1;
public PhantomTrait() {
super("phantomtrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof Phantom) {
Phantom phantom = (Phantom) npc.getEntity();
phantom.setSize(size);
}
}
public void setSize(int size) {
this.size = size;
}
}

View File

@ -1,51 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import org.bukkit.DyeColor;
import org.bukkit.entity.Shulker;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.nms.v1_15_R1.util.NMSImpl;
import net.citizensnpcs.util.NMS;
@TraitName("shulkertrait")
public class ShulkerTrait extends Trait {
@Persist("color")
private DyeColor color = DyeColor.PURPLE;
private int lastPeekSet = 0;
@Persist("peek")
private int peek = 0;
public ShulkerTrait() {
super("shulkertrait");
}
@Override
public void onSpawn() {
setPeek(peek);
}
@Override
public void run() {
if (color == null) {
color = DyeColor.PURPLE;
}
if (npc.getEntity() instanceof Shulker) {
if (peek != lastPeekSet) {
NMS.setPeekShulker((Shulker) npc.getEntity(), peek);
lastPeekSet = peek;
}
NMSImpl.setShulkerColor((Shulker) npc.getEntity(), color);
}
}
public void setColor(DyeColor color) {
this.color = color;
}
public void setPeek(int peek) {
this.peek = peek;
lastPeekSet = -1;
}
}

View File

@ -1,45 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import org.bukkit.DyeColor;
import org.bukkit.entity.TropicalFish;
import org.bukkit.entity.TropicalFish.Pattern;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("tropicalfishtrait")
public class TropicalFishTrait extends Trait {
@Persist
private DyeColor bodyColor = DyeColor.BLUE;
@Persist
private Pattern pattern = Pattern.BRINELY;
@Persist
private DyeColor patternColor = DyeColor.BLUE;
public TropicalFishTrait() {
super("tropicalfishtrait");
}
@Override
public void run() {
if (npc.isSpawned() && npc.getEntity() instanceof TropicalFish) {
TropicalFish fish = (TropicalFish) npc.getEntity();
fish.setBodyColor(bodyColor);
fish.setPatternColor(patternColor);
fish.setPattern(pattern);
}
}
public void setBodyColor(DyeColor color) {
this.bodyColor = color;
}
public void setPattern(Pattern pattern) {
this.pattern = pattern;
}
public void setPatternColor(DyeColor color) {
this.patternColor = color;
}
}

View File

@ -1,38 +0,0 @@
package net.citizensnpcs.nms.v1_15_R1.trait;
import org.bukkit.entity.Villager;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("villagertrait")
public class VillagerTrait extends Trait {
@Persist
private int level = 1;
@Persist
private Villager.Type type;
public VillagerTrait() {
super("villagertrait");
}
@Override
public void run() {
if (!(npc.getEntity() instanceof Villager))
return;
if (type != null) {
((Villager) npc.getEntity()).setVillagerType(type);
}
level = Math.min(5, Math.max(1, level));
((Villager) npc.getEntity()).setVillagerLevel(level);
}
public void setLevel(int level) {
this.level = level;
}
public void setType(Villager.Type type) {
this.type = type;
}
}

View File

@ -175,25 +175,25 @@ import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.ThrownTridentController;
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.TippedArrowController;
import net.citizensnpcs.nms.v1_15_R1.entity.nonliving.WitherSkullController;
import net.citizensnpcs.nms.v1_15_R1.network.EmptyChannel;
import net.citizensnpcs.nms.v1_15_R1.trait.BeeTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.BossBarTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.CatTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.Commands;
import net.citizensnpcs.nms.v1_15_R1.trait.FoxTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.LlamaTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.MushroomCowTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.PandaTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.ParrotTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.PhantomTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.PufferFishTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.ShulkerTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.TropicalFishTrait;
import net.citizensnpcs.nms.v1_15_R1.trait.VillagerTrait;
import net.citizensnpcs.npc.EntityControllers;
import net.citizensnpcs.npc.ai.MCNavigationStrategy.MCNavigator;
import net.citizensnpcs.npc.ai.MCTargetStrategy.TargetNavigator;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.trait.versioned.BeeTrait;
import net.citizensnpcs.trait.versioned.BossBarTrait;
import net.citizensnpcs.trait.versioned.CatTrait;
import net.citizensnpcs.trait.versioned.FoxTrait;
import net.citizensnpcs.trait.versioned.LlamaTrait;
import net.citizensnpcs.trait.versioned.MushroomCowTrait;
import net.citizensnpcs.trait.versioned.PandaTrait;
import net.citizensnpcs.trait.versioned.ParrotTrait;
import net.citizensnpcs.trait.versioned.PhantomTrait;
import net.citizensnpcs.trait.versioned.PufferFishTrait;
import net.citizensnpcs.trait.versioned.ShulkerTrait;
import net.citizensnpcs.trait.versioned.TropicalFishTrait;
import net.citizensnpcs.trait.versioned.VillagerTrait;
import net.citizensnpcs.util.BoundingBox;
import net.citizensnpcs.util.Messages;
import net.citizensnpcs.util.NMS;
@ -381,6 +381,34 @@ public class NMSImpl implements NMSBridge {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
Object battleObject = ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity));
if (battleObject == null) {
return null;
}
bserver = ((EnderDragonBattle) battleObject).bossBattle;
}
} catch (Throwable e) {
e.printStackTrace();
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
} catch (Throwable e) {
e.printStackTrace();
}
return ret;
}
@Override
public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
return NMSBoundingBox.wrap(NMSImpl.getHandle(handle).getBoundingBox());
@ -1004,6 +1032,10 @@ public class NMSImpl implements NMSBridge {
handle.getAttributeInstance(GenericAttributes.KNOCKBACK_RESISTANCE).setValue(d);
}
@Override
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
}
@Override
public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) {
NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed);
@ -1041,6 +1073,10 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
// sitting removed
@ -1481,33 +1517,6 @@ public class NMSImpl implements NMSBridge {
return null;
}
public static BossBar getBossBar(org.bukkit.entity.Entity entity) {
BossBattleServer bserver = null;
try {
if (entity.getType() == EntityType.WITHER) {
bserver = ((EntityWither) NMSImpl.getHandle(entity)).bossBattle;
} else if (entity.getType() == EntityType.ENDER_DRAGON) {
Object battleObject = ENDERDRAGON_BATTLE_FIELD.invoke(NMSImpl.getHandle(entity));
if (battleObject == null) {
return null;
}
bserver = ((EnderDragonBattle) battleObject).bossBattle;
}
} catch (Throwable e) {
e.printStackTrace();
}
if (bserver == null) {
return null;
}
BossBar ret = Bukkit.createBossBar("", BarColor.BLUE, BarStyle.SEGMENTED_10);
try {
CRAFT_BOSSBAR_HANDLE_FIELD.invoke(ret, bserver);
} catch (Throwable e) {
e.printStackTrace();
}
return ret;
}
public static <T extends Entity> EntityTypes<T> getEntityType(Class<?> clazz) {
return (EntityTypes<T>) CITIZENS_ENTITY_TYPES.get(clazz);
}
@ -1743,7 +1752,9 @@ public class NMSImpl implements NMSBridge {
private static final Random RANDOM = Util.getFastRandom();
private static final MethodHandle SIZE_FIELD_GETTER = NMS.getGetter(Entity.class, "size");
private static final MethodHandle SIZE_FIELD_SETTER = NMS.getSetter(Entity.class, "size");
private static Field SKULL_PROFILE_FIELD;
static {
try {
ENTITY_REGISTRY = new CustomEntityRegistry(

View File

@ -47,7 +47,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<version>3.8.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
@ -57,13 +57,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<version>3.2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>

View File

@ -16,6 +16,7 @@ import java.util.Random;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -272,6 +273,11 @@ public class NMSImpl implements NMSBridge {
return new CitizensBlockBreaker(entity, targetBlock, config);
}
@Override
public Object getBossBar(org.bukkit.entity.Entity entity) {
return null;
}
@Override
public BoundingBox getBoundingBox(org.bukkit.entity.Entity handle) {
AxisAlignedBB bb = NMSImpl.getHandle(handle).getBoundingBox();
@ -805,6 +811,10 @@ public class NMSImpl implements NMSBridge {
handle.getAttributeInstance(GenericAttributes.c).setValue(d);
}
@Override
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
}
@Override
public void setNavigationTarget(org.bukkit.entity.Entity handle, org.bukkit.entity.Entity target, float speed) {
NMSImpl.getNavigation(handle).a(NMSImpl.getHandle(target), speed);
@ -844,6 +854,10 @@ public class NMSImpl implements NMSBridge {
}
}
@Override
public void setShulkerColor(org.bukkit.entity.Entity entity, DyeColor color) {
}
@Override
public void setSitting(Ocelot ocelot, boolean sitting) {
setSitting((Tameable) ocelot, sitting);
@ -1314,8 +1328,11 @@ public class NMSImpl implements NMSBridge {
public static Field NETWORK_ADDRESS = NMS.getField(NetworkManager.class, "l");
public static final Location PACKET_CACHE_LOCATION = new Location(null, 0, 0, 0);
private static Field PATHFINDING_RANGE = NMS.getField(NavigationAbstract.class, "a");
private static final Random RANDOM = Util.getFastRandom();
private static Field SKULL_PROFILE_FIELD;
private static Field TRACKED_ENTITY_SET = NMS.getField(EntityTracker.class, "c");
static {