Merge pull request #178 from TheLonelyWolf1/master

Fix bug with the delay-Tag | Add Custom No-Permission Messages | Input-Limit
This commit is contained in:
RockyHawk 2021-11-24 10:27:30 +11:00 committed by GitHub
commit d27becbc10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 6 deletions

View File

@ -29,9 +29,11 @@ config:
error: '&cError found in config.'
offline: 'Offline'
offlineHeadValue: 'eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmU1Mjg2YzQ3MGY2NmZmYTFhMTgzMzFjYmZmYjlhM2MyYTQ0MjRhOGM3MjU5YzQ0MzZmZDJlMzU1ODJhNTIyIn19fQ=='
input: '&cYour Input is too long!'
input:
input-cancel: cancel
input-cancelled: '&cCancelled!'
max-input-length: -1
input-message:
- '%cp-tag%&aEnter Input for Command'
- '&cType &4%cp-args% &cto Cancel the command'

View File

@ -36,16 +36,26 @@ public class ExecuteOpenVoids {
panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile()));
}
if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
return;
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return;
}
}
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !openForOtherUser) {
//check for disabled worlds
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
return;
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return;
}
}
if(position != PanelPosition.Top && !plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Cannot open a panel without a panel at the top already."));
@ -101,7 +111,13 @@ public class ExecuteOpenVoids {
p.closeInventory();
}
}else{
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
return;
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return;
}
}
}

View File

@ -105,7 +105,7 @@ public class SpecialTags implements Listener {
e.commandTagUsed();
//if player uses op= it will perform command as op
final int delayTicks = Integer.parseInt(e.args[0]);
String finalCommand = String.join(" ",e.args).replace(e.args[0],"").trim();
String finalCommand = String.join(" ",e.args).replaceFirst(e.args[0],"").trim();
new BukkitRunnable() {
@Override
public void run() {

View File

@ -33,6 +33,14 @@ public class UserInputUtils implements Listener {
}
playerInput.get(e.getPlayer()).panel.placeholders.addPlaceholder("player-input",e.getMessage());
if((playerInput.get(e.getPlayer()).panel.getConfig().getString("max-input-length") != null) && (Integer.parseInt(playerInput.get(e.getPlayer()).panel.getConfig().getString("max-input-length")) != -1) && (e.getMessage().length() > Integer.parseInt(playerInput.get(e.getPlayer()).panel.getConfig().getString("max-input-length")))) {
e.getPlayer().sendMessage(plugin.tex.colour(plugin.tag + playerInput.get(e.getPlayer()).panel.getConfig().getString("custom-messages.input")));
return;
}else if(e.getMessage().length() > Integer.parseInt(plugin.config.getString("input.max-input-length")) && (Integer.parseInt(plugin.config.getString("input.max-input-length")) != -1)) {
e.getPlayer().sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.input")));
return;
}
//get certain words from the input
int c = 0;
for(String message : e.getMessage().split("\\s")){