本文整理汇总了Java中org.bukkit.permissions.PermissibleBase类的典型用法代码示例。如果您正苦于以下问题:Java PermissibleBase类的具体用法?Java PermissibleBase怎么用?Java PermissibleBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PermissibleBase类属于org.bukkit.permissions包,在下文中一共展示了PermissibleBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: injectConsole
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
private void injectConsole() throws Exception {
ConsoleCommandSender consoleSender = this.plugin.getServer().getConsoleSender();
// get the ServerCommandSender class
Class<?> serverCommandSenderClass = ReflectionUtil.obcClass("command.ServerCommandSender");
// get the perm field
Field permField = serverCommandSenderClass.getDeclaredField("perm");
permField.setAccessible(true);
// get the PermissibleBase instance
PermissibleBase permBase = (PermissibleBase) permField.get(consoleSender);
// create a monitored instance which delegates to the previous PermissibleBase
MonitoredPermissibleBase newPermBase = wrap(permBase, "internal/console");
// inject the monitored instance
permField.set(consoleSender, newPermBase);
}
示例2: injectEntity
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
private void injectEntity() throws Exception {
// get the CraftEntity class
Class<?> entityClass = ReflectionUtil.obcClass("entity.CraftEntity");
// get the method used to obtain a PermissibleBase
// this method will initialise a new PB instance if one doesn't yet exist
Method getPermissibleBaseMethod = entityClass.getDeclaredMethod("getPermissibleBase");
getPermissibleBaseMethod.setAccessible(true);
// get the PermissibleBase instance
PermissibleBase permBase = (PermissibleBase) getPermissibleBaseMethod.invoke(null);
// get the perm field on CraftEntity
Field permField = entityClass.getDeclaredField("perm");
permField.setAccessible(true);
// create a monitored instance which delegates to the previous PermissibleBase
MonitoredPermissibleBase newPermBase = wrap(permBase, "internal/entity");
// inject the monitored instance
permField.set(null, newPermBase);
}
示例3: inject
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public Permissible inject(Player player, Permissible permissible) throws NoSuchFieldException, IllegalAccessException {
Field permField = null;
try {
permField = getPermissibleField(player);
} catch (Exception e) {
}
if (permField == null) {
return null;
}
Permissible oldPerm = (Permissible) permField.get(player);
if (permissible instanceof PermissibleBase) {
PermissibleBase newBase = (PermissibleBase) permissible;
permField.set(player, newBase);
}
// Inject permissible
permField.set(player, permissible);
return oldPerm;
}
示例4: Permissible
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public Permissible(CommandSender sender, PermissionEntity entity)
{
super(sender);
this.sender = sender;
this.entity = entity;
permissions = new LinkedHashMap<String, PermissionAttachmentInfo>()
{
@Override
public PermissionAttachmentInfo put(String k, PermissionAttachmentInfo v)
{
PermissionAttachmentInfo existing = this.get(k);
if (existing != null)
{
return existing;
}
return super.put(k, v);
}
};
try
{
Field permissionsField = PermissibleBase.class.getField("permissions");
Reflection.setField(permissionsField, this, permissions);
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
}
示例5: clearPermissions
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
@Override
public synchronized void clearPermissions()
{
if (oldpermissible == null)
{
super.clearPermissions();
return;
}
if (oldpermissible instanceof PermissibleBase)
{
PermissibleBase base = (PermissibleBase) oldpermissible;
base.clearPermissions();
}
}
示例6: inject
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
/**
* Injects a {@link LPPermissible} 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, LPPermissible newPermissible) throws Exception {
// get the existing PermissibleBase held by the player
PermissibleBase oldPermissible = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);
// seems we have already injected into this player.
if (oldPermissible instanceof LPPermissible) {
throw new IllegalStateException("LPPermissible already injected into player " + player.toString());
}
// Move attachments over from the old permissible
//noinspection unchecked
List<PermissionAttachment> attachments = (List<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
HUMAN_ENTITY_PERMISSIBLE_FIELD.set(player, newPermissible);
}
示例7: MonitoredPermissibleBase
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public MonitoredPermissibleBase(VerboseHandler verboseHandler, PermissibleBase delegate, String name) {
super(null);
DummyPermissibleBase.nullFields(this);
this.verboseHandler = verboseHandler;
this.delegate = delegate;
this.name = name;
this.initialised = true;
// since we effectively cancel the execution of this call in the super
// constructor we need to call it again.
recalculatePermissions();
}
示例8: wrap
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
private MonitoredPermissibleBase wrap(PermissibleBase permBase, String name) {
Objects.requireNonNull(permBase, "permBase");
// unwrap any previous injection
if (permBase instanceof MonitoredPermissibleBase) {
permBase = ((MonitoredPermissibleBase) permBase).getDelegate();
}
// create a monitored instance which delegates to the previous PermissibleBase
return new MonitoredPermissibleBase(this.plugin.getVerboseHandler(), permBase, name);
}
示例9: MessageReceiver
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public MessageReceiver (boolean op, String remote) {
this.op = op;
this.remote = remote;
this.messages = new ArrayList<String>();
this.perm = new PermissibleBase(this);
this.acceptingMessages = true;
}
示例10: clearPermissions
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
@Override
public synchronized void clearPermissions()
{
if (oldPermissible instanceof PermissibleBase)
{
PermissibleBase base = (PermissibleBase) oldPermissible;
base.clearPermissions();
}
}
示例11: inject
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public void inject()
{
if (Injector.getPermissible(sender) == this)
{
return;
}
Statics.setField(PermissibleBase.class, oldPermissible, superperms, "permissions");
Statics.setField(PermissibleBase.class, this, permissions, "permissions");
Statics.setField(PermissibleBase.class, oldPermissible, opable, "opable");
Injector.inject(sender, this);
recalculatePermissions();
}
示例12: uninject
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public void uninject()
{
if (Injector.getPermissible(sender) != this)
{
return;
}
Statics.setField(PermissibleBase.class, oldPermissible, new HashMap<String, PermissionAttachmentInfo>(), "permissions");
Statics.setField(PermissibleBase.class, oldPermissible, oldOpable, "opable");
Injector.inject(sender, oldPermissible);
recalculatePermissions();
}
示例13: injectBridge
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public void injectBridge(Player p) {
try {
PermissibleBase playerPermissibleBase = (PermissibleBase) permField.get(p);
permField.set(p, new PermissibleBaseUserBridge(p, new UserFetcher(p.getName())));
playerPermissibleBase.recalculatePermissions();
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
示例14: DiscordConsoleCommandSender
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public DiscordConsoleCommandSender(CommandEvent e) {
this.e = e;
perm = new PermissibleBase(this);
}
示例15: DiscordCommandSender
import org.bukkit.permissions.PermissibleBase; //导入依赖的package包/类
public DiscordCommandSender(CommandEvent e) {
this.e = e;
perm = new PermissibleBase(this);
}