diff --git a/build.gradle b/build.gradle index d7b10c2..41a8041 100644 --- a/build.gradle +++ b/build.gradle @@ -1,124 +1,125 @@ -buildscript { - repositories { - mavenCentral() - mavenLocal() - - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - - } - } - - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' - - } -} - -import net.minecraftforge.gradle.common.Constants -import net.minecraftforge.gradle.delayed.DelayedFile -import net.minecraftforge.gradle.tasks.user.reobf.ArtifactSpec -import net.minecraftforge.gradle.tasks.user.reobf.ReobfTask -import net.minecraftforge.gradle.user.UserBasePlugin -import net.minecraftforge.gradle.user.UserExtension - -apply plugin: 'java' -apply plugin: 'groovy' -apply plugin: 'eclipse' - -sourceCompatibility = '1.6' -targetCompatibility = '1.6' - -repositories { - maven { - name 'forge' - url 'http://files.minecraftforge.net/maven' - } - mavenCentral() - maven { - name 'sonatypeSnapshot' - url 'https://oss.sonatype.org/content/repositories/snapshots/' - } - maven { - name 'minecraft' - url 'https://libraries.minecraft.net/' - } -} - -dependencies { - compile 'net.minecraft:launchwrapper:1.9' - compile 'org.ow2.asm:asm-debug-all:4.1' - compile 'org.scala-lang:scala-library:2.10.2' - compile 'org.scala-lang:scala-compiler:2.10.2' - compile 'net.sf.jopt-simple:jopt-simple:4.5' - compile 'java3d:vecmath:1.3.1' - compile 'net.sf.trove4j:trove4j:3.0.3' - compile 'com.ibm.icu:icu4j-core-mojang:51.2' - compile 'net.sf.jopt-simple:jopt-simple:4.5' - compile 'lzma:lzma:0.0.1' - compile 'com.paulscode:codecjorbis:20101023' - compile 'com.paulscode:codecwav:20101023' - compile 'com.paulscode:libraryjavasound:20101123' - compile 'com.paulscode:librarylwjglopenal:20100824' - compile 'com.paulscode:soundsystem:20120107' - compile 'io.netty:netty-all:4.0.10.Final' - compile 'com.google.guava:guava:15.0' - compile 'org.apache.commons:commons-lang3:3.1' - compile 'commons-io:commons-io:2.4' - compile 'net.java.jinput:jinput:2.0.5' - compile 'net.java.jutils:jutils:1.0.0' - compile 'com.google.code.gson:gson:2.2.4' - compile 'com.mojang:authlib:1.3' - compile 'org.apache.logging.log4j:log4j-api:2.0-beta9' - compile 'org.apache.logging.log4j:log4j-core:2.0-beta9' - compile 'org.lwjgl.lwjgl:lwjgl:2.9.0' - compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.0' - compile 'org.yaml:snakeyaml:1.13' - - testCompile "org.codehaus.groovy:groovy-all:2.3.0" - testCompile "org.spockframework:spock-core:1.0-groovy-2.0-SNAPSHOT" - testCompile 'junit:junit:4.5' - - testRuntime "cglib:cglib-nodep:2.2.2" - testRuntime "org.objenesis:objenesis:1.2" -} - -project.getExtensions().create(Constants.EXT_NAME_MC, UserExtension, { return project } as UserBasePlugin) - -task reobf(type: ReobfTask) { - setExceptorCfg(delayedFile('conf/srg.exc')) - setSrg(delayedFile('conf/mcp2srg.srg')) - setFieldCsv(delayedFile('conf/fields.csv')) - setFieldCsv(delayedFile('conf/methods.csv')) - reobf(tasks.getByName('jar'), new Action() { - @Override - public void execute(ArtifactSpec arg0) - { - JavaPluginConvention javaConv = (JavaPluginConvention) getConvention().getPlugins().get("java") - arg0.setClasspath(javaConv.getSourceSets().getByName("main").getCompileClasspath()) - } - }) - - mustRunAfter("test") -} -assemble.dependsOn("reobf") - -task dumpLibs(type: Copy) { - into "$buildDir/libs/libs" - from configurations.compile -} - -def delayedFile(String path) { - new DelayedFile(project, path) { - @Override - File call() { - return file(path) - } - } -} +buildscript { + repositories { + mavenCentral() + mavenLocal() + + maven { + name = "forge" + url = "http://files.minecraftforge.net/maven" + + } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + + } + } + + dependencies { + classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' + + } +} + +import net.minecraftforge.gradle.common.Constants +import net.minecraftforge.gradle.delayed.DelayedFile +import net.minecraftforge.gradle.tasks.user.reobf.ArtifactSpec +import net.minecraftforge.gradle.tasks.user.reobf.ReobfTask +import net.minecraftforge.gradle.user.UserBasePlugin +import net.minecraftforge.gradle.user.UserExtension + +apply plugin: 'java' +apply plugin: 'groovy' +apply plugin: 'eclipse' + +sourceCompatibility = '1.6' +targetCompatibility = '1.6' + +repositories { + maven { + name 'forge' + url 'http://files.minecraftforge.net/maven' + } + mavenCentral() + maven { + name 'sonatypeSnapshot' + url 'https://oss.sonatype.org/content/repositories/snapshots/' + } + maven { + name 'minecraft' + url 'https://libraries.minecraft.net/' + } +} + +dependencies { + compile 'net.minecraft:launchwrapper:1.9' + compile 'org.ow2.asm:asm-debug-all:4.1' + compile 'org.scala-lang:scala-library:2.10.2' + compile 'org.scala-lang:scala-compiler:2.10.2' + compile 'net.sf.jopt-simple:jopt-simple:4.5' + compile 'java3d:vecmath:1.3.1' + compile 'net.sf.trove4j:trove4j:3.0.3' + compile 'com.ibm.icu:icu4j-core-mojang:51.2' + compile 'net.sf.jopt-simple:jopt-simple:4.5' + compile 'lzma:lzma:0.0.1' + compile 'com.paulscode:codecjorbis:20101023' + compile 'com.paulscode:codecwav:20101023' + compile 'com.paulscode:libraryjavasound:20101123' + compile 'com.paulscode:librarylwjglopenal:20100824' + compile 'com.paulscode:soundsystem:20120107' + compile 'io.netty:netty-all:4.0.10.Final' + compile 'com.google.guava:guava:15.0' + compile 'org.apache.commons:commons-lang3:3.1' + compile 'commons-io:commons-io:2.4' + compile 'net.java.jinput:jinput:2.0.5' + compile 'net.java.jutils:jutils:1.0.0' + compile 'com.google.code.gson:gson:2.2.4' + compile 'com.mojang:authlib:1.3' + compile 'org.apache.logging.log4j:log4j-api:2.0-beta9' + compile 'org.apache.logging.log4j:log4j-core:2.0-beta9' + compile 'org.lwjgl.lwjgl:lwjgl:2.9.0' + compile 'org.lwjgl.lwjgl:lwjgl_util:2.9.0' + compile 'org.yaml:snakeyaml:1.13' + compile 'com.lmax:disruptor:3.2.1' + + testCompile "org.codehaus.groovy:groovy-all:2.3.0" + testCompile "org.spockframework:spock-core:1.0-groovy-2.0-SNAPSHOT" + testCompile 'junit:junit:4.5' + + testRuntime "cglib:cglib-nodep:2.2.2" + testRuntime "org.objenesis:objenesis:1.2" +} + +project.getExtensions().create(Constants.EXT_NAME_MC, UserExtension, { return project } as UserBasePlugin) + +task reobf(type: ReobfTask) { + setExceptorCfg(delayedFile('conf/srg.exc')) + setSrg(delayedFile('conf/mcp2srg.srg')) + setFieldCsv(delayedFile('conf/fields.csv')) + setFieldCsv(delayedFile('conf/methods.csv')) + reobf(tasks.getByName('jar'), new Action() { + @Override + public void execute(ArtifactSpec arg0) + { + JavaPluginConvention javaConv = (JavaPluginConvention) getConvention().getPlugins().get("java") + arg0.setClasspath(javaConv.getSourceSets().getByName("main").getCompileClasspath()) + } + }) + + mustRunAfter("test") +} +assemble.dependsOn("reobf") + +task dumpLibs(type: Copy) { + into "$buildDir/libs/libs" + from configurations.compile +} + +def delayedFile(String path) { + new DelayedFile(project, path) { + @Override + File call() { + return file(path) + } + } +} diff --git a/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java b/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java index ab61c63..fe709eb 100644 --- a/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java +++ b/src/main/java/cpw/mods/fml/relauncher/ServerLaunchWrapper.java @@ -1,53 +1,57 @@ -package cpw.mods.fml.relauncher; - -import java.lang.reflect.Method; - -public class ServerLaunchWrapper { - - /** - * @param args - */ - public static void main(String[] args) - { - new ServerLaunchWrapper().run(args); - } - - private ServerLaunchWrapper() - { - - } - - private void run(String[] args) - { - Class launchwrapper = null; - try - { - launchwrapper = Class.forName("net.minecraft.launchwrapper.Launch",true,getClass().getClassLoader()); - Class.forName("org.objectweb.asm.Type",true,getClass().getClassLoader()); - } - catch (Exception e) - { - System.err.printf("We appear to be missing one or more essential library files.\n" + - "You will need to add them to your server before FML and Forge will run successfully."); - e.printStackTrace(System.err); - System.exit(1); - } - - try - { - Method main = launchwrapper.getMethod("main", String[].class); - String[] allArgs = new String[args.length + 2]; - allArgs[0] = "--tweakClass"; - allArgs[1] = "cpw.mods.fml.common.launcher.FMLServerTweaker"; - System.arraycopy(args, 0, allArgs, 2, args.length); - main.invoke(null,(Object)allArgs); - } - catch (Exception e) - { - System.err.printf("A problem occurred running the Server launcher."); - e.printStackTrace(System.err); - System.exit(1); - } - } - +package cpw.mods.fml.relauncher; + +import java.lang.reflect.Method; + +public class ServerLaunchWrapper { + + /** + * @param args + */ + public static void main(String[] args) + { + new ServerLaunchWrapper().run(args); + } + + private ServerLaunchWrapper() + { + + } + + private void run(String[] args) + { + boolean useUMConsole = Boolean.parseBoolean(System.getProperty("org.ultramine.server.umconsole")); + System.out.println((useUMConsole ? "\u00A7e" : "") + "================[ Starting UltraMine server ]================"); + System.setProperty("Log4jContextSelector", "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector"); //always async logging + + Class launchwrapper = null; + try + { + launchwrapper = Class.forName("net.minecraft.launchwrapper.Launch",true,getClass().getClassLoader()); + Class.forName("org.objectweb.asm.Type",true,getClass().getClassLoader()); + } + catch (Exception e) + { + System.err.printf("We appear to be missing one or more essential library files.\n" + + "You will need to add them to your server before FML and Forge will run successfully."); + e.printStackTrace(System.err); + System.exit(1); + } + + try + { + Method main = launchwrapper.getMethod("main", String[].class); + String[] allArgs = new String[args.length + 2]; + allArgs[0] = "--tweakClass"; + allArgs[1] = "cpw.mods.fml.common.launcher.FMLServerTweaker"; + System.arraycopy(args, 0, allArgs, 2, args.length); + main.invoke(null,(Object)allArgs); + } + catch (Exception e) + { + System.err.printf("A problem occurred running the Server launcher."); + e.printStackTrace(System.err); + System.exit(1); + } + } + } \ No newline at end of file diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java index cf12421..bd86d2e 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -390,6 +390,7 @@ if (normalStarted = startServer()) { FMLCommonHandler.instance().handleServerStarted(); + logger.info((useUMConsole ? "\u00a7e" : "") + "Server loading totally finished"); long i = getSystemTimeMillis(); long l = 0L; this.field_147147_p.func_151315_a(new ChatComponentText(this.motd)); @@ -838,7 +839,7 @@ public void addChatMessage(IChatComponent p_145747_1_) { - logger.info(p_145747_1_.getUnformattedText()); + logger.info(useUMConsole ? p_145747_1_.getFormattedText() : p_145747_1_.getUnformattedText()); } public boolean canCommandSenderUseCommand(int par1, String par2Str) @@ -1444,6 +1445,7 @@ /* ========================================= ULTRAMINE START ======================================*/ + private static final boolean useUMConsole = Boolean.parseBoolean(System.getProperty("org.ultramine.server.umconsole")); private final MultiWorld multiworld = new MultiWorld(this); public MultiWorld getMultiWorld() diff --git a/src/main/java/net/minecraft/util/ChatComponentStyle.java b/src/main/java/net/minecraft/util/ChatComponentStyle.java index af22b68..73d824b 100644 --- a/src/main/java/net/minecraft/util/ChatComponentStyle.java +++ b/src/main/java/net/minecraft/util/ChatComponentStyle.java @@ -1,158 +1,158 @@ -package net.minecraft.util; - -import com.google.common.base.Function; -import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.util.Iterator; -import java.util.List; - -public abstract class ChatComponentStyle implements IChatComponent -{ - protected List siblings = Lists.newArrayList(); - private ChatStyle style; - private static final String __OBFID = "CL_00001257"; - - public IChatComponent appendSibling(IChatComponent p_150257_1_) - { - p_150257_1_.getChatStyle().setParentStyle(this.getChatStyle()); - this.siblings.add(p_150257_1_); - return this; - } - - public List getSiblings() - { - return this.siblings; - } - - public IChatComponent appendText(String p_150258_1_) - { - return this.appendSibling(new ChatComponentText(p_150258_1_)); - } - - public IChatComponent setChatStyle(ChatStyle p_150255_1_) - { - this.style = p_150255_1_; - Iterator iterator = this.siblings.iterator(); - - while (iterator.hasNext()) - { - IChatComponent ichatcomponent = (IChatComponent)iterator.next(); - ichatcomponent.getChatStyle().setParentStyle(this.getChatStyle()); - } - - return this; - } - - public ChatStyle getChatStyle() - { - if (this.style == null) - { - this.style = new ChatStyle(); - Iterator iterator = this.siblings.iterator(); - - while (iterator.hasNext()) - { - IChatComponent ichatcomponent = (IChatComponent)iterator.next(); - ichatcomponent.getChatStyle().setParentStyle(this.style); - } - } - - return this.style; - } - - public Iterator iterator() - { - return Iterators.concat(Iterators.forArray(new ChatComponentStyle[] {this}), createDeepCopyIterator(this.siblings)); - } - - public final String getUnformattedText() - { - StringBuilder stringbuilder = new StringBuilder(); - Iterator iterator = this.iterator(); - - while (iterator.hasNext()) - { - IChatComponent ichatcomponent = (IChatComponent)iterator.next(); - stringbuilder.append(ichatcomponent.getUnformattedTextForChat()); - } - - return stringbuilder.toString(); - } - - @SideOnly(Side.CLIENT) - public final String getFormattedText() - { - StringBuilder stringbuilder = new StringBuilder(); - Iterator iterator = this.iterator(); - - while (iterator.hasNext()) - { - IChatComponent ichatcomponent = (IChatComponent)iterator.next(); - stringbuilder.append(ichatcomponent.getChatStyle().getFormattingCode()); - stringbuilder.append(ichatcomponent.getUnformattedTextForChat()); - stringbuilder.append(EnumChatFormatting.RESET); - } - - return stringbuilder.toString(); - } - - public static Iterator createDeepCopyIterator(Iterable p_150262_0_) - { - Iterator iterator = Iterators.concat(Iterators.transform(p_150262_0_.iterator(), new Function() - { - private static final String __OBFID = "CL_00001258"; - public Iterator apply(IChatComponent p_150665_1_) - { - return p_150665_1_.iterator(); - } - public Object apply(Object par1Obj) - { - return this.apply((IChatComponent)par1Obj); - } - })); - iterator = Iterators.transform(iterator, new Function() - { - private static final String __OBFID = "CL_00001259"; - public IChatComponent apply(IChatComponent p_150666_1_) - { - IChatComponent ichatcomponent1 = p_150666_1_.createCopy(); - ichatcomponent1.setChatStyle(ichatcomponent1.getChatStyle().createDeepCopy()); - return ichatcomponent1; - } - public Object apply(Object par1Obj) - { - return this.apply((IChatComponent)par1Obj); - } - }); - return iterator; - } - - public boolean equals(Object par1Obj) - { - if (this == par1Obj) - { - return true; - } - else if (!(par1Obj instanceof ChatComponentStyle)) - { - return false; - } - else - { - ChatComponentStyle chatcomponentstyle = (ChatComponentStyle)par1Obj; - return this.siblings.equals(chatcomponentstyle.siblings) && this.getChatStyle().equals(chatcomponentstyle.getChatStyle()); - } - } - - public int hashCode() - { - return 31 * this.style.hashCode() + this.siblings.hashCode(); - } - - public String toString() - { - return "BaseComponent{style=" + this.style + ", siblings=" + this.siblings + '}'; - } +package net.minecraft.util; + +import com.google.common.base.Function; +import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.Iterator; +import java.util.List; + +public abstract class ChatComponentStyle implements IChatComponent +{ + protected List siblings = Lists.newArrayList(); + private ChatStyle style; + private static final String __OBFID = "CL_00001257"; + + public IChatComponent appendSibling(IChatComponent p_150257_1_) + { + p_150257_1_.getChatStyle().setParentStyle(this.getChatStyle()); + this.siblings.add(p_150257_1_); + return this; + } + + public List getSiblings() + { + return this.siblings; + } + + public IChatComponent appendText(String p_150258_1_) + { + return this.appendSibling(new ChatComponentText(p_150258_1_)); + } + + public IChatComponent setChatStyle(ChatStyle p_150255_1_) + { + this.style = p_150255_1_; + Iterator iterator = this.siblings.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + ichatcomponent.getChatStyle().setParentStyle(this.getChatStyle()); + } + + return this; + } + + public ChatStyle getChatStyle() + { + if (this.style == null) + { + this.style = new ChatStyle(); + Iterator iterator = this.siblings.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + ichatcomponent.getChatStyle().setParentStyle(this.style); + } + } + + return this.style; + } + + public Iterator iterator() + { + return Iterators.concat(Iterators.forArray(new ChatComponentStyle[] {this}), createDeepCopyIterator(this.siblings)); + } + + public final String getUnformattedText() + { + StringBuilder stringbuilder = new StringBuilder(); + Iterator iterator = this.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + stringbuilder.append(ichatcomponent.getUnformattedTextForChat()); + } + + return stringbuilder.toString(); + } + +// @SideOnly(Side.CLIENT) + public final String getFormattedText() + { + StringBuilder stringbuilder = new StringBuilder(); + Iterator iterator = this.iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent = (IChatComponent)iterator.next(); + stringbuilder.append(ichatcomponent.getChatStyle().getFormattingCode()); + stringbuilder.append(ichatcomponent.getUnformattedTextForChat()); + stringbuilder.append(EnumChatFormatting.RESET); + } + + return stringbuilder.toString(); + } + + public static Iterator createDeepCopyIterator(Iterable p_150262_0_) + { + Iterator iterator = Iterators.concat(Iterators.transform(p_150262_0_.iterator(), new Function() + { + private static final String __OBFID = "CL_00001258"; + public Iterator apply(IChatComponent p_150665_1_) + { + return p_150665_1_.iterator(); + } + public Object apply(Object par1Obj) + { + return this.apply((IChatComponent)par1Obj); + } + })); + iterator = Iterators.transform(iterator, new Function() + { + private static final String __OBFID = "CL_00001259"; + public IChatComponent apply(IChatComponent p_150666_1_) + { + IChatComponent ichatcomponent1 = p_150666_1_.createCopy(); + ichatcomponent1.setChatStyle(ichatcomponent1.getChatStyle().createDeepCopy()); + return ichatcomponent1; + } + public Object apply(Object par1Obj) + { + return this.apply((IChatComponent)par1Obj); + } + }); + return iterator; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (!(par1Obj instanceof ChatComponentStyle)) + { + return false; + } + else + { + ChatComponentStyle chatcomponentstyle = (ChatComponentStyle)par1Obj; + return this.siblings.equals(chatcomponentstyle.siblings) && this.getChatStyle().equals(chatcomponentstyle.getChatStyle()); + } + } + + public int hashCode() + { + return 31 * this.style.hashCode() + this.siblings.hashCode(); + } + + public String toString() + { + return "BaseComponent{style=" + this.style + ", siblings=" + this.siblings + '}'; + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/ChatStyle.java b/src/main/java/net/minecraft/util/ChatStyle.java index b81b1e9..69d8505 100644 --- a/src/main/java/net/minecraft/util/ChatStyle.java +++ b/src/main/java/net/minecraft/util/ChatStyle.java @@ -1,508 +1,508 @@ -package net.minecraft.util; - -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.lang.reflect.Type; -import net.minecraft.event.ClickEvent; -import net.minecraft.event.HoverEvent; - -public class ChatStyle -{ - private ChatStyle parentStyle; - private EnumChatFormatting color; - private Boolean bold; - private Boolean italic; - private Boolean underlined; - private Boolean strikethrough; - private Boolean obfuscated; - private ClickEvent chatClickEvent; - private HoverEvent chatHoverEvent; - private static final ChatStyle rootStyle = new ChatStyle() - { - private static final String __OBFID = "CL_00001267"; - public EnumChatFormatting getColor() - { - return null; - } - public boolean getBold() - { - return false; - } - public boolean getItalic() - { - return false; - } - public boolean getStrikethrough() - { - return false; - } - public boolean getUnderlined() - { - return false; - } - public boolean getObfuscated() - { - return false; - } - public ClickEvent getChatClickEvent() - { - return null; - } - public HoverEvent getChatHoverEvent() - { - return null; - } - public ChatStyle setColor(EnumChatFormatting p_150238_1_) - { - throw new UnsupportedOperationException(); - } - public ChatStyle setBold(Boolean p_150227_1_) - { - throw new UnsupportedOperationException(); - } - public ChatStyle setItalic(Boolean p_150217_1_) - { - throw new UnsupportedOperationException(); - } - public ChatStyle setStrikethrough(Boolean p_150225_1_) - { - throw new UnsupportedOperationException(); - } - public ChatStyle setUnderlined(Boolean p_150228_1_) - { - throw new UnsupportedOperationException(); - } - public ChatStyle setObfuscated(Boolean p_150237_1_) - { - throw new UnsupportedOperationException(); - } - public ChatStyle setChatClickEvent(ClickEvent p_150241_1_) - { - throw new UnsupportedOperationException(); - } - public ChatStyle setChatHoverEvent(HoverEvent p_150209_1_) - { - throw new UnsupportedOperationException(); - } - public ChatStyle setParentStyle(ChatStyle p_150221_1_) - { - throw new UnsupportedOperationException(); - } - public String toString() - { - return "Style.ROOT"; - } - public ChatStyle createShallowCopy() - { - return this; - } - public ChatStyle createDeepCopy() - { - return this; - } - @SideOnly(Side.CLIENT) - public String getFormattingCode() - { - return ""; - } - }; - private static final String __OBFID = "CL_00001266"; - - public EnumChatFormatting getColor() - { - return this.color == null ? this.getParent().getColor() : this.color; - } - - public boolean getBold() - { - return this.bold == null ? this.getParent().getBold() : this.bold.booleanValue(); - } - - public boolean getItalic() - { - return this.italic == null ? this.getParent().getItalic() : this.italic.booleanValue(); - } - - public boolean getStrikethrough() - { - return this.strikethrough == null ? this.getParent().getStrikethrough() : this.strikethrough.booleanValue(); - } - - public boolean getUnderlined() - { - return this.underlined == null ? this.getParent().getUnderlined() : this.underlined.booleanValue(); - } - - public boolean getObfuscated() - { - return this.obfuscated == null ? this.getParent().getObfuscated() : this.obfuscated.booleanValue(); - } - - public boolean isEmpty() - { - return this.bold == null && this.italic == null && this.strikethrough == null && this.underlined == null && this.obfuscated == null && this.color == null && this.chatClickEvent == null && this.chatHoverEvent == null; - } - - public ClickEvent getChatClickEvent() - { - return this.chatClickEvent == null ? this.getParent().getChatClickEvent() : this.chatClickEvent; - } - - public HoverEvent getChatHoverEvent() - { - return this.chatHoverEvent == null ? this.getParent().getChatHoverEvent() : this.chatHoverEvent; - } - - public ChatStyle setColor(EnumChatFormatting p_150238_1_) - { - this.color = p_150238_1_; - return this; - } - - public ChatStyle setBold(Boolean p_150227_1_) - { - this.bold = p_150227_1_; - return this; - } - - public ChatStyle setItalic(Boolean p_150217_1_) - { - this.italic = p_150217_1_; - return this; - } - - public ChatStyle setStrikethrough(Boolean p_150225_1_) - { - this.strikethrough = p_150225_1_; - return this; - } - - public ChatStyle setUnderlined(Boolean p_150228_1_) - { - this.underlined = p_150228_1_; - return this; - } - - public ChatStyle setObfuscated(Boolean p_150237_1_) - { - this.obfuscated = p_150237_1_; - return this; - } - - public ChatStyle setChatClickEvent(ClickEvent p_150241_1_) - { - this.chatClickEvent = p_150241_1_; - return this; - } - - public ChatStyle setChatHoverEvent(HoverEvent p_150209_1_) - { - this.chatHoverEvent = p_150209_1_; - return this; - } - - public ChatStyle setParentStyle(ChatStyle p_150221_1_) - { - this.parentStyle = p_150221_1_; - return this; - } - - @SideOnly(Side.CLIENT) - public String getFormattingCode() - { - if (this.isEmpty()) - { - return this.parentStyle != null ? this.parentStyle.getFormattingCode() : ""; - } - else - { - StringBuilder stringbuilder = new StringBuilder(); - - if (this.getColor() != null) - { - stringbuilder.append(this.getColor()); - } - - if (this.getBold()) - { - stringbuilder.append(EnumChatFormatting.BOLD); - } - - if (this.getItalic()) - { - stringbuilder.append(EnumChatFormatting.ITALIC); - } - - if (this.getUnderlined()) - { - stringbuilder.append(EnumChatFormatting.UNDERLINE); - } - - if (this.getObfuscated()) - { - stringbuilder.append(EnumChatFormatting.OBFUSCATED); - } - - if (this.getStrikethrough()) - { - stringbuilder.append(EnumChatFormatting.STRIKETHROUGH); - } - - return stringbuilder.toString(); - } - } - - private ChatStyle getParent() - { - return this.parentStyle == null ? rootStyle : this.parentStyle; - } - - public String toString() - { - return "Style{hasParent=" + (this.parentStyle != null) + ", color=" + this.color + ", bold=" + this.bold + ", italic=" + this.italic + ", underlined=" + this.underlined + ", obfuscated=" + this.obfuscated + ", clickEvent=" + this.getChatClickEvent() + ", hoverEvent=" + this.getChatHoverEvent() + '}'; - } - - public boolean equals(Object par1Obj) - { - if (this == par1Obj) - { - return true; - } - else if (!(par1Obj instanceof ChatStyle)) - { - return false; - } - else - { - ChatStyle chatstyle = (ChatStyle)par1Obj; - boolean flag; - - if (this.getBold() == chatstyle.getBold() && this.getColor() == chatstyle.getColor() && this.getItalic() == chatstyle.getItalic() && this.getObfuscated() == chatstyle.getObfuscated() && this.getStrikethrough() == chatstyle.getStrikethrough() && this.getUnderlined() == chatstyle.getUnderlined()) - { - label56: - { - if (this.getChatClickEvent() != null) - { - if (!this.getChatClickEvent().equals(chatstyle.getChatClickEvent())) - { - break label56; - } - } - else if (chatstyle.getChatClickEvent() != null) - { - break label56; - } - - if (this.getChatHoverEvent() != null) - { - if (!this.getChatHoverEvent().equals(chatstyle.getChatHoverEvent())) - { - break label56; - } - } - else if (chatstyle.getChatHoverEvent() != null) - { - break label56; - } - - flag = true; - return flag; - } - } - - flag = false; - return flag; - } - } - - public int hashCode() - { - int i = this.color.hashCode(); - i = 31 * i + this.bold.hashCode(); - i = 31 * i + this.italic.hashCode(); - i = 31 * i + this.underlined.hashCode(); - i = 31 * i + this.strikethrough.hashCode(); - i = 31 * i + this.obfuscated.hashCode(); - i = 31 * i + this.chatClickEvent.hashCode(); - i = 31 * i + this.chatHoverEvent.hashCode(); - return i; - } - - public ChatStyle createShallowCopy() - { - ChatStyle chatstyle = new ChatStyle(); - chatstyle.bold = this.bold; - chatstyle.italic = this.italic; - chatstyle.strikethrough = this.strikethrough; - chatstyle.underlined = this.underlined; - chatstyle.obfuscated = this.obfuscated; - chatstyle.color = this.color; - chatstyle.chatClickEvent = this.chatClickEvent; - chatstyle.chatHoverEvent = this.chatHoverEvent; - chatstyle.parentStyle = this.parentStyle; - return chatstyle; - } - - public ChatStyle createDeepCopy() - { - ChatStyle chatstyle = new ChatStyle(); - chatstyle.setBold(Boolean.valueOf(this.getBold())); - chatstyle.setItalic(Boolean.valueOf(this.getItalic())); - chatstyle.setStrikethrough(Boolean.valueOf(this.getStrikethrough())); - chatstyle.setUnderlined(Boolean.valueOf(this.getUnderlined())); - chatstyle.setObfuscated(Boolean.valueOf(this.getObfuscated())); - chatstyle.setColor(this.getColor()); - chatstyle.setChatClickEvent(this.getChatClickEvent()); - chatstyle.setChatHoverEvent(this.getChatHoverEvent()); - return chatstyle; - } - - public static class Serializer implements JsonDeserializer, JsonSerializer - { - private static final String __OBFID = "CL_00001268"; - - public ChatStyle deserialize(JsonElement p_150204_1_, Type p_150204_2_, JsonDeserializationContext p_150204_3_) - { - if (p_150204_1_.isJsonObject()) - { - ChatStyle chatstyle = new ChatStyle(); - JsonObject jsonobject = p_150204_1_.getAsJsonObject(); - - if (jsonobject.has("bold")) - { - chatstyle.bold = Boolean.valueOf(jsonobject.get("bold").getAsBoolean()); - } - - if (jsonobject.has("italic")) - { - chatstyle.italic = Boolean.valueOf(jsonobject.get("italic").getAsBoolean()); - } - - if (jsonobject.has("underlined")) - { - chatstyle.underlined = Boolean.valueOf(jsonobject.get("underlined").getAsBoolean()); - } - - if (jsonobject.has("strikethrough")) - { - chatstyle.strikethrough = Boolean.valueOf(jsonobject.get("strikethrough").getAsBoolean()); - } - - if (jsonobject.has("obfuscated")) - { - chatstyle.obfuscated = Boolean.valueOf(jsonobject.get("obfuscated").getAsBoolean()); - } - - if (jsonobject.has("color")) - { - chatstyle.color = (EnumChatFormatting)p_150204_3_.deserialize(jsonobject.get("color"), EnumChatFormatting.class); - } - - JsonObject jsonobject1; - - if (jsonobject.has("clickEvent")) - { - jsonobject1 = jsonobject.getAsJsonObject("clickEvent"); - ClickEvent.Action action = ClickEvent.Action.getValueByCanonicalName(jsonobject1.getAsJsonPrimitive("action").getAsString()); - String s = jsonobject1.getAsJsonPrimitive("value").getAsString(); - - if (action != null && s != null && action.shouldAllowInChat()) - { - chatstyle.chatClickEvent = new ClickEvent(action, s); - } - } - - if (jsonobject.has("hoverEvent")) - { - jsonobject1 = jsonobject.getAsJsonObject("hoverEvent"); - HoverEvent.Action action1 = HoverEvent.Action.getValueByCanonicalName(jsonobject1.getAsJsonPrimitive("action").getAsString()); - IChatComponent ichatcomponent = (IChatComponent)p_150204_3_.deserialize(jsonobject1.get("value"), IChatComponent.class); - - if (action1 != null && ichatcomponent != null && action1.shouldAllowInChat()) - { - chatstyle.chatHoverEvent = new HoverEvent(action1, ichatcomponent); - } - } - - return chatstyle; - } - else - { - return null; - } - } - - public JsonElement serialize(ChatStyle p_150203_1_, Type p_150203_2_, JsonSerializationContext p_150203_3_) - { - if (p_150203_1_.isEmpty()) - { - return null; - } - else - { - JsonObject jsonobject = new JsonObject(); - - if (p_150203_1_.bold != null) - { - jsonobject.addProperty("bold", p_150203_1_.bold); - } - - if (p_150203_1_.italic != null) - { - jsonobject.addProperty("italic", p_150203_1_.italic); - } - - if (p_150203_1_.underlined != null) - { - jsonobject.addProperty("underlined", p_150203_1_.underlined); - } - - if (p_150203_1_.strikethrough != null) - { - jsonobject.addProperty("strikethrough", p_150203_1_.strikethrough); - } - - if (p_150203_1_.obfuscated != null) - { - jsonobject.addProperty("obfuscated", p_150203_1_.obfuscated); - } - - if (p_150203_1_.color != null) - { - jsonobject.add("color", p_150203_3_.serialize(p_150203_1_.color)); - } - - JsonObject jsonobject1; - - if (p_150203_1_.chatClickEvent != null) - { - jsonobject1 = new JsonObject(); - jsonobject1.addProperty("action", p_150203_1_.chatClickEvent.getAction().getCanonicalName()); - jsonobject1.addProperty("value", p_150203_1_.chatClickEvent.getValue()); - jsonobject.add("clickEvent", jsonobject1); - } - - if (p_150203_1_.chatHoverEvent != null) - { - jsonobject1 = new JsonObject(); - jsonobject1.addProperty("action", p_150203_1_.chatHoverEvent.getAction().getCanonicalName()); - jsonobject1.add("value", p_150203_3_.serialize(p_150203_1_.chatHoverEvent.getValue())); - jsonobject.add("hoverEvent", jsonobject1); - } - - return jsonobject; - } - } - - public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) - { - return this.serialize((ChatStyle)par1Obj, par2Type, par3JsonSerializationContext); - } - } +package net.minecraft.util; + +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.HoverEvent; + +public class ChatStyle +{ + private ChatStyle parentStyle; + private EnumChatFormatting color; + private Boolean bold; + private Boolean italic; + private Boolean underlined; + private Boolean strikethrough; + private Boolean obfuscated; + private ClickEvent chatClickEvent; + private HoverEvent chatHoverEvent; + private static final ChatStyle rootStyle = new ChatStyle() + { + private static final String __OBFID = "CL_00001267"; + public EnumChatFormatting getColor() + { + return null; + } + public boolean getBold() + { + return false; + } + public boolean getItalic() + { + return false; + } + public boolean getStrikethrough() + { + return false; + } + public boolean getUnderlined() + { + return false; + } + public boolean getObfuscated() + { + return false; + } + public ClickEvent getChatClickEvent() + { + return null; + } + public HoverEvent getChatHoverEvent() + { + return null; + } + public ChatStyle setColor(EnumChatFormatting p_150238_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setBold(Boolean p_150227_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setItalic(Boolean p_150217_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setStrikethrough(Boolean p_150225_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setUnderlined(Boolean p_150228_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setObfuscated(Boolean p_150237_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setChatClickEvent(ClickEvent p_150241_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setChatHoverEvent(HoverEvent p_150209_1_) + { + throw new UnsupportedOperationException(); + } + public ChatStyle setParentStyle(ChatStyle p_150221_1_) + { + throw new UnsupportedOperationException(); + } + public String toString() + { + return "Style.ROOT"; + } + public ChatStyle createShallowCopy() + { + return this; + } + public ChatStyle createDeepCopy() + { + return this; + } +// @SideOnly(Side.CLIENT) + public String getFormattingCode() + { + return ""; + } + }; + private static final String __OBFID = "CL_00001266"; + + public EnumChatFormatting getColor() + { + return this.color == null ? this.getParent().getColor() : this.color; + } + + public boolean getBold() + { + return this.bold == null ? this.getParent().getBold() : this.bold.booleanValue(); + } + + public boolean getItalic() + { + return this.italic == null ? this.getParent().getItalic() : this.italic.booleanValue(); + } + + public boolean getStrikethrough() + { + return this.strikethrough == null ? this.getParent().getStrikethrough() : this.strikethrough.booleanValue(); + } + + public boolean getUnderlined() + { + return this.underlined == null ? this.getParent().getUnderlined() : this.underlined.booleanValue(); + } + + public boolean getObfuscated() + { + return this.obfuscated == null ? this.getParent().getObfuscated() : this.obfuscated.booleanValue(); + } + + public boolean isEmpty() + { + return this.bold == null && this.italic == null && this.strikethrough == null && this.underlined == null && this.obfuscated == null && this.color == null && this.chatClickEvent == null && this.chatHoverEvent == null; + } + + public ClickEvent getChatClickEvent() + { + return this.chatClickEvent == null ? this.getParent().getChatClickEvent() : this.chatClickEvent; + } + + public HoverEvent getChatHoverEvent() + { + return this.chatHoverEvent == null ? this.getParent().getChatHoverEvent() : this.chatHoverEvent; + } + + public ChatStyle setColor(EnumChatFormatting p_150238_1_) + { + this.color = p_150238_1_; + return this; + } + + public ChatStyle setBold(Boolean p_150227_1_) + { + this.bold = p_150227_1_; + return this; + } + + public ChatStyle setItalic(Boolean p_150217_1_) + { + this.italic = p_150217_1_; + return this; + } + + public ChatStyle setStrikethrough(Boolean p_150225_1_) + { + this.strikethrough = p_150225_1_; + return this; + } + + public ChatStyle setUnderlined(Boolean p_150228_1_) + { + this.underlined = p_150228_1_; + return this; + } + + public ChatStyle setObfuscated(Boolean p_150237_1_) + { + this.obfuscated = p_150237_1_; + return this; + } + + public ChatStyle setChatClickEvent(ClickEvent p_150241_1_) + { + this.chatClickEvent = p_150241_1_; + return this; + } + + public ChatStyle setChatHoverEvent(HoverEvent p_150209_1_) + { + this.chatHoverEvent = p_150209_1_; + return this; + } + + public ChatStyle setParentStyle(ChatStyle p_150221_1_) + { + this.parentStyle = p_150221_1_; + return this; + } + +// @SideOnly(Side.CLIENT) + public String getFormattingCode() + { + if (this.isEmpty()) + { + return this.parentStyle != null ? this.parentStyle.getFormattingCode() : ""; + } + else + { + StringBuilder stringbuilder = new StringBuilder(); + + if (this.getColor() != null) + { + stringbuilder.append(this.getColor()); + } + + if (this.getBold()) + { + stringbuilder.append(EnumChatFormatting.BOLD); + } + + if (this.getItalic()) + { + stringbuilder.append(EnumChatFormatting.ITALIC); + } + + if (this.getUnderlined()) + { + stringbuilder.append(EnumChatFormatting.UNDERLINE); + } + + if (this.getObfuscated()) + { + stringbuilder.append(EnumChatFormatting.OBFUSCATED); + } + + if (this.getStrikethrough()) + { + stringbuilder.append(EnumChatFormatting.STRIKETHROUGH); + } + + return stringbuilder.toString(); + } + } + + private ChatStyle getParent() + { + return this.parentStyle == null ? rootStyle : this.parentStyle; + } + + public String toString() + { + return "Style{hasParent=" + (this.parentStyle != null) + ", color=" + this.color + ", bold=" + this.bold + ", italic=" + this.italic + ", underlined=" + this.underlined + ", obfuscated=" + this.obfuscated + ", clickEvent=" + this.getChatClickEvent() + ", hoverEvent=" + this.getChatHoverEvent() + '}'; + } + + public boolean equals(Object par1Obj) + { + if (this == par1Obj) + { + return true; + } + else if (!(par1Obj instanceof ChatStyle)) + { + return false; + } + else + { + ChatStyle chatstyle = (ChatStyle)par1Obj; + boolean flag; + + if (this.getBold() == chatstyle.getBold() && this.getColor() == chatstyle.getColor() && this.getItalic() == chatstyle.getItalic() && this.getObfuscated() == chatstyle.getObfuscated() && this.getStrikethrough() == chatstyle.getStrikethrough() && this.getUnderlined() == chatstyle.getUnderlined()) + { + label56: + { + if (this.getChatClickEvent() != null) + { + if (!this.getChatClickEvent().equals(chatstyle.getChatClickEvent())) + { + break label56; + } + } + else if (chatstyle.getChatClickEvent() != null) + { + break label56; + } + + if (this.getChatHoverEvent() != null) + { + if (!this.getChatHoverEvent().equals(chatstyle.getChatHoverEvent())) + { + break label56; + } + } + else if (chatstyle.getChatHoverEvent() != null) + { + break label56; + } + + flag = true; + return flag; + } + } + + flag = false; + return flag; + } + } + + public int hashCode() + { + int i = this.color.hashCode(); + i = 31 * i + this.bold.hashCode(); + i = 31 * i + this.italic.hashCode(); + i = 31 * i + this.underlined.hashCode(); + i = 31 * i + this.strikethrough.hashCode(); + i = 31 * i + this.obfuscated.hashCode(); + i = 31 * i + this.chatClickEvent.hashCode(); + i = 31 * i + this.chatHoverEvent.hashCode(); + return i; + } + + public ChatStyle createShallowCopy() + { + ChatStyle chatstyle = new ChatStyle(); + chatstyle.bold = this.bold; + chatstyle.italic = this.italic; + chatstyle.strikethrough = this.strikethrough; + chatstyle.underlined = this.underlined; + chatstyle.obfuscated = this.obfuscated; + chatstyle.color = this.color; + chatstyle.chatClickEvent = this.chatClickEvent; + chatstyle.chatHoverEvent = this.chatHoverEvent; + chatstyle.parentStyle = this.parentStyle; + return chatstyle; + } + + public ChatStyle createDeepCopy() + { + ChatStyle chatstyle = new ChatStyle(); + chatstyle.setBold(Boolean.valueOf(this.getBold())); + chatstyle.setItalic(Boolean.valueOf(this.getItalic())); + chatstyle.setStrikethrough(Boolean.valueOf(this.getStrikethrough())); + chatstyle.setUnderlined(Boolean.valueOf(this.getUnderlined())); + chatstyle.setObfuscated(Boolean.valueOf(this.getObfuscated())); + chatstyle.setColor(this.getColor()); + chatstyle.setChatClickEvent(this.getChatClickEvent()); + chatstyle.setChatHoverEvent(this.getChatHoverEvent()); + return chatstyle; + } + + public static class Serializer implements JsonDeserializer, JsonSerializer + { + private static final String __OBFID = "CL_00001268"; + + public ChatStyle deserialize(JsonElement p_150204_1_, Type p_150204_2_, JsonDeserializationContext p_150204_3_) + { + if (p_150204_1_.isJsonObject()) + { + ChatStyle chatstyle = new ChatStyle(); + JsonObject jsonobject = p_150204_1_.getAsJsonObject(); + + if (jsonobject.has("bold")) + { + chatstyle.bold = Boolean.valueOf(jsonobject.get("bold").getAsBoolean()); + } + + if (jsonobject.has("italic")) + { + chatstyle.italic = Boolean.valueOf(jsonobject.get("italic").getAsBoolean()); + } + + if (jsonobject.has("underlined")) + { + chatstyle.underlined = Boolean.valueOf(jsonobject.get("underlined").getAsBoolean()); + } + + if (jsonobject.has("strikethrough")) + { + chatstyle.strikethrough = Boolean.valueOf(jsonobject.get("strikethrough").getAsBoolean()); + } + + if (jsonobject.has("obfuscated")) + { + chatstyle.obfuscated = Boolean.valueOf(jsonobject.get("obfuscated").getAsBoolean()); + } + + if (jsonobject.has("color")) + { + chatstyle.color = (EnumChatFormatting)p_150204_3_.deserialize(jsonobject.get("color"), EnumChatFormatting.class); + } + + JsonObject jsonobject1; + + if (jsonobject.has("clickEvent")) + { + jsonobject1 = jsonobject.getAsJsonObject("clickEvent"); + ClickEvent.Action action = ClickEvent.Action.getValueByCanonicalName(jsonobject1.getAsJsonPrimitive("action").getAsString()); + String s = jsonobject1.getAsJsonPrimitive("value").getAsString(); + + if (action != null && s != null && action.shouldAllowInChat()) + { + chatstyle.chatClickEvent = new ClickEvent(action, s); + } + } + + if (jsonobject.has("hoverEvent")) + { + jsonobject1 = jsonobject.getAsJsonObject("hoverEvent"); + HoverEvent.Action action1 = HoverEvent.Action.getValueByCanonicalName(jsonobject1.getAsJsonPrimitive("action").getAsString()); + IChatComponent ichatcomponent = (IChatComponent)p_150204_3_.deserialize(jsonobject1.get("value"), IChatComponent.class); + + if (action1 != null && ichatcomponent != null && action1.shouldAllowInChat()) + { + chatstyle.chatHoverEvent = new HoverEvent(action1, ichatcomponent); + } + } + + return chatstyle; + } + else + { + return null; + } + } + + public JsonElement serialize(ChatStyle p_150203_1_, Type p_150203_2_, JsonSerializationContext p_150203_3_) + { + if (p_150203_1_.isEmpty()) + { + return null; + } + else + { + JsonObject jsonobject = new JsonObject(); + + if (p_150203_1_.bold != null) + { + jsonobject.addProperty("bold", p_150203_1_.bold); + } + + if (p_150203_1_.italic != null) + { + jsonobject.addProperty("italic", p_150203_1_.italic); + } + + if (p_150203_1_.underlined != null) + { + jsonobject.addProperty("underlined", p_150203_1_.underlined); + } + + if (p_150203_1_.strikethrough != null) + { + jsonobject.addProperty("strikethrough", p_150203_1_.strikethrough); + } + + if (p_150203_1_.obfuscated != null) + { + jsonobject.addProperty("obfuscated", p_150203_1_.obfuscated); + } + + if (p_150203_1_.color != null) + { + jsonobject.add("color", p_150203_3_.serialize(p_150203_1_.color)); + } + + JsonObject jsonobject1; + + if (p_150203_1_.chatClickEvent != null) + { + jsonobject1 = new JsonObject(); + jsonobject1.addProperty("action", p_150203_1_.chatClickEvent.getAction().getCanonicalName()); + jsonobject1.addProperty("value", p_150203_1_.chatClickEvent.getValue()); + jsonobject.add("clickEvent", jsonobject1); + } + + if (p_150203_1_.chatHoverEvent != null) + { + jsonobject1 = new JsonObject(); + jsonobject1.addProperty("action", p_150203_1_.chatHoverEvent.getAction().getCanonicalName()); + jsonobject1.add("value", p_150203_3_.serialize(p_150203_1_.chatHoverEvent.getValue())); + jsonobject.add("hoverEvent", jsonobject1); + } + + return jsonobject; + } + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((ChatStyle)par1Obj, par2Type, par3JsonSerializationContext); + } + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/EnumChatFormatting.java b/src/main/java/net/minecraft/util/EnumChatFormatting.java index b43c26a..4f75a42 100644 --- a/src/main/java/net/minecraft/util/EnumChatFormatting.java +++ b/src/main/java/net/minecraft/util/EnumChatFormatting.java @@ -1,123 +1,128 @@ -package net.minecraft.util; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - -public enum EnumChatFormatting -{ - BLACK('0'), - DARK_BLUE('1'), - DARK_GREEN('2'), - DARK_AQUA('3'), - DARK_RED('4'), - DARK_PURPLE('5'), - GOLD('6'), - GRAY('7'), - DARK_GRAY('8'), - BLUE('9'), - GREEN('a'), - AQUA('b'), - RED('c'), - LIGHT_PURPLE('d'), - YELLOW('e'), - WHITE('f'), - OBFUSCATED('k', true), - BOLD('l', true), - STRIKETHROUGH('m', true), - UNDERLINE('n', true), - ITALIC('o', true), - RESET('r'); - private static final Map formattingCodeMapping = new HashMap(); - private static final Map nameMapping = new HashMap(); - private static final Pattern formattingCodePattern = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]"); - private final char formattingCode; - private final boolean fancyStyling; - private final String controlString; - - private static final String __OBFID = "CL_00000342"; - - private EnumChatFormatting(char par3) - { - this(par3, false); - } - - private EnumChatFormatting(char par3, boolean par4) - { - this.formattingCode = par3; - this.fancyStyling = par4; - this.controlString = "\u00a7" + par3; - } - - public char getFormattingCode() - { - return this.formattingCode; - } - - public boolean isFancyStyling() - { - return this.fancyStyling; - } - - public boolean isColor() - { - return !this.fancyStyling && this != RESET; - } - - public String getFriendlyName() - { - return this.name().toLowerCase(); - } - - public String toString() - { - return this.controlString; - } - - @SideOnly(Side.CLIENT) - public static String getTextWithoutFormattingCodes(String par0Str) - { - return par0Str == null ? null : formattingCodePattern.matcher(par0Str).replaceAll(""); - } - - public static EnumChatFormatting getValueByName(String par0Str) - { - return par0Str == null ? null : (EnumChatFormatting)nameMapping.get(par0Str.toLowerCase()); - } - - public static Collection getValidValues(boolean par0, boolean par1) - { - ArrayList arraylist = new ArrayList(); - EnumChatFormatting[] aenumchatformatting = values(); - int i = aenumchatformatting.length; - - for (int j = 0; j < i; ++j) - { - EnumChatFormatting enumchatformatting = aenumchatformatting[j]; - - if ((!enumchatformatting.isColor() || par0) && (!enumchatformatting.isFancyStyling() || par1)) - { - arraylist.add(enumchatformatting.getFriendlyName()); - } - } - - return arraylist; - } - - static - { - EnumChatFormatting[] var0 = values(); - int var1 = var0.length; - - for (int var2 = 0; var2 < var1; ++var2) - { - EnumChatFormatting var3 = var0[var2]; - formattingCodeMapping.put(Character.valueOf(var3.getFormattingCode()), var3); - nameMapping.put(var3.getFriendlyName(), var3); - } - } +package net.minecraft.util; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.regex.Pattern; + +public enum EnumChatFormatting +{ + BLACK('0'), + DARK_BLUE('1'), + DARK_GREEN('2'), + DARK_AQUA('3'), + DARK_RED('4'), + DARK_PURPLE('5'), + GOLD('6'), + GRAY('7'), + DARK_GRAY('8'), + BLUE('9'), + GREEN('a'), + AQUA('b'), + RED('c'), + LIGHT_PURPLE('d'), + YELLOW('e'), + WHITE('f'), + OBFUSCATED('k', true), + BOLD('l', true), + STRIKETHROUGH('m', true), + UNDERLINE('n', true), + ITALIC('o', true), + RESET('r'); + private static final Map formattingCodeMapping = new HashMap(); + private static final Map nameMapping = new HashMap(); + private static final Pattern formattingCodePattern = Pattern.compile("(?i)" + String.valueOf('\u00a7') + "[0-9A-FK-OR]"); + private final char formattingCode; + private final boolean fancyStyling; + private final String controlString; + + private static final String __OBFID = "CL_00000342"; + + private EnumChatFormatting(char par3) + { + this(par3, false); + } + + private EnumChatFormatting(char par3, boolean par4) + { + this.formattingCode = par3; + this.fancyStyling = par4; + this.controlString = "\u00a7" + par3; + } + + public char getFormattingCode() + { + return this.formattingCode; + } + + public boolean isFancyStyling() + { + return this.fancyStyling; + } + + public boolean isColor() + { + return !this.fancyStyling && this != RESET; + } + + public String getFriendlyName() + { + return this.name().toLowerCase(); + } + + public String toString() + { + return this.controlString; + } + + @SideOnly(Side.CLIENT) + public static String getTextWithoutFormattingCodes(String par0Str) + { + return par0Str == null ? null : formattingCodePattern.matcher(par0Str).replaceAll(""); + } + + public static EnumChatFormatting getValueByName(String par0Str) + { + return par0Str == null ? null : (EnumChatFormatting)nameMapping.get(par0Str.toLowerCase()); + } + + public static Collection getValidValues(boolean par0, boolean par1) + { + ArrayList arraylist = new ArrayList(); + EnumChatFormatting[] aenumchatformatting = values(); + int i = aenumchatformatting.length; + + for (int j = 0; j < i; ++j) + { + EnumChatFormatting enumchatformatting = aenumchatformatting[j]; + + if ((!enumchatformatting.isColor() || par0) && (!enumchatformatting.isFancyStyling() || par1)) + { + arraylist.add(enumchatformatting.getFriendlyName()); + } + } + + return arraylist; + } + + static + { + EnumChatFormatting[] var0 = values(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + EnumChatFormatting var3 = var0[var2]; + formattingCodeMapping.put(Character.valueOf(var3.getFormattingCode()), var3); + nameMapping.put(var3.getFriendlyName(), var3); + } + } + + public static EnumChatFormatting getByColorCode(char code) + { + return (EnumChatFormatting)formattingCodeMapping.get(code); + } } \ No newline at end of file diff --git a/src/main/java/net/minecraft/util/IChatComponent.java b/src/main/java/net/minecraft/util/IChatComponent.java index 85b15e2..5b1d405 100644 --- a/src/main/java/net/minecraft/util/IChatComponent.java +++ b/src/main/java/net/minecraft/util/IChatComponent.java @@ -1,261 +1,261 @@ -package net.minecraft.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonDeserializationContext; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import java.lang.reflect.Type; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; - -public interface IChatComponent extends Iterable -{ - IChatComponent setChatStyle(ChatStyle var1); - - ChatStyle getChatStyle(); - - IChatComponent appendText(String var1); - - IChatComponent appendSibling(IChatComponent var1); - - String getUnformattedTextForChat(); - - String getUnformattedText(); - - @SideOnly(Side.CLIENT) - String getFormattedText(); - - List getSiblings(); - - IChatComponent createCopy(); - - public static class Serializer implements JsonDeserializer, JsonSerializer - { - private static final Gson field_150700_a; - private static final String __OBFID = "CL_00001263"; - - public IChatComponent deserialize(JsonElement p_150698_1_, Type p_150698_2_, JsonDeserializationContext p_150698_3_) - { - if (p_150698_1_.isJsonPrimitive()) - { - return new ChatComponentText(p_150698_1_.getAsString()); - } - else if (!p_150698_1_.isJsonObject()) - { - if (p_150698_1_.isJsonArray()) - { - JsonArray jsonarray1 = p_150698_1_.getAsJsonArray(); - IChatComponent ichatcomponent = null; - Iterator iterator = jsonarray1.iterator(); - - while (iterator.hasNext()) - { - JsonElement jsonelement1 = (JsonElement)iterator.next(); - IChatComponent ichatcomponent1 = this.deserialize(jsonelement1, jsonelement1.getClass(), p_150698_3_); - - if (ichatcomponent == null) - { - ichatcomponent = ichatcomponent1; - } - else - { - ichatcomponent.appendSibling(ichatcomponent1); - } - } - - return ichatcomponent; - } - else - { - throw new JsonParseException("Don\'t know how to turn " + p_150698_1_.toString() + " into a Component"); - } - } - else - { - JsonObject jsonobject = p_150698_1_.getAsJsonObject(); - Object object; - - if (jsonobject.has("text")) - { - object = new ChatComponentText(jsonobject.get("text").getAsString()); - } - else - { - if (!jsonobject.has("translate")) - { - throw new JsonParseException("Don\'t know how to turn " + p_150698_1_.toString() + " into a Component"); - } - - String s = jsonobject.get("translate").getAsString(); - - if (jsonobject.has("with")) - { - JsonArray jsonarray = jsonobject.getAsJsonArray("with"); - Object[] aobject = new Object[jsonarray.size()]; - - for (int i = 0; i < aobject.length; ++i) - { - aobject[i] = this.deserialize(jsonarray.get(i), p_150698_2_, p_150698_3_); - - if (aobject[i] instanceof ChatComponentText) - { - ChatComponentText chatcomponenttext = (ChatComponentText)aobject[i]; - - if (chatcomponenttext.getChatStyle().isEmpty() && chatcomponenttext.getSiblings().isEmpty()) - { - aobject[i] = chatcomponenttext.getChatComponentText_TextValue(); - } - } - } - - object = new ChatComponentTranslation(s, aobject); - } - else - { - object = new ChatComponentTranslation(s, new Object[0]); - } - } - - if (jsonobject.has("extra")) - { - JsonArray jsonarray2 = jsonobject.getAsJsonArray("extra"); - - if (jsonarray2.size() <= 0) - { - throw new JsonParseException("Unexpected empty array of components"); - } - - for (int j = 0; j < jsonarray2.size(); ++j) - { - ((IChatComponent)object).appendSibling(this.deserialize(jsonarray2.get(j), p_150698_2_, p_150698_3_)); - } - } - - ((IChatComponent)object).setChatStyle((ChatStyle)p_150698_3_.deserialize(p_150698_1_, ChatStyle.class)); - return (IChatComponent)object; - } - } - - private void func_150695_a(ChatStyle p_150695_1_, JsonObject p_150695_2_, JsonSerializationContext p_150695_3_) - { - JsonElement jsonelement = p_150695_3_.serialize(p_150695_1_); - - if (jsonelement.isJsonObject()) - { - JsonObject jsonobject1 = (JsonObject)jsonelement; - Iterator iterator = jsonobject1.entrySet().iterator(); - - while (iterator.hasNext()) - { - Entry entry = (Entry)iterator.next(); - p_150695_2_.add((String)entry.getKey(), (JsonElement)entry.getValue()); - } - } - } - - public JsonElement serialize(IChatComponent p_150697_1_, Type p_150697_2_, JsonSerializationContext p_150697_3_) - { - if (p_150697_1_ instanceof ChatComponentText && p_150697_1_.getChatStyle().isEmpty() && p_150697_1_.getSiblings().isEmpty()) - { - return new JsonPrimitive(((ChatComponentText)p_150697_1_).getChatComponentText_TextValue()); - } - else - { - JsonObject jsonobject = new JsonObject(); - - if (!p_150697_1_.getChatStyle().isEmpty()) - { - this.func_150695_a(p_150697_1_.getChatStyle(), jsonobject, p_150697_3_); - } - - if (!p_150697_1_.getSiblings().isEmpty()) - { - JsonArray jsonarray = new JsonArray(); - Iterator iterator = p_150697_1_.getSiblings().iterator(); - - while (iterator.hasNext()) - { - IChatComponent ichatcomponent1 = (IChatComponent)iterator.next(); - jsonarray.add(this.serialize(ichatcomponent1, ichatcomponent1.getClass(), p_150697_3_)); - } - - jsonobject.add("extra", jsonarray); - } - - if (p_150697_1_ instanceof ChatComponentText) - { - jsonobject.addProperty("text", ((ChatComponentText)p_150697_1_).getChatComponentText_TextValue()); - } - else - { - if (!(p_150697_1_ instanceof ChatComponentTranslation)) - { - throw new IllegalArgumentException("Don\'t know how to serialize " + p_150697_1_ + " as a Component"); - } - - ChatComponentTranslation chatcomponenttranslation = (ChatComponentTranslation)p_150697_1_; - jsonobject.addProperty("translate", chatcomponenttranslation.getKey()); - - if (chatcomponenttranslation.getFormatArgs() != null && chatcomponenttranslation.getFormatArgs().length > 0) - { - JsonArray jsonarray1 = new JsonArray(); - Object[] aobject = chatcomponenttranslation.getFormatArgs(); - int i = aobject.length; - - for (int j = 0; j < i; ++j) - { - Object object = aobject[j]; - - if (object instanceof IChatComponent) - { - jsonarray1.add(this.serialize((IChatComponent)object, object.getClass(), p_150697_3_)); - } - else - { - jsonarray1.add(new JsonPrimitive(String.valueOf(object))); - } - } - - jsonobject.add("with", jsonarray1); - } - } - - return jsonobject; - } - } - - public static String func_150696_a(IChatComponent p_150696_0_) - { - return field_150700_a.toJson(p_150696_0_); - } - - public static IChatComponent func_150699_a(String p_150699_0_) - { - return (IChatComponent)field_150700_a.fromJson(p_150699_0_, IChatComponent.class); - } - - public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) - { - return this.serialize((IChatComponent)par1Obj, par2Type, par3JsonSerializationContext); - } - - static - { - GsonBuilder var0 = new GsonBuilder(); - var0.registerTypeHierarchyAdapter(IChatComponent.class, new IChatComponent.Serializer()); - var0.registerTypeHierarchyAdapter(ChatStyle.class, new ChatStyle.Serializer()); - var0.registerTypeAdapterFactory(new EnumTypeAdapterFactory()); - field_150700_a = var0.create(); - } - } +package net.minecraft.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Type; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; + +public interface IChatComponent extends Iterable +{ + IChatComponent setChatStyle(ChatStyle var1); + + ChatStyle getChatStyle(); + + IChatComponent appendText(String var1); + + IChatComponent appendSibling(IChatComponent var1); + + String getUnformattedTextForChat(); + + String getUnformattedText(); + +// @SideOnly(Side.CLIENT) + String getFormattedText(); + + List getSiblings(); + + IChatComponent createCopy(); + + public static class Serializer implements JsonDeserializer, JsonSerializer + { + private static final Gson field_150700_a; + private static final String __OBFID = "CL_00001263"; + + public IChatComponent deserialize(JsonElement p_150698_1_, Type p_150698_2_, JsonDeserializationContext p_150698_3_) + { + if (p_150698_1_.isJsonPrimitive()) + { + return new ChatComponentText(p_150698_1_.getAsString()); + } + else if (!p_150698_1_.isJsonObject()) + { + if (p_150698_1_.isJsonArray()) + { + JsonArray jsonarray1 = p_150698_1_.getAsJsonArray(); + IChatComponent ichatcomponent = null; + Iterator iterator = jsonarray1.iterator(); + + while (iterator.hasNext()) + { + JsonElement jsonelement1 = (JsonElement)iterator.next(); + IChatComponent ichatcomponent1 = this.deserialize(jsonelement1, jsonelement1.getClass(), p_150698_3_); + + if (ichatcomponent == null) + { + ichatcomponent = ichatcomponent1; + } + else + { + ichatcomponent.appendSibling(ichatcomponent1); + } + } + + return ichatcomponent; + } + else + { + throw new JsonParseException("Don\'t know how to turn " + p_150698_1_.toString() + " into a Component"); + } + } + else + { + JsonObject jsonobject = p_150698_1_.getAsJsonObject(); + Object object; + + if (jsonobject.has("text")) + { + object = new ChatComponentText(jsonobject.get("text").getAsString()); + } + else + { + if (!jsonobject.has("translate")) + { + throw new JsonParseException("Don\'t know how to turn " + p_150698_1_.toString() + " into a Component"); + } + + String s = jsonobject.get("translate").getAsString(); + + if (jsonobject.has("with")) + { + JsonArray jsonarray = jsonobject.getAsJsonArray("with"); + Object[] aobject = new Object[jsonarray.size()]; + + for (int i = 0; i < aobject.length; ++i) + { + aobject[i] = this.deserialize(jsonarray.get(i), p_150698_2_, p_150698_3_); + + if (aobject[i] instanceof ChatComponentText) + { + ChatComponentText chatcomponenttext = (ChatComponentText)aobject[i]; + + if (chatcomponenttext.getChatStyle().isEmpty() && chatcomponenttext.getSiblings().isEmpty()) + { + aobject[i] = chatcomponenttext.getChatComponentText_TextValue(); + } + } + } + + object = new ChatComponentTranslation(s, aobject); + } + else + { + object = new ChatComponentTranslation(s, new Object[0]); + } + } + + if (jsonobject.has("extra")) + { + JsonArray jsonarray2 = jsonobject.getAsJsonArray("extra"); + + if (jsonarray2.size() <= 0) + { + throw new JsonParseException("Unexpected empty array of components"); + } + + for (int j = 0; j < jsonarray2.size(); ++j) + { + ((IChatComponent)object).appendSibling(this.deserialize(jsonarray2.get(j), p_150698_2_, p_150698_3_)); + } + } + + ((IChatComponent)object).setChatStyle((ChatStyle)p_150698_3_.deserialize(p_150698_1_, ChatStyle.class)); + return (IChatComponent)object; + } + } + + private void func_150695_a(ChatStyle p_150695_1_, JsonObject p_150695_2_, JsonSerializationContext p_150695_3_) + { + JsonElement jsonelement = p_150695_3_.serialize(p_150695_1_); + + if (jsonelement.isJsonObject()) + { + JsonObject jsonobject1 = (JsonObject)jsonelement; + Iterator iterator = jsonobject1.entrySet().iterator(); + + while (iterator.hasNext()) + { + Entry entry = (Entry)iterator.next(); + p_150695_2_.add((String)entry.getKey(), (JsonElement)entry.getValue()); + } + } + } + + public JsonElement serialize(IChatComponent p_150697_1_, Type p_150697_2_, JsonSerializationContext p_150697_3_) + { + if (p_150697_1_ instanceof ChatComponentText && p_150697_1_.getChatStyle().isEmpty() && p_150697_1_.getSiblings().isEmpty()) + { + return new JsonPrimitive(((ChatComponentText)p_150697_1_).getChatComponentText_TextValue()); + } + else + { + JsonObject jsonobject = new JsonObject(); + + if (!p_150697_1_.getChatStyle().isEmpty()) + { + this.func_150695_a(p_150697_1_.getChatStyle(), jsonobject, p_150697_3_); + } + + if (!p_150697_1_.getSiblings().isEmpty()) + { + JsonArray jsonarray = new JsonArray(); + Iterator iterator = p_150697_1_.getSiblings().iterator(); + + while (iterator.hasNext()) + { + IChatComponent ichatcomponent1 = (IChatComponent)iterator.next(); + jsonarray.add(this.serialize(ichatcomponent1, ichatcomponent1.getClass(), p_150697_3_)); + } + + jsonobject.add("extra", jsonarray); + } + + if (p_150697_1_ instanceof ChatComponentText) + { + jsonobject.addProperty("text", ((ChatComponentText)p_150697_1_).getChatComponentText_TextValue()); + } + else + { + if (!(p_150697_1_ instanceof ChatComponentTranslation)) + { + throw new IllegalArgumentException("Don\'t know how to serialize " + p_150697_1_ + " as a Component"); + } + + ChatComponentTranslation chatcomponenttranslation = (ChatComponentTranslation)p_150697_1_; + jsonobject.addProperty("translate", chatcomponenttranslation.getKey()); + + if (chatcomponenttranslation.getFormatArgs() != null && chatcomponenttranslation.getFormatArgs().length > 0) + { + JsonArray jsonarray1 = new JsonArray(); + Object[] aobject = chatcomponenttranslation.getFormatArgs(); + int i = aobject.length; + + for (int j = 0; j < i; ++j) + { + Object object = aobject[j]; + + if (object instanceof IChatComponent) + { + jsonarray1.add(this.serialize((IChatComponent)object, object.getClass(), p_150697_3_)); + } + else + { + jsonarray1.add(new JsonPrimitive(String.valueOf(object))); + } + } + + jsonobject.add("with", jsonarray1); + } + } + + return jsonobject; + } + } + + public static String func_150696_a(IChatComponent p_150696_0_) + { + return field_150700_a.toJson(p_150696_0_); + } + + public static IChatComponent func_150699_a(String p_150699_0_) + { + return (IChatComponent)field_150700_a.fromJson(p_150699_0_, IChatComponent.class); + } + + public JsonElement serialize(Object par1Obj, Type par2Type, JsonSerializationContext par3JsonSerializationContext) + { + return this.serialize((IChatComponent)par1Obj, par2Type, par3JsonSerializationContext); + } + + static + { + GsonBuilder var0 = new GsonBuilder(); + var0.registerTypeHierarchyAdapter(IChatComponent.class, new IChatComponent.Serializer()); + var0.registerTypeHierarchyAdapter(ChatStyle.class, new ChatStyle.Serializer()); + var0.registerTypeAdapterFactory(new EnumTypeAdapterFactory()); + field_150700_a = var0.create(); + } + } } \ No newline at end of file diff --git a/src/main/java/org/ultramine/server/log/UMConsoleLayout.java b/src/main/java/org/ultramine/server/log/UMConsoleLayout.java new file mode 100644 index 0000000..348cfb4 --- /dev/null +++ b/src/main/java/org/ultramine/server/log/UMConsoleLayout.java @@ -0,0 +1,105 @@ +package org.ultramine.server.log; + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.charset.Charset; +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Map; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginFactory; +import org.apache.logging.log4j.core.helpers.Charsets; +import org.apache.logging.log4j.core.helpers.Constants; +import org.apache.logging.log4j.core.layout.AbstractStringLayout; + +@Plugin(name = "UMConsoleLayout", category = "Core", elementType = "layout", printObject = false) +public class UMConsoleLayout extends AbstractStringLayout +{ + private static final boolean useUMConsole = Boolean.parseBoolean(System.getProperty("org.ultramine.server.umconsole")); + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss"); + + protected UMConsoleLayout(Charset charset) + { + super(charset); + } + + @Override + public String toSerializable(LogEvent event) + { + StringBuilder sb = new StringBuilder(); + + sb.append('['); + sb.append(dateFormat.format(event.getMillis())); + sb.append("] "); + + sb.append('['); + Level level = event.getLevel(); + if(useUMConsole) + { + if(level == Level.WARN) + sb.append("\u00A7e"); + else if(level == Level.ERROR) + sb.append("\u00A7c"); + else if(level == Level.FATAL) + sb.append("\u00A74"); + } + String levelS = event.getLevel().toString(); + int llen = levelS.length(); + if(llen > 4) + levelS = levelS.substring(0, 4); + sb.append(levelS); + if(llen < 4) + sb.append(' '); + if(useUMConsole && (level == Level.WARN || level == Level.ERROR || level == Level.FATAL)) + sb.append("\u00A7r"); + sb.append("] "); + + String msg = event.getMessage().getFormattedMessage(); + if(useUMConsole) + { + sb.append(msg); + } + else + { + for(int i = 0, s = msg.length(); i < s; i++) + { + char c = msg.charAt(i); + if(c == '\u00a7') + { + i++; + continue; + } + sb.append(c); + } + } + + Throwable t = event.getThrown(); + if(t != null) + { + StringWriter w = new StringWriter(); + t.printStackTrace(new PrintWriter(w)); + sb.append(Constants.LINE_SEP); + sb.append(w.toString()); + } + + sb.append(Constants.LINE_SEP); + + return sb.toString(); + } + + @Override + public Map getContentFormat() + { + return Collections.emptyMap(); + } + + @PluginFactory + public static UMConsoleLayout createLayout(@PluginAttribute("charset") final String charsetName) + { + return new UMConsoleLayout(Charsets.getSupportedCharset(charsetName)); + } +} diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 482e65a..cf675d2 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -1,35 +1,22 @@ - + - + - - - - - - - - - - - - - - - - + + + - + @@ -38,21 +25,18 @@ - - - + + - - - + + -