mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-29 14:05:25 +01:00
Show missing permission by hovering over message
This commit is contained in:
parent
b64f117d4b
commit
d1c24bed10
@ -33,6 +33,7 @@ import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -89,6 +90,7 @@ import com.gamingmesh.jobs.listeners.PistonProtectionListener;
|
||||
import com.gamingmesh.jobs.selection.SelectionManager;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.Loging;
|
||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||
import com.gamingmesh.jobs.stuff.VersionChecker;
|
||||
import com.gamingmesh.jobs.stuff.CMIScoreboardManager;
|
||||
@ -1231,4 +1233,27 @@ public class Jobs extends JavaPlugin {
|
||||
public static SelectionManager getSelectionManager() {
|
||||
return smanager;
|
||||
}
|
||||
|
||||
public static boolean hasPermission(Object sender, String perm, boolean inform) {
|
||||
if (sender instanceof Player) {
|
||||
if (((Player) sender).hasPermission(perm))
|
||||
return true;
|
||||
if (!inform)
|
||||
return false;
|
||||
RawMessage rm = new RawMessage();
|
||||
rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + perm);
|
||||
rm.show((Player) sender);
|
||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
Jobs.sendMessage(console, Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void sendMessage(Object sender, String msg) {
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||
} else
|
||||
((CommandSender) sender).sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gamingmesh.jobs.Jobs;
|
||||
@ -34,6 +35,7 @@ import com.gamingmesh.jobs.container.Job;
|
||||
import com.gamingmesh.jobs.container.JobInfo;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||
|
||||
public class JobsCommands implements CommandExecutor {
|
||||
private static final String label = "jobs";
|
||||
@ -86,9 +88,17 @@ public class JobsCommands implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (!hasCommandPermission(sender, cmd)) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
if (sender instanceof Player) {
|
||||
RawMessage rm = new RawMessage();
|
||||
rm.add(Jobs.getLanguage().getMessage("general.error.permission"), "&2" + label + ".command." + cmd);
|
||||
rm.show(sender);
|
||||
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||
Jobs.sendMessage(console, Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
} else
|
||||
Jobs.sendMessage(sender, Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
return true;
|
||||
}
|
||||
|
||||
String[] myArgs = reduceArgs(args);
|
||||
if (myArgs.length > 0) {
|
||||
if (myArgs[myArgs.length - 1].equals("?")) {
|
||||
|
@ -9,7 +9,6 @@ import com.gamingmesh.jobs.Jobs;
|
||||
import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
|
||||
public class archive implements Cmd {
|
||||
|
||||
@ -18,8 +17,7 @@ public class archive implements Cmd {
|
||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||
JobsPlayer jPlayer = null;
|
||||
if (args.length >= 1) {
|
||||
if (!sender.hasPermission("jobs.command.admin.archive")) {
|
||||
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
if (!Jobs.hasPermission(sender, "jobs.command.admin.archive", true)) {
|
||||
return true;
|
||||
}
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||
|
@ -35,8 +35,7 @@ public class log implements Cmd {
|
||||
if (args.length == 0)
|
||||
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||
else if (args.length == 1) {
|
||||
if (!sender.hasPermission("jobs.commands.log.others")) {
|
||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
if (!Jobs.hasPermission(sender, "jobs.commands.log.others", true)) {
|
||||
return true;
|
||||
}
|
||||
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||
|
@ -8,7 +8,6 @@ import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.container.PlayerPoints;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
|
||||
public class points implements Cmd {
|
||||
|
||||
@ -23,8 +22,7 @@ public class points implements Cmd {
|
||||
|
||||
JobsPlayer jPlayer = null;
|
||||
if (args.length >= 1) {
|
||||
if (!sender.hasPermission("jobs.command.admin.points")) {
|
||||
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
if (!Jobs.hasPermission(sender, "jobs.command.admin.points", true)) {
|
||||
return true;
|
||||
}
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||
|
@ -8,7 +8,6 @@ import com.gamingmesh.jobs.commands.Cmd;
|
||||
import com.gamingmesh.jobs.commands.JobCommand;
|
||||
import com.gamingmesh.jobs.container.JobProgression;
|
||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
|
||||
public class stats implements Cmd {
|
||||
|
||||
@ -17,8 +16,7 @@ public class stats implements Cmd {
|
||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||
JobsPlayer jPlayer = null;
|
||||
if (args.length >= 1) {
|
||||
if (!sender.hasPermission("jobs.command.admin.stats")) {
|
||||
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission"));
|
||||
if (!Jobs.hasPermission(sender, "jobs.command.admin.stats", true)) {
|
||||
return true;
|
||||
}
|
||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user