2020-04-16 04:52:39 +02:00
|
|
|
/*
|
|
|
|
* _____ _ _ _____ _
|
|
|
|
* | __ \| | | | / ____| | |
|
|
|
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
|
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
|
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
|
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
|
|
* | |
|
|
|
|
* |_|
|
|
|
|
* PlotSquared plot management system for Minecraft
|
|
|
|
* Copyright (C) 2020 IntellectualSites
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* (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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-04-11 02:19:18 +02:00
|
|
|
package com.plotsquared.bukkit.player;
|
2015-02-20 12:23:48 +01:00
|
|
|
|
2020-05-24 04:27:20 +02:00
|
|
|
import com.google.common.base.Charsets;
|
2020-04-11 02:19:18 +02:00
|
|
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.PlotSquared;
|
2020-04-16 06:14:33 +02:00
|
|
|
import com.plotsquared.core.configuration.Captions;
|
2020-05-24 04:27:20 +02:00
|
|
|
import com.plotsquared.core.configuration.Settings;
|
2020-04-30 12:01:52 +02:00
|
|
|
import com.plotsquared.core.events.TeleportCause;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.location.Location;
|
|
|
|
import com.plotsquared.core.player.PlotPlayer;
|
2020-04-30 12:01:52 +02:00
|
|
|
import com.plotsquared.core.plot.PlotWeather;
|
2020-07-10 17:32:07 +02:00
|
|
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.util.EconHandler;
|
|
|
|
import com.plotsquared.core.util.MathMan;
|
|
|
|
import com.plotsquared.core.util.StringMan;
|
2019-11-04 20:58:24 +01:00
|
|
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
2019-11-04 22:55:40 +01:00
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
2019-11-04 20:55:55 +01:00
|
|
|
import com.sk89q.worldedit.world.item.ItemType;
|
2019-11-12 21:38:18 +01:00
|
|
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
2019-01-21 09:20:33 +01:00
|
|
|
import io.papermc.lib.PaperLib;
|
2019-02-04 15:02:21 +01:00
|
|
|
import org.bukkit.GameMode;
|
|
|
|
import org.bukkit.Sound;
|
|
|
|
import org.bukkit.WeatherType;
|
2015-07-30 16:25:16 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2018-08-20 12:15:03 +02:00
|
|
|
import org.bukkit.event.Event;
|
2016-06-20 19:02:41 +02:00
|
|
|
import org.bukkit.event.EventException;
|
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
2018-08-10 17:01:10 +02:00
|
|
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
|
|
|
import org.bukkit.plugin.RegisteredListener;
|
2019-05-14 03:57:41 +02:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
2015-07-30 16:25:16 +02:00
|
|
|
|
2018-12-26 19:16:34 +01:00
|
|
|
import java.util.Arrays;
|
2018-05-18 06:48:17 +02:00
|
|
|
import java.util.Set;
|
2016-02-25 15:17:07 +01:00
|
|
|
import java.util.UUID;
|
2018-12-26 19:16:34 +01:00
|
|
|
import java.util.stream.Collectors;
|
2018-05-17 09:46:54 +02:00
|
|
|
|
2019-11-29 03:50:21 +01:00
|
|
|
import static com.sk89q.worldedit.world.gamemode.GameModes.ADVENTURE;
|
|
|
|
import static com.sk89q.worldedit.world.gamemode.GameModes.CREATIVE;
|
|
|
|
import static com.sk89q.worldedit.world.gamemode.GameModes.SPECTATOR;
|
|
|
|
import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL;
|
|
|
|
|
2020-05-27 14:08:48 +02:00
|
|
|
public class BukkitPlayer extends PlotPlayer<Player> {
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2019-04-24 00:48:22 +02:00
|
|
|
private static boolean CHECK_EFFECTIVE = true;
|
2015-02-20 12:23:48 +01:00
|
|
|
public final Player player;
|
2019-02-13 18:05:28 +01:00
|
|
|
private boolean offline;
|
2015-07-28 13:38:49 +02:00
|
|
|
private String name;
|
2016-06-04 23:19:37 +02:00
|
|
|
|
2015-02-21 12:38:44 +01:00
|
|
|
/**
|
2016-03-28 19:28:21 +02:00
|
|
|
* <p>Please do not use this method. Instead use
|
|
|
|
* BukkitUtil.getPlayer(Player), as it caches player objects.</p>
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2019-01-21 09:20:33 +01:00
|
|
|
* @param player Bukkit player instance
|
2015-02-21 12:38:44 +01:00
|
|
|
*/
|
2020-07-10 17:32:07 +02:00
|
|
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player) {
|
|
|
|
this(plotAreaManager, player, false);
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2020-07-10 17:32:07 +02:00
|
|
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player, final boolean offline) {
|
|
|
|
this(plotAreaManager, player, offline, true);
|
2020-05-27 14:08:48 +02:00
|
|
|
}
|
|
|
|
|
2020-07-10 17:32:07 +02:00
|
|
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final Player player, final boolean offline, final boolean realPlayer) {
|
|
|
|
super(plotAreaManager);
|
2015-08-01 22:11:28 +02:00
|
|
|
this.player = player;
|
|
|
|
this.offline = offline;
|
2020-05-27 14:08:48 +02:00
|
|
|
if (realPlayer) {
|
|
|
|
super.populatePersistentMetaMap();
|
|
|
|
}
|
2015-08-01 22:11:28 +02:00
|
|
|
}
|
2016-06-04 23:19:37 +02:00
|
|
|
|
2019-11-04 22:55:40 +01:00
|
|
|
@Override public Actor toActor() {
|
|
|
|
return BukkitAdapter.adapt(player);
|
|
|
|
}
|
|
|
|
|
2020-05-27 14:08:48 +02:00
|
|
|
@Override public Player getPlatformPlayer() {
|
|
|
|
return this.player;
|
|
|
|
}
|
|
|
|
|
2019-09-08 20:02:45 +02:00
|
|
|
@NotNull @Override public Location getLocation() {
|
2019-01-21 09:20:33 +01:00
|
|
|
final Location location = super.getLocation();
|
2016-03-23 02:41:37 +01:00
|
|
|
return location == null ? BukkitUtil.getLocation(this.player) : location;
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2019-05-14 03:57:41 +02:00
|
|
|
@NotNull @Override public UUID getUUID() {
|
2020-05-24 04:27:20 +02:00
|
|
|
if (Settings.UUID.OFFLINE) {
|
|
|
|
if (Settings.UUID.FORCE_LOWERCASE) {
|
|
|
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" +
|
|
|
|
getName().toLowerCase()).getBytes(Charsets.UTF_8));
|
|
|
|
} else {
|
|
|
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" +
|
|
|
|
getName()).getBytes(Charsets.UTF_8));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return player.getUniqueId();
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|
2016-06-04 23:19:37 +02:00
|
|
|
|
|
|
|
@Override public long getLastPlayed() {
|
|
|
|
return this.player.getLastPlayed();
|
|
|
|
}
|
|
|
|
|
2019-09-08 20:02:45 +02:00
|
|
|
@Override public boolean canTeleport(@NotNull final Location location) {
|
|
|
|
final org.bukkit.Location to = BukkitUtil.getLocation(location);
|
2019-01-21 09:20:33 +01:00
|
|
|
final org.bukkit.Location from = player.getLocation();
|
2016-06-20 19:02:41 +02:00
|
|
|
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
2018-08-20 12:15:03 +02:00
|
|
|
callEvent(event);
|
2016-06-20 19:02:41 +02:00
|
|
|
if (event.isCancelled() || !event.getTo().equals(to)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
event = new PlayerTeleportEvent(player, to, from);
|
2018-08-20 12:15:03 +02:00
|
|
|
callEvent(event);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-18 00:49:09 +02:00
|
|
|
@Override
|
|
|
|
public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) {
|
|
|
|
player.sendTitle(title, subtitle, fadeIn, stay, fadeOut);
|
|
|
|
}
|
|
|
|
|
2019-08-06 22:08:56 +02:00
|
|
|
private void callEvent(@NotNull final Event event) {
|
2019-01-21 09:20:33 +01:00
|
|
|
final RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
|
|
|
|
for (final RegisteredListener listener : listeners) {
|
2020-07-07 12:56:43 +02:00
|
|
|
if (listener.getPlugin().getName().equals(PlotSquared.platform().getPluginName())) {
|
2016-06-20 19:02:41 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
listener.callEvent(event);
|
2019-01-21 09:20:33 +01:00
|
|
|
} catch (final EventException e) {
|
2016-06-20 19:02:41 +02:00
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 09:20:33 +01:00
|
|
|
@Override public boolean hasPermission(final String permission) {
|
2020-06-24 15:26:06 +02:00
|
|
|
if (this.offline && EconHandler.getEconHandler() != null) {
|
|
|
|
return EconHandler.getEconHandler().hasPermission(getName(), permission);
|
2015-08-20 06:56:25 +02:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.player.hasPermission(permission);
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2019-01-21 09:20:33 +01:00
|
|
|
@Override public int hasPermissionRange(final String stub, final int range) {
|
2019-08-07 02:35:36 +02:00
|
|
|
if (hasPermission(Captions.PERMISSION_ADMIN.getTranslated())) {
|
2018-05-17 09:46:54 +02:00
|
|
|
return Integer.MAX_VALUE;
|
|
|
|
}
|
2019-01-21 09:20:33 +01:00
|
|
|
final String[] nodes = stub.split("\\.");
|
|
|
|
final StringBuilder n = new StringBuilder();
|
2018-05-17 09:46:54 +02:00
|
|
|
for (int i = 0; i < (nodes.length - 1); i++) {
|
|
|
|
n.append(nodes[i]).append(".");
|
2019-08-07 02:35:36 +02:00
|
|
|
if (!stub.equals(n + Captions.PERMISSION_STAR.getTranslated())) {
|
|
|
|
if (hasPermission(n + Captions.PERMISSION_STAR.getTranslated())) {
|
2018-05-17 09:46:54 +02:00
|
|
|
return Integer.MAX_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hasPermission(stub + ".*")) {
|
|
|
|
return Integer.MAX_VALUE;
|
|
|
|
}
|
|
|
|
int max = 0;
|
2019-04-22 17:06:41 +02:00
|
|
|
if (CHECK_EFFECTIVE) {
|
|
|
|
boolean hasAny = false;
|
|
|
|
String stubPlus = stub + ".";
|
2020-04-30 12:01:52 +02:00
|
|
|
final Set<PermissionAttachmentInfo> effective = player.getEffectivePermissions();
|
2019-04-22 17:06:41 +02:00
|
|
|
if (!effective.isEmpty()) {
|
|
|
|
for (PermissionAttachmentInfo attach : effective) {
|
|
|
|
String permStr = attach.getPermission();
|
|
|
|
if (permStr.startsWith(stubPlus)) {
|
|
|
|
hasAny = true;
|
|
|
|
String end = permStr.substring(stubPlus.length());
|
|
|
|
if (MathMan.isInteger(end)) {
|
|
|
|
int val = Integer.parseInt(end);
|
|
|
|
if (val > range) {
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
if (val > max) {
|
|
|
|
max = val;
|
|
|
|
}
|
2019-02-22 03:14:48 +01:00
|
|
|
}
|
2018-05-18 06:48:17 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-22 17:06:41 +02:00
|
|
|
if (hasAny) {
|
|
|
|
return max;
|
2018-05-17 09:46:54 +02:00
|
|
|
}
|
2019-04-22 17:06:41 +02:00
|
|
|
// Workaround
|
|
|
|
for (PermissionAttachmentInfo attach : effective) {
|
|
|
|
String permStr = attach.getPermission();
|
2019-04-22 17:53:24 +02:00
|
|
|
if (permStr.startsWith("plots.") && !permStr.equals("plots.use")) {
|
|
|
|
return max;
|
|
|
|
}
|
2019-04-22 17:06:41 +02:00
|
|
|
}
|
|
|
|
CHECK_EFFECTIVE = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = range; i > 0; i--) {
|
|
|
|
if (hasPermission(stub + "." + i)) {
|
|
|
|
return i;
|
2018-05-17 09:46:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
2019-01-21 09:20:33 +01:00
|
|
|
@Override public boolean isPermissionSet(final String permission) {
|
2017-01-12 21:22:28 +01:00
|
|
|
return this.player.isPermissionSet(permission);
|
|
|
|
}
|
|
|
|
|
2020-02-20 16:03:17 +01:00
|
|
|
@Override public void sendMessage(String message) {
|
2020-04-30 12:01:52 +02:00
|
|
|
message = message.replace('\u2010', '%').replace('\u2020', '&').replace('\u2030', '&');
|
2019-02-13 18:05:28 +01:00
|
|
|
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (
|
2018-08-10 17:01:10 +02:00
|
|
|
System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
2016-06-16 02:31:25 +02:00
|
|
|
setMeta("lastMessage", message);
|
2016-06-19 08:14:13 +02:00
|
|
|
setMeta("lastMessageTime", System.currentTimeMillis());
|
2016-06-16 02:31:25 +02:00
|
|
|
this.player.sendMessage(message);
|
|
|
|
}
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2020-04-30 12:01:52 +02:00
|
|
|
@Override
|
|
|
|
public void teleport(@NotNull final Location location, @NotNull final TeleportCause cause) {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
|
2015-09-13 06:04:31 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-04-30 12:01:52 +02:00
|
|
|
final org.bukkit.Location bukkitLocation =
|
2020-07-10 12:21:29 +02:00
|
|
|
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorldName()), location.getX() + 0.5,
|
2020-04-30 12:01:52 +02:00
|
|
|
location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch());
|
2020-03-15 12:22:49 +01:00
|
|
|
PaperLib.teleportAsync(player, bukkitLocation, getTeleportCause(cause));
|
2015-02-23 02:32:27 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
|
|
@Override public String getName() {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.name == null) {
|
|
|
|
this.name = this.player.getName();
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.name;
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
|
|
@Override public boolean isOnline() {
|
2016-03-23 02:41:37 +01:00
|
|
|
return !this.offline && this.player.isOnline();
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
|
|
@Override public void setCompassTarget(Location location) {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.player.setCompassTarget(
|
2020-07-10 12:21:29 +02:00
|
|
|
new org.bukkit.Location(BukkitUtil.getWorld(location.getWorldName()), location.getX(),
|
2018-08-10 17:01:10 +02:00
|
|
|
location.getY(), location.getZ()));
|
2015-02-22 13:46:47 +01:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
|
|
|
@Override public Location getLocationFull() {
|
2016-03-23 02:41:37 +01:00
|
|
|
return BukkitUtil.getLocationFull(this.player);
|
2015-02-23 12:37:36 +01:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2019-08-06 22:08:56 +02:00
|
|
|
@Override public void setWeather(@NotNull final PlotWeather weather) {
|
2015-09-13 06:04:31 +02:00
|
|
|
switch (weather) {
|
2015-07-30 16:25:16 +02:00
|
|
|
case CLEAR:
|
2016-03-23 02:41:37 +01:00
|
|
|
this.player.setPlayerWeather(WeatherType.CLEAR);
|
2016-03-23 18:09:13 +01:00
|
|
|
break;
|
2016-02-14 02:01:18 +01:00
|
|
|
case RAIN:
|
2016-03-23 02:41:37 +01:00
|
|
|
this.player.setPlayerWeather(WeatherType.DOWNFALL);
|
2016-03-23 18:09:13 +01:00
|
|
|
break;
|
2015-07-30 16:25:16 +02:00
|
|
|
case RESET:
|
2016-03-23 18:09:13 +01:00
|
|
|
default:
|
|
|
|
this.player.resetPlayerWeather();
|
|
|
|
break;
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2019-11-29 03:50:21 +01:00
|
|
|
@NotNull @Override public com.sk89q.worldedit.world.gamemode.GameMode getGameMode() {
|
2016-03-23 02:41:37 +01:00
|
|
|
switch (this.player.getGameMode()) {
|
2015-07-30 16:25:16 +02:00
|
|
|
case ADVENTURE:
|
2019-11-29 03:50:21 +01:00
|
|
|
return ADVENTURE;
|
2015-07-30 16:25:16 +02:00
|
|
|
case CREATIVE:
|
2019-11-29 03:50:21 +01:00
|
|
|
return CREATIVE;
|
2015-07-30 16:25:16 +02:00
|
|
|
case SPECTATOR:
|
2019-11-29 03:50:21 +01:00
|
|
|
return SPECTATOR;
|
2015-07-30 16:25:16 +02:00
|
|
|
case SURVIVAL:
|
2016-03-23 18:09:13 +01:00
|
|
|
default:
|
2019-11-29 03:50:21 +01:00
|
|
|
return SURVIVAL;
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2020-04-30 12:01:52 +02:00
|
|
|
@Override
|
|
|
|
public void setGameMode(@NotNull final com.sk89q.worldedit.world.gamemode.GameMode gameMode) {
|
2019-11-29 03:50:21 +01:00
|
|
|
if (ADVENTURE.equals(gameMode)) {
|
|
|
|
this.player.setGameMode(GameMode.ADVENTURE);
|
|
|
|
} else if (CREATIVE.equals(gameMode)) {
|
|
|
|
this.player.setGameMode(GameMode.CREATIVE);
|
|
|
|
} else if (SPECTATOR.equals(gameMode)) {
|
|
|
|
this.player.setGameMode(GameMode.SPECTATOR);
|
|
|
|
} else {
|
|
|
|
this.player.setGameMode(GameMode.SURVIVAL);
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2019-01-21 09:20:33 +01:00
|
|
|
@Override public void setTime(final long time) {
|
2015-11-15 03:30:52 +01:00
|
|
|
if (time != Long.MAX_VALUE) {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.player.setPlayerTime(time, false);
|
2015-11-15 03:30:52 +01:00
|
|
|
} else {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.player.resetPlayerTime();
|
2015-11-15 03:30:52 +01:00
|
|
|
}
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
2016-06-16 02:08:01 +02:00
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public boolean getFlight() {
|
2016-06-16 02:08:01 +02:00
|
|
|
return player.getAllowFlight();
|
|
|
|
}
|
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public void setFlight(boolean fly) {
|
|
|
|
this.player.setAllowFlight(fly);
|
|
|
|
}
|
|
|
|
|
2019-11-04 20:55:55 +01:00
|
|
|
@Override public void playMusic(@NotNull final Location location, @NotNull final ItemType id) {
|
2019-11-12 21:38:18 +01:00
|
|
|
if (id == ItemTypes.AIR) {
|
2018-12-26 19:16:34 +01:00
|
|
|
// Let's just stop all the discs because why not?
|
2019-02-04 15:02:21 +01:00
|
|
|
for (final Sound sound : Arrays.stream(Sound.values())
|
|
|
|
.filter(sound -> sound.name().contains("DISC")).collect(Collectors.toList())) {
|
2018-12-26 19:16:34 +01:00
|
|
|
player.stopSound(sound);
|
|
|
|
}
|
|
|
|
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, Material.AIR);
|
|
|
|
} else {
|
|
|
|
// this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id.to(Material.class));
|
2019-02-04 15:02:21 +01:00
|
|
|
this.player.playSound(BukkitUtil.getLocation(location),
|
2019-11-04 20:55:55 +01:00
|
|
|
Sound.valueOf(BukkitAdapter.adapt(id).name()), Float.MAX_VALUE, 1f);
|
2018-12-26 19:16:34 +01:00
|
|
|
}
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
2018-08-10 17:01:10 +02:00
|
|
|
|
2019-01-21 09:20:33 +01:00
|
|
|
@Override public void kick(final String message) {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.player.kickPlayer(message);
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
2016-02-28 02:11:18 +01:00
|
|
|
|
|
|
|
@Override public void stopSpectating() {
|
2019-11-29 03:50:21 +01:00
|
|
|
if (getGameMode() == SPECTATOR) {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.player.setSpectatorTarget(null);
|
2016-02-28 02:11:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-10 17:01:10 +02:00
|
|
|
@Override public boolean isBanned() {
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.player.isBanned();
|
2015-10-07 08:33:33 +02:00
|
|
|
}
|
2020-03-15 12:22:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
public PlayerTeleportEvent.TeleportCause getTeleportCause(@NotNull final TeleportCause cause) {
|
|
|
|
switch (cause) {
|
|
|
|
case COMMAND:
|
|
|
|
return PlayerTeleportEvent.TeleportCause.COMMAND;
|
|
|
|
case PLUGIN:
|
|
|
|
return PlayerTeleportEvent.TeleportCause.PLUGIN;
|
2020-04-30 12:01:52 +02:00
|
|
|
default:
|
|
|
|
return PlayerTeleportEvent.TeleportCause.UNKNOWN;
|
2020-03-15 12:22:49 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-20 12:23:48 +01:00
|
|
|
}
|