Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
33fbe74818 | |||
2abdcdd3ad | |||
754f486d1b | |||
9059790a65 | |||
6fefa8701e | |||
052d2393aa | |||
c34c6ab09f | |||
f68916ef54 | |||
cc9648315f | |||
|
2f3c555195 | ||
bcfe98bf22 | |||
b83766744d | |||
cd366cbe14 | |||
82cc31d41f | |||
|
b81071156f | ||
3050ad337d | |||
b825152415 | |||
38b644bb27 | |||
8826ca9b6e | |||
7be7c9f09e |
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>CommandGUI_V2</artifactId>
|
||||
<version>2.8.9</version>
|
||||
<version>2.9.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>CommandGUI</name>
|
||||
@@ -54,14 +54,15 @@
|
||||
|
||||
<repositories>
|
||||
<!-- repo.t2code / T2Code -->
|
||||
<repository>
|
||||
<id>Builders-Paradise</id>
|
||||
<url>https://repo.t2code.net/repository/Builders-Paradise/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>T2Code</id>
|
||||
<url>https://repo.t2code.net/repository/T2Code/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Builders-Paradise</id>
|
||||
<url>https://repo.t2code.net/repository/Builders-Paradise/</url>
|
||||
</repository>
|
||||
|
||||
<!-- placeholderAPI -->
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
@@ -71,6 +72,17 @@
|
||||
|
||||
<dependencies>
|
||||
<!-- repo.t2code / T2Code -->
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>DEV-14.2</version>
|
||||
<classifier>1</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>LuckyBox-API</artifactId>
|
||||
<version>4.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>bungee</artifactId>
|
||||
@@ -96,16 +108,7 @@
|
||||
<artifactId>PlugmanGUI</artifactId>
|
||||
<version>3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>12.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>LuckyBox-API</artifactId>
|
||||
<version>4.2.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- placeholderAPI -->
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
|
@@ -1,84 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Bungee;
|
||||
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class BListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPluginmessage(PluginMessageEvent event) {
|
||||
if (event.getTag().equalsIgnoreCase("cgui:bungee")) {
|
||||
event.setCancelled(true);
|
||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
||||
try {
|
||||
String channel = stream.readUTF();
|
||||
String input = stream.readUTF();
|
||||
if (channel.equals("cgui-Console")) {
|
||||
ProxyServer.getInstance().getConsole().sendMessage("Command Console: " + input);
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), input);
|
||||
} else {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(channel);
|
||||
if (player != null) {
|
||||
ProxyServer.getInstance().getConsole().sendMessage("Command " + player + ": " + input);
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, input);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PostLoginEvent e) {
|
||||
ProxiedPlayer player = e.getPlayer();
|
||||
sendToSpigotPlayer(player.getName(), true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisconnect(PlayerDisconnectEvent e) {
|
||||
ProxiedPlayer player = e.getPlayer();
|
||||
sendToSpigotPlayer(e.getPlayer().getName(), false);
|
||||
}
|
||||
|
||||
public static void sendToSpigotPlayer(String name, Boolean join) {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream output = new DataOutputStream(stream);
|
||||
try {
|
||||
if (join) {
|
||||
output.writeUTF("join");
|
||||
} else {
|
||||
output.writeUTF("left");
|
||||
}
|
||||
output.writeUTF(name);
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(e.getMessage());
|
||||
}
|
||||
BungeeCord.getInstance().getServers().values().stream().forEach((server) -> {
|
||||
|
||||
server.sendData("cgui:onlinepl", stream.toByteArray());
|
||||
});
|
||||
}
|
||||
|
||||
public static void sendToSpigotDeleteAll() {
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
DataOutputStream output = new DataOutputStream(stream);
|
||||
try {
|
||||
output.writeUTF("clear");
|
||||
output.writeUTF("");
|
||||
} catch (IOException e) {
|
||||
Logger.getLogger(e.getMessage());
|
||||
}
|
||||
BungeeCord.getInstance().getServers().values().stream().forEach((server) -> {
|
||||
server.sendData("cgui:onlinepl", stream.toByteArray());
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,100 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Bungee;
|
||||
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class BMain extends Plugin {
|
||||
private boolean enable = false;
|
||||
public static Plugin plugin;
|
||||
public static String update_version = null;
|
||||
|
||||
public static String prefix = "§8[§4C§9GUI§8]";
|
||||
|
||||
public static String version;
|
||||
public static String autor;
|
||||
public static Integer spigotID = 90671;
|
||||
public static Integer bstatsID = 10840;
|
||||
public static String spigot = "https://www.spigotmc.org/resources/" + spigotID;
|
||||
public static String discord = "http://dc.t2code.net";
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
Long long_ = Long.valueOf(System.currentTimeMillis());
|
||||
plugin = this;
|
||||
autor = plugin.getDescription().getAuthor();
|
||||
version = plugin.getDescription().getVersion();
|
||||
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
||||
Bsend.console(prefix + "§4============================= §8[§4Command§9GUI§5BUNGEE§8] §4=============================");
|
||||
Bsend.console(prefix + "§4 _____ §9_____ _ _ _____ §e ___ ");
|
||||
Bsend.console(prefix + "§4 / ____§9/ ____| | | |_ _|§e |__ \\ ");
|
||||
Bsend.console(prefix + "§4 | | §9| | __| | | | | |§e_ __ ) |");
|
||||
Bsend.console(prefix + "§4 | | §9| | |_ | | | | | §e\\ \\ / // / ");
|
||||
Bsend.console(prefix + "§4 | |___§9| |__| | |__| |_| |§e\\ V // /_ ");
|
||||
Bsend.console(prefix + "§4 \\_____§9\\_____|\\____/|_____§e\\_/|____|");
|
||||
Bsend.console(prefix);
|
||||
Bsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
|
||||
Bsend.console(prefix + " §2Version: §6" + version);
|
||||
Bsend.console(prefix + " §2Spigot: §6" + spigot);
|
||||
Bsend.console(prefix + " §2Discord: §6" + discord);
|
||||
|
||||
plugin.getProxy().registerChannel("cgui:bungee");
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, new BListener());
|
||||
BListener.sendToSpigotDeleteAll();
|
||||
BMetrics.Bstats();
|
||||
|
||||
Bsend.console(prefix + " §2Plugin loaded successfully." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
||||
Bsend.console(prefix + "§4==============================================================================");
|
||||
BUpdateChecker.onUpdateCheck();
|
||||
BUpdateChecker.onUpdateCheckTimer();
|
||||
enable = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if (!enable) {
|
||||
return;
|
||||
}
|
||||
Bsend.console(prefix + "§4============================= §8[§4Command§9GUI§5BUNGEE§8] §4=============================");
|
||||
Bsend.console(prefix + " §2Autor: §6" + String.valueOf(autor).replace("[", "").replace("]", ""));
|
||||
Bsend.console(prefix + " §2Version: §6" + version);
|
||||
Bsend.console(prefix + " §2Spigot: §6" + spigot);
|
||||
Bsend.console(prefix + " §2Discord: §6" + discord);
|
||||
Bsend.console(prefix + " §4Plugin successfully disabled.");
|
||||
Bsend.console(prefix + "§4==============================================================================");
|
||||
}
|
||||
|
||||
public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||
if (ProxyServer.getInstance().getPluginManager().getPlugin(pl) == null) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
||||
ProxyServer.getInstance().getConsole().sendMessage(prefix + " §e" + pl + " §4could not be found. Please download it here: " +
|
||||
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
|
||||
// BMain.plugin.getPluginLoader().disablePlugin(BMain.plugin);
|
||||
BMain.plugin.onDisable();
|
||||
return true;
|
||||
} else {
|
||||
String plVer = ProxyServer.getInstance().getPluginManager().getPlugin(pl).getDescription().getVersion();
|
||||
if (ver.contains("_")) {
|
||||
if (!plVer.equals(ver)) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
||||
ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires the version §2" + ver + " §4of §6" + pl + " §4Please use this version! Please download it here or contact us in Discord: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " Or contact us in Discord: http://dc.t2code.net");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
String[] split = plVer.split("_");
|
||||
if (Double.parseDouble(split[0]) < Double.parseDouble(ver)) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
||||
ProxyServer.getInstance().getConsole().sendMessage(prefix + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + plugin.getDescription().getName() + ".");
|
||||
BMain.plugin.onDisable();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,864 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Bungee;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class BMetrics {
|
||||
|
||||
public static void Bstats() {
|
||||
int pluginId = Util.getBstatsID(); // <-- Replace with the id of your plugin!
|
||||
BMetrics metrics = new BMetrics(BMain.plugin, pluginId);
|
||||
}
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
private final MetricsBase metricsBase;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
private String serverUUID;
|
||||
|
||||
private boolean logErrors = false;
|
||||
|
||||
private boolean logSentData;
|
||||
|
||||
private boolean logResponseStatusText;
|
||||
|
||||
/**
|
||||
* Creates a new Metrics instance.
|
||||
*
|
||||
* @param plugin Your plugin instance.
|
||||
* @param serviceId The id of the service. It can be found at <a
|
||||
* href="https://bstats.org/what-is-my-plugin-id">What is my plugin id?</a>
|
||||
*/
|
||||
public BMetrics(Plugin plugin, int serviceId) {
|
||||
this.plugin = plugin;
|
||||
try {
|
||||
loadConfig();
|
||||
} catch (IOException e) {
|
||||
// Failed to load configuration
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to load bStats config!", e);
|
||||
metricsBase = null;
|
||||
return;
|
||||
}
|
||||
metricsBase =
|
||||
new MetricsBase(
|
||||
"bungeecord",
|
||||
serverUUID,
|
||||
serviceId,
|
||||
enabled,
|
||||
this::appendPlatformData,
|
||||
this::appendServiceData,
|
||||
null,
|
||||
() -> true,
|
||||
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
|
||||
(message) -> this.plugin.getLogger().log(Level.INFO, message),
|
||||
logErrors,
|
||||
logSentData,
|
||||
logResponseStatusText);
|
||||
}
|
||||
|
||||
/** Loads the bStats configuration. */
|
||||
private void loadConfig() throws IOException {
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
bStatsFolder.mkdirs();
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
writeFile(
|
||||
configFile,
|
||||
"# bStats (https://bStats.org) collects some basic information for plugin authors, like how",
|
||||
"# many people use their plugin and their total player count. It's recommended to keep bStats",
|
||||
"# enabled, but if you're not comfortable with this, you can turn this setting off. There is no",
|
||||
"# performance penalty associated with having metrics enabled, and data sent to bStats is fully",
|
||||
"# anonymous.",
|
||||
"enabled: true",
|
||||
"serverUuid: \"" + UUID.randomUUID() + "\"",
|
||||
"logFailedRequests: false",
|
||||
"logSentData: false",
|
||||
"logResponseStatusText: false");
|
||||
}
|
||||
Configuration configuration =
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
// Load configuration
|
||||
enabled = configuration.getBoolean("enabled", true);
|
||||
serverUUID = configuration.getString("serverUuid");
|
||||
logErrors = configuration.getBoolean("logFailedRequests", false);
|
||||
logSentData = configuration.getBoolean("logSentData", false);
|
||||
logResponseStatusText = configuration.getBoolean("logResponseStatusText", false);
|
||||
}
|
||||
|
||||
private void writeFile(File file, String... lines) throws IOException {
|
||||
try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file))) {
|
||||
for (String line : lines) {
|
||||
bufferedWriter.write(line);
|
||||
bufferedWriter.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
metricsBase.addCustomChart(chart);
|
||||
}
|
||||
|
||||
private void appendPlatformData(JsonObjectBuilder builder) {
|
||||
builder.appendField("playerAmount", plugin.getProxy().getOnlineCount());
|
||||
builder.appendField("managedServers", plugin.getProxy().getServers().size());
|
||||
builder.appendField("onlineMode", plugin.getProxy().getConfig().isOnlineMode() ? 1 : 0);
|
||||
builder.appendField("bungeecordVersion", plugin.getProxy().getVersion());
|
||||
builder.appendField("javaVersion", System.getProperty("java.version"));
|
||||
builder.appendField("osName", System.getProperty("os.name"));
|
||||
builder.appendField("osArch", System.getProperty("os.arch"));
|
||||
builder.appendField("osVersion", System.getProperty("os.version"));
|
||||
builder.appendField("coreCount", Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
private void appendServiceData(JsonObjectBuilder builder) {
|
||||
builder.appendField("pluginVersion", plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
public static class MetricsBase {
|
||||
|
||||
/** The version of the Metrics class. */
|
||||
public static final String METRICS_VERSION = "2.2.1";
|
||||
|
||||
private static final ScheduledExecutorService scheduler =
|
||||
Executors.newScheduledThreadPool(1, task -> new Thread(task, "bStats-Metrics"));
|
||||
|
||||
private static final String REPORT_URL = "https://bStats.org/api/v2/data/%s";
|
||||
|
||||
private final String platform;
|
||||
|
||||
private final String serverUuid;
|
||||
|
||||
private final int serviceId;
|
||||
|
||||
private final Consumer<JsonObjectBuilder> appendPlatformDataConsumer;
|
||||
|
||||
private final Consumer<JsonObjectBuilder> appendServiceDataConsumer;
|
||||
|
||||
private final Consumer<Runnable> submitTaskConsumer;
|
||||
|
||||
private final Supplier<Boolean> checkServiceEnabledSupplier;
|
||||
|
||||
private final BiConsumer<String, Throwable> errorLogger;
|
||||
|
||||
private final Consumer<String> infoLogger;
|
||||
|
||||
private final boolean logErrors;
|
||||
|
||||
private final boolean logSentData;
|
||||
|
||||
private final boolean logResponseStatusText;
|
||||
|
||||
private final Set<CustomChart> customCharts = new HashSet<>();
|
||||
|
||||
private final boolean enabled;
|
||||
|
||||
/**
|
||||
* Creates a new MetricsBase class instance.
|
||||
*
|
||||
* @param platform The platform of the service.
|
||||
* @param serviceId The id of the service.
|
||||
* @param serverUuid The server uuid.
|
||||
* @param enabled Whether or not data sending is enabled.
|
||||
* @param appendPlatformDataConsumer A consumer that receives a {@code JsonObjectBuilder} and
|
||||
* appends all platform-specific data.
|
||||
* @param appendServiceDataConsumer A consumer that receives a {@code JsonObjectBuilder} and
|
||||
* appends all service-specific data.
|
||||
* @param submitTaskConsumer A consumer that takes a runnable with the submit task. This can be
|
||||
* used to delegate the data collection to a another thread to prevent errors caused by
|
||||
* concurrency. Can be {@code null}.
|
||||
* @param checkServiceEnabledSupplier A supplier to check if the service is still enabled.
|
||||
* @param errorLogger A consumer that accepts log message and an error.
|
||||
* @param infoLogger A consumer that accepts info log messages.
|
||||
* @param logErrors Whether or not errors should be logged.
|
||||
* @param logSentData Whether or not the sent data should be logged.
|
||||
* @param logResponseStatusText Whether or not the response status text should be logged.
|
||||
*/
|
||||
public MetricsBase(
|
||||
String platform,
|
||||
String serverUuid,
|
||||
int serviceId,
|
||||
boolean enabled,
|
||||
Consumer<JsonObjectBuilder> appendPlatformDataConsumer,
|
||||
Consumer<JsonObjectBuilder> appendServiceDataConsumer,
|
||||
Consumer<Runnable> submitTaskConsumer,
|
||||
Supplier<Boolean> checkServiceEnabledSupplier,
|
||||
BiConsumer<String, Throwable> errorLogger,
|
||||
Consumer<String> infoLogger,
|
||||
boolean logErrors,
|
||||
boolean logSentData,
|
||||
boolean logResponseStatusText) {
|
||||
this.platform = platform;
|
||||
this.serverUuid = serverUuid;
|
||||
this.serviceId = serviceId;
|
||||
this.enabled = enabled;
|
||||
this.appendPlatformDataConsumer = appendPlatformDataConsumer;
|
||||
this.appendServiceDataConsumer = appendServiceDataConsumer;
|
||||
this.submitTaskConsumer = submitTaskConsumer;
|
||||
this.checkServiceEnabledSupplier = checkServiceEnabledSupplier;
|
||||
this.errorLogger = errorLogger;
|
||||
this.infoLogger = infoLogger;
|
||||
this.logErrors = logErrors;
|
||||
this.logSentData = logSentData;
|
||||
this.logResponseStatusText = logResponseStatusText;
|
||||
checkRelocation();
|
||||
if (enabled) {
|
||||
startSubmitting();
|
||||
}
|
||||
}
|
||||
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
this.customCharts.add(chart);
|
||||
}
|
||||
|
||||
private void startSubmitting() {
|
||||
final Runnable submitTask =
|
||||
() -> {
|
||||
if (!enabled || !checkServiceEnabledSupplier.get()) {
|
||||
// Submitting data or service is disabled
|
||||
scheduler.shutdown();
|
||||
return;
|
||||
}
|
||||
if (submitTaskConsumer != null) {
|
||||
submitTaskConsumer.accept(this::submitData);
|
||||
} else {
|
||||
this.submitData();
|
||||
}
|
||||
};
|
||||
// Many servers tend to restart at a fixed time at xx:00 which causes an uneven distribution
|
||||
// of requests on the
|
||||
// bStats backend. To circumvent this problem, we introduce some randomness into the initial
|
||||
// and second delay.
|
||||
// WARNING: You must not modify and part of this Metrics class, including the submit delay or
|
||||
// frequency!
|
||||
// WARNING: Modifying this code will get your plugin banned on bStats. Just don't do it!
|
||||
long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3));
|
||||
long secondDelay = (long) (1000 * 60 * (Math.random() * 30));
|
||||
scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS);
|
||||
scheduler.scheduleAtFixedRate(
|
||||
submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private void submitData() {
|
||||
final JsonObjectBuilder baseJsonBuilder = new JsonObjectBuilder();
|
||||
appendPlatformDataConsumer.accept(baseJsonBuilder);
|
||||
final JsonObjectBuilder serviceJsonBuilder = new JsonObjectBuilder();
|
||||
appendServiceDataConsumer.accept(serviceJsonBuilder);
|
||||
JsonObjectBuilder.JsonObject[] chartData =
|
||||
customCharts.stream()
|
||||
.map(customChart -> customChart.getRequestJsonObject(errorLogger, logErrors))
|
||||
.filter(Objects::nonNull)
|
||||
.toArray(JsonObjectBuilder.JsonObject[]::new);
|
||||
serviceJsonBuilder.appendField("id", serviceId);
|
||||
serviceJsonBuilder.appendField("customCharts", chartData);
|
||||
baseJsonBuilder.appendField("service", serviceJsonBuilder.build());
|
||||
baseJsonBuilder.appendField("serverUUID", serverUuid);
|
||||
baseJsonBuilder.appendField("metricsVersion", METRICS_VERSION);
|
||||
JsonObjectBuilder.JsonObject data = baseJsonBuilder.build();
|
||||
scheduler.execute(
|
||||
() -> {
|
||||
try {
|
||||
// Send the data
|
||||
sendData(data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logErrors) {
|
||||
errorLogger.accept("Could not submit bStats metrics data", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendData(JsonObjectBuilder.JsonObject data) throws Exception {
|
||||
if (logSentData) {
|
||||
infoLogger.accept("Sent bStats metrics data: " + data.toString());
|
||||
}
|
||||
String url = String.format(REPORT_URL, platform);
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(url).openConnection();
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip");
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setRequestProperty("User-Agent", "Metrics-Service/1");
|
||||
connection.setDoOutput(true);
|
||||
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||
outputStream.write(compressedData);
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
try (BufferedReader bufferedReader =
|
||||
new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
}
|
||||
if (logResponseStatusText) {
|
||||
infoLogger.accept("Sent data to bStats and received response: " + builder);
|
||||
}
|
||||
}
|
||||
|
||||
/** Checks that the class was properly relocated. */
|
||||
private void checkRelocation() {
|
||||
// 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'});
|
||||
final String examplePackage =
|
||||
new String(new byte[] {'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
|
||||
// We want to make sure no one just copy & pastes the example and uses the wrong package
|
||||
// names
|
||||
if (MetricsBase.class.getPackage().getName().startsWith(defaultPackage)
|
||||
|| MetricsBase.class.getPackage().getName().startsWith(examplePackage)) {
|
||||
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gzips the given string.
|
||||
*
|
||||
* @param str The string to gzip.
|
||||
* @return The gzipped string.
|
||||
*/
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
}
|
||||
|
||||
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 JsonObjectBuilder.JsonObject getChartData() throws Exception {
|
||||
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
|
||||
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) {
|
||||
// Skip this invalid
|
||||
continue;
|
||||
}
|
||||
allSkipped = false;
|
||||
valuesBuilder.appendField(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
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 JsonObjectBuilder.JsonObject getChartData() throws Exception {
|
||||
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
|
||||
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()) {
|
||||
valuesBuilder.appendField(entry.getKey(), new int[] {entry.getValue()});
|
||||
}
|
||||
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
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 JsonObjectBuilder.JsonObject getChartData() throws Exception {
|
||||
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
|
||||
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) {
|
||||
// Skip this invalid
|
||||
continue;
|
||||
}
|
||||
allSkipped = false;
|
||||
valuesBuilder.appendField(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
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 JsonObjectBuilder.JsonObject getChartData() throws Exception {
|
||||
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
|
||||
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) {
|
||||
// Skip this invalid
|
||||
continue;
|
||||
}
|
||||
allSkipped = false;
|
||||
valuesBuilder.appendField(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class CustomChart {
|
||||
|
||||
private final String chartId;
|
||||
|
||||
protected CustomChart(String chartId) {
|
||||
if (chartId == null) {
|
||||
throw new IllegalArgumentException("chartId must not be null");
|
||||
}
|
||||
this.chartId = chartId;
|
||||
}
|
||||
|
||||
public JsonObjectBuilder.JsonObject getRequestJsonObject(
|
||||
BiConsumer<String, Throwable> errorLogger, boolean logErrors) {
|
||||
JsonObjectBuilder builder = new JsonObjectBuilder();
|
||||
builder.appendField("chartId", chartId);
|
||||
try {
|
||||
JsonObjectBuilder.JsonObject data = getChartData();
|
||||
if (data == null) {
|
||||
// If the data is null we don't send the chart.
|
||||
return null;
|
||||
}
|
||||
builder.appendField("data", data);
|
||||
} catch (Throwable t) {
|
||||
if (logErrors) {
|
||||
errorLogger.accept("Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
protected abstract JsonObjectBuilder.JsonObject getChartData() throws Exception;
|
||||
}
|
||||
|
||||
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 JsonObjectBuilder.JsonObject getChartData() throws Exception {
|
||||
int value = callable.call();
|
||||
if (value == 0) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
return new JsonObjectBuilder().appendField("value", value).build();
|
||||
}
|
||||
}
|
||||
|
||||
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 JsonObjectBuilder.JsonObject getChartData() throws Exception {
|
||||
String value = callable.call();
|
||||
if (value == null || value.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
return new JsonObjectBuilder().appendField("value", value).build();
|
||||
}
|
||||
}
|
||||
|
||||
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 JsonObjectBuilder.JsonObject getChartData() throws Exception {
|
||||
JsonObjectBuilder valuesBuilder = new JsonObjectBuilder();
|
||||
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()) {
|
||||
JsonObjectBuilder valueBuilder = new JsonObjectBuilder();
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||
valueBuilder.appendField(valueEntry.getKey(), valueEntry.getValue());
|
||||
allSkipped = false;
|
||||
}
|
||||
if (!allSkipped) {
|
||||
reallyAllSkipped = false;
|
||||
valuesBuilder.appendField(entryValues.getKey(), valueBuilder.build());
|
||||
}
|
||||
}
|
||||
if (reallyAllSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
return new JsonObjectBuilder().appendField("values", valuesBuilder.build()).build();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An extremely simple JSON builder.
|
||||
*
|
||||
* <p>While this class is neither feature-rich nor the most performant one, it's sufficient enough
|
||||
* for its use-case.
|
||||
*/
|
||||
public static class JsonObjectBuilder {
|
||||
|
||||
private StringBuilder builder = new StringBuilder();
|
||||
|
||||
private boolean hasAtLeastOneField = false;
|
||||
|
||||
public JsonObjectBuilder() {
|
||||
builder.append("{");
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a null field to the JSON.
|
||||
*
|
||||
* @param key The key of the field.
|
||||
* @return A reference to this object.
|
||||
*/
|
||||
public JsonObjectBuilder appendNull(String key) {
|
||||
appendFieldUnescaped(key, "null");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a string field to the JSON.
|
||||
*
|
||||
* @param key The key of the field.
|
||||
* @param value The value of the field.
|
||||
* @return A reference to this object.
|
||||
*/
|
||||
public JsonObjectBuilder appendField(String key, String value) {
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("JSON value must not be null");
|
||||
}
|
||||
appendFieldUnescaped(key, "\"" + escape(value) + "\"");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an integer field to the JSON.
|
||||
*
|
||||
* @param key The key of the field.
|
||||
* @param value The value of the field.
|
||||
* @return A reference to this object.
|
||||
*/
|
||||
public JsonObjectBuilder appendField(String key, int value) {
|
||||
appendFieldUnescaped(key, String.valueOf(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an object to the JSON.
|
||||
*
|
||||
* @param key The key of the field.
|
||||
* @param object The object.
|
||||
* @return A reference to this object.
|
||||
*/
|
||||
public JsonObjectBuilder appendField(String key, JsonObject object) {
|
||||
if (object == null) {
|
||||
throw new IllegalArgumentException("JSON object must not be null");
|
||||
}
|
||||
appendFieldUnescaped(key, object.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a string array to the JSON.
|
||||
*
|
||||
* @param key The key of the field.
|
||||
* @param values The string array.
|
||||
* @return A reference to this object.
|
||||
*/
|
||||
public JsonObjectBuilder appendField(String key, String[] values) {
|
||||
if (values == null) {
|
||||
throw new IllegalArgumentException("JSON values must not be null");
|
||||
}
|
||||
String escapedValues =
|
||||
Arrays.stream(values)
|
||||
.map(value -> "\"" + escape(value) + "\"")
|
||||
.collect(Collectors.joining(","));
|
||||
appendFieldUnescaped(key, "[" + escapedValues + "]");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an integer array to the JSON.
|
||||
*
|
||||
* @param key The key of the field.
|
||||
* @param values The integer array.
|
||||
* @return A reference to this object.
|
||||
*/
|
||||
public JsonObjectBuilder appendField(String key, int[] values) {
|
||||
if (values == null) {
|
||||
throw new IllegalArgumentException("JSON values must not be null");
|
||||
}
|
||||
String escapedValues =
|
||||
Arrays.stream(values).mapToObj(String::valueOf).collect(Collectors.joining(","));
|
||||
appendFieldUnescaped(key, "[" + escapedValues + "]");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an object array to the JSON.
|
||||
*
|
||||
* @param key The key of the field.
|
||||
* @param values The integer array.
|
||||
* @return A reference to this object.
|
||||
*/
|
||||
public JsonObjectBuilder appendField(String key, JsonObject[] values) {
|
||||
if (values == null) {
|
||||
throw new IllegalArgumentException("JSON values must not be null");
|
||||
}
|
||||
String escapedValues =
|
||||
Arrays.stream(values).map(JsonObject::toString).collect(Collectors.joining(","));
|
||||
appendFieldUnescaped(key, "[" + escapedValues + "]");
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends a field to the object.
|
||||
*
|
||||
* @param key The key of the field.
|
||||
* @param escapedValue The escaped value of the field.
|
||||
*/
|
||||
private void appendFieldUnescaped(String key, String escapedValue) {
|
||||
if (builder == null) {
|
||||
throw new IllegalStateException("JSON has already been built");
|
||||
}
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("JSON key must not be null");
|
||||
}
|
||||
if (hasAtLeastOneField) {
|
||||
builder.append(",");
|
||||
}
|
||||
builder.append("\"").append(escape(key)).append("\":").append(escapedValue);
|
||||
hasAtLeastOneField = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the JSON string and invalidates this builder.
|
||||
*
|
||||
* @return The built JSON string.
|
||||
*/
|
||||
public JsonObject build() {
|
||||
if (builder == null) {
|
||||
throw new IllegalStateException("JSON has already been built");
|
||||
}
|
||||
JsonObject object = new JsonObject(builder.append("}").toString());
|
||||
builder = null;
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes the given string like stated in https://www.ietf.org/rfc/rfc4627.txt.
|
||||
*
|
||||
* <p>This method escapes only the necessary characters '"', '\'. and '\u0000' - '\u001F'.
|
||||
* Compact escapes are not used (e.g., '\n' is escaped as "\u000a" and not as "\n").
|
||||
*
|
||||
* @param value The value to escape.
|
||||
* @return The escaped value.
|
||||
*/
|
||||
private static String escape(String value) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
if (c == '"') {
|
||||
builder.append("\\\"");
|
||||
} else if (c == '\\') {
|
||||
builder.append("\\\\");
|
||||
} else if (c <= '\u000F') {
|
||||
builder.append("\\u000").append(Integer.toHexString(c));
|
||||
} else if (c <= '\u001F') {
|
||||
builder.append("\\u00").append(Integer.toHexString(c));
|
||||
} else {
|
||||
builder.append(c);
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* A super simple representation of a JSON object.
|
||||
*
|
||||
* <p>This class only exists to make methods of the {@link JsonObjectBuilder} type-safe and not
|
||||
* allow a raw string inputs for methods like {@link JsonObjectBuilder#appendField(String,
|
||||
* JsonObject)}.
|
||||
*/
|
||||
public static class JsonObject {
|
||||
|
||||
private final String value;
|
||||
|
||||
private JsonObject(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,106 +0,0 @@
|
||||
// This claas was created by JaTiTV
|
||||
|
||||
// -----------------------------
|
||||
// _____ _____ _ _ _____
|
||||
// / ____/ ____| | | |_ _|
|
||||
// | | | | __| | | | | |
|
||||
// | | | | |_ | | | | | |
|
||||
// | |___| |__| | |__| |_| |_
|
||||
// \_____\_____|\____/|_____|
|
||||
// -----------------------------
|
||||
|
||||
package de.jatitv.commandguiv2.Bungee;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class BUpdateChecker {
|
||||
|
||||
public static void sendUpdateMsg(String Prefix, String foundVersion, String update_version) {
|
||||
Bsend.console("§4=========== " + Prefix + " §4===========");
|
||||
Bsend.console("§6A new version was found!");
|
||||
Bsend.console("§6Your version: §c" + foundVersion + " §7- §6Current version: §a" + update_version);
|
||||
Bsend.console("§6You can download it here: §e" + BMain.spigot);
|
||||
Bsend.console("§6You can find more information on Discord: §e" + BMain.discord);
|
||||
Bsend.console("§4=========== " + Prefix + " §4===========");
|
||||
}
|
||||
|
||||
public static void onUpdateCheckTimer() {
|
||||
ProxyServer.getInstance().getScheduler().schedule(BMain.plugin, new Runnable() {
|
||||
public void run() {
|
||||
(new BUpdateChecker(BMain.plugin, BMain.spigotID)).getVersion((update_version) -> {
|
||||
String foundVersion = BMain.plugin.getDescription().getVersion();
|
||||
BMain.update_version = update_version;
|
||||
if (!foundVersion.replace("_Bungee", "").equalsIgnoreCase(update_version)) {
|
||||
sendUpdateMsg(BMain.prefix, foundVersion, update_version);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 0, 20 * 60 * 60L, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public static void onUpdateCheck() {
|
||||
(new BUpdateChecker(BMain.plugin, BMain.spigotID)).getVersion((update_version) -> {
|
||||
String foundVersion = BMain.plugin.getDescription().getVersion();
|
||||
BMain.update_version = update_version;
|
||||
if (foundVersion.replace("_Bungee", "").equalsIgnoreCase(update_version)) {
|
||||
Bsend.console(BMain.prefix + " §2No update found.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Plugin plugin;
|
||||
private int resourceId;
|
||||
|
||||
public BUpdateChecker(Plugin plugin, int resourceId) {
|
||||
this.plugin = plugin;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public void getVersion(Consumer<String> consumer) {
|
||||
ProxyServer.getInstance().getScheduler().runAsync(this.plugin, () -> {
|
||||
try {
|
||||
InputStream inputStream = (new URL("https://api.spigotmc.org/legacy/update.php?resource=" + this.resourceId)).openStream();
|
||||
try {
|
||||
Scanner scanner = new Scanner(inputStream);
|
||||
|
||||
try {
|
||||
if (scanner.hasNext()) {
|
||||
consumer.accept(scanner.next());
|
||||
}
|
||||
} catch (Throwable var8) {
|
||||
try {
|
||||
scanner.close();
|
||||
} catch (Throwable var7) {
|
||||
var8.addSuppressed(var7);
|
||||
}
|
||||
throw var8;
|
||||
}
|
||||
scanner.close();
|
||||
} catch (Throwable var9) {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (Throwable var6) {
|
||||
var9.addSuppressed(var6);
|
||||
}
|
||||
}
|
||||
throw var9;
|
||||
}
|
||||
if (inputStream != null) {
|
||||
inputStream.close();
|
||||
}
|
||||
} catch (IOException var10) {
|
||||
this.plugin.getLogger().severe(BMain.prefix + "§4 Cannot look for updates: " + var10.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@@ -1,212 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Spigot.cmdManagement;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
|
||||
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.UseItem;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.system.Permissions;
|
||||
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import de.jatitv.commandguiv2.Spigot.sound.Sound;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.SoundEnum;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Commands {
|
||||
public static void info(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
send.player(player, Util.getPrefix() + "§4======= §8[§4Command§9GUI§8] §4=======");
|
||||
send.player(player, Util.getPrefix() + " §2Autor: §6" + String.valueOf(Main.autor).replace("[", "").replace("]", ""));
|
||||
|
||||
if (UpdateAPI.PluginVersionen.get(Main.getPlugin().getName()).publicVersion.equalsIgnoreCase(Main.version)) {
|
||||
send.player(player, Util.getPrefix() + " §2Version: §6" + Main.version);
|
||||
} else {
|
||||
UpdateAPI.sendUpdateMsg(Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.version, UpdateAPI.PluginVersionen.get(Main.getPlugin().getName()).publicVersion, player);
|
||||
}
|
||||
|
||||
send.player(player, Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot());
|
||||
send.player(player, Util.getPrefix() + " §2Discord: §6" + Util.getDiscord());
|
||||
send.player(player, Util.getPrefix() + "§4======= §8[§4Command§9GUI§8] §4=======");
|
||||
} else {
|
||||
send.sender(sender, Util.getPrefix() + "§4======= §8[§4Command§9GUI§8] §4=======");
|
||||
send.sender(sender, Util.getPrefix() + " §2String.valueOf(Main.autor): §6" + String.valueOf(String.valueOf(Main.autor)).replace("[", "").replace("]", ""));
|
||||
|
||||
if (UpdateAPI.PluginVersionen.get(Main.getPlugin().getName()).publicVersion.equalsIgnoreCase(Main.version)) {
|
||||
send.sender(sender, Util.getPrefix() + " §2Version: §6" + Main.version);
|
||||
} else {
|
||||
UpdateAPI.sendUpdateMsg(Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.version, UpdateAPI.PluginVersionen.get(Main.getPlugin().getName()).publicVersion);
|
||||
}
|
||||
|
||||
send.sender(sender, Util.getPrefix() + " §2Spigot: §6" + Util.getSpigot());
|
||||
send.sender(sender, Util.getPrefix() + " §2Discord: §6" + Util.getDiscord());
|
||||
send.sender(sender, Util.getPrefix() + "§4======= §8[§4Command§9GUI§8] §4=======");
|
||||
}
|
||||
}
|
||||
|
||||
public static void reload(CommandSender sender) {
|
||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadStart);
|
||||
send.console(Util.getPrefix() + "§8-------------------------------");
|
||||
send.console(Util.getPrefix() + " §6Plugin reload...");
|
||||
send.console(Util.getPrefix() + "§8-------------------------------");
|
||||
SelectConfig.onSelect();
|
||||
Main.getPlugin().reloadConfig();
|
||||
|
||||
CmdExecuter_GUI.arg1.clear();
|
||||
CmdExecuter_GUI.arg1.put(SelectConfig.getAdminSubCommand(), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
|
||||
|
||||
if (!Objects.equals(SelectDatabase.getStorage().toString(), SelectConfig.getStorage())) {
|
||||
if (sender instanceof Player) send.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!");
|
||||
send.warning(Main.getPlugin(), "You have changed the storage medium! To apply this change, you must restart the server!");
|
||||
}
|
||||
|
||||
LanguagesCreate.langCreate();
|
||||
|
||||
Obj_Select.onSelect();
|
||||
SelectMessages.onSelect(Util.getPrefix());
|
||||
SelectConfig.sound(Util.getPrefix());
|
||||
|
||||
try {
|
||||
AliasRegister.onRegister();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Permissions.onPermRegister();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (SelectConfig.getBungee()) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.getPlugin(), "commandgui:bungee");
|
||||
|
||||
}
|
||||
|
||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadEnd);
|
||||
send.console(Util.getPrefix() + "§8-------------------------------");
|
||||
send.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
||||
send.console(Util.getPrefix() + "§8-------------------------------");
|
||||
}
|
||||
|
||||
public static void give(CommandSender sender, Player target) {
|
||||
if (Bukkit.getPlayer(target.getName()) != null) {
|
||||
UseItem.giveUseItem(target);
|
||||
send.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", SelectConfig.getUseItem_Name()));
|
||||
send.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", SelectConfig.getUseItem_Name()));
|
||||
Sound.play(target, SoundEnum.Give);
|
||||
} else {
|
||||
sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName()));
|
||||
if (sender instanceof Player) Sound.play((Player) sender, SoundEnum.PlayerNotFound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void itemOn(Player player) {
|
||||
UseItem.removeItem(player);
|
||||
Integer slot = null;
|
||||
if (SelectConfig.getUseItem_InventorySlotEnforce()) {
|
||||
slot = SelectConfig.getUseItem_InventorySlot();
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
send.debug(Main.getPlugin(), String.valueOf(slot));
|
||||
if (player.getInventory().getItem(slot - 1) == null) {
|
||||
SelectDatabase.setItemStatusTrue(player);
|
||||
UseItem.giveUseItem(player);
|
||||
} else {
|
||||
boolean empty = false;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (player.getInventory().getItem(i) == null) {
|
||||
empty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty) {
|
||||
SelectDatabase.setItemStatusTrue(player);
|
||||
UseItem.addUseItem(player);
|
||||
send.player(player, SelectMessages.ItemON);
|
||||
} else {
|
||||
send.player(player, SelectMessages.NoInventorySpace);
|
||||
Sound.play(player,SoundEnum.NoInventorySpace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void itemOff(Player player) {
|
||||
SelectDatabase.setItemStatusFalse(player);
|
||||
UseItem.removeItem(player);
|
||||
send.player(player, SelectMessages.ItemOFF);
|
||||
}
|
||||
|
||||
public static void onSetSlot(Player player, Integer setSlot) {
|
||||
if (!SelectConfig.getUseItem_AllowSetSlot()) {
|
||||
send.player(player, Util.getPrefix() + " §4Function disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if (setSlot < 1) {
|
||||
send.player(player, SelectMessages.ItemSlot_wrongValue);
|
||||
return;
|
||||
}
|
||||
if (setSlot > 9) {
|
||||
send.player(player, SelectMessages.ItemSlot_wrongValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
if (Objects.equals(Events.useItemSlotHashMap.get(player.getName()), setSlot)) {
|
||||
send.player(player, SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectConfig.getUseItem_InventorySlotEnforce() || player.getInventory().getItem(setSlot - 1) != null) {
|
||||
send.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
|
||||
return;
|
||||
}
|
||||
|
||||
UseItem.removeItem(player);
|
||||
SelectDatabase.setSlot(player, setSlot);
|
||||
Events.useItemSlotHashMap.replace(player.getName(), setSlot);
|
||||
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
UseItem.giveUseItem(player);
|
||||
}
|
||||
|
||||
send.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
|
||||
}
|
||||
|
||||
public static void gui(Player player) {
|
||||
if (Main.guiHashMap.containsKey(SelectConfig.getDefaultGUI())) {
|
||||
Gui gui = Main.guiHashMap.get(SelectConfig.getDefaultGUI());
|
||||
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
|
||||
OpenGUI.openGUI(player, SelectConfig.getDefaultGUI(), true);
|
||||
} else send.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui")
|
||||
.replace("[perm]", "commandgui.command"));
|
||||
} else send.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));
|
||||
}
|
||||
}
|
||||
|
||||
public static void gui(Player player, String arg) {
|
||||
if (Main.guiHashMap.containsKey(arg)) {
|
||||
Gui gui = Main.guiHashMap.get(arg);
|
||||
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) {
|
||||
OpenGUI.openGUI(player, arg, true);
|
||||
} else send.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key)
|
||||
.replace("[perm]", "commandgui.command." + arg.toLowerCase()));
|
||||
} else send.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.key));
|
||||
} else send.player(player, SelectMessages.guiNotFound);
|
||||
}
|
||||
}
|
@@ -1,111 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Spigot.cmdManagement;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Help {
|
||||
private static String prefix = Util.getPrefix();
|
||||
|
||||
public static void sendHelp(CommandSender sender, String Prefix) {
|
||||
Gui gui = Main.guiHashMap.get(SelectConfig.getDefaultGUI());
|
||||
|
||||
send.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
|
||||
cgui(sender, gui);
|
||||
open(sender);
|
||||
help(sender);
|
||||
gUIItemHelp(sender);
|
||||
info(sender);
|
||||
give(sender);
|
||||
createDefaultGUI(sender);
|
||||
reload(sender);
|
||||
send.sender(sender, Prefix + " §8-------------------------");
|
||||
}
|
||||
|
||||
|
||||
private static void cgui(CommandSender sender, Gui gui) {
|
||||
if (!sender.hasPermission("commandgui.command")) return;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpCgui.replace("[gui]", Replace.replace(prefix, gui.guiName)));
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.HelpCgui.replace("[gui]", Replace.replace(prefix, gui.guiName)));
|
||||
}
|
||||
|
||||
private static void open(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.command")) return;
|
||||
|
||||
for (String alias : Main.allAliases) {
|
||||
if (Main.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) {
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix, Main.guiHashMap.get(alias).guiName)));
|
||||
} else
|
||||
send.sender(sender, prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", Replace.replace(prefix, Main.guiHashMap.get(alias).guiName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void help(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.command")) return;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpHelp);
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.HelpHelp);
|
||||
}
|
||||
|
||||
private static void info(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.command.info")) return;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpInfo);
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.HelpInfo);
|
||||
}
|
||||
|
||||
private static void give(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.admin")) return;
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpGive);
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.HelpGive);
|
||||
}
|
||||
|
||||
private static void createDefaultGUI(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.admin")) return;
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpCreateDefaultGUI.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
|
||||
}
|
||||
|
||||
private static void reload(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.admin")) return;
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpReload);
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.HelpReload);
|
||||
}
|
||||
|
||||
|
||||
public static void gUIItemHelp(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_on);
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_on);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_off);
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_off);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
send.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_Slot);
|
||||
} else send.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_Slot);
|
||||
}
|
||||
public static void sendGUIItemHelp(CommandSender sender) {
|
||||
if (sender.hasPermission("commandgui.useitem.toggle")) {
|
||||
send.sender(sender, prefix + " §8------ §4Command§9GUI§2Item §chelp §8------");
|
||||
gUIItemHelp(sender);
|
||||
send.sender(sender, prefix + " §8------------------------------");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,190 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Spigot.config.config;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ConfigCreate {
|
||||
|
||||
|
||||
public static void configCreate() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
if (new File(Main.getPath(), "config.yml").exists()) {
|
||||
if (Main.getPlugin().getConfig().getBoolean("Plugin.Debug")) send.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
|
||||
} else send.console(Util.getPrefix() + " §4config.yml are created...");
|
||||
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (!config.exists()) Config.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
|
||||
|
||||
Config.set("Plugin.Debug", false, yamlConfiguration);
|
||||
Config.set("Plugin.HelpAlias", true, yamlConfiguration);
|
||||
Config.set("Plugin.AdminSubCommand", "admin", yamlConfiguration);
|
||||
Config.set("Plugin.language", "english", yamlConfiguration);
|
||||
Config.set("Plugin.Currency", "$", yamlConfiguration);
|
||||
Config.set("Plugin.DefaultGUI", "default", yamlConfiguration);
|
||||
|
||||
if (Main.legacy){
|
||||
Config.set("Storage.Type", "YML", yamlConfiguration);
|
||||
} else Config.set("Storage.Type", "SQLITE", yamlConfiguration);
|
||||
Config.set("Storage.MySQL.IP", "localhost", yamlConfiguration);
|
||||
Config.set("Storage.MySQL.Port", 3306, yamlConfiguration);
|
||||
Config.set("Storage.MySQL.Database", "database", yamlConfiguration);
|
||||
Config.set("Storage.MySQL.User", "root", yamlConfiguration);
|
||||
Config.set("Storage.MySQL.Password", "password", yamlConfiguration);
|
||||
Config.set("Storage.MySQL.SSL", false, yamlConfiguration);
|
||||
|
||||
Config.set("BungeeCord.Enable", false, yamlConfiguration);
|
||||
Config.set("BungeeCord.ThisServer", "server", yamlConfiguration);
|
||||
|
||||
Config.set("UseItem.Enable", true, yamlConfiguration);
|
||||
Config.set("UseItem.AllowToggle", true, yamlConfiguration);
|
||||
Config.set("UseItem.AllowSetSlot", true, yamlConfiguration);
|
||||
Config.set("UseItem.BlockMoveAndDrop", true, yamlConfiguration);
|
||||
Config.set("UseItem.OpenGUI", "default", yamlConfiguration);
|
||||
Config.set("UseItem.Permission.NeededToUse", true, yamlConfiguration);
|
||||
Config.set("UseItem.KeepAtCommandClear", true, yamlConfiguration);
|
||||
|
||||
Config.set("UseItem.InventorySlot.Slot", 1, yamlConfiguration);
|
||||
Config.set("UseItem.InventorySlot.SlotEnforce", false, yamlConfiguration);
|
||||
Config.set("UseItem.InventorySlot.FreeSlot", false, yamlConfiguration);
|
||||
|
||||
Config.set("UseItem.Item.Material", "paper", yamlConfiguration);
|
||||
if (!(MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12)) {
|
||||
Config.set("UseItem.Item.PlayerHead.Enable", false, yamlConfiguration);
|
||||
Config.set("UseItem.Item.PlayerHead.Base64.Enable", false, yamlConfiguration);
|
||||
Config.set("UseItem.Item.PlayerHead.Base64.Base64Value", "", yamlConfiguration);
|
||||
Config.set("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration);
|
||||
Config.set("UseItem.Item.PlayerHead.Playername", "", yamlConfiguration);
|
||||
}
|
||||
Config.set("UseItem.Item.Name", "&bDefault &6GUI", yamlConfiguration);
|
||||
Config.set("UseItem.Item.Lore", Arrays.asList("&eThis is an example GUI"), yamlConfiguration);
|
||||
Config.set("UseItem.Join.GiveOnEveryJoin", true, yamlConfiguration);
|
||||
Config.set("UseItem.Join.GiveOnlyOnFirstJoin", false, yamlConfiguration);
|
||||
|
||||
//convert
|
||||
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin")) {
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin", yamlConfiguration);
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin"), yamlConfiguration);
|
||||
}
|
||||
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin")) {
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin", yamlConfiguration);
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin"), yamlConfiguration);
|
||||
}
|
||||
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange")) {
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange", yamlConfiguration);
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange"), yamlConfiguration);
|
||||
}
|
||||
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", true, yamlConfiguration);
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", true, yamlConfiguration);
|
||||
Config.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, yamlConfiguration);
|
||||
|
||||
Config.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration);
|
||||
Config.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration);
|
||||
if (Main.legacy) {
|
||||
Config.set("Toggle.Items.OnOrYes.Item.Material", "WOOL,5", yamlConfiguration);
|
||||
} else Config.set("Toggle.Items.OnOrYes.Item.Material", ItemVersion.getGreenWool().getType().toString(), yamlConfiguration);
|
||||
|
||||
Config.set("Toggle.Items.OffOrNo.Item.Base64.Enable", false, yamlConfiguration);
|
||||
Config.set("Toggle.Items.OffOrNo.Item.Base64.Base64Value", "", yamlConfiguration);
|
||||
if (Main.legacy) {
|
||||
Config.set("Toggle.Items.OffOrNo.Item.Material", "WOOL,14", yamlConfiguration);
|
||||
} else Config.set("Toggle.Items.OffOrNo.Item.Material", ItemVersion.getRedWool().getType().toString(), yamlConfiguration);
|
||||
|
||||
Config.set("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", yamlConfiguration);
|
||||
Config.set("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", yamlConfiguration);
|
||||
|
||||
Config.set("Placeholder.True", "&2true", yamlConfiguration);
|
||||
Config.set("Placeholder.False", "&4false", yamlConfiguration);
|
||||
|
||||
Config.set("Sound.Enable", true, yamlConfiguration);
|
||||
|
||||
Config.set("Sound.OpenInventory.Enable", true, yamlConfiguration);
|
||||
if (MCVersion.minecraft1_8) {
|
||||
Config.set("Sound.OpenInventory.Sound", "CHEST_OPEN", yamlConfiguration);
|
||||
} else Config.set("Sound.OpenInventory.Sound", "BLOCK_CHEST_OPEN", yamlConfiguration);
|
||||
|
||||
Config.set("Sound.Click.Enable", true, yamlConfiguration);
|
||||
if (MCVersion.minecraft1_8) {
|
||||
Config.set("Sound.Click.Sound", "NOTE_STICKS", yamlConfiguration);
|
||||
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
Config.set("Sound.Click.Sound", "BLOCK_NOTE_HAT", yamlConfiguration);
|
||||
} else Config.set("Sound.Click.Sound", "BLOCK_NOTE_BLOCK_HAT", yamlConfiguration);
|
||||
|
||||
Config.set("Sound.NoMoney.Enable", true, yamlConfiguration);
|
||||
if (MCVersion.minecraft1_8) {
|
||||
Config.set("Sound.NoMoney.Sound", "NOTE_PIANO", yamlConfiguration);
|
||||
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
Config.set("Sound.NoMoney.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
|
||||
} else Config.set("Sound.NoMoney.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
|
||||
|
||||
Config.set("Sound.NoInventorySpace.Enable", true, yamlConfiguration);
|
||||
if (MCVersion.minecraft1_8) {
|
||||
Config.set("Sound.NoInventorySpace.Sound", "NOTE_PIANO", yamlConfiguration);
|
||||
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
Config.set("Sound.NoInventorySpace.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
|
||||
} else Config.set("Sound.NoInventorySpace.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
|
||||
|
||||
Config.set("Sound.Give.Enable", true, yamlConfiguration);
|
||||
if (MCVersion.minecraft1_8) {
|
||||
Config.set("Sound.Give.Sound", "LEVEL_UP", yamlConfiguration);
|
||||
} else Config.set("Sound.Give.Sound", "ENTITY_PLAYER_LEVELUP", yamlConfiguration);
|
||||
|
||||
Config.set("Sound.PlayerNotFound.Enable", true, yamlConfiguration);
|
||||
if (MCVersion.minecraft1_8) {
|
||||
Config.set("Sound.PlayerNotFound.Sound", "NOTE_PIANO", yamlConfiguration);
|
||||
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
Config.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
|
||||
} else Config.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
|
||||
|
||||
Config.set("Advanced.UseItem.GameMode.Change.Enable", true, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.Enable", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration);
|
||||
|
||||
Config.set("Advanced.UseItem.World.Change.Enable", true, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Change.DelayInTicks", 1, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Protection.Enable", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
|
||||
Config.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
|
||||
|
||||
if (!yamlConfiguration.contains("Advanced.UseItem.ItemBlockBlacklist")) {
|
||||
List<String> materialList = Arrays.asList("BUTTON", "DOOR", "FENCE", "CHEST", "FURNACE", "NOTE_BLOCK", "CRAFTING_TABLE", "WORKBENCH",
|
||||
"ANVIL", "LOOM", "COMPOSTER", "BARREL", "SMOKER", "BLAST_FURNACE", "CARTOGRAPHY_TABLE", "FLETCHING_TABLE", "GRINDSTONE",
|
||||
"SMITHING_TABLE", "STONECUTTER", "HOPPER", "DISPENSER", "DROPPER", "REPEATER", "COMPARATOR", "LEVER", "DAYLIGHT_DETECTOR", "BREWING_STAND", "TRAPDOOR", "BEACON"
|
||||
);
|
||||
|
||||
List<String> materialBlacklist = new ArrayList<>();
|
||||
for (Material material : Material.values()) {
|
||||
for (String target : materialList) {
|
||||
if (material.toString().contains(target)) materialBlacklist.add(material.toString());
|
||||
}
|
||||
}
|
||||
Config.set("Advanced.UseItem.ItemBlockBlacklist", materialBlacklist, yamlConfiguration);
|
||||
}
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
send.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Spigot.sound;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.SoundEnum;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Sound {
|
||||
private static String prefix = Util.getPrefix();
|
||||
|
||||
public static void play(Player player, SoundEnum soundEnum) {
|
||||
if (!SelectConfig.getSound_Enable()) return;
|
||||
play(player, soundEnum, null, null, null);
|
||||
}
|
||||
|
||||
public static void play(Player player, SoundEnum soundEnum, Function function, Slot slot, Gui gui) {
|
||||
if (!SelectConfig.getSound_Enable()) return;
|
||||
switch (soundEnum) {
|
||||
case OpenInventory:
|
||||
if (!SelectConfig.getSound_OpenInventory_Enable()) return;
|
||||
player.playSound(player.getLocation(), SelectConfig.getSound_OpenInventory(), 3, 1);
|
||||
break;
|
||||
case Click:
|
||||
if (!SelectConfig.getSound_Click_Enable()) return;
|
||||
if (!function.customSound_Enable) {
|
||||
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (function.customSound_NoSound) return;
|
||||
try {
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
|
||||
} catch (Exception e1) {
|
||||
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
|
||||
.replace("[sound]", "§6GUI: §e" + gui.key + " §6Function: §e" + function.key + "§r §6Slot: §e" + (slot.slot + 1) + " §6CustomSound: §9" + function.customSound_Sound));
|
||||
player.playSound(player.getLocation(), SelectConfig.getSound_Click(), 3, 1);
|
||||
}
|
||||
break;
|
||||
case NoMoney:
|
||||
if (!SelectConfig.getSound_NoMoney_Enable()) return;
|
||||
player.playSound(player.getLocation(), SelectConfig.getSound_NoMoney(), 3, 1);
|
||||
break;
|
||||
case NoInventorySpace:
|
||||
if (!SelectConfig.getSound_NoInventorySpace_Enable()) return;
|
||||
player.playSound(player.getLocation(), SelectConfig.getSound_NoInventorySpace(), 3, 1);
|
||||
break;
|
||||
case Give:
|
||||
if (!SelectConfig.getSound_Give_Enable()) return;
|
||||
player.playSound(player.getLocation(), SelectConfig.getSound_Give(), 3, 1);
|
||||
break;
|
||||
case PlayerNotFound:
|
||||
if (!SelectConfig.getSound_PlayerNotFound_Enable()) return;
|
||||
player.playSound(player.getLocation(), SelectConfig.getSound_PlayerNotFound(), 3, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,57 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Spigot.system;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
public class Debug {
|
||||
|
||||
private static final Plugin plugin = Main.getPlugin();
|
||||
|
||||
public static void debugmsg() {
|
||||
send.debug(plugin, "§5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
send.debug(plugin, "§3Bukkit Version: §e" + Bukkit.getBukkitVersion());
|
||||
send.debug(plugin, "§3NMS Version: §e" + Bukkit.getServer().getClass().getPackage().getName().replace("org.bukkit.craftbukkit.", ""));
|
||||
send.debug(plugin, "§3Version: §e" + Bukkit.getVersion());
|
||||
send.debug(plugin, "§3Java: §e" + System.getProperty("java.version"));
|
||||
send.debug(plugin, "§3Worlds: §e" + String.valueOf(Bukkit.getServer().getWorlds()));
|
||||
send.debug(plugin, String.valueOf(Arrays.asList(Main.getPlugin().getServer().getPluginManager().getPlugins())));
|
||||
send.debug(plugin, "§5----------------------------------");
|
||||
if (new File(Main.getPath(), "config.yml").exists()) {
|
||||
File f = new File(String.valueOf(Main.getPath()));
|
||||
File f2 = new File(String.valueOf(Main.getPath() + "/GUIs/"));
|
||||
File f3 = new File(String.valueOf(Main.getPath() + "/languages/"));
|
||||
File[] fileArray = f.listFiles();
|
||||
File[] fileArray2 = f2.listFiles();
|
||||
File[] fileArray3 = f3.listFiles();
|
||||
if (fileArray != null) {
|
||||
for (File config : fileArray) {
|
||||
send.debug(plugin, String.valueOf(config).replace("plugins/CommandGUI/", ""));
|
||||
}
|
||||
}
|
||||
if (fileArray2 != null) {
|
||||
for (File config2 : fileArray2) {
|
||||
send.debug(plugin, String.valueOf(config2).replace("plugins/CommandGUI/", ""));
|
||||
}
|
||||
} else send.debug(plugin, "No GUI files available");
|
||||
|
||||
if (fileArray3 != null) {
|
||||
for (File config3 : fileArray3) {
|
||||
send.debug(plugin, String.valueOf(config3).replace("plugins/CommandGUI/", ""));
|
||||
}
|
||||
} else send.debug(plugin, "No language files available");
|
||||
|
||||
}
|
||||
send.debug(plugin, "§5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
}
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Spigot.system;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||
import net.t2code.lib.Spigot.Lib.register.Register;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Permissions {
|
||||
private static final Plugin plugin = Main.getPlugin();
|
||||
|
||||
public static final String key = "commandgui.";
|
||||
public static final String command = key + "command";
|
||||
public static final String info = key + "command.info";
|
||||
public static final String bypass = key + "bypass";
|
||||
public static final String useitemToggle = key + "useitem.toggle";
|
||||
public static final String useitem = key + "useitem";
|
||||
public static final String getGuiItemAtLogin = key + "get.guiitem.at.login";
|
||||
public static final String giveItemOther = key + "giveitem.other";
|
||||
public static final String updatemsg = key + "updatemsg";
|
||||
|
||||
public static final String player = key + "player";
|
||||
public static final String admin = key + "admin";
|
||||
|
||||
public static final PermissionDefault op = PermissionDefault.OP;
|
||||
public static final PermissionDefault notOp = PermissionDefault.NOT_OP;
|
||||
|
||||
public static void onPermRegister() {
|
||||
Register.permission(command, op, plugin);
|
||||
Register.permissionDescription(command, "Required permission to open GUIs via command", plugin);
|
||||
|
||||
Register.permission(getGuiItemAtLogin, op, plugin);
|
||||
Register.permission(giveItemOther, op, plugin);
|
||||
Register.permissionDescription(getGuiItemAtLogin, "Only players with this permission will receive the GUI item", plugin);
|
||||
|
||||
Register.permission(useitem, op, plugin);
|
||||
Register.permissionDescription(useitem, "Required permission to use the GUI Item", plugin);
|
||||
|
||||
Register.permission(useitemToggle, op, plugin);
|
||||
Register.permissionDescription(useitemToggle, "Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)", plugin);
|
||||
|
||||
Register.permission(updatemsg, op, plugin);
|
||||
Register.permissionDescription(updatemsg, "Players with this permission get the update message when joining if an update is available", plugin);
|
||||
|
||||
Register.permission(bypass, op, plugin);
|
||||
Register.permissionDescription(bypass, "Bypass to open disabled GUIs", plugin);
|
||||
|
||||
Register.permission(info, notOp, plugin);
|
||||
Register.permissionDescription(info, "Permission to view T2C-CommandGUI info", plugin);
|
||||
|
||||
Register.permission(player, op, command, true, plugin);
|
||||
Register.permission(player, op, getGuiItemAtLogin, true, plugin);
|
||||
Register.permission(player, op, useitem, true, plugin);
|
||||
Register.permission(player, op, useitemToggle, true, plugin);
|
||||
Register.permissionDescription(player, "All permissions from T2C-CommandGUI for Player", plugin);
|
||||
|
||||
Register.permission(admin, op, command, true, plugin);
|
||||
Register.permission(admin, op, getGuiItemAtLogin, true, plugin);
|
||||
Register.permission(admin, op, giveItemOther, true, plugin);
|
||||
Register.permission(admin, op, useitem, true, plugin);
|
||||
Register.permission(admin, op, useitemToggle, true, plugin);
|
||||
Register.permission(admin, op, updatemsg, true, plugin);
|
||||
Register.permission(admin, op, bypass, true, plugin);
|
||||
Register.permission(admin, op, info, true, plugin);
|
||||
Register.permissionDescription(admin, "All permissions from T2C-CommandGUI", plugin);
|
||||
|
||||
|
||||
for (Gui gui : Main.guiHashMap.values()) {
|
||||
Register.permission(command + "." + gui.key, op, plugin);
|
||||
Register.permission(admin, op, command + "." + gui.key, true, plugin);
|
||||
for (Slot slot : gui.slots) {
|
||||
Register.permission(slot.permissionToUse, op, plugin);
|
||||
Register.permission(admin, op, slot.permissionToUse, true, plugin);
|
||||
Register.permission(slot.permissionToSee, op, plugin);
|
||||
Register.permission(admin, op, slot.permissionToSee, true, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,112 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Spigot.useItem;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ItemChange {
|
||||
public static void itemChange(Player player, Boolean setCursor) {
|
||||
Integer slot;
|
||||
if (SelectConfig.getUseItem_InventorySlotEnforce()) {
|
||||
slot = SelectConfig.getUseItem_InventorySlot();
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
|
||||
if (!SelectConfig.getUseItem_Enable()) {
|
||||
return;
|
||||
}
|
||||
UseItem.removeItem(player);
|
||||
if (UseItem.protection(player, false)) return;
|
||||
if (SelectConfig.getUseItem_GiveOnlyOnFirstJoin()) {
|
||||
if (!SelectConfig.getUseItem_AllowToggle() || Events.useItemHashMap.get(player.getName())) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UseItem.giveUseItem(player);
|
||||
if (setCursor) {
|
||||
setCursor(player, slot);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(Main.getPlugin(), 1L * 1);
|
||||
if (SelectConfig.getCursor_ToGUIItem_OnlyOnFirstLogin() || SelectConfig.getCursor_ToGUIItem_OnLogin()) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
send.debug(Main.getPlugin(), "GiveOnlyOnFirstJoin: " + player.getName());
|
||||
return;
|
||||
}
|
||||
if (!SelectConfig.getUseItem_GiveOnEveryJoin()) {
|
||||
send.debug(Main.getPlugin(), "!GiveOnEveryJoin: " + player.getName());
|
||||
return;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Boolean pln = Events.useItemHashMap.get(player.getName());
|
||||
if (pln == null) return;
|
||||
if (!SelectConfig.getUseItem_AllowToggle() || pln) {
|
||||
if (SelectConfig.getUseItem_InventorySlotEnforce() || player.getInventory().getItem(slot - 1) == null) {
|
||||
send.debug(Main.getPlugin(), "Give: " + player.getName());
|
||||
UseItem.giveUseItem(player);
|
||||
if (setCursor) {
|
||||
setCursor(player, slot);
|
||||
}
|
||||
} else if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) {
|
||||
boolean empty = false;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (player.getInventory().getItem(i) == null) {
|
||||
empty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty) {
|
||||
UseItem.addUseItem(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLater(Main.getPlugin(), 1L * 1);
|
||||
|
||||
}
|
||||
|
||||
private static void setCursor(Player player, int slot) {
|
||||
send.debug(Main.getPlugin(), "setCursor 1 Player: " + player.getName());
|
||||
|
||||
if (!SelectConfig.getCursor_ToGUIItem_OnLogin()) {
|
||||
return;
|
||||
}
|
||||
send.debug(Main.getPlugin(), "setCursor 2 Player: " + player.getName());
|
||||
if (SelectConfig.getCursor_ToGUIItem_OnlyOnFirstLogin()) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
send.debug(Main.getPlugin(), "setCursor 3 Player: " + player.getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
send.debug(Main.getPlugin(), "setCursor 4 Player: " + player.getName());
|
||||
if (!SelectConfig.getBungee()) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
send.debug(Main.getPlugin(), "setCursor 5 Player: " + player.getName());
|
||||
return;
|
||||
}
|
||||
send.debug(Main.getPlugin(), "setCursor 6 Player: " + player.getName());
|
||||
if (SelectConfig.getUseItem_ServerChange()) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
send.debug(Main.getPlugin(), "setCursor 7 Player: " + player.getName());
|
||||
return;
|
||||
}
|
||||
send.debug(Main.getPlugin(), "setCursor 8 Player: " + player.getName());
|
||||
send.debug(Main.getPlugin(), "setCursor bungeejoinplayers: " + Main.bungeejoinplayers);
|
||||
send.debug(Main.getPlugin(), "setCursor Player: " + player.getName());
|
||||
if (Main.bungeejoinplayers.contains(player.getName())) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
send.debug(Main.getPlugin(), "setCursor 9 Player: " + player.getName());
|
||||
Main.bungeejoinplayers.remove(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,143 +0,0 @@
|
||||
package de.jatitv.commandguiv2.Spigot.useItem;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UseItem {
|
||||
public static void giveUseItem(Player player) {
|
||||
Integer slot;
|
||||
if (protection(player, false)) return;
|
||||
if (SelectConfig.getUseItem_InventorySlotEnforce()) {
|
||||
slot = SelectConfig.getUseItem_InventorySlot();
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) {
|
||||
player.getInventory().addItem(itemStack(player));
|
||||
} else {
|
||||
send.debug(Main.getPlugin(), "setUseItem: " + player.getName() + " Slot: " + Integer.parseInt(String.valueOf(slot - 1)));
|
||||
player.getInventory().setItem(slot - 1, itemStack(player));
|
||||
}
|
||||
}
|
||||
|
||||
public static void addUseItem(Player player) {
|
||||
if (protection(player, false)) return;
|
||||
if (SelectConfig.getUseItem_InventorySlot_FreeSlot()) {
|
||||
player.getInventory().addItem(itemStack(player));
|
||||
} else player.getInventory().addItem(itemStack(player));
|
||||
}
|
||||
|
||||
private static ItemStack itemStack(Player player) {
|
||||
ItemStack item = null;
|
||||
if (SelectConfig.getUseItem_PlayerHead_Enable()) {
|
||||
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
send.player(player, Util.getPrefix() + "§c Playerheads for UseItem are only available from version §61.13§c!");
|
||||
send.error(Main.getPlugin(), "Playerheads for UseItem are only available from version 1.13!");
|
||||
} else {
|
||||
item = ItemVersion.getHeadIS();
|
||||
SkullMeta playerheadmeta = (SkullMeta) item.getItemMeta();
|
||||
playerheadmeta.setDisplayName(SelectConfig.getUseItem_Name());
|
||||
if (SelectConfig.getUseItem_Base64_Enable()) {
|
||||
if (Main.PaPi) {
|
||||
playerheadmeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore()));
|
||||
} else playerheadmeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore()));
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
|
||||
profile.getProperties().put("textures", new Property("textures", SelectConfig.getUseItem_Base64value()));
|
||||
Field profileField = null;
|
||||
try {
|
||||
profileField = playerheadmeta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(playerheadmeta, profile);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
String p;
|
||||
if (SelectConfig.getUseItem_PlayerWhoHasOpenedTheGUI()) {
|
||||
p = player.getName();
|
||||
} else p = SelectConfig.getUseItem_PlayerName();
|
||||
playerheadmeta.setOwner(p);
|
||||
if (Main.PaPi) {
|
||||
playerheadmeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore()));
|
||||
} else playerheadmeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore()));
|
||||
}
|
||||
item.setItemMeta(playerheadmeta);
|
||||
}
|
||||
} else {
|
||||
item = new ItemStack(Material.valueOf(SelectConfig.getUseItem_Material()));
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(SelectConfig.getUseItem_Name());
|
||||
if (Main.PaPi) {
|
||||
itemMeta.setLore(Replace.replace(Util.getPrefix(), player, SelectConfig.getUseItem_Lore()));
|
||||
} else itemMeta.setLore(Replace.replace(Util.getPrefix(), SelectConfig.getUseItem_Lore()));
|
||||
item.setItemMeta(itemMeta);
|
||||
item.setAmount(1);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static boolean protection(Player player, Boolean interact) {
|
||||
if (SelectConfig.getUseItemGameModeProtection()) {
|
||||
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) {
|
||||
if (interact) {
|
||||
send.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||
} else if (!SelectConfig.getUseItemGameModeRemoveItemWhenItIsDisabled()) removeItem(player);
|
||||
return true;
|
||||
}
|
||||
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) {
|
||||
if (interact) {
|
||||
send.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||
} else if (!SelectConfig.getUseItemGameModeRemoveItemWhenItIsDisabled()) removeItem(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (SelectConfig.getUseItemWorldProtection()) {
|
||||
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) {
|
||||
if (interact) {
|
||||
send.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||
} else if (!SelectConfig.getUseItemWorldRemoveItemWhenItIsDisabled()) removeItem(player);
|
||||
return true;
|
||||
}
|
||||
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) {
|
||||
if (interact) {
|
||||
send.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||
} else if (!SelectConfig.getUseItemWorldRemoveItemWhenItIsDisabled()) removeItem(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removeItem(Player player) {
|
||||
send.debug(Main.getPlugin(), "World disabled: " + player.getName() + " " + player.getWorld().toString());
|
||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
||||
ItemStack itm = player.getInventory().getItem(iam);
|
||||
if (itm != null) {
|
||||
if (itm.getType() == Material.valueOf(SelectConfig.getUseItem_Material()) || itm.getType() == ItemVersion.getHead()) {
|
||||
if (itm.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
player.getInventory().remove(itm);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
package de.jatitv.commandguiv2;
|
||||
|
||||
import net.t2code.lib.Spigot.system.T2CodeMain;
|
||||
|
||||
public class Util {
|
||||
private static Integer configVersion = 5;
|
||||
private static String requiredT2CodeLibVersion = "12.4";
|
||||
private static String Prefix = "§8[§4C§9GUI§8]";
|
||||
private static Integer SpigotID = 90671;
|
||||
private static Integer BstatsID = 10840;
|
||||
private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
|
||||
|
||||
public static String getRequiredT2CodeLibVersion() {
|
||||
return requiredT2CodeLibVersion;
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return Prefix;
|
||||
}
|
||||
|
||||
public static Integer getSpigotID() {
|
||||
return SpigotID;
|
||||
}
|
||||
|
||||
public static Integer getBstatsID() {
|
||||
return BstatsID;
|
||||
}
|
||||
|
||||
public static String getSpigot() {
|
||||
return Spigot;
|
||||
}
|
||||
|
||||
public static String getDiscord() {
|
||||
return T2CodeMain.getDiscord();
|
||||
}
|
||||
|
||||
public static Integer getConfigVersion() {
|
||||
return configVersion;
|
||||
}
|
||||
}
|
@@ -1,16 +1,14 @@
|
||||
package de.jatitv.commandguiv2.Spigot;
|
||||
//s<ds
|
||||
package net.t2code.commandguiv2.Spigot;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
||||
import de.jatitv.commandguiv2.Spigot.system.Load;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.database.MySQL;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
|
||||
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
|
||||
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
||||
import net.t2code.commandguiv2.Spigot.system.Load;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.database.MySQL;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -41,11 +39,6 @@ public final class Main extends JavaPlugin {
|
||||
public static Boolean LuckyBox = false;
|
||||
public static Boolean PlugManGUI = false;
|
||||
|
||||
public static HashMap<String, Gui> guiHashMap = new HashMap<>();
|
||||
public static ArrayList<String> allAliases = new ArrayList<>();
|
||||
|
||||
public static HashMap<String, Function> functionHashMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
@@ -53,24 +46,25 @@ public final class Main extends JavaPlugin {
|
||||
autor = this.getDescription().getAuthors();
|
||||
version = this.getDescription().getVersion();
|
||||
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
||||
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12 || MCVersion.minecraft1_13 || MCVersion.minecraft1_14 || MCVersion.minecraft1_15 || NMSVersion.v1_16_R1) {
|
||||
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12() || T2CmcVersion.isMc1_13() ||
|
||||
T2CmcVersion.isMc1_14() || T2CmcVersion.isMc1_15() || T2CmcVersion.isNms1_16_R1()) {
|
||||
legacy = true;
|
||||
}
|
||||
|
||||
if (PluginCheck.pluginCheck("CommandGUI")) {
|
||||
send.error(this, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
send.error(this, "");
|
||||
send.error(this, "An older version of the plugin T2C-CommandGUI was found!");
|
||||
send.error(this, "This plugin is now called T2C-CommandGUI and no longer CommandGUI!");
|
||||
send.error(this, "Please remove the older version (CommandGUI)!");
|
||||
send.error(this, this.getName() + " version: " + this.getDescription().getVersion() + " could not be loaded!");
|
||||
send.error(this, "");
|
||||
send.error(this, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
if (T2CpluginCheck.pluginCheck("CommandGUI")) {
|
||||
T2Csend.error( plugin, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.error( plugin,"");
|
||||
T2Csend.error( plugin,"An older version of the plugin T2C-CommandGUI was found!");
|
||||
T2Csend.error( plugin,"This plugin is now called T2C-CommandGUI and no longer CommandGUI!");
|
||||
T2Csend.error( plugin,"Please remove the older version (CommandGUI)!");
|
||||
T2Csend.error( plugin,this.getName() + " version: " + this.getDescription().getVersion() + " could not be loaded!");
|
||||
T2Csend.error( plugin,"");
|
||||
T2Csend.error( plugin,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
Main.plugin.getPluginLoader().disablePlugin(Main.plugin);
|
||||
return;
|
||||
}
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
if (PluginCheck.papi()) {
|
||||
if (T2CpluginCheck.papi()) {
|
||||
PaPi = true;
|
||||
}
|
||||
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID());
|
||||
@@ -78,24 +72,24 @@ public final class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static void addonLoad() {
|
||||
if (PluginCheck.plotSquaredGUI()) {
|
||||
if (T2CpluginCheck.plotSquaredGUI()) {
|
||||
PlotSquaredGUI = true;
|
||||
addonEnable(Bukkit.getPluginManager().getPlugin("PlotSquaredGUI"));
|
||||
}
|
||||
|
||||
if (PluginCheck.luckyBox()) {
|
||||
if (T2CpluginCheck.luckyBox()) {
|
||||
LuckyBox = true;
|
||||
addonEnable(Bukkit.getPluginManager().getPlugin("T2C-LuckyBox"));
|
||||
}
|
||||
|
||||
if (PluginCheck.plugManGUI()) {
|
||||
if (T2CpluginCheck.plugManGUI()) {
|
||||
PlugManGUI = true;
|
||||
addonEnable(Bukkit.getPluginManager().getPlugin("PlugManGUI"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void addonEnable(Plugin plugin) {
|
||||
send.console(Util.getPrefix() + " §aAddon for: §e" + plugin.getName() + "§7 - Version: " + plugin.getDescription().getVersion() + " §aloaded successfully!");
|
||||
T2Csend.console(Util.getPrefix() + " §aAddon for: §e" + plugin.getName() + "§7 - Version: " + plugin.getDescription().getVersion() + " §aloaded successfully!");
|
||||
}
|
||||
|
||||
public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||
@@ -132,13 +126,13 @@ public final class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static void sendTryCatch(Class c, StackTraceElement line) {
|
||||
send.error(plugin, c.getName() + " Line: " + line.getLineNumber());
|
||||
T2Csend.error(plugin,c.getName() + " Line: " + line.getLineNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
if (enable) T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
if (enable) T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||
MySQL.close();
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package de.jatitv.commandguiv2.Spigot.cmdManagement;
|
||||
package net.t2code.commandguiv2.Spigot.cmdManagement;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.commands.Tab;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -30,7 +30,7 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
|
||||
Player player = (Player) sender;
|
||||
Commands.gui(player);
|
||||
} else {
|
||||
if (args[0].equals(SelectConfig.getAdminSubCommand())) {
|
||||
if (args[0].equals(String.valueOf(ConfigValues.adminSubCommand.value))) {
|
||||
if (args.length == 1) {
|
||||
Help.sendHelp(sender, prefix);
|
||||
return false;
|
||||
@@ -90,7 +90,6 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
|
||||
|
||||
//TabCompleter
|
||||
|
||||
|
||||
public static HashMap<String, String> arg1 = new HashMap<String, String>();
|
||||
|
||||
private static HashMap<String, String> arg2 = new HashMap<String, String>() {{
|
||||
@@ -105,34 +104,9 @@ public class CmdExecuter_GUI implements CommandExecutor, TabCompleter {
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
Tab.tab(list, sender, 0, args, arg1);
|
||||
Tab.tab(list, sender, 0, SelectConfig.getAdminSubCommand(), 1, args, arg2);
|
||||
Tab.tab(list, sender, 1, "give", 2, args, "commandgui.giveitem.other", true);
|
||||
|
||||
// if (args.length == 1) {
|
||||
// for (String command : arg1.keySet()) {
|
||||
// Boolean passend = true;
|
||||
// for (int i = 0; i < args[0].length(); i++) {
|
||||
// if (args[0].length() >= command.length()) {
|
||||
// passend = false;
|
||||
// } else {
|
||||
// if (args[0].charAt(i) != command.charAt(i)) {
|
||||
// passend = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (hasPermission(sender, arg1.get(command)) && passend) {
|
||||
// list.add(command);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (args.length > 1) {
|
||||
// if (args[0].toLowerCase().equals("admin")){
|
||||
// return Tab.tab(sender,1,args,arg2);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
T2Ctab.tab(list, sender, 0, args, arg1);
|
||||
T2Ctab.tab(list, sender, 0, String.valueOf(ConfigValues.adminSubCommand.value), 1, args, arg2);
|
||||
T2Ctab.tab(list, sender, 1, "give", 2, args, "commandgui.giveitem.other", true);
|
||||
return list;
|
||||
}
|
||||
|
@@ -1,9 +1,10 @@
|
||||
package de.jatitv.commandguiv2.Spigot.cmdManagement;
|
||||
package net.t2code.commandguiv2.Spigot.cmdManagement;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -20,38 +21,56 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (sender.hasPermission("commandgui.useitem.toggle")) {
|
||||
if (args.length == 0) {
|
||||
if (SelectConfig.getUseItem_AllowToggle()) {
|
||||
if ((Boolean) ConfigValues.useItemAllowToggle.value) {
|
||||
Help.sendGUIItemHelp(sender);
|
||||
} else send.sender(sender, "§4UseItem toggle is disabled!");// todo
|
||||
} else T2Csend.sender(sender, "§4UseItem toggle is disabled!");// todo
|
||||
} else {
|
||||
if (args.length == 1 || args.length == 2) {
|
||||
if (args.length == 2 || args.length == 3) {
|
||||
String useItemKey= args[0];
|
||||
|
||||
if (!Cache.useItemHash.containsKey(useItemKey)){
|
||||
T2Csend.sender(sender,"das useitem " +useItemKey+" exestiert nicht");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (sender instanceof Player) {
|
||||
if (SelectConfig.getUseItem_AllowToggle()) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
if ((Boolean) ConfigValues.useItemAllowToggle.value) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "on":
|
||||
Commands.itemOn(player);
|
||||
Commands.itemOn(player, useItemKey);
|
||||
break;
|
||||
case "off":
|
||||
Commands.itemOff(player);
|
||||
Commands.itemOff(player, useItemKey);
|
||||
break;
|
||||
case "slot":
|
||||
if (args.length == 2) {
|
||||
if (args.length == 3) {
|
||||
try {
|
||||
Commands.onSetSlot(player, Integer.valueOf(args[1]));
|
||||
Commands.onSetSlot(player, useItemKey, Integer.valueOf(args[2]));
|
||||
} catch (Exception e5) {
|
||||
send.player(player, SelectMessages.ItemSlot_wrongValue);
|
||||
T2Csend.player(player, SelectMessages.ItemSlot_wrongValue);
|
||||
}
|
||||
|
||||
} else send.player(player, "§4Use: §7/gui-item slot [slot]");
|
||||
} else T2Csend.player(player, "§4Use: §7/gui-item slot [slot]");
|
||||
|
||||
break;
|
||||
default:
|
||||
Help.sendHelp(player, prefix);
|
||||
|
||||
}
|
||||
} else send.sender(sender, "§4UseItem toggle is disabled!");// todo
|
||||
} else T2Csend.sender(sender, "§4UseItem toggle is disabled!");// todo
|
||||
} else sender.sendMessage(SelectMessages.OnlyForPlayer);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +84,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
|
||||
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
|
||||
put("on", "commandgui.useitem.toggle");
|
||||
put("off", "commandgui.useitem.toggle");
|
||||
if (SelectConfig.getUseItem_AllowSetSlot()) {
|
||||
if ((Boolean) ConfigValues.useItemAllowToggle.value) {
|
||||
put("slot", "commandgui.useitem.toggle");
|
||||
}
|
||||
}};
|
||||
@@ -74,7 +93,7 @@ public class CmdExecuter_GUIItem implements CommandExecutor, TabCompleter {
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String s, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (sender instanceof Player) {
|
||||
if (SelectConfig.getUseItem_AllowToggle()) {
|
||||
if ((Boolean) ConfigValues.useItemAllowToggle.value) {
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
for (String command : arg1.keySet()) {
|
@@ -1,6 +1,6 @@
|
||||
package de.jatitv.commandguiv2.Spigot.cmdManagement;
|
||||
package net.t2code.commandguiv2.Spigot.cmdManagement;
|
||||
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
@@ -0,0 +1,208 @@
|
||||
package net.t2code.commandguiv2.Spigot.cmdManagement;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect;
|
||||
import net.t2code.commandguiv2.Spigot.config.functions.SelectFunctions;
|
||||
import net.t2code.commandguiv2.Spigot.config.gui.SelectGui;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
|
||||
import net.t2code.commandguiv2.Spigot.function.gui.OpenGUI;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.UseItem;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.LanguagesCreate;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.system.Permissions;
|
||||
import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import net.t2code.commandguiv2.Spigot.sound.PlaySound;
|
||||
import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.system.config.config.SelectLibConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Commands {
|
||||
public static void info(CommandSender sender) {
|
||||
T2Ctemplate.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
|
||||
}
|
||||
|
||||
public static void reload(CommandSender sender) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Main.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadStart);
|
||||
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||
T2Csend.console(Util.getPrefix() + " §6Plugin reload...");
|
||||
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||
try {
|
||||
ConfigSelect.selectConfig();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Main.getPlugin().reloadConfig();
|
||||
|
||||
CmdExecuter_GUI.arg1.clear();
|
||||
CmdExecuter_GUI.arg1.put(String.valueOf(ConfigValues.adminSubCommand.value), "commandgui.admin;commandgui.giveitem.other;commandgui.command.info");
|
||||
|
||||
if (!Objects.equals(SelectDatabase.getStorage().toString(), ConfigValues.storage.value)) {
|
||||
if (sender instanceof Player) T2Csend.sender(sender, "You have changed the storage medium! To apply this change, you must restart the server!");
|
||||
T2Csend.warning(Main.getPlugin(), "You have changed the storage medium! To apply this change, you must restart the server!");
|
||||
}
|
||||
|
||||
LanguagesCreate.langCreate();
|
||||
|
||||
try {
|
||||
SelectFunctions.onSelectFunction();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
SelectGui.onSelectGui();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
SelectMessages.onSelect(Util.getPrefix());
|
||||
ConfigValues.sound();
|
||||
|
||||
try {
|
||||
AliasRegister.onRegister();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Permissions.onPermRegister();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (SelectLibConfig.getBungee()) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.getPlugin(), "commandgui:bungee");
|
||||
|
||||
}
|
||||
|
||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.ReloadEnd);
|
||||
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||
T2Csend.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
||||
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void give(CommandSender sender, Player target) {
|
||||
if (Bukkit.getPlayer(target.getName()) != null) {
|
||||
UseItem.giveUseItem(target);
|
||||
T2Csend.sender(sender, SelectMessages.Give_Sender.replace("[player]", target.getName()).replace("[item]", String.valueOf(ConfigValues.useItemName.value)));
|
||||
T2Csend.player(target, SelectMessages.Give_Receiver.replace("[sender]", sender.getName()).replace("[item]", String.valueOf(ConfigValues.useItemName.value)));
|
||||
PlaySound.play(target, SoundEnum.Give);
|
||||
} else {
|
||||
sender.sendMessage(SelectMessages.PlayerNotFond.replace("[player]", target.getName()));
|
||||
if (sender instanceof Player) PlaySound.play((Player) sender, SoundEnum.PlayerNotFound);
|
||||
}
|
||||
}
|
||||
|
||||
public static void itemOn(Player player, String useItemKey) {
|
||||
UseItem.removeItem(player);
|
||||
Integer slot = null;
|
||||
if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value) {
|
||||
slot = (Integer) ConfigValues.useItemInventorySlot.value;
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
T2Csend.debug(Main.getPlugin(), String.valueOf(slot));
|
||||
if (player.getInventory().getItem(slot - 1) == null) {
|
||||
SelectDatabase.setItemStatus(player, useItemKey, true);
|
||||
UseItem.giveUseItem(player);
|
||||
} else {
|
||||
boolean empty = false;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (player.getInventory().getItem(i) == null) {
|
||||
empty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty) {
|
||||
SelectDatabase.setItemStatus(player, useItemKey, true);
|
||||
UseItem.addUseItem(player);
|
||||
T2Csend.player(player, SelectMessages.ItemON);
|
||||
} else {
|
||||
T2Csend.player(player, SelectMessages.NoInventorySpace);
|
||||
PlaySound.play(player, SoundEnum.NoInventorySpace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void itemOff(Player player, String useItemKey) {
|
||||
SelectDatabase.setItemStatus(player, useItemKey, false);
|
||||
UseItem.removeItem(player);
|
||||
T2Csend.player(player, SelectMessages.ItemOFF);
|
||||
}
|
||||
|
||||
public static void onSetSlot(Player player, String useItemKey, Integer setSlot) {
|
||||
if (!(Boolean) ConfigValues.useItemAllowSetSlot.value) {
|
||||
T2Csend.player(player, Util.getPrefix() + " §4Function disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if (setSlot < 1) {
|
||||
T2Csend.player(player, SelectMessages.ItemSlot_wrongValue);
|
||||
return;
|
||||
}
|
||||
if (setSlot > 9) {
|
||||
T2Csend.player(player, SelectMessages.ItemSlot_wrongValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
if (Objects.equals(Events.useItemSlotHashMap.get(player.getName()), setSlot)) {
|
||||
T2Csend.player(player, SelectMessages.ItemSlotAlreadySet.replace("[slot]", setSlot.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value || player.getInventory().getItem(setSlot - 1) != null) {
|
||||
T2Csend.player(player, SelectMessages.ItemSlotNotEmpty.replace("[slot]", setSlot.toString()));
|
||||
return;
|
||||
}
|
||||
|
||||
UseItem.removeItem(player);
|
||||
SelectDatabase.setSlot(player, useItemKey, setSlot);
|
||||
Events.useItemSlotHashMap.replace(player.getName(), setSlot);
|
||||
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
UseItem.giveUseItem(player);
|
||||
}
|
||||
|
||||
T2Csend.player(player, SelectMessages.ItemSlot.replace("[slot]", setSlot.toString()));
|
||||
}
|
||||
|
||||
public static void gui(Player player) {
|
||||
if (Cache.guiHashMap.containsKey(String.valueOf(ConfigValues.defaultGUI.value))) {
|
||||
GuiObject gui = Cache.guiHashMap.get(String.valueOf(ConfigValues.defaultGUI.value));
|
||||
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
|
||||
OpenGUI.openGUI(player, String.valueOf(ConfigValues.defaultGUI.value), true);
|
||||
} else T2Csend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui")
|
||||
.replace("[perm]", "commandgui.command"));
|
||||
} else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));
|
||||
}
|
||||
}
|
||||
|
||||
public static void gui(Player player, String arg) {
|
||||
if (Cache.guiHashMap.containsKey(arg)) {
|
||||
GuiObject gui = Cache.guiHashMap.get(arg);
|
||||
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + gui.key) || player.hasPermission("commandgui.bypass")) {
|
||||
OpenGUI.openGUI(player, arg, true);
|
||||
} else T2Csend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + gui.key)
|
||||
.replace("[perm]", "commandgui.command." + arg.toLowerCase()));
|
||||
} else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", gui.key));
|
||||
} else T2Csend.player(player, SelectMessages.guiNotFound.replace("[gui]", arg));
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
package net.t2code.commandguiv2.Spigot.cmdManagement;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Help {
|
||||
private static String prefix = Util.getPrefix();
|
||||
|
||||
public static void sendHelp(CommandSender sender, String Prefix) {
|
||||
GuiObject gui = Cache.guiHashMap.get(String.valueOf(ConfigValues.defaultGUI.value));
|
||||
|
||||
T2Csend.sender(sender, Prefix + " §8----- §4Command§9GUI §chelp §8-----");
|
||||
cgui(sender, gui);
|
||||
open(sender);
|
||||
help(sender);
|
||||
gUIItemHelp(sender);
|
||||
info(sender);
|
||||
give(sender);
|
||||
createDefaultGUI(sender);
|
||||
reload(sender);
|
||||
T2Csend.sender(sender, Prefix + " §8-------------------------");
|
||||
}
|
||||
|
||||
|
||||
private static void cgui(CommandSender sender, GuiObject gui) {
|
||||
if (!sender.hasPermission("commandgui.command")) return;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpCgui.replace("[gui]", T2Creplace.replace(prefix, gui.guiName)));
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.HelpCgui.replace("[gui]", T2Creplace.replace(prefix, gui.guiName)));
|
||||
}
|
||||
|
||||
private static void open(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.command")) return;
|
||||
|
||||
for (String alias : Cache.allAliases) {
|
||||
if (Cache.guiHashMap.get(alias).guiEnable || sender.hasPermission("commandgui.bypass")) {
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Cache.guiHashMap.get(alias).guiName)));
|
||||
} else
|
||||
T2Csend.sender(sender, prefix + " " + SelectMessages.HelpOpen.replace("[gui]", alias).replace("[guiname]", T2Creplace.replace(prefix, Cache.guiHashMap.get(alias).guiName)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void help(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.command")) return;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpHelp);
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.HelpHelp);
|
||||
}
|
||||
|
||||
private static void info(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.command.info")) return;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpInfo);
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.HelpInfo);
|
||||
}
|
||||
|
||||
private static void give(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.admin")) return;
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpGive);
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.HelpGive);
|
||||
}
|
||||
|
||||
private static void createDefaultGUI(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.admin")) return;
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpCreateDefaultGUI.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.HelpCreateDefaultGUI.replace("[directory]", Main.getPath() + "\\GUIs\\default.yml"));
|
||||
}
|
||||
|
||||
private static void reload(CommandSender sender) {
|
||||
if (!sender.hasPermission("commandgui.admin")) return;
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerHelpReload);
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.HelpReload);
|
||||
}
|
||||
|
||||
|
||||
public static void gUIItemHelp(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_on);
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_on);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_off);
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_off);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
T2Csend.player((Player) sender, prefix + " " + SelectMessages.PlayerGUIItemHelp_Slot);
|
||||
} else T2Csend.sender(sender, prefix + " " + SelectMessages.GUIItemHelp_Slot);
|
||||
}
|
||||
|
||||
public static void sendGUIItemHelp(CommandSender sender) {
|
||||
if (sender.hasPermission("commandgui.useitem.toggle")) {
|
||||
T2Csend.sender(sender, prefix + " §8------ §4Command§9GUI§2Item §chelp §8------");
|
||||
gUIItemHelp(sender);
|
||||
T2Csend.sender(sender, prefix + " §8------------------------------");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,27 +1,27 @@
|
||||
package de.jatitv.commandguiv2.Spigot.cmdManagement.register;
|
||||
package net.t2code.commandguiv2.Spigot.cmdManagement.register;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
|
||||
public class AliasRegister {
|
||||
public static void onRegister() {
|
||||
Plugin plugin = Main.getPlugin();
|
||||
send.debug(plugin, Bukkit.getServer().getClass().getPackage().getName());
|
||||
if (Main.allAliases.toString().equals("[]")) {
|
||||
send.console(Util.getPrefix() + " §4No GUI files available");
|
||||
T2Csend.debug(plugin, Bukkit.getServer().getClass().getPackage().getName());
|
||||
if (Cache.allAliases.toString().equals("[]")) {
|
||||
T2Csend.console(Util.getPrefix() + " §4No GUI files available");
|
||||
return;
|
||||
}
|
||||
for (String alias : Main.allAliases) {
|
||||
if (Main.guiHashMap.get(alias) != null) {
|
||||
if (Main.guiHashMap.get(alias).commandAliasEnable) {
|
||||
for (String alias : Cache.allAliases) {
|
||||
if (Cache.guiHashMap.get(alias) != null) {
|
||||
if (Cache.guiHashMap.get(alias).commandAliasEnable) {
|
||||
try {
|
||||
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||
bukkitCommandMap.setAccessible(true);
|
@@ -1,11 +1,12 @@
|
||||
package de.jatitv.commandguiv2.Spigot.cmdManagement.register;
|
||||
package net.t2code.commandguiv2.Spigot.cmdManagement.register;
|
||||
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.function.gui.OpenGUI;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -23,13 +24,13 @@ public class RegisterCommand extends Command {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
Gui gui = Main.guiHashMap.get(alias);
|
||||
GuiObject gui = Cache.guiHashMap.get(alias);
|
||||
if (gui.guiEnable || player.hasPermission("commandgui.bypass")) {
|
||||
if (!gui.commandPermissionEnable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) {
|
||||
OpenGUI.openGUI(player, alias, true);
|
||||
} else send.player(player,SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias)
|
||||
} else T2Csend.player(player, SelectMessages.NoPermissionForCommand.replace("[cmd]", "/commandgui " + alias)
|
||||
.replace("[perm]", "commandgui.command." + alias));
|
||||
} else send.player(player,SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));
|
||||
} else T2Csend.player(player,SelectMessages.GUIIsDisabled.replace("[gui]", gui.guiName));
|
||||
} else sender.sendMessage("§8[§6Command§9GUI§8] §cThis command is only for players!");
|
||||
return true;
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
package net.t2code.commandguiv2.Spigot.config.config;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
|
||||
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV6;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ConfigSelect {
|
||||
|
||||
public static void selectConfig() throws IOException {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (yamlConfiguration.contains("ConfigVersion")) {
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < (Integer) ConfigValues.configVersion.value && new File(Main.getPath(), "config.yml").exists()) {
|
||||
T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
T2Csend.console(Util.getPrefix() + " ");
|
||||
T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
|
||||
T2Csend.console(Util.getPrefix() + " ");
|
||||
T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < 5) {
|
||||
ConfigConverterV5.convert();
|
||||
config = new File(Main.getPath(), "config.yml");
|
||||
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
}
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < 6) {
|
||||
new ConfigConverterV6();
|
||||
config = new File(Main.getPath(), "config.yml");
|
||||
yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yamlConfiguration.set(ConfigValues.configVersion.path, ConfigValues.configVersion.value);
|
||||
for (ConfigValues value : ConfigValues.values()) {
|
||||
T2Cconfig.set(value.path, value.value, yamlConfiguration);
|
||||
value.value = T2Cconfig.selectObject(Util.getPrefix(), value.path, yamlConfiguration);
|
||||
}
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (
|
||||
IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
T2Csend.console(Util.getPrefix() + " §2Config was loaded successfully.");
|
||||
}
|
||||
}
|
@@ -0,0 +1,200 @@
|
||||
package net.t2code.commandguiv2.Spigot.config.config;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.enums.StorageEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public enum ConfigValues {
|
||||
|
||||
configVersion("configVersion", 6),
|
||||
debug("plugins.debug", false),
|
||||
updateCheckOnJoin("plugin.updateCheck.onJoin", true),
|
||||
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true),
|
||||
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60),
|
||||
helpAlias("plugin.helpAlias", true),
|
||||
adminSubCommand("plugin.adminSubCommand", "admin"),
|
||||
language("plugin.language", "english"),
|
||||
currency("plugin.currency", "$"),
|
||||
defaultGUI("plugin.defaultGUI", "default"),
|
||||
|
||||
|
||||
storage("storage.type", StorageEnum.SQLITE.name()),
|
||||
mysqlIp("storage.mySQL.ip", "localhost"),
|
||||
mysqlPort("storage.mySQL.port", 3306),
|
||||
mysqlDatabase("storage.mySQL.database", "database"),
|
||||
mysqlUser("storage.mySQL.user", "root"),
|
||||
mysqlPassword("storage.mySQL.password", "password"),
|
||||
mysqlSSL("storage.mySQL.ssl", false),
|
||||
|
||||
|
||||
useItemEnable("useItem.enable", true),
|
||||
useItemAllowToggle("useItem.allowToggle", true),
|
||||
useItemAllowSetSlot("useItem.allowSetSlot", true),
|
||||
useItemBlockMoveAndDrop("useItem.blockMoveAndDrop", true),
|
||||
useItemOpenGUI("useItem.openGUI", "default"),
|
||||
useItemPermission("useItem.permission.neededToUse", true),
|
||||
useItemKeepAtCommandClear("useItem.keepAtCommandClear", true),
|
||||
useItemInventorySlotFreeSlot("useItem.inventorySlot.freeSlot", 1),
|
||||
useItemInventorySlot("useItem.inventorySlot.slot", 1),
|
||||
useItemInventorySlotEnforce("useItem.inventorySlot.slotEnforce", false),
|
||||
useItemMaterial("useItem.item.material", "paper"),
|
||||
|
||||
useItemPlayerHeadEnable("useItem.item.playerHead.enable", false),
|
||||
useItemBase64Enable("useItem.item.playerHead.base64.enable", false),
|
||||
useItemBase64value("useItem.item.playerHead.base64.base64Value", ""),
|
||||
useItemPlayerWhoHasOpenedTheGUI("useItem.item.playerHead.playerWhoHasOpenedTheGUI", false),
|
||||
useItemPlayerName("useItem.item.playerHead.playerName", ""),
|
||||
useItemName("useItem.item.name", "&bDefault &6GUI"),
|
||||
useItemLore("useItem.item.lore", Collections.singletonList("&eThis is an example GUI")),
|
||||
useItemGiveOnEveryJoin("useItem.join.giveOnEveryJoin", true),
|
||||
useItemGiveOnlyOnFirstJoin("useItem.join.giveOnlyOnFirstJoin", false),
|
||||
cursorToGUIItemOnLogin("useItem.join.cursor.toGUIItem.onLogin.enable", true),
|
||||
cursorToGUIItemOnlyOnFirstLogin("useItem.join.cursor.toGUIItem.spigot.onlyOnFirstLogin", true),
|
||||
useItemServerChange("useItem.join.cursor.toGUIItem.bungee.onServerChange", false),
|
||||
|
||||
|
||||
toggleItemOnOrYesBase64("toggle.items.onOrYes.item.base64.enable", false),
|
||||
toggleItemOnOrYesBase64Value("toggle.items.onOrYes.item.base64.base64Value", ""),
|
||||
toggleItemOnOrYesMaterial("toggle.items.onOrYes.item.material", Main.legacy ? "WOOL,5" : T2CitemVersion.getGreenWool().getType().toString()),
|
||||
toggleItemOffOrNoBase64("toggle.items.offOrNo.item.base64.enable", false),
|
||||
toggleItemOffOrNoBase64Value("toggle.items.offOrNo.item.base64.base64Value", T2CitemVersion.getGreenWool().getType().toString()),
|
||||
toggleItemOffOrNoMaterial("toggle.items.offOrNo.item.material", Main.legacy ? "WOOL,14" : T2CitemVersion.getRedWool().getType().toString()),
|
||||
|
||||
|
||||
togglePermTrue("toggle.permission.commands.true", "luckperms user [player] permission set [perm] true"),
|
||||
togglePermFalse("toggle.permission.commands.false", "luckperms user [player] permission set [perm] false"),
|
||||
placeholderTrue("placeholder.True", "&2true"),
|
||||
placeholderFalse("placeholder.False", "&4false"),
|
||||
|
||||
|
||||
soundEnable("sound.enable", true),
|
||||
soundOpenInventoryEnable("sound.openInventory.enable", true),
|
||||
soundOpenInventoryInput("sound.openInventory.sound", getOpenInventory().toString()),
|
||||
soundClickEnable("sound.click.enable", true),
|
||||
soundClickInput("sound.click.sound", getClick().toString()),
|
||||
soundNoMoneyEnable("sound.noMoney.enable", true),
|
||||
soundNoMoneyInput("sound.noMoney.sound", getNoMoney().toString()),
|
||||
soundNoInventorySpaceEnable("sound.noInventorySpace.enable", true),
|
||||
soundNoInventorySpaceInput("sound.noInventorySpace.sound", getNoInventorySpace().toString()),
|
||||
soundGiveEnable("sound.give.enable", true),
|
||||
soundGiveInput("sound.give.sound", getGive().toString()),
|
||||
soundPlayerNotFoundEnable("sound.playerNotFound.enable", true),
|
||||
soundPlayerNotFoundInput("sound.playerNotFound.sound", getPlayerNotFound().toString()),
|
||||
|
||||
|
||||
useItemGameModeChangeEnable("advanced.useItem.gameMode.change.enable", true),
|
||||
useItemGameModeChangeDelayInTicks("advanced.useItem.gameMode.change.delayInTicks", 1),
|
||||
useItemGameModeProtection("advanced.useItem.gameMode.protection.enable", false),
|
||||
useItemGameModeRemoveItemWhenItIsDisabled("advanced.useItem.gameMode.protection.removeItemWhenItIsDisabled", false),
|
||||
useItemGameModeMode("advanced.useItem.gameMode.protection.mode", "blacklist"),
|
||||
useItemGameModeList("advanced.useItem.gameMode.protection.list", Arrays.asList("CREATIVE", "Spectator")),
|
||||
|
||||
useItemWorldChangeEnable("advanced.useItem.world.change.enable", true),
|
||||
useItemWorldChangeDelayInTicks("advanced.useItem.world.change.delayInTicks", 1),
|
||||
useItemWorldProtection("advanced.useItem.world.protection.enable", false),
|
||||
useItemWorldRemoveItemWhenItIsDisabled("advanced.useItem.world.protection.removeItemWhenItIsDisabled", false),
|
||||
useItemWorldMode("advanced.useItem.world.protection.mode", "blacklist"),
|
||||
useItemWorldList("advanced.useItem.world.protection.list", Arrays.asList("World1", "World2")),
|
||||
|
||||
|
||||
disableInfoBySneak("advanced.useItem.disableInfoBySneak", false),
|
||||
useItemItemBlockBlacklist("advanced.useItem.itemBlockBlacklist", getItemBlockBlacklist());
|
||||
|
||||
|
||||
public final String path;
|
||||
public Object value;
|
||||
|
||||
ConfigValues(String path, Object defaultValue) {
|
||||
this.path = path;
|
||||
this.value = defaultValue;
|
||||
}
|
||||
|
||||
public static void sound() {
|
||||
check(soundOpenInventoryInput,getOpenInventory());
|
||||
check(soundNoMoneyInput,getNoMoney());
|
||||
check(soundNoInventorySpaceInput,getNoInventorySpace());
|
||||
check(soundGiveInput,getGive());
|
||||
check(soundPlayerNotFoundInput,getPlayerNotFound());
|
||||
}
|
||||
|
||||
private static void check(ConfigValues object, Sound defaultSound){
|
||||
try {
|
||||
Sound sound = Sound.valueOf(String.valueOf(object.value));
|
||||
if (sound != null) {
|
||||
object.value = defaultSound;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Util.getPrefix())
|
||||
.replace("[sound]", "§8OpenInventory: §6" + object.value) + "§4\n§4\n§4\n");
|
||||
object.value = defaultSound;
|
||||
}
|
||||
}
|
||||
|
||||
private static Sound getOpenInventory() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
return Sound.valueOf("CHEST_OPEN");
|
||||
} else return Sound.valueOf("BLOCK_CHEST_OPEN");
|
||||
}
|
||||
|
||||
private static Sound getClick() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
return Sound.valueOf("NOTE_STICKS");
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
return Sound.valueOf("BLOCK_NOTE_HAT");
|
||||
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HAT");
|
||||
}
|
||||
|
||||
private static Sound getNoMoney() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
return Sound.valueOf("NOTE_PIANO");
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
return Sound.valueOf("BLOCK_NOTE_HARP");
|
||||
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
|
||||
}
|
||||
|
||||
private static Sound getNoInventorySpace() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
return Sound.valueOf("NOTE_PIANO");
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
return Sound.valueOf("BLOCK_NOTE_HARP");
|
||||
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
|
||||
}
|
||||
|
||||
private static Sound getGive() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
return Sound.valueOf("LEVEL_UP");
|
||||
} else return Sound.valueOf("ENTITY_PLAYER_LEVELUP");
|
||||
}
|
||||
|
||||
private static Sound getPlayerNotFound() {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
return Sound.valueOf("NOTE_PIANO");
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
return Sound.valueOf("BLOCK_NOTE_HARP");
|
||||
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
|
||||
}
|
||||
|
||||
private static List<String> getItemBlockBlacklist() {
|
||||
List<String> materialList = Arrays.asList("BUTTON", "DOOR", "FENCE", "CHEST", "FURNACE", "NOTE_BLOCK", "CRAFTING_TABLE", "WORKBENCH",
|
||||
"ANVIL", "LOOM", "COMPOSTER", "BARREL", "SMOKER", "BLAST_FURNACE", "CARTOGRAPHY_TABLE", "FLETCHING_TABLE", "GRINDSTONE",
|
||||
"SMITHING_TABLE", "STONECUTTER", "HOPPER", "DISPENSER", "DROPPER", "REPEATER", "COMPARATOR", "LEVER", "DAYLIGHT_DETECTOR", "BREWING_STAND", "TRAPDOOR", "BEACON"
|
||||
);
|
||||
|
||||
List<String> materialBlacklist = new ArrayList<>();
|
||||
for (Material material : Material.values()) {
|
||||
if (materialList.contains(material.toString())) materialBlacklist.add(material.toString());
|
||||
}
|
||||
return materialBlacklist;
|
||||
}
|
||||
}
|
@@ -0,0 +1,191 @@
|
||||
package net.t2code.commandguiv2.Spigot.config.config.old;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigCreate {
|
||||
|
||||
public static void configCreate() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
if (new File(Main.getPath(), "config.yml").exists()) {
|
||||
if (Main.getPlugin().getConfig().getBoolean("Plugin.Debug")) T2Csend.console(Util.getPrefix() + " §5DEBUG: §6" + " §4config.yml are created / updated...");
|
||||
} else T2Csend.console(Util.getPrefix() + " §4config.yml are created...");
|
||||
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
// if (!config.exists()) T2Cconfig.set("ConfigVersion", Util.getConfigVersion(), yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Plugin.Debug", false, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.updateCheck.onJoin", true, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.updateCheck.seePreReleaseUpdates", true, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.updateCheck.timeInterval", 60, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.HelpAlias", true, yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.AdminSubCommand", "admin", yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.language", "english", yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.Currency", "$", yamlConfiguration);
|
||||
T2Cconfig.set("Plugin.DefaultGUI", "default", yamlConfiguration);
|
||||
|
||||
if (Main.legacy){
|
||||
T2Cconfig.set("Storage.Type", "YML", yamlConfiguration);
|
||||
} else T2Cconfig.set("Storage.Type", "SQLITE", yamlConfiguration);
|
||||
T2Cconfig.set("Storage.MySQL.IP", "localhost", yamlConfiguration);
|
||||
T2Cconfig.set("Storage.MySQL.Port", 3306, yamlConfiguration);
|
||||
T2Cconfig.set("Storage.MySQL.Database", "database", yamlConfiguration);
|
||||
T2Cconfig.set("Storage.MySQL.User", "root", yamlConfiguration);
|
||||
T2Cconfig.set("Storage.MySQL.Password", "password", yamlConfiguration);
|
||||
T2Cconfig.set("Storage.MySQL.SSL", false, yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("BungeeCord.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("BungeeCord.ThisServer", "server", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("UseItem.Enable", true, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.AllowToggle", true, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.AllowSetSlot", true, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.BlockMoveAndDrop", true, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.OpenGUI", "default", yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Permission.NeededToUse", true, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.KeepAtCommandClear", true, yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("UseItem.InventorySlot.Slot", 1, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.InventorySlot.SlotEnforce", false, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.InventorySlot.FreeSlot", false, yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("UseItem.Item.Material", "paper", yamlConfiguration);
|
||||
if (!(T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12())) {
|
||||
T2Cconfig.set("UseItem.Item.PlayerHead.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Item.PlayerHead.Base64.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Item.PlayerHead.Base64.Base64Value", "", yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI", false, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Item.PlayerHead.Playername", "", yamlConfiguration);
|
||||
}
|
||||
T2Cconfig.set("UseItem.Item.Name", "&bDefault &6GUI", yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Item.Lore", Arrays.asList("&eThis is an example GUI"), yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Join.GiveOnEveryJoin", true, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Join.GiveOnlyOnFirstJoin", false, yamlConfiguration);
|
||||
|
||||
//convert
|
||||
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin")) {
|
||||
T2Cconfig.set( "UseItem.Join.Cursor.ToGUIItem.OnEveryLogin", yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnEveryLogin"), yamlConfiguration);
|
||||
}
|
||||
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin")) {
|
||||
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin", yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.OnOnlyFirstLogin"), yamlConfiguration);
|
||||
}
|
||||
if (yamlConfiguration.contains("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange")) {
|
||||
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange", yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", yamlConfiguration.getBoolean("UseItem.Join.Cursor.ToGUIItem.EXPERIMENTELL_ServerChange"), yamlConfiguration);
|
||||
}
|
||||
|
||||
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable", true, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.Spigot.OnOnlyFirstLogin", true, yamlConfiguration);
|
||||
T2Cconfig.set("UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange", false, yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Toggle.Items.OnOrYes.Item.Base64.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("Toggle.Items.OnOrYes.Item.Base64.Base64Value", "", yamlConfiguration);
|
||||
if (Main.legacy) {
|
||||
T2Cconfig.set("Toggle.Items.OnOrYes.Item.Material", "WOOL,5", yamlConfiguration);
|
||||
} else T2Cconfig.set("Toggle.Items.OnOrYes.Item.Material", T2CitemVersion.getGreenWool().getType().toString(), yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Toggle.Items.OffOrNo.Item.Base64.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("Toggle.Items.OffOrNo.Item.Base64.Base64Value", "", yamlConfiguration);
|
||||
if (Main.legacy) {
|
||||
T2Cconfig.set("Toggle.Items.OffOrNo.Item.Material", "WOOL,14", yamlConfiguration);
|
||||
} else T2Cconfig.set("Toggle.Items.OffOrNo.Item.Material", T2CitemVersion.getRedWool().getType().toString(), yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Toggle.Permission.Commands.True", "luckperms user [player] permission set [perm] true", yamlConfiguration);
|
||||
T2Cconfig.set("Toggle.Permission.Commands.False", "luckperms user [player] permission set [perm] false", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Placeholder.True", "&2true", yamlConfiguration);
|
||||
T2Cconfig.set("Placeholder.False", "&4false", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Sound.Enable", true, yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Sound.OpenInventory.Enable", true, yamlConfiguration);
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
T2Cconfig.set("Sound.OpenInventory.Sound", "CHEST_OPEN", yamlConfiguration);
|
||||
} else T2Cconfig.set("Sound.OpenInventory.Sound", "BLOCK_CHEST_OPEN", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Sound.Click.Enable", true, yamlConfiguration);
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
T2Cconfig.set("Sound.Click.Sound", "NOTE_STICKS", yamlConfiguration);
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
T2Cconfig.set("Sound.Click.Sound", "BLOCK_NOTE_HAT", yamlConfiguration);
|
||||
} else T2Cconfig.set("Sound.Click.Sound", "BLOCK_NOTE_BLOCK_HAT", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Sound.NoMoney.Enable", true, yamlConfiguration);
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
T2Cconfig.set("Sound.NoMoney.Sound", "NOTE_PIANO", yamlConfiguration);
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
T2Cconfig.set("Sound.NoMoney.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
|
||||
} else T2Cconfig.set("Sound.NoMoney.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Sound.NoInventorySpace.Enable", true, yamlConfiguration);
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
T2Cconfig.set("Sound.NoInventorySpace.Sound", "NOTE_PIANO", yamlConfiguration);
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
T2Cconfig.set("Sound.NoInventorySpace.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
|
||||
} else T2Cconfig.set("Sound.NoInventorySpace.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Sound.Give.Enable", true, yamlConfiguration);
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
T2Cconfig.set("Sound.Give.Sound", "LEVEL_UP", yamlConfiguration);
|
||||
} else T2Cconfig.set("Sound.Give.Sound", "ENTITY_PLAYER_LEVELUP", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Sound.PlayerNotFound.Enable", true, yamlConfiguration);
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
T2Cconfig.set("Sound.PlayerNotFound.Sound", "NOTE_PIANO", yamlConfiguration);
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
T2Cconfig.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_HARP", yamlConfiguration);
|
||||
} else T2Cconfig.set("Sound.PlayerNotFound.Sound", "BLOCK_NOTE_BLOCK_HARP", yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Advanced.UseItem.GameMode.Change.Enable", true, yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.GameMode.Change.DelayInTicks", 1, yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.GameMode.Protection.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.GameMode.Protection.Mode", "blacklist", yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.GameMode.Protection.List", Arrays.asList("CREATIVE", "Spectator"), yamlConfiguration);
|
||||
|
||||
T2Cconfig.set("Advanced.UseItem.World.Change.Enable", true, yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.World.Change.DelayInTicks", 1, yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.World.Protection.Enable", false, yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled", false, yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.World.Protection.Mode", "blacklist", yamlConfiguration);
|
||||
T2Cconfig.set("Advanced.UseItem.World.Protection.List", Arrays.asList("World1", "World2"), yamlConfiguration);
|
||||
|
||||
if (!yamlConfiguration.contains("Advanced.UseItem.ItemBlockBlacklist")) {
|
||||
List<String> materialList = Arrays.asList("BUTTON", "DOOR", "FENCE", "CHEST", "FURNACE", "NOTE_BLOCK", "CRAFTING_TABLE", "WORKBENCH",
|
||||
"ANVIL", "LOOM", "COMPOSTER", "BARREL", "SMOKER", "BLAST_FURNACE", "CARTOGRAPHY_TABLE", "FLETCHING_TABLE", "GRINDSTONE",
|
||||
"SMITHING_TABLE", "STONECUTTER", "HOPPER", "DISPENSER", "DROPPER", "REPEATER", "COMPARATOR", "LEVER", "DAYLIGHT_DETECTOR", "BREWING_STAND", "TRAPDOOR", "BEACON"
|
||||
);
|
||||
|
||||
List<String> materialBlacklist = new ArrayList<>();
|
||||
for (Material material : Material.values()) {
|
||||
for (String target : materialList) {
|
||||
if (material.toString().contains(target)) materialBlacklist.add(material.toString());
|
||||
}
|
||||
}
|
||||
T2Cconfig.set("Advanced.UseItem.ItemBlockBlacklist", materialBlacklist, yamlConfiguration);
|
||||
}
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
T2Csend.console(Util.getPrefix() + " §2config.yml were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
}
|
@@ -1,18 +1,17 @@
|
||||
package de.jatitv.commandguiv2.Spigot.config.config;
|
||||
package net.t2code.commandguiv2.Spigot.config.config.old;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SelectConfig {
|
||||
@@ -20,23 +19,27 @@ public class SelectConfig {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
|
||||
send.console(Util.getPrefix() + " §4----------------------");
|
||||
send.console(Util.getPrefix() + " ");
|
||||
send.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
|
||||
send.console(Util.getPrefix() + " ");
|
||||
send.console(Util.getPrefix() + " §4----------------------");
|
||||
if (yamlConfiguration.getInt("ConfigVersion") < 5) {
|
||||
ConfigConverterUnderV5.convert();
|
||||
}
|
||||
}
|
||||
// if (yamlConfiguration.getInt("ConfigVersion") < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) {
|
||||
// T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
// T2Csend.console(Util.getPrefix() + " ");
|
||||
// T2Csend.console(Util.getPrefix() + " §6New features have been added to CommandGUI. The Config is adapted!");
|
||||
// T2Csend.console(Util.getPrefix() + " ");
|
||||
// T2Csend.console(Util.getPrefix() + " §4----------------------");
|
||||
// if (yamlConfiguration.getInt("ConfigVersion") < 5) {
|
||||
// ConfigConverterV5.convert();
|
||||
// }
|
||||
// }
|
||||
|
||||
Debug = yamlConfiguration.getBoolean("Plugin.Debug");
|
||||
updateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.updateCheck.onJoin");
|
||||
updateCheckSeePreReleaseUpdates = yamlConfiguration.getBoolean("Plugin.updateCheck.seePreReleaseUpdates");
|
||||
updateCheckTimeInterval = yamlConfiguration.getInt("Plugin.updateCheck.timeInterval");
|
||||
HelpAlias = yamlConfiguration.getBoolean("Plugin.HelpAlias");
|
||||
adminSubCommand = yamlConfiguration.getString("Plugin.AdminSubCommand").toLowerCase();
|
||||
language = yamlConfiguration.getString("Plugin.language");
|
||||
Currency = yamlConfiguration.getString("Plugin.Currency");
|
||||
DefaultGUI = yamlConfiguration.getString("Plugin.DefaultGUI");
|
||||
|
||||
storage = yamlConfiguration.getString("Storage.Type").toUpperCase();
|
||||
|
||||
mysqlIp = yamlConfiguration.getString("Storage.MySQL.IP");
|
||||
@@ -47,7 +50,6 @@ public class SelectConfig {
|
||||
mysqlSSL = yamlConfiguration.getBoolean("Storage.MySQL.SSL");
|
||||
|
||||
Bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
|
||||
thisServer = yamlConfiguration.getString("BungeeCord.ThisServer");
|
||||
|
||||
|
||||
UseItem_Enable = yamlConfiguration.getBoolean("UseItem.Enable");
|
||||
@@ -67,7 +69,7 @@ public class SelectConfig {
|
||||
UseItem_Base64value = yamlConfiguration.getString("UseItem.Item.PlayerHead.Base64.Base64Value");
|
||||
UseItem_PlayerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI");
|
||||
UseItem_PlayerName = yamlConfiguration.getString("UseItem.Item.PlayerHead.PlayerName");
|
||||
UseItem_Name = Replace.replace(Util.getPrefix(), yamlConfiguration.getString("UseItem.Item.Name"));
|
||||
UseItem_Name = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString("UseItem.Item.Name"));
|
||||
UseItem_Lore = yamlConfiguration.getStringList("UseItem.Item.Lore");
|
||||
UseItem_GiveOnEveryJoin = yamlConfiguration.getBoolean("UseItem.Join.GiveOnEveryJoin");
|
||||
UseItem_GiveOnlyOnFirstJoin = yamlConfiguration.getBoolean("UseItem.Join.GiveOnlyOnFirstJoin");
|
||||
@@ -109,11 +111,8 @@ public class SelectConfig {
|
||||
UseItemGameModeProtection = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.Enable");
|
||||
UseItemGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled");
|
||||
UseItemGameModeMode = yamlConfiguration.getString("Advanced.UseItem.GameMode.Protection.Mode");
|
||||
List<String> gml = new ArrayList<>();
|
||||
for (String gm : yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List")) {
|
||||
gml.add(gm.toUpperCase());
|
||||
}
|
||||
UseItemGameModeList = gml;
|
||||
|
||||
UseItemGameModeList = yamlConfiguration.getStringList("Advanced.UseItem.GameMode.Protection.List");
|
||||
|
||||
UseItemWorldChangeEnable = yamlConfiguration.getBoolean("Advanced.UseItem.World.Change.Enable");
|
||||
UseItemWorldChangeDelayInTicks = yamlConfiguration.getInt("Advanced.UseItem.World.Change.DelayInTicks");
|
||||
@@ -133,50 +132,50 @@ public class SelectConfig {
|
||||
|
||||
public static void sound(String Prefix) {
|
||||
String soundOpenInventory;
|
||||
if (MCVersion.minecraft1_8) {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
soundOpenInventory = "CHEST_OPEN";
|
||||
} else {
|
||||
soundOpenInventory = "BLOCK_CHEST_OPEN";
|
||||
}
|
||||
|
||||
String soundClick;
|
||||
if (MCVersion.minecraft1_8) {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
soundClick = "NOTE_STICKS";
|
||||
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
soundClick = "BLOCK_NOTE_HAT";
|
||||
} else {
|
||||
soundClick = "BLOCK_NOTE_BLOCK_HAT";
|
||||
}
|
||||
|
||||
String soundNoMoney;
|
||||
if (MCVersion.minecraft1_8) {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
soundNoMoney = "NOTE_PIANO";
|
||||
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
soundNoMoney = "BLOCK_NOTE_HARP";
|
||||
} else {
|
||||
soundNoMoney = "BLOCK_NOTE_BLOCK_HARP";
|
||||
}
|
||||
|
||||
String soundNoInventorySpace;
|
||||
if (MCVersion.minecraft1_8) {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
soundNoInventorySpace = "NOTE_PIANO";
|
||||
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
soundNoInventorySpace = "BLOCK_NOTE_BASS";
|
||||
} else {
|
||||
soundNoInventorySpace = "BLOCK_NOTE_BLOCK_GUITAR";
|
||||
}
|
||||
|
||||
String soundGive;
|
||||
if (MCVersion.minecraft1_8) {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
soundGive = "LEVEL_UP";
|
||||
} else {
|
||||
soundGive = "ENTITY_PLAYER_LEVELUP";
|
||||
}
|
||||
|
||||
String soundPlayerNotFound;
|
||||
if (MCVersion.minecraft1_8) {
|
||||
if (T2CmcVersion.isMc1_8()) {
|
||||
soundPlayerNotFound = "NOTE_PIANO";
|
||||
} else if (MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
soundPlayerNotFound = "BLOCK_NOTE_HARP";
|
||||
} else {
|
||||
soundPlayerNotFound = "BLOCK_NOTE_BLOCK_HARP";
|
||||
@@ -188,7 +187,7 @@ public class SelectConfig {
|
||||
Sound_OpenInventory = sound_OpenInventory;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
.replace("[sound]", "§8OpenInventory: §6" + Sound_OpenInventory_input) + "§4\n§4\n§4\n");
|
||||
Sound_OpenInventory = Sound.valueOf(soundOpenInventory);
|
||||
}
|
||||
@@ -199,7 +198,7 @@ public class SelectConfig {
|
||||
Sound_Click = sound_Click;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
.replace("[sound]", "§8Click: §6" + Sound_Click_input) + "§4\n§4\n§4\n");
|
||||
Sound_Click = Sound.valueOf(soundClick);
|
||||
}
|
||||
@@ -210,7 +209,7 @@ public class SelectConfig {
|
||||
Sound_Click = sound_NoMoney;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
.replace("[sound]", "§8NoMoney: §6" + Sound_NoMoney_input) + "§4\n§4\n§4\n");
|
||||
Sound_NoMoney = Sound.valueOf(soundNoMoney);
|
||||
}
|
||||
@@ -222,7 +221,7 @@ public class SelectConfig {
|
||||
Sound_NoInventorySpace = sound_NoInventorySpace;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
.replace("[sound]", "§8NoInventorySpace: §6" + Sound_NoInventorySpace_input) + "§4\n§4\n§4\n");
|
||||
Sound_NoInventorySpace = Sound.valueOf(soundNoInventorySpace);
|
||||
}
|
||||
@@ -233,7 +232,7 @@ public class SelectConfig {
|
||||
Sound_Give = sound_Give;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
.replace("[sound]", "§8Give: §6" + Sound_Give_input) + "§4\n§4\n§4\n");
|
||||
Sound_Give = Sound.valueOf(soundGive);
|
||||
}
|
||||
@@ -244,7 +243,7 @@ public class SelectConfig {
|
||||
Sound_PlayerNotFound = sound_PlayerNotFound;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
send.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", Prefix)
|
||||
.replace("[sound]", "§8PlayerNotFound: §6" + Sound_PlayerNotFound_input) + "§4\n§4\n§4\n");
|
||||
Sound_PlayerNotFound = Sound.valueOf(soundPlayerNotFound);
|
||||
}
|
||||
@@ -254,7 +253,7 @@ public class SelectConfig {
|
||||
public static void setConfigVersion() {
|
||||
File config = new File(Main.getPath(), "config.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
yamlConfiguration.set("ConfigVersion", Util.getConfigVersion());
|
||||
// yamlConfiguration.set("ConfigVersion", Util.getConfigVersion());
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
@@ -263,6 +262,10 @@ public class SelectConfig {
|
||||
}
|
||||
|
||||
private static Boolean Debug;
|
||||
|
||||
private static Boolean updateCheckOnJoin;
|
||||
private static Boolean updateCheckSeePreReleaseUpdates;
|
||||
private static Integer updateCheckTimeInterval;
|
||||
private static Boolean HelpAlias;
|
||||
private static String adminSubCommand;
|
||||
private static String language;
|
||||
@@ -279,7 +282,6 @@ public class SelectConfig {
|
||||
|
||||
|
||||
private static Boolean Bungee;
|
||||
private static String thisServer;
|
||||
|
||||
private static String DefaultGUI;
|
||||
|
||||
@@ -365,327 +367,335 @@ public class SelectConfig {
|
||||
private static Sound Sound_PlayerNotFound;
|
||||
private static String Sound_PlayerNotFound_input;
|
||||
|
||||
public static Boolean getDebug() {
|
||||
return Debug;
|
||||
}
|
||||
|
||||
public static Boolean getHelpAlias() {
|
||||
return HelpAlias;
|
||||
}
|
||||
|
||||
public static String getAdminSubCommand() {
|
||||
return adminSubCommand;
|
||||
}
|
||||
|
||||
public static String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public static String getCurrency() {
|
||||
return Currency;
|
||||
}
|
||||
|
||||
public static String getStorage() {
|
||||
return storage;
|
||||
}
|
||||
|
||||
public static String getMysqlIp() {
|
||||
return mysqlIp;
|
||||
}
|
||||
|
||||
public static Integer getMysqlPort() {
|
||||
return mysqlPort;
|
||||
}
|
||||
|
||||
public static String getMysqlDatabase() {
|
||||
return mysqlDatabase;
|
||||
}
|
||||
|
||||
public static String getMysqlUser() {
|
||||
return mysqlUser;
|
||||
}
|
||||
|
||||
public static String getMysqlPassword() {
|
||||
return mysqlPassword;
|
||||
}
|
||||
|
||||
public static Boolean getMysqlSSL() {
|
||||
return mysqlSSL;
|
||||
}
|
||||
|
||||
public static Boolean getBungee() {
|
||||
return Bungee;
|
||||
}
|
||||
|
||||
public static String getThisServer() {
|
||||
return thisServer;
|
||||
}
|
||||
|
||||
public static String getDefaultGUI() {
|
||||
return DefaultGUI;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_Enable() {
|
||||
return UseItem_Enable;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_AllowToggle() {
|
||||
return UseItem_AllowToggle;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_AllowSetSlot() {
|
||||
return UseItem_AllowSetSlot;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_GiveOnEveryJoin() {
|
||||
return UseItem_GiveOnEveryJoin;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_GiveOnlyOnFirstJoin() {
|
||||
return UseItem_GiveOnlyOnFirstJoin;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_ServerChange() {
|
||||
return UseItem_ServerChange;
|
||||
}
|
||||
|
||||
public static Boolean getCursor_ToGUIItem_OnLogin() {
|
||||
return Cursor_ToGUIItem_OnLogin;
|
||||
}
|
||||
|
||||
public static Boolean getCursor_ToGUIItem_OnlyOnFirstLogin() {
|
||||
return Cursor_ToGUIItem_OnlyOnFirstLogin;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_BlockMoveAndDrop() {
|
||||
return UseItem_BlockMoveAndDrop;
|
||||
}
|
||||
|
||||
public static String getUseItem_OpenGUI() {
|
||||
return UseItem_OpenGUI;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_Permission() {
|
||||
return UseItem_Permission;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_KeepAtCommandClear() {
|
||||
return UseItem_KeepAtCommandClear;
|
||||
}
|
||||
|
||||
public static Boolean getUseItemGameModeChangeEnable() {
|
||||
return UseItemGameModeChangeEnable;
|
||||
}
|
||||
|
||||
public static int getUseItemGameModeChangeDelayInTicks() {
|
||||
return UseItemGameModeChangeDelayInTicks;
|
||||
}
|
||||
|
||||
public static Boolean getUseItemGameModeProtection() {
|
||||
return UseItemGameModeProtection;
|
||||
}
|
||||
|
||||
public static Boolean getUseItemGameModeRemoveItemWhenItIsDisabled() {
|
||||
return UseItemGameModeRemoveItemWhenItIsDisabled;
|
||||
}
|
||||
|
||||
public static String getUseItemGameModeMode() {
|
||||
return UseItemGameModeMode;
|
||||
}
|
||||
|
||||
public static List<String> getUseItemGameModeList() {
|
||||
return UseItemGameModeList;
|
||||
}
|
||||
|
||||
public static Boolean getUseItemWorldChangeEnable() {
|
||||
return UseItemWorldChangeEnable;
|
||||
}
|
||||
|
||||
public static int getUseItemWorldChangeDelayInTicks() {
|
||||
return UseItemWorldChangeDelayInTicks;
|
||||
}
|
||||
|
||||
public static Boolean getUseItemWorldProtection() {
|
||||
return UseItemWorldProtection;
|
||||
}
|
||||
|
||||
public static Boolean getUseItemWorldRemoveItemWhenItIsDisabled() {
|
||||
return UseItemWorldRemoveItemWhenItIsDisabled;
|
||||
}
|
||||
|
||||
public static String getUseItemWorldMode() {
|
||||
return UseItemWorldMode;
|
||||
}
|
||||
|
||||
public static List<String> getUseItemWorldList() {
|
||||
return UseItemWorldList;
|
||||
}
|
||||
|
||||
public static List<String> getUseItemItemBlockBlacklist() {
|
||||
return UseItemItemBlockBlacklist;
|
||||
}
|
||||
|
||||
public static Boolean getDisableInfoBySneak() {
|
||||
return disableInfoBySneak;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_InventorySlot_FreeSlot() {
|
||||
return UseItem_InventorySlot_FreeSlot;
|
||||
}
|
||||
|
||||
public static Integer getUseItem_InventorySlot() {
|
||||
return UseItem_InventorySlot;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_InventorySlotEnforce() {
|
||||
return UseItem_InventorySlotEnforce;
|
||||
}
|
||||
|
||||
public static String getUseItem_Material() {
|
||||
return UseItem_Material;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_PlayerHead_Enable() {
|
||||
return UseItem_PlayerHead_Enable;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_Base64_Enable() {
|
||||
return UseItem_Base64_Enable;
|
||||
}
|
||||
|
||||
public static String getUseItem_Base64value() {
|
||||
return UseItem_Base64value;
|
||||
}
|
||||
|
||||
public static Boolean getUseItem_PlayerWhoHasOpenedTheGUI() {
|
||||
return UseItem_PlayerWhoHasOpenedTheGUI;
|
||||
}
|
||||
|
||||
public static String getUseItem_PlayerName() {
|
||||
return UseItem_PlayerName;
|
||||
}
|
||||
|
||||
public static String getUseItem_Name() {
|
||||
return UseItem_Name;
|
||||
}
|
||||
|
||||
public static List<String> getUseItem_Lore() {
|
||||
return UseItem_Lore;
|
||||
}
|
||||
|
||||
public static Boolean getToggleItemOnOrYesBase64() {
|
||||
return toggleItemOnOrYesBase64;
|
||||
}
|
||||
|
||||
public static String getToggleItemOnOrYesBase64Value() {
|
||||
return toggleItemOnOrYesBase64Value;
|
||||
}
|
||||
|
||||
public static String getToggleItemOnOrYesMaterial() {
|
||||
return toggleItemOnOrYesMaterial;
|
||||
}
|
||||
|
||||
public static Boolean getToggleItemOffOrNoBase64() {
|
||||
return toggleItemOffOrNoBase64;
|
||||
}
|
||||
|
||||
public static String getToggleItemOffOrNoBase64Value() {
|
||||
return toggleItemOffOrNoBase64Value;
|
||||
}
|
||||
|
||||
public static String getToggleItemOffOrNoMaterial() {
|
||||
return toggleItemOffOrNoMaterial;
|
||||
}
|
||||
|
||||
public static String getTogglePermTrue() {
|
||||
return togglePermTrue;
|
||||
}
|
||||
|
||||
public static String getTogglePermFalse() {
|
||||
return togglePermFalse;
|
||||
}
|
||||
|
||||
public static String getPlaceholderTrue() {
|
||||
return placeholderTrue;
|
||||
}
|
||||
|
||||
public static String getPlaceholderFalse() {
|
||||
return placeholderFalse;
|
||||
}
|
||||
|
||||
public static Boolean getSound_Enable() {
|
||||
return Sound_Enable;
|
||||
}
|
||||
|
||||
public static Boolean getSound_OpenInventory_Enable() {
|
||||
return Sound_OpenInventory_Enable;
|
||||
}
|
||||
|
||||
public static Sound getSound_OpenInventory() {
|
||||
return Sound_OpenInventory;
|
||||
}
|
||||
|
||||
public static String getSound_OpenInventory_input() {
|
||||
return Sound_OpenInventory_input;
|
||||
}
|
||||
|
||||
public static Boolean getSound_Click_Enable() {
|
||||
return Sound_Click_Enable;
|
||||
}
|
||||
|
||||
public static Sound getSound_Click() {
|
||||
return Sound_Click;
|
||||
}
|
||||
|
||||
public static String getSound_Click_input() {
|
||||
return Sound_Click_input;
|
||||
}
|
||||
|
||||
public static Boolean getSound_NoMoney_Enable() {
|
||||
return Sound_NoMoney_Enable;
|
||||
}
|
||||
|
||||
public static Sound getSound_NoMoney() {
|
||||
return Sound_NoMoney;
|
||||
}
|
||||
|
||||
public static String getSound_NoMoney_input() {
|
||||
return Sound_NoMoney_input;
|
||||
}
|
||||
|
||||
public static Boolean getSound_NoInventorySpace_Enable() {
|
||||
return Sound_NoInventorySpace_Enable;
|
||||
}
|
||||
|
||||
public static Sound getSound_NoInventorySpace() {
|
||||
return Sound_NoInventorySpace;
|
||||
}
|
||||
|
||||
public static String getSound_NoInventorySpace_input() {
|
||||
return Sound_NoInventorySpace_input;
|
||||
}
|
||||
|
||||
public static Boolean getSound_Give_Enable() {
|
||||
return Sound_Give_Enable;
|
||||
}
|
||||
|
||||
public static Sound getSound_Give() {
|
||||
return Sound_Give;
|
||||
}
|
||||
|
||||
public static String getSound_Give_input() {
|
||||
return Sound_Give_input;
|
||||
}
|
||||
|
||||
public static Boolean getSound_PlayerNotFound_Enable() {
|
||||
return Sound_PlayerNotFound_Enable;
|
||||
}
|
||||
|
||||
public static Sound getSound_PlayerNotFound() {
|
||||
return Sound_PlayerNotFound;
|
||||
}
|
||||
|
||||
public static String getSound_PlayerNotFound_input() {
|
||||
return Sound_PlayerNotFound_input;
|
||||
}
|
||||
// public static Boolean getDebug() {
|
||||
// return Debug;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUpdateCheckOnJoin() {
|
||||
// return updateCheckOnJoin;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUpdateCheckSeePreReleaseUpdates() {
|
||||
// return updateCheckSeePreReleaseUpdates;
|
||||
// }
|
||||
//
|
||||
// public static Integer getUpdateCheckTimeInterval() {
|
||||
// return updateCheckTimeInterval;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getHelpAlias() {
|
||||
// return HelpAlias;
|
||||
// }
|
||||
//
|
||||
// public static String getAdminSubCommand() {
|
||||
// return adminSubCommand;
|
||||
// }
|
||||
//
|
||||
// public static String getLanguage() {
|
||||
// return language;
|
||||
// }
|
||||
//
|
||||
// public static String getCurrency() {
|
||||
// return Currency;
|
||||
// }
|
||||
//
|
||||
// public static String getStorage() {
|
||||
// return storage;
|
||||
// }
|
||||
//
|
||||
// public static String getMysqlIp() {
|
||||
// return mysqlIp;
|
||||
// }
|
||||
//
|
||||
// public static Integer getMysqlPort() {
|
||||
// return mysqlPort;
|
||||
// }
|
||||
//
|
||||
// public static String getMysqlDatabase() {
|
||||
// return mysqlDatabase;
|
||||
// }
|
||||
//
|
||||
// public static String getMysqlUser() {
|
||||
// return mysqlUser;
|
||||
// }
|
||||
//
|
||||
// public static String getMysqlPassword() {
|
||||
// return mysqlPassword;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getMysqlSSL() {
|
||||
// return mysqlSSL;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getBungee() {
|
||||
// return Bungee;
|
||||
// }
|
||||
//
|
||||
// public static String getDefaultGUI() {
|
||||
// return DefaultGUI;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_Enable() {
|
||||
// return UseItem_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_AllowToggle() {
|
||||
// return UseItem_AllowToggle;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_AllowSetSlot() {
|
||||
// return UseItem_AllowSetSlot;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_GiveOnEveryJoin() {
|
||||
// return UseItem_GiveOnEveryJoin;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_GiveOnlyOnFirstJoin() {
|
||||
// return UseItem_GiveOnlyOnFirstJoin;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_ServerChange() {
|
||||
// return UseItem_ServerChange;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getCursor_ToGUIItem_OnLogin() {
|
||||
// return Cursor_ToGUIItem_OnLogin;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getCursor_ToGUIItem_OnlyOnFirstLogin() {
|
||||
// return Cursor_ToGUIItem_OnlyOnFirstLogin;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_BlockMoveAndDrop() {
|
||||
// return UseItem_BlockMoveAndDrop;
|
||||
// }
|
||||
//
|
||||
// public static String getUseItem_OpenGUI() {
|
||||
// return UseItem_OpenGUI;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_Permission() {
|
||||
// return UseItem_Permission;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_KeepAtCommandClear() {
|
||||
// return UseItem_KeepAtCommandClear;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItemGameModeChangeEnable() {
|
||||
// return UseItemGameModeChangeEnable;
|
||||
// }
|
||||
//
|
||||
// public static int getUseItemGameModeChangeDelayInTicks() {
|
||||
// return UseItemGameModeChangeDelayInTicks;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItemGameModeProtection() {
|
||||
// return UseItemGameModeProtection;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItemGameModeRemoveItemWhenItIsDisabled() {
|
||||
// return UseItemGameModeRemoveItemWhenItIsDisabled;
|
||||
// }
|
||||
//
|
||||
// public static String getUseItemGameModeMode() {
|
||||
// return UseItemGameModeMode;
|
||||
// }
|
||||
//
|
||||
// public static List<String> getUseItemGameModeList() {
|
||||
// return UseItemGameModeList;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItemWorldChangeEnable() {
|
||||
// return UseItemWorldChangeEnable;
|
||||
// }
|
||||
//
|
||||
// public static int getUseItemWorldChangeDelayInTicks() {
|
||||
// return UseItemWorldChangeDelayInTicks;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItemWorldProtection() {
|
||||
// return UseItemWorldProtection;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItemWorldRemoveItemWhenItIsDisabled() {
|
||||
// return UseItemWorldRemoveItemWhenItIsDisabled;
|
||||
// }
|
||||
//
|
||||
// public static String getUseItemWorldMode() {
|
||||
// return UseItemWorldMode;
|
||||
// }
|
||||
//
|
||||
// public static List<String> getUseItemWorldList() {
|
||||
// return UseItemWorldList;
|
||||
// }
|
||||
//
|
||||
// public static List<String> getUseItemItemBlockBlacklist() {
|
||||
// return UseItemItemBlockBlacklist;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getDisableInfoBySneak() {
|
||||
// return disableInfoBySneak;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_InventorySlot_FreeSlot() {
|
||||
// return UseItem_InventorySlot_FreeSlot;
|
||||
// }
|
||||
//
|
||||
// public static Integer getUseItem_InventorySlot() {
|
||||
// return UseItem_InventorySlot;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_InventorySlotEnforce() {
|
||||
// return UseItem_InventorySlotEnforce;
|
||||
// }
|
||||
//
|
||||
// public static String getUseItem_Material() {
|
||||
// return UseItem_Material;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_PlayerHead_Enable() {
|
||||
// return UseItem_PlayerHead_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_Base64_Enable() {
|
||||
// return UseItem_Base64_Enable;
|
||||
// }
|
||||
//
|
||||
// public static String getUseItem_Base64value() {
|
||||
// return UseItem_Base64value;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getUseItem_PlayerWhoHasOpenedTheGUI() {
|
||||
// return UseItem_PlayerWhoHasOpenedTheGUI;
|
||||
// }
|
||||
//
|
||||
// public static String getUseItem_PlayerName() {
|
||||
// return UseItem_PlayerName;
|
||||
// }
|
||||
//
|
||||
// public static String getUseItem_Name() {
|
||||
// return UseItem_Name;
|
||||
// }
|
||||
//
|
||||
// public static List<String> getUseItem_Lore() {
|
||||
// return UseItem_Lore;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getToggleItemOnOrYesBase64() {
|
||||
// return toggleItemOnOrYesBase64;
|
||||
// }
|
||||
//
|
||||
// public static String getToggleItemOnOrYesBase64Value() {
|
||||
// return toggleItemOnOrYesBase64Value;
|
||||
// }
|
||||
//
|
||||
// public static String getToggleItemOnOrYesMaterial() {
|
||||
// return toggleItemOnOrYesMaterial;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getToggleItemOffOrNoBase64() {
|
||||
// return toggleItemOffOrNoBase64;
|
||||
// }
|
||||
//
|
||||
// public static String getToggleItemOffOrNoBase64Value() {
|
||||
// return toggleItemOffOrNoBase64Value;
|
||||
// }
|
||||
//
|
||||
// public static String getToggleItemOffOrNoMaterial() {
|
||||
// return toggleItemOffOrNoMaterial;
|
||||
// }
|
||||
//
|
||||
// public static String getTogglePermTrue() {
|
||||
// return togglePermTrue;
|
||||
// }
|
||||
//
|
||||
// public static String getTogglePermFalse() {
|
||||
// return togglePermFalse;
|
||||
// }
|
||||
//
|
||||
// public static String getPlaceholderTrue() {
|
||||
// return placeholderTrue;
|
||||
// }
|
||||
//
|
||||
// public static String getPlaceholderFalse() {
|
||||
// return placeholderFalse;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getSound_Enable() {
|
||||
// return Sound_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getSound_OpenInventory_Enable() {
|
||||
// return Sound_OpenInventory_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Sound getSound_OpenInventory() {
|
||||
// return Sound_OpenInventory;
|
||||
// }
|
||||
//
|
||||
// public static String getSound_OpenInventory_input() {
|
||||
// return Sound_OpenInventory_input;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getSound_Click_Enable() {
|
||||
// return Sound_Click_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Sound getSound_Click() {
|
||||
// return Sound_Click;
|
||||
// }
|
||||
//
|
||||
// public static String getSound_Click_input() {
|
||||
// return Sound_Click_input;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getSound_NoMoney_Enable() {
|
||||
// return Sound_NoMoney_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Sound getSound_NoMoney() {
|
||||
// return Sound_NoMoney;
|
||||
// }
|
||||
//
|
||||
// public static String getSound_NoMoney_input() {
|
||||
// return Sound_NoMoney_input;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getSound_NoInventorySpace_Enable() {
|
||||
// return Sound_NoInventorySpace_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Sound getSound_NoInventorySpace() {
|
||||
// return Sound_NoInventorySpace;
|
||||
// }
|
||||
//
|
||||
// public static String getSound_NoInventorySpace_input() {
|
||||
// return Sound_NoInventorySpace_input;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getSound_Give_Enable() {
|
||||
// return Sound_Give_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Sound getSound_Give() {
|
||||
// return Sound_Give;
|
||||
// }
|
||||
//
|
||||
// public static String getSound_Give_input() {
|
||||
// return Sound_Give_input;
|
||||
// }
|
||||
//
|
||||
// public static Boolean getSound_PlayerNotFound_Enable() {
|
||||
// return Sound_PlayerNotFound_Enable;
|
||||
// }
|
||||
//
|
||||
// public static Sound getSound_PlayerNotFound() {
|
||||
// return Sound_PlayerNotFound;
|
||||
// }
|
||||
//
|
||||
// public static String getSound_PlayerNotFound_input() {
|
||||
// return Sound_PlayerNotFound_input;
|
||||
// }
|
||||
}
|
@@ -1,12 +1,13 @@
|
||||
package de.jatitv.commandguiv2.Spigot.config.configConverter;
|
||||
package net.t2code.commandguiv2.Spigot.config.configConverter;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.functions.CreateFunctions;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@@ -15,26 +16,26 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigConverterUnderV5 {
|
||||
public class ConfigConverterV5 {
|
||||
public static void renameMainFolder() {
|
||||
if (new File("plugins/CommandGUI").exists() && !Main.getPath().exists()) {
|
||||
File oldF = new File("plugins/CommandGUI");
|
||||
File newF = new File("plugins/T2C-CommandGUI");
|
||||
|
||||
if (oldF.renameTo(newF)) {
|
||||
send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
send.error(Main.getPlugin(), "");
|
||||
send.warning(Main.getPlugin(), "File renamed successfully");
|
||||
send.warning(Main.getPlugin(), "The plugin folder has been renamed from 'CommandGUI' to 'T2C-CommandGUI");
|
||||
send.error(Main.getPlugin(), "");
|
||||
send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.error(Main.getPlugin(), "");
|
||||
T2Csend.warning(Main.getPlugin(), "File renamed successfully");
|
||||
T2Csend.warning(Main.getPlugin(), "The plugin folder has been renamed from 'CommandGUI' to 'T2C-CommandGUI");
|
||||
T2Csend.error(Main.getPlugin(), "");
|
||||
T2Csend.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
} else {
|
||||
send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
send.error(Main.getPlugin(), "");
|
||||
send.error(Main.getPlugin(), "Failed to rename file");
|
||||
send.error(Main.getPlugin(), "An error occurred while renaming the plugin folder from 'CommandGUI' to 'T2C-CommandGUI'! Please report on our Discord: " + Util.getDiscord());
|
||||
send.error(Main.getPlugin(), "");
|
||||
send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.error(Main.getPlugin(), "");
|
||||
T2Csend.error(Main.getPlugin(), "Failed to rename file");
|
||||
T2Csend.error(Main.getPlugin(), "An error occurred while renaming the plugin folder from 'CommandGUI' to 'T2C-CommandGUI'! Please report on our Discord: " + Util.getDiscord());
|
||||
T2Csend.error(Main.getPlugin(), "");
|
||||
T2Csend.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,23 +50,23 @@ public class ConfigConverterUnderV5 {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
send.error(Main.getPlugin(), "");
|
||||
send.warning(Main.getPlugin(), "'Slots.Function.NoPermission.Message.Enable' was added to the function " + config.getName() + "!");
|
||||
send.warning(Main.getPlugin(), "'Slots.Function.NoPermission.Message.CustomNoPermMessage' was added to the function " + config.getName() + "!");
|
||||
send.warning(Main.getPlugin(), "'Slots.Function.NoPermission.Item.Lore.Enable' was added to the function " + config.getName() + "!");
|
||||
send.warning(Main.getPlugin(), "'Slots.Function.NoPermission.Item.Lore.Lore' was added to the function " + config.getName() + "!");
|
||||
send.error(Main.getPlugin(), "");
|
||||
send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.error(Main.getPlugin(), "");
|
||||
T2Csend.warning(Main.getPlugin(), "'Slots.Function.NoPermission.Message.Enable' was added to the function " + config.getName() + "!");
|
||||
T2Csend.warning(Main.getPlugin(), "'Slots.Function.NoPermission.Message.CustomNoPermMessage' was added to the function " + config.getName() + "!");
|
||||
T2Csend.warning(Main.getPlugin(), "'Slots.Function.NoPermission.Item.Lore.Enable' was added to the function " + config.getName() + "!");
|
||||
T2Csend.warning(Main.getPlugin(), "'Slots.Function.NoPermission.Item.Lore.Lore' was added to the function " + config.getName() + "!");
|
||||
T2Csend.error(Main.getPlugin(), "");
|
||||
T2Csend.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
}
|
||||
|
||||
public static void convert() {
|
||||
renameFolder();
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4Config conversion to the new config structure starts!");
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4Config conversion to the new config structure starts!");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
|
||||
File f = new File(Main.getPath() + "/OldConfig/GUIs/Version4");
|
||||
File[] fileArray = f.listFiles();
|
||||
|
||||
@@ -77,13 +78,15 @@ public class ConfigConverterUnderV5 {
|
||||
File config = new File(Main.getPath(), "GUIs/" + configOld.getName().replace(".yml", "") + ".yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
yamlConfiguration.set(ConfigValues.configVersion.path, 5);
|
||||
|
||||
Boolean enable = yamlConfigurationOld.getBoolean("GUI.Enable");
|
||||
Integer lines = yamlConfigurationOld.getInt("GUI.Lines");
|
||||
|
||||
String name = yamlConfigurationOld.getString("GUI.Name");
|
||||
Boolean fillItemEnable = yamlConfigurationOld.getBoolean("GUI.FillItem.Enable");
|
||||
String fillItem;
|
||||
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
fillItem = yamlConfigurationOld.getString("GUI.FillItem.GlassPaneColor");
|
||||
} else fillItem = yamlConfigurationOld.getString("GUI.FillItem.Item");
|
||||
|
||||
@@ -162,11 +165,11 @@ public class ConfigConverterUnderV5 {
|
||||
}
|
||||
}
|
||||
}
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4The conversion to the new config structure is completed!");
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
|
||||
send.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4The conversion to the new config structure is completed!");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7]");
|
||||
T2Csend.console(Util.getPrefix() + " §7[§5ConfigConvert§7] §4----------------------");
|
||||
}
|
||||
|
||||
private static void renameFolder() {
|
||||
@@ -185,7 +188,7 @@ public class ConfigConverterUnderV5 {
|
||||
set("GUI.Lines", lines, yamlConfiguration);
|
||||
set("GUI.Name", name, yamlConfiguration);
|
||||
set("GUI.FillItem.Enable", fillItemEnable, yamlConfiguration);
|
||||
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
set("GUI.FillItem.GlassPaneColor", fillItem, yamlConfiguration);
|
||||
} else set("GUI.FillItem.Item", fillItem, yamlConfiguration);
|
||||
|
@@ -0,0 +1,134 @@
|
||||
package net.t2code.commandguiv2.Spigot.config.configConverter;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ConfigConverterV6 {
|
||||
|
||||
public ConfigConverterV6() {
|
||||
try {
|
||||
convert();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private File configOld;
|
||||
private YamlConfiguration yamlConfigurationOld;
|
||||
|
||||
private File defaultUseItem = new File(Main.getPath(), "UseItems/default.yml");
|
||||
private YamlConfiguration yamlConfigurationUseItem = YamlConfiguration.loadConfiguration(defaultUseItem);
|
||||
|
||||
private void convert() throws IOException {
|
||||
|
||||
|
||||
File oldF = new File("plugins/T2C-CommandGUI/config.yml");
|
||||
File newF = new File("plugins/T2C-CommandGUI/configV5.yml");
|
||||
oldF.renameTo(newF);
|
||||
|
||||
configOld = new File(Main.getPath(), "configV5.yml");
|
||||
yamlConfigurationOld = YamlConfiguration.loadConfiguration(configOld);
|
||||
set(ConfigValues.debug, "Plugin.Debug");
|
||||
|
||||
set(ConfigValues.updateCheckOnJoin, "Plugin.updateCheck.onJoin");
|
||||
set(ConfigValues.updateCheckSeePreReleaseUpdates, "Plugin.updateCheck.seePreReleaseUpdates");
|
||||
set(ConfigValues.updateCheckTimeInterval, "Plugin.updateCheck.timeInterval");
|
||||
set(ConfigValues.helpAlias, "Plugin.HelpAlias");
|
||||
set(ConfigValues.adminSubCommand, "Plugin.AdminSubCommand");
|
||||
set(ConfigValues.language, "Plugin.language");
|
||||
set(ConfigValues.currency, "Plugin.Currency");
|
||||
set(ConfigValues.defaultGUI, "Plugin.DefaultGUI");
|
||||
|
||||
set(ConfigValues.storage, "Storage.Type");
|
||||
set(ConfigValues.mysqlIp, "Storage.MySQL.IP");
|
||||
set(ConfigValues.mysqlPort, "Storage.MySQL.Port");
|
||||
set(ConfigValues.mysqlDatabase, "Storage.MySQL.Database");
|
||||
set(ConfigValues.mysqlUser, "Storage.MySQL.User");
|
||||
set(ConfigValues.mysqlPassword, "Storage.MySQL.Password");
|
||||
set(ConfigValues.mysqlSSL, "Storage.MySQL.SSL");
|
||||
|
||||
set(ConfigValues.useItemEnable, "UseItem.Enable");
|
||||
set(ConfigValues.useItemAllowToggle, "UseItem.AllowToggle");
|
||||
set(ConfigValues.useItemAllowSetSlot, "UseItem.AllowSetSlot");
|
||||
set(ConfigValues.useItemBlockMoveAndDrop, "UseItem.BlockMoveAndDrop");
|
||||
set(ConfigValues.useItemOpenGUI, "UseItem.OpenGUI");
|
||||
set(ConfigValues.useItemPermission, "UseItem.Permission.NeededToUse");
|
||||
set(ConfigValues.useItemKeepAtCommandClear, "UseItem.KeepAtCommandClear");
|
||||
|
||||
set(ConfigValues.useItemInventorySlotFreeSlot, "UseItem.InventorySlot.FreeSlot");
|
||||
set(ConfigValues.useItemInventorySlot, "UseItem.InventorySlot.Slot");
|
||||
set(ConfigValues.useItemInventorySlotEnforce, "UseItem.InventorySlot.SlotEnforce");
|
||||
set(ConfigValues.useItemMaterial, "UseItem.Item.Material");
|
||||
|
||||
set(ConfigValues.useItemPlayerHeadEnable, "UseItem.Item.PlayerHead.Enable");
|
||||
set(ConfigValues.useItemBase64Enable, "UseItem.Item.PlayerHead.Base64.Enable");
|
||||
set(ConfigValues.useItemBase64value, "UseItem.Item.PlayerHead.Base64.Base64Value");
|
||||
set(ConfigValues.useItemPlayerWhoHasOpenedTheGUI, "UseItem.Item.PlayerHead.PlayerWhoHasOpenedTheGUI");
|
||||
set(ConfigValues.useItemPlayerName, "UseItem.Item.PlayerHead.PlayerName");
|
||||
set(ConfigValues.useItemName, "UseItem.Item.Name");
|
||||
set(ConfigValues.useItemLore, "UseItem.Item.Lore");
|
||||
set(ConfigValues.useItemGiveOnEveryJoin, "UseItem.Join.GiveOnEveryJoin");
|
||||
set(ConfigValues.useItemGiveOnlyOnFirstJoin, "UseItem.Join.GiveOnlyOnFirstJoin");
|
||||
set(ConfigValues.cursorToGUIItemOnLogin, "UseItem.Join.Cursor.ToGUIItem.OnLogin.Enable");
|
||||
set(ConfigValues.cursorToGUIItemOnlyOnFirstLogin, "UseItem.Join.Cursor.ToGUIItem.Spigot.OnlyOnFirstLogin");
|
||||
set(ConfigValues.useItemServerChange, "UseItem.Join.Cursor.ToGUIItem.Bungee.OnServerChange");
|
||||
|
||||
set(ConfigValues.toggleItemOnOrYesBase64, "Toggle.Items.OnOrYes.Item.Base64.Enable");
|
||||
set(ConfigValues.toggleItemOnOrYesBase64Value, "Toggle.Items.OnOrYes.Item.Base64.Base64Value");
|
||||
set(ConfigValues.toggleItemOnOrYesMaterial, "Toggle.Items.OnOrYes.Item.Material");
|
||||
|
||||
set(ConfigValues.toggleItemOffOrNoBase64, "Toggle.Items.OffOrNo.Item.Base64.Enable");
|
||||
set(ConfigValues.toggleItemOffOrNoBase64Value, "Toggle.Items.OffOrNo.Item.Base64.Base64Value");
|
||||
set(ConfigValues.toggleItemOffOrNoMaterial, "Toggle.Items.OffOrNo.Item.Material");
|
||||
|
||||
set(ConfigValues.togglePermTrue, "Toggle.Permission.Commands.True");
|
||||
set(ConfigValues.togglePermFalse, "Toggle.Permission.Commands.False");
|
||||
|
||||
set(ConfigValues.placeholderTrue, "Placeholder.True");
|
||||
set(ConfigValues.placeholderFalse, "Placeholder.False");
|
||||
|
||||
set(ConfigValues.soundEnable, "Sound.Enable");
|
||||
set(ConfigValues.soundOpenInventoryEnable, "Sound.OpenInventory.Enable");
|
||||
set(ConfigValues.soundOpenInventoryInput, "Sound.OpenInventory.Sound");
|
||||
set(ConfigValues.soundClickEnable, "Sound.Click.Enable");
|
||||
set(ConfigValues.soundClickInput, "Sound.Click.Sound");
|
||||
set(ConfigValues.soundNoMoneyEnable, "Sound.NoMoney.Enable");
|
||||
set(ConfigValues.soundNoMoneyInput, "Sound.NoMoney.Sound");
|
||||
|
||||
set(ConfigValues.soundNoInventorySpaceEnable, "Sound.NoInventorySpace.Enable");
|
||||
set(ConfigValues.soundNoInventorySpaceInput, "Sound.NoInventorySpace.Sound");
|
||||
set(ConfigValues.soundGiveEnable, "Sound.Give.Enable");
|
||||
set(ConfigValues.soundGiveInput, "Sound.Give.Sound");
|
||||
set(ConfigValues.soundPlayerNotFoundEnable, "Sound.PlayerNotFound.Enable");
|
||||
set(ConfigValues.soundPlayerNotFoundInput, "Sound.PlayerNotFound.Sound");
|
||||
|
||||
set(ConfigValues.useItemGameModeChangeEnable, "Advanced.UseItem.GameMode.Change.Enable");
|
||||
set(ConfigValues.useItemGameModeChangeDelayInTicks, "Advanced.UseItem.GameMode.Change.DelayInTicks");
|
||||
set(ConfigValues.useItemGameModeProtection, "Advanced.UseItem.GameMode.Protection.Enable");
|
||||
set(ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled, "Advanced.UseItem.GameMode.Protection.RemoveItemWhenItIsDisabled");
|
||||
set(ConfigValues.useItemGameModeMode, "Advanced.UseItem.GameMode.Protection.Mode");
|
||||
|
||||
set(ConfigValues.useItemGameModeList, "Advanced.UseItem.GameMode.Protection.List");
|
||||
|
||||
set(ConfigValues.useItemWorldChangeEnable, "Advanced.UseItem.World.Change.Enable");
|
||||
set(ConfigValues.useItemWorldChangeDelayInTicks, "Advanced.UseItem.World.Change.DelayInTicks");
|
||||
set(ConfigValues.useItemWorldProtection, "Advanced.UseItem.World.Protection.Enable");
|
||||
set(ConfigValues.useItemWorldRemoveItemWhenItIsDisabled, "Advanced.UseItem.World.Protection.RemoveItemWhenItIsDisabled");
|
||||
set(ConfigValues.useItemWorldMode, "Advanced.UseItem.World.Protection.Mode");
|
||||
set(ConfigValues.useItemWorldList, "Advanced.UseItem.World.Protection.List");
|
||||
|
||||
set(ConfigValues.disableInfoBySneak, "Advanced.UseItem.DisableInfoBySneak");
|
||||
|
||||
|
||||
set(ConfigValues.useItemItemBlockBlacklist, "Advanced.UseItem.ItemBlockBlacklist");
|
||||
}
|
||||
|
||||
private void set(ConfigValues obj, String path) {
|
||||
if (!yamlConfigurationOld.contains(path)) return;
|
||||
obj.value = yamlConfigurationOld.get(path);
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
package de.jatitv.commandguiv2.Spigot.config.functions;
|
||||
package net.t2code.commandguiv2.Spigot.config.functions;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
@@ -56,7 +56,7 @@ public class CreateFunctions {
|
||||
i++;
|
||||
}
|
||||
|
||||
send.console(Util.getPrefix() + " §4Function GUI file (Functions/" + config.getName() + ") is loaded...");
|
||||
T2Csend.console(Util.getPrefix() + " §4Function GUI file (Functions/" + config.getName() + ") is loaded...");
|
||||
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
@@ -130,7 +130,7 @@ public class CreateFunctions {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
send.console(Util.getPrefix() + " §2Function file (Functions/" + config.getName() + ") was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Csend.console(Util.getPrefix() + " §2Function file (Functions/" + config.getName() + ") was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
|
||||
}
|
||||
|
@@ -1,102 +1,22 @@
|
||||
package de.jatitv.commandguiv2.Spigot.objects;
|
||||
package net.t2code.commandguiv2.Spigot.config.functions;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
|
||||
import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.EcoEnum;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
|
||||
import net.t2code.commandguiv2.Spigot.enums.EcoEnum;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Obj_Select {
|
||||
public static void onSelect() {
|
||||
onSelectFunction();
|
||||
onSelectGui();
|
||||
}
|
||||
|
||||
public static void onSelectGui() {
|
||||
Main.guiHashMap.clear();
|
||||
Main.allAliases.clear();
|
||||
File f = new File(Main.getPath() + "/GUIs/");
|
||||
File[] fileArray = f.listFiles();
|
||||
|
||||
for (File config : fileArray) {
|
||||
try {
|
||||
if (config.getName().equals("guiDeclaration.yml")) continue;
|
||||
String sub = config.getName().substring(config.getName().length() - 4);
|
||||
if (sub.equals(".yml")) {
|
||||
String key = config.getName().replace(".yml", "");
|
||||
Main.allAliases.add(key);
|
||||
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable");
|
||||
Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines");
|
||||
if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) {
|
||||
yamlConfiguration_gui.set("GUI.Lines", 6);
|
||||
}
|
||||
if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) {
|
||||
yamlConfiguration_gui.set("GUI.Lines", 1);
|
||||
}
|
||||
|
||||
String guiName = yamlConfiguration_gui.getString("GUI.Name");
|
||||
Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable");
|
||||
String guiFillItemItem;
|
||||
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor");
|
||||
} else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item");
|
||||
|
||||
Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias");
|
||||
Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
|
||||
|
||||
ArrayList<Slot> slots = new ArrayList<>();
|
||||
for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
|
||||
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1;
|
||||
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable");
|
||||
String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function");
|
||||
Function functionCheck = Main.functionHashMap.get(function);
|
||||
if (functionCheck == null) {
|
||||
send.error(Main.getPlugin(), "The Function " + function + " in the GUI " + key + " does not exist!");
|
||||
}
|
||||
Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Permission.Required");
|
||||
String permSee = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.See");
|
||||
String permUse = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.Use");
|
||||
|
||||
Slot slot = new Slot(slotNumber, enable, function, permRequired,
|
||||
permSee.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
|
||||
.replace("[slotname]", slotKey.toLowerCase()),
|
||||
permUse.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
|
||||
.replace("[slotname]", slotKey.toLowerCase()));
|
||||
slots.add(slot);
|
||||
}
|
||||
Gui gui = new Gui(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem,
|
||||
key, commandAliasEnable, commandPermission, slots);
|
||||
|
||||
Main.guiHashMap.put(key, gui);
|
||||
CmdExecuter_GUI.arg1.put(config.getName()
|
||||
.replace(".yml", ""), "commandgui.gui." + key);
|
||||
|
||||
|
||||
yamlConfiguration_gui.save(config);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class SelectFunctions {
|
||||
public static void onSelectFunction() {
|
||||
Main.functionHashMap.clear();
|
||||
Cache.functionHashMap.clear();
|
||||
File f = new File(Main.getPath() + "/Functions/");
|
||||
File[] fileArray = f.listFiles();
|
||||
|
||||
@@ -118,7 +38,7 @@ public class Obj_Select {
|
||||
String name = yamlConfiguration.getString("Slots.Function.Item.Name");
|
||||
List<String> lore = yamlConfiguration.getStringList("Slots.Function.Item.Lore");
|
||||
if (yamlConfiguration.get("Slots.Function.NoPermission") == null) {
|
||||
ConfigConverterUnderV5.noPermLore(yamlConfiguration, config);
|
||||
ConfigConverterV5.noPermLore(yamlConfiguration, config);
|
||||
}
|
||||
Boolean noPermMessageEnable = yamlConfiguration.getBoolean("Slots.Function.NoPermission.Message.Enable");
|
||||
String customNoPermMessage = yamlConfiguration.getString("Slots.Function.NoPermission.Message.CustomNoPermMessage");
|
||||
@@ -133,7 +53,7 @@ public class Obj_Select {
|
||||
try {
|
||||
ecoModule = EcoEnum.valueOf(yamlConfiguration.getString("Slots.Function.Cost.EcoModule").toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
send.error(Main.getPlugin(), "The EcoModule " + yamlConfiguration.getString("Slots.Function.Cost.EcoModule").toUpperCase() + " in the function file "
|
||||
T2Csend.error(Main.getPlugin(), "The EcoModule " + yamlConfiguration.getString("Slots.Function.Cost.EcoModule").toUpperCase() + " in the function file "
|
||||
+ config.getName() + " does not exist. Please use one of the supported modules. (VAULT, ITEM, VOTEPOINTS)");
|
||||
}
|
||||
} else ecoModule = EcoEnum.VAULT;
|
||||
@@ -182,7 +102,7 @@ public class Obj_Select {
|
||||
try {
|
||||
functionVotePointsMode = FunctionVoteEnum.valueOf(yamlConfiguration.getString("Slots.Function.FunctionVotePoints.Mode").toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
send.error(Main.getPlugin(), "The VotePoints Mode " + yamlConfiguration.getString("Slots.Function.FunctionVotePoints.Mode").toUpperCase() + " in the function file "
|
||||
T2Csend.error(Main.getPlugin(), "The VotePoints Mode " + yamlConfiguration.getString("Slots.Function.FunctionVotePoints.Mode").toUpperCase() + " in the function file "
|
||||
+ config.getName() + " does not exist. Please use one of the supported modules. (ADD, REMOVE)");
|
||||
}
|
||||
}
|
||||
@@ -194,13 +114,13 @@ public class Obj_Select {
|
||||
try {
|
||||
functionItemMode = FunctionItemEnum.valueOf(yamlConfiguration.getString("Slots.Function.FunctionItem.Mode").toUpperCase());
|
||||
} catch (Exception ex) {
|
||||
send.error(Main.getPlugin(), "The Item Mode " + yamlConfiguration.getString("Slots.Function.FunctionItem.Mode").toUpperCase() + " in the function file "
|
||||
T2Csend.error(Main.getPlugin(), "The Item Mode " + yamlConfiguration.getString("Slots.Function.FunctionItem.Mode").toUpperCase() + " in the function file "
|
||||
+ config.getName() + " does not exist. Please use one of the supported modules. (ADD, REMOVE)");
|
||||
}
|
||||
}
|
||||
String functionItemItem = yamlConfiguration.getString("Slots.Function.FunctionItem.Item");
|
||||
|
||||
Function function = new Function(key, empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore,
|
||||
FunctionObject function = new FunctionObject(key, empty, itemAmount, playerHead_Enable, base64_Enable, base64Value, playerWhoHasOpenedTheGUI, playerName, item, name, lore,
|
||||
noPermMessageEnable, customNoPermMessage, noPermLoreEnable, noPermLore,
|
||||
customSound_Enable, customSound_NoSound, customSound_Sound, cost_Enable, ecoModule, ecoItem, votePoints, price, command_Enable, command_BungeeCommand,
|
||||
commandAsConsole, command, serverChange, serverChangeServer, openGUI_Enable, openGUI, togglePermission, togglePermissionPerm, toggleUseItem, message_Enable,
|
||||
@@ -208,7 +128,7 @@ public class Obj_Select {
|
||||
configDoubleValueLeft, configListValueLeft, configStringValueRight, configBooleanValueRight, configIntegerValueRight, configDoubleValueRight,
|
||||
configListValueRight, pluginReloadEnable, pluginReloadCommand, functionVotePoints, functionVotePointsMode, functionVotePointsAmount,
|
||||
functionItem, functionItemMode, functionItemItem);
|
||||
Main.functionHashMap.put(key, function);
|
||||
Cache.functionHashMap.put(key, function);
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
@@ -218,4 +138,5 @@ public class Obj_Select {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,21 +1,19 @@
|
||||
package de.jatitv.commandguiv2.Spigot.config.gui;
|
||||
package net.t2code.commandguiv2.Spigot.config.gui;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CreateGUI {
|
||||
public static void configCreate() {
|
||||
long long_ = System.currentTimeMillis();
|
||||
send.console(Util.getPrefix() + " §4Default GUI file (GUIs/default.yml) is loaded...");
|
||||
T2Csend.console(Util.getPrefix() + " §4Default GUI file (GUIs/default.yml) is loaded...");
|
||||
File config = new File(Main.getPath(), "GUIs/default.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
@@ -23,7 +21,7 @@ public class CreateGUI {
|
||||
set("GUI.Lines", 1, yamlConfiguration);
|
||||
set("GUI.Name", "&5default &9GUI", yamlConfiguration);
|
||||
set("GUI.FillItem.Enable", true, yamlConfiguration);
|
||||
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
set("GUI.FillItem.GlassPaneColor", 15, yamlConfiguration);
|
||||
} else set("GUI.FillItem.Item", "BLACK_STAINED_GLASS_PANE", yamlConfiguration);
|
||||
|
||||
@@ -50,7 +48,7 @@ public class CreateGUI {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
send.console(Util.getPrefix() + " §2Default GUI file (GUIs/default.yml) was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Csend.console(Util.getPrefix() + " §2Default GUI file (GUIs/default.yml) was loaded." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
private static void set(String path, String value, YamlConfiguration config) {
|
@@ -0,0 +1,89 @@
|
||||
package net.t2code.commandguiv2.Spigot.config.gui;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
|
||||
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.SlotObject;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SelectGui {
|
||||
|
||||
public static void onSelectGui() {
|
||||
Cache.guiHashMap.clear();
|
||||
Cache.allAliases.clear();
|
||||
File f = new File(Main.getPath() + "/GUIs/");
|
||||
File[] fileArray = f.listFiles();
|
||||
|
||||
for (File config : fileArray) {
|
||||
try {
|
||||
if (config.getName().equals("guiDeclaration.yml")) continue;
|
||||
String sub = config.getName().substring(config.getName().length() - 4);
|
||||
if (sub.equals(".yml")) {
|
||||
String key = config.getName().replace(".yml", "");
|
||||
Cache.allAliases.add(key);
|
||||
YamlConfiguration yamlConfiguration_gui = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
Boolean guiEnable = yamlConfiguration_gui.getBoolean("GUI.Enable");
|
||||
Integer guiLines = yamlConfiguration_gui.getInt("GUI.Lines");
|
||||
if (yamlConfiguration_gui.getInt("GUI.Lines") > 6) {
|
||||
yamlConfiguration_gui.set("GUI.Lines", 6);
|
||||
}
|
||||
if (yamlConfiguration_gui.getInt("GUI.Lines") < 1) {
|
||||
yamlConfiguration_gui.set("GUI.Lines", 1);
|
||||
}
|
||||
|
||||
String guiName = yamlConfiguration_gui.getString("GUI.Name");
|
||||
Boolean guiFillItemEnable = yamlConfiguration_gui.getBoolean("GUI.FillItem.Enable");
|
||||
String guiFillItemItem;
|
||||
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.GlassPaneColor");
|
||||
} else guiFillItemItem = yamlConfiguration_gui.getString("GUI.FillItem.Item");
|
||||
|
||||
Boolean commandAliasEnable = yamlConfiguration_gui.getBoolean("Command.Alias");
|
||||
Boolean commandPermission = yamlConfiguration_gui.getBoolean("Command.Permission.Required");
|
||||
|
||||
ArrayList<SlotObject> slots = new ArrayList<>();
|
||||
for (String slotKey : yamlConfiguration_gui.getConfigurationSection("Slots").getKeys(false)) {
|
||||
Integer slotNumber = yamlConfiguration_gui.getInt("Slots." + slotKey + ".Slot") - 1;
|
||||
Boolean enable = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Enable");
|
||||
String function = yamlConfiguration_gui.getString("Slots." + slotKey + ".Function");
|
||||
FunctionObject functionCheck = Cache.functionHashMap.get(function);
|
||||
if (functionCheck == null) {
|
||||
T2Csend.error(Main.getPlugin(), "The Function " + function + " in the GUI " + key + " does not exist!");
|
||||
}
|
||||
Boolean permRequired = yamlConfiguration_gui.getBoolean("Slots." + slotKey + ".Permission.Required");
|
||||
String permSee = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.See");
|
||||
String permUse = yamlConfiguration_gui.getString("Slots." + slotKey + ".Permission.Use");
|
||||
|
||||
SlotObject slot = new SlotObject(slotNumber, enable, function, permRequired,
|
||||
permSee.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
|
||||
.replace("[slotname]", slotKey.toLowerCase()),
|
||||
permUse.replace("[function]", key).replace("[slot]", String.valueOf(slotNumber + 1))
|
||||
.replace("[slotname]", slotKey.toLowerCase()));
|
||||
slots.add(slot);
|
||||
}
|
||||
GuiObject gui = new GuiObject(guiEnable, guiLines, guiName, guiFillItemEnable, guiFillItemItem,
|
||||
key, commandAliasEnable, commandPermission, slots);
|
||||
|
||||
Cache.guiHashMap.put(key, gui);
|
||||
CmdExecuter_GUI.arg1.put(config.getName()
|
||||
.replace(".yml", ""), "commandgui.gui." + key);
|
||||
|
||||
|
||||
yamlConfiguration_gui.save(config);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Main.sendTryCatch(SelectGui.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
package de.jatitv.commandguiv2.Spigot.config.languages;
|
||||
package net.t2code.commandguiv2.Spigot.config.languages;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class LanguagesCreate {
|
||||
private static Plugin plugin = Main.getPlugin();
|
||||
|
||||
public static void langCreate() {
|
||||
send.debug(plugin,"§4Language files are created / updated...");
|
||||
T2Csend.debug(plugin, "§4Language files are created / updated...");
|
||||
Long long_ = Long.valueOf(System.currentTimeMillis());
|
||||
|
||||
/**
|
||||
@@ -63,13 +63,13 @@ public class LanguagesCreate {
|
||||
set("Player.PlayerNotFond", MSG.EN_PlayerNotFond, yamlConfigurationEN);
|
||||
set("Player.PlayerNoInventorySpace", MSG.EN_PlayerNoInventorySpace, yamlConfigurationEN);
|
||||
|
||||
set("FunctionItem.Add", MSG.EN_FunctionItemAdd,yamlConfigurationEN);
|
||||
set("FunctionItem.Remove", MSG.EN_FunctionItemRemove,yamlConfigurationEN);
|
||||
set("FunctionItem.RemoveError", MSG.EN_FunctionItemRemoveError,yamlConfigurationEN);
|
||||
set("FunctionItem.Add", MSG.EN_FunctionItemAdd, yamlConfigurationEN);
|
||||
set("FunctionItem.Remove", MSG.EN_FunctionItemRemove, yamlConfigurationEN);
|
||||
set("FunctionItem.RemoveError", MSG.EN_FunctionItemRemoveError, yamlConfigurationEN);
|
||||
|
||||
set("FunctionVote.Add", MSG.EN_FunctionVoteAdd,yamlConfigurationEN);
|
||||
set("FunctionVote.Remove", MSG.EN_FunctionVoteRemove,yamlConfigurationEN);
|
||||
set("FunctionVote.RemoveError", MSG.EN_FunctionVoteRemoveError,yamlConfigurationEN);
|
||||
set("FunctionVote.Add", MSG.EN_FunctionVoteAdd, yamlConfigurationEN);
|
||||
set("FunctionVote.Remove", MSG.EN_FunctionVoteRemove, yamlConfigurationEN);
|
||||
set("FunctionVote.RemoveError", MSG.EN_FunctionVoteRemoveError, yamlConfigurationEN);
|
||||
|
||||
set("Help.CGUI", MSG.EN_Help_CGUI, yamlConfigurationEN);
|
||||
set("Help.Help", MSG.EN_Help_Help, yamlConfigurationEN);
|
||||
@@ -96,7 +96,7 @@ public class LanguagesCreate {
|
||||
try {
|
||||
yamlConfigurationEN.save(messagesEN);
|
||||
} catch (IOException e) {
|
||||
send.warning(plugin,e.getMessage());
|
||||
T2Csend.warning(plugin, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -148,13 +148,13 @@ public class LanguagesCreate {
|
||||
set("Player.PlayerNotFond", MSG.DE_PlayerNotFond, yamlConfigurationDE);
|
||||
set("Player.PlayerNoInventorySpace", MSG.DE_PlayerNoInventorySpace, yamlConfigurationDE);
|
||||
|
||||
set("FunctionItem.Add", MSG.DE_FunctionItemAdd,yamlConfigurationDE);
|
||||
set("FunctionItem.Remove", MSG.DE_FunctionItemRemove,yamlConfigurationDE);
|
||||
set("FunctionItem.RemoveError", MSG.DE_FunctionItemRemoveError,yamlConfigurationDE);
|
||||
set("FunctionItem.Add", MSG.DE_FunctionItemAdd, yamlConfigurationDE);
|
||||
set("FunctionItem.Remove", MSG.DE_FunctionItemRemove, yamlConfigurationDE);
|
||||
set("FunctionItem.RemoveError", MSG.DE_FunctionItemRemoveError, yamlConfigurationDE);
|
||||
|
||||
set("FunctionVote.Add", MSG.DE_FunctionVoteAdd,yamlConfigurationDE);
|
||||
set("FunctionVote.Remove", MSG.DE_FunctionVoteRemove,yamlConfigurationDE);
|
||||
set("FunctionVote.RemoveError", MSG.DE_FunctionVoteRemoveError,yamlConfigurationDE);
|
||||
set("FunctionVote.Add", MSG.DE_FunctionVoteAdd, yamlConfigurationDE);
|
||||
set("FunctionVote.Remove", MSG.DE_FunctionVoteRemove, yamlConfigurationDE);
|
||||
set("FunctionVote.RemoveError", MSG.DE_FunctionVoteRemoveError, yamlConfigurationDE);
|
||||
|
||||
set("Help.CGUI", MSG.DE_Help_CGUI, yamlConfigurationDE);
|
||||
set("Help.Help", MSG.DE_Help_Help, yamlConfigurationDE);
|
||||
@@ -181,7 +181,7 @@ public class LanguagesCreate {
|
||||
try {
|
||||
yamlConfigurationDE.save(messagesDE);
|
||||
} catch (IOException e) {
|
||||
send.warning(plugin,e.getMessage());
|
||||
T2Csend.warning(plugin, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -234,13 +234,13 @@ public class LanguagesCreate {
|
||||
set("Player.PlayerNotFond", MSG.NO_PlayerNotFond, yamlConfigurationNO);
|
||||
set("Player.PlayerNoInventorySpace", MSG.NO_PlayerNoInventorySpace, yamlConfigurationNO);
|
||||
|
||||
set("FunctionItem.Add", MSG.NO_FunctionItemAdd,yamlConfigurationNO);
|
||||
set("FunctionItem.Remove", MSG.NO_FunctionItemRemove,yamlConfigurationNO);
|
||||
set("FunctionItem.RemoveError", MSG.NO_FunctionItemRemoveError,yamlConfigurationNO);
|
||||
set("FunctionItem.Add", MSG.NO_FunctionItemAdd, yamlConfigurationNO);
|
||||
set("FunctionItem.Remove", MSG.NO_FunctionItemRemove, yamlConfigurationNO);
|
||||
set("FunctionItem.RemoveError", MSG.NO_FunctionItemRemoveError, yamlConfigurationNO);
|
||||
|
||||
set("FunctionVote.Add", MSG.NO_FunctionVoteAdd,yamlConfigurationNO);
|
||||
set("FunctionVote.Remove", MSG.NO_FunctionVoteRemove,yamlConfigurationNO);
|
||||
set("FunctionVote.RemoveError", MSG.NO_FunctionVoteRemoveError,yamlConfigurationNO);
|
||||
set("FunctionVote.Add", MSG.NO_FunctionVoteAdd, yamlConfigurationNO);
|
||||
set("FunctionVote.Remove", MSG.NO_FunctionVoteRemove, yamlConfigurationNO);
|
||||
set("FunctionVote.RemoveError", MSG.NO_FunctionVoteRemoveError, yamlConfigurationNO);
|
||||
|
||||
set("Help.CGUI", MSG.NO_Help_CGUI, yamlConfigurationNO);
|
||||
set("Help.Help", MSG.NO_Help_Help, yamlConfigurationNO);
|
||||
@@ -267,12 +267,11 @@ public class LanguagesCreate {
|
||||
try {
|
||||
yamlConfigurationNO.save(messagesNO);
|
||||
} catch (IOException e) {
|
||||
send.warning(plugin,e.getMessage());
|
||||
T2Csend.warning(plugin, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
send.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
||||
T2Csend.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
||||
}
|
||||
|
||||
private static void set(String path, String value, YamlConfiguration config) {
|
@@ -9,7 +9,7 @@
|
||||
// \_____\_____|\____/|_____|
|
||||
// -----------------------------
|
||||
|
||||
package de.jatitv.commandguiv2.Spigot.config.languages;
|
||||
package net.t2code.commandguiv2.Spigot.config.languages;
|
||||
|
||||
public class MSG {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class MSG {
|
||||
public static String EN_UseItemDisabledInGameMode = "[prefix] &cThe UseItem is disabled in this GameMode!";
|
||||
public static String EN_UseItemDisabledInWorld = "[prefix] &cThe UseItem is disabled in this World!";
|
||||
|
||||
public static String EN_GUInotFound = "[prefix] &cThe GUI chosen by the does not exist.";
|
||||
public static String EN_GUInotFound = "[prefix] &cThe gui [gui] does not exist!";
|
||||
public static String EN_GUIisDisabled = "[prefix] &cThe GUI [gui] &cis currently Disabled!";
|
||||
|
||||
public static String EN_GiveSender = "[prefix] &2You have given &6[player] &2an [item] &2!";
|
||||
@@ -113,7 +113,7 @@ public class MSG {
|
||||
|
||||
public static String DE_onServerChange = "[prefix] &2Du wirst auf den Server §e[server] §2verbunden.";
|
||||
|
||||
public static String DE_GUInotFound = "[prefix] &cDie von die gew[ae]hlte GUI gibt es nicht.";
|
||||
public static String DE_GUInotFound = "[prefix] &cDie gui [gui] existiert nicht!";
|
||||
public static String DE_GUIisDisabled = "[prefix] &cDie GUI [gui] &cist derzeit Deaktiviert!";
|
||||
|
||||
public static String DE_GiveSender = "[prefix] &2Du hast &6[player] &2ein [item] &2gegeben!";
|
@@ -1,10 +1,10 @@
|
||||
package de.jatitv.commandguiv2.Spigot.config.languages;
|
||||
package net.t2code.commandguiv2.Spigot.config.languages;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
@@ -82,23 +82,22 @@ public class SelectMessages {
|
||||
public static String PlayerGUIItemHelp_Slot;
|
||||
|
||||
public static void onSelect(String Prefix) {
|
||||
|
||||
send.debug(Main.getPlugin(), "§4Select language...");
|
||||
T2Csend.debug(Main.getPlugin(), "§4Select language...");
|
||||
long long_ = System.currentTimeMillis();
|
||||
|
||||
File msg;
|
||||
|
||||
msg = new File(Main.getPath(), "languages/" + SelectConfig.getLanguage() + "_messages.yml");
|
||||
msg = new File(Main.getPath(), "languages/" + ConfigValues.language.value + "_messages.yml");
|
||||
if (!msg.isFile()) {
|
||||
send.console(Prefix);
|
||||
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
send.console(Prefix + " §4The selected §c" + SelectConfig.getLanguage() + " §4language file was not found.");
|
||||
send.console(Prefix + " §6The default language §eEnglish §6is used!");
|
||||
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
send.console(Prefix);
|
||||
T2Csend.console(Prefix);
|
||||
T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.console(Prefix + " §4The selected §c" + ConfigValues.language.value + " §4language file was not found.");
|
||||
T2Csend.console(Prefix + " §6The default language §eEnglish §6is used!");
|
||||
T2Csend.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.console(Prefix);
|
||||
msg = new File(Main.getPath(), "languages/" + "english_messages.yml");
|
||||
selectMSG = "english";
|
||||
} else selectMSG = SelectConfig.getLanguage();
|
||||
} else selectMSG = String.valueOf(ConfigValues.language.value);
|
||||
YamlConfiguration yamlConfiguration_msg = YamlConfiguration.loadConfiguration(msg);
|
||||
|
||||
VaultNotSetUp = select("Plugin.VaultNotSetUp", yamlConfiguration_msg);
|
||||
@@ -171,10 +170,10 @@ public class SelectMessages {
|
||||
PlayerGUIItemHelp_Slot = select("Help.Player.UseItem_Slot", yamlConfiguration_msg);
|
||||
|
||||
|
||||
send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Csend.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
private static String select(String path, YamlConfiguration yamlConfiguration) {
|
||||
return Replace.replace(Util.getPrefix(), Objects.requireNonNull(yamlConfiguration.getString(path)));
|
||||
return T2Creplace.replace(Util.getPrefix(), Objects.requireNonNull(yamlConfiguration.getString(path)));
|
||||
}
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
package net.t2code.commandguiv2.Spigot.config.useItems;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.objects.UseItemObject;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class UseItemSelect {
|
||||
|
||||
public static void create() {
|
||||
File config = new File(Main.getPath(), "/UseItems/default.yml");
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
for (UseItemValues value : UseItemValues.values()) {
|
||||
T2Cconfig.set(value.path, value.value, yamlConfiguration);
|
||||
}
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (
|
||||
IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void onSelect() {
|
||||
Cache.useItemHash.clear();
|
||||
File f = new File(Main.getPath() + "/UseItems/");
|
||||
File[] fileArray = f.listFiles();
|
||||
|
||||
for (File config : fileArray) {
|
||||
if (config.getName().equals("useItemDeclaration.yml")) continue;
|
||||
String sub = config.getName().substring(config.getName().length() - 4);
|
||||
if (sub.equals(".yml")) {
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
String key = config.getName().replace(".yml", "");
|
||||
Boolean enable = yamlConfiguration.getBoolean("useItem.enable");
|
||||
String openGui = yamlConfiguration.getString("useItem.openGUI");
|
||||
Boolean allowToggle = yamlConfiguration.getBoolean("useItem.allowToggle");
|
||||
Boolean allowSetBlock = yamlConfiguration.getBoolean("useItem.allowSetSlot");
|
||||
Boolean blockMoveAndDrop = yamlConfiguration.getBoolean("useItem.blockMoveAndDrop");
|
||||
|
||||
Boolean permBecomeNeeded = yamlConfiguration.getBoolean("useItem.permission.become.needed");
|
||||
String permBecome = yamlConfiguration.getString("useItem.permission.become.permission");
|
||||
PermissionDefault permBecomeDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.become.default"));
|
||||
|
||||
Boolean permUseNeeded = yamlConfiguration.getBoolean("useItem.permission.use.needed");
|
||||
String permUse = yamlConfiguration.getString("useItem.permission.use.permission");
|
||||
PermissionDefault permUseDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.use.default"));
|
||||
|
||||
Boolean permToggleNeeded = yamlConfiguration.getBoolean("useItem.permission.toggle.needed");
|
||||
String permToggle = yamlConfiguration.getString("useItem.permission.toggle.permission");
|
||||
PermissionDefault permToggleDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.toggle.default"));
|
||||
|
||||
Boolean permSetSlotNeeded = yamlConfiguration.getBoolean("useItem.permission.setSlot.needed");
|
||||
String permSetSlot = yamlConfiguration.getString("useItem.permission.setSlot.permission");
|
||||
PermissionDefault permSetSlotDefault = PermissionDefault.valueOf(yamlConfiguration.getString("useItem.permission.setSlot.default"));
|
||||
|
||||
Boolean keepAtCommandClear = yamlConfiguration.getBoolean("useItem.keepAtCommandClear");
|
||||
|
||||
Integer invSlotSlot = yamlConfiguration.getInt("useItem.inventorySlot.slot");
|
||||
Boolean invSlotEnforce = yamlConfiguration.getBoolean("useItem.inventorySlot.slotEnforce");
|
||||
Boolean invFreeSlot = yamlConfiguration.getBoolean("useItem.inventorySlot.freeSlot");
|
||||
|
||||
String itemMaterial = yamlConfiguration.getString("useItem.item.material");
|
||||
String itemName = yamlConfiguration.getString("useItem.item.name");
|
||||
List<String> itemLore = yamlConfiguration.getStringList("useItem.item.lore");
|
||||
Boolean itemPlayerHeadEnable = yamlConfiguration.getBoolean("useItem.item.playerHead.enable");
|
||||
Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI = yamlConfiguration.getBoolean("useItem.item.playerHead.playerWhoHasOpenedTheGUI");
|
||||
String itemPlayerHeadPlayerName = yamlConfiguration.getString("useItem.item.playerHead.playerName");
|
||||
Boolean itemPlayerHeadBase64Enable = yamlConfiguration.getBoolean("useItem.item.playerHead.base64.enable");
|
||||
String itemPlayerHeadBase64Value = yamlConfiguration.getString("useItem.item.playerHead.base64.base64Value");
|
||||
|
||||
Boolean joinGiveOnEveryJoin = yamlConfiguration.getBoolean("useItem.join.giveOnEveryJoin");
|
||||
Boolean joinGiveOnlyOnFirstJoin = yamlConfiguration.getBoolean("useItem.join.giveOnlyOnFirstJoin");
|
||||
|
||||
Boolean quitRemoveOnQuit = yamlConfiguration.getBoolean("useItem.quit.removeOnQuit");
|
||||
|
||||
Boolean protectGameModeEnable = yamlConfiguration.getBoolean("useItem.protection.gameMode.enable");
|
||||
Boolean protectGameModeRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("useItem.protection.gameMode.removeItemWhenItIsDisabled");
|
||||
String protectGameModeMode = yamlConfiguration.getString("useItem.protection.gameMode.mode");
|
||||
List<String> protectGameModeList = yamlConfiguration.getStringList("useItem.protection.gameMode.list");
|
||||
|
||||
Boolean protectWorldEnable = yamlConfiguration.getBoolean("useItem.protection.world.enable");
|
||||
Boolean protectWorldRemoveItemWhenItIsDisabled = yamlConfiguration.getBoolean("useItem.protection.world.removeItemWhenItIsDisabled");
|
||||
String protectWorldMode = yamlConfiguration.getString("useItem.protection.world.mode");
|
||||
List<String> protectWorldList = yamlConfiguration.getStringList("useItem.protection.world.list");
|
||||
|
||||
|
||||
UseItemObject useItem = new UseItemObject(key, enable, openGui, allowToggle, allowSetBlock, blockMoveAndDrop, permBecomeNeeded, permBecome, permBecomeDefault,
|
||||
permUseNeeded, permUse, permUseDefault, permToggleNeeded, permToggle, permToggleDefault, permSetSlotNeeded, permSetSlot, permSetSlotDefault, keepAtCommandClear,
|
||||
invSlotSlot, invSlotEnforce, invFreeSlot, itemMaterial, itemName, itemLore, itemPlayerHeadEnable, itemPlayerHeadPlayerWhoHasOpenedTheGUI,
|
||||
itemPlayerHeadPlayerName, itemPlayerHeadBase64Enable, itemPlayerHeadBase64Value, joinGiveOnEveryJoin, joinGiveOnlyOnFirstJoin, quitRemoveOnQuit,
|
||||
protectGameModeEnable, protectGameModeRemoveItemWhenItIsDisabled, protectGameModeMode, protectGameModeList, protectWorldEnable,
|
||||
protectWorldRemoveItemWhenItIsDisabled, protectWorldMode, protectWorldList);
|
||||
Cache.useItemHash.put(key, useItem);
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(config);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package net.t2code.commandguiv2.Spigot.config.useItems;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public enum UseItemValues {
|
||||
|
||||
enable("useItem.enable",true),
|
||||
openGUI("useItem.openGUI","default"),
|
||||
allowToggle("useItem.allowToggle",true),
|
||||
allowSetSlot("useItem.allowSetSlot",true),
|
||||
blockMoveAndDrop("useItem.blockMoveAndDrop",true),
|
||||
permissionBecomeNeeded("useItem.permission.become.needed",true),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null),
|
||||
xxxx("useItem.enable",null);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public final String path;
|
||||
public Object value;
|
||||
|
||||
UseItemValues(String path, Object defaultValue) {
|
||||
this.path = path;
|
||||
this.value = defaultValue;
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
package de.jatitv.commandguiv2.Spigot.database;
|
||||
package net.t2code.commandguiv2.Spigot.database;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
|
||||
import java.sql.*;
|
||||
import java.time.ZoneId;
|
||||
@@ -22,34 +22,34 @@ public class MySQL {
|
||||
long long_ = System.currentTimeMillis();
|
||||
Calendar now = Calendar.getInstance();
|
||||
ZoneId timeZone = now.getTimeZone().toZoneId();
|
||||
send.debug(Main.getPlugin(), "Server TimeZone is : " + timeZone);
|
||||
T2Csend.debug(Main.getPlugin(), "Server TimeZone is : " + timeZone);
|
||||
try {
|
||||
config.setJdbcUrl("jdbc:mysql://" + SelectConfig.getMysqlIp() + ":" + SelectConfig.getMysqlPort() + "/" + SelectConfig.getMysqlDatabase()
|
||||
config.setJdbcUrl("jdbc:mysql://" + ConfigValues.mysqlIp.value + ":" + ConfigValues.mysqlPort.value + "/" + ConfigValues.mysqlDatabase.value
|
||||
+ "?useJDBCCompliantTimezoneShift=true&allowMultiQueries=true&useLegacyDatetimeCode=false&autoReconnect=true&serverTimezone=" + timeZone
|
||||
+ "&useSSL=" + SelectConfig.getMysqlSSL());
|
||||
config.setUsername(SelectConfig.getMysqlUser());
|
||||
config.setPassword(SelectConfig.getMysqlPassword());
|
||||
+ "&useSSL=" + ConfigValues.mysqlSSL.value);
|
||||
config.setUsername(String.valueOf(ConfigValues.mysqlUser.value));
|
||||
config.setPassword(String.valueOf(ConfigValues.mysqlPassword.value));
|
||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
||||
ds = new HikariDataSource(config);
|
||||
send.console(Util.getPrefix() + " §2MYSQL successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Csend.console(Util.getPrefix() + " §2MYSQL successfully connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
} catch (Exception ex) {
|
||||
send.console(Util.getPrefix() + " §4MYSQL not connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
send.error(Main.getPlugin(), ex.getMessage() + " --- " + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Csend.console(Util.getPrefix() + " §4MYSQL not connected." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||
T2Csend.error(Main.getPlugin(), ex.getMessage() + " --- " + (System.currentTimeMillis() - long_) + "ms");
|
||||
}
|
||||
|
||||
if (SelectConfig.getDebug() || Main.version.toLowerCase().contains("dev") || Main.version.toLowerCase().contains("beta") || Main.version.toLowerCase().contains("snapshot")) {
|
||||
if ((Boolean) ConfigValues.debug.value || Main.version.toLowerCase().contains("dev") || Main.version.toLowerCase().contains("beta") || Main.version.toLowerCase().contains("snapshot")) {
|
||||
try {
|
||||
send.error(Main.getPlugin(), "MySQL DEBUG:");
|
||||
T2Csend.error(Main.getPlugin(), "MySQL DEBUG:");
|
||||
Connection con = ds.getConnection();
|
||||
DatabaseMetaData dbmd = con.getMetaData();
|
||||
send.debugmsg(Main.getPlugin(), "§6Metadata of the database:");
|
||||
send.debugmsg(Main.getPlugin(), "§6DB: §e" + dbmd.getDatabaseProductName());
|
||||
send.debugmsg(Main.getPlugin(), "§6Version: §e" + dbmd.getDatabaseProductVersion());
|
||||
send.debugmsg(Main.getPlugin(), "§6Driver: §e" + dbmd.getDriverName());
|
||||
send.debugmsg(Main.getPlugin(), "§6Driver MajorVersion: §e" + dbmd.getDriverMajorVersion() + "." + dbmd.getDriverMinorVersion());
|
||||
send.debugmsg(Main.getPlugin(), "§6Driver Version: §e" + dbmd.getDriverVersion());
|
||||
T2Csend.debugmsg(Main.getPlugin(), "§6Metadata of the database:");
|
||||
T2Csend.debugmsg(Main.getPlugin(), "§6DB: §e" + dbmd.getDatabaseProductName());
|
||||
T2Csend.debugmsg(Main.getPlugin(), "§6Version: §e" + dbmd.getDatabaseProductVersion());
|
||||
T2Csend.debugmsg(Main.getPlugin(), "§6Driver: §e" + dbmd.getDriverName());
|
||||
T2Csend.debugmsg(Main.getPlugin(), "§6Driver MajorVersion: §e" + dbmd.getDriverMajorVersion() + "." + dbmd.getDriverMinorVersion());
|
||||
T2Csend.debugmsg(Main.getPlugin(), "§6Driver Version: §e" + dbmd.getDriverVersion());
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -65,7 +65,7 @@ public class MySQL {
|
||||
if (ds == null) {
|
||||
return;
|
||||
}
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
Connection con = ds.getConnection();
|
||||
Statement stmt = con.createStatement();
|
||||
stmt.execute(query);
|
||||
@@ -75,7 +75,7 @@ public class MySQL {
|
||||
|
||||
|
||||
public static HashMap<String, ArrayList<String>> selectAll(String query) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
HashMap<String, ArrayList<String>> Result = new HashMap<>();
|
||||
try (Connection con = ds.getConnection()) {
|
||||
Statement stmt = con.createStatement();
|
||||
@@ -97,7 +97,7 @@ public class MySQL {
|
||||
}
|
||||
|
||||
public static String select(String query) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
String Ausgabe = "";
|
||||
try (Connection con = ds.getConnection()) {
|
||||
Statement stmt = con.createStatement();
|
||||
@@ -114,7 +114,7 @@ public class MySQL {
|
||||
}
|
||||
|
||||
public static int count(String query) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
int count = 0;
|
||||
try (Connection con = ds.getConnection()) {
|
||||
Statement stmt = con.createStatement();
|
||||
@@ -131,7 +131,7 @@ public class MySQL {
|
||||
}
|
||||
|
||||
public static ArrayList<String> selectRow(String query) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
ArrayList<String> Result = new ArrayList<>();
|
||||
try (Connection con = ds.getConnection()) {
|
||||
Statement stmt = con.createStatement();
|
@@ -1,8 +1,8 @@
|
||||
package de.jatitv.commandguiv2.Spigot.database;
|
||||
package net.t2code.commandguiv2.Spigot.database;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.io.File;
|
||||
@@ -28,7 +28,7 @@ public class SQLITE {
|
||||
|
||||
public static void query(String query) {
|
||||
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
try {
|
||||
Statement stmt = con.createStatement();
|
||||
stmt.execute(query);
|
||||
@@ -42,7 +42,7 @@ public class SQLITE {
|
||||
try {
|
||||
Statement stmt = con.createStatement();
|
||||
for (String query : queryList) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
stmt.addBatch(query);
|
||||
}
|
||||
stmt.executeBatch();
|
||||
@@ -54,7 +54,7 @@ public class SQLITE {
|
||||
|
||||
|
||||
public static HashMap<String, ArrayList<String>> selectAll(String query) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
HashMap<String, ArrayList<String>> Result = new HashMap<>();
|
||||
try {
|
||||
Statement stmt = con.createStatement();
|
||||
@@ -76,7 +76,7 @@ public class SQLITE {
|
||||
}
|
||||
|
||||
public static String select(String query) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
String Ausgabe = "";
|
||||
try {
|
||||
Statement stmt = con.createStatement();
|
||||
@@ -93,7 +93,7 @@ public class SQLITE {
|
||||
}
|
||||
|
||||
public static int count(String query) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
int count = 0;
|
||||
try {
|
||||
Statement stmt = con.createStatement();
|
||||
@@ -110,7 +110,7 @@ public class SQLITE {
|
||||
}
|
||||
|
||||
public static ArrayList<String> selectRow(String query) {
|
||||
send.debug(Main.getPlugin(), query);
|
||||
T2Csend.debug(Main.getPlugin(), query);
|
||||
ArrayList<String> Result = new ArrayList<>();
|
||||
try {
|
||||
Statement stmt = con.createStatement();
|
@@ -1,8 +1,8 @@
|
||||
package de.jatitv.commandguiv2.Spigot.database;
|
||||
package net.t2code.commandguiv2.Spigot.database;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.StorageEnum;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.enums.StorageEnum;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.SQLException;
|
||||
@@ -39,7 +39,7 @@ public class SelectDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setSlot(Player player, Integer slot) {
|
||||
public static void setSlot(Player player, String useItemKey, Integer slot) {
|
||||
switch (Storage) {
|
||||
case MYSQL:
|
||||
try {
|
||||
@@ -61,7 +61,7 @@ public class SelectDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setItemStatusTrue(Player player) {
|
||||
public static void setItemStatusFalse(Player player) {
|
||||
Events.useItemHashMap.replace(player.getName(), true);
|
||||
switch (Storage) {
|
||||
case MYSQL:
|
||||
@@ -74,7 +74,7 @@ public class SelectDatabase {
|
||||
}
|
||||
break;
|
||||
case YML:
|
||||
YML.setGuiitemOn(player);
|
||||
YML.setGuiItem(player, true);
|
||||
break;
|
||||
case SQLITE:
|
||||
default:
|
||||
@@ -84,30 +84,34 @@ public class SelectDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setItemStatusFalse(Player player) {
|
||||
public static void setItemStatus(Player player, String useItemKey, boolean status) {
|
||||
int i;
|
||||
if (status) {
|
||||
i = 1;
|
||||
} else i = 0;
|
||||
Events.useItemHashMap.replace(player.getName(), false);
|
||||
switch (Storage) {
|
||||
case MYSQL:
|
||||
try {
|
||||
MySQL.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||
+ "', '0') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '0';");
|
||||
+ "', '" + i + "') ON DUPLICATE KEY UPDATE `Name` = '" + player.getName() + "', `Status` = '" + i + "';");
|
||||
} catch (SQLException e) {
|
||||
Main.sendTryCatch(SelectDatabase.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
break;
|
||||
case YML:
|
||||
YML.setGuiitemOff(player);
|
||||
YML.setGuiItem(player, status);
|
||||
break;
|
||||
case SQLITE:
|
||||
default:
|
||||
SQLITE.query("INSERT INTO `gui-item` (`UUID`, `Name`, `Status`) VALUES ('" + player.getUniqueId() + "', '" + player.getName()
|
||||
+ "', '0') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Status` = '0';");
|
||||
+ "', '" + i + "') ON CONFLICT(UUID) DO UPDATE SET `Name` = '" + player.getName() + "', `Status` = '" + i + "';");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean selectItemStatus(Player player) {
|
||||
public static Boolean selectItemStatus(Player player,String useItemKey) {
|
||||
switch (Storage) {
|
||||
case MYSQL:
|
||||
String result = MySQL.select("SELECT `Status` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
|
||||
@@ -127,7 +131,7 @@ public class SelectDatabase {
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer selectSlot(Player player) {
|
||||
public static Integer selectSlot(Player player,String useItemKey) {
|
||||
switch (Storage) {
|
||||
case MYSQL:
|
||||
String result = MySQL.select("SELECT `Slot` FROM `gui-item` WHERE `UUID`='" + player.getUniqueId() + "';");
|
@@ -1,8 +1,7 @@
|
||||
package de.jatitv.commandguiv2.Spigot.database;
|
||||
package net.t2code.commandguiv2.Spigot.database;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -17,20 +16,9 @@ public class YML {
|
||||
public static File storage = new File(Main.getPath(), "Storage/gui-item.yml");
|
||||
public static YamlConfiguration yamlConfigurationStorage = YamlConfiguration.loadConfiguration(storage);
|
||||
|
||||
public static void setGuiitemOn(Player player) {
|
||||
public static void setGuiItem(Player player, boolean status) {
|
||||
yamlConfigurationStorage.set(player.getUniqueId() + ".Playername", player.getName());
|
||||
yamlConfigurationStorage.set(player.getUniqueId() + ".Status", true);
|
||||
|
||||
try {
|
||||
yamlConfigurationStorage.save(storage);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setGuiitemOff(Player player) {
|
||||
yamlConfigurationStorage.set(player.getUniqueId() + ".Playername", player.getName());
|
||||
yamlConfigurationStorage.set(player.getUniqueId() + ".Status", false);
|
||||
yamlConfigurationStorage.set(player.getUniqueId() + ".Status", status);
|
||||
|
||||
try {
|
||||
yamlConfigurationStorage.save(storage);
|
||||
@@ -46,23 +34,23 @@ public class YML {
|
||||
try {
|
||||
yamlConfigurationStorage.save(storage);
|
||||
} catch (IOException e) {
|
||||
Main.sendTryCatch(Obj_Select.class, e.getStackTrace()[0]);
|
||||
Main.sendTryCatch(YML.class, e.getStackTrace()[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean selectGuiitemOn(Player player){
|
||||
public static Boolean selectGuiitemOn(Player player) {
|
||||
if (!yamlConfigurationStorage.contains(String.valueOf(player.getUniqueId()))) return true;
|
||||
return yamlConfigurationStorage.getBoolean(player.getUniqueId() + ".Status");
|
||||
}
|
||||
|
||||
|
||||
public static Integer selectSlot(Player player) {
|
||||
send.debug(plugin, "yml-1");
|
||||
T2Csend.debug(plugin, "yml-1");
|
||||
if (!yamlConfigurationStorage.contains(String.valueOf(player.getUniqueId()))) return null;
|
||||
if (yamlConfigurationStorage.getString(player.getUniqueId() + ".Slot") == null) return null;
|
||||
send.debug(plugin, "yml-2");
|
||||
send.debug(plugin, String.valueOf(yamlConfigurationStorage.getInt(player.getUniqueId() + ".Slot")));
|
||||
T2Csend.debug(plugin, "yml-2");
|
||||
T2Csend.debug(plugin, String.valueOf(yamlConfigurationStorage.getInt(player.getUniqueId() + ".Slot")));
|
||||
return yamlConfigurationStorage.getInt(player.getUniqueId() + ".Slot");
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package de.jatitv.commandguiv2.Spigot.enums;
|
||||
package net.t2code.commandguiv2.Spigot.enums;
|
||||
|
||||
public enum EcoEnum {
|
||||
VAULT, MONEY,
|
@@ -1,5 +1,5 @@
|
||||
|
||||
package de.jatitv.commandguiv2.Spigot.enums;
|
||||
package net.t2code.commandguiv2.Spigot.enums;
|
||||
|
||||
public enum FunctionItemEnum {
|
||||
REMOVE, ADD
|
@@ -1,4 +1,4 @@
|
||||
package de.jatitv.commandguiv2.Spigot.enums;
|
||||
package net.t2code.commandguiv2.Spigot.enums;
|
||||
|
||||
public enum FunctionVoteEnum {
|
||||
REMOVE, ADD
|
@@ -1,4 +1,4 @@
|
||||
package de.jatitv.commandguiv2.Spigot.enums;
|
||||
package net.t2code.commandguiv2.Spigot.enums;
|
||||
|
||||
public enum SoundEnum {
|
||||
OpenInventory,
|
@@ -1,4 +1,4 @@
|
||||
package de.jatitv.commandguiv2.Spigot.enums;
|
||||
package net.t2code.commandguiv2.Spigot.enums;
|
||||
|
||||
public enum StorageEnum {
|
||||
MYSQL,
|
@@ -1,23 +1,25 @@
|
||||
package de.jatitv.commandguiv2.Spigot.gui;
|
||||
package net.t2code.commandguiv2.Spigot.function.gui;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.listener.ServerChange;
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||
import de.jatitv.commandguiv2.Spigot.listener.Bungee_Sender_Reciver;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.system.Placeholder;
|
||||
import de.jatitv.commandguiv2.Spigot.sound.Sound;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.SoundEnum;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.eco.Eco;
|
||||
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.function.listener.ServerChange;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
|
||||
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.Commands;
|
||||
import net.t2code.commandguiv2.Spigot.objects.SlotObject;
|
||||
import net.t2code.commandguiv2.Spigot.function.listener.Bungee_Sender_Reciver;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.system.Placeholder;
|
||||
import net.t2code.commandguiv2.Spigot.sound.PlaySound;
|
||||
import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.eco.T2Ceco;
|
||||
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -26,8 +28,8 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
@@ -44,34 +46,37 @@ public class GUIListener implements Listener {
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (e.getInventory() == null) return;
|
||||
if (e.getCurrentItem() == null) return;
|
||||
for (Gui gui : Main.guiHashMap.values()) {
|
||||
if (player.getOpenInventory().getTitle().equals(Replace.replace(prefix, GUICode + gui.guiName))
|
||||
|| (Main.PaPi && player.getOpenInventory().getTitle().equals(Replace.replace(prefix, player, GUICode + gui.guiName)))) {
|
||||
for (GuiObject gui : Cache.guiHashMap.values()) {
|
||||
if (player.getOpenInventory().getTitle().equals(T2Creplace.replace(prefix, GUICode + gui.guiName))
|
||||
|| (Main.PaPi && player.getOpenInventory().getTitle().equals(T2Creplace.replace(prefix, player, GUICode + gui.guiName)))) {
|
||||
e.setCancelled(true);
|
||||
for (Slot slot : gui.slots) {
|
||||
if (player.getOpenInventory().getTopInventory() != e.getClickedInventory()) {
|
||||
continue;
|
||||
}
|
||||
for (SlotObject slot : gui.slots) {
|
||||
execute(e, slot, player, gui);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void execute(InventoryClickEvent e, Slot slot, Player player, Gui gui) {
|
||||
private static void execute(InventoryClickEvent e, SlotObject slot, Player player, GuiObject gui) {
|
||||
if (e.getSlot() != slot.slot) return;
|
||||
Function function = Main.functionHashMap.get(slot.function);
|
||||
FunctionObject function = Cache.functionHashMap.get(slot.function);
|
||||
if (slot.permission && !player.hasPermission(slot.permissionToSee)) return;
|
||||
if (slot.permission && !player.hasPermission(slot.permissionToUse)) {
|
||||
if (function.noPermMessageEnable) {
|
||||
if (function.customNoPermMessage == null || function.customNoPermMessage.equals("")) {
|
||||
send.player(player, SelectMessages.NoPermissionForItem.replace("[item]", Replace.replace(prefix, function.name))
|
||||
T2Csend.player(player, SelectMessages.NoPermissionForItem.replace("[item]", T2Creplace.replace(prefix, function.name))
|
||||
.replace("[perm]", slot.permissionToUse));
|
||||
} else send.player(player, function.customNoPermMessage.replace("[item]", Replace.replace(prefix, function.name))
|
||||
} else T2Csend.player(player, function.customNoPermMessage.replace("[item]", T2Creplace.replace(prefix, function.name))
|
||||
.replace("[perm]", slot.permissionToUse));
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (e.getCurrentItem().getType() == ItemVersion.getHead() || e.getCurrentItem().getType() == ItemVersion.getGreenWool().getType() ||
|
||||
e.getCurrentItem().getType() == ItemVersion.getRedWool().getType() ||
|
||||
if (e.getCurrentItem().getType() == T2CitemVersion.getHead() || e.getCurrentItem().getType() == T2CitemVersion.getGreenWool().getType() ||
|
||||
e.getCurrentItem().getType() == T2CitemVersion.getRedWool().getType() ||
|
||||
e.getCurrentItem().getType() == Material.valueOf(function.item.toUpperCase().replace(".", "_"))) {
|
||||
if (!slot.enable) return;
|
||||
if (function.cost_Enable) {
|
||||
@@ -84,7 +89,7 @@ public class GUIListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean functions(Function function) {
|
||||
private static boolean functions(FunctionObject function) {
|
||||
if (function.togglePermission) return true;
|
||||
if (function.toggleUseItem) return true;
|
||||
if (function.command_Enable) return true;
|
||||
@@ -96,7 +101,7 @@ public class GUIListener implements Listener {
|
||||
return function.functionItem;
|
||||
}
|
||||
|
||||
private static void execute(Function function, Slot slot, Player player, InventoryClickEvent e, Gui gui) {
|
||||
private static void execute(FunctionObject function, SlotObject slot, Player player, InventoryClickEvent e, GuiObject gui) {
|
||||
if (function.togglePermission) togglePerm(function, gui, player);
|
||||
if (function.toggleUseItem) toggleUseItem(player, gui);
|
||||
if (function.command_Enable) command(function, player);
|
||||
@@ -106,22 +111,22 @@ public class GUIListener implements Listener {
|
||||
if (function.setConfigEnable) setConfig(function, player, e);
|
||||
if (function.functionVotePoints) votePoints(e, function, player);
|
||||
if (function.functionItem) item(function, player);
|
||||
Sound.play(player, SoundEnum.Click, function, slot, gui);
|
||||
PlaySound.play(player, SoundEnum.Click, function, slot, gui);
|
||||
}
|
||||
|
||||
private static void command(Function slot, Player player) {
|
||||
private static void command(FunctionObject slot, Player player) {
|
||||
player.closeInventory();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (slot.command_BungeeCommand) {
|
||||
if (SelectConfig.getBungee()) {
|
||||
if (T2CLibConfig.getBungee()) {
|
||||
for (String cmd : slot.command) {
|
||||
Bungee_Sender_Reciver.sendToBungee(player, cmd.replace("[player]", player.getName()), slot.commandAsConsole);
|
||||
}
|
||||
} else {
|
||||
send.console(prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||
send.player(player, prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||
T2Csend.console(prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||
T2Csend.player(player, prefix + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||
}
|
||||
} else {
|
||||
for (String cmd : slot.command) {
|
||||
@@ -134,7 +139,7 @@ public class GUIListener implements Listener {
|
||||
}.runTaskLater(plugin, 2L);
|
||||
}
|
||||
|
||||
private static void openGUI(Function slot, Player player) {
|
||||
private static void openGUI(FunctionObject slot, Player player) {
|
||||
player.closeInventory();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
@@ -144,29 +149,29 @@ public class GUIListener implements Listener {
|
||||
}.runTaskLater(plugin, 1L);
|
||||
}
|
||||
|
||||
private static void message(Function slot, Player player) {
|
||||
private static void message(FunctionObject slot, Player player) {
|
||||
player.closeInventory();
|
||||
for (String msg : slot.message) {
|
||||
if (Main.PaPi) {
|
||||
if (slot.cost_Enable) {
|
||||
send.player(player, Replace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.getCurrency()));
|
||||
} else send.player(player, Replace.replace(prefix, player, Placeholder.replace(msg, player)));
|
||||
T2Csend.player(player, T2Creplace.replacePrice(prefix, player, Placeholder.replace(msg, player), slot.price + " " + ConfigValues.currency.value));
|
||||
} else T2Csend.player(player, T2Creplace.replace(prefix, player, Placeholder.replace(msg, player)));
|
||||
} else {
|
||||
if (slot.cost_Enable) {
|
||||
send.player(player, Replace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + SelectConfig.getCurrency()));
|
||||
} else send.player(player, Replace.replace(prefix, Placeholder.replace(msg, player)));
|
||||
T2Csend.player(player, T2Creplace.replacePrice(prefix, Placeholder.replace(msg, player), slot.price + " " + ConfigValues.currency.value));
|
||||
} else T2Csend.player(player, T2Creplace.replace(prefix, Placeholder.replace(msg, player)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void serverChange(Function slot, Player player) {
|
||||
private static void serverChange(FunctionObject slot, Player player) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.closeInventory();
|
||||
}
|
||||
}.runTaskLater(plugin, 1L);
|
||||
send.player(player, SelectMessages.onServerChange.replace("[server]", slot.serverChangeServer));
|
||||
T2Csend.player(player, SelectMessages.onServerChange.replace("[server]", slot.serverChangeServer));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -175,7 +180,7 @@ public class GUIListener implements Listener {
|
||||
}.runTaskLater(Main.getPlugin(), 20L);
|
||||
}
|
||||
|
||||
private static void setConfig(Function slot, Player player, InventoryClickEvent e) {
|
||||
private static void setConfig(FunctionObject slot, Player player, InventoryClickEvent e) {
|
||||
File config = new File(slot.configFilePath);
|
||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||
|
||||
@@ -197,7 +202,7 @@ public class GUIListener implements Listener {
|
||||
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueLeft);
|
||||
break;
|
||||
default:
|
||||
send.player(player, "§cCheck the Option §6SetConfig/Option/Premat"); //todo
|
||||
T2Csend.player(player, "§cCheck the Option §6SetConfig/Option/Premat"); //todo
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -220,7 +225,7 @@ public class GUIListener implements Listener {
|
||||
yamlConfiguration.set(slot.configOptionPath.replace("/", "."), slot.configListValueRight);
|
||||
break;
|
||||
default:
|
||||
send.player(player, "§cCheck the Option §6SetConfig/Option/Premat"); //todo
|
||||
T2Csend.player(player, "§cCheck the Option §6SetConfig/Option/Premat"); //todo
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -241,9 +246,9 @@ public class GUIListener implements Listener {
|
||||
}.runTaskLater(plugin, 1L);
|
||||
}
|
||||
|
||||
private static void togglePerm(Function function, Gui gui, Player player) {
|
||||
private static void togglePerm(FunctionObject function, GuiObject gui, Player player) {
|
||||
if (player.hasPermission(function.togglePermissionPerm)) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.getTogglePermFalse().replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), String.valueOf(ConfigValues.togglePermFalse.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -252,7 +257,7 @@ public class GUIListener implements Listener {
|
||||
}
|
||||
}.runTaskLater(plugin, 4L);
|
||||
} else
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), SelectConfig.getTogglePermTrue().replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), String.valueOf(ConfigValues.togglePermTrue.value).replace("[player]", player.getName()).replace("[perm]", function.togglePermissionPerm));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -262,7 +267,7 @@ public class GUIListener implements Listener {
|
||||
}.runTaskLater(plugin, 4L);
|
||||
}
|
||||
|
||||
private static void toggleUseItem(Player player, Gui gui) {
|
||||
private static void toggleUseItem(Player player, GuiObject gui) {
|
||||
if (Events.useItemHashMap.get(player.getName())) {
|
||||
Commands.itemOff(player);
|
||||
} else {
|
||||
@@ -277,87 +282,87 @@ public class GUIListener implements Listener {
|
||||
}.runTaskLater(plugin, 2L);
|
||||
}
|
||||
|
||||
private static void votePoints(InventoryClickEvent e, Function function, Player player) {
|
||||
private static void votePoints(InventoryClickEvent e, FunctionObject function, Player player) {
|
||||
player.closeInventory();
|
||||
switch (function.functionVotePointsMode) {
|
||||
case ADD:
|
||||
Eco.votePointsAdd(prefix, player, function.functionVotePointsAmount);
|
||||
send.player(player, SelectMessages.functionVoteAdd.replace("[amount]", function.functionVotePointsAmount.toString()));
|
||||
T2Ceco.votePointsAdd(prefix, player, function.functionVotePointsAmount);
|
||||
T2Csend.player(player, SelectMessages.functionVoteAdd.replace("[amount]", function.functionVotePointsAmount.toString()));
|
||||
break;
|
||||
case REMOVE:
|
||||
if (Eco.votePointsRemove(prefix, player, function.functionVotePointsAmount)) {
|
||||
send.player(player, SelectMessages.functionVoteRemove.replace("[amount]", function.functionVotePointsAmount.toString()));
|
||||
} else send.player(player, SelectMessages.functionVoteRemoveError.replace("[amount]", function.functionVotePointsAmount.toString()));
|
||||
if (T2Ceco.votePointsRemove(prefix, player, function.functionVotePointsAmount)) {
|
||||
T2Csend.player(player, SelectMessages.functionVoteRemove.replace("[amount]", function.functionVotePointsAmount.toString()));
|
||||
} else T2Csend.player(player, SelectMessages.functionVoteRemoveError.replace("[amount]", function.functionVotePointsAmount.toString()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void item(Function function, Player player) {
|
||||
private static void item(FunctionObject function, Player player) {
|
||||
String[] item = function.functionItemItem.split(";");
|
||||
player.closeInventory();
|
||||
switch (function.functionItemMode) {
|
||||
case ADD:
|
||||
Eco.itemAdd(player, item[0], Integer.parseInt(item[1]));
|
||||
send.player(player, SelectMessages.functionItemAdd.replace("[amount]", item[1]).replace("[item]", item[0]));
|
||||
T2Ceco.itemAdd(player, new ItemStack(Material.valueOf(item[0])), Integer.parseInt(item[1]));
|
||||
T2Csend.player(player, SelectMessages.functionItemAdd.replace("[amount]", item[1]).replace("[item]", item[0]));
|
||||
break;
|
||||
case REMOVE:
|
||||
if (Eco.itemRemove(player, item[0], Integer.parseInt(item[1]))) {
|
||||
send.player(player, SelectMessages.functionItemRemove.replace("[amount]", item[1]).replace("[item]", item[0]));
|
||||
if (T2Ceco.itemRemove(player, item[0], Integer.parseInt(item[1]))) {
|
||||
T2Csend.player(player, SelectMessages.functionItemRemove.replace("[amount]", item[1]).replace("[item]", item[0]));
|
||||
|
||||
} else send.player(player, SelectMessages.functionItemRemoveError.replace("[amount]", item[1]));
|
||||
} else T2Csend.player(player, SelectMessages.functionItemRemoveError.replace("[amount]", item[1]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void eco(InventoryClickEvent e, Slot slot, Player player, Gui gui, Function function) {
|
||||
private static void eco(InventoryClickEvent e, SlotObject slot, Player player, GuiObject gui, FunctionObject function) {
|
||||
switch (function.ecoModule) {
|
||||
case ITEM:
|
||||
String[] item = function.ecoItem.split(";");
|
||||
if (!Eco.itemRemove(player, item[0], Integer.parseInt(item[1]))) {
|
||||
if (!T2Ceco.itemRemove(player, item[0], Integer.parseInt(item[1]))) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.closeInventory();
|
||||
}
|
||||
}.runTaskLater(plugin, 1L);
|
||||
send.player(player, SelectMessages.noMoneyItem.replace("[item]", item[0]).replace("[amount]", item[1]));
|
||||
Sound.play(player, SoundEnum.NoMoney);
|
||||
T2Csend.player(player, SelectMessages.noMoneyItem.replace("[item]", item[0]).replace("[amount]", item[1]));
|
||||
PlaySound.play(player, SoundEnum.NoMoney);
|
||||
} else {
|
||||
send.player(player, SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name))
|
||||
T2Csend.player(player, SelectMessages.Buy_msg.replace("[itemname]", T2Creplace.replace(prefix, function.name))
|
||||
.replace("[price]", item[1] + " " + item[0]));
|
||||
execute(function, slot, player, e, gui);
|
||||
}
|
||||
break;
|
||||
case VOTEPOINTS:
|
||||
if (!Eco.votePointsRemove(prefix, player, function.votePoints)) {
|
||||
if (!T2Ceco.votePointsRemove(prefix, player, function.votePoints)) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.closeInventory();
|
||||
}
|
||||
}.runTaskLater(plugin, 1L);
|
||||
send.player(player, SelectMessages.noMoneyVote.replace("[amount]", function.votePoints.toString()));
|
||||
Sound.play(player, SoundEnum.NoMoney);
|
||||
T2Csend.player(player, SelectMessages.noMoneyVote.replace("[amount]", function.votePoints.toString()));
|
||||
PlaySound.play(player, SoundEnum.NoMoney);
|
||||
} else {
|
||||
send.player(player, SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name))
|
||||
T2Csend.player(player, SelectMessages.Buy_msg.replace("[itemname]", T2Creplace.replace(prefix, function.name))
|
||||
.replace("[price]", function.votePoints + " VotePoints"));
|
||||
execute(function, slot, player, e, gui);
|
||||
}
|
||||
break;
|
||||
case VAULT:
|
||||
case MONEY:
|
||||
if (!Eco.moneyRemove(prefix, player, function.price)) {
|
||||
if (!T2Ceco.moneyRemove(prefix, player, function.price)) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.closeInventory();
|
||||
}
|
||||
}.runTaskLater(plugin, 1L);
|
||||
send.player(player, Replace.replacePrice(prefix, SelectMessages.noMoney, String.valueOf(function.price)));
|
||||
Sound.play(player, SoundEnum.NoMoney);
|
||||
T2Csend.player(player, T2Creplace.replacePrice(prefix, SelectMessages.noMoney, String.valueOf(function.price)));
|
||||
PlaySound.play(player, SoundEnum.NoMoney);
|
||||
} else {
|
||||
send.player(player, SelectMessages.Buy_msg.replace("[itemname]", Replace.replace(prefix, function.name))
|
||||
.replace("[price]", function.price + " " + SelectConfig.getCurrency()));
|
||||
T2Csend.player(player, SelectMessages.Buy_msg.replace("[itemname]", T2Creplace.replace(prefix, function.name))
|
||||
.replace("[price]", function.price + " " + ConfigValues.currency.value));
|
||||
execute(function, slot, player, e, gui);
|
||||
}
|
||||
break;
|
@@ -1,17 +1,18 @@
|
||||
package de.jatitv.commandguiv2.Spigot.gui;
|
||||
package net.t2code.commandguiv2.Spigot.function.gui;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||
import de.jatitv.commandguiv2.Spigot.system.Placeholder;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.SlotObject;
|
||||
import net.t2code.commandguiv2.Spigot.system.Placeholder;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@@ -26,8 +27,8 @@ public class GuiBuilder {
|
||||
|
||||
private static String prefix = Util.getPrefix();
|
||||
|
||||
protected static void item(Slot slot, Player player, Inventory inventory) {
|
||||
Function function = Main.functionHashMap.get(slot.function);
|
||||
protected static void item(SlotObject slot, Player player, Inventory inventory) {
|
||||
FunctionObject function = Cache.functionHashMap.get(slot.function);
|
||||
ItemStack item;
|
||||
if (Main.legacy && function.item.toUpperCase().contains(",")) {
|
||||
String[] split = function.item.toUpperCase().split(",");
|
||||
@@ -44,8 +45,8 @@ public class GuiBuilder {
|
||||
inventory.setItem(slot.slot, item);
|
||||
}
|
||||
|
||||
protected static void item(String material, Slot slot, Player player, Inventory inventory) {
|
||||
Function function = Main.functionHashMap.get(slot.function);
|
||||
protected static void item(String material, SlotObject slot, Player player, Inventory inventory) {
|
||||
FunctionObject function = Cache.functionHashMap.get(slot.function);
|
||||
ItemStack item;
|
||||
if (Main.legacy && material.contains(",")) {
|
||||
String[] split = material.split(",");
|
||||
@@ -63,24 +64,24 @@ public class GuiBuilder {
|
||||
}
|
||||
|
||||
|
||||
private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Slot slot) {
|
||||
Function function = Main.functionHashMap.get(slot.function);
|
||||
private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, SlotObject slot) {
|
||||
FunctionObject function = Cache.functionHashMap.get(slot.function);
|
||||
if (Main.PaPi) {
|
||||
itemMeta.setDisplayName(Replace.replace(prefix, player, Placeholder.replace(function.name, player)));
|
||||
itemMeta.setDisplayName(T2Creplace.replace(prefix, player, Placeholder.replace(function.name, player)));
|
||||
if (slot.permission && !player.hasPermission(slot.permissionToUse) && function.noPermLoreEnable) {
|
||||
itemMeta.setLore(Replace.replacePrice(prefix, player, Placeholder.replace(function.noPermLore, player), function.price + " " + SelectConfig.getCurrency()));
|
||||
} else itemMeta.setLore(Replace.replacePrice(prefix, player, Placeholder.replace(function.lore, player), function.price + " " + SelectConfig.getCurrency()));
|
||||
itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.noPermLore, player), function.price + " " + ConfigValues.currency.value));
|
||||
} else itemMeta.setLore(T2Creplace.replacePrice(prefix, player, Placeholder.replace(function.lore, player), function.price + " " + ConfigValues.currency.value));
|
||||
} else {
|
||||
itemMeta.setDisplayName(Replace.replace(prefix, Placeholder.replace(function.name, player)));
|
||||
itemMeta.setDisplayName(T2Creplace.replace(prefix, Placeholder.replace(function.name, player)));
|
||||
if (slot.permission && !player.hasPermission(slot.permissionToUse) && function.noPermLoreEnable) {
|
||||
itemMeta.setLore(Replace.replacePrice(prefix, Placeholder.replace(function.noPermLore, player), function.price + " " + SelectConfig.getCurrency()));
|
||||
} else itemMeta.setLore(Replace.replacePrice(prefix, Placeholder.replace(function.lore, player), function.price + " " + SelectConfig.getCurrency()));
|
||||
itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.noPermLore, player), function.price + " " + ConfigValues.currency.value));
|
||||
} else itemMeta.setLore(T2Creplace.replacePrice(prefix, Placeholder.replace(function.lore, player), function.price + " " + ConfigValues.currency.value));
|
||||
}
|
||||
}
|
||||
|
||||
protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) {
|
||||
Function function = Main.functionHashMap.get(slot.function);
|
||||
ItemStack item = ItemVersion.getHeadIS();
|
||||
protected static void base64(String base64Value, SlotObject slot, Player player, Inventory inventory) {
|
||||
FunctionObject function = Cache.functionHashMap.get(slot.function);
|
||||
ItemStack item = T2CitemVersion.getHeadIS();
|
||||
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
|
||||
setBase64(itemMeta, base64Value);
|
||||
setDisplayNameAndLore(itemMeta, player, slot);
|
||||
@@ -106,14 +107,14 @@ public class GuiBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
protected static void base64(Slot slot, Player player, Inventory inventory) {
|
||||
Function function = Main.functionHashMap.get(slot.function);
|
||||
protected static void base64(SlotObject slot, Player player, Inventory inventory) {
|
||||
FunctionObject function = Cache.functionHashMap.get(slot.function);
|
||||
base64(function.base64Value, slot, player, inventory);
|
||||
}
|
||||
|
||||
protected static void playerHead(Slot slot, Player player, Inventory inventory, String skullName) {
|
||||
Function function = Main.functionHashMap.get(slot.function);
|
||||
ItemStack item = ItemVersion.getHeadIS();
|
||||
protected static void playerHead(SlotObject slot, Player player, Inventory inventory, String skullName) {
|
||||
FunctionObject function = Cache.functionHashMap.get(slot.function);
|
||||
ItemStack item = T2CitemVersion.getHeadIS();
|
||||
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
|
||||
setDisplayNameAndLore(itemMeta, player, slot);
|
||||
itemMeta.setOwner(skullName);
|
||||
@@ -126,9 +127,9 @@ public class GuiBuilder {
|
||||
inventory.setItem(slot.slot, item);
|
||||
}
|
||||
|
||||
public static void fillItem(Inventory inventory, Gui gui) {
|
||||
public static void fillItem(Inventory inventory, GuiObject gui) {
|
||||
ItemStack glass;
|
||||
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
|
||||
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.parseShort(gui.guiFillItemItem));
|
||||
} else glass = new ItemStack(Material.valueOf(gui.guiFillItemItem.toUpperCase().replace(".", "_")));
|
||||
ItemMeta itemMetaglass = glass.getItemMeta();
|
@@ -1,21 +1,22 @@
|
||||
package de.jatitv.commandguiv2.Spigot.gui;
|
||||
package net.t2code.commandguiv2.Spigot.function.gui;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.system.Permissions;
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.functions.Function;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.guis.Gui;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||
import de.jatitv.commandguiv2.Spigot.sound.Sound;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.SoundEnum;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.system.Permissions;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.SlotObject;
|
||||
import net.t2code.commandguiv2.Spigot.sound.PlaySound;
|
||||
import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import io.github.solyze.plugmangui.inventories.PluginListGUI;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.luckyBox.api.LuckyBoxAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -29,7 +30,7 @@ public class OpenGUI {
|
||||
private static String prefix = Util.getPrefix();
|
||||
|
||||
public static void openGUI(Player player, String guiString, Boolean sound) {
|
||||
Gui gui = Main.guiHashMap.get(guiString);
|
||||
GuiObject gui = Cache.guiHashMap.get(guiString);
|
||||
Long long_ = Long.valueOf(System.currentTimeMillis());
|
||||
switch (guiString) {
|
||||
//case "plugin.PlotSquaredGUI":
|
||||
@@ -47,7 +48,7 @@ public class OpenGUI {
|
||||
player.openInventory((new PluginListGUI(54, 1)).getInventory());
|
||||
} else {
|
||||
if (player.hasPermission(Permissions.admin)) {
|
||||
send.player(player, prefix + " §4PlugManGUI could not be found! §9Please download it here: " +
|
||||
T2Csend.player(player, prefix + " §4PlugManGUI could not be found! §9Please download it here: " +
|
||||
"§6https://spigotmc.org/resources/plugmangui.87599/");
|
||||
}
|
||||
}
|
||||
@@ -57,30 +58,30 @@ public class OpenGUI {
|
||||
LuckyBoxAPI.openShop(player);
|
||||
} else {
|
||||
if (player.hasPermission(Permissions.admin)) {
|
||||
send.player(player, prefix + " §4T2C-LuckyBox could not be found! §9Please download it here: " +
|
||||
T2Csend.player(player, prefix + " §4T2C-LuckyBox could not be found! §9Please download it here: " +
|
||||
"§6https://www.spigotmc.org/resources/luckybox.98154/");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (MCVersion.minecraft1_13) {
|
||||
if (T2CmcVersion.isMc1_13()) {
|
||||
GUIListener.GUICode = "";
|
||||
} else GUIListener.GUICode = "§6§8§9§r";
|
||||
if (gui.guiEnable || player.hasPermission(Permissions.updatemsg)) {
|
||||
Inventory inventory;
|
||||
if (Main.PaPi) {
|
||||
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (Replace.replace(prefix, player, GUIListener.GUICode + gui.guiName)));
|
||||
} else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (Replace.replace(prefix, GUIListener.GUICode + gui.guiName)));
|
||||
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (T2Creplace.replace(prefix, player, GUIListener.GUICode + gui.guiName)));
|
||||
} else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.guiLines, (T2Creplace.replace(prefix, GUIListener.GUICode + gui.guiName)));
|
||||
|
||||
if (gui.guiFillItemEnable) {
|
||||
GuiBuilder.fillItem(inventory, gui);
|
||||
}
|
||||
for (Slot slot : gui.slots) {
|
||||
for (SlotObject slot : gui.slots) {
|
||||
try {
|
||||
Function function = Main.functionHashMap.get(slot.function);
|
||||
FunctionObject function = Cache.functionHashMap.get(slot.function);
|
||||
if (function == null) {
|
||||
send.error(Main.getPlugin(), "The Function " + slot.function + " in the GUI " + gui.key + " does not exist!");
|
||||
T2Csend.error(Main.getPlugin(), "The Function " + slot.function + " in the GUI " + gui.key + " does not exist!");
|
||||
continue;
|
||||
}
|
||||
if (slot.permission && !player.hasPermission(slot.permissionToSee)) continue;
|
||||
@@ -128,22 +129,22 @@ public class OpenGUI {
|
||||
|
||||
}
|
||||
if (sound) {
|
||||
Sound.play(player, SoundEnum.OpenInventory);
|
||||
PlaySound.play(player, SoundEnum.OpenInventory);
|
||||
}
|
||||
player.openInventory(inventory);
|
||||
send.debug(plugin, "§6" + player.getName() + " §5Open §6" + Replace.replace(prefix, gui.guiName) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
||||
} else send.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", Replace.replace(prefix, gui.guiName)));
|
||||
T2Csend.debug(plugin, "§6" + player.getName() + " §5Open §6" + T2Creplace.replace(prefix, gui.guiName) + " §5" + " §7- §e" + (System.currentTimeMillis() - long_.longValue()) + "ms");
|
||||
} else T2Csend.player(player, SelectMessages.GUIIsDisabled.replace("[gui]", T2Creplace.replace(prefix, gui.guiName)));
|
||||
}
|
||||
|
||||
private static void toggleOn(Function function, Slot slot, Player player, Inventory inventory) {
|
||||
if (SelectConfig.getToggleItemOnOrYesBase64()) {
|
||||
GuiBuilder.base64(SelectConfig.getToggleItemOnOrYesBase64Value(), slot, player, inventory);
|
||||
} else GuiBuilder.item(SelectConfig.getToggleItemOnOrYesMaterial(), slot, player, inventory);
|
||||
private static void toggleOn(FunctionObject function, SlotObject slot, Player player, Inventory inventory) {
|
||||
if ((Boolean) ConfigValues.toggleItemOnOrYesBase64.value) {
|
||||
GuiBuilder.base64(String.valueOf( ConfigValues.toggleItemOnOrYesBase64Value.value), slot, player, inventory);
|
||||
} else GuiBuilder.item(String.valueOf(ConfigValues.toggleItemOnOrYesMaterial.value), slot, player, inventory);
|
||||
}
|
||||
|
||||
private static void toggleOff(Function function, Slot slot, Player player, Inventory inventory) {
|
||||
if (SelectConfig.getToggleItemOffOrNoBase64()) {
|
||||
GuiBuilder.base64(SelectConfig.getToggleItemOffOrNoBase64Value(), slot, player, inventory);
|
||||
} else GuiBuilder.item(SelectConfig.getToggleItemOffOrNoMaterial(), slot, player, inventory);
|
||||
private static void toggleOff(FunctionObject function, SlotObject slot, Player player, Inventory inventory) {
|
||||
if ((Boolean) ConfigValues.toggleItemOffOrNoBase64.value) {
|
||||
GuiBuilder.base64(String.valueOf( ConfigValues.toggleItemOffOrNoBase64Value.value), slot, player, inventory);
|
||||
} else GuiBuilder.item(String.valueOf(ConfigValues.toggleItemOffOrNoMaterial.value), slot, player, inventory);
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package de.jatitv.commandguiv2.Spigot.listener;
|
||||
package net.t2code.commandguiv2.Spigot.function.listener;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -16,12 +16,12 @@ public class Bungee_Sender_Reciver implements PluginMessageListener {
|
||||
DataOutputStream output = new DataOutputStream(stream);
|
||||
try {
|
||||
if (console) {
|
||||
output.writeUTF("cgui-Console");
|
||||
output.writeUTF("T2Code-Console");
|
||||
} else {
|
||||
if (sender instanceof Player) {
|
||||
output.writeUTF(sender.getName());
|
||||
} else {
|
||||
output.writeUTF("cgui-Console");
|
||||
output.writeUTF("T2Code-Console");
|
||||
}
|
||||
}
|
||||
output.writeUTF(information);
|
||||
@@ -30,10 +30,10 @@ public class Bungee_Sender_Reciver implements PluginMessageListener {
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
player.sendPluginMessage(Main.getPlugin(), "cgui:bungee", stream.toByteArray());
|
||||
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
|
||||
}else {
|
||||
for(Player player : Bukkit.getOnlinePlayers()){
|
||||
player.sendPluginMessage(Main.getPlugin(), "cgui:bungee", stream.toByteArray());
|
||||
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -42,12 +42,12 @@ public class Bungee_Sender_Reciver implements PluginMessageListener {
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(message));
|
||||
send.debug(Main.getPlugin(),"stream: "+stream.toString());
|
||||
T2Csend.debug(Main.getPlugin(),"stream: "+stream.toString());
|
||||
try {
|
||||
String subChannel = stream.readUTF();
|
||||
String input = stream.readUTF();
|
||||
send.debug(Main.getPlugin(),"subChannel: " +subChannel);
|
||||
send.debug(Main.getPlugin(),"input: " +input);
|
||||
T2Csend.debug(Main.getPlugin(),"subChannel: " +subChannel);
|
||||
T2Csend.debug(Main.getPlugin(),"input: " +input);
|
||||
switch (subChannel) {
|
||||
case "join":
|
||||
Main.bungeejoinplayers.add(input);
|
@@ -1,11 +1,12 @@
|
||||
// This claas was created by JaTiTV
|
||||
|
||||
package de.jatitv.commandguiv2.Spigot.listener;
|
||||
package net.t2code.commandguiv2.Spigot.function.listener;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import net.t2code.commandguiv2.Spigot.system.Permissions;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -18,6 +19,6 @@ public class PluginEvent implements Listener {
|
||||
public void onJoinEvent(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
SelectDatabase.nameCheck(player);
|
||||
UpdateAPI.join(Main.getPlugin(),prefix, "commandgui.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
|
||||
T2CupdateAPI.join(Main.getPlugin(),prefix, Permissions.updatemsg, event.getPlayer(), Util.getSpigotID(), Util.getDiscord());
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
package de.jatitv.commandguiv2.Spigot.listener;
|
||||
package net.t2code.commandguiv2.Spigot.function.listener;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
@@ -1,14 +1,14 @@
|
||||
package de.jatitv.commandguiv2.Spigot.useItem;
|
||||
package net.t2code.commandguiv2.Spigot.function.useItem;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.gui.OpenGUI;
|
||||
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import de.jatitv.commandguiv2.api.CGuiAPI;
|
||||
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.Commands;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.function.gui.OpenGUI;
|
||||
import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import net.t2code.commandguiv2.api.CGuiAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -40,18 +40,18 @@ public class Events implements Listener {
|
||||
useItemHashMap.put(e.getPlayer().getName(), SelectDatabase.selectItemStatus(e.getPlayer()));
|
||||
Integer i = SelectDatabase.selectSlot(e.getPlayer());
|
||||
if (i == null) {
|
||||
useItemSlotHashMap.put(e.getPlayer().getName(), SelectConfig.getUseItem_InventorySlot());
|
||||
useItemSlotHashMap.put(e.getPlayer().getName(), (Integer) ConfigValues.useItemInventorySlot.value);
|
||||
} else useItemSlotHashMap.put(e.getPlayer().getName(), i);
|
||||
|
||||
if (CGuiAPI.JoinDisable) {
|
||||
send.debug(Main.getPlugin(), "JoinDisable");
|
||||
T2Csend.debug(Main.getPlugin(), "JoinDisable");
|
||||
return;
|
||||
}
|
||||
if (e.getPlayer().hasPermission("commandgui.get.guiitem.at.login")) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
send.debug(Main.getPlugin(), "itemChange: " + e.getPlayer().getName());
|
||||
T2Csend.debug(Main.getPlugin(), "itemChange: " + e.getPlayer().getName());
|
||||
ItemChange.itemChange(e.getPlayer(), true);
|
||||
}
|
||||
}.runTaskLater(Main.getPlugin(), 20L * 1);
|
||||
@@ -64,7 +64,6 @@ public class Events implements Listener {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onDeathDrop(PlayerDeathEvent e) {
|
||||
Player player = e.getEntity().getPlayer();
|
||||
@@ -74,7 +73,7 @@ public class Events implements Listener {
|
||||
while (var3.hasNext()) {
|
||||
ItemStack items = (ItemStack) var3.next();
|
||||
if (items != null && items.hasItemMeta() && items.getItemMeta().hasDisplayName()
|
||||
&& items.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& items.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
e.getDrops().remove(items);
|
||||
}
|
||||
}
|
||||
@@ -84,10 +83,10 @@ public class Events implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onRespawn(PlayerRespawnEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (SelectConfig.getUseItem_Enable()) {
|
||||
if ((Boolean) ConfigValues.useItemEnable.value) {
|
||||
ItemChange.itemChange(player, false);
|
||||
//if (!SelectConfig.getUseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
|
||||
// if (SelectConfig.getUseItem_GiveOnlyOnFirstJoin) {
|
||||
//if (!Config.getUseItem_AllowToggle || Select_Database.selectItemStatus(player)) {
|
||||
// if (Config.getUseItem_GiveOnlyOnFirstJoin) {
|
||||
// if (!player.hasPlayedBefore()) {
|
||||
// new BukkitRunnable() {
|
||||
// @Override
|
||||
@@ -111,7 +110,7 @@ public class Events implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onGameModeChange(PlayerGameModeChangeEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (!SelectConfig.getUseItemGameModeChangeEnable()) {
|
||||
if (!(Boolean) ConfigValues.useItemGameModeChangeEnable.value) {
|
||||
return;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@@ -119,13 +118,13 @@ public class Events implements Listener {
|
||||
public void run() {
|
||||
ItemChange.itemChange(player, false);
|
||||
}
|
||||
}.runTaskLater(Main.getPlugin(), SelectConfig.getUseItemGameModeChangeDelayInTicks() * 1L);
|
||||
}.runTaskLater(Main.getPlugin(), (Integer) ConfigValues.useItemGameModeChangeDelayInTicks.value * 1L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldChange(PlayerChangedWorldEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (!SelectConfig.getUseItemWorldChangeEnable()) {
|
||||
if (!(Boolean) ConfigValues.useItemWorldChangeEnable.value) {
|
||||
return;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@@ -133,30 +132,30 @@ public class Events implements Listener {
|
||||
public void run() {
|
||||
ItemChange.itemChange(player, false);
|
||||
}
|
||||
}.runTaskLater(Main.getPlugin(), SelectConfig.getUseItemWorldChangeDelayInTicks() * 1L);
|
||||
}.runTaskLater(Main.getPlugin(), (Integer) ConfigValues.useItemWorldChangeDelayInTicks.value * 1L);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (!p.isSneaking()) {
|
||||
for (String material : SelectConfig.getUseItemItemBlockBlacklist()) {
|
||||
for (String material : (ArrayList<String>) ConfigValues.useItemItemBlockBlacklist.value) {
|
||||
if (e.getClickedBlock() != null) {
|
||||
if (e.getClickedBlock().getType() == Material.valueOf(material)) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectConfig.getUseItem_Enable()) {
|
||||
if (SelectConfig.getUseItem_PlayerHead_Enable()) {
|
||||
if (e.getItem() != null && p.getItemInHand().getType() == ItemVersion.getHead()) {
|
||||
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
if ((Boolean) ConfigValues.useItemEnable.value) {
|
||||
if ((Boolean) ConfigValues.useItemPlayerHeadEnable.value) {
|
||||
if (e.getItem() != null && p.getItemInHand().getType() == T2CitemVersion.getHead()) {
|
||||
if (e.getItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
openGUI(e, p);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(SelectConfig.getUseItem_Material())) {
|
||||
if (e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
if (e.getItem() != null && p.getItemInHand().getType() == Material.valueOf(String.valueOf(ConfigValues.useItemMaterial.value))) {
|
||||
if (e.getItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
openGUI(e, p);
|
||||
}
|
||||
}
|
||||
@@ -167,7 +166,7 @@ public class Events implements Listener {
|
||||
private static void openGUI(PlayerInteractEvent e, Player player) {
|
||||
e.setCancelled(true);
|
||||
|
||||
if ((!SelectConfig.getDisableInfoBySneak()) && player.isSneaking()) {
|
||||
if ((!(Boolean) ConfigValues.disableInfoBySneak.value) && player.isSneaking()) {
|
||||
Commands.info(player);
|
||||
return;
|
||||
}
|
||||
@@ -178,45 +177,45 @@ public class Events implements Listener {
|
||||
|
||||
if (UseItem.protection(player, true)) return;
|
||||
|
||||
if (SelectConfig.getUseItemGameModeProtection()) {
|
||||
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) {
|
||||
if ((Boolean) ConfigValues.useItemGameModeProtection.value) {
|
||||
if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.useItemGameModeList.value).contains(player.getGameMode().toString())) {
|
||||
e.setCancelled(true);
|
||||
send.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||
T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.getUseItemGameModeMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemGameModeList().contains(player.getGameMode().toString())) {
|
||||
if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.useItemGameModeList.value).contains(player.getGameMode().toString())) {
|
||||
e.setCancelled(true);
|
||||
send.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||
T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectConfig.getUseItemWorldProtection()) {
|
||||
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("blacklist") && SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) {
|
||||
if ((Boolean) ConfigValues.useItemWorldProtection.value) {
|
||||
if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.useItemWorldList.value).contains(player.getWorld().getName())) {
|
||||
e.setCancelled(true);
|
||||
send.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||
T2Csend.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||
return;
|
||||
}
|
||||
if (SelectConfig.getUseItemWorldMode().equalsIgnoreCase("whitelist") && !SelectConfig.getUseItemWorldList().contains(player.getWorld().getName())) {
|
||||
if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.useItemWorldList.value).contains(player.getWorld().getName())) {
|
||||
e.setCancelled(true);
|
||||
send.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||
T2Csend.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!SelectConfig.getUseItem_Permission() || player.hasPermission("commandgui.useitem")) {
|
||||
OpenGUI.openGUI(player, SelectConfig.getUseItem_OpenGUI(), true);
|
||||
if (!(Boolean) ConfigValues.useItemPermission.value || player.hasPermission("commandgui.useitem")) {
|
||||
OpenGUI.openGUI(player, String.valueOf(ConfigValues.useItemOpenGUI.value), true);
|
||||
} else {
|
||||
send.player(player,SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
|
||||
.replace("[gui]", SelectConfig.getUseItem_OpenGUI()));
|
||||
T2Csend.player(player, SelectMessages.NoPermissionForUseItem.replace("[perm]", "commandgui.useitem")
|
||||
.replace("[gui]", String.valueOf(ConfigValues.useItemOpenGUI.value)));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onItemMoveEvent(InventoryMoveItemEvent e) {
|
||||
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
|
||||
if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return;
|
||||
if (e.getItem() != null && e.getItem().hasItemMeta() && e.getItem().getItemMeta().hasDisplayName()
|
||||
&& e.getItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -224,19 +223,19 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onItemMove(InventoryDragEvent e) {
|
||||
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
|
||||
if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return;
|
||||
|
||||
if (e.getWhoClicked() instanceof Player) {
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
|
||||
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getCursor().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
p.closeInventory();
|
||||
e.setCancelled(true);
|
||||
ItemChange.itemChange(p, false);
|
||||
}
|
||||
|
||||
if (e.getOldCursor() != null && e.getOldCursor().hasItemMeta() && e.getOldCursor().getItemMeta().hasDisplayName()
|
||||
&& e.getOldCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getOldCursor().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
p.closeInventory();
|
||||
e.setCancelled(true);
|
||||
ItemChange.itemChange(p, false);
|
||||
@@ -246,14 +245,14 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onItemMove(InventoryClickEvent e) {
|
||||
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
|
||||
if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return;
|
||||
|
||||
if (e.getCursor() != null && e.getCursor().hasItemMeta() && e.getCursor().getItemMeta().hasDisplayName()
|
||||
&& e.getCursor().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getCursor().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (e.getCurrentItem() != null && e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName()
|
||||
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
|
||||
e.setCancelled(true);
|
||||
}
|
||||
@@ -261,12 +260,12 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onItemMove(InventoryPickupItemEvent e) {
|
||||
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
|
||||
if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return;
|
||||
|
||||
if (e.getItem() != null && e.getItem().getItemStack() != null) {
|
||||
ItemStack item = e.getItem().getItemStack();
|
||||
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
||||
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& item.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -274,21 +273,21 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlace(BlockPlaceEvent e) {
|
||||
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
|
||||
if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return;
|
||||
if (e.getItemInHand() != null && e.getItemInHand().hasItemMeta() && e.getItemInHand().getItemMeta().hasDisplayName()
|
||||
&& e.getItemInHand().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getItemInHand().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onDrop(PlayerDropItemEvent e) {
|
||||
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
|
||||
if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return;
|
||||
|
||||
if (e.getItemDrop() != null && e.getItemDrop().getItemStack() != null) {
|
||||
ItemStack item = e.getItemDrop().getItemStack();
|
||||
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
||||
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& item.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -300,18 +299,18 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onClearServer(ServerCommandEvent event) {
|
||||
if (SelectConfig.getUseItem_KeepAtCommandClear()) {
|
||||
if ((Boolean) ConfigValues.useItemKeepAtCommandClear.value) {
|
||||
if (event.getCommand().contains("clear " + event.getCommand().replace("/", "").replace("clear ", ""))) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Player player = Bukkit.getPlayer(event.getCommand().replace("/", "").replace("clear ", ""));
|
||||
if (player == null){
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
clearGive(player);
|
||||
} catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
@@ -324,7 +323,7 @@ public class Events implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onClearPlayer(PlayerCommandPreprocessEvent event) {
|
||||
if (SelectConfig.getUseItem_KeepAtCommandClear()) {
|
||||
if ((Boolean) ConfigValues.useItemKeepAtCommandClear.value) {
|
||||
if (event.getMessage().toLowerCase().contains("clear")) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
@@ -1,7 +1,6 @@
|
||||
package de.jatitv.commandguiv2.Spigot.useItem;
|
||||
package net.t2code.commandguiv2.Spigot.function.useItem;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -12,27 +11,27 @@ public class EventsFrom110 implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onHandSwap(PlayerSwapHandItemsEvent e) {
|
||||
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
|
||||
if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return;
|
||||
if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName()
|
||||
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
}
|
||||
if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName()
|
||||
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onItemMove(PlayerSwapHandItemsEvent e) {
|
||||
if (!SelectConfig.getUseItem_BlockMoveAndDrop() || !SelectConfig.getUseItem_Enable()) return;
|
||||
if (!(Boolean) ConfigValues.useItemBlockMoveAndDrop.value || !(Boolean) ConfigValues.useItemEnable.value) return;
|
||||
Player p = e.getPlayer();
|
||||
if (e.getOffHandItem() != null && e.getOffHandItem().hasItemMeta() && e.getOffHandItem().getItemMeta().hasDisplayName()
|
||||
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getOffHandItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
p.closeInventory();
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (e.getMainHandItem() != null && e.getMainHandItem().hasItemMeta() && e.getMainHandItem().getItemMeta().hasDisplayName()
|
||||
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name())) {
|
||||
&& e.getMainHandItem().getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
p.closeInventory();
|
||||
e.setCancelled(true);
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
package net.t2code.commandguiv2.Spigot.function.useItem;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ItemChange {
|
||||
public static void itemChange(Player player, Boolean setCursor) {
|
||||
T2Csend.debug(Main.getPlugin(), "Join: " + player.getName());
|
||||
Integer slot;
|
||||
if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value) {
|
||||
slot = (Integer) ConfigValues.useItemInventorySlot.value;
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
T2Csend.debug(Main.getPlugin(), "Slot " + slot + " for player: " + player.getName());
|
||||
|
||||
if (!(Boolean) ConfigValues.useItemEnable.value) {
|
||||
return;
|
||||
}
|
||||
UseItem.removeItem(player);
|
||||
if (UseItem.protection(player, false)) return;
|
||||
if ((Boolean) ConfigValues.useItemGiveOnlyOnFirstJoin.value) {
|
||||
T2Csend.debug(Main.getPlugin(), "OnlyOnFirstJoin: " + player.getName());
|
||||
if (!(Boolean) ConfigValues.useItemAllowToggle.value || Events.useItemHashMap.get(player.getName())) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() { //todo testen
|
||||
@Override
|
||||
public void run() {
|
||||
UseItem.giveUseItem(player);
|
||||
if (setCursor) {
|
||||
setCursor(player, slot);
|
||||
}
|
||||
}
|
||||
},1L);
|
||||
if ((Boolean) ConfigValues.cursorToGUIItemOnlyOnFirstLogin.value || (Boolean) ConfigValues.cursorToGUIItemOnLogin.value) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
T2Csend.debug(Main.getPlugin(), "GiveOnlyOnFirstJoin: " + player.getName());
|
||||
return;
|
||||
}
|
||||
if (!(Boolean) ConfigValues.useItemGiveOnEveryJoin.value) {
|
||||
T2Csend.debug(Main.getPlugin(), "!GiveOnEveryJoin: " + player.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Main.getPlugin(), new Runnable() { //todo testen
|
||||
@Override
|
||||
public void run() {
|
||||
Boolean pln = Events.useItemHashMap.get(player.getName());
|
||||
if (pln == null) return;
|
||||
if (!(Boolean) ConfigValues.useItemAllowToggle.value || pln) {
|
||||
if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value || player.getInventory().getItem(slot - 1) == null) {
|
||||
T2Csend.debug(Main.getPlugin(), "Give: " + player.getName());
|
||||
UseItem.giveUseItem(player);
|
||||
if (setCursor) {
|
||||
setCursor(player, slot);
|
||||
}
|
||||
} else if ((Boolean) ConfigValues.useItemInventorySlotFreeSlot.value) {
|
||||
boolean empty = false;
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (player.getInventory().getItem(i) == null) {
|
||||
empty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty) {
|
||||
UseItem.addUseItem(player);
|
||||
}
|
||||
} else T2Csend.debug(Main.getPlugin(), "give skip [1]: " + player.getName());
|
||||
} else T2Csend.debug(Main.getPlugin(), "give skip [2]: " + player.getName());
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
private static void setCursor(Player player, int slot) {
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 1 Player: " + player.getName());
|
||||
|
||||
if (!(Boolean) ConfigValues.cursorToGUIItemOnLogin.value) {
|
||||
return;
|
||||
}
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 2 Player: " + player.getName());
|
||||
if ((Boolean) ConfigValues.cursorToGUIItemOnlyOnFirstLogin.value) {
|
||||
if (!player.hasPlayedBefore()) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 3 Player: " + player.getName());
|
||||
}
|
||||
return;
|
||||
}
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 4 Player: " + player.getName());
|
||||
if (!T2CLibConfig.getBungee()) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 5 Player: " + player.getName());
|
||||
return;
|
||||
}
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 6 Player: " + player.getName());
|
||||
if ((Boolean) ConfigValues.useItemServerChange.value) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 7 Player: " + player.getName());
|
||||
return;
|
||||
}
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 8 Player: " + player.getName());
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor bungeejoinplayers: " + Main.bungeejoinplayers);
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor Player: " + player.getName());
|
||||
if (Main.bungeejoinplayers.contains(player.getName())) {
|
||||
player.getInventory().setHeldItemSlot(slot - 1);
|
||||
T2Csend.debug(Main.getPlugin(), "setCursor 9 Player: " + player.getName());
|
||||
Main.bungeejoinplayers.remove(player.getName());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,143 @@
|
||||
package net.t2code.commandguiv2.Spigot.function.useItem;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UseItem {
|
||||
public static void giveUseItem(Player player) {
|
||||
Integer slot;
|
||||
if (protection(player, false)) return;
|
||||
if ((Boolean) ConfigValues.useItemInventorySlotEnforce.value) {
|
||||
slot = (Integer) ConfigValues.useItemInventorySlot.value;
|
||||
} else {
|
||||
slot = Events.useItemSlotHashMap.get(player.getName());
|
||||
}
|
||||
if ((Boolean) ConfigValues.useItemInventorySlotFreeSlot.value) {
|
||||
player.getInventory().addItem(itemStack(player));
|
||||
} else {
|
||||
T2Csend.debug(Main.getPlugin(), "setUseItem: " + player.getName() + " Slot: " + Integer.parseInt(String.valueOf(slot - 1)));
|
||||
player.getInventory().setItem(slot - 1, itemStack(player));
|
||||
}
|
||||
}
|
||||
|
||||
public static void addUseItem(Player player) {
|
||||
if (protection(player, false)) return;
|
||||
if ((Boolean) ConfigValues.useItemInventorySlotFreeSlot.value) {
|
||||
player.getInventory().addItem(itemStack(player));
|
||||
} else player.getInventory().addItem(itemStack(player));
|
||||
}
|
||||
|
||||
private static ItemStack itemStack(Player player) {
|
||||
ItemStack item = null;
|
||||
if ((Boolean) ConfigValues.useItemPlayerHeadEnable.value) {
|
||||
if (T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
|
||||
T2Csend.player(player, Util.getPrefix() + "§c Playerheads for UseItem are only available from version §61.13§c!");
|
||||
T2Csend.error(Main.getPlugin(), "Playerheads for UseItem are only available from version 1.13!");
|
||||
} else {
|
||||
item = T2CitemVersion.getHeadIS();
|
||||
SkullMeta playerheadmeta = (SkullMeta) item.getItemMeta();
|
||||
playerheadmeta.setDisplayName(String.valueOf(ConfigValues.useItemName.value));
|
||||
if ((Boolean) ConfigValues.useItemBase64Enable.value) {
|
||||
if (Main.PaPi) {
|
||||
playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList<String>) ConfigValues.useItemLore.value));
|
||||
} else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) ConfigValues.useItemLore.value));
|
||||
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
|
||||
profile.getProperties().put("textures", new Property("textures", String.valueOf(ConfigValues.useItemBase64value.value)));
|
||||
Field profileField = null;
|
||||
try {
|
||||
profileField = playerheadmeta.getClass().getDeclaredField("profile");
|
||||
profileField.setAccessible(true);
|
||||
profileField.set(playerheadmeta, profile);
|
||||
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
String p;
|
||||
if ((Boolean) ConfigValues.useItemPlayerWhoHasOpenedTheGUI.value) {
|
||||
p = player.getName();
|
||||
} else p = String.valueOf(ConfigValues.useItemPlayerName.value);
|
||||
playerheadmeta.setOwner(p);
|
||||
if (Main.PaPi) {
|
||||
playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList<String>) ConfigValues.useItemLore.value));
|
||||
} else playerheadmeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) ConfigValues.useItemLore.value));
|
||||
}
|
||||
item.setItemMeta(playerheadmeta);
|
||||
}
|
||||
} else {
|
||||
item = new ItemStack(Material.valueOf(String.valueOf(ConfigValues.useItemMaterial.value)));
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(String.valueOf(ConfigValues.useItemName.value));
|
||||
if (Main.PaPi) {
|
||||
itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), player, (ArrayList<String>) ConfigValues.useItemLore.value));
|
||||
} else itemMeta.setLore(T2Creplace.replace(Util.getPrefix(), (ArrayList<String>) ConfigValues.useItemLore.value));
|
||||
item.setItemMeta(itemMeta);
|
||||
item.setAmount(1);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public static boolean protection(Player player, Boolean interact) {
|
||||
if ((Boolean) ConfigValues.useItemGameModeProtection.value) {
|
||||
if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.useItemGameModeList.value).contains(player.getGameMode().toString())) {
|
||||
if (interact) {
|
||||
T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||
} else if (!(Boolean) ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player);
|
||||
return true;
|
||||
}
|
||||
if (String.valueOf(ConfigValues.useItemGameModeMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.useItemGameModeList.value).contains(player.getGameMode().toString())) {
|
||||
if (interact) {
|
||||
T2Csend.player(player, SelectMessages.UseItemDisabledInGameMode);
|
||||
} else if (!(Boolean) ConfigValues.useItemGameModeRemoveItemWhenItIsDisabled.value) removeItem(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if ((Boolean) ConfigValues.useItemWorldProtection.value) {
|
||||
if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("blacklist") && String.valueOf(ConfigValues.useItemWorldList.value).contains(player.getWorld().getName())) {
|
||||
if (interact) {
|
||||
T2Csend.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||
} else if (!(Boolean) ConfigValues.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player);
|
||||
return true;
|
||||
}
|
||||
if (String.valueOf(ConfigValues.useItemWorldMode.value).equalsIgnoreCase("whitelist") && !String.valueOf(ConfigValues.useItemWorldList.value).contains(player.getWorld().getName())) {
|
||||
if (interact) {
|
||||
T2Csend.player(player, SelectMessages.UseItemDisabledInWorld);
|
||||
} else if (!(Boolean) ConfigValues.useItemWorldRemoveItemWhenItIsDisabled.value) removeItem(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removeItem(Player player) {
|
||||
T2Csend.debug(Main.getPlugin(), "World disabled: " + player.getName() + " " + player.getWorld().toString());
|
||||
for (int iam = 0; iam < player.getInventory().getSize() - 5; iam++) {
|
||||
ItemStack itm = player.getInventory().getItem(iam);
|
||||
if (itm != null) {
|
||||
if (itm.getType() == Material.valueOf(String.valueOf(ConfigValues.useItemMaterial.value)) || itm.getType() == T2CitemVersion.getHead()) {
|
||||
if (itm.getItemMeta().getDisplayName().equals(ConfigValues.useItemName.value)) {
|
||||
player.getInventory().remove(itm);
|
||||
player.updateInventory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +1,12 @@
|
||||
package de.jatitv.commandguiv2.Spigot.objects.functions;
|
||||
package net.t2code.commandguiv2.Spigot.objects;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.enums.EcoEnum;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
import net.t2code.commandguiv2.Spigot.enums.EcoEnum;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionItemEnum;
|
||||
import net.t2code.commandguiv2.Spigot.enums.FunctionVoteEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Function {
|
||||
public class FunctionObject {
|
||||
|
||||
public String key;
|
||||
public Boolean empty;
|
||||
@@ -71,67 +71,67 @@ public class Function {
|
||||
public FunctionItemEnum functionItemMode;
|
||||
public String functionItemItem;
|
||||
|
||||
public Function(String key,
|
||||
Boolean empty,
|
||||
Integer itemAmount,
|
||||
Boolean playerHead_Enable,
|
||||
Boolean base64Value_Enable,
|
||||
String base64Value,
|
||||
Boolean playerWhoHasOpenedTheGUI,
|
||||
String playerName,
|
||||
String item,
|
||||
String name,
|
||||
List<String> lore,
|
||||
Boolean noPermMessageEnable,
|
||||
String customNoPermMessage,
|
||||
Boolean noPermLoreEnable,
|
||||
List<String> noPermLore,
|
||||
Boolean customSound_Enable,
|
||||
Boolean customSound_NoSound,
|
||||
String customSound_Sound,
|
||||
Boolean cost_Enable,
|
||||
EcoEnum ecoModule,
|
||||
String ecoItem,
|
||||
Integer votePoints,
|
||||
Double price,
|
||||
Boolean command_Enable,
|
||||
Boolean command_BungeeCommand,
|
||||
Boolean commandAsConsole,
|
||||
List<String> command,
|
||||
Boolean serverChange,
|
||||
String serverChangeServer,
|
||||
Boolean openGUI_Enable,
|
||||
String openGUI,
|
||||
Boolean togglePermission,
|
||||
String togglePermissionPerm,
|
||||
Boolean toggleUseItem,
|
||||
Boolean message_Enable,
|
||||
List<String> message,
|
||||
Boolean setConfigEnable,
|
||||
String configFilePath,
|
||||
String configOptionPath,
|
||||
String configOptionPremat,
|
||||
public FunctionObject(String key,
|
||||
Boolean empty,
|
||||
Integer itemAmount,
|
||||
Boolean playerHead_Enable,
|
||||
Boolean base64Value_Enable,
|
||||
String base64Value,
|
||||
Boolean playerWhoHasOpenedTheGUI,
|
||||
String playerName,
|
||||
String item,
|
||||
String name,
|
||||
List<String> lore,
|
||||
Boolean noPermMessageEnable,
|
||||
String customNoPermMessage,
|
||||
Boolean noPermLoreEnable,
|
||||
List<String> noPermLore,
|
||||
Boolean customSound_Enable,
|
||||
Boolean customSound_NoSound,
|
||||
String customSound_Sound,
|
||||
Boolean cost_Enable,
|
||||
EcoEnum ecoModule,
|
||||
String ecoItem,
|
||||
Integer votePoints,
|
||||
Double price,
|
||||
Boolean command_Enable,
|
||||
Boolean command_BungeeCommand,
|
||||
Boolean commandAsConsole,
|
||||
List<String> command,
|
||||
Boolean serverChange,
|
||||
String serverChangeServer,
|
||||
Boolean openGUI_Enable,
|
||||
String openGUI,
|
||||
Boolean togglePermission,
|
||||
String togglePermissionPerm,
|
||||
Boolean toggleUseItem,
|
||||
Boolean message_Enable,
|
||||
List<String> message,
|
||||
Boolean setConfigEnable,
|
||||
String configFilePath,
|
||||
String configOptionPath,
|
||||
String configOptionPremat,
|
||||
|
||||
String configStringValueLeft,
|
||||
Boolean configBooleanValueLeft,
|
||||
Integer configIntegerValueLeft,
|
||||
Double configDoubleValueLeft,
|
||||
List<String> configListValueLeft,
|
||||
String configStringValueLeft,
|
||||
Boolean configBooleanValueLeft,
|
||||
Integer configIntegerValueLeft,
|
||||
Double configDoubleValueLeft,
|
||||
List<String> configListValueLeft,
|
||||
|
||||
String configStringValueRight,
|
||||
Boolean configBooleanValueRight,
|
||||
Integer configIntegerValueRight,
|
||||
Double configDoubleValueRight,
|
||||
List<String> configListValueRight,
|
||||
String configStringValueRight,
|
||||
Boolean configBooleanValueRight,
|
||||
Integer configIntegerValueRight,
|
||||
Double configDoubleValueRight,
|
||||
List<String> configListValueRight,
|
||||
|
||||
Boolean pluginReloadEnable,
|
||||
String pluginReloadCommand,
|
||||
Boolean functionVotePoints,
|
||||
FunctionVoteEnum functionVotePointsMode,
|
||||
Integer functionVotePointsAmount,
|
||||
Boolean functionItem,
|
||||
FunctionItemEnum functionItemMode,
|
||||
String functionItemItem) {
|
||||
Boolean pluginReloadEnable,
|
||||
String pluginReloadCommand,
|
||||
Boolean functionVotePoints,
|
||||
FunctionVoteEnum functionVotePointsMode,
|
||||
Integer functionVotePointsAmount,
|
||||
Boolean functionItem,
|
||||
FunctionItemEnum functionItemMode,
|
||||
String functionItemItem) {
|
||||
this.key = key;
|
||||
this.empty = empty;
|
||||
this.itemAmount = itemAmount;
|
@@ -1,24 +1,21 @@
|
||||
package de.jatitv.commandguiv2.Spigot.objects.guis;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.objects.slots.Slot;
|
||||
package net.t2code.commandguiv2.Spigot.objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Gui {
|
||||
public class GuiObject {
|
||||
public Boolean guiEnable;
|
||||
public Integer guiLines;
|
||||
public String guiName;
|
||||
public Boolean guiFillItemEnable;
|
||||
public String guiFillItemItem;
|
||||
|
||||
|
||||
public String key;
|
||||
public Boolean commandAliasEnable;
|
||||
public Boolean commandPermissionEnable;
|
||||
public ArrayList<Slot> slots;
|
||||
public ArrayList<SlotObject> slots;
|
||||
|
||||
public Gui(Boolean guiEnable, Integer guiLines, String guiName, Boolean guiFillitemEnable, String guiFillitemItem,
|
||||
String commandCommand, Boolean commandAliasEnable, Boolean commandPermissionEnable, ArrayList<Slot> slots){
|
||||
public GuiObject(Boolean guiEnable, Integer guiLines, String guiName, Boolean guiFillitemEnable, String guiFillitemItem,
|
||||
String commandCommand, Boolean commandAliasEnable, Boolean commandPermissionEnable, ArrayList<SlotObject> slots){
|
||||
this.guiEnable = guiEnable;
|
||||
this.guiLines = guiLines;
|
||||
this.guiName = guiName;
|
@@ -1,6 +1,6 @@
|
||||
package de.jatitv.commandguiv2.Spigot.objects.slots;
|
||||
package net.t2code.commandguiv2.Spigot.objects;
|
||||
|
||||
public class Slot {
|
||||
public class SlotObject {
|
||||
|
||||
public Integer slot;
|
||||
public Boolean enable;
|
||||
@@ -10,12 +10,12 @@ public class Slot {
|
||||
public String permissionToUse;
|
||||
|
||||
|
||||
public Slot(Integer slot,
|
||||
Boolean enable,
|
||||
String function,
|
||||
Boolean permission,
|
||||
String permissionToSee,
|
||||
String permissionToUse
|
||||
public SlotObject(Integer slot,
|
||||
Boolean enable,
|
||||
String function,
|
||||
Boolean permission,
|
||||
String permissionToSee,
|
||||
String permissionToUse
|
||||
) {
|
||||
this.slot = slot;
|
||||
this.enable = enable;
|
@@ -0,0 +1,145 @@
|
||||
package net.t2code.commandguiv2.Spigot.objects;
|
||||
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UseItemObject {
|
||||
public String key;
|
||||
public Boolean enable;
|
||||
public String openGui;
|
||||
public Boolean allowToggle;
|
||||
public Boolean allowSetBlock;
|
||||
public Boolean blockMoveAndDrop;
|
||||
|
||||
public Boolean permBecomeNeeded;
|
||||
public String permBecome;
|
||||
public PermissionDefault permBecomeDefault;
|
||||
|
||||
public Boolean permUseNeeded;
|
||||
public String permUse;
|
||||
public PermissionDefault permUseDefault;
|
||||
|
||||
public Boolean permToggleNeeded;
|
||||
public String permToggle;
|
||||
public PermissionDefault permToggleDefault;
|
||||
|
||||
public Boolean permSetSlotNeeded;
|
||||
public String permSetSlot;
|
||||
public PermissionDefault permSetSlotDefault;
|
||||
|
||||
public Boolean keepAtCommandClear;
|
||||
|
||||
public Integer invSlotSlot;
|
||||
public Boolean invSlotEnforce;
|
||||
public Boolean invFreeSlot;
|
||||
|
||||
public String itemMaterial;
|
||||
public String itemName;
|
||||
public List<String> itemLore;
|
||||
public Boolean itemPlayerHeadEnable;
|
||||
public Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI;
|
||||
public String itemPlayerHeadPlayerName;
|
||||
public Boolean itemPlayerHeadBase64Enable;
|
||||
public String itemPlayerHeadBase64Value;
|
||||
|
||||
public Boolean joinGiveOnEveryJoin;
|
||||
public Boolean joinGiveOnlyOnFirstJoin;
|
||||
|
||||
public Boolean quitRemoveOnQuit;
|
||||
|
||||
public Boolean protectGameModeEnable;
|
||||
public Boolean protectGameModeRemoveItemWhenItIsDisabled;
|
||||
public String protectGameModeMode;
|
||||
public List<String> protectGameModeList;
|
||||
|
||||
public Boolean protectWorldEnable;
|
||||
public Boolean protectWorldRemoveItemWhenItIsDisabled;
|
||||
public String protectWorldMode;
|
||||
public List<String> protectWorldList;
|
||||
|
||||
public UseItemObject(String key,
|
||||
Boolean enable,
|
||||
String openGui,
|
||||
Boolean allowToggle,
|
||||
Boolean allowSetBlock,
|
||||
Boolean blockMoveAndDrop,
|
||||
Boolean permBecomeNeeded,
|
||||
String permBecome,
|
||||
PermissionDefault permBecomeDefault,
|
||||
Boolean permUseNeeded,
|
||||
String permUse,
|
||||
PermissionDefault permUseDefault,
|
||||
Boolean permToggleNeeded,
|
||||
String permToggle,
|
||||
PermissionDefault permToggleDefault,
|
||||
Boolean permSetSlotNeeded,
|
||||
String permSetSlot,
|
||||
PermissionDefault permSetSlotDefault,
|
||||
Boolean keepAtCommandClear,
|
||||
Integer invSlotSlot,
|
||||
Boolean invSlotEnforce,
|
||||
Boolean invFreeSlot,
|
||||
String itemMaterial,
|
||||
String itemName,
|
||||
List<String> itemLore,
|
||||
Boolean itemPlayerHeadEnable,
|
||||
Boolean itemPlayerHeadPlayerWhoHasOpenedTheGUI,
|
||||
String itemPlayerHeadPlayerName,
|
||||
Boolean itemPlayerHeadBase64Enable,
|
||||
String itemPlayerHeadBase64Value,
|
||||
Boolean joinGiveOnEveryJoin,
|
||||
Boolean joinGiveOnlyOnFirstJoin,
|
||||
Boolean quitRemoveOnQuit,
|
||||
Boolean protectGameModeEnable,
|
||||
Boolean protectGameModeRemoveItemWhenItIsDisabled,
|
||||
String protectGameModeMode,
|
||||
List<String> protectGameModeList,
|
||||
Boolean protectWorldEnable,
|
||||
Boolean protectWorldRemoveItemWhenItIsDisabled,
|
||||
String protectWorldMode,
|
||||
List<String> protectWorldList) {
|
||||
this.key = key;
|
||||
this.enable = enable;
|
||||
this.openGui = openGui;
|
||||
this.allowToggle = allowToggle;
|
||||
this.allowSetBlock = allowSetBlock;
|
||||
this.blockMoveAndDrop = blockMoveAndDrop;
|
||||
this.permBecomeNeeded = permBecomeNeeded;
|
||||
this.permBecome = permBecome;
|
||||
this.permBecomeDefault = permBecomeDefault;
|
||||
this.permUseNeeded = permUseNeeded;
|
||||
this.permUse = permUse;
|
||||
this.permUseDefault = permUseDefault;
|
||||
this.permToggleNeeded = permToggleNeeded;
|
||||
this.permToggle = permToggle;
|
||||
this.permToggleDefault = permToggleDefault;
|
||||
this.permSetSlotNeeded = permSetSlotNeeded;
|
||||
this.permSetSlot = permSetSlot;
|
||||
this.permSetSlotDefault = permSetSlotDefault;
|
||||
this.keepAtCommandClear = keepAtCommandClear;
|
||||
this.invSlotSlot = invSlotSlot;
|
||||
this.invSlotEnforce = invSlotEnforce;
|
||||
this.invFreeSlot = invFreeSlot;
|
||||
this.itemMaterial = itemMaterial;
|
||||
this.itemName = itemName;
|
||||
this.itemLore = itemLore;
|
||||
this.itemPlayerHeadEnable = itemPlayerHeadEnable;
|
||||
this.itemPlayerHeadPlayerWhoHasOpenedTheGUI = itemPlayerHeadPlayerWhoHasOpenedTheGUI;
|
||||
this.itemPlayerHeadPlayerName = itemPlayerHeadPlayerName;
|
||||
this.itemPlayerHeadBase64Enable = itemPlayerHeadBase64Enable;
|
||||
this.itemPlayerHeadBase64Value = itemPlayerHeadBase64Value;
|
||||
this.joinGiveOnEveryJoin = joinGiveOnEveryJoin;
|
||||
this.joinGiveOnlyOnFirstJoin = joinGiveOnlyOnFirstJoin;
|
||||
this.quitRemoveOnQuit = quitRemoveOnQuit;
|
||||
this.protectGameModeEnable = protectGameModeEnable;
|
||||
this.protectGameModeRemoveItemWhenItIsDisabled = protectGameModeRemoveItemWhenItIsDisabled;
|
||||
this.protectGameModeMode = protectGameModeMode;
|
||||
this.protectGameModeList = protectGameModeList;
|
||||
this.protectWorldEnable = protectWorldEnable;
|
||||
this.protectWorldRemoveItemWhenItIsDisabled = protectWorldRemoveItemWhenItIsDisabled;
|
||||
this.protectWorldMode = protectWorldMode;
|
||||
this.protectWorldList = protectWorldList;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package net.t2code.commandguiv2.Spigot.objects.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PlayerObject {
|
||||
public ArrayList<UseItemPlayerObject> useItems;
|
||||
|
||||
public PlayerObject(ArrayList<UseItemPlayerObject> useItems) {
|
||||
this.useItems = useItems;
|
||||
}
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package net.t2code.commandguiv2.Spigot.objects.player;
|
||||
|
||||
public class UseItemPlayerObject {
|
||||
public String key;
|
||||
public Boolean enable;
|
||||
public Integer slot;
|
||||
|
||||
public UseItemPlayerObject(String key, Boolean enable, Integer slot) {
|
||||
this.key = key;
|
||||
this.enable = enable;
|
||||
this.slot = slot;
|
||||
}
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package net.t2code.commandguiv2.Spigot.sound;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.SlotObject;
|
||||
import net.t2code.commandguiv2.Spigot.enums.SoundEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlaySound {
|
||||
private static String prefix = Util.getPrefix();
|
||||
|
||||
public static void play(Player player, SoundEnum soundEnum) {
|
||||
play(player, soundEnum, null, null, null);
|
||||
}
|
||||
|
||||
public static void play(Player player, SoundEnum soundEnum, FunctionObject function, SlotObject slot, GuiObject gui) {
|
||||
if (!(Boolean) ConfigValues.soundEnable.value) return;
|
||||
switch (soundEnum) {
|
||||
case OpenInventory:
|
||||
if (!(Boolean) ConfigValues.soundOpenInventoryEnable.value) return;
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundOpenInventoryInput.value).toUpperCase().replace(".", "_")), 3, 1);
|
||||
break;
|
||||
case Click:
|
||||
if (!(Boolean) ConfigValues.soundClickEnable.value) return;
|
||||
if (!function.customSound_Enable) {
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundClickInput.value).toUpperCase().replace(".", "_")), 3, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (function.customSound_NoSound) return;
|
||||
try {
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(function.customSound_Sound.toUpperCase().replace(".", "_")), 3, 1);
|
||||
} catch (Exception e1) {
|
||||
T2Csend.console("§4\n§4\n§4\n" + SelectMessages.SoundNotFound.replace("[prefix]", prefix)
|
||||
.replace("[sound]", "§6GUI: §e" + gui.key + " §6Function: §e" + function.key + "§r §6Slot: §e" + (slot.slot + 1) + " §6CustomSound: §9" + function.customSound_Sound));
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundClickInput.value).toUpperCase().replace(".", "_")), 3, 1);
|
||||
}
|
||||
break;
|
||||
case NoMoney:
|
||||
if (!(Boolean) ConfigValues.soundNoMoneyEnable.value) return;
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundNoMoneyInput.value).toUpperCase().replace(".", "_")), 3, 1);
|
||||
break;
|
||||
case NoInventorySpace:
|
||||
if (!(Boolean) ConfigValues.soundNoInventorySpaceEnable.value) return;
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundNoInventorySpaceInput.value).toUpperCase().replace(".", "_")), 3, 1);
|
||||
break;
|
||||
case Give:
|
||||
if (!(Boolean) ConfigValues.soundGiveEnable.value) return;
|
||||
player.playSound(player.getLocation(),org.bukkit.Sound.valueOf(String.valueOf( ConfigValues.soundGiveInput.value).toUpperCase().replace(".", "_")), 3, 1);
|
||||
break;
|
||||
case PlayerNotFound:
|
||||
if (!(Boolean) ConfigValues.soundPlayerNotFoundEnable.value) return;
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf(String.valueOf(ConfigValues.soundPlayerNotFoundInput.value).toUpperCase().replace(".", "_")), 3, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package net.t2code.commandguiv2.Spigot.system;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Debug {
|
||||
|
||||
private static final Plugin plugin = Main.getPlugin();
|
||||
|
||||
public static void debugmsg() {
|
||||
T2Csend.debug(plugin, "§5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
T2Csend.debug(plugin, "§3Bukkit Version: §e" + Bukkit.getBukkitVersion());
|
||||
T2Csend.debug(plugin, "§3NMS Version: §e" + Bukkit.getServer().getClass().getPackage().getName().replace("org.bukkit.craftbukkit.", ""));
|
||||
T2Csend.debug(plugin, "§3Version: §e" + Bukkit.getVersion());
|
||||
T2Csend.debug(plugin, "§3Java: §e" + System.getProperty("java.version"));
|
||||
T2Csend.debug(plugin, "§3Worlds: §e" + String.valueOf(Bukkit.getServer().getWorlds()));
|
||||
T2Csend.debug(plugin, String.valueOf(Arrays.asList(Main.getPlugin().getServer().getPluginManager().getPlugins())));
|
||||
T2Csend.debug(plugin, "§5----------------------------------");
|
||||
if (new File(Main.getPath(), "config.yml").exists()) {
|
||||
File f = new File(String.valueOf(Main.getPath()));
|
||||
File f2 = new File(String.valueOf(Main.getPath() + "/GUIs/"));
|
||||
File f3 = new File(String.valueOf(Main.getPath() + "/languages/"));
|
||||
File[] fileArray = f.listFiles();
|
||||
File[] fileArray2 = f2.listFiles();
|
||||
File[] fileArray3 = f3.listFiles();
|
||||
if (fileArray != null) {
|
||||
for (File config : fileArray) {
|
||||
T2Csend.debug(plugin, String.valueOf(config).replace("plugins/CommandGUI/", ""));
|
||||
}
|
||||
}
|
||||
if (fileArray2 != null) {
|
||||
for (File config2 : fileArray2) {
|
||||
T2Csend.debug(plugin, String.valueOf(config2).replace("plugins/CommandGUI/", ""));
|
||||
}
|
||||
} else T2Csend.debug(plugin, "No GUI files available");
|
||||
|
||||
if (fileArray3 != null) {
|
||||
for (File config3 : fileArray3) {
|
||||
T2Csend.debug(plugin, String.valueOf(config3).replace("plugins/CommandGUI/", ""));
|
||||
}
|
||||
} else T2Csend.debug(plugin, "No language files available");
|
||||
|
||||
}
|
||||
T2Csend.debug(plugin, "§5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
}
|
||||
}
|
@@ -1,32 +1,36 @@
|
||||
package de.jatitv.commandguiv2.Spigot.system;
|
||||
package net.t2code.commandguiv2.Spigot.system;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.config.configConverter.ConfigConverterUnderV5;
|
||||
import de.jatitv.commandguiv2.Spigot.gui.GUIListener;
|
||||
import de.jatitv.commandguiv2.Spigot.listener.Bungee_Sender_Reciver;
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.EventsFrom110;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
|
||||
import de.jatitv.commandguiv2.Spigot.config.functions.CreateFunctions;
|
||||
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.LanguagesCreate;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.database.MySQL;
|
||||
import de.jatitv.commandguiv2.Spigot.listener.PluginEvent;
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.objects.Obj_Select;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.ConfigCreate;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.database.SQLITE;
|
||||
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import de.jatitv.commandguiv2.Spigot.enums.StorageEnum;
|
||||
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
|
||||
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
|
||||
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigSelect;
|
||||
import net.t2code.commandguiv2.Spigot.config.configConverter.ConfigConverterV5;
|
||||
import net.t2code.commandguiv2.Spigot.config.functions.SelectFunctions;
|
||||
import net.t2code.commandguiv2.Spigot.config.gui.SelectGui;
|
||||
import net.t2code.commandguiv2.Spigot.config.useItems.UseItemSelect;
|
||||
import net.t2code.commandguiv2.Spigot.function.gui.GUIListener;
|
||||
import net.t2code.commandguiv2.Spigot.function.listener.Bungee_Sender_Reciver;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.EventsFrom110;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUI;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_GUIItem;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.CmdExecuter_Help;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.register.AliasRegister;
|
||||
import net.t2code.commandguiv2.Spigot.config.functions.CreateFunctions;
|
||||
import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.LanguagesCreate;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.database.MySQL;
|
||||
import net.t2code.commandguiv2.Spigot.function.listener.PluginEvent;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.database.SQLITE;
|
||||
import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import net.t2code.commandguiv2.Spigot.enums.StorageEnum;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
||||
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@@ -39,27 +43,23 @@ public class Load {
|
||||
|
||||
public static void onLoad(String prefix, List<String> autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
|
||||
|
||||
Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
||||
long long_ = T2Ctemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
||||
try {
|
||||
Debug.debugmsg();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
send.console(prefix + " §8-------------------------------");
|
||||
T2Csend.console(prefix + " §8-------------------------------");
|
||||
try {
|
||||
ConfigConverterUnderV5.renameMainFolder();
|
||||
ConfigConverterV5.renameMainFolder();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if (!new File(Main.getPath(), "config.yml").exists()) {
|
||||
try {
|
||||
plugin.saveResource("configDeclaration.yml", false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
CreateGUI.configCreate();
|
||||
} catch (Exception e) {
|
||||
@@ -70,15 +70,21 @@ public class Load {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
UseItemSelect.create();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
ConfigCreate.configCreate();
|
||||
ConfigSelect.selectConfig();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
SelectConfig.onSelect();
|
||||
plugin.saveResource("configDeclaration.yml", true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -92,21 +98,24 @@ public class Load {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
plugin.saveResource("UseItems/useItemDeclaration.yml", true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
SelectConfig.setConfigVersion();
|
||||
|
||||
if (SelectConfig.getBungee()) {
|
||||
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "cgui:bungee")) {
|
||||
send.debug(plugin, "registerOutgoingPluginChannel §ecgui:bungee");
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "cgui:bungee");
|
||||
if (T2CLibConfig.getBungee()) {
|
||||
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(plugin, "t2c:bcmd")) {
|
||||
T2Csend.debug(plugin, "registerOutgoingPluginChannel §et2c:bcmd");
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
|
||||
}
|
||||
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "cgui:onlinepl")) {
|
||||
send.debug(plugin, "registerIncomingPluginChannel §ecgui:onlinepl");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "cgui:onlinepl", new Bungee_Sender_Reciver());
|
||||
if (!Bukkit.getMessenger().isIncomingChannelRegistered(plugin, "t2c:cguiopl")) {
|
||||
T2Csend.debug(plugin, "registerIncomingPluginChannel §et2c:cguiopl");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "t2c:cguiopl", new Bungee_Sender_Reciver());
|
||||
}
|
||||
}
|
||||
|
||||
if (PluginCheck.papi()) {
|
||||
if (T2CpluginCheck.papi()) {
|
||||
new Papi().register();
|
||||
}
|
||||
|
||||
@@ -116,7 +125,17 @@ public class Load {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
Obj_Select.onSelect();
|
||||
SelectFunctions.onSelectFunction();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
SelectGui.onSelectGui();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
UseItemSelect.onSelect();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -127,24 +146,24 @@ public class Load {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
SelectConfig.sound(prefix);
|
||||
ConfigValues.sound();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
CmdExecuter_GUI.arg1.put(SelectConfig.getAdminSubCommand(), Permissions.admin+";"+Permissions.giveItemOther+";"+Permissions.info);
|
||||
CmdExecuter_GUI.arg1.put(String.valueOf(ConfigValues.adminSubCommand.value), Permissions.admin + ";" + Permissions.giveItemOther + ";" + Permissions.info);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
send.console(prefix + " §8-------------------------------");
|
||||
T2Csend.console(prefix + " §8-------------------------------");
|
||||
loadStorage(prefix);
|
||||
send.console(prefix + " §8-------------------------------");
|
||||
T2Csend.console(prefix + " §8-------------------------------");
|
||||
|
||||
if (Main.PaPi) {
|
||||
send.console(prefix + " §2PlaceholderAPI successfully connected!");
|
||||
T2Csend.console(prefix + " §2PlaceholderAPI successfully connected!");
|
||||
} else {
|
||||
send.console(prefix + " §4PlaceholderAPI could not be connected / found!");
|
||||
T2Csend.console(prefix + " §4PlaceholderAPI could not be connected / found!");
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -153,14 +172,14 @@ public class Load {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (SelectConfig.getHelpAlias()) {
|
||||
if ((Boolean) ConfigValues.helpAlias.value) {
|
||||
Main.getPlugin().getCommand("commandguihelp").setExecutor(new CmdExecuter_Help());
|
||||
send.debug(plugin, "CommandRegister: commandguihelp");
|
||||
T2Csend.debug(plugin, "CommandRegister: commandguihelp");
|
||||
}
|
||||
Main.getPlugin().getCommand("commandgui").setExecutor(new CmdExecuter_GUI());
|
||||
send.debug(plugin, "CommandRegister: commandgui");
|
||||
T2Csend.debug(plugin, "CommandRegister: commandgui");
|
||||
Main.getPlugin().getCommand("commandgui-item").setExecutor(new CmdExecuter_GUIItem());
|
||||
send.debug(plugin, "CommandRegister: commandgui-item");
|
||||
T2Csend.debug(plugin, "CommandRegister: commandgui-item");
|
||||
|
||||
try {
|
||||
AliasRegister.onRegister();
|
||||
@@ -173,28 +192,29 @@ public class Load {
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new Events(), Main.getPlugin());
|
||||
|
||||
if (!MCVersion.minecraft1_8 && !MCVersion.minecraft1_9) {
|
||||
if (!T2CmcVersion.isMc1_8() && !T2CmcVersion.isMc1_9()) {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(new EventsFrom110(), plugin);
|
||||
}
|
||||
|
||||
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
|
||||
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), spigotID, discord
|
||||
, (Boolean) ConfigValues.updateCheckOnJoin.value, (Boolean) ConfigValues.updateCheckSeePreReleaseUpdates.value, (Integer) ConfigValues.updateCheckTimeInterval.value);
|
||||
Metrics.Bstats();
|
||||
Main.addonLoad();
|
||||
T2CodeTemplate.onLoadFooter(prefix, long_);
|
||||
T2Ctemplate.onLoadFooter(prefix, long_);
|
||||
}
|
||||
|
||||
private static void loadStorage(String prefix) {
|
||||
try {
|
||||
SelectDatabase.setStorage(StorageEnum.valueOf(SelectConfig.getStorage()));
|
||||
SelectDatabase.setStorage(StorageEnum.valueOf(String.valueOf(ConfigValues.storage.value)));
|
||||
} catch (Exception ignored) {
|
||||
send.error(Main.getPlugin(), "The storage medium " + SelectConfig.getStorage() + " is not supported!");
|
||||
send.error(Main.getPlugin(), "Storage medium " + StorageEnum.SQLITE + " is used.");
|
||||
T2Csend.error(plugin, "The storage medium '" + ConfigValues.storage.value + "' is not supported!");
|
||||
T2Csend.error(plugin, "Storage medium " + StorageEnum.SQLITE + " is used.");
|
||||
SelectDatabase.setStorage(StorageEnum.SQLITE);
|
||||
}
|
||||
|
||||
switch (SelectDatabase.getStorage()) {
|
||||
case MYSQL:
|
||||
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||
T2Csend.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||
MySQL.main();
|
||||
try {
|
||||
MySQL.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
|
||||
@@ -217,11 +237,11 @@ public class Load {
|
||||
}
|
||||
break;
|
||||
case YML:
|
||||
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||
T2Csend.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||
break;
|
||||
default:
|
||||
case SQLITE:
|
||||
send.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||
T2Csend.console(prefix + " §2Storage medium §6" + SelectDatabase.getStorage() + " §2is used.");
|
||||
try {
|
||||
SQLITE.main();
|
||||
SQLITE.query("CREATE TABLE IF NOT EXISTS `gui-item` (" +
|
@@ -1,11 +1,11 @@
|
||||
// This claas was created by JaTiTV
|
||||
|
||||
|
||||
package de.jatitv.commandguiv2.Spigot.system;
|
||||
package net.t2code.commandguiv2.Spigot.system;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
@@ -1,8 +1,8 @@
|
||||
// This claas was created by JaTiTV
|
||||
|
||||
package de.jatitv.commandguiv2.Spigot.system;
|
||||
package net.t2code.commandguiv2.Spigot.system;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@@ -0,0 +1,81 @@
|
||||
package net.t2code.commandguiv2.Spigot.system;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.SlotObject;
|
||||
import net.t2code.commandguiv2.cache.Cache;
|
||||
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Permissions {
|
||||
private static final Plugin plugin = Main.getPlugin();
|
||||
|
||||
public static final String key = "commandgui.";
|
||||
public static final String command = key + "command";
|
||||
public static final String info = key + "command.info";
|
||||
public static final String bypass = key + "bypass";
|
||||
public static final String useitemToggle = key + "useitem.toggle";
|
||||
public static final String useitem = key + "useitem";
|
||||
public static final String getGuiItemAtLogin = key + "get.guiitem.at.login";
|
||||
public static final String giveItemOther = key + "giveitem.other";
|
||||
public static final String updatemsg = key + "updatemsg";
|
||||
|
||||
public static final String player = key + "player";
|
||||
public static final String admin = key + "admin";
|
||||
|
||||
public static final PermissionDefault op = PermissionDefault.OP;
|
||||
public static final PermissionDefault notOp = PermissionDefault.NOT_OP;
|
||||
|
||||
public static void onPermRegister() {
|
||||
T2Cregister.permission(command, op, plugin);
|
||||
T2Cregister.permissionDescription(command, "Required permission to open GUIs via command", plugin);
|
||||
|
||||
T2Cregister.permission(getGuiItemAtLogin, op, plugin);
|
||||
T2Cregister.permission(giveItemOther, op, plugin);
|
||||
T2Cregister.permissionDescription(getGuiItemAtLogin, "Only players with this permission will receive the GUI item", plugin);
|
||||
|
||||
T2Cregister.permission(useitem, op, plugin);
|
||||
T2Cregister.permissionDescription(useitem, "Required permission to use the GUI Item", plugin);
|
||||
|
||||
T2Cregister.permission(useitemToggle, op, plugin);
|
||||
T2Cregister.permissionDescription(useitemToggle, "Required permission to enable/disable the GUI Item for itself (if the function UseItem/AllowToggle is set to true)", plugin);
|
||||
|
||||
T2Cregister.permission(updatemsg, op, plugin);
|
||||
T2Cregister.permissionDescription(updatemsg, "Players with this permission get the update message when joining if an update is available", plugin);
|
||||
|
||||
T2Cregister.permission(bypass, op, plugin);
|
||||
T2Cregister.permissionDescription(bypass, "Bypass to open disabled GUIs", plugin);
|
||||
|
||||
T2Cregister.permission(info, notOp, plugin);
|
||||
T2Cregister.permissionDescription(info, "Permission to view T2C-CommandGUI info", plugin);
|
||||
|
||||
T2Cregister.permission(player, op, command, true, plugin);
|
||||
T2Cregister.permission(player, op, getGuiItemAtLogin, true, plugin);
|
||||
T2Cregister.permission(player, op, useitem, true, plugin);
|
||||
T2Cregister.permission(player, op, useitemToggle, true, plugin);
|
||||
T2Cregister.permissionDescription(player, "All permissions from T2C-CommandGUI for Player", plugin);
|
||||
|
||||
T2Cregister.permission(admin, op, command, true, plugin);
|
||||
T2Cregister.permission(admin, op, getGuiItemAtLogin, true, plugin);
|
||||
T2Cregister.permission(admin, op, giveItemOther, true, plugin);
|
||||
T2Cregister.permission(admin, op, useitem, true, plugin);
|
||||
T2Cregister.permission(admin, op, useitemToggle, true, plugin);
|
||||
T2Cregister.permission(admin, op, updatemsg, true, plugin);
|
||||
T2Cregister.permission(admin, op, bypass, true, plugin);
|
||||
T2Cregister.permission(admin, op, info, true, plugin);
|
||||
T2Cregister.permissionDescription(admin, "All permissions from T2C-CommandGUI", plugin);
|
||||
|
||||
|
||||
for (GuiObject gui : Cache.guiHashMap.values()) {
|
||||
T2Cregister.permission(command + "." + gui.key, op, plugin);
|
||||
T2Cregister.permission(admin, op, command + "." + gui.key, true, plugin);
|
||||
for (SlotObject slot : gui.slots) {
|
||||
T2Cregister.permission(slot.permissionToUse, op, plugin);
|
||||
T2Cregister.permission(admin, op, slot.permissionToUse, true, plugin);
|
||||
T2Cregister.permission(slot.permissionToSee, op, plugin);
|
||||
T2Cregister.permission(admin, op, slot.permissionToSee, true, plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
package de.jatitv.commandguiv2.Spigot.system;
|
||||
package net.t2code.commandguiv2.Spigot.system;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -10,8 +10,8 @@ import java.util.List;
|
||||
public class Placeholder {
|
||||
public static String useitem(Player p) {
|
||||
if (Events.useItemHashMap.get(p.getName())) {
|
||||
return SelectConfig.getPlaceholderTrue();
|
||||
} else return SelectConfig.getPlaceholderFalse();
|
||||
return ConfigValues.placeholderTrue.name();
|
||||
} else return ConfigValues.placeholderFalse.name();
|
||||
}
|
||||
|
||||
public static String useitem_boolean(Player p) {
|
@@ -0,0 +1,37 @@
|
||||
package net.t2code.commandguiv2;
|
||||
|
||||
public class Util {
|
||||
|
||||
public static String getInfoText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String getRequiredT2CodeLibVersion() {
|
||||
return "14.2";
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return "§8[§4C§9GUI§8]";
|
||||
}
|
||||
|
||||
public static Integer getSpigotID() {
|
||||
return 90671;
|
||||
}
|
||||
|
||||
public static String getGit() {
|
||||
return "JaTiTV/T2C-CommandGUI";
|
||||
}
|
||||
|
||||
public static Integer getBstatsID() {
|
||||
return 10840;
|
||||
}
|
||||
|
||||
public static String getSpigot() {
|
||||
return "https://www.spigotmc.org/resources/" + getSpigotID();
|
||||
}
|
||||
|
||||
public static String getDiscord() {
|
||||
return net.t2code.t2codelib.Util.getDiscord();
|
||||
}
|
||||
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
package de.jatitv.commandguiv2.api;
|
||||
package net.t2code.commandguiv2.api;
|
||||
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.ItemChange;
|
||||
import de.jatitv.commandguiv2.Spigot.useItem.Events;
|
||||
import de.jatitv.commandguiv2.Spigot.Main;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.Commands;
|
||||
import de.jatitv.commandguiv2.Spigot.cmdManagement.Help;
|
||||
import de.jatitv.commandguiv2.Spigot.config.gui.CreateGUI;
|
||||
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
|
||||
import de.jatitv.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import de.jatitv.commandguiv2.Spigot.system.Permissions;
|
||||
import de.jatitv.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import de.jatitv.commandguiv2.Util;
|
||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
||||
import net.t2code.commandguiv2.Spigot.config.config.ConfigValues;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.ItemChange;
|
||||
import net.t2code.commandguiv2.Spigot.function.useItem.Events;
|
||||
import net.t2code.commandguiv2.Spigot.Main;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.Commands;
|
||||
import net.t2code.commandguiv2.Spigot.cmdManagement.Help;
|
||||
import net.t2code.commandguiv2.Spigot.config.gui.CreateGUI;
|
||||
import net.t2code.commandguiv2.Spigot.config.languages.SelectMessages;
|
||||
import net.t2code.commandguiv2.Spigot.system.Permissions;
|
||||
import net.t2code.commandguiv2.Spigot.database.SelectDatabase;
|
||||
import net.t2code.commandguiv2.Util;
|
||||
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -20,27 +20,26 @@ public class CGuiAPI {
|
||||
public static Boolean JoinDisable = false;
|
||||
|
||||
public static void onItemChange(Player player) {
|
||||
ItemChange.itemChange(player, false);
|
||||
onItemChange(player,false);
|
||||
}
|
||||
public static void onItemChange(Player player, Boolean setCursor) {
|
||||
ItemChange.itemChange(player, setCursor);
|
||||
}
|
||||
|
||||
public static boolean hasUseItemInMainHand(Player player) {
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
return item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
||||
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name());
|
||||
&& item.getItemMeta().getDisplayName().equals(String.valueOf(ConfigValues.useItemName.value));
|
||||
}
|
||||
|
||||
public static boolean hasUseItemInOffHand(Player player) {
|
||||
ItemStack item = player.getInventory().getItemInOffHand();
|
||||
return item.hasItemMeta() && item.getItemMeta().hasDisplayName()
|
||||
&& item.getItemMeta().getDisplayName().equals(SelectConfig.getUseItem_Name());
|
||||
}
|
||||
|
||||
public static void onItemChange(Player player, Boolean setCursor) {
|
||||
ItemChange.itemChange(player, setCursor);
|
||||
&& item.getItemMeta().getDisplayName().equals(String.valueOf(ConfigValues.useItemName.value));
|
||||
}
|
||||
|
||||
public static void disableItemGiveOnJoin(Boolean disableItemGiveOnJoin) {
|
||||
send.debug(Main.getPlugin(), "CGuiAPI: " + disableItemGiveOnJoin);
|
||||
T2Csend.debug(Main.getPlugin(), "CGuiAPI: " + disableItemGiveOnJoin);
|
||||
JoinDisable = disableItemGiveOnJoin;
|
||||
}
|
||||
|
||||
@@ -54,8 +53,8 @@ public class CGuiAPI {
|
||||
|
||||
public static void setPlayerItemEnable(Player player, Boolean value) {
|
||||
if (value) {
|
||||
SelectDatabase.setItemStatusTrue(player);
|
||||
} else SelectDatabase.setItemStatusFalse(player);
|
||||
SelectDatabase.setItemStatus(player, true);
|
||||
} else SelectDatabase.setItemStatus(player, true);
|
||||
}
|
||||
|
||||
public static void setPlayerItemSlot(Player player, Integer value) {
|
17
CommandGUI V2/src/main/java/net/t2code/commandguiv2/cache/Cache.java
vendored
Normal file
17
CommandGUI V2/src/main/java/net/t2code/commandguiv2/cache/Cache.java
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
package net.t2code.commandguiv2.cache;
|
||||
|
||||
import net.t2code.commandguiv2.Spigot.objects.FunctionObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.GuiObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.UseItemObject;
|
||||
import net.t2code.commandguiv2.Spigot.objects.player.PlayerObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Cache {
|
||||
public static HashMap<String, GuiObject> guiHashMap = new HashMap<>();
|
||||
public static HashMap<String, UseItemObject> useItemHash = new HashMap<>();
|
||||
public static ArrayList<String> allAliases = new ArrayList<>();
|
||||
public static HashMap<String, FunctionObject> functionHashMap = new HashMap<>();
|
||||
}
|
114
CommandGUI V2/src/main/resources/UseItems/useItemDeclaration.yml
Normal file
114
CommandGUI V2/src/main/resources/UseItems/useItemDeclaration.yml
Normal file
@@ -0,0 +1,114 @@
|
||||
useItem:
|
||||
# enable: Set here if the UseItem is to be used in use
|
||||
enable: false
|
||||
|
||||
# openGUI: Set here which GUI should open the UseItem
|
||||
openGUI: default
|
||||
|
||||
# allowToggle: Set here if players are allowed to enable or disable the UseItem with '/gui-item <useitemname> <on/off>'.
|
||||
allowToggle: true
|
||||
|
||||
# allowSetSlot: Set here if players are allowed to change the slot in the inventory where the UseItem is located with '/gui-item <useitemname> slot <slot>'.
|
||||
allowSetSlot: true
|
||||
|
||||
# blockMoveAndDrop: Set here if the dropping of the UseItem should be blocked
|
||||
blockMoveAndDrop: true
|
||||
|
||||
permission:
|
||||
become:
|
||||
# Here you define if and which permission is needed to get the UseItem (for Join etc.).
|
||||
needed: true
|
||||
permission: 'commandgui.useitem.[useitemname].use'
|
||||
# Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP]
|
||||
default: TRUE
|
||||
use:
|
||||
# Here you define if and which permission is needed to use the UseItem
|
||||
needed: true
|
||||
permission: 'commandgui.useitem.[useitemname].use'
|
||||
# Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP]
|
||||
default: TRUE
|
||||
toggle:
|
||||
# Here you define if and which permission is needed to use the command '/gui-item <useitemname> <on/off>' for this UseItem
|
||||
needed: true
|
||||
permission: 'commandgui.useitem.[useitemname].toggle'
|
||||
# Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP]
|
||||
default: OP
|
||||
setSlot:
|
||||
# Here you define if and which permission is needed to use the command '/gui-item <useitemname> slot <slot>' for this UseItem
|
||||
needed: true
|
||||
permission: 'commandgui.useitem.[useitemname].setslot'
|
||||
# Specify here how the permission should be set by default. [TRUE, FALSE, OP, NOT_OP]
|
||||
default: OP
|
||||
|
||||
# keepAtCommandClear: Set here if the UseItem should stay in the inventory with the '/clear' command
|
||||
keepAtCommandClear: true
|
||||
|
||||
inventorySlot:
|
||||
# slot: slot: Set here on which slot the UseItem should be located by default
|
||||
slot: 1
|
||||
# slotEnforce: Set here if the slot should be forced even if another item is on this slot (also the set slot of the player).
|
||||
# NOTE: The item that was on this slot before will be deleted.
|
||||
slotEnforce: false
|
||||
# freeSlot: Set here if the UseItem should be placed on another free slot, if the selected slot (also the set slot of the player) is occupied.
|
||||
freeSlot: false
|
||||
|
||||
# Set here the item that should be used as UseItem
|
||||
item:
|
||||
# material: Set here which material should be used as UseItem
|
||||
material: paper
|
||||
# name: Set the DisplayName of the UseItem here
|
||||
name: '&6GUI UseItem'
|
||||
# lore: Set the lore of the UseItem here
|
||||
lore:
|
||||
- 'Lore line 1'
|
||||
- 'Lore line 2'
|
||||
playerHead:
|
||||
# enable: This specifies whether a PlayerHead is to be used as a UseItem. If this is set to true, the 'material' option is ignored.
|
||||
enable: false
|
||||
# playerWhoHasOpenedTheGUI: Here you can set whether the player head should be used as a UseItem by the player
|
||||
playerWhoHasOpenedTheGUI: false
|
||||
# playerName: Here you can set a player name whose head should be used as UseItem
|
||||
playerName: ''
|
||||
base64:
|
||||
# enable: Set here if a Base64 PlayerHead should be used as UseItem
|
||||
enable: false
|
||||
# base64Value: Here you can set the Base64 Value.
|
||||
# You can find the Base64 Value for example on https://minecraft-heads.com.
|
||||
base64Value: ''
|
||||
|
||||
join:
|
||||
# giveOnEveryJoin: Set here if the UseItem should be given at every server join
|
||||
giveOnEveryJoin: true
|
||||
# giveOnlyOnFirstJoin: Set here if the UseItem should only be given to the server at the first join of the player.
|
||||
giveOnlyOnFirstJoin: false
|
||||
|
||||
quit:
|
||||
# removeOnQuit: Set here if the UseItem should be removed from the inventory when leaving the server
|
||||
removeOnQuit: false
|
||||
|
||||
protection:
|
||||
gameMode:
|
||||
# enable: Set here in which gamemode the UseItem may be used
|
||||
enable: false
|
||||
# removeItemWhenItIsDisabled: Set here if the UseItem should be removed if you are in a not allowed Gamemode
|
||||
removeItemWhenItIsDisabled: false
|
||||
# mode: Set here if a 'blacklist' or 'whitelist' should be used
|
||||
mode: blacklist
|
||||
# list: Set the GameMode list here
|
||||
list:
|
||||
- CREATIVE
|
||||
- SPECTATOR
|
||||
|
||||
world:
|
||||
# enable: Set here in which world the UseItem may be used
|
||||
enable: false
|
||||
# removeItemWhenItIsDisabled: Here you specify whether the UseItem should be removed if you are in a world that is not permitted
|
||||
removeItemWhenItIsDisabled: false
|
||||
# mode: Set here if a 'blacklist' or 'whitelist' should be used
|
||||
mode: blacklist
|
||||
# list: Set the worlds here
|
||||
list:
|
||||
- World1
|
||||
- World2
|
||||
|
||||
#/useitem <itemname> on/off/slot [slotnumber]
|
@@ -1,4 +0,0 @@
|
||||
name: T2C-CommandGUI
|
||||
version: ${project.version}
|
||||
main: de.jatitv.commandguiv2.Bungee.BMain
|
||||
author: JaTiTV
|
@@ -2,210 +2,127 @@
|
||||
#########################################
|
||||
## Please do not change ConfigVersion! ##
|
||||
#########################################
|
||||
ConfigVersion: 5
|
||||
configVersion: 6
|
||||
|
||||
Plugin:
|
||||
plugin:
|
||||
# Here you can set the debug mode of the plugin.
|
||||
# It is recommended not to activate this on productive systems. Only if it is really needed!
|
||||
Debug: false
|
||||
debug: false
|
||||
# Here you can set whether the Helpalias command (/commandguihelp) should be activated.
|
||||
# If this is changed the server MUST be restarted to change this!
|
||||
HelpAlias: true
|
||||
helpAlias: true
|
||||
# Here you set which subcommand should be for the admin functions.
|
||||
# (/commandgui 'admin' reload)
|
||||
AdminSubCommand: admin
|
||||
adminSubCommand: admin
|
||||
# here you set the language to be used
|
||||
language: english
|
||||
# Here you set the character or word that will be used as currency
|
||||
Currency: $
|
||||
currency: $
|
||||
# Here you set which GUI should be opened at '/commandgui' / '/gui'.
|
||||
DefaultGUI: default
|
||||
defaultGUI: default
|
||||
|
||||
Storage:
|
||||
storage:
|
||||
# Set here if MySQL, SQLITE or YML should be used as storage.
|
||||
Type: SQLITE
|
||||
type: SQLITE
|
||||
# Enter here the access data to the database you want to use, if you use MySQL
|
||||
MySQL:
|
||||
IP: localhost
|
||||
Port: 3306
|
||||
Database: database
|
||||
User: root
|
||||
Password: password
|
||||
SSL: false
|
||||
mySQL:
|
||||
ip: localhost
|
||||
port: 3306
|
||||
database: database
|
||||
user: root
|
||||
password: password
|
||||
ssl: false
|
||||
|
||||
BungeeCord:
|
||||
# Set here if the plugin runs in a BungeeCord subserver.
|
||||
# The plugin file must then be installed on the proxy (BungeeCord, Waterfall) and on the servers.
|
||||
Enable: false
|
||||
# Set here the server name of the server
|
||||
ThisServer: server
|
||||
|
||||
UseItem:
|
||||
# Set here if the UseItem is to be used in use
|
||||
Enable: true
|
||||
# Set here if players are allowed to enable or disable the UseItem with '/gui-item <on/off>'.
|
||||
# Permission 'commandgui.useitem.toggle' is additionally required
|
||||
AllowToggle: true
|
||||
# Set here if players are allowed to change the slot in the inventory where the UseItem is located with '/gui-item <slot>'.
|
||||
# Permission 'commandgui.useitem.toggle' is additionally required
|
||||
AllowSetSlot: true
|
||||
# Set here if the dropping of the UseItem should be blocked
|
||||
BlockMoveAndDrop: true
|
||||
# Set here which GUI should open the UseItem
|
||||
OpenGUI: default
|
||||
Permission:
|
||||
# Set here if the permission 'commandgui.useitem' is required to use the UseItem
|
||||
NeededToUse: true
|
||||
# Set here if the UseItem should stay in the inventory with the '/clear' command
|
||||
KeepAtCommandClear: true
|
||||
InventorySlot:
|
||||
# Set here on which slot the UseItem should be located by default
|
||||
Slot: 1
|
||||
# Set here if the slot should be forced even if another item is on this slot (also the set slot of the player).
|
||||
# NOTE: The item that was on this slot before will be deleted.
|
||||
SlotEnforce: false
|
||||
# Set here if the UseItem should be placed on another free slot, if the selected slot (also the set slot of the player) is occupied.
|
||||
FreeSlot: false
|
||||
# Set here the item that should be used as UseItem
|
||||
Item:
|
||||
# Set here which material should be used as UseItem
|
||||
Material: paper
|
||||
PlayerHead:
|
||||
# Set here if a PlayerHead should be used as UseItem
|
||||
Enable: false
|
||||
Base64:
|
||||
# Set here if a Base64 PlayerHead should be used as UseItem
|
||||
Enable: false
|
||||
# Here you can set the Base64 Value.
|
||||
# You can find the Base64 Value for example on https://minecraft-heads.com.
|
||||
Base64Value: ''
|
||||
# Here you can set whether the player head should be used as a UseItem by the player
|
||||
PlayerWhoHasOpenedTheGUI: false
|
||||
# Here you can set a player name whose head should be used as UseItem
|
||||
Playername: ''
|
||||
# Set the DisplayName of the UseItem here
|
||||
Name: '&6GUI UseItem'
|
||||
# Set the lore of the UseItem here
|
||||
Lore:
|
||||
- 'Lore line 1'
|
||||
- 'Lore line 2'
|
||||
Join:
|
||||
# Set here if the UseItem should be given at every server join
|
||||
GiveOnEveryJoin: true
|
||||
# Set here if the UseItem should only be given to the server at the first join of the player.
|
||||
GiveOnlyOnFirstJoin: false
|
||||
Cursor:
|
||||
ToGUIItem:
|
||||
OnLogin:
|
||||
# Here you define whether the UseItem should be selected when joining the server.
|
||||
Enable: true
|
||||
Spigot:
|
||||
# Set here if the UseItem should only be selected at the first join
|
||||
OnOnlyFirstLogin: true
|
||||
Bungee:
|
||||
# Set here if the UseItem should be selected even if you change the server of the bungee network.
|
||||
# The option BungeeCord must be activated for this!
|
||||
OnServerChange: false
|
||||
|
||||
Toggle:
|
||||
toggle:
|
||||
# Set the items to be used with the Toggle function here
|
||||
Items:
|
||||
items:
|
||||
# Set here the item that should be used if you have the permission or the UseItem is active.
|
||||
OnOrYes:
|
||||
Item:
|
||||
Base64:
|
||||
onOrYes:
|
||||
item:
|
||||
base64:
|
||||
# Set here if a Base64 head should be used
|
||||
Enable: false
|
||||
enable: false
|
||||
# Here you can set the Base64 Value.
|
||||
# You can find the Base64 Value for example on https://minecraft-heads.com.
|
||||
Base64Value: ''
|
||||
base64Value: ''
|
||||
# Set the material to be used here
|
||||
Material: GREEN_WOOL
|
||||
material: GREEN_WOOL
|
||||
# Set here the item to be used if you have the permission or the UseItem is disabled
|
||||
OffOrNo:
|
||||
Item:
|
||||
Base64:
|
||||
offOrNo:
|
||||
item:
|
||||
base64:
|
||||
# Set here if a Base64 head should be used
|
||||
Enable: false
|
||||
enable: false
|
||||
# Here you can set the Base64 Value.
|
||||
# You can find the Base64 Value for example on https://minecraft-heads.com.
|
||||
Base64Value: ''
|
||||
base64Value: ''
|
||||
# Set the material to be used here
|
||||
Material: RED_WOOL
|
||||
Permission:
|
||||
material: RED_WOOL
|
||||
permission:
|
||||
# Set here the commands to be used for Toggle.Permission
|
||||
Commands:
|
||||
'True': luckperms user [player] permission set [perm] true
|
||||
'False': luckperms user [player] permission set [perm] false
|
||||
commands:
|
||||
'true': luckperms user [player] permission set [perm] true
|
||||
'false': luckperms user [player] permission set [perm] false
|
||||
|
||||
# Set the design of the placeholders here
|
||||
Placeholder:
|
||||
placeholder:
|
||||
# Placeholder for true / enabled
|
||||
'True': '&2true'
|
||||
'true': '&2true'
|
||||
# Placeholder for false / disabled
|
||||
'False': '&4false'
|
||||
'false': '&4false'
|
||||
|
||||
Sound:
|
||||
sound:
|
||||
# Here you can disable all sounds
|
||||
Enable: true
|
||||
enable: true
|
||||
# Set here At which action which sound should be played or none at all
|
||||
OpenInventory:
|
||||
Enable: true
|
||||
Sound: BLOCK_CHEST_OPEN
|
||||
Click:
|
||||
Enable: true
|
||||
Sound: BLOCK_NOTE_BLOCK_HAT
|
||||
NoMoney:
|
||||
Enable: true
|
||||
Sound: BLOCK_NOTE_BLOCK_HARP
|
||||
NoInventorySpace:
|
||||
Enable: true
|
||||
Sound: BLOCK_NOTE_BLOCK_HARP
|
||||
Give:
|
||||
Enable: true
|
||||
Sound: ENTITY_PLAYER_LEVELUP
|
||||
PlayerNotFound:
|
||||
Enable: true
|
||||
Sound: BLOCK_NOTE_BLOCK_HARP
|
||||
openInventory:
|
||||
enable: true
|
||||
sound: BLOCK_CHEST_OPEN
|
||||
click:
|
||||
enable: true
|
||||
sound: BLOCK_NOTE_BLOCK_HAT
|
||||
noMoney:
|
||||
enable: true
|
||||
sound: BLOCK_NOTE_BLOCK_HARP
|
||||
noInventorySpace:
|
||||
enable: true
|
||||
sound: BLOCK_NOTE_BLOCK_HARP
|
||||
give:
|
||||
enable: true
|
||||
sound: ENTITY_PLAYER_LEVELUP
|
||||
playerNotFound:
|
||||
enable: true
|
||||
sound: BLOCK_NOTE_BLOCK_HARP
|
||||
|
||||
Advanced:
|
||||
UseItem:
|
||||
GameMode:
|
||||
Change:
|
||||
# Set here if the UseItem should be reset when the GameMode is changed.
|
||||
Enable: true
|
||||
# Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second).
|
||||
DelayInTicks: 1
|
||||
Protection:
|
||||
# Set here in which gamemode the UseItem may be used
|
||||
Enable: false
|
||||
# Set here if the UseItem should be removed if you are in a not allowed Gamemode
|
||||
RemoveItemWhenItIsDisabled: false
|
||||
# Set here if a 'blacklist' or 'whitelist' should be used
|
||||
Mode: blacklist
|
||||
# Set the GameMode list here
|
||||
List:
|
||||
- CREATIVE
|
||||
- Spectator
|
||||
World:
|
||||
Change:
|
||||
# This specifies whether the UseItem should be reset when the world is changed.
|
||||
Enable: true
|
||||
# Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second).
|
||||
DelayInTicks: 1
|
||||
Protection:
|
||||
# Set here in which world the UseItem may be used
|
||||
Enable: false
|
||||
# Here you specify whether the UseItem should be removed if you are in a world that is not permitted
|
||||
RemoveItemWhenItIsDisabled: false
|
||||
# Set here if a 'blacklist' or 'whitelist' should be used
|
||||
Mode: blacklist
|
||||
# Set the worlds here
|
||||
List:
|
||||
- World1
|
||||
- World2
|
||||
# Set here for which blocks the UseItem is blocked and the function of the block you are looking at should be used.
|
||||
ItemBlockBlacklist:
|
||||
useItemSettings:
|
||||
cursor:
|
||||
toGUIItem:
|
||||
# useItem: Here you define on which UseItem the cursor should be set.
|
||||
useItem: default
|
||||
onLogin:
|
||||
# Here you define whether the UseItem should be selected when joining the server.
|
||||
enable: true
|
||||
spigot:
|
||||
# Set here if the UseItem should only be selected at the first join
|
||||
onOnlyFirstLogin: true
|
||||
bungee:
|
||||
# Set here if the UseItem should be selected even if you change the server of the bungee network.
|
||||
# The option BungeeCord must be activated for this!
|
||||
onServerChange: false
|
||||
gameMode:
|
||||
change:
|
||||
# Set here if the UseItem should be reset when the GameMode is changed.
|
||||
enable: true
|
||||
# Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second).
|
||||
delayInTicks: 1
|
||||
world:
|
||||
change:
|
||||
# This specifies whether the UseItem should be reset when the world is changed.
|
||||
enable: true
|
||||
# Set the delay with which the UseItem should be reset (time in Minecraft ticks. 20 is one second).
|
||||
delayInTicks: 1
|
||||
# Set here for which blocks the UseItem is blocked and the function of the block you are looking at should be used.
|
||||
itemBlockBlacklist:
|
||||
- CHEST
|
||||
- CRAFTING_TABLE
|
||||
- FURNACE
|
||||
|
@@ -1,6 +1,6 @@
|
||||
name: T2C-CommandGUI
|
||||
version: ${project.version}
|
||||
main: de.jatitv.commandguiv2.Spigot.Main
|
||||
main: net.t2code.commandguiv2.Spigot.Main
|
||||
api-version: 1.13
|
||||
prefix: T2C-CommandGUI
|
||||
authors: [ JaTiTV ]
|
||||
|
Reference in New Issue
Block a user