mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-23 23:55:33 +02:00
Compare commits
2 Commits
feat/v7/gu
...
chore/v7/g
Author | SHA1 | Date | |
---|---|---|---|
![]() |
17cbcf394c | ||
![]() |
3d87ee41b3 |
@@ -28,7 +28,6 @@ package com.plotsquared.bukkit.inject;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import com.plotsquared.bukkit.BukkitPlatform;
|
||||
import com.plotsquared.bukkit.listener.SingleWorldListener;
|
||||
@@ -44,8 +43,6 @@ import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.fawe.FaweRegionManager;
|
||||
import com.plotsquared.bukkit.util.fawe.FaweSchematicHandler;
|
||||
import com.plotsquared.bukkit.util.gui.BukkitPlotInventory;
|
||||
import com.plotsquared.bukkit.util.gui.BukkitPlotInventoryProvider;
|
||||
import com.plotsquared.core.PlotPlatform;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
@@ -73,7 +70,6 @@ import com.plotsquared.core.util.RegionManager;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.SetupUtils;
|
||||
import com.plotsquared.core.util.WorldUtil;
|
||||
import com.plotsquared.core.util.gui.PlotInventoryProvider;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -107,7 +103,6 @@ public class BukkitModule extends AbstractModule {
|
||||
bind(InventoryUtil.class).to(BukkitInventoryUtil.class);
|
||||
bind(SetupUtils.class).to(BukkitSetupUtils.class);
|
||||
bind(WorldUtil.class).to(BukkitUtil.class);
|
||||
bind(new TypeLiteral<PlotInventoryProvider<?, ?>>(){}).to(BukkitPlotInventoryProvider.class);
|
||||
install(new FactoryModuleBuilder()
|
||||
.implement(ProgressSubscriber.class, DefaultProgressSubscriber.class)
|
||||
.build(ProgressSubscriberFactory.class));
|
||||
|
@@ -364,11 +364,6 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
this.player.closeInventory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from PlotSquared's {@link TeleportCause} to Bukkit's {@link PlayerTeleportEvent.TeleportCause}
|
||||
*
|
||||
|
@@ -31,7 +31,6 @@ import org.bukkit.Bukkit;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BukkitWorld implements World<org.bukkit.World> {
|
||||
|
||||
@@ -140,14 +139,6 @@ public class BukkitWorld implements World<org.bukkit.World> {
|
||||
return world.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof BukkitWorld;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "BukkitWorld(world=" + this.world + ")";
|
||||
}
|
||||
|
@@ -105,11 +105,6 @@ public class FaweRegionManager extends BukkitRegionManager {
|
||||
delegate.swap(pos1, pos2, swapPos, whenDone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(CuboidRegion region, int extendBiome, BiomeType biome, String world, Runnable whenDone) {
|
||||
delegate.setBiome(region, extendBiome, biome, world, whenDone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(CuboidRegion region, int extendBiome, BiomeType biome, PlotArea area, Runnable whenDone) {
|
||||
delegate.setBiome(region, extendBiome, biome, area.getWorldName(), whenDone);
|
||||
|
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.bukkit.util.gui;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.plotsquared.bukkit.BukkitPlatform;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.caption.Caption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotItemStack;
|
||||
import com.plotsquared.core.util.gui.PlotInventory;
|
||||
import com.plotsquared.core.util.gui.PlotInventoryClickHandler;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
/**
|
||||
* Implementation of the {@link PlotInventory} for the bukkit platform.
|
||||
*/
|
||||
public class BukkitPlotInventory extends PlotInventory<Player, ItemStack> {
|
||||
|
||||
private static Listener INVENTORY_LISTENER;
|
||||
private static final Map<UUID, BukkitPlotInventory> INVENTORIES = new WeakHashMap<>();
|
||||
|
||||
private final ItemStack[] items;
|
||||
final PlotInventoryClickHandler[] clickHandlers;
|
||||
Inventory nativeInventory;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected BukkitPlotInventory(
|
||||
PlotPlayer<Player> player, final int size, final Caption titleCaption,
|
||||
final TagResolver... titleResolvers
|
||||
) {
|
||||
super(player, size, titleCaption, titleResolvers);
|
||||
this.items = new ItemStack[size];
|
||||
this.clickHandlers = new PlotInventoryClickHandler[size];
|
||||
this.nativeInventory = Bukkit.createInventory(player.getPlatformPlayer(), size(),
|
||||
BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(MiniMessage.miniMessage().deserialize(
|
||||
titleCaption().getComponent(player), titleResolvers()
|
||||
))
|
||||
);
|
||||
|
||||
if (INVENTORY_LISTENER == null) {
|
||||
INVENTORY_LISTENER = new BukkitPlotInventoryListener(INVENTORIES);
|
||||
BukkitPlatform bukkitPlatform = ((BukkitPlatform) PlotSquared.platform());
|
||||
bukkitPlatform.getServer().getPluginManager().registerEvents(INVENTORY_LISTENER, bukkitPlatform);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(final int slot, final PlotItemStack item, final PlotInventoryClickHandler onClick) {
|
||||
Preconditions.checkElementIndex(slot, size(), "Slot must be in range (0, " + size() + ")");
|
||||
this.items[slot] = toPlatformItem(item);
|
||||
this.clickHandlers[slot] = onClick;
|
||||
this.nativeInventory.setItem(slot, this.items[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItem(final PlotItemStack item, final PlotInventoryClickHandler onClick) {
|
||||
// TODO: probably needs more love (who doesn't)
|
||||
int slot = -1;
|
||||
// try to fill stacks
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (Objects.equals(items[i], toPlatformItem(item))) {
|
||||
slot = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// search for empty slots
|
||||
if (slot == -1) {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] == null || items[i].getType() == Material.AIR) {
|
||||
slot = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Preconditions.checkElementIndex(slot, size());
|
||||
this.items[slot] = toPlatformItem(item);
|
||||
this.clickHandlers[slot] = onClick;
|
||||
this.nativeInventory.setItem(slot, this.items[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
INVENTORIES.put(player().getUUID(), this);
|
||||
player().getPlatformPlayer().openInventory(this.nativeInventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (Objects.equals(player().getPlatformPlayer().getOpenInventory().getTopInventory(), this.nativeInventory)) {
|
||||
player().getPlatformPlayer().closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack toPlatformItem(final PlotItemStack item) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
Material material = BukkitAdapter.adapt(item.getType());
|
||||
if (material == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack stack = new ItemStack(material, item.getAmount());
|
||||
ItemMeta meta = null;
|
||||
if (item.getName() != null) {
|
||||
meta = stack.getItemMeta();
|
||||
Component nameComponent = BukkitUtil.MINI_MESSAGE.deserialize(item.getName());
|
||||
meta.setDisplayName(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(nameComponent));
|
||||
}
|
||||
if (item.getLore() != null) {
|
||||
if (meta == null) {
|
||||
meta = stack.getItemMeta();
|
||||
}
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String entry : item.getLore()) {
|
||||
lore.add(BukkitUtil.LEGACY_COMPONENT_SERIALIZER.serialize(BukkitUtil.MINI_MESSAGE.deserialize(entry)));
|
||||
}
|
||||
meta.setLore(lore);
|
||||
}
|
||||
if (meta != null) {
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.bukkit.util.gui;
|
||||
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotItemStack;
|
||||
import com.plotsquared.core.util.gui.PlotInventoryClickHandler;
|
||||
import com.plotsquared.core.util.gui.PlotInventoryClickType;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitPlotInventoryListener implements Listener {
|
||||
|
||||
private static final EnumMap<ClickType, PlotInventoryClickType> CLICK_MAPPING = new EnumMap<>(ClickType.class);
|
||||
|
||||
static {
|
||||
CLICK_MAPPING.put(ClickType.LEFT, PlotInventoryClickType.LEFT);
|
||||
CLICK_MAPPING.put(ClickType.RIGHT, PlotInventoryClickType.RIGHT);
|
||||
CLICK_MAPPING.put(ClickType.SHIFT_LEFT, PlotInventoryClickType.SHIFT_LEFT);
|
||||
CLICK_MAPPING.put(ClickType.SHIFT_RIGHT, PlotInventoryClickType.SHIFT_RIGHT);
|
||||
CLICK_MAPPING.put(ClickType.MIDDLE, PlotInventoryClickType.MIDDLE);
|
||||
}
|
||||
|
||||
private final Map<UUID, BukkitPlotInventory> inventories;
|
||||
|
||||
public BukkitPlotInventoryListener(final Map<UUID, BukkitPlotInventory> inventories) {
|
||||
this.inventories = inventories;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(final org.bukkit.event.inventory.InventoryClickEvent event) {
|
||||
final PlotPlayer<Player> player = BukkitUtil.adapt((Player) event.getWhoClicked());
|
||||
|
||||
BukkitPlotInventory currentInventory = inventories.get(player.getUUID());
|
||||
if (currentInventory == null) {
|
||||
return;
|
||||
}
|
||||
if (!Objects.equals(event.getClickedInventory(), currentInventory.nativeInventory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int slot = event.getRawSlot();
|
||||
if (slot < 0 || slot >= currentInventory.size()) {
|
||||
return;
|
||||
}
|
||||
PlotInventoryClickType clickType = CLICK_MAPPING.getOrDefault(event.getClick(), PlotInventoryClickType.OTHER);
|
||||
event.setCancelled(true);
|
||||
|
||||
final PlotInventoryClickHandler clickHandler = currentInventory.clickHandlers[slot];
|
||||
if (clickHandler == null) {
|
||||
return;
|
||||
}
|
||||
final ItemStack item = event.getCurrentItem();
|
||||
if (item == null) {
|
||||
clickHandler.handle(null, clickType);
|
||||
return;
|
||||
}
|
||||
clickHandler.handle(new PlotItemStack(
|
||||
BukkitAdapter.asItemType(item.getType()),
|
||||
item.getAmount(),
|
||||
item.getItemMeta().getDisplayName(),
|
||||
item.getItemMeta().hasLore() ? item.getItemMeta().getLore().toArray(String[]::new) : new String[0]
|
||||
), clickType);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
final PlotPlayer<Player> player = BukkitUtil.adapt((Player) event.getPlayer());
|
||||
BukkitPlotInventory currentInventory = inventories.get(player.getUUID());
|
||||
if (currentInventory == null) {
|
||||
return;
|
||||
}
|
||||
currentInventory.nativeInventory = null;
|
||||
inventories.remove(player.getUUID());
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.bukkit.util.gui;
|
||||
|
||||
import com.plotsquared.core.configuration.caption.Caption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.util.gui.PlotInventory;
|
||||
import com.plotsquared.core.util.gui.PlotInventoryProvider;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BukkitPlotInventoryProvider implements PlotInventoryProvider<Player, ItemStack> {
|
||||
|
||||
@Override
|
||||
public PlotInventory<Player, ItemStack> createInventory(
|
||||
PlotPlayer<?> player,
|
||||
final int size,
|
||||
final Caption titleCaption,
|
||||
final TagResolver... titleResolvers
|
||||
) {
|
||||
return new BukkitPlotInventory((PlotPlayer<Player>) player, size, titleCaption, titleResolvers);
|
||||
}
|
||||
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
|
||||
/**
|
||||
* @deprecated In favor of "/plot toggle chat" and
|
||||
* scheduled for removal within the next major release.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
@CommandDeclaration(command = "chat",
|
||||
usage = "/plot chat",
|
||||
permission = "plots.chat",
|
||||
category = CommandCategory.CHAT,
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Chat extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer<?> player, String[] args) {
|
||||
PlotArea area = player.getPlotAreaAbs();
|
||||
check(area, TranslatableCaption.of("errors.not_in_plot_world"));
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("errors.deprecated_commands"),
|
||||
TagResolver.resolver("replacement", Tag.inserting(Component.text("/plot toggle chat")))
|
||||
);
|
||||
if (player.getPlotAreaAbs().isForcingPlotChat()) {
|
||||
player.sendMessage(TranslatableCaption.of("chat.plot_chat_forced"));
|
||||
return true;
|
||||
}
|
||||
MainCommand.getInstance().toggle.chat(this, player, args, null, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -229,41 +229,4 @@ public class Load extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link TimeUtil#secToTime(long)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.6.2")
|
||||
public String secToTime(long time) {
|
||||
StringBuilder toreturn = new StringBuilder();
|
||||
if (time >= 33868800) {
|
||||
int years = (int) (time / 33868800);
|
||||
time -= years * 33868800;
|
||||
toreturn.append(years).append("y ");
|
||||
}
|
||||
if (time >= 604800) {
|
||||
int weeks = (int) (time / 604800);
|
||||
time -= weeks * 604800;
|
||||
toreturn.append(weeks).append("w ");
|
||||
}
|
||||
if (time >= 86400) {
|
||||
int days = (int) (time / 86400);
|
||||
time -= days * 86400;
|
||||
toreturn.append(days).append("d ");
|
||||
}
|
||||
if (time >= 3600) {
|
||||
int hours = (int) (time / 3600);
|
||||
time -= hours * 3600;
|
||||
toreturn.append(hours).append("h ");
|
||||
}
|
||||
if (time >= 60) {
|
||||
int minutes = (int) (time / 60);
|
||||
time -= minutes * 60;
|
||||
toreturn.append(minutes).append("m ");
|
||||
}
|
||||
if (toreturn.length() == 0 || (time > 0)) {
|
||||
toreturn.append(time).append("s ");
|
||||
}
|
||||
return toreturn.toString().trim();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -82,7 +82,6 @@ public class MainCommand extends Command {
|
||||
commands.add(Buy.class);
|
||||
if (Settings.Web.LEGACY_WEBINTERFACE) {
|
||||
LOGGER.warn("Legacy webinterface is used. Please note that it will be removed in future.");
|
||||
commands.add(Save.class);
|
||||
}
|
||||
commands.add(Load.class);
|
||||
commands.add(Confirm.class);
|
||||
@@ -131,7 +130,6 @@ public class MainCommand extends Command {
|
||||
commands.add(Move.class);
|
||||
commands.add(Condense.class);
|
||||
commands.add(Copy.class);
|
||||
commands.add(Chat.class);
|
||||
commands.add(Trim.class);
|
||||
commands.add(Done.class);
|
||||
commands.add(Continue.class);
|
||||
|
@@ -27,18 +27,32 @@ package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.gui.PlotMusicInventory;
|
||||
import com.plotsquared.core.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
||||
import com.plotsquared.core.events.Result;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.permissions.Permission;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotInventory;
|
||||
import com.plotsquared.core.plot.PlotItemStack;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.MusicFlag;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.plotsquared.core.util.InventoryUtil;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.gui.PlotInventoryProvider;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
@CommandDeclaration(command = "music",
|
||||
permission = "plots.music",
|
||||
usage = "/plot music",
|
||||
@@ -46,16 +60,20 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Music extends SubCommand {
|
||||
|
||||
private static final Collection<String> DISCS = Arrays
|
||||
.asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp",
|
||||
"music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal",
|
||||
"music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait", "music_disc_otherside",
|
||||
"music_disc_pigstep"
|
||||
);
|
||||
|
||||
private final InventoryUtil inventoryUtil;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
private final PlotInventoryProvider<?, ?> inventoryProvider;
|
||||
|
||||
@Inject
|
||||
public Music(
|
||||
final @NonNull EventDispatcher eventDispatcher,
|
||||
final PlotInventoryProvider<?, ?> inventoryProvider
|
||||
) {
|
||||
public Music(final @Nullable InventoryUtil inventoryUtil, final @NonNull EventDispatcher eventDispatcher) {
|
||||
this.inventoryUtil = inventoryUtil;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
this.inventoryProvider = inventoryProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,8 +99,85 @@ public class Music extends SubCommand {
|
||||
);
|
||||
return true;
|
||||
}
|
||||
PlotInventory inv = new PlotInventory(
|
||||
this.inventoryUtil,
|
||||
player,
|
||||
2,
|
||||
TranslatableCaption.of("plotjukebox.jukebox_header").getComponent(player)
|
||||
) {
|
||||
@Override
|
||||
public boolean onClick(int index) {
|
||||
PlotItemStack item = getItem(index);
|
||||
if (item == null) {
|
||||
return true;
|
||||
}
|
||||
if (item.getType() == ItemTypes.BEDROCK) {
|
||||
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
|
||||
.createFlagInstance(item.getType());
|
||||
PlotFlagRemoveEvent event = eventDispatcher.callFlagRemove(plotFlag, plot);
|
||||
if (event.getEventResult() == Result.DENY) {
|
||||
getPlayer().sendMessage(
|
||||
TranslatableCaption.of("events.event_denied"),
|
||||
TagResolver.resolver("value", Tag.inserting(Component.text("Music removal")))
|
||||
);
|
||||
return true;
|
||||
}
|
||||
plot.removeFlag(event.getFlag());
|
||||
getPlayer().sendMessage(
|
||||
TranslatableCaption.of("flag.flag_removed"),
|
||||
TagResolver.builder()
|
||||
.tag("flag", Tag.inserting(Component.text("music")))
|
||||
.tag("value", Tag.inserting(Component.text("music_disc")))
|
||||
.build()
|
||||
);
|
||||
} else if (item.getName().toLowerCase(Locale.ENGLISH).contains("disc")) {
|
||||
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
|
||||
.createFlagInstance(item.getType());
|
||||
PlotFlagAddEvent event = eventDispatcher.callFlagAdd(plotFlag, plot);
|
||||
if (event.getEventResult() == Result.DENY) {
|
||||
getPlayer().sendMessage(
|
||||
TranslatableCaption.of("events.event_denied"),
|
||||
TagResolver.resolver("value", Tag.inserting(Component.text("Music addition")))
|
||||
);
|
||||
return true;
|
||||
}
|
||||
plot.setFlag(event.getFlag());
|
||||
getPlayer().sendMessage(
|
||||
TranslatableCaption.of("flag.flag_added"),
|
||||
TagResolver.builder()
|
||||
.tag("flag", Tag.inserting(Component.text("music")))
|
||||
.tag("value", Tag.inserting(Component.text(event.getFlag().getValue().toString())))
|
||||
.build()
|
||||
);
|
||||
} else {
|
||||
getPlayer().sendMessage(TranslatableCaption.of("flag.flag_not_added"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
int index = 0;
|
||||
|
||||
new PlotMusicInventory<>(inventoryProvider, player, plot, eventDispatcher).open();
|
||||
for (final String disc : DISCS) {
|
||||
final String name = String.format("<gold>%s</gold>", disc);
|
||||
final String[] lore = {TranslatableCaption.of("plotjukebox.click_to_play").getComponent(player)};
|
||||
ItemType type = ItemTypes.get(disc);
|
||||
if (type == null) {
|
||||
continue;
|
||||
}
|
||||
final PlotItemStack item = new PlotItemStack(type, 1, name, lore);
|
||||
if (inv.setItemChecked(index, item)) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
// Always add the cancel button
|
||||
// if (player.getMeta("music") != null) {
|
||||
String name = TranslatableCaption.of("plotjukebox.cancel_music").getComponent(player);
|
||||
String[] lore = {TranslatableCaption.of("plotjukebox.reset_music").getComponent(player)};
|
||||
inv.setItem(index, new PlotItemStack("bedrock", 1, name, lore));
|
||||
// }
|
||||
|
||||
inv.openInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -1,141 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.command;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.permissions.Permission;
|
||||
import com.plotsquared.core.player.MetaDataAccess;
|
||||
import com.plotsquared.core.player.PlayerMetaDataKeys;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotId;
|
||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||
import com.plotsquared.core.util.Permissions;
|
||||
import com.plotsquared.core.util.SchematicHandler;
|
||||
import com.plotsquared.core.util.task.RunnableVal;
|
||||
import com.plotsquared.core.util.task.TaskManager;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @deprecated In favor of "/plot download" (Arkitektonika) and scheduled
|
||||
* for removal within the next major release.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.0.9")
|
||||
@CommandDeclaration(command = "save",
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.save")
|
||||
public class Save extends SubCommand {
|
||||
|
||||
private final PlotAreaManager plotAreaManager;
|
||||
private final SchematicHandler schematicHandler;
|
||||
|
||||
@Inject
|
||||
public Save(
|
||||
final @NonNull PlotAreaManager plotAreaManager,
|
||||
final @NonNull SchematicHandler schematicHandler
|
||||
) {
|
||||
this.plotAreaManager = plotAreaManager;
|
||||
this.schematicHandler = schematicHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer<?> player, final String[] args) {
|
||||
final String world = player.getLocation().getWorldName();
|
||||
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||
player.sendMessage(TranslatableCaption.of("errors.not_in_plot_world"));
|
||||
return false;
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
player.sendMessage(TranslatableCaption.of("errors.not_in_plot"));
|
||||
return false;
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
player.sendMessage(TranslatableCaption.of("info.plot_unowned"));
|
||||
return false;
|
||||
}
|
||||
if (plot.getVolume() > Integer.MAX_VALUE) {
|
||||
player.sendMessage(TranslatableCaption.of("schematics.schematic_too_large"));
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_SAVE)) {
|
||||
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
player.sendMessage(TranslatableCaption.of("errors.wait_for_timer"));
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
this.schematicHandler.getCompoundTag(plot)
|
||||
.whenComplete((compoundTag, throwable) -> {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
String time = (System.currentTimeMillis() / 1000) + "";
|
||||
Location[] corners = plot.getCorners();
|
||||
corners[0] = corners[0].withY(plot.getArea().getMinBuildHeight());
|
||||
corners[1] = corners[1].withY(plot.getArea().getMaxBuildHeight());
|
||||
int size = (corners[1].getX() - corners[0].getX()) + 1;
|
||||
PlotId id = plot.getId();
|
||||
String world1 = plot.getArea().toString().replaceAll(";", "-")
|
||||
.replaceAll("[^A-Za-z0-9]", "");
|
||||
final String file = time + '_' + world1 + '_' + id.getX() + '_' + id.getY() + '_' + size;
|
||||
UUID uuid = player.getUUID();
|
||||
schematicHandler.upload(compoundTag, uuid, file, new RunnableVal<>() {
|
||||
@Override
|
||||
public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
player.sendMessage(TranslatableCaption.of("backups.backup_save_failed"));
|
||||
return;
|
||||
}
|
||||
player.sendMessage(TranslatableCaption.of("web.save_success"));
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("errors.deprecated_commands"),
|
||||
TagResolver.resolver("replacement", Tag.inserting(Component.text("/plot download")))
|
||||
);
|
||||
try (final MetaDataAccess<List<String>> schematicAccess =
|
||||
player.accessTemporaryMetaData(PlayerMetaDataKeys.TEMPORARY_SCHEMATICS)) {
|
||||
schematicAccess.get().ifPresent(schematics -> schematics.add(file + ".schem"));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@@ -112,38 +112,6 @@ public class PlayerAutoPlotEvent extends PlotEvent implements CancellablePlotEve
|
||||
return this.plotArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeX()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.0")
|
||||
public int getSize_x() {
|
||||
return getSizeX();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeX(int)} )}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.0")
|
||||
public void setSize_x(int sizeX) {
|
||||
setSizeX(sizeX);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated for removal. Use {@link PlayerAutoPlotEvent#getSizeZ()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.0")
|
||||
public int getSize_z() {
|
||||
return getSizeZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated for removal. Use {@link PlayerAutoPlotEvent#setSizeZ(int)} )}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.0")
|
||||
public void setSize_z(int sizeZ) {
|
||||
setSizeZ(sizeZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the x size of the auto-area
|
||||
*
|
||||
|
@@ -38,15 +38,6 @@ public class PlayerTeleportToPlotEvent extends PlotPlayerEvent implements Cancel
|
||||
private final TeleportCause cause;
|
||||
private Result eventResult;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link PlayerTeleportToPlotEvent#PlayerTeleportToPlotEvent(PlotPlayer, Location, Plot, TeleportCause)}.
|
||||
* You should not be creating events in the first place.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.0")
|
||||
public PlayerTeleportToPlotEvent(PlotPlayer<?> player, Location from, Plot plot) {
|
||||
this(player, from, plot, TeleportCause.UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot
|
||||
*
|
||||
|
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.gui;
|
||||
|
||||
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
||||
import com.plotsquared.core.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.core.events.PlotFlagRemoveEvent;
|
||||
import com.plotsquared.core.events.Result;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotItemStack;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.plot.flag.implementations.MusicFlag;
|
||||
import com.plotsquared.core.util.EventDispatcher;
|
||||
import com.plotsquared.core.util.gui.ExtendablePlotInventory;
|
||||
import com.plotsquared.core.util.gui.PlotInventoryProvider;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class PlotMusicInventory<P, I> extends ExtendablePlotInventory<P, I> {
|
||||
|
||||
private static final List<String> DISCS = Stream.of(
|
||||
"music_disc_13",
|
||||
"music_disc_cat",
|
||||
"music_disc_blocks",
|
||||
"music_disc_chirp",
|
||||
"music_disc_far",
|
||||
"music_disc_mall",
|
||||
"music_disc_mellohi",
|
||||
"music_disc_stal",
|
||||
"music_disc_strad",
|
||||
"music_disc_ward",
|
||||
"music_disc_11",
|
||||
"music_disc_wait",
|
||||
"music_disc_otherside",
|
||||
"music_disc_pigstep"
|
||||
).filter(s -> ItemTypes.get(s) != null).toList();
|
||||
private final Plot plot;
|
||||
private final EventDispatcher eventDispatcher;
|
||||
|
||||
public PlotMusicInventory(
|
||||
final PlotInventoryProvider<P, I> provider,
|
||||
PlotPlayer<?> player,
|
||||
Plot plot,
|
||||
EventDispatcher eventDispatcher
|
||||
) {
|
||||
super(
|
||||
provider, player, 2 * 9,
|
||||
TranslatableCaption.of("plotjukebox.jukebox_header")
|
||||
);
|
||||
this.plot = plot;
|
||||
this.eventDispatcher = eventDispatcher;
|
||||
setDiscs();
|
||||
setCancelButton();
|
||||
}
|
||||
|
||||
private void setDiscs() {
|
||||
for (final String disc : DISCS) {
|
||||
PlotItemStack itemStack = new PlotItemStack(
|
||||
disc, 1, String.format("<gold>%s</gold>", disc),
|
||||
TranslatableCaption.of("plotjukebox.click_to_play").getComponent(player())
|
||||
);
|
||||
addItem(itemStack, (item, type) -> {
|
||||
close();
|
||||
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
|
||||
.createFlagInstance(item.getType());
|
||||
PlotFlagAddEvent event = eventDispatcher.callFlagAdd(plotFlag, plot);
|
||||
if (event.getEventResult() == Result.DENY) {
|
||||
player().sendMessage(
|
||||
TranslatableCaption.of("events.event_denied"),
|
||||
TagResolver.resolver("value", Tag.inserting(Component.text("Music addition")))
|
||||
);
|
||||
return;
|
||||
}
|
||||
plot.setFlag(event.getFlag());
|
||||
player().sendMessage(
|
||||
TranslatableCaption.of("flag.flag_added"),
|
||||
TagResolver.builder()
|
||||
.tag("flag", Tag.inserting(Component.text("music")))
|
||||
.tag("value", Tag.inserting(Component.text(event.getFlag().getValue().toString())))
|
||||
.build()
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setCancelButton() {
|
||||
PlotItemStack cancelItem = new PlotItemStack(
|
||||
ItemTypes.BEDROCK, 1,
|
||||
TranslatableCaption.of("plotjukebox.cancel_music").getComponent(player()),
|
||||
TranslatableCaption.of("plotjukebox.reset_music").getComponent(player())
|
||||
);
|
||||
setItem(size() - 1, cancelItem, (item, type) -> {
|
||||
close();
|
||||
PlotFlag<?, ?> plotFlag = plot.getFlagContainer().getFlag(MusicFlag.class)
|
||||
.createFlagInstance(item.getType());
|
||||
PlotFlagRemoveEvent event = eventDispatcher.callFlagRemove(plotFlag, plot);
|
||||
if (event.getEventResult() == Result.DENY) {
|
||||
player().sendMessage(
|
||||
TranslatableCaption.of("events.event_denied"),
|
||||
TagResolver.resolver("value", Tag.inserting(Component.text("Music removal")))
|
||||
);
|
||||
return;
|
||||
}
|
||||
plot.removeFlag(event.getFlag());
|
||||
player().sendMessage(
|
||||
TranslatableCaption.of("flag.flag_removed"),
|
||||
TagResolver.builder()
|
||||
.tag("flag", Tag.inserting(Component.text("music")))
|
||||
.tag("value", Tag.inserting(Component.text("music_disc")))
|
||||
.build()
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -40,10 +40,6 @@ public enum Permission implements ComponentLike {
|
||||
PERMISSION_STAR("*"),
|
||||
PERMISSION_ADMIN("plots.admin"),
|
||||
PERMISSION_ADMIN_AREA_SUDO("plots.admin.area.sudo"),
|
||||
@Deprecated(forRemoval = true, since = "6.2.2")
|
||||
PERMISSION_PROJECTILE_UNOWNED("plots.projectile.unowned"),
|
||||
@Deprecated(forRemoval = true, since = "6.2.2")
|
||||
PERMISSION_PROJECTILE_OTHER("plots.projectile.other"),
|
||||
PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS("plots.admin.interact.blockedcommands"),
|
||||
PERMISSION_WORLDEDIT_BYPASS("plots.worldedit.bypass"),
|
||||
PERMISSION_PLOT_TOGGLE_TITLES("plots.toggle.titles"),
|
||||
|
@@ -258,8 +258,4 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1015,12 +1015,6 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer,
|
||||
public @NonNull
|
||||
abstract Audience getAudience();
|
||||
|
||||
/**
|
||||
* Closes the current open inventory, if present
|
||||
* @since TODO
|
||||
*/
|
||||
public abstract void closeInventory();
|
||||
|
||||
/**
|
||||
* Get this player's {@link LockRepository}
|
||||
*
|
||||
|
@@ -124,9 +124,6 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||
*/
|
||||
public class Plot {
|
||||
|
||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
||||
public static final int MAX_HEIGHT = 256;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("PlotSquared/" + Plot.class.getSimpleName());
|
||||
private static final DecimalFormat FLAG_DECIMAL_FORMAT = new DecimalFormat("0");
|
||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.builder().build();
|
||||
@@ -1695,19 +1692,6 @@ public class Plot {
|
||||
return base.settings != null && base.settings.getRatings() != null;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "6.1.0")
|
||||
public boolean claim(final @NonNull PlotPlayer<?> player, boolean teleport, String schematic) {
|
||||
if (!canClaim(player)) {
|
||||
return false;
|
||||
}
|
||||
return claim(player, teleport, schematic, true);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "6.1.0")
|
||||
public boolean claim(final @NonNull PlotPlayer<?> player, boolean teleport, String schematic, boolean updateDB) {
|
||||
return claim(player, teleport, schematic, updateDB, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Claim the plot
|
||||
*
|
||||
|
@@ -42,7 +42,6 @@ import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||
import com.plotsquared.core.location.BlockLoc;
|
||||
import com.plotsquared.core.location.Direction;
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.location.PlotLoc;
|
||||
import com.plotsquared.core.player.ConsolePlayer;
|
||||
import com.plotsquared.core.player.MetaDataAccess;
|
||||
import com.plotsquared.core.player.PlayerMetaDataKeys;
|
||||
@@ -1280,20 +1279,6 @@ public abstract class PlotArea implements ComponentLike {
|
||||
return this.signMaterial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the legacy plot sign material before wall signs used a "wall" stance.
|
||||
*
|
||||
* @return the legacy sign material.
|
||||
* @deprecated Use {@link #signMaterial()}. This method is used for 1.13 only and
|
||||
* will be removed without replacement in favor of {@link #signMaterial()}
|
||||
* once we remove the support for 1.13.
|
||||
* @since 6.0.3
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.0.3")
|
||||
public String getLegacySignMaterial() {
|
||||
return this.legacySignMaterial;
|
||||
}
|
||||
|
||||
public boolean isSpawnCustom() {
|
||||
return this.spawnCustom;
|
||||
}
|
||||
@@ -1352,22 +1337,6 @@ public abstract class PlotArea implements ComponentLike {
|
||||
return this.defaultHome;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #nonmemberHome}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.4")
|
||||
public PlotLoc getNonmemberHome() {
|
||||
return new PlotLoc(this.defaultHome.getX(), this.defaultHome.getY(), this.defaultHome.getZ());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #defaultHome}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.4")
|
||||
public PlotLoc getDefaultHome() {
|
||||
return new PlotLoc(this.defaultHome.getX(), this.defaultHome.getY(), this.defaultHome.getZ());
|
||||
}
|
||||
|
||||
protected void setDefaultHome(BlockLoc defaultHome) {
|
||||
this.defaultHome = defaultHome;
|
||||
}
|
||||
|
@@ -210,15 +210,6 @@ public abstract class PlotManager {
|
||||
Template.zipAll(plotArea.getWorldName(), files);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the world height
|
||||
* @deprecated In favor of custom world heights within 1.17 and therefore scheduled for removal without replacement
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
public int getWorldHeight() {
|
||||
return 255;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed).
|
||||
*
|
||||
|
@@ -31,7 +31,6 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A world that contains plots
|
||||
@@ -122,12 +121,4 @@ public abstract class PlotWorld {
|
||||
return world.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof PlotWorld;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -445,11 +445,6 @@ public class ExpireManager {
|
||||
plot.getPlotModificationManager().deletePlot(null, whenDone);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "6.4.0")
|
||||
public long getAge(UUID uuid) {
|
||||
return getAge(uuid, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the age (last play time) of the passed player
|
||||
*
|
||||
|
@@ -39,7 +39,6 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Container type for {@link PlotFlag plot flags}.
|
||||
@@ -388,14 +387,6 @@ public class FlagContainer {
|
||||
return flagMap.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof FlagContainer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update event types used in {@link PlotFlagUpdateHandler}.
|
||||
*/
|
||||
|
@@ -228,13 +228,4 @@ public abstract class PlotFlag<T, F extends PlotFlag<T, F>> {
|
||||
return value.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof PlotFlag;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,89 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.util;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
*
|
||||
* @deprecated Do not use
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
public class MainUtil {
|
||||
|
||||
/**
|
||||
* Cache of mapping x,y,z coordinates to the chunk array<br>
|
||||
* - Used for efficient world generation<br>
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
public static short[][] x_loc;
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
public static short[][] y_loc;
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
public static short[][] z_loc;
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
public static short[][][] CACHE_I = null;
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
public static short[][][] CACHE_J = null;
|
||||
|
||||
/**
|
||||
* This cache is used for world generation and just saves a bit of calculation time when checking if something is in the plot area.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.0.0")
|
||||
public static void initCache() {
|
||||
if (x_loc == null) {
|
||||
x_loc = new short[16][4096];
|
||||
y_loc = new short[16][4096];
|
||||
z_loc = new short[16][4096];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int i4 = i << 4;
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
int y = i4 + (j >> 8);
|
||||
int a = j - ((y & 0xF) << 8);
|
||||
int z1 = a >> 4;
|
||||
int x1 = a - (z1 << 4);
|
||||
x_loc[i][j] = (short) x1;
|
||||
y_loc[i][j] = (short) y;
|
||||
z_loc[i][j] = (short) z1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CACHE_I == null) {
|
||||
CACHE_I = new short[256][16][16];
|
||||
CACHE_J = new short[256][16][16];
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 256; y++) {
|
||||
short i = (short) (y >> 4);
|
||||
short j = (short) ((y & 0xF) << 8 | z << 4 | x);
|
||||
CACHE_I[y][x][z] = i;
|
||||
CACHE_J[y][x][z] = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -167,56 +167,6 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> {
|
||||
return list.asComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name from a UUID.
|
||||
*
|
||||
* @param owner Owner UUID
|
||||
* @return The player's name, None, Everyone or Unknown
|
||||
* @deprecated Use {@link #resolveName(UUID)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.4.0")
|
||||
public static @NonNull String getName(final @Nullable UUID owner) {
|
||||
return getName(owner, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name from a UUID.
|
||||
*
|
||||
* @param owner Owner UUID
|
||||
* @param blocking Whether or not the operation can be blocking
|
||||
* @return The player's name, None, Everyone or Unknown
|
||||
* @deprecated Use {@link #resolveName(UUID, boolean)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.4.0")
|
||||
public static @NonNull String getName(final @Nullable UUID owner, final boolean blocking) {
|
||||
if (owner == null) {
|
||||
TranslatableCaption.of("info.none");
|
||||
}
|
||||
if (owner.equals(DBFunc.EVERYONE)) {
|
||||
TranslatableCaption.of("info.everyone");
|
||||
}
|
||||
if (owner.equals(DBFunc.SERVER)) {
|
||||
TranslatableCaption.of("info.server");
|
||||
}
|
||||
final String name;
|
||||
if (blocking) {
|
||||
name = PlotSquared.get().getImpromptuUUIDPipeline()
|
||||
.getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
} else {
|
||||
final UUIDMapping uuidMapping =
|
||||
PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner);
|
||||
if (uuidMapping != null) {
|
||||
name = uuidMapping.getUsername();
|
||||
} else {
|
||||
name = null;
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
TranslatableCaption.of("info.unknown");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to resolve the username by an uuid
|
||||
* <p>
|
||||
|
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Deprecated(since = "6.6.2", forRemoval = true)
|
||||
public class RegExUtil {
|
||||
|
||||
public static Map<String, Pattern> compiledPatterns;
|
||||
|
||||
static {
|
||||
compiledPatterns = new HashMap<>();
|
||||
}
|
||||
|
||||
}
|
@@ -379,17 +379,6 @@ public abstract class RegionManager {
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
||||
public void setBiome(
|
||||
final CuboidRegion region,
|
||||
final int extendBiome,
|
||||
final BiomeType biome,
|
||||
final String world,
|
||||
final Runnable whenDone
|
||||
) {
|
||||
setBiome(region, extendBiome, biome, PlotSquared.get().getPlotAreaManager().getPlotAreas(world, region)[0], whenDone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a region to a biome type.
|
||||
*
|
||||
|
@@ -26,7 +26,6 @@
|
||||
package com.plotsquared.core.util;
|
||||
|
||||
import com.plotsquared.core.location.Location;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
@@ -76,11 +75,6 @@ public class RegionUtil {
|
||||
return new CuboidRegion(min, max);
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
||||
public static CuboidRegion createRegion(int pos1x, int pos2x, int pos1z, int pos2z) {
|
||||
return createRegion(pos1x, pos2x, 0, 255, pos1z, pos2z);
|
||||
}
|
||||
|
||||
public static CuboidRegion createRegion(
|
||||
int pos1x, int pos2x, int pos1y, int pos2y, int pos1z,
|
||||
int pos2z
|
||||
|
@@ -32,13 +32,11 @@ import com.plotsquared.core.command.Command;
|
||||
import com.plotsquared.core.command.CommandCategory;
|
||||
import com.plotsquared.core.command.RequiredType;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.player.ConsolePlayer;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.PlotArea;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -75,23 +73,6 @@ public final class TabCompletions {
|
||||
"This is a utility class and cannot be instantiated");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of tab completions corresponding to player names. This uses the UUID pipeline
|
||||
* cache, so it will complete will all names known to PlotSquared
|
||||
*
|
||||
* @param input Command input
|
||||
* @param existing Players that should not be included in completions
|
||||
* @return List of completions
|
||||
* @deprecated In favor {@link #completePlayers(PlotPlayer, String, List)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.3")
|
||||
public static @NonNull List<Command> completePlayers(
|
||||
final @NonNull String input,
|
||||
final @NonNull List<String> existing
|
||||
) {
|
||||
return completePlayers(ConsolePlayer.getConsole(), input, existing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of tab completions corresponding to player names. This uses the UUID pipeline
|
||||
* cache, so it will complete will all names known to PlotSquared
|
||||
@@ -110,24 +91,6 @@ public final class TabCompletions {
|
||||
return completePlayers("players", issuer, input, existing, uuid -> true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of tab completions corresponding to player names added to the given plot.
|
||||
*
|
||||
* @param plot Plot to complete added players for
|
||||
* @param input Command input
|
||||
* @param existing Players that should not be included in completions
|
||||
* @return List of completions
|
||||
*
|
||||
* @deprecated In favor {@link #completeAddedPlayers(PlotPlayer, Plot, String, List)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.1.3")
|
||||
public static @NonNull List<Command> completeAddedPlayers(
|
||||
final @NonNull Plot plot,
|
||||
final @NonNull String input, final @NonNull List<String> existing
|
||||
) {
|
||||
return completeAddedPlayers(ConsolePlayer.getConsole(), plot, input, existing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of tab completions corresponding to player names added to the given plot.
|
||||
*
|
||||
@@ -259,24 +222,6 @@ public final class TabCompletions {
|
||||
return Collections.unmodifiableList(completions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cacheIdentifier Cache key
|
||||
* @param input Command input
|
||||
* @param existing Players that should not be included in completions
|
||||
* @param uuidFilter Filter applied before caching values
|
||||
* @return List of completions
|
||||
* @deprecated In favor {@link #completePlayers(String, PlotPlayer, String, List, Predicate)}
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@Deprecated(forRemoval = true, since = "6.1.3")
|
||||
private static List<Command> completePlayers(
|
||||
final @NonNull String cacheIdentifier,
|
||||
final @NonNull String input, final @NonNull List<String> existing,
|
||||
final @NonNull Predicate<UUID> uuidFilter
|
||||
) {
|
||||
return completePlayers(cacheIdentifier, ConsolePlayer.getConsole(), input, existing, uuidFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cacheIdentifier Cache key
|
||||
* @param issuer The player who issued the tab completion
|
||||
|
@@ -37,7 +37,6 @@ import com.sk89q.jnbt.NBTInputStream;
|
||||
import com.sk89q.jnbt.NBTOutputStream;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
@@ -70,26 +69,6 @@ import java.util.zip.ZipOutputStream;
|
||||
|
||||
public abstract class WorldUtil {
|
||||
|
||||
/**
|
||||
* Set the biome in a region
|
||||
*
|
||||
* @param world World name
|
||||
* @param p1x Min X
|
||||
* @param p1z Min Z
|
||||
* @param p2x Max X
|
||||
* @param p2z Max Z
|
||||
* @param biome Biome
|
||||
* @deprecated use {@link WorldUtil#setBiome(String, CuboidRegion, BiomeType)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void setBiome(String world, int p1x, int p1z, int p2x, int p2z, BiomeType biome) {
|
||||
World weWorld = PlotSquared.platform().worldUtil().getWeWorld(world);
|
||||
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3(weWorld.getMinY());
|
||||
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(weWorld.getMaxY());
|
||||
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
||||
PlotSquared.platform().worldUtil().setBiomes(world, region, biome);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the biome in a region
|
||||
*
|
||||
|
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.util.gui;
|
||||
|
||||
import com.plotsquared.core.configuration.caption.Caption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotItemStack;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
|
||||
public class ExtendablePlotInventory<P, I> extends PlotInventory<P, I> {
|
||||
|
||||
private final PlotInventory<P, I> delegate;
|
||||
|
||||
public ExtendablePlotInventory(PlotInventory<P, I> delegate) {
|
||||
super(delegate.player(), delegate.size(), delegate.titleCaption(), delegate.titleResolvers());
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public ExtendablePlotInventory(
|
||||
PlotInventoryProvider<P, I> provider, PlotPlayer<?> player, int size, Caption title,
|
||||
TagResolver... titleResolver
|
||||
) {
|
||||
this(provider.createInventory(player, size, title, titleResolver));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(final int slot, final PlotItemStack item, final PlotInventoryClickHandler onClick) {
|
||||
delegate.setItem(slot, item, onClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItem(final PlotItemStack item, final PlotInventoryClickHandler onClick) {
|
||||
delegate.addItem(item, onClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
delegate.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
delegate.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public I toPlatformItem(final PlotItemStack item) {
|
||||
return delegate.toPlatformItem(item);
|
||||
}
|
||||
|
||||
}
|
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.util.gui;
|
||||
|
||||
import com.plotsquared.core.configuration.caption.Caption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.PlotItemStack;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
|
||||
/**
|
||||
* @param <P> The platform player
|
||||
* @param <I> The platform item object
|
||||
* @since TODO
|
||||
*/
|
||||
public abstract class PlotInventory<P, I> {
|
||||
|
||||
private final PlotInventoryClickHandler NOOP_CLICK_HANDLER = (x, y) -> {
|
||||
};
|
||||
|
||||
private final PlotPlayer<P> player;
|
||||
private final int size;
|
||||
private final Caption titleCaption;
|
||||
private final TagResolver[] titleResolvers;
|
||||
|
||||
/**
|
||||
* Instantiates a new Plot inventory.
|
||||
*
|
||||
* @param size The size of the inventory - must be a multiple of 9
|
||||
* @param titleCaption The caption to use for the title
|
||||
* @param titleResolvers The tag resolvers to use for the title
|
||||
* @since 7.0.0
|
||||
*/
|
||||
protected PlotInventory(PlotPlayer<P> player, int size, Caption titleCaption, TagResolver... titleResolvers) {
|
||||
this.player = player;
|
||||
this.size = size;
|
||||
this.titleCaption = titleCaption;
|
||||
this.titleResolvers = titleResolvers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an item in this inventory at a specific slot / index.
|
||||
* Overrides existing items and click handler.
|
||||
*
|
||||
* @param slot The slot / index where to place the item
|
||||
* @param item The item to add to this inventory
|
||||
* @param onClick The handler to call when clicking this item
|
||||
* @since TODO
|
||||
*/
|
||||
public abstract void setItem(int slot, PlotItemStack item, PlotInventoryClickHandler onClick);
|
||||
|
||||
/**
|
||||
* Set an item in this inventory at a specific slot / index.
|
||||
* Overrides existing items and click handler.
|
||||
*
|
||||
* @param slot The slot / index where to place the item
|
||||
* @param item The item to add to this inventory
|
||||
* @since TODO
|
||||
*/
|
||||
public void setItem(int slot, PlotItemStack item) {
|
||||
setItem(slot, item, NOOP_CLICK_HANDLER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to this inventory, at the first slot possible (first empty slot, or first slot with the exact same item)
|
||||
*
|
||||
* @param item The item to add to this inventory
|
||||
* @param onClick The handler to call when clicking this item
|
||||
* @since TODO
|
||||
*/
|
||||
public abstract void addItem(PlotItemStack item, PlotInventoryClickHandler onClick);
|
||||
|
||||
/**
|
||||
* Add an item to this inventory, at the first slot possible (first empty slot, or first slot with the exact same item)
|
||||
*
|
||||
* @param item The item to add to this inventory
|
||||
* @since TODO
|
||||
*/
|
||||
public void addItem(PlotItemStack item) {
|
||||
addItem(item, NOOP_CLICK_HANDLER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens this inventory
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
public abstract void open();
|
||||
|
||||
/**
|
||||
* Close this inventory
|
||||
*
|
||||
* @since TODO
|
||||
*/
|
||||
public abstract void close();
|
||||
|
||||
public abstract I toPlatformItem(PlotItemStack item);
|
||||
|
||||
/**
|
||||
* @return the size of this inventory (must be a multiple of 9)
|
||||
* @since TODO
|
||||
*/
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated player of this inventory
|
||||
* @return {@link PlotPlayer}
|
||||
*/
|
||||
public PlotPlayer<P> player() {
|
||||
return player;
|
||||
}
|
||||
|
||||
protected Caption titleCaption() {
|
||||
return titleCaption;
|
||||
}
|
||||
|
||||
protected TagResolver[] titleResolvers() {
|
||||
return titleResolvers;
|
||||
}
|
||||
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.util.gui;
|
||||
|
||||
import com.plotsquared.core.plot.PlotItemStack;
|
||||
|
||||
public interface PlotInventoryClickHandler {
|
||||
|
||||
void handle(PlotItemStack itemStack, PlotInventoryClickType clickType);
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.util.gui;
|
||||
|
||||
public enum PlotInventoryClickType {
|
||||
|
||||
LEFT,
|
||||
SHIFT_LEFT,
|
||||
RIGHT,
|
||||
SHIFT_RIGHT,
|
||||
MIDDLE,
|
||||
OTHER
|
||||
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* _____ _ _ _____ _
|
||||
* | __ \| | | | / ____| | |
|
||||
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||
* | |
|
||||
* |_|
|
||||
* PlotSquared plot management system for Minecraft
|
||||
* Copyright (C) 2014 - 2022 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.plotsquared.core.util.gui;
|
||||
|
||||
import com.plotsquared.core.configuration.caption.Caption;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
|
||||
/**
|
||||
* Provider for creating a {@link PlotInventory}
|
||||
*
|
||||
* @param <P> The platform player
|
||||
* @param <I> The platform item
|
||||
*/
|
||||
public interface PlotInventoryProvider<P, I> {
|
||||
|
||||
/**
|
||||
* Creates a new {@link PlotInventory} based on the passed data for the current platform.
|
||||
*
|
||||
* @param size The size of the inventory (must be a multiple of 9)
|
||||
* @param titleCaption The title for the inventory
|
||||
* @param titleResolvers The (optional) placeholder resolvers for the inventory
|
||||
* @return The platform inventory
|
||||
*/
|
||||
PlotInventory<P, I> createInventory(PlotPlayer<?> player, int size, Caption titleCaption, TagResolver... titleResolvers);
|
||||
|
||||
}
|
@@ -68,12 +68,4 @@ public class UUIDMapping {
|
||||
return Objects.hash(uuid, username);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This method is not meant to be invoked or overridden, with no replacement.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
||||
protected boolean canEqual(final Object other) {
|
||||
return other instanceof UUIDMapping;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ plugins {
|
||||
idea
|
||||
}
|
||||
|
||||
version = "6.8.2-SNAPSHOT"
|
||||
version = "7.0.0-SNAPSHOT"
|
||||
|
||||
allprojects {
|
||||
group = "com.intellectualsites.plotsquared"
|
||||
|
Reference in New Issue
Block a user