diff --git a/TASK.md b/TASK.md index 794f5760..cc2f0383 100644 --- a/TASK.md +++ b/TASK.md @@ -5,7 +5,7 @@ _If you have any idea for this project, please make an issue and post to this pr - [x] Auto Sign Create GUI - [ ] Auto Image Upload to online such as Gyazo - [ ] 短縮URL bitly, goo.gl... -- [ ] Config +- [x] Config - [x] Blend func problem (transparent png, playernames...) - [x] Thread Pool - [x] Load Faster @@ -14,4 +14,9 @@ _If you have any idea for this project, please make an issue and post to this pr - [x] テキストボックスメタ情報優先化 - [x] 回転構文 - [x] PlaceModeリフレクションエラーの時のPlaceモード使用不可表示 -- [ ] Waila \ No newline at end of file +- [ ] Waila +- [ ] ロードリトライ +- [ ] 制限プラグイン +- [ ] 曲 +- [ ] チャット画像 +- [ ] アイテム画像変更 \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index b7511886..9ccd6e72 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ modid=signpic modname=SignPicture version_major=2 version_minor=3 -version_micro=0 +version_micro=1 version_minecraft=1.10.2 version_forge=12.18.1.2011 version_minforge=12.18.1.2011 diff --git a/info/info.json b/info/info.json index 57619602..09e1c1e5 100644 --- a/info/info.json +++ b/info/info.json @@ -10,32 +10,34 @@ } }, "1.8.9": { - "version": "2.2.2", - "remote": "https://github.com/Team-Fruit/SignPicture/releases/download/1.8.9-2.2.2/SignPicture-1.8.9-2.2.2-universal.jar", - "local": "SignPicture-1.8.9-2.2.2-universal.jar", - "message": "Offset And Rotations! More freely images! SignPicture 2.2.2 Released!", + "version": "2.3.0", + "remote": "https://github.com/Team-Fruit/SignPicture/releases/download/1.8.9-2.3.0/SignPicture-1.8.9-2.3.0-universal.jar", + "local": "SignPicture-1.8.9-2.3.0-universal.jar", + "message": "Config & Prevent Anti-AutoSign Mode added. SignPicture 2.3.0 Released.", "message_local": { - "ja_JP": "オフセットと回転機能実装! さらに自由自在に画像を貼ろう! SignPicture 2.2.2 リリース!" + "ja_JP": "Anti-AutoSign回避モードとコンフィグの追加 SignPicture 2.3.0 リリース!" } }, "1.9.4": { - "version": "2.1.5", - "remote": "https://github.com/Team-Fruit/SignPicture/releases/download/1.9.4-2.1.5/SignPicture-1.9.4-2.1.5-universal.jar", - "local": "SignPicture-1.9.4-2.1.5-universal.jar", - "message": "GUI Update! SignPicture 2.1.5 Released!", + "version": "2.3.0", + "remote": "https://github.com/Team-Fruit/SignPicture/releases/download/1.9.4-2.3.0/SignPicture-1.9.4-2.3.0-universal.jar", + "local": "SignPicture-1.9.4-2.3.0-universal.jar", + "message": "Config & Prevent Anti-AutoSign Mode added. SignPicture 2.3.0 Released.", "message_local": { - "ja_JP": "遂にSignPictureにGUIが! SignPicture 2.1.5リリース!!" + "ja_JP": "Anti-AutoSign回避モードとコンフィグの追加 SignPicture 2.3.0 リリース!" } }, "1.10.2": { - "version": "2.1.5", - "remote": "https://github.com/Team-Fruit/SignPicture/releases/download/1.10.2-2.1.5/SignPicture-1.10.2-2.1.5-universal.jar", - "local": "SignPicture-1.10.2-2.1.5-universal.jar", - "message": "GUI Update! SignPicture 2.1.5 Released!", + "version": "2.3.0", + "remote": "https://github.com/Team-Fruit/SignPicture/releases/download/1.10.2-2.3.0/SignPicture-1.10.2-2.3.0-universal.jar", + "local": "SignPicture-1.10.2-2.3.0-universal.jar", + "message": "Config & Prevent Anti-AutoSign Mode added. SignPicture 2.3.0 Released.", "message_local": { - "ja_JP": "遂にSignPictureにGUIが! SignPicture 2.1.5リリース!!" + "ja_JP": "Anti-AutoSign回避モードとコンフィグの追加 SignPicture 2.3.0 リリース!" } } }, + "website": "https://github.com/Kamesuta/SignPicture/", + "changelog": "https://github.com/Kamesuta/SignPicture/releases", "private_msg": "http://fruit.bebehp.com/signpic.php/msg?id=%id%&name=%name%&vmod=%modversion%&vmodmc=%modmcversion%&vmodforge=%modforgeversion%&vmc=%mcversion%&vforge=%forgeversion%" } diff --git a/src/main/java/com/kamesuta/mc/signpic/information/Info.java b/src/main/java/com/kamesuta/mc/signpic/information/Info.java index c9e56228..0ae9252d 100644 --- a/src/main/java/com/kamesuta/mc/signpic/information/Info.java +++ b/src/main/java/com/kamesuta/mc/signpic/information/Info.java @@ -4,6 +4,8 @@ public class Info { public Map versions; + public String website; + public String changelog; public String private_msg; public static class Version { public String version; @@ -11,6 +13,8 @@ public static class Version { public String local; public String message; public Map message_local; + public String website; + public String changelog; } public static class PrivateMsg { public boolean json; diff --git a/src/main/java/com/kamesuta/mc/signpic/information/InformationChecker.java b/src/main/java/com/kamesuta/mc/signpic/information/InformationChecker.java index 66eac293..e6e4e0ba 100644 --- a/src/main/java/com/kamesuta/mc/signpic/information/InformationChecker.java +++ b/src/main/java/com/kamesuta/mc/signpic/information/InformationChecker.java @@ -17,6 +17,7 @@ public final class InformationChecker { public static InfoState state = new InfoState(); public static class InfoState { + public Info info; public Info.Version onlineVersion; public Info.Version stableVersion; public Info.Version unstableVersion; @@ -31,8 +32,13 @@ public void onTick() { final EntityPlayer player = Client.mc.thePlayer; if(this.doneChecking && player != null && !this.triedToWarnPlayer) { final String lang = Client.mc.gameSettings.language; - if (Config.instance.informationNotice && !StringUtils.equals(Reference.VERSION, "${version}")) { + if (this.info!=null && Config.instance.informationNotice && !StringUtils.equals(Reference.VERSION, "${version}")) { try { + if (this.info.versions!=null) { + this.stableVersion = this.info.versions.get(Client.mcversion); + this.unstableVersion = this.info.versions.get(Client.mcversion + "-beta"); + } + final String[] client = Reference.VERSION.split("\\."); if (client.length>=3) { final int clientBuild1 = Integer.parseInt(client[0]); @@ -72,12 +78,27 @@ public void onTick() { } if(betaneedupdate || needupdate) { + ChatBuilder.create("signpic.versioning.outdated").setParams(Reference.VERSION, this.onlineVersion.version).useTranslation().chatClient(); if (this.onlineVersion.message_local!=null && this.onlineVersion.message_local.containsKey(lang)) ChatBuilder.create(this.onlineVersion.message_local.get(lang)).chatClient(); else if (!StringUtils.isEmpty(this.onlineVersion.message)) ChatBuilder.create(this.onlineVersion.message).chatClient(); - ChatBuilder.create("signpic.versioning.outdated").setParams(Reference.VERSION, this.onlineVersion.version).useTranslation().chatClient(); - ChatBuilder.create("signpic.versioning.updateMessage").useTranslation().useJson().chatClient();; + + final String website; + if (this.onlineVersion.website!=null) website = this.onlineVersion.website; + else if (this.info.website!=null) website = this.info.website; + else website = "https://github.com/Kamesuta/SignPicture/"; + + final String changelog; + if (this.onlineVersion.changelog!=null) changelog = this.onlineVersion.changelog; + else if (this.info.changelog!=null) changelog = this.info.changelog; + else changelog = "https://github.com/Kamesuta/SignPicture/releases"; + + ChatBuilder.create("signpic.versioning.updateMessage").useTranslation().useJson() + .replace("$download$", "{\"action\":\"run_command\",\"value\":\"/signpic-download-latest\"}") + .replace("$website$", "{\"action\":\"open_url\",\"value\":\"" + website + "\"}") + .replace("$changelog$", "{\"action\":\"open_url\",\"value\":\"" + changelog + "\"}") + .chatClient(); } } } diff --git a/src/main/java/com/kamesuta/mc/signpic/information/ThreadInformationChecker.java b/src/main/java/com/kamesuta/mc/signpic/information/ThreadInformationChecker.java index d506d96a..41fd3f1c 100644 --- a/src/main/java/com/kamesuta/mc/signpic/information/ThreadInformationChecker.java +++ b/src/main/java/com/kamesuta/mc/signpic/information/ThreadInformationChecker.java @@ -36,17 +36,13 @@ public void run() { final HttpResponse response = Downloader.downloader.client.execute(req); final HttpEntity entity = response.getEntity(); input = entity.getContent(); - final Info info = gson.fromJson(new JsonReader(new InputStreamReader(input, CharEncoding.UTF_8)), Info.class); - if (info!=null) { - if (info.versions!=null) { - state.stableVersion = info.versions.get(Client.mcversion); - state.unstableVersion = info.versions.get(Client.mcversion + "-beta"); - } - if (!StringUtils.isEmpty(info.private_msg)) { + state.info = gson.fromJson(new JsonReader(new InputStreamReader(input, CharEncoding.UTF_8)), Info.class); + if (state.info!=null) { + if (!StringUtils.isEmpty(state.info.private_msg)) { InputStream input1 = null; try { if (!StringUtils.isEmpty(Client.name) && !StringUtils.isEmpty(Client.id)) { - final String msgurl = info.private_msg + final String msgurl = state.info.private_msg .replace("%name%", Client.name) .replace("%id%", Client.id) .replace("%mcversion%", Client.mcversion) diff --git a/src/main/java/com/kamesuta/mc/signpic/proxy/ClientProxy.java b/src/main/java/com/kamesuta/mc/signpic/proxy/ClientProxy.java index e85b7052..27fc38ff 100644 --- a/src/main/java/com/kamesuta/mc/signpic/proxy/ClientProxy.java +++ b/src/main/java/com/kamesuta/mc/signpic/proxy/ClientProxy.java @@ -2,7 +2,6 @@ import java.io.File; import java.io.IOException; -import java.util.Map; import com.kamesuta.mc.signpic.Client; import com.kamesuta.mc.signpic.Reference; @@ -12,13 +11,11 @@ import com.kamesuta.mc.signpic.render.CustomTileEntitySignRenderer; import com.mojang.util.UUIDTypeAdapter; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntitySign; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; @@ -108,9 +105,7 @@ public void init(final FMLInitializationEvent event) { super.init(event); // Replace Sign Renderer - Client.renderer.setRendererDispatcher(TileEntityRendererDispatcher.instance); - final Map, TileEntitySpecialRenderer> renderers = TileEntityRendererDispatcher.instance.mapSpecialRenderers; - renderers.put(TileEntitySign.class, Client.renderer); + ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySign.class, Client.renderer); // Event Register Client.handler.init(); diff --git a/src/main/java/com/kamesuta/mc/signpic/render/CustomTileEntitySignRenderer.java b/src/main/java/com/kamesuta/mc/signpic/render/CustomTileEntitySignRenderer.java index 903ffb7d..c0c97ab2 100644 --- a/src/main/java/com/kamesuta/mc/signpic/render/CustomTileEntitySignRenderer.java +++ b/src/main/java/com/kamesuta/mc/signpic/render/CustomTileEntitySignRenderer.java @@ -104,28 +104,27 @@ public void renderSignPicture(final Entry entry, final int destroy, final float } public void translateBase(final TileEntitySign tile, final double x, final double y, final double z, final float rotateratio) { - // Vanilla Translate - final Block block = tile.getBlockType(); - GlStateManager.pushMatrix(); - final float f1 = 0.6666667F; - float f3; - - if (block == Blocks.STANDING_SIGN) { - GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F * f1, (float)z + 0.5F); - final float f2 = tile.getBlockMetadata() * 360 / 16.0F; - GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F); - } else { - final int j = tile.getBlockMetadata(); - f3 = 0.0F; - - if (j == 2) f3 = 180.0F; - if (j == 4) f3 = 90.0F; - if (j == 5) f3 = -90.0F; - - GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F * f1, (float)z + 0.5F); - GlStateManager.rotate(-f3, 0.0F, 1.0F, 0.0F); - GlStateManager.translate(0.0F, 0.0F, -0.4375F); - } + // Vanilla Translate + final Block block = tile.getBlockType(); + final float f1 = 0.6666667F; + float f3; + + if (block == Blocks.STANDING_SIGN) { + GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F * f1, (float)z + 0.5F); + final float f2 = tile.getBlockMetadata() * 360 / 16.0F; + GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F); + } else { + final int j = tile.getBlockMetadata(); + f3 = 0.0F; + + if (j == 2) f3 = 180.0F; + if (j == 4) f3 = 90.0F; + if (j == 5) f3 = -90.0F; + + GlStateManager.translate((float)x + 0.5F, (float)y + 0.75F * f1, (float)z + 0.5F); + GlStateManager.rotate(-f3, 0.0F, 1.0F, 0.0F); + GlStateManager.translate(0.0F, 0.0F, -0.4375F); + } } public void renderSignPictureBase(final TileEntitySign tile, final double x, final double y, final double z, final float partialTicks, final int destroy, final float opacity) { @@ -164,6 +163,7 @@ public void renderTileEntityAt(final TileEntitySign tile, final double x, final { Client.startSection("signpic-render"); renderSignPictureBase(tile, x, y, z, partialTicks, destroy, 1f); + //super.renderTileEntityAt(tile, x, y, z, partialTicks, destroy); Client.endSection(); } diff --git a/src/main/java/com/kamesuta/mc/signpic/util/ChatBuilder.java b/src/main/java/com/kamesuta/mc/signpic/util/ChatBuilder.java index dc9d83df..13a40b56 100644 --- a/src/main/java/com/kamesuta/mc/signpic/util/ChatBuilder.java +++ b/src/main/java/com/kamesuta/mc/signpic/util/ChatBuilder.java @@ -1,6 +1,10 @@ package com.kamesuta.mc.signpic.util; -import com.google.gson.JsonSyntaxException; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; + +import com.google.common.collect.Maps; import com.kamesuta.mc.signpic.Client; import net.minecraft.client.Minecraft; @@ -24,6 +28,7 @@ public class ChatBuilder { private boolean useTranslation = false; private boolean useJson = false; private boolean useId = false; + private final Map replace = Maps.newHashMap(); private int id = -1; public ChatBuilder() {} @@ -36,14 +41,20 @@ public ITextComponent build() { else { String s; if (this.useTranslation) { - s = String.format(translateToLocal(this.text), this.params); + s = translateToLocal(this.text); } else s = this.text; + for (final Map.Entry entry: this.replace.entrySet()) + s = StringUtils.replace(s, entry.getKey(), entry.getValue()); + + if (this.params.length>0) + s = String.format(s, this.params); + if (this.useJson) try { chat = ITextComponent.Serializer.jsonToComponent(s); - } catch (final JsonSyntaxException e) { + } catch (final Exception e) { chat = new TextComponentString("Invaild Json: " + this.text); } else @@ -63,6 +74,10 @@ public static String translateToLocal(final String text) { return net.minecraft.util.text.translation.I18n.translateToLocal(text); } + public boolean isEmpty() { + return StringUtils.isEmpty(this.text) && (this.chat==null || StringUtils.isEmpty(this.chat.getUnformattedText())); + } + public ChatBuilder setId(final int id) { this.useId = true; this.id = id; @@ -104,13 +119,19 @@ public ChatBuilder useJson() { return this; } + public ChatBuilder replace(final String from, final String to) { + this.replace.put(from, to); + return this; + } + public static ChatBuilder create(final String text) { return new ChatBuilder().setText(text); } @SideOnly(Side.CLIENT) public void chatClient() { - chatClient(this); + if (!isEmpty()) + chatClient(this); } @SideOnly(Side.CLIENT) diff --git a/src/main/resources/assets/signpic/lang/en_US.lang b/src/main/resources/assets/signpic/lang/en_US.lang index 49e8f4ee..145521af 100644 --- a/src/main/resources/assets/signpic/lang/en_US.lang +++ b/src/main/resources/assets/signpic/lang/en_US.lang @@ -83,7 +83,7 @@ signpic.advmsg.unknown=Unknown Error: §7%s # Version Checking signpic.versioning.outdated=[§6SignPicture§r] You are running Sign Picture %s, the latest is %s. -signpic.versioning.updateMessage=["Click for... [",{"text":"Download","color":"green","hoverEvent":{"action":"show_text","value":{"text":"Click this to automatically download the latest version","color":"green"}},"clickEvent":{"action":"run_command","value":"/signpic-download-latest"}},"] [",{"text":"Website","color":"green","hoverEvent":{"action":"show_text","value":{"text":"Click this to go to the mod's website","color":"green"}},"clickEvent":{"action":"open_url","value":"https://github.com/Kamesuta/SignPicture/"}},"] [",{"text":"Changelog","color":"green","hoverEvent":{"action":"show_text","value":{"text":"Click this to go to the version's Changelog","color":"green"}},"clickEvent":{"action":"open_url","value":"https://github.com/Kamesuta/SignPicture/releases"}},"]"] +signpic.versioning.updateMessage=["Click for... [",{"text":"Download","color":"green","hoverEvent":{"action":"show_text","value":{"text":"Click this to automatically download the latest version","color":"green"}},"clickEvent":$download$},"] [",{"text":"Website","color":"green","hoverEvent":{"action":"show_text","value":{"text":"Click this to go to the mod's website","color":"green"}},"clickEvent":$website$},"] [",{"text":"Changelog","color":"green","hoverEvent":{"action":"show_text","value":{"text":"Click this to go to the version's Changelog","color":"green"}},"clickEvent":$changelog$},"]"] signpic.versioning.startingDownload=[{"text":"Starting download of %s. Please do not remove your hard disk. Enjoying ","color":"aqua"}] signpic.versioning.downloading=Now Downloading... %s%% (%s / %s bytes) signpic.versioning.doneDownloading=Finished downloading %s. Delete your old SignPicture .jar and reload your game to update. diff --git a/src/main/resources/assets/signpic/lang/ja_JP.lang b/src/main/resources/assets/signpic/lang/ja_JP.lang index 4b1fa9aa..9d36e6d3 100644 --- a/src/main/resources/assets/signpic/lang/ja_JP.lang +++ b/src/main/resources/assets/signpic/lang/ja_JP.lang @@ -48,7 +48,7 @@ signpic.advmsg.unknown=不明なエラー: §7%s # Version Checking signpic.versioning.outdated=[§6SignPicture§r] 現在のSignPictureのバージョンは %s です。新しいバージョン %s がご利用可能です! -signpic.versioning.updateMessage=["[",{"text":"ダウンロード","color":"green","hoverEvent":{"action":"show_text","value":{"text":"自動的に最新バージョンをダウンロードします","color":"green"}},"clickEvent":{"action":"run_command","value":"/signpic-download-latest"}},"] [",{"text":"ウェブサイト","color":"green","hoverEvent":{"action":"show_text","value":{"text":"ウェブサイトへ","color":"green"}},"clickEvent":{"action":"open_url","value":"https://github.com/Kamesuta/SignPicture/"}},"] [",{"text":"チェンジログ","color":"green","hoverEvent":{"action":"show_text","value":{"text":"更新履歴を見る","color":"green"}},"clickEvent":{"action":"open_url","value":"https://github.com/Kamesuta/SignPicture/releases"}},"]"] +signpic.versioning.updateMessage=["[",{"text":"ダウンロード","color":"green","hoverEvent":{"action":"show_text","value":{"text":"自動的に最新バージョンをダウンロードします","color":"green"}},"clickEvent":$download$},"] [",{"text":"ウェブサイト","color":"green","hoverEvent":{"action":"show_text","value":{"text":"ウェブサイトへ","color":"green"}},"clickEvent":$website$},"] [",{"text":"チェンジログ","color":"green","hoverEvent":{"action":"show_text","value":{"text":"更新履歴を見る","color":"green"}},"clickEvent":$changelog$},"]"] signpic.versioning.startingDownload=[{"text":"ダウンロード開始 %s","color":"aqua"}] signpic.versioning.downloading=ダウンロード中... %s%% (%s / %s バイト) signpic.versioning.doneDownloading=ダウンロード完了 %s 適用するためには古いSignPictureの.jarファイルを消し、Minecraftを再起動してください