forge message color

This commit is contained in:
Jesse Boyd 2016-06-07 07:50:12 +10:00
parent b30007a4e4
commit 0c8291bbc8
5 changed files with 29 additions and 9 deletions

View File

@ -37,6 +37,13 @@ public class PlayerWrapper implements Player {
this.parent = parent; this.parent = parent;
} }
public static PlayerWrapper wrap(Player parent) {
if (parent instanceof PlayerWrapper) {
return (PlayerWrapper) parent;
}
return new PlayerWrapper(parent);
}
public Player getParent() { public Player getParent() {
return parent; return parent;
} }
@ -223,18 +230,28 @@ public class PlayerWrapper implements Player {
} }
@Override @Override
public WorldVector getBlockTrace(int range, boolean useLastBlock) { public WorldVector getBlockTrace(final int range, final boolean useLastBlock) {
return parent.getBlockTrace(range, useLastBlock); return TaskManager.IMP.sync(new RunnableVal<WorldVector>() {
@Override
public void run(WorldVector value) {
this.value = parent.getBlockTrace(range, useLastBlock);
}
});
} }
@Override @Override
public WorldVectorFace getBlockTraceFace(int range, boolean useLastBlock) { public WorldVectorFace getBlockTraceFace(final int range, final boolean useLastBlock) {
return parent.getBlockTraceFace(range, useLastBlock); return TaskManager.IMP.sync(new RunnableVal<WorldVectorFace>() {
@Override
public void run(WorldVectorFace value) {
this.value = parent.getBlockTraceFace(range, useLastBlock);
}
});
} }
@Override @Override
public WorldVector getBlockTrace(int range) { public WorldVector getBlockTrace(int range) {
return parent.getBlockTrace(range); return getBlockTrace(range, false);
} }
@Override @Override

View File

@ -245,7 +245,7 @@ public final class CommandManager {
return; return;
} }
fp.setMeta("fawe_action", true); fp.setMeta("fawe_action", true);
locals.put(Actor.class, new PlayerWrapper((Player) actor)); locals.put(Actor.class, PlayerWrapper.wrap((Player) actor));
} else { } else {
locals.put(Actor.class, actor); locals.put(Actor.class, actor);
} }

View File

@ -23,6 +23,7 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.wrappers.PlayerWrapper;
import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.ServerInterface; import com.sk89q.worldedit.ServerInterface;
@ -440,7 +441,7 @@ public class PlatformManager {
public void handlePlayerInput(PlayerInputEvent event) { public void handlePlayerInput(PlayerInputEvent event) {
// Create a proxy actor with a potentially different world for // Create a proxy actor with a potentially different world for
// making changes to the world // making changes to the world
final Player player = createProxyActor(event.getPlayer()); final Player player = PlayerWrapper.wrap(createProxyActor(event.getPlayer()));
try { try {
switch (event.getInputType()) { switch (event.getInputType()) {
case PRIMARY: { case PRIMARY: {

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.forge; package com.boydti.fawe.forge;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLocation; import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
@ -51,7 +52,7 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
@Override @Override
public void sendMessage(String msg) { public void sendMessage(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
part = EnumChatFormatting.getTextWithoutFormattingCodes(msg); part = BBC.color(part);
ChatComponentText component = new ChatComponentText(part); ChatComponentText component = new ChatComponentText(part);
component.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE); component.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE);
this.parent.addChatMessage(component); this.parent.addChatMessage(component);

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.forge; package com.boydti.fawe.forge;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings; import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLocation; import com.boydti.fawe.object.FaweLocation;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
@ -51,7 +52,7 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
@Override @Override
public void sendMessage(String msg) { public void sendMessage(String msg) {
for (String part : msg.split("\n")) { for (String part : msg.split("\n")) {
part = EnumChatFormatting.getTextWithoutFormattingCodes(msg); part = BBC.color(part);
ChatComponentText component = new ChatComponentText(part); ChatComponentText component = new ChatComponentText(part);
component.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE); component.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE);
this.parent.addChatMessage(component); this.parent.addChatMessage(component);