use of net.minecraft.server.PlayerManager in project dynmap by webbukkit.
the class FabricServer method isPlayerBanned.
@Override
public boolean isPlayerBanned(String pid) {
PlayerManager scm = server.getPlayerManager();
BannedPlayerList bl = scm.getUserBanList();
try {
return bl.contains(getProfileByName(pid).get());
} catch (NoSuchElementException e) {
/* If this profile doesn't exist, default to "banned" for good measure. */
return true;
}
}
use of net.minecraft.server.PlayerManager in project dynmap by webbukkit.
the class FabricServer method checkPlayerPermission.
@Override
public boolean checkPlayerPermission(String player, String perm) {
PlayerManager scm = server.getPlayerManager();
if (scm == null)
return false;
BannedPlayerList bl = scm.getUserBanList();
if (bl == null)
return false;
if (bl.contains(getProfileByName(player))) {
return false;
}
return plugin.hasOfflinePermission(player, perm);
}
use of net.minecraft.server.PlayerManager in project Rug by RubixDev.
the class SudoCommand method register.
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
LiteralArgumentBuilder<ServerCommandSource> command = literal("sudo").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandSudo)).then(argument("player", StringArgumentType.word()).suggests(((context, builder) -> suggestMatching(getPlayers(context.getSource()), builder))).then(literal("chat").then(argument("message", StringArgumentType.greedyString()).executes(context -> {
String targetPlayerName = StringArgumentType.getString(context, "player");
MinecraftServer server = context.getSource().getServer();
PlayerManager playerManager = server.getPlayerManager();
ServerPlayerEntity targetPlayer = playerManager.getPlayer(targetPlayerName);
if (targetPlayer == null) {
context.getSource().sendError(new LiteralText("Targeted Player could not be found"));
return 0;
}
Text text = new TranslatableText("chat.type.text", targetPlayerName, StringArgumentType.getString(context, "message"));
playerManager.broadcast(text, MessageType.CHAT, targetPlayer.getUuid());
return 1;
}))).then(literal("command").redirect(dispatcher.getRoot(), context -> {
String targetPlayerName = StringArgumentType.getString(context, "player");
MinecraftServer server = context.getSource().getServer();
ServerPlayerEntity player = server.getPlayerManager().getPlayer(targetPlayerName);
if (player == null) {
Message errorMessage = new LiteralText("Targeted player could not be found");
throw new CommandSyntaxException(new SimpleCommandExceptionType(errorMessage), errorMessage);
}
return player.getCommandSource();
})));
dispatcher.register(command);
}
Aggregations