Bump to v0.6 -> Renamed packages following Java standard, and added 1.16 support.
This commit is contained in:
parent
b367e4ea65
commit
d57406f66e
40 changed files with 1154 additions and 342 deletions
30
pom.xml
30
pom.xml
|
@ -4,7 +4,7 @@
|
|||
|
||||
<groupId>nl.SBDeveloper</groupId>
|
||||
<artifactId>V10Lift2</artifactId>
|
||||
<version>0.5.9</version>
|
||||
<version>0.6</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>V10Lift</name>
|
||||
|
@ -47,7 +47,11 @@
|
|||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>nl.SBDeveloper.V10Lift.Metrics</shadedPattern>
|
||||
<shadedPattern>nl.SBDeveloper.V10Lift.utils.metrics</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>nl.SBDeveloper.V10Lift.utils.hikari</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
|
@ -153,7 +157,7 @@
|
|||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -165,14 +169,6 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- SBUtilities, our own Util dependency, used for all sort of things -->
|
||||
<dependency>
|
||||
<groupId>nl.SBDevelopment</groupId>
|
||||
<artifactId>SBUtilities</artifactId>
|
||||
<version>1.9</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- BStats, used for metrics -->
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
|
@ -188,6 +184,18 @@
|
|||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zaxxer</groupId>
|
||||
<artifactId>HikariCP</artifactId>
|
||||
<version>3.4.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* All the runnables of V10Lift
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.API.Runnables;
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* The main API package
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.API;
|
|
@ -1,18 +1,17 @@
|
|||
package nl.SBDeveloper.V10Lift;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.V10LiftAPI;
|
||||
import nl.SBDeveloper.V10Lift.Commands.V10LiftCommand;
|
||||
import nl.SBDeveloper.V10Lift.Commands.V10LiftTabCompleter;
|
||||
import nl.SBDeveloper.V10Lift.Listeners.BlockBreakListener;
|
||||
import nl.SBDeveloper.V10Lift.Listeners.EntityDamageListener;
|
||||
import nl.SBDeveloper.V10Lift.Listeners.PlayerInteractListener;
|
||||
import nl.SBDeveloper.V10Lift.Listeners.SignChangeListener;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DBManager;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.Managers.VaultManager;
|
||||
import nl.SBDevelopment.SBUtilities.Data.YamlFile;
|
||||
import nl.SBDevelopment.SBUtilities.PrivateManagers.UpdateManager;
|
||||
import nl.SBDevelopment.SBUtilities.SBUtilities;
|
||||
import nl.SBDeveloper.V10Lift.api.V10LiftAPI;
|
||||
import nl.SBDeveloper.V10Lift.commands.V10LiftCommand;
|
||||
import nl.SBDeveloper.V10Lift.commands.V10LiftTabCompleter;
|
||||
import nl.SBDeveloper.V10Lift.listeners.BlockBreakListener;
|
||||
import nl.SBDeveloper.V10Lift.listeners.EntityDamageListener;
|
||||
import nl.SBDeveloper.V10Lift.listeners.PlayerInteractListener;
|
||||
import nl.SBDeveloper.V10Lift.listeners.SignChangeListener;
|
||||
import nl.SBDeveloper.V10Lift.managers.DBManager;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.managers.VaultManager;
|
||||
import nl.SBDeveloper.V10Lift.sbutils.UpdateManager;
|
||||
import nl.SBDeveloper.V10Lift.sbutils.YamlFile;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -34,9 +33,6 @@ public class V10LiftPlugin extends JavaPlugin {
|
|||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
//Initialize the util
|
||||
new SBUtilities(this, "V10Lift");
|
||||
|
||||
//Load the config
|
||||
config = new YamlFile("config");
|
||||
config.loadDefaults();
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package nl.SBDeveloper.V10Lift.API;
|
||||
package nl.SBDeveloper.V10Lift.api;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.*;
|
||||
import nl.SBDeveloper.V10Lift.API.Runnables.DoorCloser;
|
||||
import nl.SBDeveloper.V10Lift.API.Runnables.MoveLift;
|
||||
import nl.SBDeveloper.V10Lift.Managers.AntiCopyBlockManager;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.Managers.ForbiddenBlockManager;
|
||||
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.DirectionUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.DoorUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.XMaterial;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import nl.SBDevelopment.SBUtilities.Utils.LocationSerializer;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.*;
|
||||
import nl.SBDeveloper.V10Lift.api.runnables.DoorCloser;
|
||||
import nl.SBDeveloper.V10Lift.api.runnables.MoveLift;
|
||||
import nl.SBDeveloper.V10Lift.managers.AntiCopyBlockManager;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.managers.ForbiddenBlockManager;
|
||||
import nl.SBDeveloper.V10Lift.sbutils.LocationSerializer;
|
||||
import nl.SBDeveloper.V10Lift.utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.DirectionUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.DoorUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.XMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
@ -175,7 +175,7 @@ public class V10LiftAPI {
|
|||
|
||||
/**
|
||||
* Add a block to a lift
|
||||
* Use {@link nl.SBDeveloper.V10Lift.API.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
* Use {@link nl.SBDeveloper.V10Lift.api.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
*
|
||||
* @param liftName The name of the lift
|
||||
* @param block The block
|
||||
|
@ -189,7 +189,7 @@ public class V10LiftAPI {
|
|||
|
||||
/**
|
||||
* Add a block to a lift
|
||||
* Use {@link nl.SBDeveloper.V10Lift.API.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
* Use {@link nl.SBDeveloper.V10Lift.api.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
*
|
||||
* @param blocks The blockset
|
||||
* @param block The block
|
||||
|
@ -229,7 +229,7 @@ public class V10LiftAPI {
|
|||
|
||||
/**
|
||||
* Add a block to a lift
|
||||
* Use {@link nl.SBDeveloper.V10Lift.API.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
* Use {@link nl.SBDeveloper.V10Lift.api.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
*
|
||||
* @param blocks The blockset
|
||||
* @param block The LiftBlock
|
||||
|
@ -244,7 +244,7 @@ public class V10LiftAPI {
|
|||
|
||||
/**
|
||||
* Remove a block from a lift
|
||||
* Use {@link nl.SBDeveloper.V10Lift.API.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
* Use {@link nl.SBDeveloper.V10Lift.api.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
*
|
||||
* @param liftName The name of the lift
|
||||
* @param block The block
|
||||
|
@ -288,7 +288,7 @@ public class V10LiftAPI {
|
|||
|
||||
/**
|
||||
* Switch a block at a lift
|
||||
* Use {@link nl.SBDeveloper.V10Lift.API.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
* Use {@link nl.SBDeveloper.V10Lift.api.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
*
|
||||
* @param liftName The name of the lift
|
||||
* @param block The block
|
||||
|
@ -301,7 +301,7 @@ public class V10LiftAPI {
|
|||
|
||||
/**
|
||||
* Switch a block at a lift
|
||||
* Use {@link nl.SBDeveloper.V10Lift.API.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
* Use {@link nl.SBDeveloper.V10Lift.api.V10LiftAPI#sortLiftBlocks(String liftName)} after!
|
||||
*
|
||||
* @param blocks The blockset
|
||||
* @param block The block
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.API.Objects;
|
||||
package nl.SBDeveloper.V10Lift.api.objects;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,9 +1,9 @@
|
|||
package nl.SBDeveloper.V10Lift.API.Objects;
|
||||
package nl.SBDeveloper.V10Lift.api.objects;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import nl.SBDeveloper.V10Lift.API.Runnables.DoorCloser;
|
||||
import nl.SBDeveloper.V10Lift.api.runnables.DoorCloser;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.API.Objects;
|
||||
package nl.SBDeveloper.V10Lift.api.objects;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.API.Objects;
|
||||
package nl.SBDeveloper.V10Lift.api.objects;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.API.Objects;
|
||||
package nl.SBDeveloper.V10Lift.api.objects;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.API.Objects;
|
||||
package nl.SBDeveloper.V10Lift.api.objects;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* All the objects used for V10Lift
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.API.Objects;
|
||||
package nl.SBDeveloper.V10Lift.api.objects;
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* The main API package
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.api;
|
|
@ -1,6 +1,6 @@
|
|||
package nl.SBDeveloper.V10Lift.API.Runnables;
|
||||
package nl.SBDeveloper.V10Lift.api.runnables;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
package nl.SBDeveloper.V10Lift.API.Runnables;
|
||||
package nl.SBDeveloper.V10Lift.api.runnables;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.*;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.DirectionUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.XMaterial;
|
||||
import nl.SBDeveloper.V10Lift.Utils.XSound;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import nl.SBDevelopment.SBUtilities.Utils.LocationSerializer;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.*;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.sbutils.LocationSerializer;
|
||||
import nl.SBDeveloper.V10Lift.utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.DirectionUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.XMaterial;
|
||||
import nl.SBDeveloper.V10Lift.utils.XSound;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
@ -532,7 +532,7 @@ public class MoveLift implements Runnable {
|
|||
if (lift.isSound()) {
|
||||
if (block != null) {
|
||||
loc = block.getLocation();
|
||||
XSound.ENTITY_EXPERIENCE_ORB_PICKUP.playSound(loc, 2.0F, 63.0F);
|
||||
XSound.ENTITY_EXPERIENCE_ORB_PICKUP.play(loc, 2.0F, 63.0F);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* All the runnables of V10Lift
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.api.runnables;
|
|
@ -1,15 +1,15 @@
|
|||
package nl.SBDeveloper.V10Lift.Commands;
|
||||
package nl.SBDeveloper.V10Lift.commands;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Floor;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.LiftSign;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.Managers.VaultManager;
|
||||
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.XMaterial;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import nl.SBDevelopment.SBUtilities.Utils.LocationSerializer;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Floor;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.LiftSign;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.managers.VaultManager;
|
||||
import nl.SBDeveloper.V10Lift.sbutils.LocationSerializer;
|
||||
import nl.SBDeveloper.V10Lift.utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.XMaterial;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
|
@ -1,8 +1,8 @@
|
|||
package nl.SBDeveloper.V10Lift.Commands;
|
||||
package nl.SBDeveloper.V10Lift.commands;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.Managers.VaultManager;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.managers.VaultManager;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* The command and tab manager of v10lift
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.Commands;
|
||||
package nl.SBDeveloper.V10Lift.commands;
|
|
@ -1,11 +1,11 @@
|
|||
package nl.SBDeveloper.V10Lift.Listeners;
|
||||
package nl.SBDeveloper.V10Lift.listeners;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Floor;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.DoorUtil;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Floor;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.DoorUtil;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
|
@ -1,8 +1,8 @@
|
|||
package nl.SBDeveloper.V10Lift.Listeners;
|
||||
package nl.SBDeveloper.V10Lift.listeners;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
|
@ -1,13 +1,13 @@
|
|||
package nl.SBDeveloper.V10Lift.Listeners;
|
||||
package nl.SBDeveloper.V10Lift.listeners;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Floor;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.Managers.VaultManager;
|
||||
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.DoorUtil;
|
||||
import nl.SBDeveloper.V10Lift.Utils.XMaterial;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Floor;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.managers.VaultManager;
|
||||
import nl.SBDeveloper.V10Lift.utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.DoorUtil;
|
||||
import nl.SBDeveloper.V10Lift.utils.XMaterial;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
|
@ -1,9 +1,9 @@
|
|||
package nl.SBDeveloper.V10Lift.Listeners;
|
||||
package nl.SBDeveloper.V10Lift.listeners;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.LiftSign;
|
||||
import nl.SBDeveloper.V10Lift.Managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.Utils.ConfigUtil;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.LiftSign;
|
||||
import nl.SBDeveloper.V10Lift.managers.DataManager;
|
||||
import nl.SBDeveloper.V10Lift.utils.ConfigUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* All the event listeners of V10Lift
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.Listeners;
|
||||
package nl.SBDeveloper.V10Lift.listeners;
|
|
@ -1,6 +1,6 @@
|
|||
package nl.SBDeveloper.V10Lift.Managers;
|
||||
package nl.SBDeveloper.V10Lift.managers;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.Utils.XMaterial;
|
||||
import nl.SBDeveloper.V10Lift.utils.XMaterial;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashSet;
|
|
@ -1,8 +1,8 @@
|
|||
package nl.SBDeveloper.V10Lift.Managers;
|
||||
package nl.SBDeveloper.V10Lift.managers;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Lift;
|
||||
import nl.SBDevelopment.SBUtilities.Data.SQLiteDB;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.sbutils.SQLiteDB;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.sql.Connection;
|
|
@ -1,7 +1,7 @@
|
|||
package nl.SBDeveloper.V10Lift.Managers;
|
||||
package nl.SBDeveloper.V10Lift.managers;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.API.Objects.LiftBlock;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.Lift;
|
||||
import nl.SBDeveloper.V10Lift.api.objects.LiftBlock;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package nl.SBDeveloper.V10Lift.Managers;
|
||||
package nl.SBDeveloper.V10Lift.managers;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.Utils.XMaterial;
|
||||
import nl.SBDeveloper.V10Lift.utils.XMaterial;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.HashSet;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.Managers;
|
||||
package nl.SBDeveloper.V10Lift.managers;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* The package with all the managers, like forbidden blocks, data and more
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.Managers;
|
||||
package nl.SBDeveloper.V10Lift.managers;
|
|
@ -0,0 +1,81 @@
|
|||
package nl.SBDeveloper.V10Lift.sbutils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class LocationSerializer {
|
||||
|
||||
/**
|
||||
* Deserialize a serialized location, without {@link Location#getYaw()} and {@link Location#getPitch()}
|
||||
*
|
||||
* @param string The location string
|
||||
*
|
||||
* @return The location or null if error
|
||||
*/
|
||||
@Nullable
|
||||
public static Location deserialize(@Nonnull String string) {
|
||||
String[] split = string.split("_");
|
||||
|
||||
if (split.length < 4) return null;
|
||||
|
||||
//world_x_y_z
|
||||
return new Location(
|
||||
Bukkit.getWorld(split[0]),
|
||||
Double.parseDouble(split[1]),
|
||||
Double.parseDouble(split[2]),
|
||||
Double.parseDouble(split[3])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a serialized location, with {@link Location#getYaw()} and {@link Location#getPitch()}
|
||||
*
|
||||
* @param string The location string
|
||||
*
|
||||
* @return The location or null if error
|
||||
*/
|
||||
@Nonnull
|
||||
public static Location deserializePY(@Nonnull String string) {
|
||||
String[] split = string.split("_");
|
||||
|
||||
//world_x_y_z
|
||||
return new Location(
|
||||
Bukkit.getWorld(split[0]),
|
||||
Double.parseDouble(split[1]),
|
||||
Double.parseDouble(split[2]),
|
||||
Double.parseDouble(split[3]),
|
||||
Float.parseFloat(split[4]),
|
||||
Float.parseFloat(split[5])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a location, without {@link Location#getYaw()} and {@link Location#getPitch()}
|
||||
*
|
||||
* @param loc The location
|
||||
*
|
||||
* @return The serialized string
|
||||
*/
|
||||
@Nullable
|
||||
public static String serialize(@Nonnull Location loc) {
|
||||
if (loc.getWorld() == null) return null;
|
||||
return loc.getWorld().getName() + "_" + loc.getX() + "_" + loc.getY() + "_" + loc.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize a location, with {@link Location#getYaw()} and {@link Location#getPitch()}
|
||||
*
|
||||
* @param loc The location
|
||||
*
|
||||
* @return The serialized string
|
||||
*/
|
||||
@Nullable
|
||||
public static String serializePY(@Nonnull Location loc) {
|
||||
if (loc.getWorld() == null) return null;
|
||||
return loc.getWorld().getName() + "_" + loc.getX() + "_" + loc.getY() + "_" + loc.getZ() + "_" + loc.getYaw() + "_" + loc.getPitch();
|
||||
}
|
||||
|
||||
}
|
90
src/main/lombok/nl/SBDeveloper/V10Lift/sbutils/SQLiteDB.java
Normal file
90
src/main/lombok/nl/SBDeveloper/V10Lift/sbutils/SQLiteDB.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
package nl.SBDeveloper.V10Lift.sbutils;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
|
||||
public class SQLiteDB {
|
||||
|
||||
private String dbName;
|
||||
private HikariDataSource source;
|
||||
private Connection con;
|
||||
|
||||
/**
|
||||
* Initialize a new connection
|
||||
*
|
||||
* @param dbName The database name
|
||||
*/
|
||||
public SQLiteDB(String dbName) {
|
||||
this.dbName = dbName;
|
||||
|
||||
File dbFile = new File(V10LiftPlugin.getInstance().getDataFolder(), dbName + ".db");
|
||||
|
||||
if (!dbFile.exists()) {
|
||||
try {
|
||||
Bukkit.getLogger().info("[V10Lift] Generating the " + dbName + ".db!");
|
||||
if (!dbFile.createNewFile()) {
|
||||
Bukkit.getLogger().severe("[V10Lift] Couldn't generate the " + dbName + ".db!");
|
||||
return;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().info("[V10Lift] Couldn't generate the " + dbName + ".db!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
HikariConfig config = new HikariConfig();
|
||||
config.setPoolName("V10Lift");
|
||||
config.setUsername(null);
|
||||
config.setPassword(null);
|
||||
config.setDriverClassName("org.sqlite.JDBC");
|
||||
config.setConnectionTestQuery("SELECT 1");
|
||||
config.setMaximumPoolSize(1);
|
||||
|
||||
Properties prop = new Properties();
|
||||
prop.setProperty("date_string_format", "yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
config.setJdbcUrl("jdbc:sqlite:" + dbFile.getAbsolutePath());
|
||||
config.setDataSourceProperties(prop);
|
||||
this.source = new HikariDataSource(config);
|
||||
|
||||
try {
|
||||
this.con = this.source.getConnection();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the connection, to execute queries
|
||||
*
|
||||
* CREATE TABLE -> execute()
|
||||
* SELECT -> executeQuery()
|
||||
* UPDATE -> executeUpdate()
|
||||
*
|
||||
* @return Connection
|
||||
*/
|
||||
public Connection getConnection() {
|
||||
return this.con;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the connection
|
||||
*/
|
||||
public void closeSource() {
|
||||
Bukkit.getLogger().info("[V10Lift] Closing the database connection for " + dbName + ".db!");
|
||||
try {
|
||||
this.con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.source.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
package nl.SBDeveloper.V10Lift.sbutils;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
/**
|
||||
* Update class for SBDevelopment
|
||||
* @author Stijn [SBDeveloper]
|
||||
* @since 05-03-2020
|
||||
* @version 1.4
|
||||
*
|
||||
* © Stijn Bannink <stijnbannink23@gmail.com> - All rights reserved.
|
||||
*/
|
||||
public class UpdateManager {
|
||||
|
||||
private static final String SPIGOT_API = "https://api.spigotmc.org/legacy/update.php?resource=%d";
|
||||
|
||||
/* Port 4000 is now legacy, 4443 has a SSL cert */
|
||||
/* As of 24-05-2020, using the legacy port because of SSL errors */
|
||||
private static final String SBDPLUGINS_API = "http://updates.sbdplugins.nl:4000/api/resources/%d";
|
||||
|
||||
private static final String RESOURCE_DOWNLOAD = "http://api.spiget.org/v2/resources/%s/download";
|
||||
|
||||
private Plugin plugin;
|
||||
private Version currentVersion;
|
||||
private int resourceID;
|
||||
private CheckType type;
|
||||
private BiConsumer<VersionResponse, Version> versionResponse;
|
||||
private BiConsumer<DownloadResponse, String> downloadResponse;
|
||||
|
||||
/**
|
||||
* Construct a new UpdateManager
|
||||
*
|
||||
* @param plugin The javaplugin (Main class)
|
||||
* @param resourceID The resourceID on spigot/sbdplugins
|
||||
* @param type The check type
|
||||
*/
|
||||
public UpdateManager(@Nonnull Plugin plugin, int resourceID, CheckType type) {
|
||||
this.plugin = plugin;
|
||||
this.currentVersion = new Version(plugin.getDescription().getVersion());
|
||||
this.resourceID = resourceID;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the response given by check();
|
||||
* @param versionResponse The response
|
||||
* @return The updatemanager
|
||||
*/
|
||||
public UpdateManager handleResponse(BiConsumer<VersionResponse, Version> versionResponse) {
|
||||
this.versionResponse = versionResponse;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UpdateManager handleDownloadResponse(BiConsumer<DownloadResponse, String> downloadResponse) {
|
||||
this.downloadResponse = downloadResponse;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for a new version
|
||||
*/
|
||||
public void check() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
try {
|
||||
BufferedReader in = null;
|
||||
if (type == CheckType.SPIGOT) {
|
||||
HttpsURLConnection con = (HttpsURLConnection) new URL(String.format(SPIGOT_API, this.resourceID)).openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
} else if (type == CheckType.SBDPLUGINS) {
|
||||
HttpURLConnection con = (HttpURLConnection) new URL(String.format(SBDPLUGINS_API, this.resourceID)).openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
}
|
||||
|
||||
if (in == null) return;
|
||||
|
||||
String version = null;
|
||||
|
||||
String inputLine;
|
||||
StringBuilder response = new StringBuilder();
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
in.close();
|
||||
|
||||
JsonParser parser = new JsonParser();
|
||||
|
||||
if (type == CheckType.SPIGOT) {
|
||||
JsonArray array = parser.parse(response.toString()).getAsJsonArray();
|
||||
|
||||
version = array.get(0).getAsJsonObject().get("name").getAsString();
|
||||
} else if (type == CheckType.SBDPLUGINS) {
|
||||
JsonObject object = parser.parse(response.toString()).getAsJsonObject();
|
||||
|
||||
version = object.get("data").getAsJsonObject().get("version").getAsString();
|
||||
}
|
||||
|
||||
if (version == null) return;
|
||||
|
||||
Version onlineVersion = new Version(version);
|
||||
|
||||
boolean latestVersion = this.currentVersion.compareTo(onlineVersion) < 0;
|
||||
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.versionResponse.accept(latestVersion ? VersionResponse.LATEST : VersionResponse.FOUND_NEW, latestVersion ? this.currentVersion : onlineVersion));
|
||||
} catch (IOException | NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.versionResponse.accept(VersionResponse.UNAVAILABLE, null));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void runUpdate() {
|
||||
File pluginFile = getPluginFile();// /plugins/XXX.jar
|
||||
if (pluginFile == null) {
|
||||
this.downloadResponse.accept(DownloadResponse.ERROR, null);
|
||||
return;
|
||||
}
|
||||
File updateFolder = Bukkit.getUpdateFolderFile();
|
||||
if (!updateFolder.exists()) {
|
||||
if (!updateFolder.mkdirs()) {
|
||||
this.downloadResponse.accept(DownloadResponse.ERROR, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
final File updateFile = new File(updateFolder, pluginFile.getName());
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
if (this.type == CheckType.SBDPLUGINS) {
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.downloadResponse.accept(DownloadResponse.UNAVAILABLE, null));
|
||||
return;
|
||||
}
|
||||
|
||||
ReadableByteChannel channel;
|
||||
try {
|
||||
//https://stackoverflow.com/questions/921262/how-to-download-and-save-a-file-from-internet-using-java
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(String.format(RESOURCE_DOWNLOAD, this.resourceID)).openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
if (connection.getResponseCode() != 200) {
|
||||
throw new RuntimeException("Download returned status #" + connection.getResponseCode());
|
||||
}
|
||||
channel = Channels.newChannel(connection.getInputStream());
|
||||
} catch (IOException e) {
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.downloadResponse.accept(DownloadResponse.ERROR, null));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
FileOutputStream output = new FileOutputStream(updateFile);
|
||||
output.getChannel().transferFrom(channel, 0, Long.MAX_VALUE);
|
||||
output.flush();
|
||||
output.close();
|
||||
} catch (IOException e) {
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.downloadResponse.accept(DownloadResponse.ERROR, null));
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(this.plugin, () -> this.downloadResponse.accept(DownloadResponse.DONE, updateFile.getPath()));
|
||||
});
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private File getPluginFile() {
|
||||
if (!(this.plugin instanceof JavaPlugin)) { return null; }
|
||||
try {
|
||||
Method method = JavaPlugin.class.getDeclaredMethod("getFile");
|
||||
method.setAccessible(true);
|
||||
return (File) method.invoke(this.plugin);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException("Could not get plugin file", e);
|
||||
}
|
||||
}
|
||||
|
||||
public enum CheckType {
|
||||
SPIGOT, SBDPLUGINS
|
||||
}
|
||||
|
||||
public enum VersionResponse {
|
||||
LATEST, FOUND_NEW, UNAVAILABLE
|
||||
}
|
||||
|
||||
public enum DownloadResponse {
|
||||
DONE, ERROR, UNAVAILABLE
|
||||
}
|
||||
|
||||
public static class Version implements Comparable<Version> {
|
||||
|
||||
private String version;
|
||||
|
||||
public final String get() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public Version(String version) {
|
||||
if(version == null)
|
||||
throw new IllegalArgumentException("Version can not be null");
|
||||
if(!version.matches("[0-9]+(\\.[0-9]+)*"))
|
||||
throw new IllegalArgumentException("Invalid version format");
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@Nonnull Version that) {
|
||||
String[] thisParts = this.get().split("\\.");
|
||||
String[] thatParts = that.get().split("\\.");
|
||||
|
||||
int length = Math.max(thisParts.length, thatParts.length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int thisPart = i < thisParts.length ? Integer.parseInt(thisParts[i]) : 0;
|
||||
int thatPart = i < thatParts.length ? Integer.parseInt(thatParts[i]) : 0;
|
||||
if(thisPart < thatPart)
|
||||
return -1;
|
||||
if(thisPart > thatPart)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) return true;
|
||||
if (that == null) return false;
|
||||
if (this.getClass() != that.getClass()) return false;
|
||||
return this.compareTo((UpdateManager.Version) that) == 0;
|
||||
}
|
||||
}
|
||||
}
|
71
src/main/lombok/nl/SBDeveloper/V10Lift/sbutils/YamlFile.java
Normal file
71
src/main/lombok/nl/SBDeveloper/V10Lift/sbutils/YamlFile.java
Normal file
|
@ -0,0 +1,71 @@
|
|||
package nl.SBDeveloper.V10Lift.sbutils;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
public class YamlFile {
|
||||
//SBYamlFile file = new SBYamlFile(this, "data");
|
||||
|
||||
private FileConfiguration fileConfiguration;
|
||||
private File file;
|
||||
private String name;
|
||||
|
||||
public YamlFile(String name) {
|
||||
this.name = name;
|
||||
|
||||
if (!V10LiftPlugin.getInstance().getDataFolder().exists()) {
|
||||
if (!V10LiftPlugin.getInstance().getDataFolder().mkdir()) {
|
||||
Bukkit.getLogger().severe("[ActionFoto] Couldn't generate the pluginfolder!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.file = new File(V10LiftPlugin.getInstance().getDataFolder(), name + ".yml");
|
||||
if (!this.file.exists()) {
|
||||
try {
|
||||
if (!this.file.createNewFile()) {
|
||||
Bukkit.getLogger().severe("[ActionFoto] Couldn't generate the " + name + ".yml!");
|
||||
return;
|
||||
}
|
||||
Bukkit.getLogger().info("[ActionFoto] Generating the " + name + ".yml!");
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().severe("[ActionFoto] Couldn't generate the " + name + ".yml!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.fileConfiguration = YamlConfiguration.loadConfiguration(this.file);
|
||||
}
|
||||
|
||||
public void loadDefaults() {
|
||||
Reader defConfigStream1 = new InputStreamReader(Objects.requireNonNull(V10LiftPlugin.getInstance().getResource(name + ".yml"), "Resource is null"), StandardCharsets.UTF_8);
|
||||
YamlConfiguration defConfig1 = YamlConfiguration.loadConfiguration(defConfigStream1);
|
||||
getFile().setDefaults(defConfig1);
|
||||
getFile().options().copyDefaults(true);
|
||||
saveFile();
|
||||
}
|
||||
|
||||
public FileConfiguration getFile() {
|
||||
return this.fileConfiguration;
|
||||
}
|
||||
|
||||
public void saveFile() {
|
||||
try {
|
||||
this.fileConfiguration.save(this.file);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().severe("[ActionFoto] Couldn't save the " + name + ".yml!");
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
this.fileConfiguration = YamlConfiguration.loadConfiguration(this.file);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.Utils;
|
||||
package nl.SBDeveloper.V10Lift.utils;
|
||||
|
||||
import nl.SBDeveloper.V10Lift.V10LiftPlugin;
|
||||
import org.bukkit.ChatColor;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.Utils;
|
||||
package nl.SBDeveloper.V10Lift.utils;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
|
@ -1,4 +1,4 @@
|
|||
package nl.SBDeveloper.V10Lift.Utils;
|
||||
package nl.SBDeveloper.V10Lift.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -16,9 +16,9 @@ public class DoorUtil {
|
|||
* @return true if opened, false if not opened
|
||||
*/
|
||||
public static boolean openDoor(@Nonnull Block b) {
|
||||
if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_OPEN.playSound(b.getLocation());
|
||||
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_OPEN.playSound(b.getLocation());
|
||||
if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_OPEN.playSound(b.getLocation());
|
||||
if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_OPEN.play(b.getLocation());
|
||||
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_OPEN.play(b.getLocation());
|
||||
if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_OPEN.play(b.getLocation());
|
||||
if (XMaterial.isNewVersion()) {
|
||||
//1.13+
|
||||
org.bukkit.block.data.BlockData blockData = b.getBlockData();
|
||||
|
@ -54,9 +54,9 @@ public class DoorUtil {
|
|||
* @return true if opened, false if not opened
|
||||
*/
|
||||
public static boolean closeDoor(@Nonnull Block b) {
|
||||
if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_CLOSE.playSound(b.getLocation());
|
||||
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_CLOSE.playSound(b.getLocation());
|
||||
if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_CLOSE.playSound(b.getLocation());
|
||||
if (b.getType() == XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_IRON_DOOR_CLOSE.play(b.getLocation());
|
||||
if (b.getType().toString().contains("DOOR") && b.getType() != XMaterial.IRON_DOOR.parseMaterial()) XSound.BLOCK_WOODEN_DOOR_CLOSE.play(b.getLocation());
|
||||
if (b.getType().toString().contains("GATE")) XSound.BLOCK_FENCE_GATE_CLOSE.play(b.getLocation());
|
||||
if (XMaterial.isNewVersion()) {
|
||||
//1.13+
|
||||
org.bukkit.block.data.BlockData blockData = b.getBlockData();
|
|
@ -20,7 +20,7 @@
|
|||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.Utils;
|
||||
package nl.SBDeveloper.V10Lift.utils;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.cache.Cache;
|
||||
|
@ -43,7 +43,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
/**
|
||||
* <b>XMaterial</b> - Data Values/Pre-flattening<br>
|
||||
* Supports 1.8-1.15<br>
|
||||
* 1.13 and above as priority.
|
||||
* <p>
|
||||
* This class is mainly designed to support ItemStacks.
|
||||
|
@ -58,14 +57,14 @@ import java.util.regex.Pattern;
|
|||
* XMaterial v1: https://www.spigotmc.org/threads/329630/
|
||||
*
|
||||
* @author Crypto Morin
|
||||
* @version 4.0.0
|
||||
* @version 5.0.1
|
||||
* @see Material
|
||||
* @see ItemStack
|
||||
*/
|
||||
public enum XMaterial {
|
||||
ACACIA_BOAT("BOAT_ACACIA"),
|
||||
ACACIA_BUTTON("WOOD_BUTTON"),
|
||||
ACACIA_DOOR("ACACIA_DOOR_ITEM"),
|
||||
ACACIA_DOOR("ACACIA_DOOR_ITEM", "ACACIA_DOOR"),
|
||||
ACACIA_FENCE,
|
||||
ACACIA_FENCE_GATE,
|
||||
ACACIA_LEAVES("LEAVES_2"),
|
||||
|
@ -89,6 +88,7 @@ public enum XMaterial {
|
|||
*/
|
||||
AIR,
|
||||
ALLIUM(2, "RED_ROSE"),
|
||||
ANCIENT_DEBRIS("1.16"),
|
||||
ANDESITE(5, "STONE"),
|
||||
ANDESITE_SLAB,
|
||||
ANDESITE_STAIRS,
|
||||
|
@ -105,6 +105,7 @@ public enum XMaterial {
|
|||
BAMBOO_SAPLING("1.14"),
|
||||
BARREL("1.14", "CHEST", ""),
|
||||
BARRIER,
|
||||
BASALT("1.16"),
|
||||
BAT_SPAWN_EGG(65, "MONSTER_EGG"),
|
||||
BEACON,
|
||||
BEDROCK,
|
||||
|
@ -123,7 +124,7 @@ public enum XMaterial {
|
|||
BELL("1.14"),
|
||||
BIRCH_BOAT("BOAT_BIRCH"),
|
||||
BIRCH_BUTTON("WOOD_BUTTON"),
|
||||
BIRCH_DOOR("BIRCH_DOOR_ITEM"),
|
||||
BIRCH_DOOR("BIRCH_DOOR_ITEM", "BIRCH_DOOR"),
|
||||
BIRCH_FENCE,
|
||||
BIRCH_FENCE_GATE,
|
||||
BIRCH_LEAVES(2, "LEAVES"),
|
||||
|
@ -137,8 +138,12 @@ public enum XMaterial {
|
|||
BIRCH_TRAPDOOR("TRAP_DOOR"),
|
||||
BIRCH_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||
BIRCH_WOOD(2, "LOG"),
|
||||
BLACKSTONE("1.16"),
|
||||
BLACKSTONE_SLAB("1.16"),
|
||||
BLACKSTONE_STAIRS("1.16"),
|
||||
BLACKSTONE_WALL("1.16"),
|
||||
BLACK_BANNER("BANNER", "STANDING_BANNER"),
|
||||
BLACK_BED(15, "BED", "BED_BLOCK"),
|
||||
BLACK_BED(15, "BED_BLOCK", "BED"),
|
||||
BLACK_CARPET(15, "CARPET"),
|
||||
BLACK_CONCRETE(15, "CONCRETE"),
|
||||
BLACK_CONCRETE_POWDER(15, "CONCRETE_POWDER"),
|
||||
|
@ -154,8 +159,8 @@ public enum XMaterial {
|
|||
BLAZE_POWDER,
|
||||
BLAZE_ROD,
|
||||
BLAZE_SPAWN_EGG(61, "MONSTER_EGG"),
|
||||
BLUE_BANNER(11, "BANNER", "STANDING_BANNER"),
|
||||
BLUE_BED(4, "BED", "BED_BLOCK"),
|
||||
BLUE_BANNER(4, "BANNER", "STANDING_BANNER"),
|
||||
BLUE_BED(11, "BED_BLOCK", "BED"),
|
||||
BLUE_CARPET(11, "CARPET"),
|
||||
BLUE_CONCRETE(11, "CONCRETE"),
|
||||
BLUE_CONCRETE_POWDER(11, "CONCRETE_POWDER"),
|
||||
|
@ -166,8 +171,8 @@ public enum XMaterial {
|
|||
BLUE_SHULKER_BOX,
|
||||
BLUE_STAINED_GLASS(11, "STAINED_GLASS"),
|
||||
BLUE_STAINED_GLASS_PANE(11, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||
BLUE_TERRACOTTA(11, "STAINED_CLAY"),
|
||||
BLUE_WALL_BANNER(11, "WALL_BANNER"),
|
||||
BLUE_TERRACOTTA(11, "HARD_CLAY", "STAINED_CLAY"),
|
||||
BLUE_WALL_BANNER(4, "WALL_BANNER"),
|
||||
BLUE_WOOL(11, "WOOL"),
|
||||
BONE,
|
||||
BONE_BLOCK,
|
||||
|
@ -188,7 +193,7 @@ public enum XMaterial {
|
|||
BRICK_STAIRS,
|
||||
BRICK_WALL,
|
||||
BROWN_BANNER(3, "BANNER", "STANDING_BANNER"),
|
||||
BROWN_BED(12, "BED", "BED_BLOCK"),
|
||||
BROWN_BED(12, "BED_BLOCK", "BED"),
|
||||
BROWN_CARPET(12, "CARPET"),
|
||||
BROWN_CONCRETE(12, "CONCRETE"),
|
||||
BROWN_CONCRETE_POWDER(12, "CONCRETE_POWDER"),
|
||||
|
@ -225,6 +230,7 @@ public enum XMaterial {
|
|||
*/
|
||||
CAVE_AIR("AIR"),
|
||||
CAVE_SPIDER_SPAWN_EGG(59, "MONSTER_EGG"),
|
||||
CHAIN("1.16"),
|
||||
CHAINMAIL_BOOTS,
|
||||
CHAINMAIL_CHESTPLATE,
|
||||
CHAINMAIL_HELMET,
|
||||
|
@ -236,6 +242,8 @@ public enum XMaterial {
|
|||
CHICKEN("RAW_CHICKEN"),
|
||||
CHICKEN_SPAWN_EGG(93, "MONSTER_EGG"),
|
||||
CHIPPED_ANVIL(1, "ANVIL"),
|
||||
CHISELED_NETHER_BRICKS(1, "NETHER_BRICKS"),
|
||||
CHISELED_POLISHED_BLACKSTONE("1.16", "POLISHED_BLACKSTONE"),
|
||||
CHISELED_QUARTZ_BLOCK(1, "QUARTZ_BLOCK"),
|
||||
CHISELED_RED_SANDSTONE(1, "RED_SANDSTONE"),
|
||||
CHISELED_SANDSTONE(1, "SANDSTONE"),
|
||||
|
@ -262,7 +270,14 @@ public enum XMaterial {
|
|||
COD_SPAWN_EGG("1.13", "MONSTER_EGG", ""),
|
||||
COMMAND_BLOCK("COMMAND"),
|
||||
COMMAND_BLOCK_MINECART("COMMAND_MINECART"),
|
||||
COMPARATOR("REDSTONE_COMPARATOR", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR_OFF"),
|
||||
/**
|
||||
* Unlike redstone torch and redstone lamp... neither REDTONE_COMPARATOR_OFF nor REDSTONE_COMPARATOR_ON
|
||||
* are items. REDSTONE_COMPARATOR is.
|
||||
*
|
||||
* @see #REDSTONE_TORCH
|
||||
* @see #REDSTONE_LAMP
|
||||
*/
|
||||
COMPARATOR("REDSTONE_COMPARATOR_OFF", "REDSTONE_COMPARATOR_ON", "REDSTONE_COMPARATOR"),
|
||||
COMPASS,
|
||||
COMPOSTER("1.14", "CAULDRON", ""),
|
||||
CONDUIT("1.13", "BEACON"),
|
||||
|
@ -276,19 +291,38 @@ public enum XMaterial {
|
|||
COOKIE,
|
||||
CORNFLOWER(4, "1.14", "BLUE_DYE", ""),
|
||||
COW_SPAWN_EGG(92, "MONSTER_EGG"),
|
||||
CRACKED_NETHER_BRICKS(2, "NETHER_BRICKS"),
|
||||
CRACKED_POLISHED_BLACKSTONE_BRICKS("1.16", "POLISHED_BLACKSTONE_BRICKS"),
|
||||
CRACKED_STONE_BRICKS(2, "SMOOTH_BRICK"),
|
||||
CRAFTING_TABLE("WORKBENCH"),
|
||||
CREEPER_BANNER_PATTERN,
|
||||
CREEPER_HEAD(4, "SKULL", "SKULL_ITEM"),
|
||||
CREEPER_SPAWN_EGG(50, "MONSTER_EGG"),
|
||||
CREEPER_WALL_HEAD(4, "SKULL", "SKULL_ITEM"),
|
||||
CRIMSON_BUTTON("1.16"),
|
||||
CRIMSON_DOOR("1.16"),
|
||||
CRIMSON_FENCE("1.16"),
|
||||
CRIMSON_FENCE_GATE("1.16"),
|
||||
CRIMSON_FUNGUS("1.16"),
|
||||
CRIMSON_HYPHAE("1.16"),
|
||||
CRIMSON_NYLIUM("1.16"),
|
||||
CRIMSON_PLANKS("1.16"),
|
||||
CRIMSON_PRESSURE_PLATE("1.16"),
|
||||
CRIMSON_ROOTS("1.16"),
|
||||
CRIMSON_SIGN("1.16"),
|
||||
CRIMSON_SLAB("1.16"),
|
||||
CRIMSON_STAIRS("1.16"),
|
||||
CRIMSON_STEM("1.16"),
|
||||
CRIMSON_TRAPDOOR("1.16"),
|
||||
CRIMSON_WALL_SIGN("1.16"),
|
||||
CROSSBOW,
|
||||
CRYING_OBSIDIAN("1.16"),
|
||||
CUT_RED_SANDSTONE("1.13"),
|
||||
CUT_RED_SANDSTONE_SLAB("STONE_SLAB2"),
|
||||
CUT_SANDSTONE("1.13"),
|
||||
CUT_SANDSTONE_SLAB("STEP"),
|
||||
CYAN_BANNER(6, "BANNER", "STANDING_BANNER"),
|
||||
CYAN_BED(9, "BED", "BED_BLOCK"),
|
||||
CYAN_BED(9, "BED_BLOCK", "BED"),
|
||||
CYAN_CARPET(9, "CARPET"),
|
||||
CYAN_CONCRETE(9, "CONCRETE"),
|
||||
CYAN_CONCRETE_POWDER(9, "CONCRETE_POWDER"),
|
||||
|
@ -304,16 +338,16 @@ public enum XMaterial {
|
|||
DANDELION("YELLOW_FLOWER"),
|
||||
DARK_OAK_BOAT("BOAT_DARK_OAK"),
|
||||
DARK_OAK_BUTTON("WOOD_BUTTON"),
|
||||
DARK_OAK_DOOR("DARK_OAK_DOOR_ITEM"),
|
||||
DARK_OAK_DOOR("DARK_OAK_DOOR_ITEM", "DARK_OAK_DOOR"),
|
||||
DARK_OAK_FENCE,
|
||||
DARK_OAK_FENCE_GATE,
|
||||
DARK_OAK_LEAVES(1, "LEAVES", "LEAVES_2"),
|
||||
DARK_OAK_LEAVES(4, "LEAVES", "LEAVES_2"),
|
||||
DARK_OAK_LOG(1, "LOG", "LOG_2"),
|
||||
DARK_OAK_PLANKS(5, "WOOD"),
|
||||
DARK_OAK_PRESSURE_PLATE("WOOD_PLATE"),
|
||||
DARK_OAK_SAPLING(5, "SAPLING"),
|
||||
DARK_OAK_SIGN("SIGN"),
|
||||
DARK_OAK_SLAB("WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||
DARK_OAK_SLAB(5, "WOOD_STEP", "WOODEN_SLAB", "WOOD_DOUBLE_STEP"),
|
||||
DARK_OAK_STAIRS,
|
||||
DARK_OAK_TRAPDOOR("TRAP_DOOR"),
|
||||
DARK_OAK_WALL_SIGN("SIGN_POST", "WALL_SIGN"),
|
||||
|
@ -395,7 +429,7 @@ public enum XMaterial {
|
|||
END_ROD("1.9", "BLAZE_ROD", ""),
|
||||
END_STONE("ENDER_STONE"),
|
||||
END_STONE_BRICKS("END_BRICKS"),
|
||||
END_STONE_BRICK_SLAB(4, "STEP"),
|
||||
END_STONE_BRICK_SLAB(6, "STEP"),
|
||||
END_STONE_BRICK_STAIRS("SMOOTH_STAIRS"),
|
||||
END_STONE_BRICK_WALL,
|
||||
EVOKER_SPAWN_EGG(34, "MONSTER_EGG"),
|
||||
|
@ -403,7 +437,12 @@ public enum XMaterial {
|
|||
FARMLAND("SOIL"),
|
||||
FEATHER,
|
||||
FERMENTED_SPIDER_EYE,
|
||||
FERN(2, "LONG_GRASS"),
|
||||
FERN(1, "LONG_GRASS"),
|
||||
/**
|
||||
* For some reasons filled map items are really special.
|
||||
* Their data value starts from 0 and every time a player
|
||||
* creates a new map that maps data value increases.
|
||||
*/
|
||||
FILLED_MAP("MAP"),
|
||||
FIRE,
|
||||
FIREWORK_ROCKET("FIREWORK"),
|
||||
|
@ -460,7 +499,7 @@ public enum XMaterial {
|
|||
GRASS_PATH,
|
||||
GRAVEL,
|
||||
GRAY_BANNER(8, "BANNER", "STANDING_BANNER"),
|
||||
GRAY_BED(7, "BED", "BED_BLOCK"),
|
||||
GRAY_BED(7, "BED_BLOCK", "BED"),
|
||||
GRAY_CARPET(7, "CARPET"),
|
||||
GRAY_CONCRETE(7, "CONCRETE"),
|
||||
GRAY_CONCRETE_POWDER(7, "CONCRETE_POWDER"),
|
||||
|
@ -473,7 +512,7 @@ public enum XMaterial {
|
|||
GRAY_WALL_BANNER(8, "WALL_BANNER"),
|
||||
GRAY_WOOL(7, "WOOL"),
|
||||
GREEN_BANNER(2, "BANNER", "STANDING_BANNER"),
|
||||
GREEN_BED(13, "BED", "BED_BLOCK"),
|
||||
GREEN_BED(13, "BED_BLOCK", "BED"),
|
||||
GREEN_CARPET(13, "CARPET"),
|
||||
GREEN_CONCRETE(13, "CONCRETE"),
|
||||
GREEN_CONCRETE_POWDER(13, "CONCRETE_POWDER"),
|
||||
|
@ -491,6 +530,7 @@ public enum XMaterial {
|
|||
HAY_BLOCK,
|
||||
HEART_OF_THE_SEA("1.13"),
|
||||
HEAVY_WEIGHTED_PRESSURE_PLATE("IRON_PLATE"),
|
||||
HOGLIN_SPAWN_EGG("1.16", "MONSTER_EGG"),
|
||||
HONEYCOMB("1.15"),
|
||||
HONEYCOMB_BLOCK("1.15"),
|
||||
HONEY_BLOCK("1.15", "SLIME_BLOCK", ""),
|
||||
|
@ -534,7 +574,7 @@ public enum XMaterial {
|
|||
JUKEBOX,
|
||||
JUNGLE_BOAT("BOAT_JUNGLE"),
|
||||
JUNGLE_BUTTON("WOOD_BUTTON"),
|
||||
JUNGLE_DOOR("JUNGLE_DOOR_ITEM"),
|
||||
JUNGLE_DOOR("JUNGLE_DOOR_ITEM", "JUNGLE_DOOR"),
|
||||
JUNGLE_FENCE,
|
||||
JUNGLE_FENCE_GATE,
|
||||
JUNGLE_LEAVES(3, "LEAVES"),
|
||||
|
@ -568,8 +608,8 @@ public enum XMaterial {
|
|||
LEATHER_LEGGINGS,
|
||||
LECTERN("1.14", "BOOKSHELF", ""),
|
||||
LEVER,
|
||||
LIGHT_BLUE_BANNER(3, "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_BLUE_BED(3, "BED", "BED_BLOCK"),
|
||||
LIGHT_BLUE_BANNER(12, "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_BLUE_BED(3, "BED_BLOCK", "BED"),
|
||||
LIGHT_BLUE_CARPET(3, "CARPET"),
|
||||
LIGHT_BLUE_CONCRETE(3, "CONCRETE"),
|
||||
LIGHT_BLUE_CONCRETE_POWDER(3, "CONCRETE_POWDER"),
|
||||
|
@ -582,16 +622,16 @@ public enum XMaterial {
|
|||
LIGHT_BLUE_WALL_BANNER(12, "WALL_BANNER", "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_BLUE_WOOL(3, "WOOL"),
|
||||
LIGHT_GRAY_BANNER(7, "BANNER", "STANDING_BANNER"),
|
||||
LIGHT_GRAY_BED(8, "BED", "BED_BLOCK"),
|
||||
LIGHT_GRAY_BED(8, "BED_BLOCK", "BED"),
|
||||
LIGHT_GRAY_CARPET(8, "CARPET"),
|
||||
LIGHT_GRAY_CONCRETE(8, "CONCRETE"),
|
||||
LIGHT_GRAY_CONCRETE_POWDER(8, "CONCRETE_POWDER"),
|
||||
LIGHT_GRAY_DYE(7, "INK_SACK"),
|
||||
/**
|
||||
* Renamed to SILVER_GLAZED_TERRACOTTA in 1.13
|
||||
* Renamed to SILVER_GLAZED_TERRACOTTA in 1.12
|
||||
* Renamed to LIGHT_GRAY_GLAZED_TERRACOTTA in 1.14
|
||||
*/
|
||||
LIGHT_GRAY_GLAZED_TERRACOTTA(8, "1.12", "HARD_CLAY", "STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA"),
|
||||
LIGHT_GRAY_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY", "LIGHT_GRAY_TERRACOTTA", "SILVER_GLAZED_TERRACOTTA"),
|
||||
LIGHT_GRAY_SHULKER_BOX("SILVER_SHULKER_BOX"),
|
||||
LIGHT_GRAY_STAINED_GLASS(8, "STAINED_GLASS"),
|
||||
LIGHT_GRAY_STAINED_GLASS_PANE(8, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||
|
@ -603,7 +643,7 @@ public enum XMaterial {
|
|||
LILY_OF_THE_VALLEY(15, "1.14", "WHITE_DYE", ""),
|
||||
LILY_PAD("WATER_LILY"),
|
||||
LIME_BANNER(10, "BANNER", "STANDING_BANNER"),
|
||||
LIME_BED(5, "BED", "BED_BLOCK"),
|
||||
LIME_BED(5, "BED_BLOCK", "BED"),
|
||||
LIME_CARPET(5, "CARPET"),
|
||||
LIME_CONCRETE(5, "CONCRETE"),
|
||||
LIME_CONCRETE_POWDER(5, "CONCRETE_POWDER"),
|
||||
|
@ -617,9 +657,10 @@ public enum XMaterial {
|
|||
LIME_WOOL(5, "WOOL"),
|
||||
LINGERING_POTION,
|
||||
LLAMA_SPAWN_EGG(103, "MONSTER_EGG"),
|
||||
LODESTONE("1.16"),
|
||||
LOOM("1.14"),
|
||||
MAGENTA_BANNER(13, "BANNER", "STANDING_BANNER"),
|
||||
MAGENTA_BED(2, "BED", "BED_BLOCK"),
|
||||
MAGENTA_BED(2, "BED_BLOCK", "BED"),
|
||||
MAGENTA_CARPET(2, "CARPET"),
|
||||
MAGENTA_CONCRETE(2, "CONCRETE"),
|
||||
MAGENTA_CONCRETE_POWDER(2, "CONCRETE_POWDER"),
|
||||
|
@ -634,6 +675,13 @@ public enum XMaterial {
|
|||
MAGMA_BLOCK("1.10", "MAGMA"),
|
||||
MAGMA_CREAM,
|
||||
MAGMA_CUBE_SPAWN_EGG(62, "MONSTER_EGG"),
|
||||
/**
|
||||
* Adding this to the duplicated list will give you a filled map
|
||||
* for 1.13+ versions and removing it from duplicated list will
|
||||
* still give you a filled map in -1.12 versions.
|
||||
* Since higher versions are our priority I'll keep 1.13+ support
|
||||
* until I can come up with something to fix it.
|
||||
*/
|
||||
MAP("EMPTY_MAP"),
|
||||
MELON("MELON_BLOCK"),
|
||||
MELON_SEEDS,
|
||||
|
@ -648,7 +696,7 @@ public enum XMaterial {
|
|||
MOSSY_COBBLESTONE_STAIRS,
|
||||
MOSSY_COBBLESTONE_WALL(1, "COBBLE_WALL", "COBBLESTONE_WALL"),
|
||||
MOSSY_STONE_BRICKS(1, "SMOOTH_BRICK"),
|
||||
MOSSY_STONE_BRICK_SLAB(4, "STEP"),
|
||||
MOSSY_STONE_BRICK_SLAB(5, "STEP"),
|
||||
MOSSY_STONE_BRICK_STAIRS("SMOOTH_STAIRS"),
|
||||
MOSSY_STONE_BRICK_WALL,
|
||||
MOVING_PISTON("PISTON_BASE", "PISTON_MOVING_PIECE"),
|
||||
|
@ -671,15 +719,29 @@ public enum XMaterial {
|
|||
MYCELIUM("MYCEL"),
|
||||
NAME_TAG,
|
||||
NAUTILUS_SHELL("1.13"),
|
||||
NETHERITE_AXE("1.16"),
|
||||
NETHERITE_BLOCK("1.16"),
|
||||
NETHERITE_BOOTS("1.16"),
|
||||
NETHERITE_CHESTPLATE("1.16"),
|
||||
NETHERITE_HELMET("1.16"),
|
||||
NETHERITE_HOE("1.16"),
|
||||
NETHERITE_INGOT("1.16"),
|
||||
NETHERITE_LEGGINGS("1.16"),
|
||||
NETHERITE_PICKAXE("1.16"),
|
||||
NETHERITE_SCRAP("1.16"),
|
||||
NETHERITE_SHOVEL("1.16"),
|
||||
NETHERITE_SWORD("1.16"),
|
||||
NETHERRACK,
|
||||
NETHER_BRICK("NETHER_BRICK_ITEM"),
|
||||
NETHER_BRICKS("NETHER_BRICK"),
|
||||
NETHER_BRICK_FENCE("NETHER_FENCE"),
|
||||
NETHER_BRICK_SLAB(4, "STEP"),
|
||||
NETHER_BRICK_SLAB(6, "STEP"),
|
||||
NETHER_BRICK_STAIRS,
|
||||
NETHER_BRICK_WALL,
|
||||
NETHER_GOLD_ORE("1.16"),
|
||||
NETHER_PORTAL("PORTAL"),
|
||||
NETHER_QUARTZ_ORE("QUARTZ_ORE"),
|
||||
NETHER_SPROUTS("1.16"),
|
||||
NETHER_STAR,
|
||||
/**
|
||||
* Just like mentioned in https://minecraft.gamepedia.com/Nether_Wart
|
||||
|
@ -709,7 +771,7 @@ public enum XMaterial {
|
|||
OBSIDIAN,
|
||||
OCELOT_SPAWN_EGG(98, "MONSTER_EGG"),
|
||||
ORANGE_BANNER(14, "BANNER", "STANDING_BANNER"),
|
||||
ORANGE_BED(1, "BED", "BED_BLOCK"),
|
||||
ORANGE_BED(1, "BED_BLOCK", "BED"),
|
||||
ORANGE_CARPET(1, "CARPET"),
|
||||
ORANGE_CONCRETE(1, "CONCRETE"),
|
||||
ORANGE_CONCRETE_POWDER(1, "CONCRETE_POWDER"),
|
||||
|
@ -735,7 +797,7 @@ public enum XMaterial {
|
|||
PIG_SPAWN_EGG(90, "MONSTER_EGG"),
|
||||
PILLAGER_SPAWN_EGG("1.14"),
|
||||
PINK_BANNER(9, "BANNER", "STANDING_BANNER"),
|
||||
PINK_BED(6, "BED", "BED_BLOCK"),
|
||||
PINK_BED(6, "BED_BLOCK", "BED"),
|
||||
PINK_CARPET(6, "CARPET"),
|
||||
PINK_CONCRETE(6, "CONCRETE"),
|
||||
PINK_CONCRETE_POWDER(6, "CONCRETE_POWDER"),
|
||||
|
@ -746,7 +808,7 @@ public enum XMaterial {
|
|||
PINK_STAINED_GLASS_PANE(6, "THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||
PINK_TERRACOTTA(6, "HARD_CLAY", "STAINED_CLAY"),
|
||||
PINK_TULIP(7, "RED_ROSE"),
|
||||
PINK_WALL_BANNER(14, "WALL_BANNER"),
|
||||
PINK_WALL_BANNER(9, "WALL_BANNER"),
|
||||
PINK_WOOL(6, "WOOL"),
|
||||
PISTON("PISTON_BASE"),
|
||||
PISTON_HEAD("PISTON_EXTENSION"),
|
||||
|
@ -758,6 +820,17 @@ public enum XMaterial {
|
|||
POLISHED_ANDESITE(6, "STONE"),
|
||||
POLISHED_ANDESITE_SLAB,
|
||||
POLISHED_ANDESITE_STAIRS,
|
||||
POLISHED_BASALT("1.16"),
|
||||
POLISHED_BLACKSTONE("1.16"),
|
||||
POLISHED_BLACKSTONE_BRICKS("1.16"),
|
||||
POLISHED_BLACKSTONE_BRICK_SLAB("1.16"),
|
||||
POLISHED_BLACKSTONE_BRICK_STAIRS("1.16"),
|
||||
POLISHED_BLACKSTONE_BRICK_WALL("1.16"),
|
||||
POLISHED_BLACKSTONE_BUTTON("1.16"),
|
||||
POLISHED_BLACKSTONE_PRESSURE_PLATE("1.16"),
|
||||
POLISHED_BLACKSTONE_SLAB("1.16"),
|
||||
POLISHED_BLACKSTONE_STAIRS("1.16"),
|
||||
POLISHED_BLACKSTONE_WALL("1.16"),
|
||||
POLISHED_DIORITE(4, "STONE"),
|
||||
POLISHED_DIORITE_SLAB,
|
||||
POLISHED_DIORITE_STAIRS,
|
||||
|
@ -813,7 +886,7 @@ public enum XMaterial {
|
|||
PUMPKIN_SEEDS,
|
||||
PUMPKIN_STEM,
|
||||
PURPLE_BANNER(5, "BANNER", "STANDING_BANNER"),
|
||||
PURPLE_BED(10, "BED", "BED_BLOCK"),
|
||||
PURPLE_BED(10, "BED_BLOCK", "BED"),
|
||||
PURPLE_CARPET(10, "CARPET"),
|
||||
PURPLE_CONCRETE(10, "CONCRETE"),
|
||||
PURPLE_CONCRETE_POWDER(10, "CONCRETE_POWDER"),
|
||||
|
@ -843,17 +916,34 @@ public enum XMaterial {
|
|||
RAVAGER_SPAWN_EGG("1.14"),
|
||||
REDSTONE,
|
||||
REDSTONE_BLOCK,
|
||||
REDSTONE_LAMP("REDSTONE_LAMP_OFF", "REDSTONE_LAMP_ON"),
|
||||
/**
|
||||
* Unlike redstone torch, REDSTONE_LAMP_ON isn't an item.
|
||||
* The name is just here on the list for matching.
|
||||
*
|
||||
* @see #REDSTONE_TORCH
|
||||
*/
|
||||
REDSTONE_LAMP("REDSTONE_LAMP_ON", "REDSTONE_LAMP_OFF"),
|
||||
REDSTONE_ORE("GLOWING_REDSTONE_ORE"),
|
||||
REDSTONE_TORCH("REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"),
|
||||
REDSTONE_WALL_TORCH(1, "REDSTONE_TORCH_ON", "REDSTONE_TORCH_OFF"),
|
||||
/**
|
||||
* REDSTONE_TORCH_OFF isn't an item, but a block.
|
||||
* But REDSTONE_TORCH_ON is the item.
|
||||
* The name is just here on the list for matching.
|
||||
*/
|
||||
REDSTONE_TORCH("REDSTONE_TORCH_OFF", "REDSTONE_TORCH_ON"),
|
||||
REDSTONE_WALL_TORCH,
|
||||
REDSTONE_WIRE,
|
||||
RED_BANNER(1, "BANNER", "STANDING_BANNER"),
|
||||
RED_BED(14, "BED", "BED_BLOCK"),
|
||||
/**
|
||||
* Data value 14 or 0
|
||||
*/
|
||||
RED_BED(0, "BED_BLOCK", "BED"),
|
||||
RED_CARPET(14, "CARPET"),
|
||||
RED_CONCRETE(14, "CONCRETE"),
|
||||
RED_CONCRETE_POWDER(14, "CONCRETE_POWDER"),
|
||||
RED_DYE(1, "ROSE_RED"),
|
||||
/**
|
||||
* Data value 0 or 1?
|
||||
*/
|
||||
RED_DYE(0, "INK_SACK", "ROSE_RED"),
|
||||
RED_GLAZED_TERRACOTTA(14, "1.12", "HARD_CLAY", "STAINED_CLAY", "RED_TERRACOTTA"),
|
||||
RED_MUSHROOM,
|
||||
RED_MUSHROOM_BLOCK("RED_MUSHROOM", "HUGE_MUSHROOM_2"),
|
||||
|
@ -875,6 +965,7 @@ public enum XMaterial {
|
|||
RED_WOOL(14, "WOOL"),
|
||||
REPEATER("DIODE", "DIODE_BLOCK_ON", "DIODE_BLOCK_OFF"),
|
||||
REPEATING_COMMAND_BLOCK("COMMAND", "COMMAND_REPEATING"),
|
||||
RESPAWN_ANCHOR("1.16"),
|
||||
ROSE_BUSH(4, "DOUBLE_PLANT"),
|
||||
ROTTEN_FLESH,
|
||||
SADDLE,
|
||||
|
@ -894,6 +985,7 @@ public enum XMaterial {
|
|||
SHEARS,
|
||||
SHEEP_SPAWN_EGG(91, "MONSTER_EGG"),
|
||||
SHIELD,
|
||||
SHROOMLIGHT("1.16"),
|
||||
SHULKER_BOX("PURPLE_SHULKER_BOX"),
|
||||
SHULKER_SHELL,
|
||||
SHULKER_SPAWN_EGG(69, "MONSTER_EGG"),
|
||||
|
@ -922,7 +1014,13 @@ public enum XMaterial {
|
|||
SNOW,
|
||||
SNOWBALL("SNOW_BALL"),
|
||||
SNOW_BLOCK,
|
||||
SOUL_CAMPFIRE("1.16"),
|
||||
SOUL_FIRE("1.16"),
|
||||
SOUL_LANTERN("1.16"),
|
||||
SOUL_SAND,
|
||||
SOUL_SOIL("1.16"),
|
||||
SOUL_TORCH("1.16"),
|
||||
SOUL_WALL_TORCH("1.16"),
|
||||
SPAWNER("MOB_SPAWNER"),
|
||||
SPECTRAL_ARROW("1.9", "ARROW", ""),
|
||||
SPIDER_EYE,
|
||||
|
@ -931,7 +1029,7 @@ public enum XMaterial {
|
|||
SPONGE,
|
||||
SPRUCE_BOAT("BOAT_SPRUCE"),
|
||||
SPRUCE_BUTTON("WOOD_BUTTON"),
|
||||
SPRUCE_DOOR("SPRUCE_DOOR_ITEM"),
|
||||
SPRUCE_DOOR("SPRUCE_DOOR_ITEM", "SPRUCE_DOOR"),
|
||||
SPRUCE_FENCE,
|
||||
SPRUCE_FENCE_GATE,
|
||||
SPRUCE_LEAVES(1, "LEAVES"),
|
||||
|
@ -969,6 +1067,8 @@ public enum XMaterial {
|
|||
STRIPPED_ACACIA_WOOD("LOG_2"),
|
||||
STRIPPED_BIRCH_LOG(2, "LOG"),
|
||||
STRIPPED_BIRCH_WOOD(2, "LOG"),
|
||||
STRIPPED_CRIMSON_HYPHAE("1.16"),
|
||||
STRIPPED_CRIMSON_STEM("1.16"),
|
||||
STRIPPED_DARK_OAK_LOG("LOG"),
|
||||
STRIPPED_DARK_OAK_WOOD("LOG"),
|
||||
STRIPPED_JUNGLE_LOG(3, "LOG"),
|
||||
|
@ -977,6 +1077,8 @@ public enum XMaterial {
|
|||
STRIPPED_OAK_WOOD("LOG"),
|
||||
STRIPPED_SPRUCE_LOG(1, "LOG"),
|
||||
STRIPPED_SPRUCE_WOOD(1, "LOG"),
|
||||
STRIPPED_WARPED_HYPHAE("1.16"),
|
||||
STRIPPED_WARPED_STEM("1.16"),
|
||||
STRUCTURE_BLOCK,
|
||||
/**
|
||||
* Originally developers used barrier blocks for its purpose.
|
||||
|
@ -995,6 +1097,7 @@ public enum XMaterial {
|
|||
SWEET_BERRY_BUSH("1.14", "GRASS", ""),
|
||||
TALL_GRASS(2, "DOUBLE_PLANT"),
|
||||
TALL_SEAGRASS(2, "1.13", "TALL_GRASS", ""),
|
||||
TARGET("1.16"),
|
||||
TERRACOTTA("HARD_CLAY"),
|
||||
TIPPED_ARROW("1.9", "ARROW", ""),
|
||||
TNT,
|
||||
|
@ -1016,6 +1119,8 @@ public enum XMaterial {
|
|||
TURTLE_EGG("1.13", "EGG", ""),
|
||||
TURTLE_HELMET("1.13", "IRON_HELMET", ""),
|
||||
TURTLE_SPAWN_EGG("1.13", "CHICKEN_SPAWN_EGG", ""),
|
||||
TWISTING_VINES("1.16"),
|
||||
TWISTING_VINES_PLANT("1.16"),
|
||||
VEX_SPAWN_EGG(35, "MONSTER_EGG"),
|
||||
VILLAGER_SPAWN_EGG(120, "MONSTER_EGG"),
|
||||
VINDICATOR_SPAWN_EGG(36, "MONSTER_EGG"),
|
||||
|
@ -1028,6 +1133,24 @@ public enum XMaterial {
|
|||
VOID_AIR("AIR"),
|
||||
WALL_TORCH("TORCH"),
|
||||
WANDERING_TRADER_SPAWN_EGG("1.14", "VILLAGER_SPAWN_EGG", ""),
|
||||
WARPED_BUTTON("1.16"),
|
||||
WARPED_DOOR("1.16"),
|
||||
WARPED_FENCE("1.16"),
|
||||
WARPED_FENCE_GATE("1.16"),
|
||||
WARPED_FUNGUS("1.16"),
|
||||
WARPED_FUNGUS_ON_A_STICK("1.16"),
|
||||
WARPED_HYPHAE("1.16"),
|
||||
WARPED_NYLIUM("1.16"),
|
||||
WARPED_PLANKS("1.16"),
|
||||
WARPED_PRESSURE_PLATE("1.16"),
|
||||
WARPED_ROOTS("1.16"),
|
||||
WARPED_SIGN("1.16"),
|
||||
WARPED_SLAB("1.16"),
|
||||
WARPED_STAIRS("1.16"),
|
||||
WARPED_STEM("1.16"),
|
||||
WARPED_TRAPDOOR("1.16"),
|
||||
WARPED_WALL_SIGN("1.16"),
|
||||
WARPED_WART_BLOCK("1.16"),
|
||||
/**
|
||||
* This is used for blocks only.
|
||||
* In 1.13- WATER will turn into STATIONARY_WATER after it finished spreading.
|
||||
|
@ -1037,6 +1160,8 @@ public enum XMaterial {
|
|||
*/
|
||||
WATER("STATIONARY_WATER"),
|
||||
WATER_BUCKET,
|
||||
WEEPING_VINES("1.16"),
|
||||
WEEPING_VINES_PLANT("1.16"),
|
||||
WET_SPONGE(1, "SPONGE"),
|
||||
/**
|
||||
* Wheat is a known material in pre-1.13
|
||||
|
@ -1045,16 +1170,16 @@ public enum XMaterial {
|
|||
WHEAT("CROPS"),
|
||||
WHEAT_SEEDS("SEEDS"),
|
||||
WHITE_BANNER(15, "BANNER", "STANDING_BANNER"),
|
||||
WHITE_BED("BED", "BED_BLOCK"),
|
||||
WHITE_BED("BED_BLOCK", "BED"),
|
||||
WHITE_CARPET("CARPET"),
|
||||
WHITE_CONCRETE("CONCRETE"),
|
||||
WHITE_CONCRETE_POWDER("CONCRETE_POWDER"),
|
||||
WHITE_DYE(15, "1.14", "INK_SACK", "BONE_MEAL"),
|
||||
WHITE_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY", "WHITE_TERRACOTTA"),
|
||||
WHITE_GLAZED_TERRACOTTA("1.12", "HARD_CLAY", "STAINED_CLAY"),
|
||||
WHITE_SHULKER_BOX,
|
||||
WHITE_STAINED_GLASS("STAINED_GLASS"),
|
||||
WHITE_STAINED_GLASS_PANE("THIN_GLASS", "STAINED_GLASS_PANE"),
|
||||
WHITE_TERRACOTTA("HARD_CLAY", "TERRACOTTA"),
|
||||
WHITE_TERRACOTTA("HARD_CLAY", "STAINED_CLAY", "TERRACOTTA"),
|
||||
WHITE_TULIP(6, "RED_ROSE"),
|
||||
WHITE_WALL_BANNER(15, "WALL_BANNER"),
|
||||
WHITE_WOOL("WOOL"),
|
||||
|
@ -1072,7 +1197,7 @@ public enum XMaterial {
|
|||
WRITABLE_BOOK("BOOK_AND_QUILL"),
|
||||
WRITTEN_BOOK,
|
||||
YELLOW_BANNER(11, "BANNER", "STANDING_BANNER"),
|
||||
YELLOW_BED(4, "BED", "BED_BLOCK"),
|
||||
YELLOW_BED(4, "BED_BLOCK", "BED"),
|
||||
YELLOW_CARPET(4, "CARPET"),
|
||||
YELLOW_CONCRETE(4, "CONCRETE"),
|
||||
YELLOW_CONCRETE_POWDER(4, "CONCRETE_POWDER"),
|
||||
|
@ -1086,10 +1211,11 @@ public enum XMaterial {
|
|||
YELLOW_WOOL(4, "WOOL"),
|
||||
ZOMBIE_HEAD(2, "SKULL", "SKULL_ITEM"),
|
||||
ZOMBIE_HORSE_SPAWN_EGG(29, "MONSTER_EGG"),
|
||||
ZOMBIE_PIGMAN_SPAWN_EGG(57, "MONSTER_EGG"),
|
||||
ZOMBIE_SPAWN_EGG(54, "MONSTER_EGG"),
|
||||
ZOMBIE_VILLAGER_SPAWN_EGG(27, "MONSTER_EGG"),
|
||||
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM");
|
||||
ZOMBIE_WALL_HEAD(2, "SKULL", "SKULL_ITEM"),
|
||||
PIGLIN_SPAWN_EGG(57, "MONSTER_EGG"),
|
||||
ZOMBIFIED_PIGLIN_SPAWN_EGG(57, "MONSTER_EGG", "ZOMBIE_PIGMAN_SPAWN_EGG");
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1125,16 +1251,27 @@ public enum XMaterial {
|
|||
* @since 3.0.0
|
||||
*/
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
private static final ImmutableMap<XMaterial, XMaterial> DUPLICATED = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
|
||||
private static final ImmutableMap<XMaterial, XMaterial> duplicated = Maps.immutableEnumMap(ImmutableMap.<XMaterial, XMaterial>builder()
|
||||
.put(MELON, MELON_SLICE)
|
||||
.put(CARROT, CARROTS)
|
||||
.put(POTATO, POTATOES)
|
||||
.put(BEETROOT, BEETROOTS)
|
||||
.put(BROWN_MUSHROOM, BROWN_MUSHROOM_BLOCK)
|
||||
.put(BRICK, BRICKS)
|
||||
.put(RED_MUSHROOM, RED_MUSHROOM_BLOCK)
|
||||
.put(MAP, FILLED_MAP)
|
||||
.put(NETHER_BRICK, NETHER_BRICKS)
|
||||
|
||||
// Illegal Elements
|
||||
// Since both 1.12 and 1.13 have <type>_DOOR XMaterial will use it
|
||||
// for 1.12 to parse the material, but it needs <type>_DOOR_ITEM.
|
||||
// We'll trick XMaterial into thinking this needs to be parsed
|
||||
// using the old methods.
|
||||
// These materials have their enum name added to the legacy list as well.
|
||||
.put(DARK_OAK_DOOR, DARK_OAK_DOOR)
|
||||
.put(ACACIA_DOOR, ACACIA_DOOR)
|
||||
.put(BIRCH_DOOR, BIRCH_DOOR)
|
||||
.put(JUNGLE_DOOR, JUNGLE_DOOR)
|
||||
.put(SPRUCE_DOOR, SPRUCE_DOOR)
|
||||
|
||||
.build()
|
||||
);
|
||||
/*
|
||||
|
@ -1276,13 +1413,14 @@ public enum XMaterial {
|
|||
@Nullable
|
||||
private static XMaterial requestOldXMaterial(@Nonnull String name, byte data) {
|
||||
String holder = name + data;
|
||||
XMaterial material = NAME_CACHE.getIfPresent(holder);
|
||||
if (material != null) return material;
|
||||
XMaterial cache = NAME_CACHE.getIfPresent(holder);
|
||||
if (cache != null) return cache;
|
||||
|
||||
for (XMaterial materials : VALUES) {
|
||||
if ((data == -1 || data == materials.data) && materials.anyMatchLegacy(name)) {
|
||||
NAME_CACHE.put(holder, materials);
|
||||
return materials;
|
||||
for (XMaterial material : VALUES) {
|
||||
// Not using material.name().equals(name) check is intended.
|
||||
if ((data == -1 || data == material.data) && material.anyMatchLegacy(name)) {
|
||||
NAME_CACHE.put(holder, material);
|
||||
return material;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1313,37 +1451,15 @@ public enum XMaterial {
|
|||
/**
|
||||
* Parses the given material name as an XMaterial with unspecified data value.
|
||||
*
|
||||
* @see #matchXMaterial(String, byte)
|
||||
* @see #matchXMaterialWithData(String)
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Nonnull
|
||||
public static Optional<XMaterial> matchXMaterial(@Nonnull String name) {
|
||||
return matchXMaterial(name, (byte) -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given material name as an XMaterial.
|
||||
* Can also be used like: <b>MATERIAL:DATA</b>
|
||||
* <p>
|
||||
* <b>Examples</b>
|
||||
* <pre>
|
||||
* {@code INK_SACK:1 -> RED_DYE}
|
||||
* {@code WOOL, 14 -> RED_WOOL}
|
||||
* </pre>
|
||||
*
|
||||
* @see #matchDefinedXMaterial(String, byte)
|
||||
* @see #matchXMaterial(ItemStack)
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Nonnull
|
||||
public static Optional<XMaterial> matchXMaterial(@Nonnull String name, byte data) {
|
||||
Validate.notEmpty(name, "Cannot match a material with null or empty material name");
|
||||
Optional<XMaterial> oldMatch = matchXMaterialWithData(name);
|
||||
if (oldMatch.isPresent()) return oldMatch;
|
||||
|
||||
// -1 Determines whether the item's data value is unknown and only the name is given.
|
||||
// Checking if the item is damageable won't do anything as the data is not going to be checked in requestOldMaterial anyway.
|
||||
return matchDefinedXMaterial(format(name), data);
|
||||
return matchDefinedXMaterial(format(name), (byte) -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1387,7 +1503,7 @@ public enum XMaterial {
|
|||
public static XMaterial matchXMaterial(@Nonnull Material material) {
|
||||
Objects.requireNonNull(material, "Cannot match null material");
|
||||
return matchDefinedXMaterial(material.name(), (byte) -1)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material));
|
||||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material With No Bytes: " + material.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1404,9 +1520,10 @@ public enum XMaterial {
|
|||
public static XMaterial matchXMaterial(@Nonnull ItemStack item) {
|
||||
Objects.requireNonNull(item, "Cannot match null ItemStack");
|
||||
String material = item.getType().name();
|
||||
return matchDefinedXMaterial(material,
|
||||
isDamageable(material) ? (byte) 0 : (byte) item.getDurability())
|
||||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material));
|
||||
byte data = (byte) (ISFLAT || isDamageable(material) ? 0 : item.getDurability());
|
||||
|
||||
return matchDefinedXMaterial(material, data)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Material: " + material + " (" + data + ')'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1416,7 +1533,6 @@ public enum XMaterial {
|
|||
* @param name the formatted name of the material.
|
||||
* @param data the data value of the material.
|
||||
* @return an XMaterial (with the same data value if specified)
|
||||
* @see #matchXMaterial(String, byte)
|
||||
* @see #matchXMaterial(Material)
|
||||
* @see #matchXMaterial(int, byte)
|
||||
* @see #matchXMaterial(ItemStack)
|
||||
|
@ -1429,7 +1545,7 @@ public enum XMaterial {
|
|||
// Do basic number and boolean checks before accessing more complex enum stuff.
|
||||
// Maybe we can simplify (ISFLAT || !duplicated) with the (!ISFLAT && duplicated) under it to save a few nanoseconds?
|
||||
// if (!Boolean.valueOf(Boolean.getBoolean(Boolean.TRUE.toString())).equals(Boolean.FALSE.booleanValue())) return null;
|
||||
if (data <= 0 && (ISFLAT || !duplicated)) {
|
||||
if (data <= 0 && !duplicated) {
|
||||
// Apparently the transform method is more efficient than toJavaUtil()
|
||||
// toJavaUtil isn't even supported in older versions.
|
||||
Optional<XMaterial> xMat = Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
|
||||
|
@ -1440,8 +1556,20 @@ public enum XMaterial {
|
|||
// I've concluded that this is just an infinite loop that keeps
|
||||
// going around the Singular Form and the Plural Form materials. A waste of brain cells and a waste of time.
|
||||
// This solution works just fine anyway.
|
||||
if (!ISFLAT && duplicated) return Optional.ofNullable(requestDuplicatedXMaterial(name, data));
|
||||
return Optional.ofNullable(requestOldXMaterial(name, data));
|
||||
XMaterial xMat = requestOldXMaterial(name, data);
|
||||
if (xMat == null) {
|
||||
// Special case. Refer to FILLED_MAP for more info.
|
||||
if (data > 0 && name.endsWith("MAP")) return Optional.of(FILLED_MAP);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
if (!ISFLAT && duplicated && xMat.name().charAt(xMat.name().length() - 1) == 'S') {
|
||||
// A solution for XMaterial Paradox.
|
||||
// Manually parses the duplicated materials to find the exact material based on the server version.
|
||||
// If ends with "S" -> Plural Form Material
|
||||
return Enums.getIfPresent(XMaterial.class, name).transform(Optional::of).or(Optional.empty());
|
||||
}
|
||||
return Optional.ofNullable(xMat);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1456,13 +1584,12 @@ public enum XMaterial {
|
|||
* @see #isDuplicated()
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public static boolean isDuplicated(@Nonnull String name) {
|
||||
Validate.notEmpty(name, "Cannot check duplication for null or empty material name");
|
||||
name = format(name);
|
||||
|
||||
private static boolean isDuplicated(@Nonnull String name) {
|
||||
// Don't use matchXMaterial() since this method is being called from matchXMaterial() itself and will cause a StackOverflowError.
|
||||
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet())
|
||||
if (duplicated.getKey().name().equals(name) || duplicated.getKey().anyMatchLegacy(name)) return true;
|
||||
for (Map.Entry<XMaterial, XMaterial> duplicated : duplicated.entrySet()) {
|
||||
XMaterial material = duplicated.getKey();
|
||||
if (material.name().equals(name) || material.anyMatchLegacy(name)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1486,60 +1613,6 @@ public enum XMaterial {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* A solution for <b>XMaterial Paradox</b>.
|
||||
* Manually parses the duplicated materials to find the exact material based on the server version.
|
||||
*
|
||||
* @param name the name of the material.
|
||||
* @return the duplicated XMaterial based on the version.
|
||||
* @throws IllegalArgumentException may be thrown. If thrown, it's a bug.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Nullable
|
||||
private static XMaterial requestDuplicatedXMaterial(@Nonnull String name, byte data) {
|
||||
XMaterial mat = requestOldXMaterial(name, data);
|
||||
// If ends with "S" -> Plural Form Material
|
||||
return mat.name().charAt(mat.name().length() - 1) == 'S' ? Enums.getIfPresent(XMaterial.class, name).orNull() : mat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns the value with the given duplicated material key name.
|
||||
*
|
||||
* @param name the name of the material.
|
||||
* @return the new XMaterial of this duplicated material.
|
||||
* @see #getXMaterialIfDuplicated(String)
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Nonnull
|
||||
public static Optional<XMaterial> getNewXMaterialIfDuplicated(@Nonnull String name) {
|
||||
Validate.notEmpty(name, "Cannot get new duplicated material for null or empty material name");
|
||||
name = format(name);
|
||||
|
||||
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet())
|
||||
if (duplicated.getKey().name().equals(name)) return Optional.of(duplicated.getKey());
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is duplicated for a different purpose in new versions from {@link #DUPLICATED}.
|
||||
*
|
||||
* @param name the name of the material.
|
||||
* @return the other XMaterial (key or value) of the XMaterial (key or value).
|
||||
* @see #matchXMaterial(String, byte)
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Nullable
|
||||
public static XMaterial getXMaterialIfDuplicated(@Nonnull String name) {
|
||||
Validate.notEmpty(name, "Cannot get duplicated material for null or empty material name");
|
||||
name = format(name);
|
||||
|
||||
for (Map.Entry<XMaterial, XMaterial> duplicated : DUPLICATED.entrySet())
|
||||
if (duplicated.getKey().name().equals(name)) return duplicated.getValue();
|
||||
else if (duplicated.getValue().name().equals(name)) return duplicated.getKey();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to build the string like an enum name.
|
||||
* Removes all the spaces, numbers and extra non-English characters. Also removes some config/in-game based strings.
|
||||
|
@ -1783,7 +1856,6 @@ public enum XMaterial {
|
|||
* @since 3.0.0
|
||||
*/
|
||||
@Override
|
||||
@Nonnull
|
||||
public String toString() {
|
||||
return toWord(this.name());
|
||||
}
|
||||
|
@ -1806,25 +1878,11 @@ public enum XMaterial {
|
|||
* Checks if the material has any duplicates.
|
||||
*
|
||||
* @return true if there is a duplicated name for this material, otherwise false.
|
||||
* @see #getXMaterialIfDuplicated()
|
||||
* @see #isDuplicated(String)
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public boolean isDuplicated() {
|
||||
return DUPLICATED.containsKey(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is duplicated for a different purpose in new versions.
|
||||
*
|
||||
* @return true if the item's name is duplicated, otherwise false.
|
||||
* @see #isDuplicated()
|
||||
* @see #getNewXMaterialIfDuplicated(String)
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Nullable
|
||||
public XMaterial getXMaterialIfDuplicated() {
|
||||
return DUPLICATED.get(this);
|
||||
return duplicated.containsKey(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1914,7 +1972,6 @@ public enum XMaterial {
|
|||
*
|
||||
* @param suggest use a suggested material (from older materials) if the material is added in a later version of Minecraft.
|
||||
* @return the material related to this XMaterial based on the server version.
|
||||
* @see #matchXMaterial(String, byte)
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@SuppressWarnings("OptionalAssignedToNull")
|
|
@ -19,7 +19,7 @@
|
|||
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.Utils;
|
||||
package nl.SBDeveloper.V10Lift.utils;
|
||||
|
||||
import com.google.common.base.Enums;
|
||||
import com.google.common.base.Strings;
|
||||
|
@ -28,10 +28,7 @@ import com.google.common.cache.CacheBuilder;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -46,7 +43,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
/**
|
||||
* <b>XSound</b> - Universal Minecraft Sound Support<br>
|
||||
* Supports 1.8-1.15<br>
|
||||
* 1.13 and above as priority.
|
||||
* <p>
|
||||
* Sounds are thread-safe. But this doesn't mean you should
|
||||
|
@ -58,10 +54,10 @@ import java.util.regex.Pattern;
|
|||
* 1.8: http://docs.codelanx.com/Bukkit/1.8/org/bukkit/Sound.html
|
||||
* Latest: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html
|
||||
* Basics: https://bukkit.org/threads/151517/
|
||||
* playSound command: https://minecraft.gamepedia.com/Commands/playsound
|
||||
* play command: https://minecraft.gamepedia.com/Commands/play
|
||||
*
|
||||
* @author Crypto Morin
|
||||
* @version 2.2.0
|
||||
* @version 3.0.0
|
||||
* @see Sound
|
||||
*/
|
||||
public enum XSound {
|
||||
|
@ -303,9 +299,176 @@ public enum XSound {
|
|||
ENTITY_BLAZE_HURT("BLAZE_HIT"),
|
||||
ENTITY_BLAZE_SHOOT,
|
||||
ENTITY_BOAT_PADDLE_LAND,
|
||||
AMBIENT_BASALT_DELTAS_ADDITIONS,
|
||||
AMBIENT_BASALT_DELTAS_LOOP,
|
||||
AMBIENT_BASALT_DELTAS_MOOD,
|
||||
AMBIENT_CRIMSON_FOREST_ADDITIONS,
|
||||
AMBIENT_CRIMSON_FOREST_LOOP,
|
||||
AMBIENT_CRIMSON_FOREST_MOOD,
|
||||
AMBIENT_NETHER_WASTES_ADDITIONS,
|
||||
AMBIENT_NETHER_WASTES_LOOP,
|
||||
AMBIENT_NETHER_WASTES_MOOD,
|
||||
AMBIENT_SOUL_SAND_VALLEY_ADDITIONS,
|
||||
AMBIENT_SOUL_SAND_VALLEY_LOOP,
|
||||
AMBIENT_SOUL_SAND_VALLEY_MOOD,
|
||||
ENTITY_BOAT_PADDLE_WATER,
|
||||
ENTITY_CAT_AMBIENT("CAT_MEOW"),
|
||||
ENTITY_CAT_BEG_FOR_FOOD,
|
||||
AMBIENT_WARPED_FOREST_ADDITIONS,
|
||||
AMBIENT_WARPED_FOREST_LOOP,
|
||||
AMBIENT_WARPED_FOREST_MOOD,
|
||||
BLOCK_ANCIENT_DEBRIS_BREAK,
|
||||
BLOCK_ANCIENT_DEBRIS_FALL,
|
||||
BLOCK_ANCIENT_DEBRIS_HIT,
|
||||
BLOCK_ANCIENT_DEBRIS_PLACE,
|
||||
BLOCK_ANCIENT_DEBRIS_STEP,
|
||||
BLOCK_BASALT_BREAK,
|
||||
BLOCK_BASALT_FALL,
|
||||
BLOCK_BASALT_HIT,
|
||||
BLOCK_BASALT_PLACE,
|
||||
BLOCK_BASALT_STEP,
|
||||
BLOCK_BONE_BLOCK_BREAK,
|
||||
BLOCK_BONE_BLOCK_FALL,
|
||||
BLOCK_BONE_BLOCK_HIT,
|
||||
BLOCK_BONE_BLOCK_PLACE,
|
||||
BLOCK_BONE_BLOCK_STEP,
|
||||
BLOCK_CHAIN_BREAK,
|
||||
BLOCK_CHAIN_FALL,
|
||||
BLOCK_CHAIN_HIT,
|
||||
BLOCK_CHAIN_PLACE,
|
||||
BLOCK_CHAIN_STEP,
|
||||
BLOCK_FUNGUS_BREAK,
|
||||
BLOCK_FUNGUS_FALL,
|
||||
BLOCK_FUNGUS_HIT,
|
||||
BLOCK_FUNGUS_PLACE,
|
||||
BLOCK_FUNGUS_STEP,
|
||||
BLOCK_LODESTONE_BREAK,
|
||||
BLOCK_LODESTONE_FALL,
|
||||
BLOCK_LODESTONE_HIT,
|
||||
BLOCK_LODESTONE_PLACE,
|
||||
BLOCK_LODESTONE_STEP,
|
||||
BLOCK_NETHERITE_BLOCK_BREAK,
|
||||
BLOCK_NETHERITE_BLOCK_FALL,
|
||||
BLOCK_NETHERITE_BLOCK_HIT,
|
||||
BLOCK_NETHERITE_BLOCK_PLACE,
|
||||
BLOCK_NETHERITE_BLOCK_STEP,
|
||||
BLOCK_NETHERRACK_BREAK,
|
||||
BLOCK_NETHERRACK_FALL,
|
||||
BLOCK_NETHERRACK_HIT,
|
||||
BLOCK_NETHERRACK_PLACE,
|
||||
BLOCK_NETHERRACK_STEP,
|
||||
BLOCK_NETHER_BRICKS_BREAK,
|
||||
BLOCK_NETHER_BRICKS_FALL,
|
||||
BLOCK_NETHER_BRICKS_HIT,
|
||||
BLOCK_NETHER_BRICKS_PLACE,
|
||||
BLOCK_NETHER_BRICKS_STEP,
|
||||
BLOCK_NETHER_GOLD_ORE_BREAK,
|
||||
BLOCK_NETHER_GOLD_ORE_FALL,
|
||||
BLOCK_NETHER_GOLD_ORE_HIT,
|
||||
BLOCK_NETHER_GOLD_ORE_PLACE,
|
||||
BLOCK_NETHER_GOLD_ORE_STEP,
|
||||
BLOCK_NETHER_ORE_BREAK,
|
||||
BLOCK_NETHER_ORE_FALL,
|
||||
BLOCK_NETHER_ORE_HIT,
|
||||
BLOCK_NETHER_ORE_PLACE,
|
||||
BLOCK_NETHER_ORE_STEP,
|
||||
BLOCK_NETHER_SPROUTS_BREAK,
|
||||
BLOCK_NETHER_SPROUTS_FALL,
|
||||
BLOCK_NETHER_SPROUTS_HIT,
|
||||
BLOCK_NETHER_SPROUTS_PLACE,
|
||||
BLOCK_NETHER_SPROUTS_STEP,
|
||||
BLOCK_NYLIUM_BREAK,
|
||||
BLOCK_NYLIUM_FALL,
|
||||
BLOCK_NYLIUM_HIT,
|
||||
BLOCK_NYLIUM_PLACE,
|
||||
BLOCK_NYLIUM_STEP,
|
||||
BLOCK_RESPAWN_ANCHOR_AMBIENT,
|
||||
BLOCK_RESPAWN_ANCHOR_CHARGE,
|
||||
BLOCK_RESPAWN_ANCHOR_DEPLETE,
|
||||
BLOCK_RESPAWN_ANCHOR_SET_SPAWN,
|
||||
BLOCK_ROOTS_BREAK,
|
||||
BLOCK_ROOTS_FALL,
|
||||
BLOCK_ROOTS_HIT,
|
||||
BLOCK_ROOTS_PLACE,
|
||||
BLOCK_ROOTS_STEP,
|
||||
BLOCK_SHROOMLIGHT_BREAK,
|
||||
BLOCK_SHROOMLIGHT_FALL,
|
||||
BLOCK_SHROOMLIGHT_HIT,
|
||||
BLOCK_SHROOMLIGHT_PLACE,
|
||||
BLOCK_SHROOMLIGHT_STEP,
|
||||
BLOCK_SMITHING_TABLE_USE,
|
||||
BLOCK_SOUL_SAND_BREAK,
|
||||
BLOCK_SOUL_SAND_FALL,
|
||||
BLOCK_SOUL_SAND_HIT,
|
||||
BLOCK_SOUL_SAND_PLACE,
|
||||
BLOCK_SOUL_SAND_STEP,
|
||||
BLOCK_SOUL_SOIL_BREAK,
|
||||
BLOCK_SOUL_SOIL_FALL,
|
||||
BLOCK_SOUL_SOIL_HIT,
|
||||
BLOCK_SOUL_SOIL_PLACE,
|
||||
BLOCK_SOUL_SOIL_STEP,
|
||||
BLOCK_STEM_BREAK,
|
||||
BLOCK_STEM_FALL,
|
||||
BLOCK_STEM_HIT,
|
||||
BLOCK_STEM_PLACE,
|
||||
BLOCK_STEM_STEP,
|
||||
BLOCK_VINE_STEP,
|
||||
BLOCK_WART_BLOCK_BREAK,
|
||||
BLOCK_WART_BLOCK_FALL,
|
||||
BLOCK_WART_BLOCK_HIT,
|
||||
BLOCK_WART_BLOCK_PLACE,
|
||||
BLOCK_WART_BLOCK_STEP,
|
||||
ENTITY_DONKEY_EAT,
|
||||
ENTITY_FOX_TELEPORT,
|
||||
ENTITY_HOGLIN_AMBIENT,
|
||||
ENTITY_HOGLIN_ANGRY,
|
||||
ENTITY_HOGLIN_ATTACK,
|
||||
ENTITY_HOGLIN_CONVERTED_TO_ZOMBIFIED,
|
||||
ENTITY_HOGLIN_DEATH,
|
||||
ENTITY_HOGLIN_HURT,
|
||||
ENTITY_HOGLIN_RETREAT,
|
||||
ENTITY_HOGLIN_STEP,
|
||||
ENTITY_MULE_EAT,
|
||||
ENTITY_MULE_ANGRY,
|
||||
ENTITY_PARROT_IMITATE_HOGLIN,
|
||||
ENTITY_PARROT_IMITATE_PIGLIN,
|
||||
ENTITY_PARROT_IMITATE_ZOGLIN,
|
||||
ENTITY_PIGLIN_ADMIRING_ITEM,
|
||||
ENTITY_PIGLIN_AMBIENT,
|
||||
ENTITY_PIGLIN_ANGRY,
|
||||
ENTITY_PIGLIN_CELEBRATE,
|
||||
ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED,
|
||||
ENTITY_PIGLIN_DEATH,
|
||||
ENTITY_PIGLIN_HURT,
|
||||
ENTITY_PIGLIN_JEALOUS,
|
||||
ENTITY_PIGLIN_RETREAT,
|
||||
ENTITY_PIGLIN_STEP,
|
||||
ENTITY_SNOW_GOLEM_SHEAR,
|
||||
ENTITY_STRIDER_AMBIENT,
|
||||
ENTITY_STRIDER_DEATH,
|
||||
ENTITY_STRIDER_EAT,
|
||||
ENTITY_STRIDER_HAPPY,
|
||||
ENTITY_STRIDER_HURT,
|
||||
ENTITY_STRIDER_RETREAT,
|
||||
ENTITY_STRIDER_SADDLE,
|
||||
ENTITY_STRIDER_STEP,
|
||||
ENTITY_STRIDER_STEP_LAVA,
|
||||
ENTITY_ZOGLIN_AMBIENT,
|
||||
ENTITY_ZOGLIN_ANGRY,
|
||||
ENTITY_ZOGLIN_ATTACK,
|
||||
ENTITY_ZOGLIN_DEATH,
|
||||
ENTITY_ZOGLIN_HURT,
|
||||
ENTITY_ZOGLIN_STEP,
|
||||
BLOCK_WEEPING_VINES_BREAK,
|
||||
BLOCK_WEEPING_VINES_FALL,
|
||||
BLOCK_WEEPING_VINES_HIT,
|
||||
BLOCK_WEEPING_VINES_PLACE,
|
||||
BLOCK_WEEPING_VINES_STEP,
|
||||
BLOCK_GILDED_BLACKSTONE_BREAK,
|
||||
BLOCK_GILDED_BLACKSTONE_FALL,
|
||||
BLOCK_GILDED_BLACKSTONE_HIT,
|
||||
BLOCK_GILDED_BLACKSTONE_PLACE,
|
||||
BLOCK_GILDED_BLACKSTONE_STEP,
|
||||
ENTITY_CAT_DEATH,
|
||||
ENTITY_CAT_EAT,
|
||||
ENTITY_CAT_HISS("CAT_HISS"),
|
||||
|
@ -568,7 +731,6 @@ public enum XSound {
|
|||
ENTITY_PARROT_IMITATE_WITHER_SKELETON,
|
||||
ENTITY_PARROT_IMITATE_WOLF,
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE,
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE_PIGMAN,
|
||||
ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER,
|
||||
ENTITY_PARROT_STEP,
|
||||
ENTITY_PHANTOM_AMBIENT,
|
||||
|
@ -787,10 +949,14 @@ public enum XSound {
|
|||
ENTITY_ZOMBIE_HORSE_HURT("HORSE_ZOMBIE_HIT"),
|
||||
ENTITY_ZOMBIE_HURT("ZOMBIE_HURT"),
|
||||
ENTITY_ZOMBIE_INFECT("ZOMBIE_INFECT"),
|
||||
ENTITY_ZOMBIE_PIGMAN_AMBIENT("ZOMBIE_PIG_IDLE", "ENTITY_ZOMBIE_PIG_AMBIENT"),
|
||||
ENTITY_ZOMBIE_PIGMAN_ANGRY("ZOMBIE_PIG_ANGRY", "ENTITY_ZOMBIE_PIG_ANGRY"),
|
||||
ENTITY_ZOMBIE_PIGMAN_DEATH("ZOMBIE_PIG_DEATH", "ENTITY_ZOMBIE_PIG_DEATH"),
|
||||
ENTITY_ZOMBIE_PIGMAN_HURT("ZOMBIE_PIG_HURT", "ENTITY_ZOMBIE_PIG_HURT"),
|
||||
ITEM_ARMOR_EQUIP_NETHERITE,
|
||||
ITEM_LODESTONE_COMPASS_LOCK,
|
||||
MUSIC_DISC_PIGSTEP,
|
||||
|
||||
ENTITY_ZOMBIFIED_PIGLIN_AMBIENT("ZOMBE_PIG_IDLE", "ENTITY_ZOMBIE_PIG_AMBIENT", "ENTITY_ZOMBIE_PIGMAN_AMBIENT"),
|
||||
ENTITY_ZOMBIFIED_PIGLIN_ANGRY("ZOMBIE_PIG_ANGRY", "ENTITY_ZOMBIE_PIG_ANGRY", "ENTITY_ZOMBIE_PIGMAN_ANGRY"),
|
||||
ENTITY_ZOMBIFIED_PIGLIN_DEATH("ZOMBIE_PIG_DEATH", "ENTITY_ZOMBIE_PIG_DEATH", "ENTITY_ZOMBIE_PIGMAN_DEATH"),
|
||||
ENTITY_ZOMBIFIED_PIGLIN_HURT("ZOMBIE_PIG_HURT", "ENTITY_ZOMBIE_PIG_HURT", "ENTITY_ZOMBIE_PIGMAN_HURT"),
|
||||
ENTITY_ZOMBIE_STEP("ZOMBIE_WALK"),
|
||||
ENTITY_ZOMBIE_VILLAGER_AMBIENT,
|
||||
ENTITY_ZOMBIE_VILLAGER_CONVERTED("ZOMBIE_UNFECT"),
|
||||
|
@ -866,7 +1032,12 @@ public enum XSound {
|
|||
MUSIC_END,
|
||||
MUSIC_GAME,
|
||||
MUSIC_MENU,
|
||||
MUSIC_NETHER,
|
||||
MUSIC_NETHER_BASALT_DELTAS("MUSIC_NETHER"),
|
||||
PARTICLE_SOUL_ESCAPE,
|
||||
MUSIC_NETHER_CRIMSON_FOREST,
|
||||
MUSIC_NETHER_NETHER_WASTES,
|
||||
MUSIC_NETHER_SOUL_SAND_VALLEY,
|
||||
MUSIC_NETHER_WARPED_FOREST,
|
||||
MUSIC_UNDER_WATER,
|
||||
UI_BUTTON_CLICK("CLICK"),
|
||||
UI_CARTOGRAPHY_TABLE_TAKE_RESULT,
|
||||
|
@ -891,7 +1062,7 @@ public enum XSound {
|
|||
/**
|
||||
* Guava (Google Core Libraries for Java)'s cache for performance and timed caches.
|
||||
* Caches the parsed {@link Sound} objects instead of string. Because it has to go through catching exceptions again
|
||||
* since {@link Sound} class doesn't have a method like {@link org.bukkit.Material#getMaterial(String)}.
|
||||
* since {@link Sound} class doesn't have a method like {@link Material#getMaterial(String)}.
|
||||
* So caching these would be more efficient.
|
||||
*
|
||||
* @since 2.0.0
|
||||
|
@ -907,6 +1078,7 @@ public enum XSound {
|
|||
* @since 1.0.0
|
||||
*/
|
||||
private static final Pattern FORMAT_PATTERN = Pattern.compile("\\d+|\\W+");
|
||||
private static final Pattern DOUBLE_SPACE = Pattern.compile(" +");
|
||||
private final String[] legacy;
|
||||
|
||||
XSound(String... legacy) {
|
||||
|
@ -975,18 +1147,50 @@ public enum XSound {
|
|||
.orElseThrow(() -> new IllegalArgumentException("Unsupported Sound: " + sound.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #play(Location, String)
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Nonnull
|
||||
public static CompletableFuture<Record> play(@Nullable Player player, @Nullable String sound) {
|
||||
Objects.requireNonNull(player, "Cannot play sound to null player");
|
||||
return parse(player, player.getLocation(), sound, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #play(Location, String)
|
||||
* @since 3.0.0
|
||||
*/
|
||||
@Nonnull
|
||||
public static CompletableFuture<Record> play(@Nonnull Location location, @Nullable String sound) {
|
||||
return parse(null, location, sound, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Just an extra feature that loads sounds from strings.
|
||||
* Useful for getting sounds from config files.
|
||||
* Sounds are thread safe.
|
||||
* <p>
|
||||
* It's strongly recommended to use this method while using it inside a loop.
|
||||
* This can help to avoid parsing the sound properties multiple times.
|
||||
* A simple usage of using it in a loop is:
|
||||
* <blockquote><pre>
|
||||
* Record record = XSound.parse(player, location, sound, false).join();
|
||||
* // Loop:
|
||||
* if (record != null) record.play();
|
||||
* </pre></blockquote>
|
||||
* <p>
|
||||
* This will also ignore {@code none} and {@code null} strings.
|
||||
* <p>
|
||||
* <b>Format:</b> Sound, Volume, Pitch<br>
|
||||
* <b>Format:</b> [LOC:]Sound, [Volume], [Pitch]<br>
|
||||
* Where {@code LOC:} will play the sound at the location if a player is specified.
|
||||
* A sound played at a location will be heard by everyone around.
|
||||
* Comma separators are optional.
|
||||
* <p>
|
||||
* <b>Examples:</b>
|
||||
* <p>
|
||||
* <pre>
|
||||
* LOC:ENTITY_PLAYER_BURP, 2.5f, 0.5
|
||||
* ENTITY_PLAYER_BURP, 0.5, 1f
|
||||
* BURP 0.5f 1
|
||||
* MUSIC_END, 10f
|
||||
|
@ -994,27 +1198,32 @@ public enum XSound {
|
|||
* null
|
||||
* </pre>
|
||||
*
|
||||
* @param player the player to play the sound to.
|
||||
* @param sound the string of the sound with volume and pitch (if needed).
|
||||
* @since 1.0.0
|
||||
* @param player the only player to play the sound to if requested to do so.
|
||||
* @param location the location to play the sound to.
|
||||
* @param sound the string of the sound with volume and pitch (if needed).
|
||||
* @param play if the sound should be played right away.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static CompletableFuture<Void> playSoundFromString(@Nonnull Player player, @Nullable String sound) {
|
||||
Objects.requireNonNull(player, "Cannot play sound to null player");
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
if (Strings.isNullOrEmpty(sound) || sound.equalsIgnoreCase("none")) return;
|
||||
@Nonnull
|
||||
public static CompletableFuture<Record> parse(@Nullable Player player, @Nonnull Location location, @Nullable String sound, boolean play) {
|
||||
Objects.requireNonNull(player, "Cannot play sound to null location");
|
||||
if (Strings.isNullOrEmpty(sound) || sound.equalsIgnoreCase("none")) return null;
|
||||
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
String[] split = StringUtils.contains(sound, ',') ?
|
||||
StringUtils.split(StringUtils.deleteWhitespace(sound), ',') :
|
||||
StringUtils.split(sound.replaceAll(" +", " "), ' ');
|
||||
|
||||
// You should replace the exception with your own message handler.
|
||||
Validate.isTrue(split.length != 0, "Sound string must at least have a sound name: ", sound);
|
||||
StringUtils.split(DOUBLE_SPACE.matcher(sound).replaceAll(" "), ' ');
|
||||
|
||||
String name = split[0];
|
||||
boolean playForEveryone = player == null;
|
||||
if (!playForEveryone && StringUtils.startsWithIgnoreCase(name, "loc:")) {
|
||||
name = name.substring(4);
|
||||
playForEveryone = true;
|
||||
}
|
||||
Optional<XSound> typeOpt = matchXSound(name);
|
||||
if (!typeOpt.isPresent()) return;
|
||||
if (!typeOpt.isPresent()) return null;
|
||||
Sound type = typeOpt.get().parseSound();
|
||||
if (type == null) return;
|
||||
if (type == null) return null;
|
||||
|
||||
float volume = 1.0f;
|
||||
float pitch = 1.0f;
|
||||
|
@ -1027,7 +1236,13 @@ public enum XSound {
|
|||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
|
||||
if (player.isOnline()) player.playSound(player.getLocation(), type, volume, pitch);
|
||||
Record record = new Record(type, player, location, volume, pitch, playForEveryone);
|
||||
if (play) record.play();
|
||||
return record;
|
||||
}).exceptionally((ex) -> {
|
||||
System.err.println("Could not play sound for string: " + sound);
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1051,7 +1266,7 @@ public enum XSound {
|
|||
MUSIC_DISC_11, MUSIC_DISC_13, MUSIC_DISC_BLOCKS, MUSIC_DISC_CAT, MUSIC_DISC_CHIRP,
|
||||
MUSIC_DISC_FAR, MUSIC_DISC_MALL, MUSIC_DISC_MELLOHI, MUSIC_DISC_STAL,
|
||||
MUSIC_DISC_STRAD, MUSIC_DISC_WAIT, MUSIC_DISC_WARD,
|
||||
MUSIC_DRAGON, MUSIC_END, MUSIC_GAME, MUSIC_MENU, MUSIC_NETHER, MUSIC_UNDER_WATER);
|
||||
MUSIC_DRAGON, MUSIC_END, MUSIC_GAME, MUSIC_MENU, MUSIC_NETHER_BASALT_DELTAS, MUSIC_UNDER_WATER);
|
||||
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
for (XSound music : musics) {
|
||||
|
@ -1148,10 +1363,10 @@ public enum XSound {
|
|||
* @param pitch the pitch of the sound.
|
||||
* @param repeat the amount of times to repeat playing.
|
||||
* @param delay the delay between each repeat.
|
||||
* @see #playSound(Location, float, float)
|
||||
* @see #play(Location, float, float)
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public void playSoundRepeatedly(JavaPlugin plugin, Entity entity, float volume, float pitch, int repeat, int delay) {
|
||||
public void playRepeatedly(JavaPlugin plugin, Entity entity, float volume, float pitch, int repeat, int delay) {
|
||||
Objects.requireNonNull(plugin, "Cannot play repeating sound from null plugin");
|
||||
Objects.requireNonNull(entity, "Cannot play repeating sound at null location");
|
||||
|
||||
|
@ -1163,7 +1378,7 @@ public enum XSound {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
playSound(entity.getLocation(), volume, pitch);
|
||||
play(entity.getLocation(), volume, pitch);
|
||||
if (repeating-- == 0) cancel();
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, delay);
|
||||
|
@ -1220,8 +1435,8 @@ public enum XSound {
|
|||
* @param entity the entity to play the sound to.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void playSound(@Nonnull Entity entity) {
|
||||
playSound(entity, 1.0f, 1.0f);
|
||||
public void play(@Nonnull Entity entity) {
|
||||
play(entity, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1232,9 +1447,15 @@ public enum XSound {
|
|||
* @param pitch the pitch of the sound, 0 is normal.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public void playSound(@Nonnull Entity entity, float volume, float pitch) {
|
||||
public void play(@Nonnull Entity entity, float volume, float pitch) {
|
||||
Objects.requireNonNull(entity, "Cannot play sound to a null entity");
|
||||
playSound(entity.getLocation(), volume, pitch);
|
||||
if (entity instanceof Player) {
|
||||
Sound sound = this.parseSound();
|
||||
if (sound == null) return;
|
||||
((Player) entity).playSound(entity.getLocation(), sound, volume, pitch);
|
||||
} else {
|
||||
play(entity.getLocation(), volume, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1243,8 +1464,8 @@ public enum XSound {
|
|||
* @param location the location to play the sound in.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public void playSound(@Nonnull Location location) {
|
||||
playSound(location, 1.0f, 1.0f);
|
||||
public void play(@Nonnull Location location) {
|
||||
play(location, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1255,11 +1476,53 @@ public enum XSound {
|
|||
* @param pitch the pitch of the sound, 0 is normal.
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public void playSound(@Nonnull Location location, float volume, float pitch) {
|
||||
public void play(@Nonnull Location location, float volume, float pitch) {
|
||||
Objects.requireNonNull(location, "Cannot play sound to null location");
|
||||
Sound sound = this.parseSound();
|
||||
|
||||
Validate.isTrue(sound != null, "Unsupported sound type: ", this.name());
|
||||
if (sound == null) return;
|
||||
location.getWorld().playSound(location, sound, volume, pitch);
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to help caching sound properties parsed from config.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public static class Record {
|
||||
public final Sound sound;
|
||||
public final Player player;
|
||||
public final Location location;
|
||||
public final float volume;
|
||||
public final float pitch;
|
||||
public final boolean playAtLocation;
|
||||
|
||||
public Record(Sound sound, Player player, Location location, float volume, float pitch, boolean playAtLocation) {
|
||||
this.sound = sound;
|
||||
this.player = player;
|
||||
this.location = location;
|
||||
this.volume = volume;
|
||||
this.pitch = pitch;
|
||||
this.playAtLocation = playAtLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays the sound with the given options and updating the players location.
|
||||
*
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public void play() {
|
||||
play(player == null ? location : player.getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays the sound with the updated location.
|
||||
*
|
||||
* @param updatedLocation the upated location.
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public void play(Location updatedLocation) {
|
||||
if (playAtLocation) location.getWorld().playSound(updatedLocation, sound, volume, pitch);
|
||||
else if (player.isOnline()) player.playSound(updatedLocation, sound, volume, pitch);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* The package with all the utils
|
||||
*/
|
||||
package nl.SBDeveloper.V10Lift.Utils;
|
||||
package nl.SBDeveloper.V10Lift.utils;
|
Loading…
Reference in a new issue