mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-16 07:35:32 +01:00
Fix skin trait and text bugs
This commit is contained in:
parent
261ac1b4b1
commit
918fcb9ca7
@ -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() {
|
||||||
|
try {
|
||||||
trait.setSkinPersistent(uuid, signature, textureEncoded);
|
trait.setSkinPersistent(uuid, signature, textureEncoded);
|
||||||
Messaging.sendTr(sender, Messages.SKIN_URL_SET, npc.getName(), url);
|
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) {
|
||||||
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user