mirror of
https://github.com/xoo0524tw/OpenMBedwars.git
synced 2026-12-05 22:06:02 +02:00
update
This commit is contained in:
1 parent
af0b27c807
commit
0ab0874476
50 files changed
+6322
-3
No files matched your search
@@ -0,0 +1,23 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public interface CloseableIterator<T> extends Closeable, Iterator<T> {
|
||||
class AlwaysClosed<T> implements CloseableIterator<T> {
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,414 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.api.remote.RemotePlayer;
|
||||
import de.marcely.bedwars.api.remote.RemoteServer;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import java.util.UUID;
|
||||
import lombok.Generated;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
public interface CommandSenderWrapper {
|
||||
String getName();
|
||||
|
||||
@Nullable
|
||||
UUID getUniqueId();
|
||||
|
||||
boolean isBukkitPlayer();
|
||||
|
||||
boolean isRemotePlayer();
|
||||
|
||||
boolean isConsole();
|
||||
|
||||
boolean isPlayer();
|
||||
|
||||
boolean isLocal();
|
||||
|
||||
boolean isRemote();
|
||||
|
||||
Object getReference();
|
||||
|
||||
CommandSender getCommandSender();
|
||||
|
||||
@Nullable
|
||||
Player getBukkitPlayer();
|
||||
|
||||
@Nullable
|
||||
RemotePlayer getRemotePlayer();
|
||||
|
||||
void sendMessage(String var1);
|
||||
|
||||
void sendMessage(String... var1);
|
||||
|
||||
void sendMessage(BaseComponent... var1);
|
||||
|
||||
boolean hasPermission(String var1);
|
||||
|
||||
boolean hasPermission(Permission var1);
|
||||
|
||||
static CommandSenderWrapper wrap(CommandSender var0) {
|
||||
return wrap(var0, false);
|
||||
}
|
||||
|
||||
static CommandSenderWrapper wrap(CommandSender var0, boolean var1) {
|
||||
Validate.notNull(var0, "sender");
|
||||
return new CommandSenderWrapper.BukkitWrapper(var0, var1);
|
||||
}
|
||||
|
||||
static CommandSenderWrapper wrap(RemotePlayer var0) {
|
||||
Validate.notNull(var0, "player");
|
||||
return var0.isLocal() && var0.asBukkit().isOnline() ? wrap(var0.asBukkit()) : new CommandSenderWrapper.RemotePlayerWrapper(var0);
|
||||
}
|
||||
|
||||
static CommandSenderWrapper wrapConsole(RemoteServer var0) {
|
||||
Validate.notNull(var0, "server");
|
||||
return new CommandSenderWrapper.RemoteConsoleWrapper(var0);
|
||||
}
|
||||
|
||||
class BukkitWrapper implements CommandSenderWrapper {
|
||||
private final CommandSender sender;
|
||||
private final boolean hasOP;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
if (this.isBukkitPlayer()) {
|
||||
return this.getBukkitPlayer().getUniqueId();
|
||||
} else {
|
||||
return this.isRemotePlayer() ? this.getRemotePlayer().getUniqueId() : null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBukkitPlayer() {
|
||||
return this.sender instanceof Player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemotePlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return this.sender instanceof ConsoleCommandSender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return this.sender instanceof Player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemote() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getReference() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getCommandSender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Player getBukkitPlayer() {
|
||||
return this.isBukkitPlayer() ? (Player)this.sender : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RemotePlayer getRemotePlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String var1) {
|
||||
this.sender.sendMessage(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String... var1) {
|
||||
this.sender.sendMessage(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent... var1) {
|
||||
Validate.notNull(var1, "components");
|
||||
if (var1.length != 0) {
|
||||
if (this.isBukkitPlayer()) {
|
||||
this.getBukkitPlayer().spigot().sendMessage(var1);
|
||||
} else {
|
||||
this.sender.sendMessage(TextComponent.toLegacyText(var1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String var1) {
|
||||
return this.hasOP || this.sender.hasPermission(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission var1) {
|
||||
return this.hasOP || this.sender.hasPermission(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == null) {
|
||||
return false;
|
||||
} else if (!(var1 instanceof CommandSenderWrapper.BukkitWrapper)) {
|
||||
return var1 instanceof CommandSender ? this.sender.equals(var1) : false;
|
||||
} else {
|
||||
return this == var1 || this.sender.equals(((CommandSenderWrapper.BukkitWrapper)var1).sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommandSenderWrapper.BukkitWrapper(sender=" + this.sender + ", hasOP=" + this.hasOP + ")";
|
||||
}
|
||||
|
||||
@Generated
|
||||
public BukkitWrapper(CommandSender var1, boolean var2) {
|
||||
this.sender = var1;
|
||||
this.hasOP = var2;
|
||||
}
|
||||
}
|
||||
|
||||
class RemoteConsoleWrapper implements CommandSenderWrapper {
|
||||
private final RemoteServer server;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Console";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBukkitPlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemotePlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemote() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getReference() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getCommandSender() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Player getBukkitPlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RemotePlayer getRemotePlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String var1) {
|
||||
this.server.sendConsoleMessage(new String[]{var1});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String... var1) {
|
||||
this.server.sendConsoleMessage(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent... var1) {
|
||||
this.server.sendConsoleMessage(new String[]{TextComponent.toLegacyText(var1)});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommandSenderWrapper.RemoteConsoleWrapper(server=" + this.server + ")";
|
||||
}
|
||||
|
||||
@Generated
|
||||
public RemoteConsoleWrapper(RemoteServer var1) {
|
||||
this.server = var1;
|
||||
}
|
||||
}
|
||||
|
||||
class RemotePlayerWrapper implements CommandSenderWrapper {
|
||||
private final RemotePlayer player;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.player.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return this.player.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBukkitPlayer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemotePlayer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConsole() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLocal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemote() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getReference() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getCommandSender() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Player getBukkitPlayer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RemotePlayer getRemotePlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String var1) {
|
||||
this.player.sendMessage(new String[]{var1});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String... var1) {
|
||||
this.player.sendMessage(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent... var1) {
|
||||
this.player.sendMessage(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == null) {
|
||||
return false;
|
||||
} else if (!(var1 instanceof CommandSenderWrapper.RemotePlayerWrapper)) {
|
||||
return var1 instanceof RemotePlayer ? this.player.equals(var1) : false;
|
||||
} else {
|
||||
return this == var1 || ((CommandSenderWrapper.RemotePlayerWrapper)var1).player.equals(this.player);
|
||||
}
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CommandSenderWrapper.RemotePlayerWrapper(player=" + this.player + ")";
|
||||
}
|
||||
|
||||
@Generated
|
||||
public RemotePlayerWrapper(RemotePlayer var1) {
|
||||
this.player = var1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface DynamicItemStack extends Cloneable {
|
||||
String getInput();
|
||||
|
||||
ItemStack get();
|
||||
|
||||
ItemStack getClone();
|
||||
|
||||
ItemStack get(Player var1);
|
||||
|
||||
ItemStack getClone(Player var1);
|
||||
|
||||
DynamicItemStack clone();
|
||||
|
||||
boolean isDynamic();
|
||||
|
||||
@Nullable
|
||||
static DynamicItemStack from(String var0) {
|
||||
Validate.notNull(var0, "string");
|
||||
return BedwarsAPILayer.INSTANCE.dynamicItemStack(var0);
|
||||
}
|
||||
|
||||
static DynamicItemStack from(ItemStack var0) {
|
||||
Validate.notNull(var0, "is");
|
||||
return BedwarsAPILayer.INSTANCE.dynamicItemStack(var0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import lombok.Generated;
|
||||
|
||||
public interface Either<L, R> {
|
||||
boolean hasLeft();
|
||||
|
||||
boolean hasRight();
|
||||
|
||||
@Nullable
|
||||
L left();
|
||||
|
||||
@Nullable
|
||||
R right();
|
||||
|
||||
static <L, R> Either<L, R> left(L var0) {
|
||||
Validate.notNull(var0, "left");
|
||||
return new Either.Left<>((L)var0);
|
||||
}
|
||||
|
||||
static <L, R> Either<L, R> right(R var0) {
|
||||
Validate.notNull(var0, "right");
|
||||
return new Either.Right<>((R)var0);
|
||||
}
|
||||
|
||||
class Left<L, R> implements Either<L, R> {
|
||||
private final L entry;
|
||||
|
||||
public Left(L var1) {
|
||||
this.entry = (L)var1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLeft() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRight() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public L left() {
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R right() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Either.Left(entry=" + this.entry + ")";
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(var1 instanceof Either.Left)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Either.Left var2 = (Either.Left)var1;
|
||||
if (!var2.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object var3 = this.entry;
|
||||
Object var4 = var2.entry;
|
||||
return var3 == null ? var4 == null : var3.equals(var4);
|
||||
}
|
||||
|
||||
@Generated
|
||||
protected boolean canEqual(Object var1) {
|
||||
return var1 instanceof Either.Left;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte var1 = 59;
|
||||
byte var2 = 1;
|
||||
Object var3 = this.entry;
|
||||
return var2 * 59 + (var3 == null ? 43 : var3.hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
class Right<L, R> implements Either<L, R> {
|
||||
private final R entry;
|
||||
|
||||
public Right(R var1) {
|
||||
this.entry = (R)var1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasLeft() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasRight() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public L left() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R right() {
|
||||
return this.entry;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Either.Right(entry=" + this.entry + ")";
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(var1 instanceof Either.Right)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Either.Right var2 = (Either.Right)var1;
|
||||
if (!var2.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Object var3 = this.entry;
|
||||
Object var4 = var2.entry;
|
||||
return var3 == null ? var4 == null : var3.equals(var4);
|
||||
}
|
||||
|
||||
@Generated
|
||||
protected boolean canEqual(Object var1) {
|
||||
return var1 instanceof Either.Right;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte var1 = 59;
|
||||
byte var2 = 1;
|
||||
Object var3 = this.entry;
|
||||
return var2 * 59 + (var3 == null ? 43 : var3.hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.api.BedwarsAPI;
|
||||
import de.marcely.bedwars.libraries.com.google.gson.JsonObject;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import de.marcely.bedwars.tools.location.XYZ;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionType;
|
||||
|
||||
public interface Helper {
|
||||
int getJavaVersion();
|
||||
|
||||
@Nullable
|
||||
Integer parseInt(String var1);
|
||||
|
||||
@Nullable
|
||||
Long parseLong(String var1);
|
||||
|
||||
@Nullable
|
||||
Double parseDouble(String var1);
|
||||
|
||||
String formatNumber(long var1);
|
||||
|
||||
String formatNumber(double var1);
|
||||
|
||||
String formatNumber(BigDecimal var1);
|
||||
|
||||
default String formatDuration(Duration var1) {
|
||||
return this.formatDuration(var1.toMillis());
|
||||
}
|
||||
|
||||
String formatDuration(long var1);
|
||||
|
||||
@Nullable
|
||||
Double evaluateString(String var1);
|
||||
|
||||
@Nullable
|
||||
ItemStack parseItemStack(String var1);
|
||||
|
||||
String composeItemStack(ItemStack var1);
|
||||
|
||||
@Deprecated
|
||||
ItemStack dye(ItemStack var1, DyeColor var2);
|
||||
|
||||
@Deprecated
|
||||
void setUnbreakable(ItemMeta var1, boolean var2);
|
||||
|
||||
@Deprecated
|
||||
default void setUnbreakable(ItemStack var1, boolean var2) {
|
||||
ItemMeta var3 = var1.getItemMeta();
|
||||
this.setUnbreakable(var3, var2);
|
||||
var1.setItemMeta(var3);
|
||||
}
|
||||
|
||||
String replacePAPIPlaceholders(String var1, Player var2);
|
||||
|
||||
@Nullable
|
||||
String getPlayerNickName(Player var1);
|
||||
|
||||
String replaceFirst(String var1, String var2, String var3);
|
||||
|
||||
String replaceLast(String var1, String var2, String var3);
|
||||
|
||||
String[] split(String var1, char var2);
|
||||
|
||||
String remove(String var1, char var2);
|
||||
|
||||
String getNickedPlayerRealName(Player var1);
|
||||
|
||||
String getPlayerDisplayName(Player var1);
|
||||
|
||||
@Nullable
|
||||
Player getPlayerByName(String var1);
|
||||
|
||||
boolean isBedrockPlayer(UUID var1);
|
||||
|
||||
boolean isBedrockPlayer(OfflinePlayer var1);
|
||||
|
||||
@Nullable
|
||||
EntityType getEntityTypeByName(String var1);
|
||||
|
||||
int copy(InputStream var1, OutputStream var2) throws IOException;
|
||||
|
||||
@Deprecated
|
||||
JsonObject parseSNBTAsJson(String var1) throws IllegalArgumentException;
|
||||
|
||||
@Deprecated
|
||||
String composeJsonAsSNBT(JsonObject var1);
|
||||
|
||||
boolean setPlayerArmor(Player var1, ItemStack var2, boolean var3);
|
||||
|
||||
void givePlayerItem(Player var1, ItemStack var2);
|
||||
|
||||
@Nullable
|
||||
Material getMaterialByName(String var1);
|
||||
|
||||
@Nullable
|
||||
Effect getEffectByName(String var1);
|
||||
|
||||
@Nullable
|
||||
PotionType getPotionTypeByName(String var1);
|
||||
|
||||
@Nullable
|
||||
Sound getSoundByName(String var1);
|
||||
|
||||
@Nullable
|
||||
Enchantment getEnchantmentByName(String var1);
|
||||
|
||||
Material getBlockVariant(Material var1);
|
||||
|
||||
Material getInventoryVariant(Material var1);
|
||||
|
||||
void synchronize(Runnable var1);
|
||||
|
||||
int getMinHeight(World var1);
|
||||
|
||||
@Deprecated
|
||||
@Nullable
|
||||
Pair<String, String> getPlayerSkinData(Player var1);
|
||||
|
||||
@Nullable
|
||||
Skin getPlayerSkin(Player var1);
|
||||
|
||||
ChatColor getBukkitChatColorFromBungee(net.md_5.bungee.api.ChatColor var1);
|
||||
|
||||
default void getBlockAsync(Location var1, Consumer<Block> var2) {
|
||||
this.getBlockAsync(var1.getWorld(), var1.getBlockX(), var1.getBlockY(), var1.getBlockZ(), var2);
|
||||
}
|
||||
|
||||
default void getBlockAsync(World var1, XYZ var2, Consumer<Block> var3) {
|
||||
this.getBlockAsync(var1, var2.getBlockX(), var2.getBlockY(), var2.getBlockZ(), var3);
|
||||
}
|
||||
|
||||
void getBlockAsync(World var1, int var2, int var3, int var4, Consumer<Block> var5);
|
||||
|
||||
void getChunkAsync(World var1, int var2, int var3, Consumer<Chunk> var4);
|
||||
|
||||
void teleportAsync(Entity var1, Location var2, @Nullable Runnable var3);
|
||||
|
||||
void playSound(Player var1, Location var2, Sound var3, float var4, float var5);
|
||||
|
||||
void playSound(Location var1, Sound var2, float var3, float var4);
|
||||
|
||||
void playCustomSound(Player var1, Location var2, String var3, float var4, float var5);
|
||||
|
||||
void playCustomSound(Location var1, String var2, float var3, float var4);
|
||||
|
||||
@Deprecated
|
||||
boolean isInteractableBlock(Material var1);
|
||||
|
||||
int takeItems(Player var1, ItemStack var2, int var3);
|
||||
|
||||
int takeItems(Player var1, Predicate<ItemStack> var2, int var3);
|
||||
|
||||
int giveItems(Player var1, ItemStack var2, boolean var3);
|
||||
|
||||
@Deprecated
|
||||
boolean isTransparent(Material var1);
|
||||
|
||||
boolean isWorldLoaded(Location var1);
|
||||
|
||||
void playPickupItemSound(Player var1);
|
||||
|
||||
void playPickupItemSound(Location var1);
|
||||
|
||||
@Nullable
|
||||
Collection<Material> getColorGroupMaterials(Material var1);
|
||||
|
||||
void addAllColors(Set<Material> var1);
|
||||
|
||||
boolean isSword(Material var1);
|
||||
|
||||
boolean isAxe(Material var1);
|
||||
|
||||
boolean isPickaxe(Material var1);
|
||||
|
||||
boolean isArmor(Material var1);
|
||||
|
||||
static Helper get() {
|
||||
return BedwarsAPI.getHelper();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.api.arena.Team;
|
||||
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
||||
import de.marcely.bedwars.libraries.com.cryptomorin.xseries.XMaterial;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import java.util.List;
|
||||
import java.util.function.UnaryOperator;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public interface ItemBuilder {
|
||||
ItemBuilder name(String var1);
|
||||
|
||||
ItemBuilder emptyName();
|
||||
|
||||
String name();
|
||||
|
||||
boolean hasName();
|
||||
|
||||
ItemBuilder amount(int var1);
|
||||
|
||||
int amount();
|
||||
|
||||
ItemBuilder lore(String... var1);
|
||||
|
||||
ItemBuilder lore(List<String> var1);
|
||||
|
||||
ItemBuilder addLore(String var1);
|
||||
|
||||
ItemBuilder addLoreNLable(String var1);
|
||||
|
||||
ItemBuilder addLore(String... var1);
|
||||
|
||||
ItemBuilder addLore(List<String> var1);
|
||||
|
||||
ItemBuilder addLoreNLable(List<String> var1);
|
||||
|
||||
ItemBuilder addEmptyLore();
|
||||
|
||||
ItemBuilder replaceLore(int var1, String var2);
|
||||
|
||||
ItemBuilder computeLoreComponents(UnaryOperator<String> var1);
|
||||
|
||||
ItemBuilder clearLore();
|
||||
|
||||
boolean hasLore();
|
||||
|
||||
int loreLines();
|
||||
|
||||
ItemBuilder friendlyDescription(String var1, ChatColor var2);
|
||||
|
||||
ItemBuilder addEnchant(Enchantment var1, int var2, boolean var3);
|
||||
|
||||
int enchantLevel(Enchantment var1);
|
||||
|
||||
ItemBuilder dye(DyeColor var1);
|
||||
|
||||
ItemBuilder dye(Team var1);
|
||||
|
||||
ItemBuilder hideAttributes();
|
||||
|
||||
ItemBuilder glowing();
|
||||
|
||||
ItemBuilder unbreakable();
|
||||
|
||||
ItemBuilder maxStackLimit();
|
||||
|
||||
ItemBuilder cloned();
|
||||
|
||||
ItemStack build();
|
||||
|
||||
@Nullable
|
||||
ItemMeta getInternalMeta();
|
||||
|
||||
boolean isMetaless();
|
||||
|
||||
static ItemBuilder of(ItemStack var0) {
|
||||
Validate.notNull(var0, "item");
|
||||
return BedwarsAPILayer.INSTANCE.newItemBuilder(var0);
|
||||
}
|
||||
|
||||
static ItemBuilder of(Material var0) {
|
||||
return of(var0, 1);
|
||||
}
|
||||
|
||||
static ItemBuilder of(Material var0, int var1) {
|
||||
Validate.notNull(var0, "mat");
|
||||
return BedwarsAPILayer.INSTANCE.newItemBuilder(new ItemStack(var0, var1));
|
||||
}
|
||||
|
||||
static ItemBuilder of(XMaterial var0) {
|
||||
Validate.notNull(var0, "mat");
|
||||
ItemStack var1 = var0.parseItem();
|
||||
if (var1 == null) {
|
||||
throw new IllegalArgumentException("XMaterial is not supported on this server: " + var0);
|
||||
} else {
|
||||
return BedwarsAPILayer.INSTANCE.newItemBuilder(var1);
|
||||
}
|
||||
}
|
||||
|
||||
static ItemBuilder of(XMaterial var0, int var1) {
|
||||
Validate.notNull(var0, "mat");
|
||||
return of(var0).amount(var1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.api.BedwarsAPI;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public interface NMSHelper {
|
||||
int getVersion();
|
||||
|
||||
int getPatchVersion();
|
||||
|
||||
int getRevision();
|
||||
|
||||
boolean isRunningPaper();
|
||||
|
||||
String getLocale(Player var1);
|
||||
|
||||
@Deprecated
|
||||
ItemStack setGlowEffect(ItemStack var1, boolean var2);
|
||||
|
||||
void showTitle(Player var1, String var2, String var3, int var4, int var5, int var6);
|
||||
|
||||
void showTitle(Player var1, String var2, String var3);
|
||||
|
||||
void showActionbar(Player var1, String var2);
|
||||
|
||||
void setSkullTexture(Skull var1, String var2);
|
||||
|
||||
@Nullable
|
||||
String getSkullTexture(Skull var1);
|
||||
|
||||
void setSkullTexture(SkullMeta var1, String var2);
|
||||
|
||||
@Nullable
|
||||
String getSkullTexture(SkullMeta var1);
|
||||
|
||||
String getVanillaDeathMessage(Player var1);
|
||||
|
||||
void setEntityTarget(Entity var1, @Nullable Location var2);
|
||||
|
||||
void sendPacket(Player var1, Object var2);
|
||||
|
||||
float getAttackDamage(Player var1);
|
||||
|
||||
@Nullable
|
||||
Entity getEntityById(World var1, int var2);
|
||||
|
||||
void simulateChestOpening(World var1, int var2, int var3, int var4);
|
||||
|
||||
default void simulateChestOpening(Block var1) {
|
||||
Validate.notNull(var1, "block");
|
||||
this.simulateChestOpening(var1.getWorld(), var1.getX(), var1.getY(), var1.getZ());
|
||||
}
|
||||
|
||||
void simulateChestClosing(World var1, int var2, int var3, int var4);
|
||||
|
||||
default void simulateChestClosing(Block var1) {
|
||||
Validate.notNull(var1, "block");
|
||||
this.simulateChestClosing(var1.getWorld(), var1.getX(), var1.getY(), var1.getZ());
|
||||
}
|
||||
|
||||
void setServerMotd(String var1);
|
||||
|
||||
void playItemPickupAnimation(Entity var1, Entity var2, int var3);
|
||||
|
||||
void simulatePlayerClickingRespawn(Player var1);
|
||||
|
||||
void setEntityMovementSpeed(LivingEntity var1, double var2);
|
||||
|
||||
void setEntityFollowRange(LivingEntity var1, double var2);
|
||||
|
||||
void setEntitySilent(Entity var1, boolean var2);
|
||||
|
||||
void teleportWithoutEvent(Entity var1, Location var2);
|
||||
|
||||
double getItemDamage(ItemStack var1);
|
||||
|
||||
@Deprecated
|
||||
ItemStack hideAttributes(ItemStack var1);
|
||||
|
||||
void sendWorldTimePacket(Player var1, long var2);
|
||||
|
||||
@Nullable
|
||||
Sound getEntityDamageSound(Entity var1);
|
||||
|
||||
@Nullable
|
||||
Sound getEntityDeathSound(Entity var1);
|
||||
|
||||
@Nullable
|
||||
Sound getSoundByMinecraftName(String var1);
|
||||
|
||||
float getEntityWidth(Entity var1);
|
||||
|
||||
float getEntityHeight(Entity var1);
|
||||
|
||||
int getEffectInfiniteDuration();
|
||||
|
||||
void setFireballDirection(Entity var1, Vector var2, double var3);
|
||||
|
||||
boolean useFireworkBoost(Player var1, ItemStack var2);
|
||||
|
||||
static NMSHelper get() {
|
||||
return BedwarsAPI.getNMSHelper();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import lombok.Generated;
|
||||
|
||||
public class Pair<K, V> {
|
||||
private final K key;
|
||||
private final V value;
|
||||
|
||||
public Pair(@Nullable K var1, @Nullable V var2) {
|
||||
this.key = (K)var1;
|
||||
this.value = (V)var2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public K getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public V getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == this) {
|
||||
return true;
|
||||
} else if (!(var1 instanceof Pair)) {
|
||||
return false;
|
||||
} else {
|
||||
Pair var2 = (Pair)var1;
|
||||
if (!var2.canEqual(this)) {
|
||||
return false;
|
||||
} else {
|
||||
Object var3 = this.getKey();
|
||||
Object var4 = var2.getKey();
|
||||
if (var3 == null ? var4 == null : var3.equals(var4)) {
|
||||
Object var5 = this.getValue();
|
||||
Object var6 = var2.getValue();
|
||||
return var5 == null ? var6 == null : var5.equals(var6);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Generated
|
||||
protected boolean canEqual(Object var1) {
|
||||
return var1 instanceof Pair;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte var1 = 59;
|
||||
int var2 = 1;
|
||||
Object var3 = this.getKey();
|
||||
var2 = var2 * 59 + (var3 == null ? 43 : var3.hashCode());
|
||||
Object var4 = this.getValue();
|
||||
return var2 * 59 + (var4 == null ? 43 : var4.hashCode());
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pair(key=" + this.getKey() + ", value=" + this.getValue() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public interface PersistentBlockData {
|
||||
Material getMaterial();
|
||||
|
||||
default void place(Block var1) {
|
||||
this.place(var1, true);
|
||||
}
|
||||
|
||||
void place(Block var1, boolean var2);
|
||||
|
||||
String getAsString();
|
||||
|
||||
boolean matches(PersistentBlockData var1);
|
||||
|
||||
boolean matches(Block var1);
|
||||
|
||||
PersistentBlockData getDyedData(DyeColor var1);
|
||||
|
||||
@Nullable
|
||||
static PersistentBlockData parse(String var0) {
|
||||
Validate.notNull(var0, "string");
|
||||
return BedwarsAPILayer.INSTANCE.blockDataParse(var0);
|
||||
}
|
||||
|
||||
static PersistentBlockData fromBlock(Block var0) {
|
||||
Validate.notNull(var0, "block");
|
||||
return BedwarsAPILayer.INSTANCE.blockDataFromBlock(var0);
|
||||
}
|
||||
|
||||
static PersistentBlockData fromMaterial(Material var0) {
|
||||
Validate.notNull(var0, "material");
|
||||
return BedwarsAPILayer.INSTANCE.blockDataFromMaterial(var0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface PersistentStorage extends StringMapSerializationHelper {
|
||||
Set<String> getKeys();
|
||||
|
||||
void set(String var1, String var2);
|
||||
|
||||
boolean remove(String var1);
|
||||
|
||||
void saveAsync();
|
||||
|
||||
interface Holder {
|
||||
PersistentStorage getPersistentStorage();
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
public interface PlayerSpawnLocationEventWrapper {
|
||||
boolean isAsync();
|
||||
|
||||
UUID getPlayerUUID();
|
||||
|
||||
String getPlayerName();
|
||||
|
||||
Location getSpawnLocation();
|
||||
|
||||
void setSpawnLocation(Location var1);
|
||||
|
||||
void sendMessage(String var1);
|
||||
|
||||
static RegisteredListener register(Consumer<PlayerSpawnLocationEventWrapper> var0, Plugin var1) {
|
||||
return register(var0, var1, EventPriority.NORMAL);
|
||||
}
|
||||
|
||||
static RegisteredListener register(Consumer<PlayerSpawnLocationEventWrapper> var0, Plugin var1, EventPriority var2) {
|
||||
Validate.notNull(var0, "handler");
|
||||
Validate.notNull(var1, "plugin");
|
||||
Validate.notNull(var2, "priority");
|
||||
return BedwarsAPILayer.INSTANCE.registerPlayerSpawnLocationEventWrapper(var0, var1, var2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
||||
import de.marcely.bedwars.libraries.com.google.gson.JsonObject;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import lombok.Generated;
|
||||
|
||||
public final class Skin {
|
||||
public static final Skin STEVE = new Skin("", "");
|
||||
private final String texture;
|
||||
private final String signature;
|
||||
private URL textureURL;
|
||||
private boolean cachedURL = false;
|
||||
|
||||
private Skin(String var1, String var2) {
|
||||
this.texture = var1;
|
||||
this.signature = var2;
|
||||
}
|
||||
|
||||
public String getTexture() {
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public URL getTextureURL() {
|
||||
if (this.cachedURL) {
|
||||
return this.textureURL;
|
||||
}
|
||||
|
||||
try {
|
||||
String var1 = new String(Base64.getDecoder().decode(this.texture), StandardCharsets.UTF_8);
|
||||
JsonObject var2 = (JsonObject)BedwarsAPILayer.INSTANCE.getGson().fromJson(var1, JsonObject.class);
|
||||
String var3 = var2.getAsJsonObject("textures").getAsJsonObject("SKIN").get("url").getAsString();
|
||||
return this.textureURL = new URL(var3);
|
||||
} catch (Exception var8) {
|
||||
return this.textureURL = null;
|
||||
} finally {
|
||||
this.cachedURL = true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTextureValid() {
|
||||
return this.getTextureURL() != null;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return this.signature;
|
||||
}
|
||||
|
||||
public static Skin of(String var0, String var1) {
|
||||
Validate.notNull(var0, "texture");
|
||||
Validate.notNull(var1, "signature");
|
||||
return new Skin(var0, var1);
|
||||
}
|
||||
|
||||
public static Skin of(URL var0, String var1) {
|
||||
Validate.notNull(var0, "url");
|
||||
Validate.notNull(var1, "signature");
|
||||
return new Skin(serialize(var0), var1);
|
||||
}
|
||||
|
||||
private static String serialize(URL var0) {
|
||||
JsonObject var1 = new JsonObject();
|
||||
JsonObject var2 = new JsonObject();
|
||||
JsonObject var3 = new JsonObject();
|
||||
var3.addProperty("url", var0.toString());
|
||||
var2.add("SKIN", var3);
|
||||
var1.add("textures", var2);
|
||||
return Base64.getEncoder().encodeToString(var1.toString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(var1 instanceof Skin)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Skin var2 = (Skin)var1;
|
||||
if (this.cachedURL != var2.cachedURL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String var3 = this.getTexture();
|
||||
String var4 = var2.getTexture();
|
||||
if (var3 == null ? var4 == null : var3.equals(var4)) {
|
||||
String var5 = this.getSignature();
|
||||
String var6 = var2.getSignature();
|
||||
if (var5 == null ? var6 == null : var5.equals(var6)) {
|
||||
URL var7 = this.getTextureURL();
|
||||
URL var8 = var2.getTextureURL();
|
||||
return var7 == null ? var8 == null : var7.equals(var8);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte var1 = 59;
|
||||
int var2 = 1;
|
||||
var2 = var2 * 59 + (this.cachedURL ? 79 : 97);
|
||||
String var3 = this.getTexture();
|
||||
var2 = var2 * 59 + (var3 == null ? 43 : var3.hashCode());
|
||||
String var4 = this.getSignature();
|
||||
var2 = var2 * 59 + (var4 == null ? 43 : var4.hashCode());
|
||||
URL var5 = this.getTextureURL();
|
||||
return var2 * 59 + (var5 == null ? 43 : var5.hashCode());
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Skin(texture="
|
||||
+ this.getTexture()
|
||||
+ ", signature="
|
||||
+ this.getSignature()
|
||||
+ ", textureURL="
|
||||
+ this.getTextureURL()
|
||||
+ ", cachedURL="
|
||||
+ this.cachedURL
|
||||
+ ")";
|
||||
}
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface StringMapSerializationHelper {
|
||||
Optional<String> get(String var1);
|
||||
|
||||
void set(String var1, String var2);
|
||||
|
||||
default Optional<Integer> getInt(String var1) {
|
||||
Optional var2 = this.get(var1);
|
||||
return !var2.isPresent() ? Optional.empty() : Optional.ofNullable(Helper.get().parseInt((String)var2.get()));
|
||||
}
|
||||
|
||||
default Optional<Long> getLong(String var1) {
|
||||
Optional var2 = this.get(var1);
|
||||
return !var2.isPresent() ? Optional.empty() : Optional.ofNullable(Helper.get().parseLong((String)var2.get()));
|
||||
}
|
||||
|
||||
default Optional<Boolean> getBoolean(String var1) {
|
||||
Optional var2 = this.get(var1);
|
||||
if (!var2.isPresent()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
switch (((String)var2.get()).toLowerCase()) {
|
||||
case "true":
|
||||
case "1":
|
||||
return Optional.of(true);
|
||||
case "false":
|
||||
case "0":
|
||||
return Optional.of(false);
|
||||
default:
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
default Optional<Double> getDouble(String var1) {
|
||||
Optional var2 = this.get(var1);
|
||||
return !var2.isPresent() ? Optional.empty() : Optional.ofNullable(Helper.get().parseDouble((String)var2.get()));
|
||||
}
|
||||
|
||||
default Optional<ItemStack> getItemStack(String var1) {
|
||||
Optional var2 = this.get(var1);
|
||||
return !var2.isPresent() ? Optional.empty() : Optional.ofNullable(Helper.get().parseItemStack((String)var2.get()));
|
||||
}
|
||||
|
||||
default void set(String var1, Number var2) {
|
||||
Validate.notNull(var2, "value");
|
||||
this.set(var1, var2.toString());
|
||||
}
|
||||
|
||||
default void set(String var1, ItemStack var2) {
|
||||
Validate.notNull(var2, "value");
|
||||
this.set(var1, Helper.get().composeItemStack(var2));
|
||||
}
|
||||
|
||||
default void set(String var1, boolean var2) {
|
||||
this.set(var1, Boolean.toString(var2));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class Validate {
|
||||
private Validate() {
|
||||
}
|
||||
|
||||
public static void notNull(@Nullable Object var0, String var1) {
|
||||
if (var0 == null) {
|
||||
throw new IllegalArgumentException("The passed parameter " + var1 + " is null");
|
||||
}
|
||||
}
|
||||
|
||||
public static void notNullDeep(@Nullable Object[] var0, String var1) {
|
||||
for (int var2 = 0; var2 < var0.length; var2++) {
|
||||
notNull(var0[var2], var1 + "[" + var2 + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public static void isTrue(boolean var0, String var1) {
|
||||
if (!var0) {
|
||||
throw new IllegalArgumentException(var1);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,204 @@
|
||||
package de.marcely.bedwars.tools;
|
||||
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import lombok.Generated;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class VarSound implements Cloneable {
|
||||
private float volume;
|
||||
private float pitch;
|
||||
private boolean isActive;
|
||||
|
||||
public abstract boolean isVanilla();
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
public abstract Sound getBukkitEnum();
|
||||
|
||||
public float getVolume() {
|
||||
return this.volume;
|
||||
}
|
||||
|
||||
public VarSound setVolume(float var1) {
|
||||
this.volume = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
public VarSound setPitch(float var1) {
|
||||
this.pitch = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.isActive;
|
||||
}
|
||||
|
||||
public VarSound setActive(boolean var1) {
|
||||
this.isActive = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract void play(Player var1, Location var2, @Nullable Float var3, @Nullable Float var4);
|
||||
|
||||
public abstract void play(Location var1, @Nullable Float var2, @Nullable Float var3);
|
||||
|
||||
public void play(Player var1, Location var2) {
|
||||
this.play(var1, var2, null, null);
|
||||
}
|
||||
|
||||
public void play(Player var1) {
|
||||
this.play(var1, var1.getLocation(), null, null);
|
||||
}
|
||||
|
||||
public void play(Location var1) {
|
||||
this.play(var1, null, null);
|
||||
}
|
||||
|
||||
public VarParticle clone() {
|
||||
try {
|
||||
return (VarParticle)super.clone();
|
||||
} catch (CloneNotSupportedException var2) {
|
||||
throw new RuntimeException(var2);
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection serializeAsConfig() {
|
||||
MemoryConfiguration var1 = new MemoryConfiguration();
|
||||
var1.set("name", this.getName());
|
||||
var1.set("is-active", this.isActive());
|
||||
var1.set("is-custom-resourcepack", !this.isVanilla());
|
||||
var1.set("volume", this.getVolume());
|
||||
var1.set("pitch", this.getPitch());
|
||||
return var1;
|
||||
}
|
||||
|
||||
public static VarSound parse(ConfigurationSection var0) {
|
||||
Validate.notNull(var0, "config");
|
||||
if (!var0.contains("name")) {
|
||||
throw new IllegalArgumentException("Missing \"name\" config");
|
||||
} else {
|
||||
String var1 = var0.getString("name");
|
||||
boolean var2 = var0.getBoolean("is-custom-resourcepack", false);
|
||||
boolean var3 = var0.getBoolean("is-active", true);
|
||||
float var4 = (float)var0.getDouble("volume", 1.0);
|
||||
float var5 = (float)var0.getDouble("pitch", 1.0);
|
||||
if (var2) {
|
||||
return new VarSound.Custom(var1, var4, var5, var3);
|
||||
} else {
|
||||
Sound var6 = Helper.get().getSoundByName(var1);
|
||||
if (var6 == null) {
|
||||
throw new IllegalArgumentException("Invalid sound name: " + var1);
|
||||
} else {
|
||||
return new VarSound.Vanilla(var6, var4, var5, var3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static VarSound from(Sound var0) {
|
||||
Validate.notNull(var0, "sound");
|
||||
return new VarSound.Vanilla(var0, 1.0F, 1.0F, true);
|
||||
}
|
||||
|
||||
public static VarSound fromCustom(String var0) {
|
||||
Validate.notNull(var0, "name");
|
||||
return new VarSound.Custom(var0, 1.0F, 1.0F, true);
|
||||
}
|
||||
|
||||
@Generated
|
||||
private VarSound(float var1, float var2, boolean var3) {
|
||||
this.volume = var1;
|
||||
this.pitch = var2;
|
||||
this.isActive = var3;
|
||||
}
|
||||
|
||||
static final class Custom extends VarSound {
|
||||
private String name;
|
||||
|
||||
private Custom(String var1, float var2, float var3, boolean var4) {
|
||||
super(var2, var3, var4);
|
||||
this.name = var1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVanilla() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getBukkitEnum() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play(Player var1, Location var2, @Nullable Float var3, @Nullable Float var4) {
|
||||
Validate.notNull(var1, "player");
|
||||
Validate.notNull(var2, "loc");
|
||||
if (this.isActive()) {
|
||||
Helper.get().playCustomSound(var1, var2, this.name, var3 != null ? var3 : this.getVolume(), var4 != null ? var4 : this.getPitch());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play(Location var1, @Nullable Float var2, @Nullable Float var3) {
|
||||
Validate.notNull(var1, "loc");
|
||||
if (this.isActive()) {
|
||||
Helper.get().playCustomSound(var1, this.name, var2 != null ? var2 : this.getVolume(), var3 != null ? var3 : this.getPitch());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static final class Vanilla extends VarSound {
|
||||
private final Sound sound;
|
||||
|
||||
private Vanilla(Sound var1, float var2, float var3, boolean var4) {
|
||||
super(var2, var3, var4);
|
||||
this.sound = var1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVanilla() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.sound.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sound getBukkitEnum() {
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play(Player var1, Location var2, @Nullable Float var3, @Nullable Float var4) {
|
||||
Validate.notNull(var1, "player");
|
||||
Validate.notNull(var2, "loc");
|
||||
if (this.isActive()) {
|
||||
Helper.get().playSound(var1, var2, this.sound, var3 != null ? var3 : this.getVolume(), var4 != null ? var4 : this.getPitch());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void play(Location var1, @Nullable Float var2, @Nullable Float var3) {
|
||||
Validate.notNull(var1, "loc");
|
||||
if (this.isActive()) {
|
||||
Helper.get().playSound(var1, this.sound, var2 != null ? var2 : this.getVolume(), var3 != null ? var3 : this.getPitch());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.marcely.bedwars.tools.gui;
|
||||
|
||||
import lombok.Generated;
|
||||
|
||||
public final class AddItemCondition {
|
||||
private static final byte TYPE_WITHIN_X = 0;
|
||||
private static final byte TYPE_WITHIN_Y = 1;
|
||||
private static final byte TYPE_WITHIN = 2;
|
||||
private final byte type;
|
||||
private final int[] parameters;
|
||||
|
||||
private AddItemCondition(byte var1, int[] var2) {
|
||||
this.type = var1;
|
||||
this.parameters = var2;
|
||||
}
|
||||
|
||||
public static AddItemCondition withinX(int var0, int var1) {
|
||||
int[] var2 = new int[]{var0, var1, 0, 5};
|
||||
return new AddItemCondition((byte)0, var2);
|
||||
}
|
||||
|
||||
public static AddItemCondition withinY(int var0, int var1) {
|
||||
int[] var2 = new int[]{0, 8, var0, var1};
|
||||
return new AddItemCondition((byte)1, var2);
|
||||
}
|
||||
|
||||
public static AddItemCondition within(int var0, int var1, int var2, int var3) {
|
||||
int[] var4 = new int[]{var0, var1, var2, var3};
|
||||
return new AddItemCondition((byte)2, var4);
|
||||
}
|
||||
|
||||
@Generated
|
||||
public byte getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Generated
|
||||
public int[] getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package de.marcely.bedwars.tools.gui;
|
||||
|
||||
public enum CenterFormat {
|
||||
CENTRALIZED,
|
||||
CENTRALIZED_EVEN,
|
||||
ALIGNED;
|
||||
|
||||
public int calculate(int var1, int var2, int var3, int var4) {
|
||||
switch (this) {
|
||||
case CENTRALIZED:
|
||||
return getSlotCenterCentralized(var1, var2, var3, var4);
|
||||
case CENTRALIZED_EVEN:
|
||||
return getSlotCenterCentralizedEven(var1, var2, var3, var4);
|
||||
case ALIGNED:
|
||||
return getSlotCenterAligned(var1, var2, var3, var4);
|
||||
default:
|
||||
return var1;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getSlotCenterCentralized(int var0, int var1, int var2, int var3) {
|
||||
return (int)((var3 - var2) / 2.0 - var1 / 2 + var0) + var2;
|
||||
}
|
||||
|
||||
private static int getSlotCenterCentralizedEven(int var0, int var1, int var2, int var3) {
|
||||
int var4 = getSlotCenterCentralized(var0, var1, var2, var3);
|
||||
if (var1 == 9) {
|
||||
return var4;
|
||||
} else if (var1 % 2 == 1) {
|
||||
return var4;
|
||||
} else {
|
||||
return var0 < var1 / 2 ? var4 : var4 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getSlotCenterAligned(int var0, int var1, int var2, int var3) {
|
||||
if (var2 == 0 && var3 == 9) {
|
||||
return getSlotCenterAligned9(var0, var1);
|
||||
} else {
|
||||
return var3 - var2 == 3 ? getSlotCenterAligned3(var0, var1) + var2 : (int)((double)var0 / var1 * (var3 - var2) + 0.5) + var2;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getSlotCenterAligned3(int var0, int var1) {
|
||||
switch (var1) {
|
||||
case 1:
|
||||
return 1;
|
||||
case 2:
|
||||
switch (var0) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 2;
|
||||
}
|
||||
default:
|
||||
return var0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int getSlotCenterAligned9(int var0, int var1) {
|
||||
switch (var1) {
|
||||
case 1:
|
||||
return 4;
|
||||
case 2:
|
||||
switch (var0) {
|
||||
case 0:
|
||||
return 3;
|
||||
case 1:
|
||||
return 5;
|
||||
}
|
||||
case 3:
|
||||
switch (var0) {
|
||||
case 0:
|
||||
return 1;
|
||||
case 1:
|
||||
return 4;
|
||||
case 2:
|
||||
return 7;
|
||||
}
|
||||
case 4:
|
||||
switch (var0) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 3;
|
||||
case 2:
|
||||
return 5;
|
||||
case 3:
|
||||
return 8;
|
||||
}
|
||||
case 5:
|
||||
switch (var0) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 2;
|
||||
case 2:
|
||||
return 4;
|
||||
case 3:
|
||||
return 6;
|
||||
case 4:
|
||||
return 8;
|
||||
}
|
||||
case 6:
|
||||
switch (var0) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 1;
|
||||
case 2:
|
||||
return 3;
|
||||
case 3:
|
||||
return 5;
|
||||
case 4:
|
||||
return 7;
|
||||
case 5:
|
||||
return 8;
|
||||
}
|
||||
case 7:
|
||||
switch (var0) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
return 2;
|
||||
case 2:
|
||||
return 3;
|
||||
case 3:
|
||||
return 4;
|
||||
case 4:
|
||||
return 5;
|
||||
case 5:
|
||||
return 6;
|
||||
case 6:
|
||||
return 8;
|
||||
}
|
||||
case 8:
|
||||
case 9:
|
||||
return var0;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package de.marcely.bedwars.tools.gui;
|
||||
|
||||
import de.marcely.bedwars.tools.Validate;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ClickListener {
|
||||
void onClick(Player var1, boolean var2, boolean var3);
|
||||
|
||||
default void onNumClick(Player var1, int var2) {
|
||||
}
|
||||
|
||||
class Proxy implements ClickListener {
|
||||
private final ClickListener listener;
|
||||
|
||||
public Proxy(ClickListener var1) {
|
||||
Validate.notNull(var1, "listener");
|
||||
this.listener = var1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(Player var1, boolean var2, boolean var3) {
|
||||
this.listener.onClick(var1, var2, var3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNumClick(Player var1, int var2) {
|
||||
this.listener.onNumClick(var1, var2);
|
||||
}
|
||||
}
|
||||
|
||||
class Silent implements ClickListener {
|
||||
public static ClickListener INSTANCE = new ClickListener.Silent();
|
||||
|
||||
private Silent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onClick(Player var1, boolean var2, boolean var3) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
package de.marcely.bedwars.tools.gui;
|
||||
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import de.marcely.bedwars.tools.gui.ClickListener.Silent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface ClickableGUI extends GUI {
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
|
||||
default int getSize() {
|
||||
return this.getWidth() * this.getHeight();
|
||||
}
|
||||
|
||||
void setItem(GUIItem var1, int var2);
|
||||
|
||||
@Nullable
|
||||
GUIItem getItem(int var1);
|
||||
|
||||
void fill(GUIItem var1);
|
||||
|
||||
void fillSpace(GUIItem var1);
|
||||
|
||||
default void fill(ItemStack var1) {
|
||||
this.fill(new GUIItem(var1, Silent.INSTANCE));
|
||||
}
|
||||
|
||||
default void fill(ItemStack var1, ClickListener var2) {
|
||||
this.fill(new GUIItem(var1, var2));
|
||||
}
|
||||
|
||||
default void fillSpace(ItemStack var1) {
|
||||
this.fillSpace(new GUIItem(var1, Silent.INSTANCE));
|
||||
}
|
||||
|
||||
default void fillSpace(ItemStack var1, ClickListener var2) {
|
||||
this.fillSpace(new GUIItem(var1, var2));
|
||||
}
|
||||
|
||||
default void setItem(GUIItem var1, int var2, int var3) {
|
||||
this.setItem(var1, this.calcSlot(var2, var3));
|
||||
}
|
||||
|
||||
default void setItem(ItemStack var1, int var2, ClickListener var3) {
|
||||
this.setItem(var1 != null ? new GUIItem(var1, var3) : null, var2);
|
||||
}
|
||||
|
||||
default void setItem(ItemStack var1, int var2, int var3, ClickListener var4) {
|
||||
this.setItem(var1, this.calcSlot(var2, var3), var4);
|
||||
}
|
||||
|
||||
default void setItem(ItemStack var1, int var2) {
|
||||
this.setItem(var1 != null ? new GUIItem(var1, Silent.INSTANCE) : null, var2);
|
||||
}
|
||||
|
||||
default void setItem(ItemStack var1, int var2, int var3) {
|
||||
this.setItem(var1, this.calcSlot(var2, var3));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default GUIItem getItem(int var1, int var2) {
|
||||
return this.getItem(this.calcSlot(var1, var2));
|
||||
}
|
||||
|
||||
int getNextSpace(@Nullable AddItemCondition var1);
|
||||
|
||||
default int getNextSpace() {
|
||||
return this.getNextSpace(null);
|
||||
}
|
||||
|
||||
default int addItem(GUIItem var1, @Nullable AddItemCondition var2) {
|
||||
int var3 = this.getNextSpace(var2);
|
||||
if (var3 != -1) {
|
||||
this.setItem(var1, var3);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
default int addItem(GUIItem var1) {
|
||||
return this.addItem(var1, null);
|
||||
}
|
||||
|
||||
default int addItem(ItemStack var1, ClickListener var2, @Nullable AddItemCondition var3) {
|
||||
return this.addItem(new GUIItem(var1, var2), var3);
|
||||
}
|
||||
|
||||
default int addItem(ItemStack var1, ClickListener var2) {
|
||||
return this.addItem(new GUIItem(var1, var2), null);
|
||||
}
|
||||
|
||||
default int addItem(ItemStack var1, @Nullable AddItemCondition var2) {
|
||||
return this.addItem(new GUIItem(var1, Silent.INSTANCE), var2);
|
||||
}
|
||||
|
||||
default int addItem(ItemStack var1) {
|
||||
return this.addItem(new GUIItem(var1, Silent.INSTANCE), null);
|
||||
}
|
||||
|
||||
default void formatRow(int var1, CenterFormat var2, int var3, int var4) {
|
||||
if (++var4 - var3 > 0) {
|
||||
GUIItem[] var5 = new GUIItem[var4 - var3];
|
||||
int var6 = 0;
|
||||
|
||||
for (int var7 = 0; var7 < var5.length; var7++) {
|
||||
int var8 = var3 + var7;
|
||||
if ((var5[var7] = this.getItem(var8, var1)) != null) {
|
||||
this.setItem((GUIItem)null, var8, var1);
|
||||
var6++;
|
||||
}
|
||||
}
|
||||
|
||||
int var11 = 0;
|
||||
|
||||
for (int var12 = 0; var12 < var5.length; var12++) {
|
||||
GUIItem var9 = var5[var12];
|
||||
if (var9 != null) {
|
||||
this.setItem(var9, var2.calculate(var11++, var6, var3, var4), var1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default void formatRow(int var1, CenterFormat var2) {
|
||||
this.formatRow(var1, var2, 0, this.getWidth() - 1);
|
||||
}
|
||||
|
||||
default void formatColumn(int var1, CenterFormat var2, int var3, int var4) {
|
||||
if (++var4 - var3 > 0) {
|
||||
GUIItem[] var5 = new GUIItem[var4 - var3];
|
||||
int var6 = 0;
|
||||
|
||||
for (int var7 = 0; var7 < var5.length; var7++) {
|
||||
int var8 = var3 + var7;
|
||||
if ((var5[var7] = this.getItem(var1, var8)) != null) {
|
||||
this.setItem((GUIItem)null, var1, var8);
|
||||
var6++;
|
||||
}
|
||||
}
|
||||
|
||||
int var13 = 0;
|
||||
|
||||
for (GUIItem var11 : var5) {
|
||||
if (var11 != null) {
|
||||
this.setItem(var11, var1, var2.calculate(var13++, var6, var3, var4));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default void formatColumn(int var1, CenterFormat var2) {
|
||||
this.formatColumn(var1, var2, 0, this.getHeight() - 1);
|
||||
}
|
||||
|
||||
default void formatAnyRow(CenterFormat var1, int var2, int var3) {
|
||||
for (int var4 = 0; var4 < this.getHeight(); var4++) {
|
||||
this.formatRow(var4, var1, var2, var3);
|
||||
}
|
||||
}
|
||||
|
||||
default void formatAnyColumn(CenterFormat var1, int var2, int var3) {
|
||||
for (int var4 = 0; var4 < this.getWidth(); var4++) {
|
||||
this.formatColumn(var4, var1, var2, var3);
|
||||
}
|
||||
}
|
||||
|
||||
default void formatAnyRow(CenterFormat var1) {
|
||||
for (int var2 = 0; var2 < this.getHeight(); var2++) {
|
||||
this.formatRow(var2, var1);
|
||||
}
|
||||
}
|
||||
|
||||
default void formatAnyColumn(CenterFormat var1) {
|
||||
for (int var2 = 0; var2 < this.getWidth(); var2++) {
|
||||
this.formatColumn(var2, var1);
|
||||
}
|
||||
}
|
||||
|
||||
default int calcSlot(int var1, int var2) {
|
||||
return var2 * this.getWidth() + var1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package de.marcely.bedwars.tools.gui;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface GUI {
|
||||
void open(Player var1);
|
||||
|
||||
void closeAll();
|
||||
|
||||
void setTitle(String var1);
|
||||
|
||||
String getTitle();
|
||||
|
||||
boolean areItemsMoveable();
|
||||
|
||||
default boolean ignoresCancelEvent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
Collection<Player> getPlayers();
|
||||
|
||||
boolean hasOpen(Player var1);
|
||||
|
||||
boolean addCloseListener(Consumer<Player> var1);
|
||||
|
||||
boolean removeCloseListener(Consumer<Player> var1);
|
||||
|
||||
Collection<Consumer<Player>> getCloseListeners();
|
||||
|
||||
void clear();
|
||||
|
||||
@Deprecated
|
||||
default void onClose(Player var1) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package de.marcely.bedwars.tools.gui;
|
||||
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import de.marcely.bedwars.tools.Validate;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public final class GUIItem implements Cloneable {
|
||||
private final ItemStack item;
|
||||
private final ClickListener listener;
|
||||
private Object attachement;
|
||||
|
||||
public GUIItem(ItemStack var1, ClickListener var2) {
|
||||
this(var1, var2, null);
|
||||
}
|
||||
|
||||
public GUIItem(ItemStack var1, ClickListener var2, @Nullable Object var3) {
|
||||
Validate.notNull(var1, "is");
|
||||
Validate.notNull(var2, "listener");
|
||||
this.item = var1;
|
||||
this.listener = var2;
|
||||
this.attachement = var3;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public ClickListener getListener() {
|
||||
return this.listener;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getAttachement() {
|
||||
return this.attachement;
|
||||
}
|
||||
|
||||
public void setAttachement(@Nullable Object var1) {
|
||||
this.attachement = var1;
|
||||
}
|
||||
|
||||
public GUIItem clone() {
|
||||
GUIItem var1 = new GUIItem(this.item.clone(), this.listener);
|
||||
var1.attachement = this.attachement;
|
||||
return var1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package de.marcely.bedwars.tools.gui;
|
||||
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import de.marcely.bedwars.tools.Validate;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public final class VillagerOffer {
|
||||
private static final long ID_MOST_BIT = new Random().nextInt();
|
||||
private static long ID_INDEX = Long.MIN_VALUE;
|
||||
private final UUID id;
|
||||
private ItemStack result;
|
||||
private ItemStack price1;
|
||||
private ItemStack price2;
|
||||
|
||||
public VillagerOffer(ItemStack var1, ItemStack var2) {
|
||||
this(var1, var2, null);
|
||||
}
|
||||
|
||||
public VillagerOffer(ItemStack var1, List<ItemStack> var2) {
|
||||
this(var1, (ItemStack)var2.get(0), var2.size() > 1 ? (ItemStack)var2.get(1) : null);
|
||||
}
|
||||
|
||||
public VillagerOffer(ItemStack var1, ItemStack var2, @Nullable ItemStack var3) {
|
||||
Validate.notNull(var1, "result");
|
||||
Validate.notNull(var2, "price1");
|
||||
this.id = new UUID(ID_MOST_BIT, ID_INDEX++);
|
||||
this.result = var1.clone();
|
||||
this.price1 = var2.clone();
|
||||
this.price2 = var3 != null ? var3.clone() : null;
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public ItemStack getResult() {
|
||||
return this.result.clone();
|
||||
}
|
||||
|
||||
public ItemStack getFirstPrice() {
|
||||
return this.price1.clone();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getSecondPrice() {
|
||||
return this.price2 != null ? this.price2.clone() : null;
|
||||
}
|
||||
|
||||
public boolean hasSecondPrice() {
|
||||
return this.price2 != null;
|
||||
}
|
||||
|
||||
public void setResult(ItemStack var1) {
|
||||
Validate.notNull(var1, "result");
|
||||
this.result = var1.clone();
|
||||
}
|
||||
|
||||
public void setFirstPrice(ItemStack var1) {
|
||||
Validate.notNull(var1, "price1");
|
||||
this.price1 = var1.clone();
|
||||
}
|
||||
|
||||
public void setSecondPrice(@Nullable ItemStack var1) {
|
||||
this.price2 = var1 != null ? var1.clone() : null;
|
||||
}
|
||||
|
||||
public static UUID getNextId() {
|
||||
return new UUID(ID_MOST_BIT, ID_INDEX);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package de.marcely.bedwars.tools.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface WriteListener {
|
||||
void onWrite(Player var1, String var2);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package de.marcely.bedwars.tools.gui.type;
|
||||
|
||||
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
||||
import de.marcely.bedwars.tools.Validate;
|
||||
import de.marcely.bedwars.tools.gui.GUI;
|
||||
import de.marcely.bedwars.tools.gui.WriteListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import lombok.Generated;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class AnvilGUI implements GUI {
|
||||
private final List<Consumer<Player>> closeListeners = new ArrayList<>();
|
||||
private Map<Player, Inventory> openPlayers = new IdentityHashMap<>();
|
||||
private String title = "";
|
||||
private String defaultMessage;
|
||||
private Set<WriteListener> listeners = new HashSet<>();
|
||||
|
||||
public AnvilGUI() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public AnvilGUI(String var1) {
|
||||
Validate.notNull(var1, "defaultMessage");
|
||||
this.defaultMessage = var1;
|
||||
}
|
||||
|
||||
public void open(Player var1) {
|
||||
this.openPlayers.put(var1, BedwarsAPILayer.INSTANCE.open(this, var1));
|
||||
}
|
||||
|
||||
public void closeAll() {
|
||||
for (Player var2 : this.openPlayers.keySet()) {
|
||||
var2.closeInventory();
|
||||
}
|
||||
|
||||
this.openPlayers.clear();
|
||||
}
|
||||
|
||||
public void setTitle(String var1) {
|
||||
Validate.notNull(var1, "title");
|
||||
this.title = var1;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public boolean areItemsMoveable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Collection<Player> getPlayers() {
|
||||
return Collections.unmodifiableCollection(this.openPlayers.keySet());
|
||||
}
|
||||
|
||||
public boolean hasOpen(Player var1) {
|
||||
Validate.notNull(var1, "player");
|
||||
return this.openPlayers.containsKey(var1);
|
||||
}
|
||||
|
||||
public boolean addCloseListener(Consumer<Player> var1) {
|
||||
Validate.notNull(var1, "callback");
|
||||
return this.closeListeners.contains(var1) ? false : this.closeListeners.add(var1);
|
||||
}
|
||||
|
||||
public boolean removeCloseListener(Consumer<Player> var1) {
|
||||
Validate.notNull(var1, "callback");
|
||||
return this.closeListeners.remove(var1);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
public void onClose(Player var1) {
|
||||
this.openPlayers.remove(var1);
|
||||
}
|
||||
|
||||
public String getDefaultMessage() {
|
||||
return this.defaultMessage;
|
||||
}
|
||||
|
||||
public Set<WriteListener> getListeners() {
|
||||
return Collections.unmodifiableSet(this.listeners);
|
||||
}
|
||||
|
||||
public boolean addListener(WriteListener var1) {
|
||||
Validate.notNull(var1, "listener");
|
||||
return this.listeners.add(var1);
|
||||
}
|
||||
|
||||
public boolean removeListener(WriteListener var1) {
|
||||
return this.listeners.remove(var1);
|
||||
}
|
||||
|
||||
@Generated
|
||||
public List<Consumer<Player>> getCloseListeners() {
|
||||
return this.closeListeners;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
package de.marcely.bedwars.tools.gui.type;
|
||||
|
||||
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import de.marcely.bedwars.tools.Validate;
|
||||
import de.marcely.bedwars.tools.gui.AddItemCondition;
|
||||
import de.marcely.bedwars.tools.gui.ClickableGUI;
|
||||
import de.marcely.bedwars.tools.gui.GUIItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Generated;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ChestGUI implements ClickableGUI {
|
||||
private final List<Consumer<Player>> closeListeners = new ArrayList<>();
|
||||
private Inventory inv;
|
||||
private GUIItem[] items;
|
||||
private boolean ignoresCancelEvent = false;
|
||||
private String title;
|
||||
|
||||
public ChestGUI() {
|
||||
this(1, "");
|
||||
}
|
||||
|
||||
public ChestGUI(int var1) {
|
||||
this(var1, "");
|
||||
}
|
||||
|
||||
public ChestGUI(String var1) {
|
||||
this(1, var1);
|
||||
}
|
||||
|
||||
public ChestGUI(int var1, String var2) {
|
||||
Validate.notNull(var2, "title");
|
||||
var1 = Math.max(1, Math.min(6, var1));
|
||||
this.inv = Bukkit.createInventory(null, var1 * 9, this.title = var2);
|
||||
this.items = new GUIItem[var1 * 9];
|
||||
}
|
||||
|
||||
public void open(Player var1) {
|
||||
var1.openInventory(this.inv);
|
||||
BedwarsAPILayer.INSTANCE.open(this, var1);
|
||||
}
|
||||
|
||||
public void closeAll() {
|
||||
List var1 = this.inv.getViewers();
|
||||
|
||||
for (int var2 = var1.size() - 1; var2 >= 0; var2--) {
|
||||
((HumanEntity)var1.get(var2)).closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public void setTitle(String var1) {
|
||||
Validate.notNull(var1, "title");
|
||||
if (!var1.equals(this.title)) {
|
||||
Inventory var2 = this.inv;
|
||||
ArrayList var3 = new ArrayList(var2.getViewers());
|
||||
this.inv = Bukkit.createInventory(null, var2.getSize(), this.title = var1);
|
||||
this.inv.setContents(var2.getContents());
|
||||
this.ignoresCancelEvent = true;
|
||||
var3.forEach(var1x -> ((HumanEntity)var1x).openInventory(this.inv));
|
||||
this.ignoresCancelEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public boolean areItemsMoveable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean ignoresCancelEvent() {
|
||||
return this.ignoresCancelEvent;
|
||||
}
|
||||
|
||||
public Collection<Player> getPlayers() {
|
||||
return this.inv.getViewers().stream().map(var0 -> (Player)var0).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public boolean hasOpen(Player var1) {
|
||||
Validate.notNull(var1, "player");
|
||||
return this.inv.getViewers().contains(var1);
|
||||
}
|
||||
|
||||
public boolean addCloseListener(Consumer<Player> var1) {
|
||||
Validate.notNull(var1, "callback");
|
||||
return this.closeListeners.contains(var1) ? false : this.closeListeners.add(var1);
|
||||
}
|
||||
|
||||
public boolean removeCloseListener(Consumer<Player> var1) {
|
||||
Validate.notNull(var1, "callback");
|
||||
return this.closeListeners.remove(var1);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.inv.getSize() / 9;
|
||||
}
|
||||
|
||||
public void setItem(GUIItem var1, int var2) {
|
||||
this.items[var2] = var1;
|
||||
this.inv.setItem(var2, var1 != null ? var1.getItem() : null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GUIItem getItem(int var1) {
|
||||
return this.items[var1];
|
||||
}
|
||||
|
||||
public void setHeight(int var1) {
|
||||
if (this.getHeight() != var1) {
|
||||
Inventory var2 = this.inv;
|
||||
ArrayList var3 = new ArrayList(var2.getViewers());
|
||||
GUIItem[] var4 = this.items;
|
||||
this.inv = Bukkit.createInventory(null, 9 * var1, this.getTitle());
|
||||
this.items = new GUIItem[9 * var1];
|
||||
this.inv.setContents(Arrays.copyOfRange(var2.getContents(), 0, Math.min(var4.length, this.items.length)));
|
||||
System.arraycopy(var4, 0, this.items, 0, Math.min(var4.length, this.items.length));
|
||||
this.ignoresCancelEvent = true;
|
||||
var3.forEach(var1x -> ((HumanEntity)var1x).openInventory(this.inv));
|
||||
this.ignoresCancelEvent = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
Arrays.fill(this.items, null);
|
||||
this.inv.setContents(new ItemStack[0]);
|
||||
}
|
||||
|
||||
public void fill(GUIItem var1) {
|
||||
for (int var2 = 0; var2 < this.items.length; var2++) {
|
||||
this.setItem(var1, var2);
|
||||
}
|
||||
}
|
||||
|
||||
public void fillSpace(GUIItem var1) {
|
||||
for (int var2 = 0; var2 < this.items.length; var2++) {
|
||||
if (this.items[var2] == null) {
|
||||
this.setItem(var1, var2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getNextSpace(@Nullable AddItemCondition var1) {
|
||||
int var2 = 0;
|
||||
int var3 = 8;
|
||||
int var4 = 0;
|
||||
int var5 = 5;
|
||||
if (var1 != null) {
|
||||
int[] var6 = var1.getParameters();
|
||||
var2 = var6[0];
|
||||
var3 = var6[1];
|
||||
var4 = var6[2];
|
||||
var5 = var6[3];
|
||||
}
|
||||
|
||||
int var11 = var5 * 9 + var3;
|
||||
int var7 = var4 * 9 + var2 - 1;
|
||||
|
||||
while (++var7 <= var11) {
|
||||
boolean var8 = false;
|
||||
|
||||
do {
|
||||
int var9 = var7 % 9;
|
||||
int var10 = var7 / 9;
|
||||
var8 = false;
|
||||
if (var9 > var3) {
|
||||
var7 = (var10 + 1) * 9 + var2;
|
||||
var8 = true;
|
||||
}
|
||||
|
||||
if (var10 > var5) {
|
||||
return -1;
|
||||
}
|
||||
} while (var8);
|
||||
|
||||
if (var7 >= this.items.length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (this.items[var7] == null) {
|
||||
return var7;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int addItem(GUIItem var1, @Nullable AddItemCondition var2) {
|
||||
int var3 = -1;
|
||||
|
||||
while ((var3 = ClickableGUI.super.addItem(var1, var2)) == -1 && this.getHeight() <= 5) {
|
||||
this.setHeight(this.getHeight() + 1);
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
|
||||
public boolean mergeFrom(ChestGUI var1, boolean var2) {
|
||||
Validate.notNull(var1, "gui");
|
||||
if (this == var1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!this.title.equals(var1.title) || var1.getHeight() != this.getHeight()) {
|
||||
if (!var2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.setTitle(var1.getTitle());
|
||||
this.setHeight(var1.getHeight());
|
||||
}
|
||||
|
||||
for (int var3 = 0; var3 < this.items.length; var3++) {
|
||||
this.setItem(var1.getItem(var3), var3);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Generated
|
||||
public List<Consumer<Player>> getCloseListeners() {
|
||||
return this.closeListeners;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package de.marcely.bedwars.tools.gui.type;
|
||||
|
||||
import de.marcely.bedwars.api.event.player.PlayerTradeVillagerGUIEvent;
|
||||
import de.marcely.bedwars.api.unsafe.BedwarsAPILayer;
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import de.marcely.bedwars.tools.Validate;
|
||||
import de.marcely.bedwars.tools.gui.GUI;
|
||||
import de.marcely.bedwars.tools.gui.VillagerOffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import lombok.Generated;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class VillagerGUI implements GUI {
|
||||
private final List<Consumer<Player>> closeListeners = new ArrayList<>();
|
||||
private Set<Player> openPlayers = new HashSet<>();
|
||||
private String title;
|
||||
private Set<VillagerOffer> offers = new LinkedHashSet<>();
|
||||
private Set<Consumer<PlayerTradeVillagerGUIEvent>> tradeListeners = new LinkedHashSet<>();
|
||||
|
||||
public VillagerGUI() {
|
||||
this("");
|
||||
}
|
||||
|
||||
public VillagerGUI(String var1) {
|
||||
Validate.notNull(var1, "title");
|
||||
this.title = var1;
|
||||
}
|
||||
|
||||
public void open(Player var1) {
|
||||
BedwarsAPILayer.INSTANCE.open(this, var1);
|
||||
this.openPlayers.add(var1);
|
||||
}
|
||||
|
||||
public void closeAll() {
|
||||
for (Player var2 : this.openPlayers) {
|
||||
var2.closeInventory();
|
||||
}
|
||||
|
||||
this.openPlayers.clear();
|
||||
}
|
||||
|
||||
public void setTitle(String var1) {
|
||||
Validate.notNull(var1, "title");
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public boolean areItemsMoveable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Collection<Player> getPlayers() {
|
||||
return Collections.unmodifiableCollection(this.openPlayers);
|
||||
}
|
||||
|
||||
public boolean hasOpen(Player var1) {
|
||||
Validate.notNull(var1, "player");
|
||||
return this.openPlayers.contains(var1);
|
||||
}
|
||||
|
||||
public boolean addCloseListener(Consumer<Player> var1) {
|
||||
Validate.notNull(var1, "callback");
|
||||
return this.closeListeners.contains(var1) ? false : this.closeListeners.add(var1);
|
||||
}
|
||||
|
||||
public boolean removeCloseListener(Consumer<Player> var1) {
|
||||
Validate.notNull(var1, "callback");
|
||||
return this.closeListeners.remove(var1);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.offers.clear();
|
||||
}
|
||||
|
||||
public final void onClose(Player var1) {
|
||||
this.openPlayers.remove(var1);
|
||||
}
|
||||
|
||||
public Set<VillagerOffer> getOffers() {
|
||||
return Collections.unmodifiableSet(this.offers);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public VillagerOffer getOffer(UUID var1) {
|
||||
for (VillagerOffer var3 : this.offers) {
|
||||
if (var3.getId().equals(var1)) {
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean addOffer(VillagerOffer var1) {
|
||||
Validate.notNull(var1, "offer");
|
||||
return this.offers.add(var1);
|
||||
}
|
||||
|
||||
public boolean removeOffer(VillagerOffer var1) {
|
||||
return this.offers.remove(var1);
|
||||
}
|
||||
|
||||
public Set<Consumer<PlayerTradeVillagerGUIEvent>> getTradeListeners() {
|
||||
return this.tradeListeners;
|
||||
}
|
||||
|
||||
public boolean registerTradeListener(Consumer<PlayerTradeVillagerGUIEvent> var1) {
|
||||
return this.tradeListeners.add(var1);
|
||||
}
|
||||
|
||||
public boolean unregisterTradeListener(Consumer<PlayerTradeVillagerGUIEvent> var1) {
|
||||
return this.tradeListeners.remove(var1);
|
||||
}
|
||||
|
||||
@Generated
|
||||
public List<Consumer<Player>> getCloseListeners() {
|
||||
return this.closeListeners;
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package de.marcely.bedwars.tools.location;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public final class ImmutableLocation extends Location {
|
||||
public ImmutableLocation(Location var1) {
|
||||
this(var1.getWorld(), var1.getX(), var1.getY(), var1.getZ(), var1.getYaw(), var1.getPitch());
|
||||
}
|
||||
|
||||
public ImmutableLocation(World var1, double var2, double var4, double var6) {
|
||||
super(var1, var2, var4, var6);
|
||||
}
|
||||
|
||||
public ImmutableLocation(World var1, double var2, double var4, double var6, float var8, float var9) {
|
||||
super(var1, var2, var4, var6, var8, var9);
|
||||
}
|
||||
|
||||
public void setWorld(World var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public void setX(double var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public void setY(double var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public void setZ(double var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public void setYaw(float var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public void setPitch(float var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location setDirection(Vector var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location add(Location var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location add(Vector var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location add(double var1, double var3, double var5) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location subtract(Location var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location subtract(Vector var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location subtract(double var1, double var3, double var5) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location multiply(double var1) {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public Location zero() {
|
||||
throw new UnsupportedOperationException("Trying to modify an immutable object");
|
||||
}
|
||||
|
||||
public ImmutableLocation clone() {
|
||||
return (ImmutableLocation)super.clone();
|
||||
}
|
||||
|
||||
public Location cloneMutable() {
|
||||
return new Location(this.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYaw(), this.getPitch());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package de.marcely.bedwars.tools.location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Generated;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class IntXYZ implements Cloneable, ConfigurationSerializable {
|
||||
protected int x;
|
||||
protected int y;
|
||||
protected int z;
|
||||
|
||||
public IntXYZ() {
|
||||
this(0, 0, 0);
|
||||
}
|
||||
|
||||
public IntXYZ(Location var1) {
|
||||
this(var1.getBlockX(), var1.getBlockY(), var1.getBlockZ());
|
||||
}
|
||||
|
||||
public IntXYZ(Vector var1) {
|
||||
this(var1.getBlockX(), var1.getBlockY(), var1.getBlockZ());
|
||||
}
|
||||
|
||||
public IntXYZ(XYZ var1) {
|
||||
this(var1.getBlockX(), var1.getBlockY(), var1.getBlockZ());
|
||||
}
|
||||
|
||||
public IntXYZ(Block var1) {
|
||||
this(var1.getX(), var1.getY(), var1.getZ());
|
||||
}
|
||||
|
||||
public IntXYZ(int var1, int var2, int var3) {
|
||||
this.x = var1;
|
||||
this.y = var2;
|
||||
this.z = var3;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public IntXYZ setX(int var1) {
|
||||
this.x = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ setY(int var1) {
|
||||
this.y = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ setZ(int var1) {
|
||||
this.z = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ set(int var1, int var2, int var3) {
|
||||
this.x = var1;
|
||||
this.y = var2;
|
||||
this.z = var3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ set(XYZ var1) {
|
||||
this.x = var1.getBlockX();
|
||||
this.y = var1.getBlockY();
|
||||
this.z = var1.getBlockZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ set(Location var1) {
|
||||
this.x = var1.getBlockX();
|
||||
this.y = var1.getBlockY();
|
||||
this.z = var1.getBlockZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ set(Block var1) {
|
||||
this.x = var1.getX();
|
||||
this.y = var1.getY();
|
||||
this.z = var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ add(int var1, int var2, int var3) {
|
||||
this.x += var1;
|
||||
this.y += var2;
|
||||
this.z += var3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ add(IntXYZ var1) {
|
||||
this.x = this.x + var1.x;
|
||||
this.y = this.y + var1.y;
|
||||
this.z = this.z + var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ subtract(int var1, int var2, int var3) {
|
||||
this.x -= var1;
|
||||
this.y -= var2;
|
||||
this.z -= var3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ subtract(IntXYZ var1) {
|
||||
this.x = this.x - var1.x;
|
||||
this.y = this.y - var1.y;
|
||||
this.z = this.z - var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ multiply(int var1) {
|
||||
this.x *= var1;
|
||||
this.y *= var1;
|
||||
this.z *= var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ multiply(int var1, int var2, int var3) {
|
||||
this.x *= var1;
|
||||
this.y *= var2;
|
||||
this.z *= var3;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IntXYZ zero() {
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
this.z = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isZero() {
|
||||
return this.x == 0 && this.y == 0 && this.z == 0;
|
||||
}
|
||||
|
||||
public double distance(IntXYZ var1) {
|
||||
return Math.sqrt(this.distanceSquared(var1));
|
||||
}
|
||||
|
||||
public double distanceSquared(IntXYZ var1) {
|
||||
return NumberConversions.square(this.x - var1.x) + NumberConversions.square(this.y - var1.y) + NumberConversions.square(this.z - var1.z);
|
||||
}
|
||||
|
||||
public Location toLocation(World var1) {
|
||||
return new Location(var1, this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public Vector toVector() {
|
||||
return new Vector(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public Block getBlock(World var1) {
|
||||
return var1.getBlockAt(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public boolean equalsBlockCoords(XYZ var1) {
|
||||
return this.x == var1.getBlockX() && this.y == var1.getBlockY() && this.z == var1.getBlockZ();
|
||||
}
|
||||
|
||||
public boolean equalsBlockCoords(Location var1) {
|
||||
return this.x == var1.getBlockX() && this.y == var1.getBlockY() && this.z == var1.getBlockZ();
|
||||
}
|
||||
|
||||
public boolean equalsBlockCoords(Block var1) {
|
||||
return this.x == var1.getX() && this.y == var1.getY() && this.z == var1.getZ();
|
||||
}
|
||||
|
||||
public IntXYZ clone() {
|
||||
return new IntXYZ(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap var1 = new HashMap();
|
||||
var1.put("x", this.x);
|
||||
var1.put("y", this.y);
|
||||
var1.put("z", this.z);
|
||||
return var1;
|
||||
}
|
||||
|
||||
public static IntXYZ deserialize(Map<String, Object> var0) {
|
||||
return new IntXYZ(NumberConversions.toInt(var0.get("x")), NumberConversions.toInt(var0.get("y")), NumberConversions.toInt(var0.get("z")));
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == this) {
|
||||
return true;
|
||||
} else if (!(var1 instanceof IntXYZ)) {
|
||||
return false;
|
||||
} else {
|
||||
IntXYZ var2 = (IntXYZ)var1;
|
||||
if (!var2.canEqual(this)) {
|
||||
return false;
|
||||
} else if (this.getX() != var2.getX()) {
|
||||
return false;
|
||||
} else {
|
||||
return this.getY() != var2.getY() ? false : this.getZ() == var2.getZ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Generated
|
||||
protected boolean canEqual(Object var1) {
|
||||
return var1 instanceof IntXYZ;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte var1 = 59;
|
||||
int var2 = 1;
|
||||
var2 = var2 * 59 + this.getX();
|
||||
var2 = var2 * 59 + this.getY();
|
||||
return var2 * 59 + this.getZ();
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "IntXYZ(x=" + this.getX() + ", y=" + this.getY() + ", z=" + this.getZ() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
package de.marcely.bedwars.tools.location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Generated;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class XYZ implements Cloneable, ConfigurationSerializable {
|
||||
protected double x;
|
||||
protected double y;
|
||||
protected double z;
|
||||
|
||||
public XYZ() {
|
||||
this(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
public XYZ(Location var1) {
|
||||
this(var1.getX(), var1.getY(), var1.getZ());
|
||||
}
|
||||
|
||||
public XYZ(Vector var1) {
|
||||
this(var1.getX(), var1.getY(), var1.getZ());
|
||||
}
|
||||
|
||||
public XYZ(XYZ var1) {
|
||||
this(var1.x, var1.y, var1.z);
|
||||
}
|
||||
|
||||
public XYZ(IntXYZ var1) {
|
||||
this(var1.x, var1.y, var1.z);
|
||||
}
|
||||
|
||||
public XYZ(double var1, double var3, double var5) {
|
||||
this.x = var1;
|
||||
this.y = var3;
|
||||
this.z = var5;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public int getBlockX() {
|
||||
return NumberConversions.floor(this.x);
|
||||
}
|
||||
|
||||
public int getBlockY() {
|
||||
return NumberConversions.floor(this.y);
|
||||
}
|
||||
|
||||
public int getBlockZ() {
|
||||
return NumberConversions.floor(this.z);
|
||||
}
|
||||
|
||||
public XYZ setX(double var1) {
|
||||
this.x = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ setY(double var1) {
|
||||
this.y = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ setZ(double var1) {
|
||||
this.z = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ set(double var1, double var3, double var5) {
|
||||
this.x = var1;
|
||||
this.y = var3;
|
||||
this.z = var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ set(XYZ var1) {
|
||||
this.x = var1.x;
|
||||
this.y = var1.y;
|
||||
this.z = var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ set(IntXYZ var1) {
|
||||
this.x = var1.x;
|
||||
this.y = var1.y;
|
||||
this.z = var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ set(Location var1) {
|
||||
this.x = var1.getX();
|
||||
this.y = var1.getY();
|
||||
this.z = var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ add(double var1, double var3, double var5) {
|
||||
this.x += var1;
|
||||
this.y += var3;
|
||||
this.z += var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ add(XYZ var1) {
|
||||
this.x = this.x + var1.x;
|
||||
this.y = this.y + var1.y;
|
||||
this.z = this.z + var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ add(IntXYZ var1) {
|
||||
this.x = this.x + var1.x;
|
||||
this.y = this.y + var1.y;
|
||||
this.z = this.z + var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ add(Location var1) {
|
||||
this.x = this.x + var1.getX();
|
||||
this.y = this.y + var1.getY();
|
||||
this.z = this.z + var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ add(Vector var1) {
|
||||
this.x = this.x + var1.getX();
|
||||
this.y = this.y + var1.getY();
|
||||
this.z = this.z + var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ subtract(double var1, double var3, double var5) {
|
||||
this.x -= var1;
|
||||
this.y -= var3;
|
||||
this.z -= var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ subtract(XYZ var1) {
|
||||
this.x = this.x - var1.x;
|
||||
this.y = this.y - var1.y;
|
||||
this.z = this.z - var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ subtract(IntXYZ var1) {
|
||||
this.x = this.x - var1.x;
|
||||
this.y = this.y - var1.y;
|
||||
this.z = this.z - var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ subtract(Location var1) {
|
||||
this.x = this.x - var1.getX();
|
||||
this.y = this.y - var1.getY();
|
||||
this.z = this.z - var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ subtract(Vector var1) {
|
||||
this.x = this.x - var1.getX();
|
||||
this.y = this.y - var1.getY();
|
||||
this.z = this.z - var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ multiply(double var1) {
|
||||
this.x *= var1;
|
||||
this.y *= var1;
|
||||
this.z *= var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ multiply(double var1, double var3, double var5) {
|
||||
this.x *= var1;
|
||||
this.y *= var3;
|
||||
this.z *= var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZ zero() {
|
||||
this.x = 0.0;
|
||||
this.y = 0.0;
|
||||
this.z = 0.0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isZero() {
|
||||
return this.x == 0.0 && this.y == 0.0 && this.z == 0.0;
|
||||
}
|
||||
|
||||
public double distance(Location var1) {
|
||||
return Math.sqrt(this.distanceSquared(var1));
|
||||
}
|
||||
|
||||
public double distanceSquared(Location var1) {
|
||||
return NumberConversions.square(this.x - var1.getX()) + NumberConversions.square(this.y - var1.getY()) + NumberConversions.square(this.z - var1.getZ());
|
||||
}
|
||||
|
||||
public double distance(XYZ var1) {
|
||||
return Math.sqrt(this.distanceSquared(var1));
|
||||
}
|
||||
|
||||
public double distanceSquared(XYZ var1) {
|
||||
return NumberConversions.square(this.x - var1.x) + NumberConversions.square(this.y - var1.y) + NumberConversions.square(this.z - var1.z);
|
||||
}
|
||||
|
||||
public Location toLocation(World var1) {
|
||||
return new Location(var1, this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public Vector toVector() {
|
||||
return new Vector(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public Block getBlock(World var1) {
|
||||
return var1.getBlockAt((int)this.x, (int)this.y, (int)this.z);
|
||||
}
|
||||
|
||||
public boolean equalsBlockCoords(XYZ var1) {
|
||||
return this.getBlockX() == var1.getBlockX() && this.getBlockY() == var1.getBlockY() && this.getBlockZ() == var1.getBlockZ();
|
||||
}
|
||||
|
||||
public boolean equalsBlockCoords(Location var1) {
|
||||
return this.getBlockX() == var1.getBlockX() && this.getBlockY() == var1.getBlockY() && this.getBlockZ() == var1.getBlockZ();
|
||||
}
|
||||
|
||||
public boolean equalsBlockCoords(Block var1) {
|
||||
return this.getBlockX() == var1.getX() && this.getBlockY() == var1.getY() && this.getBlockZ() == var1.getZ();
|
||||
}
|
||||
|
||||
public XYZ clone() {
|
||||
return new XYZ(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap var1 = new HashMap();
|
||||
var1.put("x", this.x);
|
||||
var1.put("y", this.y);
|
||||
var1.put("z", this.z);
|
||||
return var1;
|
||||
}
|
||||
|
||||
public static XYZ deserialize(Map<String, Object> var0) {
|
||||
return new XYZ(NumberConversions.toDouble(var0.get("x")), NumberConversions.toDouble(var0.get("y")), NumberConversions.toDouble(var0.get("z")));
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == this) {
|
||||
return true;
|
||||
} else if (!(var1 instanceof XYZ)) {
|
||||
return false;
|
||||
} else {
|
||||
XYZ var2 = (XYZ)var1;
|
||||
if (!var2.canEqual(this)) {
|
||||
return false;
|
||||
} else if (Double.compare(this.getX(), var2.getX()) != 0) {
|
||||
return false;
|
||||
} else {
|
||||
return Double.compare(this.getY(), var2.getY()) != 0 ? false : Double.compare(this.getZ(), var2.getZ()) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Generated
|
||||
protected boolean canEqual(Object var1) {
|
||||
return var1 instanceof XYZ;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte var1 = 59;
|
||||
int var2 = 1;
|
||||
long var3 = Double.doubleToLongBits(this.getX());
|
||||
var2 = var2 * 59 + (int)(var3 >>> 32 ^ var3);
|
||||
long var5 = Double.doubleToLongBits(this.getY());
|
||||
var2 = var2 * 59 + (int)(var5 >>> 32 ^ var5);
|
||||
long var7 = Double.doubleToLongBits(this.getZ());
|
||||
return var2 * 59 + (int)(var7 >>> 32 ^ var7);
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "XYZ(x=" + this.getX() + ", y=" + this.getY() + ", z=" + this.getZ() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,346 @@
|
||||
package de.marcely.bedwars.tools.location;
|
||||
|
||||
import de.marcely.bedwars.libraries.org.jetbrains.annotations.Nullable;
|
||||
import de.marcely.bedwars.tools.Validate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import lombok.Generated;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class XYZD extends XYZ implements Cloneable, ConfigurationSerializable {
|
||||
protected XYZD.Direction dir;
|
||||
|
||||
public XYZD(Location var1) {
|
||||
this(var1.getX(), var1.getY(), var1.getZ());
|
||||
}
|
||||
|
||||
public XYZD(Vector var1) {
|
||||
this(var1.getX(), var1.getY(), var1.getZ());
|
||||
}
|
||||
|
||||
public XYZD(XYZ var1) {
|
||||
this(var1.x, var1.y, var1.z);
|
||||
}
|
||||
|
||||
public XYZD(XYZD var1) {
|
||||
this(var1.x, var1.y, var1.z, var1.dir);
|
||||
}
|
||||
|
||||
public XYZD() {
|
||||
this(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
public XYZD(double var1, double var3, double var5) {
|
||||
this(var1, var3, var5, XYZD.Direction.NORTH);
|
||||
}
|
||||
|
||||
public XYZD(double var1, double var3, double var5, XYZD.Direction var7) {
|
||||
Validate.notNull(var7, "direction");
|
||||
this.x = var1;
|
||||
this.y = var3;
|
||||
this.z = var5;
|
||||
this.dir = var7;
|
||||
}
|
||||
|
||||
public XYZD setX(double var1) {
|
||||
this.x = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD setY(double var1) {
|
||||
this.y = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD setZ(double var1) {
|
||||
this.z = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD set(double var1, double var3, double var5) {
|
||||
this.x = var1;
|
||||
this.y = var3;
|
||||
this.z = var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD set(XYZ var1) {
|
||||
this.x = var1.x;
|
||||
this.y = var1.y;
|
||||
this.z = var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD set(Location var1) {
|
||||
this.x = var1.getX();
|
||||
this.y = var1.getY();
|
||||
this.z = var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD add(double var1, double var3, double var5) {
|
||||
this.x += var1;
|
||||
this.y += var3;
|
||||
this.z += var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD add(XYZ var1) {
|
||||
this.x = this.x + var1.x;
|
||||
this.y = this.y + var1.y;
|
||||
this.z = this.z + var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD add(Location var1) {
|
||||
this.x = this.x + var1.getX();
|
||||
this.y = this.y + var1.getY();
|
||||
this.z = this.z + var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD add(Vector var1) {
|
||||
this.x = this.x + var1.getX();
|
||||
this.y = this.y + var1.getY();
|
||||
this.z = this.z + var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD subtract(double var1, double var3, double var5) {
|
||||
this.x -= var1;
|
||||
this.y -= var3;
|
||||
this.z -= var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD subtract(XYZ var1) {
|
||||
this.x = this.x - var1.x;
|
||||
this.y = this.y - var1.y;
|
||||
this.z = this.z - var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD subtract(Location var1) {
|
||||
this.x = this.x - var1.getX();
|
||||
this.y = this.y - var1.getY();
|
||||
this.z = this.z - var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD subtract(Vector var1) {
|
||||
this.x = this.x - var1.getX();
|
||||
this.y = this.y - var1.getY();
|
||||
this.z = this.z - var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD multiply(double var1) {
|
||||
this.x *= var1;
|
||||
this.y *= var1;
|
||||
this.z *= var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD multiply(double var1, double var3, double var5) {
|
||||
this.x *= var1;
|
||||
this.y *= var3;
|
||||
this.z *= var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD zero() {
|
||||
this.x = 0.0;
|
||||
this.y = 0.0;
|
||||
this.z = 0.0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location toLocation(World var1) {
|
||||
return new Location(var1, this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public XYZD set(XYZD var1) {
|
||||
this.x = var1.x;
|
||||
this.y = var1.y;
|
||||
this.z = var1.z;
|
||||
this.dir = var1.dir;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD.Direction getDirection() {
|
||||
return this.dir;
|
||||
}
|
||||
|
||||
public XYZD setDirection(XYZD.Direction var1) {
|
||||
Validate.notNull(var1, "direction");
|
||||
this.dir = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZD clone() {
|
||||
return new XYZD(this.x, this.y, this.z, this.dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap var1 = new HashMap();
|
||||
var1.put("x", this.x);
|
||||
var1.put("y", this.y);
|
||||
var1.put("z", this.z);
|
||||
var1.put("direction", this.dir.name());
|
||||
return var1;
|
||||
}
|
||||
|
||||
public static XYZD deserialize(Map<String, Object> var0) {
|
||||
return new XYZD(
|
||||
NumberConversions.toDouble(var0.get("x")),
|
||||
NumberConversions.toDouble(var0.get("y")),
|
||||
NumberConversions.toDouble(var0.get("z")),
|
||||
XYZD.Direction.valueOf((String)var0.get("direction"))
|
||||
);
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == this) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(var1 instanceof XYZD)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XYZD var2 = (XYZD)var1;
|
||||
if (!var2.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
XYZD.Direction var3 = this.dir;
|
||||
XYZD.Direction var4 = var2.dir;
|
||||
return var3 == null ? var4 == null : var3.equals(var4);
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
protected boolean canEqual(Object var1) {
|
||||
return var1 instanceof XYZD;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte var1 = 59;
|
||||
byte var2 = 1;
|
||||
XYZD.Direction var3 = this.dir;
|
||||
return var2 * 59 + (var3 == null ? 43 : var3.hashCode());
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "XYZD(super=" + super.toString() + ", dir=" + this.dir + ")";
|
||||
}
|
||||
|
||||
public enum Direction {
|
||||
NORTH(BlockFace.NORTH),
|
||||
SOUTH(BlockFace.SOUTH),
|
||||
EAST(BlockFace.EAST),
|
||||
WEST(BlockFace.WEST);
|
||||
|
||||
private final BlockFace blockFace;
|
||||
|
||||
Direction(BlockFace var3) {
|
||||
this.blockFace = var3;
|
||||
}
|
||||
|
||||
public BlockFace asBlockFace() {
|
||||
return this.blockFace;
|
||||
}
|
||||
|
||||
public int getModX() {
|
||||
switch (this) {
|
||||
case EAST:
|
||||
return 1;
|
||||
case WEST:
|
||||
return -1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int getModZ() {
|
||||
switch (this) {
|
||||
case NORTH:
|
||||
return -1;
|
||||
case SOUTH:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int toLegacy() {
|
||||
switch (this) {
|
||||
case NORTH:
|
||||
return 2;
|
||||
case SOUTH:
|
||||
return 0;
|
||||
case EAST:
|
||||
return 3;
|
||||
case WEST:
|
||||
return 1;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static XYZD.Direction fromName(String var0) {
|
||||
try {
|
||||
return valueOf(var0.toUpperCase(Locale.ENGLISH));
|
||||
} catch (IllegalArgumentException var2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static XYZD.Direction fromBlockFace(BlockFace var0) {
|
||||
switch (var0) {
|
||||
case NORTH:
|
||||
return NORTH;
|
||||
case SOUTH:
|
||||
return SOUTH;
|
||||
case EAST:
|
||||
return EAST;
|
||||
case WEST:
|
||||
return WEST;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static XYZD.Direction fromLegacy(int var0) {
|
||||
switch (var0) {
|
||||
case 0:
|
||||
return SOUTH;
|
||||
case 1:
|
||||
return WEST;
|
||||
case 2:
|
||||
return NORTH;
|
||||
case 3:
|
||||
return EAST;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
package de.marcely.bedwars.tools.location;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Generated;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class XYZYP extends XYZ implements Cloneable, ConfigurationSerializable {
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
|
||||
public XYZYP(Location var1) {
|
||||
this(var1.getX(), var1.getY(), var1.getZ(), var1.getYaw(), var1.getPitch());
|
||||
}
|
||||
|
||||
public XYZYP(Vector var1) {
|
||||
this(var1.getX(), var1.getY(), var1.getZ());
|
||||
}
|
||||
|
||||
public XYZYP(XYZ var1) {
|
||||
this(var1.x, var1.y, var1.z);
|
||||
}
|
||||
|
||||
public XYZYP(XYZYP var1) {
|
||||
this(var1.x, var1.y, var1.z, var1.yaw, var1.pitch);
|
||||
}
|
||||
|
||||
public XYZYP() {
|
||||
this(0.0, 0.0, 0.0, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
public XYZYP(double var1, double var3, double var5) {
|
||||
this(var1, var3, var5, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
public XYZYP(double var1, double var3, double var5, float var7, float var8) {
|
||||
super(var1, var3, var5);
|
||||
this.yaw = var7;
|
||||
this.pitch = var8;
|
||||
}
|
||||
|
||||
public XYZYP setX(double var1) {
|
||||
this.x = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP setY(double var1) {
|
||||
this.y = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP setZ(double var1) {
|
||||
this.z = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP set(double var1, double var3, double var5) {
|
||||
this.x = var1;
|
||||
this.y = var3;
|
||||
this.z = var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP set(XYZ var1) {
|
||||
this.x = var1.x;
|
||||
this.y = var1.y;
|
||||
this.z = var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP set(Location var1) {
|
||||
this.x = var1.getX();
|
||||
this.y = var1.getY();
|
||||
this.z = var1.getZ();
|
||||
this.yaw = var1.getYaw();
|
||||
this.pitch = var1.getPitch();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP add(double var1, double var3, double var5) {
|
||||
this.x += var1;
|
||||
this.y += var3;
|
||||
this.z += var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP add(XYZ var1) {
|
||||
this.x = this.x + var1.x;
|
||||
this.y = this.y + var1.y;
|
||||
this.z = this.z + var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP add(Location var1) {
|
||||
this.x = this.x + var1.getX();
|
||||
this.y = this.y + var1.getY();
|
||||
this.z = this.z + var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP add(Vector var1) {
|
||||
this.x = this.x + var1.getX();
|
||||
this.y = this.y + var1.getY();
|
||||
this.z = this.z + var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP subtract(double var1, double var3, double var5) {
|
||||
this.x -= var1;
|
||||
this.y -= var3;
|
||||
this.z -= var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP subtract(XYZ var1) {
|
||||
this.x = this.x - var1.x;
|
||||
this.y = this.y - var1.y;
|
||||
this.z = this.z - var1.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP subtract(Location var1) {
|
||||
this.x = this.x - var1.getX();
|
||||
this.y = this.y - var1.getY();
|
||||
this.z = this.z - var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP subtract(Vector var1) {
|
||||
this.x = this.x - var1.getX();
|
||||
this.y = this.y - var1.getY();
|
||||
this.z = this.z - var1.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP multiply(double var1) {
|
||||
this.x *= var1;
|
||||
this.y *= var1;
|
||||
this.z *= var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP multiply(double var1, double var3, double var5) {
|
||||
this.x *= var1;
|
||||
this.y *= var3;
|
||||
this.z *= var5;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP zero() {
|
||||
this.x = 0.0;
|
||||
this.y = 0.0;
|
||||
this.z = 0.0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location toLocation(World var1) {
|
||||
return new Location(var1, this.x, this.y, this.z, this.yaw, this.pitch);
|
||||
}
|
||||
|
||||
public XYZYP set(XYZYP var1) {
|
||||
this.x = var1.x;
|
||||
this.y = var1.y;
|
||||
this.z = var1.z;
|
||||
this.yaw = var1.yaw;
|
||||
this.pitch = var1.pitch;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return this.yaw;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return this.pitch;
|
||||
}
|
||||
|
||||
public XYZYP setYaw(float var1) {
|
||||
this.yaw = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP setPitch(float var1) {
|
||||
this.pitch = var1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XYZYP clone() {
|
||||
return new XYZYP(this.x, this.y, this.z, this.yaw, this.pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap var1 = new HashMap();
|
||||
var1.put("x", this.x);
|
||||
var1.put("y", this.y);
|
||||
var1.put("z", this.z);
|
||||
var1.put("yaw", this.yaw);
|
||||
var1.put("pitch", this.pitch);
|
||||
return var1;
|
||||
}
|
||||
|
||||
public static XYZYP deserialize(Map<String, Object> var0) {
|
||||
return new XYZYP(
|
||||
NumberConversions.toDouble(var0.get("x")),
|
||||
NumberConversions.toDouble(var0.get("y")),
|
||||
NumberConversions.toDouble(var0.get("z")),
|
||||
NumberConversions.toFloat(var0.get("yaw")),
|
||||
NumberConversions.toFloat(var0.get("pitch"))
|
||||
);
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public boolean equals(Object var1) {
|
||||
if (var1 == this) {
|
||||
return true;
|
||||
} else if (!(var1 instanceof XYZYP)) {
|
||||
return false;
|
||||
} else {
|
||||
XYZYP var2 = (XYZYP)var1;
|
||||
if (!var2.canEqual(this)) {
|
||||
return false;
|
||||
} else {
|
||||
return Float.compare(this.getYaw(), var2.getYaw()) != 0 ? false : Float.compare(this.getPitch(), var2.getPitch()) == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
protected boolean canEqual(Object var1) {
|
||||
return var1 instanceof XYZYP;
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public int hashCode() {
|
||||
byte var1 = 59;
|
||||
int var2 = 1;
|
||||
var2 = var2 * 59 + Float.floatToIntBits(this.getYaw());
|
||||
return var2 * 59 + Float.floatToIntBits(this.getPitch());
|
||||
}
|
||||
|
||||
@Generated
|
||||
@Override
|
||||
public String toString() {
|
||||
return "XYZYP(super=" + super.toString() + ", yaw=" + this.getYaw() + ", pitch=" + this.getPitch() + ")";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user