diff options
author | Florian Rinke <develop@torui.de> | 2021-11-05 20:17:35 +0100 |
---|---|---|
committer | Florian Rinke <develop@torui.de> | 2021-11-05 20:17:35 +0100 |
commit | e533c7f6f9860479f5f472280d6fce8b87d8d0b8 (patch) | |
tree | ad90d70a17908fab7325d5eee30f0c20b3192081 /src/main/java/de/torui/coflsky/commands | |
parent | 0e9a5837522132b946ab1568ad0485622f32a921 (diff) | |
download | COFL-e533c7f6f9860479f5f472280d6fce8b87d8d0b8.tar.gz COFL-e533c7f6f9860479f5f472280d6fce8b87d8d0b8.tar.bz2 COFL-e533c7f6f9860479f5f472280d6fce8b87d8d0b8.zip |
rename de.torui.coflsky.core to commands in for refactor
Diffstat (limited to 'src/main/java/de/torui/coflsky/commands')
6 files changed, 178 insertions, 0 deletions
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<T> { + @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<String> { + + 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 <T> Command<T> GetAs(TypeToken<T> type){ + T t = new GsonBuilder().create().fromJson(this.getData(),type.getType()); + Command<?> cmd = new Command<Object>(this.getType(), t); + + return (Command<T>) 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; + } + + +} |