6 Commits

Author SHA1 Message Date
9aede116ac 1.4
Bugfix:
Fixed a bug where the plugin was not loading properly
2023-07-31 18:35:45 +02:00
97fc283951 1.3 hotfix 2023-07-16 11:43:13 +02:00
7e6c889583 1.3
T2CodeLib 15.7 is required
2023-07-16 08:27:20 +02:00
a1ffd48f3e The admin permission now also supports the placeholder <alias>.
The admin permission now also supports the placeholder <alias>.
2023-07-16 08:19:03 +02:00
0c1d32e0e8 Update AliasRegisterPermissions.java
Bugfix: The permissions of the alias commands were not registered
2023-07-16 08:10:18 +02:00
987370586a 1.3_beta-2
A bug was fixed, if you use confirm via the gui and let another gui open via the alias, then this direnk was closed again.
2023-07-09 17:46:16 +02:00
10 changed files with 47 additions and 19 deletions

View File

@@ -7,7 +7,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>Alias</artifactId> <artifactId>Alias</artifactId>
<version>1.3_beta-1</version> <version>1.4</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>T2C-Alias</name> <name>T2C-Alias</name>
@@ -71,8 +71,8 @@
<dependency> <dependency>
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>T2CodeLib</artifactId> <artifactId>T2CodeLib</artifactId>
<version>15.6</version> <version>15.7</version>
<classifier>dev-3</classifier> <!--classifier>dev-3</classifier-->
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -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)) { 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);
} }
@@ -127,7 +127,7 @@ public class ExecuteAlias {
Player player = (Player) sender; Player player = (Player) sender;
if (aliasObject.adminEnable) { if (aliasObject.adminEnable) {
if (player.hasPermission(aliasObject.adminPermission)) { if (player.hasPermission(aliasObject.adminPermission.replace("<alias>", alias.toLowerCase()))){
if (aliasObject.adminCommandEnable) { if (aliasObject.adminCommandEnable) {
subAliasAdminCommand(aliasObject, alias, player, args); subAliasAdminCommand(aliasObject, alias, player, args);
} }

View File

@@ -17,8 +17,9 @@ import java.util.logging.Level;
public class Convert { public class Convert {
protected static void convert() { protected static void convert() {
File config = new File(Main.getPath(),""); File path = new File(Main.getPath(),"");
if (config.exists()) convertTo4(); File file = new File(Main.getPath(), "config.yml");
if (path.exists() && file.exists()) convertTo4();
} }
private static void convertTo4() { private static void convertTo4() {
@@ -26,7 +27,7 @@ public class Convert {
File config = new File(Main.getPath(), "config.yml"); File config = new File(Main.getPath(), "config.yml");
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config); YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(config);
if (yamlConfiguration.get(Config.configVersion.path) == null || ((Integer) Config.configVersion.value) < Util.getConfigVersion() && new File(Main.getPath(), "config.yml").exists()) { if (yamlConfiguration.get(Config.configVersion.path) == null || ((Integer) Config.configVersion.value) < Util.getConfigVersion()) {
yamlConfiguration.set("ConfigVersion", null); yamlConfiguration.set("ConfigVersion", null);
try { try {
yamlConfiguration.save(config); yamlConfiguration.save(config);
@@ -36,6 +37,9 @@ public class Convert {
File dir = new File(Main.getPath() + "/languages"); File dir = new File(Main.getPath() + "/languages");
File newDir = new File(Main.getPath() + "/OldConfig/Version3/languages"); File newDir = new File(Main.getPath() + "/OldConfig/Version3/languages");
if (!dir.exists()){
return;
}
try { try {
FileUtils.moveDirectory(dir, newDir); FileUtils.moveDirectory(dir, newDir);
} catch (IOException e) { } catch (IOException e) {

View File

@@ -20,16 +20,16 @@ public class GuiListener implements Listener {
if (e.getClickedInventory() != e.getWhoClicked().getOpenInventory().getTopInventory()) return; if (e.getClickedInventory() != e.getWhoClicked().getOpenInventory().getTopInventory()) return;
switch (e.getSlot()) { switch (e.getSlot()) {
case 12: case 12:
Cache.openPlayers.remove(player.getUniqueId());
player.closeInventory();
ExecuteAlias.storage(player, true); ExecuteAlias.storage(player, true);
break; break;
case 14: case 14:
ExecuteAlias.storage(player, false);
break;
default:
return;
}
Cache.openPlayers.remove(player.getUniqueId()); Cache.openPlayers.remove(player.getUniqueId());
player.closeInventory(); player.closeInventory();
ExecuteAlias.storage(player, false);
break;
}
} }
@EventHandler @EventHandler

View File

@@ -1,15 +1,35 @@
package net.t2code.alias.Spigot.system; package net.t2code.alias.Spigot.system;
import net.t2code.alias.Spigot.Main; import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.objects.AliasObject;
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;
public class AliasRegisterPermissions { public class AliasRegisterPermissions {
public static void onPermRegister() { public static void onPermRegister() {
for (String alias : Main.allAliases){
if (Bukkit.getPluginManager().getPermission("t2code.alias.use." + alias.toLowerCase()) == null) { for (AliasObject aliasObject : Main.aliasHashMap.values()) {
T2Cregister.permission("t2code.alias.use." + alias.toLowerCase(), Main.getPlugin());
for (String alias : aliasObject.aliasList){
if (Bukkit.getPluginManager().getPermission(aliasObject.permission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.permission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission(aliasObject.adminPermission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(aliasObject.adminPermission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
}
}
}
for (SubAliasObject subAliasObject : Main.subAliasHashMap.values()) {
for (String alias : subAliasObject.subAliasList){
if (Bukkit.getPluginManager().getPermission(subAliasObject.permission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.permission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
}
if (Bukkit.getPluginManager().getPermission(subAliasObject.adminPermission.replace("<alias>",alias).toLowerCase()) == null) {
T2Cregister.permission(subAliasObject.adminPermission.replace("<alias>",alias).toLowerCase(), Main.getPlugin());
}
} }
} }
} }

View File

@@ -44,10 +44,11 @@ public class Load {
public static void loadReload() { public static void loadReload() {
HandlerList.unregisterAll(chatListener); HandlerList.unregisterAll(chatListener);
HandlerList.unregisterAll(guiListener); HandlerList.unregisterAll(guiListener);
boolean newInstall = !new File(Main.getPath(), "config.yml").exists();
FileSelect.config(); FileSelect.config();
T2Ctemplate.onLoadSeparateStroke(Util.getPrefix()); T2Ctemplate.onLoadSeparateStroke(Util.getPrefix());
FileSelect.language(); FileSelect.language();
if (!new File(Main.getPath(), "config.yml").exists()) { if (newInstall) {
try { try {
CreateExampleAliasConfig.configCreate(); CreateExampleAliasConfig.configCreate();
} catch (Exception e) { } catch (Exception e) {

View File

@@ -2,7 +2,6 @@
package net.t2code.alias.Spigot.system; package net.t2code.alias.Spigot.system;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@@ -8,7 +8,7 @@ public class Util {
} }
public static String getRequiredT2CodeLibVersion() { public static String getRequiredT2CodeLibVersion() {
return "15.6"; return "15.7";
} }
public static String getPrefix() { public static String getPrefix() {

View File

@@ -78,6 +78,8 @@ 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.
# If you have set multiple alias referrers in the list 'Alias.AliasList' you have a permission for each alias.
Permission: t2code.alias.admin Permission: t2code.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

View File

@@ -20,7 +20,7 @@ SubAlias:
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.SubAliasList' you have a permission for each alias.
Permission: 't2code.alias.use.subalias.<alias>' Permission: 't2code.alias.use.subalias.<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: ""
@@ -82,6 +82,8 @@ 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.
# If you have set multiple alias referrers in the list 'Alias.SubAliasList' you have a permission for each alias.
Permission: t2code.alias.admin Permission: t2code.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