5 Commits

Author SHA1 Message Date
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
32 changed files with 531 additions and 713 deletions

View File

@@ -63,14 +63,14 @@ WebUI: https://webui.adventure.kyori.net
**/t2code-alias** | **/alias**
**/alias info** - Open the T2C-Alias info. | *t2code.alias.command.info*
**/alias info** - Open the T2C-Alias info. | *t2c.alias.command.info*
**/alias reload** - Reload the plugin. | *t2code.alias.command.reload*
**/alias reload** - Reload the plugin. | *t2c.alias.command.reload*
*t2code.alias.admin* - Permission for all T2C-Alias Commands
*t2c.alias.admin* - Permission for all T2C-Alias Commands
*t2code.alias.updatemsg* - Get a notification when an update is available when joining
*t2c.alias.updatemsg* - Get a notification when an update is available when joining
---
<img src="https://i.imgur.com/HoZSt7c.png" width="600">

69
pom.xml
View File

@@ -7,7 +7,10 @@
<groupId>net.t2code</groupId>
<artifactId>Alias</artifactId>
<version>1.4</version>
<version>1.6_DEV-1</version>
<!--version>VERSION_snapshot-0</version-->
<!--version>VERSION_beta-0</version-->
<!--version>VERSION_dev-0</version-->
<packaging>jar</packaging>
<name>T2C-Alias</name>
@@ -37,15 +40,19 @@
<version>3.2.4</version>
<executions>
<execution>
<id>shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
</relocations>
</configuration>
</plugin>
</plugins>
<resources>
@@ -57,47 +64,51 @@
</build>
<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>
<id>T2Code</id>
<url>https://repo.t2code.net/repository/T2Code/</url>
</repository>
<repository>
<id>Builders-Paradise</id>
<url>https://repo.t2code.net/repository/Builders-Paradise/</url>
</repository>
</repositories>
<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>
<groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId>
<version>15.7</version>
<!--classifier>dev-3</classifier-->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>bungee</artifactId>
<version>1615</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.t2code</groupId>
<artifactId>PlugmanGUI</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.t2code.minecraft.1_13.r1</groupId>
<artifactId>spigot</artifactId>
<version>1.13r1</version>
<version>16.7</version>
<classifier>dev-3</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@@ -3,13 +3,13 @@ package net.t2code.alias.Spigot;
import lombok.Getter;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Spigot.system.BukkitCommandWrap;
import net.t2code.alias.Spigot.system.BukkitCommandWrap_Useless;
import net.t2code.alias.Spigot.system.Load;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
@@ -38,13 +38,6 @@ public final class Main extends JavaPlugin {
public static ArrayList<String> allSubAliases = new ArrayList<>();
public static ArrayList<String> allForSubAliases = new ArrayList<>();
private BukkitCommandWrap bukkitCommandWrap = null;
public BukkitCommandWrap getBukkitCommandWrap() {
return this.bukkitCommandWrap;
}
@Override
public void onEnable() {
@@ -52,17 +45,14 @@ public final class Main extends JavaPlugin {
plugin = this;
autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return;
try {
Class.forName("com.mojang.brigadier.CommandDispatcher");
this.bukkitCommandWrap = new BukkitCommandWrap();
} catch (ClassNotFoundException | NoClassDefFoundError e) {
this.bukkitCommandWrap = new BukkitCommandWrap_Useless();
}
if (T2CmcVersion.isMc1_13()) {
guiCode = "";
} else guiCode = "§6§8§9§r";
Load.onLoad(Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getBstatsID());
new Load(this, Util.getPrefix(), autor, version, Util.getSpigot(), Util.getDiscord(), Util.getBstatsID());
}
@Override

View File

@@ -23,21 +23,21 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
if (args.length == 0) {
// Command
if (sender.hasPermission("t2code.alias.command.info")) {
if (sender.hasPermission("t2c.alias.command.info")) {
Commands.info(sender);
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info"));
.replace("[perm]", "t2c.alias.command.info"));
} else {
switch (args[0].toLowerCase()) {
case "reload":
case "rl":
if (sender.hasPermission("t2code.alias.command.reload") || sender.isOp()) {
if (sender.hasPermission("t2c.alias.command.reload") || sender.isOp()) {
Commands.reload(sender);
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias reload")
.replace("[perm]", "t2code.alias.command.reload"));
.replace("[perm]", "t2c.alias.command.reload"));
break;
case "confirm":
if (Config.buyConfirmDefault.value == Confirm.COMMAND) ExecuteAlias.storage(sender, true);
if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.COMMAND) ExecuteAlias.storage(sender, true);
break;
case "cancel":
ExecuteAlias.storage(sender, false);
@@ -45,10 +45,10 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
case "info":
case "plugin":
case "version":
if (sender.hasPermission("t2code.alias.command.info")) {
if (sender.hasPermission("t2c.alias.command.info")) {
Commands.info(sender);
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info"));
.replace("[perm]", "t2c.alias.command.info"));
break;
}
@@ -58,9 +58,9 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
//TabCompleter
private static HashMap<String, String> arg1 = new HashMap<String, String>() {{
put("reload", "t2code.alias.command.reload");
put("rl", "t2code.alias.command.reload");
put("info", "t2code.alias.command.info");
put("reload", "t2c.alias.command.reload");
put("rl", "t2c.alias.command.reload");
put("info", "t2c.alias.command.info");
}};
@Override
@@ -70,7 +70,7 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
Player p = (Player) sender;
if (args.length == 1) {
for (String command : arg1.keySet()) {
Boolean passend = true;
boolean passend = true;
for (int i = 0; i < args[0].length(); i++) {
if (args[0].length() >= command.length()) {
passend = false;

View File

@@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands {
public static void info(CommandSender sender) {
T2Ctemplate.sendInfo(sender, Main.getPlugin(), Util.getSpigotID(), Util.getDiscord(), Util.getInfoText());
}
@@ -19,7 +20,7 @@ public class Commands {
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §6Plugin reload...");
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
Load.loadReload();
Load.loadReload(Main.getPlugin());
if (sender instanceof Player) T2Csend.player((Player) sender, Language.reloadEnd.value);
T2Csend.console(Util.getPrefix() + "§8-------------------------------");
T2Csend.console(Util.getPrefix() + " §2Plugin successfully reloaded.");

View File

@@ -15,7 +15,7 @@ import net.t2code.t2codelib.SPIGOT.api.eco.T2Ceco;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Creplace;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.plugins.T2CpluginCheck;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -52,7 +52,7 @@ public class ExecuteAlias {
Player player = (Player) sender;
if (aliasObject.adminEnable) {
if (player.hasPermission(aliasObject.adminPermission.replace("<alias>", alias.toLowerCase()))) {
if (player.hasPermission(aliasObject.adminPermission.replace("[alias]", alias.toLowerCase()))) {
if (aliasObject.adminCommandEnable) {
aliasAdminCommand(aliasObject, alias, player, args);
}
@@ -64,31 +64,31 @@ public class ExecuteAlias {
}
if (aliasObject.permNecessary) {
if (!(player.hasPermission(aliasObject.permission.replace("<alias>", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
if (!(player.hasPermission(aliasObject.permission.replace("[alias]", alias.toLowerCase())) || player.hasPermission("t2c.alias.admin"))) {
String npmsg;
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
npmsg = Language.noPermission.value;
} else npmsg = aliasObject.permissionMSG;
T2Csend.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", aliasObject.permission.replace("<alias>", alias.toLowerCase())).replace("[alias]", alias));
.replace("[perm]", aliasObject.permission.replace("[alias]", alias.toLowerCase())).replace("[alias]", alias));
return;
}
}
if (aliasObject.costEnable && aliasObject.costConfirm) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy." + alias.toLowerCase() + ".bypass"))) {
Cache.aliasStorage.put(player.getUniqueId(), new AliasStorageObject(aliasObject, alias, args, false));
switch ((Confirm) Config.buyConfirmDefault.value) {
switch ((Confirm) Config.VALUES.buyConfirmDefault.getValue()) {
case GUI:
ConfirmGUI.open(player, aliasObject.costPrice, alias);
break;
case CHAT:
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
case COMMAND:
default:
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
}
return;
@@ -99,16 +99,44 @@ public class ExecuteAlias {
}
protected static void executeAlias(Player player, AliasObject aliasObject, String alias, String[] args) {
if (aliasObject.cooldownGlobal != 0) {
if (!(player.hasPermission("t2code.alias.cooldown.global." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.cooldown.global.all.bypass"))) {
if (aliasObject.globalCooldownInt != 0) {
Long duration = System.currentTimeMillis() - aliasObject.globalCooldownInt;
if (!(duration > (aliasObject.cooldownGlobal * 1000))) {
T2Csend.player(player, Language.cooldownGlobal.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownGlobal - (int) (duration / 1000))));
return;
}
}
aliasObject.globalCooldownInt = System.currentTimeMillis();
}
}
if (aliasObject.cooldownPlayer != 0) {
if (!(player.hasPermission("t2code.alias.cooldown.player." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.cooldown.player.all.bypass"))) {
Long cooldown = aliasObject.cooldownPlayerMap.get(player.getUniqueId());
if (cooldown != null) {
long duration = System.currentTimeMillis() - cooldown;
if (!(duration > (aliasObject.cooldownPlayer * 1000))) {
T2Csend.player(player, Language.cooldownPlayer.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownPlayer - (int) (duration / 1000))));
return;
}
}
aliasObject.cooldownPlayerMap.put(player.getUniqueId(), System.currentTimeMillis());
}
}
if (aliasObject.costEnable) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.buy.all.bypass"))) {
if (!T2Ceco.moneyRemove(prefix, player, aliasObject.costPrice)) {
T2Csend.player(player, Language.noMoney.value);
return;
}
if ((Boolean) Config.buyMessage.value)
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
if ((Boolean) Config.VALUES.buyMessage.getValue())
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getPath()));
}
}
if (aliasObject.commandEnable) {
aliasCommand(aliasObject, alias, player, args);
}
@@ -127,7 +155,7 @@ public class ExecuteAlias {
Player player = (Player) sender;
if (aliasObject.adminEnable) {
if (player.hasPermission(aliasObject.adminPermission.replace("<alias>", alias.toLowerCase()))){
if (player.hasPermission(aliasObject.adminPermission.replace("[alias]", alias.toLowerCase()))) {
if (aliasObject.adminCommandEnable) {
subAliasAdminCommand(aliasObject, alias, player, args);
}
@@ -139,31 +167,31 @@ public class ExecuteAlias {
}
if (aliasObject.permNecessary) {
if (!(player.hasPermission(aliasObject.permission.replace("<alias>", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
if (!(player.hasPermission(aliasObject.permission.replace("[alias]", alias.toLowerCase())) || player.hasPermission("t2code.alias.admin"))) {
String npmsg;
if (aliasObject.permissionMSG == null || aliasObject.permissionMSG.equals("")) {
npmsg = Language.noPermission.value;
} else npmsg = aliasObject.permissionMSG;
T2Csend.player(player, npmsg.replace("[cmd]", "/" + alias.toLowerCase())
.replace("[perm]", aliasObject.permission.replace("<alias>", alias.toLowerCase())).replace("[alias]", alias));
.replace("[perm]", aliasObject.permission.replace("[alias]", alias.toLowerCase())).replace("[alias]", alias));
return;
}
}
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.buyConfirmDefault.value) {
switch ((Confirm) Config.VALUES.buyConfirmDefault.getValue()) {
case GUI:
ConfirmGUI.open(player, aliasObject.costPrice, alias);
break;
case CHAT:
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
T2Csend.player(player, Language.confirmChat.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
case COMMAND:
default:
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
T2Csend.player(player, Language.confirmCommand.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
break;
}
return;
@@ -179,14 +207,43 @@ public class ExecuteAlias {
}
protected static void executeSubAlias(Player player, SubAliasObject aliasObject, String alias, String[] args) {
if (aliasObject.cooldownGlobal != 0) {
if (!(player.hasPermission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.sub.cooldown.global.all.bypass"))) {
if (aliasObject.globalCooldownInt != 0) {
long duration = System.currentTimeMillis() - aliasObject.globalCooldownInt;
if (!(duration > (aliasObject.cooldownGlobal * 1000))) {
T2Csend.player(player, Language.cooldownGlobal.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownGlobal - (int) (duration / 1000))));
return;
}
}
aliasObject.globalCooldownInt = System.currentTimeMillis();
}
}
if (aliasObject.cooldownPlayer != 0) {
if (!(player.hasPermission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.sub.cooldown.player.all.bypass"))) {
Long cooldown = aliasObject.cooldownPlayerMap.get(player.getUniqueId());
if (cooldown != null) {
long duration = System.currentTimeMillis() - cooldown;
if (!(duration > (aliasObject.cooldownPlayer * 1000))) {
T2Csend.player(player, Language.cooldownPlayer.value.replace("[cooldown]", String.valueOf(aliasObject.cooldownPlayer - (int) (duration / 1000))));
return;
}
}
aliasObject.cooldownPlayerMap.put(player.getUniqueId(), System.currentTimeMillis());
}
}
if (aliasObject.costEnable) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2code.alias.buy.bypass"))) {
if (!(aliasObject.costAllowBypass && player.hasPermission("t2c.alias.sub.buy." + alias.toLowerCase() + ".bypass") && player.hasPermission("t2c.alias.sub.buy.all.bypass"))) {
if (!T2Ceco.moneyRemove(prefix, player, aliasObject.costPrice)) {
T2Csend.player(player, Language.noMoney.value);
return;
}
if ((Boolean) Config.buyMessage.value)
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.buyCurrency.value));
if ((Boolean) Config.VALUES.buyMessage.getValue())
T2Csend.player(player, Language.buy.value.replace("[price]", aliasObject.costPrice.toString() + " " + Config.VALUES.buyCurrency.getValue()));
}
}
if (aliasObject.commandEnable) {
@@ -201,7 +258,7 @@ public class ExecuteAlias {
if (alias.consoleCommandEnable) {
for (String cmd : alias.consoleCommands) {
if (alias.consoleBungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean)T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(sender, cmd, true);
} else {
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
@@ -231,7 +288,7 @@ public class ExecuteAlias {
for (String cmd : aliasObject.consoleCommands) {
String replace = cmd.replace("[target]", targetSt).replace("[alias]", alias);
if (aliasObject.consoleBungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(sender, replace, true);
} else {
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
@@ -259,7 +316,7 @@ public class ExecuteAlias {
}
for (String cmd : aliasObject.adminCommands) {
if (aliasObject.adminBungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.adminCommandAsConsole);
} else {
@@ -286,7 +343,7 @@ public class ExecuteAlias {
}
for (String cmd : aliasObject.adminCommands) {
if (aliasObject.adminBungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.adminCommandAsConsole);
} else {
@@ -351,7 +408,7 @@ public class ExecuteAlias {
}
for (String cmd : aliasObject.command) {
if (aliasObject.bungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt).replace("[alias]", alias), aliasObject.commandAsConsole);
} else {
T2Csend.console(Util.getPrefix() + " §4To use bungee commands, enable the Bungee option in the config.");
@@ -377,7 +434,7 @@ public class ExecuteAlias {
}
for (String cmd : alias.command) {
if (alias.bungeeCommand) {
if (T2CLibConfig.getBungee()) {
if ((boolean) T2CLibConfig.VALUES.proxy.getValue()) {
BCommandSenderReciver.sendToBungee(player, cmd.replace("[player]", player.getName()).replace("[target]", targetSt), alias.commandAsConsole);
} else {

View File

@@ -31,7 +31,7 @@ public class TabEvent implements Listener {
String[] args = input.split(" ", -1);
for (String al : aliasObject.subAliasList) {
arg1.put(al, aliasObject.permission.replace("<alias>", al.toLowerCase()));
arg1.put(al, aliasObject.permission.replace("[alias]", al.toLowerCase()));
}
int arg = aliasObject.subAliasArg;
if (args.length - 1 == arg) {

View File

@@ -36,8 +36,29 @@ public class AliasConfigConverter {
public static void convertAddPermission(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) {
if (subalias) {
yamlConfiguration.set("SubAlias.Permission.Permission", "t2code.alias.use.subalias.<alias>");
} else yamlConfiguration.set("Alias.Permission.Permission", "t2code.alias.use.<alias>");
yamlConfiguration.set("SubAlias.Permission.Permission", "t2c.alias.sub.use.[alias]");
} else yamlConfiguration.set("Alias.Permission.Permission", "t2c.alias.use.[alias]");
try {
yamlConfiguration.save(config_gui);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void convertAddCooldownInSecGlobal(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) {
if (subalias) {
yamlConfiguration.set("Alias.CooldownInSec.Global", 0);
} else yamlConfiguration.set("Alias.CooldownInSec.Global", 0);
try {
yamlConfiguration.save(config_gui);
} catch (IOException e) {
e.printStackTrace();
}
}
public static void convertAddCooldownInSecPlayer(YamlConfiguration yamlConfiguration, File config_gui, Boolean subalias) {
if (subalias) {
yamlConfiguration.set("Alias.CooldownInSec.Player", 0);
} else yamlConfiguration.set("Alias.CooldownInSec.Player", 0);
try {
yamlConfiguration.save(config_gui);
} catch (IOException e) {

View File

@@ -8,6 +8,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -21,27 +22,30 @@ public class CreateExampleAliasConfig {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
T2Cconfig.set("Alias.Enable", true, yamlConfiguration);
T2Cconfig.set("Alias.AliasList", Arrays.asList("aliasexample1"),yamlConfiguration);
T2Cconfig.set("Alias.AliasList", Arrays.asList("aliasexample1","t2caliasexample"),yamlConfiguration);
T2Cconfig.set("Alias.Permission.Necessary", true, yamlConfiguration);
T2Cconfig.set("Alias.Permission.Permission", "t2code.alias.use.<alias>", yamlConfiguration);
T2Cconfig.set("Alias.Permission.Permission", "t2c.alias.use.[alias]", yamlConfiguration);
T2Cconfig.set("Alias.Permission.CustomNoPermissionMSG", "", yamlConfiguration);
T2Cconfig.set("Alias.CooldownInSec.Global", 0, yamlConfiguration);
T2Cconfig.set("Alias.CooldownInSec.Player", 0, yamlConfiguration);
T2Cconfig.set("Alias.Cost.Enable", false,yamlConfiguration);
T2Cconfig.set("Alias.Cost.Confirm", true,yamlConfiguration);
T2Cconfig.set("Alias.Cost.Price", 0.0,yamlConfiguration);
T2Cconfig.set("Alias.Cost.AllowByPass", true,yamlConfiguration);
T2Cconfig.set("Alias.Command.Enable", true, yamlConfiguration);
T2Cconfig.set("Alias.Command.Enable", false, yamlConfiguration);
T2Cconfig.set("Alias.Command.CommandAsConsole", true, yamlConfiguration);
T2Cconfig.set("Alias.Command.BungeeCommand", false, yamlConfiguration);
T2Cconfig.set("Alias.Command.Commands", Arrays.asList("say hi"), yamlConfiguration);
T2Cconfig.set("Alias.Command.Commands", Arrays.asList(), yamlConfiguration);
T2Cconfig.set("Alias.Message.Enable", false, yamlConfiguration);
T2Cconfig.set("Alias.Message.Messages", Arrays.asList(), yamlConfiguration);
T2Cconfig.set("Alias.Message.Enable", true, yamlConfiguration);
T2Cconfig.set("Alias.Message.Messages", Arrays.asList("<rainbow>This is a test alias</rainbow>", "<color:#d7ff0f>With this you can use several functions such as <color:#ffd6ad>colored text</color>, <click:suggest_command:'/command'><hover:show_text:'<color:#ff745c>Use Command</color>'>clickable texts</hover></click>, <hover:show_text:'<color:#1f66ff>For example Warps</color>'><click:suggest_command:'/warp home'><color:#365eff>shorten commands of other plugins</color></click></hover> and much more.</color>", "<color:#85a0ff><click:open_url:'http://dc.t2code.net'><hover:show_text:'<color:#0887ff>http://dc.t2code.net</color>'>If you have any questions, please contact our support Discord.</hover></click></color>"), yamlConfiguration);
T2Cconfig.set("Alias.Admin.Enable", false, yamlConfiguration);
T2Cconfig.set("Alias.Admin.Permission", "t2code.alias.admin", yamlConfiguration);
T2Cconfig.set("Alias.Admin.Permission", "t2c.alias.[alias].admin", yamlConfiguration);
T2Cconfig.set("Alias.Admin.Command.Enable", true, yamlConfiguration);
T2Cconfig.set("Alias.Admin.Command.CommandAsConsole", true, yamlConfiguration);

View File

@@ -4,14 +4,12 @@ import com.google.common.base.Preconditions;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.system.AliasRegister;
import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.system.BukkitCommandWrap_Useless;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.FileNotFoundException;
@@ -22,8 +20,11 @@ import java.util.logging.Level;
public class SelectAlias {
private static String Prefix = Util.getPrefix();
public static void onSelect() {
public SelectAlias(Main main){
onSelect(main);
}
private void onSelect(Main main) {
Main.aliasHashMap.clear();
Main.allAliases.clear();
@@ -65,6 +66,17 @@ public class SelectAlias {
}
String permissionMSG = yamlConfiguration.getString("Alias.Permission.CustomNoPermissionMSG");
if (yamlConfiguration.get("Alias.CooldownInSec.Global") == null) {
AliasConfigConverter.convertAddCooldownInSecGlobal(yamlConfiguration, config_gui, false);
}
Integer cooldownGlobal = yamlConfiguration.getInt("Alias.CooldownInSec.Global");
if (yamlConfiguration.get("Alias.CooldownInSec.Player") == null) {
AliasConfigConverter.convertAddCooldownInSecPlayer(yamlConfiguration, config_gui, false);
}
Integer cooldownPlayer = yamlConfiguration.getInt("Alias.CooldownInSec.Player");
Boolean costEnable = yamlConfiguration.getBoolean("Alias.Cost.Enable");
if (yamlConfiguration.get("Alias.Cost.Confirm") == null) {
AliasConfigConverter.convertAddCostConfirm(yamlConfiguration, config_gui, false);
@@ -100,9 +112,9 @@ public class SelectAlias {
List<String> consoleMessages = yamlConfiguration.getStringList("Alias.Console.Message.Messages");
Main.allAliases.addAll(aliasList);
AliasObject alias = new AliasObject(aliasEnable, aliasList, permNecessary, permission, permissionMSG, costEnable, costConfirm, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand,
command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands,
adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
AliasObject alias = new AliasObject(aliasEnable, aliasList, permNecessary, permission, permissionMSG, cooldownGlobal, cooldownPlayer, costEnable, costConfirm, costPrice, costAllowBypass, commandEnable,
commandAsConsole, bungeeCommand, command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands, adminMessageEnable,
adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
for (String al : aliasList) {
Main.aliasHashMap.put(al, alias);
}
@@ -110,7 +122,7 @@ public class SelectAlias {
}
}
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
AliasRegister.onRegister();
new AliasRegister(main);
}
private YamlConfiguration loadFile(File file) throws InvalidConfigurationException {

View File

@@ -1,45 +1,82 @@
package net.t2code.alias.Spigot.config.config;
import net.t2code.alias.Spigot.enums.ConfigParam;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.enums.Confirm;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemBuilder;
import net.t2code.t2codelib.SPIGOT.api.items.T2CitemVersion;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Sound;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CconfigWriter;
public enum Config {
configVersion("configVersion", Util.getConfigVersion(), ConfigParam.INTEGER),
language("plugin.language", "english", ConfigParam.STRING),
updateCheckOnJoin("plugin.updateCheck.onJoin", true, ConfigParam.BOOLEAN),
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true, ConfigParam.BOOLEAN),
updateCheckTimeInterval("plugin.updateCheck.timeInterval", 60, ConfigParam.INTEGER),
import net.t2code.t2codelib.T2CconfigItem;
buyMessage("buy.message", true, ConfigParam.BOOLEAN),
buyCurrency("buy.currency", "$", ConfigParam.STRING),
buyConfirmDefault("buy.confirm.use", Confirm.COMMAND, ConfigParam.CONFIRMENUM),
buyConfirmGuiFillItemEnabled("buy.confirm.gui.fillItem.enabled", true, ConfigParam.BOOLEAN),
buyConfirmGuiFillItem("buy.confirm.gui.fillItem.material", T2CitemVersion.getBlackStainedGlassPane().getType().toString(), ConfigParam.STRING),
buyConfirmGuiConfirm("buy.confirm.gui.confirm.material", T2CitemVersion.getGreenWool().getType().toString(), ConfigParam.STRING),
buyConfirmGuiCancel("buy.confirm.gui.cancel.material", T2CitemVersion.getRedWool().getType().toString(), ConfigParam.STRING),
subAliasTab("subAlias.tabComplete", true, ConfigParam.BOOLEAN);
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public String path;
public Object value;
public Sound sound;
public ConfigParam configParam;
public class Config {
Config(String path, Object value, ConfigParam cEnum) {
public enum VALUES implements T2CconfigItem{
language("plugin.language", "english", true,"In this option you can set the language of the plugin."),
updateCheckOnJoin("plugin.updateCheck.onJoin", true,true,"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."),
updateCheckSeePreReleaseUpdates("plugin.updateCheck.seePreReleaseUpdates", true,true,"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,"In this option you can set the time interval in minutes in which updates should be checked."),
buyMessage("buy.message", true,true,"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,"With this option you set the currency."),
buyConfirmDefault("buy.confirm.use", Confirm.COMMAND,true,"Here you can choose which confirmation method you want to use. (COMMAND, CHAT, GUI)"),
buyConfirmGuiFillItemDesc("buy.confirm.gui.fillItem", null,true," ","!! You can change the GUI name and the button texts in the language file !!"," "),
buyConfirmGuiFillItemEnabled("buy.confirm.gui.fillItem.enabled", true,true,"Here you can set if a fillitem should be used in the Confirm GUI."),
buyConfirmGuiFillItem("buy.confirm.gui.fillItem.material", T2CitemVersion.getBlackStainedGlassPane().getType().toString(),true,"Here you can set which fillitem should be used in the Confirm GUI."),
buyConfirmGuiConfirm("buy.confirm.gui.confirm.material", T2CitemVersion.getGreenWool().getType().toString(),true,"Here you can set the material for the confirmation button."),
buyConfirmGuiCancel("buy.confirm.gui.cancel.material", T2CitemVersion.getRedWool().getType().toString(),true,"Here you can set the material for the cancel button."),
subAliasTab("subAlias.tabComplete", true,true,"Here you can set if subcommands should be displayed as tabComplete."),
;
private final String path;
private Object value;
private final boolean forceSet;
private final List<String> comments;
VALUES(String path, Object value,boolean forceSet, String... comments) {
this.path = path;
this.value = value;
this.configParam = cEnum;
this.forceSet=forceSet;
this.comments = new ArrayList<>(Arrays.asList(comments));
}
public static Sound sound() {
if (T2CmcVersion.isMc1_8()) {
return Sound.valueOf("NOTE_PIANO");
} else if (T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12()) {
return Sound.valueOf("BLOCK_NOTE_HARP");
} else return Sound.valueOf("BLOCK_NOTE_BLOCK_HARP");
@Override
public String getPath() {
return path;
}
@Override
public Object getValue() {
return value;
}
@Override
public boolean getForceSet() {
return forceSet;
}
@Override
public List<String> getComments() {
return comments;
}
@Override
public void setValue(Object newValue) {
value = newValue;
}
}
public static void set() {
long long_ = System.currentTimeMillis();
T2CconfigWriter.createConfig(new File(Main.getPath(), "config.yml"), VALUES.values(), Util.getConfigLogo());
T2Csend.console(Util.getPrefix() + " §2The config.yml was loaded successfully §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
}

View File

@@ -1,98 +0,0 @@
package net.t2code.alias.Spigot.config.config;
import com.google.common.base.Preconditions;
import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
public class Convert {
protected static void convert() {
File path = new File(Main.getPath(),"");
File file = new File(Main.getPath(), "config.yml");
if (path.exists() && file.exists()) convertTo4();
}
private static void convertTo4() {
long long1 = System.currentTimeMillis();
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.get(Config.configVersion.path) == null || ((Integer) Config.configVersion.value) < Util.getConfigVersion()) {
yamlConfiguration.set("ConfigVersion", null);
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
File dir = new File(Main.getPath() + "/languages");
File newDir = new File(Main.getPath() + "/OldConfig/Version3/languages");
if (!dir.exists()){
return;
}
try {
FileUtils.moveDirectory(dir, newDir);
} catch (IOException e) {
e.printStackTrace();
}
File f = new File(Main.getPath() + "/OldConfig/Version3/languages/");
File[] fileArray = f.listFiles();
for (File file : fileArray) {
long long2 = System.currentTimeMillis();
String sub = file.getName().substring(file.getName().length() - 4);
if (sub.equals(".yml")) {
YamlConfiguration yamlConfigurationOld;
try {
Preconditions.checkArgument(file != null, "File cannot be null");
YamlConfiguration language = new YamlConfiguration();
language.load(file);
yamlConfigurationOld = language;
} catch (FileNotFoundException var3) {
continue;
} catch (IOException var4) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, var4);
continue;
} catch (InvalidConfigurationException var5) {
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, var5);
continue;
}
File newFile = new File(Main.getPath(), "languages/" + file.getName().replace("_messages.yml", "") + ".yml");
YamlConfiguration yamlConfigurationNew = YamlConfiguration.loadConfiguration(newFile);
yamlConfigurationNew.set("plugin.onlyForPlayer", yamlConfigurationOld.getString("Plugin.OnlyForPlayer"));
yamlConfigurationNew.set("plugin.aliasDisabled", yamlConfigurationOld.getString("Plugin.AliasDisabled"));
yamlConfigurationNew.set("plugin.reload.start", yamlConfigurationOld.getString("Plugin.Reload.Start"));
yamlConfigurationNew.set("plugin.reload.end", yamlConfigurationOld.getString("Plugin.Reload.End"));
yamlConfigurationNew.set("plugin.noPermissionForCommand", yamlConfigurationOld.getString("Plugin.ForCommand"));
yamlConfigurationNew.set("plugin.noSubCommand", yamlConfigurationOld.getString("Plugin.NoSubCommand"));
yamlConfigurationNew.set("cost.buy", yamlConfigurationOld.getString("Cost.Buy"));
yamlConfigurationNew.set("cost.noMoney", yamlConfigurationOld.getString("Cost.NoMoney"));
yamlConfigurationNew.set("cost.confirm.command", yamlConfigurationOld.getString("Cost.BuyConfirm"));
yamlConfigurationNew.set("cost.confirm.cancel", yamlConfigurationOld.getString("Cost.BuyCancel"));
yamlConfigurationNew.set("cost.confirm.notPossible", yamlConfigurationOld.getString("Cost.BuyConfirmNotPossible"));
try {
yamlConfigurationNew.save(newFile);
} catch (IOException e) {
T2Csend.warning(Main.getPlugin(), e.getMessage());
e.printStackTrace();
}
T2Csend.console(Util.getPrefix() + " §2The language file §6(" + newFile.getName() + ") &2was converted to the new config format §7- §e" + (System.currentTimeMillis() - long2) + "ms");
}
}
}
T2Csend.console(Util.getPrefix() + " §2All files were successfully converted. §7- §e" + (System.currentTimeMillis() - long1) + "ms");
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
}
}

View File

@@ -18,63 +18,6 @@ import java.util.List;
public class FileSelect {
public static void config() {
Convert.convert();
long long_ = System.currentTimeMillis();
File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Config value : Config.values()) {
switch (value.configParam) {
case STRING:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.value);
}
value.value = T2Creplace.replace(Util.getPrefix(), yamlConfiguration.getString(value.path));
break;
case SOUND:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.sound.toString());
}
try {
value.sound = Sound.valueOf(yamlConfiguration.getString(value.path));
} catch (Exception ex) {
T2Csend.console("§4\n§4\n§4\n" + SelectLibMsg.soundNotFound.replace("[prefix]", Util.getPrefix())
.replace("[sound]", "§8" + value.path + ": §6" + yamlConfiguration.getString(value.path)) + "§4\n§4\n§4\n");
}
break;
case BOOLEAN:
case INTEGER:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.value);
}
value.value = yamlConfiguration.get(value.path);
break;
case CONFIRMENUM:
if (!yamlConfiguration.contains(value.path)) {
yamlConfiguration.set(value.path, value.value.toString());
}
try {
value.value = Confirm.valueOf(yamlConfiguration.getString(value.path).toUpperCase());
} catch (Exception ex) {
value.value = Confirm.COMMAND;
T2Csend.console(("[prefix] <red>The value in the <gold>config.yml</gold> at the path <gold>[path]</gold> <aqua>([value])</aqua> must be one of these values!</red>" +
" <gray>COMMAND, CHAT, GUI</gray><br>[prefix] <blue>The default option COMMAND is used!</blue>")
.replace("[prefix]", Util.getPrefix()).replace("[path]", value.path).replace("[value]", yamlConfiguration.getString(value.path)));
}
break;
}
}
try {
yamlConfiguration.save(config);
} catch (IOException e) {
e.printStackTrace();
}
T2Csend.console(Util.getPrefix() + " §2The config.yml was loaded successfully §7- §e" + (System.currentTimeMillis() - long_) + "ms");
}
private static ArrayList<String> defaultLanguages = new ArrayList<>(Arrays.asList("german", "english"));
public static void language() {
@@ -118,18 +61,18 @@ public class FileSelect {
}
String selectMSG;
File config = new File(Main.getPath(), "languages/" + Config.language.value + ".yml");
File config = new File(Main.getPath(), "languages/" + Config.VALUES.language.getValue() + ".yml");
T2Cdebug.debug(Main.getPlugin(), config.getAbsolutePath());
if (!config.isFile()) {
T2Csend.console(Util.getPrefix());
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.language.value + " §4language file was not found.");
T2Csend.console(Util.getPrefix() + " §4The selected §c" + Config.VALUES.language.getPath() + " §4language file was not found.");
T2Csend.console(Util.getPrefix() + " §6The default language §eEnglish §6is used!");
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Util.getPrefix());
config = new File(Main.getPath(), "languages/" + "english.yml");
selectMSG = "english";
} else selectMSG = (String) Config.language.value;
} else selectMSG = (String) Config.VALUES.language.getValue();
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Language value : Language.values()) {
switch (value.configParam) {

View File

@@ -27,6 +27,10 @@ public enum Language {
buy("cost.buy", null, "[prefix] <dark_green>Du hast f[ue]r diesen Command <gold>[price]</gold> bezahlt.</dark_green>",
"[prefix] <dark_green>You have paid <gold>[price]</gold> for this command.</dark_green>", ConfigParam.STRING),
noMoney("cost.noMoney", null, "[prefix] <red>Du hast nicht gen[ue]gend Geld für diesen Command!</red>", "[prefix] <red>You don't have enough money for this command!</red>", ConfigParam.STRING),
cooldownPlayer("cooldown.player",null,"[prefix] <red>Du musst noch <gold>[cooldown]</gold> Sekunden warten um diesen Command erneut zu nutzen.</red>","[prefix] <red>You must wait <gold>[cooldown]</gold> seconds to use this command again.</red>",ConfigParam.STRING),
cooldownGlobal("cooldown.global",null,"[prefix] <red>Du musst noch <gold>[cooldown]</gold> Sekunden warten um diesen Command zu nutzen.</red>","[prefix] <red>You have to wait <gold>[cooldown]</gold> seconds to use this command.</red>",ConfigParam.STRING),
confirmCommand("cost.confirm.command", null, "[prefix] <gold>Für diesen Befehl musst du [price] bezahlen!</gold><br>[prefix] <green><click:run_command:'/t2c-a confirm'><hover:show_text:'<gray>Klicke zum bestätigen</gray>'>Bestätigen</hover></click></green> <gray>-</gray> <red><click:run_command:'/t2c-a cancel'><hover:show_text:'<gray>Klicke zum abbrechen</gray>'>Abbrechen</hover></click></red>",
"[prefix] <gold>For this command you have to pay [price]!</gold><br>[prefix] <green><click:run_command:'/t2c-a confirm'><hover:show_text:'<gray>Click to confirm</gray>'>Confirm</hover></click></green> <gray>-</gray> <red><click:run_command:'/t2c-a cancel'><hover:show_text:'<gray>click to cancel</gray>'>Cancel</hover></click></red>", ConfigParam.STRING),
confirmChat("cost.confirm.chat", null, "[prefix] <gold>Für diesen Befehl musst du [price] bezahlen!</gold><br>[prefix] <green><click:run_command:'t2code-alias-confirm'><hover:show_text:'<gray>Klicke zum bestätigen</gray>'>Bestätigen</hover></click></green> <gray>-</gray> <red><click:run_command:'t2code-alias-cancel'><hover:show_text:'<gray>Klicke zum abbrechen</gray>'>Abbrechen</hover></click></red>",

View File

@@ -25,9 +25,12 @@ public class CreateExampleSubAliasConfig {
T2Cconfig.set("SubAlias.SubAliasFor", "aliasexample1", yamlConfiguration);
T2Cconfig.set("SubAlias.Permission.Necessary", true, yamlConfiguration);
T2Cconfig.set("SubAlias.Permission.Permission", "t2code.alias.use.subalias.<alias>", yamlConfiguration);
T2Cconfig.set("SubAlias.Permission.Permission", "t2c.alias.sub.use.[alias]", yamlConfiguration);
T2Cconfig.set("SubAlias.Permission.CustomNoPermissionMSG", "", yamlConfiguration);
T2Cconfig.set("SubAlias.CooldownInSec.Global", 0, yamlConfiguration);
T2Cconfig.set("SubAlias.CooldownInSec.Player", 0, yamlConfiguration);
T2Cconfig.set("SubAlias.Cost.Enable", false, yamlConfiguration);
T2Cconfig.set("SubAlias.Cost.Confirm", true,yamlConfiguration);
T2Cconfig.set("SubAlias.Cost.Price", 0.0, yamlConfiguration);
@@ -42,7 +45,7 @@ public class CreateExampleSubAliasConfig {
T2Cconfig.set("SubAlias.Message.Messages",Arrays.asList(), yamlConfiguration);
T2Cconfig.set("SubAlias.Admin.Enable", false, yamlConfiguration);
T2Cconfig.set("SubAlias.Admin.Permission", "t2code.alias.admin", yamlConfiguration);
T2Cconfig.set("SubAlias.Admin.Permission", "t2c.alias.admin", yamlConfiguration);
T2Cconfig.set("SubAlias.Admin.Command.Enable", true, yamlConfiguration);
T2Cconfig.set("SubAlias.Admin.Command.CommandAsConsole", true, yamlConfiguration);

View File

@@ -66,6 +66,16 @@ public class SelectSubAlias {
}
String permissionMSG = yamlConfiguration.getString("SubAlias.Permission.CustomNoPermissionMSG");
if (yamlConfiguration.get("SubAlias.CooldownInSec.Global") == null) {
AliasConfigConverter.convertAddCooldownInSecGlobal(yamlConfiguration, config_gui, true);
}
Integer cooldownGlobal = yamlConfiguration.getInt("SubAlias.CooldownInSec.Global");
if (yamlConfiguration.get("SubAlias.CooldownInSec.Player") == null) {
AliasConfigConverter.convertAddCooldownInSecPlayer(yamlConfiguration, config_gui, true);
}
Integer cooldownPlayer = yamlConfiguration.getInt("SubAlias.CooldownInSec.Player");
Boolean costEnable = yamlConfiguration.getBoolean("SubAlias.Cost.Enable");
if (yamlConfiguration.get("SubAlias.Cost.Confirm") == null) {
AliasConfigConverter.convertAddCostConfirm(yamlConfiguration, config_gui, true);
@@ -100,12 +110,14 @@ public class SelectSubAlias {
Boolean consoleMessageEnable = yamlConfiguration.getBoolean("SubAlias.Console.Message.Enable");
List<String> consoleMessages = yamlConfiguration.getStringList("SubAlias.Console.Message.Messages");
SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, costEnable,costConfirm, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand,
command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands,
adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, cooldownGlobal, cooldownPlayer, costEnable, costConfirm,
costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand, command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole,
adminBungeeCommand, adminCommands, adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
for (String sal : subAliasList) {
Main.subAliasHashMap.put(sal, subAlias);
}
Main.allSubAliases.addAll(subAliasList);
Main.allForSubAliases.add(subAliasFor);
T2Csend.console(Prefix + " §aSubAlias file §e" + config_gui.getName() + " §awas loaded");

View File

@@ -18,14 +18,14 @@ public class ConfirmGUI {
public static void open(Player player, Double price, String alias) {
Inventory inventory = Bukkit.createInventory((InventoryHolder) null, 9 * 3, (T2Creplace.replace(Util.getPrefix(), player,
Main.getGuiCode() + Language.confirmGuiTitle.value.replace("[price]",price+ " "+Config.buyCurrency.value).replace("[alias]", alias))));
Main.getGuiCode() + Language.confirmGuiTitle.value.replace("[price]",price+ " "+Config.VALUES.buyCurrency.getValue()).replace("[alias]", alias))));
T2CitemBuilder.fillItem((boolean) Config.buyConfirmGuiFillItemEnabled.value, (String) Config.buyConfirmGuiFillItem.value, 3, inventory);
T2CitemBuilder.fillItem((boolean) Config.VALUES.buyConfirmGuiFillItemEnabled.getValue(), (String) Config.VALUES.buyConfirmGuiFillItem.getValue(), 3, inventory);
T2CitemBuilder.setItem(12, 1, (String) Config.buyConfirmGuiConfirm.value, Language.confirmGuiConfirm.value,
(List<String>) T2Creplace.replace(Language.confirmGuiConfirmLore.valueList, "[price]", price + " " + Config.buyCurrency.value), inventory);
T2CitemBuilder.setItem(14, 1, (String) Config.buyConfirmGuiCancel.value, Language.confirmGuiCancel.value,
(List<String>) T2Creplace.replace(Language.confirmGuiCancelLore.valueList, "[price]", price + " " + Config.buyCurrency.value), inventory);
T2CitemBuilder.setItem(12, 1, (String) Config.VALUES.buyConfirmGuiConfirm.getValue(), Language.confirmGuiConfirm.value,
(List<String>) T2Creplace.replace(Language.confirmGuiConfirmLore.valueList, "[price]", price + " " + Config.VALUES.buyCurrency.getValue()), inventory);
T2CitemBuilder.setItem(14, 1, (String) Config.VALUES.buyConfirmGuiCancel.getValue(), Language.confirmGuiCancel.value,
(List<String>) T2Creplace.replace(Language.confirmGuiCancelLore.valueList, "[price]", price + " " + Config.VALUES.buyCurrency.getValue()), inventory);
Cache.openPlayers.add(player.getUniqueId());
player.openInventory(inventory);
}

View File

@@ -1,8 +1,14 @@
package net.t2code.alias.Spigot.objects;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
public class AliasObject {
public HashMap<UUID, Long> cooldownPlayerMap = new HashMap<>();
public Long globalCooldownInt = 0L;
public Boolean aliasEnable;
public List<String> aliasList;
@@ -10,6 +16,9 @@ public class AliasObject {
public String permission;
public String permissionMSG;
public Integer cooldownGlobal;
public Integer cooldownPlayer;
public Boolean costEnable;
public Boolean costConfirm;
public Double costPrice;
@@ -44,6 +53,9 @@ public class AliasObject {
String permission,
String permissionMSG,
Integer cooldownGlobal,
Integer cooldownPlayer,
Boolean costEnable,
Boolean costConfirm,
Double costPrice,
@@ -77,6 +89,9 @@ public class AliasObject {
this.permission = permission;
this.permissionMSG = permissionMSG;
this.cooldownGlobal = cooldownGlobal;
this.cooldownPlayer = cooldownPlayer;
this.costEnable = costEnable;
this.costConfirm = costConfirm;
this.costPrice = costPrice;

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

@@ -1,8 +1,13 @@
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;
@@ -12,6 +17,9 @@ public class SubAliasObject {
public String permission;
public String permissionMSG;
public Integer cooldownGlobal;
public Integer cooldownPlayer;
public Boolean costEnable;
public Boolean costConfirm;
public Double costPrice;
@@ -48,6 +56,9 @@ public class SubAliasObject {
String permission,
String permissionMSG,
Integer cooldownGlobal,
Integer cooldownPlayer,
Boolean costEnable,
Boolean costConfirm,
Double costPrice,
@@ -83,6 +94,9 @@ public class SubAliasObject {
this.permission = permission;
this.permissionMSG = permissionMSG;
this.cooldownGlobal = cooldownGlobal;
this.cooldownPlayer = cooldownPlayer;
this.costEnable = costEnable;
this.costConfirm = costConfirm;
this.costPrice = costPrice;

View File

@@ -8,83 +8,48 @@ import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.entity.Player;
import org.bukkit.plugin.SimplePluginManager;
import java.lang.reflect.Field;
import java.util.Map;
import java.util.Objects;
public class AliasRegister {
public static void onRegister() {
try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
// onUnRegister(bukkitCommandMap);
private Main main;
public AliasRegister (Main main){
this.main=main;
loadAliasCommands();
}
private void loadAliasCommands() {
CommandMap commandMap = getCommandMap();
if (commandMap == null) {
main. getLogger().severe("CommandMap konnte nicht geladen werden!");
return;
}
for (String alias : Main.allAliases) {
register(alias, commandMap);
// wrap(alias, commandMap);
}
if (!(T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12())) {
Main.getPlugin().getBukkitCommandWrap().sync();
if (Bukkit.getOnlinePlayers().size() >= 1)
for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
// Registrieren des Befehls
Command dynamicCommand = new RegisterCommands(alias);
commandMap.register(main.getDescription().getName(), dynamicCommand);
T2Csend.console(Util.getPrefix() + " §aAlias §e" + alias + " §aregister");
}
}
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();
}
}
//public static void onUnRegister(Field bukkitCommandMap) throws IllegalAccessException {
//
// // if (Main.allAliases != null && !Main.allAliases.isEmpty()) {
// // if (!(Main.getPlugin().getBukkitCommandWrap() instanceof BukkitCommandWrap_Useless)) {
// // for (String alias : Main.allAliases) {
// // T2Csend.debugmsg(Main.getPlugin(),"uload: " + alias);
// // Main.getPlugin().
// // Main.getPlugin().getBukkitCommandWrap().unwrap(alias);
// // }
// // Main.getPlugin().getBukkitCommandWrap().sync();
// // if (Bukkit.getOnlinePlayers().size() >= 1)
// // for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
// // }
// // }
// // commandMap.clearCommands();
//
//
// for (Map.Entry<String, Boolean> entry : Main.loadAliasHashMap.entrySet()) {
// ((SimpleCommandMap) bukkitCommandMap.get(simplePluginManager)).getCommand(entry.getKey()).unregister(bukkitCommandMap.get(Bukkit.getServer()));
//
//
// if (entry.getValue())
// Main.getPlugin().getBukkitCommandWrap().unwrap(entry.getKey());
// }
//
// Main.getPlugin().getBukkitCommandWrap().sync();
// if (Bukkit.getOnlinePlayers().size() >= 1)
// for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
// Main.loadAliasHashMap.clear();
//
//}
private static void register(String alias, CommandMap commandMap) {
if (Main.aliasHashMap.get(alias) != null) {
if (alias.equals(" ")) return;
if (Main.aliasHashMap.get(alias).aliasEnable) {
commandMap.register(alias, new RegisterCommands(alias));
T2Csend.console(Util.getPrefix() + " §aAlias §e" + alias + " §aregister");
Main.loadAliasHashMap.put(alias, true);
} else Main.loadAliasHashMap.put(alias, false);
} else T2Csend.warning(Main.getPlugin(), " §4AliasHashmap is null! - " + alias);
return null;
}
private static void wrap(String alias, CommandMap commandMap) {
Command cmd = commandMap.getCommand(alias);
Main.getPlugin().getBukkitCommandWrap().wrap(cmd, alias);
}
}

View File

@@ -5,6 +5,7 @@ import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
import org.bukkit.Bukkit;
import org.bukkit.permissions.PermissionDefault;
public class AliasRegisterPermissions {
@@ -13,22 +14,40 @@ public class AliasRegisterPermissions {
for (AliasObject aliasObject : Main.aliasHashMap.values()) {
for (String alias : aliasObject.aliasList) {
if (Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.permission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
if (aliasObject.permission != null && Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("[alias]", alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.permission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.adminPermission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
if (aliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("[alias]", alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.adminPermission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.buy." + alias.toLowerCase() + ".bypass") == null) {
T2Cregister.permission("t2c.alias.buy." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.cooldown.global." + alias.toLowerCase() + ".bypass") == null) {
T2Cregister.permission("t2c.alias.cooldown.global." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.cooldown.player." + alias.toLowerCase() + ".bypass") == null) {
T2Cregister.permission("t2c.alias.cooldown.player." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
}
}
}
for (SubAliasObject subAliasObject : Main.subAliasHashMap.values()) {
for (String alias : subAliasObject.subAliasList) {
if (Bukkit.getPluginManager().getPermission(subAliasObject.permission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.permission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
if (subAliasObject.permission != null && Bukkit.getPluginManager().getPermission(subAliasObject.permission.replace("[alias]", alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.permission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.adminPermission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
if (subAliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("[alias]", alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.adminPermission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.buy." + alias.toLowerCase() + ".bypass") == null) {
T2Cregister.permission("t2c.alias.sub.buy." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass") == null) {
T2Cregister.permission("t2c.alias.sub.cooldown.global." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass") == null) {
T2Cregister.permission("t2c.alias.sub.cooldown.player." + alias.toLowerCase() + ".bypass", PermissionDefault.OP, Main.getPlugin());
}
}
}

View File

@@ -1,6 +1,7 @@
package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Main;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -12,31 +13,7 @@ import java.io.IOException;
public class BCommandSenderReciver {
public static void sendToBungee(CommandSender sender, String information, Boolean console) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(stream);
try {
if (console) {
output.writeUTF("T2Code-Console");
} else {
if (sender instanceof Player) {
output.writeUTF(sender.getName());
} else {
output.writeUTF("T2Code-Console");
}
}
output.writeUTF(information);
} catch (IOException e) {
e.printStackTrace();
}
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
}else {
for(Player player : Bukkit.getOnlinePlayers()){
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
return;
}
}
T2CbungeeCommandSenderReciver.sendToBungee(sender,information,console);
}
}

View File

@@ -1,247 +0,0 @@
package net.t2code.alias.Spigot.system;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.RootCommandNode;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class BukkitCommandWrap {
private Field bField;
private Method removeCommandMethod;
private String nmsVersion;
private Class minecraftServerClass;
private Method aMethod;
private Method getServerMethod;
private Field vanillaCommandDispatcherField;
private Method getCommandDispatcherMethod;
private Method registerMethod;
private Method syncCommandsMethod;
private Constructor bukkitcommandWrapperConstructor;
public BukkitCommandWrap() {
try {
this.nmsVersion = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
} catch (ArrayIndexOutOfBoundsException e) {
e.printStackTrace();
this.nmsVersion = null;
}
}
public void wrap(Command command, String alias) {
if (this.nmsVersion == null) return;
if (this.minecraftServerClass == null) try {
this.minecraftServerClass = Class.forName("net.minecraft.server." + this.nmsVersion + ".MinecraftServer");
} catch (ClassNotFoundException e) {
try {
this.minecraftServerClass = Class.forName("net.minecraft.server.MinecraftServer");
} catch (ClassNotFoundException classNotFoundException) {
classNotFoundException.addSuppressed(e);
classNotFoundException.printStackTrace();
return;
}
}
if (this.getServerMethod == null) try {
this.getServerMethod = this.minecraftServerClass.getMethod("getServer");
this.getServerMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
return;
}
Object minecraftServer;
try {
minecraftServer = this.getServerMethod.invoke(this.minecraftServerClass);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return;
}
if (this.vanillaCommandDispatcherField == null) try {
this.vanillaCommandDispatcherField = this.minecraftServerClass.getDeclaredField("vanillaCommandDispatcher");
this.vanillaCommandDispatcherField.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
return;
}
Object commandDispatcher = null;
try {
commandDispatcher = this.vanillaCommandDispatcherField.get(minecraftServer);
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
if (this.bField == null) try {
this.bField = Class.forName("net.minecraft.commands.CommandDispatcher").getDeclaredField("g");
this.bField.setAccessible(true);
} catch (NoSuchFieldException | ClassNotFoundException e) {
e.printStackTrace();
return;
}
com.mojang.brigadier.CommandDispatcher b;
try {
b = (com.mojang.brigadier.CommandDispatcher) this.bField.get(commandDispatcher);
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
if (this.aMethod == null) try {
this.aMethod = commandDispatcher.getClass().getDeclaredMethod("a");
this.aMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
return;
}
if (this.bukkitcommandWrapperConstructor == null) try {
this.bukkitcommandWrapperConstructor = Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".command.BukkitCommandWrapper").getDeclaredConstructor(Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".CraftServer"), Command.class);
this.bukkitcommandWrapperConstructor.setAccessible(true);
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
return;
}
Object commandWrapper;
try {
commandWrapper = this.bukkitcommandWrapperConstructor.newInstance(Bukkit.getServer(), command);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return;
}
Object a;
try {
a = this.aMethod.invoke(commandDispatcher);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return;
}
if (this.registerMethod == null) try {
this.registerMethod = Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".command.BukkitCommandWrapper").getMethod("register", com.mojang.brigadier.CommandDispatcher.class, String.class);
this.registerMethod.setAccessible(true);
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
return;
}
try {
this.registerMethod.invoke(commandWrapper, a, alias);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
public void sync() {
if (this.syncCommandsMethod == null) try {
this.syncCommandsMethod = Class.forName("org.bukkit.craftbukkit." + this.nmsVersion + ".CraftServer").getDeclaredMethod("syncCommands");
this.syncCommandsMethod.setAccessible(true);
} catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace();
return;
}
try {
this.syncCommandsMethod.invoke(Bukkit.getServer());
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
public void unwrap(String command) {
if (this.nmsVersion == null) return;
if (this.minecraftServerClass == null) try {
this.minecraftServerClass = Class.forName("net.minecraft.server." + this.nmsVersion + ".MinecraftServer");
} catch (ClassNotFoundException e) {
try {
this.minecraftServerClass = Class.forName("net.minecraft.server.MinecraftServer");
} catch (ClassNotFoundException classNotFoundException) {
classNotFoundException.printStackTrace();
classNotFoundException.addSuppressed(e);
return;
}
}
if (this.getServerMethod == null) try {
this.getServerMethod = this.minecraftServerClass.getMethod("getServer");
this.getServerMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
return;
}
Object server;
try {
server = this.getServerMethod.invoke(this.minecraftServerClass);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return;
}
if (this.vanillaCommandDispatcherField == null) try {
this.vanillaCommandDispatcherField = this.minecraftServerClass.getDeclaredField("vanillaCommandDispatcher");
this.vanillaCommandDispatcherField.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
return;
}
Object commandDispatcher = null;
try {
commandDispatcher = this.vanillaCommandDispatcherField.get(server);
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
if (this.bField == null) try {
this.bField = Class.forName("net.minecraft.server." + this.nmsVersion + ".CommandDispatcher").getDeclaredField("b");
this.bField.setAccessible(true);
} catch (NoSuchFieldException | ClassNotFoundException e) {
if (this.bField == null) try {
this.bField = Class.forName("net.minecraft.commands.CommandDispatcher").getDeclaredField("g");
this.bField.setAccessible(true);
} catch (NoSuchFieldException | ClassNotFoundException ex) {
ex.addSuppressed(e);
e.printStackTrace();
return;
}
}
com.mojang.brigadier.CommandDispatcher b;
try {
b = (com.mojang.brigadier.CommandDispatcher) this.bField.get(commandDispatcher);
} catch (IllegalAccessException e) {
e.printStackTrace();
return;
}
if (this.removeCommandMethod == null) try {
try {
this.removeCommandMethod = RootCommandNode.class.getDeclaredMethod("removeCommand", String.class);
} catch (NoSuchMethodException | NoSuchMethodError ex) {
this.removeCommandMethod = CommandNode.class.getDeclaredMethod("removeCommand", String.class);
}
} catch (NoSuchMethodException e) {
e.printStackTrace();
return;
}
try {
this.removeCommandMethod.invoke(b.getRoot(), command);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
}

View File

@@ -1,17 +0,0 @@
package net.t2code.alias.Spigot.system;
import org.bukkit.command.Command;
public class BukkitCommandWrap_Useless extends BukkitCommandWrap {
public BukkitCommandWrap_Useless() {
}
@Override
public void wrap(Command command, String alias) {
}
@Override
public void unwrap(String command) {
}
}

View File

@@ -16,7 +16,7 @@ import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
import net.t2code.t2codelib.SPIGOT.api.update.T2CupdateAPI;
import net.t2code.t2codelib.SPIGOT.api.yaml.T2CLibConfig;
import net.t2code.t2codelib.SPIGOT.system.config.config.T2CLibConfig;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
@@ -26,12 +26,16 @@ import java.util.List;
public class Load {
private static final Main plugin = Main.getPlugin();
public static void onLoad(String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID) {
public Load (Main main,String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID){
onLoad(main, prefix, autor, version, spigot, discord, bstatsID);
}
private void onLoad(Main main,String prefix, List<String> autor, String version, String spigot, String discord, int bstatsID) {
Long long_ = T2Ctemplate.onLoadHeader(prefix, autor, version, spigot, discord);
plugin.getCommand("t2code-alias").setExecutor(new AliasCmdExecuter());
loadReload();
loadReload(main);
T2CupdateAPI.onUpdateCheck(plugin, prefix, Util.getGit(), Util.getSpigotID(), Util.getDiscord(),
(Boolean) Config.updateCheckOnJoin.value, (Boolean) Config.updateCheckSeePreReleaseUpdates.value, (Integer) Config.updateCheckTimeInterval.value);
(Boolean) Config.VALUES.updateCheckOnJoin.getValue(), (Boolean) Config.VALUES.updateCheckSeePreReleaseUpdates.getValue(), (Integer) Config.VALUES.updateCheckTimeInterval.getValue());
T2Ctemplate.onLoadFooter(prefix, long_);
T2Cregister.listener(new PluginEvents(), plugin);
@@ -41,11 +45,11 @@ public class Load {
private static ChatConfirm chatListener;
private static GuiListener guiListener;
public static void loadReload() {
public static void loadReload(Main main) {
HandlerList.unregisterAll(chatListener);
HandlerList.unregisterAll(guiListener);
boolean newInstall = !new File(Main.getPath(), "config.yml").exists();
FileSelect.config();
Config.set();
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
FileSelect.language();
if (newInstall) {
@@ -66,12 +70,13 @@ public class Load {
} catch (Exception e) {
e.printStackTrace();
}
/**
try {
plugin.saveResource("X_configDeclaration_X.yml", true);
} catch (Exception e) {
e.printStackTrace();
}
*/
try {
plugin.saveResource("SubAlias/X_subAliasDeclaration_X.yml", true);
@@ -80,17 +85,17 @@ public class Load {
}
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
SelectAlias.onSelect();
new SelectAlias(main);
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
SelectSubAlias.onSelect();
if ((Boolean) Config.subAliasTab.value) {
if ((Boolean) Config.VALUES.subAliasTab.getValue()) {
T2Cregister.listener(new TabEvent(), plugin);
}
chatListener = new ChatConfirm();
if (Config.buyConfirmDefault.value == Confirm.CHAT) T2Cregister.listener(chatListener, plugin);
if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.CHAT) T2Cregister.listener(chatListener, plugin);
guiListener = new GuiListener();
if (Config.buyConfirmDefault.value == Confirm.GUI) T2Cregister.listener(guiListener, plugin);
if (T2CLibConfig.getBungee()) {
if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.GUI) T2Cregister.listener(guiListener, plugin);
if ((boolean)T2CLibConfig.VALUES.proxy.getValue()) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "t2c:bcmd");
}
AliasRegisterPermissions.onPermRegister();

View File

@@ -22,6 +22,6 @@ public class PluginEvents implements Listener {
@EventHandler
public void onJoinEvent(PlayerLoginEvent event) {
T2CupdateAPI.join(Main.getPlugin(), Util.getPrefix(), "t2code.alias.updatemsg", event.getPlayer(), Util.getSpigotID(), Util.getDiscord());
T2CupdateAPI.join(Main.getPlugin(), Util.getPrefix(), "t2c.alias.updatemsg", event.getPlayer(), Util.getSpigotID(), Util.getDiscord());
}
}

View File

@@ -1,5 +1,7 @@
package net.t2code.alias;
import lombok.Getter;
public class Util {
@@ -8,7 +10,7 @@ public class Util {
}
public static String getRequiredT2CodeLibVersion() {
return "15.7";
return "16.7";
}
public static String getPrefix() {
@@ -41,7 +43,22 @@ public class Util {
private static String prefix = "§8[§4T2Code§7-§aAlias§8]";
public static Integer getConfigVersion() {
return 4;
}
@Getter
private static final String[] configLogo = new String[]{
"####################################################################################################################",
"## ##",
"## /$$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ ##",
"## |__ $$__//$$__ $$ /$$__ $$ | $$ | $$ ##",
"## | $$ |__/ \\ $$| $$ \\__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ ##",
"## | $$ /$$$$$$/| $$ /$$__ $$ /$$__ $$ /$$__ $$ | $$__ $$ /$$__ $$|_ $$_/ ##",
"## | $$ /$$____/ | $$ | $$ \\ $$| $$ | $$| $$$$$$$$ | $$ \\ $$| $$$$$$$$ | $$ ##",
"## | $$ | $$ | $$ $$| $$ | $$| $$ | $$| $$_____/ | $$ | $$| $$_____/ | $$ /$$ ##",
"## | $$ | $$$$$$$$| $$$$$$/| $$$$$$/| $$$$$$$| $$$$$$$ /$$| $$ | $$| $$$$$$$ | $$$$/ ##",
"## |__/ |________/ \\______/ \\______/ \\_______/ \\_______/|__/|__/ |__/ \\_______/ \\___/ ##",
"## ##",
"## T2CodeLib from JaTiTV / T2Code.net. In case of problems please contact the Discord: https://dc.t2code.net ##",
"## ##",
"####################################################################################################################"
};
}

View File

@@ -11,25 +11,43 @@ Alias:
AliasList:
- aliasexample1
- aliasexample2
-
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 alias name.
# The placeholder <[alias] is the alias name.
# If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias.
Permission: 't2code.alias.use.<alias>'
Permission: 't2c.alias.use.[alias]'
# Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank.
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:
# 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 (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
# 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
@@ -42,6 +60,7 @@ Alias:
# 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
@@ -78,9 +97,9 @@ Alias:
# 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.
# 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: t2code.alias.admin
Permission: t2c.alias.[alias].admin
Command:
# Here you can tell the alias to execute one or more commands
Enable: false
@@ -93,6 +112,7 @@ Alias:
# 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

View File

@@ -19,21 +19,38 @@ SubAlias:
# 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 alias name.
# 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: 't2code.alias.use.subalias.<alias>'
Permission: 't2c.subalias.use.[alias]'
# Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank.
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 (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
# 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
@@ -46,6 +63,7 @@ SubAlias:
# 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
@@ -82,9 +100,9 @@ SubAlias:
# 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.
# 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: t2code.alias.admin
Permission: t2c.alias.sub.[alias].admin
Command:
# Here you can tell the alias to execute one or more commands
Enable: false
@@ -97,6 +115,7 @@ SubAlias:
# 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

View File

@@ -10,7 +10,7 @@ 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 't2code.alias.updatemsg' will get an update message on join when an update for the plugin is available.
# 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

View File

@@ -16,20 +16,39 @@ commands:
aliases: [t2c-a, alias]
permissions:
t2code.alias.admin:
t2c.alias.admin:
default: op
children:
t2code.alias.updatemsg: true
t2code.alias.command.reload: true
t2code.alias.command.info: true
t2code.alias.buy.bypass: true
t2c.alias.updatemsg: true
t2c.alias.command.reload: true
t2c.alias.command.info: 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
t2code.alias.updatemsg:
t2c.alias.command.reload:
default: op
t2code.alias.command.reload:
t2c.alias.command.info:
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