mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 12:46:04 +01:00
Merge branch 'master' of github.com:CitizensDev/Citizens2
This commit is contained in:
commit
aea3cd37a7
@ -114,7 +114,7 @@ public class Settings {
|
||||
QUICK_SELECT("npc.selection.quick-select", false),
|
||||
REMOVE_PLAYERS_FROM_PLAYER_LIST("npc.player.remove-from-list", true),
|
||||
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>!"),
|
||||
SERVER_OWNS_NPCS("npc.server-ownership", false),
|
||||
STORAGE_FILE("storage.file", "saves.yml"),
|
||||
@ -122,7 +122,7 @@ public class Settings {
|
||||
SUBPLUGIN_FOLDER("subplugins.folder", "plugins"),
|
||||
TALK_CLOSE_MAXIMUM_COOLDOWN("npc.text.max-talk-cooldown", 5),
|
||||
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),
|
||||
USE_BOAT_CONTROLS("npc.controllable.use-boat-controls", true),
|
||||
USE_NEW_PATHFINDER("npc.pathfinding.use-new-finder", false),
|
||||
|
@ -287,9 +287,12 @@ public class CitizensNPC extends AbstractNPC {
|
||||
NMS.trySwim(getEntity());
|
||||
}
|
||||
navigator.run();
|
||||
if (SUPPORT_GLOWING) {
|
||||
try {
|
||||
getEntity().setGlowing(data().get(NPC.GLOWING_METADATA, false));
|
||||
} catch (NoSuchMethodError e) {
|
||||
SUPPORT_GLOWING = false;
|
||||
}
|
||||
}
|
||||
if (!getNavigator().isNavigating() && updateCounter++ > Setting.PACKET_UPDATE_DELAY.asInt()) {
|
||||
updateCounter = 0;
|
||||
@ -310,11 +313,15 @@ public class CitizensNPC extends AbstractNPC {
|
||||
team.unregister();
|
||||
data().remove(NPC.SCOREBOARD_FAKE_TEAM_NAME_METADATA);
|
||||
} else {
|
||||
if (SUPPORT_TEAM_SETOPTION) {
|
||||
try {
|
||||
team.setOption(Option.NAME_TAG_VISIBILITY,
|
||||
nameVisibility ? OptionStatus.ALWAYS : OptionStatus.NEVER);
|
||||
} catch (NoSuchMethodError e) {
|
||||
SUPPORT_TEAM_SETOPTION = false;
|
||||
} catch (NoClassDefFoundError e) {
|
||||
SUPPORT_TEAM_SETOPTION = false;
|
||||
}
|
||||
}
|
||||
if (data().has(NPC.GLOWING_COLOR_METADATA)) {
|
||||
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 {
|
||||
getEntity().setSilent(Boolean.parseBoolean(data().get(NPC.SILENT_METADATA).toString()));
|
||||
} catch (NoSuchMethodError e) {
|
||||
SUPPORT_SILENT = false;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
@ -369,4 +377,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ public class FollowTrait extends Trait {
|
||||
}
|
||||
this.followingUUID = player.getUniqueId();
|
||||
if (npc.getNavigator().isNavigating() && this.player != null
|
||||
&& npc.getNavigator().getEntityTarget() != null
|
||||
&& this.player == npc.getNavigator().getEntityTarget().getTarget()) {
|
||||
npc.getNavigator().cancelNavigation();
|
||||
}
|
||||
|
@ -237,8 +237,17 @@ public class Util {
|
||||
if (parts.contains("*"))
|
||||
return true;
|
||||
for (String part : Splitter.on(',').split(parts)) {
|
||||
if ((SpigotUtil.isUsing1_13API() ? Material.matchMaterial(part, true)
|
||||
: Material.matchMaterial(part)) == player.getInventory().getItemInHand().getType()) {
|
||||
Material matchMaterial = SpigotUtil.isUsing1_13API() ? Material.matchMaterial(part, true)
|
||||
: 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;
|
||||
}
|
||||
}
|
||||
|
@ -1320,7 +1320,7 @@ public class NMSImpl implements NMSBridge {
|
||||
} else {
|
||||
float f9 = 0.91F;
|
||||
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;
|
||||
float f4;
|
||||
float f3;
|
||||
@ -1407,12 +1407,12 @@ public class NMSImpl implements NMSBridge {
|
||||
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 {
|
||||
return blockPos.c(x, y, z);
|
||||
} catch (NoSuchMethodError ex) {
|
||||
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) {
|
||||
ex2.printStackTrace();
|
||||
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,
|
||||
EntityType.SHULKER, EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME,
|
||||
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);
|
||||
private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle");
|
||||
private static final float DEFAULT_SPEED = 1F;
|
||||
|
@ -185,11 +185,11 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
|
||||
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) {
|
||||
if (var5 == PathType.WALKABLE) {
|
||||
BlockPosition.b var6 = BlockPosition.b.r();
|
||||
BlockPosition.PooledBlockPosition var6 = BlockPosition.PooledBlockPosition.r();
|
||||
Throwable var7 = null;
|
||||
|
||||
try {
|
||||
@ -202,7 +202,7 @@ public class PlayerPathfinderNormal extends PlayerPathfinderAbstract {
|
||||
}
|
||||
catch (NoSuchMethodError ex) {
|
||||
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) {
|
||||
ex2.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user