aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/torui/coflsky
diff options
context:
space:
mode:
authorÄkwav <xekwavx@gmail.com>2022-03-22 23:47:57 +0100
committerÄkwav <xekwavx@gmail.com>2022-03-22 23:47:57 +0100
commitb5a680e8fcea1bd0e491ae5725fbacaf372f748e (patch)
tree4fa1e39f8ea0c95f9266d379dd5fe1a0d9cb6834 /src/main/java/de/torui/coflsky
parent1caa3e1840e51800200458b776712f38b470d772 (diff)
downloadCOFL-b5a680e8fcea1bd0e491ae5725fbacaf372f748e.tar.gz
COFL-b5a680e8fcea1bd0e491ae5725fbacaf372f748e.tar.bz2
COFL-b5a680e8fcea1bd0e491ae5725fbacaf372f748e.zip
implicit connect & bug fixes
Diffstat (limited to 'src/main/java/de/torui/coflsky')
-rw-r--r--src/main/java/de/torui/coflsky/CoflSky.java1
-rw-r--r--src/main/java/de/torui/coflsky/CoflSkyCommand.java15
-rw-r--r--src/main/java/de/torui/coflsky/Config.java2
-rw-r--r--src/main/java/de/torui/coflsky/EventRegistry.java8
-rw-r--r--src/main/java/de/torui/coflsky/FlipperChatCommand.java52
-rw-r--r--src/main/java/de/torui/coflsky/minecraft_integration/CoflSessionManager.java2
6 files changed, 70 insertions, 10 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..51760ec 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,6 +110,8 @@ 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:
@@ -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..4488747
--- /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";
+ CommandNotRecognized(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;