Fix skin trait and text bugs

This commit is contained in:
fullwall 2021-01-15 19:00:30 +08:00
parent 261ac1b4b1
commit 918fcb9ca7
3 changed files with 17 additions and 11 deletions

View File

@ -1851,8 +1851,12 @@ public class NPCCommands {
Bukkit.getScheduler().runTask(CitizensAPI.getPlugin(), new Runnable() { Bukkit.getScheduler().runTask(CitizensAPI.getPlugin(), new Runnable() {
@Override @Override
public void run() { public void run() {
trait.setSkinPersistent(uuid, signature, textureEncoded); try {
Messaging.sendTr(sender, Messages.SKIN_URL_SET, npc.getName(), url); trait.setSkinPersistent(uuid, signature, textureEncoded);
Messaging.sendTr(sender, Messages.SKIN_URL_SET, npc.getName(), url);
} catch (IllegalArgumentException e) {
Messaging.sendErrorTr(sender, Messages.ERROR_SETTING_SKIN_URL, url);
}
} }
}); });
} catch (Throwable t) { } catch (Throwable t) {

View File

@ -1,5 +1,9 @@
package net.citizensnpcs.npc.ai.speech; package net.citizensnpcs.npc.ai.speech;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import net.citizensnpcs.api.CitizensAPI; import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.ai.speech.SpeechContext; import net.citizensnpcs.api.ai.speech.SpeechContext;
import net.citizensnpcs.api.ai.speech.Talkable; import net.citizensnpcs.api.ai.speech.Talkable;
@ -9,10 +13,6 @@ import net.citizensnpcs.api.ai.speech.event.SpeechTargetedEvent;
import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Messaging; import net.citizensnpcs.api.util.Messaging;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class TalkableEntity implements Talkable { public class TalkableEntity implements Talkable {
Entity entity; Entity entity;
@ -66,9 +66,9 @@ public class TalkableEntity implements Talkable {
} }
} }
private void talk(String message) { private void talk(NPC npc, String message) {
if (entity instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(entity)) { if (entity instanceof Player && !CitizensAPI.getNPCRegistry().isNPC(entity)) {
Messaging.send((Player) entity, message); Messaging.sendWithNPC(entity, message, npc);
} }
} }
@ -78,7 +78,8 @@ public class TalkableEntity implements Talkable {
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) if (event.isCancelled())
return; return;
talk(event.getMessage()); NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getContext().getTalker().getEntity());
talk(npc, event.getMessage());
} }
@Override @Override
@ -87,7 +88,8 @@ public class TalkableEntity implements Talkable {
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) if (event.isCancelled())
return; return;
talk(event.getMessage()); NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getContext().getTalker().getEntity());
talk(npc, event.getMessage());
} }
} }

View File

@ -198,7 +198,7 @@ public class SkinTrait extends Trait {
Preconditions.checkNotNull(data); Preconditions.checkNotNull(data);
setSkinNameInternal(skinName); setSkinNameInternal(skinName);
String json = new String(BaseEncoding.base64().decode(textureRaw), Charsets.UTF_8); String json = new String(BaseEncoding.base64().decode(data), Charsets.UTF_8);
if (!json.contains("textures")) { if (!json.contains("textures")) {
throw new IllegalArgumentException("Invalid texture data"); throw new IllegalArgumentException("Invalid texture data");
} }