From e533c7f6f9860479f5f472280d6fce8b87d8d0b8 Mon Sep 17 00:00:00 2001 From: Florian Rinke Date: Fri, 5 Nov 2021 20:17:35 +0100 Subject: rename de.torui.coflsky.core to commands in for refactor --- src/main/java/de/torui/coflsky/CoflSkyCommand.java | 6 ++-- src/main/java/de/torui/coflsky/EventRegistry.java | 6 ++-- .../java/de/torui/coflsky/WSCommandHandler.java | 8 ++--- .../java/de/torui/coflsky/commands/Command.java | 42 ++++++++++++++++++++++ .../de/torui/coflsky/commands/CommandType.java | 30 ++++++++++++++++ .../torui/coflsky/commands/JsonStringCommand.java | 28 +++++++++++++++ .../torui/coflsky/commands/models/AuctionData.java | 30 ++++++++++++++++ .../coflsky/commands/models/ChatMessageData.java | 25 +++++++++++++ .../torui/coflsky/commands/models/SoundData.java | 23 ++++++++++++ src/main/java/de/torui/coflsky/core/Command.java | 42 ---------------------- .../java/de/torui/coflsky/core/CommandType.java | 30 ---------------- .../de/torui/coflsky/core/JsonStringCommand.java | 28 --------------- .../coflsky/core/commandEntities/AuctionData.java | 30 ---------------- .../core/commandEntities/ChatMessageData.java | 25 ------------- .../coflsky/core/commandEntities/SoundData.java | 23 ------------ .../java/de/torui/coflsky/network/WSClient.java | 4 +-- .../de/torui/coflsky/network/WSClientWrapper.java | 4 +-- 17 files changed, 192 insertions(+), 192 deletions(-) create mode 100644 src/main/java/de/torui/coflsky/commands/Command.java create mode 100644 src/main/java/de/torui/coflsky/commands/CommandType.java create mode 100644 src/main/java/de/torui/coflsky/commands/JsonStringCommand.java create mode 100644 src/main/java/de/torui/coflsky/commands/models/AuctionData.java create mode 100644 src/main/java/de/torui/coflsky/commands/models/ChatMessageData.java create mode 100644 src/main/java/de/torui/coflsky/commands/models/SoundData.java delete mode 100644 src/main/java/de/torui/coflsky/core/Command.java delete mode 100644 src/main/java/de/torui/coflsky/core/CommandType.java delete mode 100644 src/main/java/de/torui/coflsky/core/JsonStringCommand.java delete mode 100644 src/main/java/de/torui/coflsky/core/commandEntities/AuctionData.java delete mode 100644 src/main/java/de/torui/coflsky/core/commandEntities/ChatMessageData.java delete mode 100644 src/main/java/de/torui/coflsky/core/commandEntities/SoundData.java diff --git a/src/main/java/de/torui/coflsky/CoflSkyCommand.java b/src/main/java/de/torui/coflsky/CoflSkyCommand.java index 8f4e9e7..b48a3cd 100644 --- a/src/main/java/de/torui/coflsky/CoflSkyCommand.java +++ b/src/main/java/de/torui/coflsky/CoflSkyCommand.java @@ -4,9 +4,9 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; -import de.torui.coflsky.core.Command; -import de.torui.coflsky.core.CommandType; -import de.torui.coflsky.core.JsonStringCommand; +import de.torui.coflsky.commands.Command; +import de.torui.coflsky.commands.CommandType; +import de.torui.coflsky.commands.JsonStringCommand; import de.torui.coflsky.minecraft_integration.CoflSessionManager; import de.torui.coflsky.minecraft_integration.CoflSessionManager.CoflSession; import de.torui.coflsky.network.QueryServerCommands; diff --git a/src/main/java/de/torui/coflsky/EventRegistry.java b/src/main/java/de/torui/coflsky/EventRegistry.java index bb2f24f..f155cfb 100644 --- a/src/main/java/de/torui/coflsky/EventRegistry.java +++ b/src/main/java/de/torui/coflsky/EventRegistry.java @@ -1,10 +1,10 @@ package de.torui.coflsky; -import de.torui.coflsky.core.Command; -import de.torui.coflsky.core.CommandType; -import de.torui.coflsky.core.JsonStringCommand; import java.util.UUID; +import de.torui.coflsky.commands.Command; +import de.torui.coflsky.commands.CommandType; +import de.torui.coflsky.commands.JsonStringCommand; import de.torui.coflsky.network.WSClient; import net.minecraft.client.Minecraft; import net.minecraft.server.MinecraftServer; diff --git a/src/main/java/de/torui/coflsky/WSCommandHandler.java b/src/main/java/de/torui/coflsky/WSCommandHandler.java index 287ed09..a06640c 100644 --- a/src/main/java/de/torui/coflsky/WSCommandHandler.java +++ b/src/main/java/de/torui/coflsky/WSCommandHandler.java @@ -2,10 +2,10 @@ package de.torui.coflsky; import com.google.gson.reflect.TypeToken; -import de.torui.coflsky.core.Command; -import de.torui.coflsky.core.JsonStringCommand; -import de.torui.coflsky.core.commandEntities.SoundData; -import de.torui.coflsky.core.commandEntities.ChatMessageData; +import de.torui.coflsky.commands.Command; +import de.torui.coflsky.commands.JsonStringCommand; +import de.torui.coflsky.commands.models.ChatMessageData; +import de.torui.coflsky.commands.models.SoundData; import de.torui.coflsky.network.WSClient; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.PositionedSoundRecord; diff --git a/src/main/java/de/torui/coflsky/commands/Command.java b/src/main/java/de/torui/coflsky/commands/Command.java new file mode 100644 index 0000000..20ab8f1 --- /dev/null +++ b/src/main/java/de/torui/coflsky/commands/Command.java @@ -0,0 +1,42 @@ +package de.torui.coflsky.commands; + +import com.google.gson.annotations.SerializedName; + +public class Command { + @SerializedName("type") + private CommandType Type; + @SerializedName("data") + private T data; + + public Command() { + } + + public Command(CommandType type, T data) { + super(); + Type = type; + this.data = data; + } + + public CommandType getType() { + return Type; + } + + public void setType(CommandType type) { + Type = type; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + @Override + public String toString() { + return "Command [Type=" + Type + ", data=" + data + "]"; + } + +} + diff --git a/src/main/java/de/torui/coflsky/commands/CommandType.java b/src/main/java/de/torui/coflsky/commands/CommandType.java new file mode 100644 index 0000000..3fac287 --- /dev/null +++ b/src/main/java/de/torui/coflsky/commands/CommandType.java @@ -0,0 +1,30 @@ +package de.torui.coflsky.commands; + +import com.google.gson.annotations.SerializedName; + +public enum CommandType { + @SerializedName("writeToChat") + WriteToChat, + + @SerializedName("execute") + Execute, + + @SerializedName("tokenLogin") + TokenLogin, + + @SerializedName("clicked") + Clicked, + + @SerializedName("playSound") + PlaySound, + + @SerializedName("chatMessage") + ChatMessage, + + @SerializedName("purchaseStart") + PurchaseStart, + + @SerializedName("purchaseConfirm") + PurchaseConfirm, + +} diff --git a/src/main/java/de/torui/coflsky/commands/JsonStringCommand.java b/src/main/java/de/torui/coflsky/commands/JsonStringCommand.java new file mode 100644 index 0000000..6bc22d8 --- /dev/null +++ b/src/main/java/de/torui/coflsky/commands/JsonStringCommand.java @@ -0,0 +1,28 @@ +package de.torui.coflsky.commands; + +import com.google.gson.GsonBuilder; +import com.google.gson.reflect.TypeToken; + +public class JsonStringCommand extends Command { + + public JsonStringCommand(String type, String data) { + this.setType(CommandType.valueOf(type)); + this.setData(data); + } + + public JsonStringCommand() { + super(); + + } + + public JsonStringCommand(CommandType type, String data) { + super(type, data); + } + + public Command GetAs(TypeToken type){ + T t = new GsonBuilder().create().fromJson(this.getData(),type.getType()); + Command cmd = new Command(this.getType(), t); + + return (Command) cmd; + } +} diff --git a/src/main/java/de/torui/coflsky/commands/models/AuctionData.java b/src/main/java/de/torui/coflsky/commands/models/AuctionData.java new file mode 100644 index 0000000..ff1f705 --- /dev/null +++ b/src/main/java/de/torui/coflsky/commands/models/AuctionData.java @@ -0,0 +1,30 @@ +package de.torui.coflsky.commands.models; + +import com.google.gson.annotations.SerializedName; + +public class AuctionData { + @SerializedName("auctionId") + private String auctionId; + @SerializedName("itemId") + private String itemId; + public String getAuctionId() { + return auctionId; + } + public void setAuctionId(String auctionId) { + this.auctionId = auctionId; + } + public String getItemId() { + return itemId; + } + public void setItemId(String itemId) { + this.itemId = itemId; + } + public AuctionData(String auctionId, String itemId) { + super(); + this.auctionId = auctionId; + this.itemId = itemId; + } + + public AuctionData() {} + +} diff --git a/src/main/java/de/torui/coflsky/commands/models/ChatMessageData.java b/src/main/java/de/torui/coflsky/commands/models/ChatMessageData.java new file mode 100644 index 0000000..65459c5 --- /dev/null +++ b/src/main/java/de/torui/coflsky/commands/models/ChatMessageData.java @@ -0,0 +1,25 @@ +package de.torui.coflsky.commands.models; + +import com.google.gson.annotations.SerializedName; + +public class ChatMessageData { + @SerializedName("text") + public String Text; + @SerializedName("onClick") + public String OnClick; + + @SerializedName("hover") + public String Hover; + + public ChatMessageData() { + + } + + public ChatMessageData(String text, String onClick, String hover) { + super(); + Text = text; + OnClick = onClick; + Hover = hover; + } + +} diff --git a/src/main/java/de/torui/coflsky/commands/models/SoundData.java b/src/main/java/de/torui/coflsky/commands/models/SoundData.java new file mode 100644 index 0000000..5df18d3 --- /dev/null +++ b/src/main/java/de/torui/coflsky/commands/models/SoundData.java @@ -0,0 +1,23 @@ +package de.torui.coflsky.commands.models; + +import com.google.gson.annotations.SerializedName; + +public class SoundData { + @SerializedName("name") + public String Name; + + @SerializedName("pitch") + public float Pitch; + + public SoundData() { + super(); + } + + public SoundData(String name, float pitch) { + super(); + Name = name; + Pitch = pitch; + } + + +} diff --git a/src/main/java/de/torui/coflsky/core/Command.java b/src/main/java/de/torui/coflsky/core/Command.java deleted file mode 100644 index e18c59a..0000000 --- a/src/main/java/de/torui/coflsky/core/Command.java +++ /dev/null @@ -1,42 +0,0 @@ -package de.torui.coflsky.core; - -import com.google.gson.annotations.SerializedName; - -public class Command { - @SerializedName("type") - private CommandType Type; - @SerializedName("data") - private T data; - - public Command() { - } - - public Command(CommandType type, T data) { - super(); - Type = type; - this.data = data; - } - - public CommandType getType() { - return Type; - } - - public void setType(CommandType type) { - Type = type; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } - - @Override - public String toString() { - return "Command [Type=" + Type + ", data=" + data + "]"; - } - -} - diff --git a/src/main/java/de/torui/coflsky/core/CommandType.java b/src/main/java/de/torui/coflsky/core/CommandType.java deleted file mode 100644 index 74e8a41..0000000 --- a/src/main/java/de/torui/coflsky/core/CommandType.java +++ /dev/null @@ -1,30 +0,0 @@ -package de.torui.coflsky.core; - -import com.google.gson.annotations.SerializedName; - -public enum CommandType { - @SerializedName("writeToChat") - WriteToChat, - - @SerializedName("execute") - Execute, - - @SerializedName("tokenLogin") - TokenLogin, - - @SerializedName("clicked") - Clicked, - - @SerializedName("playSound") - PlaySound, - - @SerializedName("chatMessage") - ChatMessage, - - @SerializedName("purchaseStart") - PurchaseStart, - - @SerializedName("purchaseConfirm") - PurchaseConfirm, - -} diff --git a/src/main/java/de/torui/coflsky/core/JsonStringCommand.java b/src/main/java/de/torui/coflsky/core/JsonStringCommand.java deleted file mode 100644 index 9ce0cb1..0000000 --- a/src/main/java/de/torui/coflsky/core/JsonStringCommand.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.torui.coflsky.core; - -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; - -public class JsonStringCommand extends Command { - - public JsonStringCommand(String type, String data) { - this.setType(CommandType.valueOf(type)); - this.setData(data); - } - - public JsonStringCommand() { - super(); - - } - - public JsonStringCommand(CommandType type, String data) { - super(type, data); - } - - public Command GetAs(TypeToken type){ - T t = new GsonBuilder().create().fromJson(this.getData(),type.getType()); - Command cmd = new Command(this.getType(), t); - - return (Command) cmd; - } -} diff --git a/src/main/java/de/torui/coflsky/core/commandEntities/AuctionData.java b/src/main/java/de/torui/coflsky/core/commandEntities/AuctionData.java deleted file mode 100644 index 0e677b2..0000000 --- a/src/main/java/de/torui/coflsky/core/commandEntities/AuctionData.java +++ /dev/null @@ -1,30 +0,0 @@ -package de.torui.coflsky.core.commandEntities; - -import com.google.gson.annotations.SerializedName; - -public class AuctionData { - @SerializedName("auctionId") - private String auctionId; - @SerializedName("itemId") - private String itemId; - public String getAuctionId() { - return auctionId; - } - public void setAuctionId(String auctionId) { - this.auctionId = auctionId; - } - public String getItemId() { - return itemId; - } - public void setItemId(String itemId) { - this.itemId = itemId; - } - public AuctionData(String auctionId, String itemId) { - super(); - this.auctionId = auctionId; - this.itemId = itemId; - } - - public AuctionData() {} - -} diff --git a/src/main/java/de/torui/coflsky/core/commandEntities/ChatMessageData.java b/src/main/java/de/torui/coflsky/core/commandEntities/ChatMessageData.java deleted file mode 100644 index cfc1381..0000000 --- a/src/main/java/de/torui/coflsky/core/commandEntities/ChatMessageData.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.torui.coflsky.core.commandEntities; - -import com.google.gson.annotations.SerializedName; - -public class ChatMessageData { - @SerializedName("text") - public String Text; - @SerializedName("onClick") - public String OnClick; - - @SerializedName("hover") - public String Hover; - - public ChatMessageData() { - - } - - public ChatMessageData(String text, String onClick, String hover) { - super(); - Text = text; - OnClick = onClick; - Hover = hover; - } - -} diff --git a/src/main/java/de/torui/coflsky/core/commandEntities/SoundData.java b/src/main/java/de/torui/coflsky/core/commandEntities/SoundData.java deleted file mode 100644 index 64687ab..0000000 --- a/src/main/java/de/torui/coflsky/core/commandEntities/SoundData.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.torui.coflsky.core.commandEntities; - -import com.google.gson.annotations.SerializedName; - -public class SoundData { - @SerializedName("name") - public String Name; - - @SerializedName("pitch") - public float Pitch; - - public SoundData() { - super(); - } - - public SoundData(String name, float pitch) { - super(); - Name = name; - Pitch = pitch; - } - - -} diff --git a/src/main/java/de/torui/coflsky/network/WSClient.java b/src/main/java/de/torui/coflsky/network/WSClient.java index b3f28ca..cd23b30 100644 --- a/src/main/java/de/torui/coflsky/network/WSClient.java +++ b/src/main/java/de/torui/coflsky/network/WSClient.java @@ -16,8 +16,8 @@ import com.neovisionaries.ws.client.WebSocketState; import net.minecraft.client.Minecraft; import de.torui.coflsky.CoflSky; import de.torui.coflsky.WSCommandHandler; -import de.torui.coflsky.core.Command; -import de.torui.coflsky.core.JsonStringCommand; +import de.torui.coflsky.commands.Command; +import de.torui.coflsky.commands.JsonStringCommand; public class WSClient extends WebSocketAdapter { diff --git a/src/main/java/de/torui/coflsky/network/WSClientWrapper.java b/src/main/java/de/torui/coflsky/network/WSClientWrapper.java index dd9d13b..6542542 100644 --- a/src/main/java/de/torui/coflsky/network/WSClientWrapper.java +++ b/src/main/java/de/torui/coflsky/network/WSClientWrapper.java @@ -9,8 +9,8 @@ import java.util.UUID; import com.neovisionaries.ws.client.WebSocketException; import de.torui.coflsky.CoflSky; -import de.torui.coflsky.core.Command; -import de.torui.coflsky.core.JsonStringCommand; +import de.torui.coflsky.commands.Command; +import de.torui.coflsky.commands.JsonStringCommand; import de.torui.coflsky.minecraft_integration.PlayerDataProvider; import net.minecraft.client.Minecraft; import net.minecraft.util.ChatComponentText; -- cgit