Merge branch 'master' of github.com:CitizensDev/Citizens2

This commit is contained in:
fullwall 2019-03-28 22:46:45 +08:00
commit aea3cd37a7
6 changed files with 41 additions and 20 deletions

View File

@ -114,7 +114,7 @@ public class Settings {
QUICK_SELECT("npc.selection.quick-select", false), QUICK_SELECT("npc.selection.quick-select", false),
REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true), REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true),
SAVE_TASK_DELAY("storage.save-task.delay", 20 * 60 * 60), SAVE_TASK_DELAY("storage.save-task.delay", 20 * 60 * 60),
SELECTION_ITEM("npc.selection.item", "280"), SELECTION_ITEM("npc.selection.item", "stick"),
SELECTION_MESSAGE("npc.selection.message", "<b>You selected <a><npc><b>!"), SELECTION_MESSAGE("npc.selection.message", "<b>You selected <a><npc><b>!"),
SERVER_OWNS_NPCS("npc.server-ownership", false), SERVER_OWNS_NPCS("npc.server-ownership", false),
STORAGE_FILE("storage.file", "saves.yml"), STORAGE_FILE("storage.file", "saves.yml"),
@ -122,7 +122,7 @@ public class Settings {
SUBPLUGIN_FOLDER("subplugins.folder", "plugins"), SUBPLUGIN_FOLDER("subplugins.folder", "plugins"),
TALK_CLOSE_MAXIMUM_COOLDOWN("npc.text.max-talk-cooldown", 5), TALK_CLOSE_MAXIMUM_COOLDOWN("npc.text.max-talk-cooldown", 5),
TALK_CLOSE_MINIMUM_COOLDOWN("npc.text.min-talk-cooldown", 10), TALK_CLOSE_MINIMUM_COOLDOWN("npc.text.min-talk-cooldown", 10),
TALK_ITEM("npc.text.talk-item", "340"), TALK_ITEM("npc.text.talk-item", "book"),
TELEPORT_DELAY("npc.teleport-delay", -1), TELEPORT_DELAY("npc.teleport-delay", -1),
USE_BOAT_CONTROLS("npc.controllable.use-boat-controls", true), USE_BOAT_CONTROLS("npc.controllable.use-boat-controls", true),
USE_NEW_PATHFINDER("npc.pathfinding.use-new-finder", false), USE_NEW_PATHFINDER("npc.pathfinding.use-new-finder", false),

View File

@ -287,9 +287,12 @@ public class CitizensNPC extends AbstractNPC {
NMS.trySwim(getEntity()); NMS.trySwim(getEntity());
} }
navigator.run(); navigator.run();
try { if (SUPPORT_GLOWING) {
getEntity().setGlowing(data().get(NPC.GLOWING_METADATA, false)); try {
} catch (NoSuchMethodError e) { getEntity().setGlowing(data().get(NPC.GLOWING_METADATA, false));
} catch (NoSuchMethodError e) {
SUPPORT_GLOWING = false;
}
} }
if (!getNavigator().isNavigating() && updateCounter++ > Setting.PACKET_UPDATE_DELAY.asInt()) { if (!getNavigator().isNavigating() && updateCounter++ > Setting.PACKET_UPDATE_DELAY.asInt()) {
updateCounter = 0; updateCounter = 0;
@ -310,11 +313,15 @@ public class CitizensNPC extends AbstractNPC {
team.unregister(); team.unregister();
data().remove(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA); data().remove(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
} else { } else {
try { if (SUPPORT_TEAM_SETOPTION) {
team.setOption(Option.NAME_TAG_VISIBILITY, try {
nameVisibility ? OptionStatus.ALWAYS : OptionStatus.NEVER); team.setOption(Option.NAME_TAG_VISIBILITY,
} catch (NoSuchMethodError e) { nameVisibility ? OptionStatus.ALWAYS : OptionStatus.NEVER);
} catch (NoClassDefFoundError e) { } catch (NoSuchMethodError e) {
SUPPORT_TEAM_SETOPTION = false;
} catch (NoClassDefFoundError e) {
SUPPORT_TEAM_SETOPTION = false;
}
} }
if (data().has(NPC.GLOWING_COLOR_METADATA)) { if (data().has(NPC.GLOWING_COLOR_METADATA)) {
if (team.getPrefix() == null || team.getPrefix().length() == 0 if (team.getPrefix() == null || team.getPrefix().length() == 0
@ -346,10 +353,11 @@ public class CitizensNPC extends AbstractNPC {
} }
} }
if (data().has(NPC.SILENT_METADATA)) { if (SUPPORT_SILENT && data().has(NPC.SILENT_METADATA)) {
try { try {
getEntity().setSilent(Boolean.parseBoolean(data().get(NPC.SILENT_METADATA).toString())); getEntity().setSilent(Boolean.parseBoolean(data().get(NPC.SILENT_METADATA).toString()));
} catch (NoSuchMethodError e) { } catch (NoSuchMethodError e) {
SUPPORT_SILENT = false;
} }
} }
} catch (Exception ex) { } catch (Exception ex) {
@ -369,4 +377,7 @@ public class CitizensNPC extends AbstractNPC {
} }
private static final String NPC_METADATA_MARKER = "NPC"; private static final String NPC_METADATA_MARKER = "NPC";
private static boolean SUPPORT_SILENT = true;
private static boolean SUPPORT_GLOWING = true;
private static boolean SUPPORT_TEAM_SETOPTION = true;
} }

View File

@ -62,6 +62,7 @@ public class FollowTrait extends Trait {
} }
this.followingUUID = player.getUniqueId(); this.followingUUID = player.getUniqueId();
if (npc.getNavigator().isNavigating() && this.player != null if (npc.getNavigator().isNavigating() && this.player != null
&& npc.getNavigator().getEntityTarget() != null
&& this.player == npc.getNavigator().getEntityTarget().getTarget()) { && this.player == npc.getNavigator().getEntityTarget().getTarget()) {
npc.getNavigator().cancelNavigation(); npc.getNavigator().cancelNavigation();
} }

View File

@ -237,8 +237,17 @@ public class Util {
if (parts.contains("*")) if (parts.contains("*"))
return true; return true;
for (String part : Splitter.on(',').split(parts)) { for (String part : Splitter.on(',').split(parts)) {
if ((SpigotUtil.isUsing1_13API() ? Material.matchMaterial(part, true) Material matchMaterial = SpigotUtil.isUsing1_13API() ? Material.matchMaterial(part, true)
: Material.matchMaterial(part)) == player.getInventory().getItemInHand().getType()) { : Material.matchMaterial(part);
if (matchMaterial == null) {
if (part.equals("280")) {
matchMaterial = Material.STICK;
}
else if (part.equals("340")) {
matchMaterial = Material.BOOK;
}
}
if (matchMaterial == player.getInventory().getItemInHand().getType()) {
return true; return true;
} }
} }

View File

@ -1320,7 +1320,7 @@ public class NMSImpl implements NMSBridge {
} else { } else {
float f9 = 0.91F; float f9 = 0.91F;
BoundingBox bb = NMSBoundingBox.wrap(entity.getBoundingBox()); BoundingBox bb = NMSBoundingBox.wrap(entity.getBoundingBox());
BlockPosition.b blockposition_b = BlockPosition.b.d(entity.locX, bb.minY - 1.0D, entity.locZ); BlockPosition.PooledBlockPosition blockposition_b = BlockPosition.PooledBlockPosition.d(entity.locX, bb.minY - 1.0D, entity.locZ);
Throwable throwable = null; Throwable throwable = null;
float f4; float f4;
float f3; float f3;
@ -1407,12 +1407,12 @@ public class NMSImpl implements NMSBridge {
entity.aK += entity.aJ; entity.aK += entity.aJ;
} }
private static BlockPosition.b getBlockPositionBE(BlockPosition.b blockPos, double x, double y, double z) { private static BlockPosition.PooledBlockPosition getBlockPositionBE(BlockPosition.PooledBlockPosition blockPos, double x, double y, double z) {
try { try {
return blockPos.c(x, y, z); return blockPos.c(x, y, z);
} catch (NoSuchMethodError ex) { } catch (NoSuchMethodError ex) {
try { try {
return (BlockPosition.b) BLOCK_POSITION_B_D.invoke(blockPos, x, y, z); return (BlockPosition.PooledBlockPosition) BLOCK_POSITION_B_D.invoke(blockPos, x, y, z);
} catch (Throwable ex2) { } catch (Throwable ex2) {
ex2.printStackTrace(); ex2.printStackTrace();
return null; return null;
@ -1619,7 +1619,7 @@ public class NMSImpl implements NMSBridge {
private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH, private static final Set<EntityType> BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH,
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST); EntityType.MAGMA_CUBE, EntityType.HORSE, EntityType.GHAST);
private static final Method BLOCK_POSITION_B_D = NMS.getMethod(BlockPosition.b.class, "e", false, double.class, private static final Method BLOCK_POSITION_B_D = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "e", false, double.class,
double.class, double.class); double.class, double.class);
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle"); private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
private static final float DEFAULT_SPEED = 1F; private static final float DEFAULT_SPEED = 1F;

View File

@ -185,11 +185,11 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
return var11; return var11;
} }
private static final Method BLOCK_POSITION_B_C = NMS.getMethod(BlockPosition.b.class, "f", false, int.class, int.class, int.class); private static final Method BLOCK_POSITION_B_C = NMS.getMethod(BlockPosition.PooledBlockPosition.class, "f", false, int.class, int.class, int.class);
public PathType a(IBlockAccess var1, int var2, int var3, int var4, PathType var5) { public PathType a(IBlockAccess var1, int var2, int var3, int var4, PathType var5) {
if (var5 == PathType.WALKABLE) { if (var5 == PathType.WALKABLE) {
BlockPosition.b var6 = BlockPosition.b.r(); BlockPosition.PooledBlockPosition var6 = BlockPosition.PooledBlockPosition.r();
Throwable var7 = null; Throwable var7 = null;
try { try {
@ -202,7 +202,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
} }
catch (NoSuchMethodError ex) { catch (NoSuchMethodError ex) {
try { try {
blockPos = (BlockPosition.b) BLOCK_POSITION_B_C.invoke(var6, var8 + var2, var3, var9 + var4); blockPos = (BlockPosition.PooledBlockPosition) BLOCK_POSITION_B_C.invoke(var6, var8 + var2, var3, var9 + var4);
} }
catch (Throwable ex2) { catch (Throwable ex2) {
ex2.printStackTrace(); ex2.printStackTrace();