aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml30
-rw-r--r--src/main/java/com/leonardobishop/quests/Quests.java23
-rw-r--r--src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java23
-rw-r--r--src/main/java/com/leonardobishop/quests/blocktype/SimilarBlocks.java186
-rw-r--r--src/main/java/com/leonardobishop/quests/bstats/Metrics.java233
-rw-r--r--src/main/java/com/leonardobishop/quests/obj/misc/QMenuCancel.java2
-rw-r--r--src/main/java/com/leonardobishop/quests/obj/misc/creator/QMenuCreator.java56
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java20
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java6
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java7
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java5
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java7
-rw-r--r--src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java18
-rw-r--r--src/main/resources/config.yml16
-rw-r--r--src/main/resources/plugin.yml1
-rw-r--r--src/main/resources/quests/example1.yml2
-rw-r--r--src/main/resources/quests/example2.yml2
-rw-r--r--src/main/resources/quests/example3.yml4
-rw-r--r--src/main/resources/quests/example5.yml2
-rw-r--r--src/main/resources/quests/example6.yml2
20 files changed, 303 insertions, 342 deletions
diff --git a/pom.xml b/pom.xml
index 1012ee42..1b369703 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
<groupId>com.leonardobishop</groupId>
<artifactId>quests</artifactId>
- <version>2.5</version>
+ <version>2.6</version>
<name>Quests</name>
<properties>
@@ -55,7 +55,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
- <version>1.12.2-R0.1-SNAPSHOT</version>
+ <version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
@@ -92,27 +92,6 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
-
-
- <!-- &lt;!&ndash; Test &ndash;&gt;-->
-<!-- <dependency>-->
-<!-- <groupId>org.powermock</groupId>-->
-<!-- <artifactId>powermock-module-junit4</artifactId>-->
-<!-- <version>2.0.0</version>-->
-<!-- <scope>test</scope>-->
-<!-- </dependency>-->
-<!-- <dependency>-->
-<!-- <groupId>org.powermock</groupId>-->
-<!-- <artifactId>powermock-api-mockito2</artifactId>-->
-<!-- <version>2.0.0</version>-->
-<!-- <scope>test</scope>-->
-<!-- </dependency>-->
-<!-- <dependency>-->
-<!-- <groupId>junit</groupId>-->
-<!-- <artifactId>junit</artifactId>-->
-<!-- <version>4.11</version>-->
-<!-- <scope>test</scope>-->
-<!-- </dependency>-->
</dependencies>
<build>
@@ -136,11 +115,6 @@
</configuration>
</plugin>
-<!-- <plugin>-->
-<!-- <groupId>org.apache.maven.plugins</groupId>-->
-<!-- <artifactId>maven-surefire-plugin</artifactId>-->
-<!-- </plugin>-->
-
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
diff --git a/src/main/java/com/leonardobishop/quests/Quests.java b/src/main/java/com/leonardobishop/quests/Quests.java
index bef7e659..933d6cfc 100644
--- a/src/main/java/com/leonardobishop/quests/Quests.java
+++ b/src/main/java/com/leonardobishop/quests/Quests.java
@@ -21,7 +21,6 @@ import com.leonardobishop.quests.title.Title_Bukkit;
import com.leonardobishop.quests.title.Title_BukkitNoTimings;
import com.leonardobishop.quests.title.Title_Other;
import com.leonardobishop.quests.updater.Updater;
-import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -132,7 +131,9 @@ public class Quests extends JavaPlugin {
Bukkit.getPluginManager().registerEvents(new EventPlayerLeave(this), this);
metrics = new Metrics(this);
- this.getLogger().log(Level.INFO, "Metrics started. This can be disabled at /plugins/bStats/config.yml.");
+ if (metrics.isEnabled()) {
+ this.getLogger().log(Level.INFO, "Metrics started. This can be disabled at /plugins/bStats/config.yml.");
+ }
questsConfigLoader = new QuestsConfigLoader(Quests.this);
@@ -270,24 +271,8 @@ public class Quests extends JavaPlugin {
}
}
name = ChatColor.translateAlternateColorCodes('&', cName);
+ type = Material.matchMaterial(cType);
- if (StringUtils.isNumeric(cType)) {
- type = Material.getMaterial(Integer.parseInt(cType));
- } else if (Material.getMaterial(cType) != null) {
- type = Material.getMaterial(cType);
- } else if (cType.contains(":")) {
- String[] parts = cType.split(":");
- if (parts.length > 1) {
- if (StringUtils.isNumeric(parts[0])) {
- type = Material.getMaterial(Integer.parseInt(parts[0]));
- } else if (Material.getMaterial(parts[0]) != null) {
- type = Material.getMaterial(parts[0]);
- }
- if (StringUtils.isNumeric(parts[1])) {
- data = Integer.parseInt(parts[1]);
- }
- }
- }
if (type == null) {
type = Material.STONE;
diff --git a/src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java b/src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java
index 96cff812..3b45b523 100644
--- a/src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java
+++ b/src/main/java/com/leonardobishop/quests/QuestsConfigLoader.java
@@ -85,10 +85,6 @@ public class QuestsConfigLoader {
int sortOrder = config.getInt("options.sort-order", 1);
String category = config.getString("options.category");
- if (rewardString == null) rewardString = new ArrayList<>();
- if (startString == null) startString = new ArrayList<>();
- if (requirements == null) requirements = new ArrayList<>();
- if (rewards == null) rewards = new ArrayList<>();
if (category == null) category = "";
Quest quest;
@@ -156,23 +152,8 @@ public class QuestsConfigLoader {
}
name = ChatColor.translateAlternateColorCodes('&', cName);
- if (StringUtils.isNumeric(cType)) {
- type = Material.getMaterial(Integer.parseInt(cType));
- } else if (Material.getMaterial(cType) != null) {
- type = Material.getMaterial(cType);
- } else if (cType.contains(":")) {
- String[] parts = cType.split(":");
- if (parts.length > 1) {
- if (StringUtils.isNumeric(parts[0])) {
- type = Material.getMaterial(Integer.parseInt(parts[0]));
- } else if (Material.getMaterial(parts[0]) != null) {
- type = Material.getMaterial(parts[0]);
- }
- if (StringUtils.isNumeric(parts[1])) {
- data = Integer.parseInt(parts[1]);
- }
- }
- }
+ type = Material.matchMaterial(cType);
+
if (type == null) {
type = Material.STONE;
diff --git a/src/main/java/com/leonardobishop/quests/blocktype/SimilarBlocks.java b/src/main/java/com/leonardobishop/quests/blocktype/SimilarBlocks.java
index 4e6571d4..fc910170 100644
--- a/src/main/java/com/leonardobishop/quests/blocktype/SimilarBlocks.java
+++ b/src/main/java/com/leonardobishop/quests/blocktype/SimilarBlocks.java
@@ -1,93 +1,93 @@
-package com.leonardobishop.quests.blocktype;
-
-import org.bukkit.Material;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class SimilarBlocks {
-
- private static HashMap<Block, Block> similarBlocks = new HashMap<>();
-
- static {
- // Redstone Ore
- similarBlocks.put(new Block(Material.REDSTONE_ORE), new Block(Material.GLOWING_REDSTONE_ORE));
- similarBlocks.put(new Block(Material.GLOWING_REDSTONE_ORE), new Block(Material.REDSTONE_ORE));
-
- // Oak Door
- similarBlocks.put(new Block(Material.WOODEN_DOOR, (short) 0), new Block(Material.WOODEN_DOOR));
- similarBlocks.put(new Block(Material.WOODEN_DOOR, (short) 1), new Block(Material.WOODEN_DOOR));
- similarBlocks.put(new Block(Material.WOODEN_DOOR, (short) 2), new Block(Material.WOODEN_DOOR));
- similarBlocks.put(new Block(Material.WOODEN_DOOR, (short) 3), new Block(Material.WOODEN_DOOR));
-
- // Dark Oak Door
- similarBlocks.put(new Block(Material.DARK_OAK_DOOR, (short) 0), new Block(Material.DARK_OAK_DOOR));
- similarBlocks.put(new Block(Material.DARK_OAK_DOOR, (short) 1), new Block(Material.DARK_OAK_DOOR));
- similarBlocks.put(new Block(Material.DARK_OAK_DOOR, (short) 2), new Block(Material.DARK_OAK_DOOR));
- similarBlocks.put(new Block(Material.DARK_OAK_DOOR, (short) 3), new Block(Material.DARK_OAK_DOOR));
-
- // Acacia Door
- similarBlocks.put(new Block(Material.ACACIA_DOOR, (short) 0), new Block(Material.ACACIA_DOOR));
- similarBlocks.put(new Block(Material.ACACIA_DOOR, (short) 1), new Block(Material.ACACIA_DOOR));
- similarBlocks.put(new Block(Material.ACACIA_DOOR, (short) 2), new Block(Material.ACACIA_DOOR));
- similarBlocks.put(new Block(Material.ACACIA_DOOR, (short) 3), new Block(Material.ACACIA_DOOR));
-
- // Birch Door
- similarBlocks.put(new Block(Material.BIRCH_DOOR, (short) 0), new Block(Material.BIRCH_DOOR));
- similarBlocks.put(new Block(Material.BIRCH_DOOR, (short) 1), new Block(Material.BIRCH_DOOR));
- similarBlocks.put(new Block(Material.BIRCH_DOOR, (short) 2), new Block(Material.BIRCH_DOOR));
- similarBlocks.put(new Block(Material.BIRCH_DOOR, (short) 3), new Block(Material.BIRCH_DOOR));
-
- // Jungle Door
- similarBlocks.put(new Block(Material.JUNGLE_DOOR, (short) 0), new Block(Material.JUNGLE_DOOR));
- similarBlocks.put(new Block(Material.JUNGLE_DOOR, (short) 1), new Block(Material.JUNGLE_DOOR));
- similarBlocks.put(new Block(Material.JUNGLE_DOOR, (short) 2), new Block(Material.JUNGLE_DOOR));
- similarBlocks.put(new Block(Material.JUNGLE_DOOR, (short) 3), new Block(Material.JUNGLE_DOOR));
-
- // Spruce Door
- similarBlocks.put(new Block(Material.SPRUCE_DOOR, (short) 0), new Block(Material.SPRUCE_DOOR));
- similarBlocks.put(new Block(Material.SPRUCE_DOOR, (short) 1), new Block(Material.SPRUCE_DOOR));
- similarBlocks.put(new Block(Material.SPRUCE_DOOR, (short) 2), new Block(Material.SPRUCE_DOOR));
- similarBlocks.put(new Block(Material.SPRUCE_DOOR, (short) 3), new Block(Material.SPRUCE_DOOR));
-
- // Iron Door
- similarBlocks.put(new Block(Material.IRON_DOOR, (short) 0), new Block(Material.IRON_DOOR));
- similarBlocks.put(new Block(Material.IRON_DOOR, (short) 1), new Block(Material.IRON_DOOR));
- similarBlocks.put(new Block(Material.IRON_DOOR, (short) 2), new Block(Material.IRON_DOOR));
- similarBlocks.put(new Block(Material.IRON_DOOR, (short) 3), new Block(Material.IRON_DOOR));
-
- // Oak Log
- similarBlocks.put(new Block(Material.LOG, (short) 4), new Block(Material.LOG, (short) 0));
- similarBlocks.put(new Block(Material.LOG, (short) 8), new Block(Material.LOG, (short) 0));
-
- // Spruce Log
- similarBlocks.put(new Block(Material.LOG, (short) 5), new Block(Material.LOG, (short) 1));
- similarBlocks.put(new Block(Material.LOG, (short) 9), new Block(Material.LOG, (short) 1));
-
- // Birch Log
- similarBlocks.put(new Block(Material.LOG, (short) 6), new Block(Material.LOG, (short) 2));
- similarBlocks.put(new Block(Material.LOG, (short) 10), new Block(Material.LOG, (short) 2));
-
- // Jungle Log
- similarBlocks.put(new Block(Material.LOG, (short) 7), new Block(Material.LOG, (short) 3));
- similarBlocks.put(new Block(Material.LOG, (short) 11), new Block(Material.LOG, (short) 3));
-
- // Acacia Log
- similarBlocks.put(new Block(Material.LOG_2, (short) 4), new Block(Material.LOG, (short) 0));
- similarBlocks.put(new Block(Material.LOG_2, (short) 8), new Block(Material.LOG, (short) 0));
-
- // Dark Oak Log
- similarBlocks.put(new Block(Material.LOG_2, (short) 5), new Block(Material.LOG, (short) 1));
- similarBlocks.put(new Block(Material.LOG_2, (short) 9), new Block(Material.LOG, (short) 1));
- }
-
- public static Block getSimilarBlock(Block block) {
- for (Map.Entry<Block, Block> entry : similarBlocks.entrySet()) {
- if (entry.getKey().getMaterial() == block.getMaterial() && entry.getKey().getData() == block.getData()) {
- return entry.getValue();
- }
- }
- return null;
- }
-
-}
+//package com.leonardobishop.quests.blocktype;
+//
+//import org.bukkit.Material;
+//
+//import java.util.HashMap;
+//import java.util.Map;
+//
+//public class SimilarBlocks {
+//
+// private static HashMap<Block, Block> similarBlocks = new HashMap<>();
+//
+// static {
+// // Redstone Ore
+// similarBlocks.put(new Block(Material.REDSTONE_ORE), new Block(Material.GLOWING_REDSTONE_ORE));
+// similarBlocks.put(new Block(Material.GLOWING_REDSTONE_ORE), new Block(Material.REDSTONE_ORE));
+//
+// // Oak Door
+// similarBlocks.put(new Block(Material.WOODEN_DOOR, (short) 0), new Block(Material.WOODEN_DOOR));
+// similarBlocks.put(new Block(Material.WOODEN_DOOR, (short) 1), new Block(Material.WOODEN_DOOR));
+// similarBlocks.put(new Block(Material.WOODEN_DOOR, (short) 2), new Block(Material.WOODEN_DOOR));
+// similarBlocks.put(new Block(Material.WOODEN_DOOR, (short) 3), new Block(Material.WOODEN_DOOR));
+//
+// // Dark Oak Door
+// similarBlocks.put(new Block(Material.DARK_OAK_DOOR, (short) 0), new Block(Material.DARK_OAK_DOOR));
+// similarBlocks.put(new Block(Material.DARK_OAK_DOOR, (short) 1), new Block(Material.DARK_OAK_DOOR));
+// similarBlocks.put(new Block(Material.DARK_OAK_DOOR, (short) 2), new Block(Material.DARK_OAK_DOOR));
+// similarBlocks.put(new Block(Material.DARK_OAK_DOOR, (short) 3), new Block(Material.DARK_OAK_DOOR));
+//
+// // Acacia Door
+// similarBlocks.put(new Block(Material.ACACIA_DOOR, (short) 0), new Block(Material.ACACIA_DOOR));
+// similarBlocks.put(new Block(Material.ACACIA_DOOR, (short) 1), new Block(Material.ACACIA_DOOR));
+// similarBlocks.put(new Block(Material.ACACIA_DOOR, (short) 2), new Block(Material.ACACIA_DOOR));
+// similarBlocks.put(new Block(Material.ACACIA_DOOR, (short) 3), new Block(Material.ACACIA_DOOR));
+//
+// // Birch Door
+// similarBlocks.put(new Block(Material.BIRCH_DOOR, (short) 0), new Block(Material.BIRCH_DOOR));
+// similarBlocks.put(new Block(Material.BIRCH_DOOR, (short) 1), new Block(Material.BIRCH_DOOR));
+// similarBlocks.put(new Block(Material.BIRCH_DOOR, (short) 2), new Block(Material.BIRCH_DOOR));
+// similarBlocks.put(new Block(Material.BIRCH_DOOR, (short) 3), new Block(Material.BIRCH_DOOR));
+//
+// // Jungle Door
+// similarBlocks.put(new Block(Material.JUNGLE_DOOR, (short) 0), new Block(Material.JUNGLE_DOOR));
+// similarBlocks.put(new Block(Material.JUNGLE_DOOR, (short) 1), new Block(Material.JUNGLE_DOOR));
+// similarBlocks.put(new Block(Material.JUNGLE_DOOR, (short) 2), new Block(Material.JUNGLE_DOOR));
+// similarBlocks.put(new Block(Material.JUNGLE_DOOR, (short) 3), new Block(Material.JUNGLE_DOOR));
+//
+// // Spruce Door
+// similarBlocks.put(new Block(Material.SPRUCE_DOOR, (short) 0), new Block(Material.SPRUCE_DOOR));
+// similarBlocks.put(new Block(Material.SPRUCE_DOOR, (short) 1), new Block(Material.SPRUCE_DOOR));
+// similarBlocks.put(new Block(Material.SPRUCE_DOOR, (short) 2), new Block(Material.SPRUCE_DOOR));
+// similarBlocks.put(new Block(Material.SPRUCE_DOOR, (short) 3), new Block(Material.SPRUCE_DOOR));
+//
+// // Iron Door
+// similarBlocks.put(new Block(Material.IRON_DOOR, (short) 0), new Block(Material.IRON_DOOR));
+// similarBlocks.put(new Block(Material.IRON_DOOR, (short) 1), new Block(Material.IRON_DOOR));
+// similarBlocks.put(new Block(Material.IRON_DOOR, (short) 2), new Block(Material.IRON_DOOR));
+// similarBlocks.put(new Block(Material.IRON_DOOR, (short) 3), new Block(Material.IRON_DOOR));
+//
+// // Oak Log
+// similarBlocks.put(new Block(Material.LOG, (short) 4), new Block(Material.LOG, (short) 0));
+// similarBlocks.put(new Block(Material.LOG, (short) 8), new Block(Material.LOG, (short) 0));
+//
+// // Spruce Log
+// similarBlocks.put(new Block(Material.LOG, (short) 5), new Block(Material.LOG, (short) 1));
+// similarBlocks.put(new Block(Material.LOG, (short) 9), new Block(Material.LOG, (short) 1));
+//
+// // Birch Log
+// similarBlocks.put(new Block(Material.LOG, (short) 6), new Block(Material.LOG, (short) 2));
+// similarBlocks.put(new Block(Material.LOG, (short) 10), new Block(Material.LOG, (short) 2));
+//
+// // Jungle Log
+// similarBlocks.put(new Block(Material.LOG, (short) 7), new Block(Material.LOG, (short) 3));
+// similarBlocks.put(new Block(Material.LOG, (short) 11), new Block(Material.LOG, (short) 3));
+//
+// // Acacia Log
+// similarBlocks.put(new Block(Material.LOG_2, (short) 4), new Block(Material.LOG, (short) 0));
+// similarBlocks.put(new Block(Material.LOG_2, (short) 8), new Block(Material.LOG, (short) 0));
+//
+// // Dark Oak Log
+// similarBlocks.put(new Block(Material.LOG_2, (short) 5), new Block(Material.LOG, (short) 1));
+// similarBlocks.put(new Block(Material.LOG_2, (short) 9), new Block(Material.LOG, (short) 1));
+// }
+//
+// public static Block getSimilarBlock(Block block) {
+// for (Map.Entry<Block, Block> entry : similarBlocks.entrySet()) {
+// if (entry.getKey().getMaterial() == block.getMaterial() && entry.getKey().getData() == block.getData()) {
+// return entry.getValue();
+// }
+// }
+// return null;
+// }
+//
+//}
diff --git a/src/main/java/com/leonardobishop/quests/bstats/Metrics.java b/src/main/java/com/leonardobishop/quests/bstats/Metrics.java
index a84fea79..88ae12f3 100644
--- a/src/main/java/com/leonardobishop/quests/bstats/Metrics.java
+++ b/src/main/java/com/leonardobishop/quests/bstats/Metrics.java
@@ -1,22 +1,21 @@
package com.leonardobishop.quests.bstats;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.ServicePriority;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.json.simple.JSONArray;
-import org.json.simple.JSONObject;
import javax.net.ssl.HttpsURLConnection;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.IOException;
+import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.logging.Level;
@@ -24,9 +23,10 @@ import java.util.zip.GZIPOutputStream;
/**
* bStats collects some data for plugin authors.
- *
+ * <p>
* Check out https://bStats.org/ to learn more about bStats!
*/
+@SuppressWarnings({"WeakerAccess", "unused"})
public class Metrics {
static {
@@ -49,14 +49,23 @@ public class Metrics {
// The url to which the data is sent
private static final String URL = "https://bStats.org/submitData/bukkit";
+ // Is bStats enabled on this server?
+ private boolean enabled;
+
// Should failed requests be logged?
private static boolean logFailedRequests;
+ // Should the sent data be logged?
+ private static boolean logSentData;
+
+ // Should the response text be logged?
+ private static boolean logResponseStatusText;
+
// The uuid of the server
private static String serverUUID;
// The plugin
- private final JavaPlugin plugin;
+ private final Plugin plugin;
// A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>();
@@ -66,7 +75,7 @@ public class Metrics {
*
* @param plugin The plugin which stats should be submitted.
*/
- public Metrics(JavaPlugin plugin) {
+ public Metrics(Plugin plugin) {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null!");
}
@@ -86,6 +95,10 @@ public class Metrics {
config.addDefault("serverUuid", UUID.randomUUID().toString());
// Should failed request be logged?
config.addDefault("logFailedRequests", false);
+ // Should the sent data be logged?
+ config.addDefault("logSentData", false);
+ // Should the response text be logged?
+ config.addDefault("logResponseStatusText", false);
// Inform the server owners about bStats
config.options().header(
@@ -100,9 +113,13 @@ public class Metrics {
}
// Load the data
+ enabled = config.getBoolean("enabled", true);
serverUUID = config.getString("serverUuid");
logFailedRequests = config.getBoolean("logFailedRequests", false);
- if (config.getBoolean("enabled", true)) {
+ logSentData = config.getBoolean("logSentData", false);
+ logResponseStatusText = config.getBoolean("logResponseStatusText", false);
+
+ if (enabled) {
boolean found = false;
// Search for all other bStats Metrics classes to see if we are the first one
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
@@ -122,6 +139,15 @@ public class Metrics {
}
/**
+ * Checks if bStats is enabled.
+ *
+ * @return Whether bStats is enabled or not.
+ */
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ /**
* Adds a custom chart.
*
* @param chart The chart to add.
@@ -147,14 +173,9 @@ public class Metrics {
}
// Nevertheless we want our code to run in the Bukkit main thread, so we have to use the Bukkit scheduler
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
- Bukkit.getScheduler().runTask(plugin, new Runnable() {
- @Override
- public void run() {
- submitData();
- }
- });
+ Bukkit.getScheduler().runTask(plugin, () -> submitData());
}
- }, 1000*60*5, 1000*60*30);
+ }, 1000 * 60 * 5, 1000 * 60 * 30);
// Submit the data every 30 minutes, first time after 5 minutes to give other plugins enough time to start
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
// WARNING: Just don't do it!
@@ -166,24 +187,24 @@ public class Metrics {
*
* @return The plugin specific data.
*/
- public JSONObject getPluginData() {
- JSONObject data = new JSONObject();
+ public JsonObject getPluginData() {
+ JsonObject data = new JsonObject();
String pluginName = plugin.getDescription().getName();
String pluginVersion = plugin.getDescription().getVersion();
- data.put("pluginName", pluginName); // Append the name of the plugin
- data.put("pluginVersion", pluginVersion); // Append the version of the plugin
- JSONArray customCharts = new JSONArray();
+ data.addProperty("pluginName", pluginName); // Append the name of the plugin
+ data.addProperty("pluginVersion", pluginVersion); // Append the version of the plugin
+ JsonArray customCharts = new JsonArray();
for (CustomChart customChart : charts) {
// Add the data of the custom charts
- JSONObject chart = customChart.getRequestJsonObject();
+ JsonObject chart = customChart.getRequestJsonObject();
if (chart == null) { // If the chart is null, we skip it
continue;
}
customCharts.add(chart);
}
- data.put("customCharts", customCharts);
+ data.add("customCharts", customCharts);
return data;
}
@@ -193,7 +214,7 @@ public class Metrics {
*
* @return The server specific data.
*/
- private JSONObject getServerData() {
+ private JsonObject getServerData() {
// Minecraft specific data
int playerAmount;
try {
@@ -207,8 +228,8 @@ public class Metrics {
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
}
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
- String bukkitVersion = org.bukkit.Bukkit.getVersion();
- bukkitVersion = bukkitVersion.substring(bukkitVersion.indexOf("MC: ") + 4, bukkitVersion.length() - 1);
+ String bukkitVersion = Bukkit.getVersion();
+ String bukkitName = Bukkit.getName();
// OS/Java specific data
String javaVersion = System.getProperty("java.version");
@@ -217,19 +238,20 @@ public class Metrics {
String osVersion = System.getProperty("os.version");
int coreCount = Runtime.getRuntime().availableProcessors();
- JSONObject data = new JSONObject();
+ JsonObject data = new JsonObject();
- data.put("serverUUID", serverUUID);
+ data.addProperty("serverUUID", serverUUID);
- data.put("playerAmount", playerAmount);
- data.put("onlineMode", onlineMode);
- data.put("bukkitVersion", bukkitVersion);
+ data.addProperty("playerAmount", playerAmount);
+ data.addProperty("onlineMode", onlineMode);
+ data.addProperty("bukkitVersion", bukkitVersion);
+ data.addProperty("bukkitName", bukkitName);
- data.put("javaVersion", javaVersion);
- data.put("osName", osName);
- data.put("osArch", osArch);
- data.put("osVersion", osVersion);
- data.put("coreCount", coreCount);
+ data.addProperty("javaVersion", javaVersion);
+ data.addProperty("osName", osName);
+ data.addProperty("osArch", osArch);
+ data.addProperty("osVersion", osVersion);
+ data.addProperty("coreCount", coreCount);
return data;
}
@@ -238,9 +260,9 @@ public class Metrics {
* Collects the data and sends it afterwards.
*/
private void submitData() {
- final JSONObject data = getServerData();
+ final JsonObject data = getServerData();
- JSONArray pluginData = new JSONArray();
+ JsonArray pluginData = new JsonArray();
// Search for all other bStats Metrics classes to get their plugin data
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
@@ -248,13 +270,33 @@ public class Metrics {
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
- pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
+ Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider());
+ if (plugin instanceof JsonObject) {
+ pluginData.add((JsonObject) plugin);
+ } else { // old bstats version compatibility
+ try {
+ Class<?> jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject");
+ if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) {
+ Method jsonStringGetter = jsonObjectJsonSimple.getDeclaredMethod("toJSONString");
+ jsonStringGetter.setAccessible(true);
+ String jsonString = (String) jsonStringGetter.invoke(plugin);
+ JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
+ pluginData.add(object);
+ }
+ } catch (ClassNotFoundException e) {
+ // minecraft version 1.14+
+ if (logFailedRequests) {
+ this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e);
+ }
+ continue; // continue looping since we cannot do any other thing.
+ }
+ }
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
}
} catch (NoSuchFieldException ignored) { }
}
- data.put("plugins", pluginData);
+ data.add("plugins", pluginData);
// Create a new thread for the connection to the bStats server
new Thread(new Runnable() {
@@ -262,7 +304,7 @@ public class Metrics {
public void run() {
try {
// Send the data
- sendData(data);
+ sendData(plugin, data);
} catch (Exception e) {
// Something went wrong! :(
if (logFailedRequests) {
@@ -276,16 +318,20 @@ public class Metrics {
/**
* Sends the data to the bStats server.
*
+ * @param plugin Any plugin. It's just used to get a logger instance.
* @param data The data to send.
* @throws Exception If the request failed.
*/
- private static void sendData(JSONObject data) throws Exception {
+ private static void sendData(Plugin plugin, JsonObject data) throws Exception {
if (data == null) {
throw new IllegalArgumentException("Data cannot be null!");
}
if (Bukkit.isPrimaryThread()) {
throw new IllegalAccessException("This method must not be called from the main thread!");
}
+ if (logSentData) {
+ plugin.getLogger().info("Sending data to bStats: " + data.toString());
+ }
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
// Compress the data to save bandwidth
@@ -307,7 +353,18 @@ public class Metrics {
outputStream.flush();
outputStream.close();
- connection.getInputStream().close(); // We don't care about the response - Just send our data :)
+ InputStream inputStream = connection.getInputStream();
+ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
+
+ StringBuilder builder = new StringBuilder();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ builder.append(line);
+ }
+ bufferedReader.close();
+ if (logResponseStatusText) {
+ plugin.getLogger().info("Sent data to bStats and received response: " + builder.toString());
+ }
}
/**
@@ -323,7 +380,7 @@ public class Metrics {
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
- gzip.write(str.getBytes("UTF-8"));
+ gzip.write(str.getBytes(StandardCharsets.UTF_8));
gzip.close();
return outputStream.toByteArray();
}
@@ -348,16 +405,16 @@ public class Metrics {
this.chartId = chartId;
}
- private JSONObject getRequestJsonObject() {
- JSONObject chart = new JSONObject();
- chart.put("chartId", chartId);
+ private JsonObject getRequestJsonObject() {
+ JsonObject chart = new JsonObject();
+ chart.addProperty("chartId", chartId);
try {
- JSONObject data = getChartData();
+ JsonObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
- chart.put("data", data);
+ chart.add("data", data);
} catch (Throwable t) {
if (logFailedRequests) {
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
@@ -367,7 +424,7 @@ public class Metrics {
return chart;
}
- protected abstract JSONObject getChartData() throws Exception;
+ protected abstract JsonObject getChartData() throws Exception;
}
@@ -390,14 +447,14 @@ public class Metrics {
}
@Override
- protected JSONObject getChartData() throws Exception {
- JSONObject data = new JSONObject();
+ protected JsonObject getChartData() throws Exception {
+ JsonObject data = new JsonObject();
String value = callable.call();
if (value == null || value.isEmpty()) {
// Null = skip the chart
return null;
}
- data.put("value", value);
+ data.addProperty("value", value);
return data;
}
}
@@ -421,9 +478,9 @@ public class Metrics {
}
@Override
- protected JSONObject getChartData() throws Exception {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
+ protected JsonObject getChartData() throws Exception {
+ JsonObject data = new JsonObject();
+ JsonObject values = new JsonObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
@@ -435,13 +492,13 @@ public class Metrics {
continue; // Skip this invalid
}
allSkipped = false;
- values.put(entry.getKey(), entry.getValue());
+ values.addProperty(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
- data.put("values", values);
+ data.add("values", values);
return data;
}
}
@@ -465,9 +522,9 @@ public class Metrics {
}
@Override
- public JSONObject getChartData() throws Exception {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
+ public JsonObject getChartData() throws Exception {
+ JsonObject data = new JsonObject();
+ JsonObject values = new JsonObject();
Map<String, Map<String, Integer>> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
@@ -475,22 +532,22 @@ public class Metrics {
}
boolean reallyAllSkipped = true;
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
- JSONObject value = new JSONObject();
+ JsonObject value = new JsonObject();
boolean allSkipped = true;
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
- value.put(valueEntry.getKey(), valueEntry.getValue());
+ value.addProperty(valueEntry.getKey(), valueEntry.getValue());
allSkipped = false;
}
if (!allSkipped) {
reallyAllSkipped = false;
- values.put(entryValues.getKey(), value);
+ values.add(entryValues.getKey(), value);
}
}
if (reallyAllSkipped) {
// Null = skip the chart
return null;
}
- data.put("values", values);
+ data.add("values", values);
return data;
}
}
@@ -514,14 +571,14 @@ public class Metrics {
}
@Override
- protected JSONObject getChartData() throws Exception {
- JSONObject data = new JSONObject();
+ protected JsonObject getChartData() throws Exception {
+ JsonObject data = new JsonObject();
int value = callable.call();
if (value == 0) {
// Null = skip the chart
return null;
}
- data.put("value", value);
+ data.addProperty("value", value);
return data;
}
@@ -546,9 +603,9 @@ public class Metrics {
}
@Override
- protected JSONObject getChartData() throws Exception {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
+ protected JsonObject getChartData() throws Exception {
+ JsonObject data = new JsonObject();
+ JsonObject values = new JsonObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
@@ -560,13 +617,13 @@ public class Metrics {
continue; // Skip this invalid
}
allSkipped = false;
- values.put(entry.getKey(), entry.getValue());
+ values.addProperty(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
- data.put("values", values);
+ data.add("values", values);
return data;
}
@@ -591,20 +648,20 @@ public class Metrics {
}
@Override
- protected JSONObject getChartData() throws Exception {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
+ protected JsonObject getChartData() throws Exception {
+ JsonObject data = new JsonObject();
+ JsonObject values = new JsonObject();
Map<String, Integer> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
return null;
}
for (Map.Entry<String, Integer> entry : map.entrySet()) {
- JSONArray categoryValues = new JSONArray();
+ JsonArray categoryValues = new JsonArray();
categoryValues.add(entry.getValue());
- values.put(entry.getKey(), categoryValues);
+ values.add(entry.getKey(), categoryValues);
}
- data.put("values", values);
+ data.add("values", values);
return data;
}
@@ -629,9 +686,9 @@ public class Metrics {
}
@Override
- protected JSONObject getChartData() throws Exception {
- JSONObject data = new JSONObject();
- JSONObject values = new JSONObject();
+ protected JsonObject getChartData() throws Exception {
+ JsonObject data = new JsonObject();
+ JsonObject values = new JsonObject();
Map<String, int[]> map = callable.call();
if (map == null || map.isEmpty()) {
// Null = skip the chart
@@ -643,19 +700,19 @@ public class Metrics {
continue; // Skip this invalid
}
allSkipped = false;
- JSONArray categoryValues = new JSONArray();
+ JsonArray categoryValues = new JsonArray();
for (int categoryValue : entry.getValue()) {
categoryValues.add(categoryValue);
}
- values.put(entry.getKey(), categoryValues);
+ values.add(entry.getKey(), categoryValues);
}
if (allSkipped) {
// Null = skip the chart
return null;
}
- data.put("values", values);
+ data.add("values", values);
return data;
}
-
}
+
} \ No newline at end of file
diff --git a/src/main/java/com/leonardobishop/quests/obj/misc/QMenuCancel.java b/src/main/java/com/leonardobishop/quests/obj/misc/QMenuCancel.java
index abebb17d..f705fe53 100644
--- a/src/main/java/com/leonardobishop/quests/obj/misc/QMenuCancel.java
+++ b/src/main/java/com/leonardobishop/quests/obj/misc/QMenuCancel.java
@@ -52,7 +52,7 @@ public class QMenuCancel implements QMenu {
ItemStack yes = Items.QUEST_CANCEL_YES.getItem();
ItemStack no = Items.QUEST_CANCEL_NO.getItem();
- ItemStack is = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 7);
+ ItemStack is = new ItemStack(Material.RED_STAINED_GLASS_PANE);
ItemMeta ism = is.getItemMeta();
ism.setDisplayName(" ");
is.setItemMeta(ism);
diff --git a/src/main/java/com/leonardobishop/quests/obj/misc/creator/QMenuCreator.java b/src/main/java/com/leonardobishop/quests/obj/misc/creator/QMenuCreator.java
index 86fffd12..235bc23e 100644
--- a/src/main/java/com/leonardobishop/quests/obj/misc/creator/QMenuCreator.java
+++ b/src/main/java/com/leonardobishop/quests/obj/misc/creator/QMenuCreator.java
@@ -35,34 +35,34 @@ public class QMenuCreator implements QMenu {
String title = "Quest Creator";
Inventory inventory = Bukkit.createInventory(null, 9, title);
-
- ItemStack newQuest = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
- ItemMeta newQuestM = newQuest.getItemMeta();
- List<String> newQuestL = new ArrayList<>();
- newQuestM.setDisplayName(ChatColor.GREEN.toString() + ChatColor.BOLD + "New Quest");
- newQuestL.add(ChatColor.GRAY + "Click to make a new quest.");
- newQuestM.setLore(newQuestL);
- newQuest.setItemMeta(newQuestM);
-
- ItemStack editQuest = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 1);
- ItemMeta editQuestM = editQuest.getItemMeta();
- List<String> editQuestL = new ArrayList<>();
- editQuestM.setDisplayName(ChatColor.GREEN.toString() + ChatColor.BOLD + "Edit Quest");
- editQuestL.add(ChatColor.GRAY + "Click to edit an existing quest.");
- editQuestM.setLore(editQuestL);
- editQuest.setItemMeta(editQuestM);
-
- ItemStack removeQuest = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
- ItemMeta removeQuestM = removeQuest.getItemMeta();
- List<String> removeQuestL = new ArrayList<>();
- removeQuestM.setDisplayName(ChatColor.GREEN.toString() + ChatColor.BOLD + "Delete Quest");
- removeQuestL.add(ChatColor.GRAY + "Click to delete an existing quest.");
- removeQuestM.setLore(removeQuestL);
- removeQuest.setItemMeta(removeQuestM);
-
- inventory.setItem(2, newQuest);
- inventory.setItem(4, editQuest);
- inventory.setItem(6, removeQuest);
+//
+// ItemStack newQuest = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 5);
+// ItemMeta newQuestM = newQuest.getItemMeta();
+// List<String> newQuestL = new ArrayList<>();
+// newQuestM.setDisplayName(ChatColor.GREEN.toString() + ChatColor.BOLD + "New Quest");
+// newQuestL.add(ChatColor.GRAY + "Click to make a new quest.");
+// newQuestM.setLore(newQuestL);
+// newQuest.setItemMeta(newQuestM);
+//
+// ItemStack editQuest = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 1);
+// ItemMeta editQuestM = editQuest.getItemMeta();
+// List<String> editQuestL = new ArrayList<>();
+// editQuestM.setDisplayName(ChatColor.GREEN.toString() + ChatColor.BOLD + "Edit Quest");
+// editQuestL.add(ChatColor.GRAY + "Click to edit an existing quest.");
+// editQuestM.setLore(editQuestL);
+// editQuest.setItemMeta(editQuestM);
+//
+// ItemStack removeQuest = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
+// ItemMeta removeQuestM = removeQuest.getItemMeta();
+// List<String> removeQuestL = new ArrayList<>();
+// removeQuestM.setDisplayName(ChatColor.GREEN.toString() + ChatColor.BOLD + "Delete Quest");
+// removeQuestL.add(ChatColor.GRAY + "Click to delete an existing quest.");
+// removeQuestM.setLore(removeQuestL);
+// removeQuest.setItemMeta(removeQuestM);
+//
+// inventory.setItem(2, newQuest);
+// inventory.setItem(4, editQuest);
+// inventory.setItem(6, removeQuest);
return inventory;
}
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java
index 2e680490..fcd4b08a 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/BuildingCertainTaskType.java
@@ -1,8 +1,6 @@
package com.leonardobishop.quests.quests.tasktypes.types;
import com.leonardobishop.quests.QuestsAPI;
-import com.leonardobishop.quests.blocktype.Block;
-import com.leonardobishop.quests.blocktype.SimilarBlocks;
import com.leonardobishop.quests.player.QPlayer;
import com.leonardobishop.quests.player.questprogressfile.QuestProgress;
import com.leonardobishop.quests.player.questprogressfile.QuestProgressFile;
@@ -11,7 +9,6 @@ import com.leonardobishop.quests.quests.Quest;
import com.leonardobishop.quests.quests.Task;
import com.leonardobishop.quests.quests.tasktypes.ConfigValue;
import com.leonardobishop.quests.quests.tasktypes.TaskType;
-import org.apache.commons.lang.StringUtils;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -29,7 +26,7 @@ public final class BuildingCertainTaskType extends TaskType {
this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of blocks to be placed."));
this.creatorConfigValues.add(new ConfigValue("block", true, "Name or ID of block."));
this.creatorConfigValues.add(new ConfigValue("data", false, "Data code for block."));
- this.creatorConfigValues.add(new ConfigValue("use-similar-blocks", false, "If true, this will ignore orientation of doors, logs etc."));
+ this.creatorConfigValues.add(new ConfigValue("use-similar-blocks", false, "(Deprecated) If true, this will ignore orientation of doors, logs etc."));
}
@Override
@@ -58,23 +55,12 @@ public final class BuildingCertainTaskType extends TaskType {
Object configData = task.getConfigValue("data");
Object configSimilarBlocks = task.getConfigValue("use-similar-blocks");
- if (StringUtils.isNumeric(String.valueOf(configBlock))) {
- material = Material.getMaterial((int) configBlock);
- } else {
- material = Material.getMaterial(String.valueOf(configBlock));
- }
+ material = Material.matchMaterial(String.valueOf(configBlock));
+
Material blockType = event.getBlock().getType();
short blockData = event.getBlock().getData();
- if (configSimilarBlocks != null && ((Boolean) configSimilarBlocks)) {
- Block block;
- if ((block = SimilarBlocks.getSimilarBlock(new Block(blockType, blockData))) != null) {
- blockType = block.getMaterial();
- blockData = block.getData();
- }
- }
-
if (blockType.equals(material)) {
if (configData != null && (((int) blockData) != ((int) configData))) {
continue;
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java
index 224176bf..6c0635fe 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/CitizensDeliverTaskType.java
@@ -79,11 +79,7 @@ public final class CitizensDeliverTaskType extends TaskType {
Object configData = task.getConfigValue("data");
Object remove = task.getConfigValue("remove-items-when-complete");
- if (StringUtils.isNumeric(String.valueOf(configBlock))) {
- material = Material.getMaterial((int) configBlock);
- } else {
- material = Material.getMaterial(String.valueOf(configBlock));
- }
+ material = Material.matchMaterial(String.valueOf(configBlock));
if (material == null) {
continue;
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java
index 1e190d11..b96a57ea 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FarmingTaskType.java
@@ -60,11 +60,8 @@ public final class FarmingTaskType extends TaskType {
Object configBlock = task.getConfigValue("block");
Object configData = task.getConfigValue("data");
- if (StringUtils.isNumeric(String.valueOf(configBlock))) {
- material = Material.getMaterial((int) configBlock);
- } else {
- material = Material.getMaterial(String.valueOf(configBlock));
- }
+ material = Material.matchMaterial(String.valueOf(configBlock));
+
if (material != null && event.getBlock().getType().equals(material)) {
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java
index 4cd43fbf..96840e2f 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/FishingTaskType.java
@@ -35,13 +35,12 @@ public final class FishingTaskType extends TaskType {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFishCaught(PlayerFishEvent event) {
- if (event.getState() == PlayerFishEvent.State.BITE) {
+ if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH) {
return;
}
Location hookLocation = event.getHook().getLocation().add(0, -1, 0);
- if (!(hookLocation.getBlock().getType() == Material.STATIONARY_WATER ||
- hookLocation.getBlock().getType() == Material.WATER)) {
+ if (!(hookLocation.getBlock().getType() == Material.WATER)) {
return;
}
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java
index 080f9073..97710a96 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/InventoryTaskType.java
@@ -85,11 +85,8 @@ public final class InventoryTaskType extends TaskType {
Object configData = task.getConfigValue("data");
Object remove = task.getConfigValue("remove-items-when-complete");
- if (StringUtils.isNumeric(String.valueOf(configBlock))) {
- material = Material.getMaterial((int) configBlock);
- } else {
- material = Material.getMaterial(String.valueOf(configBlock));
- }
+ material = Material.matchMaterial(String.valueOf(configBlock));
+
if (material == null) {
continue;
diff --git a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java
index 8ee5a84e..544c5341 100644
--- a/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java
+++ b/src/main/java/com/leonardobishop/quests/quests/tasktypes/types/MiningCertainTaskType.java
@@ -2,7 +2,6 @@ package com.leonardobishop.quests.quests.tasktypes.types;
import com.leonardobishop.quests.QuestsAPI;
import com.leonardobishop.quests.blocktype.Block;
-import com.leonardobishop.quests.blocktype.SimilarBlocks;
import com.leonardobishop.quests.player.QPlayer;
import com.leonardobishop.quests.player.questprogressfile.QuestProgress;
import com.leonardobishop.quests.player.questprogressfile.QuestProgressFile;
@@ -29,7 +28,7 @@ public final class MiningCertainTaskType extends TaskType {
this.creatorConfigValues.add(new ConfigValue("amount", true, "Amount of blocks to be broken."));
this.creatorConfigValues.add(new ConfigValue("block", true, "Name or ID of block."));
this.creatorConfigValues.add(new ConfigValue("data", false, "Data code for block."));
- this.creatorConfigValues.add(new ConfigValue("use-similar-blocks", false, "If true, this will ignore orientation of doors, logs etc."));
+ this.creatorConfigValues.add(new ConfigValue("use-similar-blocks", false, "(Deprecated) If true, this will ignore orientation of doors, logs etc."));
}
@Override
@@ -58,23 +57,12 @@ public final class MiningCertainTaskType extends TaskType {
Object configData = task.getConfigValue("data");
Object configSimilarBlocks = task.getConfigValue("use-similar-blocks");
- if (StringUtils.isNumeric(String.valueOf(configBlock))) {
- material = Material.getMaterial((int) configBlock);
- } else {
- material = Material.getMaterial(String.valueOf(configBlock));
- }
+ material = Material.matchMaterial(String.valueOf(configBlock));
+
Material blockType = event.getBlock().getType();
short blockData = event.getBlock().getData();
- if (configSimilarBlocks != null && ((Boolean) configSimilarBlocks)) {
- Block block;
- if ((block = SimilarBlocks.getSimilarBlock(new Block(blockType, blockData))) != null) {
- blockType = block.getMaterial();
- blockData = block.getData();
- }
- }
-
if (blockType.equals(material)) {
if (configData != null && (((int) blockData) != ((int) configData))) {
continue;
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index b5a5273e..83e9977c 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -36,7 +36,7 @@ categories:
- "&cIt is highly recommended you read this"
- "&csection and all the comments so you can"
- "&cmake the most of this plugin."
- type: "327"
+ type: "WATER_BUCKET"
permissionexample:
display:
name: "&cPermission Example"
@@ -47,7 +47,7 @@ categories:
- "&cIt is highly recommended you read this"
- "&csection and all the comments so you can"
- "&cmake the most of this plugin."
- type: "327"
+ type: "WATER_BUCKET"
# This category needs the permission "quests.category.permissionexample", because the category ID is 'permissionexample'.
# The permission for other categories is: "quests.category.<id>".
permission-required: true
@@ -82,39 +82,39 @@ gui:
- ""
- "&7Requires: &c{requirements}"
- "&7to be completed to unlock."
- type: "160:14"
+ type: "RED_STAINED_GLASS_PANE"
quest-permission-display:
name: "&6&lNo Permission"
lore:
- "&7You do not have permission for this"
- "&7quest (&6{quest}&7)."
- type: "160:12"
+ type: "BROWN_STAINED_GLASS_PANE"
quest-cooldown-display:
name: "&e&lQuest On Cooldown"
lore:
- "&7You have recently completed this quest"
- "&7(&e{quest}&7) and you must"
- "&7wait another &e{time} &7to unlock again."
- type: "160:1"
+ type: "ORANGE_STAINED_GLASS_PANE"
quest-completed-display:
name: "&a&lQuest Complete"
lore:
- "&7You have completed this quest"
- "&7(&a{quest}&7) and cannot."
- "&7repeat it."
- type: "160:5"
+ type: "GREEN_STAINED_GLASS_PANE"
quest-cancel-yes:
name: "&a&lConfirm Cancel"
lore:
- "&7Confirm you wish to cancel"
- "&7this quest and lose all"
- "&7progress."
- type: "160:5"
+ type: "GREEN_STAINED_GLASS_PANE"
quest-cancel-no:
name: "&c&lAbort Cancel"
lore:
- "&7Return to the quest menu."
- type: "160:14"
+ type: "RED_STAINED_GLASS_PANE"
options:
# If categories are disabled, quests will be put into one big gui.
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index fd126f77..5cbc933f 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -7,6 +7,7 @@ main: com.leonardobishop.quests.Quests
author: LMBishop
softdepend: [ASkyBlock, uSkyBlock, Citizens]
prefix: Quests
+api-version: 1.14
commands:
quests:
diff --git a/src/main/resources/quests/example1.yml b/src/main/resources/quests/example1.yml
index 82e6e810..eb6b865a 100644
--- a/src/main/resources/quests/example1.yml
+++ b/src/main/resources/quests/example1.yml
@@ -32,7 +32,7 @@ display:
- "&7Your current progression:"
- "&7 - {mining:progress}/30 blocks broken."
# This is the material of the item. It is recommended to stick to bukkit names.
- type: "WOOD_PICKAXE"
+ type: "WOODEN_PICKAXE"
# List all commands to be executed by the server when the player completes the quest. Use {player} to get the players name.
rewards:
diff --git a/src/main/resources/quests/example2.yml b/src/main/resources/quests/example2.yml
index 5b6d2c4e..1ed6c0e1 100644
--- a/src/main/resources/quests/example2.yml
+++ b/src/main/resources/quests/example2.yml
@@ -27,7 +27,7 @@ display:
- "&7Your current progression:"
- "&7 - {mining:progress}/100 blocks broken."
- "&7 - {building:progress}/100 blocks placed."
- type: "GRASS"
+ type: "GRASS_BLOCK"
rewards:
- "give {player} diamond 15"
- "eco give {player} 50"
diff --git a/src/main/resources/quests/example3.yml b/src/main/resources/quests/example3.yml
index 8254a257..29e4f91a 100644
--- a/src/main/resources/quests/example3.yml
+++ b/src/main/resources/quests/example3.yml
@@ -6,11 +6,11 @@ tasks:
mining:
type: "blockbreakcertain"
amount: 81
- block: 14 # (gold ore)
+ block: GOLD_ORE
building:
type: "blockplacecertain"
amount: 9
- block: 41 # (gold blocks)
+ block: GOLD_BLOCK
display:
name: "&cExample III (Repeatable, 10 minute cooldown)"
lore-normal:
diff --git a/src/main/resources/quests/example5.yml b/src/main/resources/quests/example5.yml
index a143d315..bfdc8d94 100644
--- a/src/main/resources/quests/example5.yml
+++ b/src/main/resources/quests/example5.yml
@@ -18,7 +18,7 @@ display:
- ""
- "&7Your current progression:"
- "&7 - {building:progress}/10 blocks placed."
- type: "GRASS"
+ type: "GRASS_BLOCK"
rewards:
- "eco give {player} 10"
options:
diff --git a/src/main/resources/quests/example6.yml b/src/main/resources/quests/example6.yml
index 8d5a8feb..abadba2a 100644
--- a/src/main/resources/quests/example6.yml
+++ b/src/main/resources/quests/example6.yml
@@ -18,7 +18,7 @@ display:
- ""
- "&7Your current progression:"
- "&7 - {building:progress}/10 blocks placed."
- type: "GRASS"
+ type: "GRASS_BLOCK"
rewards:
- "eco give {player} 10"
options: