mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +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.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
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.selection.SelectionManager;
|
||||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||||
import com.gamingmesh.jobs.stuff.Loging;
|
import com.gamingmesh.jobs.stuff.Loging;
|
||||||
|
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||||
import com.gamingmesh.jobs.stuff.TabComplete;
|
import com.gamingmesh.jobs.stuff.TabComplete;
|
||||||
import com.gamingmesh.jobs.stuff.VersionChecker;
|
import com.gamingmesh.jobs.stuff.VersionChecker;
|
||||||
import com.gamingmesh.jobs.stuff.CMIScoreboardManager;
|
import com.gamingmesh.jobs.stuff.CMIScoreboardManager;
|
||||||
@ -1231,4 +1233,27 @@ public class Jobs extends JavaPlugin {
|
|||||||
public static SelectionManager getSelectionManager() {
|
public static SelectionManager getSelectionManager() {
|
||||||
return smanager;
|
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.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
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.JobInfo;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
|
import com.gamingmesh.jobs.stuff.RawMessage;
|
||||||
|
|
||||||
public class JobsCommands implements CommandExecutor {
|
public class JobsCommands implements CommandExecutor {
|
||||||
private static final String label = "jobs";
|
private static final String label = "jobs";
|
||||||
@ -85,10 +87,18 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasCommandPermission(sender, cmd)) {
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] myArgs = reduceArgs(args);
|
String[] myArgs = reduceArgs(args);
|
||||||
if (myArgs.length > 0) {
|
if (myArgs.length > 0) {
|
||||||
if (myArgs[myArgs.length - 1].equals("?")) {
|
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.Cmd;
|
||||||
import com.gamingmesh.jobs.commands.JobCommand;
|
import com.gamingmesh.jobs.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
|
||||||
|
|
||||||
public class archive implements Cmd {
|
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) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
JobsPlayer jPlayer = null;
|
JobsPlayer jPlayer = null;
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
if (!sender.hasPermission("jobs.command.admin.archive")) {
|
if (!Jobs.hasPermission(sender, "jobs.command.admin.archive", true)) {
|
||||||
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||||
|
@ -35,8 +35,7 @@ public class log implements Cmd {
|
|||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
JPlayer = Jobs.getPlayerManager().getJobsPlayer((Player) sender);
|
||||||
else if (args.length == 1) {
|
else if (args.length == 1) {
|
||||||
if (!sender.hasPermission("jobs.commands.log.others")) {
|
if (!Jobs.hasPermission(sender, "jobs.commands.log.others", true)) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("general.error.permission"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
JPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
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.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.container.PlayerPoints;
|
import com.gamingmesh.jobs.container.PlayerPoints;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
|
||||||
|
|
||||||
public class points implements Cmd {
|
public class points implements Cmd {
|
||||||
|
|
||||||
@ -23,8 +22,7 @@ public class points implements Cmd {
|
|||||||
|
|
||||||
JobsPlayer jPlayer = null;
|
JobsPlayer jPlayer = null;
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
if (!sender.hasPermission("jobs.command.admin.points")) {
|
if (!Jobs.hasPermission(sender, "jobs.command.admin.points", true)) {
|
||||||
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
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.commands.JobCommand;
|
||||||
import com.gamingmesh.jobs.container.JobProgression;
|
import com.gamingmesh.jobs.container.JobProgression;
|
||||||
import com.gamingmesh.jobs.container.JobsPlayer;
|
import com.gamingmesh.jobs.container.JobsPlayer;
|
||||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
|
||||||
|
|
||||||
public class stats implements Cmd {
|
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) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
JobsPlayer jPlayer = null;
|
JobsPlayer jPlayer = null;
|
||||||
if (args.length >= 1) {
|
if (args.length >= 1) {
|
||||||
if (!sender.hasPermission("jobs.command.admin.stats")) {
|
if (!Jobs.hasPermission(sender, "jobs.command.admin.stats", true)) {
|
||||||
sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("general.error.permission"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
jPlayer = Jobs.getPlayerManager().getJobsPlayer(args[0]);
|
||||||
|
Loading…
Reference in New Issue
Block a user