cn.nukkit.permission.PermissibleBase Java Examples
The following examples show how to use
cn.nukkit.permission.PermissibleBase.
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: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Player(SourceInterface interfaz, Long clientID, String ip, int port) { super(null, new CompoundTag()); this.interfaz = interfaz; this.perm = new PermissibleBase(this); this.server = Server.getInstance(); this.lastBreak = -1; this.ip = ip; this.port = port; this.clientID = clientID; this.loaderId = Level.generateChunkLoaderId(this); this.chunksPerTick = this.server.getConfig("chunk-sending.per-tick", 4); this.spawnThreshold = this.server.getConfig("chunk-sending.spawn-threshold", 56); this.spawnPosition = null; this.gamemode = this.server.getGamemode(); this.setLevel(this.server.getDefaultLevel()); this.viewDistance = this.server.getViewDistance(); this.chunkRadius = viewDistance; //this.newPosition = new Vector3(0, 0, 0); this.boundingBox = new SimpleAxisAlignedBB(0, 0, 0, 0, 0, 0); this.lastSkinChange = -1; this.uuid = null; this.rawUUID = null; this.creationTime = System.currentTimeMillis(); }
Example #2
Source File: PermissibleMonitoringInjector.java From LuckPerms with MIT License | 6 votes |
private PermissibleBase transform(PermissibleBase permBase, String name) { Objects.requireNonNull(permBase, "permBase"); // don't bother injecting if already setup. if (this.mode == Mode.INJECT && permBase instanceof MonitoredPermissibleBase && ((MonitoredPermissibleBase) permBase).plugin == this.plugin) { return null; } // unwrap any previous injection if (permBase instanceof MonitoredPermissibleBase) { permBase = ((MonitoredPermissibleBase) permBase).getDelegate(); } // if the mode is uninject, just return the unwrapped PermissibleBase if (this.mode == Mode.UNINJECT) { return permBase; } // create a monitored instance which delegates to the previous PermissibleBase return new MonitoredPermissibleBase(this.plugin, permBase, name); }
Example #3
Source File: PermissibleMonitoringInjector.java From LuckPerms with MIT License | 6 votes |
private void injectConsole() throws Exception { ConsoleCommandSender consoleSender = this.plugin.getBootstrap().getServer().getConsoleSender(); // get the perm field Field permField = ConsoleCommandSender.class.getDeclaredField("perm"); permField.setAccessible(true); // get the PermissibleBase instance PermissibleBase permBase = (PermissibleBase) permField.get(consoleSender); // create a new instance which delegates to the previous PermissibleBase PermissibleBase newPermBase = transform(permBase, "internal/console"); if (newPermBase == null) { return; } // inject the new instance permField.set(consoleSender, newPermBase); }
Example #4
Source File: Player.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Player(SourceInterface interfaz, Long clientID, String ip, int port) { super(null, new CompoundTag()); this.interfaz = interfaz; this.windows = new HashMap<>(); this.perm = new PermissibleBase(this); this.server = Server.getInstance(); this.lastBreak = Long.MAX_VALUE; this.ip = ip; this.port = port; this.clientID = clientID; this.loaderId = Level.generateChunkLoaderId(this); this.chunksPerTick = (int) this.server.getConfig("chunk-sending.per-tick", 4); this.spawnThreshold = (int) this.server.getConfig("chunk-sending.spawn-threshold", 56); this.spawnPosition = null; this.gamemode = this.server.getGamemode(); this.setLevel(this.server.getDefaultLevel()); this.viewDistance = this.server.getViewDistance(); this.chunkRadius = viewDistance; //this.newPosition = new Vector3(0, 0, 0); this.boundingBox = new SimpleAxisAlignedBB(0, 0, 0, 0, 0, 0); this.uuid = null; this.rawUUID = null; this.creationTime = System.currentTimeMillis(); }
Example #5
Source File: BlockEntityCommandBlock.java From Jupiter with GNU General Public License v3.0 | 5 votes |
public BlockEntityCommandBlock(FullChunk chunk, CompoundTag nbt) { super(chunk, nbt); if (!nbt.contains("CustomName")) { nbt.putString("CustomName", ""); } if (!nbt.contains("commandBlockMode")) { nbt.putInt("commandBlockMode", 0); } if (!nbt.contains("Command")) { nbt.putString("Command", ""); } if (!nbt.contains("LastOutput")) { nbt.putString("LastOutput", ""); } if (!nbt.contains("powered")) { nbt.putBoolean("powered", false); } if (!nbt.contains("auto")) { nbt.putBoolean("auto", false); } if (!nbt.contains("conditionalMode")) { nbt.putBoolean("conditionalMode", false); } this.perm = new PermissibleBase(this); this.scheduleUpdate(); }
Example #6
Source File: PermissibleInjector.java From LuckPerms with MIT License | 5 votes |
/** * Injects a {@link LuckPermsPermissible} into a {@link Player}. * * @param player the player to inject into * @param newPermissible the permissible to inject * @throws Exception propagates any exceptions which were thrown during injection */ public static void inject(Player player, LuckPermsPermissible newPermissible) throws Exception { // get the existing PermissibleBase held by the player PermissibleBase oldPermissible = (PermissibleBase) PLAYER_PERMISSIBLE_FIELD.get(player); // seems we have already injected into this player. if (oldPermissible instanceof LuckPermsPermissible) { throw new IllegalStateException("LPPermissible already injected into player " + player.toString()); } // Move attachments over from the old permissible //noinspection unchecked Set<PermissionAttachment> attachments = (Set<PermissionAttachment>) PERMISSIBLE_BASE_ATTACHMENTS_FIELD.get(oldPermissible); newPermissible.convertAndAddAttachments(attachments); attachments.clear(); oldPermissible.clearPermissions(); // Setup the new permissible newPermissible.getActive().set(true); newPermissible.setOldPermissible(oldPermissible); // inject the new instance PLAYER_PERMISSIBLE_FIELD.set(player, newPermissible); }
Example #7
Source File: DummyPermissibleBase.java From LuckPerms with MIT License | 5 votes |
public static void copyFields(PermissibleBase from, PermissibleBase to) { try { ATTACHMENTS_FIELD.set(to, ATTACHMENTS_FIELD.get(from)); PERMISSIONS_FIELD.set(to, PERMISSIONS_FIELD.get(from)); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
Example #8
Source File: MonitoredPermissibleBase.java From LuckPerms with MIT License | 5 votes |
public MonitoredPermissibleBase(LuckPermsPlugin plugin, PermissibleBase delegate, String name) { super(null); DummyPermissibleBase.copyFields(delegate, this); this.plugin = plugin; this.delegate = delegate; this.name = name; this.initialised = true; }
Example #9
Source File: ConsoleCommandSender.java From Jupiter with GNU General Public License v3.0 | 4 votes |
public ConsoleCommandSender() { this.perm = new PermissibleBase(this); }
Example #10
Source File: ConsoleCommandSender.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ConsoleCommandSender() { this.perm = new PermissibleBase(this); }
Example #11
Source File: LuckPermsPermissible.java From LuckPerms with MIT License | 4 votes |
PermissibleBase getOldPermissible() { return this.oldPermissible; }
Example #12
Source File: LuckPermsPermissible.java From LuckPerms with MIT License | 4 votes |
void setOldPermissible(PermissibleBase oldPermissible) { this.oldPermissible = oldPermissible; }
Example #13
Source File: MonitoredPermissibleBase.java From LuckPerms with MIT License | 4 votes |
PermissibleBase getDelegate() { return this.delegate; }
Example #14
Source File: ConsoleCommandSender.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public ConsoleCommandSender() { this.perm = new PermissibleBase(this); }