2014-04-04 22:03:18 +00:00
|
|
|
/*
|
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-12-13 07:17:00 +00:00
|
|
|
package com.sk89q.wepif;
|
|
|
|
|
2012-01-18 02:17:02 +00:00
|
|
|
import org.bukkit.Location;
|
2011-12-13 07:17:00 +00:00
|
|
|
import org.bukkit.OfflinePlayer;
|
|
|
|
import org.bukkit.entity.Player;
|
2011-12-25 23:36:23 +00:00
|
|
|
import org.bukkit.permissions.Permissible;
|
|
|
|
import org.bukkit.permissions.Permission;
|
|
|
|
import org.bukkit.permissions.PermissionAttachment;
|
|
|
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
2011-12-13 07:17:00 +00:00
|
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
|
2014-04-06 03:09:20 +00:00
|
|
|
import java.util.*;
|
2011-12-13 07:17:00 +00:00
|
|
|
|
|
|
|
public class TestOfflinePermissible implements OfflinePlayer, Permissible {
|
|
|
|
private boolean op;
|
2014-04-06 03:09:20 +00:00
|
|
|
private UUID randomUuid = UUID.randomUUID();
|
2011-12-13 07:17:00 +00:00
|
|
|
|
|
|
|
private final Map<String, Boolean> assignedPermissions = new HashMap<String, Boolean>();
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean isOp() {
|
|
|
|
return op;
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public void setOp(boolean b) {
|
|
|
|
this.op = b;
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean isPermissionSet(String s) {
|
|
|
|
return assignedPermissions.containsKey(s.toLowerCase());
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean isPermissionSet(Permission permission) {
|
|
|
|
return isPermissionSet(permission.getName());
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean hasPermission(String s) {
|
|
|
|
if (isPermissionSet(s)) {
|
|
|
|
return assignedPermissions.get(s.toLowerCase());
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean hasPermission(Permission permission) {
|
|
|
|
return hasPermission(permission.getName());
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b) {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public PermissionAttachment addAttachment(Plugin plugin) {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public PermissionAttachment addAttachment(Plugin plugin, String s, boolean b, int i) {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public PermissionAttachment addAttachment(Plugin plugin, int i) {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public void removeAttachment(PermissionAttachment permissionAttachment) {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public void recalculatePermissions() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
|
|
|
Set<PermissionAttachmentInfo> ret = new HashSet<PermissionAttachmentInfo>();
|
|
|
|
for (Map.Entry<String, Boolean> entry : assignedPermissions.entrySet()) {
|
|
|
|
ret.add(new PermissionAttachmentInfo(this, entry.getKey(), null, entry.getValue()));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPermission(String permission, boolean value) {
|
|
|
|
assignedPermissions.put(permission.toLowerCase(), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void unsetPermission(String permission) {
|
|
|
|
assignedPermissions.remove(permission.toLowerCase());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void clearPermissions() {
|
|
|
|
assignedPermissions.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -- Unneeded OfflinePlayer methods
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean isOnline() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public String getName() {
|
|
|
|
return "Tester";
|
|
|
|
}
|
|
|
|
|
2014-04-06 03:09:20 +00:00
|
|
|
public UUID getUniqueId() {
|
|
|
|
return randomUuid;
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean isBanned() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public void setBanned(boolean b) {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean isWhitelisted() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public void setWhitelisted(boolean b) {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public Player getPlayer() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public long getFirstPlayed() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public long getLastPlayed() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public boolean hasPlayedBefore() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2012-01-18 02:17:02 +00:00
|
|
|
public Location getBedSpawnLocation() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
|
2014-07-29 18:04:04 +00:00
|
|
|
@Override
|
2011-12-13 07:17:00 +00:00
|
|
|
public Map<String, Object> serialize() {
|
|
|
|
throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
}
|
|
|
|
}
|