mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-25 02:27:38 +01:00
Fixed gamemode command (CommandBuilder update)
This commit is contained in:
parent
ce40627a36
commit
754821f447
@ -10,7 +10,7 @@ sourceCompatibility = 1.11
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://jitpack.io'}
|
||||
maven { url 'https://jitpack.io' }
|
||||
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ dependencies {
|
||||
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||
|
||||
compile 'com.github.TheMode:CommandBuilder:611d16a487'
|
||||
compile 'com.github.TheMode:CommandBuilder:a5f9d78a66'
|
||||
|
||||
// https://mvnrepository.com/artifact/javax.vecmath/vecmath
|
||||
compile group: 'javax.vecmath', name: 'vecmath', version: '1.5.2' // Used for Fastnoise
|
||||
|
@ -20,7 +20,7 @@ public class GamemodeCommand extends Command<Player> {
|
||||
|
||||
setDefaultExecutor(this::usage);
|
||||
|
||||
Argument player = ArgumentType.String("player");
|
||||
Argument player = ArgumentType.Word("player");
|
||||
|
||||
GameMode[] gameModes = GameMode.values();
|
||||
String[] names = new String[gameModes.length];
|
||||
@ -44,27 +44,27 @@ public class GamemodeCommand extends Command<Player> {
|
||||
GameMode mode = GameMode.valueOf(gamemodeName.toUpperCase());
|
||||
assert mode != null; // mode is not supposed to be null, because gamemodeName will be valid
|
||||
player.setGameMode(mode);
|
||||
player.sendMessage("You are now playing in "+gamemodeName);
|
||||
player.sendMessage("You are now playing in " + gamemodeName);
|
||||
|
||||
System.out.println("hello");
|
||||
}
|
||||
|
||||
private void executeOnOther(Player player, Arguments arguments) {
|
||||
String gamemodeName = arguments.getWord("mode");
|
||||
String targetName = arguments.getString("player");
|
||||
String targetName = arguments.getWord("player");
|
||||
GameMode mode = GameMode.valueOf(gamemodeName.toUpperCase());
|
||||
assert mode != null; // mode is not supposed to be null, because gamemodeName will be valid
|
||||
Optional<Player> target = player.getInstance().getPlayers().stream().filter(p -> p.getUsername().equals(targetName)).findFirst();
|
||||
if(target.isPresent()) {
|
||||
Optional<Player> target = player.getInstance().getPlayers().stream().filter(p -> p.getUsername().equalsIgnoreCase(targetName)).findFirst();
|
||||
if (target.isPresent()) {
|
||||
target.get().setGameMode(mode);
|
||||
target.get().sendMessage("You are now playing in "+gamemodeName);
|
||||
target.get().sendMessage("You are now playing in " + gamemodeName);
|
||||
} else {
|
||||
player.sendMessage("'"+targetName+"' is not a valid player name.");
|
||||
player.sendMessage("'" + targetName + "' is not a valid player name.");
|
||||
}
|
||||
}
|
||||
|
||||
private void gameModeCallback(Player player, String gamemode, int error) {
|
||||
player.sendMessage("'"+gamemode+"' is not a valid gamemode!");
|
||||
player.sendMessage("'" + gamemode + "' is not a valid gamemode!");
|
||||
}
|
||||
|
||||
private boolean isAllowed(Player player) {
|
||||
|
Loading…
Reference in New Issue
Block a user