diff --git a/.gitignore b/.gitignore index 9610036..134f494 100644 --- a/.gitignore +++ b/.gitignore @@ -8,12 +8,13 @@ common/* # allow any !*.md -!src/ +!LICENSE +!sources/ !gradle/ !lib/ !info/ !build.gradle -!common.gradle +!build.subprojects.gradle !project.gradle !settings.gradle !gradle.properties diff --git a/.travis.yml b/.travis.yml index 5c77bf6..ebe51ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_install: install: "./gradlew setupCIWorkspace --continue" script: "./gradlew build --continue" after_success: - - ./gradlew githubRelease curseforge --continue + - ./gradlew githubRelease curseforge bintrayUpload --continue #- ./gradlew githubRelease --continue #- ./gradlew bintrayUpload --continue before_cache: @@ -22,8 +22,4 @@ cache: - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ notifications: - email: false - webhooks: - urls: - - secure: "SHLyTtef5pR6tD2t+RoVAeamp8bY7coFFTvITvG5kfmpjaLartudM/cwU7FtDds6BdWiUjqZl9esPshUVXJdv88+NMZoF8HZQD+Rz0M2A4pVh1eEZKzdD0d2OjbCaMzapZgRxyKtjrt5zDJo8G0H1LEMFxcoNLP3JF7nmNeUN+Dmg7QEi54dtLmDF/4rpBJUb1OJ/8E3JXI21GXIWev1e+MZW4Jy3OFYFhpDbcPMxu3JjdsCQMNLW9VQo4dQ2BHngVLMdi0AVwkw4qfd3FqLdZYlbeMnnJUns6UpfClpZZjoCM1OIAxSH4cZXzMO9eONjbtIQGVhSci4FXVodzCBV3KNCnPNIK/wI9O11Y4aFcq4j27nR7HXlxSTWaYXkIu8Ot9RyCVqOfBEFP0/BtFaE9LlTXM0bPq2KEZCMb/fhV0Vp0azeTMdeKGhgxVFclVr0YcplJ1xpYFZGleVSBhqMzVKjZ4GmCWfWCGDsz/XwvEblJfc+Nt5x1bTiuTBn6b72h28r/W55iiV0zUZdNZG1Cx1tcqkOELWJnkgnCHIPBd62NM3D8DgHVH6sgd599/Vl1udincKkSw6IEgilRdAXnu9ogJbimXHatjkjEWXnKSINGUmizqqheA3eRDYL/R7TmGGcnle3gDZ4Zbs2sIJzh5Mbkwp7dLf3hpferjOAG0=" - - secure: "TaPOaDHt+rkHB5QBpz0ajwrMB2mmbWnofOFONITqlx+pyP1roq87gDK10+KY8/JqnB1fw+6epcRK+l1R6jzffAdBZzb1c7uaB7DLksHJc8oxFpLcDBArHUonWX82K+4NjVe80pVfwzMX6L9JEaV2xPSxTY1VHRnuc7qhVUk7yMkt9pweSwJu2vzlJLiwLabc2NIkTUQaCaWmEREt0Tb13HZWGEUidoFPKODSAQzByGlkdX6NkJhRmlpSEkhGytvV1QY2I9rO5D9Y3bnfLYRRQ57kHRjbMQe2von31UYYAfkArY4TniogTMJj/pbWsX/v0YFm2Yx/pQsgFkXYwoaDS29isYc6EqSUiQmqOI6bRuXb/5ksn38VhIj4MbVIFKGG6XkV1hzZ3nQ/AQaONmVGIy+IVwmOjZirYRsGuazEFAXp9CTGK6FACk+TCmswEMZOTnVH5w6m9OFLEokmNYCwoHudrEjgGhPT8IlV6MR+WZOYVJgBuO3zMxOe2nk/4nR4ulhtgH/JYGW5KVUK8+eVSc58tN98SgtFpWMK6MqDxrrMB6A41AzkbsMwB+cg99+0ZMTAjrW+2r2HhynnNVJbOW8cv499lV8cdkVg1V0BjZIAJxLb5RedLFSa/5cWViDNqJZuvp288OdSShf4buH0ElhGmAR3tgOoPhGQD2h8TvE=" \ No newline at end of file + email: false \ No newline at end of file diff --git a/1.10.2/src/main/java/net/teamfruit/serverobserver/IProxy.java b/1.10.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java similarity index 96% rename from 1.10.2/src/main/java/net/teamfruit/serverobserver/IProxy.java rename to 1.10.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java index 936416a..72a66f2 100644 --- a/1.10.2/src/main/java/net/teamfruit/serverobserver/IProxy.java +++ b/1.10.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java @@ -1,17 +1,17 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public interface IProxy { - - void preInit(@Nonnull FMLPreInitializationEvent event); - - void init(@Nonnull FMLInitializationEvent event); - - void postInit(@Nonnull FMLPostInitializationEvent event); - +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public interface IProxy { + + void preInit(@Nonnull FMLPreInitializationEvent event); + + void init(@Nonnull FMLInitializationEvent event); + + void postInit(@Nonnull FMLPostInitializationEvent event); + } \ No newline at end of file diff --git a/1.12.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java b/1.10.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java similarity index 96% rename from 1.12.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java rename to 1.10.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java index 6cd19f1..43f16c7 100644 --- a/1.12.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java +++ b/1.10.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java @@ -1,44 +1,44 @@ -package net.teamfruit.serverobserver; - -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkCheckHandler; -import net.minecraftforge.fml.relauncher.Side; - -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) -public class ServerObserver { - @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) - private static @Nullable IProxy proxy; - - @NetworkCheckHandler - public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { - return true; - } - - @EventHandler - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - if (proxy!=null) - proxy.preInit(event); - } - - @EventHandler - public void init(final @Nonnull FMLInitializationEvent event) { - if (proxy!=null) - proxy.init(event); - } - - @EventHandler - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - if (proxy!=null) - proxy.postInit(event); - } -} +package net.teamfruit.serverobserver; + +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkCheckHandler; +import net.minecraftforge.fml.relauncher.Side; + +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) +public class ServerObserver { + @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) + private static @Nullable IProxy proxy; + + @NetworkCheckHandler + public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { + return true; + } + + @EventHandler + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + if (proxy!=null) + proxy.preInit(event); + } + + @EventHandler + public void init(final @Nonnull FMLInitializationEvent event) { + if (proxy!=null) + proxy.init(event); + } + + @EventHandler + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + if (proxy!=null) + proxy.postInit(event); + } +} diff --git a/1.10.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java b/1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java similarity index 96% rename from 1.10.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java rename to 1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java index cf0c0a3..3c7bb02 100644 --- a/1.10.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java +++ b/1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java @@ -1,45 +1,45 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.io.IOException; - -import javax.annotation.Nonnull; - -import org.apache.commons.io.FileUtils; - -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class ClientProxy extends CommonProxy { - @Override - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - super.preInit(event); - final File cfgDir = event.getModConfigurationDirectory(); - final File modCfgDir = new File(cfgDir, Reference.MODID); - final File oldCfg = event.getSuggestedConfigurationFile(); - final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); - if (oldCfg.exists()) - try { - FileUtils.moveFile(oldCfg, cfg); - } catch (final IOException e) { - } - final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); - Config.init(cfg, dynCfg, "1.1.0", Compat.compat); - CoreHandler.instance.preInit(modCfgDir); - } - - @Override - public void init(final @Nonnull FMLInitializationEvent event) { - super.init(event); - // Event Register - CoreHandler.instance.init(); - } - - @Override - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - super.postInit(event); - Config.getConfig().save(); - } +package net.teamfruit.serverobserver; + +import java.io.File; +import java.io.IOException; + +import javax.annotation.Nonnull; + +import org.apache.commons.io.FileUtils; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class ClientProxy extends CommonProxy { + @Override + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + super.preInit(event); + final File cfgDir = event.getModConfigurationDirectory(); + final File modCfgDir = new File(cfgDir, Reference.MODID); + final File oldCfg = event.getSuggestedConfigurationFile(); + final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); + if (oldCfg.exists()) + try { + FileUtils.moveFile(oldCfg, cfg); + } catch (final IOException e) { + } + final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); + Config.init(cfg, dynCfg, "1.1.0", Compat.compat); + CoreHandler.instance.preInit(modCfgDir); + } + + @Override + public void init(final @Nonnull FMLInitializationEvent event) { + super.init(event); + // Event Register + CoreHandler.instance.init(); + } + + @Override + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + super.postInit(event); + Config.getConfig().save(); + } } \ No newline at end of file diff --git a/1.12.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java b/1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java similarity index 96% rename from 1.12.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java rename to 1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java index c909736..42d04c0 100644 --- a/1.12.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java +++ b/1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java @@ -1,19 +1,19 @@ -package net.teamfruit.serverobserver; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class CommonProxy implements IProxy { - @Override - public void preInit(final FMLPreInitializationEvent event) { - } - - @Override - public void init(final FMLInitializationEvent event) { - } - - @Override - public void postInit(final FMLPostInitializationEvent event) { - } -} +package net.teamfruit.serverobserver; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class CommonProxy implements IProxy { + @Override + public void preInit(final FMLPreInitializationEvent event) { + } + + @Override + public void init(final FMLInitializationEvent event) { + } + + @Override + public void postInit(final FMLPostInitializationEvent event) { + } +} diff --git a/1.11.2/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java similarity index 96% rename from 1.11.2/src/main/java/net/teamfruit/serverobserver/Compat.java rename to 1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java index 019547f..f6bd5c5 100644 --- a/1.11.2/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,159 +1,159 @@ -package net.teamfruit.serverobserver; - -import java.net.SocketAddress; -import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; - -import javax.annotation.Nonnull; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ServerListEntryNormal; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.ServerList; -import net.minecraft.init.SoundEvents; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.teamfruit.serverobserver.GuiHandler.SkeletonButtonDrawInside; - -public class Compat implements ICompat { - public static final @Nonnull ICompat compat = new Compat(); - - @Override - public void color(final float colorRed, final float colorGreen, final float colorBlue, final float colorAlpha) { - GL11.glColor4f(colorRed, colorGreen, colorBlue, colorAlpha); - } - - @Override - public List getButtonList(final InitGuiEvent e) { - return e.getButtonList(); - } - - @Override - public FontRenderer font(final Minecraft mc) { - return mc.fontRendererObj; - } - - @Override - public int getHeight(final GuiDisconnected dcgui) { - return dcgui.height/2+dcgui.textHeight/2+font(dcgui.mc).FONT_HEIGHT+25; - } - - @Override - public GuiScreen getParentScreen(final GuiDisconnected dcgui) { - return dcgui.parentScreen; - } - - @Override - public GuiButton getButton(final ActionPerformedEvent e) { - return e.getButton(); - } - - @Override - public int getSelected(final GuiMultiplayer mpgui) { - return mpgui.serverListSelector.getSelected(); - } - - @Override - public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { - FMLClientHandler.instance().connectToServer(mpgui, serverData); - } - - @Override - public boolean getPinged(final ServerData serverData) { - return serverData.pinged; - } - - @Override - public void setPinged(final ServerData serverData, final boolean pinged) { - serverData.pinged = pinged; - } - - @Override - public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { - mpgui.getOldServerPinger().ping(serverData); - } - - @Override - public String getDefaultSound() { - return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); - } - - @Override - public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { - mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, SoundCategory.MASTER, 0.25F, pitch, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F)); - } - - @Override - public void selectServer(final GuiMultiplayer mpgui, final int index) { - mpgui.selectServer(index); - } - - @Override - public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { - return mpgui.getServerList().getServerData(index); - } - - @Override - public ServerList getServerList(final GuiMultiplayer mpgui) { - return mpgui.getServerList(); - } - - @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); - } - - @Override - public NetworkManager getClientToServerNetworkManager() { - return FMLClientHandler.instance().getClientToServerNetworkManager(); - } - - @Override - public ThreadPoolExecutor getThreadPool() { - return ServerListEntryNormal.EXECUTOR; - } - - @Override - public SocketAddress getSocketAddress(final NetworkManager netManager) { - return netManager.getRemoteAddress(); - } - - public static class SkeletonButton extends GuiButton { - private final SkeletonButtonDrawInside inside; - private final ICompat compat; - - public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - super(buttonId, x, y, widthIn, heightIn, buttonText); - this.inside = inside; - this.compat = compat; - } - - protected boolean isHovered; - - @Override - public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { - if (this.visible) { - this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); - final int x = this.xPosition; - final int y = this.yPosition; - this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getButtonList(final InitGuiEvent e) { + return e.getButtonList(); + } + + @Override + public FontRenderer font(final Minecraft mc) { + return mc.fontRendererObj; + } + + @Override + public int getHeight(final GuiDisconnected dcgui) { + return dcgui.height/2+dcgui.textHeight/2+font(dcgui.mc).FONT_HEIGHT+25; + } + + @Override + public GuiScreen getParentScreen(final GuiDisconnected dcgui) { + return dcgui.parentScreen; + } + + @Override + public GuiButton getButton(final ActionPerformedEvent e) { + return e.getButton(); + } + + @Override + public int getSelected(final GuiMultiplayer mpgui) { + return mpgui.serverListSelector.getSelected(); + } + + @Override + public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { + FMLClientHandler.instance().connectToServer(mpgui, serverData); + } + + @Override + public boolean getPinged(final ServerData serverData) { + return serverData.pinged; + } + + @Override + public void setPinged(final ServerData serverData, final boolean pinged) { + serverData.pinged = pinged; + } + + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + + @Override + public String getDefaultSound() { + return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); + } + + @Override + public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { + mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, SoundCategory.MASTER, 0.25F, pitch, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F)); + } + + @Override + public void selectServer(final GuiMultiplayer mpgui, final int index) { + mpgui.selectServer(index); + } + + @Override + public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { + return mpgui.getServerList().getServerData(index); + } + + @Override + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); + } + + @Override + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + } + + @Override + public NetworkManager getClientToServerNetworkManager() { + return FMLClientHandler.instance().getClientToServerNetworkManager(); + } + + @Override + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.EXECUTOR; + } + + @Override + public SocketAddress getSocketAddress(final NetworkManager netManager) { + return netManager.getRemoteAddress(); + } + + public static class SkeletonButton extends GuiButton { + private final SkeletonButtonDrawInside inside; + private final ICompat compat; + + public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + super(buttonId, x, y, widthIn, heightIn, buttonText); + this.inside = inside; + this.compat = compat; + } + + protected boolean isHovered; + + @Override + public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { + if (this.visible) { + this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); + final int x = this.xPosition; + final int y = this.yPosition; + this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getConfigElements() { - final List list = new ArrayList(); - getConfigElements(list, Config.getConfig().getBase()); - getConfigElements(list, Config.getConfig().getBaseDynamic()); - return list; - } - - private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { - ConfigCategory general = null; - - for (final String cat : cb.getCategoryNames()) { - final ConfigCategory cc = cb.getCategory(cat); - - if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { - general = cc; - continue; - } - - if (cc.isChild()) - continue; - - list.add(new ConfigElement(cc)); - } - - // General項目をトップに表示します - if (general!=null) { - for (final ConfigCategory cc : general.getChildren()) - list.add(new ConfigElement(cc)); - for (final Property prop : general.values()) - list.add(new ConfigElement(prop)); - } - - return list; - } - } - - @Override - public void initialize(final @Nullable Minecraft minecraftInstance) { - - } - - @Override - public @Nullable Class mainConfigGuiClass() { - return ConfigGui.class; - } - - @Override - public @Nullable Set runtimeGuiCategories() { - return null; - } - - @SuppressWarnings("deprecation") - @Override - public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { - return null; - } +package net.teamfruit.serverobserver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import net.minecraftforge.fml.client.IModGuiFactory; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; + +/** + * コンフィグGUI + * + * @author Kamesuta + */ +public class ConfigGuiFactory implements IModGuiFactory { + + public static class ConfigGui extends GuiConfig { + + public ConfigGui(final @Nullable GuiScreen parent) { + super(parent, getConfigElements(), Reference.MODID, false, false, I18n.format("serverobserver.config")); + } + + private static @Nonnull List getConfigElements() { + final List list = new ArrayList(); + getConfigElements(list, Config.getConfig().getBase()); + getConfigElements(list, Config.getConfig().getBaseDynamic()); + return list; + } + + private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { + ConfigCategory general = null; + + for (final String cat : cb.getCategoryNames()) { + final ConfigCategory cc = cb.getCategory(cat); + + if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { + general = cc; + continue; + } + + if (cc.isChild()) + continue; + + list.add(new ConfigElement(cc)); + } + + // General項目をトップに表示します + if (general!=null) { + for (final ConfigCategory cc : general.getChildren()) + list.add(new ConfigElement(cc)); + for (final Property prop : general.values()) + list.add(new ConfigElement(prop)); + } + + return list; + } + } + + @Override + public void initialize(final @Nullable Minecraft minecraftInstance) { + + } + + @Override + public @Nullable Class mainConfigGuiClass() { + return ConfigGui.class; + } + + @Override + public @Nullable Set runtimeGuiCategories() { + return null; + } + + @SuppressWarnings("deprecation") + @Override + public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { + return null; + } } \ No newline at end of file diff --git a/1.12.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java b/1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java similarity index 96% rename from 1.12.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java rename to 1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java index 63b4ced..0d9b3f6 100644 --- a/1.12.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java +++ b/1.10.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java @@ -1,60 +1,60 @@ -package net.teamfruit.serverobserver; - -import java.io.File; - -import javax.annotation.Nonnull; - -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.event.ConfigChangedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; - -public class CoreHandler { - public static final @Nonnull CoreHandler instance = new CoreHandler(); - - public final @Nonnull Config configHandler = Config.getConfig(); - public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); - - public void preInit(final File root) { - this.guiHandler.init(root); - } - - public void init() { - // FMLCommonHandler.instance().bus().register(this); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - for (final ConfigBase base : ConfigBase.configChangeHandlers) - base.onConfigChanged(eventArgs.getModID()); - } - - @SubscribeEvent - public void open(final InitGuiEvent.Post e) { - this.guiHandler.open(e); - } - - @SubscribeEvent - public void draw(final DrawScreenEvent.Post e) { - this.guiHandler.draw(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Pre e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Post e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void tickclient(final @Nonnull ClientTickEvent e) { - this.guiHandler.tickclient(); - } +package net.teamfruit.serverobserver; + +import java.io.File; + +import javax.annotation.Nonnull; + +import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; +import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.event.ConfigChangedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; + +public class CoreHandler { + public static final @Nonnull CoreHandler instance = new CoreHandler(); + + public final @Nonnull Config configHandler = Config.getConfig(); + public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); + + public void preInit(final File root) { + this.guiHandler.init(root); + } + + public void init() { + // FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + for (final ConfigBase base : ConfigBase.configChangeHandlers) + base.onConfigChanged(eventArgs.getModID()); + } + + @SubscribeEvent + public void open(final InitGuiEvent.Post e) { + this.guiHandler.open(e); + } + + @SubscribeEvent + public void draw(final DrawScreenEvent.Post e) { + this.guiHandler.draw(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Pre e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Post e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void tickclient(final @Nonnull ClientTickEvent e) { + this.guiHandler.tickclient(); + } } \ No newline at end of file diff --git a/1.12.2/src/main/java/net/teamfruit/serverobserver/IProxy.java b/1.11.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java similarity index 96% rename from 1.12.2/src/main/java/net/teamfruit/serverobserver/IProxy.java rename to 1.11.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java index 936416a..72a66f2 100644 --- a/1.12.2/src/main/java/net/teamfruit/serverobserver/IProxy.java +++ b/1.11.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java @@ -1,17 +1,17 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public interface IProxy { - - void preInit(@Nonnull FMLPreInitializationEvent event); - - void init(@Nonnull FMLInitializationEvent event); - - void postInit(@Nonnull FMLPostInitializationEvent event); - +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public interface IProxy { + + void preInit(@Nonnull FMLPreInitializationEvent event); + + void init(@Nonnull FMLInitializationEvent event); + + void postInit(@Nonnull FMLPostInitializationEvent event); + } \ No newline at end of file diff --git a/1.11.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java b/1.11.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java similarity index 96% rename from 1.11.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java rename to 1.11.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java index 6cd19f1..43f16c7 100644 --- a/1.11.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java +++ b/1.11.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java @@ -1,44 +1,44 @@ -package net.teamfruit.serverobserver; - -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkCheckHandler; -import net.minecraftforge.fml.relauncher.Side; - -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) -public class ServerObserver { - @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) - private static @Nullable IProxy proxy; - - @NetworkCheckHandler - public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { - return true; - } - - @EventHandler - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - if (proxy!=null) - proxy.preInit(event); - } - - @EventHandler - public void init(final @Nonnull FMLInitializationEvent event) { - if (proxy!=null) - proxy.init(event); - } - - @EventHandler - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - if (proxy!=null) - proxy.postInit(event); - } -} +package net.teamfruit.serverobserver; + +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkCheckHandler; +import net.minecraftforge.fml.relauncher.Side; + +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) +public class ServerObserver { + @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) + private static @Nullable IProxy proxy; + + @NetworkCheckHandler + public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { + return true; + } + + @EventHandler + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + if (proxy!=null) + proxy.preInit(event); + } + + @EventHandler + public void init(final @Nonnull FMLInitializationEvent event) { + if (proxy!=null) + proxy.init(event); + } + + @EventHandler + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + if (proxy!=null) + proxy.postInit(event); + } +} diff --git a/1.11.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java b/1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java similarity index 96% rename from 1.11.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java rename to 1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java index 95159a8..9da3ac9 100644 --- a/1.11.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java +++ b/1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java @@ -1,45 +1,45 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.io.IOException; - -import javax.annotation.Nonnull; - -import org.apache.commons.io.FileUtils; - -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class ClientProxy extends CommonProxy { - @Override - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - super.preInit(event); - final File cfgDir = event.getModConfigurationDirectory(); - final File modCfgDir = new File(cfgDir, Reference.MODID); - final File oldCfg = event.getSuggestedConfigurationFile(); - final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); - if (oldCfg.exists()) - try { - FileUtils.moveFile(oldCfg, cfg); - } catch (final IOException e) { - } - final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); - Config.init(cfg, dynCfg, "1.0.0", Compat.compat); - CoreHandler.instance.preInit(modCfgDir); - } - - @Override - public void init(final @Nonnull FMLInitializationEvent event) { - super.init(event); - // Event Register - CoreHandler.instance.init(); - } - - @Override - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - super.postInit(event); - Config.getConfig().save(); - } +package net.teamfruit.serverobserver; + +import java.io.File; +import java.io.IOException; + +import javax.annotation.Nonnull; + +import org.apache.commons.io.FileUtils; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class ClientProxy extends CommonProxy { + @Override + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + super.preInit(event); + final File cfgDir = event.getModConfigurationDirectory(); + final File modCfgDir = new File(cfgDir, Reference.MODID); + final File oldCfg = event.getSuggestedConfigurationFile(); + final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); + if (oldCfg.exists()) + try { + FileUtils.moveFile(oldCfg, cfg); + } catch (final IOException e) { + } + final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); + Config.init(cfg, dynCfg, "1.0.0", Compat.compat); + CoreHandler.instance.preInit(modCfgDir); + } + + @Override + public void init(final @Nonnull FMLInitializationEvent event) { + super.init(event); + // Event Register + CoreHandler.instance.init(); + } + + @Override + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + super.postInit(event); + Config.getConfig().save(); + } } \ No newline at end of file diff --git a/1.10.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java b/1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java similarity index 96% rename from 1.10.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java rename to 1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java index c909736..42d04c0 100644 --- a/1.10.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java +++ b/1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java @@ -1,19 +1,19 @@ -package net.teamfruit.serverobserver; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class CommonProxy implements IProxy { - @Override - public void preInit(final FMLPreInitializationEvent event) { - } - - @Override - public void init(final FMLInitializationEvent event) { - } - - @Override - public void postInit(final FMLPostInitializationEvent event) { - } -} +package net.teamfruit.serverobserver; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class CommonProxy implements IProxy { + @Override + public void preInit(final FMLPreInitializationEvent event) { + } + + @Override + public void init(final FMLInitializationEvent event) { + } + + @Override + public void postInit(final FMLPostInitializationEvent event) { + } +} diff --git a/1.9.4/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java similarity index 96% rename from 1.9.4/src/main/java/net/teamfruit/serverobserver/Compat.java rename to 1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java index 69bc6ea..f6bd5c5 100644 --- a/1.9.4/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,159 +1,159 @@ -package net.teamfruit.serverobserver; - -import java.net.SocketAddress; -import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; - -import javax.annotation.Nonnull; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ServerListEntryNormal; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.ServerList; -import net.minecraft.init.SoundEvents; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.teamfruit.serverobserver.GuiHandler.SkeletonButtonDrawInside; - -public class Compat implements ICompat { - public static final @Nonnull ICompat compat = new Compat(); - - @Override - public void color(final float colorRed, final float colorGreen, final float colorBlue, final float colorAlpha) { - GL11.glColor4f(colorRed, colorGreen, colorBlue, colorAlpha); - } - - @Override - public List getButtonList(final InitGuiEvent e) { - return e.getButtonList(); - } - - @Override - public FontRenderer font(final Minecraft mc) { - return mc.fontRendererObj; - } - - @Override - public int getHeight(final GuiDisconnected dcgui) { - return dcgui.height/2+dcgui.textHeight/2+font(dcgui.mc).FONT_HEIGHT+25; - } - - @Override - public GuiScreen getParentScreen(final GuiDisconnected dcgui) { - return dcgui.parentScreen; - } - - @Override - public GuiButton getButton(final ActionPerformedEvent e) { - return e.getButton(); - } - - @Override - public int getSelected(final GuiMultiplayer mpgui) { - return mpgui.serverListSelector.getSelected(); - } - - @Override - public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { - FMLClientHandler.instance().connectToServer(mpgui, serverData); - } - - @Override - public boolean getPinged(final ServerData serverData) { - return serverData.pinged; - } - - @Override - public void setPinged(final ServerData serverData, final boolean pinged) { - serverData.pinged = pinged; - } - - @Override - public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { - mpgui.getOldServerPinger().ping(serverData); - } - - @Override - public String getDefaultSound() { - return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); - } - - @Override - public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { - mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, SoundCategory.MASTER, 0.25F, pitch, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F)); - } - - @Override - public void selectServer(final GuiMultiplayer mpgui, final int index) { - mpgui.selectServer(index); - } - - @Override - public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { - return mpgui.getServerList().getServerData(index); - } - - @Override - public ServerList getServerList(final GuiMultiplayer mpgui) { - return mpgui.getServerList(); - } - - @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); - } - - @Override - public ThreadPoolExecutor getThreadPool() { - return ServerListEntryNormal.EXECUTOR; - } - - @Override - public NetworkManager getClientToServerNetworkManager() { - return FMLClientHandler.instance().getClientToServerNetworkManager(); - } - - @Override - public SocketAddress getSocketAddress(final NetworkManager netManager) { - return netManager.getRemoteAddress(); - } - - public static class SkeletonButton extends GuiButton { - private final SkeletonButtonDrawInside inside; - private final ICompat compat; - - public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - super(buttonId, x, y, widthIn, heightIn, buttonText); - this.inside = inside; - this.compat = compat; - } - - protected boolean isHovered; - - @Override - public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { - if (this.visible) { - this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); - final int x = this.xPosition; - final int y = this.yPosition; - this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getButtonList(final InitGuiEvent e) { + return e.getButtonList(); + } + + @Override + public FontRenderer font(final Minecraft mc) { + return mc.fontRendererObj; + } + + @Override + public int getHeight(final GuiDisconnected dcgui) { + return dcgui.height/2+dcgui.textHeight/2+font(dcgui.mc).FONT_HEIGHT+25; + } + + @Override + public GuiScreen getParentScreen(final GuiDisconnected dcgui) { + return dcgui.parentScreen; + } + + @Override + public GuiButton getButton(final ActionPerformedEvent e) { + return e.getButton(); + } + + @Override + public int getSelected(final GuiMultiplayer mpgui) { + return mpgui.serverListSelector.getSelected(); + } + + @Override + public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { + FMLClientHandler.instance().connectToServer(mpgui, serverData); + } + + @Override + public boolean getPinged(final ServerData serverData) { + return serverData.pinged; + } + + @Override + public void setPinged(final ServerData serverData, final boolean pinged) { + serverData.pinged = pinged; + } + + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + + @Override + public String getDefaultSound() { + return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); + } + + @Override + public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { + mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, SoundCategory.MASTER, 0.25F, pitch, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F)); + } + + @Override + public void selectServer(final GuiMultiplayer mpgui, final int index) { + mpgui.selectServer(index); + } + + @Override + public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { + return mpgui.getServerList().getServerData(index); + } + + @Override + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); + } + + @Override + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + } + + @Override + public NetworkManager getClientToServerNetworkManager() { + return FMLClientHandler.instance().getClientToServerNetworkManager(); + } + + @Override + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.EXECUTOR; + } + + @Override + public SocketAddress getSocketAddress(final NetworkManager netManager) { + return netManager.getRemoteAddress(); + } + + public static class SkeletonButton extends GuiButton { + private final SkeletonButtonDrawInside inside; + private final ICompat compat; + + public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + super(buttonId, x, y, widthIn, heightIn, buttonText); + this.inside = inside; + this.compat = compat; + } + + protected boolean isHovered; + + @Override + public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { + if (this.visible) { + this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); + final int x = this.xPosition; + final int y = this.yPosition; + this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getConfigElements() { - final List list = new ArrayList(); - getConfigElements(list, Config.getConfig().getBase()); - getConfigElements(list, Config.getConfig().getBaseDynamic()); - return list; - } - - private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { - ConfigCategory general = null; - - for (final String cat : cb.getCategoryNames()) { - final ConfigCategory cc = cb.getCategory(cat); - - if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { - general = cc; - continue; - } - - if (cc.isChild()) - continue; - - list.add(new ConfigElement(cc)); - } - - // General項目をトップに表示します - if (general!=null) { - for (final ConfigCategory cc : general.getChildren()) - list.add(new ConfigElement(cc)); - for (final Property prop : general.values()) - list.add(new ConfigElement(prop)); - } - - return list; - } - } - - @Override - public void initialize(final @Nullable Minecraft minecraftInstance) { - - } - - @Override - public @Nullable Class mainConfigGuiClass() { - return ConfigGui.class; - } - - @Override - public @Nullable Set runtimeGuiCategories() { - return null; - } - - @SuppressWarnings("deprecation") - @Override - public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { - return null; - } - - @Override - public boolean hasConfigGui() { - return true; - } - - @Override - public GuiScreen createConfigGui(final GuiScreen parentScreen) { - return new ConfigGui(parentScreen); - } +package net.teamfruit.serverobserver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import net.minecraftforge.fml.client.IModGuiFactory; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; + +/** + * コンフィグGUI + * + * @author Kamesuta + */ +public class ConfigGuiFactory implements IModGuiFactory { + + public static class ConfigGui extends GuiConfig { + + public ConfigGui(final @Nullable GuiScreen parent) { + super(parent, getConfigElements(), Reference.MODID, false, false, I18n.format("serverobserver.config")); + } + + private static @Nonnull List getConfigElements() { + final List list = new ArrayList(); + getConfigElements(list, Config.getConfig().getBase()); + getConfigElements(list, Config.getConfig().getBaseDynamic()); + return list; + } + + private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { + ConfigCategory general = null; + + for (final String cat : cb.getCategoryNames()) { + final ConfigCategory cc = cb.getCategory(cat); + + if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { + general = cc; + continue; + } + + if (cc.isChild()) + continue; + + list.add(new ConfigElement(cc)); + } + + // General項目をトップに表示します + if (general!=null) { + for (final ConfigCategory cc : general.getChildren()) + list.add(new ConfigElement(cc)); + for (final Property prop : general.values()) + list.add(new ConfigElement(prop)); + } + + return list; + } + } + + @Override + public void initialize(final @Nullable Minecraft minecraftInstance) { + + } + + @Override + public @Nullable Class mainConfigGuiClass() { + return ConfigGui.class; + } + + @Override + public @Nullable Set runtimeGuiCategories() { + return null; + } + + @SuppressWarnings("deprecation") + @Override + public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { + return null; + } + + @Override + public boolean hasConfigGui() { + return true; + } + + @Override + public GuiScreen createConfigGui(final GuiScreen parentScreen) { + return new ConfigGui(parentScreen); + } } \ No newline at end of file diff --git a/1.10.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java b/1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java similarity index 96% rename from 1.10.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java rename to 1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java index 63b4ced..0d9b3f6 100644 --- a/1.10.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java +++ b/1.11.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java @@ -1,60 +1,60 @@ -package net.teamfruit.serverobserver; - -import java.io.File; - -import javax.annotation.Nonnull; - -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.event.ConfigChangedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; - -public class CoreHandler { - public static final @Nonnull CoreHandler instance = new CoreHandler(); - - public final @Nonnull Config configHandler = Config.getConfig(); - public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); - - public void preInit(final File root) { - this.guiHandler.init(root); - } - - public void init() { - // FMLCommonHandler.instance().bus().register(this); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - for (final ConfigBase base : ConfigBase.configChangeHandlers) - base.onConfigChanged(eventArgs.getModID()); - } - - @SubscribeEvent - public void open(final InitGuiEvent.Post e) { - this.guiHandler.open(e); - } - - @SubscribeEvent - public void draw(final DrawScreenEvent.Post e) { - this.guiHandler.draw(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Pre e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Post e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void tickclient(final @Nonnull ClientTickEvent e) { - this.guiHandler.tickclient(); - } +package net.teamfruit.serverobserver; + +import java.io.File; + +import javax.annotation.Nonnull; + +import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; +import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.event.ConfigChangedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; + +public class CoreHandler { + public static final @Nonnull CoreHandler instance = new CoreHandler(); + + public final @Nonnull Config configHandler = Config.getConfig(); + public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); + + public void preInit(final File root) { + this.guiHandler.init(root); + } + + public void init() { + // FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + for (final ConfigBase base : ConfigBase.configChangeHandlers) + base.onConfigChanged(eventArgs.getModID()); + } + + @SubscribeEvent + public void open(final InitGuiEvent.Post e) { + this.guiHandler.open(e); + } + + @SubscribeEvent + public void draw(final DrawScreenEvent.Post e) { + this.guiHandler.draw(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Pre e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Post e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void tickclient(final @Nonnull ClientTickEvent e) { + this.guiHandler.tickclient(); + } } \ No newline at end of file diff --git a/1.11.2/src/main/resources/META-INF/serverobserver_at.cfg b/1.11.2/src/main/resources/META-INF/serverobserver_at.cfg deleted file mode 100644 index 1e5ce1e..0000000 --- a/1.11.2/src/main/resources/META-INF/serverobserver_at.cfg +++ /dev/null @@ -1,5 +0,0 @@ -public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector -public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight -public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer -public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/1.8.9/src/main/java/net/teamfruit/serverobserver/IProxy.java b/1.12.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java similarity index 96% rename from 1.8.9/src/main/java/net/teamfruit/serverobserver/IProxy.java rename to 1.12.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java index 936416a..72a66f2 100644 --- a/1.8.9/src/main/java/net/teamfruit/serverobserver/IProxy.java +++ b/1.12.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java @@ -1,17 +1,17 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public interface IProxy { - - void preInit(@Nonnull FMLPreInitializationEvent event); - - void init(@Nonnull FMLInitializationEvent event); - - void postInit(@Nonnull FMLPostInitializationEvent event); - +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public interface IProxy { + + void preInit(@Nonnull FMLPreInitializationEvent event); + + void init(@Nonnull FMLInitializationEvent event); + + void postInit(@Nonnull FMLPostInitializationEvent event); + } \ No newline at end of file diff --git a/1.10.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java b/1.12.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java similarity index 96% rename from 1.10.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java rename to 1.12.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java index 6cd19f1..43f16c7 100644 --- a/1.10.2/src/main/java/net/teamfruit/serverobserver/ServerObserver.java +++ b/1.12.2/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java @@ -1,44 +1,44 @@ -package net.teamfruit.serverobserver; - -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkCheckHandler; -import net.minecraftforge.fml.relauncher.Side; - -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) -public class ServerObserver { - @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) - private static @Nullable IProxy proxy; - - @NetworkCheckHandler - public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { - return true; - } - - @EventHandler - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - if (proxy!=null) - proxy.preInit(event); - } - - @EventHandler - public void init(final @Nonnull FMLInitializationEvent event) { - if (proxy!=null) - proxy.init(event); - } - - @EventHandler - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - if (proxy!=null) - proxy.postInit(event); - } -} +package net.teamfruit.serverobserver; + +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkCheckHandler; +import net.minecraftforge.fml.relauncher.Side; + +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) +public class ServerObserver { + @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) + private static @Nullable IProxy proxy; + + @NetworkCheckHandler + public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { + return true; + } + + @EventHandler + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + if (proxy!=null) + proxy.preInit(event); + } + + @EventHandler + public void init(final @Nonnull FMLInitializationEvent event) { + if (proxy!=null) + proxy.init(event); + } + + @EventHandler + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + if (proxy!=null) + proxy.postInit(event); + } +} diff --git a/1.12.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java b/1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java similarity index 96% rename from 1.12.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java rename to 1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java index cf0c0a3..3c7bb02 100644 --- a/1.12.2/src/main/java/net/teamfruit/serverobserver/ClientProxy.java +++ b/1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java @@ -1,45 +1,45 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.io.IOException; - -import javax.annotation.Nonnull; - -import org.apache.commons.io.FileUtils; - -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class ClientProxy extends CommonProxy { - @Override - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - super.preInit(event); - final File cfgDir = event.getModConfigurationDirectory(); - final File modCfgDir = new File(cfgDir, Reference.MODID); - final File oldCfg = event.getSuggestedConfigurationFile(); - final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); - if (oldCfg.exists()) - try { - FileUtils.moveFile(oldCfg, cfg); - } catch (final IOException e) { - } - final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); - Config.init(cfg, dynCfg, "1.1.0", Compat.compat); - CoreHandler.instance.preInit(modCfgDir); - } - - @Override - public void init(final @Nonnull FMLInitializationEvent event) { - super.init(event); - // Event Register - CoreHandler.instance.init(); - } - - @Override - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - super.postInit(event); - Config.getConfig().save(); - } +package net.teamfruit.serverobserver; + +import java.io.File; +import java.io.IOException; + +import javax.annotation.Nonnull; + +import org.apache.commons.io.FileUtils; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class ClientProxy extends CommonProxy { + @Override + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + super.preInit(event); + final File cfgDir = event.getModConfigurationDirectory(); + final File modCfgDir = new File(cfgDir, Reference.MODID); + final File oldCfg = event.getSuggestedConfigurationFile(); + final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); + if (oldCfg.exists()) + try { + FileUtils.moveFile(oldCfg, cfg); + } catch (final IOException e) { + } + final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); + Config.init(cfg, dynCfg, "1.1.0", Compat.compat); + CoreHandler.instance.preInit(modCfgDir); + } + + @Override + public void init(final @Nonnull FMLInitializationEvent event) { + super.init(event); + // Event Register + CoreHandler.instance.init(); + } + + @Override + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + super.postInit(event); + Config.getConfig().save(); + } } \ No newline at end of file diff --git a/1.11.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java b/1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java similarity index 96% rename from 1.11.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java rename to 1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java index c909736..42d04c0 100644 --- a/1.11.2/src/main/java/net/teamfruit/serverobserver/CommonProxy.java +++ b/1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java @@ -1,19 +1,19 @@ -package net.teamfruit.serverobserver; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class CommonProxy implements IProxy { - @Override - public void preInit(final FMLPreInitializationEvent event) { - } - - @Override - public void init(final FMLInitializationEvent event) { - } - - @Override - public void postInit(final FMLPostInitializationEvent event) { - } -} +package net.teamfruit.serverobserver; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class CommonProxy implements IProxy { + @Override + public void preInit(final FMLPreInitializationEvent event) { + } + + @Override + public void init(final FMLInitializationEvent event) { + } + + @Override + public void postInit(final FMLPostInitializationEvent event) { + } +} diff --git a/1.12.2/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java similarity index 96% rename from 1.12.2/src/main/java/net/teamfruit/serverobserver/Compat.java rename to 1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java index 619784d..8039b37 100644 --- a/1.12.2/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,159 +1,159 @@ -package net.teamfruit.serverobserver; - -import java.net.SocketAddress; -import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; - -import javax.annotation.Nonnull; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ServerListEntryNormal; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.ServerList; -import net.minecraft.init.SoundEvents; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.teamfruit.serverobserver.GuiHandler.SkeletonButtonDrawInside; - -public class Compat implements ICompat { - public static final @Nonnull ICompat compat = new Compat(); - - @Override - public void color(final float colorRed, final float colorGreen, final float colorBlue, final float colorAlpha) { - GL11.glColor4f(colorRed, colorGreen, colorBlue, colorAlpha); - } - - @Override - public List getButtonList(final InitGuiEvent e) { - return e.getButtonList(); - } - - @Override - public FontRenderer font(final Minecraft mc) { - return mc.fontRenderer; - } - - @Override - public int getHeight(final GuiDisconnected dcgui) { - return dcgui.height/2+dcgui.textHeight/2+font(dcgui.mc).FONT_HEIGHT+25; - } - - @Override - public GuiScreen getParentScreen(final GuiDisconnected dcgui) { - return dcgui.parentScreen; - } - - @Override - public GuiButton getButton(final ActionPerformedEvent e) { - return e.getButton(); - } - - @Override - public int getSelected(final GuiMultiplayer mpgui) { - return mpgui.serverListSelector.getSelected(); - } - - @Override - public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { - FMLClientHandler.instance().connectToServer(mpgui, serverData); - } - - @Override - public boolean getPinged(final ServerData serverData) { - return serverData.pinged; - } - - @Override - public void setPinged(final ServerData serverData, final boolean pinged) { - serverData.pinged = pinged; - } - - @Override - public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { - mpgui.getOldServerPinger().ping(serverData); - } - - @Override - public String getDefaultSound() { - return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); - } - - @Override - public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { - mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, SoundCategory.MASTER, 0.25F, pitch, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F)); - } - - @Override - public void selectServer(final GuiMultiplayer mpgui, final int index) { - mpgui.selectServer(index); - } - - @Override - public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { - return mpgui.getServerList().getServerData(index); - } - - @Override - public ServerList getServerList(final GuiMultiplayer mpgui) { - return mpgui.getServerList(); - } - - @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); - } - - @Override - public ThreadPoolExecutor getThreadPool() { - return ServerListEntryNormal.EXECUTOR; - } - - @Override - public NetworkManager getClientToServerNetworkManager() { - return FMLClientHandler.instance().getClientToServerNetworkManager(); - } - - @Override - public SocketAddress getSocketAddress(final NetworkManager netManager) { - return netManager.getRemoteAddress(); - } - - public static class SkeletonButton extends GuiButton { - private final SkeletonButtonDrawInside inside; - private final ICompat compat; - - public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - super(buttonId, x, y, widthIn, heightIn, buttonText); - this.inside = inside; - this.compat = compat; - } - - protected boolean isHovered; - - @Override - public void drawButton(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks) { - if (this.visible) { - this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); - final int x = this.x; - final int y = this.y; - this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getButtonList(final InitGuiEvent e) { + return e.getButtonList(); + } + + @Override + public FontRenderer font(final Minecraft mc) { + return mc.fontRenderer; + } + + @Override + public int getHeight(final GuiDisconnected dcgui) { + return dcgui.height/2+dcgui.textHeight/2+font(dcgui.mc).FONT_HEIGHT+25; + } + + @Override + public GuiScreen getParentScreen(final GuiDisconnected dcgui) { + return dcgui.parentScreen; + } + + @Override + public GuiButton getButton(final ActionPerformedEvent e) { + return e.getButton(); + } + + @Override + public int getSelected(final GuiMultiplayer mpgui) { + return mpgui.serverListSelector.getSelected(); + } + + @Override + public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { + FMLClientHandler.instance().connectToServer(mpgui, serverData); + } + + @Override + public boolean getPinged(final ServerData serverData) { + return serverData.pinged; + } + + @Override + public void setPinged(final ServerData serverData, final boolean pinged) { + serverData.pinged = pinged; + } + + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + + @Override + public String getDefaultSound() { + return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); + } + + @Override + public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { + mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, SoundCategory.MASTER, 0.25F, pitch, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F)); + } + + @Override + public void selectServer(final GuiMultiplayer mpgui, final int index) { + mpgui.selectServer(index); + } + + @Override + public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { + return mpgui.getServerList().getServerData(index); + } + + @Override + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); + } + + @Override + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + } + + @Override + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.EXECUTOR; + } + + @Override + public NetworkManager getClientToServerNetworkManager() { + return FMLClientHandler.instance().getClientToServerNetworkManager(); + } + + @Override + public SocketAddress getSocketAddress(final NetworkManager netManager) { + return netManager.getRemoteAddress(); + } + + public static class SkeletonButton extends GuiButton { + private final SkeletonButtonDrawInside inside; + private final ICompat compat; + + public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + super(buttonId, x, y, widthIn, heightIn, buttonText); + this.inside = inside; + this.compat = compat; + } + + protected boolean isHovered; + + @Override + public void drawButton(final Minecraft mc, final int mouseX, final int mouseY, final float partialTicks) { + if (this.visible) { + this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); + final int x = this.x; + final int y = this.y; + this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getConfigElements() { - final List list = new ArrayList(); - getConfigElements(list, Config.getConfig().getBase()); - getConfigElements(list, Config.getConfig().getBaseDynamic()); - return list; - } - - private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { - ConfigCategory general = null; - - for (final String cat : cb.getCategoryNames()) { - final ConfigCategory cc = cb.getCategory(cat); - - if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { - general = cc; - continue; - } - - if (cc.isChild()) - continue; - - list.add(new ConfigElement(cc)); - } - - // General項目をトップに表示します - if (general!=null) { - for (final ConfigCategory cc : general.getChildren()) - list.add(new ConfigElement(cc)); - for (final Property prop : general.values()) - list.add(new ConfigElement(prop)); - } - - return list; - } - } - - @Override - public void initialize(final @Nullable Minecraft minecraftInstance) { - - } - - @Override - public @Nullable Set runtimeGuiCategories() { - return null; - } - - @Override - public boolean hasConfigGui() { - return true; - } - - @Override - public GuiScreen createConfigGui(final GuiScreen parentScreen) { - return new ConfigGui(parentScreen); - } +package net.teamfruit.serverobserver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import net.minecraftforge.fml.client.IModGuiFactory; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; + +/** + * コンフィグGUI + * + * @author Kamesuta + */ +public class ConfigGuiFactory implements IModGuiFactory { + + public static class ConfigGui extends GuiConfig { + + public ConfigGui(final @Nullable GuiScreen parent) { + super(parent, getConfigElements(), Reference.MODID, false, false, I18n.format("serverobserver.config")); + } + + private static @Nonnull List getConfigElements() { + final List list = new ArrayList(); + getConfigElements(list, Config.getConfig().getBase()); + getConfigElements(list, Config.getConfig().getBaseDynamic()); + return list; + } + + private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { + ConfigCategory general = null; + + for (final String cat : cb.getCategoryNames()) { + final ConfigCategory cc = cb.getCategory(cat); + + if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { + general = cc; + continue; + } + + if (cc.isChild()) + continue; + + list.add(new ConfigElement(cc)); + } + + // General項目をトップに表示します + if (general!=null) { + for (final ConfigCategory cc : general.getChildren()) + list.add(new ConfigElement(cc)); + for (final Property prop : general.values()) + list.add(new ConfigElement(prop)); + } + + return list; + } + } + + @Override + public void initialize(final @Nullable Minecraft minecraftInstance) { + + } + + @Override + public @Nullable Set runtimeGuiCategories() { + return null; + } + + @Override + public boolean hasConfigGui() { + return true; + } + + @Override + public GuiScreen createConfigGui(final GuiScreen parentScreen) { + return new ConfigGui(parentScreen); + } } \ No newline at end of file diff --git a/1.11.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java b/1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java similarity index 96% rename from 1.11.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java rename to 1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java index 63b4ced..0d9b3f6 100644 --- a/1.11.2/src/main/java/net/teamfruit/serverobserver/CoreHandler.java +++ b/1.12.2/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java @@ -1,60 +1,60 @@ -package net.teamfruit.serverobserver; - -import java.io.File; - -import javax.annotation.Nonnull; - -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.event.ConfigChangedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; - -public class CoreHandler { - public static final @Nonnull CoreHandler instance = new CoreHandler(); - - public final @Nonnull Config configHandler = Config.getConfig(); - public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); - - public void preInit(final File root) { - this.guiHandler.init(root); - } - - public void init() { - // FMLCommonHandler.instance().bus().register(this); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - for (final ConfigBase base : ConfigBase.configChangeHandlers) - base.onConfigChanged(eventArgs.getModID()); - } - - @SubscribeEvent - public void open(final InitGuiEvent.Post e) { - this.guiHandler.open(e); - } - - @SubscribeEvent - public void draw(final DrawScreenEvent.Post e) { - this.guiHandler.draw(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Pre e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Post e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void tickclient(final @Nonnull ClientTickEvent e) { - this.guiHandler.tickclient(); - } +package net.teamfruit.serverobserver; + +import java.io.File; + +import javax.annotation.Nonnull; + +import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; +import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.event.ConfigChangedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; + +public class CoreHandler { + public static final @Nonnull CoreHandler instance = new CoreHandler(); + + public final @Nonnull Config configHandler = Config.getConfig(); + public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); + + public void preInit(final File root) { + this.guiHandler.init(root); + } + + public void init() { + // FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + for (final ConfigBase base : ConfigBase.configChangeHandlers) + base.onConfigChanged(eventArgs.getModID()); + } + + @SubscribeEvent + public void open(final InitGuiEvent.Post e) { + this.guiHandler.open(e); + } + + @SubscribeEvent + public void draw(final DrawScreenEvent.Post e) { + this.guiHandler.draw(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Pre e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Post e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void tickclient(final @Nonnull ClientTickEvent e) { + this.guiHandler.tickclient(); + } } \ No newline at end of file diff --git a/1.12.2/src/main/resources/META-INF/serverobserver_at.cfg b/1.12.2/src/main/resources/META-INF/serverobserver_at.cfg deleted file mode 100644 index 1e5ce1e..0000000 --- a/1.12.2/src/main/resources/META-INF/serverobserver_at.cfg +++ /dev/null @@ -1,5 +0,0 @@ -public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector -public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight -public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer -public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/common/src/main/java/net/teamfruit/serverobserver/IProxyL.java b/1.7.10/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxyL.java similarity index 96% rename from common/src/main/java/net/teamfruit/serverobserver/IProxyL.java rename to 1.7.10/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxyL.java index 921e07a..0116e65 100644 --- a/common/src/main/java/net/teamfruit/serverobserver/IProxyL.java +++ b/1.7.10/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxyL.java @@ -1,17 +1,17 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; - -public interface IProxyL { - - void preInit(@Nonnull FMLPreInitializationEvent event); - - void init(@Nonnull FMLInitializationEvent event); - - void postInit(@Nonnull FMLPostInitializationEvent event); - +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public interface IProxyL { + + void preInit(@Nonnull FMLPreInitializationEvent event); + + void init(@Nonnull FMLInitializationEvent event); + + void postInit(@Nonnull FMLPostInitializationEvent event); + } \ No newline at end of file diff --git a/1.7.10/src/main/java/net/teamfruit/serverobserver/ServerObserver.java b/1.7.10/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java similarity index 96% rename from 1.7.10/src/main/java/net/teamfruit/serverobserver/ServerObserver.java rename to 1.7.10/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java index 7b03719..3d0f97d 100644 --- a/1.7.10/src/main/java/net/teamfruit/serverobserver/ServerObserver.java +++ b/1.7.10/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java @@ -1,44 +1,44 @@ -package net.teamfruit.serverobserver; - -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkCheckHandler; -import cpw.mods.fml.relauncher.Side; - -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) -public class ServerObserver { - @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) - private static @Nullable IProxyL proxy; - - @NetworkCheckHandler - public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { - return true; - } - - @EventHandler - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - if (proxy!=null) - proxy.preInit(event); - } - - @EventHandler - public void init(final @Nonnull FMLInitializationEvent event) { - if (proxy!=null) - proxy.init(event); - } - - @EventHandler - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - if (proxy!=null) - proxy.postInit(event); - } -} +package net.teamfruit.serverobserver; + +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkCheckHandler; +import cpw.mods.fml.relauncher.Side; + +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) +public class ServerObserver { + @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) + private static @Nullable IProxyL proxy; + + @NetworkCheckHandler + public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { + return true; + } + + @EventHandler + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + if (proxy!=null) + proxy.preInit(event); + } + + @EventHandler + public void init(final @Nonnull FMLInitializationEvent event) { + if (proxy!=null) + proxy.init(event); + } + + @EventHandler + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + if (proxy!=null) + proxy.postInit(event); + } +} diff --git a/1.7.10/src/main/java/net/teamfruit/serverobserver/ClientProxy.java b/1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java similarity index 96% rename from 1.7.10/src/main/java/net/teamfruit/serverobserver/ClientProxy.java rename to 1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java index f802923..83dd19c 100644 --- a/1.7.10/src/main/java/net/teamfruit/serverobserver/ClientProxy.java +++ b/1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java @@ -1,45 +1,45 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.io.IOException; - -import javax.annotation.Nonnull; - -import org.apache.commons.io.FileUtils; - -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import net.minecraft.client.Minecraft; - -public class ClientProxy extends CommonProxy { - @Override - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - super.preInit(event); - final File cfgDir = event.getModConfigurationDirectory(); - final File modCfgDir = new File(cfgDir, Reference.MODID); - final File oldCfg = event.getSuggestedConfigurationFile(); - final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); - if (oldCfg.exists()) - try { - FileUtils.moveFile(oldCfg, cfg); - } catch (final IOException e) { - } - final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); - Config.init(cfg, dynCfg, "1.0.0", Compat.compat); - CoreHandler.instance.preInit(modCfgDir); - } - - @Override - public void init(final @Nonnull FMLInitializationEvent event) { - super.init(event); - // Event Register - CoreHandler.instance.init(); - } - - @Override - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - super.postInit(event); - Config.getConfig().save(); - } +package net.teamfruit.serverobserver; + +import java.io.File; +import java.io.IOException; + +import javax.annotation.Nonnull; + +import org.apache.commons.io.FileUtils; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import net.minecraft.client.Minecraft; + +public class ClientProxy extends CommonProxy { + @Override + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + super.preInit(event); + final File cfgDir = event.getModConfigurationDirectory(); + final File modCfgDir = new File(cfgDir, Reference.MODID); + final File oldCfg = event.getSuggestedConfigurationFile(); + final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); + if (oldCfg.exists()) + try { + FileUtils.moveFile(oldCfg, cfg); + } catch (final IOException e) { + } + final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); + Config.init(cfg, dynCfg, "1.0.0", Compat.compat); + CoreHandler.instance.preInit(modCfgDir); + } + + @Override + public void init(final @Nonnull FMLInitializationEvent event) { + super.init(event); + // Event Register + CoreHandler.instance.init(); + } + + @Override + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + super.postInit(event); + Config.getConfig().save(); + } } \ No newline at end of file diff --git a/1.7.10/src/main/java/net/teamfruit/serverobserver/CommonProxy.java b/1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java similarity index 96% rename from 1.7.10/src/main/java/net/teamfruit/serverobserver/CommonProxy.java rename to 1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java index 1784f0b..1a894bb 100644 --- a/1.7.10/src/main/java/net/teamfruit/serverobserver/CommonProxy.java +++ b/1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java @@ -1,19 +1,19 @@ -package net.teamfruit.serverobserver; - -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; - -public class CommonProxy implements IProxyL { - @Override - public void preInit(final FMLPreInitializationEvent event) { - } - - @Override - public void init(final FMLInitializationEvent event) { - } - - @Override - public void postInit(final FMLPostInitializationEvent event) { - } -} +package net.teamfruit.serverobserver; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public class CommonProxy implements IProxyL { + @Override + public void preInit(final FMLPreInitializationEvent event) { + } + + @Override + public void init(final FMLInitializationEvent event) { + } + + @Override + public void postInit(final FMLPostInitializationEvent event) { + } +} diff --git a/1.7.10/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java similarity index 96% rename from 1.7.10/src/main/java/net/teamfruit/serverobserver/Compat.java rename to 1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java index 6433a67..a901b71 100644 --- a/1.7.10/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,159 +1,160 @@ -package net.teamfruit.serverobserver; - -import java.net.SocketAddress; -import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; - -import javax.annotation.Nonnull; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.client.FMLClientHandler; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ServerListEntryNormal; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.ServerList; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.teamfruit.serverobserver.GuiHandler.SkeletonButtonDrawInside; - -public class Compat implements ICompat { - public static final @Nonnull ICompat compat = new Compat(); - - @Override - public void color(final float colorRed, final float colorGreen, final float colorBlue, final float colorAlpha) { - GL11.glColor4f(colorRed, colorGreen, colorBlue, colorAlpha); - } - - @Override - @SuppressWarnings("unchecked") - public List getButtonList(final InitGuiEvent e) { - return e.buttonList; - } - - @Override - public FontRenderer font(final Minecraft mc) { - return mc.fontRenderer; - } - - @Override - public int getHeight(final GuiDisconnected dcgui) { - return dcgui.height/4+120+12+25; - } - - @Override - public GuiScreen getParentScreen(final GuiDisconnected dcgui) { - return dcgui.field_146307_h; - } - - @Override - public GuiButton getButton(final ActionPerformedEvent e) { - return e.button; - } - - @Override - public int getSelected(final GuiMultiplayer mpgui) { - return mpgui.field_146803_h.func_148193_k(); - } - - @Override - public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { - FMLClientHandler.instance().connectToServer(mpgui, serverData); - } - - @Override - public boolean getPinged(final ServerData serverData) { - return serverData.field_78841_f; - } - - @Override - public void setPinged(final ServerData serverData, final boolean pinged) { - serverData.field_78841_f = pinged; - } - - @Override - public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { - mpgui.func_146789_i().func_147224_a(serverData); - } - - private final String defaultSound = "minecraft:random.orb"; - - @Override - public String getDefaultSound() { - return this.defaultSound; - } - - @Override - public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { - mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(sound, pitch)); - } - - @Override - public void selectServer(final GuiMultiplayer mpgui, final int index) { - mpgui.func_146790_a(index); - } - - @Override - public ServerList getServerList(final GuiMultiplayer mpgui) { - return mpgui.func_146795_p(); - } - - @Override - public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { - return mpgui.func_146795_p().getServerData(index); - } - - @Override - public ThreadPoolExecutor getThreadPool() { - return ServerListEntryNormal.field_148302_b; - } - - @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); - } - - @Override - public NetworkManager getClientToServerNetworkManager() { - return FMLClientHandler.instance().getClientToServerNetworkManager(); - } - - @Override - public SocketAddress getSocketAddress(final NetworkManager netManager) { - return netManager.getSocketAddress(); - } - - public static class SkeletonButton extends GuiButton { - private final SkeletonButtonDrawInside inside; - private final ICompat compat; - - public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - super(buttonId, x, y, widthIn, heightIn, buttonText); - this.inside = inside; - this.compat = compat; - } - - protected boolean isHovered; - - @Override - public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { - if (this.visible) { - this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); - final int x = this.xPosition; - final int y = this.yPosition; - this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getButtonList(final InitGuiEvent e) { + return e.buttonList; + } + + @Override + public FontRenderer font(final Minecraft mc) { + return mc.fontRenderer; + } + + @Override + public int getHeight(final GuiDisconnected dcgui) { + return dcgui.height/4+120+12+25; + } + + @Override + public GuiScreen getParentScreen(final GuiDisconnected dcgui) { + return dcgui.field_146307_h; + } + + @Override + public GuiButton getButton(final ActionPerformedEvent e) { + return e.button; + } + + @Override + public int getSelected(final GuiMultiplayer mpgui) { + return mpgui.field_146803_h.func_148193_k(); + } + + @Override + public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { + FMLClientHandler.instance().connectToServer(mpgui, serverData); + } + + @Override + public boolean getPinged(final ServerData serverData) { + return serverData.field_78841_f; + } + + @Override + public void setPinged(final ServerData serverData, final boolean pinged) { + serverData.field_78841_f = pinged; + } + + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.func_146789_i().func_147224_a(serverData); + } + + private final String defaultSound = "minecraft:random.orb"; + + @Override + public String getDefaultSound() { + return this.defaultSound; + } + + @Override + public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { + mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(sound, pitch)); + } + + @Override + public void selectServer(final GuiMultiplayer mpgui, final int index) { + mpgui.func_146790_a(index); + } + + @Override + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.func_146795_p(); + } + + @Override + public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { + return mpgui.func_146795_p().getServerData(index); + } + + @Override + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.field_148302_b; + } + + @Override + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + } + + @Override + public NetworkManager getClientToServerNetworkManager() { + return FMLClientHandler.instance().getClientToServerNetworkManager(); + } + + @Override + public SocketAddress getSocketAddress(final NetworkManager netManager) { + return netManager.getSocketAddress(); + } + + public static class SkeletonButton extends GuiButton { + private final SkeletonButtonDrawInside inside; + private final ICompat compat; + + public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + super(buttonId, x, y, widthIn, heightIn, buttonText); + this.inside = inside; + this.compat = compat; + } + + protected boolean isHovered; + + @Override + public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { + if (this.visible) { + this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); + final int x = this.xPosition; + final int y = this.yPosition; + this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getConfigElements() { - final List list = new ArrayList(); - getConfigElements(list, Config.getConfig().getBase()); - getConfigElements(list, Config.getConfig().getBaseDynamic()); - return list; - } - - @SuppressWarnings("rawtypes") - private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { - ConfigCategory general = null; - - for (final String cat : cb.getCategoryNames()) { - final ConfigCategory cc = cb.getCategory(cat); - - if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { - general = cc; - continue; - } - - if (cc.isChild()) - continue; - - list.add(new ConfigElement(cc)); - } - - // General項目をトップに表示します - if (general!=null) { - for (final ConfigCategory cc : general.getChildren()) - list.add(new ConfigElement(cc)); - for (final Property prop : general.values()) - list.add(new ConfigElement(prop)); - } - - return list; - } - - } - - @Override - public void initialize(final @Nullable Minecraft minecraftInstance) { - - } - - @Override - public @Nullable Class mainConfigGuiClass() { - return ConfigGui.class; - } - - @Override - public @Nullable Set runtimeGuiCategories() { - return null; - } - - @Override - public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { - return null; - } +package net.teamfruit.serverobserver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.commons.lang3.StringUtils; + +import cpw.mods.fml.client.IModGuiFactory; +import cpw.mods.fml.client.config.GuiConfig; +import cpw.mods.fml.client.config.IConfigElement; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +/** + * コンフィグGUI + * + * @author Kamesuta + */ +public class ConfigGuiFactory implements IModGuiFactory { + + public static class ConfigGui extends GuiConfig { + + public ConfigGui(final @Nullable GuiScreen parent) { + super(parent, getConfigElements(), Reference.MODID, false, false, I18n.format("serverobserver.config")); + } + + @SuppressWarnings("rawtypes") + private static @Nonnull List getConfigElements() { + final List list = new ArrayList(); + getConfigElements(list, Config.getConfig().getBase()); + getConfigElements(list, Config.getConfig().getBaseDynamic()); + return list; + } + + @SuppressWarnings("rawtypes") + private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { + ConfigCategory general = null; + + for (final String cat : cb.getCategoryNames()) { + final ConfigCategory cc = cb.getCategory(cat); + + if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { + general = cc; + continue; + } + + if (cc.isChild()) + continue; + + list.add(new ConfigElement(cc)); + } + + // General項目をトップに表示します + if (general!=null) { + for (final ConfigCategory cc : general.getChildren()) + list.add(new ConfigElement(cc)); + for (final Property prop : general.values()) + list.add(new ConfigElement(prop)); + } + + return list; + } + + } + + @Override + public void initialize(final @Nullable Minecraft minecraftInstance) { + + } + + @Override + public @Nullable Class mainConfigGuiClass() { + return ConfigGui.class; + } + + @Override + public @Nullable Set runtimeGuiCategories() { + return null; + } + + @Override + public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { + return null; + } } \ No newline at end of file diff --git a/1.7.10/src/main/java/net/teamfruit/serverobserver/CoreHandler.java b/1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java similarity index 96% rename from 1.7.10/src/main/java/net/teamfruit/serverobserver/CoreHandler.java rename to 1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java index b138cf7..ae5a7b5 100644 --- a/1.7.10/src/main/java/net/teamfruit/serverobserver/CoreHandler.java +++ b/1.7.10/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java @@ -1,62 +1,62 @@ -package net.teamfruit.serverobserver; - -import java.io.File; - -import javax.annotation.Nonnull; - -import cpw.mods.fml.client.event.ConfigChangedEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.common.MinecraftForge; - -public class CoreHandler { - public static final @Nonnull CoreHandler instance = new CoreHandler(); - - public final @Nonnull Config configHandler = Config.getConfig(); - public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); - - public void preInit(final File root) { - this.guiHandler.init(root); - } - - public void init() { - // FMLCommonHandler.instance().bus().register(this); - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); - } - - @SubscribeEvent - public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - for (final ConfigBase base : ConfigBase.configChangeHandlers) - base.onConfigChanged(eventArgs.modID); - } - - @SubscribeEvent - public void open(final InitGuiEvent.Post e) { - this.guiHandler.open(e); - } - - @SubscribeEvent - public void draw(final DrawScreenEvent.Post e) { - this.guiHandler.draw(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Pre e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Post e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void tickclient(final @Nonnull ClientTickEvent e) { - this.guiHandler.tickclient(); - } +package net.teamfruit.serverobserver; + +import java.io.File; + +import javax.annotation.Nonnull; + +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; +import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; +import net.minecraftforge.common.MinecraftForge; + +public class CoreHandler { + public static final @Nonnull CoreHandler instance = new CoreHandler(); + + public final @Nonnull Config configHandler = Config.getConfig(); + public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); + + public void preInit(final File root) { + this.guiHandler.init(root); + } + + public void init() { + // FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); + } + + @SubscribeEvent + public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + for (final ConfigBase base : ConfigBase.configChangeHandlers) + base.onConfigChanged(eventArgs.modID); + } + + @SubscribeEvent + public void open(final InitGuiEvent.Post e) { + this.guiHandler.open(e); + } + + @SubscribeEvent + public void draw(final DrawScreenEvent.Post e) { + this.guiHandler.draw(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Pre e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Post e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void tickclient(final @Nonnull ClientTickEvent e) { + this.guiHandler.tickclient(); + } } \ No newline at end of file diff --git a/1.7.10/src/main/resources/META-INF/serverobserver_at.cfg b/1.7.10/src/main/resources/META-INF/serverobserver_at.cfg deleted file mode 100644 index 1e5ce1e..0000000 --- a/1.7.10/src/main/resources/META-INF/serverobserver_at.cfg +++ /dev/null @@ -1,5 +0,0 @@ -public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector -public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight -public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer -public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/1.11.2/src/main/java/net/teamfruit/serverobserver/IProxy.java b/1.8.9/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java similarity index 96% rename from 1.11.2/src/main/java/net/teamfruit/serverobserver/IProxy.java rename to 1.8.9/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java index 936416a..72a66f2 100644 --- a/1.11.2/src/main/java/net/teamfruit/serverobserver/IProxy.java +++ b/1.8.9/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java @@ -1,17 +1,17 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public interface IProxy { - - void preInit(@Nonnull FMLPreInitializationEvent event); - - void init(@Nonnull FMLInitializationEvent event); - - void postInit(@Nonnull FMLPostInitializationEvent event); - +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public interface IProxy { + + void preInit(@Nonnull FMLPreInitializationEvent event); + + void init(@Nonnull FMLInitializationEvent event); + + void postInit(@Nonnull FMLPostInitializationEvent event); + } \ No newline at end of file diff --git a/1.8.9/src/main/java/net/teamfruit/serverobserver/ServerObserver.java b/1.8.9/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java similarity index 96% rename from 1.8.9/src/main/java/net/teamfruit/serverobserver/ServerObserver.java rename to 1.8.9/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java index 6cd19f1..43f16c7 100644 --- a/1.8.9/src/main/java/net/teamfruit/serverobserver/ServerObserver.java +++ b/1.8.9/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java @@ -1,44 +1,44 @@ -package net.teamfruit.serverobserver; - -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkCheckHandler; -import net.minecraftforge.fml.relauncher.Side; - -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) -public class ServerObserver { - @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) - private static @Nullable IProxy proxy; - - @NetworkCheckHandler - public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { - return true; - } - - @EventHandler - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - if (proxy!=null) - proxy.preInit(event); - } - - @EventHandler - public void init(final @Nonnull FMLInitializationEvent event) { - if (proxy!=null) - proxy.init(event); - } - - @EventHandler - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - if (proxy!=null) - proxy.postInit(event); - } -} +package net.teamfruit.serverobserver; + +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkCheckHandler; +import net.minecraftforge.fml.relauncher.Side; + +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) +public class ServerObserver { + @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) + private static @Nullable IProxy proxy; + + @NetworkCheckHandler + public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { + return true; + } + + @EventHandler + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + if (proxy!=null) + proxy.preInit(event); + } + + @EventHandler + public void init(final @Nonnull FMLInitializationEvent event) { + if (proxy!=null) + proxy.init(event); + } + + @EventHandler + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + if (proxy!=null) + proxy.postInit(event); + } +} diff --git a/1.8.9/src/main/java/net/teamfruit/serverobserver/ClientProxy.java b/1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java similarity index 96% rename from 1.8.9/src/main/java/net/teamfruit/serverobserver/ClientProxy.java rename to 1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java index cf0c0a3..3c7bb02 100644 --- a/1.8.9/src/main/java/net/teamfruit/serverobserver/ClientProxy.java +++ b/1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java @@ -1,45 +1,45 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.io.IOException; - -import javax.annotation.Nonnull; - -import org.apache.commons.io.FileUtils; - -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class ClientProxy extends CommonProxy { - @Override - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - super.preInit(event); - final File cfgDir = event.getModConfigurationDirectory(); - final File modCfgDir = new File(cfgDir, Reference.MODID); - final File oldCfg = event.getSuggestedConfigurationFile(); - final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); - if (oldCfg.exists()) - try { - FileUtils.moveFile(oldCfg, cfg); - } catch (final IOException e) { - } - final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); - Config.init(cfg, dynCfg, "1.1.0", Compat.compat); - CoreHandler.instance.preInit(modCfgDir); - } - - @Override - public void init(final @Nonnull FMLInitializationEvent event) { - super.init(event); - // Event Register - CoreHandler.instance.init(); - } - - @Override - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - super.postInit(event); - Config.getConfig().save(); - } +package net.teamfruit.serverobserver; + +import java.io.File; +import java.io.IOException; + +import javax.annotation.Nonnull; + +import org.apache.commons.io.FileUtils; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class ClientProxy extends CommonProxy { + @Override + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + super.preInit(event); + final File cfgDir = event.getModConfigurationDirectory(); + final File modCfgDir = new File(cfgDir, Reference.MODID); + final File oldCfg = event.getSuggestedConfigurationFile(); + final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); + if (oldCfg.exists()) + try { + FileUtils.moveFile(oldCfg, cfg); + } catch (final IOException e) { + } + final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); + Config.init(cfg, dynCfg, "1.1.0", Compat.compat); + CoreHandler.instance.preInit(modCfgDir); + } + + @Override + public void init(final @Nonnull FMLInitializationEvent event) { + super.init(event); + // Event Register + CoreHandler.instance.init(); + } + + @Override + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + super.postInit(event); + Config.getConfig().save(); + } } \ No newline at end of file diff --git a/1.8.9/src/main/java/net/teamfruit/serverobserver/CommonProxy.java b/1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java similarity index 96% rename from 1.8.9/src/main/java/net/teamfruit/serverobserver/CommonProxy.java rename to 1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java index c909736..42d04c0 100644 --- a/1.8.9/src/main/java/net/teamfruit/serverobserver/CommonProxy.java +++ b/1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java @@ -1,19 +1,19 @@ -package net.teamfruit.serverobserver; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class CommonProxy implements IProxy { - @Override - public void preInit(final FMLPreInitializationEvent event) { - } - - @Override - public void init(final FMLInitializationEvent event) { - } - - @Override - public void postInit(final FMLPostInitializationEvent event) { - } -} +package net.teamfruit.serverobserver; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class CommonProxy implements IProxy { + @Override + public void preInit(final FMLPreInitializationEvent event) { + } + + @Override + public void init(final FMLInitializationEvent event) { + } + + @Override + public void postInit(final FMLPostInitializationEvent event) { + } +} diff --git a/1.8.9/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java similarity index 96% rename from 1.8.9/src/main/java/net/teamfruit/serverobserver/Compat.java rename to 1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java index 13a8a15..b58c4ce 100644 --- a/1.8.9/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,158 +1,158 @@ -package net.teamfruit.serverobserver; - -import java.net.SocketAddress; -import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; - -import javax.annotation.Nonnull; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ServerListEntryNormal; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.ServerList; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.teamfruit.serverobserver.GuiHandler.SkeletonButtonDrawInside; - -public class Compat implements ICompat { - public static final @Nonnull ICompat compat = new Compat(); - - @Override - public void color(final float colorRed, final float colorGreen, final float colorBlue, final float colorAlpha) { - GL11.glColor4f(colorRed, colorGreen, colorBlue, colorAlpha); - } - - @Override - public List getButtonList(final InitGuiEvent e) { - return e.buttonList; - } - - @Override - public FontRenderer font(final Minecraft mc) { - return mc.fontRendererObj; - } - - @Override - public int getHeight(final GuiDisconnected dcgui) { - return dcgui.height/2+dcgui.field_175353_i/2+font(dcgui.mc).FONT_HEIGHT+25; - } - - @Override - public GuiScreen getParentScreen(final GuiDisconnected dcgui) { - return dcgui.parentScreen; - } - - @Override - public GuiButton getButton(final ActionPerformedEvent e) { - return e.button; - } - - @Override - public int getSelected(final GuiMultiplayer mpgui) { - return mpgui.serverListSelector.func_148193_k(); - } - - @Override - public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { - FMLClientHandler.instance().connectToServer(mpgui, serverData); - } - - @Override - public boolean getPinged(final ServerData serverData) { - return serverData.field_78841_f; - } - - @Override - public void setPinged(final ServerData serverData, final boolean pinged) { - serverData.field_78841_f = pinged; - } - - @Override - public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { - mpgui.getOldServerPinger().ping(serverData); - } - - private final String defaultSound = "minecraft:random.orb"; - - @Override - public String getDefaultSound() { - return this.defaultSound; - } - - @Override - public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { - mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, 0.25F, pitch, 0.0F, 0.0F, 0.0F)); - } - - @Override - public void selectServer(final GuiMultiplayer mpgui, final int index) { - mpgui.selectServer(index); - } - - @Override - public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { - return mpgui.getServerList().getServerData(index); - } - - @Override - public ServerList getServerList(final GuiMultiplayer mpgui) { - return mpgui.getServerList(); - } - - @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); - } - - @Override - public ThreadPoolExecutor getThreadPool() { - return ServerListEntryNormal.field_148302_b; - } - - @Override - public NetworkManager getClientToServerNetworkManager() { - return FMLClientHandler.instance().getClientToServerNetworkManager(); - } - - @Override - public SocketAddress getSocketAddress(final NetworkManager netManager) { - return netManager.getRemoteAddress(); - } - - public static class SkeletonButton extends GuiButton { - private final SkeletonButtonDrawInside inside; - private final ICompat compat; - - public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - super(buttonId, x, y, widthIn, heightIn, buttonText); - this.inside = inside; - this.compat = compat; - } - - protected boolean isHovered; - - @Override - public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { - if (this.visible) { - this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); - final int x = this.xPosition; - final int y = this.yPosition; - this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getButtonList(final InitGuiEvent e) { + return e.buttonList; + } + + @Override + public FontRenderer font(final Minecraft mc) { + return mc.fontRendererObj; + } + + @Override + public int getHeight(final GuiDisconnected dcgui) { + return dcgui.height/2+dcgui.field_175353_i/2+font(dcgui.mc).FONT_HEIGHT+25; + } + + @Override + public GuiScreen getParentScreen(final GuiDisconnected dcgui) { + return dcgui.parentScreen; + } + + @Override + public GuiButton getButton(final ActionPerformedEvent e) { + return e.button; + } + + @Override + public int getSelected(final GuiMultiplayer mpgui) { + return mpgui.serverListSelector.func_148193_k(); + } + + @Override + public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { + FMLClientHandler.instance().connectToServer(mpgui, serverData); + } + + @Override + public boolean getPinged(final ServerData serverData) { + return serverData.field_78841_f; + } + + @Override + public void setPinged(final ServerData serverData, final boolean pinged) { + serverData.field_78841_f = pinged; + } + + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + + private final String defaultSound = "minecraft:random.orb"; + + @Override + public String getDefaultSound() { + return this.defaultSound; + } + + @Override + public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { + mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, 0.25F, pitch, 0.0F, 0.0F, 0.0F)); + } + + @Override + public void selectServer(final GuiMultiplayer mpgui, final int index) { + mpgui.selectServer(index); + } + + @Override + public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { + return mpgui.getServerList().getServerData(index); + } + + @Override + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); + } + + @Override + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + } + + @Override + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.field_148302_b; + } + + @Override + public NetworkManager getClientToServerNetworkManager() { + return FMLClientHandler.instance().getClientToServerNetworkManager(); + } + + @Override + public SocketAddress getSocketAddress(final NetworkManager netManager) { + return netManager.getRemoteAddress(); + } + + public static class SkeletonButton extends GuiButton { + private final SkeletonButtonDrawInside inside; + private final ICompat compat; + + public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + super(buttonId, x, y, widthIn, heightIn, buttonText); + this.inside = inside; + this.compat = compat; + } + + protected boolean isHovered; + + @Override + public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { + if (this.visible) { + this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); + final int x = this.xPosition; + final int y = this.yPosition; + this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getConfigElements() { - final List list = new ArrayList(); - getConfigElements(list, Config.getConfig().getBase()); - getConfigElements(list, Config.getConfig().getBaseDynamic()); - return list; - } - - private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { - ConfigCategory general = null; - - for (final String cat : cb.getCategoryNames()) { - final ConfigCategory cc = cb.getCategory(cat); - - if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { - general = cc; - continue; - } - - if (cc.isChild()) - continue; - - list.add(new ConfigElement(cc)); - } - - // General項目をトップに表示します - if (general!=null) { - for (final ConfigCategory cc : general.getChildren()) - list.add(new ConfigElement(cc)); - for (final Property prop : general.values()) - list.add(new ConfigElement(prop)); - } - - return list; - } - } - - @Override - public void initialize(final @Nullable Minecraft minecraftInstance) { - - } - - @Override - public @Nullable Class mainConfigGuiClass() { - return ConfigGui.class; - } - - @Override - public @Nullable Set runtimeGuiCategories() { - return null; - } - - @Override - public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { - return null; - } +package net.teamfruit.serverobserver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import net.minecraftforge.fml.client.IModGuiFactory; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; + +/** + * コンフィグGUI + * + * @author Kamesuta + */ +public class ConfigGuiFactory implements IModGuiFactory { + + public static class ConfigGui extends GuiConfig { + + public ConfigGui(final @Nullable GuiScreen parent) { + super(parent, getConfigElements(), Reference.MODID, false, false, I18n.format("serverobserver.config")); + } + + private static @Nonnull List getConfigElements() { + final List list = new ArrayList(); + getConfigElements(list, Config.getConfig().getBase()); + getConfigElements(list, Config.getConfig().getBaseDynamic()); + return list; + } + + private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { + ConfigCategory general = null; + + for (final String cat : cb.getCategoryNames()) { + final ConfigCategory cc = cb.getCategory(cat); + + if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { + general = cc; + continue; + } + + if (cc.isChild()) + continue; + + list.add(new ConfigElement(cc)); + } + + // General項目をトップに表示します + if (general!=null) { + for (final ConfigCategory cc : general.getChildren()) + list.add(new ConfigElement(cc)); + for (final Property prop : general.values()) + list.add(new ConfigElement(prop)); + } + + return list; + } + } + + @Override + public void initialize(final @Nullable Minecraft minecraftInstance) { + + } + + @Override + public @Nullable Class mainConfigGuiClass() { + return ConfigGui.class; + } + + @Override + public @Nullable Set runtimeGuiCategories() { + return null; + } + + @Override + public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { + return null; + } } \ No newline at end of file diff --git a/1.8.9/src/main/java/net/teamfruit/serverobserver/CoreHandler.java b/1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java similarity index 96% rename from 1.8.9/src/main/java/net/teamfruit/serverobserver/CoreHandler.java rename to 1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java index 690af1e..21449c9 100644 --- a/1.8.9/src/main/java/net/teamfruit/serverobserver/CoreHandler.java +++ b/1.8.9/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java @@ -1,60 +1,60 @@ -package net.teamfruit.serverobserver; - -import java.io.File; - -import javax.annotation.Nonnull; - -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.event.ConfigChangedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; - -public class CoreHandler { - public static final @Nonnull CoreHandler instance = new CoreHandler(); - - public final @Nonnull Config configHandler = Config.getConfig(); - public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); - - public void preInit(final File root) { - this.guiHandler.init(root); - } - - public void init() { - // FMLCommonHandler.instance().bus().register(this); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - for (final ConfigBase base : ConfigBase.configChangeHandlers) - base.onConfigChanged(eventArgs.modID); - } - - @SubscribeEvent - public void open(final InitGuiEvent.Post e) { - this.guiHandler.open(e); - } - - @SubscribeEvent - public void draw(final DrawScreenEvent.Post e) { - this.guiHandler.draw(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Pre e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Post e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void tickclient(final @Nonnull ClientTickEvent e) { - this.guiHandler.tickclient(); - } +package net.teamfruit.serverobserver; + +import java.io.File; + +import javax.annotation.Nonnull; + +import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; +import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.event.ConfigChangedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; + +public class CoreHandler { + public static final @Nonnull CoreHandler instance = new CoreHandler(); + + public final @Nonnull Config configHandler = Config.getConfig(); + public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); + + public void preInit(final File root) { + this.guiHandler.init(root); + } + + public void init() { + // FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + for (final ConfigBase base : ConfigBase.configChangeHandlers) + base.onConfigChanged(eventArgs.modID); + } + + @SubscribeEvent + public void open(final InitGuiEvent.Post e) { + this.guiHandler.open(e); + } + + @SubscribeEvent + public void draw(final DrawScreenEvent.Post e) { + this.guiHandler.draw(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Pre e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Post e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void tickclient(final @Nonnull ClientTickEvent e) { + this.guiHandler.tickclient(); + } } \ No newline at end of file diff --git a/1.8.9/src/main/resources/META-INF/serverobserver_at.cfg b/1.8.9/src/main/resources/META-INF/serverobserver_at.cfg deleted file mode 100644 index 1e5ce1e..0000000 --- a/1.8.9/src/main/resources/META-INF/serverobserver_at.cfg +++ /dev/null @@ -1,5 +0,0 @@ -public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector -public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight -public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer -public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/1.9.4/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java b/1.9.4/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java new file mode 100644 index 0000000..72a66f2 --- /dev/null +++ b/1.9.4/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/IProxy.java @@ -0,0 +1,17 @@ +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public interface IProxy { + + void preInit(@Nonnull FMLPreInitializationEvent event); + + void init(@Nonnull FMLInitializationEvent event); + + void postInit(@Nonnull FMLPostInitializationEvent event); + +} \ No newline at end of file diff --git a/1.9.4/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java b/1.9.4/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java new file mode 100644 index 0000000..43f16c7 --- /dev/null +++ b/1.9.4/sources/bootstrap/src/main/java/net/teamfruit/serverobserver/ServerObserver.java @@ -0,0 +1,44 @@ +package net.teamfruit.serverobserver; + +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkCheckHandler; +import net.minecraftforge.fml.relauncher.Side; + +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) +public class ServerObserver { + @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) + private static @Nullable IProxy proxy; + + @NetworkCheckHandler + public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { + return true; + } + + @EventHandler + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + if (proxy!=null) + proxy.preInit(event); + } + + @EventHandler + public void init(final @Nonnull FMLInitializationEvent event) { + if (proxy!=null) + proxy.init(event); + } + + @EventHandler + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + if (proxy!=null) + proxy.postInit(event); + } +} diff --git a/1.9.4/src/main/java/net/teamfruit/serverobserver/ClientProxy.java b/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java similarity index 96% rename from 1.9.4/src/main/java/net/teamfruit/serverobserver/ClientProxy.java rename to 1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java index cf0c0a3..3c7bb02 100644 --- a/1.9.4/src/main/java/net/teamfruit/serverobserver/ClientProxy.java +++ b/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/ClientProxy.java @@ -1,45 +1,45 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.io.IOException; - -import javax.annotation.Nonnull; - -import org.apache.commons.io.FileUtils; - -import net.minecraft.client.Minecraft; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class ClientProxy extends CommonProxy { - @Override - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - super.preInit(event); - final File cfgDir = event.getModConfigurationDirectory(); - final File modCfgDir = new File(cfgDir, Reference.MODID); - final File oldCfg = event.getSuggestedConfigurationFile(); - final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); - if (oldCfg.exists()) - try { - FileUtils.moveFile(oldCfg, cfg); - } catch (final IOException e) { - } - final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); - Config.init(cfg, dynCfg, "1.1.0", Compat.compat); - CoreHandler.instance.preInit(modCfgDir); - } - - @Override - public void init(final @Nonnull FMLInitializationEvent event) { - super.init(event); - // Event Register - CoreHandler.instance.init(); - } - - @Override - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - super.postInit(event); - Config.getConfig().save(); - } +package net.teamfruit.serverobserver; + +import java.io.File; +import java.io.IOException; + +import javax.annotation.Nonnull; + +import org.apache.commons.io.FileUtils; + +import net.minecraft.client.Minecraft; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class ClientProxy extends CommonProxy { + @Override + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + super.preInit(event); + final File cfgDir = event.getModConfigurationDirectory(); + final File modCfgDir = new File(cfgDir, Reference.MODID); + final File oldCfg = event.getSuggestedConfigurationFile(); + final File cfg = new File(modCfgDir, Reference.MODID+".cfg"); + if (oldCfg.exists()) + try { + FileUtils.moveFile(oldCfg, cfg); + } catch (final IOException e) { + } + final File dynCfg = new File(Minecraft.getMinecraft().mcDataDir, Reference.MODID+".cfg"); + Config.init(cfg, dynCfg, "1.1.0", Compat.compat); + CoreHandler.instance.preInit(modCfgDir); + } + + @Override + public void init(final @Nonnull FMLInitializationEvent event) { + super.init(event); + // Event Register + CoreHandler.instance.init(); + } + + @Override + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + super.postInit(event); + Config.getConfig().save(); + } } \ No newline at end of file diff --git a/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java b/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java new file mode 100644 index 0000000..42d04c0 --- /dev/null +++ b/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/CommonProxy.java @@ -0,0 +1,19 @@ +package net.teamfruit.serverobserver; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public class CommonProxy implements IProxy { + @Override + public void preInit(final FMLPreInitializationEvent event) { + } + + @Override + public void init(final FMLInitializationEvent event) { + } + + @Override + public void postInit(final FMLPostInitializationEvent event) { + } +} diff --git a/1.10.2/src/main/java/net/teamfruit/serverobserver/Compat.java b/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java similarity index 96% rename from 1.10.2/src/main/java/net/teamfruit/serverobserver/Compat.java rename to 1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java index 019547f..452ebd2 100644 --- a/1.10.2/src/main/java/net/teamfruit/serverobserver/Compat.java +++ b/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/Compat.java @@ -1,159 +1,159 @@ -package net.teamfruit.serverobserver; - -import java.net.SocketAddress; -import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; - -import javax.annotation.Nonnull; - -import org.lwjgl.opengl.GL11; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.ISound; -import net.minecraft.client.audio.PositionedSoundRecord; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ServerListEntryNormal; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.ServerList; -import net.minecraft.init.SoundEvents; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.fml.client.FMLClientHandler; -import net.teamfruit.serverobserver.GuiHandler.SkeletonButtonDrawInside; - -public class Compat implements ICompat { - public static final @Nonnull ICompat compat = new Compat(); - - @Override - public void color(final float colorRed, final float colorGreen, final float colorBlue, final float colorAlpha) { - GL11.glColor4f(colorRed, colorGreen, colorBlue, colorAlpha); - } - - @Override - public List getButtonList(final InitGuiEvent e) { - return e.getButtonList(); - } - - @Override - public FontRenderer font(final Minecraft mc) { - return mc.fontRendererObj; - } - - @Override - public int getHeight(final GuiDisconnected dcgui) { - return dcgui.height/2+dcgui.textHeight/2+font(dcgui.mc).FONT_HEIGHT+25; - } - - @Override - public GuiScreen getParentScreen(final GuiDisconnected dcgui) { - return dcgui.parentScreen; - } - - @Override - public GuiButton getButton(final ActionPerformedEvent e) { - return e.getButton(); - } - - @Override - public int getSelected(final GuiMultiplayer mpgui) { - return mpgui.serverListSelector.getSelected(); - } - - @Override - public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { - FMLClientHandler.instance().connectToServer(mpgui, serverData); - } - - @Override - public boolean getPinged(final ServerData serverData) { - return serverData.pinged; - } - - @Override - public void setPinged(final ServerData serverData, final boolean pinged) { - serverData.pinged = pinged; - } - - @Override - public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { - mpgui.getOldServerPinger().ping(serverData); - } - - @Override - public String getDefaultSound() { - return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); - } - - @Override - public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { - mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, SoundCategory.MASTER, 0.25F, pitch, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F)); - } - - @Override - public void selectServer(final GuiMultiplayer mpgui, final int index) { - mpgui.selectServer(index); - } - - @Override - public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { - return mpgui.getServerList().getServerData(index); - } - - @Override - public ServerList getServerList(final GuiMultiplayer mpgui) { - return mpgui.getServerList(); - } - - @Override - public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); - } - - @Override - public NetworkManager getClientToServerNetworkManager() { - return FMLClientHandler.instance().getClientToServerNetworkManager(); - } - - @Override - public ThreadPoolExecutor getThreadPool() { - return ServerListEntryNormal.EXECUTOR; - } - - @Override - public SocketAddress getSocketAddress(final NetworkManager netManager) { - return netManager.getRemoteAddress(); - } - - public static class SkeletonButton extends GuiButton { - private final SkeletonButtonDrawInside inside; - private final ICompat compat; - - public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { - super(buttonId, x, y, widthIn, heightIn, buttonText); - this.inside = inside; - this.compat = compat; - } - - protected boolean isHovered; - - @Override - public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { - if (this.visible) { - this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); - final int x = this.xPosition; - final int y = this.yPosition; - this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getButtonList(final InitGuiEvent e) { + return e.getButtonList(); + } + + @Override + public FontRenderer font(final Minecraft mc) { + return mc.fontRendererObj; + } + + @Override + public int getHeight(final GuiDisconnected dcgui) { + return dcgui.height/2+dcgui.textHeight/2+font(dcgui.mc).FONT_HEIGHT+25; + } + + @Override + public GuiScreen getParentScreen(final GuiDisconnected dcgui) { + return dcgui.parentScreen; + } + + @Override + public GuiButton getButton(final ActionPerformedEvent e) { + return e.getButton(); + } + + @Override + public int getSelected(final GuiMultiplayer mpgui) { + return mpgui.serverListSelector.getSelected(); + } + + @Override + public void connectToServer(final GuiScreen mpgui, final ServerData serverData) { + FMLClientHandler.instance().connectToServer(mpgui, serverData); + } + + @Override + public boolean getPinged(final ServerData serverData) { + return serverData.pinged; + } + + @Override + public void setPinged(final ServerData serverData, final boolean pinged) { + serverData.pinged = pinged; + } + + @Override + public void ping(final GuiMultiplayer mpgui, final ServerData serverData) throws Exception { + mpgui.getOldServerPinger().ping(serverData); + } + + @Override + public String getDefaultSound() { + return SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP.getSoundName().toString(); + } + + @Override + public void playSound(final Minecraft mc, final ResourceLocation sound, final float pitch) { + mc.getSoundHandler().playSound(new PositionedSoundRecord(sound, SoundCategory.MASTER, 0.25F, pitch, false, 0, ISound.AttenuationType.NONE, 0.0F, 0.0F, 0.0F)); + } + + @Override + public void selectServer(final GuiMultiplayer mpgui, final int index) { + mpgui.selectServer(index); + } + + @Override + public ServerData getServerData(final GuiMultiplayer mpgui, final int index) { + return mpgui.getServerList().getServerData(index); + } + + @Override + public ServerList getServerList(final GuiMultiplayer mpgui) { + return mpgui.getServerList(); + } + + @Override + public GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + return new SkeletonButton(this, buttonId, x, y, widthIn, heightIn, buttonText, inside); + } + + @Override + public ThreadPoolExecutor getThreadPool() { + return ServerListEntryNormal.EXECUTOR; + } + + @Override + public NetworkManager getClientToServerNetworkManager() { + return FMLClientHandler.instance().getClientToServerNetworkManager(); + } + + @Override + public SocketAddress getSocketAddress(final NetworkManager netManager) { + return netManager.getRemoteAddress(); + } + + public static class SkeletonButton extends GuiButton { + private final SkeletonButtonDrawInside inside; + private final ICompat compat; + + public SkeletonButton(final ICompat compat, final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside) { + super(buttonId, x, y, widthIn, heightIn, buttonText); + this.inside = inside; + this.compat = compat; + } + + protected boolean isHovered; + + @Override + public void drawButton(final Minecraft mc, final int mouseX, final int mouseY) { + if (this.visible) { + this.compat.color(1.0F, 1.0F, 1.0F, 1.0F); + final int x = this.xPosition; + final int y = this.yPosition; + this.isHovered = mouseX>=x&&mouseY>=y&&mouseX getConfigElements() { - final List list = new ArrayList(); - getConfigElements(list, Config.getConfig().getBase()); - getConfigElements(list, Config.getConfig().getBaseDynamic()); - return list; - } - - private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { - ConfigCategory general = null; - - for (final String cat : cb.getCategoryNames()) { - final ConfigCategory cc = cb.getCategory(cat); - - if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { - general = cc; - continue; - } - - if (cc.isChild()) - continue; - - list.add(new ConfigElement(cc)); - } - - // General項目をトップに表示します - if (general!=null) { - for (final ConfigCategory cc : general.getChildren()) - list.add(new ConfigElement(cc)); - for (final Property prop : general.values()) - list.add(new ConfigElement(prop)); - } - - return list; - } - } - - @Override - public void initialize(final @Nullable Minecraft minecraftInstance) { - - } - - @Override - public @Nullable Class mainConfigGuiClass() { - return ConfigGui.class; - } - - @Override - public @Nullable Set runtimeGuiCategories() { - return null; - } - - @Override - public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { - return null; - } +package net.teamfruit.serverobserver; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.commons.lang3.StringUtils; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraftforge.common.config.ConfigCategory; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; +import net.minecraftforge.fml.client.IModGuiFactory; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraftforge.fml.client.config.IConfigElement; + +/** + * コンフィグGUI + * + * @author Kamesuta + */ +public class ConfigGuiFactory implements IModGuiFactory { + + public static class ConfigGui extends GuiConfig { + + public ConfigGui(final @Nullable GuiScreen parent) { + super(parent, getConfigElements(), Reference.MODID, false, false, I18n.format("serverobserver.config")); + } + + private static @Nonnull List getConfigElements() { + final List list = new ArrayList(); + getConfigElements(list, Config.getConfig().getBase()); + getConfigElements(list, Config.getConfig().getBaseDynamic()); + return list; + } + + private static @Nonnull List getConfigElements(final List list, final ConfigBase cb) { + ConfigCategory general = null; + + for (final String cat : cb.getCategoryNames()) { + final ConfigCategory cc = cb.getCategory(cat); + + if (StringUtils.equals(cc.getName(), Configuration.CATEGORY_GENERAL)) { + general = cc; + continue; + } + + if (cc.isChild()) + continue; + + list.add(new ConfigElement(cc)); + } + + // General項目をトップに表示します + if (general!=null) { + for (final ConfigCategory cc : general.getChildren()) + list.add(new ConfigElement(cc)); + for (final Property prop : general.values()) + list.add(new ConfigElement(prop)); + } + + return list; + } + } + + @Override + public void initialize(final @Nullable Minecraft minecraftInstance) { + + } + + @Override + public @Nullable Class mainConfigGuiClass() { + return ConfigGui.class; + } + + @Override + public @Nullable Set runtimeGuiCategories() { + return null; + } + + @Override + public @Nullable RuntimeOptionGuiHandler getHandlerFor(final @Nullable RuntimeOptionCategoryElement element) { + return null; + } } \ No newline at end of file diff --git a/1.9.4/src/main/java/net/teamfruit/serverobserver/CoreHandler.java b/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java similarity index 96% rename from 1.9.4/src/main/java/net/teamfruit/serverobserver/CoreHandler.java rename to 1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java index 63b4ced..0d9b3f6 100644 --- a/1.9.4/src/main/java/net/teamfruit/serverobserver/CoreHandler.java +++ b/1.9.4/sources/compat/src/main/java/net/teamfruit/serverobserver/CoreHandler.java @@ -1,60 +1,60 @@ -package net.teamfruit.serverobserver; - -import java.io.File; - -import javax.annotation.Nonnull; - -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.client.event.ConfigChangedEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; - -public class CoreHandler { - public static final @Nonnull CoreHandler instance = new CoreHandler(); - - public final @Nonnull Config configHandler = Config.getConfig(); - public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); - - public void preInit(final File root) { - this.guiHandler.init(root); - } - - public void init() { - // FMLCommonHandler.instance().bus().register(this); - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { - for (final ConfigBase base : ConfigBase.configChangeHandlers) - base.onConfigChanged(eventArgs.getModID()); - } - - @SubscribeEvent - public void open(final InitGuiEvent.Post e) { - this.guiHandler.open(e); - } - - @SubscribeEvent - public void draw(final DrawScreenEvent.Post e) { - this.guiHandler.draw(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Pre e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void action(final ActionPerformedEvent.Post e) { - this.guiHandler.action(e); - } - - @SubscribeEvent - public void tickclient(final @Nonnull ClientTickEvent e) { - this.guiHandler.tickclient(); - } +package net.teamfruit.serverobserver; + +import java.io.File; + +import javax.annotation.Nonnull; + +import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; +import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.event.ConfigChangedEvent; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent; + +public class CoreHandler { + public static final @Nonnull CoreHandler instance = new CoreHandler(); + + public final @Nonnull Config configHandler = Config.getConfig(); + public final @Nonnull GuiHandler guiHandler = new GuiHandler(Compat.compat); + + public void preInit(final File root) { + this.guiHandler.init(root); + } + + public void init() { + // FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void onConfigChanged(final @Nonnull ConfigChangedEvent.OnConfigChangedEvent eventArgs) { + for (final ConfigBase base : ConfigBase.configChangeHandlers) + base.onConfigChanged(eventArgs.getModID()); + } + + @SubscribeEvent + public void open(final InitGuiEvent.Post e) { + this.guiHandler.open(e); + } + + @SubscribeEvent + public void draw(final DrawScreenEvent.Post e) { + this.guiHandler.draw(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Pre e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void action(final ActionPerformedEvent.Post e) { + this.guiHandler.action(e); + } + + @SubscribeEvent + public void tickclient(final @Nonnull ClientTickEvent e) { + this.guiHandler.tickclient(); + } } \ No newline at end of file diff --git a/1.9.4/src/main/java/net/teamfruit/serverobserver/CommonProxy.java b/1.9.4/src/main/java/net/teamfruit/serverobserver/CommonProxy.java deleted file mode 100644 index c909736..0000000 --- a/1.9.4/src/main/java/net/teamfruit/serverobserver/CommonProxy.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.teamfruit.serverobserver; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public class CommonProxy implements IProxy { - @Override - public void preInit(final FMLPreInitializationEvent event) { - } - - @Override - public void init(final FMLInitializationEvent event) { - } - - @Override - public void postInit(final FMLPostInitializationEvent event) { - } -} diff --git a/1.9.4/src/main/java/net/teamfruit/serverobserver/IProxy.java b/1.9.4/src/main/java/net/teamfruit/serverobserver/IProxy.java deleted file mode 100644 index 936416a..0000000 --- a/1.9.4/src/main/java/net/teamfruit/serverobserver/IProxy.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public interface IProxy { - - void preInit(@Nonnull FMLPreInitializationEvent event); - - void init(@Nonnull FMLInitializationEvent event); - - void postInit(@Nonnull FMLPostInitializationEvent event); - -} \ No newline at end of file diff --git a/1.9.4/src/main/java/net/teamfruit/serverobserver/ServerObserver.java b/1.9.4/src/main/java/net/teamfruit/serverobserver/ServerObserver.java deleted file mode 100644 index 6cd19f1..0000000 --- a/1.9.4/src/main/java/net/teamfruit/serverobserver/ServerObserver.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.teamfruit.serverobserver; - -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkCheckHandler; -import net.minecraftforge.fml.relauncher.Side; - -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) -public class ServerObserver { - @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) - private static @Nullable IProxy proxy; - - @NetworkCheckHandler - public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { - return true; - } - - @EventHandler - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - if (proxy!=null) - proxy.preInit(event); - } - - @EventHandler - public void init(final @Nonnull FMLInitializationEvent event) { - if (proxy!=null) - proxy.init(event); - } - - @EventHandler - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - if (proxy!=null) - proxy.postInit(event); - } -} diff --git a/1.9.4/src/main/resources/META-INF/serverobserver_at.cfg b/1.9.4/src/main/resources/META-INF/serverobserver_at.cfg deleted file mode 100644 index 1e5ce1e..0000000 --- a/1.9.4/src/main/resources/META-INF/serverobserver_at.cfg +++ /dev/null @@ -1,5 +0,0 @@ -public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector -public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight -public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer -public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/LICENSE b/LICENSE index 8029ab9..32f1c39 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2017 TeamFruit - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2017-2018 TeamFruit + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/build.gradle b/build.gradle index ff1312e..ce0ef47 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,16 @@ +// Buildscript Dependencies buildscript { } +// Plugins plugins { id 'com.palantir.git-version' version '0.7.1' id 'co.riiid.gradle' version '0.4.2' - id 'com.jfrog.bintray' version '1.7.3' + id 'com.jfrog.bintray' version '1.8.4' id 'com.matthewprenger.cursegradle' version '1.0.10' } +// Configure Utility allprojects { project.metaClass { isProperty = { propName -> @@ -16,8 +19,8 @@ allprojects { } } +// Configure Variables import org.apache.commons.lang.StringUtils - ext { mod_commonname = "${rootProject.name}-common" mod_build_prefix = 'b' @@ -88,7 +91,6 @@ ext { mod_version = "${mod_version_min}${mod_version_build}" mod_version_full = "${mod_version}${mod_version_meta}" mod_artifacts_dir = file "artifacts/${mod_version_min}/${mod_version_full}" - mod_artifacts_release_dir = file 'artifacts/release' mod_git_repo = plugins.findPlugin('com.palantir.git-version').gitRepo(rootProject).repository mod_git_head = mod_git_repo.getRef('HEAD').objectId.name() @@ -174,69 +176,18 @@ ext { sec_github_key = System.getenv('GITHUB_TOKEN') ?: project.isProperty('api_key_github') ? project.api_key_github : null sec_bintray_user = System.getenv('BINTRAY_USER') ?: project.isProperty('api_user_bintray') ? project.api_user_bintray : null sec_bintray_key = System.getenv('BINTRAY_KEY') ?: project.isProperty('api_key_bintray') ? project.api_key_github : null - sec_keystore_location = System.getenv('KEYSTORE_LOCATION') ?: project.isProperty('keystore_location') ? project.keystore_location : null - sec_keystore_alias = System.getenv('KEYSTORE_ALIAS') ?: project.isProperty('keystore_alias') ? project.keystore_alias : null - sec_keystore_password = System.getenv('KEYSTORE_PASSWORD') ?: project.isProperty('keystore_password') ? project.keystore_password : null -} - -class DeployExtension { - def project, targets - - DeployExtension(proj, List tar) { - targets = tar - project = proj - } - - DeployExtension(proj) { - this(proj, []) - } - - void target(File t) { - targets.add(t) - } - - void target(String t) { - target(project.file(t)) - } -} - -class ManifestExtension { - def manifests - - ManifestExtension(def mf) { - manifests = mf - } - - ManifestExtension() { - this([:]) - } - - void manifest(String key, String value) { - targets.put(key, value) - } - - void manifest(Map map) { - targets.putAll(map) - } -} - -project.extensions.create('deploy', DeployExtension, project) -project.extensions.create('manifests', ManifestExtension) -['private.gradle', 'properties.gradle'].each { def its = file(it); if (its.exists()) apply from: its } - -subprojects { - ext.deploy_target = project.extensions.create('deploy', DeployExtension, project, deploy.targets.clone()) - ext.manifests = project.extensions.create('manifests', ManifestExtension, manifests.manifests.clone()) - ['private.gradle', 'properties.gradle'].each { def its = file(it); if (its.exists()) apply from: its } } +// Configure Subprojects evaluationDependsOnChildren() +// Plugins apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'maven-publish' +// Configure Source Sets sourceSets { delegate.each { s -> s.java { @@ -248,6 +199,7 @@ sourceSets { } } +// Auto-Generated Directory task setupSourceSets { doLast { sourceSets*.java.srcDirs*.each { it.mkdirs() } @@ -256,8 +208,10 @@ task setupSourceSets { [tasks.eclipseClasspath, tasks.ideaModule]*.dependsOn 'setupSourceSets' } +// Configure Version version = "${mod_version}" +// Universal Jar jar { subprojects.each { p -> if (p.name==mod_commonname) { @@ -273,17 +227,17 @@ jar { } } dependsOn p.tasks.build - mustRunAfter p.tasks.signJars } classifier = 'universal' destinationDir = mod_artifacts_dir } -task releaseArtifacts(dependsOn: 'build', type: Sync) { - from mod_artifacts_dir - into mod_artifacts_release_dir +// Output Jar +artifacts { + archives jar } +// Release GitHub gradle.taskGraph.whenReady {taskGraph -> if (taskGraph.hasTask(tasks.githubRelease)) { assert sec_github_key!=null, 'missing sec_github_key' @@ -311,16 +265,23 @@ if (sec_github_key!=null&&project.isProperty('extra_github_owner')&&project.isPr } } -publishing { - publications { - ModPublication(MavenPublication) { - groupId = project.group - artifactId = project.modid - version = "${mod_version}" - artifact jar - subprojects.each { p -> +// Release Bintray - Maven Publishing +publishing.publications { + ModPublication(MavenPublication) { + groupId = project.group + artifactId = project.modid + version = "${mod_version}" + artifact jar + } + + subprojects.each { p -> + if (p.name!=mod_commonname) { + "ModPublication-${p.version_minecraft}"(MavenPublication) { + groupId = p.group + artifactId = p.modid + version = "${p.version_minecraft}-${p.mod_version}" artifact p.shadowJar - artifact p.jar + //artifact p.jar artifact p.devJar artifact p.sourceJar artifact p.apiJar @@ -329,6 +290,7 @@ publishing { } } +// Release Bintray gradle.taskGraph.whenReady {taskGraph -> if (taskGraph.hasTask(tasks.bintrayUpload)) { assert sec_bintray_user!=null, 'missing sec_bintray_user' @@ -342,20 +304,30 @@ if (sec_bintray_user!=null&&sec_bintray_key!=null&&project.isProperty('extra_bin tasks.bintrayUpload.enabled = !mod_autorelease user = sec_bintray_user key = sec_bintray_key - publications = ['ModPublication'] + def pubs = ['ModPublication'] + subprojects.each { p -> + if (p.name!=mod_commonname) + pubs += "ModPublication-${p.version_minecraft}" + } + publications = pubs + publish = true pkg { + userOrg = project.extra_bintray_org repo = project.extra_bintray_repo name = project.extra_bintray_name version { name = "${mod_version}" released = new Date() + desc = "${mod_changelog_title}"+(StringUtils.isEmpty(mod_changelog)?'':"\n\n${mod_changelog}") + vcsTag = mod_buildtag } } } } else tasks.bintrayUpload.enabled = false +// Release CurseForge if (sec_curseforge_key!=null&&project.isProperty('extra_curseforge_id')) { curseforge { tasks.curseforge.enabled = !mod_autorelease diff --git a/common.gradle b/build.subprojects.gradle similarity index 54% rename from common.gradle rename to build.subprojects.gradle index 4bf119d..26f5f97 100644 --- a/common.gradle +++ b/build.subprojects.gradle @@ -1,3 +1,4 @@ +// Buildscript Dependencies buildscript { repositories { mavenCentral() @@ -17,35 +18,67 @@ buildscript { } } +// Plugins plugins { id 'com.github.johnrengelman.shadow' version '2.0.1' } - apply plugin: 'com.matthewprenger.cursegradle' - -// ForgeGradle 2.3 with Kotlin to add new sourceSets apply plugin: 'java' + +// Configure Source Sets - Step1 sourceSets { - common_api {} - common_main {} - common_test {} + base_api {} + base_main {} + base_test {} + compat_api {} + compat_main {} + compat_test {} + universal_api {} + universal_main {} + universal_test {} } +// Configure Source Sets - Step2 apply plugin: project.forgegradle_plugin def fg_plugin = plugins.findPlugin project.forgegradle_plugin +// Configure Source Sets - Step3 sourceSets { - [[common: common_api, src: api], [common: common_main, src: main], [common: common_test, src: test]].each { s -> - s.common.java { - srcDirs = ["../src/${s.src.name}/java"] - } - s.common.resources { - srcDirs = ["../src/${s.src.name}/resources"] - } - s.common.compileClasspath += s.src.compileClasspath - s.common.runtimeClasspath += s.src.runtimeClasspath - s.src.compileClasspath += s.common.output - s.src.runtimeClasspath += s.common.output + [ + [src: api, base: base_api, bootstrap: bootstrap_api, compat: compat_api, universal: universal_api], + [src: main, base: base_main, bootstrap: bootstrap_main, compat: compat_main, universal: universal_main], + [src: test, base: base_test, bootstrap: bootstrap_test, compat: compat_test, universal: universal_test] + ].each { s -> + s.src.java.srcDirs = ["../sources/default/src/${s.src.name}/java"] + s.src.resources.srcDirs = ["../sources/default/src/${s.src.name}/resources"] + s.base.java.srcDirs = ["../sources/base/src/${s.src.name}/java"] + s.base.resources.srcDirs = ["../sources/base/src/${s.src.name}/resources"] + s.bootstrap.java.srcDirs = ["./sources/bootstrap/src/${s.src.name}/java"] + s.bootstrap.resources.srcDirs = ["./sources/bootstrap/src/${s.src.name}/resources"] + s.compat.java.srcDirs = ["./sources/compat/src/${s.src.name}/java"] + s.compat.resources.srcDirs = ["./sources/compat/src/${s.src.name}/resources"] + s.universal.java.srcDirs = ["../sources/universal/src/${s.src.name}/java"] + s.universal.resources.srcDirs = ["../sources/universal/src/${s.src.name}/resources"] + + s.base.compileClasspath += s.src.compileClasspath + s.base.runtimeClasspath += s.src.runtimeClasspath + s.bootstrap.compileClasspath += s.src.compileClasspath + s.bootstrap.runtimeClasspath += s.src.runtimeClasspath + s.compat.compileClasspath += s.src.compileClasspath + s.compat.runtimeClasspath += s.src.runtimeClasspath + s.universal.compileClasspath += s.src.compileClasspath + s.universal.runtimeClasspath += s.src.runtimeClasspath + + s.src.compileClasspath += s.base.output + s.src.runtimeClasspath += s.base.output + s.bootstrap.compileClasspath += s.base.output + s.bootstrap.runtimeClasspath += s.base.output + s.compat.compileClasspath += s.base.output + s.compat.runtimeClasspath += s.base.output + s.universal.compileClasspath += s.base.output + s.universal.runtimeClasspath += s.base.output + s.universal.compileClasspath += s.compat.output + s.universal.runtimeClasspath += s.compat.output } } @@ -68,17 +101,39 @@ if (project.forgegradle.contains('2.1')) { } } +// Configure Version version = mod_version +// Configure Shade configurations { shade compile.extendsFrom shade } -[compileJava, compileApiJava, compileTestJava]*.options*.encoding = 'UTF-8' +// Configure Java Compile Options +[ +compileJava, compileApiJava, compileTestJava, +compileBase_mainJava, compileBase_apiJava, compileBase_testJava, +compileBootstrap_mainJava, compileBootstrap_apiJava, compileBootstrap_testJava, +compileCompat_mainJava, compileCompat_apiJava, compileCompat_testJava, +compileUniversal_mainJava, compileUniversal_apiJava, compileUniversal_testJava +]*.options*.encoding = 'UTF-8' sourceCompatibility = targetCompatibility = '1.8' +// Add Arguments for Eclipse +if (tasks.findByPath('makeEclipseCleanRunClient')!=null) { + tasks.makeEclipseCleanRunClient.doFirst { + setArguments '--username Kamesuta' + if (project.isProperty('extra_fmlcore')) + setJvmArguments "-Dfml.coreMods.load=${project.extra_fmlcore}" + } +} + +// Configure Minecraft minecraft { + if (project.forgegradle.contains('2.2')) + setSuppressVersionTest(true); + version = "${project.version_minecraft}-${project.version_forge}" if (project.isProperty('version_mappings')) @@ -97,6 +152,7 @@ minecraft { replace '${forgeversion}', project.version_forge } +// Auto-Generated Directory task setupSourceSets { doLast { sourceSets*.java.srcDirs*.each { it.mkdirs() } @@ -105,29 +161,14 @@ task setupSourceSets { [tasks.eclipseClasspath, tasks.ideaModule]*.dependsOn 'setupSourceSets' } +// Version Update Check processResources { // this will ensure that this task is redone when the versions change. inputs.property 'version', mod_version inputs.property 'mcversion', project.version_minecraft - - from(sourceSets.common_main.resources.srcDirs) { - include 'mcmod.info' - - /*expand([ - 'modid' : project.modid, - 'modname' : project.modname, - 'version' : mod_version, - 'mcversion' : project.version_minecraft, - 'forgeversion' : project.version_forge, - 'minforgeversion': project.isProperty('version_minforge') ? project.version_minforge : project.version_forge, - ])*/ - } - - from(sourceSets.common_main.resources.srcDirs) { - exclude 'mcmod.info' - } } +// Dependency Repositories repositories { jcenter() maven { @@ -140,49 +181,21 @@ repositories { } } +// Dependencies dependencies { compile fileTree(dir: 'libs', include: '*.jar') shade fileTree(dir: 'libs/shade', include: '*.jar') compile fileTree(dir: '../libs', include: '*.jar') shade fileTree(dir: '../libs/shade', include: '*.jar') - if (project.name==mod_commonname) - compile 'net.teamfruit:fmllegacydependency:1.0.2' -} - -ext.commonManifest = { - if (project.isProperty('extra_fmlcore')) - attributes 'FMLCorePlugin': project.extra_fmlcore - if (project.isProperty('extra_fmlmod')) - attributes 'FMLCorePluginContainsFMLMod': project.extra_fmlcore - if (project.isProperty('extra_fmlat')) - attributes 'FMLAT': project.extra_fmlat - // Prevent from CurseForge duplicate error - attributes 'ModVersion': mod_version_full - attributes manifests.manifests -} - -// println(shadowJar.getSource().getFiles()) -shadowJar.configurations = [project.configurations.shade] - -shadowJar { - from sourceSets.main.output - from sourceSets.api.output - from sourceSets.common_main.output - from sourceSets.common_api.output - classifier 'universal' - manifest commonManifest -} - -jar { - from sourceSets.main.output - from sourceSets.api.output - classifier 'diff' - manifest commonManifest + if (project.name==mod_commonname) { + compile 'net.teamfruit:fmllegacydependency:1.0.4' + if (project.isProperty('extra_fmlcore')) + shade 'net.teamfruit:coremodlegacydependency:1.0.0' + } } -tasks.jar.dependsOn 'shadowJar' -// println !reobf.hasProperty('dependsOn') +// ReobfShadowJar for 1.7.10 if (!reobf.hasProperty('dependsOn')) { reobf { shadowJar { mappingType = 'SEARGE' } @@ -212,102 +225,113 @@ if (!reobf.hasProperty('dependsOn')) { reobf.dependsOn 'reobfShadowJar' } +// SourceJar for 1.7.10 if (tasks.findByPath('sourceJar')==null) { task sourceJar(dependsOn: 'classes', type: Jar) { - from sourceSets.main.allSource - classifier = 'sources' - manifest commonManifest } } -sourceJar { - from sourceSets.api.allSource +// Jar Manifest +ext.commonManifest = { + if (project.isProperty('extra_fmlcore')) + attributes 'FMLCorePlugin': project.extra_fmlcore + if (project.isProperty('extra_fmlmod')) + attributes 'FMLCorePluginContainsFMLMod': project.extra_fmlcore + if (project.isProperty('extra_fmlat')) + attributes 'FMLAT': project.extra_fmlat + // Prevent from CurseForge duplicate error + attributes 'ModVersion': mod_version_full +} + +// Output Jar Universal +shadowJar.configurations = [project.configurations.shade] +shadowJar { + from sourceSets.main.output + from sourceSets.api.output + from sourceSets.base_main.output + from sourceSets.base_api.output + from sourceSets.bootstrap_main.output + from sourceSets.bootstrap_api.output + if (project.name==mod_commonname) { + tasks.reobfShadowJar.classpath += sourceSets.compat_main.output + tasks.reobfShadowJar.classpath += sourceSets.compat_api.output + } else { + from sourceSets.compat_main.output + from sourceSets.compat_api.output + } + from sourceSets.universal_main.output + from sourceSets.universal_api.output + classifier 'universal' + manifest commonManifest +} + +// Output Jar Diff +jar { + from sourceSets.main.output + from sourceSets.api.output + from sourceSets.compat_main.output + from sourceSets.compat_api.output + classifier 'diff' + manifest commonManifest } +tasks.jar.dependsOn 'shadowJar' -// An Error occured while switching above 1.8 -> under 1.7 -task cleanMakeStart(type: Delete) { - // makeStart.dependsOn 'cleanMakeStart' - delete file(new File(tasks.makeStart.getTemporaryDir(), 'extracted')) +// Output Jar Source +sourceJar { + from sourceSets.main.allSource + from sourceSets.api.allSource + from sourceSets.base_main.allSource + from sourceSets.base_api.allSource + from sourceSets.bootstrap_main.allSource + from sourceSets.bootstrap_api.allSource + from sourceSets.compat_main.allSource + from sourceSets.compat_api.allSource + from sourceSets.universal_main.allSource + from sourceSets.universal_api.allSource + classifier 'sources' + manifest commonManifest } +// Output Jar Dev task devJar(dependsOn: 'classes', type: Jar) { from sourceSets.main.output from sourceSets.api.output - classifier = 'dev' + from sourceSets.base_main.output + from sourceSets.base_api.output + from sourceSets.bootstrap_main.output + from sourceSets.bootstrap_api.output + from sourceSets.compat_main.output + from sourceSets.compat_api.output + from sourceSets.universal_main.output + from sourceSets.universal_api.output + classifier 'dev' manifest commonManifest } +// Output Jar Api task apiJar(dependsOn: 'classes', type: Jar) { from sourceSets.api.output - classifier = 'api' + from sourceSets.base_api.output + from sourceSets.bootstrap_api.output + from sourceSets.compat_api.output + from sourceSets.universal_api.output + classifier 'api' manifest commonManifest } +// Configure Destination Directory [jar, shadowJar, devJar, sourceJar, apiJar]*.destinationDir = mod_artifacts_dir +// Output Jar artifacts { - archives jar - archives shadowJar - archives devJar - archives sourceJar - archives apiJar -} - -task signJars(dependsOn: 'build') { - gradle.taskGraph.whenReady {taskGraph -> - if (taskGraph.hasTask(tasks.signJars)) - assert sec_keystore_location!=null, 'missing sec_keystore_location' - } - - def keystore_location = sec_keystore_location ?: '' - def keystore_alias = sec_keystore_alias ?: '' - def keystore_password = sec_keystore_password ?: '' - - inputs.dir shadowJar.destinationDir - inputs.file keystore_location - inputs.property 'keystore_alias', keystore_alias - inputs.property 'keystore_password', keystore_password - outputs.dir shadowJar.destinationDir - - doLast { - [jar, shadowJar, devJar, sourceJar, apiJar].each { eachtask -> - eachtask.outputs.files.each { file -> - if (!file.path.endsWith('.jar')) - return - - logger.lifecycle "signing ${file}" - ant.signjar( - destDir: file.parentFile, - jar: file, - keystore: keystore_location, - alias: keystore_alias, - storepass: keystore_password - ) - } - } - } -} - -task deploy(dependsOn: 'build', type: Copy) { - mustRunAfter 'signJars' - - deploy_target.targets.each { target -> - def dest = target.name.endsWith('.jar') ? target.parentFile : target - - from(project.tasks.shadowJar.outputs.files.singleFile) - into(dest) - - rename { String oldname -> - target.name.endsWith('.jar') ? target.name : oldname - } - - eachFile { file -> - def path = file.relativePath.getFile(dest) - logger.lifecycle "copying to ${path}" - } - } + archives jar + archives shadowJar + archives devJar + archives sourceJar + archives apiJar } +// Release CurseForge gradle.taskGraph.whenReady {taskGraph -> if (taskGraph.hasTask(tasks.curseforge)) { assert sec_curseforge_key!=null, 'missing sec_curseforge_key' @@ -319,7 +343,6 @@ if (sec_curseforge_key!=null&&project.isProperty('extra_curseforge_id')) { tasks.curseforge.enabled = !mod_autorelease && project.name!=mod_commonname tasks.curseforge.dependsOn 'reobfShadowJar' - tasks.curseforge.mustRunAfter 'signJars' apiKey = sec_curseforge_key project { id = project.extra_curseforge_id @@ -347,4 +370,5 @@ if (sec_curseforge_key!=null&&project.isProperty('extra_curseforge_id')) { } else tasks.curseforge.enabled = false +// Configure Project Settings ['project.gradle'].each { f -> [rootProject, project].each { p -> def fs = p.file(f); if (fs.exists()) apply from: fs } } \ No newline at end of file diff --git a/common/sources/compat/src/main/java/net/teamfruit/serverobserver/IProxy.java b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/IProxy.java new file mode 100644 index 0000000..72a66f2 --- /dev/null +++ b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/IProxy.java @@ -0,0 +1,17 @@ +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; + +public interface IProxy { + + void preInit(@Nonnull FMLPreInitializationEvent event); + + void init(@Nonnull FMLInitializationEvent event); + + void postInit(@Nonnull FMLPostInitializationEvent event); + +} \ No newline at end of file diff --git a/1.7.10/src/main/java/net/teamfruit/serverobserver/IProxyL.java b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/IProxyL.java similarity index 96% rename from 1.7.10/src/main/java/net/teamfruit/serverobserver/IProxyL.java rename to common/sources/compat/src/main/java/net/teamfruit/serverobserver/IProxyL.java index 921e07a..0116e65 100644 --- a/1.7.10/src/main/java/net/teamfruit/serverobserver/IProxyL.java +++ b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/IProxyL.java @@ -1,17 +1,17 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; - -public interface IProxyL { - - void preInit(@Nonnull FMLPreInitializationEvent event); - - void init(@Nonnull FMLInitializationEvent event); - - void postInit(@Nonnull FMLPostInitializationEvent event); - +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; + +public interface IProxyL { + + void preInit(@Nonnull FMLPreInitializationEvent event); + + void init(@Nonnull FMLInitializationEvent event); + + void postInit(@Nonnull FMLPostInitializationEvent event); + } \ No newline at end of file diff --git a/common/src/main/java/net/teamfruit/serverobserver/ServerObserver.java b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/ServerObserver.java similarity index 96% rename from common/src/main/java/net/teamfruit/serverobserver/ServerObserver.java rename to common/sources/compat/src/main/java/net/teamfruit/serverobserver/ServerObserver.java index 3f47829..d1da0c9 100644 --- a/common/src/main/java/net/teamfruit/serverobserver/ServerObserver.java +++ b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/ServerObserver.java @@ -1,52 +1,52 @@ -package net.teamfruit.serverobserver; - -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.fml.common.Mod.EventHandler; -import net.minecraftforge.fml.common.Mod.Instance; -import net.minecraftforge.fml.common.SidedProxy; -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; -import net.minecraftforge.fml.common.network.NetworkCheckHandler; -import net.minecraftforge.fml.relauncher.Side; - -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) -public class ServerObserver { - @Instance(Reference.MODID) - public static @Nullable ServerObserver instance; - - static { - UniversalVersioner.loadVersion(); - } - - @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) - public static @Nullable IProxy proxy; - - @NetworkCheckHandler - public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { - return true; - } - - @EventHandler - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - if (proxy!=null) - proxy.preInit(event); - } - - @EventHandler - public void init(final @Nonnull FMLInitializationEvent event) { - if (proxy!=null) - proxy.init(event); - } - - @EventHandler - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - if (proxy!=null) - proxy.postInit(event); - } -} +package net.teamfruit.serverobserver; + +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.common.Mod.EventHandler; +import net.minecraftforge.fml.common.Mod.Instance; +import net.minecraftforge.fml.common.SidedProxy; +import net.minecraftforge.fml.common.event.FMLInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; +import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; +import net.minecraftforge.fml.common.network.NetworkCheckHandler; +import net.minecraftforge.fml.relauncher.Side; + +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) +public class ServerObserver { + @Instance(Reference.MODID) + public static @Nullable ServerObserver instance; + + static { + UniversalVersioner.loadVersion(); + } + + @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) + public static @Nullable IProxy proxy; + + @NetworkCheckHandler + public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { + return true; + } + + @EventHandler + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + if (proxy!=null) + proxy.preInit(event); + } + + @EventHandler + public void init(final @Nonnull FMLInitializationEvent event) { + if (proxy!=null) + proxy.init(event); + } + + @EventHandler + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + if (proxy!=null) + proxy.postInit(event); + } +} diff --git a/common/src/main/java/net/teamfruit/serverobserver/ServerObserverL.java b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/ServerObserverL.java similarity index 96% rename from common/src/main/java/net/teamfruit/serverobserver/ServerObserverL.java rename to common/sources/compat/src/main/java/net/teamfruit/serverobserver/ServerObserverL.java index bce5948..0694a51 100644 --- a/common/src/main/java/net/teamfruit/serverobserver/ServerObserverL.java +++ b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/ServerObserverL.java @@ -1,52 +1,52 @@ -package net.teamfruit.serverobserver; - -import java.util.Map; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.network.NetworkCheckHandler; -import cpw.mods.fml.relauncher.Side; - -@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) -public class ServerObserverL { - @Instance(Reference.MODID) - public static @Nullable ServerObserverL instance; - - static { - UniversalVersioner.loadVersion(); - } - - @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) - public static @Nullable IProxyL proxy; - - @NetworkCheckHandler - public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { - return true; - } - - @EventHandler - public void preInit(final @Nonnull FMLPreInitializationEvent event) { - if (proxy!=null) - proxy.preInit(event); - } - - @EventHandler - public void init(final @Nonnull FMLInitializationEvent event) { - if (proxy!=null) - proxy.init(event); - } - - @EventHandler - public void postInit(final @Nonnull FMLPostInitializationEvent event) { - if (proxy!=null) - proxy.postInit(event); - } -} +package net.teamfruit.serverobserver; + +import java.util.Map; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.network.NetworkCheckHandler; +import cpw.mods.fml.relauncher.Side; + +@Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, guiFactory = Reference.GUI_FACTORY) +public class ServerObserverL { + @Instance(Reference.MODID) + public static @Nullable ServerObserverL instance; + + static { + UniversalVersioner.loadVersion(); + } + + @SidedProxy(serverSide = Reference.PROXY_SERVER, clientSide = Reference.PROXY_CLIENT) + public static @Nullable IProxyL proxy; + + @NetworkCheckHandler + public boolean checkModList(final @Nonnull Map versions, final @Nonnull Side side) { + return true; + } + + @EventHandler + public void preInit(final @Nonnull FMLPreInitializationEvent event) { + if (proxy!=null) + proxy.preInit(event); + } + + @EventHandler + public void init(final @Nonnull FMLInitializationEvent event) { + if (proxy!=null) + proxy.init(event); + } + + @EventHandler + public void postInit(final @Nonnull FMLPostInitializationEvent event) { + if (proxy!=null) + proxy.postInit(event); + } +} diff --git a/common/src/main/java/net/teamfruit/serverobserver/UniversalVersioner.java b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/UniversalVersioner.java similarity index 97% rename from common/src/main/java/net/teamfruit/serverobserver/UniversalVersioner.java rename to common/sources/compat/src/main/java/net/teamfruit/serverobserver/UniversalVersioner.java index a93fdf2..b0a0f7d 100644 --- a/common/src/main/java/net/teamfruit/serverobserver/UniversalVersioner.java +++ b/common/sources/compat/src/main/java/net/teamfruit/serverobserver/UniversalVersioner.java @@ -1,109 +1,109 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.Map.Entry; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; - -import com.google.common.collect.ImmutableMap; - -import net.minecraft.launchwrapper.Launch; - -public class UniversalVersioner { - public static final ImmutableMap versions = ImmutableMap. builder() - .put("1.7", "1.7.10") - .put("1.8", "1.8.9") - .put("1.9", "1.9.4") - .put("1.10", "1.10.2") - .put("1.11", "1.11.2") - .put("1.12", "1.12.2") - .build(); - - public static String getVersion(final String mccversion) { - for (final Entry entry : UniversalVersioner.versions.entrySet()) { - final String key = entry.getKey(); - if (StringUtils.startsWith(mccversion, key)) - return entry.getValue(); - } - return null; - } - - private static T invoke(final String afterFmlPath, final String name, final Class[] types, final Object instance, final Object[] params) { - Class $class; - try { - $class = Class.forName("net.minecraftforge.fml."+afterFmlPath); - } catch (final ClassNotFoundException e1) { - try { - $class = Class.forName("cpw.mods.fml."+afterFmlPath); - } catch (final ClassNotFoundException e2) { - throw new RuntimeException("Could not load fml class"); - } - } - if ($class==null) - throw new RuntimeException("Could not find fml class"); - Method $method; - try { - $method = $class.getMethod(name, types); - } catch (final Exception e) { - throw new RuntimeException("Could not find or access fml method"); - } - try { - @SuppressWarnings("unchecked") - final T res = (T) $method.invoke(instance, params); - return res; - } catch (IllegalAccessException|IllegalArgumentException|InvocationTargetException e) { - throw new RuntimeException("Could not invoke fml method"); - } - } - - public static void loadVersion() { - final Object loader = invoke("common.Loader", "instance", new Class[0], null, new Object[0]); - final Object container = invoke("common.Loader", "activeModContainer", new Class[0], loader, new Object[0]); - final Object[] data = invoke("relauncher.FMLInjectionData", "data", new Class[0], null, new Object[0]); - final String mccversion0 = (String) data[4]; - final String mccversion = getVersion(mccversion0); - - if (mccversion==null) - throw new RuntimeException(String.format("Version %s is not supported! Supported version is %s.", mccversion0, versions)); - - final File minecraftDir = (File) data[6]; - final File modsDir = new File(minecraftDir, "mods"); - if (container!=null) { - final File modFile = invoke("common.ModContainer", "getSource", new Class[0], container, new Object[0]); - if (modFile!=null) { - ZipFile file = null; - InputStream stream = null; - try { - final File canonicalModsDir = modsDir.getCanonicalFile(); - final File versionSpecificModsDir = new File(canonicalModsDir, mccversion); - final File modVersionSpecific = new File(versionSpecificModsDir, Reference.MODID); - - final String jarname = String.format("%s.jar", mccversion); - final File destMod = new File(modVersionSpecific, jarname); - - file = new ZipFile(modFile); - final ZipEntry entry = file.getEntry(jarname); - if (entry==null) - throw new RuntimeException("Could not find version-specific file: "+jarname); - stream = file.getInputStream(entry); - - FileUtils.copyInputStreamToFile(stream, destMod); - Launch.classLoader.addURL(destMod.toURI().toURL()); - } catch (final IOException e) { - new RuntimeException("Could not load version-specific file.", e); - } finally { - IOUtils.closeQuietly(file); - IOUtils.closeQuietly(stream); - } - } - } - } -} +package net.teamfruit.serverobserver; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Map.Entry; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; + +import com.google.common.collect.ImmutableMap; + +import net.minecraft.launchwrapper.Launch; + +public class UniversalVersioner { + public static final ImmutableMap versions = ImmutableMap. builder() + .put("1.7", "1.7.10") + .put("1.8", "1.8.9") + .put("1.9", "1.9.4") + .put("1.10", "1.10.2") + .put("1.11", "1.11.2") + .put("1.12", "1.12.2") + .build(); + + public static String getVersion(final String mccversion) { + for (final Entry entry : UniversalVersioner.versions.entrySet()) { + final String key = entry.getKey(); + if (StringUtils.startsWith(mccversion, key)) + return entry.getValue(); + } + return null; + } + + private static T invoke(final String afterFmlPath, final String name, final Class[] types, final Object instance, final Object[] params) { + Class $class; + try { + $class = Class.forName("net.minecraftforge.fml."+afterFmlPath); + } catch (final ClassNotFoundException e1) { + try { + $class = Class.forName("cpw.mods.fml."+afterFmlPath); + } catch (final ClassNotFoundException e2) { + throw new RuntimeException("Could not load fml class"); + } + } + if ($class==null) + throw new RuntimeException("Could not find fml class"); + Method $method; + try { + $method = $class.getMethod(name, types); + } catch (final Exception e) { + throw new RuntimeException("Could not find or access fml method"); + } + try { + @SuppressWarnings("unchecked") + final T res = (T) $method.invoke(instance, params); + return res; + } catch (IllegalAccessException|IllegalArgumentException|InvocationTargetException e) { + throw new RuntimeException("Could not invoke fml method"); + } + } + + public static void loadVersion() { + final Object loader = invoke("common.Loader", "instance", new Class[0], null, new Object[0]); + final Object container = invoke("common.Loader", "activeModContainer", new Class[0], loader, new Object[0]); + final Object[] data = invoke("relauncher.FMLInjectionData", "data", new Class[0], null, new Object[0]); + final String mccversion0 = (String) data[4]; + final String mccversion = getVersion(mccversion0); + + if (mccversion==null) + throw new RuntimeException(String.format("Version %s is not supported! Supported version is %s.", mccversion0, versions)); + + final File minecraftDir = (File) data[6]; + final File modsDir = new File(minecraftDir, "mods"); + if (container!=null) { + final File modFile = invoke("common.ModContainer", "getSource", new Class[0], container, new Object[0]); + if (modFile!=null) { + ZipFile file = null; + InputStream stream = null; + try { + final File canonicalModsDir = modsDir.getCanonicalFile(); + final File versionSpecificModsDir = new File(canonicalModsDir, mccversion); + final File modVersionSpecific = new File(versionSpecificModsDir, Reference.MODID); + + final String jarname = String.format("%s.jar", mccversion); + final File destMod = new File(modVersionSpecific, jarname); + + file = new ZipFile(modFile); + final ZipEntry entry = file.getEntry(jarname); + if (entry==null) + throw new RuntimeException("Could not find version-specific file: "+jarname); + stream = file.getInputStream(entry); + + FileUtils.copyInputStreamToFile(stream, destMod); + Launch.classLoader.addURL(destMod.toURI().toURL()); + } catch (final IOException e) { + new RuntimeException("Could not load version-specific file.", e); + } finally { + IOUtils.closeQuietly(file); + IOUtils.closeQuietly(stream); + } + } + } + } +} diff --git a/common/src/test/java/net/teamfruit/serverobserver/UniversalVersionerTest.java b/common/sources/compat/src/test/java/net/teamfruit/serverobserver/UniversalVersionerTest.java similarity index 97% rename from common/src/test/java/net/teamfruit/serverobserver/UniversalVersionerTest.java rename to common/sources/compat/src/test/java/net/teamfruit/serverobserver/UniversalVersionerTest.java index 70cd527..28b34be 100644 --- a/common/src/test/java/net/teamfruit/serverobserver/UniversalVersionerTest.java +++ b/common/sources/compat/src/test/java/net/teamfruit/serverobserver/UniversalVersionerTest.java @@ -1,57 +1,57 @@ -package net.teamfruit.serverobserver; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class UniversalVersionerTest { - - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void test() { - assertEquals("1.7.10", UniversalVersioner.getVersion("1.7")); - assertEquals("1.7.10", UniversalVersioner.getVersion("1.7.4")); - assertEquals("1.7.10", UniversalVersioner.getVersion("1.7.10")); - assertEquals("1.7.10", UniversalVersioner.getVersion("1.70.2")); - assertEquals("1.8.9", UniversalVersioner.getVersion("1.8")); - assertEquals("1.8.9", UniversalVersioner.getVersion("1.8.1")); - assertEquals("1.8.9", UniversalVersioner.getVersion("1.8.9")); - assertEquals("1.8.9", UniversalVersioner.getVersion("1.82.3")); - assertEquals("1.9.4", UniversalVersioner.getVersion("1.9")); - assertEquals("1.9.4", UniversalVersioner.getVersion("1.9.2")); - assertEquals("1.9.4", UniversalVersioner.getVersion("1.9.4")); - assertEquals("1.9.4", UniversalVersioner.getVersion("1.9.80")); - assertEquals("1.10.2", UniversalVersioner.getVersion("1.10")); - assertEquals("1.10.2", UniversalVersioner.getVersion("1.10.1")); - assertEquals("1.10.2", UniversalVersioner.getVersion("1.10.2")); - assertEquals("1.10.2", UniversalVersioner.getVersion("1.10.50")); - assertEquals("1.11.2", UniversalVersioner.getVersion("1.11")); - assertEquals("1.11.2", UniversalVersioner.getVersion("1.11.0")); - assertEquals("1.11.2", UniversalVersioner.getVersion("1.11.2")); - assertEquals("1.11.2", UniversalVersioner.getVersion("1.11.93")); - assertEquals("1.12.2", UniversalVersioner.getVersion("1.12")); - assertEquals("1.12.2", UniversalVersioner.getVersion("1.12.4")); - assertEquals("1.12.2", UniversalVersioner.getVersion("1.12.2")); - assertEquals("1.12.2", UniversalVersioner.getVersion("1.12.18")); - } - -} +package net.teamfruit.serverobserver; + +import static org.junit.Assert.*; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class UniversalVersionerTest { + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + } + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void test() { + assertEquals("1.7.10", UniversalVersioner.getVersion("1.7")); + assertEquals("1.7.10", UniversalVersioner.getVersion("1.7.4")); + assertEquals("1.7.10", UniversalVersioner.getVersion("1.7.10")); + assertEquals("1.7.10", UniversalVersioner.getVersion("1.70.2")); + assertEquals("1.8.9", UniversalVersioner.getVersion("1.8")); + assertEquals("1.8.9", UniversalVersioner.getVersion("1.8.1")); + assertEquals("1.8.9", UniversalVersioner.getVersion("1.8.9")); + assertEquals("1.8.9", UniversalVersioner.getVersion("1.82.3")); + assertEquals("1.9.4", UniversalVersioner.getVersion("1.9")); + assertEquals("1.9.4", UniversalVersioner.getVersion("1.9.2")); + assertEquals("1.9.4", UniversalVersioner.getVersion("1.9.4")); + assertEquals("1.9.4", UniversalVersioner.getVersion("1.9.80")); + assertEquals("1.10.2", UniversalVersioner.getVersion("1.10")); + assertEquals("1.10.2", UniversalVersioner.getVersion("1.10.1")); + assertEquals("1.10.2", UniversalVersioner.getVersion("1.10.2")); + assertEquals("1.10.2", UniversalVersioner.getVersion("1.10.50")); + assertEquals("1.11.2", UniversalVersioner.getVersion("1.11")); + assertEquals("1.11.2", UniversalVersioner.getVersion("1.11.0")); + assertEquals("1.11.2", UniversalVersioner.getVersion("1.11.2")); + assertEquals("1.11.2", UniversalVersioner.getVersion("1.11.93")); + assertEquals("1.12.2", UniversalVersioner.getVersion("1.12")); + assertEquals("1.12.2", UniversalVersioner.getVersion("1.12.4")); + assertEquals("1.12.2", UniversalVersioner.getVersion("1.12.2")); + assertEquals("1.12.2", UniversalVersioner.getVersion("1.12.18")); + } + +} diff --git a/common/src/main/java/net/teamfruit/serverobserver/IProxy.java b/common/src/main/java/net/teamfruit/serverobserver/IProxy.java deleted file mode 100644 index 936416a..0000000 --- a/common/src/main/java/net/teamfruit/serverobserver/IProxy.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; -import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; - -public interface IProxy { - - void preInit(@Nonnull FMLPreInitializationEvent event); - - void init(@Nonnull FMLInitializationEvent event); - - void postInit(@Nonnull FMLPostInitializationEvent event); - -} \ No newline at end of file diff --git a/common/src/main/resources/META-INF/serverobserver_at.cfg b/common/src/main/resources/META-INF/serverobserver_at.cfg deleted file mode 100644 index 1e5ce1e..0000000 --- a/common/src/main/resources/META-INF/serverobserver_at.cfg +++ /dev/null @@ -1,5 +0,0 @@ -public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector -public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight -public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer -public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 2543e17..4691e2d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,17 @@ -group=net.teamfruit -modid=serverobserver -modname=ServerObserver -version_major=1 -version_minor=0 -version_patch=2 -extra_changelog_location= -extra_fmlcore= -extra_fmlmod= -extra_fmlat=serverobserver_at.cfg -extra_curseforge_id=279375 -extra_github_owner=Team-Fruit -extra_github_repo=ServerObserver -extra_bintray_repo=mods -extra_bintray_name=ServerObserver -deploy_name= +group=net.teamfruit +modid=serverobserver +modname=ServerObserver +version_major=1 +version_minor=0 +version_patch=3 +extra_changelog_location= +extra_fmlcore= +extra_fmlmod= +extra_fmlat=serverobserver_at.cfg +extra_curseforge_id=279375 +extra_github_owner=Team-Fruit +extra_github_repo=ServerObserver +extra_bintray_org=team-fruit +extra_bintray_repo=mods +extra_bintray_name=ServerObserver org.gradle.jvmargs=-Xmx2048m \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index c32e42d..5facf2d 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,7 @@ -rootProject.name = 'ServerObserver' -include 'common' -include '1.7.10', '1.8.9', '1.9.4', '1.10.2', '1.11.2', '1.12.2' -rootProject.children.each { project -> - project.buildFileName = '../common.gradle' - project.name = "${rootProject.name}-${project.name}" +rootProject.name = 'ServerObserver' +include 'common' +include '1.7.10', '1.8.9', '1.9.4', '1.10.2', '1.11.2', '1.12.2' +rootProject.children.each { project -> + project.buildFileName = '../build.subprojects.gradle' + project.name = "${rootProject.name}-${project.name}" } \ No newline at end of file diff --git a/src/main/java/net/teamfruit/serverobserver/Log.java b/sources/base/src/main/java/net/teamfruit/serverobserver/Log.java similarity index 96% rename from src/main/java/net/teamfruit/serverobserver/Log.java rename to sources/base/src/main/java/net/teamfruit/serverobserver/Log.java index b86b04e..89aa72a 100644 --- a/src/main/java/net/teamfruit/serverobserver/Log.java +++ b/sources/base/src/main/java/net/teamfruit/serverobserver/Log.java @@ -1,10 +1,10 @@ -package net.teamfruit.serverobserver; - -import javax.annotation.Nonnull; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class Log { - public final static @Nonnull Logger log = LogManager.getLogger(Reference.NAME); +package net.teamfruit.serverobserver; + +import javax.annotation.Nonnull; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +public class Log { + public final static @Nonnull Logger log = LogManager.getLogger(Reference.NAME); } \ No newline at end of file diff --git a/src/main/java/net/teamfruit/serverobserver/Reference.java b/sources/base/src/main/java/net/teamfruit/serverobserver/Reference.java similarity index 100% rename from src/main/java/net/teamfruit/serverobserver/Reference.java rename to sources/base/src/main/java/net/teamfruit/serverobserver/Reference.java diff --git a/1.10.2/src/main/resources/META-INF/serverobserver_at.cfg b/sources/default/src/main/resources/META-INF/serverobserver_at.cfg similarity index 99% rename from 1.10.2/src/main/resources/META-INF/serverobserver_at.cfg rename to sources/default/src/main/resources/META-INF/serverobserver_at.cfg index 1e5ce1e..c6804c3 100644 --- a/1.10.2/src/main/resources/META-INF/serverobserver_at.cfg +++ b/sources/default/src/main/resources/META-INF/serverobserver_at.cfg @@ -1,5 +1,5 @@ -public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector -public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight -public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen -public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer +public net.minecraft.client.gui.GuiMultiplayer field_146803_h # serverListSelector +public net.minecraft.client.gui.GuiDisconnected field_175353_i # textHeight +public net.minecraft.client.gui.GuiDisconnected field_146307_h # parentScreen +public net.minecraft.client.gui.GuiMultiplayer func_146791_a(Lnet/minecraft/client/multiplayer/ServerData;)V # connectToServer public net.minecraft.client.gui.ServerListEntryNormal field_148302_b # threadPool \ No newline at end of file diff --git a/src/main/java/net/teamfruit/serverobserver/Config.java b/sources/universal/src/main/java/net/teamfruit/serverobserver/Config.java similarity index 100% rename from src/main/java/net/teamfruit/serverobserver/Config.java rename to sources/universal/src/main/java/net/teamfruit/serverobserver/Config.java diff --git a/src/main/java/net/teamfruit/serverobserver/ConfigBase.java b/sources/universal/src/main/java/net/teamfruit/serverobserver/ConfigBase.java similarity index 96% rename from src/main/java/net/teamfruit/serverobserver/ConfigBase.java rename to sources/universal/src/main/java/net/teamfruit/serverobserver/ConfigBase.java index a1e4ae2..535e631 100644 --- a/src/main/java/net/teamfruit/serverobserver/ConfigBase.java +++ b/sources/universal/src/main/java/net/teamfruit/serverobserver/ConfigBase.java @@ -1,240 +1,240 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.util.Collections; -import java.util.Set; -import java.util.WeakHashMap; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import org.apache.commons.lang3.StringUtils; - -import com.google.common.collect.Sets; - -import net.minecraftforge.common.config.Configuration; -import net.minecraftforge.common.config.Property; - -public class ConfigBase extends Configuration { - private final @Nonnull Set configs = Sets.newHashSet(); - - public static interface IReloadableConfig { - void reload(); - } - - public @Nonnull T registerReload(final @Nonnull T config) { - this.configs.add(config); - return config; - } - - public void reload() { - for (final IReloadableConfig config : this.configs) - config.reload(); - } - - public static Set configChangeHandlers = Collections.newSetFromMap(new WeakHashMap()); - - public ConfigBase(final @Nonnull File configFile, final @Nonnull String version) { - super(configFile, version, true); - configChangeHandlers.add(this); - } - - @Override - public void save() { - if (hasChanged()) - super.save(); - } - - public void onConfigChanged(final @Nonnull String modid) { - if (StringUtils.equals(modid, Reference.MODID)) { - save(); - reload(); - } - } - - public @Nonnull ConfigProperty propertyString(final @Nonnull Property property) { - return registerReload(ConfigProperty.propertyString(this, property)); - } - - public @Nonnull ConfigProperty propertyBoolean(final @Nonnull Property property) { - return registerReload(ConfigProperty.propertyBoolean(this, property)); - } - - public @Nonnull ConfigProperty propertyDouble(final @Nonnull Property property) { - return registerReload(ConfigProperty.propertyDouble(this, property)); - } - - public @Nonnull ConfigProperty propertyInteger(final @Nonnull Property property) { - return registerReload(ConfigProperty.propertyInteger(this, property)); - } - - public static interface ConfigListener { - void onChanged(@Nonnull E value); - } - - public static abstract class ConfigProperty implements IReloadableConfig { - protected final @Nonnull Configuration config; - protected final @Nonnull Property property; - private transient @Nonnull E prop; - private @Nullable ConfigListener listener; - - protected ConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property, final @Nonnull E prop) { - this.config = config; - this.property = property; - this.prop = prop; - } - - public @Nonnull Property getProperty() { - return this.property; - } - - public @Nonnull ConfigProperty setListener(@Nullable final ConfigListener listener) { - this.listener = listener; - return this; - } - - protected void setProp(final @Nonnull E prop) { - if (!this.property.requiresMcRestart()) { - this.prop = prop; - if (this.listener!=null) - this.listener.onChanged(prop); - } - } - - public @Nonnull E get() { - return this.prop; - } - - public abstract @Nonnull ConfigProperty set(@Nonnull E value); - - public abstract @Nonnull ConfigProperty reset(); - - public static @Nonnull ConfigProperty propertyString(final @Nonnull ConfigBase config, final @Nonnull Property property) { - return new StringConfigProperty(config, property); - } - - public static @Nonnull ConfigProperty propertyBoolean(final @Nonnull ConfigBase config, final @Nonnull Property property) { - return new BooleanConfigProperty(config, property); - } - - public static @Nonnull ConfigProperty propertyDouble(final @Nonnull ConfigBase config, final @Nonnull Property property) { - return new DoubleConfigProperty(config, property); - } - - public static @Nonnull ConfigProperty propertyInteger(final @Nonnull ConfigBase config, final @Nonnull Property property) { - return new IntegerConfigProperty(config, property); - } - - private static class StringConfigProperty extends ConfigProperty { - protected StringConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property) { - super(config, property, property.getString()); - } - - @Override - public @Nonnull StringConfigProperty set(final @Nonnull String value) { - this.property.set(value); - setProp(value); - this.config.save(); - return this; - } - - @Override - public @Nonnull StringConfigProperty reset() { - final String p = this.property.getDefault(); - this.property.set(p); - setProp(p); - this.config.save(); - return this; - } - - @Override - public void reload() { - setProp(this.property.getString()); - } - } - - private static class BooleanConfigProperty extends ConfigProperty { - protected BooleanConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property) { - super(config, property, property.getBoolean()); - } - - @Override - public @Nonnull BooleanConfigProperty set(final @Nonnull Boolean value) { - this.property.set(value); - setProp(value); - this.config.save(); - return this; - } - - @Override - public @Nonnull BooleanConfigProperty reset() { - final String p = this.property.getDefault(); - this.property.set(p); - setProp(this.property.getBoolean()); - this.config.save(); - return this; - } - - @Override - public void reload() { - setProp(this.property.getBoolean()); - } - } - - private static class DoubleConfigProperty extends ConfigProperty { - protected DoubleConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property) { - super(config, property, property.getDouble()); - } - - @Override - public @Nonnull DoubleConfigProperty set(final @Nonnull Double value) { - this.property.set(value); - setProp(value); - this.config.save(); - return this; - } - - @Override - public @Nonnull DoubleConfigProperty reset() { - final String p = this.property.getDefault(); - this.property.set(p); - setProp(this.property.getDouble()); - this.config.save(); - return this; - } - - @Override - public void reload() { - setProp(this.property.getDouble()); - } - } - - private static class IntegerConfigProperty extends ConfigProperty { - protected IntegerConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property) { - super(config, property, property.getInt()); - } - - @Override - public @Nonnull IntegerConfigProperty set(final @Nonnull Integer value) { - this.property.set(value); - setProp(value); - this.config.save(); - return this; - } - - @Override - public @Nonnull IntegerConfigProperty reset() { - final String p = this.property.getDefault(); - this.property.set(p); - setProp(this.property.getInt()); - this.config.save(); - return this; - } - - @Override - public void reload() { - setProp(this.property.getInt()); - } - } - } +package net.teamfruit.serverobserver; + +import java.io.File; +import java.util.Collections; +import java.util.Set; +import java.util.WeakHashMap; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import org.apache.commons.lang3.StringUtils; + +import com.google.common.collect.Sets; + +import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.common.config.Property; + +public class ConfigBase extends Configuration { + private final @Nonnull Set configs = Sets.newHashSet(); + + public static interface IReloadableConfig { + void reload(); + } + + public @Nonnull T registerReload(final @Nonnull T config) { + this.configs.add(config); + return config; + } + + public void reload() { + for (final IReloadableConfig config : this.configs) + config.reload(); + } + + public static Set configChangeHandlers = Collections.newSetFromMap(new WeakHashMap()); + + public ConfigBase(final @Nonnull File configFile, final @Nonnull String version) { + super(configFile, version, true); + configChangeHandlers.add(this); + } + + @Override + public void save() { + if (hasChanged()) + super.save(); + } + + public void onConfigChanged(final @Nonnull String modid) { + if (StringUtils.equals(modid, Reference.MODID)) { + save(); + reload(); + } + } + + public @Nonnull ConfigProperty propertyString(final @Nonnull Property property) { + return registerReload(ConfigProperty.propertyString(this, property)); + } + + public @Nonnull ConfigProperty propertyBoolean(final @Nonnull Property property) { + return registerReload(ConfigProperty.propertyBoolean(this, property)); + } + + public @Nonnull ConfigProperty propertyDouble(final @Nonnull Property property) { + return registerReload(ConfigProperty.propertyDouble(this, property)); + } + + public @Nonnull ConfigProperty propertyInteger(final @Nonnull Property property) { + return registerReload(ConfigProperty.propertyInteger(this, property)); + } + + public static interface ConfigListener { + void onChanged(@Nonnull E value); + } + + public static abstract class ConfigProperty implements IReloadableConfig { + protected final @Nonnull Configuration config; + protected final @Nonnull Property property; + private transient @Nonnull E prop; + private @Nullable ConfigListener listener; + + protected ConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property, final @Nonnull E prop) { + this.config = config; + this.property = property; + this.prop = prop; + } + + public @Nonnull Property getProperty() { + return this.property; + } + + public @Nonnull ConfigProperty setListener(@Nullable final ConfigListener listener) { + this.listener = listener; + return this; + } + + protected void setProp(final @Nonnull E prop) { + if (!this.property.requiresMcRestart()) { + this.prop = prop; + if (this.listener!=null) + this.listener.onChanged(prop); + } + } + + public @Nonnull E get() { + return this.prop; + } + + public abstract @Nonnull ConfigProperty set(@Nonnull E value); + + public abstract @Nonnull ConfigProperty reset(); + + public static @Nonnull ConfigProperty propertyString(final @Nonnull ConfigBase config, final @Nonnull Property property) { + return new StringConfigProperty(config, property); + } + + public static @Nonnull ConfigProperty propertyBoolean(final @Nonnull ConfigBase config, final @Nonnull Property property) { + return new BooleanConfigProperty(config, property); + } + + public static @Nonnull ConfigProperty propertyDouble(final @Nonnull ConfigBase config, final @Nonnull Property property) { + return new DoubleConfigProperty(config, property); + } + + public static @Nonnull ConfigProperty propertyInteger(final @Nonnull ConfigBase config, final @Nonnull Property property) { + return new IntegerConfigProperty(config, property); + } + + private static class StringConfigProperty extends ConfigProperty { + protected StringConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property) { + super(config, property, property.getString()); + } + + @Override + public @Nonnull StringConfigProperty set(final @Nonnull String value) { + this.property.set(value); + setProp(value); + this.config.save(); + return this; + } + + @Override + public @Nonnull StringConfigProperty reset() { + final String p = this.property.getDefault(); + this.property.set(p); + setProp(p); + this.config.save(); + return this; + } + + @Override + public void reload() { + setProp(this.property.getString()); + } + } + + private static class BooleanConfigProperty extends ConfigProperty { + protected BooleanConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property) { + super(config, property, property.getBoolean()); + } + + @Override + public @Nonnull BooleanConfigProperty set(final @Nonnull Boolean value) { + this.property.set(value); + setProp(value); + this.config.save(); + return this; + } + + @Override + public @Nonnull BooleanConfigProperty reset() { + final String p = this.property.getDefault(); + this.property.set(p); + setProp(this.property.getBoolean()); + this.config.save(); + return this; + } + + @Override + public void reload() { + setProp(this.property.getBoolean()); + } + } + + private static class DoubleConfigProperty extends ConfigProperty { + protected DoubleConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property) { + super(config, property, property.getDouble()); + } + + @Override + public @Nonnull DoubleConfigProperty set(final @Nonnull Double value) { + this.property.set(value); + setProp(value); + this.config.save(); + return this; + } + + @Override + public @Nonnull DoubleConfigProperty reset() { + final String p = this.property.getDefault(); + this.property.set(p); + setProp(this.property.getDouble()); + this.config.save(); + return this; + } + + @Override + public void reload() { + setProp(this.property.getDouble()); + } + } + + private static class IntegerConfigProperty extends ConfigProperty { + protected IntegerConfigProperty(final @Nonnull Configuration config, final @Nonnull Property property) { + super(config, property, property.getInt()); + } + + @Override + public @Nonnull IntegerConfigProperty set(final @Nonnull Integer value) { + this.property.set(value); + setProp(value); + this.config.save(); + return this; + } + + @Override + public @Nonnull IntegerConfigProperty reset() { + final String p = this.property.getDefault(); + this.property.set(p); + setProp(this.property.getInt()); + this.config.save(); + return this; + } + + @Override + public void reload() { + setProp(this.property.getInt()); + } + } + } } \ No newline at end of file diff --git a/src/main/java/net/teamfruit/serverobserver/CoreEvent.java b/sources/universal/src/main/java/net/teamfruit/serverobserver/CoreEvent.java similarity index 95% rename from src/main/java/net/teamfruit/serverobserver/CoreEvent.java rename to sources/universal/src/main/java/net/teamfruit/serverobserver/CoreEvent.java index 2724130..f32c290 100644 --- a/src/main/java/net/teamfruit/serverobserver/CoreEvent.java +++ b/sources/universal/src/main/java/net/teamfruit/serverobserver/CoreEvent.java @@ -1,16 +1,16 @@ -package net.teamfruit.serverobserver; - -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Instead of Forge Subscribe Event - * @author Kamesuta - */ -@Target(value={METHOD}) -@Retention(value=RUNTIME) -public @interface CoreEvent { -} +package net.teamfruit.serverobserver; + +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.*; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +/** + * Instead of Forge Subscribe Event + * @author Kamesuta + */ +@Target(value={METHOD}) +@Retention(value=RUNTIME) +public @interface CoreEvent { +} diff --git a/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java b/sources/universal/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java similarity index 96% rename from src/main/java/net/teamfruit/serverobserver/DefaultServerList.java rename to sources/universal/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java index 4363f6c..b068ee0 100644 --- a/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java +++ b/sources/universal/src/main/java/net/teamfruit/serverobserver/DefaultServerList.java @@ -1,33 +1,33 @@ -package net.teamfruit.serverobserver; - -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStreamReader; -import java.util.List; - -import com.google.common.base.Charsets; -import com.google.gson.Gson; -import com.google.gson.stream.JsonReader; - -public class DefaultServerList { - public final Gson gson = new Gson(); - - public ServerListModel loadModel(final File file) { - if (file.exists()) - try (JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8))) { - return this.gson.fromJson(reader, ServerListModel.class); - } catch (final Exception e) { - Log.log.warn("Could not load "+file.getName(), e); - } - return null; - } - - public static class ServerListModel { - public List servers; - } - - public static class ServerModel { - public String serverName; - public String serverIP; - } -} +package net.teamfruit.serverobserver; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.util.List; + +import com.google.common.base.Charsets; +import com.google.gson.Gson; +import com.google.gson.stream.JsonReader; + +public class DefaultServerList { + public final Gson gson = new Gson(); + + public ServerListModel loadModel(final File file) { + if (file.exists()) + try (JsonReader reader = new JsonReader(new InputStreamReader(new FileInputStream(file), Charsets.UTF_8))) { + return this.gson.fromJson(reader, ServerListModel.class); + } catch (final Exception e) { + Log.log.warn("Could not load "+file.getName(), e); + } + return null; + } + + public static class ServerListModel { + public List servers; + } + + public static class ServerModel { + public String serverName; + public String serverIP; + } +} diff --git a/src/main/java/net/teamfruit/serverobserver/GuiHandler.java b/sources/universal/src/main/java/net/teamfruit/serverobserver/GuiHandler.java similarity index 100% rename from src/main/java/net/teamfruit/serverobserver/GuiHandler.java rename to sources/universal/src/main/java/net/teamfruit/serverobserver/GuiHandler.java diff --git a/src/main/java/net/teamfruit/serverobserver/ICompat.java b/sources/universal/src/main/java/net/teamfruit/serverobserver/ICompat.java similarity index 97% rename from src/main/java/net/teamfruit/serverobserver/ICompat.java rename to sources/universal/src/main/java/net/teamfruit/serverobserver/ICompat.java index a49de97..966b1f5 100644 --- a/src/main/java/net/teamfruit/serverobserver/ICompat.java +++ b/sources/universal/src/main/java/net/teamfruit/serverobserver/ICompat.java @@ -1,66 +1,66 @@ -package net.teamfruit.serverobserver; - -import java.net.SocketAddress; -import java.util.List; -import java.util.concurrent.ThreadPoolExecutor; - -import javax.annotation.Nonnull; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiDisconnected; -import net.minecraft.client.gui.GuiMultiplayer; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.client.multiplayer.ServerList; -import net.minecraft.network.NetworkManager; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; -import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; -import net.teamfruit.serverobserver.GuiHandler.SkeletonButtonDrawInside; - -public interface ICompat { - - void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha); - - List getButtonList(InitGuiEvent e); - - FontRenderer font(Minecraft mc); - - int getHeight(GuiDisconnected dcgui); - - GuiScreen getParentScreen(GuiDisconnected dcgui); - - GuiButton getButton(ActionPerformedEvent e); - - int getSelected(GuiMultiplayer mpgui); - - void connectToServer(GuiScreen mpgui, @Nonnull ServerData serverData); - - boolean getPinged(@Nonnull ServerData serverData); - - void setPinged(@Nonnull ServerData serverData, boolean pinged); - - void ping(GuiMultiplayer mpgui, @Nonnull ServerData serverData) throws Exception; - - String getDefaultSound(); - - void playSound(Minecraft mc, ResourceLocation sound, float pitch); - - void selectServer(GuiMultiplayer mpgui, int index); - - @Deprecated - ServerData getServerData(GuiMultiplayer mpgui, int index); - - ServerList getServerList(GuiMultiplayer mpgui); - - GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside); - - ThreadPoolExecutor getThreadPool(); - - NetworkManager getClientToServerNetworkManager(); - - SocketAddress getSocketAddress(NetworkManager netManager); - +package net.teamfruit.serverobserver; + +import java.net.SocketAddress; +import java.util.List; +import java.util.concurrent.ThreadPoolExecutor; + +import javax.annotation.Nonnull; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiDisconnected; +import net.minecraft.client.gui.GuiMultiplayer; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.client.multiplayer.ServerList; +import net.minecraft.network.NetworkManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent; +import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent; +import net.teamfruit.serverobserver.GuiHandler.SkeletonButtonDrawInside; + +public interface ICompat { + + void color(float colorRed, float colorGreen, float colorBlue, float colorAlpha); + + List getButtonList(InitGuiEvent e); + + FontRenderer font(Minecraft mc); + + int getHeight(GuiDisconnected dcgui); + + GuiScreen getParentScreen(GuiDisconnected dcgui); + + GuiButton getButton(ActionPerformedEvent e); + + int getSelected(GuiMultiplayer mpgui); + + void connectToServer(GuiScreen mpgui, @Nonnull ServerData serverData); + + boolean getPinged(@Nonnull ServerData serverData); + + void setPinged(@Nonnull ServerData serverData, boolean pinged); + + void ping(GuiMultiplayer mpgui, @Nonnull ServerData serverData) throws Exception; + + String getDefaultSound(); + + void playSound(Minecraft mc, ResourceLocation sound, float pitch); + + void selectServer(GuiMultiplayer mpgui, int index); + + @Deprecated + ServerData getServerData(GuiMultiplayer mpgui, int index); + + ServerList getServerList(GuiMultiplayer mpgui); + + GuiButton createSkeletonButton(final int buttonId, final int x, final int y, final int widthIn, final int heightIn, final String buttonText, final SkeletonButtonDrawInside inside); + + ThreadPoolExecutor getThreadPool(); + + NetworkManager getClientToServerNetworkManager(); + + SocketAddress getSocketAddress(NetworkManager netManager); + } \ No newline at end of file diff --git a/src/main/resources/assets/serverobserver/lang/en_US.lang b/sources/universal/src/main/resources/assets/serverobserver/lang/en_US.lang similarity index 100% rename from src/main/resources/assets/serverobserver/lang/en_US.lang rename to sources/universal/src/main/resources/assets/serverobserver/lang/en_US.lang diff --git a/src/main/resources/assets/serverobserver/lang/ja_JP.lang b/sources/universal/src/main/resources/assets/serverobserver/lang/ja_JP.lang similarity index 100% rename from src/main/resources/assets/serverobserver/lang/ja_JP.lang rename to sources/universal/src/main/resources/assets/serverobserver/lang/ja_JP.lang diff --git a/src/main/resources/assets/serverobserver/lang/ru_RU.lang b/sources/universal/src/main/resources/assets/serverobserver/lang/ru_RU.lang similarity index 98% rename from src/main/resources/assets/serverobserver/lang/ru_RU.lang rename to sources/universal/src/main/resources/assets/serverobserver/lang/ru_RU.lang index 394720d..aace212 100644 --- a/src/main/resources/assets/serverobserver/lang/ru_RU.lang +++ b/sources/universal/src/main/resources/assets/serverobserver/lang/ru_RU.lang @@ -1,32 +1,32 @@ - -serverobserver.gui.mode.1=§eАвтоЛогин %s -serverobserver.gui.mode.2=§aНаблюдать %s -serverobserver.gui.mode.3=§cОтключено -serverobserver.gui.nextping= §7Проверка: %s -serverobserver.gui.nextconnect= §7Подключение, через: %s -serverobserver.gui.maintomulti.time=%s: %s -serverobserver.gui.backandstop=Назад и Стоп -serverobserver.gui.backandstop.time=%s: %s -serverobserver.config=ServerObserver Настройки -serverobserver.config.observetarget=Мониторинг Сервера -serverobserver.config.observetarget.tooltip=Напомнить про мониторинг -serverobserver.config.observetarget.serverip=IP Сервера -serverobserver.config.observetarget.serverip.tooltip=IP Сервера для мониторинга -serverobserver.config.observetarget.autologin=Авто Логин -serverobserver.config.observetarget.autologin.tooltip=Режим Авто Логина -serverobserver.config.duration=Продолжительность -serverobserver.config.duration.tooltip=Установите время, такое как интервал пинга -serverobserver.config.duration.mainmenu=Время Главное Меню→Мультиплеер -serverobserver.config.duration.mainmenu.tooltip=Время, пока меню мультиплеера не появится после запуска Minecraft (недействительный с 0) -serverobserver.config.duration.ping=Длительность Ping -serverobserver.config.duration.ping.tooltip=Частота обновления Ping (минимум: 10 секунд) -serverobserver.config.duration.autologin=Время Авто Логина -serverobserver.config.duration.autologin.tooltip=Время до автоматического логина (минимум: 10 секунд) -serverobserver.config.duration.disconnected=Время после Дисконекта→Мультиплеера -serverobserver.config.duration.disconnected.tooltip=Время от GUI отключения до отображения GUI мультиплеера (Минимум: 10 секунд, менее 10 не вернется к GUI мультиплеера) -serverobserver.config.notification=Уведомление -serverobserver.config.notification.tooltip=Звуковое уведомление -serverobserver.config.notification.sound=Звук -serverobserver.config.notification.sound.tooltip=Расположение звукового файла -serverobserver.config.notification.pitch=Питч -serverobserver.config.notification.pitch.tooltip=Громкость звука (минимум: 0.0, максимум: 2.0) + +serverobserver.gui.mode.1=§eАвтоЛогин %s +serverobserver.gui.mode.2=§aНаблюдать %s +serverobserver.gui.mode.3=§cОтключено +serverobserver.gui.nextping= §7Проверка: %s +serverobserver.gui.nextconnect= §7Подключение, через: %s +serverobserver.gui.maintomulti.time=%s: %s +serverobserver.gui.backandstop=Назад и Стоп +serverobserver.gui.backandstop.time=%s: %s +serverobserver.config=ServerObserver Настройки +serverobserver.config.observetarget=Мониторинг Сервера +serverobserver.config.observetarget.tooltip=Напомнить про мониторинг +serverobserver.config.observetarget.serverip=IP Сервера +serverobserver.config.observetarget.serverip.tooltip=IP Сервера для мониторинга +serverobserver.config.observetarget.autologin=Авто Логин +serverobserver.config.observetarget.autologin.tooltip=Режим Авто Логина +serverobserver.config.duration=Продолжительность +serverobserver.config.duration.tooltip=Установите время, такое как интервал пинга +serverobserver.config.duration.mainmenu=Время Главное Меню→Мультиплеер +serverobserver.config.duration.mainmenu.tooltip=Время, пока меню мультиплеера не появится после запуска Minecraft (недействительный с 0) +serverobserver.config.duration.ping=Длительность Ping +serverobserver.config.duration.ping.tooltip=Частота обновления Ping (минимум: 10 секунд) +serverobserver.config.duration.autologin=Время Авто Логина +serverobserver.config.duration.autologin.tooltip=Время до автоматического логина (минимум: 10 секунд) +serverobserver.config.duration.disconnected=Время после Дисконекта→Мультиплеера +serverobserver.config.duration.disconnected.tooltip=Время от GUI отключения до отображения GUI мультиплеера (Минимум: 10 секунд, менее 10 не вернется к GUI мультиплеера) +serverobserver.config.notification=Уведомление +serverobserver.config.notification.tooltip=Звуковое уведомление +serverobserver.config.notification.sound=Звук +serverobserver.config.notification.sound.tooltip=Расположение звукового файла +serverobserver.config.notification.pitch=Питч +serverobserver.config.notification.pitch.tooltip=Громкость звука (минимум: 0.0, максимум: 2.0) diff --git a/src/main/resources/assets/serverobserver/textures/banner.png b/sources/universal/src/main/resources/assets/serverobserver/textures/banner.png similarity index 100% rename from src/main/resources/assets/serverobserver/textures/banner.png rename to sources/universal/src/main/resources/assets/serverobserver/textures/banner.png diff --git a/src/main/resources/assets/serverobserver/textures/logo.png b/sources/universal/src/main/resources/assets/serverobserver/textures/logo.png similarity index 100% rename from src/main/resources/assets/serverobserver/textures/logo.png rename to sources/universal/src/main/resources/assets/serverobserver/textures/logo.png diff --git a/src/main/resources/mcmod.info b/sources/universal/src/main/resources/mcmod.info similarity index 96% rename from src/main/resources/mcmod.info rename to sources/universal/src/main/resources/mcmod.info index 7adc7db..8a6f3f2 100644 --- a/src/main/resources/mcmod.info +++ b/sources/universal/src/main/resources/mcmod.info @@ -1,25 +1,25 @@ -{ - "modListVersion": 2, - "modList": [ - { - "modid": "serverobserver", - "name": "ServerObserver", - "description": "Observe Minecraft Server Status", - "mcversion": "", - "version": "", - "authorList": [ - "Kamesuta" - ], - "credits": "2017 TeamFruit", - "dependants": [], - "dependencies": ["Forge"], - "parent": "", - "requiredMods": ["Forge"], - "logoFile": "assets/serverobserver/textures/banner.png", - "screenshots": [], - "updateUrl": "https://github.com/Team-Fruit/ServerObserver/releases", - "url": "https://minecraft.curseforge.com/projects/serverobserver", - "useDependencyInformation": false - } - ] +{ + "modListVersion": 2, + "modList": [ + { + "modid": "serverobserver", + "name": "ServerObserver", + "description": "Observe Minecraft Server Status", + "mcversion": "", + "version": "", + "authorList": [ + "Kamesuta" + ], + "credits": "2017 TeamFruit", + "dependants": [], + "dependencies": ["Forge"], + "parent": "", + "requiredMods": ["Forge"], + "logoFile": "assets/serverobserver/textures/banner.png", + "screenshots": [], + "updateUrl": "https://github.com/Team-Fruit/ServerObserver/releases", + "url": "https://minecraft.curseforge.com/projects/serverobserver", + "useDependencyInformation": false + } + ] } \ No newline at end of file