remove italic gui text

This commit is contained in:
Flemmli97 2021-05-12 18:30:35 +02:00
parent da5044d5c4
commit d75f788288
10 changed files with 48 additions and 60 deletions

View File

@ -15,8 +15,6 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -50,22 +48,22 @@ public class ClaimMenuScreenHandler extends ServerOnlyScreenHandler {
switch (i) {
case 0:
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenClose).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenClose, Formatting.DARK_RED));
inv.setStack(i, close);
break;
case 2:
ItemStack perm = new ItemStack(Items.BEACON);
perm.setCustomName(new LiteralText(ConfigHandler.lang.screenMenuGlobal).setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
perm.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGlobal, Formatting.GOLD));
inv.setStack(i, perm);
break;
case 3:
ItemStack group = new ItemStack(Items.WRITABLE_BOOK);
group.setCustomName(new LiteralText(ConfigHandler.lang.screenMenuGroup).setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
group.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuGroup, Formatting.GOLD));
inv.setStack(i, group);
break;
case 8:
ItemStack delete = new ItemStack(Items.BARRIER);
delete.setCustomName(new LiteralText(ConfigHandler.lang.screenMenuDelete).setStyle(Style.EMPTY.withFormatting(Formatting.RED)));
delete.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenMenuDelete, Formatting.RED));
inv.setStack(i, delete);
break;
default:

View File

@ -11,8 +11,6 @@ import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -49,12 +47,12 @@ public class ConfirmScreenHandler extends ServerOnlyScreenHandler {
switch (i) {
case 3:
ItemStack yes = new ItemStack(Items.GREEN_WOOL);
yes.setCustomName(new LiteralText(ConfigHandler.lang.screenYes).setStyle(Style.EMPTY.withFormatting(Formatting.GREEN)));
yes.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenYes, Formatting.GREEN));
inv.setStack(i, yes);
break;
case 5:
ItemStack no = new ItemStack(Items.RED_WOOL);
no.setCustomName(new LiteralText(ConfigHandler.lang.screenNo).setStyle(Style.EMPTY.withFormatting(Formatting.RED)));
no.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNo, Formatting.RED));
inv.setStack(i, no);
break;
default:

View File

@ -17,8 +17,6 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -60,15 +58,15 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED));
inv.setStack(i, close);
} else if (i == 3) {
ItemStack stack = new ItemStack(Items.ANVIL);
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenAdd).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GREEN)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, Formatting.DARK_GREEN));
inv.setStack(i, stack);
} else if (i == 4) {
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode), Formatting.DARK_RED));
inv.setStack(i, stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -123,7 +121,7 @@ public class GroupPlayerScreenHandler extends ServerOnlyScreenHandler {
if (index == 4) {
this.removeMode = !this.removeMode;
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode), Formatting.DARK_RED));
slot.setStack(stack);
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
return true;

View File

@ -13,8 +13,6 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -54,15 +52,15 @@ public class GroupScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText("Back").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(ServerScreenHelper.coloredGuiText("Back", Formatting.DARK_RED));
inv.setStack(i, close);
} else if (i == 3) {
ItemStack stack = new ItemStack(Items.ANVIL);
stack.setCustomName(new LiteralText("Add").setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GREEN)));
stack.setCustomName(ServerScreenHelper.coloredGuiText("Add", Formatting.DARK_GREEN));
inv.setStack(i, stack);
} else if (i == 4) {
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText("Remove Mode: " + this.removeMode).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(ServerScreenHelper.coloredGuiText("Remove Mode: " + this.removeMode, Formatting.DARK_RED));
inv.setStack(i, stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -72,7 +70,7 @@ public class GroupScreenHandler extends ServerOnlyScreenHandler {
int id = (i % 9) + row * 7 - 1;
if (id < groups.size()) {
ItemStack group = new ItemStack(Items.PAPER);
group.setCustomName(new LiteralText(groups.get(id)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_BLUE)));
group.setCustomName(ServerScreenHelper.coloredGuiText(groups.get(id), Formatting.DARK_BLUE));
inv.setStack(i, group);
}
}
@ -110,7 +108,7 @@ public class GroupScreenHandler extends ServerOnlyScreenHandler {
if (index == 4) {
this.removeMode = !this.removeMode;
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText("Remove Mode: " + this.removeMode).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(ServerScreenHelper.coloredGuiText("Remove Mode: " + this.removeMode, Formatting.DARK_RED));
slot.setStack(stack);
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
return true;

View File

@ -15,8 +15,6 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -75,15 +73,15 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
int page = (int) additionalData[2];
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED));
inv.setStack(i, close);
} else if (page == 1 && i == 47) {
ItemStack close = new ItemStack(Items.ARROW);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenPrevious).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenPrevious, Formatting.WHITE));
inv.setStack(i, close);
} else if (page == 0 && i == 51) {
ItemStack close = new ItemStack(Items.ARROW);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenNext).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, Formatting.WHITE));
inv.setStack(i, close);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -104,20 +102,20 @@ public class PermissionScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED));
this.slots.get(i).setStack(close);
} else if (i == 47) {
ItemStack stack = ServerScreenHelper.emptyFiller();
if (this.page >= 1) {
stack = new ItemStack(Items.ARROW);
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenPrevious).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenPrevious, Formatting.WHITE));
}
this.slots.get(i).setStack(stack);
} else if (i == 51) {
ItemStack stack = ServerScreenHelper.emptyFiller();
if (this.page < maxPages) {
stack = new ItemStack(Items.ARROW);
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenNext).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, Formatting.WHITE));
}
this.slots.get(i).setStack(stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)

View File

@ -14,8 +14,6 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -52,15 +50,15 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED));
inv.setStack(i, close);
} else if (i == 3) {
ItemStack stack = new ItemStack(Items.ANVIL);
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenAdd).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GREEN)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenAdd, Formatting.DARK_GREEN));
inv.setStack(i, stack);
} else if (i == 4) {
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode), Formatting.DARK_RED));
inv.setStack(i, stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -71,7 +69,7 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler {
int id = (i % 9) + row * 7 - 1;
if (id < groups.size()) {
ItemStack group = new ItemStack(Items.PAPER);
group.setCustomName(new LiteralText(groups.get(id)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_BLUE)));
group.setCustomName(ServerScreenHelper.coloredGuiText(groups.get(id), Formatting.DARK_BLUE));
inv.setStack(i, group);
}
}
@ -108,7 +106,7 @@ public class PersonalGroupScreenHandler extends ServerOnlyScreenHandler {
if (index == 4) {
this.removeMode = !this.removeMode;
ItemStack stack = new ItemStack(Items.REDSTONE_BLOCK);
stack.setCustomName(new LiteralText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode)).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenRemoveMode, this.removeMode), Formatting.DARK_RED));
slot.setStack(stack);
ServerScreenHelper.playSongToPlayer(player, SoundEvents.UI_BUTTON_CLICK, 1, 1f);
return true;

View File

@ -15,8 +15,6 @@ import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
@ -64,15 +62,15 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler {
int page = (int) additionalData[1];
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED));
inv.setStack(i, close);
} else if (page == 1 && i == 47) {
ItemStack close = new ItemStack(Items.ARROW);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenPrevious).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenPrevious, Formatting.WHITE));
inv.setStack(i, close);
} else if (page == 0 && i == 51) {
ItemStack close = new ItemStack(Items.ARROW);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenNext).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, Formatting.WHITE));
inv.setStack(i, close);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)
inv.setStack(i, ServerScreenHelper.emptyFiller());
@ -95,20 +93,20 @@ public class PersonalPermissionScreenHandler extends ServerOnlyScreenHandler {
for (int i = 0; i < 54; i++) {
if (i == 0) {
ItemStack close = new ItemStack(Items.TNT);
close.setCustomName(new LiteralText(ConfigHandler.lang.screenBack).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED)));
close.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenBack, Formatting.DARK_RED));
this.slots.get(i).setStack(close);
} else if (i == 47) {
ItemStack stack = ServerScreenHelper.emptyFiller();
if (this.page >= 1) {
stack = new ItemStack(Items.ARROW);
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenPrevious).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenPrevious, Formatting.WHITE));
}
this.slots.get(i).setStack(stack);
} else if (i == 51) {
ItemStack stack = ServerScreenHelper.emptyFiller();
if (this.page < maxPages) {
stack = new ItemStack(Items.ARROW);
stack.setCustomName(new LiteralText(ConfigHandler.lang.screenNext).setStyle(Style.EMPTY.withFormatting(Formatting.WHITE)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenNext, Formatting.WHITE));
}
this.slots.get(i).setStack(stack);
} else if (i < 9 || i > 44 || i % 9 == 0 || i % 9 == 8)

View File

@ -76,7 +76,7 @@ public abstract class ServerOnlyScreenHandler extends ScreenHandler {
if (this.isRightSlot(i))
this.handleSlotClicked((ServerPlayerEntity) playerEntity, i, slot, j);
ItemStack stack = slot.getStack().copy();
for(ScreenHandlerListener listener : this.listeners)
for (ScreenHandlerListener listener : this.listeners)
listener.onSlotUpdate(this, i, stack);
((ServerPlayerEntity) playerEntity).updateCursorStack();
return stack;

View File

@ -31,18 +31,18 @@ public class ServerScreenHelper {
public static ItemStack fromPermission(Claim claim, ClaimPermission perm, String group) {
ItemStack stack = perm.getItem();
stack.setCustomName(new LiteralText(perm.id).setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(perm.id, Formatting.GOLD));
ListTag lore = new ListTag();
for (String pdesc : perm.desc) {
Text trans = new LiteralText(pdesc).setStyle(Style.EMPTY.withFormatting(Formatting.YELLOW));
Text trans = ServerScreenHelper.coloredGuiText(pdesc, Formatting.YELLOW);
lore.add(StringTag.of(Text.Serializer.toJson(trans)));
}
Boolean global = ConfigHandler.config.getGlobal(claim.getWorld(), perm);
if (!claim.isAdminClaim() && global != null) {
Text text = new LiteralText(ConfigHandler.lang.screenUneditable).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED));
Text text = ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenUneditable, Formatting.DARK_RED);
lore.add(StringTag.of(Text.Serializer.toJson(text)));
String permFlag = global.toString();
Text text2 = new LiteralText(String.format(ConfigHandler.lang.screenEnableText, permFlag)).setStyle(Style.EMPTY.withFormatting(permFlag.equals("true") ? Formatting.GREEN : Formatting.RED));
Text text2 = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals("true") ? Formatting.GREEN : Formatting.RED);
lore.add(StringTag.of(Text.Serializer.toJson(text2)));
} else {
String permFlag;
@ -75,7 +75,7 @@ public class ServerScreenHelper {
break;
}
}
Text text = new LiteralText(String.format(ConfigHandler.lang.screenEnableText, permFlag)).setStyle(Style.EMPTY.withFormatting(permFlag.equals("true") ? Formatting.GREEN : Formatting.RED));
Text text = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals("true") ? Formatting.GREEN : Formatting.RED);
lore.add(StringTag.of(Text.Serializer.toJson(text)));
}
stack.getOrCreateSubTag("display").put("Lore", lore);
@ -84,18 +84,18 @@ public class ServerScreenHelper {
public static ItemStack getFromPersonal(ServerPlayerEntity player, ClaimPermission perm, String group) {
ItemStack stack = perm.getItem();
stack.setCustomName(new LiteralText(perm.id).setStyle(Style.EMPTY.withFormatting(Formatting.GOLD)));
stack.setCustomName(ServerScreenHelper.coloredGuiText(perm.id, Formatting.GOLD));
ListTag lore = new ListTag();
for (String pdesc : perm.desc) {
Text trans = new LiteralText(pdesc).setStyle(Style.EMPTY.withFormatting(Formatting.YELLOW));
Text trans = ServerScreenHelper.coloredGuiText(pdesc, Formatting.YELLOW);
lore.add(StringTag.of(Text.Serializer.toJson(trans)));
}
Boolean global = ConfigHandler.config.getGlobal(player.getServerWorld(), perm);
if (global != null) {
Text text = new LiteralText(ConfigHandler.lang.screenUneditable).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_RED));
Text text = ServerScreenHelper.coloredGuiText(ConfigHandler.lang.screenUneditable, Formatting.DARK_RED);
lore.add(StringTag.of(Text.Serializer.toJson(text)));
String permFlag = global.toString();
Text text2 = new LiteralText(String.format(ConfigHandler.lang.screenEnableText, permFlag)).setStyle(Style.EMPTY.withFormatting(permFlag.equals("true") ? Formatting.GREEN : Formatting.RED));
Text text2 = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals("true") ? Formatting.GREEN : Formatting.RED);
lore.add(StringTag.of(Text.Serializer.toJson(text2)));
} else {
String permFlag;
@ -104,7 +104,7 @@ public class ServerScreenHelper {
permFlag = map.get(perm) ? "true" : "false";
else
permFlag = "default";
Text text = new LiteralText(String.format(ConfigHandler.lang.screenEnableText, permFlag)).setStyle(Style.EMPTY.withFormatting(permFlag.equals("true") ? Formatting.GREEN : Formatting.RED));
Text text = ServerScreenHelper.coloredGuiText(String.format(ConfigHandler.lang.screenEnableText, permFlag), permFlag.equals("true") ? Formatting.GREEN : Formatting.RED);
lore.add(StringTag.of(Text.Serializer.toJson(text)));
}
stack.getOrCreateSubTag("display").put("Lore", lore);
@ -114,6 +114,9 @@ public class ServerScreenHelper {
public static void playSongToPlayer(ServerPlayerEntity player, SoundEvent event, float vol, float pitch) {
player.networkHandler.sendPacket(
new PlaySoundS2CPacket(event, SoundCategory.PLAYERS, player.getPos().x, player.getPos().y, player.getPos().z, vol, pitch));
}
public static Text coloredGuiText(String text, Formatting... formattings) {
return new LiteralText(text).setStyle(Style.EMPTY.withItalic(false).withFormatting(formattings));
}
}

View File

@ -13,7 +13,6 @@ import net.minecraft.screen.ScreenHandlerListener;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import org.apache.commons.lang3.StringUtils;
@ -37,7 +36,7 @@ public class StringResultScreenHandler extends AnvilScreenHandler {
stack.setCustomName(PermHelper.simpleColoredText(""));
this.input.setStack(0, stack);
ItemStack out = new ItemStack(Items.BOOK);
out.setCustomName(PermHelper.simpleColoredText(ConfigHandler.lang.stringScreenReturn));
out.setCustomName(ServerScreenHelper.coloredGuiText(ConfigHandler.lang.stringScreenReturn));
this.output.setStack(0, out);
this.cons = cons;
this.ret = ret;
@ -130,7 +129,7 @@ public class StringResultScreenHandler extends AnvilScreenHandler {
if (StringUtils.isBlank(this.name))
out.removeCustomName();
else if (!this.name.equals(out.getName().getString())) {
out.setCustomName(new LiteralText(this.name));
out.setCustomName(ServerScreenHelper.coloredGuiText(this.name));
}
}
this.sendContentUpdates();