mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2025-01-10 19:47:58 +01:00
Fixed Via commands for the CLi interface
This commit is contained in:
parent
2f53b38769
commit
55b58444bd
@ -18,11 +18,10 @@
|
||||
package net.raphimc.viaproxy.cli;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.connection.UserConnectionImpl;
|
||||
import net.lenni0451.classtransform.utils.log.Logger;
|
||||
import net.raphimc.viaprotocolhack.commands.UserCommandSender;
|
||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||
import net.raphimc.viaproxy.plugins.events.ConsoleCommandEvent;
|
||||
import net.raphimc.viaproxy.protocolhack.viaproxy.ConsoleCommandSender;
|
||||
import net.raphimc.viaproxy.util.ArrayHelper;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -50,7 +49,7 @@ public class ConsoleHandler {
|
||||
System.gc();
|
||||
System.out.println("GC Done");
|
||||
} else if (command.equalsIgnoreCase("via")) {
|
||||
Via.getManager().getCommandHandler().onCommand(new UserCommandSender(new UserConnectionImpl(null, true)), args.getAsArray());
|
||||
Via.getManager().getCommandHandler().onCommand(new ConsoleCommandSender(), args.getAsArray());
|
||||
} else if (command.equalsIgnoreCase("threaddump")) {
|
||||
System.out.println("Thread Dump:");
|
||||
for (Thread thread : Thread.getAllStackTraces().keySet()) {
|
||||
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy
|
||||
* Copyright (C) 2023 RK_01/RaphiMC and contributors
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.raphimc.viaproxy.protocolhack.viaproxy;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.command.ViaCommandSender;
|
||||
import net.raphimc.viaproxy.cli.ConsoleFormatter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ConsoleCommandSender implements ViaCommandSender {
|
||||
|
||||
private static final UUID CONSOLE_UUID = new UUID(0, 0);
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String msg) {
|
||||
Via.getPlatform().getLogger().info(ConsoleFormatter.convert(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return CONSOLE_UUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Console";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user