mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Merge branch 'master' of github.com:mcMMO-Dev/mcMMO
This commit is contained in:
commit
0cd8d2b333
@ -12,35 +12,6 @@ import com.gmail.nossr50.util.Permissions;
|
|||||||
public final class CommandHelper {
|
public final class CommandHelper {
|
||||||
private CommandHelper() {}
|
private CommandHelper() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks for command permissions.
|
|
||||||
*
|
|
||||||
* @param sender The command sender
|
|
||||||
* @param permission The permission to check
|
|
||||||
* @return true if the sender is a player without permissions, false otherwise
|
|
||||||
*/
|
|
||||||
public static boolean noCommandPermissions(CommandSender sender, String permission) {
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (!Permissions.hasPermission(player, permission)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean noCommandPermissions(Player player, String permission) {
|
|
||||||
if (!Permissions.hasPermission(player, permission)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean noConsoleUsage(CommandSender sender) {
|
public static boolean noConsoleUsage(CommandSender sender) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
|
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
|
||||||
|
@ -8,7 +8,6 @@ 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 com.gmail.nossr50.commands.CommandHelper;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
import com.gmail.nossr50.database.Leaderboard;
|
import com.gmail.nossr50.database.Leaderboard;
|
||||||
@ -23,18 +22,18 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
display(1, "ALL", sender, useMySQL);
|
display(1, "ALL", sender, useMySQL, command);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if (Misc.isInt(args[0])) {
|
if (Misc.isInt(args[0])) {
|
||||||
display(Integer.valueOf(args[0]), "ALL", sender, useMySQL);
|
display(Integer.valueOf(args[0]), "ALL", sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else if (SkillTools.isSkill(args[0])) {
|
else if (SkillTools.isSkill(args[0])) {
|
||||||
display(1, args[0], sender, useMySQL);
|
display(1, args[0], sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||||
display(1, SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL);
|
display(1, SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -48,10 +47,10 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SkillTools.isSkill(args[0])) {
|
if (SkillTools.isSkill(args[0])) {
|
||||||
display(Integer.valueOf(args[1]), args[0], sender, useMySQL);
|
display(Integer.valueOf(args[1]), args[0], sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else if (SkillTools.isLocalizedSkill(args[0])) {
|
else if (SkillTools.isLocalizedSkill(args[0])) {
|
||||||
display(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL);
|
display(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL, command);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
@ -64,22 +63,23 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void display(int page, String skill, CommandSender sender, boolean sql) {
|
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
|
||||||
if (sql) {
|
if (sql) {
|
||||||
if (skill.equalsIgnoreCase("all")) {
|
if (skill.equalsIgnoreCase("all")) {
|
||||||
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender);
|
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sqlDisplay(page, skill, sender);
|
sqlDisplay(page, skill, sender, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
flatfileDisplay(page, skill, sender);
|
flatfileDisplay(page, skill, sender, command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void flatfileDisplay(int page, String skill, CommandSender sender) {
|
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
|
||||||
if (!skill.equalsIgnoreCase("all") && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mctop." + skill.toLowerCase())) {
|
if (!skill.equalsIgnoreCase("all") && !sender.hasPermission("mcmmo.commands.mctop." + skill.toLowerCase())) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,9 +114,10 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
private void sqlDisplay(int page, String query, CommandSender sender, Command command) {
|
||||||
if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mctop." + query.toLowerCase())) {
|
if (!sender.hasPermission("mcmmo.commands.mctop." + query.toLowerCase())) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,9 +579,9 @@ public final class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void printErrors(SQLException ex) {
|
private static void printErrors(SQLException ex) {
|
||||||
System.out.println("SQLException: " + ex.getMessage());
|
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
|
||||||
System.out.println("SQLState: " + ex.getSQLState());
|
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
|
||||||
System.out.println("VendorError: " + ex.getErrorCode());
|
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void profileCleanup(String playerName) {
|
public static void profileCleanup(String playerName) {
|
||||||
|
@ -279,7 +279,7 @@ public final class Leaderboard {
|
|||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("User found, removing...");
|
mcMMO.p.getLogger().info("User found, removing...");
|
||||||
worked = true;
|
worked = true;
|
||||||
continue; //Skip the player
|
continue; //Skip the player
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ public final class Leaderboard {
|
|||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
System.out.println("User found, removing...");
|
mcMMO.p.getLogger().info("User found, removing...");
|
||||||
removedPlayers++;
|
removedPlayers++;
|
||||||
continue; //Skip the player
|
continue; //Skip the player
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ public class SQLConversionTask implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
|
mcMMO.p.getLogger().info("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.listeners;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +24,7 @@ public class SelfListener implements Listener {
|
|||||||
throw new Exception("Gained negative XP!");
|
throw new Exception("Gained negative XP!");
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
System.out.println(e.getMessage());
|
mcMMO.p.getLogger().severe(e.getMessage());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -507,7 +507,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
metrics.start();
|
metrics.start();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
System.out.println("Failed to submit stats.");
|
mcMMO.p.getLogger().warning("Failed to submit stats.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.utilities;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
@ -124,7 +125,7 @@ public enum SkillType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("[DEBUG] Invalid mcMMO skill (" + skillName + ")");
|
mcMMO.p.getLogger().warning("[DEBUG] Invalid mcMMO skill (" + skillName + ")");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public class SpoutTools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (menuKey == null) {
|
if (menuKey == null) {
|
||||||
System.out.println("Invalid KEY for Menu.Key, using KEY_M");
|
mcMMO.p.getLogger().warning("Invalid KEY for Menu.Key, using KEY_M");
|
||||||
menuKey = Keyboard.KEY_M;
|
menuKey = Keyboard.KEY_M;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public final class Anniversary {
|
|||||||
try {
|
try {
|
||||||
anniversaryFile.createNewFile();
|
anniversaryFile.createNewFile();
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
System.out.println(ex);
|
mcMMO.p.getLogger().severe(ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hasCelebrated = new ArrayList<String>();
|
hasCelebrated = new ArrayList<String>();
|
||||||
@ -55,7 +55,7 @@ public final class Anniversary {
|
|||||||
|
|
||||||
reader.close();
|
reader.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println(ex);
|
mcMMO.p.getLogger().severe(ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public final class Anniversary {
|
|||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
System.out.println(ex);
|
mcMMO.p.getLogger().severe(ex.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ public class ZipLibrary {
|
|||||||
|
|
||||||
public static void mcMMObackup() throws IOException {
|
public static void mcMMObackup() throws IOException {
|
||||||
if (Config.getInstance().getUseMySQL()) {
|
if (Config.getInstance().getUseMySQL()) {
|
||||||
System.out.println("No Backup performed, in SQL Mode.");
|
mcMMO.p.getLogger().info("No Backup performed, in SQL Mode.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ public class ZipLibrary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Actually do something
|
//Actually do something
|
||||||
System.out.println("Backing up your mcMMO Configuration... ");
|
mcMMO.p.getLogger().info("Backing up your mcMMO Configuration... ");
|
||||||
|
|
||||||
packZip(fileZip, sources);
|
packZip(fileZip, sources);
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ public class ZipLibrary {
|
|||||||
|
|
||||||
zipOut.flush();
|
zipOut.flush();
|
||||||
zipOut.close();
|
zipOut.close();
|
||||||
System.out.println("Backup Completed.");
|
mcMMO.p.getLogger().info("Backup Completed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String buildPath(String path, String file) {
|
private static String buildPath(String path, String file) {
|
||||||
@ -95,7 +95,7 @@ public class ZipLibrary {
|
|||||||
|
|
||||||
private static void zipDir(ZipOutputStream zos, String path, File dir) throws IOException {
|
private static void zipDir(ZipOutputStream zos, String path, File dir) throws IOException {
|
||||||
if (!dir.canRead()) {
|
if (!dir.canRead()) {
|
||||||
System.out.println("Cannot read " + dir.getCanonicalPath() + " (Maybe because of permissions?)");
|
mcMMO.p.getLogger().severe("Cannot read " + dir.getCanonicalPath() + " (Maybe because of permissions?)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public class ZipLibrary {
|
|||||||
|
|
||||||
private static void zipFile(ZipOutputStream zos, String path, File file) throws IOException {
|
private static void zipFile(ZipOutputStream zos, String path, File file) throws IOException {
|
||||||
if (!file.canRead()) {
|
if (!file.canRead()) {
|
||||||
System.out.println("Cannot read " + file.getCanonicalPath() + "(File Permissions?)");
|
mcMMO.p.getLogger().severe("Cannot read " + file.getCanonicalPath() + "(File Permissions?)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user