2014-04-03 03:03:52 +00:00
|
|
|
/*
|
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
|
2014-04-03 03:03:52 +00:00
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2014-04-03 03:03:52 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* 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 General Public License for more details.
|
2014-04-03 03:03:52 +00:00
|
|
|
*
|
2020-08-25 01:31:47 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2014-04-04 22:03:18 +00:00
|
|
|
*/
|
2014-04-03 03:03:52 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit.bukkit;
|
|
|
|
|
2019-11-21 20:37:56 +00:00
|
|
|
import com.boydti.fawe.config.Caption;
|
2019-09-15 16:50:37 +00:00
|
|
|
import com.boydti.fawe.config.Settings;
|
2018-08-15 14:04:40 +00:00
|
|
|
import com.boydti.fawe.object.RunnableVal;
|
|
|
|
import com.boydti.fawe.util.TaskManager;
|
2014-04-03 03:03:52 +00:00
|
|
|
import com.sk89q.util.StringUtil;
|
2020-09-15 01:18:06 +00:00
|
|
|
import com.sk89q.wepif.VaultResolver;
|
2018-08-15 14:04:40 +00:00
|
|
|
import com.sk89q.worldedit.WorldEdit;
|
2014-07-10 22:49:34 +00:00
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
2018-12-23 16:19:33 +00:00
|
|
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
2014-07-10 22:49:34 +00:00
|
|
|
import com.sk89q.worldedit.entity.BaseEntity;
|
2018-06-16 05:29:48 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
2019-10-23 04:23:52 +00:00
|
|
|
import com.sk89q.worldedit.extent.Extent;
|
2014-04-03 03:03:52 +00:00
|
|
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
|
|
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
2018-12-23 16:19:33 +00:00
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
|
|
|
import com.sk89q.worldedit.math.Vector3;
|
2014-07-28 03:44:05 +00:00
|
|
|
import com.sk89q.worldedit.session.SessionKey;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.util.HandSide;
|
2019-10-05 09:06:18 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.WorldEditText;
|
2020-01-31 22:44:50 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.component.TextUtils;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
2019-11-21 19:56:10 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
2020-01-08 18:36:12 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
2019-07-06 00:46:48 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.text.adapter.bukkit.TextAdapter;
|
2020-01-08 18:36:12 +00:00
|
|
|
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
|
|
|
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
|
2018-06-16 05:29:48 +00:00
|
|
|
import com.sk89q.worldedit.world.World;
|
2019-03-26 17:41:09 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
2018-12-23 16:19:33 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
|
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
2018-07-19 12:41:26 +00:00
|
|
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
|
|
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
2014-07-28 03:44:05 +00:00
|
|
|
import org.bukkit.Bukkit;
|
2014-07-10 22:49:34 +00:00
|
|
|
import org.bukkit.Location;
|
2018-08-15 14:04:40 +00:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.entity.Item;
|
2014-07-10 22:49:34 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2018-08-15 14:04:40 +00:00
|
|
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
2014-07-10 22:49:34 +00:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
2018-08-15 14:04:40 +00:00
|
|
|
import org.bukkit.inventory.PlayerInventory;
|
2020-09-21 15:07:35 +00:00
|
|
|
import org.bukkit.permissions.PermissionAttachment;
|
2014-04-03 03:03:52 +00:00
|
|
|
|
2019-10-30 11:26:52 +00:00
|
|
|
import java.util.HashMap;
|
2020-01-31 22:44:50 +00:00
|
|
|
import java.util.Locale;
|
2020-10-05 17:41:41 +00:00
|
|
|
import java.util.Map;
|
2019-10-30 11:26:52 +00:00
|
|
|
import java.util.UUID;
|
2020-10-05 17:41:41 +00:00
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
2020-10-14 18:56:16 +00:00
|
|
|
import javax.annotation.Nonnull;
|
2020-01-31 22:44:50 +00:00
|
|
|
import javax.annotation.Nullable;
|
2019-10-30 11:26:52 +00:00
|
|
|
|
2018-06-16 05:29:48 +00:00
|
|
|
public class BukkitPlayer extends AbstractPlayerActor {
|
2014-07-28 03:44:05 +00:00
|
|
|
|
2020-09-28 17:11:28 +00:00
|
|
|
private final Player player;
|
|
|
|
private final WorldEditPlugin plugin;
|
|
|
|
private final PermissionAttachment permAttachment;
|
2020-10-14 18:56:16 +00:00
|
|
|
/**
|
|
|
|
* This constructs a new {@link BukkitPlayer} for the given {@link Player}.
|
|
|
|
*
|
|
|
|
* @param player The corresponding {@link Player} or null if you need a null WorldEdit player for some reason.
|
|
|
|
*/
|
|
|
|
public BukkitPlayer(@Nullable Player player) {
|
|
|
|
super(player != null ? getExistingMap(WorldEditPlugin.getInstance(), player) : new ConcurrentHashMap<>());
|
2019-11-02 18:31:32 +00:00
|
|
|
this.plugin = WorldEditPlugin.getInstance();
|
|
|
|
this.player = player;
|
2020-10-01 13:33:34 +00:00
|
|
|
this.permAttachment = plugin.getPermissionAttachmentManager().getOrAddAttachment(player);
|
2019-03-30 21:32:10 +00:00
|
|
|
}
|
|
|
|
|
2020-10-14 18:56:16 +00:00
|
|
|
/**
|
|
|
|
* This constructs a new {@link BukkitPlayer} for the given {@link Player}.
|
|
|
|
*
|
|
|
|
* @param plugin The running instance of {@link WorldEditPlugin}
|
|
|
|
* @param player The corresponding {@link Player} or null if you need a null WorldEdit player for some reason.
|
|
|
|
*/
|
|
|
|
public BukkitPlayer(@Nonnull WorldEditPlugin plugin, @Nullable Player player) {
|
2014-04-03 03:03:52 +00:00
|
|
|
this.plugin = plugin;
|
|
|
|
this.player = player;
|
2020-10-01 13:33:34 +00:00
|
|
|
this.permAttachment = plugin.getPermissionAttachmentManager().getOrAddAttachment(player);
|
2020-10-14 18:56:16 +00:00
|
|
|
if (player != null && Settings.IMP.CLIPBOARD.USE_DISK) {
|
2019-09-15 16:50:37 +00:00
|
|
|
loadClipboardFromDisk();
|
|
|
|
}
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
2019-11-02 18:31:32 +00:00
|
|
|
private static Map<String, Object> getExistingMap(WorldEditPlugin plugin, Player player) {
|
|
|
|
BukkitPlayer cached = plugin.getCachedPlayer(player);
|
|
|
|
if (cached != null) {
|
|
|
|
return cached.getRawMeta();
|
|
|
|
}
|
|
|
|
return new ConcurrentHashMap<>();
|
|
|
|
}
|
|
|
|
|
2014-07-28 03:44:05 +00:00
|
|
|
@Override
|
|
|
|
public UUID getUniqueId() {
|
|
|
|
return player.getUniqueId();
|
|
|
|
}
|
|
|
|
|
2014-04-03 03:03:52 +00:00
|
|
|
@Override
|
2018-06-17 07:50:04 +00:00
|
|
|
public BaseItemStack getItemInHand(HandSide handSide) {
|
|
|
|
ItemStack itemStack = handSide == HandSide.MAIN_HAND
|
2019-11-19 21:25:36 +00:00
|
|
|
? player.getInventory().getItemInMainHand()
|
|
|
|
: player.getInventory().getItemInOffHand();
|
2018-07-19 02:55:02 +00:00
|
|
|
return BukkitAdapter.adapt(itemStack);
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
2014-06-27 20:14:44 +00:00
|
|
|
@Override
|
2018-08-10 10:29:06 +00:00
|
|
|
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
|
2018-06-17 07:50:04 +00:00
|
|
|
ItemStack itemStack = handSide == HandSide.MAIN_HAND
|
2019-11-19 21:25:36 +00:00
|
|
|
? player.getInventory().getItemInMainHand()
|
|
|
|
: player.getInventory().getItemInOffHand();
|
2018-08-10 10:29:06 +00:00
|
|
|
return BukkitAdapter.asBlockState(itemStack).toBaseBlock();
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return player.getName();
|
|
|
|
}
|
|
|
|
|
2018-12-18 07:36:53 +00:00
|
|
|
@Override
|
|
|
|
public String getDisplayName() {
|
2019-11-19 21:25:36 +00:00
|
|
|
return player.getDisplayName();
|
2018-12-18 07:36:53 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 03:03:52 +00:00
|
|
|
@Override
|
2018-06-18 07:53:33 +00:00
|
|
|
public void giveItem(BaseItemStack itemStack) {
|
2019-11-19 21:25:36 +00:00
|
|
|
final PlayerInventory inv = player.getInventory();
|
2018-08-15 14:04:40 +00:00
|
|
|
ItemStack newItem = BukkitAdapter.adapt(itemStack);
|
2019-01-31 15:08:58 +00:00
|
|
|
if (itemStack.getType().getId().equalsIgnoreCase(WorldEdit.getInstance().getConfiguration().wandItem)) {
|
2018-08-15 14:04:40 +00:00
|
|
|
inv.remove(newItem);
|
|
|
|
}
|
2019-11-19 21:25:36 +00:00
|
|
|
final ItemStack item = player.getInventory().getItemInMainHand();
|
|
|
|
player.getInventory().setItemInMainHand(newItem);
|
2019-03-26 17:41:09 +00:00
|
|
|
HashMap<Integer, ItemStack> overflow = inv.addItem(item);
|
|
|
|
if (!overflow.isEmpty()) {
|
|
|
|
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
|
|
|
@Override
|
|
|
|
public void run(Object value) {
|
|
|
|
for (Map.Entry<Integer, ItemStack> entry : overflow.entrySet()) {
|
|
|
|
ItemStack stack = entry.getValue();
|
|
|
|
if (stack.getType() != Material.AIR && stack.getAmount() > 0) {
|
|
|
|
Item
|
2019-11-19 21:25:36 +00:00
|
|
|
dropped = player.getWorld().dropItem(player.getLocation(), stack);
|
2019-03-26 17:41:09 +00:00
|
|
|
PlayerDropItemEvent event = new PlayerDropItemEvent(player, dropped);
|
2020-03-29 09:53:31 +00:00
|
|
|
Bukkit.getPluginManager().callEvent(event);
|
2019-03-26 17:41:09 +00:00
|
|
|
if (event.isCancelled()) {
|
|
|
|
dropped.remove();
|
2018-08-15 14:04:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-03-26 17:41:09 +00:00
|
|
|
}
|
|
|
|
});
|
2018-08-15 14:04:40 +00:00
|
|
|
}
|
2019-11-19 21:25:36 +00:00
|
|
|
player.updateInventory();
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void printRaw(String msg) {
|
|
|
|
for (String part : msg.split("\n")) {
|
2019-11-19 21:25:36 +00:00
|
|
|
player.sendMessage(part);
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-05 21:07:20 +00:00
|
|
|
@Override
|
|
|
|
public void print(String msg) {
|
|
|
|
for (String part : msg.split("\n")) {
|
2020-10-05 17:41:41 +00:00
|
|
|
player.sendMessage("§d" + part);
|
2020-03-05 21:07:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void printDebug(String msg) {
|
|
|
|
for (String part : msg.split("\n")) {
|
2020-10-05 17:41:41 +00:00
|
|
|
player.sendMessage("§7" + part);
|
2020-03-05 21:07:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void printError(String msg) {
|
|
|
|
for (String part : msg.split("\n")) {
|
2020-10-05 17:41:41 +00:00
|
|
|
player.sendMessage("§c" + part);
|
2020-03-05 21:07:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-10-05 17:41:41 +00:00
|
|
|
|
2019-07-06 00:46:48 +00:00
|
|
|
@Override
|
|
|
|
public void print(Component component) {
|
2019-12-25 02:34:20 +00:00
|
|
|
component = Caption.color(TranslatableComponent.of("prefix", component), getLocale());
|
2021-04-04 17:56:57 +00:00
|
|
|
TextAdapter.sendMessage(player, WorldEditText.format(component, getLocale()));
|
2019-07-06 00:46:48 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 03:03:52 +00:00
|
|
|
@Override
|
2020-07-13 17:09:03 +00:00
|
|
|
public boolean trySetPosition(Vector3 pos, float pitch, float yaw) {
|
2019-11-19 21:25:36 +00:00
|
|
|
org.bukkit.World world = player.getWorld();
|
2019-10-23 04:23:52 +00:00
|
|
|
if (pos instanceof com.sk89q.worldedit.util.Location) {
|
|
|
|
com.sk89q.worldedit.util.Location loc = (com.sk89q.worldedit.util.Location) pos;
|
|
|
|
Extent extent = loc.getExtent();
|
|
|
|
if (extent instanceof World) {
|
|
|
|
world = Bukkit.getWorld(((World) extent).getName());
|
|
|
|
}
|
|
|
|
}
|
2020-07-24 19:29:08 +00:00
|
|
|
org.bukkit.World finalWorld = world;
|
|
|
|
return TaskManager.IMP.sync(() -> player.teleport(new Location(finalWorld, pos.getX(), pos.getY(), pos.getZ(), yaw, pitch)));
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String[] getGroups() {
|
2019-11-19 21:25:36 +00:00
|
|
|
return plugin.getPermissionsResolver().getGroups(player);
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BlockBag getInventoryBlockBag() {
|
2019-11-19 21:25:36 +00:00
|
|
|
return new BukkitPlayerBlockBag(player);
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
2018-07-19 12:41:26 +00:00
|
|
|
@Override
|
|
|
|
public GameMode getGameMode() {
|
2019-05-01 07:03:37 +00:00
|
|
|
return GameModes.get(player.getGameMode().name().toLowerCase(Locale.ROOT));
|
2018-07-19 12:41:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setGameMode(GameMode gameMode) {
|
2019-05-01 07:03:37 +00:00
|
|
|
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase(Locale.ROOT)));
|
2018-07-19 12:41:26 +00:00
|
|
|
}
|
|
|
|
|
2014-04-03 03:03:52 +00:00
|
|
|
@Override
|
|
|
|
public boolean hasPermission(String perm) {
|
2019-11-22 15:30:45 +00:00
|
|
|
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp())
|
|
|
|
|| plugin.getPermissionsResolver().hasPermission(
|
2020-01-31 22:44:50 +00:00
|
|
|
player.getWorld().getName(), player, perm);
|
2019-11-19 21:23:47 +00:00
|
|
|
}
|
|
|
|
|
2019-06-30 18:56:32 +00:00
|
|
|
@Override
|
|
|
|
public void setPermission(String permission, boolean value) {
|
|
|
|
/*
|
|
|
|
* Permissions are used to managing WorldEdit region restrictions
|
|
|
|
* - The `/wea` command will give/remove the required bypass permission
|
|
|
|
*/
|
2020-09-21 15:07:35 +00:00
|
|
|
boolean usesuperperms = VaultResolver.perms == null;
|
2020-09-15 23:07:52 +00:00
|
|
|
if (VaultResolver.perms != null) {
|
|
|
|
if (value) {
|
|
|
|
if (!VaultResolver.perms.playerAdd(player, permission)) {
|
2020-09-21 15:07:35 +00:00
|
|
|
usesuperperms = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!VaultResolver.perms.playerRemove(player, permission)) {
|
|
|
|
usesuperperms = true;
|
2020-09-15 01:18:06 +00:00
|
|
|
}
|
2019-06-30 18:56:32 +00:00
|
|
|
}
|
2020-09-21 15:07:35 +00:00
|
|
|
}
|
|
|
|
if (usesuperperms) {
|
|
|
|
permAttachment.setPermission(permission, value);
|
2019-06-30 18:56:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-03 03:03:52 +00:00
|
|
|
@Override
|
2018-06-16 05:29:48 +00:00
|
|
|
public World getWorld() {
|
2019-11-19 21:25:36 +00:00
|
|
|
return BukkitAdapter.adapt(player.getWorld());
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void dispatchCUIEvent(CUIEvent event) {
|
|
|
|
String[] params = event.getParameters();
|
|
|
|
String send = event.getTypeId();
|
|
|
|
if (params.length > 0) {
|
|
|
|
send = send + "|" + StringUtil.joinString(params, "|");
|
|
|
|
}
|
2019-11-19 21:25:36 +00:00
|
|
|
player.sendPluginMessage(plugin, WorldEditPlugin.CUI_PLUGIN_CHANNEL, send.getBytes(CUIChannelListener.UTF_8_CHARSET));
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
2020-01-31 22:44:50 +00:00
|
|
|
public Player getPlayer() {
|
|
|
|
return player;
|
|
|
|
}
|
|
|
|
|
2019-11-21 07:57:32 +00:00
|
|
|
@Override
|
|
|
|
public boolean isAllowedToFly() {
|
|
|
|
return player.getAllowFlight();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setFlying(boolean flying) {
|
|
|
|
player.setFlying(flying);
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|
|
|
|
|
2014-04-28 06:34:39 +00:00
|
|
|
@Override
|
|
|
|
public BaseEntity getState() {
|
|
|
|
throw new UnsupportedOperationException("Cannot create a state from this object");
|
|
|
|
}
|
|
|
|
|
2014-04-27 02:48:21 +00:00
|
|
|
@Override
|
|
|
|
public com.sk89q.worldedit.util.Location getLocation() {
|
2019-11-19 21:25:36 +00:00
|
|
|
Location nativeLocation = player.getLocation();
|
2018-12-23 16:19:33 +00:00
|
|
|
Vector3 position = BukkitAdapter.asVector(nativeLocation);
|
2014-07-10 22:49:34 +00:00
|
|
|
return new com.sk89q.worldedit.util.Location(
|
|
|
|
getWorld(),
|
|
|
|
position,
|
2014-07-16 03:10:14 +00:00
|
|
|
nativeLocation.getYaw(),
|
|
|
|
nativeLocation.getPitch());
|
2014-04-27 02:48:21 +00:00
|
|
|
}
|
2014-07-16 02:47:47 +00:00
|
|
|
|
2018-12-21 06:56:10 +00:00
|
|
|
@Override
|
|
|
|
public boolean setLocation(com.sk89q.worldedit.util.Location location) {
|
2019-11-19 21:25:36 +00:00
|
|
|
return player.teleport(BukkitAdapter.adapt(location));
|
2018-12-21 06:56:10 +00:00
|
|
|
}
|
|
|
|
|
2019-10-13 11:47:26 +00:00
|
|
|
@Override
|
|
|
|
public Locale getLocale() {
|
2019-12-09 19:07:57 +00:00
|
|
|
return TextUtils.getLocaleByMinecraftTag(player.getLocale());
|
2019-10-13 11:47:26 +00:00
|
|
|
}
|
|
|
|
|
2020-01-08 18:36:12 +00:00
|
|
|
@Override
|
|
|
|
public void sendAnnouncements() {
|
|
|
|
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() == null) {
|
|
|
|
printError(TranslatableComponent.of("worldedit.version.bukkit.unsupported-adapter",
|
|
|
|
TextComponent.of("https://intellectualsites.github.io/download/fawe.html", TextColor.AQUA)
|
2020-01-31 22:44:50 +00:00
|
|
|
.clickEvent(ClickEvent.openUrl("https://intellectualsites.github.io/download/fawe.html"))));
|
2020-01-08 18:36:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-16 02:47:47 +00:00
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public <T> T getFacet(Class<? extends T> cls) {
|
|
|
|
return null;
|
|
|
|
}
|
2014-07-28 03:44:05 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public SessionKey getSessionKey() {
|
2019-11-21 07:57:32 +00:00
|
|
|
return new SessionKeyImpl(this.player.getUniqueId(), player.getName());
|
2014-07-28 03:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static class SessionKeyImpl implements SessionKey {
|
|
|
|
// If not static, this will leak a reference
|
|
|
|
|
|
|
|
private final UUID uuid;
|
|
|
|
private final String name;
|
|
|
|
|
|
|
|
private SessionKeyImpl(UUID uuid, String name) {
|
|
|
|
this.uuid = uuid;
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public UUID getUniqueId() {
|
|
|
|
return uuid;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isActive() {
|
|
|
|
// This is a thread safe call on CraftBukkit because it uses a
|
|
|
|
// CopyOnWrite list for the list of players, but the Bukkit
|
|
|
|
// specification doesn't require thread safety (though the
|
|
|
|
// spec is extremely incomplete)
|
2018-07-12 12:23:03 +00:00
|
|
|
return Bukkit.getServer().getPlayer(uuid) != null;
|
2014-07-28 03:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isPersistent() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-12-27 00:39:10 +00:00
|
|
|
@Override
|
2019-06-06 22:39:51 +00:00
|
|
|
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
|
2019-11-19 21:25:36 +00:00
|
|
|
Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
|
2018-12-27 00:39:10 +00:00
|
|
|
if (block == null) {
|
2019-11-19 21:25:36 +00:00
|
|
|
player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
|
2018-12-27 00:39:10 +00:00
|
|
|
} else {
|
2019-11-19 21:25:36 +00:00
|
|
|
player.sendBlockChange(loc, BukkitAdapter.adapt(block));
|
2018-12-27 00:39:10 +00:00
|
|
|
if (block instanceof BaseBlock && ((BaseBlock) block).hasNbtData()) {
|
|
|
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
|
|
|
if (adapter != null) {
|
|
|
|
if (block.getBlockType() == BlockTypes.STRUCTURE_BLOCK) {
|
2020-01-10 13:26:24 +00:00
|
|
|
adapter.sendFakeNBT(player, pos, ((BaseBlock) block).getNbtData());
|
2018-12-27 00:39:10 +00:00
|
|
|
adapter.sendFakeOP(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-14 03:05:16 +00:00
|
|
|
|
|
|
|
@Override
|
2019-11-21 19:56:10 +00:00
|
|
|
public void sendTitle(Component title, Component sub) {
|
|
|
|
String titleStr = WorldEditText.reduceToText(title, getLocale());
|
|
|
|
String subStr = WorldEditText.reduceToText(sub, getLocale());
|
|
|
|
player.sendTitle(titleStr, subStr, 0, 70, 20);
|
2019-09-14 03:05:16 +00:00
|
|
|
}
|
2019-10-30 11:26:52 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void unregister() {
|
2019-11-19 21:25:36 +00:00
|
|
|
player.removeMetadata("WE", WorldEditPlugin.getInstance());
|
2020-09-28 17:11:28 +00:00
|
|
|
plugin.getPermissionAttachmentManager().removeAttachment(player);
|
2020-03-30 16:41:41 +00:00
|
|
|
super.unregister();
|
2019-10-30 11:26:52 +00:00
|
|
|
}
|
2014-04-03 03:03:52 +00:00
|
|
|
}
|