Skip to content

Commit

Permalink
use raw string & remove gson
Browse files Browse the repository at this point in the history
  • Loading branch information
michaljaz committed Dec 30, 2023
1 parent d364839 commit 97a6906
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import app.shopmc.plugin.config.Config;
import app.shopmc.plugin.config.EmptyConfigFieldException;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
Expand Down Expand Up @@ -37,12 +35,7 @@ public void onOpen(ServerHandshake handshakedata) {
}

@Override
public void onMessage(String message) {
Bukkit.getConsoleSender().sendMessage("Received message: " + message);
Gson gson = new Gson();
JsonObject jsonObject = gson.fromJson(message, JsonObject.class);
String commands = jsonObject.get("commands").getAsString();
Bukkit.getConsoleSender().sendMessage("Received messagex: " + commands);
public void onMessage(String commands) {
for (String command : commands.split("\n")) {
Bukkit.getScheduler().runTask(_this, () -> Bukkit.dispatchCommand(getServer().getConsoleSender(), command));
}
Expand Down

0 comments on commit 97a6906

Please sign in to comment.