Java Code Examples for org.bukkit.entity.Player#setOp()
The following examples show how to use
org.bukkit.entity.Player#setOp() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoginListener.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
protected void applyPermissions(Player player, UserDoc.Login userDoc) { boolean op = false; final Server localServer = minecraftService.getLocalServer(); if(localServer.operators().containsKey(player.getUniqueId())) { logger.info("Opping " + player.getName() + " because they are in the server op list"); op = true; } if(localServer.team() != null && localServer.team().members().contains(userDoc)) { logger.info("Opping " + player.getName() + " because they are on the team that owns the server"); op = true; } PermissionAttachment attachment = player.addAttachment(this.plugin); PermissionUtils.setPermissions(attachment, Permissions.mergePermissions(localServer.realms(), userDoc.mc_permissions_by_realm())); player.recalculatePermissions(); if(player.hasPermission("op")) { op = true; logger.info("Opping " + player.getName() + " because they have the op permission node"); } player.setOp(op); // This is always explicitly set to true or false on login }
Example 2
Source File: BukkitAutoOpListener.java From LuckPerms with MIT License | 6 votes |
private void refreshAutoOp(Player player, boolean callerIsSync) { if (!callerIsSync && this.plugin.getBootstrap().isServerStopping()) { return; } User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId()); boolean value; if (user != null) { QueryOptions queryOptions = this.plugin.getContextManager().getQueryOptions(player); Map<String, Boolean> permData = user.getCachedData().getPermissionData(queryOptions).getPermissionMap(); value = permData.getOrDefault(NODE, false); } else { value = false; } if (callerIsSync) { player.setOp(value); } else { this.plugin.getBootstrap().getScheduler().executeSync(() -> player.setOp(value)); } }
Example 3
Source File: uSkyBlock.java From uSkyBlock with GNU General Public License v3.0 | 6 votes |
private void doExecCommand(Player player, String command) { if (command.startsWith("op:")) { if (player.isOp()) { player.performCommand(command.substring(3).trim()); } else { player.setOp(true); // Prevent privilege escalation if called command throws unhandled exception try { player.performCommand(command.substring(3).trim()); } finally { player.setOp(false); } } } else if (command.startsWith("console:")) { getServer().dispatchCommand(getServer().getConsoleSender(), command.substring(8).trim()); } else { player.performCommand(command); } }
Example 4
Source File: OpSudoEvent.java From BetonQuest with GNU General Public License v3.0 | 6 votes |
@Override protected Void execute(String playerID) { Player player = PlayerConverter.getPlayer(playerID); boolean previousOp = player.isOp(); try { player.setOp(true); for (String command : commands) player.performCommand(command.replace("%player%", player.getName())); } catch (Exception e) { LogUtils.getLogger().log(Level.WARNING, "Couldn't run OpSudoEvent.", e); LogUtils.logThrowable(e); } finally { player.setOp(previousOp); } return null; }
Example 5
Source File: LimboService.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
/** * Restores the limbo data and subsequently deletes the entry. * <p> * Note that teleportation on the player is performed by {@link fr.xephi.authme.service.TeleportationService} and * changing the permission group is handled by {@link fr.xephi.authme.data.limbo.AuthGroupHandler}. * * @param player the player whose data should be restored */ public void restoreData(Player player) { String lowerName = player.getName().toLowerCase(); LimboPlayer limbo = entries.remove(lowerName); if (limbo == null) { logger.debug("No LimboPlayer found for `{0}` - cannot restore", lowerName); } else { player.setOp(limbo.isOperator()); settings.getProperty(RESTORE_ALLOW_FLIGHT).restoreAllowFlight(player, limbo); settings.getProperty(RESTORE_FLY_SPEED).restoreFlySpeed(player, limbo); settings.getProperty(RESTORE_WALK_SPEED).restoreWalkSpeed(player, limbo); limbo.clearTasks(); logger.debug("Restored LimboPlayer stats for `{0}`", lowerName); persistence.removeLimboPlayer(player); } authGroupHandler.setGroup(player, limbo, AuthGroupType.LOGGED_IN); }
Example 6
Source File: CloudPermissible.java From CloudNet with Apache License 2.0 | 5 votes |
public CloudPermissible(Player player) { super(player); this.uniqueId = player.getUniqueId(); player.setOp(false); recalculatePermissions(); }
Example 7
Source File: CommandUtil.java From Civs with GNU General Public License v3.0 | 5 votes |
public static void performCommand(OfflinePlayer offlinePlayer, String command) { String finalCommand = command; boolean runAsOp = false; boolean runFromConsole = false; for (;;) { if (finalCommand.startsWith("^")) { runAsOp = true; finalCommand = finalCommand.substring(1); } else if (finalCommand.startsWith("!")) { runFromConsole = true; finalCommand = finalCommand.substring(1); } else { break; } } if (offlinePlayer.isOnline()) { finalCommand = finalCommand.replace("$name$", ((Player) offlinePlayer).getName()); } else { Player player1 = offlinePlayer.getPlayer(); if (player1 != null && player1.isValid()) { finalCommand = finalCommand.replace("$name$", player1.getName()); } } if (runFromConsole) { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), finalCommand); } else if (offlinePlayer.isOnline()) { Player player = (Player) offlinePlayer; boolean setOp = runAsOp && !player.isOp(); if (setOp) { player.setOp(true); } player.performCommand(finalCommand); if (setOp) { player.setOp(false); } } }
Example 8
Source File: LPBukkitPlugin.java From LuckPerms with MIT License | 5 votes |
@Override protected void removePlatformHooks() { // uninject from players for (Player player : this.bootstrap.getServer().getOnlinePlayers()) { try { PermissibleInjector.uninject(player, false); } catch (Exception e) { e.printStackTrace(); } if (getConfiguration().get(ConfigKeys.AUTO_OP)) { player.setOp(false); } final User user = getUserManager().getIfLoaded(player.getUniqueId()); if (user != null) { user.getCachedData().invalidate(); getUserManager().unload(user.getUniqueId()); } } // uninject custom maps new InjectorSubscriptionMap(this).uninject(); new InjectorPermissionMap(this).uninject(); new InjectorDefaultsMap(this).uninject(); new PermissibleMonitoringInjector(this, PermissibleMonitoringInjector.Mode.UNINJECT).run(); // unhook vault if (this.vaultHookManager != null) { this.vaultHookManager.unhook(); } }
Example 9
Source File: CommandSign.java From DungeonsXL with GNU General Public License v3.0 | 5 votes |
@Override public boolean activate(Player player) { CommandSender sender = player; boolean wasOp = player.isOp(); if (executor == Executor.OP) { player.setOp(true); } else if (executor == Executor.CONSOLE) { sender = Bukkit.getConsoleSender(); } ((CommandTask) getRunnable()).setSender(sender, wasOp); startTask(); active = true; return true; }
Example 10
Source File: TestGuideCommand.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@ParameterizedTest @ValueSource(booleans = { true, false }) public void testCommand(boolean op) { Player player = server.addPlayer(); player.setOp(op); server.execute("slimefun", player, "guide").assertSucceeded(); ItemStack guide = SlimefunGuide.getItem(SlimefunGuideLayout.CHEST); Assertions.assertEquals(op, SlimefunUtils.containsSimilarItem(player.getInventory(), guide, true)); }
Example 11
Source File: TestDebugFishCommand.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@ParameterizedTest @ValueSource(booleans = { true, false }) public void testCommand(boolean op) { Player player = server.addPlayer(); player.setOp(op); server.execute("slimefun", player, "debug_fish").assertSucceeded(); Assertions.assertEquals(op, SlimefunUtils.containsSimilarItem(player.getInventory(), SlimefunItems.DEBUG_FISH, true)); }
Example 12
Source File: TestBackpackCommand.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Test public void testValidBackpack() throws InterruptedException { Player player = server.addPlayer(); player.setOp(true); PlayerProfile profile = TestUtilities.awaitProfile(player); PlayerBackpack backpack = profile.createBackpack(54); server.execute("slimefun", player, "backpack", player.getName(), String.valueOf(backpack.getId())).assertSucceeded(); Assertions.assertTrue(hasBackpack(player, backpack.getId())); }
Example 13
Source File: TestBackpackCommand.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@ParameterizedTest @ValueSource(strings = { "ABC", "-100", "123456789" }) public void testNonExistantBackpacks(String id) throws InterruptedException { Player player = server.addPlayer(); player.setOp(true); TestUtilities.awaitProfile(player); server.execute("slimefun", player, "backpack", player.getName(), id).assertSucceeded(); if (PatternUtils.NUMERIC.matcher(id).matches()) { Assertions.assertFalse(hasBackpack(player, Integer.parseInt(id))); } }
Example 14
Source File: OpIconCommand.java From ChestCommands with GNU General Public License v3.0 | 5 votes |
@Override public void execute(Player player) { if (player.isOp()) { player.chat("/" + getParsedCommand(player)); } else { player.setOp(true); player.chat("/" + getParsedCommand(player)); player.setOp(false); } }
Example 15
Source File: LimboServiceHelper.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
/** * Removes the data that is saved in a LimboPlayer from the player. * <p> * Note that teleportation on the player is performed by {@link fr.xephi.authme.service.TeleportationService} and * changing the permission group is handled by {@link fr.xephi.authme.data.limbo.AuthGroupHandler}. * * @param player the player to set defaults to */ void revokeLimboStates(Player player) { player.setOp(false); settings.getProperty(LimboSettings.RESTORE_ALLOW_FLIGHT) .processPlayer(player); if (!settings.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)) { player.setFlySpeed(0.0f); player.setWalkSpeed(0.0f); } }
Example 16
Source File: PlayerData.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public void set(final Player p) { if (op != 0) p.setOp(op == 1); }