diff options
8 files changed, 85 insertions, 22 deletions
diff --git a/src/main/java/de/torui/coflsky/CoflSky.java b/src/main/java/de/torui/coflsky/CoflSky.java index 0191ea1..18b4008 100644 --- a/src/main/java/de/torui/coflsky/CoflSky.java +++ b/src/main/java/de/torui/coflsky/CoflSky.java @@ -52,6 +52,7 @@ public class CoflSky if(event.getSide() == Side.CLIENT) { ClientCommandHandler.instance.registerCommand(new CoflSkyCommand()); ClientCommandHandler.instance.registerCommand(new ColfCommand()); + ClientCommandHandler.instance.registerCommand(new FlipperChatCommand()); for (int i = 0; i < keyBindings.length; ++i) { diff --git a/src/main/java/de/torui/coflsky/CoflSkyCommand.java b/src/main/java/de/torui/coflsky/CoflSkyCommand.java index c6b38fd..d5ee857 100644 --- a/src/main/java/de/torui/coflsky/CoflSkyCommand.java +++ b/src/main/java/de/torui/coflsky/CoflSkyCommand.java @@ -47,10 +47,11 @@ public class CoflSkyCommand extends CommandBase { } public static final String HelpText = "Available local sub-commands:\n" - + "start: starts a new connection\n" - + "stop: stops the connection\n" - + "reset: resets all local session information and stops the connection\n" - + "status: Emits status information\nServer-Only Commands:"; + + "§bstart: §7starts a new connection\n" + + "§bstop: §7stops the connection\n" + + "§bconnect: §7Connects to a different server\n" + + "§breset: §7resets all local session information and stops the connection\n" + + "§bstatus: §7Emits status information\nServer-Only Commands:"; @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { new Thread(()->{ @@ -109,10 +110,12 @@ public class CoflSkyCommand extends CommandBase { } else { sender.addChatMessage(new ChatComponentText("Could not open connection, please check the logs")); } + } else { + sender.addChatMessage(new ChatComponentText("§cPleace specify a server to connect to")); } break; default: - CommandNotRecognized(args, sender); + SendCommandToServer(args, sender); return; } } @@ -156,7 +159,7 @@ public class CoflSkyCommand extends CommandBase { return status; } - public void CommandNotRecognized(String[] args, ICommandSender sender) { + public void SendCommandToServer(String[] args, ICommandSender sender) { String command = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); //JsonStringCommand sc = new JsonStringCommand(args[0], WSClient.gson.toJson(command)); @@ -164,7 +167,9 @@ public class CoflSkyCommand extends CommandBase { if(CoflSky.Wrapper.isRunning) { CoflSky.Wrapper.SendMessage(rc); } else { - sender.addChatMessage(new ChatComponentText("CoflSky not active. Server Commands are currently not available.").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + sender.addChatMessage(new ChatComponentText("CoflSky wasn't active.").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED))); + CoflSky.Wrapper.startConnection(); + CoflSky.Wrapper.SendMessage(rc); } diff --git a/src/main/java/de/torui/coflsky/Config.java b/src/main/java/de/torui/coflsky/Config.java index 905f4a9..314d83b 100644 --- a/src/main/java/de/torui/coflsky/Config.java +++ b/src/main/java/de/torui/coflsky/Config.java @@ -1,5 +1,5 @@ package de.torui.coflsky; public class Config { - public static final int KeepFlipsForSeconds = 50; + public static final int KeepFlipsForSeconds = 42; }
\ No newline at end of file diff --git a/src/main/java/de/torui/coflsky/EventRegistry.java b/src/main/java/de/torui/coflsky/EventRegistry.java index 511b155..4b5186b 100644 --- a/src/main/java/de/torui/coflsky/EventRegistry.java +++ b/src/main/java/de/torui/coflsky/EventRegistry.java @@ -56,18 +56,20 @@ public class EventRegistry { } if(CoflSky.keyBindings[1].isKeyDown()) { - if((System.currentTimeMillis() - LastClick) >= 500) { + if((System.currentTimeMillis() - LastClick) >= 400) { Flip f = WSCommandHandler.flipHandler.fds.GetHighestFlip(); if(f != null) { + WSCommandHandler.Execute("/viewauction " + f.id, null); LastClick = System.currentTimeMillis(); String command = WSClient.gson.toJson("/viewauction " + f.id); - WSCommandHandler.Execute("/viewauction " + f.id, null); WSCommandHandler.flipHandler.fds.InvalidateFlip(f); - WSCommandHandler.Execute("/cofl track besthotkey " + f.id, Minecraft.getMinecraft().thePlayer); + WSCommandHandler.Execute("/cofl track besthotkey " + f.id, Minecraft.getMinecraft().thePlayer); CoflSky.Wrapper.SendMessage(new JsonStringCommand(CommandType.Clicked, command)); + } else { + WSCommandHandler.Execute("/cofl dialog nobestflip", Minecraft.getMinecraft().thePlayer); } } diff --git a/src/main/java/de/torui/coflsky/FlipperChatCommand.java b/src/main/java/de/torui/coflsky/FlipperChatCommand.java new file mode 100644 index 0000000..61e7c52 --- /dev/null +++ b/src/main/java/de/torui/coflsky/FlipperChatCommand.java @@ -0,0 +1,52 @@ +package de.torui.coflsky; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Base64; +import java.util.List; + +import de.torui.coflsky.commands.Command; +import de.torui.coflsky.commands.CommandType; +import de.torui.coflsky.commands.JsonStringCommand; +import de.torui.coflsky.commands.RawCommand; +import de.torui.coflsky.minecraft_integration.CoflSessionManager; +import de.torui.coflsky.minecraft_integration.CoflSessionManager.CoflSession; +import de.torui.coflsky.network.QueryServerCommands; +import de.torui.coflsky.network.WSClient; +import de.torui.coflsky.minecraft_integration.PlayerDataProvider; +import net.minecraft.client.Minecraft; +import net.minecraft.command.CommandBase; +import net.minecraft.command.CommandException; +import net.minecraft.command.ICommandSender; +import net.minecraft.event.ClickEvent; +import net.minecraft.event.ClickEvent.Action; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.BlockPos; +import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChatStyle; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IChatComponent; + +public class FlipperChatCommand extends CoflSkyCommand { + + + @Override + public String getCommandName() { + return "fc"; + } + + @Override + public String getCommandUsage(ICommandSender sender) { + return "Shorthand for /cofl chat"; + } + + @Override + public void processCommand(ICommandSender sender, String[] args) throws CommandException { + new Thread(()->{ + String[] newArgs = new String[args.length +1]; + System.arraycopy(args, 0, newArgs, 1, args.length); + newArgs[0] = "chat"; + SendCommandToServer(newArgs, sender); + }).start(); + } +} diff --git a/src/main/java/de/torui/coflsky/minecraft_integration/CoflSessionManager.java b/src/main/java/de/torui/coflsky/minecraft_integration/CoflSessionManager.java index 6f74bf4..26db791 100644 --- a/src/main/java/de/torui/coflsky/minecraft_integration/CoflSessionManager.java +++ b/src/main/java/de/torui/coflsky/minecraft_integration/CoflSessionManager.java @@ -86,7 +86,7 @@ public class CoflSessionManager { } public static boolean isValidSession(CoflSession session) { - if(session.timestampCreated.plus(Duration.ofDays(7)).isAfter(ZonedDateTime.now())) { + if(session.timestampCreated.plus(Duration.ofDays(14)).isAfter(ZonedDateTime.now())) { return true; } return false; diff --git a/src/main/java/de/torui/coflsky/network/WSClientWrapper.java b/src/main/java/de/torui/coflsky/network/WSClientWrapper.java index e6592bb..044a3e2 100644 --- a/src/main/java/de/torui/coflsky/network/WSClientWrapper.java +++ b/src/main/java/de/torui/coflsky/network/WSClientWrapper.java @@ -41,16 +41,18 @@ public class WSClientWrapper { System.out.println("Sleeping..."); Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText("Lost connection to Coflnet, trying to reestablish the connection in 2 Seconds...")); - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - socket = new WSClient(socket.uri); - isRunning = false; - start(); + isRunning = false; + while(isRunning == false) { + start(); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + socket.shouldRun = true; } diff --git a/src/main/resources/assets/coflsky/lang/en_US.lang b/src/main/resources/assets/coflsky/lang/en_US.lang index 38a6461..7d2d724 100644 --- a/src/main/resources/assets/coflsky/lang/en_US.lang +++ b/src/main/resources/assets/coflsky/lang/en_US.lang @@ -1,2 +1,3 @@ key.coflskycategory.name=Coflnet Skyblock -key.replay_last.onclick=Open last flip [use at own risk]
\ No newline at end of file +key.replay_last.onclick=Open last flip [use at own risk] +key.start_highest_bid=Open best/next flip
\ No newline at end of file |