Merge branch 'development'

This commit is contained in:
Brianna 2020-01-27 08:19:19 -05:00
commit 41d2f5ff29
80 changed files with 631 additions and 1532 deletions

View File

@ -1,19 +0,0 @@
image: gradle:alpine
variables:
path: "/builds/$CI_PROJECT_PATH"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
stages:
- build
build:
stage: build
script:
- gradle build
- mv $path/build/libs/*.jar $path/
artifacts:
paths:
- $path/*.jar

View File

@ -1,4 +0,0 @@
dependencies {
compile project(':UltimateTimber-Core')
compileOnly 'org.spigotmc:spigot:1.14.4'
}

View File

@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>CurrentAdapter</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,4 +0,0 @@
dependencies {
compile project(':UltimateTimber-Core')
compileOnly 'org.spigotmc:spigot:1.12.2'
}

View File

@ -0,0 +1,29 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>LegacyAdapter</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +0,0 @@
dependencies {
compile project(':UltimateTimber-Core')
compileOnly 'org.spigotmc:spigot:1.14.4'
compileOnly 'net:coreprotect:2.17.5'
}

View File

@ -0,0 +1,35 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>CoreProtect</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net</groupId>
<artifactId>coreprotect</artifactId>
<version>2.17.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +0,0 @@
dependencies {
compile project(':UltimateTimber-Core')
compileOnly 'org.spigotmc:spigot:1.14.4'
compileOnly 'com.gamingmesh:jobs:4.13.0'
}

View File

@ -0,0 +1,35 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>Jobs</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.gamingmesh</groupId>
<artifactId>jobs</artifactId>
<version>4.13.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +0,0 @@
dependencies {
compile project(':UltimateTimber-Core')
compileOnly 'org.spigotmc:spigot:1.14.4'
compileOnly 'com.gmail.nossr50:mcmmo:2.1.50'
}

View File

@ -0,0 +1,35 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>McMMO</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.gmail.nossr50</groupId>
<artifactId>mcmmo</artifactId>
<version>2.1.50</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +0,0 @@
dependencies {
compile project(':UltimateTimber-Core')
compileOnly 'org.spigotmc:spigot:1.12.2'
compileOnly 'com.gmail.nossr50:mcmmo:1.5.10'
}

View File

@ -0,0 +1,35 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>McMMOClassic12</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.gmail.nossr50</groupId>
<artifactId>mcmmo</artifactId>
<version>1.5.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +0,0 @@
dependencies {
compile project(':UltimateTimber-Core')
compileOnly 'org.spigotmc:spigot:1.14.4'
compileOnly 'com.gmail.nossr50:mcmmo:1.6.0'
}

View File

@ -0,0 +1,35 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>McMMOClassic13</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.gmail.nossr50</groupId>
<artifactId>mcmmo</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +0,0 @@
dependencies {
compile project(':UltimateTimber-Core')
compileOnly 'org.spigotmc:spigot:1.8.8'
compileOnly 'com.gmail.nossr50:mcmmo:1.5.04'
}

View File

@ -0,0 +1,35 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>McMMOClassic8</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.8.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.gmail.nossr50</groupId>
<artifactId>mcmmo</artifactId>
<version>1.5.04</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,3 +0,0 @@
dependencies {
compileOnly 'org.spigotmc:spigot:1.14'
}

View File

@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>Core</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,707 +0,0 @@
package com.songoda.ultimatetimber.utils;
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.json.simple.JSONArray;
import org.json.simple.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.logging.Level;
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 {
// You can use the property to disable the check in your test environment
if (System.getProperty("bstats.relocatecheck") == null || !System.getProperty("bstats.relocatecheck").equals("false")) {
// Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
final String defaultPackage = new String(
new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.', 'b', 'u', 'k', 'k', 'i', 't'});
final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
// We want to make sure nobody just copy & pastes the example and use the wrong package names
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
}
}
}
// The version of this bStats class
public static final int B_STATS_VERSION = 1;
// 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 Plugin plugin;
// A list with all custom charts
private final List<CustomChart> charts = new ArrayList<>();
/**
* Class constructor.
*
* @param plugin The plugin which stats should be submitted.
*/
public Metrics(Plugin plugin) {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null!");
}
this.plugin = plugin;
// Get the config file
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
File configFile = new File(bStatsFolder, "config.yml");
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
// Check if the config file exists
if (!config.isSet("serverUuid")) {
// Add default values
config.addDefault("enabled", true);
// Every server gets it's unique random id.
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(
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
"To honor their work, you should not disable it.\n" +
"This has nearly no effect on the server performance!\n" +
"Check out https://bStats.org/ to learn more :)"
).copyDefaults(true);
try {
config.save(configFile);
} catch (IOException ignored) { }
}
// Load the data
enabled = config.getBoolean("enabled", true);
serverUUID = config.getString("serverUuid");
logFailedRequests = config.getBoolean("logFailedRequests", false);
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()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
found = true; // We aren't the first
break;
} catch (NoSuchFieldException ignored) { }
}
// Register our service
Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal);
if (!found) {
// We are the first!
startSubmitting();
}
}
}
/**
* 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.
*/
public void addCustomChart(CustomChart chart) {
if (chart == null) {
throw new IllegalArgumentException("Chart cannot be null!");
}
charts.add(chart);
}
/**
* Starts the Scheduler which submits our data every 30 minutes.
*/
private void startSubmitting() {
final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (!plugin.isEnabled()) { // Plugin was disabled
timer.cancel();
return;
}
// 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, () -> submitData());
}
}, 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!
}
/**
* Gets the plugin specific data.
* This method is called using Reflection.
*
* @return The plugin specific data.
*/
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();
for (CustomChart customChart : charts) {
// Add the data of the custom charts
JSONObject chart = customChart.getRequestJsonObject();
if (chart == null) { // If the chart is null, we skip it
continue;
}
customCharts.add(chart);
}
data.put("customCharts", customCharts);
return data;
}
/**
* Gets the server specific data.
*
* @return The server specific data.
*/
private JSONObject getServerData() {
// Minecraft specific data
int playerAmount;
try {
// Around MC 1.8 the return type was changed to a collection from an array,
// This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
} catch (Exception e) {
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
}
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
String bukkitVersion = Bukkit.getVersion();
// OS/Java specific data
String javaVersion = System.getProperty("java.version");
String osName = System.getProperty("os.name");
String osArch = System.getProperty("os.arch");
String osVersion = System.getProperty("os.version");
int coreCount = Runtime.getRuntime().availableProcessors();
JSONObject data = new JSONObject();
data.put("serverUUID", serverUUID);
data.put("playerAmount", playerAmount);
data.put("onlineMode", onlineMode);
data.put("bukkitVersion", bukkitVersion);
data.put("javaVersion", javaVersion);
data.put("osName", osName);
data.put("osArch", osArch);
data.put("osVersion", osVersion);
data.put("coreCount", coreCount);
return data;
}
/**
* Collects the data and sends it afterwards.
*/
private void submitData() {
final JSONObject data = getServerData();
JSONArray pluginData = new JSONArray();
// Search for all other bStats Metrics classes to get their plugin data
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
try {
service.getField("B_STATS_VERSION"); // Our identifier :)
for (RegisteredServiceProvider<?> provider : Bukkit.getServicesManager().getRegistrations(service)) {
try {
pluginData.add(provider.getService().getMethod("getPluginData").invoke(provider.getProvider()));
} catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) { }
}
} catch (NoSuchFieldException ignored) { }
}
data.put("plugins", pluginData);
// Create a new thread for the connection to the bStats server
new Thread(new Runnable() {
@Override
public void run() {
try {
// Send the data
sendData(plugin, data);
} catch (Exception e) {
// Something went wrong! :(
if (logFailedRequests) {
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
}
}
}
}).start();
}
/**
* 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(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
byte[] compressedData = compress(data.toString());
// Add headers
connection.setRequestMethod("POST");
connection.addRequestProperty("Accept", "application/json");
connection.addRequestProperty("Connection", "close");
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
// Send data
connection.setDoOutput(true);
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
outputStream.write(compressedData);
outputStream.flush();
outputStream.close();
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());
}
}
/**
* Gzips the given String.
*
* @param str The string to gzip.
* @return The gzipped String.
* @throws IOException If the compression failed.
*/
private static byte[] compress(final String str) throws IOException {
if (str == null) {
return null;
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
gzip.write(str.getBytes(StandardCharsets.UTF_8));
gzip.close();
return outputStream.toByteArray();
}
/**
* Represents a custom chart.
*/
public static abstract class CustomChart {
// The id of the chart
final String chartId;
/**
* Class constructor.
*
* @param chartId The id of the chart.
*/
CustomChart(String chartId) {
if (chartId == null || chartId.isEmpty()) {
throw new IllegalArgumentException("ChartId cannot be null or empty!");
}
this.chartId = chartId;
}
private JSONObject getRequestJsonObject() {
JSONObject chart = new JSONObject();
chart.put("chartId", chartId);
try {
JSONObject data = getChartData();
if (data == null) {
// If the data is null we don't send the chart.
return null;
}
chart.put("data", data);
} catch (Throwable t) {
if (logFailedRequests) {
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
}
return null;
}
return chart;
}
protected abstract JSONObject getChartData() throws Exception;
}
/**
* Represents a custom simple pie.
*/
public static class SimplePie extends CustomChart {
private final Callable<String> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimplePie(String chartId, Callable<String> callable) {
super(chartId);
this.callable = callable;
}
@Override
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);
return data;
}
}
/**
* Represents a custom advanced pie.
*/
public static class AdvancedPie extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
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;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
continue; // Skip this invalid
}
allSkipped = false;
values.put(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.put("values", values);
return data;
}
}
/**
* Represents a custom drilldown pie.
*/
public static class DrilldownPie extends CustomChart {
private final Callable<Map<String, Map<String, Integer>>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
super(chartId);
this.callable = callable;
}
@Override
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
return null;
}
boolean reallyAllSkipped = true;
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
JSONObject value = new JSONObject();
boolean allSkipped = true;
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
value.put(valueEntry.getKey(), valueEntry.getValue());
allSkipped = false;
}
if (!allSkipped) {
reallyAllSkipped = false;
values.put(entryValues.getKey(), value);
}
}
if (reallyAllSkipped) {
// Null = skip the chart
return null;
}
data.put("values", values);
return data;
}
}
/**
* Represents a custom single line chart.
*/
public static class SingleLineChart extends CustomChart {
private final Callable<Integer> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SingleLineChart(String chartId, Callable<Integer> callable) {
super(chartId);
this.callable = callable;
}
@Override
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);
return data;
}
}
/**
* Represents a custom multi line chart.
*/
public static class MultiLineChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
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;
}
boolean allSkipped = true;
for (Map.Entry<String, Integer> entry : map.entrySet()) {
if (entry.getValue() == 0) {
continue; // Skip this invalid
}
allSkipped = false;
values.put(entry.getKey(), entry.getValue());
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.put("values", values);
return data;
}
}
/**
* Represents a custom simple bar chart.
*/
public static class SimpleBarChart extends CustomChart {
private final Callable<Map<String, Integer>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
super(chartId);
this.callable = callable;
}
@Override
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();
categoryValues.add(entry.getValue());
values.put(entry.getKey(), categoryValues);
}
data.put("values", values);
return data;
}
}
/**
* Represents a custom advanced bar chart.
*/
public static class AdvancedBarChart extends CustomChart {
private final Callable<Map<String, int[]>> callable;
/**
* Class constructor.
*
* @param chartId The id of the chart.
* @param callable The callable which is used to request the chart data.
*/
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
super(chartId);
this.callable = callable;
}
@Override
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
return null;
}
boolean allSkipped = true;
for (Map.Entry<String, int[]> entry : map.entrySet()) {
if (entry.getValue().length == 0) {
continue; // Skip this invalid
}
allSkipped = false;
JSONArray categoryValues = new JSONArray();
for (int categoryValue : entry.getValue()) {
categoryValues.add(categoryValue);
}
values.put(entry.getKey(), categoryValues);
}
if (allSkipped) {
// Null = skip the chart
return null;
}
data.put("values", values);
return data;
}
}
}

View File

@ -1,36 +0,0 @@
import org.apache.tools.ant.filters.ReplaceTokens
configurations {
extraLibs
}
dependencies {
compile project(':UltimateTimber-Core')
compile project(':UltimateTimber-CurrentAdapter')
compile project(':UltimateTimber-LegacyAdapter')
compile project(':UltimateTimber-Jobs')
compile project(':UltimateTimber-McMMO')
compile project(':UltimateTimber-McMMOClassic13')
compile project(':UltimateTimber-McMMOClassic12')
compile project(':UltimateTimber-McMMOClassic8')
compile project(':UltimateTimber-CoreProtect')
compileOnly 'org.spigotmc:spigot:1.14.4'
extraLibs 'com.songoda:songodaupdater:1'
configurations.compileOnly.extendsFrom(configurations.extraLibs)
}
processResources {
from (sourceSets.main.resources.srcDirs) {
include '**/*.yml'
filter ReplaceTokens, tokens: ["version": project.property("version")]
}
}
jar {
from {
configurations.extraLibs.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}

View File

@ -0,0 +1,119 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<parent>
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.4</version>
<relativePath>../../</relativePath>
</parent>
<artifactId>Plugin</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<build>
<finalName>${parent.artifactId}-${parent.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<showDeprecation>false</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>com.songoda.core</pattern>
<shadedPattern>com.songoda.ultimatetimber.core</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>CurrentAdapter</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>LegacyAdapter</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>CoreProtect</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Jobs</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>McMMO</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>McMMOClassic8</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>McMMOClassic12</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>McMMOClassic13</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,17 @@
# General Messages
general.nametag.prefix: "&8[&6UltimateTimber&8] "
general.nopermission: "&cYou don't have permission for that!"
# Command Messages
command.reload.description: "&8 - &a/ut reload &7 - Reloads the config."
command.reload.reloaded: "&7Configuration and locale files have been reloaded."
command.toggle.description: "&8 - &a/ut toggle &7 - Toggles your chopping mode"
command.toggle.enabled: "&7Chopping Mode: &aEnabled"
command.toggle.disabled: "&7Chopping Mode: &cDisabled"
# Misc
event.on.cooldown: "&eYou are on cooldown and cannot topple trees right now."

View File

@ -1,14 +1,16 @@
package com.songoda.ultimatetimber;
import com.songoda.core.SongodaCore;
import com.songoda.core.SongodaPlugin;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.configuration.Config;
import com.songoda.ultimatetimber.adapter.VersionAdapter;
import com.songoda.ultimatetimber.adapter.current.CurrentAdapter;
import com.songoda.ultimatetimber.adapter.legacy.LegacyAdapter;
import com.songoda.ultimatetimber.locale.LocaleModule;
import com.songoda.ultimatetimber.manager.ChoppingManager;
import com.songoda.ultimatetimber.manager.CommandManager;
import com.songoda.ultimatetimber.manager.ConfigurationManager;
import com.songoda.ultimatetimber.manager.HookManager;
import com.songoda.ultimatetimber.manager.LocaleManager;
import com.songoda.ultimatetimber.manager.Manager;
import com.songoda.ultimatetimber.manager.PlacedBlockManager;
import com.songoda.ultimatetimber.manager.SaplingManager;
@ -16,27 +18,19 @@ import com.songoda.ultimatetimber.manager.TreeAnimationManager;
import com.songoda.ultimatetimber.manager.TreeDefinitionManager;
import com.songoda.ultimatetimber.manager.TreeDetectionManager;
import com.songoda.ultimatetimber.manager.TreeFallManager;
import com.songoda.ultimatetimber.utils.Methods;
import com.songoda.ultimatetimber.utils.Metrics;
import com.songoda.ultimatetimber.utils.NMSUtil;
import com.songoda.update.Plugin;
import com.songoda.update.SongodaUpdate;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @author Esophose
*/
public class UltimateTimber extends JavaPlugin {
public class UltimateTimber extends SongodaPlugin {
private static UltimateTimber INSTANCE;
private final CommandSender console = Bukkit.getConsoleSender();
private Set<Manager> managers;
private VersionAdapter versionAdapter;
@ -44,7 +38,6 @@ public class UltimateTimber extends JavaPlugin {
private CommandManager commandManager;
private ConfigurationManager configurationManager;
private HookManager hookManager;
private LocaleManager localeManager;
private PlacedBlockManager placedBlockManager;
private SaplingManager saplingManager;
private TreeAnimationManager treeAnimationManager;
@ -57,20 +50,14 @@ public class UltimateTimber extends JavaPlugin {
}
@Override
public void onEnable() {
public void onPluginLoad() {
INSTANCE = this;
}
this.console.sendMessage(Methods.formatText("&a============================="));
this.console.sendMessage(Methods.formatText("&7" + this.getDescription().getName() + " " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
this.console.sendMessage(Methods.formatText("&7Action: &aEnabling&7..."));
// Songoda Updater
Plugin plugin = new Plugin(this, 18);
plugin.addModule(new LocaleModule());
SongodaUpdate.load(plugin);
// bStats Metrics
new Metrics(this);
@Override
public void onPluginEnable() {
// Run Songoda Updater
SongodaCore.registerPlugin(this, 44, CompatibleMaterial.IRON_AXE);
// Register managers
this.managers = new HashSet<>();
@ -78,7 +65,6 @@ public class UltimateTimber extends JavaPlugin {
this.commandManager = this.registerManager(CommandManager.class);
this.configurationManager = new ConfigurationManager(this);
this.hookManager = this.registerManager(HookManager.class);
this.localeManager = this.registerManager(LocaleManager.class);
this.placedBlockManager = this.registerManager(PlacedBlockManager.class);
this.saplingManager = this.registerManager(SaplingManager.class);
this.treeAnimationManager = this.registerManager(TreeAnimationManager.class);
@ -86,22 +72,27 @@ public class UltimateTimber extends JavaPlugin {
this.treeDetectionManager = this.registerManager(TreeDetectionManager.class);
this.treeFallManager = this.registerManager(TreeFallManager.class);
// Setup Locale
this.setLocale(getConfig().getString("locale"), false);
// Load version adapter and managers
this.setupVersionAdapter();
this.reload();
this.console.sendMessage(Methods.formatText("&a============================="));
}
@Override
public void onDisable() {
this.console.sendMessage(Methods.formatText("&a============================="));
this.console.sendMessage(Methods.formatText("&7" + this.getDescription().getName() + " " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
this.console.sendMessage(Methods.formatText("&7Action: &cDisabling&7..."));
public void onPluginDisable() {
this.disable();
}
this.console.sendMessage(Methods.formatText("&a============================="));
@Override
public void onConfigReload() {
reload();
}
@Override
public List<Config> getExtraConfig() {
return null;
}
/**
@ -110,6 +101,7 @@ public class UltimateTimber extends JavaPlugin {
public void reload() {
this.configurationManager.reload();
this.managers.forEach(Manager::reload);
this.setLocale(getConfig().getString("locale"), true);
}
/**
@ -194,15 +186,6 @@ public class UltimateTimber extends JavaPlugin {
return this.hookManager;
}
/**
* Gets the locale manager
*
* @return The LocaleManager instance
*/
public LocaleManager getLocaleManager() {
return this.localeManager;
}
/**
* Gets the placed block manager
*

View File

@ -85,7 +85,7 @@ public class ChoppingManager extends Manager {
public boolean isInCooldown(Player player) {
boolean cooldowned = this.useCooldown && this.cooldownedPlayers.containsKey(player.getUniqueId());
if (cooldowned && !this.cooldownedPlayers.get(player.getUniqueId())) {
this.ultimateTimber.getLocaleManager().sendPrefixedMessage(player, LocaleManager.Locale.ON_COOLDOWN);
this.plugin.getLocale().getMessage("event.on.cooldown").sendPrefixedMessage(player);
this.cooldownedPlayers.replace(player.getUniqueId(), true);
}
return cooldowned;

View File

@ -1,12 +1,9 @@
package com.songoda.ultimatetimber.manager;
import com.songoda.core.locale.Locale;
import com.songoda.ultimatetimber.UltimateTimber;
import com.songoda.ultimatetimber.utils.Methods;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
@ -17,10 +14,10 @@ import java.util.Set;
public class CommandManager extends Manager implements CommandExecutor, TabCompleter {
public CommandManager(UltimateTimber ultimateTimber) {
super(ultimateTimber);
public CommandManager(UltimateTimber plugin) {
super(plugin);
PluginCommand command = ultimateTimber.getCommand("ultimatetimber");
PluginCommand command = plugin.getCommand("ultimatetimber");
if (command != null) {
command.setExecutor(this);
command.setTabCompleter(this);
@ -39,15 +36,15 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
LocaleManager localeManager = this.ultimateTimber.getLocaleManager();
Locale locale = this.plugin.getLocale();
if (args.length > 0) {
if (args[0].equalsIgnoreCase("reload")) {
if (commandSender instanceof Player && this.doesntHavePermission(commandSender, "ultimatetimber.reload", localeManager))
if (commandSender instanceof Player && this.doesntHavePermission(commandSender, "ultimatetimber.reload", locale))
return true;
UltimateTimber.getInstance().reload();
localeManager.sendPrefixedMessage(commandSender, LocaleManager.Locale.COMMAND_RELOAD_RELOADED);
locale.getMessage("command.reload.reloaded").sendPrefixedMessage(commandSender);
return true;
} else if (args[0].equalsIgnoreCase("toggle")) {
if (!(commandSender instanceof Player)) {
@ -55,13 +52,13 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
return true;
}
if (this.doesntHavePermission(commandSender, "ultimatetimber.toggle", localeManager))
if (this.doesntHavePermission(commandSender, "ultimatetimber.toggle", locale))
return true;
if (UltimateTimber.getInstance().getChoppingManager().togglePlayer((Player) commandSender)) {
localeManager.sendPrefixedMessage(commandSender, LocaleManager.Locale.COMMAND_TOGGLE_ENABLED);
locale.getMessage("command.toggle.enabled").sendPrefixedMessage(commandSender);
} else {
localeManager.sendPrefixedMessage(commandSender, LocaleManager.Locale.COMMAND_TOGGLE_DISABLED);
locale.getMessage("command.toggle.disabled").sendPrefixedMessage(commandSender);
}
return true;
@ -69,9 +66,10 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
}
commandSender.sendMessage("");
commandSender.sendMessage(Methods.formatText(LocaleManager.Locale.PREFIX.get() + " &7Version " + UltimateTimber.getInstance().getDescription().getVersion() + " Created with <3 by &5&l&oSongoda"));
localeManager.sendMessage(commandSender, LocaleManager.Locale.COMMAND_RELOAD_DESCRIPTION);
localeManager.sendMessage(commandSender, LocaleManager.Locale.COMMAND_TOGGLE_DESCRIPTION);
locale.newMessage("&7Version " + plugin.getDescription().getVersion()
+ " Created with <3 by &5&l&oSongoda").sendPrefixedMessage(commandSender);
locale.getMessage("command.reload.description").sendMessage(commandSender);
locale.getMessage("command.toggle.description").sendMessage(commandSender);
commandSender.sendMessage("");
return true;
@ -101,14 +99,14 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
* Checks if a player does have a permission
* Sends them an error message if they don't
*
* @param sender The CommandSender to check
* @param sender The CommandSender to check
* @param permission The permission to check for
* @param localeManager The LocaleManager instance
* @param locale The LocaleManager instance
* @return True if the player has permission, otherwise false and sends a message
*/
private boolean doesntHavePermission(CommandSender sender, String permission, LocaleManager localeManager) {
private boolean doesntHavePermission(CommandSender sender, String permission, Locale locale) {
if (!sender.hasPermission(permission)) {
localeManager.sendPrefixedMessage(sender, LocaleManager.Locale.NO_PERMISSION);
locale.getMessage("general.nopermission").sendPrefixedMessage(sender);
return true;
}
return false;

View File

@ -167,21 +167,21 @@ public class ConfigurationManager extends Manager {
@Override
public void reload() {
File configFile = new File(this.ultimateTimber.getDataFolder() + "/config.yml");
File configFile = new File(this.plugin.getDataFolder() + "/config.yml");
// If an old config still exists, rename it so it doesn't interfere
if (configFile.exists() && this.ultimateTimber.getConfig().get("server-type") == null) {
File renameConfigTo = new File(this.ultimateTimber.getDataFolder() + "/config-old.yml");
if (configFile.exists() && this.plugin.getConfig().get("server-type") == null) {
File renameConfigTo = new File(this.plugin.getDataFolder() + "/config-old.yml");
configFile.renameTo(renameConfigTo);
configFile = new File(this.ultimateTimber.getDataFolder() + "/config.yml");
configFile = new File(this.plugin.getDataFolder() + "/config.yml");
}
// Create the new config if it doesn't exist
if (!configFile.exists()) {
boolean isCurrentConfig = this.ultimateTimber.getVersionAdapter().getVersionAdapterType() == VersionAdapterType.CURRENT;
boolean isCurrentConfig = this.plugin.getVersionAdapter().getVersionAdapterType() == VersionAdapterType.CURRENT;
String newConfigName = "config-" + (isCurrentConfig ? "current" : "legacy") + ".yml";
File newConfigFile = new File(this.ultimateTimber.getDataFolder() + "/" + newConfigName);
this.ultimateTimber.saveResource(newConfigName, false);
File newConfigFile = new File(this.plugin.getDataFolder() + "/" + newConfigName);
this.plugin.saveResource(newConfigName, false);
newConfigFile.renameTo(configFile);
}

View File

@ -11,14 +11,13 @@ import com.songoda.ultimatetimber.hook.McMMOHook;
import com.songoda.ultimatetimber.hook.TimberHook;
import com.songoda.ultimatetimber.tree.TreeBlockSet;
import com.songoda.ultimatetimber.utils.NMSUtil;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.HashSet;
import java.util.Set;
public class HookManager extends Manager {
private Set<TimberHook> hooks;
@ -35,23 +34,25 @@ public class HookManager extends Manager {
this.tryHook("Jobs", JobsHook.class);
this.tryHook("CoreProtect", CoreProtectHook.class);
if (this.ultimateTimber.getVersionAdapter().getVersionAdapterType().equals(VersionAdapterType.CURRENT)) {
Plugin mcMMO = Bukkit.getPluginManager().getPlugin("mcMMO");
if (mcMMO != null) {
String version = mcMMO.getDescription().getVersion();
if (version.startsWith("2")) {
this.tryHook("mcMMO", McMMOHook.class);
} else {
this.tryHook("mcMMO", McMMOClassic13Hook.class);
Bukkit.getScheduler().runTaskAsynchronously(this.plugin, () -> {
if (this.plugin.getVersionAdapter().getVersionAdapterType().equals(VersionAdapterType.CURRENT)) {
Plugin mcMMO = Bukkit.getPluginManager().getPlugin("mcMMO");
if (mcMMO != null) {
String version = mcMMO.getDescription().getVersion();
if (version.startsWith("2")) {
this.tryHook("mcMMO", McMMOHook.class);
} else {
this.tryHook("mcMMO", McMMOClassic13Hook.class);
}
}
} else {
if (NMSUtil.getVersionNumber() == 12) {
this.tryHook("mcMMO", McMMOClassic12Hook.class);
} else if (NMSUtil.getVersionNumber() == 8) {
this.tryHook("mcMMO", McMMOClassic8Hook.class);
}
}
} else {
if (NMSUtil.getVersionNumber() == 12) {
this.tryHook("mcMMO", McMMOClassic12Hook.class);
} else if (NMSUtil.getVersionNumber() == 8) {
this.tryHook("mcMMO", McMMOClassic8Hook.class);
}
}
});
}
@Override

View File

@ -4,10 +4,10 @@ import com.songoda.ultimatetimber.UltimateTimber;
public abstract class Manager {
protected UltimateTimber ultimateTimber;
protected UltimateTimber plugin;
Manager(UltimateTimber ultimateTimber) {
this.ultimateTimber = ultimateTimber;
Manager(UltimateTimber plugin) {
this.plugin = plugin;
}
/**

View File

@ -15,7 +15,6 @@ import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Collections;
import java.util.LinkedHashMap;

View File

@ -51,7 +51,7 @@ public class SaplingManager extends Manager {
if (!block.getType().equals(Material.AIR) || treeBlock.getTreeBlockType().equals(TreeBlockType.LEAF))
return;
Bukkit.getScheduler().scheduleSyncDelayedTask(this.ultimateTimber, () -> this.internalReplant(treeDefinition, treeBlock), 1L);
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> this.internalReplant(treeDefinition, treeBlock), 1L);
}
/**
@ -69,7 +69,7 @@ public class SaplingManager extends Manager {
if (this.random.nextDouble() > chance / 100)
return;
Bukkit.getScheduler().scheduleSyncDelayedTask(this.ultimateTimber, () -> this.internalReplant(treeDefinition, treeBlock), 1L);
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> this.internalReplant(treeDefinition, treeBlock), 1L);
}
/**
@ -79,7 +79,7 @@ public class SaplingManager extends Manager {
* @param treeBlock The ITreeBlock to replant for
*/
private void internalReplant(TreeDefinition treeDefinition, ITreeBlock treeBlock) {
TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
TreeDefinitionManager treeDefinitionManager = this.plugin.getTreeDefinitionManager();
Block block = treeBlock.getLocation().getBlock();
Block blockBelow = block.getRelative(BlockFace.DOWN);
@ -100,7 +100,7 @@ public class SaplingManager extends Manager {
int cooldown = ConfigurationManager.Setting.REPLANT_SAPLINGS_COOLDOWN.getInt();
if (cooldown != 0) {
this.protectedSaplings.add(block.getLocation());
Bukkit.getScheduler().scheduleSyncDelayedTask(this.ultimateTimber, () -> this.protectedSaplings.remove(block.getLocation()), cooldown * 20L);
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () -> this.protectedSaplings.remove(block.getLocation()), cooldown * 20L);
}
}

View File

@ -36,7 +36,7 @@ public class TreeAnimationManager extends Manager implements Listener, Runnable
this.activeAnimations = new HashSet<>();
this.taskId = -1;
Bukkit.getPluginManager().registerEvents(this, ultimateTimber);
Bukkit.getScheduler().runTaskTimer(this.ultimateTimber, this, 0, 1L);
Bukkit.getScheduler().runTaskTimer(this.plugin, this, 0, 1L);
}
@Override
@ -144,8 +144,8 @@ public class TreeAnimationManager extends Manager implements Listener, Runnable
* @param treeBlock The tree block to impact
*/
public void runFallingBlockImpact(TreeAnimation treeAnimation, ITreeBlock<FallingBlock> treeBlock) {
TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
VersionAdapter versionAdapter = this.ultimateTimber.getVersionAdapter();
TreeDefinitionManager treeDefinitionManager = this.plugin.getTreeDefinitionManager();
VersionAdapter versionAdapter = this.plugin.getVersionAdapter();
boolean useCustomSound = ConfigurationManager.Setting.USE_CUSTOM_SOUNDS.getBoolean();
boolean useCustomParticles = ConfigurationManager.Setting.USE_CUSTOM_PARTICLES.getBoolean();
TreeDefinition treeDefinition = treeAnimation.getDetectedTree().getTreeDefinition();
@ -156,7 +156,7 @@ public class TreeAnimationManager extends Manager implements Listener, Runnable
versionAdapter.playLandingSound(treeBlock);
treeDefinitionManager.dropTreeLoot(treeDefinition, treeBlock, treeAnimation.getPlayer(), treeAnimation.hasSilkTouch(), false);
this.ultimateTimber.getSaplingManager().replantSaplingWithChance(treeDefinition, treeBlock);
this.plugin.getSaplingManager().replantSaplingWithChance(treeDefinition, treeBlock);
treeAnimation.getFallingTreeBlocks().remove(treeBlock);
}

View File

@ -49,8 +49,8 @@ public class TreeDefinitionManager extends Manager {
this.globalEntireTreeLoot.clear();
this.globalRequiredTools.clear();
VersionAdapter versionAdapter = this.ultimateTimber.getVersionAdapter();
ConfigurationManager configurationManager = this.ultimateTimber.getConfigurationManager();
VersionAdapter versionAdapter = this.plugin.getVersionAdapter();
ConfigurationManager configurationManager = this.plugin.getConfigurationManager();
YamlConfiguration config = configurationManager.getConfig();
// Load tree settings
@ -236,8 +236,8 @@ public class TreeDefinitionManager extends Manager {
* @param isForEntireTree If the loot is for the entire tree
*/
public void dropTreeLoot(TreeDefinition treeDefinition, ITreeBlock treeBlock, Player player, boolean hasSilkTouch, boolean isForEntireTree) {
VersionAdapter versionAdapter = this.ultimateTimber.getVersionAdapter();
HookManager hookManager = this.ultimateTimber.getHookManager();
VersionAdapter versionAdapter = this.plugin.getVersionAdapter();
HookManager hookManager = this.plugin.getHookManager();
boolean addToInventory = ConfigurationManager.Setting.ADD_ITEMS_TO_INVENTORY.getBoolean();
boolean hasBonusChance = player.hasPermission("ultimatetimber.bonusloot");

View File

@ -48,8 +48,8 @@ public class TreeDetectionManager extends Manager {
@Override
public void reload() {
this.treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
this.placedBlockManager = this.ultimateTimber.getPlacedBlockManager();
this.treeDefinitionManager = this.plugin.getTreeDefinitionManager();
this.placedBlockManager = this.plugin.getPlacedBlockManager();
this.maxLogBlocksAllowed = ConfigurationManager.Setting.MAX_LOGS_PER_CHOP.getInt();
this.numLeavesRequiredForTree = ConfigurationManager.Setting.LEAVES_REQUIRED_FOR_TREE.getInt();
this.onlyBreakLogsUpwards = ConfigurationManager.Setting.ONLY_DETECT_LOGS_UPWARDS.getBoolean();
@ -69,7 +69,7 @@ public class TreeDetectionManager extends Manager {
* @return A DetectedTree if one was found, otherwise null
*/
public DetectedTree detectTree(Block initialBlock) {
TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
TreeDefinitionManager treeDefinitionManager = this.plugin.getTreeDefinitionManager();
TreeBlock initialTreeBlock = new TreeBlock(initialBlock, TreeBlockType.LOG);
TreeBlockSet<Block> detectedTreeBlocks = new TreeBlockSet<>(initialTreeBlock);

View File

@ -38,13 +38,13 @@ public class TreeFallManager extends Manager implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
TreeDefinitionManager treeDefinitionManager = this.ultimateTimber.getTreeDefinitionManager();
TreeDetectionManager treeDetectionManager = this.ultimateTimber.getTreeDetectionManager();
TreeAnimationManager treeAnimationManager = this.ultimateTimber.getTreeAnimationManager();
ChoppingManager choppingManager = this.ultimateTimber.getChoppingManager();
SaplingManager saplingManager = this.ultimateTimber.getSaplingManager();
VersionAdapter versionAdapter = this.ultimateTimber.getVersionAdapter();
HookManager hookManager = this.ultimateTimber.getHookManager();
TreeDefinitionManager treeDefinitionManager = this.plugin.getTreeDefinitionManager();
TreeDetectionManager treeDetectionManager = this.plugin.getTreeDetectionManager();
TreeAnimationManager treeAnimationManager = this.plugin.getTreeAnimationManager();
ChoppingManager choppingManager = this.plugin.getChoppingManager();
SaplingManager saplingManager = this.plugin.getSaplingManager();
VersionAdapter versionAdapter = this.plugin.getVersionAdapter();
HookManager hookManager = this.plugin.getHookManager();
Player player = event.getPlayer();
Block block = event.getBlock();
@ -97,7 +97,7 @@ public class TreeFallManager extends Manager implements Listener {
return;
if (alwaysReplantSapling) {
Bukkit.getScheduler().scheduleSyncDelayedTask(this.ultimateTimber, () ->
Bukkit.getScheduler().scheduleSyncDelayedTask(this.plugin, () ->
saplingManager.replantSapling(detectedTree.getTreeDefinition(), detectedTree.getDetectedTreeBlocks().getInitialLogBlock()));
if (!isValid)

View File

@ -1,30 +0,0 @@
package com.songoda.ultimatetimber.locale;
import com.songoda.ultimatetimber.manager.LocaleManager;
import com.songoda.update.Module;
import com.songoda.update.Plugin;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.io.IOException;
import java.net.URL;
public class LocaleModule implements Module {
@Override
public void run(Plugin plugin) {
JSONObject json = plugin.getJson();
try {
JSONArray files = (JSONArray) json.get("neededFiles");
for (Object o : files) {
JSONObject file = (JSONObject) o;
if (file.get("type").equals("locale"))
LocaleManager.saveDefaultLocale(new URL((String) file.get("link")), (String) file.get("name"));
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}

View File

@ -1,211 +0,0 @@
package com.songoda.ultimatetimber.manager;
import com.songoda.ultimatetimber.UltimateTimber;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class LocaleManager extends Manager {
public enum Locale {
PREFIX,
NO_PERMISSION,
COMMAND_RELOAD_DESCRIPTION,
COMMAND_RELOAD_RELOADED,
COMMAND_TOGGLE_DESCRIPTION,
COMMAND_TOGGLE_ENABLED,
COMMAND_TOGGLE_DISABLED,
ON_COOLDOWN;
private String message;
/**
* Gets a Locale message
*
* @return A message formatted for chat
*/
public String get() {
if (this.message == null)
this.loadMessage();
return this.message;
}
/**
* Loads the locale message and caches it
*/
private void loadMessage() {
String message = UltimateTimber.getInstance().getLocaleManager().getLocale().getString(this.getNameAsKey());
if (message != null)
this.message = ChatColor.translateAlternateColorCodes('&', message);
}
/**
* Resets the cached message
*/
private void reset() {
this.message = null;
}
/**
* Gets the name of this Setting as a FileConfiguration-compatible key
*
* @return The key for a FileConfiguration
*/
private String getNameAsKey() {
return this.name().replace("_", "-").toLowerCase();
}
}
public LocaleManager(UltimateTimber ultimateTimber) {
super(ultimateTimber);
}
private FileConfiguration locale;
@Override
public void reload() {
for (Locale value : Locale.values())
value.reset();
String targetLocaleName = ConfigurationManager.Setting.LOCALE.getString() + ".lang";
File targetLocaleFile = new File(UltimateTimber.getInstance().getDataFolder() + "/locale", targetLocaleName);
if (!targetLocaleFile.exists()) {
targetLocaleFile = new File(UltimateTimber.getInstance().getDataFolder() + "/locale", "en_US.lang");
if (!targetLocaleFile.exists()) {
UltimateTimber.getInstance().saveResource("locale/en_US.lang", false);
}
}
this.locale = YamlConfiguration.loadConfiguration(targetLocaleFile);
}
@Override
public void disable() {
}
/**
* Gets the FileConfiguration that contains the locale messages
*
* @return A FileConfiguration of the messages
*/
public FileConfiguration getLocale() {
return this.locale;
}
/**
* Sends a message to a CommandSender with the prefix
*
* @param sender The CommandSender to send to
* @param locale The Locale to send
*/
public void sendPrefixedMessage(CommandSender sender, Locale locale) {
sender.sendMessage(Locale.PREFIX.get() + locale.get());
}
/**
* Sends a message to a CommandSender
*
* @param sender The CommandSender to send to
* @param locale The Locale to send
*/
public void sendMessage(CommandSender sender, Locale locale) {
sender.sendMessage(locale.get());
}
/**
* Saves a locale to disk in the /locale folder if it doesn't already exist
* If it does exist, it checks to see if anything needs to be updated
*
* @param fileUrl The URL of the file to download
* @param fileName The name of the file to save
*/
public static void saveDefaultLocale(URL fileUrl, String fileName) {
File localeFolder = new File(UltimateTimber.getInstance().getDataFolder() + "/locale");
if (!localeFolder.exists())
localeFolder.mkdirs();
File targetFile = new File(localeFolder, fileName);
if (targetFile.exists()) {
checkExistingFile(fileUrl, targetFile);
return;
}
try (OutputStream outputStream = new FileOutputStream(targetFile)) {
copy(fileUrl.openStream(), outputStream);
} catch (IOException ex) {
ex.printStackTrace();
}
}
/**
* Checks and updates a locale file with additions if any exist
*
* @param fileUrl The URL of the file to download
* @param targetFile The target file
*/
private static void checkExistingFile(URL fileUrl, File targetFile) {
UltimateTimber ultimateTimber = UltimateTimber.getInstance();
List<String> keysToUpdate = new ArrayList<>();
FileConfiguration existingConfiguration = YamlConfiguration.loadConfiguration(targetFile);
for (Locale locale : Locale.values())
if (existingConfiguration.get(locale.getNameAsKey()) == null)
keysToUpdate.add(locale.getNameAsKey());
if (keysToUpdate.isEmpty())
return;
try (Reader reader = new InputStreamReader(fileUrl.openStream());
BufferedWriter writer = new BufferedWriter(new FileWriter(targetFile, true))) {
FileConfiguration newFileConfiguration = YamlConfiguration.loadConfiguration(reader);
writer.newLine();
writer.newLine();
writer.write("# Changes since " + ultimateTimber.getName() + " v" + ultimateTimber.getDescription().getVersion());
for (String key : keysToUpdate) {
writer.newLine();
writer.write(key + ": " + "\"" + newFileConfiguration.getString(key) + "\"");
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
/**
* Copies a file from an InputStream to an OutputStream
*
* @param input The InputStream to copy
* @param output The OutputStream to copy to
*/
private static void copy(InputStream input, OutputStream output) {
try {
byte[] buffer = new byte[1024 * 4];
int n;
while ((n = input.read(buffer)) != -1)
output.write(buffer, 0, n);
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,17 +0,0 @@
# General Messages
prefix: "&8[&6UltimateTimber&8] "
no-permission: "&cYou don't have permission for that!"
# Command Messages
command-reload-description: "&8 - &a/ut reload &7 - Reloads the config."
command-reload-reloaded: "&7Configuration and locale files have been reloaded."
command-toggle-description: "&8 - &a/ut toggle &7 - Toggles your chopping mode"
command-toggle-enabled: "&7Chopping Mode: &aEnabled"
command-toggle-disabled: "&7Chopping Mode: &cDisabled"
# Misc
on-cooldown: "&eYou are on cooldown and cannot topple trees right now."

View File

@ -1,50 +0,0 @@
allprojects {
apply plugin: 'java'
group = 'com.songoda.ultimatetimber'
version = '2.0.4'
}
subprojects {
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
maven {
url = 'http://repo.songoda.com/artifactory/private'
}
}
}
dependencies {
compile project(':UltimateTimber-Core')
compile project(':UltimateTimber-CurrentAdapter')
compile project(':UltimateTimber-LegacyAdapter')
compile project(':UltimateTimber-Jobs')
compile project(':UltimateTimber-McMMO')
compile project(':UltimateTimber-McMMOClassic13')
compile project(':UltimateTimber-McMMOClassic12')
compile project(':UltimateTimber-McMMOClassic8')
compile project(':UltimateTimber-CoreProtect')
compile project(':UltimateTimber-Plugin')
}
configurations {
childJars
}
dependencies {
subprojects.each {
childJars project(it.path)
}
}
jar {
dependsOn configurations.childJars
from {
configurations.childJars.collect {
zipTree(it)
}
}
}

View File

@ -1,6 +0,0 @@
#Mon Apr 22 18:01:52 MDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

172
gradlew vendored
View File

@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored
View File

@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

106
pom.xml Normal file
View File

@ -0,0 +1,106 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<groupId>com.songoda</groupId>
<artifactId>UltimateTimber</artifactId>
<version>2.0.5</version>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
<modules>
<module>UltimateTimber/Core</module>
<module>UltimateTimber/Plugin</module>
<module>UltimateTimber-Adapter/Current</module>
<module>UltimateTimber-Adapter/Legacy</module>
<module>UltimateTimber-Hook/Jobs</module>
<module>UltimateTimber-Hook/McMMO</module>
<module>UltimateTimber-Hook/McMMOClassic13</module>
<module>UltimateTimber-Hook/McMMOClassic12</module>
<module>UltimateTimber-Hook/McMMOClassic8</module>
<module>UltimateTimber-Hook/CoreProtect</module>
</modules>
<repositories>
<repository>
<id>private</id>
<url>https://repo.songoda.com/artifactory/private/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<defaultGoal>clean install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<configuration>
<outputDirectory>jars</outputDirectory>
<stripVersion>true</stripVersion>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>LegacyAdapter</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>McMMO</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>Plugin</artifactId>
<version>${project.version}</version>
</artifactItem>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>Core</artifactId>
<version>${project.version}</version>
</artifactItem>
</artifactItems>
</configuration>
<inherited>false</inherited>
</plugin>
</plugins>
<resources>
<resource>
<directory>resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

View File

@ -1,31 +0,0 @@
rootProject.name = 'UltimateTimber'
include(':UltimateTimber-Core')
project(':UltimateTimber-Core').projectDir = file('UltimateTimber/Core')
include(':UltimateTimber-CurrentAdapter')
project(':UltimateTimber-CurrentAdapter').projectDir = file('UltimateTimber-Adapter/Current')
include(':UltimateTimber-LegacyAdapter')
project(':UltimateTimber-LegacyAdapter').projectDir = file('UltimateTimber-Adapter/Legacy')
include(':UltimateTimber-Jobs')
project(':UltimateTimber-Jobs').projectDir = file('UltimateTimber-Hook/Jobs')
include(':UltimateTimber-McMMO')
project(':UltimateTimber-McMMO').projectDir = file('UltimateTimber-Hook/McMMO')
include(':UltimateTimber-McMMOClassic13')
project(':UltimateTimber-McMMOClassic13').projectDir = file('UltimateTimber-Hook/McMMOClassic13')
include(':UltimateTimber-McMMOClassic12')
project(':UltimateTimber-McMMOClassic12').projectDir = file('UltimateTimber-Hook/McMMOClassic12')
include(':UltimateTimber-McMMOClassic8')
project(':UltimateTimber-McMMOClassic8').projectDir = file('UltimateTimber-Hook/McMMOClassic8')
include(':UltimateTimber-CoreProtect')
project(':UltimateTimber-CoreProtect').projectDir = file('UltimateTimber-Hook/CoreProtect')
include(':UltimateTimber-Plugin')
project(':UltimateTimber-Plugin').projectDir = file('UltimateTimber/Plugin')