Skip to content

Commit

Permalink
Add Ban Restrictions 2
Browse files Browse the repository at this point in the history
- Add missing config set commands.
- Update deoponban options.
- Update the help command.
  • Loading branch information
aappleton8 committed May 14, 2019
1 parent 874693e commit eecf11b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 19 deletions.
Binary file modified Jar/OpPermissions_v1.0.3.1_1.7.6-1.14.0.jar
Binary file not shown.
1 change: 1 addition & 0 deletions OpPermissions/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ permissions:
oppermissions.config.set.bannableops: true
oppermissions.config.set.bannablepermanentops: true
oppermissions.config.set.deoponban: true
oppermissions.config.set.showbanattempts: true
oppermissions.config.set.opscanop:
description: Set the value of the opscanop field of the config file
default: false
Expand Down
4 changes: 4 additions & 0 deletions OpPermissions/src/me/OpPermissions/MyPlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ else if (bannablePermanentOps.equalsIgnoreCase("permission")) {
ops.remove(playerNameToBan);
plugin.getConfig().set("ops", ops);
plugin.saveConfig();
Bukkit.getOfflinePlayer(playerNameToBan).setOp(false);
Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.BLUE + plugin.formattedPluginName + playerNameToBan + " was deopped due to being banned ");
Bukkit.broadcast(ChatColor.BLUE + plugin.formattedPluginName + playerNameToBan + " was deopped due to being banned ", "oppermissions.ban.show");
Bukkit.broadcast(ChatColor.BLUE + plugin.formattedPluginName + playerNameToBan + " was deopped due to being banned ", "oppermissions.seepluginmessages");
}
}
}
Expand Down
61 changes: 42 additions & 19 deletions OpPermissions/src/me/OpPermissions/OpPermissionsCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private void helpCommand(CommandSender s, Boolean showAll, int page) {
s.sendMessage(ChatColor.DARK_PURPLE + "/opset help [1|2|3] " + ChatColor.AQUA + "- Show help messages ");
if (s.hasPermission("oppermissions.showallhelp") || showAll) {
s.sendMessage(ChatColor.DARK_PURPLE + "/opset help all [1|2|3] " + ChatColor.AQUA + "- Show help for all " + plugin.getName() + " commands ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset help config " + ChatColor.AQUA + "- Show help for config fields " + plugin.getName() + " commands ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset help config [1|2]" + ChatColor.AQUA + "- Show help for config fields " + plugin.getName() + " commands ");
}
else if (s.hasPermission("oppermissions.config.seedetailedsethelp") || showAll) {
s.sendMessage(ChatColor.DARK_PURPLE + "/opset help config " + ChatColor.AQUA + "- Show help for config fields " + plugin.getName() + " commands ");
Expand Down Expand Up @@ -121,21 +121,30 @@ else if (page == 2) {
}

private void helpConfigFields(CommandSender s) {
s.sendMessage(ChatColor.DARK_AQUA + "The commands for setting the config fields of the " + ChatColor.AQUA + plugin.getName() + ChatColor.DARK_AQUA + " plugin are: ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set opscanop default|op|permission|no|false " + ChatColor.AQUA + "- Set the opscanop field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set opscandeop default|op|permission|no|false " + ChatColor.AQUA + "- Set the opscandeop field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set allowrequests op|permission|both|all|no|false " + ChatColor.AQUA + "- Set the allowrequests field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set useuuids true|false " + ChatColor.AQUA + "- Set the useuuids field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set updateonplayerjoins true|false " + ChatColor.AQUA + "- Set the updateonplayerjoins field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set onlyautoupdateonline true|false " + ChatColor.AQUA + "- Set the onlyautoupdateonline field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set announceops all|permanent|normal|no|false " + ChatColor.AQUA + "- Set the announceops field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set permanentopsusecommands true|false " + ChatColor.AQUA + "- Set the permanentopsusecommands field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set showopattempts true|false " + ChatColor.AQUA + "- Set the showopattempts field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set showcommanduse true|false " + ChatColor.AQUA + "- Set the showcommanduse field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set bannableops op|permanent|permission|default|no|false " + ChatColor.AQUA + "- Set the bannableops field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set bannablepermanentops op|permanent|permission|default|no|false " + ChatColor.AQUA + "- Set the bannablepermanentops field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set deoponban true|false " + ChatColor.AQUA + "- Set the deoponban field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set showbanattempts true|false " + ChatColor.AQUA + "- Set the showbanattempts field ");
helpConfigFields(s, 1);
}

private void helpConfigFields(CommandSender s, int page) {
if (page == 1) {
s.sendMessage(ChatColor.DARK_AQUA + "The commands for setting the config fields of the " + ChatColor.AQUA + plugin.getName() + ChatColor.DARK_AQUA + " plugin are: ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set opscanop default|op|permission|no|false " + ChatColor.AQUA + "- Set the opscanop field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set opscandeop default|op|permission|no|false " + ChatColor.AQUA + "- Set the opscandeop field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set allowrequests op|permission|both|all|no|false " + ChatColor.AQUA + "- Set the allowrequests field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set useuuids true|false " + ChatColor.AQUA + "- Set the useuuids field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set updateonplayerjoins true|false " + ChatColor.AQUA + "- Set the updateonplayerjoins field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set onlyautoupdateonline true|false " + ChatColor.AQUA + "- Set the onlyautoupdateonline field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set announceops all|permanent|normal|no|false " + ChatColor.AQUA + "- Set the announceops field ");
}
else {
s.sendMessage(ChatColor.DARK_AQUA + "The commands for setting the config fields of the " + ChatColor.AQUA + plugin.getName() + ChatColor.DARK_AQUA + " plugin are: ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set permanentopsusecommands true|false " + ChatColor.AQUA + "- Set the permanentopsusecommands field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set showopattempts true|false " + ChatColor.AQUA + "- Set the showopattempts field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set showcommanduse true|false " + ChatColor.AQUA + "- Set the showcommanduse field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set bannableops op|permanent|permission|default|no|false " + ChatColor.AQUA + "- Set the bannableops field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set bannablepermanentops op|permanent|permission|default|no|false " + ChatColor.AQUA + "- Set the bannablepermanentops field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set deoponban true|false " + ChatColor.AQUA + "- Set the deoponban field ");
s.sendMessage(ChatColor.DARK_PURPLE + "/opset config set showbanattempts true|false " + ChatColor.AQUA + "- Set the showbanattempts field ");
}
}

private void configUpdateMessage() {
Expand Down Expand Up @@ -242,7 +251,7 @@ else if (args[3].equalsIgnoreCase("false")) {
plugin.noPermission(s);
}
}
else if (args[2].equalsIgnoreCase("updateonplayerjoins") || args[2].equalsIgnoreCase("onlyautoupdateonline") || args[2].equalsIgnoreCase("permanentopsusecommands") || args[2].equalsIgnoreCase("showopattempts") || args[2].equalsIgnoreCase("showcommanduse") || args[2].equalsIgnoreCase("deoponban")) {
else if (args[2].equalsIgnoreCase("updateonplayerjoins") || args[2].equalsIgnoreCase("onlyautoupdateonline") || args[2].equalsIgnoreCase("permanentopsusecommands") || args[2].equalsIgnoreCase("showopattempts") || args[2].equalsIgnoreCase("showcommanduse") || args[2].equalsIgnoreCase("deoponban") || args[2].equalsIgnoreCase("showbanattempts")) {
if (s.hasPermission("oppermissions.config.set." + args[2].toLowerCase()) || (s instanceof ConsoleCommandSender)) {
if (args[3].equalsIgnoreCase("true")) {
plugin.getConfig().set(args[2], true);
Expand Down Expand Up @@ -310,7 +319,21 @@ else if (args[2].equalsIgnoreCase("3")) {
helpCommand(s, true, 3);
}
else {
s.sendMessage(ChatColor.RED + "There are only two pages of help commands (1 and 2) ");
s.sendMessage(ChatColor.RED + "There are only three pages of help commands (1, 2 and 3) ");
return false;
}
}
}
else if (args[0].equalsIgnoreCase("help") && args[1].equalsIgnoreCase("config")) {
if ((s instanceof ConsoleCommandSender) || (s.hasPermission("oppermissions.config.seedetailedsethelp")) || (s.hasPermission("oppermissions.showallhelp"))) {
if (args[2].equalsIgnoreCase("1")) {
helpConfigFields(s);
}
else if (args[2].equalsIgnoreCase("2")) {
helpConfigFields(s, 2);
}
else {
s.sendMessage(ChatColor.RED + "There are only two pages of config help commands (1 and 2) ");
return false;
}
}
Expand Down Expand Up @@ -463,7 +486,7 @@ else if (args[0].equalsIgnoreCase("help")) {
}
else if (args[1].equalsIgnoreCase("config")) {
if ((s instanceof ConsoleCommandSender) || (s.hasPermission("oppermissions.config.seedetailedsethelp")) || (s.hasPermission("oppermissions.showallhelp"))) {
helpConfigFields(s);
helpConfigFields(s, 1);
}
else {
plugin.noPermission(s);
Expand Down

0 comments on commit eecf11b

Please sign in to comment.