Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
5d72e0d48d | |||
d25b704ff1 | |||
9aede116ac | |||
97fc283951 | |||
7e6c889583 | |||
a1ffd48f3e | |||
0c1d32e0e8 | |||
987370586a | |||
020f33da07 | |||
48196f446c | |||
6e96509069 | |||
fd0db6939a | |||
b5f3737fbd | |||
7833144a9a | |||
10e23c6dcf | |||
be73deface | |||
f4d8d3496a | |||
5514e62f5d | |||
ba1db37a90 | |||
02e7020815 | |||
546b827e02 | |||
1ae32b2b59 | |||
93f63ffad0 | |||
2d49a7a4b7 | |||
f00ac77743 | |||
e96447d4fa | |||
|
3053bc53a3 | ||
1de8c1d2ea | |||
e8a0b99a56 | |||
dc75e49988 | |||
|
555e3a192c | ||
|
7d2cf9a122 | ||
|
ecd3362db6 | ||
|
078e9404e6 | ||
|
2617f55062 | ||
bcfcc2e863 | |||
dbe5f82030 | |||
6586ac4ee9 | |||
|
a7518530c7 | ||
b9a91baed7 |
77
README.md
Normal file
77
README.md
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
<p align="center">
|
||||||
|
<img src="https://i.imgur.com/M4a7pVS.png" width="300">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
---
|
||||||
|
# Links
|
||||||
|
* [Spigot](https://www.spigotmc.org/resources/1-19-ready-t2c-alias-alias-plugin-for-spigot-bungee-commands-1-8-x-1-19-x.96389/)
|
||||||
|
* [Discord](http://dc.T2Code.net)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<img src="https://i.imgur.com/pK7kR6R.png" width="600">
|
||||||
|
|
||||||
|
T2C-Alias is an alias plugin that works for servers but also for bungee commands.
|
||||||
|
|
||||||
|
**Example:** */warp CityBuild* **->** */CityBuild* **or** */cb*
|
||||||
|
|
||||||
|
**Features:**
|
||||||
|
- Execute multiple commands directly with one alias
|
||||||
|
- Run commands as console
|
||||||
|
- Run commands as player
|
||||||
|
- Execute bungee commands
|
||||||
|
- Admin mode (more info below)
|
||||||
|
- Alias for the console
|
||||||
|
- Show messages (more info below)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Functions:**
|
||||||
|
***Admin Mode:***
|
||||||
|
|
||||||
|
With the admin mudus you can distinguish an alias for players / mods / admins.
|
||||||
|
For example the alias '/citybuild' executes the command '/warp CityBuild' for players and '/server citybuild' for players with an adjustable permission.
|
||||||
|
|
||||||
|
So you could set that players are teleported to a specific position and for example team members / VIPs or so are teleported to the server but to the last position and much more.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Send messages to players:**
|
||||||
|
|
||||||
|
With this plugin it is possible with an alias to send messages to players with or without TextBuilder.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Console Alias:**
|
||||||
|
|
||||||
|
It is possible to set an alias for the console.
|
||||||
|
|
||||||
|
For example for Paper to reload the server instead of '/reload confirm' just '/rlc'.
|
||||||
|
|
||||||
|
Info: There are different functions for an alias for player, admin and console possible.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**You can use MiniMessage:**
|
||||||
|
|
||||||
|
Wiki: https://docs.adventure.kyori.net/minimessage/format.html
|
||||||
|
|
||||||
|
WebUI: https://webui.adventure.kyori.net
|
||||||
|
|
||||||
|
|
||||||
|
<img src="https://i.imgur.com/55BlvCg.png" width="600">
|
||||||
|
|
||||||
|
**/t2code-alias** | **/alias**
|
||||||
|
|
||||||
|
**/alias info** - Open the T2C-Alias info. | *t2c.alias.command.info*
|
||||||
|
|
||||||
|
**/alias reload** - Reload the plugin. | *t2c.alias.command.reload*
|
||||||
|
|
||||||
|
|
||||||
|
*t2c.alias.admin* - Permission for all T2C-Alias Commands
|
||||||
|
|
||||||
|
*t2c.alias.updatemsg* - Get a notification when an update is available when joining
|
||||||
|
|
||||||
|
---
|
||||||
|
<img src="https://i.imgur.com/HoZSt7c.png" width="600">
|
||||||
|
<img src="https://bstats.org/signatures/bukkit/T2Code-Alias.svg" width="600">
|
49
pom.xml
49
pom.xml
@@ -6,7 +6,11 @@
|
|||||||
|
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>Alias</artifactId>
|
<artifactId>Alias</artifactId>
|
||||||
<version>1.1.0_Snapshot-#3</version>
|
|
||||||
|
<version>1.5</version>
|
||||||
|
<!--version>VERSION_snapshot-0</version-->
|
||||||
|
<!--version>VERSION_beta-0</version-->
|
||||||
|
<!--version>VERSION_dev-0</version-->
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>T2C-Alias</name>
|
<name>T2C-Alias</name>
|
||||||
@@ -19,6 +23,7 @@
|
|||||||
<url>T2Code.net</url>
|
<url>T2Code.net</url>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<finalName>${project.name}_${project.version}</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@@ -55,6 +60,16 @@
|
|||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<!-- Spigot -->
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
<!-- Mojang authlib -->
|
||||||
|
<repository>
|
||||||
|
<id>minecraft-repo</id>
|
||||||
|
<url>https://libraries.minecraft.net/</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>T2Code</id>
|
<id>T2Code</id>
|
||||||
<url>https://repo.t2code.net/repository/T2Code/</url>
|
<url>https://repo.t2code.net/repository/T2Code/</url>
|
||||||
@@ -66,26 +81,46 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- Spigot-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- Mojang authlib -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mojang</groupId>
|
||||||
|
<artifactId>authlib</artifactId>
|
||||||
|
<version>1.5.21</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>T2CodeLib</artifactId>
|
<artifactId>T2CodeLib</artifactId>
|
||||||
<version>12.4</version>
|
<version>16.5</version>
|
||||||
|
<!--classifier>dev-3</classifier-->
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>bungee</artifactId>
|
<artifactId>bungee</artifactId>
|
||||||
<version>1615</version>
|
<version>1615</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.t2code</groupId>
|
<groupId>net.t2code</groupId>
|
||||||
<artifactId>PlugmanGUI</artifactId>
|
<artifactId>PlugmanGUI</artifactId>
|
||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
</dependency>
|
<scope>provided</scope>
|
||||||
<dependency>
|
|
||||||
<groupId>net.t2code.minecraft.1_19.r1</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.19r1</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@@ -1,40 +0,0 @@
|
|||||||
package net.t2code.alias.Bungee;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import net.t2code.alias.Bungee.system.BLoad;
|
|
||||||
import net.t2code.alias.Util;
|
|
||||||
import net.t2code.lib.Bungee.Lib.messages.BT2CodeTemplate;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public final class BMain extends Plugin {
|
|
||||||
|
|
||||||
|
|
||||||
public static Plugin plugin;
|
|
||||||
public static String version;
|
|
||||||
public static String autor;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
// Plugin startup logic
|
|
||||||
plugin = this;
|
|
||||||
version = plugin.getDescription().getVersion();
|
|
||||||
autor = plugin.getDescription().getAuthor();
|
|
||||||
if (ProxyServer.getInstance().getPluginManager().getPlugin("T2CodeLib") == null) {
|
|
||||||
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
|
|
||||||
ProxyServer.getInstance().getConsole().sendMessage(Util.getPrefix() + " §eT2CodeLib §4could not be found. Please download it here: " +
|
|
||||||
"§6https://www.spigotmc.org/resources/t2codelib.96388/ §4to be able to use this plugin.");
|
|
||||||
getProxy().getPluginManager().getPlugin(plugin.getDescription().getName()).onDisable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BLoad.onLoad(plugin, Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getSpigotID(), Util.getBstatsID());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
// Plugin shutdown logic
|
|
||||||
if (ProxyServer.getInstance().getPluginManager().getPlugin("T2CodeLib") == null) return;
|
|
||||||
BT2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,38 +0,0 @@
|
|||||||
package net.t2code.alias.Bungee.system;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
|
||||||
import net.md_5.bungee.event.EventHandler;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class BListener implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPluginmessage(PluginMessageEvent event) {
|
|
||||||
if (event.getTag().equalsIgnoreCase("t2codealias:bungee")) {
|
|
||||||
|
|
||||||
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(event.getData()));
|
|
||||||
try {
|
|
||||||
String channel = stream.readUTF();
|
|
||||||
String input = stream.readUTF();
|
|
||||||
if (channel.equals("T2Code-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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
package net.t2code.alias.Bungee.system;
|
|
||||||
|
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import net.t2code.lib.Bungee.Lib.messages.BT2CodeTemplate;
|
|
||||||
import net.t2code.lib.Bungee.Lib.messages.Bsend;
|
|
||||||
import net.t2code.lib.Bungee.Lib.update.BUpdateAPI;
|
|
||||||
|
|
||||||
public class BLoad {
|
|
||||||
|
|
||||||
public static void onLoad(Plugin plugin, String prefix, String autor, String version, String spigot, String discord, Integer spigotID, Integer bstatsID) {
|
|
||||||
Long long_ = BT2CodeTemplate.onLoadHeader(prefix,autor,version,spigot,discord);
|
|
||||||
|
|
||||||
|
|
||||||
plugin.getProxy().registerChannel("t2codealias:bungee");
|
|
||||||
Bsend.console(prefix + " registerChannel(t2codealias:bungee)");
|
|
||||||
plugin.getProxy().getPluginManager().registerListener(plugin, new BListener());
|
|
||||||
|
|
||||||
BMetrics metrics = new BMetrics(plugin, bstatsID);
|
|
||||||
|
|
||||||
BUpdateAPI.onUpdateCheckTimer(plugin, prefix, spigot, discord, spigotID);
|
|
||||||
|
|
||||||
BT2CodeTemplate.onLoadFooter(prefix, long_);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,846 +0,0 @@
|
|||||||
package net.t2code.alias.Bungee.system;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import java.io.*;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.*;
|
|
||||||
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;
|
|
||||||
|
|
||||||
public class BMetrics {
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
12
src/main/java/net/t2code/alias/Spigot/Cache.java
Normal file
12
src/main/java/net/t2code/alias/Spigot/Cache.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package net.t2code.alias.Spigot;
|
||||||
|
|
||||||
|
import net.t2code.alias.Spigot.objects.AliasStorageObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Cache {
|
||||||
|
public static ArrayList<UUID> openPlayers = new ArrayList<UUID>();
|
||||||
|
public static HashMap<UUID, AliasStorageObject> aliasStorage = new HashMap<>();
|
||||||
|
}
|
@@ -1,10 +1,12 @@
|
|||||||
package net.t2code.alias.Spigot;
|
package net.t2code.alias.Spigot;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import net.t2code.alias.Spigot.objects.AliasObject;
|
import net.t2code.alias.Spigot.objects.AliasObject;
|
||||||
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
||||||
import net.t2code.alias.Spigot.system.Load;
|
import net.t2code.alias.Spigot.system.Load;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@@ -19,15 +21,29 @@ public final class Main extends JavaPlugin {
|
|||||||
return plugin.getDataFolder();
|
return plugin.getDataFolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static String version;
|
private static String version;
|
||||||
|
@Getter
|
||||||
private static List<String> autor;
|
private static List<String> autor;
|
||||||
|
@Getter
|
||||||
private static Main plugin;
|
private static Main plugin;
|
||||||
|
@Getter
|
||||||
|
private static String guiCode;
|
||||||
public static HashMap<String, AliasObject> aliasHashMap = new HashMap<>();
|
public static HashMap<String, AliasObject> aliasHashMap = new HashMap<>();
|
||||||
|
public static HashMap<String, Boolean> loadAliasHashMap = new HashMap<>();
|
||||||
public static HashMap<String, SubAliasObject> subAliasHashMap = new HashMap<>();
|
public static HashMap<String, SubAliasObject> subAliasHashMap = new HashMap<>();
|
||||||
public static ArrayList<String> allAliases = new ArrayList<>();
|
public static ArrayList<String> allAliases = new ArrayList<>();
|
||||||
public static ArrayList<String> allSubAliases = new ArrayList<>();
|
public static ArrayList<String> allSubAliases = new ArrayList<>();
|
||||||
public static ArrayList<String> allForSubAliases = new ArrayList<>();
|
public static ArrayList<String> allForSubAliases = new ArrayList<>();
|
||||||
|
|
||||||
|
// private BukkitCommandWrap bukkitCommandWrap = null;
|
||||||
|
//
|
||||||
|
// public BukkitCommandWrap getBukkitCommandWrap() {
|
||||||
|
// return this.bukkitCommandWrap;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Plugin startup logic
|
// Plugin startup logic
|
||||||
@@ -35,7 +51,16 @@ public final class Main extends JavaPlugin {
|
|||||||
autor = plugin.getDescription().getAuthors();
|
autor = plugin.getDescription().getAuthors();
|
||||||
version = plugin.getDescription().getVersion();
|
version = plugin.getDescription().getVersion();
|
||||||
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
|
||||||
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID());
|
// try {
|
||||||
|
// Class.forName("com.mojang.brigadier.CommandDispatcher");
|
||||||
|
// this.bukkitCommandWrap = new BukkitCommandWrap();
|
||||||
|
// } catch (ClassNotFoundException | NoClassDefFoundError e) {
|
||||||
|
// this.bukkitCommandWrap = new BukkitCommandWrap_Useless();
|
||||||
|
// }
|
||||||
|
if (T2CmcVersion.isMc1_13()) {
|
||||||
|
guiCode = "";
|
||||||
|
} else guiCode = "§6§8§9§r";
|
||||||
|
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getBstatsID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -44,7 +69,7 @@ public final class Main extends JavaPlugin {
|
|||||||
aliasHashMap.clear();
|
aliasHashMap.clear();
|
||||||
allAliases.clear();
|
allAliases.clear();
|
||||||
if (Bukkit.getPluginManager().getPlugin("T2CodeLib") == null) return;
|
if (Bukkit.getPluginManager().getPlugin("T2CodeLib") == null) return;
|
||||||
T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
T2Ctemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
|
||||||
@@ -79,16 +104,4 @@ public final class Main extends JavaPlugin {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Main getPlugin() {
|
|
||||||
return plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<String> getAutor() {
|
|
||||||
return autor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
package net.t2code.alias.Spigot.cmdManagement;
|
package net.t2code.alias.Spigot.cmdManagement;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.config.config.Config;
|
||||||
import net.t2code.alias.Spigot.config.languages.SelectMessages;
|
import net.t2code.alias.Spigot.config.config.Language;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.alias.Spigot.enums.Confirm;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -10,7 +11,6 @@ import org.bukkit.command.TabCompleter;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -23,26 +23,32 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
// Command
|
// Command
|
||||||
if (sender.hasPermission("t2code.alias.command.info")) {
|
if (sender.hasPermission("t2c.alias.command.info")) {
|
||||||
Commands.info(sender);
|
Commands.info(sender);
|
||||||
} else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
|
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info")
|
||||||
.replace("[perm]", "t2code.alias.command.info"));
|
.replace("[perm]", "t2c.alias.command.info"));
|
||||||
} else {
|
} else {
|
||||||
switch (args[0].toLowerCase()) {
|
switch (args[0].toLowerCase()) {
|
||||||
case "reload":
|
case "reload":
|
||||||
case "rl":
|
case "rl":
|
||||||
if (sender.hasPermission("t2code.alias.command.reload") || sender.isOp()) {
|
if (sender.hasPermission("t2c.alias.command.reload") || sender.isOp()) {
|
||||||
Commands.reload(sender);
|
Commands.reload(sender);
|
||||||
} else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias reload")
|
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias reload")
|
||||||
.replace("[perm]", "t2code.alias.command.reload"));
|
.replace("[perm]", "t2c.alias.command.reload"));
|
||||||
|
break;
|
||||||
|
case "confirm":
|
||||||
|
if (Config.buyConfirmDefault.value == Confirm.COMMAND) ExecuteAlias.storage(sender, true);
|
||||||
|
break;
|
||||||
|
case "cancel":
|
||||||
|
ExecuteAlias.storage(sender, false);
|
||||||
break;
|
break;
|
||||||
case "info":
|
case "info":
|
||||||
case "plugin":
|
case "plugin":
|
||||||
case "version":
|
case "version":
|
||||||
if (sender.hasPermission("t2code.alias.command.info")) {
|
if (sender.hasPermission("t2c.alias.command.info")) {
|
||||||
Commands.info(sender);
|
Commands.info(sender);
|
||||||
} else send.sender(sender, SelectMessages.noPermissionForCommand.replace("[cmd]", "/t2code-alias info")
|
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info")
|
||||||
.replace("[perm]", "t2code.alias.command.info"));
|
.replace("[perm]", "t2c.alias.command.info"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -52,9 +58,9 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
//TabCompleter
|
//TabCompleter
|
||||||
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
|
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
|
||||||
put("reload", "t2code.alias.command.reload");
|
put("reload", "t2c.alias.command.reload");
|
||||||
put("rl", "t2code.alias.command.reload");
|
put("rl", "t2c.alias.command.reload");
|
||||||
put("info", "t2code.alias.command.info");
|
put("info", "t2c.alias.command.info");
|
||||||
}};
|
}};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -64,7 +70,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
for (String command : arg1.keySet()) {
|
for (String command : arg1.keySet()) {
|
||||||
Boolean passend = true;
|
boolean passend = true;
|
||||||
for (int i = 0; i < args[0].length(); i++) {
|
for (int i = 0; i < args[0].length(); i++) {
|
||||||
if (args[0].length() >= command.length()) {
|
if (args[0].length() >= command.length()) {
|
||||||
passend = false;
|
passend = false;
|
||||||
|
@@ -1,31 +1,28 @@
|
|||||||
package net.t2code.alias.Spigot.cmdManagement;
|
package net.t2code.alias.Spigot.cmdManagement;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.alias.Spigot.config.languages.SelectMessages;
|
import net.t2code.alias.Spigot.config.config.Language;
|
||||||
import net.t2code.alias.Spigot.system.Load;
|
import net.t2code.alias.Spigot.system.Load;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
public static void info(CommandSender sender) {
|
public static void info(CommandSender sender) {
|
||||||
T2CodeTemplate.sendInfo(sender, Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.getAutor(), Main.getVersion(),
|
T2Ctemplate.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
|
||||||
UpdateAPI.PluginVersionen.get(Main.getPlugin().getName()).publicVersion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload(CommandSender sender) {
|
public static void reload(CommandSender sender) {
|
||||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadStart);
|
if (sender instanceof Player) T2Csend.player((Player) sender, Language.reloadStart.value);
|
||||||
send.console(Util.getPrefix() + "§8-------------------------------");
|
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||||
send.console(Util.getPrefix() + " §6Plugin reload...");
|
T2Csend.console(Util.getPrefix() + " §6Plugin reload...");
|
||||||
send.console(Util.getPrefix() + "§8-------------------------------");
|
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||||
Main.getPlugin().onEnable();
|
Load.loadReload();
|
||||||
if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadEnd);
|
if (sender instanceof Player) T2Csend.player((Player) sender, Language.reloadEnd.value);
|
||||||
send.console(Util.getPrefix() + "§8-------------------------------");
|
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||||
send.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
T2Csend.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
|
||||||
send.console(Util.getPrefix() + "§8-------------------------------");
|
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,17 +1,21 @@
|
|||||||
package net.t2code.alias.Spigot.cmdManagement;
|
package net.t2code.alias.Spigot.cmdManagement;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Cache;
|
||||||
import net.t2code.alias.Spigot.config.config.SelectConfig;
|
import net.t2code.alias.Spigot.config.config.Config;
|
||||||
import net.t2code.alias.Spigot.config.languages.SelectMessages;
|
import net.t2code.alias.Spigot.config.config.Language;
|
||||||
|
import net.t2code.alias.Spigot.confirm.gui.ConfirmGUI;
|
||||||
|
import net.t2code.alias.Spigot.enums.Confirm;
|
||||||
import net.t2code.alias.Spigot.objects.AliasObject;
|
import net.t2code.alias.Spigot.objects.AliasObject;
|
||||||
|
import net.t2code.alias.Spigot.objects.AliasStorageObject;
|
||||||
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
||||||
import net.t2code.alias.Spigot.system.BCommandSenderReciver;
|
import net.t2code.alias.Spigot.system.BCommandSenderReciver;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.commands.Cmd;
|
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ccmd;
|
||||||
import net.t2code.lib.Spigot.Lib.eco.Eco;
|
import net.t2code.t2codelib.SPIGOT.api.eco.T2Ceco;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||||
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@@ -20,15 +24,37 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ExecuteAlias {
|
public class ExecuteAlias {
|
||||||
|
|
||||||
private static final String prefix = Util.getPrefix();
|
private static final String prefix = Util.getPrefix();
|
||||||
|
|
||||||
|
public static void storage(CommandSender sender, boolean confirm) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
if (!Cache.aliasStorage.containsKey(player.getUniqueId())) {
|
||||||
|
T2Csend.player(player, Language.confirmNotPossible.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AliasStorageObject object = Cache.aliasStorage.get(player.getUniqueId());
|
||||||
|
Cache.aliasStorage.remove(player.getUniqueId());
|
||||||
|
|
||||||
|
if (!confirm) {
|
||||||
|
T2Csend.player(player, Language.confirmCancel.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (object.sub) {
|
||||||
|
executeSubAlias(player, (SubAliasObject) object.aliasObject, object.alias, object.args);
|
||||||
|
} else executeAlias(player, (AliasObject) object.aliasObject, object.alias, object.args);
|
||||||
|
}
|
||||||
|
|
||||||
protected static void aliasPlayer(CommandSender sender, AliasObject aliasObject, String alias, String[] args) {
|
protected static void aliasPlayer(CommandSender sender, AliasObject aliasObject, String alias, String[] args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (aliasObject.adminEnable) {
|
if (aliasObject.adminEnable) {
|
||||||
if (player.hasPermission(aliasObject.adminPermission)) {
|
if (player.hasPermission(aliasObject.adminPermission.replace("[alias]", alias.toLowerCase()))) {
|
||||||
if (aliasObject.adminCommandEnable) {
|
if (aliasObject.adminCommandEnable) {
|
||||||
aliasAdminCommand(aliasObject, player, args);
|
aliasAdminCommand(aliasObject, alias, player, args);
|
||||||
}
|
}
|
||||||
if (aliasObject.adminMessageEnable) {
|
if (aliasObject.adminMessageEnable) {
|
||||||
aliasAdminMessage(aliasObject, alias, player, args);
|
aliasAdminMessage(aliasObject, alias, player, args);
|
||||||
@@ -38,27 +64,81 @@ public class ExecuteAlias {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aliasObject.permNecessary) {
|
if (aliasObject.permNecessary) {
|
||||||
if (!(player.hasPermission(aliasObject.permission.replace("<alias>", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
|
if (!(player.hasPermission(aliasObject.permission.replace("[alias]", alias.toLowerCase())) || player.hasPermission("t2c.alias.admin"))) {
|
||||||
String npmsg;
|
String npmsg;
|
||||||
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
|
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
|
||||||
npmsg = SelectMessages.noPermissionForCommand;
|
npmsg = Language.noPermission.value;
|
||||||
} else npmsg = aliasObject.permissionMSG;
|
} else npmsg = aliasObject.permissionMSG;
|
||||||
send.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
|
T2Csend.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
|
||||||
.replace("[perm]", aliasObject.permission.replace("<alias>", alias.toLowerCase())).replace("[alias]", alias));
|
.replace("[perm]", aliasObject.permission.replace("[alias]", alias.toLowerCase())).replace("[alias]", alias));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aliasObject.costEnable) {
|
if (aliasObject.costEnable && aliasObject.costConfirm) {
|
||||||
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
|
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy." + alias.toLowerCase() + ".bypass"))) {
|
||||||
if (!Eco.moneyRemove(prefix, player, aliasObject.costPrice)) {
|
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, false));
|
||||||
send.player(player, SelectMessages.noMoney);
|
switch ((Confirm) Config.buyConfirmDefault.value) {
|
||||||
return;
|
case GUI:
|
||||||
|
ConfirmGUI.open(player, aliasObject.costPrice, alias);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CHAT:
|
||||||
|
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMMAND:
|
||||||
|
default:
|
||||||
|
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString()));
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
executeAlias(player, aliasObject, alias, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void executeAlias(Player player, AliasObject aliasObject, String alias, String[] args) {
|
||||||
|
if (aliasObject.cooldownGlobal != 0) {
|
||||||
|
if (!(player.hasPermission("t2code.alias.cooldown.global." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.cooldown.global.all.bypass"))) {
|
||||||
|
if (aliasObject.globalCooldownInt != 0) {
|
||||||
|
Long duration = System.currentTimeMillis() - aliasObject.globalCooldownInt;
|
||||||
|
if (!(duration > (aliasObject.cooldownGlobal * 1000))) {
|
||||||
|
T2Csend.player(player, Language.cooldownGlobal.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownGlobal - (int) (duration / 1000))));
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aliasObject.globalCooldownInt = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aliasObject.cooldownPlayer != 0) {
|
||||||
|
if (!(player.hasPermission("t2code.alias.cooldown.player." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.cooldown.player.all.bypass"))) {
|
||||||
|
Long cooldown = aliasObject.cooldownPlayerMap.get(player.getUniqueId());
|
||||||
|
if (cooldown != null) {
|
||||||
|
Long duration = System.currentTimeMillis() - cooldown;
|
||||||
|
if (!(duration > (aliasObject.cooldownPlayer * 1000))) {
|
||||||
|
T2Csend.player(player, Language.cooldownPlayer.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownPlayer - (int) (duration / 1000))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aliasObject.cooldownPlayerMap.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aliasObject.costEnable) {
|
||||||
|
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.buy.all.bypass"))) {
|
||||||
|
if (!T2Ceco.moneyRemove(prefix, player, aliasObject.costPrice)) {
|
||||||
|
T2Csend.player(player, Language.noMoney.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((Boolean) Config.buyMessage.value)
|
||||||
|
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (aliasObject.commandEnable) {
|
if (aliasObject.commandEnable) {
|
||||||
aliasCommand(aliasObject, player, args);
|
aliasCommand(aliasObject, alias, player, args);
|
||||||
}
|
}
|
||||||
if (aliasObject.messageEnable) {
|
if (aliasObject.messageEnable) {
|
||||||
aliasMessage(aliasObject, alias, player, args);
|
aliasMessage(aliasObject, alias, player, args);
|
||||||
@@ -67,7 +147,7 @@ public class ExecuteAlias {
|
|||||||
|
|
||||||
protected static void subAliasPlayer(CommandSender sender, SubAliasObject aliasObject, String alias, String[] args) {
|
protected static void subAliasPlayer(CommandSender sender, SubAliasObject aliasObject, String alias, String[] args) {
|
||||||
if (!aliasObject.subAliasEnable) {
|
if (!aliasObject.subAliasEnable) {
|
||||||
send.sender(sender, SelectMessages.aliasDisabled);
|
T2Csend.sender(sender, Language.aliasDisabled.value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +155,9 @@ public class ExecuteAlias {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
if (aliasObject.adminEnable) {
|
if (aliasObject.adminEnable) {
|
||||||
if (player.hasPermission(aliasObject.adminPermission)) {
|
if (player.hasPermission(aliasObject.adminPermission.replace("[alias]", alias.toLowerCase()))) {
|
||||||
if (aliasObject.adminCommandEnable) {
|
if (aliasObject.adminCommandEnable) {
|
||||||
subAliasAdminCommand(aliasObject, player, args);
|
subAliasAdminCommand(aliasObject, alias, player, args);
|
||||||
}
|
}
|
||||||
if (aliasObject.adminMessageEnable) {
|
if (aliasObject.adminMessageEnable) {
|
||||||
subAliasAdminMessage(aliasObject, alias, player, args);
|
subAliasAdminMessage(aliasObject, alias, player, args);
|
||||||
@@ -87,35 +167,90 @@ public class ExecuteAlias {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (aliasObject.permNecessary) {
|
if (aliasObject.permNecessary) {
|
||||||
if (!(player.hasPermission(aliasObject.permission.replace("<alias>", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
|
if (!(player.hasPermission(aliasObject.permission.replace("[alias]", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
|
||||||
String npmsg;
|
String npmsg;
|
||||||
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
|
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
|
||||||
npmsg = SelectMessages.noPermissionForCommand;
|
npmsg = Language.noPermission.value;
|
||||||
} else npmsg = aliasObject.permissionMSG;
|
} else npmsg = aliasObject.permissionMSG;
|
||||||
send.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
|
T2Csend.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
|
||||||
.replace("[perm]", aliasObject.permission.replace("<alias>", alias.toLowerCase())).replace("[alias]", alias));
|
.replace("[perm]", aliasObject.permission.replace("[alias]", alias.toLowerCase())).replace("[alias]", alias));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aliasObject.costEnable) {
|
if (aliasObject.costEnable && aliasObject.costConfirm) {
|
||||||
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
|
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
|
||||||
if (!Eco.moneyRemove(prefix, player, aliasObject.costPrice)) {
|
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, true));
|
||||||
send.player(player, SelectMessages.noMoney);
|
switch ((Confirm) Config.buyConfirmDefault.value) {
|
||||||
return;
|
case GUI:
|
||||||
|
ConfirmGUI.open(player, aliasObject.costPrice, alias);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CHAT:
|
||||||
|
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case COMMAND:
|
||||||
|
default:
|
||||||
|
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", aliasObject.costPrice.toString()));
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (aliasObject.commandEnable) {
|
|
||||||
subAliasCommand(aliasObject, player, args);
|
executeSubAlias(player, aliasObject, alias, args);
|
||||||
}
|
|
||||||
if (aliasObject.messageEnable) {
|
|
||||||
subAliasMessage(aliasObject, alias, player, args);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (aliasObject.consoleEnable) {
|
if (aliasObject.consoleEnable) {
|
||||||
subAliasConsole(aliasObject, sender, args);
|
subAliasConsole(aliasObject, alias, sender, args);
|
||||||
} else send.sender(sender, SelectMessages.onlyForPlayer);
|
} else T2Csend.sender(sender, Language.onlyForPlayer.value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void executeSubAlias(Player player, SubAliasObject aliasObject, String alias, String[] args) {
|
||||||
|
|
||||||
|
if (aliasObject.cooldownGlobal != 0) {
|
||||||
|
if (!(player.hasPermission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.sub.cooldown.global.all.bypass"))) {
|
||||||
|
if (aliasObject.globalCooldownInt != 0) {
|
||||||
|
Long duration = System.currentTimeMillis() - aliasObject.globalCooldownInt;
|
||||||
|
if (!(duration > (aliasObject.cooldownGlobal * 1000))) {
|
||||||
|
T2Csend.player(player, Language.cooldownGlobal.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownGlobal - (int) (duration / 1000))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aliasObject.globalCooldownInt = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aliasObject.cooldownPlayer != 0) {
|
||||||
|
if (!(player.hasPermission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.sub.cooldown.player.all.bypass"))) {
|
||||||
|
Long cooldown = aliasObject.cooldownPlayerMap.get(player.getUniqueId());
|
||||||
|
if (cooldown != null) {
|
||||||
|
Long duration = System.currentTimeMillis() - cooldown;
|
||||||
|
if (!(duration > (aliasObject.cooldownPlayer * 1000))) {
|
||||||
|
T2Csend.player(player, Language.cooldownPlayer.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownPlayer - (int) (duration / 1000))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
aliasObject.cooldownPlayerMap.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (aliasObject.costEnable) {
|
||||||
|
if (!(aliasObject.costAllowBypass && player.hasPermission("t2c.alias.sub.buy." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.sub.buy.all.bypass"))) {
|
||||||
|
if (!T2Ceco.moneyRemove(prefix, player, aliasObject.costPrice)) {
|
||||||
|
T2Csend.player(player, Language.noMoney.value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((Boolean) Config.buyMessage.value)
|
||||||
|
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (aliasObject.commandEnable) {
|
||||||
|
subAliasCommand(aliasObject, player, args);
|
||||||
|
}
|
||||||
|
if (aliasObject.messageEnable) {
|
||||||
|
subAliasMessage(aliasObject, alias, player, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,25 +258,25 @@ public class ExecuteAlias {
|
|||||||
if (alias.consoleCommandEnable) {
|
if (alias.consoleCommandEnable) {
|
||||||
for (String cmd : alias.consoleCommands) {
|
for (String cmd : alias.consoleCommands) {
|
||||||
if (alias.consoleBungeeCommand) {
|
if (alias.consoleBungeeCommand) {
|
||||||
if (SelectConfig.Bungee) {
|
if (T2CLibConfig.getBungee()) {
|
||||||
BCommandSenderReciver.sendToBungee(sender, cmd, true);
|
BCommandSenderReciver.sendToBungee(sender, cmd, true);
|
||||||
} else {
|
} else {
|
||||||
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Cmd.console(cmd);
|
T2Ccmd.console(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (alias.consoleMessageEnable) {
|
if (alias.consoleMessageEnable) {
|
||||||
for (String msg : alias.consoleMessages) {
|
for (String msg : alias.consoleMessages) {
|
||||||
send.console(Replace.replace(prefix, msg));
|
T2Csend.console(T2Creplace.replace(prefix, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void subAliasConsole(SubAliasObject alias, CommandSender sender, String[] args) {
|
private static void subAliasConsole(SubAliasObject aliasObject, String alias, CommandSender sender, String[] args) {
|
||||||
String targetSt = "[target]";
|
String targetSt = "[target]";
|
||||||
try {
|
try {
|
||||||
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
|
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
|
||||||
@@ -149,28 +284,29 @@ public class ExecuteAlias {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
if (alias.consoleCommandEnable) {
|
if (aliasObject.consoleCommandEnable) {
|
||||||
for (String cmd : alias.consoleCommands) {
|
for (String cmd : aliasObject.consoleCommands) {
|
||||||
if (alias.consoleBungeeCommand) {
|
String replace = cmd.replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
if (SelectConfig.Bungee) {
|
if (aliasObject.consoleBungeeCommand) {
|
||||||
BCommandSenderReciver.sendToBungee(sender, cmd.replace("[target]", targetSt), true);
|
if (T2CLibConfig.getBungee()) {
|
||||||
|
BCommandSenderReciver.sendToBungee(sender, replace, true);
|
||||||
} else {
|
} else {
|
||||||
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Cmd.console(cmd.replace("[target]", targetSt));
|
T2Ccmd.console(replace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (alias.consoleMessageEnable) {
|
if (aliasObject.consoleMessageEnable) {
|
||||||
for (String msg : alias.consoleMessages) {
|
for (String msg : aliasObject.consoleMessages) {
|
||||||
send.console(Replace.replace(prefix, msg));
|
T2Csend.console(T2Creplace.replace(prefix, msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void aliasAdminCommand(AliasObject alias, Player player, String[] args) {
|
private static void aliasAdminCommand(AliasObject aliasObject, String alias, Player player, String[] args) {
|
||||||
String targetSt = "[target]";
|
String targetSt = "[target]";
|
||||||
try {
|
try {
|
||||||
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
|
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
|
||||||
@@ -178,26 +314,26 @@ public class ExecuteAlias {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
for (String cmd : alias.adminCommands) {
|
for (String cmd : aliasObject.adminCommands) {
|
||||||
if (alias.adminBungeeCommand) {
|
if (aliasObject.adminBungeeCommand) {
|
||||||
if (SelectConfig.Bungee) {
|
if (T2CLibConfig.getBungee()) {
|
||||||
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.adminCommandAsConsole);
|
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.adminCommandAsConsole);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (alias.adminCommandAsConsole) {
|
if (aliasObject.adminCommandAsConsole) {
|
||||||
Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
|
||||||
} else {
|
} else {
|
||||||
Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
T2Ccmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void subAliasAdminCommand(SubAliasObject alias, Player player, String[] args) {
|
private static void subAliasAdminCommand(SubAliasObject aliasObject, String alias, Player player, String[] args) {
|
||||||
String targetSt = "[target]";
|
String targetSt = "[target]";
|
||||||
try {
|
try {
|
||||||
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
|
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
|
||||||
@@ -205,20 +341,20 @@ public class ExecuteAlias {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
for (String cmd : alias.adminCommands) {
|
for (String cmd : aliasObject.adminCommands) {
|
||||||
if (alias.adminBungeeCommand) {
|
if (aliasObject.adminBungeeCommand) {
|
||||||
if (SelectConfig.Bungee) {
|
if (T2CLibConfig.getBungee()) {
|
||||||
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.adminCommandAsConsole);
|
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.adminCommandAsConsole);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (alias.adminCommandAsConsole) {
|
if (aliasObject.adminCommandAsConsole) {
|
||||||
Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
|
||||||
} else {
|
} else {
|
||||||
Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
T2Ccmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -234,12 +370,12 @@ public class ExecuteAlias {
|
|||||||
}
|
}
|
||||||
for (String msg : aliasObject.adminMessages) {
|
for (String msg : aliasObject.adminMessages) {
|
||||||
String text;
|
String text;
|
||||||
if (PluginCheck.papi()) {
|
if (T2CpluginCheck.papi()) {
|
||||||
text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
text = T2Creplace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
} else {
|
} else {
|
||||||
text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
text = T2Creplace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
}
|
}
|
||||||
send.player(player, text);
|
T2Csend.player(player, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,16 +389,16 @@ public class ExecuteAlias {
|
|||||||
}
|
}
|
||||||
for (String msg : subAliasObject.adminMessages) {
|
for (String msg : subAliasObject.adminMessages) {
|
||||||
String text;
|
String text;
|
||||||
if (PluginCheck.papi()) {
|
if (T2CpluginCheck.papi()) {
|
||||||
text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
text = T2Creplace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
} else {
|
} else {
|
||||||
text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
text = T2Creplace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
}
|
}
|
||||||
send.player(player, text);
|
T2Csend.player(player, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void aliasCommand(AliasObject alias, Player player, String[] args) {
|
private static void aliasCommand(AliasObject aliasObject, String alias, Player player, String[] args) {
|
||||||
String targetSt = "[target]";
|
String targetSt = "[target]";
|
||||||
try {
|
try {
|
||||||
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
|
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
|
||||||
@@ -270,20 +406,19 @@ public class ExecuteAlias {
|
|||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
}
|
}
|
||||||
for (String cmd : alias.command) {
|
for (String cmd : aliasObject.command) {
|
||||||
if (alias.bungeeCommand) {
|
if (aliasObject.bungeeCommand) {
|
||||||
if (SelectConfig.Bungee) {
|
if (T2CLibConfig.getBungee()) {
|
||||||
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole);
|
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.commandAsConsole);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (alias.commandAsConsole) {
|
if (aliasObject.commandAsConsole) {
|
||||||
Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
|
||||||
} else {
|
} else {
|
||||||
Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
T2Ccmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,18 +434,18 @@ public class ExecuteAlias {
|
|||||||
}
|
}
|
||||||
for (String cmd : alias.command) {
|
for (String cmd : alias.command) {
|
||||||
if (alias.bungeeCommand) {
|
if (alias.bungeeCommand) {
|
||||||
if (SelectConfig.Bungee) {
|
if (T2CLibConfig.getBungee()) {
|
||||||
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole);
|
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
T2Csend.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (alias.commandAsConsole) {
|
if (alias.commandAsConsole) {
|
||||||
Cmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
T2Ccmd.console(cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
||||||
} else {
|
} else {
|
||||||
Cmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
T2Ccmd.player(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,12 +463,12 @@ public class ExecuteAlias {
|
|||||||
|
|
||||||
for (String msg : aliasObject.messages) {
|
for (String msg : aliasObject.messages) {
|
||||||
String text;
|
String text;
|
||||||
if (PluginCheck.papi()) {
|
if (T2CpluginCheck.papi()) {
|
||||||
text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
text = T2Creplace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
} else {
|
} else {
|
||||||
text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
text = T2Creplace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
}
|
}
|
||||||
send.player(player, text);
|
T2Csend.player(player, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,12 +482,12 @@ public class ExecuteAlias {
|
|||||||
}
|
}
|
||||||
for (String msg : subAliasObject.messages) {
|
for (String msg : subAliasObject.messages) {
|
||||||
String text;
|
String text;
|
||||||
if (PluginCheck.papi()) {
|
if (T2CpluginCheck.papi()) {
|
||||||
text = Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
text = T2Creplace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
} else {
|
} else {
|
||||||
text = Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
text = T2Creplace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
|
||||||
}
|
}
|
||||||
send.player(player, text);
|
T2Csend.player(player, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,23 +1,16 @@
|
|||||||
package net.t2code.alias.Spigot.cmdManagement;
|
package net.t2code.alias.Spigot.cmdManagement;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.alias.Spigot.config.languages.SelectMessages;
|
import net.t2code.alias.Spigot.config.config.Language;
|
||||||
import net.t2code.alias.Spigot.objects.AliasObject;
|
import net.t2code.alias.Spigot.objects.AliasObject;
|
||||||
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
public class RegisterCommands extends Command {
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RegisterCommands extends Command implements TabCompleter {
|
|
||||||
private String alias;
|
private String alias;
|
||||||
private String prefix = Util.getPrefix();
|
private String prefix = Util.getPrefix();
|
||||||
|
|
||||||
@@ -31,11 +24,11 @@ public class RegisterCommands extends Command implements TabCompleter {
|
|||||||
AliasObject alias = Main.aliasHashMap.get(this.alias);
|
AliasObject alias = Main.aliasHashMap.get(this.alias);
|
||||||
|
|
||||||
if (alias == null) {
|
if (alias == null) {
|
||||||
send.error(Main.getPlugin(), "The alias " + this.alias + " does not exist.");
|
T2Csend.error(Main.getPlugin(), "The alias " + this.alias + " does not exist.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!alias.aliasEnable) {
|
if (!alias.aliasEnable) {
|
||||||
send.sender(sender, SelectMessages.aliasDisabled);
|
T2Csend.sender(sender, Language.aliasDisabled.value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (args.length == 0 || args.length == 1 && args[0].contains("-p:")) {
|
if (args.length == 0 || args.length == 1 && args[0].contains("-p:")) {
|
||||||
@@ -44,7 +37,7 @@ public class RegisterCommands extends Command implements TabCompleter {
|
|||||||
} else {
|
} else {
|
||||||
if (alias.consoleEnable) {
|
if (alias.consoleEnable) {
|
||||||
ExecuteAlias.aliasConsole(alias, sender, prefix);
|
ExecuteAlias.aliasConsole(alias, sender, prefix);
|
||||||
} else send.sender(sender, SelectMessages.onlyForPlayer);
|
} else T2Csend.sender(sender, Language.onlyForPlayer.value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!Main.allForSubAliases.contains(this.alias)) {
|
if (!Main.allForSubAliases.contains(this.alias)) {
|
||||||
@@ -61,15 +54,9 @@ public class RegisterCommands extends Command implements TabCompleter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
send.sender(sender, "<color:#ffbd17><hover:show_text:'<dark_red>TODO <blue>DEV</blue></dark_red>'>Diesen Befehl gibt es nicht</hover></color>");
|
T2Csend.sender(sender, Language.noSubCommand.value);
|
||||||
//todo
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {
|
|
||||||
return Collections.singletonList("hallodepp");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,11 +2,10 @@ package net.t2code.alias.Spigot.cmdManagement;
|
|||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
||||||
import net.t2code.lib.Spigot.Lib.commands.Tab;
|
import net.t2code.t2codelib.SPIGOT.api.commands.T2Ctab;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.server.TabCompleteEvent;
|
import org.bukkit.event.server.TabCompleteEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -17,11 +16,10 @@ public class TabEvent implements Listener {
|
|||||||
public void onTab(TabCompleteEvent e) {
|
public void onTab(TabCompleteEvent e) {
|
||||||
String buffer = e.getBuffer();
|
String buffer = e.getBuffer();
|
||||||
String[] imp = buffer.replace("/", "").split(" ");
|
String[] imp = buffer.replace("/", "").split(" ");
|
||||||
List<String> list = new ArrayList<>(Collections.emptyList());
|
|
||||||
if (!Main.allAliases.contains(imp[0]) || !Main.allForSubAliases.contains(imp[0])){
|
if (!Main.allAliases.contains(imp[0]) || !Main.allForSubAliases.contains(imp[0])){
|
||||||
e.setCompletions(list);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
List<String> list = new ArrayList<>(Collections.emptyList());
|
||||||
arg1.clear();
|
arg1.clear();
|
||||||
|
|
||||||
for (String sals : Main.allSubAliases) {
|
for (String sals : Main.allSubAliases) {
|
||||||
@@ -33,12 +31,12 @@ public class TabEvent implements Listener {
|
|||||||
String[] args = input.split(" ", -1);
|
String[] args = input.split(" ", -1);
|
||||||
|
|
||||||
for (String al : aliasObject.subAliasList) {
|
for (String al : aliasObject.subAliasList) {
|
||||||
arg1.put(al, aliasObject.permission.replace("<alias>", al.toLowerCase()));
|
arg1.put(al, aliasObject.permission.replace("[alias]", al.toLowerCase()));
|
||||||
}
|
}
|
||||||
int arg = aliasObject.subAliasArg;
|
int arg = aliasObject.subAliasArg;
|
||||||
if (args.length - 1 == arg) {
|
if (args.length - 1 == arg) {
|
||||||
for (String command : aliasObject.subAliasList) {
|
for (String command : aliasObject.subAliasList) {
|
||||||
if (Tab.hasPermission(e.getSender(), arg1.get(command)) && Tab.passend(command, args[arg])) {
|
if (T2Ctab.hasPermission(e.getSender(), arg1.get(command)) && T2Ctab.passend(command, args[arg])) {
|
||||||
list.add(command);
|
list.add(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package net.t2code.alias.Spigot.config.alias;
|
package net.t2code.alias.Spigot.config.alias;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -24,20 +24,41 @@ public class AliasConfigConverter {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
T2Csend.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
send.error(Main.getPlugin(), "");
|
T2Csend.error(Main.getPlugin(), "");
|
||||||
send.warning(Main.getPlugin(), "The " + config_gui.getName() + " file is converted to the new config format.");
|
T2Csend.warning(Main.getPlugin(), "The " + config_gui.getName() + " file is converted to the new config format.");
|
||||||
send.warning(Main.getPlugin(), "The alias is no longer the filename, this is now adjustable in the file under 'Alias.AliasList'!");
|
T2Csend.warning(Main.getPlugin(), "The alias is no longer the filename, this is now adjustable in the file under 'Alias.AliasList'!");
|
||||||
send.warning(Main.getPlugin(), "This allows a function to have multiple alias commands without creating multiple files!");
|
T2Csend.warning(Main.getPlugin(), "This allows a function to have multiple alias commands without creating multiple files!");
|
||||||
send.error(Main.getPlugin(), "");
|
T2Csend.error(Main.getPlugin(), "");
|
||||||
send.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
T2Csend.error(Main.getPlugin(), "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void convertAddPermission(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) {
|
public static void convertAddPermission(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) {
|
||||||
if (subalias) {
|
if (subalias) {
|
||||||
yamlConfiguration.set("SubAlias.Permission.Permission", "t2code.alias.use.subalias.<alias>");
|
yamlConfiguration.set("SubAlias.Permission.Permission", "t2c.alias.sub.use.[alias]");
|
||||||
} else yamlConfiguration.set("Alias.Permission.Permission", "t2code.alias.use.<alias>");
|
} else yamlConfiguration.set("Alias.Permission.Permission", "t2c.alias.use.[alias]");
|
||||||
|
try {
|
||||||
|
yamlConfiguration.save(config_gui);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void convertAddCooldownInSecGlobal(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) {
|
||||||
|
if (subalias) {
|
||||||
|
yamlConfiguration.set("Alias.CooldownInSec.Global", 0);
|
||||||
|
} else yamlConfiguration.set("Alias.CooldownInSec.Global", 0);
|
||||||
|
try {
|
||||||
|
yamlConfiguration.save(config_gui);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void convertAddCooldownInSecPlayer(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) {
|
||||||
|
if (subalias) {
|
||||||
|
yamlConfiguration.set("Alias.CooldownInSec.Player", 0);
|
||||||
|
} else yamlConfiguration.set("Alias.CooldownInSec.Player", 0);
|
||||||
try {
|
try {
|
||||||
yamlConfiguration.save(config_gui);
|
yamlConfiguration.save(config_gui);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -55,4 +76,15 @@ public class AliasConfigConverter {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void convertAddCostConfirm(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) {
|
||||||
|
if (subalias) {
|
||||||
|
yamlConfiguration.set("SubAlias.Cost.Confirm", false);
|
||||||
|
} else yamlConfiguration.set("Alias.Cost.Confirm", false);
|
||||||
|
try {
|
||||||
|
yamlConfiguration.save(config_gui);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,12 +2,13 @@ package net.t2code.alias.Spigot.config.alias;
|
|||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
@@ -15,52 +16,56 @@ public class CreateExampleAliasConfig {
|
|||||||
|
|
||||||
public static void configCreate() {
|
public static void configCreate() {
|
||||||
long long_ = System.currentTimeMillis();
|
long long_ = System.currentTimeMillis();
|
||||||
send.console(Util.getPrefix() + " §4Alias/aliasexample.yml are created...");
|
T2Csend.console(Util.getPrefix() + " §4Alias/aliasexample.yml are created...");
|
||||||
|
|
||||||
File config = new File(Main.getPath(), "Alias/aliasexample.yml");
|
File config = new File(Main.getPath(), "Alias/aliasexample.yml");
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
Config.set("Alias.Enable", true, yamlConfiguration);
|
T2Cconfig.set("Alias.Enable", true, yamlConfiguration);
|
||||||
Config.set("Alias.AliasList", Arrays.asList("aliasexample1"),yamlConfiguration);
|
T2Cconfig.set("Alias.AliasList", Arrays.asList("aliasexample1","t2caliasexample"),yamlConfiguration);
|
||||||
|
|
||||||
Config.set("Alias.Permission.Necessary", true, yamlConfiguration);
|
T2Cconfig.set("Alias.Permission.Necessary", true, yamlConfiguration);
|
||||||
Config.set("Alias.Permission.Permission", "t2code.alias.use.<alias>", yamlConfiguration);
|
T2Cconfig.set("Alias.Permission.Permission", "t2c.alias.use.[alias]", yamlConfiguration);
|
||||||
Config.set("Alias.Permission.CustomNoPermissionMSG", "", yamlConfiguration);
|
T2Cconfig.set("Alias.Permission.CustomNoPermissionMSG", "", yamlConfiguration);
|
||||||
|
|
||||||
Config.set("Alias.Cost.Enable", false,yamlConfiguration);
|
T2Cconfig.set("Alias.CooldownInSec.Global", 0, yamlConfiguration);
|
||||||
Config.set("Alias.Cost.Price", 0.0,yamlConfiguration);
|
T2Cconfig.set("Alias.CooldownInSec.Player", 0, yamlConfiguration);
|
||||||
Config.set("Alias.Cost.AllowByPass", true,yamlConfiguration);
|
|
||||||
|
|
||||||
Config.set("Alias.Command.Enable", true, yamlConfiguration);
|
T2Cconfig.set("Alias.Cost.Enable", false,yamlConfiguration);
|
||||||
Config.set("Alias.Command.CommandAsConsole", true, yamlConfiguration);
|
T2Cconfig.set("Alias.Cost.Confirm", true,yamlConfiguration);
|
||||||
Config.set("Alias.Command.BungeeCommand", false, yamlConfiguration);
|
T2Cconfig.set("Alias.Cost.Price", 0.0,yamlConfiguration);
|
||||||
Config.set("Alias.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration);
|
T2Cconfig.set("Alias.Cost.AllowByPass", true,yamlConfiguration);
|
||||||
|
|
||||||
Config.set("Alias.Message.Enable", false, yamlConfiguration);
|
T2Cconfig.set("Alias.Command.Enable", false, yamlConfiguration);
|
||||||
Config.set("Alias.Message.Messages", Collections.emptyList(), yamlConfiguration);
|
T2Cconfig.set("Alias.Command.CommandAsConsole", true, yamlConfiguration);
|
||||||
|
T2Cconfig.set("Alias.Command.BungeeCommand", false, yamlConfiguration);
|
||||||
|
T2Cconfig.set("Alias.Command.Commands", Arrays.asList(), yamlConfiguration);
|
||||||
|
|
||||||
Config.set("Alias.Admin.Enable", true, yamlConfiguration);
|
T2Cconfig.set("Alias.Message.Enable", true, yamlConfiguration);
|
||||||
Config.set("Alias.Admin.Permission", "t2code.alias.admin", yamlConfiguration);
|
T2Cconfig.set("Alias.Message.Messages", Arrays.asList("<rainbow>This is a test alias</rainbow>", "<color:#d7ff0f>With this you can use several functions such as <color:#ffd6ad>colored text</color>, <click:suggest_command:'/command'><hover:show_text:'<color:#ff745c>Use Command</color>'>clickable texts</hover></click>, <hover:show_text:'<color:#1f66ff>For example Warps</color>'><click:suggest_command:'/warp home'><color:#365eff>shorten commands of other plugins</color></click></hover> and much more.</color>", "<color:#85a0ff><click:open_url:'http://dc.t2code.net'><hover:show_text:'<color:#0887ff>http://dc.t2code.net</color>'>If you have any questions, please contact our support Discord.</hover></click></color>"), yamlConfiguration);
|
||||||
|
|
||||||
Config.set("Alias.Admin.Command.Enable", true, yamlConfiguration);
|
T2Cconfig.set("Alias.Admin.Enable", false, yamlConfiguration);
|
||||||
Config.set("Alias.Admin.Command.CommandAsConsole", true, yamlConfiguration);
|
T2Cconfig.set("Alias.Admin.Permission", "t2c.alias.[alias].admin", yamlConfiguration);
|
||||||
Config.set("Alias.Admin.Command.BungeeCommand", false, yamlConfiguration);
|
|
||||||
Config.set("Alias.Admin.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration);
|
|
||||||
|
|
||||||
Config.set("Alias.Admin.Message.Enable", false, yamlConfiguration);
|
T2Cconfig.set("Alias.Admin.Command.Enable", true, yamlConfiguration);
|
||||||
Config.set("Alias.Admin.Message.Messages", Collections.emptyList(), yamlConfiguration);
|
T2Cconfig.set("Alias.Admin.Command.CommandAsConsole", true, yamlConfiguration);
|
||||||
|
T2Cconfig.set("Alias.Admin.Command.BungeeCommand", false, yamlConfiguration);
|
||||||
|
T2Cconfig.set("Alias.Admin.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration);
|
||||||
|
|
||||||
Config.set("Alias.Console.Enable", false, yamlConfiguration);
|
T2Cconfig.set("Alias.Admin.Message.Enable", false, yamlConfiguration);
|
||||||
Config.set("Alias.Console.Command.Enable", false, yamlConfiguration);
|
T2Cconfig.set("Alias.Admin.Message.Messages", Arrays.asList(), yamlConfiguration);
|
||||||
Config.set("Alias.Console.Command.BungeeCommand", false, yamlConfiguration);
|
|
||||||
Config.set("Alias.Console.Command.Commands", Collections.emptyList(), yamlConfiguration);
|
T2Cconfig.set("Alias.Console.Enable", false, yamlConfiguration);
|
||||||
Config.set("Alias.Console.Message.Enable", false, yamlConfiguration);
|
T2Cconfig.set("Alias.Console.Command.Enable", false, yamlConfiguration);
|
||||||
Config.set("Alias.Console.Message.Messages", Collections.emptyList(), yamlConfiguration);
|
T2Cconfig.set("Alias.Console.Command.BungeeCommand", false, yamlConfiguration);
|
||||||
|
T2Cconfig.set("Alias.Console.Command.Commands", Arrays.asList(), yamlConfiguration);
|
||||||
|
T2Cconfig.set("Alias.Console.Message.Enable", false, yamlConfiguration);
|
||||||
|
T2Cconfig.set("Alias.Console.Message.Messages", Arrays.asList(), yamlConfiguration);
|
||||||
try {
|
try {
|
||||||
yamlConfiguration.save(config);
|
yamlConfiguration.save(config);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
send.console(Util.getPrefix() + " §2Alias/aliasexample.yml were successfully created." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
T2Csend.console(Util.getPrefix() + " §2Alias/aliasexample.yml were successfully created." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,11 +2,11 @@ package net.t2code.alias.Spigot.config.alias;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.alias.Spigot.config.config.SelectConfig;
|
|
||||||
import net.t2code.alias.Spigot.system.AliasRegister;
|
import net.t2code.alias.Spigot.system.AliasRegister;
|
||||||
import net.t2code.alias.Spigot.objects.AliasObject;
|
import net.t2code.alias.Spigot.objects.AliasObject;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@@ -24,6 +24,7 @@ public class SelectAlias {
|
|||||||
|
|
||||||
Main.aliasHashMap.clear();
|
Main.aliasHashMap.clear();
|
||||||
Main.allAliases.clear();
|
Main.allAliases.clear();
|
||||||
|
|
||||||
File f = new File(Main.getPath() + "/Alias/");
|
File f = new File(Main.getPath() + "/Alias/");
|
||||||
File[] fileArray = f.listFiles();
|
File[] fileArray = f.listFiles();
|
||||||
for (File config_gui : fileArray) {
|
for (File config_gui : fileArray) {
|
||||||
@@ -62,7 +63,22 @@ public class SelectAlias {
|
|||||||
}
|
}
|
||||||
String permissionMSG = yamlConfiguration.getString("Alias.Permission.CustomNoPermissionMSG");
|
String permissionMSG = yamlConfiguration.getString("Alias.Permission.CustomNoPermissionMSG");
|
||||||
|
|
||||||
|
|
||||||
|
if (yamlConfiguration.get("Alias.CooldownInSec.Global") == null) {
|
||||||
|
AliasConfigConverter.convertAddCooldownInSecGlobal(yamlConfiguration, config_gui, false);
|
||||||
|
}
|
||||||
|
Integer cooldownGlobal = yamlConfiguration.getInt("Alias.CooldownInSec.Global");
|
||||||
|
|
||||||
|
if (yamlConfiguration.get("Alias.CooldownInSec.Player") == null) {
|
||||||
|
AliasConfigConverter.convertAddCooldownInSecPlayer(yamlConfiguration, config_gui, false);
|
||||||
|
}
|
||||||
|
Integer cooldownPlayer = yamlConfiguration.getInt("Alias.CooldownInSec.Player");
|
||||||
|
|
||||||
Boolean costEnable = yamlConfiguration.getBoolean("Alias.Cost.Enable");
|
Boolean costEnable = yamlConfiguration.getBoolean("Alias.Cost.Enable");
|
||||||
|
if (yamlConfiguration.get("Alias.Cost.Confirm") == null) {
|
||||||
|
AliasConfigConverter.convertAddCostConfirm(yamlConfiguration, config_gui, false);
|
||||||
|
}
|
||||||
|
Boolean costConfirm = yamlConfiguration.getBoolean("Alias.Cost.Confirm");
|
||||||
Double costPrice = yamlConfiguration.getDouble("Alias.Cost.Price");
|
Double costPrice = yamlConfiguration.getDouble("Alias.Cost.Price");
|
||||||
Boolean costAllowBypass = yamlConfiguration.getBoolean("Alias.Cost.AllowByPass");
|
Boolean costAllowBypass = yamlConfiguration.getBoolean("Alias.Cost.AllowByPass");
|
||||||
|
|
||||||
@@ -93,15 +109,16 @@ public class SelectAlias {
|
|||||||
List<String> consoleMessages = yamlConfiguration.getStringList("Alias.Console.Message.Messages");
|
List<String> consoleMessages = yamlConfiguration.getStringList("Alias.Console.Message.Messages");
|
||||||
|
|
||||||
Main.allAliases.addAll(aliasList);
|
Main.allAliases.addAll(aliasList);
|
||||||
AliasObject alias = new AliasObject(aliasEnable, aliasList, permNecessary, permission, permissionMSG, costEnable, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand,
|
AliasObject alias = new AliasObject(aliasEnable, aliasList, permNecessary, permission, permissionMSG, cooldownGlobal, cooldownPlayer, costEnable, costConfirm, costPrice, costAllowBypass, commandEnable,
|
||||||
command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands,
|
commandAsConsole, bungeeCommand, command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands, adminMessageEnable,
|
||||||
adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
|
adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
|
||||||
for (String al : aliasList) {
|
for (String al : aliasList) {
|
||||||
Main.aliasHashMap.put(al, alias);
|
Main.aliasHashMap.put(al, alias);
|
||||||
}
|
}
|
||||||
|
T2Csend.console(Prefix + " §aAlias file §e" + config_gui.getName() + " §awas loaded");
|
||||||
}
|
}
|
||||||
send.console(Prefix + " §aAlias file §e" + config_gui.getName() + " §awas loaded");
|
|
||||||
}
|
}
|
||||||
|
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
|
||||||
AliasRegister.onRegister();
|
AliasRegister.onRegister();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,44 @@
|
|||||||
|
package net.t2code.alias.Spigot.config.config;
|
||||||
|
|
||||||
|
import net.t2code.alias.Spigot.enums.ConfigParam;
|
||||||
|
import net.t2code.alias.Spigot.enums.Confirm;
|
||||||
|
import net.t2code.alias.Util;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
|
public enum Config {
|
||||||
|
configVersion("configVersion", Util.getConfigVersion(), ConfigParam.INTEGER),
|
||||||
|
language("plugin.language", "english", ConfigParam.STRING),
|
||||||
|
updateCheckOnJoin("plugin.updateCheck.onJoin", true, ConfigParam.BOOLEAN),
|
||||||
|
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, ConfigParam.BOOLEAN),
|
||||||
|
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, ConfigParam.INTEGER),
|
||||||
|
|
||||||
|
buyMessage("buy.message", true, ConfigParam.BOOLEAN),
|
||||||
|
buyCurrency("buy.currency", "$", ConfigParam.STRING),
|
||||||
|
buyConfirmDefault("buy.confirm.use", Confirm.COMMAND, ConfigParam.CONFIRMENUM),
|
||||||
|
buyConfirmGuiFillItemEnabled("buy.confirm.gui.fillItem.enabled", true, ConfigParam.BOOLEAN),
|
||||||
|
buyConfirmGuiFillItem("buy.confirm.gui.fillItem.material", T2CitemVersion.getBlackStainedGlassPane().getType().toString(), ConfigParam.STRING),
|
||||||
|
buyConfirmGuiConfirm("buy.confirm.gui.confirm.material", T2CitemVersion.getGreenWool().getType().toString(), ConfigParam.STRING),
|
||||||
|
buyConfirmGuiCancel("buy.confirm.gui.cancel.material", T2CitemVersion.getRedWool().getType().toString(), ConfigParam.STRING),
|
||||||
|
subAliasTab("subAlias.tabComplete", true, ConfigParam.BOOLEAN);
|
||||||
|
|
||||||
|
public String path;
|
||||||
|
public Object value;
|
||||||
|
public Sound sound;
|
||||||
|
public ConfigParam configParam;
|
||||||
|
|
||||||
|
Config(String path, Object value, ConfigParam cEnum) {
|
||||||
|
this.path = path;
|
||||||
|
this.value = value;
|
||||||
|
this.configParam = cEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Sound sound() {
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,98 @@
|
|||||||
|
package net.t2code.alias.Spigot.config.config;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import net.t2code.alias.Spigot.Main;
|
||||||
|
import net.t2code.alias.Util;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Convert {
|
||||||
|
protected static void convert() {
|
||||||
|
File path = new File(Main.getPath(),"");
|
||||||
|
File file = new File(Main.getPath(), "config.yml");
|
||||||
|
if (path.exists() && file.exists()) convertTo4();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void convertTo4() {
|
||||||
|
long long1 = System.currentTimeMillis();
|
||||||
|
File config = new File(Main.getPath(), "config.yml");
|
||||||
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
|
if (yamlConfiguration.get(Config.configVersion.path) == null || ((Integer) Config.configVersion.value) < Util.getConfigVersion()) {
|
||||||
|
yamlConfiguration.set("ConfigVersion", null);
|
||||||
|
try {
|
||||||
|
yamlConfiguration.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
File dir = new File(Main.getPath() + "/languages");
|
||||||
|
File newDir = new File(Main.getPath() + "/OldConfig/Version3/languages");
|
||||||
|
if (!dir.exists()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
FileUtils.moveDirectory(dir, newDir);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
File f = new File(Main.getPath() + "/OldConfig/Version3/languages/");
|
||||||
|
File[] fileArray = f.listFiles();
|
||||||
|
for (File file : fileArray) {
|
||||||
|
long long2 = System.currentTimeMillis();
|
||||||
|
String sub = file.getName().substring(file.getName().length() - 4);
|
||||||
|
if (sub.equals(".yml")) {
|
||||||
|
YamlConfiguration yamlConfigurationOld;
|
||||||
|
try {
|
||||||
|
Preconditions.checkArgument(file != null, "File cannot be null");
|
||||||
|
YamlConfiguration language = new YamlConfiguration();
|
||||||
|
language.load(file);
|
||||||
|
yamlConfigurationOld = language;
|
||||||
|
} catch (FileNotFoundException var3) {
|
||||||
|
continue;
|
||||||
|
} catch (IOException var4) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, var4);
|
||||||
|
continue;
|
||||||
|
} catch (InvalidConfigurationException var5) {
|
||||||
|
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, var5);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File newFile = new File(Main.getPath(), "languages/" + file.getName().replace("_messages.yml", "") + ".yml");
|
||||||
|
YamlConfiguration yamlConfigurationNew = YamlConfiguration.loadConfiguration(newFile);
|
||||||
|
|
||||||
|
yamlConfigurationNew.set("plugin.onlyForPlayer", yamlConfigurationOld.getString("Plugin.OnlyForPlayer"));
|
||||||
|
yamlConfigurationNew.set("plugin.aliasDisabled", yamlConfigurationOld.getString("Plugin.AliasDisabled"));
|
||||||
|
yamlConfigurationNew.set("plugin.reload.start", yamlConfigurationOld.getString("Plugin.Reload.Start"));
|
||||||
|
yamlConfigurationNew.set("plugin.reload.end", yamlConfigurationOld.getString("Plugin.Reload.End"));
|
||||||
|
yamlConfigurationNew.set("plugin.noPermissionForCommand", yamlConfigurationOld.getString("Plugin.ForCommand"));
|
||||||
|
yamlConfigurationNew.set("plugin.noSubCommand", yamlConfigurationOld.getString("Plugin.NoSubCommand"));
|
||||||
|
yamlConfigurationNew.set("cost.buy", yamlConfigurationOld.getString("Cost.Buy"));
|
||||||
|
yamlConfigurationNew.set("cost.noMoney", yamlConfigurationOld.getString("Cost.NoMoney"));
|
||||||
|
yamlConfigurationNew.set("cost.confirm.command", yamlConfigurationOld.getString("Cost.BuyConfirm"));
|
||||||
|
yamlConfigurationNew.set("cost.confirm.cancel", yamlConfigurationOld.getString("Cost.BuyCancel"));
|
||||||
|
yamlConfigurationNew.set("cost.confirm.notPossible", yamlConfigurationOld.getString("Cost.BuyConfirmNotPossible"));
|
||||||
|
|
||||||
|
try {
|
||||||
|
yamlConfigurationNew.save(newFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
T2Csend.warning(Main.getPlugin(), e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
T2Csend.console(Util.getPrefix() + " §2The language file §6(" + newFile.getName() + ") &2was converted to the new config format §7- §e" + (System.currentTimeMillis() - long2) + "ms");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
T2Csend.console(Util.getPrefix() + " §2All files were successfully converted. §7- §e" + (System.currentTimeMillis() - long1) + "ms");
|
||||||
|
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
|
||||||
|
}
|
||||||
|
}
|
@@ -1,39 +0,0 @@
|
|||||||
package net.t2code.alias.Spigot.config.config;
|
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
|
||||||
import net.t2code.alias.Util;
|
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
||||||
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class CreateConfig {
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
Config.set("Plugin.language", "english", yamlConfiguration);
|
|
||||||
|
|
||||||
Config.set("BungeeCord.Enable", false, yamlConfiguration);
|
|
||||||
Config.set("BungeeCord.ThisServer", "server", yamlConfiguration);
|
|
||||||
|
|
||||||
Config.set("Buy.Message", true, yamlConfiguration);
|
|
||||||
Config.set("SubAlias.TabComplete", true, 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");
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,150 @@
|
|||||||
|
package net.t2code.alias.Spigot.config.config;
|
||||||
|
|
||||||
|
import net.t2code.alias.Spigot.Main;
|
||||||
|
import net.t2code.alias.Spigot.enums.Confirm;
|
||||||
|
import net.t2code.alias.Util;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.config.languages.SelectLibMsg;
|
||||||
|
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.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FileSelect {
|
||||||
|
|
||||||
|
public static void config() {
|
||||||
|
Convert.convert();
|
||||||
|
long long_ = System.currentTimeMillis();
|
||||||
|
File config = new File(Main.getPath(), "config.yml");
|
||||||
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
for (Config value : Config.values()) {
|
||||||
|
switch (value.configParam) {
|
||||||
|
case STRING:
|
||||||
|
if (!yamlConfiguration.contains(value.path)) {
|
||||||
|
yamlConfiguration.set(value.path, value.value);
|
||||||
|
}
|
||||||
|
value.value = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
|
||||||
|
break;
|
||||||
|
case SOUND:
|
||||||
|
if (!yamlConfiguration.contains(value.path)) {
|
||||||
|
yamlConfiguration.set(value.path, value.sound.toString());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
value.sound = Sound.valueOf(yamlConfiguration.getString(value.path));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
T2Csend.console("§4\n§4\n§4\n" + SelectLibMsg.soundNotFound.replace("[prefix]", Util.getPrefix())
|
||||||
|
.replace("[sound]", "§8" + value.path + ": §6" + yamlConfiguration.getString(value.path)) + "§4\n§4\n§4\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BOOLEAN:
|
||||||
|
case INTEGER:
|
||||||
|
if (!yamlConfiguration.contains(value.path)) {
|
||||||
|
yamlConfiguration.set(value.path, value.value);
|
||||||
|
}
|
||||||
|
value.value = yamlConfiguration.get(value.path);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CONFIRMENUM:
|
||||||
|
if (!yamlConfiguration.contains(value.path)) {
|
||||||
|
yamlConfiguration.set(value.path, value.value.toString());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
value.value = Confirm.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
value.value = Confirm.COMMAND;
|
||||||
|
T2Csend.console(("[prefix] <red>The value in the <gold>config.yml</gold> at the path <gold>[path]</gold> <aqua>([value])</aqua> must be one of these values!</red>" +
|
||||||
|
" <gray>COMMAND, CHAT, GUI</gray><br>[prefix] <blue>The default option COMMAND is used!</blue>")
|
||||||
|
.replace("[prefix]", Util.getPrefix()).replace("[path]", value.path).replace("[value]", yamlConfiguration.getString(value.path)));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
yamlConfiguration.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
T2Csend.console(Util.getPrefix() + " §2The config.yml was loaded successfully §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArrayList<String> defaultLanguages = new ArrayList<>(Arrays.asList("german", "english"));
|
||||||
|
|
||||||
|
public static void language() {
|
||||||
|
long long_ = System.currentTimeMillis();
|
||||||
|
for (String language : defaultLanguages) {
|
||||||
|
File config = new File(Main.getPath(), "languages/" + language + ".yml");
|
||||||
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
for (Language value : Language.values()) {
|
||||||
|
if (!yamlConfiguration.contains(value.path)) {
|
||||||
|
switch (value.configParam) {
|
||||||
|
case STRING:
|
||||||
|
switch (language) {
|
||||||
|
case "german":
|
||||||
|
yamlConfiguration.set(value.path, value.german);
|
||||||
|
break;
|
||||||
|
case "english":
|
||||||
|
yamlConfiguration.set(value.path, value.english);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LIST:
|
||||||
|
switch (language) {
|
||||||
|
case "german":
|
||||||
|
yamlConfiguration.set(value.path, value.germanList);
|
||||||
|
break;
|
||||||
|
case "english":
|
||||||
|
yamlConfiguration.set(value.path, value.englishList);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
T2Cdebug.debug(Main.getPlugin(), "save: " + language);
|
||||||
|
try {
|
||||||
|
yamlConfiguration.save(config);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String selectMSG;
|
||||||
|
File config = new File(Main.getPath(), "languages/" + Config.language.value + ".yml");
|
||||||
|
T2Cdebug.debug(Main.getPlugin(), config.getAbsolutePath());
|
||||||
|
if (!config.isFile()) {
|
||||||
|
T2Csend.console(Util.getPrefix());
|
||||||
|
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
|
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.language.value + " §4language file was not found.");
|
||||||
|
T2Csend.console(Util.getPrefix() + " §6The default language §eEnglish §6is used!");
|
||||||
|
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
|
T2Csend.console(Util.getPrefix());
|
||||||
|
config = new File(Main.getPath(), "languages/" + "english.yml");
|
||||||
|
selectMSG = "english";
|
||||||
|
} else selectMSG = (String) Config.language.value;
|
||||||
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
for (Language value : Language.values()) {
|
||||||
|
switch (value.configParam) {
|
||||||
|
case STRING:
|
||||||
|
T2Cdebug.debug(Main.getPlugin(), "Select: File: " + config.getName() + " Path: " + value.path);
|
||||||
|
value.value = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LIST:
|
||||||
|
T2Cdebug.debug(Main.getPlugin(), "Select: File: " + config.getName() + " Path: " + value.path);
|
||||||
|
value.valueList = T2Creplace.replace(Util.getPrefix(), (List<String>) yamlConfiguration.getList(value.path));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
T2Csend.console(Util.getPrefix() + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,76 @@
|
|||||||
|
package net.t2code.alias.Spigot.config.config;
|
||||||
|
|
||||||
|
import net.t2code.alias.Spigot.enums.ConfigParam;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum Language {
|
||||||
|
|
||||||
|
onlyForPlayer("plugin.onlyForPlayer", null, "[prefix] <red>Dieser Command ist nur f[ue]r Spieler!</red>",
|
||||||
|
"[prefix] <red>This command is for players only!</red>", ConfigParam.STRING),
|
||||||
|
|
||||||
|
aliasDisabled("plugin.aliasDisabled", null, "Unknown command. Type ''/help'' for help.",
|
||||||
|
"Unknown command. Type ''/help'' for help.", ConfigParam.STRING),
|
||||||
|
|
||||||
|
reloadStart("plugin.reload.start", null, "[prefix] <gold>Plugin wird neu geladen...</gold>",
|
||||||
|
"[prefix] <gold>Plugin is reloaded...</gold>", ConfigParam.STRING),
|
||||||
|
|
||||||
|
reloadEnd("plugin.reload.end", null, "[prefix] <dark_green>Plugin wurde erfolgreich neu geladen.</dark_green>",
|
||||||
|
"[prefix] <dark_green>Plugin was successfully reloaded.</dark_green>", ConfigParam.STRING),
|
||||||
|
|
||||||
|
noPermission("plugin.noPermissionForCommand", null, "[prefix] <red>F[ue]r <aqua>[cmd]</aqua> fehlt dir die Permission <gold>[perm]</gold>!</red>",
|
||||||
|
"[prefix] <red>For <aqua>[cmd]</aqua> you lack the permission <gold>[perm]</gold>!</red>", ConfigParam.STRING),
|
||||||
|
|
||||||
|
noSubCommand("plugin.noSubCommand", null, "[prefix] <red>Diesen Befehl gibt es nicht!</red>",
|
||||||
|
"[prefix] <red>This command does not exist!</red>", ConfigParam.STRING),
|
||||||
|
buy("cost.buy", null, "[prefix] <dark_green>Du hast f[ue]r diesen Command <gold>[price]</gold> bezahlt.</dark_green>",
|
||||||
|
"[prefix] <dark_green>You have paid <gold>[price]</gold> for this command.</dark_green>", ConfigParam.STRING),
|
||||||
|
noMoney("cost.noMoney", null, "[prefix] <red>Du hast nicht gen[ue]gend Geld für diesen Command!</red>", "[prefix] <red>You don't have enough money for this command!</red>", ConfigParam.STRING),
|
||||||
|
|
||||||
|
cooldownPlayer("cooldown.player",null,"[prefix] <red>Du musst noch <gold>[cooldown]</gold> Sekunden warten um diesen Command erneut zu nutzen.</red>","[prefix] <red>You must wait <gold>[cooldown]</gold> seconds to use this command again.</red>",ConfigParam.STRING),
|
||||||
|
cooldownGlobal("cooldown.global",null,"[prefix] <red>Du musst noch <gold>[cooldown]</gold> Sekunden warten um diesen Command zu nutzen.</red>","[prefix] <red>You have to wait <gold>[cooldown]</gold> seconds to use this command.</red>",ConfigParam.STRING),
|
||||||
|
|
||||||
|
confirmCommand("cost.confirm.command", null, "[prefix] <gold>Für diesen Befehl musst du [price] bezahlen!</gold><br>[prefix] <green><click:run_command:'/t2c-a confirm'><hover:show_text:'<gray>Klicke zum bestätigen</gray>'>Bestätigen</hover></click></green> <gray>-</gray> <red><click:run_command:'/t2c-a cancel'><hover:show_text:'<gray>Klicke zum abbrechen</gray>'>Abbrechen</hover></click></red>",
|
||||||
|
"[prefix] <gold>For this command you have to pay [price]!</gold><br>[prefix] <green><click:run_command:'/t2c-a confirm'><hover:show_text:'<gray>Click to confirm</gray>'>Confirm</hover></click></green> <gray>-</gray> <red><click:run_command:'/t2c-a cancel'><hover:show_text:'<gray>click to cancel</gray>'>Cancel</hover></click></red>", ConfigParam.STRING),
|
||||||
|
confirmChat("cost.confirm.chat", null, "[prefix] <gold>Für diesen Befehl musst du [price] bezahlen!</gold><br>[prefix] <green><click:run_command:'t2code-alias-confirm'><hover:show_text:'<gray>Klicke zum bestätigen</gray>'>Bestätigen</hover></click></green> <gray>-</gray> <red><click:run_command:'t2code-alias-cancel'><hover:show_text:'<gray>Klicke zum abbrechen</gray>'>Abbrechen</hover></click></red>",
|
||||||
|
"[prefix] <gold>For this command you have to pay [price]!</gold><br>[prefix] <green><click:run_command:'t2code-alias-confirm'><hover:show_text:'<gray>Click to confirm</gray>'>Confirm</hover></click></green> <gray>-</gray> <red><click:run_command:'t2code-alias-cancel'><hover:show_text:'<gray>click to cancel</gray>'>Cancel</hover></click></red>", ConfigParam.STRING),
|
||||||
|
|
||||||
|
confirmGuiTitle("cost.confirm.gui.title", null, "&2Bestätige den Zahlvorgang für: &6/[alias]",
|
||||||
|
"&2Confirm the payment process for: &6/[alias]", ConfigParam.STRING),
|
||||||
|
confirmGuiConfirm("cost.confirm.gui.confirm.displayName", null, "&2Bestätigen", "&2Confirm", ConfigParam.STRING),
|
||||||
|
confirmGuiConfirmLore("cost.confirm.gui.confirm.lore", null, Arrays.asList("&aDieser Befehl kostet", "&6[price]"),
|
||||||
|
Arrays.asList("&aThis command costs","&6[price]"), ConfigParam.LIST),
|
||||||
|
confirmGuiCancel("cost.confirm.gui.cancel.displayName", null, "&cAbbrechen", "&cCancel", ConfigParam.STRING),
|
||||||
|
confirmGuiCancelLore("cost.confirm.gui.cancel.lore", null, Arrays.asList(""), Arrays.asList(""), ConfigParam.LIST),
|
||||||
|
confirmCancel("cost.confirm.cancel", null, "[prefix] <gold>Der befehl wurde abgebrochen und du musst nichts bezahlen!</gold>",
|
||||||
|
"[prefix] <gold>The command was canceled and you do not have to pay anything!</gold>", ConfigParam.STRING),
|
||||||
|
confirmNotPossible("cost.confirm.notPossible", null, "[prefix] <gold>Bestätigen nicht möglich, du hast keinen bezahlungspflichtigen befehl ausgeführt.</gold>",
|
||||||
|
"[prefix] <gold>Confirmation not possible, you have not executed a payable command.</gold>", ConfigParam.STRING);
|
||||||
|
|
||||||
|
|
||||||
|
public String path;
|
||||||
|
public String value;
|
||||||
|
public List<String> valueList;
|
||||||
|
public String german;
|
||||||
|
public List<String> germanList;
|
||||||
|
public String english;
|
||||||
|
public List<String> englishList;
|
||||||
|
public ConfigParam configParam;
|
||||||
|
|
||||||
|
Language(String path, String value, String german, String english, ConfigParam cEnum) {
|
||||||
|
this.path = path;
|
||||||
|
this.value = value;
|
||||||
|
this.german = german;
|
||||||
|
this.english = english;
|
||||||
|
this.configParam = cEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
Language(String path, List<String> valueList, List<String> german, List<String> english, ConfigParam cEnum) {
|
||||||
|
this.path = path;
|
||||||
|
this.valueList = valueList;
|
||||||
|
this.germanList = german;
|
||||||
|
this.englishList = english;
|
||||||
|
this.configParam = cEnum;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,44 +0,0 @@
|
|||||||
package net.t2code.alias.Spigot.config.config;
|
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class SelectConfig {
|
|
||||||
private static Integer ConfigVersion = 3;
|
|
||||||
public static Integer isConfigVersion;
|
|
||||||
public static Boolean UpdateCheckOnJoin;
|
|
||||||
public static String language;
|
|
||||||
public static Boolean Bungee;
|
|
||||||
public static String thisServer;
|
|
||||||
|
|
||||||
public static Boolean buyMessage;
|
|
||||||
public static Boolean subAliasTab;
|
|
||||||
|
|
||||||
public static void onSelect() {
|
|
||||||
File config = new File(Main.getPath(), "config.yml");
|
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
|
||||||
|
|
||||||
isConfigVersion = yamlConfiguration.getInt("ConfigVersion");
|
|
||||||
|
|
||||||
UpdateCheckOnJoin = yamlConfiguration.getBoolean("Plugin.UpdateCheckOnJoin");
|
|
||||||
language = yamlConfiguration.getString("Plugin.language");
|
|
||||||
Bungee = yamlConfiguration.getBoolean("BungeeCord.Enable");
|
|
||||||
thisServer = yamlConfiguration.getString("BungeeCord.ThisServer");
|
|
||||||
|
|
||||||
buyMessage = yamlConfiguration.getBoolean("Buy.Message");
|
|
||||||
subAliasTab = yamlConfiguration.getBoolean("SubAlias.TabComplete");
|
|
||||||
}
|
|
||||||
public static void setConfigVersion() {
|
|
||||||
File config = new File(Main.getPath(), "config.yml");
|
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
|
||||||
yamlConfiguration.set("ConfigVersion", ConfigVersion);
|
|
||||||
try {
|
|
||||||
yamlConfiguration.save(config);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,74 +0,0 @@
|
|||||||
package net.t2code.alias.Spigot.config.languages;
|
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
|
||||||
import net.t2code.alias.Util;
|
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
||||||
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class LanguagesCreate {
|
|
||||||
|
|
||||||
public static void langCreate() {
|
|
||||||
send.debug(Main.getPlugin(),"§4Language files are created / updated...");
|
|
||||||
long long_ = System.currentTimeMillis();
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* ENGLISH
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
File messagesEN = new File(Main.getPath(), "languages/english_messages.yml");
|
|
||||||
YamlConfiguration yamlConfigurationEN = YamlConfiguration.loadConfiguration(messagesEN);
|
|
||||||
|
|
||||||
Config.set("Plugin.OnlyForPlayer", MSG.EN_OnlyForPlayer, yamlConfigurationEN);
|
|
||||||
Config.set("Plugin.AliasDisabled", MSG.EN_Disabled, yamlConfigurationEN);
|
|
||||||
Config.set("Plugin.Reload.Start", MSG.EN_ReloadStart, yamlConfigurationEN);
|
|
||||||
Config.set("Plugin.Reload.End", MSG.EN_ReloadEnd, yamlConfigurationEN);
|
|
||||||
Config.set("Plugin.ForCommand", MSG.EN_NoPermissionForCommand, yamlConfigurationEN);
|
|
||||||
|
|
||||||
Config. set("Cost.Buy", MSG.EN_Buy, yamlConfigurationEN);
|
|
||||||
Config.set("Cost.NoMoney", MSG.EN_NoMoney, yamlConfigurationEN);
|
|
||||||
|
|
||||||
try {
|
|
||||||
yamlConfigurationEN.save(messagesEN);
|
|
||||||
} catch (IOException e) {
|
|
||||||
send.warning(Main.getPlugin(),e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* GERMAN
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
File messagesDE = new File(Main.getPath(), "languages/german_messages.yml");
|
|
||||||
YamlConfiguration yamlConfigurationDE = YamlConfiguration.loadConfiguration(messagesDE);
|
|
||||||
|
|
||||||
Config.set("Plugin.OnlyForPlayer", MSG.DE_OnlyForPlayer, yamlConfigurationDE);
|
|
||||||
Config.set("Plugin.AliasDisabled", MSG.DE_Disabled, yamlConfigurationDE);
|
|
||||||
Config.set("Plugin.Reload.Start", MSG.DE_ReloadStart, yamlConfigurationDE);
|
|
||||||
Config.set("Plugin.Reload.End", MSG.DE_ReloadEnd, yamlConfigurationDE);
|
|
||||||
Config.set("Plugin.ForCommand", MSG.DE_NoPermissionForCommand, yamlConfigurationDE);
|
|
||||||
|
|
||||||
Config.set("Cost.Buy", MSG.DE_Buy, yamlConfigurationDE);
|
|
||||||
Config.set("Cost.NoMoney", MSG.DE_NoMoney, yamlConfigurationDE);
|
|
||||||
|
|
||||||
try {
|
|
||||||
yamlConfigurationDE.save(messagesDE);
|
|
||||||
} catch (IOException e) {
|
|
||||||
send.warning(Main.getPlugin(),e.getMessage());
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
send.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,44 +0,0 @@
|
|||||||
// This claas was created by JaTiTV
|
|
||||||
|
|
||||||
// -----------------------------
|
|
||||||
// _____ _____ _ _ _____
|
|
||||||
// / ____/ ____| | | |_ _|
|
|
||||||
// | | | | __| | | | | |
|
|
||||||
// | | | | |_ | | | | | |
|
|
||||||
// | |___| |__| | |__| |_| |_
|
|
||||||
// \_____\_____|\____/|_____|
|
|
||||||
// -----------------------------
|
|
||||||
|
|
||||||
package net.t2code.alias.Spigot.config.languages;
|
|
||||||
|
|
||||||
public class MSG {
|
|
||||||
|
|
||||||
// EN
|
|
||||||
|
|
||||||
public static String EN_OnlyForPlayer = "[prefix] <red>This command is for players only!</red>";
|
|
||||||
|
|
||||||
public static String EN_Disabled = "Unknown command. Type ''/help'' for help.";
|
|
||||||
|
|
||||||
public static String EN_ReloadStart = "[prefix] <gold>Plugin is reloaded...</gold>";
|
|
||||||
public static String EN_ReloadEnd = "[prefix] <dark_green>Plugin was successfully reloaded.</dark_green>";
|
|
||||||
|
|
||||||
public static String EN_NoPermissionForCommand = "[prefix] <red>For <aqua>[cmd]</aqua> you lack the permission <gold>[perm]</gold>!</red>";
|
|
||||||
|
|
||||||
public static String EN_Buy = "[prefix] <dark_green>You have paid <gold>[price]</gold> for this command.</dark_green>";
|
|
||||||
public static String EN_NoMoney = "[prefix] <red>You don't have enough money for this command!</red>";
|
|
||||||
|
|
||||||
|
|
||||||
// DE
|
|
||||||
public static String DE_OnlyForPlayer = "[prefix] <red>Dieser Command ist nur f[ue]r Spieler!</red>";
|
|
||||||
|
|
||||||
public static String DE_Disabled = "Unknown command. Type ''/help'' for help.";
|
|
||||||
|
|
||||||
public static String DE_ReloadStart = "[prefix] <gold>Plugin wird neu geladen...</gold>";
|
|
||||||
public static String DE_ReloadEnd = "[prefix] <dark_green>Plugin wurde erfolgreich neu geladen.</dark_green>";
|
|
||||||
|
|
||||||
public static String DE_NoPermissionForCommand = "[prefix] <red>F[ue]r <aqua>[cmd]</aqua> fehlt dir die Permission <gold>[perm]</gold>!</red>";
|
|
||||||
|
|
||||||
public static String DE_Buy = "[prefix] <dark_green>Du hast f[ue]r diesen Command <gold>[price]</gold> bezahlt.</dark_green>";
|
|
||||||
public static String DE_NoMoney = "[prefix] <red>Du hast nicht gen[ue]gend Geld für diesen Command!</red>";
|
|
||||||
|
|
||||||
}
|
|
@@ -1,64 +0,0 @@
|
|||||||
package net.t2code.alias.Spigot.config.languages;
|
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
|
||||||
import net.t2code.alias.Spigot.config.config.SelectConfig;
|
|
||||||
import net.t2code.alias.Util;
|
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
||||||
import net.t2code.lib.Spigot.Lib.replace.Replace;
|
|
||||||
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public class SelectMessages {
|
|
||||||
public static String selectMSG;
|
|
||||||
|
|
||||||
public static String onlyForPlayer;
|
|
||||||
public static String reloadStart;
|
|
||||||
public static String reloadEnd;
|
|
||||||
|
|
||||||
public static String noPermissionForCommand;
|
|
||||||
public static String aliasDisabled;
|
|
||||||
|
|
||||||
public static String buy;
|
|
||||||
public static String noMoney;
|
|
||||||
|
|
||||||
|
|
||||||
public static void onSelect(String Prefix) {
|
|
||||||
|
|
||||||
send.debug(Main.getPlugin(), "§4Select language...");
|
|
||||||
long long_ = System.currentTimeMillis();
|
|
||||||
|
|
||||||
File msg;
|
|
||||||
|
|
||||||
msg = new File(Main.getPath(), "languages/" + SelectConfig.language + "_messages.yml");
|
|
||||||
if (!msg.isFile()) {
|
|
||||||
send.console(Prefix);
|
|
||||||
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
send.console(Prefix + " §4The selected §c" + SelectConfig.language + " §4language file was not found.");
|
|
||||||
send.console(Prefix + " §6The default language §eEnglish §6is used!");
|
|
||||||
send.console(Prefix + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
|
||||||
send.console(Prefix);
|
|
||||||
msg = new File(Main.getPath(), "languages/" + "english_messages.yml");
|
|
||||||
selectMSG = "english";
|
|
||||||
} else selectMSG = SelectConfig.language;
|
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(msg);
|
|
||||||
|
|
||||||
if (yamlConfiguration.get("Plugin.Prefix") != null) {
|
|
||||||
Util.setPrefix(replace(yamlConfiguration.getString("Plugin.Prefix")));
|
|
||||||
}
|
|
||||||
onlyForPlayer = replace(yamlConfiguration.getString("Plugin.OnlyForPlayer"));
|
|
||||||
aliasDisabled = replace(yamlConfiguration.getString("Plugin.AliasDisabled"));
|
|
||||||
reloadStart = replace(yamlConfiguration.getString("Plugin.Reload.Start"));
|
|
||||||
reloadEnd = replace(yamlConfiguration.getString("Plugin.Reload.End"));
|
|
||||||
noPermissionForCommand = replace(yamlConfiguration.getString("Plugin.ForCommand"));
|
|
||||||
buy = replace(yamlConfiguration.getString("Cost.Buy"));
|
|
||||||
noMoney = replace(yamlConfiguration.getString("Cost.NoMoney"));
|
|
||||||
|
|
||||||
send.console(Prefix + " §2Language successfully selected to: §6" + selectMSG + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String replace(String text) {
|
|
||||||
return Replace.replace(Util.getPrefix(), text);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -2,8 +2,8 @@ package net.t2code.alias.Spigot.config.subAlias;
|
|||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import net.t2code.lib.Spigot.Lib.yamlConfiguration.Config;
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2Cconfig;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -15,53 +15,57 @@ public class CreateExampleSubAliasConfig {
|
|||||||
|
|
||||||
public static void configCreate() {
|
public static void configCreate() {
|
||||||
long long_ = System.currentTimeMillis();
|
long long_ = System.currentTimeMillis();
|
||||||
send.console(Util.getPrefix() + " §4SubAlias/aliasexample.yml are created...");
|
T2Csend.console(Util.getPrefix() + " §4SubAlias/aliasexample.yml are created...");
|
||||||
|
|
||||||
File config = new File(Main.getPath(), "SubAlias/aliasexample.yml");
|
File config = new File(Main.getPath(), "SubAlias/aliasexample.yml");
|
||||||
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
|
||||||
|
|
||||||
Config.set("SubAlias.Enable", true, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Enable", true, yamlConfiguration);
|
||||||
Config.set("SubAlias.SubAliasList", Arrays.asList("test"),yamlConfiguration);
|
T2Cconfig.set("SubAlias.SubAliasList", Arrays.asList("test"), yamlConfiguration);
|
||||||
Config.set("SubAlias.SubAliasFor", "aliasexample1",yamlConfiguration);
|
T2Cconfig.set("SubAlias.SubAliasFor", "aliasexample1", yamlConfiguration);
|
||||||
|
|
||||||
Config.set("SubAlias.Permission.Necessary", true, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Permission.Necessary", true, yamlConfiguration);
|
||||||
Config.set("SubAlias.Permission.Permission", "t2code.alias.use.subalias.<alias>", yamlConfiguration);
|
T2Cconfig.set("SubAlias.Permission.Permission", "t2c.alias.sub.use.[alias]", yamlConfiguration);
|
||||||
Config.set("SubAlias.Permission.CustomNoPermissionMSG", "", yamlConfiguration);
|
T2Cconfig.set("SubAlias.Permission.CustomNoPermissionMSG", "", yamlConfiguration);
|
||||||
|
|
||||||
Config.set("SubAlias.Cost.Enable", false,yamlConfiguration);
|
T2Cconfig.set("SubAlias.CooldownInSec.Global", 0, yamlConfiguration);
|
||||||
Config.set("SubAlias.Cost.Price", 0.0,yamlConfiguration);
|
T2Cconfig.set("SubAlias.CooldownInSec.Player", 0, yamlConfiguration);
|
||||||
Config.set("SubAlias.Cost.AllowByPass", true,yamlConfiguration);
|
|
||||||
|
|
||||||
Config.set("SubAlias.Command.Enable", true, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Cost.Enable", false, yamlConfiguration);
|
||||||
Config.set("SubAlias.Command.CommandAsConsole", true, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Cost.Confirm", true,yamlConfiguration);
|
||||||
Config.set("SubAlias.Command.BungeeCommand", false, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Cost.Price", 0.0, yamlConfiguration);
|
||||||
Config.set("SubAlias.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration);
|
T2Cconfig.set("SubAlias.Cost.AllowByPass", true, yamlConfiguration);
|
||||||
|
|
||||||
Config.set("SubAlias.Message.Enable", false, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Command.Enable", true, yamlConfiguration);
|
||||||
Config.set("SubAlias.Message.Messages", Collections.emptyList(), yamlConfiguration);
|
T2Cconfig.set("SubAlias.Command.CommandAsConsole", true, yamlConfiguration);
|
||||||
|
T2Cconfig.set("SubAlias.Command.BungeeCommand", false, yamlConfiguration);
|
||||||
|
T2Cconfig.set("SubAlias.Command.Commands", Arrays.asList("say hi"), yamlConfiguration);
|
||||||
|
|
||||||
Config.set("SubAlias.Admin.Enable", true, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Message.Enable", false, yamlConfiguration);
|
||||||
Config.set("SubAlias.Admin.Permission", "t2code.alias.admin", yamlConfiguration);
|
T2Cconfig.set("SubAlias.Message.Messages",Arrays.asList(), yamlConfiguration);
|
||||||
|
|
||||||
Config.set("SubAlias.Admin.Command.Enable", true, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Admin.Enable", false, yamlConfiguration);
|
||||||
Config.set("SubAlias.Admin.Command.CommandAsConsole", true, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Admin.Permission", "t2c.alias.admin", yamlConfiguration);
|
||||||
Config.set("SubAlias.Admin.Command.BungeeCommand", false, yamlConfiguration);
|
|
||||||
Config.set("SubAlias.Admin.Command.Commands", Collections.singletonList("say subalias hi"), yamlConfiguration);
|
|
||||||
|
|
||||||
Config.set("SubAlias.Admin.Message.Enable", false, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Admin.Command.Enable", true, yamlConfiguration);
|
||||||
Config.set("SubAlias.Admin.Message.Messages", Collections.emptyList(), yamlConfiguration);
|
T2Cconfig.set("SubAlias.Admin.Command.CommandAsConsole", true, yamlConfiguration);
|
||||||
|
T2Cconfig.set("SubAlias.Admin.Command.BungeeCommand", false, yamlConfiguration);
|
||||||
|
T2Cconfig.set("SubAlias.Admin.Command.Commands", Arrays.asList("say subalias hi"), yamlConfiguration);
|
||||||
|
|
||||||
Config.set("SubAlias.Console.Enable", false, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Admin.Message.Enable", false, yamlConfiguration);
|
||||||
Config.set("SubAlias.Console.Command.Enable", false, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Admin.Message.Messages",Arrays.asList(), yamlConfiguration);
|
||||||
Config.set("SubAlias.Console.Command.BungeeCommand", false, yamlConfiguration);
|
|
||||||
Config.set("SubAlias.Console.Command.Commands", Collections.emptyList(), yamlConfiguration);
|
T2Cconfig.set("SubAlias.Console.Enable", false, yamlConfiguration);
|
||||||
Config.set("SubAlias.Console.Message.Enable", false, yamlConfiguration);
|
T2Cconfig.set("SubAlias.Console.Command.Enable", false, yamlConfiguration);
|
||||||
Config.set("SubAlias.Console.Message.Messages", Collections.emptyList(), yamlConfiguration);
|
T2Cconfig.set("SubAlias.Console.Command.BungeeCommand", false, yamlConfiguration);
|
||||||
|
T2Cconfig.set("SubAlias.Console.Command.Commands",Arrays.asList(), yamlConfiguration);
|
||||||
|
T2Cconfig.set("SubAlias.Console.Message.Enable", false, yamlConfiguration);
|
||||||
|
T2Cconfig.set("SubAlias.Console.Message.Messages",Arrays.asList(), yamlConfiguration);
|
||||||
try {
|
try {
|
||||||
yamlConfiguration.save(config);
|
yamlConfiguration.save(config);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
send.console(Util.getPrefix() + " §2Alias/aliasexample.yml were successfully created." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
T2Csend.console(Util.getPrefix() + " §2Alias/aliasexample.yml were successfully created." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ import net.t2code.alias.Spigot.Main;
|
|||||||
import net.t2code.alias.Spigot.config.alias.AliasConfigConverter;
|
import net.t2code.alias.Spigot.config.alias.AliasConfigConverter;
|
||||||
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@@ -51,7 +51,7 @@ public class SelectSubAlias {
|
|||||||
if (subAliasFor != null) {
|
if (subAliasFor != null) {
|
||||||
String[] imp = subAliasFor.split(" ");
|
String[] imp = subAliasFor.split(" ");
|
||||||
if (!Main.allAliases.contains(imp[0])) {
|
if (!Main.allAliases.contains(imp[0])) {
|
||||||
send.error(Main.getPlugin(), "Den Alias " + imp[0] + " in der Datei " + config_gui.getName() + " existiert nicht!");
|
T2Csend.error(Main.getPlugin(), "The alias " + imp[0] + " in the file " + config_gui.getName() + " does not exist!");
|
||||||
}
|
}
|
||||||
String[] args = subAliasFor.split(" ");
|
String[] args = subAliasFor.split(" ");
|
||||||
subAliasArg = args.length - 1;
|
subAliasArg = args.length - 1;
|
||||||
@@ -66,7 +66,21 @@ public class SelectSubAlias {
|
|||||||
}
|
}
|
||||||
String permissionMSG = yamlConfiguration.getString("SubAlias.Permission.CustomNoPermissionMSG");
|
String permissionMSG = yamlConfiguration.getString("SubAlias.Permission.CustomNoPermissionMSG");
|
||||||
|
|
||||||
|
if (yamlConfiguration.get("SubAlias.CooldownInSec.Global") == null) {
|
||||||
|
AliasConfigConverter.convertAddCooldownInSecGlobal(yamlConfiguration, config_gui, true);
|
||||||
|
}
|
||||||
|
Integer cooldownGlobal = yamlConfiguration.getInt("SubAlias.CooldownInSec.Global");
|
||||||
|
|
||||||
|
if (yamlConfiguration.get("SubAlias.CooldownInSec.Player") == null) {
|
||||||
|
AliasConfigConverter.convertAddCooldownInSecPlayer(yamlConfiguration, config_gui, true);
|
||||||
|
}
|
||||||
|
Integer cooldownPlayer = yamlConfiguration.getInt("SubAlias.CooldownInSec.Player");
|
||||||
|
|
||||||
Boolean costEnable = yamlConfiguration.getBoolean("SubAlias.Cost.Enable");
|
Boolean costEnable = yamlConfiguration.getBoolean("SubAlias.Cost.Enable");
|
||||||
|
if (yamlConfiguration.get("SubAlias.Cost.Confirm") == null) {
|
||||||
|
AliasConfigConverter.convertAddCostConfirm(yamlConfiguration, config_gui, true);
|
||||||
|
}
|
||||||
|
Boolean costConfirm = yamlConfiguration.getBoolean("SubAlias.Cost.Confirm");
|
||||||
Double costPrice = yamlConfiguration.getDouble("SubAlias.Cost.Price");
|
Double costPrice = yamlConfiguration.getDouble("SubAlias.Cost.Price");
|
||||||
Boolean costAllowBypass = yamlConfiguration.getBoolean("SubAlias.Cost.AllowByPass");
|
Boolean costAllowBypass = yamlConfiguration.getBoolean("SubAlias.Cost.AllowByPass");
|
||||||
|
|
||||||
@@ -96,15 +110,17 @@ public class SelectSubAlias {
|
|||||||
Boolean consoleMessageEnable = yamlConfiguration.getBoolean("SubAlias.Console.Message.Enable");
|
Boolean consoleMessageEnable = yamlConfiguration.getBoolean("SubAlias.Console.Message.Enable");
|
||||||
List<String> consoleMessages = yamlConfiguration.getStringList("SubAlias.Console.Message.Messages");
|
List<String> consoleMessages = yamlConfiguration.getStringList("SubAlias.Console.Message.Messages");
|
||||||
|
|
||||||
SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, costEnable, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand,
|
SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, cooldownGlobal, cooldownPlayer, costEnable, costConfirm,
|
||||||
command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands,
|
costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand, command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole,
|
||||||
adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
|
adminBungeeCommand, adminCommands, adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
|
||||||
|
|
||||||
for (String sal : subAliasList) {
|
for (String sal : subAliasList) {
|
||||||
Main.subAliasHashMap.put(sal, subAlias);
|
Main.subAliasHashMap.put(sal, subAlias);
|
||||||
}
|
}
|
||||||
|
|
||||||
Main.allSubAliases.addAll(subAliasList);
|
Main.allSubAliases.addAll(subAliasList);
|
||||||
Main.allForSubAliases.add(subAliasFor);
|
Main.allForSubAliases.add(subAliasFor);
|
||||||
send.console(Prefix + " §aSubAlias file §e" + config_gui.getName() + " §awas loaded");
|
T2Csend.console(Prefix + " §aSubAlias file §e" + config_gui.getName() + " §awas loaded");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,42 @@
|
|||||||
|
package net.t2code.alias.Spigot.confirm;
|
||||||
|
|
||||||
|
import net.t2code.alias.Spigot.Main;
|
||||||
|
import net.t2code.alias.Spigot.cmdManagement.ExecuteAlias;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
public class ChatConfirm implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onChat(AsyncPlayerChatEvent e) {
|
||||||
|
String[] args = e.getMessage().split(" ");
|
||||||
|
if (args.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = e.getPlayer();
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "t2code-alias-confirm":
|
||||||
|
e.setCancelled(true);
|
||||||
|
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ExecuteAlias.storage(player, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "t2code-alias-cancel":
|
||||||
|
e.setCancelled(true);
|
||||||
|
Bukkit.getScheduler().runTask(Main.getPlugin(), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ExecuteAlias.storage(player, false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,32 @@
|
|||||||
|
package net.t2code.alias.Spigot.confirm.gui;
|
||||||
|
|
||||||
|
import net.t2code.alias.Spigot.Cache;
|
||||||
|
import net.t2code.alias.Spigot.Main;
|
||||||
|
import net.t2code.alias.Spigot.config.config.Config;
|
||||||
|
import net.t2code.alias.Spigot.config.config.Language;
|
||||||
|
import net.t2code.alias.Util;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemBuilder;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ConfirmGUI {
|
||||||
|
|
||||||
|
public static void open(Player player, Double price, String alias) {
|
||||||
|
Inventory inventory = Bukkit.createInventory((InventoryHolder) null, 9 * 3, (T2Creplace.replace(Util.getPrefix(), player,
|
||||||
|
Main.getGuiCode() + Language.confirmGuiTitle.value.replace("[price]",price+ " "+Config.buyCurrency.value).replace("[alias]", alias))));
|
||||||
|
|
||||||
|
T2CitemBuilder.fillItem((boolean) Config.buyConfirmGuiFillItemEnabled.value, (String) Config.buyConfirmGuiFillItem.value, 3, inventory);
|
||||||
|
|
||||||
|
T2CitemBuilder.setItem(12, 1, (String) Config.buyConfirmGuiConfirm.value, Language.confirmGuiConfirm.value,
|
||||||
|
(List<String>) T2Creplace.replace(Language.confirmGuiConfirmLore.valueList, "[price]", price + " " + Config.buyCurrency.value), inventory);
|
||||||
|
T2CitemBuilder.setItem(14, 1, (String) Config.buyConfirmGuiCancel.value, Language.confirmGuiCancel.value,
|
||||||
|
(List<String>) T2Creplace.replace(Language.confirmGuiCancelLore.valueList, "[price]", price + " " + Config.buyCurrency.value), inventory);
|
||||||
|
Cache.openPlayers.add(player.getUniqueId());
|
||||||
|
player.openInventory(inventory);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,40 @@
|
|||||||
|
package net.t2code.alias.Spigot.confirm.gui;
|
||||||
|
|
||||||
|
import net.t2code.alias.Spigot.Cache;
|
||||||
|
import net.t2code.alias.Spigot.cmdManagement.ExecuteAlias;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
|
||||||
|
public class GuiListener implements Listener {
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent e) {
|
||||||
|
Player player = (Player) e.getWhoClicked();
|
||||||
|
if (e.getInventory() == null) return;
|
||||||
|
if (e.getCurrentItem() == null) return;
|
||||||
|
|
||||||
|
if (!Cache.openPlayers.contains(player.getUniqueId())) return;
|
||||||
|
e.setCancelled(true);
|
||||||
|
if (e.getClickedInventory() != e.getWhoClicked().getOpenInventory().getTopInventory()) return;
|
||||||
|
switch (e.getSlot()) {
|
||||||
|
case 12:
|
||||||
|
Cache.openPlayers.remove(player.getUniqueId());
|
||||||
|
player.closeInventory();
|
||||||
|
ExecuteAlias.storage(player, true);
|
||||||
|
break;
|
||||||
|
case 14:
|
||||||
|
Cache.openPlayers.remove(player.getUniqueId());
|
||||||
|
player.closeInventory();
|
||||||
|
ExecuteAlias.storage(player, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryCloseEvent(InventoryCloseEvent e) {
|
||||||
|
Player player = (Player) e.getPlayer();
|
||||||
|
Cache.openPlayers.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
10
src/main/java/net/t2code/alias/Spigot/enums/ConfigParam.java
Normal file
10
src/main/java/net/t2code/alias/Spigot/enums/ConfigParam.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package net.t2code.alias.Spigot.enums;
|
||||||
|
|
||||||
|
public enum ConfigParam {
|
||||||
|
STRING,
|
||||||
|
INTEGER,
|
||||||
|
LIST,
|
||||||
|
BOOLEAN,
|
||||||
|
CONFIRMENUM,
|
||||||
|
SOUND
|
||||||
|
}
|
7
src/main/java/net/t2code/alias/Spigot/enums/Confirm.java
Normal file
7
src/main/java/net/t2code/alias/Spigot/enums/Confirm.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package net.t2code.alias.Spigot.enums;
|
||||||
|
|
||||||
|
public enum Confirm {
|
||||||
|
COMMAND,
|
||||||
|
CHAT,
|
||||||
|
GUI
|
||||||
|
}
|
@@ -1,8 +1,14 @@
|
|||||||
package net.t2code.alias.Spigot.objects;
|
package net.t2code.alias.Spigot.objects;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AliasObject {
|
public class AliasObject {
|
||||||
|
|
||||||
|
public HashMap<UUID, Long> cooldownPlayerMap = new HashMap<>();
|
||||||
|
public Long globalCooldownInt = 0L;
|
||||||
|
|
||||||
public Boolean aliasEnable;
|
public Boolean aliasEnable;
|
||||||
public List<String> aliasList;
|
public List<String> aliasList;
|
||||||
|
|
||||||
@@ -10,7 +16,11 @@ public class AliasObject {
|
|||||||
public String permission;
|
public String permission;
|
||||||
public String permissionMSG;
|
public String permissionMSG;
|
||||||
|
|
||||||
|
public Integer cooldownGlobal;
|
||||||
|
public Integer cooldownPlayer;
|
||||||
|
|
||||||
public Boolean costEnable;
|
public Boolean costEnable;
|
||||||
|
public Boolean costConfirm;
|
||||||
public Double costPrice;
|
public Double costPrice;
|
||||||
public Boolean costAllowBypass;
|
public Boolean costAllowBypass;
|
||||||
|
|
||||||
@@ -43,7 +53,11 @@ public class AliasObject {
|
|||||||
String permission,
|
String permission,
|
||||||
String permissionMSG,
|
String permissionMSG,
|
||||||
|
|
||||||
|
Integer cooldownGlobal,
|
||||||
|
Integer cooldownPlayer,
|
||||||
|
|
||||||
Boolean costEnable,
|
Boolean costEnable,
|
||||||
|
Boolean costConfirm,
|
||||||
Double costPrice,
|
Double costPrice,
|
||||||
Boolean costAllowBypass,
|
Boolean costAllowBypass,
|
||||||
|
|
||||||
@@ -75,7 +89,11 @@ public class AliasObject {
|
|||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
this.permissionMSG = permissionMSG;
|
this.permissionMSG = permissionMSG;
|
||||||
|
|
||||||
|
this.cooldownGlobal = cooldownGlobal;
|
||||||
|
this.cooldownPlayer = cooldownPlayer;
|
||||||
|
|
||||||
this.costEnable = costEnable;
|
this.costEnable = costEnable;
|
||||||
|
this.costConfirm = costConfirm;
|
||||||
this.costPrice = costPrice;
|
this.costPrice = costPrice;
|
||||||
this.costAllowBypass = costAllowBypass;
|
this.costAllowBypass = costAllowBypass;
|
||||||
|
|
||||||
|
@@ -0,0 +1,15 @@
|
|||||||
|
package net.t2code.alias.Spigot.objects;
|
||||||
|
|
||||||
|
public class AliasStorageObject {
|
||||||
|
public Object aliasObject;
|
||||||
|
public String alias;
|
||||||
|
public String[] args;
|
||||||
|
public boolean sub;
|
||||||
|
|
||||||
|
public AliasStorageObject( Object aliasObject, String alias, String[] args, boolean sub) {
|
||||||
|
this.aliasObject = aliasObject;
|
||||||
|
this.alias = alias;
|
||||||
|
this.args = args;
|
||||||
|
this.sub=sub;
|
||||||
|
}
|
||||||
|
}
|
15
src/main/java/net/t2code/alias/Spigot/objects/Cooldown.java
Normal file
15
src/main/java/net/t2code/alias/Spigot/objects/Cooldown.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package net.t2code.alias.Spigot.objects;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Cooldown {
|
||||||
|
|
||||||
|
public UUID player;
|
||||||
|
public Long long_;
|
||||||
|
|
||||||
|
public Cooldown(UUID player,
|
||||||
|
Long long_) {
|
||||||
|
this.player = player;
|
||||||
|
this.long_ = long_;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,8 +1,13 @@
|
|||||||
package net.t2code.alias.Spigot.objects;
|
package net.t2code.alias.Spigot.objects;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class SubAliasObject {
|
public class SubAliasObject {
|
||||||
|
public HashMap<UUID, Long> cooldownPlayerMap = new HashMap<>();
|
||||||
|
public Long globalCooldownInt = 0L;
|
||||||
|
|
||||||
public Boolean subAliasEnable;
|
public Boolean subAliasEnable;
|
||||||
public List<String> subAliasList;
|
public List<String> subAliasList;
|
||||||
public Integer subAliasArg;
|
public Integer subAliasArg;
|
||||||
@@ -12,7 +17,11 @@ public class SubAliasObject {
|
|||||||
public String permission;
|
public String permission;
|
||||||
public String permissionMSG;
|
public String permissionMSG;
|
||||||
|
|
||||||
|
public Integer cooldownGlobal;
|
||||||
|
public Integer cooldownPlayer;
|
||||||
|
|
||||||
public Boolean costEnable;
|
public Boolean costEnable;
|
||||||
|
public Boolean costConfirm;
|
||||||
public Double costPrice;
|
public Double costPrice;
|
||||||
public Boolean costAllowBypass;
|
public Boolean costAllowBypass;
|
||||||
|
|
||||||
@@ -47,7 +56,11 @@ public class SubAliasObject {
|
|||||||
String permission,
|
String permission,
|
||||||
String permissionMSG,
|
String permissionMSG,
|
||||||
|
|
||||||
|
Integer cooldownGlobal,
|
||||||
|
Integer cooldownPlayer,
|
||||||
|
|
||||||
Boolean costEnable,
|
Boolean costEnable,
|
||||||
|
Boolean costConfirm,
|
||||||
Double costPrice,
|
Double costPrice,
|
||||||
Boolean costAllowBypass,
|
Boolean costAllowBypass,
|
||||||
|
|
||||||
@@ -81,7 +94,11 @@ public class SubAliasObject {
|
|||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
this.permissionMSG = permissionMSG;
|
this.permissionMSG = permissionMSG;
|
||||||
|
|
||||||
|
this.cooldownGlobal = cooldownGlobal;
|
||||||
|
this.cooldownPlayer = cooldownPlayer;
|
||||||
|
|
||||||
this.costEnable = costEnable;
|
this.costEnable = costEnable;
|
||||||
|
this.costConfirm = costConfirm;
|
||||||
this.costPrice = costPrice;
|
this.costPrice = costPrice;
|
||||||
this.costAllowBypass = costAllowBypass;
|
this.costAllowBypass = costAllowBypass;
|
||||||
|
|
||||||
|
@@ -1,32 +1,87 @@
|
|||||||
package net.t2code.alias.Spigot.system;
|
package net.t2code.alias.Spigot.system;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.alias.Spigot.cmdManagement.AliasCmdExecuter;
|
|
||||||
import net.t2code.alias.Spigot.cmdManagement.RegisterCommands;
|
import net.t2code.alias.Spigot.cmdManagement.RegisterCommands;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.SimplePluginManager;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class AliasRegister {
|
public class AliasRegister {
|
||||||
public static void onRegister() {
|
public static void onRegister() {
|
||||||
for (String alias : Main.allAliases) {
|
try {
|
||||||
if (Main.aliasHashMap.get(alias) != null) {
|
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||||
if (alias.equals(" ")) continue;
|
bukkitCommandMap.setAccessible(true);
|
||||||
if (Main.aliasHashMap.get(alias).aliasEnable) {
|
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
|
||||||
try {
|
// onUnRegister(bukkitCommandMap);
|
||||||
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
for (String alias : Main.allAliases) {
|
||||||
bukkitCommandMap.setAccessible(true);
|
register(alias, commandMap);
|
||||||
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
|
// wrap(alias, commandMap);
|
||||||
commandMap.register(alias, new RegisterCommands(alias));
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
if (!(T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12())) {
|
||||||
}
|
// Main.getPlugin().getBukkitCommandWrap().sync();
|
||||||
} else send.warning(Main.getPlugin(), " §4AliasHashmap is null! - " + alias);
|
if (Bukkit.getOnlinePlayers().size() >= 1)
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public static void onUnRegister(Field bukkitCommandMap) throws IllegalAccessException {
|
||||||
|
//
|
||||||
|
// // if (Main.allAliases != null && !Main.allAliases.isEmpty()) {
|
||||||
|
// // if (!(Main.getPlugin().getBukkitCommandWrap() instanceof BukkitCommandWrap_Useless)) {
|
||||||
|
// // for (String alias : Main.allAliases) {
|
||||||
|
// // T2Csend.debugmsg(Main.getPlugin(),"uload: " + alias);
|
||||||
|
// // Main.getPlugin().
|
||||||
|
// // Main.getPlugin().getBukkitCommandWrap().unwrap(alias);
|
||||||
|
// // }
|
||||||
|
// // Main.getPlugin().getBukkitCommandWrap().sync();
|
||||||
|
// // if (Bukkit.getOnlinePlayers().size() >= 1)
|
||||||
|
// // for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// // commandMap.clearCommands();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// for (Map.Entry<String, Boolean> entry : Main.loadAliasHashMap.entrySet()) {
|
||||||
|
// ((SimpleCommandMap) bukkitCommandMap.get(simplePluginManager)).getCommand(entry.getKey()).unregister(bukkitCommandMap.get(Bukkit.getServer()));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// if (entry.getValue())
|
||||||
|
// Main.getPlugin().getBukkitCommandWrap().unwrap(entry.getKey());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Main.getPlugin().getBukkitCommandWrap().sync();
|
||||||
|
// if (Bukkit.getOnlinePlayers().size() >= 1)
|
||||||
|
// for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
|
||||||
|
// Main.loadAliasHashMap.clear();
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
private static void register(String alias, CommandMap commandMap) {
|
||||||
|
if (Main.aliasHashMap.get(alias) != null) {
|
||||||
|
if (alias.equals(" ")) return;
|
||||||
|
if (Main.aliasHashMap.get(alias).aliasEnable) {
|
||||||
|
commandMap.register(alias, new RegisterCommands(alias));
|
||||||
|
T2Csend.console(Util.getPrefix() + " §aAlias §e" + alias + " §aregister");
|
||||||
|
Main.loadAliasHashMap.put(alias, true);
|
||||||
|
} else Main.loadAliasHashMap.put(alias, false);
|
||||||
|
} else T2Csend.warning(Main.getPlugin(), " §4AliasHashmap is null! - " + alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,54 @@
|
|||||||
package net.t2code.alias.Spigot.system;
|
package net.t2code.alias.Spigot.system;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
import net.t2code.lib.Spigot.Lib.register.Register;
|
import net.t2code.alias.Spigot.objects.AliasObject;
|
||||||
|
import net.t2code.alias.Spigot.objects.SubAliasObject;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
|
||||||
public class AliasRegisterPermissions {
|
public class AliasRegisterPermissions {
|
||||||
|
|
||||||
public static void onPermRegister() {
|
public static void onPermRegister() {
|
||||||
for (String alias : Main.allAliases){
|
|
||||||
if (Bukkit.getPluginManager().getPermission("t2code.alias.use." + alias.toLowerCase()) == null) {
|
for (AliasObject aliasObject : Main.aliasHashMap.values()) {
|
||||||
Register.permission("t2code.alias.use." + alias.toLowerCase(), Main.getPlugin());
|
|
||||||
|
for (String alias : aliasObject.aliasList) {
|
||||||
|
if (aliasObject.permission != null && Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("[alias]", alias).toLowerCase()) == null) {
|
||||||
|
T2Cregister.permission(aliasObject.permission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
|
||||||
|
}
|
||||||
|
if (aliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("[alias]", alias).toLowerCase()) == null) {
|
||||||
|
T2Cregister.permission(aliasObject.adminPermission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPermission("t2c.alias.buy." + alias.toLowerCase() + ".bypass") == null) {
|
||||||
|
T2Cregister.permission("t2c.alias.buy." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPermission("t2c.alias.cooldown.global." + alias.toLowerCase() + ".bypass") == null) {
|
||||||
|
T2Cregister.permission("t2c.alias.cooldown.global." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPermission("t2c.alias.cooldown.player." + alias.toLowerCase() + ".bypass") == null) {
|
||||||
|
T2Cregister.permission("t2c.alias.cooldown.player." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (SubAliasObject subAliasObject : Main.subAliasHashMap.values()) {
|
||||||
|
for (String alias : subAliasObject.subAliasList) {
|
||||||
|
if (subAliasObject.permission != null && Bukkit.getPluginManager().getPermission(subAliasObject.permission.replace("[alias]", alias).toLowerCase()) == null) {
|
||||||
|
T2Cregister.permission(subAliasObject.permission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
|
||||||
|
}
|
||||||
|
if (subAliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("[alias]", alias).toLowerCase()) == null) {
|
||||||
|
T2Cregister.permission(subAliasObject.adminPermission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.buy." + alias.toLowerCase() + ".bypass") == null) {
|
||||||
|
T2Cregister.permission("t2c.alias.sub.buy." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass") == null) {
|
||||||
|
T2Cregister.permission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
|
||||||
|
}
|
||||||
|
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass") == null) {
|
||||||
|
T2Cregister.permission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package net.t2code.alias.Spigot.system;
|
package net.t2code.alias.Spigot.system;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
import net.t2code.alias.Spigot.Main;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -12,31 +13,7 @@ import java.io.IOException;
|
|||||||
public class BCommandSenderReciver {
|
public class BCommandSenderReciver {
|
||||||
|
|
||||||
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
|
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
T2CbungeeCommandSenderReciver.sendToBungee(sender,information,console);
|
||||||
DataOutputStream output = new DataOutputStream(stream);
|
|
||||||
try {
|
|
||||||
if (console) {
|
|
||||||
output.writeUTF("T2Code-Console");
|
|
||||||
} else {
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
output.writeUTF(sender.getName());
|
|
||||||
} else {
|
|
||||||
output.writeUTF("T2Code-Console");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
output.writeUTF(information);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
player.sendPluginMessage(Main.getPlugin(), "t2codealias:bungee", stream.toByteArray());
|
|
||||||
}else {
|
|
||||||
for(Player player : Bukkit.getOnlinePlayers()){
|
|
||||||
player.sendPluginMessage(Main.getPlugin(), "t2codealias:bungee", stream.toByteArray());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,22 +0,0 @@
|
|||||||
// This claas was created by JaTiTV
|
|
||||||
|
|
||||||
package net.t2code.alias.Spigot.system;
|
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
|
||||||
import net.t2code.alias.Util;
|
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
|
||||||
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
|
||||||
import net.t2code.lib.Spigot.system.config.SelectLibConfig;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
public class JoinEvent implements Listener {
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onJoinEvent(PlayerLoginEvent event) {
|
|
||||||
UpdateAPI.join(Main.getPlugin(),Util.getPrefix(), "t2code.alias.updatemsg", event.getPlayer(), Util.getSpigot(), Util.getDiscord());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -5,39 +5,50 @@ import net.t2code.alias.Spigot.cmdManagement.AliasCmdExecuter;
|
|||||||
import net.t2code.alias.Spigot.cmdManagement.TabEvent;
|
import net.t2code.alias.Spigot.cmdManagement.TabEvent;
|
||||||
import net.t2code.alias.Spigot.config.alias.CreateExampleAliasConfig;
|
import net.t2code.alias.Spigot.config.alias.CreateExampleAliasConfig;
|
||||||
import net.t2code.alias.Spigot.config.alias.SelectAlias;
|
import net.t2code.alias.Spigot.config.alias.SelectAlias;
|
||||||
import net.t2code.alias.Spigot.config.config.*;
|
import net.t2code.alias.Spigot.config.config.Config;
|
||||||
import net.t2code.alias.Spigot.config.languages.LanguagesCreate;
|
import net.t2code.alias.Spigot.config.config.FileSelect;
|
||||||
import net.t2code.alias.Spigot.config.languages.SelectMessages;
|
|
||||||
import net.t2code.alias.Spigot.config.subAlias.CreateExampleSubAliasConfig;
|
import net.t2code.alias.Spigot.config.subAlias.CreateExampleSubAliasConfig;
|
||||||
import net.t2code.alias.Spigot.config.subAlias.SelectSubAlias;
|
import net.t2code.alias.Spigot.config.subAlias.SelectSubAlias;
|
||||||
|
import net.t2code.alias.Spigot.confirm.ChatConfirm;
|
||||||
|
import net.t2code.alias.Spigot.confirm.gui.GuiListener;
|
||||||
|
import net.t2code.alias.Spigot.enums.Confirm;
|
||||||
import net.t2code.alias.Util;
|
import net.t2code.alias.Util;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate;
|
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
|
||||||
import net.t2code.lib.Spigot.Lib.messages.send;
|
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
|
||||||
import net.t2code.lib.Spigot.Lib.register.Register;
|
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||||
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
|
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Load {
|
public class Load {
|
||||||
private static Main plugin = Main.getPlugin();
|
private static final Main plugin = Main.getPlugin();
|
||||||
|
|
||||||
public static void onLoad(String prefix, List autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
|
public static void onLoad(String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID) {
|
||||||
Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
Long long_ = T2Ctemplate.onLoadHeader(prefix, autor, version, spigot, discord);
|
||||||
plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter());
|
plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter());
|
||||||
loadReload();
|
loadReload();
|
||||||
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
|
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(),
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
|
(Boolean) Config.updateCheckOnJoin.value, (Boolean) Config.updateCheckSeePreReleaseUpdates.value, (Integer) Config.updateCheckTimeInterval.value);
|
||||||
|
|
||||||
T2CodeTemplate.onLoadFooter(prefix, long_, version);
|
T2Ctemplate.onLoadFooter(prefix, long_);
|
||||||
|
T2Cregister.listener(new PluginEvents(), plugin);
|
||||||
Metrics.Bstats(plugin, bstatsID);
|
Metrics.Bstats(plugin, bstatsID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ChatConfirm chatListener;
|
||||||
|
private static GuiListener guiListener;
|
||||||
|
|
||||||
public static void loadReload() {
|
public static void loadReload() {
|
||||||
if (!new File(Main.getPath(), "config.yml").exists()) {
|
HandlerList.unregisterAll(chatListener);
|
||||||
|
HandlerList.unregisterAll(guiListener);
|
||||||
|
boolean newInstall = !new File(Main.getPath(), "config.yml").exists();
|
||||||
|
FileSelect.config();
|
||||||
|
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
|
||||||
|
FileSelect.language();
|
||||||
|
if (newInstall) {
|
||||||
try {
|
try {
|
||||||
CreateExampleAliasConfig.configCreate();
|
CreateExampleAliasConfig.configCreate();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -49,32 +60,38 @@ public class Load {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
plugin.saveResource("Alias/X_aliasDeclaration_X.yml", true);
|
plugin.saveResource("Alias/X_aliasDeclaration_X.yml", true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
plugin.saveResource("X_configDeclaration_X.yml", true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
plugin.saveResource("SubAlias/X_subAliasDeclaration_X.yml", true);
|
plugin.saveResource("SubAlias/X_subAliasDeclaration_X.yml", true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
CreateConfig.configCreate();
|
|
||||||
LanguagesCreate.langCreate();
|
|
||||||
SelectConfig.onSelect();
|
|
||||||
SelectMessages.onSelect(Util.getPrefix());
|
|
||||||
T2CodeTemplate.onLoadSeparateStroke(Util.getPrefix());
|
|
||||||
SelectAlias.onSelect();
|
|
||||||
T2CodeTemplate.onLoadSeparateStroke(Util.getPrefix());
|
|
||||||
SelectSubAlias.onSelect();
|
|
||||||
SelectConfig.setConfigVersion();
|
|
||||||
if (SelectConfig.subAliasTab) {
|
|
||||||
Register.listener(new TabEvent(), plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SelectConfig.Bungee) {
|
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
|
||||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
SelectAlias.onSelect();
|
||||||
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2codealias:bungee");
|
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
|
||||||
|
SelectSubAlias.onSelect();
|
||||||
|
if ((Boolean) Config.subAliasTab.value) {
|
||||||
|
T2Cregister.listener(new TabEvent(), plugin);
|
||||||
|
}
|
||||||
|
chatListener = new ChatConfirm();
|
||||||
|
if (Config.buyConfirmDefault.value == Confirm.CHAT) T2Cregister.listener(chatListener, plugin);
|
||||||
|
guiListener = new GuiListener();
|
||||||
|
if (Config.buyConfirmDefault.value == Confirm.GUI) T2Cregister.listener(guiListener, plugin);
|
||||||
|
if (T2CLibConfig.getBungee()) {
|
||||||
|
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
|
||||||
}
|
}
|
||||||
AliasRegisterPermissions.onPermRegister();
|
AliasRegisterPermissions.onPermRegister();
|
||||||
}
|
}
|
||||||
|
@@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
|
|
||||||
package net.t2code.alias.Spigot.system;
|
package net.t2code.alias.Spigot.system;
|
||||||
|
|
||||||
import net.t2code.alias.Spigot.Main;
|
|
||||||
import net.t2code.alias.Spigot.config.config.SelectConfig;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -34,7 +31,6 @@ public class Metrics {
|
|||||||
public static void Bstats(Plugin plugin, int bstatsID) {
|
public static void Bstats(Plugin plugin, int bstatsID) {
|
||||||
int pluginId = bstatsID; // <-- Replace with the id of your plugin!
|
int pluginId = bstatsID; // <-- Replace with the id of your plugin!
|
||||||
Metrics metrics = new Metrics((JavaPlugin) plugin, pluginId);
|
Metrics metrics = new Metrics((JavaPlugin) plugin, pluginId);
|
||||||
metrics.addCustomChart(new SimplePie("updatecheckonjoin", () -> String.valueOf(SelectConfig.UpdateCheckOnJoin)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
|
@@ -0,0 +1,27 @@
|
|||||||
|
package net.t2code.alias.Spigot.system;
|
||||||
|
|
||||||
|
import net.t2code.alias.Spigot.Cache;
|
||||||
|
import net.t2code.alias.Spigot.Main;
|
||||||
|
import net.t2code.alias.Spigot.cmdManagement.ExecuteAlias;
|
||||||
|
import net.t2code.alias.Spigot.confirm.gui.ConfirmGUI;
|
||||||
|
import net.t2code.alias.Util;
|
||||||
|
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class PluginEvents implements Listener {
|
||||||
|
@EventHandler
|
||||||
|
public void onJoinEvent(PlayerQuitEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Cache.aliasStorage.remove(player.getUniqueId());
|
||||||
|
Cache.openPlayers.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onJoinEvent(PlayerLoginEvent event) {
|
||||||
|
T2CupdateAPI.join(Main.getPlugin(), Util.getPrefix(), "t2c.alias.updatemsg", event.getPlayer(), Util.getSpigotID(), Util.getDiscord());
|
||||||
|
}
|
||||||
|
}
|
@@ -1,38 +1,47 @@
|
|||||||
package net.t2code.alias;
|
package net.t2code.alias;
|
||||||
|
|
||||||
public class Util {
|
public class Util {
|
||||||
private static String requiredT2CodeLibVersion = "12.4";
|
|
||||||
private static String Prefix = "§8[§4T2Code§7-§aAlias§8]";
|
|
||||||
private static Integer SpigotID = 96389;
|
public static String getInfoText() {
|
||||||
private static Integer BstatsID = 12517;
|
return "";
|
||||||
private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
|
}
|
||||||
private static String Discord = "http://dc.t2code.net";
|
|
||||||
|
|
||||||
public static String getRequiredT2CodeLibVersion() {
|
public static String getRequiredT2CodeLibVersion() {
|
||||||
return requiredT2CodeLibVersion;
|
return "15.7";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPrefix() {
|
public static String getPrefix() {
|
||||||
return Prefix;
|
return prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getSpigotID() {
|
public static Integer getSpigotID() {
|
||||||
return SpigotID;
|
return 96389;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getGit() {
|
||||||
|
return "JaTiTV/T2Code-Alias";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getBstatsID() {
|
public static Integer getBstatsID() {
|
||||||
return BstatsID;
|
return 12517;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSpigot() {
|
public static String getSpigot() {
|
||||||
return Spigot;
|
return "https://www.spigotmc.org/resources/" + getSpigotID();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDiscord() {
|
public static String getDiscord() {
|
||||||
return Discord;
|
return "http://dc.t2code.net";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPrefix(String prefix) {
|
public static void setPrefix(String pr) {
|
||||||
Prefix = prefix;
|
prefix = pr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String prefix = "§8[§4T2Code§7-§aAlias§8]";
|
||||||
|
|
||||||
|
public static Integer getConfigVersion() {
|
||||||
|
return 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
####################################################################
|
####################################################################
|
||||||
## The alias command is no longer the filename! ##
|
## This is an example file and serves only for the explanation ##
|
||||||
## Multiple alias commands can now be specified in one file, ##
|
## of the individual options. ##
|
||||||
## so there is no need to create multiple files! ##
|
## Changes in this file are not considered and will be reset! ##
|
||||||
## This option is under 'Alias.AliasList' ##
|
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
Alias:
|
Alias:
|
||||||
@@ -12,22 +11,43 @@ Alias:
|
|||||||
AliasList:
|
AliasList:
|
||||||
- aliasexample1
|
- aliasexample1
|
||||||
- aliasexample2
|
- aliasexample2
|
||||||
|
-
|
||||||
Permission:
|
Permission:
|
||||||
# Here you can say if a permission is needed to use the alias#
|
# Here you can say if a permission is needed to use the alias#
|
||||||
Necessary: true
|
Necessary: true
|
||||||
# Here you can set the permission for the alias.
|
# Here you can set the permission for the alias.
|
||||||
# The placeholder <alias> is the alias name.
|
# The placeholder <[alias] is the alias name.
|
||||||
# If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias.
|
# If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias.
|
||||||
Permission: 't2code.alias.use.<alias>'
|
Permission: 't2c.alias.use.[alias]'
|
||||||
# Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank.
|
# Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank.
|
||||||
CustomNoPermissionMSG: ""
|
CustomNoPermissionMSG: ""
|
||||||
|
|
||||||
|
CooldownInSec:
|
||||||
|
# Here you can set a global cooldown for this alias.
|
||||||
|
# The value corresponds to the seconds.
|
||||||
|
# At 0, the cooldown is deactivated.
|
||||||
|
# The placeholder [alias] is the alias name.
|
||||||
|
# Bypass permission: t2c.alias.cooldown.global.[alias].bypass
|
||||||
|
# (The global cooldown is above the player cooldown).
|
||||||
|
Global: 0
|
||||||
|
# Here you can set a player-specific cooldown for this alias.
|
||||||
|
# The value corresponds to the seconds.
|
||||||
|
# At 0, the cooldown is deactivated.
|
||||||
|
# The placeholder [alias] is the alias name.
|
||||||
|
# Bypass permission: t2c.alias.cooldown.player.[alias].bypass
|
||||||
|
Player: 0
|
||||||
|
|
||||||
Cost:
|
Cost:
|
||||||
# Here you can say if you have to pay for the alias
|
# Here you can say if you have to pay for the alias
|
||||||
Enable: false
|
Enable: false
|
||||||
# Here you set the price
|
# Here you set the price
|
||||||
Price: 0.0
|
Price: 0.0
|
||||||
# Here you define if the bypass is activated or if you have to pay despite the bypass (t2code.alias.buy.bypass).
|
# Here you define if the bypass is activated or if you have to pay despite the bypass (t2c.alias.buy.[alias].bypass).
|
||||||
AllowByPass: true
|
AllowByPass: true
|
||||||
|
# Here you can set if you have to confirm if you want to pay before executing the command
|
||||||
|
# In the config.yml you can set under 'buy.confirm.use' if a command, a chatListener or a GUI should be used to confirm the command.
|
||||||
|
Confirm: true
|
||||||
|
|
||||||
Command:
|
Command:
|
||||||
# Here you can tell the alias to execute one or more commands
|
# Here you can tell the alias to execute one or more commands
|
||||||
Enable: false
|
Enable: false
|
||||||
@@ -39,7 +59,8 @@ Alias:
|
|||||||
BungeeCommand: false
|
BungeeCommand: false
|
||||||
# Here you can specify one or more commands to be executed.
|
# Here you can specify one or more commands to be executed.
|
||||||
# Placeholder: [player] = The player who executes the alias
|
# Placeholder: [player] = The player who executes the alias
|
||||||
Commands: [ ]
|
Commands: []
|
||||||
|
|
||||||
Message:
|
Message:
|
||||||
# Here you can specify whether the player should receive a message.
|
# Here you can specify whether the player should receive a message.
|
||||||
Enable: false
|
Enable: false
|
||||||
@@ -65,7 +86,7 @@ Alias:
|
|||||||
# You can also use MiniMessage:
|
# You can also use MiniMessage:
|
||||||
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html
|
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html
|
||||||
# WebUI: https://webui.adventure.kyori.net
|
# WebUI: https://webui.adventure.kyori.net
|
||||||
Messages: [ ]
|
Messages: []
|
||||||
|
|
||||||
# Here you can specify that players with the permission () have a different function than other players.
|
# Here you can specify that players with the permission () have a different function than other players.
|
||||||
# For example, you can say that players should come to a certain point and players with the admin function only to the server to the position where they were before.
|
# For example, you can say that players should come to a certain point and players with the admin function only to the server to the position where they were before.
|
||||||
@@ -74,9 +95,11 @@ Alias:
|
|||||||
# Player with Admin Perm: /server CityBuild
|
# Player with Admin Perm: /server CityBuild
|
||||||
Admin:
|
Admin:
|
||||||
# Here you can enable or disable the admin function
|
# Here you can enable or disable the admin function
|
||||||
Enable: true
|
Enable: false
|
||||||
# Here you set the permission for the admin function
|
# Here you set the permission for the admin function
|
||||||
Permission: t2code.alias.admin
|
# The placeholder [alias] is the alias name.
|
||||||
|
# If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias.
|
||||||
|
Permission: t2c.alias.[alias].admin
|
||||||
Command:
|
Command:
|
||||||
# Here you can tell the alias to execute one or more commands
|
# Here you can tell the alias to execute one or more commands
|
||||||
Enable: false
|
Enable: false
|
||||||
@@ -88,7 +111,8 @@ Alias:
|
|||||||
BungeeCommand: false
|
BungeeCommand: false
|
||||||
# Here you can specify one or more commands to be executed.
|
# Here you can specify one or more commands to be executed.
|
||||||
# Placeholder: [player] = The player who executes the alias
|
# Placeholder: [player] = The player who executes the alias
|
||||||
Commands: [ ]
|
Commands: []
|
||||||
|
|
||||||
Message:
|
Message:
|
||||||
# Here you can specify whether the player should receive a message.
|
# Here you can specify whether the player should receive a message.
|
||||||
Enable: false
|
Enable: false
|
||||||
@@ -114,7 +138,7 @@ Alias:
|
|||||||
# You can also use MiniMessage:
|
# You can also use MiniMessage:
|
||||||
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html
|
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html
|
||||||
# WebUI: https://webui.adventure.kyori.net
|
# WebUI: https://webui.adventure.kyori.net
|
||||||
Messages: [ ]
|
Messages: []
|
||||||
|
|
||||||
Console:
|
Console:
|
||||||
# Here you can define if the alias is also usable in the console and what it should do from there.
|
# Here you can define if the alias is also usable in the console and what it should do from there.
|
||||||
@@ -126,9 +150,9 @@ Alias:
|
|||||||
# For this option, BungeeCord must be set to true in config.yml and the plugin must also work on the proxy as a bridge.
|
# For this option, BungeeCord must be set to true in config.yml and the plugin must also work on the proxy as a bridge.
|
||||||
BungeeCommand: false
|
BungeeCommand: false
|
||||||
# Here you can specify one or more commands to be executed.
|
# Here you can specify one or more commands to be executed.
|
||||||
Commands: [ ]
|
Commands: []
|
||||||
Message:
|
Message:
|
||||||
# Here you can specify whether the player should receive a message.
|
# Here you can specify whether the player should receive a message.
|
||||||
Enable: false
|
Enable: false
|
||||||
# Specify here the message that the player should get.
|
# Specify here the message that the player should get.
|
||||||
Messages: [ ]
|
Messages: []
|
@@ -1,4 +1,8 @@
|
|||||||
#
|
####################################################################
|
||||||
|
## This is an example file and serves only for the explanation ##
|
||||||
|
## of the individual options. ##
|
||||||
|
## Changes in this file are not considered and will be reset! ##
|
||||||
|
####################################################################
|
||||||
|
|
||||||
SubAlias:
|
SubAlias:
|
||||||
# Here you can disable the alias
|
# Here you can disable the alias
|
||||||
@@ -10,24 +14,43 @@ SubAlias:
|
|||||||
# For example:
|
# For example:
|
||||||
# - aliasexample1 -> aliasexample1 <this SubAlias>
|
# - aliasexample1 -> aliasexample1 <this SubAlias>
|
||||||
# - aliasexample2 test -> aliasexample2 test <this SubAlias>
|
# - aliasexample2 test -> aliasexample2 test <this SubAlias>
|
||||||
SubAliasFor:
|
SubAliasFor: aliasexample1
|
||||||
- aliasexample1
|
|
||||||
Permission:
|
Permission:
|
||||||
# Here you can say if a permission is needed to use the alias#
|
# Here you can say if a permission is needed to use the alias#
|
||||||
Necessary: true
|
Necessary: true
|
||||||
# Here you can set the permission for the alias.
|
# Here you can set the permission for the alias.
|
||||||
# The placeholder <alias> is the alias name.
|
# The placeholder [alias] is the subalias name.
|
||||||
# If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias.
|
# If you have set multiple alias referrers in the list 'Alias.SubAliasList' you have a permission for each alias.
|
||||||
Permission: 't2code.alias.use.subalias.<alias>'
|
Permission: 't2c.subalias.use.[alias]'
|
||||||
# Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank.
|
# Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank.
|
||||||
CustomNoPermissionMSG: ""
|
CustomNoPermissionMSG: ""
|
||||||
|
|
||||||
|
CooldownInSec:
|
||||||
|
# Here you can set a global cooldown for this alias.
|
||||||
|
# The value corresponds to the seconds.
|
||||||
|
# At 0, the cooldown is deactivated.
|
||||||
|
# The placeholder [alias] is the subalias name.
|
||||||
|
# Bypass permission: t2c.alias.sub.cooldown.global.[alias].bypass
|
||||||
|
# (The global cooldown is above the player cooldown).
|
||||||
|
Global: 0
|
||||||
|
# Here you can set a player-specific cooldown for this alias.
|
||||||
|
# The value corresponds to the seconds.
|
||||||
|
# At 0, the cooldown is deactivated.
|
||||||
|
# The placeholder [alias] is the subalias name.
|
||||||
|
# Bypass permission: t2c.alias.sub.cooldown.player.[alias].bypass
|
||||||
|
Player: 0
|
||||||
|
|
||||||
Cost:
|
Cost:
|
||||||
# Here you can say if you have to pay for the alias
|
# Here you can say if you have to pay for the alias
|
||||||
Enable: false
|
Enable: false
|
||||||
# Here you set the price
|
# Here you set the price
|
||||||
Price: 0.0
|
Price: 0.0
|
||||||
# Here you define if the bypass is activated or if you have to pay despite the bypass (t2code.alias.buy.bypass).
|
# Here you define if the bypass is activated or if you have to pay despite the bypass (t2c.alias.buy.[alias].bypass).
|
||||||
AllowByPass: true
|
AllowByPass: true
|
||||||
|
# Here you can set if you have to confirm if you want to pay before executing the command
|
||||||
|
# In the config.yml you can set under 'buy.confirm.use' if a command, a chatListener or a GUI should be used to confirm the command.
|
||||||
|
Confirm: true
|
||||||
|
|
||||||
Command:
|
Command:
|
||||||
# Here you can tell the alias to execute one or more commands
|
# Here you can tell the alias to execute one or more commands
|
||||||
Enable: false
|
Enable: false
|
||||||
@@ -40,6 +63,7 @@ SubAlias:
|
|||||||
# Here you can specify one or more commands to be executed.
|
# Here you can specify one or more commands to be executed.
|
||||||
# Placeholder: [player] = The player who executes the alias
|
# Placeholder: [player] = The player who executes the alias
|
||||||
Commands: []
|
Commands: []
|
||||||
|
|
||||||
Message:
|
Message:
|
||||||
# Here you can specify whether the player should receive a message.
|
# Here you can specify whether the player should receive a message.
|
||||||
Enable: false
|
Enable: false
|
||||||
@@ -74,9 +98,11 @@ SubAlias:
|
|||||||
# Player with Admin Perm: /server CityBuild
|
# Player with Admin Perm: /server CityBuild
|
||||||
Admin:
|
Admin:
|
||||||
# Here you can enable or disable the admin function
|
# Here you can enable or disable the admin function
|
||||||
Enable: true
|
Enable: false
|
||||||
# Here you set the permission for the admin function
|
# Here you set the permission for the admin function
|
||||||
Permission: t2code.alias.admin
|
# The placeholder [alias] is the alias name.
|
||||||
|
# If you have set multiple alias referrers in the list 'Alias.SubAliasList' you have a permission for each alias.
|
||||||
|
Permission: t2c.alias.sub.[alias].admin
|
||||||
Command:
|
Command:
|
||||||
# Here you can tell the alias to execute one or more commands
|
# Here you can tell the alias to execute one or more commands
|
||||||
Enable: false
|
Enable: false
|
||||||
@@ -89,6 +115,7 @@ SubAlias:
|
|||||||
# Here you can specify one or more commands to be executed.
|
# Here you can specify one or more commands to be executed.
|
||||||
# Placeholder: [player] = The player who executes the alias
|
# Placeholder: [player] = The player who executes the alias
|
||||||
Commands: []
|
Commands: []
|
||||||
|
|
||||||
Message:
|
Message:
|
||||||
# Here you can specify whether the player should receive a message.
|
# Here you can specify whether the player should receive a message.
|
||||||
Enable: false
|
Enable: false
|
||||||
|
44
src/main/resources/X_configDeclaration_X.yml
Normal file
44
src/main/resources/X_configDeclaration_X.yml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
####################################################################
|
||||||
|
## This is an example file and serves only for the explanation ##
|
||||||
|
## of the individual options. ##
|
||||||
|
## Changes in this file are not considered and will be reset! ##
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
# This option is only used for updates and file conversions.
|
||||||
|
configVersion: 4
|
||||||
|
plugin:
|
||||||
|
# In this option you can set the language of the plugin.
|
||||||
|
language: english
|
||||||
|
updateCheck:
|
||||||
|
# In this option you can set if players with the permission 't2c.alias.updatemsg' will get an update message on join when an update for the plugin is available.
|
||||||
|
onJoin: true
|
||||||
|
# In this option you can set whether you want to receive and display beta and snapshot versions in the update check.
|
||||||
|
seePreReleaseUpdates: true
|
||||||
|
# In this option you can set the time interval in minutes in which updates should be checked.
|
||||||
|
timeInterval: 60
|
||||||
|
buy:
|
||||||
|
# With this option you can set whether a confirmation should be sent after the payment for an alias for which you have to pay.
|
||||||
|
message: true
|
||||||
|
# With this option you set the currency.
|
||||||
|
currency: $
|
||||||
|
confirm:
|
||||||
|
# Here you can choose which confirmation method you want to use. (COMMAND, CHAT, GUI)
|
||||||
|
use: COMMAND
|
||||||
|
gui:
|
||||||
|
#
|
||||||
|
# !! You can change the GUI name and the button texts in the language file !!
|
||||||
|
#
|
||||||
|
fillItem:
|
||||||
|
# Here you can set if a fillitem should be used in the Confirm GUI.
|
||||||
|
enabled: true
|
||||||
|
# Here you can set which fillitem should be used in the Confirm GUI
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
confirm:
|
||||||
|
# Here you can set the material for the confirmation button.
|
||||||
|
material: GREEN_WOOL
|
||||||
|
cancel:
|
||||||
|
# Here you can set the material for the cancel button.
|
||||||
|
material: RED_WOOL
|
||||||
|
subAlias:
|
||||||
|
# Here you can set if subcommands should be displayed as tabComplete
|
||||||
|
tabComplete: true
|
@@ -1,6 +0,0 @@
|
|||||||
name: T2C-Alias
|
|
||||||
version: ${project.version}
|
|
||||||
main: net.t2code.alias.Bungee.BMain
|
|
||||||
description: T2Code Alias Plugin
|
|
||||||
author: JaTiTV
|
|
||||||
softdepends: [T2CodeLib]
|
|
@@ -16,20 +16,39 @@ commands:
|
|||||||
aliases: [t2c-a, alias]
|
aliases: [t2c-a, alias]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
t2code.alias.admin:
|
t2c.alias.admin:
|
||||||
default: op
|
default: op
|
||||||
children:
|
children:
|
||||||
t2code.alias.updatemsg: true
|
t2c.alias.updatemsg: true
|
||||||
t2code.alias.command.reload: true
|
t2c.alias.command.reload: true
|
||||||
t2code.alias.command.info: true
|
t2c.alias.command.info: true
|
||||||
t2code.alias.buy.bypass: true
|
|
||||||
|
t2c.alias.buy.all.bypass: true
|
||||||
|
t2c.alias.cooldown.global.all.bypass: true
|
||||||
|
t2c.alias.cooldown.player.all.bypass: true
|
||||||
|
|
||||||
|
t2c.alias.sub.buy.all.bypass: true
|
||||||
|
t2c.alias.sub.cooldown.global.all.bypass: true
|
||||||
|
t2c.alias.sub.cooldown.player.all.bypass: true
|
||||||
|
|
||||||
|
|
||||||
t2code.alias.buy.bypass:
|
t2c.alias.updatemsg:
|
||||||
default: op
|
default: op
|
||||||
t2code.alias.updatemsg:
|
t2c.alias.command.reload:
|
||||||
default: op
|
default: op
|
||||||
t2code.alias.command.reload:
|
t2c.alias.command.info:
|
||||||
default: op
|
default: op
|
||||||
t2code.alias.command.info:
|
|
||||||
|
t2c.alias.buy.all.bypass:
|
||||||
|
default: op
|
||||||
|
t2c.alias.cooldown.global.all.bypass:
|
||||||
|
default: op
|
||||||
|
t2c.alias.cooldown.player.all.bypass:
|
||||||
|
default: op
|
||||||
|
|
||||||
|
t2c.alias.sub.buy.all.bypass:
|
||||||
|
default: op
|
||||||
|
t2c.alias.sub.cooldown.global.all.bypass:
|
||||||
|
default: op
|
||||||
|
t2c.alias.sub.cooldown.player.all.bypass:
|
||||||
default: op
|
default: op
|
||||||
|
Reference in New Issue
Block a user