Compare commits

..

61 Commits

Author SHA1 Message Date
ad55fb53de 1.6_beta-1 2024-07-11 15:21:50 +02:00
f5ec79e90d Started to implement the config descriptions 2024-07-11 13:28:30 +02:00
ffa4423b7c smal fix 2024-07-08 05:10:38 +02:00
3b0a2fbe94 all register classes moved to a directory 2024-07-06 08:46:16 +02:00
2f2c68efdd 1.6_dev-23 2024-07-05 22:37:44 +02:00
4735f9f6fe 1.6_beta-1
Config descriptions not yet complete, otherwise ready
2024-07-05 12:31:57 +02:00
bc7803831c api to T2CodeLib 16.7_dev-22 2024-07-05 09:37:10 +02:00
456e13bf5f fix 2024-07-04 06:21:23 +02:00
5f6648c628 Update ExecuteAlias.java 2024-07-04 06:13:55 +02:00
f0b3b6e4fd T2CodeLib to 16.7_dev-6 2024-07-04 01:41:34 +02:00
d95de86b58 T2CodeLib load change 2024-07-03 03:30:07 +02:00
a85fd20f93 T2CodeLib api change to 16.7_dev-4 2024-07-03 03:29:50 +02:00
b7b3fbcb03 new config.yml and new register 2024-07-01 21:21:27 +02:00
5d72e0d48d 1.5
New features:
- The option "CooldownInSec.Global" has been added to give an alias a global cooldown that counts for all players.
- The option "CooldownInSec.Player" has been added to give an alias a cooldown that counts for a single player.

The permissions have been revised:
- t2code.alias.admin -> t2c.alias.admin
- t2code.alias.updatemsg -> t2c.alias.updatemsg
- t2code.alias.command.reload -> t2c.alias.command.reload
- t2code.alias.command.info -> t2c.alias.command.info
- t2code.alias.buy.bypass -> t2c.alias.buy.all.bypass
- The bypass for payment can now also be set individually for each alias / subalias: t2c.alias.buy.[alias].bypass / t2c.alias.sub.buy.all.bypass
2024-06-15 18:47:17 +02:00
d25b704ff1 1.5 dev
Changes in the Standard Config
minor code changes / bug fixes
started for cooldown
2024-06-15 02:32:10 +02:00
9aede116ac 1.4
Bugfix:
Fixed a bug where the plugin was not loading properly
2023-07-31 18:35:45 +02:00
97fc283951 1.3 hotfix 2023-07-16 11:43:13 +02:00
7e6c889583 1.3
T2CodeLib 15.7 is required
2023-07-16 08:27:20 +02:00
a1ffd48f3e The admin permission now also supports the placeholder <alias>.
The admin permission now also supports the placeholder <alias>.
2023-07-16 08:19:03 +02:00
0c1d32e0e8 Update AliasRegisterPermissions.java
Bugfix: The permissions of the alias commands were not registered
2023-07-16 08:10:18 +02:00
987370586a 1.3_beta-2
A bug was fixed, if you use confirm via the gui and let another gui open via the alias, then this direnk was closed again.
2023-07-09 17:46:16 +02:00
020f33da07 Update pom.xml 2023-07-09 17:01:29 +02:00
48196f446c Update Language.java 2023-07-09 17:01:28 +02:00
6e96509069 final 1.2.3_beta-1 2023-07-08 22:47:52 +02:00
fd0db6939a 1.2.3_beta-1 2023-07-08 21:30:45 +02:00
b5f3737fbd 1.2.2 2023-06-30 18:50:32 +02:00
7833144a9a 1.2.1
- API update to Minecraft version 1.20
- T2CodeLib API update to 15.0 (this version is required from now on)
2023-06-08 07:23:14 +02:00
10e23c6dcf Update pom.xml 2023-06-08 07:12:30 +02:00
be73deface [1.2.0 Stable]
- Added an option for players to confirm when an alias costs. (Per alias adjustable)
- Preselected T2CodeLib version: 14.5
2023-05-10 21:12:16 +02:00
f4d8d3496a Update pom.xml 2023-05-04 16:44:45 +02:00
5514e62f5d Update pom.xml 2023-05-04 16:43:04 +02:00
ba1db37a90 dev fix 2023-05-04 16:38:21 +02:00
02e7020815 1.2.0 Dev
[HOTFIX CODE] Added an option for players to confirm when an alias costs. (Per alias adjustable)
2023-05-03 22:47:58 +02:00
546b827e02 1.2.0 Dev
Added an option for players to confirm when an alias costs. (Per alias adjustable)
2023-05-03 22:35:46 +02:00
1ae32b2b59 stable 1.1.7 2022-12-21 10:52:47 +01:00
93f63ffad0 Default config was changed
The admin area was set to false in the default config.
2022-12-21 10:43:45 +01:00
2d49a7a4b7 bugfix for < 1.13 Server
Fixed a bug where you could not reload the plugin (/t2c-alias reload) when using a server below 1.13
2022-12-21 10:35:35 +01:00
f00ac77743 1.1.6 | New alias for commands & alias registration for plugin reload
Changes:
- For commands the placeholder '[alias]' has been added.
- If you add a new alias, it will now be registred on reload of the plugin, so no restart is needed anymore (If a command is renamed / removed, the old one will still be registred, but will not work. I am looking for a solution in the next update).
2022-11-17 23:39:38 +01:00
e96447d4fa 1.1.5 2022-11-15 14:58:46 +01:00
3053bc53a3 „README.md“ ändern 2022-11-14 15:55:11 +00:00
1de8c1d2ea fix 2022-11-14 16:44:45 +01:00
e8a0b99a56 Merge branch 'main' of https://git.t2code.net/JaTiTV/T2Code-Alias 2022-11-14 16:43:58 +01:00
dc75e49988 1.1.4 2022-11-14 16:43:53 +01:00
555e3a192c „README.md/README.md“ ändern 2022-11-14 15:18:37 +00:00
7d2cf9a122 „README.md/README.md“ ändern 2022-11-14 15:18:11 +00:00
ecd3362db6 „README.md/README.md“ ändern 2022-11-14 15:17:39 +00:00
078e9404e6 „README.md/README.md“ ändern 2022-11-14 15:17:14 +00:00
2617f55062 Dateien hochladen nach „README.md“ 2022-11-14 15:12:56 +00:00
bcfcc2e863 1.1.3
T2CodeLib update to API Version 13.0

Bugfix:
- Hardcode message inserted in language file
2022-10-25 16:38:16 +02:00
dbe5f82030 1.1.2 | Bugfix
TabComplete Aller Commands was affected by T2C alias and partially disabled completely. This has been fixed.
2022-07-19 22:55:25 +02:00
6586ac4ee9 1.1.1
This update fixes a security vulnerability where players with modified clients could intercept all commands.
This bug affects the proxy (Bungee, Waterfall etc.)!
2022-07-19 18:27:07 +02:00
JaTiTV
a7518530c7 Merge pull request '1.1.0 | SubAlias, MiniMessage and more' (#3) from 1.1 into main
Reviewed-on: #3
2022-07-14 21:57:23 +02:00
b9a91baed7 1.1.0 2022-07-14 21:56:13 +02:00
63f8a8a5e2 1.1.0_Snapshot-#3 2022-07-09 04:40:03 +02:00
9aed0f5895 1.1.0_Snapshot-#1 2022-07-08 19:06:12 +02:00
41c2c95b36 code changes | update status 80% 2022-07-07 13:48:08 +02:00
d5669d82d4 1. trial version for SubCommands / Sub TabComplete 2022-07-07 05:54:36 +02:00
f8b86086db remove textBuilder and other changes 2022-07-05 20:03:22 +02:00
cf300acff1 Create SubAliasObjekt.java 2022-07-05 20:02:18 +02:00
156e5c0585 Create RegisterSubAliasCommands.java 2022-07-05 20:02:13 +02:00
f90ed13bda change config 2022-07-05 20:01:48 +02:00
50 changed files with 2942 additions and 1975 deletions

77
README.md Normal file
View 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">

157
pom.xml
View File

@ -6,7 +6,11 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>Alias</artifactId> <artifactId>Alias</artifactId>
<version>1.0.11</version>
<version>1.6_beta-1</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,14 +23,15 @@
<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>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version> <version>3.8.1</version>
<configuration> <configuration>
<source>${java.version}</source> <source>11</source>
<target>${java.version}</target> <target>11</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
@ -35,15 +40,19 @@
<version>3.2.4</version> <version>3.2.4</version>
<executions> <executions>
<execution> <execution>
<id>shade</id>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution> </execution>
</executions> </executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
</relocations>
</configuration>
</plugin> </plugin>
</plugins> </plugins>
<resources> <resources>
@ -55,121 +64,51 @@
</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>paper-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</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>
</repository> </repository>
<repository>
<id>Builders-Paradise</id>
<url>https://repo.t2code.net/repository/Builders-Paradise/</url>
</repository>
</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>3.4.40</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>12.0</version> <version>16.7</version>
<classifier>dev-23</classifier>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>org.projectlombok</groupId>
<artifactId>bungee</artifactId> <artifactId>lombok</artifactId>
<version>1615</version> <version>1.18.30</version>
</dependency> <scope>provided</scope>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>PlugmanGUI</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_18.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.18r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_18.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.18r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_17.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.17r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_16.r3</groupId>
<artifactId>spigot</artifactId>
<version>1.16r3</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_16.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.16r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_16.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.16r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_15.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.15r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_14.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.14r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_13.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.13r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_13.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.13r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_12.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.12r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_11.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.11r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_10.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.10r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_9.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.9r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_9.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.9r1</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_8.r3</groupId>
<artifactId>spigot</artifactId>
<version>1.8r3</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_8.r2</groupId>
<artifactId>spigot</artifactId>
<version>1.8r2</version>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_8.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.8r1</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -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());
}
}

View File

@ -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();
}
}
}
}

View File

@ -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_);
}
}

View File

@ -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;
}
}
}
}

View 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<>();
}

View File

@ -1,10 +1,14 @@
package net.t2code.alias.Spigot; package net.t2code.alias.Spigot;
import net.t2code.alias.Spigot.objects.AliasObjekt; import lombok.Getter;
import net.t2code.alias.Spigot.objects.AliasObject;
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.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2C_McVersion;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.io.File; import java.io.File;
@ -16,23 +20,42 @@ import java.util.logging.Level;
public final class Main extends JavaPlugin { public final class Main extends JavaPlugin {
public static File getPath() { public static File getPath() {
return plugin.getDataFolder(); return instance.getDataFolder();
} }
public static String version; @Getter
public static List<String> autor; private static String version;
public static Main plugin; @Getter
public static HashMap<String, AliasObjekt> aliasHashMap = new HashMap<>(); private static List<String> autor;
@Getter
private static Main instance;
@Getter
private static Boolean t2codeLib = false;
@Getter
private static String guiCode;
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 ArrayList<String> allAliases = new ArrayList<>(); public static ArrayList<String> allAliases = new ArrayList<>();
public static ArrayList<String> allSubAliases = new ArrayList<>();
public static ArrayList<String> allForSubAliases = new ArrayList<>();
@Override @Override
public void onEnable() { public void onEnable() {
// Plugin startup logic // Plugin startup logic
plugin = this; instance = this;
autor = plugin.getDescription().getAuthors(); autor = instance.getDescription().getAuthors();
version = plugin.getDescription().getVersion(); version = instance.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getSpigotID(), Util.getDiscord(), Util.getBstatsID()); if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
t2codeLib = true;
if (T2C_McVersion.isMc1_13()) {
guiCode = "";
} else guiCode = "§6§8§9§r";
new Load(this, Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getBstatsID());
} }
@Override @Override
@ -40,22 +63,37 @@ public final class Main extends JavaPlugin {
// Plugin shutdown logic // Plugin shutdown logic
aliasHashMap.clear(); aliasHashMap.clear();
allAliases.clear(); allAliases.clear();
if (Bukkit.getPluginManager().getPlugin("T2CodeLib") == null) return; if (!t2codeLib) return;
T2CodeTemplate.onDisable(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord()); T2C_Template.onDisable(Util.getPrefix(), instance);
} }
public static Boolean pluginNotFound(String pl, Integer spigotID, double ver) { public static Boolean pluginNotFound(String pl, Integer spigotID, String ver) {
if (Bukkit.getPluginManager().getPlugin(pl) == null) { if (Bukkit.getPluginManager().getPlugin(pl) == null) {
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); instance.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: " + Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4could not be found. Please download it here: "
"§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin."); + "§6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to be able to use this plugin.");
Main.plugin.getPluginLoader().disablePlugin(Main.plugin); Main.instance.getPluginLoader().disablePlugin(Main.instance);
return true; return true;
} else { } else {
if (Double.parseDouble(Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(pl)).getDescription().getVersion()) < ver) { String plVer = Objects.requireNonNull(Bukkit.getPluginManager().getPlugin(pl)).getDescription().getVersion();
plugin.getLogger().log(Level.SEVERE, "Plugin can not be loaded!"); if (ver.contains("_")) {
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2" + ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID + " §4to use this version of " + plugin.getDescription().getName() + "."); if (!plVer.equals(ver)) {
Main.plugin.getPluginLoader().disablePlugin(Main.plugin); instance.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires the version §2"
+ ver + " §4of §6" + pl + " §4Please use this version! Please download it here or contact us in Discord: §6https://spigotmc.org/resources/"
+ pl + "." + spigotID + " Or contact us in Discord: http://dc.t2code.net");
Main.instance.getPluginLoader().disablePlugin(Main.instance);
return true;
}
return false;
}
String[] split = plVer.split("_");
if (Double.parseDouble(split[0]) < Double.parseDouble(ver)) {
instance.getLogger().log(Level.SEVERE, "Plugin can not be loaded!");
Bukkit.getConsoleSender().sendMessage(Util.getPrefix() + " §e" + pl + " §4is out of date! This plugin requires at least version §2"
+ ver + " §4of §6" + pl + " §4Please update it here: §6https://spigotmc.org/resources/" + pl + "." + spigotID
+ " §4to use this version of " + instance.getDescription().getName() + ".");
Main.instance.getPluginLoader().disablePlugin(Main.instance);
return true; return true;
} }
return false; return false;

View File

@ -1,7 +1,9 @@
package net.t2code.alias.Spigot.cmdManagement; package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.config.languages.SelectMessages; import net.t2code.alias.Spigot.config.config.Config;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.alias.Spigot.config.config.Language;
import net.t2code.alias.Spigot.enums.Confirm;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
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;
@ -21,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 T2C_Send.sender(sender, Language.VALUES.noPermission.getValue().toString().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 T2C_Send.sender(sender, Language.VALUES.noPermission.getValue().toString().replace("[cmd]", "/t2code-alias reload")
.replace("[perm]", "t2code.alias.command.reload")); .replace("[perm]", "t2c.alias.command.reload"));
break;
case "confirm":
if (Config.VALUES.buyConfirmDefault.getValue() == 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 T2C_Send.sender(sender, Language.VALUES.noPermission.getValue().toString().replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info")); .replace("[perm]", "t2c.alias.command.info"));
break; break;
} }
@ -50,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
@ -62,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;

View File

@ -1,29 +1,29 @@
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.Util;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.lib.Spigot.Lib.messages.send; import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI;
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.autor,Main.version, UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion); T2C_Template.sendInfo(sender, Main.getInstance(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
} }
public static void reload(CommandSender sender) { public static void reload(CommandSender sender) {
if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadStart); if (sender instanceof Player) T2C_Send.player((Player) sender, Language.VALUES.reloadStart.getValue().toString());
send.console(Util.getPrefix() + "§8-------------------------------"); T2C_Send.console(Util.getPrefix() + "§8-------------------------------");
send.console(Util.getPrefix() + " §6Plugin reload..."); T2C_Send.console(Util.getPrefix() + " §6Plugin reload...");
send.console(Util.getPrefix() + "§8-------------------------------"); T2C_Send.console(Util.getPrefix() + "§8-------------------------------");
Load.loadReload(); Load.loadReload(Main.getInstance(),true);
if (sender instanceof Player) sender.sendMessage(SelectMessages.reloadEnd); if (sender instanceof Player) T2C_Send.player((Player) sender, Language.VALUES.reloadEnd.getValue().toString());
send.console(Util.getPrefix() + "§8-------------------------------"); T2C_Send.console(Util.getPrefix() + "§8-------------------------------");
send.console(Util.getPrefix() + " §2Plugin successfully reloaded."); T2C_Send.console(Util.getPrefix() + " §2Plugin successfully reloaded.");
send.console(Util.getPrefix() + "§8-------------------------------"); T2C_Send.console(Util.getPrefix() + "§8-------------------------------");
} }
} }

View File

@ -0,0 +1,496 @@
package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Cache;
import net.t2code.alias.Spigot.config.config.Config;
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.AliasStorageObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Spigot.system.BCommandSenderReciver;
import net.t2code.alias.util.Util;
import net.t2code.t2codelib.SPIGOT.api.commands.T2C_Cmd;
import net.t2code.t2codelib.SPIGOT.api.eco.T2C_Eco;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Replace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2C_PluginCheck;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class ExecuteAlias {
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())) {
T2C_Send.player(player, Language.VALUES.confirmNotPossible.getValue().toString());
return;
}
AliasStorageObject object = Cache.aliasStorage.get(player.getUniqueId());
Cache.aliasStorage.remove(player.getUniqueId());
if (!confirm) {
T2C_Send.player(player, Language.VALUES.confirmCancel.getValue().toString());
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) {
Player player = (Player) sender;
if (aliasObject.adminEnable) {
if (player.hasPermission(aliasObject.adminPermission.replace("[alias]", alias.toLowerCase()))) {
if (aliasObject.adminCommandEnable) {
aliasAdminCommand(aliasObject, alias, player, args);
}
if (aliasObject.adminMessageEnable) {
aliasAdminMessage(aliasObject, alias, player, args);
}
return;
}
}
if (aliasObject.permNecessary) {
if (!(player.hasPermission(aliasObject.permission.replace("[alias]", alias.toLowerCase())) || player.hasPermission("t2c.alias.admin"))) {
String npmsg;
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
npmsg = Language.VALUES.noPermission.getValue().toString();
} else npmsg = aliasObject.permissionMSG;
T2C_Send.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", aliasObject.permission.replace("[alias]", alias.toLowerCase())).replace("[alias]", alias));
return;
}
}
if (aliasObject.costEnable && aliasObject.costConfirm) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy." + alias.toLowerCase() + ".bypass"))) {
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, false));
switch ((Confirm) Config.VALUES.buyConfirmDefault.getValue()) {
case GUI:
ConfirmGUI.open(player, aliasObject.costPrice, alias);
break;
case CHAT:
T2C_Send.player(player, Language.VALUES.confirmChat.getValue().toString().replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
case COMMAND:
default:
T2C_Send.player(player, Language.VALUES.confirmCommand.getValue().toString().replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
}
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))) {
T2C_Send.player(player, Language.VALUES.cooldownGlobal.getValue().toString().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))) {
T2C_Send.player(player, Language.VALUES.cooldownPlayer.getValue().toString().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 (!T2C_Eco.moneyRemove(prefix, player, aliasObject.costPrice)) {
T2C_Send.player(player, Language.VALUES.noMoney.getValue().toString());
return;
}
if ((Boolean) Config.VALUES.buyMessage.getValue())
T2C_Send.player(player, Language.VALUES.buy.getValue().toString().replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getPath()));
}
}
if (aliasObject.commandEnable) {
aliasCommand(aliasObject, alias, player, args);
}
if (aliasObject.messageEnable) {
aliasMessage(aliasObject, alias, player, args);
}
}
protected static void subAliasPlayer(CommandSender sender, SubAliasObject aliasObject, String alias, String[] args) {
if (!aliasObject.subAliasEnable) {
T2C_Send.sender(sender, Language.VALUES.aliasDisabled.getValue().toString());
return;
}
if (sender instanceof Player) {
Player player = (Player) sender;
if (aliasObject.adminEnable) {
if (player.hasPermission(aliasObject.adminPermission.replace("[alias]", alias.toLowerCase()))) {
if (aliasObject.adminCommandEnable) {
subAliasAdminCommand(aliasObject, alias, player, args);
}
if (aliasObject.adminMessageEnable) {
subAliasAdminMessage(aliasObject, alias, player, args);
}
return;
}
}
if (aliasObject.permNecessary) {
if (!(player.hasPermission(aliasObject.permission.replace("[alias]", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
String npmsg;
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
npmsg = Language.VALUES.noPermission.getValue().toString();
} else npmsg = aliasObject.permissionMSG;
T2C_Send.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", aliasObject.permission.replace("[alias]", alias.toLowerCase())).replace("[alias]", alias));
return;
}
}
if (aliasObject.costEnable && aliasObject.costConfirm) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, true));
switch ((Confirm) Config.VALUES.buyConfirmDefault.getValue()) {
case GUI:
ConfirmGUI.open(player, aliasObject.costPrice, alias);
break;
case CHAT:
T2C_Send.player(player, Language.VALUES.confirmChat.getValue().toString().replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
case COMMAND:
default:
T2C_Send.player(player, Language.VALUES.confirmCommand.getValue().toString().replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
}
return;
}
}
executeSubAlias(player, aliasObject, alias, args);
} else {
if (aliasObject.consoleEnable) {
subAliasConsole(aliasObject, alias, sender, args);
} else T2C_Send.sender(sender, Language.VALUES.onlyForPlayer.getValue().toString());
}
}
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))) {
T2C_Send.player(player, Language.VALUES.cooldownGlobal.getValue().toString().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))) {
T2C_Send.player(player, Language.VALUES.cooldownPlayer.getValue().toString().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 (!T2C_Eco.moneyRemove(prefix, player, aliasObject.costPrice)) {
T2C_Send.player(player, Language.VALUES.noMoney.getValue().toString());
return;
}
if ((Boolean) Config.VALUES.buyMessage.getValue())
T2C_Send.player(player, Language.VALUES.buy.getValue().toString().replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
}
}
if (aliasObject.commandEnable) {
subAliasCommand(aliasObject, player, args);
}
if (aliasObject.messageEnable) {
subAliasMessage(aliasObject, alias, player, args);
}
}
protected static void aliasConsole(AliasObject alias, CommandSender sender, String prefix) {
if (alias.consoleCommandEnable) {
for (String cmd : alias.consoleCommands) {
if (alias.consoleBungeeCommand) {
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(sender, cmd, true);
} else {
T2C_Send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2C_Send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
T2C_Cmd.console(cmd);
}
}
}
if (alias.consoleMessageEnable) {
for (String msg : alias.consoleMessages) {
T2C_Send.console(T2C_Replace.replace(prefix, msg));
}
}
}
private static void subAliasConsole(SubAliasObject aliasObject, String alias, CommandSender sender, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
if (aliasObject.consoleCommandEnable) {
for (String cmd : aliasObject.consoleCommands) {
String replace = cmd.replace("[target]", targetSt).replace("[alias]", alias);
if (aliasObject.consoleBungeeCommand) {
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(sender, replace, true);
} else {
T2C_Send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2C_Send.sender(sender, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
T2C_Cmd.console(replace);
}
}
}
if (aliasObject.consoleMessageEnable) {
for (String msg : aliasObject.consoleMessages) {
T2C_Send.console(T2C_Replace.replace(prefix, msg));
}
}
}
private static void aliasAdminCommand(AliasObject aliasObject, String alias, Player player, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
for (String cmd : aliasObject.adminCommands) {
if (aliasObject.adminBungeeCommand) {
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.adminCommandAsConsole);
} else {
T2C_Send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2C_Send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (aliasObject.adminCommandAsConsole) {
T2C_Cmd.console(cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
} else {
T2C_Cmd.player(player, cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
}
}
}
}
private static void subAliasAdminCommand(SubAliasObject aliasObject, String alias, Player player, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
for (String cmd : aliasObject.adminCommands) {
if (aliasObject.adminBungeeCommand) {
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.adminCommandAsConsole);
} else {
T2C_Send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2C_Send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (aliasObject.adminCommandAsConsole) {
T2C_Cmd.console(cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
} else {
T2C_Cmd.player(player, cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
}
}
}
}
private static void aliasAdminMessage(AliasObject aliasObject, String alias, Player player, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
for (String msg : aliasObject.adminMessages) {
String text;
if (T2C_PluginCheck.papi()) {
text = T2C_Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
} else {
text = T2C_Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
}
T2C_Send.player(player, text);
}
}
private static void subAliasAdminMessage(SubAliasObject subAliasObject, String alias, Player player, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
for (String msg : subAliasObject.adminMessages) {
String text;
if (T2C_PluginCheck.papi()) {
text = T2C_Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
} else {
text = T2C_Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
}
T2C_Send.player(player, text);
}
}
private static void aliasCommand(AliasObject aliasObject, String alias, Player player, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
for (String cmd : aliasObject.command) {
if (aliasObject.bungeeCommand) {
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.commandAsConsole);
} else {
T2C_Send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2C_Send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (aliasObject.commandAsConsole) {
T2C_Cmd.console(cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
} else {
T2C_Cmd.player(player, cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt).replace("[alias]", alias));
}
}
}
}
private static void subAliasCommand(SubAliasObject alias, Player player, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
for (String cmd : alias.command) {
if (alias.bungeeCommand) {
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt), alias.commandAsConsole);
} else {
T2C_Send.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
T2C_Send.player(player, Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
}
} else {
if (alias.commandAsConsole) {
T2C_Cmd.console(cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt));
} else {
T2C_Cmd.player(player, cmd.replace("[player]", player.getName()).replace("%player_name%", player.getName()).replace("[target]", targetSt));
}
}
}
}
private static void aliasMessage(AliasObject aliasObject, String alias, Player player, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
for (String msg : aliasObject.messages) {
String text;
if (T2C_PluginCheck.papi()) {
text = T2C_Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
} else {
text = T2C_Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
}
T2C_Send.player(player, text);
}
}
private static void subAliasMessage(SubAliasObject subAliasObject, String alias, Player player, String[] args) {
String targetSt = "[target]";
try {
List<String> results = Arrays.stream(args).filter(a -> a.contains("-p:")).collect(Collectors.toList());
targetSt = results.get(0).replace("-p:", "");
} catch (Exception ignored) {
}
for (String msg : subAliasObject.messages) {
String text;
if (T2C_PluginCheck.papi()) {
text = T2C_Replace.replace(prefix, player, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
} else {
text = T2C_Replace.replace(prefix, replacePlayer(msg, player)).replace("[target]", targetSt).replace("[alias]", alias);
}
T2C_Send.player(player, text);
}
}
private static String replacePlayer(String s, Player player) {
return s.replace("[player]", player.getName()).replace("%player_name%", player.getName());
}
}

View File

@ -1,18 +1,11 @@
package net.t2code.alias.Spigot.cmdManagement; package net.t2code.alias.Spigot.cmdManagement;
import net.md_5.bungee.api.chat.ClickEvent;
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.config.config.Language;
import net.t2code.alias.Spigot.config.languages.SelectMessages; import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.AliasObjekt; import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Spigot.system.*; import net.t2code.alias.util.Util;
import net.t2code.alias.Util; import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.lib.Spigot.Lib.commands.Cmd;
import net.t2code.lib.Spigot.Lib.eco.Eco;
import net.t2code.lib.Spigot.Lib.messages.TextBuilder;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.plugins.PluginCheck;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,173 +21,42 @@ public class RegisterCommands extends Command {
@Override @Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) { public boolean execute(CommandSender sender, String commandLabel, String[] args) {
AliasObjekt alias = Main.aliasHashMap.get(this.alias); AliasObject alias = Main.aliasHashMap.get(this.alias);
if (alias == null) {
T2C_Send.error(Main.getInstance(), "The alias " + this.alias + " does not exist.");
return false;
}
if (!alias.aliasEnable) { if (!alias.aliasEnable) {
send.sender(sender, SelectMessages.aliasDisabled); T2C_Send.sender(sender, Language.VALUES.aliasDisabled.getValue().toString());
return true; return true;
} }
if (sender instanceof Player) { if (args.length == 0 || args.length == 1 && args[0].contains("-p:")) {
Player player = (Player) sender; if (sender instanceof Player) {
ExecuteAlias.aliasPlayer(sender, alias, this.alias, args);
if (alias.adminEnable) { } else {
if (player.hasPermission(alias.adminPermission)) { if (alias.consoleEnable) {
if (alias.adminCommandEnable) { ExecuteAlias.aliasConsole(alias, sender, prefix);
adminCommand(alias, player); } else T2C_Send.sender(sender, Language.VALUES.onlyForPlayer.getValue().toString());
}
if (alias.adminMessageEnable) {
adminMessage(alias, player, prefix);
}
return true;
}
}
if (alias.permNecessary) {
if (!(player.hasPermission("t2code.alias.use." + this.alias.toLowerCase()) || player.hasPermission("t2code.alias.admin"))) {
send.player(player, SelectMessages.noPermissionForCommand.replace("[cmd]", "/" + this.alias.toLowerCase())
.replace("[perm]", "t2code.alias.use." + this.alias.toLowerCase()));
return true;
}
}
if (alias.costEnable) {
if (!(alias.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass")) ){
if (!Eco.moneyRemove(prefix, player, alias.costPrice)) {
send.player(player, SelectMessages.noMoney);
return true;
}
if (SelectConfig.buyMessage) send.player(player, SelectMessages.buy.replace("[price]", alias.costPrice.toString()));
}
}
if (alias.commandEnable) {
command(alias, player);
}
if (alias.messageEnable) {
message(alias, player, prefix);
} }
} else { } else {
if (alias.consoleEnable) { if (!Main.allForSubAliases.contains(this.alias)) {
console(alias, sender, prefix); return false;
} else send.sender(sender, SelectMessages.onlyForPlayer); }
for (String sals : Main.allSubAliases) {
SubAliasObject sal = Main.subAliasHashMap.get(sals);
if (args.length == sal.subAliasArg + 1) {
for (String al : sal.subAliasList) {
if (args[sal.subAliasArg].toLowerCase().equals(al)) {
ExecuteAlias.subAliasPlayer(sender, sal, al, args);
return true;
}
}
}
}
T2C_Send.sender(sender, Language.VALUES.noSubCommand.getValue().toString());
} }
return true; return true;
} }
private static void adminCommand(AliasObjekt alias, Player player) {
for (String cmd : alias.adminCommands) {
if (alias.adminBungeeCommand) {
if (SelectConfig.Bungee) {
if (alias.adminCommandAsConsole) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), true);
} else BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false);
} else {
send.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.");
}
} else {
if (alias.adminCommandAsConsole) {
Cmd.console(cmd.replace("[player]", player.getName()));
} else {
Cmd.player(player, cmd.replace("[player]", player.getName()));
}
}
}
}
private static void adminMessage(AliasObjekt alias, Player player, String prefix) {
for (String msg : alias.adminMessages) {
String text;
String hover;
if (PluginCheck.papi()) {
text = Replace.replace(prefix, player, replacePlayer(msg, player));
hover = Replace.replace(prefix, player, alias.adminHover);
} else {
text = Replace.replace(prefix, replacePlayer(msg, player));
hover = Replace.replace(prefix, alias.adminHover);
}
if (alias.adminTextBuilder) {
TextBuilder textBuilder = new TextBuilder(text);
textBuilder.addHover(hover);
if (alias.adminClickEvent) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(alias.adminAction), alias.adminActionValue);
}
player.spigot().sendMessage(textBuilder.build());
} else {
send.player(player, text);
}
}
}
private static void command(AliasObjekt alias, Player player) {
for (String cmd : alias.command) {
if (alias.bungeeCommand) {
if (SelectConfig.Bungee) {
if (alias.commandAsConsole) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), true);
} else BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()), false);
} else {
send.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.");
}
} else {
if (alias.commandAsConsole) {
Cmd.console(cmd.replace("[player]", player.getName()));
} else {
Cmd.player(player, cmd.replace("[player]", player.getName()));
}
}
}
}
private static void message(AliasObjekt alias, Player player, String prefix) {
for (String msg : alias.messages) {
String text;
String hover;
if (PluginCheck.papi()) {
text = Replace.replace(prefix, player, replacePlayer(msg, player));
hover = Replace.replace(prefix, player, alias.hover);
} else {
text = Replace.replace(prefix, replacePlayer(msg, player));
hover = Replace.replace(prefix, alias.hover);
}
if (alias.textBuilder) {
TextBuilder textBuilder = new TextBuilder(text);
textBuilder.addHover(hover);
if (alias.clickEvent) {
textBuilder.addClickEvent(ClickEvent.Action.valueOf(alias.action), alias.actionValue);
}
player.spigot().sendMessage(textBuilder.build());
} else {
send.player(player, text);
}
}
}
private static void console(AliasObjekt alias, CommandSender sender, String prefix) {
if (alias.consoleCommandEnable) {
for (String cmd : alias.consoleCommands) {
if (alias.consoleBungeeCommand) {
if (SelectConfig.Bungee) {
BCommandSenderReciver.sendToBungee(sender, cmd, true);
} else {
send.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.");
}
} else {
Cmd.console(cmd);
}
}
}
if (alias.consoleMessageEnable) {
for (String msg : alias.consoleMessages) {
send.console(Replace.replace(prefix, msg));
}
}
}
private static String replacePlayer(String s, Player player) {
return s.replace("[player]", player.getName());
}
} }

View File

@ -0,0 +1,47 @@
package net.t2code.alias.Spigot.cmdManagement;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.t2codelib.SPIGOT.api.commands.T2C_Tab;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.TabCompleteEvent;
import java.util.*;
public class TabEvent implements Listener {
private static HashMap<String, String> arg1 = new HashMap<String, String>();
@EventHandler
public void onTab(TabCompleteEvent e) {
String buffer = e.getBuffer();
String[] imp = buffer.replace("/", "").split(" ");
if (!Main.allAliases.contains(imp[0]) || !Main.allForSubAliases.contains(imp[0])){
return;
}
List<String> list = new ArrayList<>(Collections.emptyList());
arg1.clear();
for (String sals : Main.allSubAliases) {
SubAliasObject aliasObject = Main.subAliasHashMap.get(sals);
if (!buffer.contains(aliasObject.subAliasFor)) continue;
String[] im = aliasObject.subAliasFor.split(" ");
String input = buffer.replace("/" + im[0] + " ", "");
String[] args = input.split(" ", -1);
for (String al : aliasObject.subAliasList) {
arg1.put(al, aliasObject.permission.replace("[alias]", al.toLowerCase()));
}
int arg = aliasObject.subAliasArg;
if (args.length - 1 == arg) {
for (String command : aliasObject.subAliasList) {
if (T2C_Tab.hasPermission(e.getSender(), arg1.get(command)) && T2C_Tab.passend(command, args[arg])) {
list.add(command);
}
}
}
}
e.setCompletions(list);
}
}

View File

@ -0,0 +1,154 @@
// This class was created by JaTiTV.
package net.t2code.alias.Spigot.config;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.alias.AliasFile;
import net.t2code.alias.Spigot.config.subAlias.SubAliasFile;
import net.t2code.alias.util.Util;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
import net.t2code.t2codelib.util.T2C_ConfigItem;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class ConfigFileConverter {
private static YamlConfiguration yamlConfiguration;
public static void convert() {
File configDeclaration = new File(Main.getPath() + "/X_configDeclaration_X.yml");
configDeclaration.delete();
File aliasDeclaration = new File(Main.getPath() + "/Alias/X_aliasDeclaration_X.yml");
aliasDeclaration.delete();
File subaliasDeclaration = new File(Main.getPath() + "/SubAlias/X_subAliasDeclaration_X.yml");
subaliasDeclaration.delete();
convertAlias();
convertSubAlias();
}
private static void convertAlias() {
File f = new File(Main.getPath() + "/Alias/");
if (!f.exists()) return;
File[] fileArray = f.listFiles();
if (fileArray == null) return;
for (File file : fileArray) {
String sub = file.getName().substring(file.getName().length() - 4);
if (sub.equals(".yml")) {
yamlConfiguration = YamlConfiguration.loadConfiguration(file);
setConfig("Alias.Enable", AliasFile.VALUES.aliasEnable);
setConfig("Alias.AliasList", AliasFile.VALUES.aliasList);
setConfig("Alias.Permission.Necessary", AliasFile.VALUES.permNecessary);
setConfig("Alias.Permission.Permission", AliasFile.VALUES.permission);
setConfig("Alias.Permission.CustomNoPermissionMSG", AliasFile.VALUES.permissionMSG);
setConfig("Alias.CooldownInSec.Global", AliasFile.VALUES.cooldownGlobal);
setConfig("Alias.CooldownInSec.Player", AliasFile.VALUES.cooldownPlayer);
setConfig("Alias.Cost.Enable", AliasFile.VALUES.costEnable);
setConfig("Alias.Cost.Confirm", AliasFile.VALUES.costConfirm);
setConfig("Alias.Cost.Price", AliasFile.VALUES.costPrice);
setConfig("Alias.Cost.AllowByPass", AliasFile.VALUES.costAllowBypass);
setConfig("Alias.Command.Enable", AliasFile.VALUES.commandEnable);
setConfig("Alias.Command.CommandAsConsole", AliasFile.VALUES.commandAsConsole);
setConfig("Alias.Command.BungeeCommand", AliasFile.VALUES.bungeeCommand);
setConfig("Alias.Command.Commands", AliasFile.VALUES.command);
setConfig("Alias.Message.Enable", AliasFile.VALUES.messageEnable);
setConfig("Alias.Message.Messages", AliasFile.VALUES.messages);
setConfig("Alias.Admin.Enable", AliasFile.VALUES.adminEnable);
setConfig("Alias.Admin.Permission", AliasFile.VALUES.adminPermission);
setConfig("Alias.Admin.Command.Enable", AliasFile.VALUES.adminCommandEnable);
setConfig("Alias.Admin.Command.CommandAsConsole", AliasFile.VALUES.adminCommandAsConsole);
setConfig("Alias.Admin.Command.BungeeCommand", AliasFile.VALUES.adminBungeeCommand);
setConfig("Alias.Admin.Command.Commands", AliasFile.VALUES.adminCommands);
setConfig("Alias.Admin.Message.Enable", AliasFile.VALUES.adminMessageEnable);
setConfig("Alias.Admin.Message.Messages", AliasFile.VALUES.adminMessages);
setConfig("Alias.Console.Enable", AliasFile.VALUES.consoleEnable);
setConfig("Alias.Console.Command.Enable", AliasFile.VALUES.consoleCommandEnable);
setConfig("Alias.Console.Command.BungeeCommand", AliasFile.VALUES.consoleBungeeCommand);
setConfig("Alias.Console.Command.Commands", AliasFile.VALUES.consoleCommands);
setConfig("Alias.Console.Message.Enable", AliasFile.VALUES.consoleMessageEnable);
setConfig("Alias.Console.Message.Messages", AliasFile.VALUES.consoleMessages);
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "alias/" + file.getName()), AliasFile.VALUES.values(), false, Util.getConfigLogo());
file.delete();
}
}
deleteDirectory(f);
}
private static void convertSubAlias() {
File f = new File(Main.getPath() + "/SubAlias/");
if (!f.exists()) return;
File[] fileArray = f.listFiles();
assert fileArray != null;
for (File file : fileArray) {
String sub = file.getName().substring(file.getName().length() - 4);
if (sub.equals(".yml")) {
yamlConfiguration = YamlConfiguration.loadConfiguration(file);
setConfig("SubAlias.Enable", SubAliasFile.VALUES.aliasEnable);
setConfig("SubAlias.SubAliasList", SubAliasFile.VALUES.subAliasList);
setConfig("SubAlias.SubAliasFor", SubAliasFile.VALUES.subAliasFor);
setConfig("SubAlias.Permission.Necessary", SubAliasFile.VALUES.permNecessary);
setConfig("SubAlias.Permission.Permission", SubAliasFile.VALUES.permission);
setConfig("SubAlias.Permission.CustomNoPermissionMSG", SubAliasFile.VALUES.permissionMSG);
setConfig("SubAlias.CooldownInSec.Global", SubAliasFile.VALUES.cooldownGlobal);
setConfig("SubAlias.CooldownInSec.Player", SubAliasFile.VALUES.cooldownPlayer);
setConfig("SubAlias.Cost.Enable", SubAliasFile.VALUES.costEnable);
setConfig("SubAlias.Cost.Confirm", SubAliasFile.VALUES.costConfirm);
setConfig("SubAlias.Cost.Price", SubAliasFile.VALUES.costPrice);
setConfig("SubAlias.Cost.AllowByPass", SubAliasFile.VALUES.costAllowBypass);
setConfig("SubAlias.Command.Enable", SubAliasFile.VALUES.commandEnable);
setConfig("SubAlias.Command.CommandAsConsole", SubAliasFile.VALUES.commandAsConsole);
setConfig("SubAlias.Command.BungeeCommand", SubAliasFile.VALUES.bungeeCommand);
setConfig("SubAlias.Command.Commands", SubAliasFile.VALUES.command);
setConfig("SubAlias.Message.Enable", SubAliasFile.VALUES.messageEnable);
setConfig("SubAlias.Message.Messages", SubAliasFile.VALUES.messages);
setConfig("SubAlias.Admin.Enable", SubAliasFile.VALUES.adminEnable);
setConfig("SubAlias.Admin.Permission", SubAliasFile.VALUES.adminPermission);
setConfig("SubAlias.Admin.Command.Enable", SubAliasFile.VALUES.adminCommandEnable);
setConfig("SubAlias.Admin.Command.CommandAsConsole", SubAliasFile.VALUES.adminCommandAsConsole);
setConfig("SubAlias.Admin.Command.BungeeCommand", SubAliasFile.VALUES.adminBungeeCommand);
setConfig("SubAlias.Admin.Command.Commands", SubAliasFile.VALUES.adminCommands);
setConfig("SubAlias.Admin.Message.Enable", SubAliasFile.VALUES.adminMessageEnable);
setConfig("SubAlias.Admin.Message.Messages", SubAliasFile.VALUES.adminMessages);
setConfig("SubAlias.Console.Enable", SubAliasFile.VALUES.consoleEnable);
setConfig("SubAlias.Console.Command.Enable", SubAliasFile.VALUES.consoleCommandEnable);
setConfig("SubAlias.Console.Command.BungeeCommand", SubAliasFile.VALUES.consoleBungeeCommand);
setConfig("SubAlias.Console.Command.Commands", SubAliasFile.VALUES.consoleCommands);
setConfig("SubAlias.Console.Message.Enable", SubAliasFile.VALUES.consoleMessageEnable);
setConfig("SubAlias.Console.Message.Messages", SubAliasFile.VALUES.consoleMessages);
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "subAlias/" + file.getName()), SubAliasFile.VALUES.values(), false, Util.getConfigLogo());
file.delete();
}
}
deleteDirectory(f);
}
private static void setConfig(String path, T2C_ConfigItem item) {
if (yamlConfiguration.contains(path)) {
item.setValue(yamlConfiguration.get(path));
}
}
public static boolean deleteDirectory(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDirectory(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
return dir.delete();
}
}

View File

@ -0,0 +1,337 @@
// This class was created by JaTiTV.
package net.t2code.alias.Spigot.config.alias;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.ConfigFileConverter;
import net.t2code.alias.Spigot.config.config.Config;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.register.AliasRegister;
import net.t2code.alias.util.Util;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
import net.t2code.t2codelib.util.T2C_ConfigItem;
import net.t2code.t2codelib.util.T2C_LanguageEnum;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public class AliasFile {
public enum VALUES implements T2C_ConfigItem {
aliasDesc("alias", null, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Wenn du weitere Alias Commands hinzufügen möchtest, lege einfach eine weitere Alias Datei an."));
put(T2C_LanguageEnum.english, List.of("If you want to add more alias commands, simply create another alias file."));
}}),
aliasEnable("alias.enable", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du den Alias deaktivieren."));
put(T2C_LanguageEnum.english, List.of("Here you can disable the alias."));
}}),
aliasList("alias.aliasList", List.of("aliasexample1", "t2caliasexample"), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier an, wie die Alias-Befehle für diese Funktion lauten sollen."));
put(T2C_LanguageEnum.english, List.of("Specify here what the Alias commands should be for this function."));
}}),
permNecessary("alias.permission.necessary", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob für die Verwendung des Alias eine Erlaubnis erforderlich ist."));
put(T2C_LanguageEnum.english, List.of("Here you can say if a permission is needed to use the alias."));
}}),
permission("alias.permission.permission", "t2c.alias.use.[alias]", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du die Berechtigung für den Alias festlegen.", "Der Platzhalter <alias> ist der Alias-Name.", "Wenn du mehrere Alias-Referrer in der Liste 'alias.aliasList' festgelegt hast, hast du für jeden Alias eine Berechtigung."));
put(T2C_LanguageEnum.english, List.of("Here you can set the permission for the alias.", "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."));
}}),
permissionMSG("alias.permission.customNoPermissionMSG", "", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du eine benutzerdefinierte Nicht-Erlaubnis-Meldung für diesen Alias festlegen. Wenn du die Standardmeldung verwenden willst, lass dieses Feld einfach leer."));
put(T2C_LanguageEnum.english, List.of("Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank."));
}}),
cooldownGlobal("alias.cooldownInSec.global", 0, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du eine globale Abklingzeit für diesen Alias festlegen.", "Der Wert entspricht den Sekunden.", "Bei 0 ist die Abklingzeit deaktiviert.", "Der Platzhalter [alias] ist der Name des Alias.", "Bypass permission: t2c.alias.cooldown.global.[alias].bypass", "(Die globale Abklingzeit ist höher als die Abklingzeit des Spielers)."));
put(T2C_LanguageEnum.english, List.of("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)."));
}}),
cooldownPlayer("alias.cooldownInSec.player", 0, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du eine spielerspezifische Abklingzeit für diesen Alias festlegen.", "Der Wert entspricht den Sekunden.", "Bei 0 ist die Abklingzeit deaktiviert.", "Der Platzhalter [alias] ist der Name des Alias.", "Bypass permission: t2c.alias.cooldown.player.[alias].bypass"));
put(T2C_LanguageEnum.english, List.of("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"));
}}),
costEnable("alias.cost.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob du für den Alias bezahlen musst."));
put(T2C_LanguageEnum.english, List.of("Here you can say if you have to pay for the alias."));
}}),
costConfirm("alias.cost.confirm", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einstellen, ob du vor dem Ausführen des Befehls bestätigen musst, ob du bezahlen willst", "In der config.yml kannst du unter 'buy.confirm.use' einstellen, ob ein Befehl, ein chatListener oder eine GUI zur Bestätigung des Befehls verwendet werden soll."));
put(T2C_LanguageEnum.english, List.of("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."));
}}),
costPrice("alias.cost.price", 0.0, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier legst du den Preis fest."));
put(T2C_LanguageEnum.english, List.of("Here you set the price."));
}}),
costAllowBypass("alias.cost.allowByPass", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier legst du fest, ob der Bypass aktiviert ist oder ob du trotz des Bypasses zahlen musst (t2c.alias.buy.[alias].bypass)."));
put(T2C_LanguageEnum.english, List.of("Here you define if the bypass is activated or if you have to pay despite the bypass (t2c.alias.buy.[alias].bypass)."));
}}),
commandEnable("alias.command.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du dem Alias mitteilen, dass er einen oder mehrere Befehle ausführen soll"));
put(T2C_LanguageEnum.english, List.of("Here you can tell the alias to execute one or more commands"));
}}),
commandAsConsole("alias.command.commandAsConsole", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Befehl über die Konsole des Servers ausgeführt werden soll"));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the command should be executed from the console of the server"));
}}),
bungeeCommand("alias.command.proxyCommand", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, ob der Befehl auf dem Proxy ausgeführt werden soll.", "Damit diese Funktion funktioniert, muss die T2CodeLib auf deinem Proxy vorhanden sein und die API für T2C-OPSecurity muss in seiner Konfiguration aktiviert sein!", "(Wenn sie von der Proxy-Konsole aus ausgeführt werden soll, muss die Option CommandAsConsole ebenfalls aktiviert sein)."));
put(T2C_LanguageEnum.english, List.of("Here you can define if the command should be executed on the proxy.", "For this function to work, the T2CodeLib must be present on your proxy and the API for T2C-OPSecurity must be activated in its config!", "(If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled)."));
}}),
command("alias.command.commands", List.of(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einen oder mehrere Befehle angeben, die ausgeführt werden sollen.", "Placeholder: [player] = Der Spieler, der den Alias ausführt"));
put(T2C_LanguageEnum.english, List.of("Here you can specify one or more commands to be executed.", "Placeholder: [player] = The player who executes the alias"));
}}),
messageEnable("alias.message.enable", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Spieler eine Nachricht erhalten soll."));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the player should receive a message."));
}}),
messages("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>"), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier die Nachricht an, die der Spieler erhalten soll.", "Es können mehrere Zeilen verwendet werden und Platzhalter werden unterstützt!", "Placeholder: [player] = Der Spieler, der den Alias ausführt", "#", "Du kannst die Minecraft eigenen Farbcodes verwenden: https://minecraft.fandom.com/de/wiki/Formatierungscodes", "Du kannst auch MiniMessage verwenden:", " Wiki: https://docs.adventure.kyori.net/minimessage/format.html", " WebUI: https://webui.adventure.kyori.net"));
put(T2C_LanguageEnum.english, List.of("Specify here the message that the player should get.", "Multiple lines can be used and placeholders are supported!", "Placeholder: [player] = The player who executes the alias", "#", "You can use Minecraft color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes", "You can also use MiniMessage:", " Wiki: https://docs.adventure.kyori.net/minimessage/format.html", " WebUI: https://webui.adventure.kyori.net"));
}}),
admin("alias.admin", null, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, dass Spieler mit der Berechtigung (Bei der Option alias.admin.permission angegeben) eine andere Funktion haben als andere Spieler.", "Du kannst z.B. sagen, dass Spieler zu einem bestimmten Punkt kommen sollen und Spieler mit der Admin-Funktion nur auf dem Server zu der Position kommen sollen, wo sie vorher waren.", "Example:", "Player: /warp CityBuild", "Spieler mit Admin Perm: /server CityBuild"));
put(T2C_LanguageEnum.english, List.of("Here you can specify that players with the authorisation (specified in the alias.admin.permission option) 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.", "Example:", "Player: /warp CityBuild", "Player with Admin Perm: /server CityBuild"));
}}),
adminEnable("alias.admin.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du die Admin-Funktion aktivieren oder deaktivieren"));
put(T2C_LanguageEnum.english, List.of("Here you can enable or disable the admin function"));
}}),
adminPermission("alias.admin.permission", "t2c.alias.[alias].admin", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier legst du die Berechtigung für die Admin-Funktion fest", "Der Platzhalter [alias] ist der Name des Alias.", "Der Platzhalter [alias] ist der Name des Alias."));
put(T2C_LanguageEnum.english, List.of("Here you set the permission for the admin function", "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."));
}}),
adminCommandEnable("alias.admin.command.enable", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du dem Alias mitteilen, dass er einen oder mehrere Befehle ausführen soll"));
put(T2C_LanguageEnum.english, List.of("Here you can tell the alias to execute one or more commands"));
}}),
adminCommandAsConsole("alias.admin.command.commandAsConsole", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Befehl über die Konsole des Servers ausgeführt werden soll"));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the command should be executed from the console of the server"));
}}),
adminBungeeCommand("alias.admin.command.proxyCommand", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, ob der Befehl auf dem Proxy ausgeführt werden soll.", "For this function to work, the T2CodeLib must be present on your proxy and the API for T2C-OPSecurity must be activated in its config!", "(If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled)."));
put(T2C_LanguageEnum.english, List.of("Here you can define if the command should be executed on the proxy.", "For this function to work, the T2CodeLib must be present on your proxy and the API for T2C-OPSecurity must be activated in its config!", "(If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled)."));
}}),
adminCommands("alias.admin.command.commands", Collections.singletonList("say hi"), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einen oder mehrere Befehle angeben, die ausgeführt werden sollen.", "Placeholder: [player] = Der Spieler, der den Alias ausführt"));
put(T2C_LanguageEnum.english, List.of("Here you can specify one or more commands to be executed.", "Placeholder: [player] = The player who executes the alias"));
}}),
adminMessageEnable("alias.admin.message.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Spieler eine Nachricht erhalten soll."));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the player should receive a message."));
}}),
adminMessages("alias.admin.message.messages", List.of(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier die Nachricht an, die der Spieler erhalten soll.", "Es können mehrere Zeilen verwendet werden und Platzhalter werden unterstützt!", "Placeholder: [player] = Der Spieler, der den Alias ausführt", "#", "Du kannst die Minecraft eigenen Farbcodes verwenden: https://minecraft.fandom.com/de/wiki/Formatierungscodes", "Du kannst auch MiniMessage verwenden:", " Wiki: https://docs.adventure.kyori.net/minimessage/format.html", " WebUI: https://webui.adventure.kyori.net"));
put(T2C_LanguageEnum.english, List.of("Specify here the message that the player should get.", "Multiple lines can be used and placeholders are supported!", "Placeholder: [player] = The player who executes the alias", "#", "You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes", "You can also use MiniMessage:", " Wiki: https://docs.adventure.kyori.net/minimessage/format.html", " WebUI: https://webui.adventure.kyori.net"));
}}),
consoleEnable("alias.console.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, ob der Alias auch in der Konsole verwendet werden kann und was er dort tun soll."));
put(T2C_LanguageEnum.english, List.of("Here you can define if the alias is also usable in the console and what it should do from there."));
}}),
consoleCommandEnable("alias.console.command.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du dem Alias mitteilen, dass er einen oder mehrere Befehle ausführen soll"));
put(T2C_LanguageEnum.english, List.of("Here you can tell the alias to execute one or more commands"));
}}),
consoleBungeeCommand("alias.console.command.proxyCommand", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, ob der Befehl auf dem Proxy ausgeführt werden soll.", "Damit diese Funktion funktioniert, muss die T2CodeLib auf deinem Proxy vorhanden sein und die API für T2C-OPSecurity muss in seiner Konfiguration aktiviert sein!", "(Wenn sie von der Proxy-Konsole aus ausgeführt werden soll, muss die Option CommandAsConsole ebenfalls aktiviert sein)."));
put(T2C_LanguageEnum.english, List.of("Here you can define if the command should be executed on the proxy.", "For this function to work, the T2CodeLib must be present on your proxy and the API for T2C-OPSecurity must be activated in its config!", "(If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled)."));
}}),
consoleCommands("alias.console.command.commands", List.of(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einen oder mehrere Befehle angeben, die ausgeführt werden sollen."));
put(T2C_LanguageEnum.english, List.of("Here you can specify one or more commands to be executed."));
}}),
consoleMessageEnable("alias.console.message.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Spieler eine Nachricht erhalten soll."));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the player should receive a message."));
}}),
consoleMessages("alias.console.message.messages", List.of(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier die Nachricht an, die der Spieler erhalten soll."));
put(T2C_LanguageEnum.english, List.of("Specify here the message that the player should get."));
}}),
;
private final String path;
private Object value;
private final boolean forceSet;
private final HashMap<T2C_LanguageEnum, List<String>> comments;
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, List<String>> comments) {
this.path = path;
this.value = value;
this.forceSet = forceSet;
this.comments = comments;
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean getForceSet() {
return forceSet;
}
@Override
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
return comments;
}
@Override
public String getLanguagePath() {
return Config.VALUES.language.getValue().toString();
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
public static void set(boolean isReload) {
ConfigFileConverter.convert();
File f = new File(Main.getPath() + "/alias/");
File[] fileArray = f.listFiles();
if (fileArray == null) {
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "alias/aliasexample.yml"), VALUES.values(), isReload, Util.getConfigLogo());
}
for (File file : fileArray) {
String sub = file.getName().substring(file.getName().length() - 4);
if (sub.equals(".yml")) {
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "alias/" + file.getName()), VALUES.values(), isReload, Util.getConfigLogo());
for (String s : (List<String>) VALUES.aliasList.value) {
if (s != null) {
Main.allAliases.add(s);
}
}
AliasObject alias = new AliasObject(
(boolean) VALUES.aliasEnable.value,
(List<String>) VALUES.aliasList.value,
(boolean) VALUES.permNecessary.value,
(String) VALUES.permission.value,
(String) VALUES.permissionMSG.value,
(int) VALUES.cooldownGlobal.value,
(int) VALUES.cooldownPlayer.value,
(boolean) VALUES.costEnable.value,
(boolean) VALUES.costConfirm.value,
(double) VALUES.costPrice.value,
(boolean) VALUES.costAllowBypass.value,
(boolean) VALUES.commandEnable.value,
(boolean) VALUES.commandAsConsole.value,
(boolean) VALUES.bungeeCommand.value,
(List<String>) VALUES.command.value,
(boolean) VALUES.messageEnable.value,
(List<String>) VALUES.messages.value,
(boolean) VALUES.adminEnable.value,
(String) VALUES.adminPermission.value,
(boolean) VALUES.adminCommandEnable.value,
(boolean) VALUES.adminCommandAsConsole.value,
(boolean) VALUES.adminBungeeCommand.value,
(List<String>) VALUES.adminCommands.value,
(boolean) VALUES.adminMessageEnable.value,
(List<String>) VALUES.adminMessages.value,
(boolean) VALUES.consoleEnable.value,
(boolean) VALUES.consoleCommandEnable.value,
(boolean) VALUES.consoleBungeeCommand.value,
(List<String>) VALUES.consoleCommands.value,
(boolean) VALUES.consoleMessageEnable.value,
(List<String>) VALUES.consoleMessages.value);
for (String al : (List<String>) VALUES.aliasList.value) {
Main.aliasHashMap.put(al, alias);
}
}
}
new AliasRegister(Main.getInstance(), isReload);
}
}

View File

@ -0,0 +1,145 @@
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.Util;
import net.t2code.t2codelib.SPIGOT.api.items.T2C_ItemVersion;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
import net.t2code.t2codelib.util.T2C_ConfigItem;
import net.t2code.t2codelib.util.T2C_LanguageEnum;
import java.io.File;
import java.util.HashMap;
import java.util.List;
public class Config {
public enum VALUES implements T2C_ConfigItem {
language("plugin.language", "english", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du die Sprache des Plugins einstellen."));
put(T2C_LanguageEnum.english, List.of("Here you can set the language of the plugin."));
}}),
updateCheckOnJoin("plugin.updateCheck.onJoin", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Mit dieser Option kannst du festlegen, ob Spieler mit der Berechtigung 't2c.opsecurity.updatemsg' beim Beitritt eine Update-Nachricht erhalten, wenn ein Update für das Plugin verfügbar ist."));
put(T2C_LanguageEnum.english, List.of("In this option you can set if players with the permission 't2c.opsecurity.updatemsg' will get an update message on join when an update for the plugin is available."));
}}),
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("In dieser Option kannst du einstellen, ob du Beta- und Snapshot-Versionen in der Update-Prüfung erhalten und anzeigen möchtest."));
put(T2C_LanguageEnum.english, List.of("In this option you can set whether you want to receive and display beta and snapshot versions in the update check."));
}}),
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Mit dieser Option kannst du das Zeitintervall in Minuten festlegen, in dem Aktualisierungen überprüft werden sollen."));
put(T2C_LanguageEnum.english, List.of("In this option you can set the time interval in minutes in which updates should be checked."));
}}),
buyMessage("buy.message", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Mit dieser Option kannst du einstellen, ob nach der Zahlung für einen Alias, für den man bezahlen muss, eine Bestätigung gesendet werden soll."));
put(T2C_LanguageEnum.english, List.of("With this option you can set whether a confirmation should be sent after the payment for an alias for which you have to pay."));
}}),
buyCurrency("buy.currency", "$", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of(""));
put(T2C_LanguageEnum.english, List.of("With this option you set the currency."));
}}),
buyConfirmDefault("buy.confirm.use", Confirm.COMMAND, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kann man wählen, welche Bestätigungsmethode verwendet werden möchte. (COMMAND, CHAT, GUI)"));
put(T2C_LanguageEnum.english, List.of("Here you can choose which confirmation method you want to use. (COMMAND, CHAT, GUI)"));
}}),
buyConfirmGuiFillItemDesc("buy.confirm.gui.fillItem", null, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("","!! Du kannst den GUI-Namen und die Schaltflächentexte in der Sprachdatei ändern !!",""));
put(T2C_LanguageEnum.english, List.of(" ", "!! You can change the GUI name and the button texts in the language file !!", " "));
}}),
buyConfirmGuiFillItemEnabled("buy.confirm.gui.fillItem.enabled", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einstellen, ob ein Fillitem in der Confirm GUI verwendet werden soll."));
put(T2C_LanguageEnum.english, List.of("Here you can set if a fillitem should be used in the Confirm GUI."));
}}),
buyConfirmGuiFillItem("buy.confirm.gui.fillItem.material", T2C_ItemVersion.getBlackStainedGlassPane().getType().toString(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einstellen, welches Fillitem in der Confirm GUI verwendet werden soll."));
put(T2C_LanguageEnum.english, List.of("Here you can set which fillitem should be used in the Confirm GUI."));
}}),
buyConfirmGuiConfirm("buy.confirm.gui.confirm.material", T2C_ItemVersion.getGreenWool().getType().toString(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du das Material für die Bestätigungsschaltfläche festlegen."));
put(T2C_LanguageEnum.english, List.of("Here you can set the material for the confirmation button."));
}}),
buyConfirmGuiCancel("buy.confirm.gui.cancel.material", T2C_ItemVersion.getRedWool().getType().toString(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du das Material für die Abbruchtaste festlegen."));
put(T2C_LanguageEnum.english, List.of("Here you can set the material for the cancel button."));
}}),
subAliasTab("subAlias.tabComplete", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einstellen, ob Unterbefehle als tabComplete angezeigt werden sollen."));
put(T2C_LanguageEnum.english, List.of("Here you can set if subcommands should be displayed as tabComplete."));
}}),
;
private final String path;
private Object value;
private final boolean forceSet;
private final HashMap<T2C_LanguageEnum, List<String>> comments;
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, List<String>> comments) {
this.path = path;
this.value = value;
this.forceSet = forceSet;
this.comments = comments;
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean getForceSet() {
return forceSet;
}
@Override
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
return comments;
}
@Override
public String getLanguagePath() {
return language.path;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
public static void set(boolean isReload) {
T2C_ConfigWriter.createConfig(Util.getPrefix(),new File(Main.getPath(), "config.yml"), VALUES.values(),isReload, Util.getConfigLogo());
}
}

View File

@ -1,40 +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 Integer ConfigVersion = 2;
public static void configCreate() {
long long_ = System.currentTimeMillis();
if (new File(Main.getPath(), "config.yml").exists()) {
if (Main.plugin.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);
yamlConfiguration.set("ConfigVersion", ConfigVersion);
Config.set("Plugin.language", "english", yamlConfiguration);
Config.set("BungeeCord.Enable", false, yamlConfiguration);
Config.set("BungeeCord.ThisServer", "server", yamlConfiguration);
Config.set("Buy.Message", 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");
}
}

View File

@ -1,71 +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;
import java.util.Collections;
public class CreateExampleAliasConfig {
public static void configCreate() {
long long_ = System.currentTimeMillis();
send.console(Util.getPrefix() + " §4Alias/aliasexample.yml are created...");
File config = new File(Main.getPath(), "Alias/aliasexample.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
Config.set("Alias.Enable", true, yamlConfiguration);
Config.set("Alias.Permission.Necessary", true, yamlConfiguration);
Config.set("Alias.Cost.Enable", false,yamlConfiguration);
Config.set("Alias.Cost.Price", 0.0,yamlConfiguration);
Config.set("Alias.Cost.AllowByPass", true,yamlConfiguration);
Config.set("Alias.Command.Enable", true, yamlConfiguration);
Config.set("Alias.Command.CommandAsConsole", true, yamlConfiguration);
Config.set("Alias.Command.BungeeCommand", false, yamlConfiguration);
Config.set("Alias.Command.Commands", Collections.singletonList("say hi"), yamlConfiguration);
Config.set("Alias.Message.Enable", false, yamlConfiguration);
Config.set("Alias.Message.Messages", Collections.emptyList(), yamlConfiguration);
Config.set("Alias.Message.TextBuilder.Enable", false, yamlConfiguration);
Config.set("Alias.Message.TextBuilder.Hover", "", yamlConfiguration);
Config.set("Alias.Message.TextBuilder.ClickEvent.Enable", false, yamlConfiguration);
Config.set("Alias.Message.TextBuilder.ClickEvent.Action", "", yamlConfiguration);
Config.set("Alias.Message.TextBuilder.ClickEvent.ActionValue", "", yamlConfiguration);
Config.set("Alias.Admin.Enable", true, yamlConfiguration);
Config.set("Alias.Admin.Permission", "t2code.alias.admin", yamlConfiguration);
Config.set("Alias.Admin.Command.Enable", true, yamlConfiguration);
Config.set("Alias.Admin.Command.CommandAsConsole", true, 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);
Config.set("Alias.Admin.Message.Messages", Collections.emptyList(), yamlConfiguration);
Config.set("Alias.Admin.Message.TextBuilder.Enable", false, yamlConfiguration);
Config.set("Alias.Admin.Message.TextBuilder.Hover", "", yamlConfiguration);
Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.Enable", false, yamlConfiguration);
Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.Action", "", yamlConfiguration);
Config.set("Alias.Admin.Message.TextBuilder.ClickEvent.ActionValue", "", yamlConfiguration);
Config.set("Alias.Console.Enable", false, yamlConfiguration);
Config.set("Alias.Console.Command.Enable", false, yamlConfiguration);
Config.set("Alias.Console.Command.BungeeCommand", false, yamlConfiguration);
Config.set("Alias.Console.Command.Commands", Collections.emptyList(), yamlConfiguration);
Config.set("Alias.Console.Message.Enable", false, yamlConfiguration);
Config.set("Alias.Console.Message.Messages", Collections.emptyList(), yamlConfiguration);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
send.console(Util.getPrefix() + " §2Alias/aliasexample.yml were successfully created." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@ -0,0 +1,256 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.enums.ConfigParam;
import net.t2code.alias.util.Util;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_LanguageWriter;
import net.t2code.t2codelib.util.T2C_ConfigItemLanguages;
import net.t2code.t2codelib.util.T2C_LanguageEnum;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public class Language {
public enum VALUES implements T2C_ConfigItemLanguages {
otherLang("plugin", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, null);
put(T2C_LanguageEnum.english, null);
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Wenn du eine Eigene Sprache hinzufügen magst, dann kopiere einfach eine Sprachdatei und benenne sie in deine Sprache, dies kannst du dann in der config.yml einstellen.", ""));
put(T2C_LanguageEnum.english, List.of("If you want to add your own language, simply copy a language file and rename it to your language, you can then set this in config.yml.", ""));
}}),
onlyForPlayer("plugin.onlyForPlayer", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <red>Dieser Command ist nur f[ue]r Spieler!</red>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <red>This command is for players only!</red>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
aliasDisabled("plugin.aliasDisabled", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Unknown command. Type ''/help'' for help."));
put(T2C_LanguageEnum.english, List.of("Unknown command. Type ''/help'' for help."));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
reloadStart("plugin.reload.start", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <gold>Plugin wird neu geladen...</gold>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <gold>Plugin is reloaded...</gold>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
reloadEnd("plugin.reload.end", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <dark_green>Plugin wurde erfolgreich neu geladen.</dark_green>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <dark_green>Plugin was successfully reloaded.</dark_green>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
noPermission("plugin.noPermissionForCommand", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <red>F[ue]r <aqua>[cmd]</aqua> fehlt dir die Permission <gold>[perm]</gold>!</red>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <red>For <aqua>[cmd]</aqua> you lack the permission <gold>[perm]</gold>!</red>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
noSubCommand("plugin.noSubCommand", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <red>Diesen Befehl gibt es nicht!</red>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <red>This command does not exist!</red>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
buy("cost.buy", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <dark_green>Du hast f[ue]r diesen Command <gold>[price]</gold> bezahlt.</dark_green>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <dark_green>You have paid <gold>[price]</gold> for this command.</dark_green>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
noMoney("cost.noMoney", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <red>Du hast nicht gen[ue]gend Geld für diesen Command!</red>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <red>You don't have enough money for this command!</red>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
cooldownPlayer("cooldown.player", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <red>Du musst noch <gold>[cooldown]</gold> Sekunden warten um diesen Command erneut zu nutzen.</red>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <red>You must wait <gold>[cooldown]</gold> seconds to use this command again.</red>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
cooldownGlobal("cooldown.global", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <red>Du musst noch <gold>[cooldown]</gold> Sekunden warten um diesen Command zu nutzen.</red>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <red>You have to wait <gold>[cooldown]</gold> seconds to use this command.</red>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmCommand("cost.confirm.command", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[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>"));
put(T2C_LanguageEnum.english, List.of("[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>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmChat("cost.confirm.chat", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[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>"));
put(T2C_LanguageEnum.english, List.of("[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>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmGuiTitle("cost.confirm.gui.title", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("&2Bestätige den Zahlvorgang für: &6/[alias]"));
put(T2C_LanguageEnum.english, List.of("&2Confirm the payment process for: &6/[alias]"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmGuiConfirm("cost.confirm.gui.confirm.displayName", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("&2Bestätigen"));
put(T2C_LanguageEnum.english, List.of("&2Confirm"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmGuiConfirmLore("cost.confirm.gui.confirm.lore", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("&aDieser Befehl kostet", "&6[price]"));
put(T2C_LanguageEnum.english, List.of("&aThis command costs", "&6[price]"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmGuiCancel("cost.confirm.gui.cancel.displayName", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german,List.of( "&cAbbrechen"));
put(T2C_LanguageEnum.english, List.of("&cCancel"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmGuiCancelLore("cost.confirm.gui.cancel.lore", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of(""));
put(T2C_LanguageEnum.english, List.of(""));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmCancel("cost.confirm.cancel", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <gold>Der befehl wurde abgebrochen und du musst nichts bezahlen!</gold>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <gold>The command was canceled and you do not have to pay anything!</gold>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
confirmNotPossible("cost.confirm.notPossible", null,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("[prefix] <gold>Bestätigen nicht möglich, du hast keinen zahlungspflichtigen befehl ausgeführt.</gold>"));
put(T2C_LanguageEnum.english, List.of("[prefix] <gold>Confirmation not possible, you have not executed a payable command.</gold>"));
}},
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of());
put(T2C_LanguageEnum.english, List.of());
}}),
;
private final String path;
private Object value;
private final HashMap<T2C_LanguageEnum, List<String>> lang;
private final HashMap<T2C_LanguageEnum, List<String>> comments;
VALUES(String path, Object value, HashMap<T2C_LanguageEnum, List<String>> lang, HashMap<T2C_LanguageEnum, List<String>> comments) {
this.path = path;
this.value = value;
this.lang = lang;
this.comments = comments;
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
if (value == null) {
return lang.get(T2C_LanguageEnum.english);
}
return value;
}
@Override
public HashMap<T2C_LanguageEnum, List<String>> getLanguage() {
return lang;
}
@Override
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
return comments;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
public static void set(boolean isReload) {
T2C_LanguageWriter.createConfig(Util.getPrefix(), Main.getPath(), VALUES.values(), Config.VALUES.language.getValue().toString(), isReload, Util.getConfigLogo());
}
}

View File

@ -1,75 +0,0 @@
package net.t2code.alias.Spigot.config.config;
import net.minecraft.world.level.levelgen.DensityFunctions;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.system.AliasRegister;
import net.t2code.alias.Spigot.objects.AliasObjekt;
import net.t2code.alias.Util;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class SelectAlias {
private static String Prefix = Util.getPrefix();
public static void onSelect() {
Main.aliasHashMap.clear();
Main.allAliases.clear();
File f = new File(Main.getPath() + "/Alias/");
File[] fileArray = f.listFiles();
for (File config_gui : fileArray) {
if (config_gui.getName().equals("X_aliasDeclaration_X.yml")) continue;
String sub = config_gui.getName().substring(config_gui.getName().length() - 4);
if (sub.equals(".yml")) {
Main.allAliases.add(config_gui.getName().replace(".yml", ""));
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config_gui);
AliasObjekt alias = new AliasObjekt(
yamlConfiguration.getBoolean("Alias.Enable"),
yamlConfiguration.getBoolean("Alias.Permission.Necessary"),
yamlConfiguration.getBoolean("Alias.Cost.Enable"),
yamlConfiguration.getDouble("Alias.Cost.Price"),
yamlConfiguration.getBoolean("Alias.Cost.AllowByPass"),
yamlConfiguration.getBoolean("Alias.Command.Enable"),
yamlConfiguration.getBoolean("Alias.Command.CommandAsConsole"),
yamlConfiguration.getBoolean("Alias.Command.BungeeCommand"),
yamlConfiguration.getStringList("Alias.Command.Commands"),
yamlConfiguration.getBoolean("Alias.Message.Enable"),
yamlConfiguration.getStringList("Alias.Message.Messages"),
yamlConfiguration.getBoolean("Alias.Message.TextBuilder.Enable"),
yamlConfiguration.getString("Alias.Message.TextBuilder.Hover"),
yamlConfiguration.getBoolean("Alias.Message.TextBuilder.ClickEvent.Enable"),
yamlConfiguration.getString("Alias.Message.TextBuilder.ClickEvent.Action"),
yamlConfiguration.getString("Alias.Message.TextBuilder.ClickEvent.ActionValue"),
yamlConfiguration.getBoolean("Alias.Admin.Enable"),
yamlConfiguration.getString("Alias.Admin.Permission"),
yamlConfiguration.getBoolean("Alias.Admin.Command.Enable"),
yamlConfiguration.getBoolean("Alias.Admin.Command.CommandAsConsole"),
yamlConfiguration.getBoolean("Alias.Admin.Command.BungeeCommand"),
yamlConfiguration.getStringList("Alias.Admin.Command.Commands"),
yamlConfiguration.getBoolean("Alias.Admin.Message.Enable"),
yamlConfiguration.getStringList("Alias.Admin.Message.Messages"),
yamlConfiguration.getBoolean("Alias.Admin.Message.TextBuilder.Enable"),
yamlConfiguration.getString("Alias.Admin.Message.TextBuilder.Hover"),
yamlConfiguration.getBoolean("Alias.Admin.Message.TextBuilder.ClickEvent.Enable"),
yamlConfiguration.getString("Alias.Admin.Message.TextBuilder.ClickEvent.Action"),
yamlConfiguration.getString("Alias.Admin.Message.TextBuilder.ClickEvent.ActionValue"),
yamlConfiguration.getBoolean("Alias.Console.Enable"),
yamlConfiguration.getBoolean("Alias.Console.Command.Enable"),
yamlConfiguration.getBoolean("Alias.Console.Command.BungeeCommand"),
yamlConfiguration.getStringList("Alias.Console.Command.Commands"),
yamlConfiguration.getBoolean("Alias.Console.Message.Enable"),
yamlConfiguration.getStringList("Alias.Console.Message.Messages"));
Main.aliasHashMap.put(config_gui.getName().replace(".yml", ""), alias);
AliasRegister.onRegister();
}
}
}
}

View File

@ -1,29 +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;
public class SelectConfig {
public static Integer ConfigVersion;
public static Boolean UpdateCheckOnJoin;
public static String language;
public static Boolean Bungee;
public static String thisServer;
public static Boolean buyMessage;
public static void onSelect() {
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
ConfigVersion =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");
}
}

View File

@ -1,75 +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 {
private static Plugin plugin = Main.plugin;
public static void langCreate() {
send.debug(plugin,"§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(plugin,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(plugin,e.getMessage());
e.printStackTrace();
}
send.console(Util.getPrefix() + " §2Language files were successfully created / updated." + " §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@ -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] &cThis command is for players only!";
public static String EN_Disabled = "Unknown command. Type ''/help'' for help.";
public static String EN_ReloadStart = "[prefix] &6Plugin is reloaded...";
public static String EN_ReloadEnd = "[prefix] &2Plugin was successfully reloaded.";
public static String EN_NoPermissionForCommand = "[prefix] &cFor &b[cmd] &cyou lack the permission &6[perm]&c!";
public static String EN_Buy = "[prefix] &2You have paid &6[price] &2for this command.&2.";
public static String EN_NoMoney = "[prefix] &cYou don't have enough money for this command!";
// DE
public static String DE_OnlyForPlayer = "[prefix] &cDieser Command ist nur f[ue]r Spieler!";
public static String DE_Disabled = "Unknown command. Type ''/help'' for help.";
public static String DE_ReloadStart = "[prefix] &6Plugin wird neu geladen...";
public static String DE_ReloadEnd = "[prefix] &2Plugin wurde erfolgreich neu geladen.";
public static String DE_NoPermissionForCommand = "[prefix] &cF[ue]r &b[cmd] &cfehlt dir die Permission &6[perm]&c!";
public static String DE_Buy = "[prefix] &2Du hast f[ue]r diesen Command &6[price] &2bezahlt.";
public static String DE_NoMoney = "[prefix] &cDu hast nicht gen[ue]gend Geld für diesen Command!";
}

View File

@ -1,61 +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.plugin, "§4Select language...");
Long long_ = Long.valueOf(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);
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_.longValue()) + "ms");
}
private static String replace(String text) {
return Replace.replace(Util.getPrefix(), text);
}
}

View File

@ -0,0 +1,350 @@
// This class was created by JaTiTV.
package net.t2code.alias.Spigot.config.subAlias;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.config.ConfigFileConverter;
import net.t2code.alias.Spigot.config.config.Config;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.util.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2C_ConfigWriter;
import net.t2code.t2codelib.util.T2C_ConfigItem;
import net.t2code.t2codelib.util.T2C_LanguageEnum;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
public class SubAliasFile {
public enum VALUES implements T2C_ConfigItem {
aliasEnable("subAlias.enable", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du den Alias deaktivieren."));
put(T2C_LanguageEnum.english, List.of("Here you can disable the alias."));
}}),
subAliasList("subAlias.subAliasList", List.of("subaliasexample1"), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier an, wie die SubAlias-Befehle für diese Funktion lauten sollen"));
put(T2C_LanguageEnum.english, List.of("Specify here what the SubAlias commands should be for this function"));
}}),
subAliasFor("subAlias.subAliasFor", "aliasexample1", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier den Alias-Befehl ein, dem die Subalias folgen sollen.","Zum Beispiel:"," - aliasexample1 -> aliasexample1 <this SubAlias>"," - aliasexample2 test -> aliasexample2 test <this SubAlias>"));
put(T2C_LanguageEnum.english, List.of("Enter here the alias command where the subalias should follow.","For example:"," - aliasexample1 -> aliasexample1 <this SubAlias>"," - aliasexample2 test -> aliasexample2 test <this SubAlias>"));
}}),
permNecessary("subAlias.permission.necessary", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob für die Verwendung des Alias eine Erlaubnis erforderlich ist."));
put(T2C_LanguageEnum.english, List.of("Here you can say if a permission is needed to use the alias."));
}}),
permission("subAlias.permission.permission", "t2c.alias.sub.use.[alias]", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du die Berechtigung für den Alias festlegen.", "Der Platzhalter <alias> ist der Alias-Name.", "Wenn du mehrere Alias Commands in der Liste 'subAlias.subAliasList' festgelegt hast, hast du für jeden Alias eine Berechtigung."));
put(T2C_LanguageEnum.english, List.of("Here you can set the permission for the alias.", "The placeholder <alias> is the alias name.", "If you have set multiple alias referrers in the list 'subAlias.subAliasList' you have a permission for each alias."));
}}),
permissionMSG("subAlias.permission.customNoPermissionMSG", "", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du eine benutzerdefinierte Nicht-Erlaubnis-Meldung für diesen Alias festlegen. Wenn du die Standardmeldung verwenden willst, lass dieses Feld einfach leer."));
put(T2C_LanguageEnum.english, List.of("Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank."));
}}),
cooldownGlobal("subAlias.cooldownInSec.global", 0, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du eine globale Abklingzeit für diesen Alias festlegen.", "Der Wert entspricht den Sekunden.", "Bei 0 ist die Abklingzeit deaktiviert.", "Der Platzhalter [alias] ist der Name des Alias.", "Bypass permission: t2c.alias.cooldown.global.[alias].bypass", "(Die globale Abklingzeit ist höher als die Abklingzeit des Spielers)."));
put(T2C_LanguageEnum.english, List.of("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)."));
}}),
cooldownPlayer("subAlias.cooldownInSec.player", 0, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du eine spielerspezifische Abklingzeit für diesen Alias festlegen.", "Der Wert entspricht den Sekunden.", "Bei 0 ist die Abklingzeit deaktiviert.", "Der Platzhalter [alias] ist der Name des Alias.", "Bypass permission: t2c.alias.cooldown.player.[alias].bypass"));
put(T2C_LanguageEnum.english, List.of("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"));
}}),
costEnable("subAlias.cost.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob du für den Alias bezahlen musst."));
put(T2C_LanguageEnum.english, List.of("Here you can say if you have to pay for the alias."));
}}),
costConfirm("subAlias.cost.confirm", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einstellen, ob du vor dem Ausführen des Befehls bestätigen musst, ob du bezahlen willst", "In der config.yml kannst du unter 'buy.confirm.use' einstellen, ob ein Befehl, ein chatListener oder eine GUI zur Bestätigung des Befehls verwendet werden soll."));
put(T2C_LanguageEnum.english, List.of("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."));
}}),
costPrice("subAlias.cost.price", 0.0, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier legst du den Preis fest."));
put(T2C_LanguageEnum.english, List.of("Here you set the price."));
}}),
costAllowBypass("subAlias.cost.allowByPass", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier legst du fest, ob der Bypass aktiviert ist oder ob du trotz des Bypasses zahlen musst (t2c.alias.buy.[alias].bypass)."));
put(T2C_LanguageEnum.english, List.of("Here you define if the bypass is activated or if you have to pay despite the bypass (t2c.alias.buy.[alias].bypass)."));
}}),
commandEnable("subAlias.command.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du dem Alias mitteilen, dass er einen oder mehrere Befehle ausführen soll"));
put(T2C_LanguageEnum.english, List.of("Here you can tell the alias to execute one or more commands"));
}}),
commandAsConsole("subAlias.command.commandAsConsole", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Befehl über die Konsole des Servers ausgeführt werden soll"));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the command should be executed from the console of the server"));
}}),
bungeeCommand("subAlias.command.proxyCommand", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, ob der Befehl auf dem Proxy ausgeführt werden soll.", "Damit diese Funktion funktioniert, muss die T2CodeLib auf deinem Proxy vorhanden sein und die API für T2C-OPSecurity muss in seiner Konfiguration aktiviert sein!", "(Wenn sie von der Proxy-Konsole aus ausgeführt werden soll, muss die Option CommandAsConsole ebenfalls aktiviert sein)"));
put(T2C_LanguageEnum.english, List.of("Here you can define if the command should be executed on the proxy.", "For this function to work, the T2CodeLib must be present on your proxy and the API for T2C-OPSecurity must be activated in its config!", "(If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled)"));
}}),
command("subAlias.command.commands", List.of(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einen oder mehrere Befehle angeben, die ausgeführt werden sollen.", "Placeholder: [player] = Der Spieler, der den Alias ausführt"));
put(T2C_LanguageEnum.english, List.of("Here you can specify one or more commands to be executed.", "Placeholder: [player] = The player who executes the alias"));
}}),
messageEnable("subAlias.message.enable", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Spieler eine Nachricht erhalten soll."));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the player should receive a message."));
}}),
messages("subAlias.message.messages", List.of("This is a test subvcommand of T2C-Alias."), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier die Nachricht an, die der Spieler erhalten soll.", "Gib hier die Nachricht an, die der Spieler erhalten soll.", "Placeholder: [player] = Der Spieler, der den Alias ausführt", "#", "Du kannst die Minecraft eigenen Farbcodes verwenden: https://minecraft.fandom.com/de/wiki/Formatierungscodes", "Du kannst auch MiniMessage verwenden:", " Wiki: https://docs.adventure.kyori.net/minimessage/format.html", " WebUI: https://webui.adventure.kyori.net"));
put(T2C_LanguageEnum.english, List.of("Specify here the message that the player should get.", "Multiple lines can be used and placeholders are supported!", "Placeholder: [player] = The player who executes the alias", "#", "You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes", "You can also use MiniMessage:", " Wiki: https://docs.adventure.kyori.net/minimessage/format.html", " WebUI: https://webui.adventure.kyori.net"));
}}),
admin("subAlias.admin", null, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, dass Spieler mit der (in der Option subAlias.admin.permission angegebenen) Erlaubnis eine andere Funktion haben als andere Spieler.", "Du kannst z.B. sagen, dass Spieler zu einem bestimmten Punkt kommen sollen und Spieler mit der Admin-Funktion nur auf dem Server zu der Position kommen sollen, wo sie vorher waren.", "Beispiel:", "Spieler: /warp CityBuild", "Spieler mit Admin Permission: /server CityBuild"));
put(T2C_LanguageEnum.english, List.of("Here you can specify that players with the permission (specified in the subAlias.admin.permission option) 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.", "Example:", "Player: /warp CityBuild", "Player with Admin Perm: /server CityBuild"));
}}),
adminEnable("subAlias.admin.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du die Admin-Funktion aktivieren oder deaktivieren"));
put(T2C_LanguageEnum.english, List.of("Here you can enable or disable the admin function"));
}}),
adminPermission("subAlias.admin.permission", "t2c.alias.[alias].admin", true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier legst du die Berechtigung für die Admin-Funktion fest","Der Platzhalter [alias] ist der Name des Alias.","Wenn du mehrere Alias-Referrer in der Liste 'subAlias.subAliasList' festgelegt hast, hast du für jeden Alias eine Berechtigung."));
put(T2C_LanguageEnum.english, List.of("Here you set the permission for the admin function","The placeholder [alias] is the alias name.","If you have set multiple alias referrers in the list 'subAlias.subAliasList' you have a permission for each alias."));
}}),
adminCommandEnable("subAlias.admin.command.enable", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du dem Alias mitteilen, dass er einen oder mehrere Befehle ausführen soll"));
put(T2C_LanguageEnum.english, List.of("Here you can tell the alias to execute one or more commands"));
}}),
adminCommandAsConsole("subAlias.admin.command.commandAsConsole", true, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Befehl über die Konsole des Servers ausgeführt werden soll"));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the command should be executed from the console of the server"));
}}),
adminBungeeCommand("subAlias.admin.command.proxyCommand", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, ob der Befehl auf dem Proxy ausgeführt werden soll.", "Damit diese Funktion funktioniert, muss die T2CodeLib auf deinem Proxy vorhanden sein und die API für T2C-Alias muss in seiner Konfiguration aktiviert sein!", "(Wenn sie von der Proxy-Konsole aus ausgeführt werden soll, muss die Option CommandAsConsole ebenfalls aktiviert sein)."));
put(T2C_LanguageEnum.english, List.of("Here you can define if the command should be executed on the proxy.", "For this function to work, the T2CodeLib must be present on your proxy and the API for T2C-Alias must be activated in its config!", "(If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled)."));
}}),
adminCommands("subAlias.admin.command.commands", Collections.singletonList("say hi"), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einen oder mehrere Befehle angeben, die ausgeführt werden sollen.", "Placeholder: [player] = Symbolleiste anpassen..."));
put(T2C_LanguageEnum.english, List.of("Here you can specify one or more commands to be executed.", "Placeholder: [player] = The player who executes the alias"));
}}),
adminMessageEnable("subAlias.admin.message.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Spieler eine Nachricht erhalten soll."));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the player should receive a message."));
}}),
adminMessages("subAlias.admin.message.messages", List.of(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier die Nachricht an, die der Spieler erhalten soll.", "Es können mehrere Zeilen verwendet werden und Platzhalter werden unterstützt!", "Placeholder: [player] = Der Spieler, der den Alias ausführt", "#", "Du kannst die Minecraft eigenen Farbcodes verwenden:: https://minecraft.fandom.com/de/wiki/Formatierungscodes", "Du kannst auch MiniMessage verwenden:", " Wiki: https://docs.adventure.kyori.net/minimessage/format.html", " WebUI: https://webui.adventure.kyori.net"));
put(T2C_LanguageEnum.english, List.of("Specify here the message that the player should get.", "Multiple lines can be used and placeholders are supported!", "Placeholder: [player] = The player who executes the alias", "#", "You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes", "You can also use MiniMessage:", " Wiki: https://docs.adventure.kyori.net/minimessage/format.html", " WebUI: https://webui.adventure.kyori.net"));
}}),
consoleEnable("subAlias.console.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, ob der Alias auch in der Konsole verwendet werden kann und was er dort tun soll."));
put(T2C_LanguageEnum.english, List.of("Here you can define if the alias is also usable in the console and what it should do from there."));
}}),
consoleCommandEnable("subAlias.console.command.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du dem Alias mitteilen, dass er einen oder mehrere Befehle ausführen soll"));
put(T2C_LanguageEnum.english, List.of("Here you can tell the alias to execute one or more commands"));
}}),
consoleBungeeCommand("subAlias.console.command.proxyCommand", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du festlegen, ob der Befehl auf dem Proxy ausgeführt werden soll.", "Damit diese Funktion funktioniert, muss die T2CodeLib auf deinem Proxy vorhanden sein und die API für T2C-Alias muss in seiner Konfiguration aktiviert sein!", "(Wenn sie von der Proxy-Konsole aus ausgeführt werden soll, muss die Option CommandAsConsole ebenfalls aktiviert sein)"));
put(T2C_LanguageEnum.english, List.of("Here you can define if the command should be executed on the proxy.", "For this function to work, the T2CodeLib must be present on your proxy and the API for T2C-Alias must be activated in its config!", "(If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled)"));
}}),
consoleCommands("subAlias.console.command.commands", List.of(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du einen oder mehrere Befehle angeben, die ausgeführt werden sollen."));
put(T2C_LanguageEnum.english, List.of("Here you can specify one or more commands to be executed."));
}}),
consoleMessageEnable("subAlias.console.message.enable", false, true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Hier kannst du angeben, ob der Spieler eine Nachricht erhalten soll."));
put(T2C_LanguageEnum.english, List.of("Here you can specify whether the player should receive a message."));
}}),
consoleMessages("subAlias.console.message.messages", List.of(), true,
new HashMap<>() {{
put(T2C_LanguageEnum.german, List.of("Gib hier die Nachricht an, die der Spieler erhalten soll."));
put(T2C_LanguageEnum.english, List.of("Specify here the message that the player should get."));
}}),
;
private final String path;
private Object value;
private final boolean forceSet;
private final HashMap<T2C_LanguageEnum, List<String>> comments;
VALUES(String path, Object value, boolean forceSet, HashMap<T2C_LanguageEnum, List<String>> comments) {
this.path = path;
this.value = value;
this.forceSet = forceSet;
this.comments = comments;
}
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean getForceSet() {
return forceSet;
}
@Override
public HashMap<T2C_LanguageEnum, List<String>> getComments() {
return comments;
}
@Override
public String getLanguagePath() {
return Config.VALUES.language.getPath();
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
public static void set(boolean isReload) {
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "subAlias/subaliasexample.yml"), VALUES.values(), isReload, Util.getConfigLogo());
}
public static void select(boolean isReload) {
ConfigFileConverter.convert();
File f = new File(Main.getPath() + "/subAlias/");
File[] fileArray = f.listFiles();
assert fileArray != null;
for (File file : fileArray) {
String sub = file.getName().substring(file.getName().length() - 4);
if (sub.equals(".yml")) {
T2C_ConfigWriter.createConfig(Util.getPrefix(), new File(Main.getPath(), "subAlias/" + file.getName()), VALUES.values(), isReload, Util.getConfigLogo());
for (String s : (List<String>) VALUES.subAliasList.value) {
if (s != null) {
Main.allSubAliases.add(s);
}
}
int subAliasArg = 0;
if (VALUES.subAliasFor.value != null) {
Main.allForSubAliases.add((String) VALUES.subAliasFor.value);
String[] imp = ((String) VALUES.subAliasFor.value).split(" ");
if (!Main.allAliases.contains(imp[0])) {
T2C_Send.error(Main.getInstance(), "The alias " + imp[0] + " in the file " + file.getName() + " does not exist!");
}
String[] args = ((String) VALUES.subAliasFor.value).split(" ");
subAliasArg = args.length - 1;
}
SubAliasObject subAlias = new SubAliasObject(
(boolean) VALUES.aliasEnable.value,
(List<String>) VALUES.subAliasList.value,
(String) VALUES.subAliasFor.value,
subAliasArg,
(boolean) VALUES.permNecessary.value,
(String) VALUES.permission.value,
(String) VALUES.permissionMSG.value,
(int) VALUES.cooldownGlobal.value,
(int) VALUES.cooldownPlayer.value,
(boolean) VALUES.costEnable.value,
(boolean) VALUES.costConfirm.value,
(double) VALUES.costPrice.value,
(boolean) VALUES.costAllowBypass.value,
(boolean) VALUES.commandEnable.value,
(boolean) VALUES.commandAsConsole.value,
(boolean) VALUES.bungeeCommand.value,
(List<String>) VALUES.command.value,
(boolean) VALUES.messageEnable.value,
(List<String>) VALUES.messages.value,
(boolean) VALUES.adminEnable.value,
(String) VALUES.adminPermission.value,
(boolean) VALUES.adminCommandEnable.value,
(boolean) VALUES.adminCommandAsConsole.value,
(boolean) VALUES.adminBungeeCommand.value,
(List<String>) VALUES.adminCommands.value,
(boolean) VALUES.adminMessageEnable.value,
(List<String>) VALUES.adminMessages.value,
(boolean) VALUES.consoleEnable.value,
(boolean) VALUES.consoleCommandEnable.value,
(boolean) VALUES.consoleBungeeCommand.value,
(List<String>) VALUES.consoleCommands.value,
(boolean) VALUES.consoleMessageEnable.value,
(List<String>) VALUES.consoleMessages.value);
for (String sal : (List<String>) VALUES.subAliasList.value) {
Main.subAliasHashMap.put(sal, subAlias);
}
}
}
}
}

View File

@ -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.getInstance(), new Runnable() {
@Override
public void run() {
ExecuteAlias.storage(player, true);
}
});
break;
case "t2code-alias-cancel":
e.setCancelled(true);
Bukkit.getScheduler().runTask(Main.getInstance(), new Runnable() {
@Override
public void run() {
ExecuteAlias.storage(player, false);
}
});
break;
}
}
}

View File

@ -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.Util;
import net.t2code.t2codelib.SPIGOT.api.items.T2C_ItemBuilder;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Replace;
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, (T2C_Replace.replace(Util.getPrefix(), player,
Main.getGuiCode() + Language.VALUES.confirmGuiTitle.getValue().toString().replace("[price]",price+ " "+Config.VALUES.buyCurrency.getValue()).replace("[alias]", alias))));
T2C_ItemBuilder.fillItem((boolean) Config.VALUES.buyConfirmGuiFillItemEnabled.getValue(), (String) Config.VALUES.buyConfirmGuiFillItem.getValue(), 3, inventory);
T2C_ItemBuilder.setItem(12, 1, (String) Config.VALUES.buyConfirmGuiConfirm.getValue(), Language.VALUES.confirmGuiConfirm.getValue().toString(),
(List<String>) T2C_Replace.replace(Language.VALUES.confirmGuiConfirmLore.getValue(), "[price]", price + " " + Config.VALUES.buyCurrency.getValue()), inventory);
T2C_ItemBuilder.setItem(14, 1, (String) Config.VALUES.buyConfirmGuiCancel.getValue(), Language.VALUES.confirmGuiCancel.getValue().toString(),
(List<String>) T2C_Replace.replace(Language.VALUES.confirmGuiCancelLore.getValue(), "[price]", price + " " + Config.VALUES.buyCurrency.getValue()), inventory);
Cache.openPlayers.add(player.getUniqueId());
player.openInventory(inventory);
}
}

View File

@ -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());
}
}

View File

@ -0,0 +1,10 @@
package net.t2code.alias.Spigot.enums;
public enum ConfigParam {
STRING,
INTEGER,
LIST,
BOOLEAN,
CONFIRMENUM,
SOUND
}

View File

@ -0,0 +1,7 @@
package net.t2code.alias.Spigot.enums;
public enum Confirm {
COMMAND,
CHAT,
GUI
}

View File

@ -1,26 +1,36 @@
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 HashMap<UUID, Long> cooldownPlayerMap = new HashMap<>();
public Long globalCooldownInt = 0L;
public class AliasObjekt {
public Boolean aliasEnable; public Boolean aliasEnable;
public Boolean commandEnable; public List<String> aliasList;
public Boolean permNecessary; public Boolean permNecessary;
public String permission;
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;
public Boolean commandEnable;
public Boolean commandAsConsole; public Boolean commandAsConsole;
public Boolean bungeeCommand; public Boolean bungeeCommand;
public List<String> command; public List<String> command;
public Boolean messageEnable; public Boolean messageEnable;
public List<String> messages; public List<String> messages;
public Boolean textBuilder;
public String hover;
public Boolean clickEvent;
public String action;
public String actionValue;
public Boolean adminEnable; public Boolean adminEnable;
public String adminPermission; public String adminPermission;
@ -30,11 +40,6 @@ public class AliasObjekt {
public List<String> adminCommands; public List<String> adminCommands;
public Boolean adminMessageEnable; public Boolean adminMessageEnable;
public List<String> adminMessages; public List<String> adminMessages;
public Boolean adminTextBuilder;
public String adminHover;
public Boolean adminClickEvent;
public String adminAction;
public String adminActionValue;
public Boolean consoleEnable; public Boolean consoleEnable;
public Boolean consoleCommandEnable; public Boolean consoleCommandEnable;
public Boolean consoleBungeeCommand; public Boolean consoleBungeeCommand;
@ -42,10 +47,17 @@ public class AliasObjekt {
public Boolean consoleMessageEnable; public Boolean consoleMessageEnable;
public List<String> consoleMessages; public List<String> consoleMessages;
public AliasObjekt(Boolean aliasEnable, public AliasObject(Boolean aliasEnable,
List<String> aliasList,
Boolean permNecessary, Boolean permNecessary,
String permission,
String permissionMSG,
Integer cooldownGlobal,
Integer cooldownPlayer,
Boolean costEnable, Boolean costEnable,
Boolean costConfirm,
Double costPrice, Double costPrice,
Boolean costAllowBypass, Boolean costAllowBypass,
@ -55,11 +67,6 @@ public class AliasObjekt {
List<String> command, List<String> command,
Boolean messageEnable, Boolean messageEnable,
List<String> messages, List<String> messages,
Boolean textBuilder,
String hover,
Boolean clickEvent,
String action,
String actionValue,
Boolean adminEnable, Boolean adminEnable,
String adminPermission, String adminPermission,
@ -69,11 +76,6 @@ public class AliasObjekt {
List<String> adminCommands, List<String> adminCommands,
Boolean adminMessageEnable, Boolean adminMessageEnable,
List<String> adminMessages, List<String> adminMessages,
Boolean adminTextBuilder,
String adminHover,
Boolean adminClickEvent,
String adminAction,
String adminActionValue,
Boolean consoleEnable, Boolean consoleEnable,
Boolean consoleCommandEnable, Boolean consoleCommandEnable,
@ -82,9 +84,16 @@ public class AliasObjekt {
Boolean consoleMessageEnable, Boolean consoleMessageEnable,
List<String> consoleMessages) { List<String> consoleMessages) {
this.aliasEnable = aliasEnable; this.aliasEnable = aliasEnable;
this.aliasList = aliasList;
this.permNecessary = permNecessary; this.permNecessary = permNecessary;
this.permission = permission;
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;
@ -94,11 +103,6 @@ public class AliasObjekt {
this.command = command; this.command = command;
this.messageEnable = messageEnable; this.messageEnable = messageEnable;
this.messages = messages; this.messages = messages;
this.textBuilder = textBuilder;
this.hover = hover;
this.clickEvent = clickEvent;
this.action = action;
this.actionValue = actionValue;
this.adminEnable = adminEnable; this.adminEnable = adminEnable;
this.adminPermission = adminPermission; this.adminPermission = adminPermission;
this.adminCommandEnable = adminCommandEnable; this.adminCommandEnable = adminCommandEnable;
@ -107,11 +111,7 @@ public class AliasObjekt {
this.adminCommands = adminCommands; this.adminCommands = adminCommands;
this.adminMessageEnable = adminMessageEnable; this.adminMessageEnable = adminMessageEnable;
this.adminMessages = adminMessages; this.adminMessages = adminMessages;
this.adminTextBuilder = adminTextBuilder;
this.adminHover = adminHover;
this.adminClickEvent = adminClickEvent;
this.adminAction = adminAction;
this.adminActionValue = adminActionValue;
this.consoleEnable = consoleEnable; this.consoleEnable = consoleEnable;
this.consoleCommandEnable = consoleCommandEnable; this.consoleCommandEnable = consoleCommandEnable;

View File

@ -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;
}
}

View 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_;
}
}

View File

@ -0,0 +1,129 @@
package net.t2code.alias.Spigot.objects;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
public class SubAliasObject {
public HashMap<UUID, Long> cooldownPlayerMap = new HashMap<>();
public Long globalCooldownInt = 0L;
public Boolean subAliasEnable;
public List<String> subAliasList;
public Integer subAliasArg;
public String subAliasFor;
public Boolean permNecessary;
public String permission;
public String permissionMSG;
public Integer cooldownGlobal;
public Integer cooldownPlayer;
public Boolean costEnable;
public Boolean costConfirm;
public Double costPrice;
public Boolean costAllowBypass;
public Boolean commandEnable;
public Boolean commandAsConsole;
public Boolean bungeeCommand;
public List<String> command;
public Boolean messageEnable;
public List<String> messages;
public Boolean adminEnable;
public String adminPermission;
public Boolean adminCommandEnable;
public Boolean adminCommandAsConsole;
public Boolean adminBungeeCommand;
public List<String> adminCommands;
public Boolean adminMessageEnable;
public List<String> adminMessages;
public Boolean consoleEnable;
public Boolean consoleCommandEnable;
public Boolean consoleBungeeCommand;
public List<String> consoleCommands;
public Boolean consoleMessageEnable;
public List<String> consoleMessages;
public SubAliasObject(Boolean subAliasEnable,
List<String> subAliasList,
String subAliasFor,
Integer subAliasArg,
Boolean permNecessary,
String permission,
String permissionMSG,
Integer cooldownGlobal,
Integer cooldownPlayer,
Boolean costEnable,
Boolean costConfirm,
Double costPrice,
Boolean costAllowBypass,
Boolean commandEnable,
Boolean commandAsConsole,
Boolean bungeeCommand,
List<String> command,
Boolean messageEnable,
List<String> messages,
Boolean adminEnable,
String adminPermission,
Boolean adminCommandEnable,
Boolean adminCommandAsConsole,
Boolean adminBungeeCommand,
List<String> adminCommands,
Boolean adminMessageEnable,
List<String> adminMessages,
Boolean consoleEnable,
Boolean consoleCommandEnable,
Boolean consoleBungeeCommand,
List<String> consoleCommands,
Boolean consoleMessageEnable,
List<String> consoleMessages) {
this.subAliasEnable = subAliasEnable;
this.subAliasList = subAliasList;
this.subAliasFor = subAliasFor;
this.subAliasArg = subAliasArg;
this.permNecessary = permNecessary;
this.permission = permission;
this.permissionMSG = permissionMSG;
this.cooldownGlobal = cooldownGlobal;
this.cooldownPlayer = cooldownPlayer;
this.costEnable = costEnable;
this.costConfirm = costConfirm;
this.costPrice = costPrice;
this.costAllowBypass = costAllowBypass;
this.commandEnable = commandEnable;
this.commandAsConsole = commandAsConsole;
this.bungeeCommand = bungeeCommand;
this.command = command;
this.messageEnable = messageEnable;
this.messages = messages;
this.adminEnable = adminEnable;
this.adminPermission = adminPermission;
this.adminCommandEnable = adminCommandEnable;
this.adminCommandAsConsole = adminCommandAsConsole;
this.adminBungeeCommand = adminBungeeCommand;
this.adminCommands = adminCommands;
this.adminMessageEnable = adminMessageEnable;
this.adminMessages = adminMessages;
this.consoleEnable = consoleEnable;
this.consoleCommandEnable = consoleCommandEnable;
this.consoleBungeeCommand = consoleBungeeCommand;
this.consoleCommands = consoleCommands;
this.consoleMessageEnable = consoleMessageEnable;
this.consoleMessages = consoleMessages;
}
}

View File

@ -0,0 +1,68 @@
package net.t2code.alias.Spigot.register;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.cmdManagement.RegisterCommands;
import net.t2code.alias.util.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Send;
import org.bukkit.command.CommandMap;
import org.bukkit.plugin.SimplePluginManager;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Objects;
public class AliasRegister {
private Main main;
public AliasRegister(Main main, boolean isReload) {
this.main = main;
loadAliasCommands(isReload);
}
private void loadAliasCommands(boolean isReload) {
CommandMap commandMap = getCommandMap();
unregister(commandMap);
if (commandMap == null) {
main.getLogger().severe("CommandMap konnte nicht geladen werden!");
return;
}
for (String alias : Main.allAliases) {
if (Main.aliasHashMap.get(alias).aliasEnable) {
// Registrieren des Befehls
commandMap.register(main.getDescription().getName(), new RegisterCommands(alias));
T2C_Send.sendStartTextCenter(Util.getPrefix(), "§aAlias §e" + alias + " §aregister", isReload);
Main.loadAliasHashMap.put(alias, true);
} else Main.loadAliasHashMap.put(alias, false);
}
}
private CommandMap getCommandMap() {
if (main.getServer().getPluginManager() instanceof SimplePluginManager) {
SimplePluginManager manager = (SimplePluginManager) main.getServer().getPluginManager();
try {
Field field = SimplePluginManager.class.getDeclaredField("commandMap");
field.setAccessible(true);
return (CommandMap) field.get(manager);
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
private void unregister(CommandMap commandMap) {
if (commandMap == null) return;
for (Map.Entry<String, Boolean> entry : Main.loadAliasHashMap.entrySet()) {
if (entry.getValue()) {
Objects.requireNonNull(commandMap.getCommand(entry.getKey())).unregister(commandMap);
}
}
Main.loadAliasHashMap.clear();
}
}

View File

@ -0,0 +1,55 @@
package net.t2code.alias.Spigot.register;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.t2codelib.SPIGOT.api.register.T2C_Register;
import org.bukkit.Bukkit;
import org.bukkit.permissions.PermissionDefault;
public class AliasRegisterPermissions {
public static void onPermRegister() {
for (AliasObject aliasObject : Main.aliasHashMap.values()) {
for (String alias : aliasObject.aliasList) {
if (aliasObject.permission != null && Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("[alias]", alias).toLowerCase()) == null) {
T2C_Register.permission(aliasObject.permission.replace("[alias]", alias).toLowerCase(), Main.getInstance());
}
if (aliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("[alias]", alias).toLowerCase()) == null) {
T2C_Register.permission(aliasObject.adminPermission.replace("[alias]", alias).toLowerCase(), Main.getInstance());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.buy." + alias.toLowerCase() + ".bypass") == null) {
T2C_Register.permission("t2c.alias.buy." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getInstance());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.cooldown.global." + alias.toLowerCase() + ".bypass") == null) {
T2C_Register.permission("t2c.alias.cooldown.global." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getInstance());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.cooldown.player." + alias.toLowerCase() + ".bypass") == null) {
T2C_Register.permission("t2c.alias.cooldown.player." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getInstance());
}
}
}
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) {
T2C_Register.permission(subAliasObject.permission.replace("[alias]", alias).toLowerCase(), Main.getInstance());
}
if (subAliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("[alias]", alias).toLowerCase()) == null) {
T2C_Register.permission(subAliasObject.adminPermission.replace("[alias]", alias).toLowerCase(), Main.getInstance());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.buy." + alias.toLowerCase() + ".bypass") == null) {
T2C_Register.permission("t2c.alias.sub.buy." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getInstance());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass") == null) {
T2C_Register.permission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getInstance());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass") == null) {
T2C_Register.permission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getInstance());
}
}
}
}
}

View File

@ -1,34 +0,0 @@
package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.cmdManagement.RegisterCommands;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.NMSVersion;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field;
public class AliasRegister {
public static void onRegister() {
Plugin plugin = Main.plugin;
for (String alias : Main.allAliases) {
if (Main.aliasHashMap.get(alias) != null) {
if (alias.equals(" ")) continue;
if (Main.aliasHashMap.get(alias).aliasEnable) {
try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
commandMap.register(alias, new RegisterCommands(alias));
} catch(Exception e) {
e.printStackTrace();
}
}
} else send.warning(plugin, " §4AliasHashmap is null! - " + alias);
}
}
}

View File

@ -1,16 +0,0 @@
package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Main;
import net.t2code.lib.Spigot.Lib.register.Register;
import org.bukkit.Bukkit;
public class AliasRegisterPermissions {
public static void onPermRegister() {
for (String alias : Main.allAliases){
if (Bukkit.getPluginManager().getPermission("t2code.alias.use." + alias.toLowerCase()) == null) {
Register.permission("t2code.alias.use." + alias.toLowerCase(), Main.plugin);
}
}
}
}

View File

@ -1,42 +1,13 @@
package net.t2code.alias.Spigot.system; package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Main;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.ByteArrayOutputStream; import net.t2code.t2codelib.SPIGOT.system.T2C_ProxyCommandSenderReceiver;
import java.io.DataOutputStream; import org.bukkit.command.CommandSender;
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(); T2C_ProxyCommandSenderReceiver.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.plugin, "t2codealias:bungee", stream.toByteArray());
}else {
for(Player player : Bukkit.getOnlinePlayers()){
player.sendPluginMessage(Main.plugin, "t2codealias:bungee", stream.toByteArray());
return;
}
}
} }
} }

View File

@ -1,35 +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) {
Player player = event.getPlayer();
new BukkitRunnable() {
@Override
public void run() {
String publicVersion = UpdateAPI.PluginVersionen.get(Main.plugin.getName()).publicVersion;
if (player.hasPermission("alias.updatemsg") || player.isOp()) {
if (!Main.version.equals(publicVersion)) {
if (SelectLibConfig.UpdateCheckOnJoin) {
UpdateAPI.sendUpdateMsg(Util.getPrefix(), Util.getSpigot(), Util.getDiscord(), Main.version, publicVersion, player);
}
}
}
}
}.runTaskLater(Main.plugin, 200L);
}
}

View File

@ -2,57 +2,72 @@ 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.AliasCmdExecuter;
import net.t2code.alias.Spigot.config.config.CreateConfig; import net.t2code.alias.Spigot.cmdManagement.TabEvent;
import net.t2code.alias.Spigot.config.config.CreateExampleAliasConfig; import net.t2code.alias.Spigot.config.alias.AliasFile;
import net.t2code.alias.Spigot.config.config.SelectAlias; import net.t2code.alias.Spigot.config.config.Config;
import net.t2code.alias.Spigot.config.config.SelectConfig; import net.t2code.alias.Spigot.config.config.Language;
import net.t2code.alias.Spigot.config.languages.LanguagesCreate; import net.t2code.alias.Spigot.config.subAlias.SubAliasFile;
import net.t2code.alias.Spigot.config.languages.SelectMessages; import net.t2code.alias.Spigot.confirm.ChatConfirm;
import net.t2code.alias.Util; import net.t2code.alias.Spigot.confirm.gui.GuiListener;
import net.t2code.lib.Spigot.Lib.messages.T2CodeTemplate; import net.t2code.alias.Spigot.enums.Confirm;
import net.t2code.lib.Spigot.Lib.update.UpdateAPI; import net.t2code.alias.Spigot.register.AliasRegisterPermissions;
import net.t2code.alias.util.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2C_Template;
import net.t2code.t2codelib.SPIGOT.api.register.T2C_Register;
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2C_LibConfig;
import net.t2code.t2codelib.util.T2C_Util;
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 {
static Plugin plugin = Main.plugin; private static final Main plugin = Main.getInstance();
public static void onLoad(String prefix, List autor, String version, String spigot, int spigotID, String discord, int bstatsID) {
Long long_ = T2CodeTemplate.onLoadHeader(prefix, autor, version, spigot, discord);
Main.plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter());
loadReload();
UpdateAPI.onUpdateCheck(plugin, prefix, spigot, spigotID, discord);
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(), plugin);
T2CodeTemplate.onLoadFooter(prefix, long_,version); public Load(Main main, String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID) {
Metrics.Bstats(plugin, bstatsID); onLoad(main, prefix, autor, version, spigot, discord, bstatsID);
} }
public static void loadReload() { private void onLoad(Main main, String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID) {
if (!new File(Main.getPath(), "config.yml").exists()) { Long long_ = T2C_Template.onLoadHeader(prefix, autor, version, spigot, discord);
try { plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter());
CreateExampleAliasConfig.configCreate(); loadReload(main, false);
} catch (Exception e) { T2C_UpdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(),
e.printStackTrace(); (Boolean) Config.VALUES.updateCheckOnJoin.getValue(), (Boolean) Config.VALUES.updateCheckSeePreReleaseUpdates.getValue(), (Integer) Config.VALUES.updateCheckTimeInterval.getValue());
}
}
try {
plugin.saveResource("Alias/X_aliasDeclaration_X.yml",true);
} catch (Exception e) {
e.printStackTrace();
}
CreateConfig.configCreate();
LanguagesCreate.langCreate();
SelectConfig.onSelect();
SelectMessages.onSelect(Util.getPrefix());
SelectAlias.onSelect();
if (SelectConfig.Bungee) { T2C_Register.listener(new PluginEvents(), plugin);
Main.plugin.getServer().getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord"); Metrics.Bstats(plugin, bstatsID);
Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "t2codealias:bungee"); T2C_Template.onLoadFooter(prefix, long_);
}
private static ChatConfirm chatListener;
private static GuiListener guiListener;
public static void loadReload(Main main, boolean isReload) {
HandlerList.unregisterAll(chatListener);
HandlerList.unregisterAll(guiListener);
boolean newInstall = !new File(Main.getPath(), "config.yml").exists();
Config.set(isReload);
Language.set(false);
T2C_Template.onLoadSeparateStroke(Util.getPrefix());
if (newInstall) {
SubAliasFile.set(false);
}
AliasFile.set(false);
SubAliasFile.select(false);
if ((Boolean) Config.VALUES.subAliasTab.getValue()) {
T2C_Register.listener(new TabEvent(), plugin);
}
chatListener = new ChatConfirm();
if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.CHAT) T2C_Register.listener(chatListener, plugin);
guiListener = new GuiListener();
if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.GUI) T2C_Register.listener(guiListener, plugin);
if ((boolean) T2C_LibConfig.VALUES.proxy.getValue()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, T2C_Util.getPluginChannel_ProxyCommand());
} }
AliasRegisterPermissions.onPermRegister(); AliasRegisterPermissions.onPermRegister();
} }

View File

@ -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;

View File

@ -0,0 +1,25 @@
package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Cache;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.util.Util;
import net.t2code.t2codelib.SPIGOT.api.update.T2C_UpdateAPI;
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) {
T2C_UpdateAPI.join(Main.getInstance(), Util.getPrefix(), "t2c.alias.updatemsg", event.getPlayer(), Util.getSpigotID(), Util.getDiscord());
}
}

View File

@ -1,34 +0,0 @@
package net.t2code.alias;
public class Util {
private static double requiredT2CodeLibVersion = 11.6;
private static String Prefix = "§8[§4T2Code§7-§aAlias§8]";
private static Integer SpigotID = 96389;
private static Integer BstatsID = 12517;
private static String Spigot = "https://www.spigotmc.org/resources/" + SpigotID;
private static String Discord = "http://dc.t2code.net";
public static double getRequiredT2CodeLibVersion() {
return requiredT2CodeLibVersion;
}
public static String getPrefix() {
return Prefix;
}
public static Integer getSpigotID() {
return SpigotID;
}
public static Integer getBstatsID() {
return BstatsID;
}
public static String getSpigot() {
return Spigot;
}
public static String getDiscord() {
return Discord;
}
}

View File

@ -0,0 +1,42 @@
package net.t2code.alias.util;
import lombok.Getter;
import lombok.Setter;
import net.t2code.t2codelib.util.T2C_Util;
import java.util.ArrayList;
import java.util.Arrays;
public class Util {
@Getter
private static final String infoText = "";
@Getter
private static final String requiredT2CodeLibVersion = "16.7";
@Getter
private static final Integer spigotID = 96389;
@Getter
private static final String git = "JaTiTV/T2Code-Alias";
@Getter
private static final Integer bstatsID = 12517;
@Getter
private static final String spigot = "https://spigotmc.org/resources/" + spigotID;
@Getter
private static final String discord = "http://dc.t2code.net";
@Getter
@Setter
private static String prefix = "§8[§4T2Code§7-§aAlias§8]";
public static String[] getConfigLogo() {
ArrayList<String> arrayList = new ArrayList<>(T2C_Util.getConfigT2CodeLogo());
arrayList.addAll(Arrays.asList("", "# Spigot: " + spigot));
return arrayList.toArray(new String[0]);
}
}

View File

@ -1,23 +1,53 @@
#################################################################### ####################################################################
## To create another alias, simply copy the file ## ## This is an example file and serves only for the explanation ##
## and name it what you want the aliascommand to be. ## ## of the individual options. ##
## The alias command is always the filename without .yml!!! ## ## Changes in this file are not considered and will be reset! ##
#################################################################### ####################################################################
Alias: Alias:
# Here you can disable the alias # Here you can disable the alias
Enable: true Enable: true
# Specify here what the Alias commands should be for this function
AliasList:
- aliasexample1
- 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#
# Permission: t2code.alias.use.<aliasname>
Necessary: true Necessary: true
# Here you can set the permission for the alias.
# 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.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.
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
@ -30,35 +60,33 @@ Alias:
# 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
# Specify here the message that the player should get. # Specify here the message that the player should get.
# Multiple lines can be used and placeholders are supported! # Multiple lines can be used and placeholders are supported!
# Placeholder: [player] = The player who executes the alias # Placeholder: [player] = The player who executes the alias
#
# You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes
# You can use the hover module from T2Code:
# You can add a hover and/or clickable feature to all messages sent to players.
# Use /*/ to separate the message.
# Use [nl] to set a line break in a message or hover.
# Hover message: <message >/*/<hover>
# Message with hover and click function: <message >/*/<hover>/*/<action>/*/<actionValue>
# Message only with click function: <message >/*//*/<action>/*/<actionValue>
# Action:
# - OPEN_URL - Opens a URL under the path specified in ActionValue.
# - OPEN_FILE - Opens a file under the path specified by ActionValue.
# - RUN_COMMAND - Runs the command specified by ActionValue.
# - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box.
# - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue.
# - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard.
# You can also use MiniMessage:
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html
# WebUI: https://webui.adventure.kyori.net
Messages: [] Messages: []
# With the TextBuilder it is possible to create messages with hover and clickable messages with actions.
# !!! There is currently a poll on our Discord asking if this option should be removed !!!
# To the poll: https://ptb.discord.com/channels/780682397950672897/915625982910672896/984228029297471529
TextBuilder:
# Here you can activate the TextBuilder.
Enable: false
# Set the hover here
Hover: ''
ClickEvent:
# Here you can give the message a function when clicked on
Enable: false
# Specify here what should happen
# OPEN_URL - Opens a URL under the path specified in ActionValue.
# OPEN_FILE - Opens a file under the path specified by ActionValue.
# RUN_COMMAND - Runs the command specified by ActionValue.
# SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box.
# CHANGE_PAGE - Changes to the page number in a book specified by ActionValue.
# COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard.
Action: ''
# Here you set the value of the action.
# For example, the URL for the link to be opened or the command to be executed.
ActionValue: ''
# 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.
@ -67,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
@ -82,35 +112,33 @@ Alias:
# 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
# Specify here the message that the player should get. # Specify here the message that the player should get.
# Multiple lines can be used and placeholders are supported! # Multiple lines can be used and placeholders are supported!
# Placeholder: [player] = The player who executes the alias # Placeholder: [player] = The player who executes the alias
Messages: [ ] #
# With the TextBuilder it is possible to create messages with hover and clickable messages with actions. # You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes
# !!! There is currently a poll on our Discord asking if this option should be removed !!! # You can use the hover module from T2Code:
# To the poll: https://ptb.discord.com/channels/780682397950672897/915625982910672896/984228029297471529 # You can add a hover and/or clickable feature to all messages sent to players.
TextBuilder: # Use /*/ to separate the message.
# Here you can activate the TextBuilder. # Use [nl] to set a line break in a message or hover.
Enable: false # Hover message: <message >/*/<hover>
# Set the hover here # Message with hover and click function: <message >/*/<hover>/*/<action>/*/<actionValue>
Hover: '' # Message only with click function: <message >/*//*/<action>/*/<actionValue>
ClickEvent: # Action:
# Here you can give the message a function when clicked on # - OPEN_URL - Opens a URL under the path specified in ActionValue.
Enable: false # - OPEN_FILE - Opens a file under the path specified by ActionValue.
# Specify here what should happen # - RUN_COMMAND - Runs the command specified by ActionValue.
# OPEN_URL - Opens a URL under the path specified in ActionValue. # - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box.
# OPEN_FILE - Opens a file under the path specified by ActionValue. # - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue.
# RUN_COMMAND - Runs the command specified by ActionValue. # - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard.
# SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box. # You can also use MiniMessage:
# CHANGE_PAGE - Changes to the page number in a book specified by ActionValue. # Wiki: https://docs.adventure.kyori.net/minimessage/format.html
# COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard. # WebUI: https://webui.adventure.kyori.net
Action: '' Messages: []
# Here you set the value of the action.
# For example, the URL for the link to be opened or the command to be executed.
ActionValue: ''
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.
@ -122,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: []

View File

@ -0,0 +1,161 @@
####################################################################
## 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:
# Here you can disable the alias
Enable: true
# Specify here what the SubAlias commands should be for this function
SubAliasList:
- subalias1
# Enter here the alias command where the subalias should follow.
# For example:
# - aliasexample1 -> aliasexample1 <this SubAlias>
# - aliasexample2 test -> aliasexample2 test <this SubAlias>
SubAliasFor: aliasexample1
Permission:
# Here you can say if a permission is needed to use the alias#
Necessary: true
# Here you can set the permission for the alias.
# The placeholder [alias] is the subalias name.
# If you have set multiple alias referrers in the list 'Alias.SubAliasList' you have a permission for each 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.
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:
# Here you can say if you have to pay for the alias
Enable: false
# Here you set the price
Price: 0.0
# Here you define if the bypass is activated or if you have to pay despite the bypass (t2c.alias.buy.[alias].bypass).
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:
# Here you can tell the alias to execute one or more commands
Enable: false
# Here you can specify whether the command should be executed from the console of the server
CommandAsConsole: false
# Here you can define if the command should be executed on the bungee.
# For this option, BungeeCord must be set to true in config.yml and the plugin must also work on the proxy as a bridge.
# (If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled).
BungeeCommand: false
# Here you can specify one or more commands to be executed.
# Placeholder: [player] = The player who executes the alias
Commands: []
Message:
# Here you can specify whether the player should receive a message.
Enable: false
# Specify here the message that the player should get.
# Multiple lines can be used and placeholders are supported!
# Placeholder: [player] = The player who executes the alias
#
# You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes
# You can use the hover module from T2Code:
# You can add a hover and/or clickable feature to all messages sent to players.
# Use /*/ to separate the message.
# Use [nl] to set a line break in a message or hover.
# Hover message: <message >/*/<hover>
# Message with hover and click function: <message >/*/<hover>/*/<action>/*/<actionValue>
# Message only with click function: <message >/*//*/<action>/*/<actionValue>
# Action:
# - OPEN_URL - Opens a URL under the path specified in ActionValue.
# - OPEN_FILE - Opens a file under the path specified by ActionValue.
# - RUN_COMMAND - Runs the command specified by ActionValue.
# - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box.
# - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue.
# - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard.
# You can also use MiniMessage:
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html
# WebUI: https://webui.adventure.kyori.net
Messages: []
# 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.
# Example:
# Player: /warp CityBuild
# Player with Admin Perm: /server CityBuild
Admin:
# Here you can enable or disable the admin function
Enable: false
# Here you set the permission for the admin function
# 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:
# Here you can tell the alias to execute one or more commands
Enable: false
# Here you can specify whether the command should be executed from the console of the server
CommandAsConsole: false
# Here you can define if the command should be executed on the bungee.
# For this option, BungeeCord must be set to true in config.yml and the plugin must also work on the proxy as a bridge.
# (If it is to be executed from the proxy console, the CommandAsConsole option must also be enabled).
BungeeCommand: false
# Here you can specify one or more commands to be executed.
# Placeholder: [player] = The player who executes the alias
Commands: []
Message:
# Here you can specify whether the player should receive a message.
Enable: false
# Specify here the message that the player should get.
# Multiple lines can be used and placeholders are supported!
# Placeholder: [player] = The player who executes the alias
#
# You can use Minecraft custom color codes: https://minecraft.fandom.com/de/wiki/Formatierungscodes
# You can use the hover module from T2Code:
# You can add a hover and/or clickable feature to all messages sent to players.
# Use /*/ to separate the message.
# Use [nl] to set a line break in a message or hover.
# Hover message: <message >/*/<hover>
# Message with hover and click function: <message >/*/<hover>/*/<action>/*/<actionValue>
# Message only with click function: <message >/*//*/<action>/*/<actionValue>
# Action:
# - OPEN_URL - Opens a URL under the path specified in ActionValue.
# - OPEN_FILE - Opens a file under the path specified by ActionValue.
# - RUN_COMMAND - Runs the command specified by ActionValue.
# - SUGGEST_COMMAND - Inserts the string specified in ActionValue into the player text box.
# - CHANGE_PAGE - Changes to the page number in a book specified by ActionValue.
# - COPY_TO_CLIPBOARD - Copies the string specified by ActionValue to the player's clipboard.
# You can also use MiniMessage:
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html
# WebUI: https://webui.adventure.kyori.net
Messages: [ ]
Console:
# Here you can define if the alias is also usable in the console and what it should do from there.
Enable: false
Command:
# Here you can tell the alias to execute one or more commands
Enable: false
# Here you can specify whether the command should be executed by the Bungee console.
# 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
# Here you can specify one or more commands to be executed.
Commands: [ ]
Message:
# Here you can specify whether the player should receive a message.
Enable: false
# Specify here the message that the player should get.
Messages: [ ]

View 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

View File

@ -1,6 +0,0 @@
name: T2C-Alias
version: ${project.version}
main: net.t2code.alias.Bungee.BMain
description: T2Code Alias Plugin
author: JaTiTV
softdepends: [T2CodeLib]

View File

@ -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