Implemented new permission system

This commit is contained in:
Dinnerbone
2011-07-17 17:19:41 +01:00
parent cc9ccc8976
commit 5d2a195835
5 changed files with 151 additions and 1 deletions

View File

@@ -1,15 +1,23 @@
package org.bukkit.craftbukkit.entity;
import java.util.Set;
import net.minecraft.server.EntityHuman;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.permissions.PermissibleBase;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private CraftInventoryPlayer inventory;
private final PermissibleBase perm = new PermissibleBase(this);
private boolean op;
public CraftHumanEntity(final CraftServer server, final EntityHuman entity) {
super(server, entity);
@@ -55,4 +63,57 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
public int getSleepTicks() {
return getHandle().sleepTicks;
}
public boolean isOp() {
return op;
}
public boolean isPermissionSet(String name) {
return perm.isPermissionSet(name);
}
public boolean isPermissionSet(Permission perm) {
return this.perm.isPermissionSet(perm);
}
public boolean hasPermission(String name) {
return perm.hasPermission(name);
}
public boolean hasPermission(Permission perm) {
return this.perm.hasPermission(perm);
}
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
return perm.addAttachment(plugin, name, value);
}
public PermissionAttachment addAttachment(Plugin plugin) {
return perm.addAttachment(plugin);
}
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
return perm.addAttachment(plugin, name, value, ticks);
}
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
return perm.addAttachment(plugin, ticks);
}
public void removeAttachment(PermissionAttachment attachment) {
perm.removeAttachment(attachment);
}
public void recalculatePermissions() {
perm.recalculatePermissions();
}
public void setOp(boolean value) {
this.op = value;
recalculatePermissions();
}
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
return perm.getEffectivePermissions();
}
}

View File

@@ -25,15 +25,20 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
public class CraftPlayer extends CraftHumanEntity implements Player {
public CraftPlayer(CraftServer server, EntityPlayer entity) {
super(server, entity);
}
@Override
public boolean isOp() {
return server.getHandle().isOp(getName());
}
@Override
public void setOp(boolean value) {
server.getHandle().e(getName());
}
public boolean isPlayer() {
return true;
}