Makes ItemCase compile for Minecraft 1.17
This commit is contained in:
parent
a9f1d9e5e7
commit
90b0223d8d
@ -21,6 +21,7 @@ ItemCase uses Maven to handle its dependencies.
|
|||||||
|
|
||||||
Coding and Pull Request Formatting
|
Coding and Pull Request Formatting
|
||||||
----------------------------------
|
----------------------------------
|
||||||
|
|
||||||
* Generally follow the Oracle coding standards.
|
* Generally follow the Oracle coding standards.
|
||||||
* Use spaces not tabs.
|
* Use spaces not tabs.
|
||||||
* No trailing whitespaces.
|
* No trailing whitespaces.
|
||||||
@ -31,6 +32,9 @@ Coding and Pull Request Formatting
|
|||||||
**Please try to follow the above conventions if you want your pull request(s) accepted.**
|
**Please try to follow the above conventions if you want your pull request(s) accepted.**
|
||||||
|
|
||||||
[License]: http://www.gnu.org/licenses/gpl.html
|
[License]: http://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
[GitHub]: http://github.com/BleedObsidian/ItemCase/
|
[GitHub]: http://github.com/BleedObsidian/ItemCase/
|
||||||
|
|
||||||
[Bukkit]: http://dev.bukkit.org/bukkit-plugins/itemcase/
|
[Bukkit]: http://dev.bukkit.org/bukkit-plugins/itemcase/
|
||||||
|
|
||||||
[Javadoc]: http://bleedobsidian.github.io/ItemCase/
|
[Javadoc]: http://bleedobsidian.github.io/ItemCase/
|
96
pom.xml
96
pom.xml
@ -1,36 +1,38 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.gmail.bleedobsidian</groupId>
|
<groupId>com.gmail.bleedobsidian</groupId>
|
||||||
<artifactId>ItemCase</artifactId>
|
<artifactId>ItemCase</artifactId>
|
||||||
<name>ItemCase</name>
|
<name>ItemCase</name>
|
||||||
<description>ItemCase is a Bukkit plugin allowing you to showcase items on slabs, that can also be used as shops.</description>
|
<description>ItemCase is a Bukkit plugin allowing you to showcase items on slabs, that can also be used as shops.
|
||||||
|
</description>
|
||||||
<version>2.0.0</version>
|
<version>2.0.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>16</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>16</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>sk89q-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>bstats-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>http://repo.bstats.org/content/repositories/releases/</url>
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>vault-repo</id>
|
<id>vault-repo</id>
|
||||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>sk89q-repo</id>
|
<id>OnARandomBox</id>
|
||||||
<url>http://maven.sk89q.com/repo/</url>
|
<url>https://repo.onarandombox.com/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@ -38,48 +40,25 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bstats</groupId>
|
|
||||||
<artifactId>bstats-bukkit</artifactId>
|
|
||||||
<version>1.2</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.onarandombox.multiversecore</groupId>
|
<groupId>com.onarandombox.multiversecore</groupId>
|
||||||
<artifactId>Multiverse-Core</artifactId>
|
<artifactId>Multiverse-Core</artifactId>
|
||||||
<version>2.5.0</version>
|
<version>4.3.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
<version>1.6</version>
|
<version>1.7</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard</artifactId>
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
<version>6.2.1</version>
|
<version>7.0.7-SNAPSHOT</version>
|
||||||
</dependency>
|
<scope>provided</scope>
|
||||||
<dependency>
|
|
||||||
<groupId>org.powermock</groupId>
|
|
||||||
<artifactId>powermock-module-junit4</artifactId>
|
|
||||||
<version>1.7.1</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.powermock</groupId>
|
|
||||||
<artifactId>powermock-api-mockito</artifactId>
|
|
||||||
<version>1.7.1</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -110,52 +89,19 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.1</version>
|
<version>3.8.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>2.4</version>
|
<version>3.2.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<addMavenDescriptor>false</addMavenDescriptor>
|
<addMavenDescriptor>false</addMavenDescriptor>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<finalName>${artifactId}</finalName>
|
|
||||||
<artifactSet>
|
|
||||||
<excludes>
|
|
||||||
<exclude>org.bukkit</exclude>
|
|
||||||
<exclude>net.milkbowl.vault</exclude>
|
|
||||||
<exclude>junit</exclude>
|
|
||||||
<exclude>com.sk89q.worldguard</exclude>
|
|
||||||
</excludes>
|
|
||||||
<includes>
|
|
||||||
<include>org.bstats:*</include>
|
|
||||||
</includes>
|
|
||||||
</artifactSet>
|
|
||||||
<relocations>
|
|
||||||
<relocation>
|
|
||||||
<pattern>org.bstats</pattern>
|
|
||||||
<shadedPattern>com.gmail.bleedobsidian</shadedPattern>
|
|
||||||
</relocation>
|
|
||||||
</relocations>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
@ -30,5 +30,5 @@ public interface Command {
|
|||||||
* @param label The label used,
|
* @param label The label used,
|
||||||
* @param args Any arguments.
|
* @param args Any arguments.
|
||||||
*/
|
*/
|
||||||
public void execute(CommandSender sender, String label, String[] args);
|
void execute(CommandSender sender, String label, String[] args);
|
||||||
}
|
}
|
||||||
|
@ -14,17 +14,18 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.bleedobsidian.itemcase;
|
package com.gmail.bleedobsidian.itemcase;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.GenericLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.commands.CreateCommand;
|
import com.gmail.bleedobsidian.itemcase.commands.CreateCommand;
|
||||||
import com.gmail.bleedobsidian.itemcase.commands.ModifyCommand;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.commands.DestroyCommand;
|
import com.gmail.bleedobsidian.itemcase.commands.DestroyCommand;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.commands.ModifyCommand;
|
||||||
import com.gmail.bleedobsidian.itemcase.commands.OrderCommand;
|
import com.gmail.bleedobsidian.itemcase.commands.OrderCommand;
|
||||||
import com.gmail.bleedobsidian.itemcase.commands.StorageCommand;
|
import com.gmail.bleedobsidian.itemcase.commands.StorageCommand;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.GenericLogger;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The central command handler for all ItemCase commands.
|
* The central command handler for all ItemCase commands.
|
||||||
@ -34,8 +35,8 @@ import org.bukkit.entity.Player;
|
|||||||
public final class CommandHandler implements CommandExecutor {
|
public final class CommandHandler implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command,
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
|
||||||
String label, String[] args) {
|
@NotNull String label, String[] args) {
|
||||||
|
|
||||||
// Check we have atleast 1 argument (sub-command label).
|
// Check we have atleast 1 argument (sub-command label).
|
||||||
if (args.length <= 0) {
|
if (args.length <= 0) {
|
||||||
@ -94,10 +95,9 @@ public final class CommandHandler implements CommandExecutor {
|
|||||||
String command = "/" + label + " [create/order/destroy/modify/storage]";
|
String command = "/" + label + " [create/order/destroy/modify/storage]";
|
||||||
|
|
||||||
// Check if sender is a player or console.
|
// Check if sender is a player or console.
|
||||||
if(sender instanceof Player) {
|
if (sender instanceof Player player) {
|
||||||
|
|
||||||
// Cast sender to player.
|
// Cast sender to player.
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Get chat logger.
|
// Get chat logger.
|
||||||
ChatLogger logger = ItemCaseCore.instance.getChatLogger();
|
ChatLogger logger = ItemCaseCore.instance.getChatLogger();
|
||||||
|
@ -14,15 +14,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.bleedobsidian.itemcase;
|
package com.gmail.bleedobsidian.itemcase;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object with a corresponding configuration file that can be loaded/saved.
|
* An object with a corresponding configuration file that can be loaded/saved.
|
||||||
@ -39,12 +40,12 @@ public class ConfigurationFile {
|
|||||||
/**
|
/**
|
||||||
* The name of this configuration file.
|
* The name of this configuration file.
|
||||||
*/
|
*/
|
||||||
private String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the default file in the jar.
|
* The name of the default file in the jar.
|
||||||
*/
|
*/
|
||||||
private String defaultName;
|
private final String defaultName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this configuration file can be copied outside of the jar.
|
* If this configuration file can be copied outside of the jar.
|
||||||
@ -91,7 +92,6 @@ public class ConfigurationFile {
|
|||||||
* does not exist, it is copied from the plugins jar.
|
* does not exist, it is copied from the plugins jar.
|
||||||
*
|
*
|
||||||
* @param plugin JavaPlugin.
|
* @param plugin JavaPlugin.
|
||||||
* @throws IOException.
|
|
||||||
*/
|
*/
|
||||||
public void load(JavaPlugin plugin) throws IOException {
|
public void load(JavaPlugin plugin) throws IOException {
|
||||||
|
|
||||||
@ -145,7 +145,6 @@ public class ConfigurationFile {
|
|||||||
* jar to the data folder.
|
* jar to the data folder.
|
||||||
*
|
*
|
||||||
* @param plugin JavaPlugin.
|
* @param plugin JavaPlugin.
|
||||||
* @throws IOException.
|
|
||||||
*/
|
*/
|
||||||
private void copyDefault(JavaPlugin plugin) throws IOException {
|
private void copyDefault(JavaPlugin plugin) throws IOException {
|
||||||
|
|
||||||
@ -175,7 +174,6 @@ public class ConfigurationFile {
|
|||||||
* Save this configuration file in the given plugin's data folder.
|
* Save this configuration file in the given plugin's data folder.
|
||||||
*
|
*
|
||||||
* @param plugin Plugin.
|
* @param plugin Plugin.
|
||||||
* @throws IOException.
|
|
||||||
*/
|
*/
|
||||||
public void save(JavaPlugin plugin) throws IOException {
|
public void save(JavaPlugin plugin) throws IOException {
|
||||||
|
|
||||||
|
@ -15,20 +15,21 @@
|
|||||||
|
|
||||||
package com.gmail.bleedobsidian.itemcase;
|
package com.gmail.bleedobsidian.itemcase;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ConsoleLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.GenericLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.ItemcaseListener;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.ItemcaseListener;
|
||||||
import com.gmail.bleedobsidian.itemcase.configurations.ConfigFile;
|
import com.gmail.bleedobsidian.itemcase.configurations.ConfigFile;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.ConsoleLogger;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.GenericLogger;
|
||||||
import com.gmail.bleedobsidian.itemcase.managers.ItemcaseManager;
|
import com.gmail.bleedobsidian.itemcase.managers.ItemcaseManager;
|
||||||
import com.gmail.bleedobsidian.itemcase.managers.OrderManager;
|
import com.gmail.bleedobsidian.itemcase.managers.OrderManager;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import java.io.IOException;
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ItemCase is a Bukkit plugin allowing you to showcase items on slabs, that
|
* ItemCase is a Bukkit plugin allowing you to showcase items on slabs, that
|
||||||
* can also be used as shops.
|
* can also be used as shops.
|
||||||
@ -104,9 +105,6 @@ public final class ItemCaseCore extends JavaPlugin {
|
|||||||
// Set current instance.
|
// Set current instance.
|
||||||
ItemCaseCore.instance = this;
|
ItemCaseCore.instance = this;
|
||||||
|
|
||||||
// Start metrics.
|
|
||||||
PluginMetrics metrics = new PluginMetrics(this);
|
|
||||||
|
|
||||||
// Attempt to load configuration file.
|
// Attempt to load configuration file.
|
||||||
try {
|
try {
|
||||||
|
|
||||||
@ -240,7 +238,6 @@ public final class ItemCaseCore extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
* @return Main ItemCase configuration file.
|
* @return Main ItemCase configuration file.
|
||||||
*/
|
*/
|
||||||
public ConfigFile getConfigFile() {
|
public ConfigFile getConfigFile() {
|
||||||
|
@ -16,15 +16,13 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase;
|
package com.gmail.bleedobsidian.itemcase;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.managers.ItemcaseManager;
|
import com.gmail.bleedobsidian.itemcase.managers.ItemcaseManager;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.UUID;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
@ -45,6 +43,10 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler of an Itemcase.
|
* Handler of an Itemcase.
|
||||||
*
|
*
|
||||||
@ -60,17 +62,17 @@ public final class Itemcase {
|
|||||||
/**
|
/**
|
||||||
* Types of Itemcase.
|
* Types of Itemcase.
|
||||||
*/
|
*/
|
||||||
public static enum Type {
|
public enum Type {
|
||||||
SHOWCASE,
|
SHOWCASE,
|
||||||
SHOP_BUY,
|
SHOP_BUY,
|
||||||
SHOP_SELL,
|
SHOP_SELL,
|
||||||
SHOP_MULTI
|
SHOP_MULTI
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Storage types.
|
* Storage types.
|
||||||
*/
|
*/
|
||||||
public static enum StorageType {
|
public enum StorageType {
|
||||||
FINITE,
|
FINITE,
|
||||||
INFINITE
|
INFINITE
|
||||||
}
|
}
|
||||||
@ -108,7 +110,7 @@ public final class Itemcase {
|
|||||||
/**
|
/**
|
||||||
* This itemcase's Type.
|
* This itemcase's Type.
|
||||||
*/
|
*/
|
||||||
private Type type = Type.SHOWCASE;
|
private Type type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The storage type of this itemcase.
|
* The storage type of this itemcase.
|
||||||
@ -207,7 +209,7 @@ public final class Itemcase {
|
|||||||
// Set display name to random UUID to prevent graphical item stacking.
|
// Set display name to random UUID to prevent graphical item stacking.
|
||||||
ItemMeta metadata = itemStack.getItemMeta();
|
ItemMeta metadata = itemStack.getItemMeta();
|
||||||
metadata.setDisplayName("com.gmail.bleedobsidian.itemcase:" +
|
metadata.setDisplayName("com.gmail.bleedobsidian.itemcase:" +
|
||||||
UUID.randomUUID().toString());
|
UUID.randomUUID());
|
||||||
itemStack.setItemMeta(metadata);
|
itemStack.setItemMeta(metadata);
|
||||||
|
|
||||||
// Spawn the item.
|
// Spawn the item.
|
||||||
@ -457,7 +459,7 @@ public final class Itemcase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param buyPrice Sell price.
|
* @param sellPrice Sell price.
|
||||||
*/
|
*/
|
||||||
public void setSellPrice(double sellPrice) {
|
public void setSellPrice(double sellPrice) {
|
||||||
|
|
||||||
@ -483,13 +485,10 @@ public final class Itemcase {
|
|||||||
Material type = this.location.getBlock().getType();
|
Material type = this.location.getBlock().getType();
|
||||||
|
|
||||||
// The relative Y coordinate.
|
// The relative Y coordinate.
|
||||||
double relY = 0;
|
double relY;
|
||||||
|
|
||||||
// If block is a slab.
|
// If block is a slab.
|
||||||
if(type == Material.STEP ||
|
if (Tag.SLABS.isTagged(type)) {
|
||||||
type == Material.STONE_SLAB2 ||
|
|
||||||
type == Material.WOOD_STEP ||
|
|
||||||
type == Material.PURPUR_SLAB) {
|
|
||||||
|
|
||||||
// Set relY.
|
// Set relY.
|
||||||
relY = 0.6;
|
relY = 0.6;
|
||||||
@ -501,14 +500,13 @@ public final class Itemcase {
|
|||||||
|
|
||||||
// Create a location that is in the centre of the block and slightly
|
// Create a location that is in the centre of the block and slightly
|
||||||
// above.
|
// above.
|
||||||
Location displayItemLocation = new Location(
|
|
||||||
|
// Return the default location to spawn the display item.
|
||||||
|
return new Location(
|
||||||
this.location.getWorld(),
|
this.location.getWorld(),
|
||||||
this.location.getBlockX() + 0.5,
|
this.location.getBlockX() + 0.5,
|
||||||
this.location.getBlockY() + relY,
|
this.location.getBlockY() + relY,
|
||||||
this.location.getBlockZ() + 0.5);
|
this.location.getBlockZ() + 0.5);
|
||||||
|
|
||||||
// Return the default location to spawn the display item.
|
|
||||||
return displayItemLocation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -579,10 +577,7 @@ public final class Itemcase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not a slab.
|
// If not a slab.
|
||||||
if(type != Material.STEP &&
|
if (Tag.SLABS.isTagged(type)) {
|
||||||
type != Material.WOOD_STEP &&
|
|
||||||
type != Material.STONE_SLAB2 &&
|
|
||||||
type != Material.PURPUR_SLAB) {
|
|
||||||
|
|
||||||
// Check if the block placed was 1 above an itemcase.
|
// Check if the block placed was 1 above an itemcase.
|
||||||
if (itemcase.location.clone().add(0, 1, 0)
|
if (itemcase.location.clone().add(0, 1, 0)
|
||||||
@ -660,7 +655,7 @@ public final class Itemcase {
|
|||||||
* is particularly useful when servers use anti-lag plugins that forcibly
|
* is particularly useful when servers use anti-lag plugins that forcibly
|
||||||
* kill entities or a player has somehow caused an item to move.
|
* kill entities or a player has somehow caused an item to move.
|
||||||
*/
|
*/
|
||||||
public final class ItemcaseTask extends BukkitRunnable {
|
public static final class ItemcaseTask extends BukkitRunnable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The itemcase that this task is for.
|
* The itemcase that this task is for.
|
||||||
@ -723,8 +718,7 @@ public final class Itemcase {
|
|||||||
|
|
||||||
// Get the vector location that belongs to this itemcase
|
// Get the vector location that belongs to this itemcase
|
||||||
// item.
|
// item.
|
||||||
Vector entityVector = (Vector) ((FixedMetadataValue)
|
Vector entityVector = (Vector) entity.getMetadata("ItemCase").get(0).value();
|
||||||
entity.getMetadata("ItemCase").get(0)).value();
|
|
||||||
|
|
||||||
// Check that the entity is an item for this itemcase only.
|
// Check that the entity is an item for this itemcase only.
|
||||||
if (entityVector.getBlockX() !=
|
if (entityVector.getBlockX() !=
|
||||||
|
@ -15,10 +15,11 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase;
|
package com.gmail.bleedobsidian.itemcase;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.configurations.LanguageFile;
|
import com.gmail.bleedobsidian.itemcase.configurations.LanguageFile;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class used for communicating in different dialects.
|
* Utility class used for communicating in different dialects.
|
||||||
@ -30,9 +31,9 @@ public final class LanguageTranslator {
|
|||||||
/**
|
/**
|
||||||
* Supported languages.
|
* Supported languages.
|
||||||
*/
|
*/
|
||||||
public static enum Language {
|
public enum Language {
|
||||||
EN
|
EN
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The language file for the chosen language.
|
* The language file for the chosen language.
|
||||||
@ -42,7 +43,7 @@ public final class LanguageTranslator {
|
|||||||
/**
|
/**
|
||||||
* A hash map of placeholders.
|
* A hash map of placeholders.
|
||||||
*/
|
*/
|
||||||
private HashMap<String, String> placeholders = new HashMap<>();
|
private final HashMap<String, String> placeholders = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load corresponding language file.
|
* Load corresponding language file.
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* ItemCase is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.gmail.bleedobsidian.itemcase;
|
|
||||||
|
|
||||||
import org.bstats.bukkit.Metrics;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles bStats plugin metrics and any custom graphs.
|
|
||||||
*
|
|
||||||
* @author Jesse Prescott (BleedObsidian)
|
|
||||||
*/
|
|
||||||
public final class PluginMetrics {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor, starts bStats.
|
|
||||||
*
|
|
||||||
* @param plugin The Bukkit JavaPlugin.
|
|
||||||
*/
|
|
||||||
public PluginMetrics(JavaPlugin plugin) {
|
|
||||||
|
|
||||||
// Start bStats.
|
|
||||||
Metrics metrics = new Metrics(plugin);
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,17 +15,19 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase.commands;
|
package com.gmail.bleedobsidian.itemcase.commands;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.Command;
|
import com.gmail.bleedobsidian.itemcase.Command;
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
||||||
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
||||||
import java.util.ArrayList;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A command handler for the 'create' command.
|
* A command handler for the 'create' command.
|
||||||
*
|
*
|
||||||
@ -38,7 +40,7 @@ public final class CreateCommand implements Command {
|
|||||||
String[] args) {
|
String[] args) {
|
||||||
|
|
||||||
// If sender is not a player.
|
// If sender is not a player.
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
|
|
||||||
// Send message.
|
// Send message.
|
||||||
ItemCaseCore.instance.getGenericLogger().message(
|
ItemCaseCore.instance.getGenericLogger().message(
|
||||||
@ -49,7 +51,6 @@ public final class CreateCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cast sender to player.
|
// Cast sender to player.
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Check if player is asking for help.
|
// Check if player is asking for help.
|
||||||
if (this.isAskingForHelp(player, label, args)) {
|
if (this.isAskingForHelp(player, label, args)) {
|
||||||
@ -76,10 +77,10 @@ public final class CreateCommand implements Command {
|
|||||||
ItemCaseCore.instance.getConfigFile().getMaterials();
|
ItemCaseCore.instance.getConfigFile().getMaterials();
|
||||||
|
|
||||||
// The target location.
|
// The target location.
|
||||||
Location target = null;
|
Location target;
|
||||||
|
|
||||||
// ItemStack to use.
|
// ItemStack to use.
|
||||||
ItemStack itemStack = null;
|
ItemStack itemStack;
|
||||||
|
|
||||||
// Get the players target block.
|
// Get the players target block.
|
||||||
target = player.getTargetBlock(null, 5).getLocation();
|
target = player.getTargetBlock(null, 5).getLocation();
|
||||||
@ -96,6 +97,8 @@ public final class CreateCommand implements Command {
|
|||||||
|
|
||||||
// If target block is not on the list of accepted materials.
|
// If target block is not on the list of accepted materials.
|
||||||
if (!materials.contains(target.getBlock().getType())) {
|
if (!materials.contains(target.getBlock().getType())) {
|
||||||
|
chatLogger.message(player, String.valueOf(materials));
|
||||||
|
chatLogger.message(player, String.valueOf(target.getBlock()));
|
||||||
|
|
||||||
// Show message.
|
// Show message.
|
||||||
chatLogger.message(player, "command.create.invalid-type");
|
chatLogger.message(player, "command.create.invalid-type");
|
||||||
@ -104,28 +107,20 @@ public final class CreateCommand implements Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this server has WorldGuard.
|
|
||||||
if(ItemCaseCore.instance.hasWorldGuard()) {
|
|
||||||
|
|
||||||
// Get world guard.
|
|
||||||
WorldGuardPlugin worldGuard = ItemCaseCore.instance.getWorldGuard();
|
|
||||||
|
|
||||||
// If player cannot build here.
|
|
||||||
if(!worldGuard.canBuild(player, target)) {
|
|
||||||
|
|
||||||
// Show message.
|
|
||||||
chatLogger.message(player, "command.create.no-build");
|
|
||||||
|
|
||||||
// Exit.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get item in players main hand to use as the Itemcase item.
|
// Get item in players main hand to use as the Itemcase item.
|
||||||
itemStack = player.getInventory().getItemInMainHand();
|
itemStack = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
|
//Allow any protection plugins to protect
|
||||||
|
BlockPlaceEvent event = new BlockPlaceEvent(target.getBlock(), target.getBlock().getState(),
|
||||||
|
target.getBlock(), itemStack, player, true, EquipmentSlot.HAND);
|
||||||
|
ItemCaseCore.instance.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled() || !event.canBuild()) {
|
||||||
|
chatLogger.message(player, "command.create.no-build");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If the player is not holding anything...
|
// If the player is not holding anything...
|
||||||
if(itemStack == null || itemStack.getType() == Material.AIR) {
|
if (itemStack.getType() == Material.AIR) {
|
||||||
|
|
||||||
// Show message.
|
// Show message.
|
||||||
chatLogger.message(player, "command.create.main-hand");
|
chatLogger.message(player, "command.create.main-hand");
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase.commands;
|
package com.gmail.bleedobsidian.itemcase.commands;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.Command;
|
import com.gmail.bleedobsidian.itemcase.Command;
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
||||||
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
||||||
import com.gmail.bleedobsidian.itemcase.managers.ItemcaseManager;
|
import com.gmail.bleedobsidian.itemcase.managers.ItemcaseManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -37,7 +37,7 @@ public final class DestroyCommand implements Command {
|
|||||||
String[] args) {
|
String[] args) {
|
||||||
|
|
||||||
// If sender is not a player.
|
// If sender is not a player.
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
|
|
||||||
// Send message.
|
// Send message.
|
||||||
ItemCaseCore.instance.getGenericLogger().message(
|
ItemCaseCore.instance.getGenericLogger().message(
|
||||||
@ -48,7 +48,6 @@ public final class DestroyCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cast sender to player.
|
// Cast sender to player.
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Check if player is asking for help.
|
// Check if player is asking for help.
|
||||||
if (this.isAskingForHelp(player, label, args)) {
|
if (this.isAskingForHelp(player, label, args)) {
|
||||||
@ -71,7 +70,7 @@ public final class DestroyCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The target location.
|
// The target location.
|
||||||
Location target = null;
|
Location target;
|
||||||
|
|
||||||
// Get ItemcaseManager.
|
// Get ItemcaseManager.
|
||||||
ItemcaseManager manager = ItemCaseCore.instance.getItemcaseManager();
|
ItemcaseManager manager = ItemCaseCore.instance.getItemcaseManager();
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase.commands;
|
package com.gmail.bleedobsidian.itemcase.commands;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.Command;
|
import com.gmail.bleedobsidian.itemcase.Command;
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
||||||
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -39,7 +39,7 @@ public final class ModifyCommand implements Command {
|
|||||||
String[] args) {
|
String[] args) {
|
||||||
|
|
||||||
// If sender is not a player.
|
// If sender is not a player.
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
|
|
||||||
// Send message.
|
// Send message.
|
||||||
ItemCaseCore.instance.getGenericLogger().message(
|
ItemCaseCore.instance.getGenericLogger().message(
|
||||||
@ -50,7 +50,6 @@ public final class ModifyCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cast sender to player.
|
// Cast sender to player.
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Check if player is asking for help.
|
// Check if player is asking for help.
|
||||||
if (this.isAskingForHelp(player, label, args)) {
|
if (this.isAskingForHelp(player, label, args)) {
|
||||||
@ -83,7 +82,7 @@ public final class ModifyCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The target location.
|
// The target location.
|
||||||
Location target = null;
|
Location target;
|
||||||
|
|
||||||
// Get the players target block.
|
// Get the players target block.
|
||||||
target = player.getTargetBlock(null, 5).getLocation();
|
target = player.getTargetBlock(null, 5).getLocation();
|
||||||
@ -163,14 +162,7 @@ public final class ModifyCommand implements Command {
|
|||||||
ChatLogger chatLogger = ItemCaseCore.instance.getChatLogger();
|
ChatLogger chatLogger = ItemCaseCore.instance.getChatLogger();
|
||||||
|
|
||||||
// If the itemcase was a shop.
|
// If the itemcase was a shop.
|
||||||
boolean wasShop = false;
|
boolean wasShop = itemcase.getType() != Type.SHOWCASE;
|
||||||
|
|
||||||
// If the itemcase was a shop.
|
|
||||||
if(itemcase.getType() != Type.SHOWCASE) {
|
|
||||||
|
|
||||||
// Set boolean.
|
|
||||||
wasShop = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the itemcase is now a shop.
|
// If the itemcase is now a shop.
|
||||||
boolean isNowShop = false;
|
boolean isNowShop = false;
|
||||||
@ -521,8 +513,6 @@ public final class ModifyCommand implements Command {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show help for main command to given sender.
|
* Show help for main command to given sender.
|
||||||
*
|
|
||||||
* @param sender CommandSender.
|
|
||||||
*/
|
*/
|
||||||
private void showHelp(Player player, String label) {
|
private void showHelp(Player player, String label) {
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase.commands;
|
package com.gmail.bleedobsidian.itemcase.commands;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.Command;
|
import com.gmail.bleedobsidian.itemcase.Command;
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
||||||
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
||||||
import com.gmail.bleedobsidian.itemcase.managers.OrderManager.ItemcaseOrder;
|
import com.gmail.bleedobsidian.itemcase.managers.OrderManager.ItemcaseOrder;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
@ -42,7 +42,7 @@ public final class OrderCommand implements Command {
|
|||||||
String[] args) {
|
String[] args) {
|
||||||
|
|
||||||
// If sender is not a player.
|
// If sender is not a player.
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
|
|
||||||
// Send message.
|
// Send message.
|
||||||
ItemCaseCore.instance.getGenericLogger().message(
|
ItemCaseCore.instance.getGenericLogger().message(
|
||||||
@ -53,7 +53,6 @@ public final class OrderCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cast sender to player.
|
// Cast sender to player.
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Check if player is asking for help.
|
// Check if player is asking for help.
|
||||||
if (this.isAskingForHelp(player, label, args)) {
|
if (this.isAskingForHelp(player, label, args)) {
|
||||||
@ -382,8 +381,6 @@ public final class OrderCommand implements Command {
|
|||||||
* Execute sell command.
|
* Execute sell command.
|
||||||
*
|
*
|
||||||
* @param player Player.
|
* @param player Player.
|
||||||
* @param label Label.
|
|
||||||
* @param args Arguments.
|
|
||||||
*/
|
*/
|
||||||
private void executeSell(Player player) {
|
private void executeSell(Player player) {
|
||||||
|
|
||||||
@ -612,7 +609,7 @@ public final class OrderCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define amount.
|
// Define amount.
|
||||||
int amount = 0;
|
int amount;
|
||||||
|
|
||||||
// Attempt to parse amount.
|
// Attempt to parse amount.
|
||||||
try {
|
try {
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase.commands;
|
package com.gmail.bleedobsidian.itemcase.commands;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.Command;
|
import com.gmail.bleedobsidian.itemcase.Command;
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
||||||
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -38,7 +38,7 @@ public final class StorageCommand implements Command {
|
|||||||
String[] args) {
|
String[] args) {
|
||||||
|
|
||||||
// If sender is not a player.
|
// If sender is not a player.
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player player)) {
|
||||||
|
|
||||||
// Send message.
|
// Send message.
|
||||||
ItemCaseCore.instance.getGenericLogger().message(
|
ItemCaseCore.instance.getGenericLogger().message(
|
||||||
@ -49,7 +49,6 @@ public final class StorageCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cast sender to player.
|
// Cast sender to player.
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
// Check if player is asking for help.
|
// Check if player is asking for help.
|
||||||
if (this.isAskingForHelp(player, label, args)) {
|
if (this.isAskingForHelp(player, label, args)) {
|
||||||
@ -72,7 +71,7 @@ public final class StorageCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The target location.
|
// The target location.
|
||||||
Location target = null;
|
Location target;
|
||||||
|
|
||||||
// Get the players target block.
|
// Get the players target block.
|
||||||
target = player.getTargetBlock(null, 5).getLocation();
|
target = player.getTargetBlock(null, 5).getLocation();
|
||||||
|
@ -16,9 +16,10 @@ package com.gmail.bleedobsidian.itemcase.configurations;
|
|||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ConfigurationFile;
|
import com.gmail.bleedobsidian.itemcase.ConfigurationFile;
|
||||||
import com.gmail.bleedobsidian.itemcase.LanguageTranslator.Language;
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator.Language;
|
||||||
import java.util.ArrayList;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main configuration file for ItemCase.
|
* The main configuration file for ItemCase.
|
||||||
*
|
*
|
||||||
@ -62,7 +63,10 @@ public final class ConfigFile extends ConfigurationFile {
|
|||||||
this.file.getStringList("Materials").forEach((id) -> {
|
this.file.getStringList("Materials").forEach((id) -> {
|
||||||
|
|
||||||
// Add material to list.
|
// Add material to list.
|
||||||
materials.add(Material.getMaterial(id));
|
Material material = Material.getMaterial(id);
|
||||||
|
if (material != null) {
|
||||||
|
materials.add(material);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return list.
|
// Return list.
|
||||||
|
@ -27,7 +27,7 @@ public final class LanguageFile extends ConfigurationFile {
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param Language The language this file is for.
|
* @param language The language this file is for.
|
||||||
*/
|
*/
|
||||||
public LanguageFile(Language language) {
|
public LanguageFile(Language language) {
|
||||||
|
|
||||||
|
@ -19,6 +19,17 @@ import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
|||||||
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
||||||
|
import com.onarandombox.MultiverseCore.utils.FileUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.MemorySection;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -27,14 +38,6 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.apache.commons.multiverse.io.FileUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.configuration.MemorySection;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A configuration file that holds all Itemcase saves for a specific world.
|
* A configuration file that holds all Itemcase saves for a specific world.
|
||||||
@ -66,7 +69,6 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
* Saves the given Itemcase to config.
|
* Saves the given Itemcase to config.
|
||||||
*
|
*
|
||||||
* @param itemcase Itemcase.
|
* @param itemcase Itemcase.
|
||||||
* @throws java.io.IOException
|
|
||||||
*/
|
*/
|
||||||
public void saveItemcase(Itemcase itemcase) throws IOException {
|
public void saveItemcase(Itemcase itemcase) throws IOException {
|
||||||
|
|
||||||
@ -98,7 +100,6 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
|
|
||||||
// If shop has finite storage.
|
// If shop has finite storage.
|
||||||
if (itemcase.getStorageType() == StorageType.FINITE) {
|
if (itemcase.getStorageType() == StorageType.FINITE) {
|
||||||
|
|
||||||
// Serialize inventory.
|
// Serialize inventory.
|
||||||
Map<String, Object> inventory =
|
Map<String, Object> inventory =
|
||||||
this.serializeInventory(itemcase.getStorage());
|
this.serializeInventory(itemcase.getStorage());
|
||||||
@ -136,7 +137,6 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
* Deletes the given Itemcase from config.
|
* Deletes the given Itemcase from config.
|
||||||
*
|
*
|
||||||
* @param itemcase Itemcase.
|
* @param itemcase Itemcase.
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public void deleteItemcase(Itemcase itemcase) throws IOException {
|
public void deleteItemcase(Itemcase itemcase) throws IOException {
|
||||||
|
|
||||||
@ -159,7 +159,6 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
* Attempts to load all itemcases from the config.
|
* Attempts to load all itemcases from the config.
|
||||||
*
|
*
|
||||||
* @return Array list of loaded itemcases.
|
* @return Array list of loaded itemcases.
|
||||||
* @throws java.io.IOException
|
|
||||||
*/
|
*/
|
||||||
public ArrayList<Itemcase> loadItemcases() throws IOException {
|
public ArrayList<Itemcase> loadItemcases() throws IOException {
|
||||||
|
|
||||||
@ -167,7 +166,7 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
this.load(ItemCaseCore.instance);
|
this.load(ItemCaseCore.instance);
|
||||||
|
|
||||||
// Create new array list to store loaded itemcases.
|
// Create new array list to store loaded itemcases.
|
||||||
ArrayList<Itemcase> itemcases = new ArrayList<>();
|
ArrayList<Itemcase> itemCases = new ArrayList<>();
|
||||||
|
|
||||||
// Get the list of keys (itemcase locations).
|
// Get the list of keys (itemcase locations).
|
||||||
Set<String> keys =
|
Set<String> keys =
|
||||||
@ -201,8 +200,7 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
|
|
||||||
// Get ItemStack.
|
// Get ItemStack.
|
||||||
Map<String, Object> itemstackMap =
|
Map<String, Object> itemstackMap =
|
||||||
this.file.getConfigurationSection(key + "itemstack")
|
this.file.getConfigurationSection(key + "itemstack").getValues(true);
|
||||||
.getValues(true);
|
|
||||||
ItemStack itemstack = ItemStack.deserialize(itemstackMap);
|
ItemStack itemstack = ItemStack.deserialize(itemstackMap);
|
||||||
|
|
||||||
// Create itemcase object.
|
// Create itemcase object.
|
||||||
@ -224,7 +222,7 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
// If itemcase has finite storage.
|
// If itemcase has finite storage.
|
||||||
if (storageType == StorageType.FINITE) {
|
if (storageType == StorageType.FINITE) {
|
||||||
|
|
||||||
// Deserialse inventory.
|
// De-serialise inventory.
|
||||||
Inventory inventory = this.deserializeInventory(
|
Inventory inventory = this.deserializeInventory(
|
||||||
this.file.getConfigurationSection(
|
this.file.getConfigurationSection(
|
||||||
key + "shop.storage").getValues(false));
|
key + "shop.storage").getValues(false));
|
||||||
@ -257,19 +255,17 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add to list.
|
// Add to list.
|
||||||
itemcases.add(itemcase);
|
itemCases.add(itemcase);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return list of loaded itemcases.
|
// Return list of loaded itemcases.
|
||||||
return itemcases;
|
return itemCases;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete directory and config.
|
* Delete directory and config.
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public void deleteDirectory() throws IOException {
|
public void deleteDirectory() {
|
||||||
|
|
||||||
// Create file reference.
|
// Create file reference.
|
||||||
File fileReference = new File(ItemCaseCore.instance.getDataFolder(),
|
File fileReference = new File(ItemCaseCore.instance.getDataFolder(),
|
||||||
@ -279,7 +275,7 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
this.file = null;
|
this.file = null;
|
||||||
|
|
||||||
// Delete directory.
|
// Delete directory.
|
||||||
FileUtils.deleteDirectory(fileReference);
|
FileUtils.deleteFolder(fileReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -291,13 +287,13 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
private Map<String, Object> serializeInventory(Inventory inventory) {
|
private Map<String, Object> serializeInventory(Inventory inventory) {
|
||||||
|
|
||||||
// Create map.
|
// Create map.
|
||||||
Map<String, Object> map = new HashMap();
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
|
||||||
// Set size.
|
// Set size.
|
||||||
map.put("size", inventory.getSize());
|
map.put("size", inventory.getSize());
|
||||||
|
|
||||||
// Set name.
|
// Set name.
|
||||||
map.put("name", inventory.getName());
|
map.put("name", ((Entity) inventory).getName());
|
||||||
|
|
||||||
// Loop through all content slots.
|
// Loop through all content slots.
|
||||||
for (int i = 0; i < inventory.getSize(); i++) {
|
for (int i = 0; i < inventory.getSize(); i++) {
|
||||||
@ -349,8 +345,7 @@ public final class WorldFile extends ConfigurationFile {
|
|||||||
MemorySection section = (MemorySection) entry.getValue();
|
MemorySection section = (MemorySection) entry.getValue();
|
||||||
|
|
||||||
// Deserialize item.
|
// Deserialize item.
|
||||||
ItemStack item = ItemStack.deserialize((Map<String, Object>)
|
ItemStack item = ItemStack.deserialize(section.getValues(true));
|
||||||
section.getValues(true));
|
|
||||||
|
|
||||||
// Set item in slot.
|
// Set item in slot.
|
||||||
inventory.setItem(slot, item);
|
inventory.setItem(slot, item);
|
||||||
|
@ -16,10 +16,11 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase.loggers;
|
package com.gmail.bleedobsidian.itemcase.loggers;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A custom logger used to add color to the console when using warnings and
|
* A custom logger used to add color to the console when using warnings and
|
||||||
|
@ -20,10 +20,6 @@ import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
|||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
||||||
import com.gmail.bleedobsidian.itemcase.configurations.WorldFile;
|
import com.gmail.bleedobsidian.itemcase.configurations.WorldFile;
|
||||||
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
|
import com.onarandombox.MultiverseCore.event.MVWorldDeleteEvent;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -35,6 +31,11 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
|||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A manager of all Itemcases in a server. This manager is also responsible
|
* A manager of all Itemcases in a server. This manager is also responsible
|
||||||
* for loading and saving Itemcases to a config.
|
* for loading and saving Itemcases to a config.
|
||||||
@ -308,10 +309,9 @@ public final class ItemcaseManager {
|
|||||||
ItemcaseManager.this.worldFiles.entrySet()) {
|
ItemcaseManager.this.worldFiles.entrySet()) {
|
||||||
|
|
||||||
// Check if world name matches.
|
// Check if world name matches.
|
||||||
if(entry.getKey().getName() == worldName) {
|
if (entry.getKey().getName().equals(worldName)) {
|
||||||
|
|
||||||
// Attempt to delete config.
|
// Attempt to delete config.
|
||||||
try {
|
|
||||||
|
|
||||||
// Set world file.
|
// Set world file.
|
||||||
worldFile = entry.getValue();
|
worldFile = entry.getValue();
|
||||||
@ -319,13 +319,7 @@ public final class ItemcaseManager {
|
|||||||
// Delete config.
|
// Delete config.
|
||||||
entry.getValue().deleteDirectory();
|
entry.getValue().deleteDirectory();
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
|
|
||||||
// Log error.
|
|
||||||
ItemCaseCore.instance.getConsoleLogger().severe(
|
|
||||||
"Failed to delete itemcase config for world:"
|
|
||||||
+ worldName, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,13 +327,13 @@ public final class ItemcaseManager {
|
|||||||
ItemcaseManager.this.worldFiles.values().remove(worldFile);
|
ItemcaseManager.this.worldFiles.values().remove(worldFile);
|
||||||
|
|
||||||
// List to store itemcases of this world.
|
// List to store itemcases of this world.
|
||||||
ArrayList<Itemcase> itemcases = new ArrayList();
|
ArrayList<Itemcase> itemcases = new ArrayList<>();
|
||||||
|
|
||||||
// For every itemcase.
|
// For every itemcase.
|
||||||
for (Itemcase itemcase : ItemcaseManager.this.itemcases) {
|
for (Itemcase itemcase : ItemcaseManager.this.itemcases) {
|
||||||
|
|
||||||
// Check if itemcase was in deleted world.
|
// Check if itemcase was in deleted world.
|
||||||
if(itemcase.getLocation().getWorld().getName() == worldName) {
|
if (itemcase.getLocation().getWorld().getName().equals(worldName)) {
|
||||||
|
|
||||||
// Despawn item.
|
// Despawn item.
|
||||||
itemcase.despawnItem();
|
itemcase.despawnItem();
|
||||||
@ -357,7 +351,7 @@ public final class ItemcaseManager {
|
|||||||
public void onInventoryCloseEvent(InventoryCloseEvent event) {
|
public void onInventoryCloseEvent(InventoryCloseEvent event) {
|
||||||
|
|
||||||
// Get inventory name.
|
// Get inventory name.
|
||||||
String name = event.getInventory().getName();
|
String name = event.getView().getTitle();
|
||||||
|
|
||||||
// If inventory is Itemcase inventory.
|
// If inventory is Itemcase inventory.
|
||||||
if (!name.equals(Itemcase.INVENTORY_NAME)) {
|
if (!name.equals(Itemcase.INVENTORY_NAME)) {
|
||||||
|
@ -14,15 +14,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.gmail.bleedobsidian.itemcase.managers;
|
package com.gmail.bleedobsidian.itemcase.managers;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
||||||
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
||||||
import java.util.HashMap;
|
import com.gmail.bleedobsidian.itemcase.loggers.ChatLogger;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages all active Itemcase orders.
|
* Manages all active Itemcase orders.
|
||||||
*
|
*
|
||||||
@ -33,7 +34,7 @@ public final class OrderManager {
|
|||||||
/**
|
/**
|
||||||
* HashMap of players and their active orders.
|
* HashMap of players and their active orders.
|
||||||
*/
|
*/
|
||||||
private final HashMap<Player, ItemcaseOrder> orders = new HashMap();
|
private final HashMap<Player, ItemcaseOrder> orders = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new order.
|
* Create new order.
|
||||||
@ -152,7 +153,7 @@ public final class OrderManager {
|
|||||||
/**
|
/**
|
||||||
* An order for a specific itemcase of some amount.
|
* An order for a specific itemcase of some amount.
|
||||||
*/
|
*/
|
||||||
public final class ItemcaseOrder {
|
public static final class ItemcaseOrder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The itemcase this order is for.
|
* The itemcase this order is for.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#-------------------- ItemCase Configuration File --------------------#
|
#-------------------- ItemCase Configuration File -----------------#
|
||||||
# This file contains all of the ItemCase configuration settings that #
|
# This file contains all the ItemCase configuration settings that #
|
||||||
# can be altered. #
|
# can be altered. #
|
||||||
#---------------------------------------------------------------------#
|
#------------------------------------------------------------------#
|
||||||
|
|
||||||
# Locale:
|
# Locale:
|
||||||
# - EN
|
# - EN
|
||||||
@ -10,7 +10,55 @@ Locale: EN
|
|||||||
# Materials that can be used for ItemCases.
|
# Materials that can be used for ItemCases.
|
||||||
# https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
|
# https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
|
||||||
Materials:
|
Materials:
|
||||||
- 'STEP' # Slabs.
|
- 'ACACIA_SLAB'
|
||||||
- 'STONE_SLAB2' # Red Sandstone Slabs.
|
- 'ANDESITE_SLAB'
|
||||||
- 'WOOD_STEP' # Wooden Slabs.
|
- 'BIRCH_SLAB'
|
||||||
- 'PURPUR_SLAB' # Purpur Slabs.
|
- 'BLACKSTONE_SLAB'
|
||||||
|
- 'BRICK_SLAB'
|
||||||
|
- 'COBBLED_DEEPSLATE_SLAB'
|
||||||
|
- 'COBBLESTONE_SLAB'
|
||||||
|
- 'CRIMSON_SLAB'
|
||||||
|
- 'CUT_COPPER_SLAB'
|
||||||
|
- 'CUT_RED_SANDSTONE_SLAB'
|
||||||
|
- 'CUT_SANDSTONE_SLAB'
|
||||||
|
- 'DARK_OAK_SLAB'
|
||||||
|
- 'DARK_PRISMARINE_SLAB'
|
||||||
|
- 'DEEPSLATE_BRICK_SLAB'
|
||||||
|
- 'DEEPSLATE_TILE_SLAB'
|
||||||
|
- 'DIORITE_SLAB'
|
||||||
|
- 'END_STONE_BRICK_SLAB'
|
||||||
|
- 'EXPOSED_CUT_COPPER_SLAB'
|
||||||
|
- 'GRANITE_SLAB'
|
||||||
|
- 'JUNGLE_SLAB'
|
||||||
|
- 'MOSSY_COBBLESTONE_SLAB'
|
||||||
|
- 'MOSSY_STONE_BRICK_SLAB'
|
||||||
|
- 'NETHER_BRICK_SLAB'
|
||||||
|
- 'OAK_SLAB'
|
||||||
|
- 'OXIDIZED_CUT_COPPER_SLAB'
|
||||||
|
- 'PETRIFIED_OAK_SLAB'
|
||||||
|
- 'POLISHED_ANDESITE_SLAB'
|
||||||
|
- 'POLISHED_BLACKSTONE_BRICK_SLAB'
|
||||||
|
- 'POLISHED_BLACKSTONE_SLAB'
|
||||||
|
- 'POLISHED_DEEPSLATE_SLAB'
|
||||||
|
- 'POLISHED_DIORITE_SLAB'
|
||||||
|
- 'POLISHED_GRANITE_SLAB'
|
||||||
|
- 'PRISMARINE_BRICK_SLAB'
|
||||||
|
- 'PRISMARINE_SLAB'
|
||||||
|
- 'PURPUR_SLAB'
|
||||||
|
- 'QUARTZ_SLAB'
|
||||||
|
- 'RED_NETHER_BRICK_SLAB'
|
||||||
|
- 'RED_SANDSTONE_SLAB'
|
||||||
|
- 'SANDSTONE_SLAB'
|
||||||
|
- 'SMOOTH_QUARTZ_SLAB'
|
||||||
|
- 'SMOOTH_RED_SANDSTONE_SLAB'
|
||||||
|
- 'SMOOTH_SANDSTONE_SLAB'
|
||||||
|
- 'SMOOTH_STONE_SLAB'
|
||||||
|
- 'SPRUCE_SLAB'
|
||||||
|
- 'STONE_BRICK_SLAB'
|
||||||
|
- 'STONE_SLAB'
|
||||||
|
- 'WARPED_SLAB'
|
||||||
|
- 'WAXED_CUT_COPPER_SLAB'
|
||||||
|
- 'WAXED_EXPOSED_CUT_COPPER_SLAB'
|
||||||
|
- 'WAXED_OXIDIZED_CUT_COPPER_SLAB'
|
||||||
|
- 'WAXED_WEATHERED_CUT_COPPER_SLAB'
|
||||||
|
- 'WEATHERED_CUT_COPPER_SLAB'
|
@ -1,10 +1,12 @@
|
|||||||
name: ItemCase
|
name: ItemCase
|
||||||
version: 2.0.1
|
version: 3.0.0
|
||||||
description: ItemCase is a Bukkit plugin allowing you to showcase items on slabs, that can also be used as shops.
|
description: ItemCase is a Bukkit plugin allowing you to showcase items on slabs, that can also be used as shops.
|
||||||
load: POSTWORLD
|
load: POSTWORLD
|
||||||
softdepend: [WorldGuard, Vault]
|
softdepend: [ WorldGuard, Vault, Multiverse-Core ]
|
||||||
author: BleedObsidian
|
author: EpicKnarvik97
|
||||||
website: http://dev.bukkit.org/bukkit-plugins/itemcase/
|
authors: [ BleedObsidian, EpicKnarvik97 ]
|
||||||
|
website: https://git.knarcraft.net
|
||||||
|
api-version: 1.17
|
||||||
database: false
|
database: false
|
||||||
prefix: ItemCase
|
prefix: ItemCase
|
||||||
|
|
||||||
|
@ -1,245 +0,0 @@
|
|||||||
/*
|
|
||||||
* ItemCase is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
|
|
||||||
*/
|
|
||||||
package com.gmail.bleedobsidian.itemcase;
|
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.ItemcaseTask;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Matchers.anyInt;
|
|
||||||
import static org.mockito.Matchers.anyString;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
|
||||||
import static org.powermock.api.mockito.PowerMockito.whenNew;
|
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit test for {@link com.gmail.bleedobsidian.itemcase.Itemcase}
|
|
||||||
*
|
|
||||||
* @author Jesse Prescott (BleedObsidian).
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest(Itemcase.class)
|
|
||||||
public class ItemcaseTest {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The material of the itemcase
|
|
||||||
*/
|
|
||||||
private Material itemcaseMaterial;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a valid itemcase.
|
|
||||||
*
|
|
||||||
* @return Itemcase.
|
|
||||||
*/
|
|
||||||
private Itemcase createValidItemcase() throws Exception {
|
|
||||||
|
|
||||||
// Itemcase type.
|
|
||||||
Type type = Type.SHOP_MULTI;
|
|
||||||
|
|
||||||
// Mock ItemMeta.
|
|
||||||
ItemMeta meta = PowerMockito.mock(ItemMeta.class);
|
|
||||||
|
|
||||||
// Mock itemstack.
|
|
||||||
ItemStack itemstack = PowerMockito.mock(ItemStack.class);
|
|
||||||
|
|
||||||
// When clone method is called, return mock itemstack.
|
|
||||||
when(itemstack.clone()).thenReturn(itemstack);
|
|
||||||
|
|
||||||
// Return mock item meta.
|
|
||||||
when(itemstack.getItemMeta()).thenReturn(meta);
|
|
||||||
|
|
||||||
// Mock world.
|
|
||||||
World world = PowerMockito.mock(World.class);
|
|
||||||
|
|
||||||
// Mock block.
|
|
||||||
Block block = PowerMockito.mock(Block.class);
|
|
||||||
|
|
||||||
// Return material.
|
|
||||||
when(block.getType()).thenReturn(this.itemcaseMaterial);
|
|
||||||
|
|
||||||
// Mock location.
|
|
||||||
Location location = PowerMockito.mock(Location.class);
|
|
||||||
|
|
||||||
// Return mock world when asked for.
|
|
||||||
when(location.getWorld()).thenReturn(world);
|
|
||||||
|
|
||||||
// Return mock block.
|
|
||||||
when(location.getBlock()).thenReturn(block);
|
|
||||||
|
|
||||||
// Mock chunk.
|
|
||||||
Chunk chunk = PowerMockito.mock(Chunk.class);
|
|
||||||
|
|
||||||
// When asking for the chunk from location, return mock.
|
|
||||||
when(location.getChunk()).thenReturn(chunk);
|
|
||||||
|
|
||||||
// Mock player.
|
|
||||||
OfflinePlayer player = PowerMockito.mock(OfflinePlayer.class);
|
|
||||||
|
|
||||||
// Create new itemcase to test.
|
|
||||||
Itemcase itemcase = new Itemcase(type, itemstack, location, player);
|
|
||||||
|
|
||||||
// Test type is correct.
|
|
||||||
assertEquals(itemcase.getType(), type);
|
|
||||||
|
|
||||||
// Test itemstack is correct.
|
|
||||||
assertEquals(itemcase.getItemStack(), itemstack);
|
|
||||||
|
|
||||||
// Verify itemstack amount was set to 1.
|
|
||||||
verify(itemstack).setAmount(1);
|
|
||||||
|
|
||||||
// Test owner is correct.
|
|
||||||
assertEquals(itemcase.getOwner(), player);
|
|
||||||
|
|
||||||
// Return itemcase.
|
|
||||||
return itemcase;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void constructor_valid_pass() throws Exception {
|
|
||||||
|
|
||||||
// Create itemcase.
|
|
||||||
Itemcase itemcase = this.createValidItemcase();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void constructor_nullType_exception() {
|
|
||||||
|
|
||||||
// Mock itemstack.
|
|
||||||
ItemStack itemstack = PowerMockito.mock(ItemStack.class);
|
|
||||||
|
|
||||||
// When clone method is called, return mock itemstack.
|
|
||||||
when(itemstack.clone()).thenReturn(itemstack);
|
|
||||||
|
|
||||||
// Mock location.
|
|
||||||
Location location = PowerMockito.mock(Location.class);
|
|
||||||
|
|
||||||
// Mock chunk.
|
|
||||||
Chunk chunk = PowerMockito.mock(Chunk.class);
|
|
||||||
|
|
||||||
// When asking for the chunk from location, return mock.
|
|
||||||
when(location.getChunk()).thenReturn(chunk);
|
|
||||||
|
|
||||||
// Mock player.
|
|
||||||
OfflinePlayer player = PowerMockito.mock(OfflinePlayer.class);
|
|
||||||
|
|
||||||
// Create object.
|
|
||||||
new Itemcase(null, itemstack, location, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void constructor_nullItemStack_exception() {
|
|
||||||
|
|
||||||
// Itemcase type.
|
|
||||||
Type type = Type.SHOP_MULTI;
|
|
||||||
|
|
||||||
// Mock location.
|
|
||||||
Location location = PowerMockito.mock(Location.class);
|
|
||||||
|
|
||||||
// Mock chunk.
|
|
||||||
Chunk chunk = PowerMockito.mock(Chunk.class);
|
|
||||||
|
|
||||||
// When asking for the chunk from location, return mock.
|
|
||||||
when(location.getChunk()).thenReturn(chunk);
|
|
||||||
|
|
||||||
// Mock player.
|
|
||||||
OfflinePlayer player = PowerMockito.mock(OfflinePlayer.class);
|
|
||||||
|
|
||||||
// Create itemcase.
|
|
||||||
new Itemcase(type, null, location, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void constructor_nullLocation_exception() {
|
|
||||||
|
|
||||||
// Itemcase type.
|
|
||||||
Type type = Type.SHOP_MULTI;
|
|
||||||
|
|
||||||
// Mock itemstack.
|
|
||||||
ItemStack itemstack = PowerMockito.mock(ItemStack.class);
|
|
||||||
|
|
||||||
// When clone method is called, return mock itemstack.
|
|
||||||
when(itemstack.clone()).thenReturn(itemstack);
|
|
||||||
|
|
||||||
// Mock player.
|
|
||||||
OfflinePlayer player = PowerMockito.mock(OfflinePlayer.class);
|
|
||||||
|
|
||||||
// Create itemcase.
|
|
||||||
new Itemcase(type, itemstack, null, player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void constructor_nullOwner_exception() {
|
|
||||||
|
|
||||||
// Itemcase type.
|
|
||||||
Type type = Type.SHOP_MULTI;
|
|
||||||
|
|
||||||
// Mock itemstack.
|
|
||||||
ItemStack itemstack = PowerMockito.mock(ItemStack.class);
|
|
||||||
|
|
||||||
// When clone method is called, return mock itemstack.
|
|
||||||
when(itemstack.clone()).thenReturn(itemstack);
|
|
||||||
|
|
||||||
// Mock location.
|
|
||||||
Location location = PowerMockito.mock(Location.class);
|
|
||||||
|
|
||||||
// Mock chunk.
|
|
||||||
Chunk chunk = PowerMockito.mock(Chunk.class);
|
|
||||||
|
|
||||||
// When asking for the chunk from location, return mock.
|
|
||||||
when(location.getChunk()).thenReturn(chunk);
|
|
||||||
|
|
||||||
// Create itemcase.
|
|
||||||
new Itemcase(type, itemstack, location, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawnItem_taskStarted_pass() throws Exception {
|
|
||||||
|
|
||||||
// Create valid itemcase.
|
|
||||||
Itemcase itemcase = this.createValidItemcase();
|
|
||||||
|
|
||||||
// Create mock bukkit runnable.
|
|
||||||
ItemcaseTask runnable = PowerMockito.mock(ItemcaseTask.class);
|
|
||||||
|
|
||||||
// When creating a new bukkit runnable (as done so inside of spawnItem
|
|
||||||
// return a mock.
|
|
||||||
whenNew(ItemcaseTask.class).withAnyArguments().thenReturn(runnable);
|
|
||||||
|
|
||||||
// Pretend chunk is loaded.
|
|
||||||
when(itemcase.getLocation().getWorld().isChunkLoaded(
|
|
||||||
any(Chunk.class))).thenReturn(true);
|
|
||||||
|
|
||||||
// Spawn item.
|
|
||||||
itemcase.spawnItem();
|
|
||||||
|
|
||||||
// verify task was started.
|
|
||||||
verify(runnable)
|
|
||||||
.runTaskTimer(any(JavaPlugin.class), anyInt(), anyInt());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user