diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/torui/coflsky/CoflSky.java | 41 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/EventRegistry.java | 26 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/WSCommandHandler.java | 6 | ||||
-rw-r--r-- | src/main/resources/assets/coflsky/lang/en_US.lang | 2 |
4 files changed, 54 insertions, 21 deletions
diff --git a/src/main/java/de/torui/coflsky/CoflSky.java b/src/main/java/de/torui/coflsky/CoflSky.java index 0fb0927..cc762ca 100644 --- a/src/main/java/de/torui/coflsky/CoflSky.java +++ b/src/main/java/de/torui/coflsky/CoflSky.java @@ -1,38 +1,21 @@ package de.torui.coflsky; -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URI; import java.net.URISyntaxException; -import java.net.URL; import java.util.UUID; -import com.google.gson.JsonArray; -import com.google.gson.stream.JsonReader; +import org.lwjgl.input.Keyboard; import de.torui.coflsky.minecraft_integration.PlayerDataProvider; import de.torui.coflsky.minecraft_integration.TemporarySession; -import de.torui.coflsky.websocket.WSClient; import de.torui.coflsky.websocket.WSClientWrapper; -import net.minecraft.client.Minecraft; -import net.minecraft.init.Blocks; +import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; -import net.minecraftforge.fml.common.event.FMLServerStartingEvent; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; -import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent; import net.minecraftforge.fml.relauncher.Side; @Mod(modid = CoflSky.MODID, version = CoflSky.VERSION) @@ -40,7 +23,11 @@ public class CoflSky { public static final String MODID = "CoflSky"; public static final String VERSION = "1.1-Alpha"; + public static WSClientWrapper Wrapper; + public static KeyBinding[] keyBindings; + + @EventHandler public void init(FMLInitializationEvent event) throws URISyntaxException @@ -78,8 +65,20 @@ public class CoflSky //CoflSky.Wrapper = new WSClientWrapper("wss://sky-commands.coflnet.com/modsocket?version=" + CoflSky.VERSION + "&uuid="); CoflSky.Wrapper = new WSClientWrapper("ws://sky-mod.coflnet.com/modsocket?version=" + CoflSky.VERSION + "&SId=" + tempUUID + "&uuid=" + uuid); - if(event.getSide() == Side.CLIENT) + keyBindings = new KeyBinding[] { + new KeyBinding("key.replay_last.onclick", Keyboard.KEY_R, "SkyCofl") + }; + + if(event.getSide() == Side.CLIENT) { ClientCommandHandler.instance.registerCommand(new CoflSkyCommand()); + + for (int i = 0; i < keyBindings.length; ++i) + { + ClientRegistry.registerKeyBinding(keyBindings[i]); + } + + + } MinecraftForge.EVENT_BUS.register(new EventRegistry()); } diff --git a/src/main/java/de/torui/coflsky/EventRegistry.java b/src/main/java/de/torui/coflsky/EventRegistry.java index 06f94cd..a05e213 100644 --- a/src/main/java/de/torui/coflsky/EventRegistry.java +++ b/src/main/java/de/torui/coflsky/EventRegistry.java @@ -7,12 +7,16 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.gui.MinecraftServerGui; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.client.FMLClientHandler; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.server.FMLServerHandler; public class EventRegistry{ @@ -46,6 +50,28 @@ public class EventRegistry{ CoflSky.Wrapper.stop(); System.out.println("CoflSky stopped"); } + + + + @SideOnly(Side.CLIENT) + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) + public void onEvent(KeyInputEvent event) { + + if(CoflSky.keyBindings[0].isPressed()) { + //System.out.println(">>>>> Key Pressed"); + + if(WSCommandHandler.lastOnClickEvent != null) { + + String command = WSCommandHandler.lastOnClickEvent; + WSCommandHandler.lastOnClickEvent = null; + //System.out.println(">>>>> HasLastONClickEvent = " + command); + Minecraft.getMinecraft().thePlayer.sendChatMessage(command); + } + + + } + + } /*@SubscribeEvent public void OnSomething(FMLNetworkEvent.ClientConnectedToServerEvent event) { System.out.println("Client connect to server from network"); diff --git a/src/main/java/de/torui/coflsky/WSCommandHandler.java b/src/main/java/de/torui/coflsky/WSCommandHandler.java index b3cb1e4..6e0f394 100644 --- a/src/main/java/de/torui/coflsky/WSCommandHandler.java +++ b/src/main/java/de/torui/coflsky/WSCommandHandler.java @@ -23,7 +23,12 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.ClientCommandHandler; import net.minecraftforge.client.event.sound.SoundEvent; + + public class WSCommandHandler { + + public static String lastOnClickEvent; + public static boolean HandleCommand(Command cmd, Entity sender) { //Entity sender = Minecraft.getMinecraft().thePlayer; System.out.println("Handling Command=" + cmd.toString()); @@ -79,6 +84,7 @@ public class WSCommandHandler { style = new ChatStyle().setChatClickEvent(new ClickEvent(Action.OPEN_URL, wcmd.OnClick)); } else { style = new ChatStyle().setChatClickEvent(new ClickEvent(Action.RUN_COMMAND, "/cofl callback " +wcmd.OnClick)); + lastOnClickEvent = "/cofl callback " +wcmd.OnClick; } comp.setChatStyle(style); } diff --git a/src/main/resources/assets/coflsky/lang/en_US.lang b/src/main/resources/assets/coflsky/lang/en_US.lang new file mode 100644 index 0000000..eb7ebad --- /dev/null +++ b/src/main/resources/assets/coflsky/lang/en_US.lang @@ -0,0 +1,2 @@ +key.coflskycategory.name=Coflnet Skyblock +key.replay_last.onclick=Activate last Coflnet message
\ No newline at end of file |