PandacubeUtil n'est plus un plugin indépendant

- PandacubeUtil est maintenant intégré dans le packetage .jar des
plugins Bungee et Spigot.
- Les librairies importés sont réorganisés. PandacubeUtil ne dépend plus
de BungeeCord et de Spigot
- L'API chat de Bungee (couleur, mise en forme chat) est intégré à
PandacubeUtil (code décompilé)
This commit is contained in:
Marc Baloup 2016-07-05 13:32:17 +02:00
parent a25f294ffa
commit 8463042cc7
17 changed files with 930 additions and 60 deletions

View File

@ -4,7 +4,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="resources"/> <classpathentry kind="src" path="resources"/>
<classpathentry kind="lib" path="lib/BungeePerms-3.0-alpha-1_modif.jar"/> <classpathentry kind="lib" path="lib/BungeePerms-3.0-alpha-1_modif.jar"/>
<classpathentry kind="lib" path="lib/spigot-1.9.4.jar" sourcepath="lib/spigot-1.9.4_source.zip"/> <classpathentry kind="lib" path="lib/commons-lang-2.6.jar"/>
<classpathentry kind="lib" path="lib/BungeeCord-1156.jar" sourcepath="lib/BungeeCord-1156_source.zip"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jardesc>
<jar path="PandacubeUtil/jar_export/PandacubeUtil-1.0-beta4.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/PandacubeUtil/make_jar.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="false" manifestLocation="/PandacubeUtil/manifest" manifestVersion="1.0" reuseManifest="true" saveManifest="true" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<javaElement handleIdentifier="=PandacubeUtil/resources"/>
<javaElement handleIdentifier="=PandacubeUtil/src"/>
</selectedElements>
</jardesc>

View File

@ -1 +0,0 @@
Manifest-Version: 1.0

View File

@ -1,4 +0,0 @@
name: PandacubeUtil
main: fr.pandacube.java.BungeeMain
version: 1.0-beta4
author: Marc Baloup (marcbal)

View File

@ -1,4 +0,0 @@
name: PandacubeUtil
main: fr.pandacube.java.SpigotMain
version: 1.0-beta4
author: Marc Baloup (marcbal)

View File

@ -1,13 +0,0 @@
package fr.pandacube.java;
import net.md_5.bungee.api.plugin.Plugin;
public class BungeeMain extends Plugin {
@Override
public void onLoad() {
PandacubeUtil.setMasterLogger(getProxy().getLogger());
PandacubeUtil.setPluginLogger(getLogger());
}
}

View File

@ -1,13 +0,0 @@
package fr.pandacube.java;
import org.bukkit.plugin.java.JavaPlugin;
public class SpigotMain extends JavaPlugin {
@Override
public void onLoad() {
PandacubeUtil.setMasterLogger(getServer().getLogger());
PandacubeUtil.setPluginLogger(getLogger());
}
}

View File

@ -5,14 +5,11 @@ import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import org.bukkit.plugin.java.JavaPlugin;
public class DBConnection { public class DBConnection {
JavaPlugin plugin;
Connection conn; Connection conn;
String url; private String url;
String login; private String login;
String pass; private String pass;
public DBConnection(String host, int port, String dbname, String l, String p) throws ClassNotFoundException, SQLException { public DBConnection(String host, int port, String dbname, String l, String p) throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");

View File

@ -61,6 +61,7 @@ public abstract class Packet implements ByteSerializable {
} }
} }
@SuppressWarnings("unused")
private static <T extends Packet> void addPacket(Class<T> packetClass) { private static <T extends Packet> void addPacket(Class<T> packetClass) {
try { try {
Packet p = (Packet)packetClass.newInstance(); Packet p = (Packet)packetClass.newInstance();

View File

@ -0,0 +1,85 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
public enum ChatColor {
BLACK('0', "black"),
DARK_BLUE('1', "dark_blue"),
DARK_GREEN('2', "dark_green"),
DARK_AQUA('3', "dark_aqua"),
DARK_RED('4', "dark_red"),
DARK_PURPLE('5', "dark_purple"),
GOLD('6', "gold"),
GRAY('7', "gray"),
DARK_GRAY('8', "dark_gray"),
BLUE('9', "blue"),
GREEN('a', "green"),
AQUA('b', "aqua"),
RED('c', "red"),
LIGHT_PURPLE('d', "light_purple"),
YELLOW('e', "yellow"),
WHITE('f', "white"),
MAGIC('k', "obfuscated"),
BOLD('l', "bold"),
STRIKETHROUGH('m', "strikethrough"),
UNDERLINE('n', "underline"),
ITALIC('o', "italic"),
RESET('r', "reset");
public static final char COLOR_CHAR = '\u00a7';
public static final String ALL_CODES = "0123456789AaBbCcDdEeFfKkLlMmNnOoRr";
public static final Pattern STRIP_COLOR_PATTERN;
private static final Map<Character, ChatColor> BY_CHAR;
private final char code;
private final String toString;
private final String name;
private ChatColor(char code, String name) {
this.code = code;
this.name = name;
this.toString = new String(new char[]{'\u00a7', code});
}
public String toString() {
return this.toString;
}
public static String stripColor(String input) {
if (input == null) {
return null;
}
return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
}
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) {
char[] b2 = textToTranslate.toCharArray();
for (int i = 0; i < b2.length - 1; ++i) {
if (b2[i] != altColorChar || "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b2[i + 1]) <= -1) continue;
b2[i] = 167;
b2[i + 1] = Character.toLowerCase(b2[i + 1]);
}
return new String(b2);
}
public static ChatColor getByChar(char code) {
return BY_CHAR.get(Character.valueOf(code));
}
public String getName() {
return this.name;
}
static {
STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]");
BY_CHAR = new HashMap<Character, ChatColor>();
for (ChatColor colour : ChatColor.values()) {
BY_CHAR.put(Character.valueOf(colour.code), colour);
}
}
}

View File

@ -0,0 +1,15 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api;
public enum ChatMessageType {
CHAT,
SYSTEM,
ACTION_BAR;
private ChatMessageType() {
}
}

View File

@ -0,0 +1,240 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.util.ArrayList;
import java.util.List;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
public abstract class BaseComponent {
BaseComponent parent;
private ChatColor color;
private Boolean bold;
private Boolean italic;
private Boolean underlined;
private Boolean strikethrough;
private Boolean obfuscated;
private String insertion;
private List<BaseComponent> extra;
private ClickEvent clickEvent;
private HoverEvent hoverEvent;
BaseComponent(BaseComponent old) {
this.setColor(old.getColorRaw());
this.setBold(old.isBoldRaw());
this.setItalic(old.isItalicRaw());
this.setUnderlined(old.isUnderlinedRaw());
this.setStrikethrough(old.isStrikethroughRaw());
this.setObfuscated(old.isObfuscatedRaw());
this.setInsertion(old.getInsertion());
this.setClickEvent(old.getClickEvent());
this.setHoverEvent(old.getHoverEvent());
if (old.getExtra() != null) {
for (BaseComponent component : old.getExtra()) {
this.addExtra(component.duplicate());
}
}
}
public abstract BaseComponent duplicate();
public static /* varargs */ String toLegacyText(BaseComponent ... components) {
StringBuilder builder = new StringBuilder();
for (BaseComponent msg : components) {
builder.append(msg.toLegacyText());
}
return builder.toString();
}
public static /* varargs */ String toPlainText(BaseComponent ... components) {
StringBuilder builder = new StringBuilder();
for (BaseComponent msg : components) {
builder.append(msg.toPlainText());
}
return builder.toString();
}
public ChatColor getColor() {
if (this.color == null) {
if (this.parent == null) {
return ChatColor.WHITE;
}
return this.parent.getColor();
}
return this.color;
}
public ChatColor getColorRaw() {
return this.color;
}
public boolean isBold() {
if (this.bold == null) {
return this.parent != null && this.parent.isBold();
}
return this.bold;
}
public Boolean isBoldRaw() {
return this.bold;
}
public boolean isItalic() {
if (this.italic == null) {
return this.parent != null && this.parent.isItalic();
}
return this.italic;
}
public Boolean isItalicRaw() {
return this.italic;
}
public boolean isUnderlined() {
if (this.underlined == null) {
return this.parent != null && this.parent.isUnderlined();
}
return this.underlined;
}
public Boolean isUnderlinedRaw() {
return this.underlined;
}
public boolean isStrikethrough() {
if (this.strikethrough == null) {
return this.parent != null && this.parent.isStrikethrough();
}
return this.strikethrough;
}
public Boolean isStrikethroughRaw() {
return this.strikethrough;
}
public boolean isObfuscated() {
if (this.obfuscated == null) {
return this.parent != null && this.parent.isObfuscated();
}
return this.obfuscated;
}
public Boolean isObfuscatedRaw() {
return this.obfuscated;
}
public void setExtra(List<BaseComponent> components) {
for (BaseComponent component : components) {
component.parent = this;
}
this.extra = components;
}
public void addExtra(String text) {
this.addExtra(new TextComponent(text));
}
public void addExtra(BaseComponent component) {
if (this.extra == null) {
this.extra = new ArrayList<BaseComponent>();
}
component.parent = this;
this.extra.add(component);
}
public boolean hasFormatting() {
return this.color != null || this.bold != null || this.italic != null || this.underlined != null || this.strikethrough != null || this.obfuscated != null || this.hoverEvent != null || this.clickEvent != null;
}
public String toPlainText() {
StringBuilder builder = new StringBuilder();
this.toPlainText(builder);
return builder.toString();
}
void toPlainText(StringBuilder builder) {
if (this.extra != null) {
for (BaseComponent e2 : this.extra) {
e2.toPlainText(builder);
}
}
}
public String toLegacyText() {
StringBuilder builder = new StringBuilder();
this.toLegacyText(builder);
return builder.toString();
}
void toLegacyText(StringBuilder builder) {
if (this.extra != null) {
for (BaseComponent e2 : this.extra) {
e2.toLegacyText(builder);
}
}
}
public void setColor(ChatColor color) {
this.color = color;
}
public void setBold(Boolean bold) {
this.bold = bold;
}
public void setItalic(Boolean italic) {
this.italic = italic;
}
public void setUnderlined(Boolean underlined) {
this.underlined = underlined;
}
public void setStrikethrough(Boolean strikethrough) {
this.strikethrough = strikethrough;
}
public void setObfuscated(Boolean obfuscated) {
this.obfuscated = obfuscated;
}
public void setInsertion(String insertion) {
this.insertion = insertion;
}
public void setClickEvent(ClickEvent clickEvent) {
this.clickEvent = clickEvent;
}
public void setHoverEvent(HoverEvent hoverEvent) {
this.hoverEvent = hoverEvent;
}
public String toString() {
return "BaseComponent(color=" + (Object)((Object)this.getColor()) + ", bold=" + this.bold + ", italic=" + this.italic + ", underlined=" + this.underlined + ", strikethrough=" + this.strikethrough + ", obfuscated=" + this.obfuscated + ", insertion=" + this.getInsertion() + ", extra=" + this.getExtra() + ", clickEvent=" + this.getClickEvent() + ", hoverEvent=" + this.getHoverEvent() + ")";
}
public BaseComponent() {
}
public String getInsertion() {
return this.insertion;
}
public List<BaseComponent> getExtra() {
return this.extra;
}
public ClickEvent getClickEvent() {
return this.clickEvent;
}
public HoverEvent getHoverEvent() {
return this.hoverEvent;
}
}

View File

@ -0,0 +1,43 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.beans.ConstructorProperties;
public final class ClickEvent {
private final Action action;
private final String value;
public Action getAction() {
return this.action;
}
public String getValue() {
return this.value;
}
public String toString() {
return "ClickEvent(action=" + (Object)((Object)this.getAction()) + ", value=" + this.getValue() + ")";
}
@ConstructorProperties(value={"action", "value"})
public ClickEvent(Action action, String value) {
this.action = action;
this.value = value;
}
public static enum Action {
OPEN_URL,
OPEN_FILE,
RUN_COMMAND,
SUGGEST_COMMAND,
CHANGE_PAGE;
private Action() {
}
}
}

View File

@ -0,0 +1,132 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.util.ArrayList;
import java.util.List;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
public class ComponentBuilder {
private TextComponent current;
private final List<BaseComponent> parts = new ArrayList<BaseComponent>();
public ComponentBuilder(ComponentBuilder original) {
this.current = new TextComponent(original.current);
for (BaseComponent baseComponent : original.parts) {
this.parts.add(baseComponent.duplicate());
}
}
public ComponentBuilder(String text) {
this.current = new TextComponent(text);
}
public ComponentBuilder append(String text) {
return this.append(text, FormatRetention.ALL);
}
public ComponentBuilder append(String text, FormatRetention retention) {
this.parts.add(this.current);
this.current = new TextComponent(this.current);
this.current.setText(text);
this.retain(retention);
return this;
}
public ComponentBuilder color(ChatColor color) {
this.current.setColor(color);
return this;
}
public ComponentBuilder bold(boolean bold) {
this.current.setBold(bold);
return this;
}
public ComponentBuilder italic(boolean italic) {
this.current.setItalic(italic);
return this;
}
public ComponentBuilder underlined(boolean underlined) {
this.current.setUnderlined(underlined);
return this;
}
public ComponentBuilder strikethrough(boolean strikethrough) {
this.current.setStrikethrough(strikethrough);
return this;
}
public ComponentBuilder obfuscated(boolean obfuscated) {
this.current.setObfuscated(obfuscated);
return this;
}
public ComponentBuilder insertion(String insertion) {
this.current.setInsertion(insertion);
return this;
}
public ComponentBuilder event(ClickEvent clickEvent) {
this.current.setClickEvent(clickEvent);
return this;
}
public ComponentBuilder event(HoverEvent hoverEvent) {
this.current.setHoverEvent(hoverEvent);
return this;
}
public ComponentBuilder reset() {
return this.retain(FormatRetention.NONE);
}
public ComponentBuilder retain(FormatRetention retention) {
TextComponent previous = this.current;
switch (retention) {
case NONE: {
this.current = new TextComponent(this.current.getText());
break;
}
case ALL: {
break;
}
case EVENTS: {
this.current = new TextComponent(this.current.getText());
this.current.setInsertion(previous.getInsertion());
this.current.setClickEvent(previous.getClickEvent());
this.current.setHoverEvent(previous.getHoverEvent());
break;
}
case FORMATTING: {
this.current.setClickEvent(null);
this.current.setHoverEvent(null);
}
}
return this;
}
public BaseComponent[] create() {
this.parts.add(this.current);
return this.parts.toArray(new BaseComponent[this.parts.size()]);
}
public static enum FormatRetention {
NONE,
FORMATTING,
EVENTS,
ALL;
private FormatRetention() {
}
}
}

View File

@ -0,0 +1,44 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.beans.ConstructorProperties;
import java.util.Arrays;
import net.md_5.bungee.api.chat.BaseComponent;
public final class HoverEvent {
private final Action action;
private final BaseComponent[] value;
public Action getAction() {
return this.action;
}
public BaseComponent[] getValue() {
return this.value;
}
public String toString() {
return "HoverEvent(action=" + (Object)((Object)this.getAction()) + ", value=" + Arrays.deepToString(this.getValue()) + ")";
}
@ConstructorProperties(value={"action", "value"})
public HoverEvent(Action action, BaseComponent[] value) {
this.action = action;
this.value = value;
}
public static enum Action {
SHOW_TEXT,
SHOW_ACHIEVEMENT,
SHOW_ITEM,
SHOW_ENTITY;
private Action() {
}
}
}

View File

@ -0,0 +1,170 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.beans.ConstructorProperties;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
public class TextComponent
extends BaseComponent {
private static final Pattern url = Pattern.compile("^(?:(https?)://)?([-\\w_\\.]{2,}\\.[a-z]{2,4})(/\\S*)?$");
private String text;
public static BaseComponent[] fromLegacyText(String message) {
ArrayList<TextComponent> components = new ArrayList<TextComponent>();
StringBuilder builder = new StringBuilder();
TextComponent component = new TextComponent();
Matcher matcher = url.matcher(message);
block8 : for (int i = 0; i < message.length(); ++i) {
TextComponent old;
char c2 = message.charAt(i);
if (c2 == '\u00a7') {
ChatColor format;
if ((c2 = message.charAt(++i)) >= 'A' && c2 <= 'Z') {
c2 = (char)(c2 + 32);
}
if ((format = ChatColor.getByChar(c2)) == null) continue;
if (builder.length() > 0) {
old = component;
component = new TextComponent(old);
old.setText(builder.toString());
builder = new StringBuilder();
components.add(old);
}
switch (format) {
case BOLD: {
component.setBold(true);
continue block8;
}
case ITALIC: {
component.setItalic(true);
continue block8;
}
case UNDERLINE: {
component.setUnderlined(true);
continue block8;
}
case STRIKETHROUGH: {
component.setStrikethrough(true);
continue block8;
}
case MAGIC: {
component.setObfuscated(true);
continue block8;
}
case RESET: {
format = ChatColor.WHITE;
}
default:
}
component = new TextComponent();
component.setColor(format);
continue;
}
int pos = message.indexOf(32, i);
if (pos == -1) {
pos = message.length();
}
if (matcher.region(i, pos).find()) {
if (builder.length() > 0) {
old = component;
component = new TextComponent(old);
old.setText(builder.toString());
builder = new StringBuilder();
components.add(old);
}
old = component;
component = new TextComponent(old);
String urlString = message.substring(i, pos);
component.setText(urlString);
component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, urlString.startsWith("http") ? urlString : "http://" + urlString));
components.add(component);
i += pos - i - 1;
component = old;
continue;
}
builder.append(c2);
}
if (builder.length() > 0) {
component.setText(builder.toString());
components.add(component);
}
if (components.isEmpty()) {
components.add(new TextComponent(""));
}
return components.toArray(new BaseComponent[components.size()]);
}
public TextComponent(TextComponent textComponent) {
super(textComponent);
this.setText(textComponent.getText());
}
public /* varargs */ TextComponent(BaseComponent ... extras) {
this.setText("");
this.setExtra(new ArrayList<BaseComponent>(Arrays.asList(extras)));
}
@Override
public BaseComponent duplicate() {
return new TextComponent(this);
}
@Override
protected void toPlainText(StringBuilder builder) {
builder.append(this.text);
super.toPlainText(builder);
}
@Override
protected void toLegacyText(StringBuilder builder) {
builder.append((Object)this.getColor());
if (this.isBold()) {
builder.append((Object)ChatColor.BOLD);
}
if (this.isItalic()) {
builder.append((Object)ChatColor.ITALIC);
}
if (this.isUnderlined()) {
builder.append((Object)ChatColor.UNDERLINE);
}
if (this.isStrikethrough()) {
builder.append((Object)ChatColor.STRIKETHROUGH);
}
if (this.isObfuscated()) {
builder.append((Object)ChatColor.MAGIC);
}
builder.append(this.text);
super.toLegacyText(builder);
}
@Override
public String toString() {
return String.format("TextComponent{text=%s, %s}", this.text, super.toString());
}
public String getText() {
return this.text;
}
public void setText(String text) {
this.text = text;
}
@ConstructorProperties(value={"text"})
public TextComponent(String text) {
this.text = text;
}
public TextComponent() {
}
}

View File

@ -0,0 +1,196 @@
/*
* Decompiled with CFR 0_114.
*/
package net.md_5.bungee.api.chat;
import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
public class TranslatableComponent
extends BaseComponent {
private final ResourceBundle locales = ResourceBundle.getBundle("mojang-translations/en_US");
private final Pattern format = Pattern.compile("%(?:(\\d+)\\$)?([A-Za-z%]|$)");
private String translate;
private List<BaseComponent> with;
public TranslatableComponent(TranslatableComponent original) {
super(original);
this.setTranslate(original.getTranslate());
if (original.getWith() != null) {
ArrayList<BaseComponent> temp = new ArrayList<BaseComponent>();
for (BaseComponent baseComponent : original.getWith()) {
temp.add(baseComponent.duplicate());
}
this.setWith(temp);
}
}
public /* varargs */ TranslatableComponent(String translate, Object ... with) {
this.setTranslate(translate);
ArrayList<BaseComponent> temp = new ArrayList<BaseComponent>();
for (Object w : with) {
if (w instanceof String) {
temp.add(new TextComponent((String)w));
continue;
}
temp.add((BaseComponent)w);
}
this.setWith(temp);
}
@Override
public BaseComponent duplicate() {
return new TranslatableComponent(this);
}
public void setWith(List<BaseComponent> components) {
for (BaseComponent component : components) {
component.parent = this;
}
this.with = components;
}
public void addWith(String text) {
this.addWith(new TextComponent(text));
}
public void addWith(BaseComponent component) {
if (this.with == null) {
this.with = new ArrayList<BaseComponent>();
}
component.parent = this;
this.with.add(component);
}
@Override
protected void toPlainText(StringBuilder builder) {
String trans;
try {
trans = this.locales.getString(this.translate);
}
catch (MissingResourceException ex) {
trans = this.translate;
}
Matcher matcher = this.format.matcher(trans);
int position = 0;
int i = 0;
while (matcher.find(position)) {
int pos = matcher.start();
if (pos != position) {
builder.append(trans.substring(position, pos));
}
position = matcher.end();
String formatCode = matcher.group(2);
switch (formatCode.charAt(0)) {
case 'd':
case 's': {
String withIndex = matcher.group(1);
this.with.get(withIndex != null ? Integer.parseInt(withIndex) - 1 : i++).toPlainText(builder);
break;
}
case '%': {
builder.append('%');
}
}
}
if (trans.length() != position) {
builder.append(trans.substring(position, trans.length()));
}
super.toPlainText(builder);
}
@Override
protected void toLegacyText(StringBuilder builder) {
String trans;
try {
trans = this.locales.getString(this.translate);
}
catch (MissingResourceException e) {
trans = this.translate;
}
Matcher matcher = this.format.matcher(trans);
int position = 0;
int i = 0;
while (matcher.find(position)) {
int pos = matcher.start();
if (pos != position) {
this.addFormat(builder);
builder.append(trans.substring(position, pos));
}
position = matcher.end();
String formatCode = matcher.group(2);
switch (formatCode.charAt(0)) {
case 'd':
case 's': {
String withIndex = matcher.group(1);
this.with.get(withIndex != null ? Integer.parseInt(withIndex) - 1 : i++).toLegacyText(builder);
break;
}
case '%': {
this.addFormat(builder);
builder.append('%');
}
}
}
if (trans.length() != position) {
this.addFormat(builder);
builder.append(trans.substring(position, trans.length()));
}
super.toLegacyText(builder);
}
private void addFormat(StringBuilder builder) {
builder.append((Object)this.getColor());
if (this.isBold()) {
builder.append((Object)ChatColor.BOLD);
}
if (this.isItalic()) {
builder.append((Object)ChatColor.ITALIC);
}
if (this.isUnderlined()) {
builder.append((Object)ChatColor.UNDERLINE);
}
if (this.isStrikethrough()) {
builder.append((Object)ChatColor.STRIKETHROUGH);
}
if (this.isObfuscated()) {
builder.append((Object)ChatColor.MAGIC);
}
}
public ResourceBundle getLocales() {
return this.locales;
}
public Pattern getFormat() {
return this.format;
}
public String getTranslate() {
return this.translate;
}
public List<BaseComponent> getWith() {
return this.with;
}
public void setTranslate(String translate) {
this.translate = translate;
}
@Override
public String toString() {
return "TranslatableComponent(locales=" + this.getLocales() + ", format=" + this.getFormat() + ", translate=" + this.getTranslate() + ", with=" + this.getWith() + ")";
}
public TranslatableComponent() {
}
}