Skip to content

Commit

Permalink
Added permissions for commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiterio authored and Taiterio committed Jul 25, 2015
1 parent f9ece93 commit c7ed446
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
11 changes: 4 additions & 7 deletions src/main/java/think/rpgitems/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
*/
package think.rpgitems;

import java.util.List;
import java.util.logging.Logger;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;

import think.rpgitems.commands.Commands;
import think.rpgitems.config.ConfigUpdater;
import think.rpgitems.data.Font;
Expand All @@ -31,10 +32,6 @@
import think.rpgitems.power.*;
import think.rpgitems.support.WorldGuard;

import java.io.*;
import java.util.List;
import java.util.logging.Logger;

@SuppressWarnings("deprecation")
public class Plugin extends JavaPlugin {

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/think/rpgitems/commands/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void exec(CommandSender sender, String com) {
for (CommandDef c : command) {
if (c.arguments.length == 0) {
try {
if (c.handlePermissions || sender.hasPermission("rpgitem"))
if (c.handlePermissions || sender.hasPermission("rpgitem") || sender.hasPermission("rpgitem.command") || sender.hasPermission("rpgitem.command." + comName))
c.method.invoke(c.handler, sender);
else
sender.sendMessage(ChatColor.RED + Locale.get("message.error.permission"));
Expand All @@ -93,7 +93,7 @@ public static void exec(CommandSender sender, String com) {
}
}
// Print usage
if (sender.hasPermission("rpgitem")) {
if (sender.hasPermission("rpgitem") || sender.hasPermission("rpgitem.command") || sender.hasPermission("rpgitem.command." + comName)) {
sender.sendMessage(String.format(ChatColor.GREEN + Locale.get("message.command.usage"), comName, Plugin.plugin.getDescription().getVersion()));
for (CommandDef c : command) {
StringBuilder buf = new StringBuilder();
Expand Down Expand Up @@ -182,7 +182,7 @@ public static void exec(CommandSender sender, String com) {
}
}
try {
if (c.handlePermissions || sender.hasPermission("rpgitem"))
if (c.handlePermissions || sender.hasPermission("rpgitem") || sender.hasPermission("rpgitem.command") || sender.hasPermission("rpgitem.command." + comName))
c.method.invoke(c.handler, outArgs.toArray());
else
sender.sendMessage(ChatColor.RED + Locale.get("message.error.permission"));
Expand All @@ -198,7 +198,7 @@ public static void exec(CommandSender sender, String com) {
}
return;
}
if (sender.hasPermission("rpgitem")) {
if (sender.hasPermission("rpgitem") || sender.hasPermission("rpgitem.command") || sender.hasPermission("rpgitem.command." + comName)) {
if (lastError != null) {
sender.sendMessage(ChatColor.RED + String.format(Locale.get("message.error.command"), lastError.error));
} else {
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/think/rpgitems/data/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
*/
package think.rpgitems.data;

import java.io.*;
import java.util.Enumeration;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import com.google.common.base.Charsets;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import think.rpgitems.Plugin;

public class Locale {
Expand Down

0 comments on commit c7ed446

Please sign in to comment.