diff --git a/distributor-core/src/main/java/com/xpdustry/distributor/core/command/CommandSender.java b/distributor-core/src/main/java/com/xpdustry/distributor/core/command/CommandSender.java
index 142880ac..96005dbf 100644
--- a/distributor-core/src/main/java/com/xpdustry/distributor/core/command/CommandSender.java
+++ b/distributor-core/src/main/java/com/xpdustry/distributor/core/command/CommandSender.java
@@ -22,47 +22,17 @@
public interface CommandSender {
- default void sendWarning(final String text) {}
-
- default void sendMessage(final String text) {}
-
static CommandSender player(final Player player) {
- return new CommandSender() {
- @Override
- public boolean isPlayer() {
- return true;
- }
-
- @Override
- public boolean isServer() {
- return false;
- }
-
- @Override
- public Player getPlayer() {
- throw new UnsupportedOperationException();
- }
- };
+ return new PlayerCommandSender(player);
}
static CommandSender server() {
- return new CommandSender() {
- @Override
- public boolean isPlayer() {
- return false;
- }
+ return ServerCommandSender.INSTANCE;
+ }
- @Override
- public boolean isServer() {
- return true;
- }
+ void sendWarning(final String text);
- @Override
- public Player getPlayer() {
- throw new UnsupportedOperationException();
- }
- };
- }
+ void sendMessage(final String text);
boolean isPlayer();
diff --git a/distributor-core/src/main/java/com/xpdustry/distributor/core/command/PlayerCommandSender.java b/distributor-core/src/main/java/com/xpdustry/distributor/core/command/PlayerCommandSender.java
new file mode 100644
index 00000000..ca778c0f
--- /dev/null
+++ b/distributor-core/src/main/java/com/xpdustry/distributor/core/command/PlayerCommandSender.java
@@ -0,0 +1,49 @@
+/*
+ * Distributor, a feature-rich framework for Mindustry plugins.
+ *
+ * Copyright (C) 2024 Xpdustry
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.xpdustry.distributor.core.command;
+
+import mindustry.gen.Player;
+
+record PlayerCommandSender(Player player) implements CommandSender {
+
+ @Override
+ public void sendMessage(final String text) {
+ this.player.sendMessage(text);
+ }
+
+ @Override
+ public void sendWarning(final String text) {
+ this.player.sendMessage("[red]" + text);
+ }
+
+ @Override
+ public boolean isPlayer() {
+ return true;
+ }
+
+ @Override
+ public boolean isServer() {
+ return false;
+ }
+
+ @Override
+ public Player getPlayer() {
+ return this.player;
+ }
+}
diff --git a/distributor-core/src/main/java/com/xpdustry/distributor/core/command/ServerCommandSender.java b/distributor-core/src/main/java/com/xpdustry/distributor/core/command/ServerCommandSender.java
new file mode 100644
index 00000000..96a04b3b
--- /dev/null
+++ b/distributor-core/src/main/java/com/xpdustry/distributor/core/command/ServerCommandSender.java
@@ -0,0 +1,58 @@
+/*
+ * Distributor, a feature-rich framework for Mindustry plugins.
+ *
+ * Copyright (C) 2024 Xpdustry
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.xpdustry.distributor.core.command;
+
+import arc.util.Log;
+import mindustry.gen.Player;
+
+final class ServerCommandSender implements CommandSender {
+
+ static final ServerCommandSender INSTANCE = new ServerCommandSender();
+
+ private ServerCommandSender() {}
+
+ @Override
+ public void sendMessage(final String text) {
+ for (final var line : text.split("\n", -1)) {
+ Log.info(line);
+ }
+ }
+
+ @Override
+ public void sendWarning(final String text) {
+ for (final var line : text.split("\n", -1)) {
+ Log.warn(line);
+ }
+ }
+
+ @Override
+ public boolean isPlayer() {
+ return false;
+ }
+
+ @Override
+ public boolean isServer() {
+ return true;
+ }
+
+ @Override
+ public Player getPlayer() {
+ throw new UnsupportedOperationException();
+ }
+}