Skip to content

Commit

Permalink
update 1.6 (this.config is null startup error)
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiar committed Apr 30, 2022
1 parent 289be8d commit 96eb242
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>it.chiarchiaooo</groupId>
<artifactId>CommandBlocker</artifactId>
<version>1.5</version>
<version>1.6</version>
<packaging>jar</packaging>

<name>CommandBlocker</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,29 @@

public class TabCompleteEvent implements Listener {

private FileConfiguration config;
//variables declaration
private final FileConfiguration config;
private final Map<String, String> commandBypasses;

public TabCompleteEvent(Main pl) {
this.config = pl.getConfig();
this.commandBypasses = new HashMap<>();
}

//config and class variables declaration
boolean BlockEnable = config.getBoolean("enabled");
List<String> cmds = config.getStringList("allowed-cmds");
List<String> staffcmds = config.getStringList("single-allowed-cmds");
Map<String, String> commandBypasses = new HashMap<>();
final String genbypass = "cmdblock.bypass.*";

@EventHandler(ignoreCancelled = true)
public void onCommandSend(final PlayerCommandSendEvent event) { //commands suggestions check on player join (rejoin after plugin reload to apply changes)
// Make sure command blocker is enabled from config
if (BlockEnable) {
if (event.getPlayer().hasPermission(genbypass)) {return;} //check for global bypass permission: orientalcmds.cmd.bypass.*
if (config.getBoolean("enabled")) {
if (event.getPlayer().hasPermission("cmdblock.bypass.*")) {return;} //check for global bypass permission: orientalcmds.cmd.bypass.*

event.getCommands().clear(); // Remove every command suggestion

for (String staffalcmds : staffcmds) { //creating hashmap for permission blocked commands
for (String staffalcmds : config.getStringList("single-allowed-cmds")) { //creating hashmap for permission blocked commands
commandBypasses.put(staffalcmds, "cmdblock.bypass." + staffalcmds.substring(1)); //layout: command (with /) , orientalcmds.command.bypass.<command> (without /)
}

for (String str: cmds) { //loop between normal allowed commands (commands that everybody can execute and see)
for (String str: config.getStringList("allowed-cmds")) { //loop between normal allowed commands (commands that everybody can execute and see)
event.getCommands().add(str.substring(1)); // Remove blocked commands from the suggestions list.
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public class TabCompleteHandler implements TabCompleter {

private HashMap<String, CommandHandler.CommandInterface> commands;
private final HashMap<String, CommandHandler.CommandInterface> commands;

public TabCompleteHandler(Main pl) {
this.commands = pl.commands;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: CommandBlocker
version: '${project.version}'
version: 1.6
main: it.chiarchiaooo.commandblocker.Main
api-version: 1.18
authors: [ Chiarchiaooo ]
description: CommandBlocker 1.17x
description: CommandBlocker 1.18x

commands:
cmdblock:
Expand Down

0 comments on commit 96eb242

Please sign in to comment.