Use new duration option
This commit is contained in:
parent
eb63c91a38
commit
513a6c7cce
|
@ -190,6 +190,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -111,33 +111,33 @@ public class ProtocolLibListener {
|
||||||
return;
|
return;
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
PlayerInfoData info = list.get(i);
|
PlayerInfoData npcInfo = list.get(i);
|
||||||
if (info == null)
|
if (npcInfo == null)
|
||||||
continue;
|
continue;
|
||||||
NPC npc = CitizensAPI.getNPCRegistry().getByUniqueIdGlobal(info.getProfile().getUUID());
|
NPC npc = CitizensAPI.getNPCRegistry().getByUniqueIdGlobal(npcInfo.getProfile().getUUID());
|
||||||
if (npc == null || !npc.isSpawned())
|
if (npc == null || !npc.isSpawned())
|
||||||
continue;
|
continue;
|
||||||
MirrorTrait trait = npc.getTraitNullable(MirrorTrait.class);
|
MirrorTrait trait = npc.getTraitNullable(MirrorTrait.class);
|
||||||
if (trait == null || !trait.isMirroring(event.getPlayer())) {
|
if (trait == null || !trait.isMirroring(event.getPlayer())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GameProfile profile = NMS.getProfile(event.getPlayer());
|
GameProfile playerProfile = NMS.getProfile(event.getPlayer());
|
||||||
if (trait.mirrorName()) {
|
if (trait.mirrorName()) {
|
||||||
list.set(i,
|
list.set(i,
|
||||||
new PlayerInfoData(
|
new PlayerInfoData(
|
||||||
WrappedGameProfile.fromPlayer(event.getPlayer()).withId(
|
WrappedGameProfile.fromPlayer(event.getPlayer())
|
||||||
info.getProfile().getId()),
|
.withId(npcInfo.getProfile().getId()),
|
||||||
info.getLatency(), info.getGameMode(),
|
npcInfo.getLatency(), npcInfo.getGameMode(),
|
||||||
WrappedChatComponent.fromText(event.getPlayer().getDisplayName())));
|
WrappedChatComponent.fromText(event.getPlayer().getDisplayName())));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Collection<Property> textures = profile.getProperties().get("textures");
|
Collection<Property> textures = playerProfile.getProperties().get("textures");
|
||||||
if (textures == null || textures.size() == 0)
|
if (textures == null || textures.size() == 0)
|
||||||
continue;
|
continue;
|
||||||
info.getProfile().getProperties().clear();
|
npcInfo.getProfile().getProperties().clear();
|
||||||
for (String key : profile.getProperties().keySet()) {
|
for (String key : playerProfile.getProperties().keySet()) {
|
||||||
info.getProfile().getProperties().putAll(key,
|
npcInfo.getProfile().getProperties().putAll(key,
|
||||||
Iterables.transform(profile.getProperties().get(key),
|
Iterables.transform(playerProfile.getProperties().get(key),
|
||||||
skin -> new WrappedSignedProperty(skin.getName(), skin.getValue(),
|
skin -> new WrappedSignedProperty(skin.getName(), skin.getValue(),
|
||||||
skin.getSignature())));
|
skin.getSignature())));
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,7 +314,7 @@ public class Settings {
|
||||||
|
|
||||||
public int asSeconds() {
|
public int asSeconds() {
|
||||||
if (duration == null) {
|
if (duration == null) {
|
||||||
duration = SpigotUtil.parseDuration(asString());
|
duration = SpigotUtil.parseDuration(asString(), null);
|
||||||
}
|
}
|
||||||
return Util.convert(TimeUnit.SECONDS, duration);
|
return Util.convert(TimeUnit.SECONDS, duration);
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ public class Settings {
|
||||||
|
|
||||||
public int asTicks() {
|
public int asTicks() {
|
||||||
if (duration == null) {
|
if (duration == null) {
|
||||||
duration = SpigotUtil.parseDuration(asString());
|
duration = SpigotUtil.parseDuration(asString(), null);
|
||||||
}
|
}
|
||||||
return Util.toTicks(duration);
|
return Util.toTicks(duration);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2996,7 +2996,7 @@ public class NPCCommands {
|
||||||
flags = "t",
|
flags = "t",
|
||||||
permission = "citizens.npc.targetable")
|
permission = "citizens.npc.targetable")
|
||||||
public void targetable(CommandContext args, CommandSender sender, NPC npc) {
|
public void targetable(CommandContext args, CommandSender sender, NPC npc) {
|
||||||
boolean targetable = !npc.data().get(NPC.Metadata.TARGETABLE, npc.isProtected());
|
boolean targetable = !npc.data().get(NPC.Metadata.TARGETABLE, !npc.isProtected());
|
||||||
if (args.hasFlag('t')) {
|
if (args.hasFlag('t')) {
|
||||||
npc.data().set(NPC.Metadata.TARGETABLE, targetable);
|
npc.data().set(NPC.Metadata.TARGETABLE, targetable);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -139,12 +139,9 @@ public class Skin {
|
||||||
if (!npc.isSpawned())
|
if (!npc.isSpawned())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
||||||
@Override
|
npc.despawn(DespawnReason.PENDING_RESPAWN);
|
||||||
public void run() {
|
npc.spawn(npc.getStoredLocation(), SpawnReason.RESPAWN);
|
||||||
npc.despawn(DespawnReason.PENDING_RESPAWN);
|
|
||||||
npc.spawn(npc.getStoredLocation(), SpawnReason.RESPAWN);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,6 @@ public class StringHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String wrapHeader(Object string) {
|
public static String wrapHeader(Object string) {
|
||||||
return "<yellow>=====[ </yellow>" + string.toString() + "<yellow> ]=====";
|
return "<yellow>=====[</yellow> " + string.toString() + "<yellow> ]=====";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -339,7 +339,7 @@ public class Util {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int parseTicks(String raw) {
|
public static int parseTicks(String raw) {
|
||||||
Duration duration = SpigotUtil.parseDuration(raw);
|
Duration duration = SpigotUtil.parseDuration(raw, null);
|
||||||
return duration == null ? -1 : toTicks(duration);
|
return duration == null ? -1 : toTicks(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
|
@ -51,16 +51,13 @@ public class HumanController extends AbstractEntityController {
|
||||||
if (skin != null) {
|
if (skin != null) {
|
||||||
skin.apply(handle);
|
skin.apply(handle);
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
||||||
@Override
|
if (getBukkitEntity() == null || !getBukkitEntity().isValid()
|
||||||
public void run() {
|
|| getBukkitEntity() != handle.getBukkitEntity())
|
||||||
if (getBukkitEntity() == null || !getBukkitEntity().isValid()
|
return;
|
||||||
|| getBukkitEntity() != handle.getBukkitEntity())
|
boolean removeFromPlayerList = npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST,
|
||||||
return;
|
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
||||||
boolean removeFromPlayerList = npc.data().get(NPC.Metadata.REMOVE_FROM_PLAYERLIST,
|
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
|
||||||
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
|
|
||||||
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
|
|
||||||
}
|
|
||||||
}, 20);
|
}, 20);
|
||||||
handle.getBukkitEntity().setSleepingIgnored(true);
|
handle.getBukkitEntity().setSleepingIgnored(true);
|
||||||
return handle.getBukkitEntity();
|
return handle.getBukkitEntity();
|
||||||
|
|
|
@ -62,9 +62,9 @@ public class CitizensEntityTracker extends ChunkMap.TrackedEntity {
|
||||||
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
final ServerPlayer entityplayer = lastUpdatedPlayer;
|
||||||
boolean sendTabRemove = NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
boolean sendTabRemove = NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
|
||||||
if (!sendTabRemove || !Setting.DISABLE_TABLIST.asBoolean()) {
|
if (!sendTabRemove || !Setting.DISABLE_TABLIST.asBoolean()) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(),
|
||||||
NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0));
|
() -> NMSImpl.sendPacket(entityplayer.getBukkitEntity(), new ClientboundAnimatePacket(tracker, 0)),
|
||||||
}, 1);
|
1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), () -> {
|
||||||
|
|
|
@ -1183,39 +1183,39 @@ public class NMSImpl implements NMSBridge {
|
||||||
List<ClientboundPlayerInfoUpdatePacket.Entry> list = Lists.newArrayList(packet.entries());
|
List<ClientboundPlayerInfoUpdatePacket.Entry> list = Lists.newArrayList(packet.entries());
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
ClientboundPlayerInfoUpdatePacket.Entry info = list.get(i);
|
ClientboundPlayerInfoUpdatePacket.Entry npcInfo = list.get(i);
|
||||||
if (info == null)
|
if (npcInfo == null)
|
||||||
continue;
|
continue;
|
||||||
NPC npc = CitizensAPI.getNPCRegistry().getByUniqueIdGlobal(info.profileId());
|
NPC npc = CitizensAPI.getNPCRegistry().getByUniqueIdGlobal(npcInfo.profileId());
|
||||||
if (npc == null || !npc.isSpawned())
|
if (npc == null || !npc.isSpawned())
|
||||||
continue;
|
continue;
|
||||||
if (Setting.DISABLE_TABLIST.asBoolean() != info.listed()) {
|
if (Setting.DISABLE_TABLIST.asBoolean() != npcInfo.listed()) {
|
||||||
list.set(i,
|
list.set(i,
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(info.profileId(), info.profile(),
|
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), npcInfo.profile(),
|
||||||
!Setting.DISABLE_TABLIST.asBoolean(), info.latency(), info.gameMode(),
|
!Setting.DISABLE_TABLIST.asBoolean(), npcInfo.latency(), npcInfo.gameMode(),
|
||||||
!Setting.DISABLE_TABLIST.asBoolean() ? info.displayName() : Component.empty(),
|
!Setting.DISABLE_TABLIST.asBoolean() ? npcInfo.displayName() : Component.empty(),
|
||||||
info.chatSession()));
|
npcInfo.chatSession()));
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
MirrorTrait trait = npc.getTraitNullable(MirrorTrait.class);
|
MirrorTrait trait = npc.getTraitNullable(MirrorTrait.class);
|
||||||
if (trait == null || !trait.isMirroring(player)) {
|
if (trait == null || !trait.isMirroring(player)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
GameProfile profile = NMS.getProfile(player);
|
GameProfile playerProfile = NMS.getProfile(player);
|
||||||
if (trait.mirrorName()) {
|
if (trait.mirrorName()) {
|
||||||
list.set(i,
|
list.set(i,
|
||||||
new ClientboundPlayerInfoUpdatePacket.Entry(info.profileId(), profile,
|
new ClientboundPlayerInfoUpdatePacket.Entry(npcInfo.profileId(), playerProfile,
|
||||||
!Setting.DISABLE_TABLIST.asBoolean(), info.latency(), info.gameMode(),
|
!Setting.DISABLE_TABLIST.asBoolean(), npcInfo.latency(), npcInfo.gameMode(),
|
||||||
Component.literal(profile.getName()), info.chatSession()));
|
Component.literal(playerProfile.getName()), npcInfo.chatSession()));
|
||||||
changed = true;
|
changed = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Collection<Property> textures = profile.getProperties().get("textures");
|
Collection<Property> textures = playerProfile.getProperties().get("textures");
|
||||||
if (textures == null || textures.size() == 0)
|
if (textures == null || textures.size() == 0)
|
||||||
continue;
|
continue;
|
||||||
info.profile().getProperties().clear();
|
npcInfo.profile().getProperties().clear();
|
||||||
for (String key : profile.getProperties().keySet()) {
|
for (String key : playerProfile.getProperties().keySet()) {
|
||||||
info.profile().getProperties().putAll(key, profile.getProperties().get(key));
|
npcInfo.profile().getProperties().putAll(key, playerProfile.getProperties().get(key));
|
||||||
}
|
}
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
@ -1260,8 +1260,8 @@ public class NMSImpl implements NMSBridge {
|
||||||
container.getBukkitView().setItem(0, anvil.getItem(0));
|
container.getBukkitView().setItem(0, anvil.getItem(0));
|
||||||
container.getBukkitView().setItem(1, anvil.getItem(1));
|
container.getBukkitView().setItem(1, anvil.getItem(1));
|
||||||
container.checkReachable = false;
|
container.checkReachable = false;
|
||||||
handle.connection.send(new ClientboundOpenScreenPacket(container.containerId, container.getType(),
|
handle.connection.send(
|
||||||
MutableComponent.create(new LiteralContents(title))));
|
new ClientboundOpenScreenPacket(container.containerId, container.getType(), container.getTitle()));
|
||||||
handle.containerMenu = container;
|
handle.containerMenu = container;
|
||||||
handle.initMenu(container);
|
handle.initMenu(container);
|
||||||
return container.getBukkitView();
|
return container.getBukkitView();
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<release>8</release>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
Loading…
Reference in New Issue