Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 08:10:09 +01:00
Added a command and a new API function "getVersion()"
Dieser Commit ist enthalten in:
Ursprung
ef118a3a64
Commit
5930a83765
48
src/main/java/us/myles/ViaVersion/ViaVersionCommand.java
Normale Datei
48
src/main/java/us/myles/ViaVersion/ViaVersionCommand.java
Normale Datei
@ -0,0 +1,48 @@
|
||||
package us.myles.ViaVersion;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by fillefilip8 on 2016-03-03.
|
||||
*/
|
||||
public class ViaVersionCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.hasPermission("viaversion.admin")) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(color("&aViaVersion &c" + ViaVersion.getInstance().getVersion() + "&b by &6_MylesC"));
|
||||
sender.sendMessage(color("&6Commands:"));
|
||||
sender.sendMessage(color("&2/viaversion list &7- &6Shows lists of all 1.9 clients and 1.8 clients."));
|
||||
} else if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("list")) {
|
||||
List<String> portedPlayers = new ArrayList<String>();
|
||||
List<String> normalPlayers = new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (ViaVersion.getInstance().isPorted(p)) {
|
||||
portedPlayers.add(p.getName());
|
||||
} else {
|
||||
normalPlayers.add(p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(color("&8[&61.9&8]: &b" + portedPlayers.toString()));
|
||||
sender.sendMessage(color("&8[&61.8&8]: &b" + normalPlayers.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public String color(String string){
|
||||
return string.replace("&", "§");
|
||||
}
|
||||
}
|
@ -52,6 +52,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
setPorted(e.getPlayer().getUniqueId(), false);
|
||||
}
|
||||
}, this);
|
||||
getCommand("viaversion").setExecutor(new ViaVersionCommand());
|
||||
}
|
||||
|
||||
public void injectPacketHandler() throws Exception {
|
||||
@ -78,6 +79,11 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
return portedPlayers.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return getDescription().getVersion();
|
||||
}
|
||||
|
||||
public void setPorted(UUID id, boolean value) {
|
||||
if (value) {
|
||||
portedPlayers.add(id);
|
||||
|
@ -9,4 +9,5 @@ public interface ViaVersionAPI {
|
||||
* @return
|
||||
*/
|
||||
boolean isPorted(Player player);
|
||||
String getVersion();
|
||||
}
|
||||
|
@ -4,3 +4,5 @@ author: _MylesC
|
||||
version: ${version}
|
||||
load: startup
|
||||
loadbefore: [ProtocolLib, ProxyPipe]
|
||||
commands:
|
||||
viaversion:
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren