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