mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-23 19:16:40 +01:00
Handle OfflinePlayer causes.
This commit is contained in:
parent
8bb28b5ef1
commit
69a0f26a52
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* WorldGuard, a suite of tools for Minecraft
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldGuard 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/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldguard.bukkit;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
class BukkitOfflinePlayer extends LocalPlayer {
|
||||
|
||||
private final OfflinePlayer player;
|
||||
|
||||
BukkitOfflinePlayer(OfflinePlayer offlinePlayer) {
|
||||
this.player = offlinePlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return player.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGroup(String group) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getPosition() {
|
||||
return Vector.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(String msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ban(String msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -73,6 +73,7 @@
|
||||
import com.sk89q.worldguard.util.task.Task;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Block;
|
||||
@ -851,6 +852,18 @@ public LocalPlayer wrapPlayer(Player player) {
|
||||
return new BukkitPlayer(this, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap a player as a LocalPlayer.
|
||||
*
|
||||
* <p>This implementation is incomplete -- permissions cannot be checked.</p>
|
||||
*
|
||||
* @param player The player to wrap
|
||||
* @return The wrapped player
|
||||
*/
|
||||
public LocalPlayer wrapOfflinePlayer(OfflinePlayer player) {
|
||||
return new BukkitOfflinePlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure WorldGuard's loggers.
|
||||
*/
|
||||
|
@ -43,6 +43,7 @@
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -108,6 +109,8 @@ private RegionAssociable createRegionAssociable(Cause cause) {
|
||||
|
||||
if (rootCause instanceof Player) {
|
||||
return getPlugin().wrapPlayer((Player) rootCause);
|
||||
} else if (rootCause instanceof OfflinePlayer) {
|
||||
return getPlugin().wrapOfflinePlayer((OfflinePlayer) rootCause);
|
||||
} else if (rootCause instanceof Entity) {
|
||||
RegionQuery query = getPlugin().getRegionContainer().createQuery();
|
||||
return new DelayedRegionOverlapAssociation(query, ((Entity) rootCause).getLocation());
|
||||
|
Loading…
Reference in New Issue
Block a user