3 Commits

Author SHA1 Message Date
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 539 additions and 711 deletions

View File

@@ -63,14 +63,14 @@ WebUI: https://webui.adventure.kyori.net
**/t2code-alias** | **/alias** **/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"> <img src="https://i.imgur.com/HoZSt7c.png" width="600">

69
pom.xml
View File

@@ -7,7 +7,10 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>Alias</artifactId> <artifactId>Alias</artifactId>
<version>1.4</version> <version>1.6_DEV</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>
@@ -37,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>
@@ -57,47 +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>15.7</version> <version>16.7</version>
<!--classifier>dev-3</classifier--> <classifier>dev-1</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>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>RELEASE</version> <version>RELEASE</version>
<scope>compile</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@@ -3,12 +3,11 @@ package net.t2code.alias.Spigot;
import lombok.Getter; import lombok.Getter;
import net.t2code.alias.Spigot.objects.AliasObject; import net.t2code.alias.Spigot.objects.AliasObject;
import net.t2code.alias.Spigot.objects.SubAliasObject; import net.t2code.alias.Spigot.objects.SubAliasObject;
import net.t2code.alias.Spigot.system.BukkitCommandWrap;
import net.t2code.alias.Spigot.system.BukkitCommandWrap_Useless;
import net.t2code.alias.Spigot.system.Load; import net.t2code.alias.Spigot.system.Load;
import net.t2code.alias.Util; import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate; import net.t2code.t2codelib.SPIGOT.api.messages.T2Ctemplate;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion; import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@@ -38,12 +37,11 @@ public final class Main extends JavaPlugin {
public static ArrayList<String> allSubAliases = new ArrayList<>(); public static ArrayList<String> allSubAliases = new ArrayList<>();
public static ArrayList<String> allForSubAliases = new ArrayList<>(); public static ArrayList<String> allForSubAliases = new ArrayList<>();
private BukkitCommandWrap bukkitCommandWrap = null; // private BukkitCommandWrap bukkitCommandWrap = null;
//
public BukkitCommandWrap getBukkitCommandWrap() { // public BukkitCommandWrap getBukkitCommandWrap() {
return this.bukkitCommandWrap; // return this.bukkitCommandWrap;
} // }
@Override @Override
@@ -52,17 +50,28 @@ public final class Main extends JavaPlugin {
plugin = this; plugin = this;
autor = plugin.getDescription().getAuthors(); autor = plugin.getDescription().getAuthors();
version = plugin.getDescription().getVersion(); version = plugin.getDescription().getVersion();
if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; if (!Bukkit.getPluginManager().isPluginEnabled("T2CodeLib")) {
try { getLogger().severe("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
Class.forName("com.mojang.brigadier.CommandDispatcher"); getLogger().severe("+ T2CodeLib ist nicht im plugins Ordner, +");
this.bukkitCommandWrap = new BukkitCommandWrap(); getLogger().severe("+ daher wurde es aus der eigenen Library geladen! +");
} catch (ClassNotFoundException | NoClassDefFoundError e) { getLogger().severe("+ Es wird empfohlen die T2CodeLib als eigenes Plugin zu laden, +");
this.bukkitCommandWrap = new BukkitCommandWrap_Useless(); getLogger().severe("+ um keine Komplikationen mit anderen Plugins von T2Code zu bekommen! +");
getLogger().severe("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
new T2CodeLibMain().onEnable();
} }
// if (pluginNotFound("T2CodeLib", 96388, Util.getRequiredT2CodeLibVersion())) return; todo
// try {
// Class.forName("com.mojang.brigadier.CommandDispatcher");
// this.bukkitCommandWrap = new BukkitCommandWrap();
// } catch (ClassNotFoundException | NoClassDefFoundError e) {
// this.bukkitCommandWrap = new BukkitCommandWrap_Useless();
// }
if (T2CmcVersion.isMc1_13()) { if (T2CmcVersion.isMc1_13()) {
guiCode = ""; guiCode = "";
} else guiCode = "§6§8§9§r"; } 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 @Override

View File

@@ -23,21 +23,21 @@ 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 T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info") } else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info")); .replace("[perm]", "t2c.alias.command.info"));
} else { } else {
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "reload": case "reload":
case "rl": case "rl":
if (sender.hasPermission("t2code.alias.command.reload") || sender.isOp()) { if (sender.hasPermission("t2c.alias.command.reload") || sender.isOp()) {
Commands.reload(sender); Commands.reload(sender);
} else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias reload") } else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias reload")
.replace("[perm]", "t2code.alias.command.reload")); .replace("[perm]", "t2c.alias.command.reload"));
break; break;
case "confirm": case "confirm":
if (Config.buyConfirmDefault.value == Confirm.COMMAND) ExecuteAlias.storage(sender, true); if (Config.VALUES.buyConfirmDefault.getValue() == Confirm.COMMAND) ExecuteAlias.storage(sender, true);
break; break;
case "cancel": case "cancel":
ExecuteAlias.storage(sender, false); ExecuteAlias.storage(sender, false);
@@ -45,10 +45,10 @@ public class AliasCmdExecuter implements CommandExecutor, TabCompleter {
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 T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info") } else T2Csend.sender(sender, Language.noPermission.value.replace("[cmd]", "/t2code-alias info")
.replace("[perm]", "t2code.alias.command.info")); .replace("[perm]", "t2c.alias.command.info"));
break; break;
} }
@@ -58,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
@@ -70,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

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

View File

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

View File

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

View File

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

View File

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

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 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")); private static ArrayList<String> defaultLanguages = new ArrayList<>(Arrays.asList("german", "english"));
public static void language() { public static void language() {
@@ -118,18 +61,18 @@ public class FileSelect {
} }
String selectMSG; 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()); T2Cdebug.debug(Main.getPlugin(), config.getAbsolutePath());
if (!config.isFile()) { if (!config.isFile()) {
T2Csend.console(Util.getPrefix()); T2Csend.console(Util.getPrefix());
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); 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() + " §6The default language §eEnglish §6is used!");
T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); T2Csend.console(Util.getPrefix() + " §4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
T2Csend.console(Util.getPrefix()); T2Csend.console(Util.getPrefix());
config = new File(Main.getPath(), "languages/" + "english.yml"); config = new File(Main.getPath(), "languages/" + "english.yml");
selectMSG = "english"; selectMSG = "english";
} else selectMSG = (String) Config.language.value; } else selectMSG = (String) Config.VALUES.language.getValue();
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
for (Language value : Language.values()) { for (Language value : Language.values()) {
switch (value.configParam) { 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>", 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), "[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), 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>", 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), "[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>", 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.SubAliasFor", "aliasexample1", yamlConfiguration);
T2Cconfig.set("SubAlias.Permission.Necessary", true, 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.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.Enable", false, yamlConfiguration);
T2Cconfig.set("SubAlias.Cost.Confirm", true,yamlConfiguration); T2Cconfig.set("SubAlias.Cost.Confirm", true,yamlConfiguration);
T2Cconfig.set("SubAlias.Cost.Price", 0.0, 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.Message.Messages",Arrays.asList(), yamlConfiguration);
T2Cconfig.set("SubAlias.Admin.Enable", false, 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.Enable", true, yamlConfiguration);
T2Cconfig.set("SubAlias.Admin.Command.CommandAsConsole", 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"); String permissionMSG = yamlConfiguration.getString("SubAlias.Permission.CustomNoPermissionMSG");
if (yamlConfiguration.get("SubAlias.CooldownInSec.Global") == null) {
AliasConfigConverter.convertAddCooldownInSecGlobal(yamlConfiguration, config_gui, true);
}
Integer cooldownGlobal = yamlConfiguration.getInt("SubAlias.CooldownInSec.Global");
if (yamlConfiguration.get("SubAlias.CooldownInSec.Player") == null) {
AliasConfigConverter.convertAddCooldownInSecPlayer(yamlConfiguration, config_gui, true);
}
Integer cooldownPlayer = yamlConfiguration.getInt("SubAlias.CooldownInSec.Player");
Boolean costEnable = yamlConfiguration.getBoolean("SubAlias.Cost.Enable"); Boolean costEnable = yamlConfiguration.getBoolean("SubAlias.Cost.Enable");
if (yamlConfiguration.get("SubAlias.Cost.Confirm") == null) { if (yamlConfiguration.get("SubAlias.Cost.Confirm") == null) {
AliasConfigConverter.convertAddCostConfirm(yamlConfiguration, config_gui, true); AliasConfigConverter.convertAddCostConfirm(yamlConfiguration, config_gui, true);
@@ -100,12 +110,14 @@ public class SelectSubAlias {
Boolean consoleMessageEnable = yamlConfiguration.getBoolean("SubAlias.Console.Message.Enable"); Boolean consoleMessageEnable = yamlConfiguration.getBoolean("SubAlias.Console.Message.Enable");
List<String> consoleMessages = yamlConfiguration.getStringList("SubAlias.Console.Message.Messages"); List<String> consoleMessages = yamlConfiguration.getStringList("SubAlias.Console.Message.Messages");
SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, costEnable,costConfirm, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand, SubAliasObject subAlias = new SubAliasObject(aliasEnable, subAliasList, subAliasFor, subAliasArg, permNecessary, permission, permissionMSG, cooldownGlobal, cooldownPlayer, costEnable, costConfirm,
command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole, adminBungeeCommand, adminCommands, costPrice, costAllowBypass, commandEnable, commandAsConsole, bungeeCommand, command, messageEnable, messages, adminEnable, adminPermission, adminCommandEnable, adminCommandAsConsole,
adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages); adminBungeeCommand, adminCommands, adminMessageEnable, adminMessages, consoleEnable, consoleCommandEnable, consoleBungeeCommand, consoleCommands, consoleMessageEnable, consoleMessages);
for (String sal : subAliasList) { for (String sal : subAliasList) {
Main.subAliasHashMap.put(sal, subAlias); Main.subAliasHashMap.put(sal, subAlias);
} }
Main.allSubAliases.addAll(subAliasList); Main.allSubAliases.addAll(subAliasList);
Main.allForSubAliases.add(subAliasFor); Main.allForSubAliases.add(subAliasFor);
T2Csend.console(Prefix + " §aSubAlias file §e" + config_gui.getName() + " §awas loaded"); 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) { public static void open(Player player, Double price, String alias) {
Inventory inventory = Bukkit.createInventory((InventoryHolder) null, 9 * 3, (T2Creplace.replace(Util.getPrefix(), player, 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, T2CitemBuilder.setItem(12, 1, (String) Config.VALUES.buyConfirmGuiConfirm.getValue(), Language.confirmGuiConfirm.value,
(List<String>) T2Creplace.replace(Language.confirmGuiConfirmLore.valueList, "[price]", price + " " + Config.buyCurrency.value), inventory); (List<String>) T2Creplace.replace(Language.confirmGuiConfirmLore.valueList, "[price]", price + " " + Config.VALUES.buyCurrency.getValue()), inventory);
T2CitemBuilder.setItem(14, 1, (String) Config.buyConfirmGuiCancel.value, Language.confirmGuiCancel.value, T2CitemBuilder.setItem(14, 1, (String) Config.VALUES.buyConfirmGuiCancel.getValue(), Language.confirmGuiCancel.value,
(List<String>) T2Creplace.replace(Language.confirmGuiCancelLore.valueList, "[price]", price + " " + Config.buyCurrency.value), inventory); (List<String>) T2Creplace.replace(Language.confirmGuiCancelLore.valueList, "[price]", price + " " + Config.VALUES.buyCurrency.getValue()), inventory);
Cache.openPlayers.add(player.getUniqueId()); Cache.openPlayers.add(player.getUniqueId());
player.openInventory(inventory); player.openInventory(inventory);
} }

View File

@@ -1,8 +1,14 @@
package net.t2code.alias.Spigot.objects; package net.t2code.alias.Spigot.objects;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID;
public class AliasObject { public class AliasObject {
public HashMap<UUID, Long> cooldownPlayerMap = new HashMap<>();
public Long globalCooldownInt = 0L;
public Boolean aliasEnable; public Boolean aliasEnable;
public List<String> aliasList; public List<String> aliasList;
@@ -10,6 +16,9 @@ public class AliasObject {
public String permission; public String permission;
public String permissionMSG; public String permissionMSG;
public Integer cooldownGlobal;
public Integer cooldownPlayer;
public Boolean costEnable; public Boolean costEnable;
public Boolean costConfirm; public Boolean costConfirm;
public Double costPrice; public Double costPrice;
@@ -44,6 +53,9 @@ public class AliasObject {
String permission, String permission,
String permissionMSG, String permissionMSG,
Integer cooldownGlobal,
Integer cooldownPlayer,
Boolean costEnable, Boolean costEnable,
Boolean costConfirm, Boolean costConfirm,
Double costPrice, Double costPrice,
@@ -77,6 +89,9 @@ public class AliasObject {
this.permission = permission; this.permission = permission;
this.permissionMSG = permissionMSG; this.permissionMSG = permissionMSG;
this.cooldownGlobal = cooldownGlobal;
this.cooldownPlayer = cooldownPlayer;
this.costEnable = costEnable; this.costEnable = costEnable;
this.costConfirm = costConfirm; this.costConfirm = costConfirm;
this.costPrice = costPrice; 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; package net.t2code.alias.Spigot.objects;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID;
public class SubAliasObject { public class SubAliasObject {
public HashMap<UUID, Long> cooldownPlayerMap = new HashMap<>();
public Long globalCooldownInt = 0L;
public Boolean subAliasEnable; public Boolean subAliasEnable;
public List<String> subAliasList; public List<String> subAliasList;
public Integer subAliasArg; public Integer subAliasArg;
@@ -12,6 +17,9 @@ public class SubAliasObject {
public String permission; public String permission;
public String permissionMSG; public String permissionMSG;
public Integer cooldownGlobal;
public Integer cooldownPlayer;
public Boolean costEnable; public Boolean costEnable;
public Boolean costConfirm; public Boolean costConfirm;
public Double costPrice; public Double costPrice;
@@ -48,6 +56,9 @@ public class SubAliasObject {
String permission, String permission,
String permissionMSG, String permissionMSG,
Integer cooldownGlobal,
Integer cooldownPlayer,
Boolean costEnable, Boolean costEnable,
Boolean costConfirm, Boolean costConfirm,
Double costPrice, Double costPrice,
@@ -83,6 +94,9 @@ public class SubAliasObject {
this.permission = permission; this.permission = permission;
this.permissionMSG = permissionMSG; this.permissionMSG = permissionMSG;
this.cooldownGlobal = cooldownGlobal;
this.cooldownPlayer = cooldownPlayer;
this.costEnable = costEnable; this.costEnable = costEnable;
this.costConfirm = costConfirm; this.costConfirm = costConfirm;
this.costPrice = costPrice; this.costPrice = costPrice;

View File

@@ -8,83 +8,48 @@ import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandMap; import org.bukkit.command.CommandMap;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.SimplePluginManager; import org.bukkit.plugin.SimplePluginManager;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Map;
import java.util.Objects;
public class AliasRegister { public class AliasRegister {
public static void onRegister() { private Main main;
try {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
// onUnRegister(bukkitCommandMap);
for (String alias : Main.allAliases) {
register(alias, commandMap);
// wrap(alias, commandMap);
}
public AliasRegister (Main main){
this.main=main;
loadAliasCommands();
}
if (!(T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12())) { private void loadAliasCommands() {
Main.getPlugin().getBukkitCommandWrap().sync(); CommandMap commandMap = getCommandMap();
if (Bukkit.getOnlinePlayers().size() >= 1)
for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
}
} catch (Exception e) { if (commandMap == null) {
e.printStackTrace(); main. getLogger().severe("CommandMap konnte nicht geladen werden!");
return;
}
for (String alias : Main.allAliases) {
// Registrieren des Befehls
Command dynamicCommand = new RegisterCommands(alias);
commandMap.register(main.getDescription().getName(), dynamicCommand);
T2Csend.console(Util.getPrefix() + " §aAlias §e" + alias + " §aregister");
} }
} }
//public static void onUnRegister(Field bukkitCommandMap) throws IllegalAccessException { private CommandMap getCommandMap() {
// if (main.getServer().getPluginManager() instanceof SimplePluginManager) {
// // if (Main.allAliases != null && !Main.allAliases.isEmpty()) { SimplePluginManager manager = (SimplePluginManager) main.getServer().getPluginManager();
// // if (!(Main.getPlugin().getBukkitCommandWrap() instanceof BukkitCommandWrap_Useless)) { try {
// // for (String alias : Main.allAliases) { Field field = SimplePluginManager.class.getDeclaredField("commandMap");
// // T2Csend.debugmsg(Main.getPlugin(),"uload: " + alias); field.setAccessible(true);
// // Main.getPlugin(). return (CommandMap) field.get(manager);
// // Main.getPlugin().getBukkitCommandWrap().unwrap(alias); } catch (Exception e) {
// // } e.printStackTrace();
// // Main.getPlugin().getBukkitCommandWrap().sync(); }
// // if (Bukkit.getOnlinePlayers().size() >= 1) }
// // for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands(); return null;
// // }
// // }
// // 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);
} }
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.alias.Spigot.objects.SubAliasObject;
import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister; import net.t2code.t2codelib.SPIGOT.api.register.T2Cregister;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.permissions.PermissionDefault;
public class AliasRegisterPermissions { public class AliasRegisterPermissions {
@@ -12,23 +13,41 @@ public class AliasRegisterPermissions {
for (AliasObject aliasObject : Main.aliasHashMap.values()) { for (AliasObject aliasObject : Main.aliasHashMap.values()) {
for (String alias : aliasObject.aliasList){ for (String alias : aliasObject.aliasList) {
if (Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("<alias>",alias).toLowerCase()) == null) { if (aliasObject.permission != null && Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("[alias]", alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.permission.replace("<alias>",alias).toLowerCase(), Main.getPlugin()); T2Cregister.permission(aliasObject.permission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
} }
if (Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("<alias>",alias).toLowerCase()) == null) { if (aliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("[alias]", alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.adminPermission.replace("<alias>",alias).toLowerCase(), Main.getPlugin()); 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 (SubAliasObject subAliasObject : Main.subAliasHashMap.values()) {
for (String alias : subAliasObject.subAliasList){ for (String alias : subAliasObject.subAliasList) {
if (Bukkit.getPluginManager().getPermission(subAliasObject.permission.replace("<alias>",alias).toLowerCase()) == null) { if (subAliasObject.permission != null && Bukkit.getPluginManager().getPermission(subAliasObject.permission.replace("[alias]", alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.permission.replace("<alias>",alias).toLowerCase(), Main.getPlugin()); T2Cregister.permission(subAliasObject.permission.replace("[alias]", alias).toLowerCase(), Main.getPlugin());
} }
if (Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("<alias>",alias).toLowerCase()) == null) { if (subAliasObject.adminPermission != null && Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("[alias]", alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.adminPermission.replace("<alias>",alias).toLowerCase(), Main.getPlugin()); 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; package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.Main;
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -12,31 +13,7 @@ import java.io.IOException;
public class BCommandSenderReciver { public class BCommandSenderReciver {
public static void sendToBungee(CommandSender sender, String information, Boolean console) { public static void sendToBungee(CommandSender sender, String information, Boolean console) {
ByteArrayOutputStream stream = new ByteArrayOutputStream(); T2CbungeeCommandSenderReciver.sendToBungee(sender,information,console);
DataOutputStream output = new DataOutputStream(stream);
try {
if (console) {
output.writeUTF("T2Code-Console");
} else {
if (sender instanceof Player) {
output.writeUTF(sender.getName());
} else {
output.writeUTF("T2Code-Console");
}
}
output.writeUTF(information);
} catch (IOException e) {
e.printStackTrace();
}
if (sender instanceof Player) {
Player player = (Player) sender;
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
}else {
for(Player player : Bukkit.getOnlinePlayers()){
player.sendPluginMessage(Main.getPlugin(), "t2c:bcmd", stream.toByteArray());
return;
}
}
} }
} }

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

View File

@@ -22,6 +22,6 @@ public class PluginEvents implements Listener {
@EventHandler @EventHandler
public void onJoinEvent(PlayerLoginEvent event) { 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; package net.t2code.alias;
import lombok.Getter;
public class Util { public class Util {
@@ -8,7 +10,7 @@ public class Util {
} }
public static String getRequiredT2CodeLibVersion() { public static String getRequiredT2CodeLibVersion() {
return "15.7"; return "16.7";
} }
public static String getPrefix() { public static String getPrefix() {
@@ -41,7 +43,22 @@ public class Util {
private static String prefix = "§8[§4T2Code§7-§aAlias§8]"; 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: AliasList:
- aliasexample1 - aliasexample1
- aliasexample2 - aliasexample2
-
Permission: Permission:
# Here you can say if a permission is needed to use the alias# # Here you can say if a permission is needed to use the alias#
Necessary: true Necessary: true
# Here you can set the permission for the alias. # Here you can set the permission for the alias.
# The placeholder <alias> is the alias name. # The placeholder <[alias] is the alias name.
# If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias. # If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias.
Permission: 't2code.alias.use.<alias>' Permission: 't2c.alias.use.[alias]'
# Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank. # Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank.
CustomNoPermissionMSG: "" CustomNoPermissionMSG: ""
CooldownInSec:
# Here you can set a global cooldown for this alias.
# The value corresponds to the seconds.
# At 0, the cooldown is deactivated.
# The placeholder [alias] is the alias name.
# Bypass permission: t2c.alias.cooldown.global.[alias].bypass
# (The global cooldown is above the player cooldown).
Global: 0
# Here you can set a player-specific cooldown for this alias.
# The value corresponds to the seconds.
# At 0, the cooldown is deactivated.
# The placeholder [alias] is the alias name.
# Bypass permission: t2c.alias.cooldown.player.[alias].bypass
Player: 0
Cost: Cost:
# Here you can say if you have to pay for the alias # Here you can say if you have to pay for the alias
Enable: false Enable: false
# Here you set the price # Here you set the price
Price: 0.0 Price: 0.0
# Here you define if the bypass is activated or if you have to pay despite the bypass (t2code.alias.buy.bypass). # Here you define if the bypass is activated or if you have to pay despite the bypass (t2c.alias.buy.[alias].bypass).
AllowByPass: true AllowByPass: true
# Here you can set if you have to confirm if you want to pay before executing the command # 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. # 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 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
@@ -41,7 +59,8 @@ Alias:
BungeeCommand: false BungeeCommand: false
# Here you can specify one or more commands to be executed. # Here you can specify one or more commands to be executed.
# Placeholder: [player] = The player who executes the alias # Placeholder: [player] = The player who executes the alias
Commands: [ ] Commands: []
Message: Message:
# Here you can specify whether the player should receive a message. # Here you can specify whether the player should receive a message.
Enable: false Enable: false
@@ -67,7 +86,7 @@ Alias:
# You can also use MiniMessage: # You can also use MiniMessage:
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html # Wiki: https://docs.adventure.kyori.net/minimessage/format.html
# WebUI: https://webui.adventure.kyori.net # WebUI: https://webui.adventure.kyori.net
Messages: [ ] Messages: []
# Here you can specify that players with the permission () have a different function than other players. # Here you can specify that players with the permission () have a different function than other players.
# For example, you can say that players should come to a certain point and players with the admin function only to the server to the position where they were before. # For example, you can say that players should come to a certain point and players with the admin function only to the server to the position where they were before.
@@ -78,9 +97,9 @@ Alias:
# Here you can enable or disable the admin function # Here you can enable or disable the admin function
Enable: false Enable: false
# Here you set the permission for the admin function # 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. # 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: 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
@@ -92,7 +111,8 @@ Alias:
BungeeCommand: false BungeeCommand: false
# Here you can specify one or more commands to be executed. # Here you can specify one or more commands to be executed.
# Placeholder: [player] = The player who executes the alias # Placeholder: [player] = The player who executes the alias
Commands: [ ] Commands: []
Message: Message:
# Here you can specify whether the player should receive a message. # Here you can specify whether the player should receive a message.
Enable: false Enable: false
@@ -118,7 +138,7 @@ Alias:
# You can also use MiniMessage: # You can also use MiniMessage:
# Wiki: https://docs.adventure.kyori.net/minimessage/format.html # Wiki: https://docs.adventure.kyori.net/minimessage/format.html
# WebUI: https://webui.adventure.kyori.net # WebUI: https://webui.adventure.kyori.net
Messages: [ ] Messages: []
Console: Console:
# Here you can define if the alias is also usable in the console and what it should do from there. # Here you can define if the alias is also usable in the console and what it should do from there.
@@ -130,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

@@ -19,21 +19,38 @@ SubAlias:
# Here you can say if a permission is needed to use the alias# # Here you can say if a permission is needed to use the alias#
Necessary: true Necessary: true
# Here you can set the permission for the alias. # Here you can set the permission for the alias.
# The placeholder <alias> is the alias name. # The placeholder [alias] is the subalias name.
# If you have set multiple alias referrers in the list 'Alias.SubAliasList' you have a permission for each alias. # If you have set multiple alias referrers in the list 'Alias.SubAliasList' you have a permission for each alias.
Permission: 't2code.alias.use.subalias.<alias>' Permission: 't2c.subalias.use.[alias]'
# Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank. # Here you can set a custom No Permission message for this alias. If you want to use the default message, just leave this blank.
CustomNoPermissionMSG: "" CustomNoPermissionMSG: ""
CooldownInSec:
# Here you can set a global cooldown for this alias.
# The value corresponds to the seconds.
# At 0, the cooldown is deactivated.
# The placeholder [alias] is the subalias name.
# Bypass permission: t2c.alias.sub.cooldown.global.[alias].bypass
# (The global cooldown is above the player cooldown).
Global: 0
# Here you can set a player-specific cooldown for this alias.
# The value corresponds to the seconds.
# At 0, the cooldown is deactivated.
# The placeholder [alias] is the subalias name.
# Bypass permission: t2c.alias.sub.cooldown.player.[alias].bypass
Player: 0
Cost: Cost:
# Here you can say if you have to pay for the alias # Here you can say if you have to pay for the alias
Enable: false Enable: false
# Here you set the price # Here you set the price
Price: 0.0 Price: 0.0
# Here you define if the bypass is activated or if you have to pay despite the bypass (t2code.alias.buy.bypass). # Here you define if the bypass is activated or if you have to pay despite the bypass (t2c.alias.buy.[alias].bypass).
AllowByPass: true AllowByPass: true
# Here you can set if you have to confirm if you want to pay before executing the command # 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. # 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 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
@@ -46,6 +63,7 @@ SubAlias:
# Here you can specify one or more commands to be executed. # Here you can specify one or more commands to be executed.
# Placeholder: [player] = The player who executes the alias # Placeholder: [player] = The player who executes the alias
Commands: [] Commands: []
Message: Message:
# Here you can specify whether the player should receive a message. # Here you can specify whether the player should receive a message.
Enable: false Enable: false
@@ -82,9 +100,9 @@ SubAlias:
# Here you can enable or disable the admin function # Here you can enable or disable the admin function
Enable: false Enable: false
# Here you set the permission for the admin function # 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. # 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: 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
@@ -97,6 +115,7 @@ SubAlias:
# Here you can specify one or more commands to be executed. # Here you can specify one or more commands to be executed.
# Placeholder: [player] = The player who executes the alias # Placeholder: [player] = The player who executes the alias
Commands: [] Commands: []
Message: Message:
# Here you can specify whether the player should receive a message. # Here you can specify whether the player should receive a message.
Enable: false Enable: false

View File

@@ -10,7 +10,7 @@ plugin:
# In this option you can set the language of the plugin. # In this option you can set the language of the plugin.
language: english language: english
updateCheck: 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 onJoin: true
# In this option you can set whether you want to receive and display beta and snapshot versions in the update check. # In this option you can set whether you want to receive and display beta and snapshot versions in the update check.
seePreReleaseUpdates: true seePreReleaseUpdates: true

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