Changing the style of our code

This commit is contained in:
nossr50 2019-02-09 22:46:30 -08:00
parent e749d5eb7f
commit bbcc1ee7da
318 changed files with 5494 additions and 5357 deletions

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.data.database.FlatfileDatabaseManager; import com.gmail.nossr50.core.data.database.FlatfileDatabaseManager;
import com.gmail.nossr50.core.data.database.SQLDatabaseManager; import com.gmail.nossr50.core.data.database.SQLDatabaseManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.data.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.skills.ModConfigType; import com.gmail.nossr50.core.skills.ModConfigType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.util.Misc; import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -71,17 +71,14 @@ public class McImportCommand implements CommandExecutor {
materialNames.get(type).add(materialName); materialNames.get(type).add(materialName);
continue; continue;
} }
} } catch (FileNotFoundException e) {
catch (FileNotFoundException e) {
mcMMO.p.getLogger().warning("Could not find " + importFile.getAbsolutePath() + " ! (No such file or directory)"); mcMMO.p.getLogger().warning("Could not find " + importFile.getAbsolutePath() + " ! (No such file or directory)");
mcMMO.p.getLogger().warning("Copy and paste latest.log to " + importFile.getParentFile().getAbsolutePath() + " and rename it to import.log"); mcMMO.p.getLogger().warning("Copy and paste latest.log to " + importFile.getParentFile().getAbsolutePath() + " and rename it to import.log");
return false; return false;
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} } finally {
finally {
tryClose(in); tryClose(in);
} }
@ -116,8 +113,7 @@ public class McImportCommand implements CommandExecutor {
} }
try { try {
c.close(); c.close();
} } catch (IOException e) {
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -169,16 +165,13 @@ public class McImportCommand implements CommandExecutor {
out = new FileWriter(outputFile); out = new FileWriter(outputFile);
out.write(writer.toString()); out.write(writer.toString());
} } catch (IOException e) {
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return; return;
} } catch (Exception e) {
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return; return;
} } finally {
finally {
tryClose(out); tryClose(out);
fileAmount++; fileAmount++;
} }
@ -208,14 +201,11 @@ public class McImportCommand implements CommandExecutor {
String skillName = "UNIDENTIFIED"; String skillName = "UNIDENTIFIED";
if (materialName.contains("ORE")) { if (materialName.contains("ORE")) {
skillName = "Mining"; skillName = "Mining";
} } else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
else if (materialName.contains("LOG") || materialName.contains("LEAVES")) {
skillName = "Woodcutting"; skillName = "Woodcutting";
} } else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
else if (materialName.contains("GRASS") || materialName.contains("FLOWER") || materialName.contains("CROP")) {
skillName = "Herbalism"; skillName = "Herbalism";
} } else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
else if (materialName.contains("DIRT") || materialName.contains("SAND")) {
skillName = "Excavation"; skillName = "Excavation";
} }
@ -230,8 +220,7 @@ public class McImportCommand implements CommandExecutor {
if (skillName.equals("Mining")) { if (skillName.equals("Mining")) {
skillContents.add(" " + " " + "Smelting_XP_Gain: 9"); skillContents.add(" " + " " + "Smelting_XP_Gain: 9");
} } else if (skillName.equals("Woodcutting")) {
else if (skillName.equals("Woodcutting")) {
skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG")); skillContents.add(" " + " " + "Is_Log: " + materialName.contains("LOG"));
} }
} }
@ -247,20 +236,15 @@ public class McImportCommand implements CommandExecutor {
String toolType = "UNIDENTIFIED"; String toolType = "UNIDENTIFIED";
if (materialName.contains("PICKAXE")) { if (materialName.contains("PICKAXE")) {
toolType = "Pickaxes"; toolType = "Pickaxes";
} } else if (materialName.contains("AXE")) {
else if (materialName.contains("AXE")) {
toolType = "Axes"; toolType = "Axes";
} } else if (materialName.contains("BOW")) {
else if (materialName.contains("BOW")) {
toolType = "Bows"; toolType = "Bows";
} } else if (materialName.contains("HOE")) {
else if (materialName.contains("HOE")) {
toolType = "Hoes"; toolType = "Hoes";
} } else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
else if (materialName.contains("SHOVEL") || materialName.contains("SPADE")) {
toolType = "Shovels"; toolType = "Shovels";
} } else if (materialName.contains("SWORD")) {
else if (materialName.contains("SWORD")) {
toolType = "Swords"; toolType = "Swords";
} }
@ -287,14 +271,11 @@ public class McImportCommand implements CommandExecutor {
String toolType = "UNIDENTIFIED"; String toolType = "UNIDENTIFIED";
if (materialName.contains("BOOT") || materialName.contains("SHOE")) { if (materialName.contains("BOOT") || materialName.contains("SHOE")) {
toolType = "Boots"; toolType = "Boots";
} } else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
else if (materialName.contains("CHESTPLATE") || materialName.contains("CHEST")) {
toolType = "Chestplates"; toolType = "Chestplates";
} } else if (materialName.contains("HELM") || materialName.contains("HAT")) {
else if (materialName.contains("HELM") || materialName.contains("HAT")) {
toolType = "Helmets"; toolType = "Helmets";
} } else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
else if (materialName.contains("LEGGINGS") || materialName.contains("LEGS") || materialName.contains("PANTS")) {
toolType = "Leggings"; toolType = "Leggings";
} }

View File

@ -22,9 +22,6 @@ public class McconvertCommand implements TabExecutor {
private static final List<String> DATABASE_TYPES; private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience"); private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
static { static {
ArrayList<String> formulaTypes = new ArrayList<String>(); ArrayList<String> formulaTypes = new ArrayList<String>();
ArrayList<String> databaseTypes = new ArrayList<String>(); ArrayList<String> databaseTypes = new ArrayList<String>();
@ -52,14 +49,16 @@ public class McconvertCommand implements TabExecutor {
} }
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) { switch (args.length) {
case 2: case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) { if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
return databaseConvertCommand.onCommand(sender, command, label, args); return databaseConvertCommand.onCommand(sender, command, label, args);
} } else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
else if (args[0].equalsIgnoreCase("experience") || args[0].equalsIgnoreCase("xp") || args[1].equalsIgnoreCase("exp")) {
return experienceConvertCommand.onCommand(sender, command, label, args); return experienceConvertCommand.onCommand(sender, command, label, args);
} }

View File

@ -3,8 +3,8 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.party.PartySubcommandType; import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -71,7 +71,7 @@ public class McmmoCommand implements CommandExecutor {
private void displayOtherCommands(CommandSender sender) { private void displayOtherCommands(CommandSender sender) {
//Don't show them this category if they have none of the permissions //Don't show them this category if they have none of the permissions
if(!Permissions.skillreset(sender) && !Permissions.mmoedit(sender) && !Permissions.adminChat(sender) && !Permissions.mcgod(sender)) if (!Permissions.skillreset(sender) && !Permissions.mmoedit(sender) && !Permissions.adminChat(sender) && !Permissions.mcgod(sender))
return; return;
sender.sendMessage(LocaleLoader.getString("Commands.Other")); sender.sendMessage(LocaleLoader.getString("Commands.Other"));

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.data.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -71,7 +71,10 @@ public abstract class ToggleCommand implements TabExecutor {
} }
protected abstract boolean hasOtherPermission(CommandSender sender); protected abstract boolean hasOtherPermission(CommandSender sender);
protected abstract boolean hasSelfPermission(CommandSender sender); protected abstract boolean hasSelfPermission(CommandSender sender);
protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer); protected abstract void applyCommandAction(McMMOPlayer mcMMOPlayer);
protected abstract void sendSuccessMessage(CommandSender sender, String playerName); protected abstract void sendSuccessMessage(CommandSender sender, String playerName);
} }

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands; package com.gmail.nossr50.commands;
import com.gmail.nossr50.core.config.skills.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.skills.AdvancedConfig;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils; import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.player.NotificationManager; import com.gmail.nossr50.core.util.player.NotificationManager;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -36,12 +36,11 @@ public class XprateCommand implements TabExecutor {
if (mcMMO.p.isXPEventEnabled()) { if (mcMMO.p.isXPEventEnabled()) {
if(AdvancedConfig.getInstance().useTitlesForXPEvent()) if (AdvancedConfig.getInstance().useTitlesForXPEvent()) {
{
NotificationManager.broadcastTitle(mcMMO.p.getServer(), NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Stop"), LocaleLoader.getString("Commands.Event.Stop"),
LocaleLoader.getString("Commands.Event.Stop.Subtitle"), LocaleLoader.getString("Commands.Event.Stop.Subtitle"),
10, 10*20, 20); 10, 10 * 20, 20);
} }
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
@ -65,36 +64,31 @@ public class XprateCommand implements TabExecutor {
if (CommandUtils.shouldDisableToggle(args[1])) { if (CommandUtils.shouldDisableToggle(args[1])) {
mcMMO.p.setXPEventEnabled(false); mcMMO.p.setXPEventEnabled(false);
} } else if (CommandUtils.shouldEnableToggle(args[1])) {
else if (CommandUtils.shouldEnableToggle(args[1])) {
mcMMO.p.setXPEventEnabled(true); mcMMO.p.setXPEventEnabled(true);
} } else {
else {
return false; return false;
} }
int newXpRate = Integer.parseInt(args[0]); int newXpRate = Integer.parseInt(args[0]);
if(newXpRate < 0) if (newXpRate < 0) {
{ sender.sendMessage(ChatColor.RED + LocaleLoader.getString("Commands.NegativeNumberWarn"));
sender.sendMessage(ChatColor.RED+LocaleLoader.getString("Commands.NegativeNumberWarn"));
return true; return true;
} }
ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate); ExperienceConfig.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if (mcMMO.p.isXPEventEnabled()) { if (mcMMO.p.isXPEventEnabled()) {
if(AdvancedConfig.getInstance().useTitlesForXPEvent()) if (AdvancedConfig.getInstance().useTitlesForXPEvent()) {
{
NotificationManager.broadcastTitle(mcMMO.p.getServer(), NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Start"), LocaleLoader.getString("Commands.Event.Start"),
LocaleLoader.getString("Commands.Event.XP", newXpRate), LocaleLoader.getString("Commands.Event.XP", newXpRate),
10, 10*20, 20); 10, 10 * 20, 20);
} }
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate)); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate)); sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));
} }

View File

@ -3,13 +3,13 @@ package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.core.chat.ChatManager; import com.gmail.nossr50.core.chat.ChatManager;
import com.gmail.nossr50.core.chat.ChatManagerFactory; import com.gmail.nossr50.core.chat.ChatManagerFactory;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.chat.ChatMode; import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.party.PartyFeature; import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -21,8 +21,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public abstract class ChatCommand implements TabExecutor { public abstract class ChatCommand implements TabExecutor {
private ChatMode chatMode;
protected ChatManager chatManager; protected ChatManager chatManager;
private ChatMode chatMode;
public ChatCommand(ChatMode chatMode) { public ChatCommand(ChatMode chatMode) {
this.chatMode = chatMode; this.chatMode = chatMode;
@ -47,8 +47,7 @@ public abstract class ChatCommand implements TabExecutor {
if (mcMMOPlayer.isChatEnabled(chatMode)) { if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender); disableChatMode(mcMMOPlayer, sender);
} } else {
else {
enableChatMode(mcMMOPlayer, sender); enableChatMode(mcMMOPlayer, sender);
} }

View File

@ -2,12 +2,12 @@ package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.core.chat.PartyChatManager; import com.gmail.nossr50.core.chat.PartyChatManager;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.chat.ChatMode; import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature; import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -35,8 +35,7 @@ public class PartyChatCommand extends ChatCommand {
} }
message = buildChatMessage(args, 0); message = buildChatMessage(args, 0);
} } else {
else {
if (args.length < 2) { if (args.length < 2) {
sender.sendMessage(LocaleLoader.getString("Party.Specify")); sender.sendMessage(LocaleLoader.getString("Party.Specify"));
return; return;

View File

@ -1,14 +1,14 @@
package com.gmail.nossr50.commands.database; package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.data.database.DatabaseManager; import com.gmail.nossr50.core.data.database.DatabaseManager;
import com.gmail.nossr50.core.data.database.DatabaseManagerFactory; import com.gmail.nossr50.core.data.database.DatabaseManagerFactory;
import com.gmail.nossr50.core.datatypes.database.DatabaseType; import com.gmail.nossr50.core.datatypes.database.DatabaseType;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.runnables.database.DatabaseConversionTask; import com.gmail.nossr50.core.runnables.database.DatabaseConversionTask;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.mcMMO;
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;
@ -41,8 +41,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
} }
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz); oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
} } catch (Throwable e) {
catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1])); sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true; return true;

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.database; package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -26,8 +26,7 @@ public class McremoveCommand implements TabExecutor {
if (mcMMO.getDatabaseManager().removeUser(playerName)) { if (mcMMO.getDatabaseManager().removeUser(playerName)) {
sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.mcremove.Success", playerName));
} } else {
else {
sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen. sender.sendMessage(playerName + " could not be removed from the database."); // Pretty sure this should NEVER happen.
} }

View File

@ -2,8 +2,8 @@ package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason; import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.EventUtils; import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason; import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.experience.XPGainSource; import com.gmail.nossr50.core.datatypes.experience.XPGainSource;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.data.UserManager;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -25,8 +25,7 @@ public class AddxpCommand extends ExperienceCommand {
protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) { protected void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (player != null) { if (player != null) {
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND); UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
} } else {
else {
profile.addXp(skill, value); profile.addXp(skill, value);
profile.scheduleAsyncSave(); profile.scheduleAsyncSave();
} }

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.FormulaType; import com.gmail.nossr50.core.datatypes.experience.FormulaType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.runnables.database.FormulaConversionTask; import com.gmail.nossr50.core.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.mcMMO;
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;

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -20,6 +20,14 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
public abstract class ExperienceCommand implements TabExecutor { public abstract class ExperienceCommand implements TabExecutor {
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill; PrimarySkillType skill;
@ -45,8 +53,7 @@ public abstract class ExperienceCommand implements TabExecutor {
skill = null; skill = null;
} }
if (skill != null && skill.isChildSkill()) if (skill != null && skill.isChildSkill()) {
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill")); sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true; return true;
} }
@ -70,8 +77,7 @@ public abstract class ExperienceCommand implements TabExecutor {
skill = null; skill = null;
} }
if (skill != null && skill.isChildSkill()) if (skill != null && skill.isChildSkill()) {
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill")); sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true; return true;
} }
@ -95,8 +101,7 @@ public abstract class ExperienceCommand implements TabExecutor {
} }
editValues(null, profile, skill, value); editValues(null, profile, skill, value);
} } else {
else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill, value);
} }
@ -122,24 +127,19 @@ public abstract class ExperienceCommand implements TabExecutor {
} }
protected abstract boolean permissionsCheckSelf(CommandSender sender); protected abstract boolean permissionsCheckSelf(CommandSender sender);
protected abstract boolean permissionsCheckOthers(CommandSender sender); protected abstract boolean permissionsCheckOthers(CommandSender sender);
protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value); protected abstract void handleCommand(Player player, PlayerProfile profile, PrimarySkillType skill, int value);
protected abstract void handlePlayerMessageAll(Player player, int value); protected abstract void handlePlayerMessageAll(Player player, int value);
protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill); protected abstract void handlePlayerMessageSkill(Player player, int value, PrimarySkillType skill);
private boolean validateArguments(CommandSender sender, String skillName, String value) { private boolean validateArguments(CommandSender sender, String skillName, String value) {
return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName))); return !(CommandUtils.isInvalidInteger(sender, value) || (!skillName.equalsIgnoreCase("all") && CommandUtils.isInvalidSkill(sender, skillName)));
} }
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) { protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill, int value) {
if (skill == null) { if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
@ -149,8 +149,7 @@ public abstract class ExperienceCommand implements TabExecutor {
if (player != null) { if (player != null) {
handlePlayerMessageAll(player, value); handlePlayerMessageAll(player, value);
} }
} } else {
else {
handleCommand(player, profile, skill, value); handleCommand(player, profile, skill, value);
if (player != null) { if (player != null) {

View File

@ -2,8 +2,8 @@ package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason; import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.EventUtils; import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,15 +1,15 @@
package com.gmail.nossr50.commands.experience; package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason; import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.EventUtils; import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -27,6 +27,14 @@ import java.util.UUID;
* value/quantity argument is removed. * value/quantity argument is removed.
*/ */
public class SkillresetCommand implements TabExecutor { public class SkillresetCommand implements TabExecutor {
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PrimarySkillType skill; PrimarySkillType skill;
@ -47,8 +55,7 @@ public class SkillresetCommand implements TabExecutor {
if (args[0].equalsIgnoreCase("all")) { if (args[0].equalsIgnoreCase("all")) {
skill = null; skill = null;
} } else {
else {
skill = PrimarySkillType.getSkill(args[1]); skill = PrimarySkillType.getSkill(args[1]);
} }
@ -67,8 +74,7 @@ public class SkillresetCommand implements TabExecutor {
if (args[1].equalsIgnoreCase("all")) { if (args[1].equalsIgnoreCase("all")) {
skill = null; skill = null;
} } else {
else {
skill = PrimarySkillType.getSkill(args[1]); skill = PrimarySkillType.getSkill(args[1]);
} }
@ -89,8 +95,7 @@ public class SkillresetCommand implements TabExecutor {
} }
editValues(null, profile, skill); editValues(null, profile, skill);
} } else {
else {
editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill); editValues(mcMMOPlayer.getPlayer(), mcMMOPlayer.getProfile(), skill);
} }
@ -149,15 +154,6 @@ public class SkillresetCommand implements TabExecutor {
return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName); return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName);
} }
protected static void handleSenderMessage(CommandSender sender, String playerName, PrimarySkillType skill) {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}
protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) { protected void editValues(Player player, PlayerProfile profile, PrimarySkillType skill) {
if (skill == null) { if (skill == null) {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
@ -167,8 +163,7 @@ public class SkillresetCommand implements TabExecutor {
if (player != null) { if (player != null) {
handlePlayerMessageAll(player); handlePlayerMessageAll(player);
} }
} } else {
else {
handleCommand(player, profile, skill); handleCommand(player, profile, skill);
if (player != null) { if (player != null) {

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.hardcore; package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class HardcoreCommand extends HardcoreModeCommand { public class HardcoreCommand extends HardcoreModeCommand {
@ -54,8 +54,7 @@ public class HardcoreCommand extends HardcoreModeCommand {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreStatLossEnabled(enable); primarySkillType.setHardcoreStatLossEnabled(enable);
} }
} } else {
else {
skill.setHardcoreStatLossEnabled(enable); skill.setHardcoreStatLossEnabled(enable);
} }

View File

@ -28,8 +28,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
if (checkEnabled(null)) { if (checkEnabled(null)) {
disable(null); disable(null);
} } else {
else {
enable(null); enable(null);
} }
@ -122,9 +121,14 @@ public abstract class HardcoreModeCommand implements TabExecutor {
} }
protected abstract boolean checkTogglePermissions(CommandSender sender); protected abstract boolean checkTogglePermissions(CommandSender sender);
protected abstract boolean checkModifyPermissions(CommandSender sender); protected abstract boolean checkModifyPermissions(CommandSender sender);
protected abstract boolean checkEnabled(PrimarySkillType skill); protected abstract boolean checkEnabled(PrimarySkillType skill);
protected abstract void enable(PrimarySkillType skill); protected abstract void enable(PrimarySkillType skill);
protected abstract void disable(PrimarySkillType skill); protected abstract void disable(PrimarySkillType skill);
protected abstract void modify(CommandSender sender, double newPercentage); protected abstract void modify(CommandSender sender, double newPercentage);
} }

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.hardcore; package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.mcMMO;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
public class VampirismCommand extends HardcoreModeCommand { public class VampirismCommand extends HardcoreModeCommand {
@ -54,8 +54,7 @@ public class VampirismCommand extends HardcoreModeCommand {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) { for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreVampirismEnabled(enable); primarySkillType.setHardcoreVampirismEnabled(enable);
} }
} } else {
else {
skill.setHardcoreVampirismEnabled(enable); skill.setHardcoreVampirismEnabled(enable);
} }

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager;
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;

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.mcMMO;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.data.UserManager;
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;

View File

@ -3,12 +3,12 @@ package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.commands.chat.PartyChatCommand; import com.gmail.nossr50.commands.chat.PartyChatCommand;
import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand; import com.gmail.nossr50.commands.party.alliance.PartyAllianceCommand;
import com.gmail.nossr50.commands.party.teleport.PtpCommand; import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager;
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;

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
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;

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature; import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.ShareMode; import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -65,8 +65,7 @@ public class PartyInfoCommand implements CommandExecutor {
if (isUnlockedFeature(party, partyFeature)) { if (isUnlockedFeature(party, partyFeature)) {
unlockedPartyFeatures.add(partyFeature.getLocaleString()); unlockedPartyFeatures.add(partyFeature.getLocaleString());
} } else {
else {
lockedPartyFeatures.add(partyFeature.getFeatureLockedLocaleString()); lockedPartyFeatures.add(partyFeature.getFeatureLockedLocaleString());
} }
} }
@ -123,7 +122,7 @@ public class PartyInfoCommand implements CommandExecutor {
int membersOnline = party.getVisibleMembers(player).size(); int membersOnline = party.getVisibleMembers(player).size();
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size()+1, membersOnline)); player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", nearMembers.size() + 1, membersOnline));
player.sendMessage(party.createMembersList(player)); player.sendMessage(party.createMembersList(player));
} }
} }

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
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;
@ -46,8 +46,7 @@ public class PartyInviteCommand implements CommandExecutor {
Party playerParty = mcMMOPlayer.getParty(); Party playerParty = mcMMOPlayer.getParty();
if(PartyManager.isPartyFull(target, playerParty)) if (PartyManager.isPartyFull(target, playerParty)) {
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize())); player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize()));
return true; return true;
} }

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.ItemShareType; import com.gmail.nossr50.core.datatypes.party.ItemShareType;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature; import com.gmail.nossr50.core.datatypes.party.PartyFeature;
@ -8,7 +9,6 @@ import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.StringUtils; import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
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;
@ -41,19 +41,16 @@ public class PartyItemShareCommand implements CommandExecutor {
if (CommandUtils.shouldEnableToggle(args[2])) { if (CommandUtils.shouldEnableToggle(args[2])) {
toggle = true; toggle = true;
} } else if (CommandUtils.shouldDisableToggle(args[2])) {
else if (CommandUtils.shouldDisableToggle(args[2])) {
toggle = false; toggle = false;
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true; return true;
} }
try { try {
handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle); handleToggleItemShareCategory(party, ItemShareType.valueOf(args[1].toUpperCase()), toggle);
} } catch (IllegalArgumentException ex) {
catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
} }

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
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;
@ -54,8 +54,7 @@ public class PartyJoinCommand implements CommandExecutor {
return true; return true;
} }
if(PartyManager.isPartyFull(player, targetParty)) if (PartyManager.isPartyFull(player, targetParty)) {
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString())); player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull", targetParty.toString()));
return true; return true;
} }

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
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;
@ -17,8 +17,7 @@ public class PartyLockCommand implements CommandExecutor {
case 1: case 1:
if (args[0].equalsIgnoreCase("lock")) { if (args[0].equalsIgnoreCase("lock")) {
togglePartyLock(sender, true); togglePartyLock(sender, true);
} } else if (args[0].equalsIgnoreCase("unlock")) {
else if (args[0].equalsIgnoreCase("unlock")) {
togglePartyLock(sender, false); togglePartyLock(sender, false);
} }
@ -32,11 +31,9 @@ public class PartyLockCommand implements CommandExecutor {
if (CommandUtils.shouldEnableToggle(args[1])) { if (CommandUtils.shouldEnableToggle(args[1])) {
togglePartyLock(sender, true); togglePartyLock(sender, true);
} } else if (CommandUtils.shouldDisableToggle(args[1])) {
else if (CommandUtils.shouldDisableToggle(args[1])) {
togglePartyLock(sender, false); togglePartyLock(sender, false);
} } else {
else {
sendUsageStrings(sender); sendUsageStrings(sender);
} }

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
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;

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
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;

View File

@ -30,20 +30,15 @@ public enum PartySubcommandType {
if (commandName.equalsIgnoreCase("?")) { if (commandName.equalsIgnoreCase("?")) {
return HELP; return HELP;
} } else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
return QUIT; return QUIT;
} } else if (commandName.equalsIgnoreCase("leader")) {
else if (commandName.equalsIgnoreCase("leader")) {
return OWNER; return OWNER;
} } else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
return XPSHARE; return XPSHARE;
} } else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
return ITEMSHARE; return ITEMSHARE;
} } else if (commandName.equalsIgnoreCase("ally")) {
else if (commandName.equalsIgnoreCase("ally")) {
return ALLIANCE; return ALLIANCE;
} }

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.party; package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature; import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.ShareMode; import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.StringUtils; import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
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;
@ -27,11 +27,9 @@ public class PartyXpShareCommand implements CommandExecutor {
case 2: case 2:
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) { if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
handleChangingShareMode(party, ShareMode.NONE); handleChangingShareMode(party, ShareMode.NONE);
} } else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || CommandUtils.shouldEnableToggle(args[1])) {
handleChangingShareMode(party, ShareMode.EQUAL); handleChangingShareMode(party, ShareMode.EQUAL);
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>")); sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
} }

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party.alliance; package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager;
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;

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.party.alliance; package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature; import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -21,12 +21,10 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PartyAllianceCommand implements TabExecutor { public class PartyAllianceCommand implements TabExecutor {
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
private Player player; private Player player;
private Party playerParty; private Party playerParty;
private Party targetParty; private Party targetParty;
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand(); private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand(); private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand(); private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.party.alliance; package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.data.UserManager;
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;

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party.alliance; package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
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;

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party.teleport; package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.data.UserManager;
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;
@ -20,8 +20,7 @@ public class PtpAcceptAnyCommand implements CommandExecutor {
if (ptpRecord.isConfirmRequired()) { if (ptpRecord.isConfirmRequired()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Enabled"));
} }

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.party.teleport; package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.SkillUtils; import com.gmail.nossr50.core.util.skills.SkillUtils;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -49,8 +49,7 @@ public class PtpAcceptCommand implements CommandExecutor {
if (!Permissions.partyTeleportWorld(target, targetWorld)) { if (!Permissions.partyTeleportWorld(target, targetWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName())); target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return true; return true;
} } else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName())); target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
return true; return true;
} }

View File

@ -2,22 +2,22 @@ package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.config.skills.WorldBlacklist; import com.gmail.nossr50.core.config.skills.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature; import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.runnables.items.TeleportationWarmup; import com.gmail.nossr50.core.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.core.util.EventUtils; import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Misc; import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.SkillUtils; import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.worldguard.WorldGuardManager; import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils; import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -36,6 +36,54 @@ public class PtpCommand implements TabExecutor {
private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand(); private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand(); private CommandExecutor ptpAcceptCommand = new PtpAcceptCommand();
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
return false;
}
if (!PartyManager.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
return false;
}
if (!target.isValid()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return false;
}
return true;
}
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
} else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
}
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
@ -45,14 +93,13 @@ public class PtpCommand implements TabExecutor {
Player player = (Player) sender; Player player = (Player) sender;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return true; return true;
} }
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(player.getWorld())) if (WorldBlacklist.isWorldBlacklisted(player.getWorld()))
return true; return true;
if (!UserManager.hasPlayerDataKey(player)) { if (!UserManager.hasPlayerDataKey(player)) {
@ -171,53 +218,4 @@ public class PtpCommand implements TabExecutor {
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout())); target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout()));
} }
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
return false;
}
if (!PartyManager.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
if (!mcMMOTarget.getPartyTeleportRecord().isEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", targetName));
return false;
}
if (!target.isValid()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return false;
}
return true;
}
protected static void handleTeleportWarmup(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetPlayer);
long warmup = Config.getInstance().getPTPCommandWarmup();
mcMMOPlayer.actualizeTeleportCommenceLocation(teleportingPlayer);
if (warmup > 0) {
teleportingPlayer.sendMessage(LocaleLoader.getString("Teleport.Commencing", warmup));
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
}
else {
EventUtils.handlePartyTeleportEvent(teleportingPlayer, targetPlayer);
}
}
} }

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party.teleport; package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.data.UserManager;
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;
@ -20,8 +20,7 @@ public class PtpToggleCommand implements CommandExecutor {
if (ptpRecord.isEnabled()) { if (ptpRecord.isEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
} } else {
else {
sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled")); sender.sendMessage(LocaleLoader.getString("Commands.ptp.Enabled"));
} }

View File

@ -1,15 +1,15 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile; import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -65,8 +65,7 @@ public class InspectCommand implements TabExecutor {
sender.sendMessage(CommandUtils.displaySkill(profile, skill)); sender.sendMessage(CommandUtils.displaySkill(profile, skill));
} }
} } else {
else {
Player target = mcMMOPlayer.getPlayer(); Player target = mcMMOPlayer.getPlayer();
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) { if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
@ -74,8 +73,7 @@ public class InspectCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline")); sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true; return true;
} }
} } else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
return true; return true;
} }

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.SuperAbilityType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.SuperAbilityType;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -52,8 +52,7 @@ public class MccooldownCommand implements TabExecutor {
if (seconds <= 0) { if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName())); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
} } else {
else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds)); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
} }
} }

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.core.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -61,8 +61,7 @@ public class McrankCommand implements TabExecutor {
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) { if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
return true; return true;
} }
} } else if (CommandUtils.inspectOffline(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) {
else if (CommandUtils.inspectOffline(sender, mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false), Permissions.mcrankOffline(sender))) {
return true; return true;
} }

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -47,8 +47,7 @@ public class McstatsCommand implements TabExecutor {
if (powerLevelCap != Integer.MAX_VALUE) { if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap)); player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
} } else {
else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel())); player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
} }

View File

@ -1,15 +1,15 @@
package com.gmail.nossr50.commands.player; package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.runnables.commands.MctopCommandAsyncTask; import com.gmail.nossr50.core.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils; import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@ -1,14 +1,14 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.random.RandomChanceSkill; import com.gmail.nossr50.core.util.random.RandomChanceSkill;
import com.gmail.nossr50.core.util.random.RandomChanceUtil; import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.skills.SkillActivationType; import com.gmail.nossr50.core.util.skills.SkillActivationType;
import com.gmail.nossr50.listeners.InteractionManager;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -55,8 +55,7 @@ public class AcrobaticsCommand extends SkillCommand {
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll"); AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll");
if(abstractSubSkill != null) if (abstractSubSkill != null) {
{
double rollChance, graceChance; double rollChance, graceChance;
//Chance to roll at half //Chance to roll at half

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.primary.alchemy.AlchemyManager; import com.gmail.nossr50.core.skills.primary.alchemy.AlchemyManager;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -16,10 +16,9 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class AprilCommand implements TabExecutor { public class AprilCommand implements TabExecutor {
private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%"); protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00"); protected DecimalFormat decimal = new DecimalFormat("##0.00");
private String skillName;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.primary.archery.Archery; import com.gmail.nossr50.core.skills.primary.archery.Archery;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.SkillActivationType; import com.gmail.nossr50.core.util.skills.SkillActivationType;

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.primary.axes.Axes; import com.gmail.nossr50.core.skills.primary.axes.Axes;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType; import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;

View File

@ -2,15 +2,15 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.config.skills.AdvancedConfig; import com.gmail.nossr50.core.config.skills.AdvancedConfig;
import com.gmail.nossr50.core.config.treasure.TreasureConfig; import com.gmail.nossr50.core.config.treasure.TreasureConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.treasure.Rarity;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.primary.fishing.Fishing; import com.gmail.nossr50.core.skills.primary.fishing.Fishing;
import com.gmail.nossr50.core.skills.primary.fishing.FishingManager; import com.gmail.nossr50.core.skills.primary.fishing.FishingManager;
import com.gmail.nossr50.core.skills.treasure.Rarity;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.random.RandomChanceUtil; import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -74,7 +74,7 @@ public class FishingCommand extends SkillCommand {
} }
} }
if(totalEnchantChance >= 1) if (totalEnchantChance >= 1)
magicChance = percent.format(totalEnchantChance / 100.0); magicChance = percent.format(totalEnchantChance / 100.0);
else else
magicChance = percent.format(0); magicChance = percent.format(0);

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
@ -45,7 +45,8 @@ public class HerbalismCommand extends SkillCommand {
// DOUBLE DROPS // DOUBLE DROPS
if (canDoubleDrop) { if (canDoubleDrop) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS);; String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.HERBALISM_DOUBLE_DROPS);
;
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }
@ -124,7 +125,7 @@ public class HerbalismCommand extends SkillCommand {
} }
if (canGreenThumbPlants) { if (canGreenThumbPlants) {
messages.add(getStatMessage(true, true,SubSkillType.HERBALISM_GREEN_THUMB, String.valueOf(greenThumbStage))); messages.add(getStatMessage(true, true, SubSkillType.HERBALISM_GREEN_THUMB, String.valueOf(greenThumbStage)));
} }
if (hasHylianLuck) { if (hasHylianLuck) {

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager; import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType; import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill; import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.listeners.InteractionManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -27,26 +27,22 @@ public class MmoInfoCommand implements TabExecutor {
/* /*
* Only allow players to use this command * Only allow players to use this command
*/ */
if(commandSender instanceof Player) if (commandSender instanceof Player) {
{ if (args.length < 1)
if(args.length < 1)
return false; return false;
Player player = (Player) commandSender; Player player = (Player) commandSender;
if(Permissions.mmoinfo(player)) if (Permissions.mmoinfo(player)) {
{ if (args == null || args[0] == null)
if(args == null || args[0] == null)
return false; return false;
if(args[0].equalsIgnoreCase( "???")) if (args[0].equalsIgnoreCase("???")) {
{
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", "???")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", "???"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery"));
return true; return true;
} else if(InteractionManager.getAbstractByName(args[0]) != null || PrimarySkillType.SUBSKILL_NAMES.contains(args[0])) } else if (InteractionManager.getAbstractByName(args[0]) != null || PrimarySkillType.SUBSKILL_NAMES.contains(args[0])) {
{
displayInfo(player, args[0]); displayInfo(player, args[0]);
return true; return true;
} }
@ -70,12 +66,10 @@ public class MmoInfoCommand implements TabExecutor {
} }
} }
private void displayInfo(Player player, String subSkillName) private void displayInfo(Player player, String subSkillName) {
{
//Check to see if the skill exists in the new system //Check to see if the skill exists in the new system
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName(subSkillName); AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName(subSkillName);
if(abstractSubSkill != null) if (abstractSubSkill != null) {
{
/* New System Skills are programmable */ /* New System Skills are programmable */
abstractSubSkill.printInfo(player); abstractSubSkill.printInfo(player);
//TextComponentFactory.sendPlayerUrlHeader(player); //TextComponentFactory.sendPlayerUrlHeader(player);
@ -89,9 +83,8 @@ public class MmoInfoCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill")); player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill"));
} }
for(SubSkillType subSkillType : SubSkillType.values()) for (SubSkillType subSkillType : SubSkillType.values()) {
{ if (subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName))
if(subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName))
subSkillName = subSkillType.getWikiName(subSkillType.toString()); subSkillName = subSkillType.getWikiName(subSkillType.toString());
} }

View File

@ -1,19 +1,19 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.MaterialType; import com.gmail.nossr50.core.skills.MaterialType;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.skills.primary.repair.ArcaneForging; import com.gmail.nossr50.core.skills.primary.repair.ArcaneForging;
import com.gmail.nossr50.core.skills.primary.repair.Repair; import com.gmail.nossr50.core.skills.primary.repair.Repair;
import com.gmail.nossr50.core.skills.primary.repair.RepairManager; import com.gmail.nossr50.core.skills.primary.repair.RepairManager;
import com.gmail.nossr50.core.skills.primary.repair.repairables.Repairable; import com.gmail.nossr50.core.skills.primary.repair.repairables.Repairable;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType; import com.gmail.nossr50.core.util.skills.SkillActivationType;
import com.gmail.nossr50.mcMMO;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.child.salvage.Salvage; import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.core.skills.child.salvage.SalvageManager; import com.gmail.nossr50.core.skills.child.salvage.SalvageManager;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -2,16 +2,16 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.config.skills.AdvancedConfig; import com.gmail.nossr50.core.config.skills.AdvancedConfig;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.child.FamilyTree; import com.gmail.nossr50.core.skills.child.FamilyTree;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils; import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.commands.CommandUtils; import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.random.RandomChanceUtil; import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.util.skills.PerksUtils; import com.gmail.nossr50.core.util.skills.PerksUtils;
@ -33,11 +33,9 @@ import java.util.Set;
public abstract class SkillCommand implements TabExecutor { public abstract class SkillCommand implements TabExecutor {
protected PrimarySkillType skill; protected PrimarySkillType skill;
private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%"); protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00"); protected DecimalFormat decimal = new DecimalFormat("##0.00");
private String skillName;
private CommandExecutor skillGuideCommand; private CommandExecutor skillGuideCommand;
public SkillCommand(PrimarySkillType skill) { public SkillCommand(PrimarySkillType skill) {
@ -46,6 +44,15 @@ public abstract class SkillCommand implements TabExecutor {
skillGuideCommand = new SkillGuideCommand(skill); skillGuideCommand = new SkillGuideCommand(skill);
} }
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
String[] newArray = new String[existingArray.length + 1];
newArray[0] = itemToAdd;
System.arraycopy(existingArray, 0, newArray, 1, existingArray.length);
return newArray;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
@ -66,9 +73,8 @@ public abstract class SkillCommand implements TabExecutor {
float skillValue = mcMMOPlayer.getSkillLevel(skill); float skillValue = mcMMOPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier //Send the players a few blank lines to make finding the top of the skill command easier
if(AdvancedConfig.getInstance().doesSkillCommandSendBlankLines()) if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
for(int i = 0; i < 2; i++) for (int i = 0; i < 2; i++) {
{
player.sendMessage(""); player.sendMessage("");
} }
@ -99,8 +105,7 @@ public abstract class SkillCommand implements TabExecutor {
//Link Header //Link Header
if(Config.getInstance().getUrlLinksEnabled()) if (Config.getInstance().getUrlLinksEnabled()) {
{
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header")); player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
TextComponentFactory.sendPlayerUrlHeader(player); TextComponentFactory.sendPlayerUrlHeader(player);
} }
@ -138,8 +143,7 @@ public abstract class SkillCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName)); player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName));
if(!skill.isChildSkill()) if (!skill.isChildSkill()) {
{
/* /*
* NON-CHILD SKILLS * NON-CHILD SKILLS
*/ */
@ -162,17 +166,16 @@ public abstract class SkillCommand implements TabExecutor {
//TODO: Add JSON here //TODO: Add JSON here
for (PrimarySkillType parent : parents) { for (PrimarySkillType parent : parents) {
parentList.add(parent); parentList.add(parent);
/*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/; /*player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level.Overhaul", mcMMOPlayer.getSkillLevel(parent), mcMMOPlayer.getSkillXpLevel(parent), mcMMOPlayer.getXpToLevel(parent)))*/
;
} }
String parentMessage = ""; String parentMessage = "";
for(int i = 0; i < parentList.size(); i++) for (int i = 0; i < parentList.size(); i++) {
{ if (i + 1 < parentList.size()) {
if(i+1 < parentList.size())
{
parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i))); parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)));
parentMessage += ChatColor.GRAY+", "; parentMessage += ChatColor.GRAY + ", ";
} else { } else {
parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i))); parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)));
} }
@ -231,11 +234,9 @@ public abstract class SkillCommand implements TabExecutor {
int length; int length;
if(abilityLengthCap <= 0) if (abilityLengthCap <= 0) {
{
length = 2 + (int) (skillValue / abilityLengthVar); length = 2 + (int) (skillValue / abilityLengthVar);
} } else {
else {
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar); length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
} }
@ -245,40 +246,27 @@ public abstract class SkillCommand implements TabExecutor {
length = Math.min(length, maxLength); length = Math.min(length, maxLength);
} }
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) }; return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
} }
protected String getStatMessage(SubSkillType subSkillType, String... vars) protected String getStatMessage(SubSkillType subSkillType, String... vars) {
{
return getStatMessage(false, false, subSkillType, vars); return getStatMessage(false, false, subSkillType, vars);
} }
protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) protected String getStatMessage(boolean isExtra, boolean isCustom, SubSkillType subSkillType, String... vars) {
{
String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template"; String templateKey = isCustom ? "Ability.Generic.Template.Custom" : "Ability.Generic.Template";
String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription(); String statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription();
if(isCustom) if (isCustom)
//Cast to Object[] to suppress warnings //Cast to Object[] to suppress warnings
return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, (Object[]) vars)); return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, (Object[]) vars));
else else {
{
String[] mergedList = addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars); String[] mergedList = addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars);
//Cast to Object[] to suppress warnings //Cast to Object[] to suppress warnings
return LocaleLoader.getString(templateKey, (Object[]) mergedList); return LocaleLoader.getString(templateKey, (Object[]) mergedList);
} }
} }
public static String[] addItemToFirstPositionOfArray(String itemToAdd, String... existingArray) {
String[] newArray = new String[existingArray.length + 1];
newArray[0] = itemToAdd;
System.arraycopy(existingArray, 0, newArray, 1, existingArray.length);
return newArray;
}
protected abstract void dataCalculations(Player player, float skillValue); protected abstract void dataCalculations(Player player, float skillValue);
protected abstract void permissionsCheck(Player player); protected abstract void permissionsCheck(Player player);
@ -291,12 +279,12 @@ public abstract class SkillCommand implements TabExecutor {
/** /**
* Checks if a player can use a skill * Checks if a player can use a skill
*
* @param player target player * @param player target player
* @param subSkillType target subskill * @param subSkillType target subskill
* @return true if the player has permission and has the skill unlocked * @return true if the player has permission and has the skill unlocked
*/ */
protected boolean canUseSubskill(Player player, SubSkillType subSkillType) protected boolean canUseSubskill(Player player, SubSkillType subSkillType) {
{
return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType); return Permissions.isSubSkillEnabled(player, subSkillType) && RankUtils.hasUnlockedSubskill(player, subSkillType);
} }
} }

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.StringUtils; import com.gmail.nossr50.core.util.StringUtils;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -75,8 +75,7 @@ public class SkillGuideCommand implements CommandExecutor {
while (allStrings.size() < 9) { while (allStrings.size() < 9) {
if (pageIndexStart + allStrings.size() > guide.size()) { if (pageIndexStart + allStrings.size() > guide.size()) {
allStrings.add(""); allStrings.add("");
} } else {
else {
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1))); allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
} }
} }

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.child.smelting.Smelting; import com.gmail.nossr50.core.skills.child.smelting.Smelting;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType; import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.config.skills.AdvancedConfig; import com.gmail.nossr50.core.config.skills.AdvancedConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType; import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.primary.taming.Taming; import com.gmail.nossr50.core.skills.primary.taming.Taming;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType; import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -39,7 +39,8 @@ public class UnarmedCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) { protected void dataCalculations(Player player, float skillValue) {
// UNARMED_ARROW_DEFLECT // UNARMED_ARROW_DEFLECT
if (canDeflect) { if (canDeflect) {
String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);; String[] deflectStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_ARROW_DEFLECT);
;
deflectChance = deflectStrings[0]; deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1]; deflectChanceLucky = deflectStrings[1];
} }
@ -53,7 +54,8 @@ public class UnarmedCommand extends SkillCommand {
// UNARMED_DISARM // UNARMED_DISARM
if (canDisarm) { if (canDisarm) {
String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM);; String[] disarmStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.UNARMED_DISARM);
;
disarmChance = disarmStrings[0]; disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1]; disarmChanceLucky = disarmStrings[1];
} }

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory; import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
@ -46,7 +46,8 @@ public class WoodcuttingCommand extends SkillCommand {
} }
private void setDoubleDropClassicChanceStrings(Player player) { private void setDoubleDropClassicChanceStrings(Player player) {
String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);; String[] doubleDropStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.WOODCUTTING_HARVEST_LUMBER);
;
doubleDropChance = doubleDropStrings[0]; doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1]; doubleDropChanceLucky = doubleDropStrings[1];
} }

View File

@ -6,6 +6,10 @@ import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
public abstract class McMMOChatEvent extends Event implements Cancellable { public abstract class McMMOChatEvent extends Event implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private boolean cancelled; private boolean cancelled;
private Plugin plugin; private Plugin plugin;
private String sender; private String sender;
@ -27,6 +31,10 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
this.message = message; this.message = message;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* @return The plugin responsible for this event, note this can be null * @return The plugin responsible for this event, note this can be null
*/ */
@ -48,13 +56,6 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
return displayName; return displayName;
} }
/**
* @return String message that will be sent
*/
public String getMessage() {
return message;
}
/** /**
* @param displayName String display name of the player who sent the chat * @param displayName String display name of the player who sent the chat
*/ */
@ -62,6 +63,13 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
this.displayName = displayName; this.displayName = displayName;
} }
/**
* @return String message that will be sent
*/
public String getMessage() {
return message;
}
/** /**
* @param message String message to be sent in chat * @param message String message to be sent in chat
*/ */
@ -69,7 +77,9 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
this.message = message; this.message = message;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
@ -80,15 +90,8 @@ public abstract class McMMOChatEvent extends Event implements Cancellable {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.events.experience; package com.gmail.nossr50.events.experience;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason; import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.data.UserManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -12,10 +12,11 @@ import org.bukkit.event.player.PlayerEvent;
* Generic event for mcMMO experience events. * Generic event for mcMMO experience events.
*/ */
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable { public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable {
private boolean cancelled; private static final HandlerList handlers = new HandlerList();
protected PrimarySkillType skill; protected PrimarySkillType skill;
protected int skillLevel; protected int skillLevel;
protected XPGainReason xpGainReason; protected XPGainReason xpGainReason;
private boolean cancelled;
@Deprecated @Deprecated
protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill) { protected McMMOPlayerExperienceEvent(Player player, PrimarySkillType skill) {
@ -32,6 +33,10 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
this.xpGainReason = xpGainReason; this.xpGainReason = xpGainReason;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* @return The skill involved in this event * @return The skill involved in this event
*/ */
@ -53,7 +58,9 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
return xpGainReason; return xpGainReason;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
@ -64,14 +71,8 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
this.cancelled = cancelled; this.cancelled = cancelled;
} }
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.event.HandlerList;
* Called when a user loses levels in a skill * Called when a user loses levels in a skill
*/ */
public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent { public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
private static final HandlerList handlers = new HandlerList();
private int levelsLost; private int levelsLost;
@Deprecated @Deprecated
@ -33,11 +34,8 @@ public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
this.levelsLost = levelsLost; this.levelsLost = levelsLost;
} }
/** public static HandlerList getHandlerList() {
* @param levelsLost Set the number of levels lost in this event return handlers;
*/
public void setLevelsLost(int levelsLost) {
this.levelsLost = levelsLost;
} }
/** /**
@ -47,14 +45,15 @@ public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
return levelsLost; return levelsLost;
} }
private static final HandlerList handlers = new HandlerList(); /**
* @param levelsLost Set the number of levels lost in this event
*/
public void setLevelsLost(int levelsLost) {
this.levelsLost = levelsLost;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.event.HandlerList;
* Called when a user levels up in a skill * Called when a user levels up in a skill
*/ */
public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent { public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
private static final HandlerList handlers = new HandlerList();
private int levelsGained; private int levelsGained;
@Deprecated @Deprecated
@ -33,11 +34,8 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
this.levelsGained = levelsGained; this.levelsGained = levelsGained;
} }
/** public static HandlerList getHandlerList() {
* @param levelsGained Set the number of levels gained in this event return handlers;
*/
public void setLevelsGained(int levelsGained) {
this.levelsGained = levelsGained;
} }
/** /**
@ -47,14 +45,15 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
return levelsGained; return levelsGained;
} }
private static final HandlerList handlers = new HandlerList(); /**
* @param levelsGained Set the number of levels gained in this event
*/
public void setLevelsGained(int levelsGained) {
this.levelsGained = levelsGained;
}
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.event.HandlerList;
* Called when a player gains XP in a skill * Called when a player gains XP in a skill
*/ */
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent { public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
private static final HandlerList handlers = new HandlerList();
private float xpGained; private float xpGained;
@Deprecated @Deprecated
@ -22,6 +23,10 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
this.xpGained = xpGained; this.xpGained = xpGained;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* @return The amount of experience gained in this event * @return The amount of experience gained in this event
*/ */
@ -29,6 +34,13 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
return xpGained; return xpGained;
} }
/**
* @param xpGained int amount of experience gained in this event
*/
public void setRawXpGained(float xpGained) {
this.xpGained = xpGained;
}
/** /**
* @return int amount of experience gained in this event * @return int amount of experience gained in this event
*/ */
@ -37,13 +49,6 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
return (int) xpGained; return (int) xpGained;
} }
/**
* @param xpGained int amount of experience gained in this event
*/
public void setRawXpGained(float xpGained) {
this.xpGained = xpGained;
}
/** /**
* @param xpGained int amount of experience gained in this event * @param xpGained int amount of experience gained in this event
*/ */
@ -52,14 +57,8 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
this.xpGained = xpGained; this.xpGained = xpGained;
} }
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -8,9 +8,12 @@ import org.bukkit.event.player.PlayerEvent;
import java.util.HashMap; import java.util.HashMap;
public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancellable { public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private HashMap<String, Integer> levelChanged; private HashMap<String, Integer> levelChanged;
private HashMap<String, Float> experienceChanged; private HashMap<String, Float> experienceChanged;
private boolean cancelled; private boolean cancelled;
public McMMOPlayerDeathPenaltyEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Float> experienceChanged) { public McMMOPlayerDeathPenaltyEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Float> experienceChanged) {
@ -26,6 +29,10 @@ public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancell
this.cancelled = false; this.cancelled = false;
} }
public static HandlerList getHandlerList() {
return handlers;
}
public HashMap<String, Integer> getLevelChanged() { public HashMap<String, Integer> getLevelChanged() {
return levelChanged; return levelChanged;
} }
@ -42,7 +49,9 @@ public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancell
this.experienceChanged = experienceChanged; this.experienceChanged = experienceChanged;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
@ -53,15 +62,8 @@ public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancell
this.cancelled = cancelled; this.cancelled = cancelled;
} }
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -6,6 +6,10 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
public class McMMOPlayerPreDeathPenaltyEvent extends PlayerEvent implements Cancellable { public class McMMOPlayerPreDeathPenaltyEvent extends PlayerEvent implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private boolean cancelled; private boolean cancelled;
public McMMOPlayerPreDeathPenaltyEvent(Player player) { public McMMOPlayerPreDeathPenaltyEvent(Player player) {
@ -13,7 +17,13 @@ public class McMMOPlayerPreDeathPenaltyEvent extends PlayerEvent implements Canc
this.cancelled = false; this.cancelled = false;
} }
/** Following are required for Cancellable **/ public static HandlerList getHandlerList() {
return handlers;
}
/**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
@ -24,15 +34,8 @@ public class McMMOPlayerPreDeathPenaltyEvent extends PlayerEvent implements Canc
this.cancelled = cancelled; this.cancelled = cancelled;
} }
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -10,6 +10,10 @@ import org.bukkit.inventory.ItemStack;
* Called when mcMMO is preparing to drop an item. * Called when mcMMO is preparing to drop an item.
*/ */
public class McMMOItemSpawnEvent extends Event implements Cancellable { public class McMMOItemSpawnEvent extends Event implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private Location location; private Location location;
private ItemStack itemStack; private ItemStack itemStack;
private boolean cancelled; private boolean cancelled;
@ -20,6 +24,10 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
this.cancelled = false; this.cancelled = false;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* @return Location where the item will be dropped * @return Location where the item will be dropped
*/ */
@ -48,7 +56,9 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
this.itemStack = itemStack; this.itemStack = itemStack;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
@ -59,15 +69,8 @@ public class McMMOItemSpawnEvent extends Event implements Cancellable {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -6,6 +6,10 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable { public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private String oldAlly; private String oldAlly;
private String newAlly; private String newAlly;
private EventReason reason; private EventReason reason;
@ -24,6 +28,10 @@ public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancel
this.cancelled = false; this.cancelled = false;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* @return The party being left, or null if the player was not in a party * @return The party being left, or null if the player was not in a party
*/ */
@ -45,6 +53,24 @@ public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancel
return reason; return reason;
} }
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
/** /**
* A list of reasons why the event may have been fired * A list of reasons why the event may have been fired
*/ */
@ -64,27 +90,4 @@ public class McMMOPartyAllianceChangeEvent extends PlayerEvent implements Cancel
*/ */
CUSTOM; CUSTOM;
} }
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -9,6 +9,10 @@ import org.bukkit.event.player.PlayerEvent;
* Called when a player attempts to join, leave, or change parties. * Called when a player attempts to join, leave, or change parties.
*/ */
public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable { public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private String oldParty; private String oldParty;
private String newParty; private String newParty;
private EventReason reason; private EventReason reason;
@ -27,6 +31,10 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
this.cancelled = false; this.cancelled = false;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* @return The party being left, or null if the player was not in a party * @return The party being left, or null if the player was not in a party
*/ */
@ -48,6 +56,24 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
return reason; return reason;
} }
/**
* Following are required for Cancellable
**/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
/** /**
* A list of reasons why the event may have been fired * A list of reasons why the event may have been fired
*/ */
@ -77,27 +103,4 @@ public class McMMOPartyChangeEvent extends PlayerEvent implements Cancellable {
*/ */
CUSTOM; CUSTOM;
} }
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -6,6 +6,10 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
public class McMMOPartyLevelUpEvent extends Event implements Cancellable { public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private Party party; private Party party;
private int levelsChanged; private int levelsChanged;
private boolean cancelled; private boolean cancelled;
@ -16,6 +20,10 @@ public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
this.cancelled = false; this.cancelled = false;
} }
public static HandlerList getHandlerList() {
return handlers;
}
public Party getParty() { public Party getParty() {
return party; return party;
} }
@ -28,7 +36,9 @@ public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
this.levelsChanged = levelsChanged; this.levelsChanged = levelsChanged;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
@ -39,15 +49,8 @@ public class McMMOPartyLevelUpEvent extends Event implements Cancellable {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -8,6 +8,10 @@ import org.bukkit.event.player.PlayerTeleportEvent;
* Called just before a player teleports using the /ptp command. * Called just before a player teleports using the /ptp command.
*/ */
public class McMMOPartyTeleportEvent extends PlayerTeleportEvent { public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private String party; private String party;
private Player target; private Player target;
@ -17,6 +21,10 @@ public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
this.target = target; this.target = target;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* @return The party the teleporting player is in * @return The party the teleporting player is in
*/ */
@ -31,15 +39,8 @@ public class McMMOPartyTeleportEvent extends PlayerTeleportEvent {
return target; return target;
} }
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -6,6 +6,10 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
public class McMMOPartyXpGainEvent extends Event implements Cancellable { public class McMMOPartyXpGainEvent extends Event implements Cancellable {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
private Party party; private Party party;
private float xpGained; private float xpGained;
private boolean cancelled; private boolean cancelled;
@ -16,6 +20,10 @@ public class McMMOPartyXpGainEvent extends Event implements Cancellable {
this.cancelled = false; this.cancelled = false;
} }
public static HandlerList getHandlerList() {
return handlers;
}
public Party getParty() { public Party getParty() {
return party; return party;
} }
@ -27,6 +35,13 @@ public class McMMOPartyXpGainEvent extends Event implements Cancellable {
return xpGained; return xpGained;
} }
/**
* @param xpGained set amount of experience gained in this event
*/
public void setRawXpGained(float xpGained) {
this.xpGained = xpGained;
}
/** /**
* @return int amount of experience gained in this event * @return int amount of experience gained in this event
*/ */
@ -35,13 +50,6 @@ public class McMMOPartyXpGainEvent extends Event implements Cancellable {
return (int) xpGained; return (int) xpGained;
} }
/**
* @param xpGained set amount of experience gained in this event
*/
public void setRawXpGained(float xpGained) {
this.xpGained = xpGained;
}
/** /**
* @param xpGained set int amount of experience gained in this event * @param xpGained set int amount of experience gained in this event
*/ */
@ -50,7 +58,9 @@ public class McMMOPartyXpGainEvent extends Event implements Cancellable {
this.xpGained = xpGained; this.xpGained = xpGained;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;
@ -61,15 +71,8 @@ public class McMMOPartyXpGainEvent extends Event implements Cancellable {
this.cancelled = cancelled; this.cancelled = cancelled;
} }
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -11,24 +11,31 @@ import org.bukkit.scoreboard.Scoreboard;
*/ */
abstract public class McMMOScoreboardEvent extends Event { abstract public class McMMOScoreboardEvent extends Event {
protected Scoreboard targetBoard; //Scoreboard involved in this event /**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
final Scoreboard currentBoard; //Can be null final Scoreboard currentBoard; //Can be null
private final ScoreboardEventReason scoreboardEventReason;
protected Scoreboard targetBoard; //Scoreboard involved in this event
protected Player targetPlayer; protected Player targetPlayer;
private final ScoreboardEventReason scoreboardEventReason; /** GETTER & SETTER BOILERPLATE **/
public McMMOScoreboardEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) public McMMOScoreboardEvent(Scoreboard targetBoard, Scoreboard currentBoard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) {
{
this.scoreboardEventReason = scoreboardEventReason; this.scoreboardEventReason = scoreboardEventReason;
this.targetBoard = targetBoard; this.targetBoard = targetBoard;
this.currentBoard = currentBoard; this.currentBoard = currentBoard;
this.targetPlayer = targetPlayer; this.targetPlayer = targetPlayer;
} }
/** GETTER & SETTER BOILERPLATE **/ public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* This is the scoreboard the player will be assigned to after this event * This is the scoreboard the player will be assigned to after this event
*
* @return the target board to assign the player after this event fires * @return the target board to assign the player after this event fires
*/ */
public Scoreboard getTargetBoard() { public Scoreboard getTargetBoard() {
@ -37,6 +44,7 @@ abstract public class McMMOScoreboardEvent extends Event {
/** /**
* Change the scoreboard that the player will be assigned to after this event fires * Change the scoreboard that the player will be assigned to after this event fires
*
* @param targetBoard the new board to assign the player to * @param targetBoard the new board to assign the player to
*/ */
public void setTargetBoard(Scoreboard targetBoard) { public void setTargetBoard(Scoreboard targetBoard) {
@ -45,15 +53,26 @@ abstract public class McMMOScoreboardEvent extends Event {
/** /**
* The player involved in this event (this can be changed) * The player involved in this event (this can be changed)
*
* @return the player involved in this event * @return the player involved in this event
*/ */
public Player getTargetPlayer() { public Player getTargetPlayer() {
return targetPlayer; return targetPlayer;
} }
/**
* Change the target player for this event
*
* @param targetPlayer the new target for this event
*/
public void setTargetPlayer(Player targetPlayer) {
this.targetPlayer = targetPlayer;
}
/** /**
* This is the scoreboard the player is currently assigned to at the time the event was fired * This is the scoreboard the player is currently assigned to at the time the event was fired
* Grabbed via player.getScoreboard() * Grabbed via player.getScoreboard()
*
* @return players current scoreboard * @return players current scoreboard
*/ */
public Scoreboard getCurrentBoard() { public Scoreboard getCurrentBoard() {
@ -62,29 +81,15 @@ abstract public class McMMOScoreboardEvent extends Event {
/** /**
* The ENUM defining the reason for this event * The ENUM defining the reason for this event
*
* @return the reason for this event * @return the reason for this event
*/ */
public ScoreboardEventReason getScoreboardEventReason() { public ScoreboardEventReason getScoreboardEventReason() {
return scoreboardEventReason; return scoreboardEventReason;
} }
/**
* Change the target player for this event
* @param targetPlayer the new target for this event
*/
public void setTargetPlayer(Player targetPlayer) {
this.targetPlayer = targetPlayer;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -6,10 +6,9 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
public class McMMOScoreboardObjectiveEvent extends McMMOScoreboardEvent implements Cancellable { public class McMMOScoreboardObjectiveEvent extends McMMOScoreboardEvent implements Cancellable {
protected boolean cancelled;
protected Objective targetObjective;
protected final ScoreboardObjectiveEventReason objectiveEventReason; protected final ScoreboardObjectiveEventReason objectiveEventReason;
protected boolean cancelled;
protected Objective targetObjective;
public McMMOScoreboardObjectiveEvent(Objective targetObjective, ScoreboardObjectiveEventReason objectiveEventReason, Scoreboard scoreboard, Scoreboard oldboard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) { public McMMOScoreboardObjectiveEvent(Objective targetObjective, ScoreboardObjectiveEventReason objectiveEventReason, Scoreboard scoreboard, Scoreboard oldboard, Player targetPlayer, ScoreboardEventReason scoreboardEventReason) {
super(scoreboard, oldboard, targetPlayer, scoreboardEventReason); super(scoreboard, oldboard, targetPlayer, scoreboardEventReason);
@ -20,6 +19,7 @@ public class McMMOScoreboardObjectiveEvent extends McMMOScoreboardEvent implemen
/** /**
* The objective that will be modified by this event * The objective that will be modified by this event
*
* @return * @return
*/ */
public Objective getTargetObjective() { public Objective getTargetObjective() {
@ -28,6 +28,7 @@ public class McMMOScoreboardObjectiveEvent extends McMMOScoreboardEvent implemen
/** /**
* Change the target objective for this event * Change the target objective for this event
*
* @param newObjective new target objective * @param newObjective new target objective
*/ */
public void setTargetObjective(Objective newObjective) { public void setTargetObjective(Objective newObjective) {

View File

@ -12,6 +12,10 @@ import org.bukkit.event.player.PlayerEvent;
* This event is sent for when mcMMO informs a player about various important information * This event is sent for when mcMMO informs a player about various important information
*/ */
public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable { public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
protected final NotificationType notificationType;
protected ChatMessageType chatMessageType;
protected TextComponent notificationTextComponent;
private boolean isCancelled; private boolean isCancelled;
/* /*
* Messages can be sent to both places, as configured in advanced.yml * Messages can be sent to both places, as configured in advanced.yml
@ -20,12 +24,6 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell
*/ */
private boolean isMessageAlsoBeingSentToChat; private boolean isMessageAlsoBeingSentToChat;
private static final HandlerList handlers = new HandlerList();
protected ChatMessageType chatMessageType;
protected TextComponent notificationTextComponent;
protected final NotificationType notificationType;
public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, TextComponent notificationTextComponent, ChatMessageType chatMessageType, boolean isMessageAlsoBeingSentToChat) { public McMMOPlayerNotificationEvent(Player who, NotificationType notificationType, TextComponent notificationTextComponent, ChatMessageType chatMessageType, boolean isMessageAlsoBeingSentToChat) {
super(who); super(who);
this.notificationType = notificationType; this.notificationType = notificationType;
@ -39,6 +37,10 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell
* Getters & Setters * Getters & Setters
*/ */
public static HandlerList getHandlerList() {
return handlers;
}
public boolean isMessageAlsoBeingSentToChat() { public boolean isMessageAlsoBeingSentToChat() {
return isMessageAlsoBeingSentToChat; return isMessageAlsoBeingSentToChat;
} }
@ -63,27 +65,24 @@ public class McMMOPlayerNotificationEvent extends PlayerEvent implements Cancell
this.chatMessageType = chatMessageType; this.chatMessageType = chatMessageType;
} }
/*
* Custom Event Boilerplate
*/
/** /**
* The notification type for this event * The notification type for this event
*
* @return this event's notification type * @return this event's notification type
*/ */
public NotificationType getEventNotificationType() { public NotificationType getEventNotificationType() {
return notificationType; return notificationType;
} }
/*
* Custom Event Boilerplate
*/
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
/* /*
* Cancellable Interface Boilerplate * Cancellable Interface Boilerplate
*/ */

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.events.skills; package com.gmail.nossr50.events.skills;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.data.UserManager; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent; import org.bukkit.event.player.PlayerEvent;
@ -10,6 +10,10 @@ import org.bukkit.event.player.PlayerEvent;
* Generic event for mcMMO skill handling. * Generic event for mcMMO skill handling.
*/ */
public abstract class McMMOPlayerSkillEvent extends PlayerEvent { public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
/**
* Rest of file is required boilerplate for custom events
**/
private static final HandlerList handlers = new HandlerList();
protected PrimarySkillType skill; protected PrimarySkillType skill;
protected int skillLevel; protected int skillLevel;
@ -19,6 +23,10 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill); this.skillLevel = UserManager.getPlayer(player).getSkillLevel(skill);
} }
public static HandlerList getHandlerList() {
return handlers;
}
/** /**
* @return The skill involved in this event * @return The skill involved in this event
*/ */
@ -33,15 +41,8 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
return skillLevel; return skillLevel;
} }
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() {
return handlers;
}
} }

View File

@ -44,7 +44,9 @@ public class McMMOPlayerRepairCheckEvent extends McMMOPlayerSkillEvent implement
return repairedObject; return repairedObject;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;

View File

@ -44,7 +44,9 @@ public class McMMOPlayerSalvageCheckEvent extends McMMOPlayerSkillEvent implemen
return enchantedBook; return enchantedBook;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;

View File

@ -13,6 +13,7 @@ public class SubSkillEvent extends McMMOPlayerSkillEvent implements Cancellable
/** /**
* Only skills using the old system will fire this event * Only skills using the old system will fire this event
*
* @param player target player * @param player target player
* @param subSkillType target subskill * @param subSkillType target subskill
* @Deprecated Skills will be using a new system stemming from the AbstractSubSkill class so make sure you check for both events, this event will be removed eventually. * @Deprecated Skills will be using a new system stemming from the AbstractSubSkill class so make sure you check for both events, this event will be removed eventually.
@ -23,13 +24,13 @@ public class SubSkillEvent extends McMMOPlayerSkillEvent implements Cancellable
this.subSkillType = subSkillType; this.subSkillType = subSkillType;
} }
public SubSkillEvent(Player player, AbstractSubSkill abstractSubSkill) public SubSkillEvent(Player player, AbstractSubSkill abstractSubSkill) {
{
super(player, abstractSubSkill.getPrimarySkill()); super(player, abstractSubSkill.getPrimarySkill());
} }
/** /**
* Gets the SubSkillType involved in the event * Gets the SubSkillType involved in the event
*
* @return the SubSkillType * @return the SubSkillType
*/ */
public SubSkillType getSubSkillType() { public SubSkillType getSubSkillType() {

View File

@ -12,8 +12,7 @@ public class SubSkillRandomCheckEvent extends SubSkillEvent {
this.chance = chance; this.chance = chance;
} }
public SubSkillRandomCheckEvent(Player player, AbstractSubSkill abstractSubSkill, double chance) public SubSkillRandomCheckEvent(Player player, AbstractSubSkill abstractSubSkill, double chance) {
{
super(player, abstractSubSkill); super(player, abstractSubSkill);
this.chance = chance; this.chance = chance;
} }

View File

@ -18,7 +18,9 @@ public class McMMOPlayerDisarmEvent extends McMMOPlayerSkillEvent implements Can
return defender; return defender;
} }
/** Following are required for Cancellable **/ /**
* Following are required for Cancellable
**/
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return cancelled; return cancelled;

View File

@ -1,34 +1,34 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.config.skills.HiddenConfig; import com.gmail.nossr50.core.config.skills.HiddenConfig;
import com.gmail.nossr50.core.config.skills.WorldBlacklist; import com.gmail.nossr50.core.config.skills.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SuperAbilityType; import com.gmail.nossr50.core.skills.SuperAbilityType;
import com.gmail.nossr50.core.skills.ToolType; import com.gmail.nossr50.core.skills.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy; import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy;
import com.gmail.nossr50.core.skills.primary.excavation.ExcavationManager; import com.gmail.nossr50.core.skills.primary.excavation.ExcavationManager;
import com.gmail.nossr50.core.skills.primary.herbalism.Herbalism; import com.gmail.nossr50.core.skills.primary.herbalism.Herbalism;
import com.gmail.nossr50.core.skills.primary.herbalism.HerbalismManager; import com.gmail.nossr50.core.skills.primary.herbalism.HerbalismManager;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager; import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.skills.primary.repair.Repair; import com.gmail.nossr50.core.skills.primary.repair.Repair;
import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.core.skills.primary.woodcutting.WoodcuttingManager; import com.gmail.nossr50.core.skills.primary.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.core.util.BlockUtils; import com.gmail.nossr50.core.util.BlockUtils;
import com.gmail.nossr50.core.util.EventUtils; import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.ItemUtils; import com.gmail.nossr50.core.util.ItemUtils;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.SkillUtils; import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.util.sounds.SoundManager; import com.gmail.nossr50.core.util.sounds.SoundManager;
import com.gmail.nossr50.core.util.sounds.SoundType; import com.gmail.nossr50.core.util.sounds.SoundType;
import com.gmail.nossr50.core.worldguard.WorldGuardManager; import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils; import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.mcMMO;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -62,7 +62,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) { public void onBlockPistonExtend(BlockPistonExtendEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
BlockFace direction = event.getDirection(); BlockFace direction = event.getDirection();
@ -85,7 +85,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) { public void onBlockPistonRetract(BlockPistonRetractEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
// Get opposite direction so we get correct block // Get opposite direction so we get correct block
@ -105,14 +105,12 @@ public class BlockListener implements Listener {
* @param event The event to watch * @param event The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityBlockFormEvent(EntityBlockFormEvent event) public void onEntityBlockFormEvent(EntityBlockFormEvent event) {
{
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
if(BlockUtils.shouldBeWatched(event.getBlock().getState())) if (BlockUtils.shouldBeWatched(event.getBlock().getState())) {
{
mcMMO.getPlaceStore().setTrue(event.getBlock()); mcMMO.getPlaceStore().setTrue(event.getBlock());
} }
} }
@ -125,14 +123,14 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFallingBlock(EntityChangeBlockEvent event) { public void onFallingBlock(EntityChangeBlockEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) { if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) { if (event.getTo().equals(Material.AIR) && mcMMO.getPlaceStore().isTrue(event.getBlock())) {
event.getEntity().setMetadata("mcMMOBlockFall", new FixedMetadataValue( plugin, event.getBlock().getLocation())); event.getEntity().setMetadata("mcMMOBlockFall", new FixedMetadataValue(plugin, event.getBlock().getLocation()));
} else { } else {
List<MetadataValue> values = event.getEntity().getMetadata( "mcMMOBlockFall" ); List<MetadataValue> values = event.getEntity().getMetadata("mcMMOBlockFall");
if (!values.isEmpty()) { if (!values.isEmpty()) {
@ -140,8 +138,8 @@ public class BlockListener implements Listener {
Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock(); Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock();
mcMMO.getPlaceStore().setTrue( event.getBlock() ); mcMMO.getPlaceStore().setTrue(event.getBlock());
mcMMO.getPlaceStore().setFalse( spawn ); mcMMO.getPlaceStore().setFalse(spawn);
} }
} }
@ -156,7 +154,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -178,8 +176,7 @@ public class BlockListener implements Listener {
if (blockState.getType() == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player)) { if (blockState.getType() == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player)) {
mcMMOPlayer.getRepairManager().placedAnvilCheck(); mcMMOPlayer.getRepairManager().placedAnvilCheck();
} } else if (blockState.getType() == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player)) {
else if (blockState.getType() == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player)) {
mcMMOPlayer.getSalvageManager().placedAnvilCheck(); mcMMOPlayer.getSalvageManager().placedAnvilCheck();
} }
} }
@ -192,7 +189,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockMultiPlace(BlockMultiPlaceEvent event) { public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -201,8 +198,7 @@ public class BlockListener implements Listener {
return; return;
} }
for (BlockState replacedBlockState : event.getReplacedBlockStates()) for (BlockState replacedBlockState : event.getReplacedBlockStates()) {
{
BlockState blockState = replacedBlockState.getBlock().getState(); BlockState blockState = replacedBlockState.getBlock().getState();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */ /* Check if the blocks placed should be monitored so they do not give out XP in the future */
@ -213,10 +209,9 @@ public class BlockListener implements Listener {
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockGrow(BlockGrowEvent event) public void onBlockGrow(BlockGrowEvent event) {
{
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
@ -236,13 +231,12 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return; return;
} }
@ -300,8 +294,7 @@ public class BlockListener implements Listener {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) { if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState); woodcuttingManager.processTreeFeller(blockState);
} } else {
else {
woodcuttingManager.woodcuttingBlockCheck(blockState); woodcuttingManager.woodcuttingBlockCheck(blockState);
} }
} }
@ -328,13 +321,12 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreakHigher(BlockBreakEvent event) { public void onBlockBreakHigher(BlockBreakEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return; return;
} }
@ -363,8 +355,7 @@ public class BlockListener implements Listener {
if (herbalismManager.processHylianLuck(blockState)) { if (herbalismManager.processHylianLuck(blockState)) {
blockState.update(true); blockState.update(true);
event.setCancelled(true); event.setCancelled(true);
} } else if (blockState.getType() == Material.FLOWER_POT) {
else if (blockState.getType() == Material.FLOWER_POT) {
blockState.setType(Material.AIR); blockState.setType(Material.AIR);
blockState.update(true); blockState.update(true);
event.setCancelled(true); event.setCancelled(true);
@ -394,13 +385,12 @@ public class BlockListener implements Listener {
BlockState blockState = event.getBlock().getState(); BlockState blockState = event.getBlock().getState();
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return; return;
} }
@ -423,17 +413,13 @@ public class BlockListener implements Listener {
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) { if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.HERBALISM);
} } else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.WOODCUTTING);
} } else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.MINING);
} } else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.EXCAVATION);
} } else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED); mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
} }
} }
@ -466,13 +452,12 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamageHigher(BlockDamageEvent event) { public void onBlockDamageHigher(BlockDamageEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return; return;
} }
@ -500,19 +485,16 @@ public class BlockListener implements Listener {
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) { if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
blockState.update(true); blockState.update(true);
} }
} } else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
else if (mcMMOPlayer.getAbilityMode(SuperAbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) { if (SuperAbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true); event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP); SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
} } else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) { if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update(); blockState.update();
} }
} }
} } else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true); event.setInstaBreak(true);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP); SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
} }
@ -532,46 +514,39 @@ public class BlockListener implements Listener {
} }
public void debugStickDump(Player player, BlockState blockState) { public void debugStickDump(Player player, BlockState blockState) {
if(player.getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) if (player.getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) {
{ if (mcMMO.getPlaceStore().isTrue(blockState))
if(mcMMO.getPlaceStore().isTrue(blockState))
player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP"); player.sendMessage("[mcMMO DEBUG] This block is not natural and does not reward treasures/XP");
else else {
{
player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO"); player.sendMessage("[mcMMO DEBUG] This block is considered natural by mcMMO");
UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState); UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
} }
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (WorldGuardManager.getInstance().hasMainFlag(player))
if(WorldGuardManager.getInstance().hasMainFlag(player))
player.sendMessage("[mcMMO DEBUG] World Guard main flag is permitted for this player in this region"); player.sendMessage("[mcMMO DEBUG] World Guard main flag is permitted for this player in this region");
else else
player.sendMessage("[mcMMO DEBUG] World Guard main flag is DENIED for this player in this region"); player.sendMessage("[mcMMO DEBUG] World Guard main flag is DENIED for this player in this region");
if(WorldGuardManager.getInstance().hasXPFlag(player)) if (WorldGuardManager.getInstance().hasXPFlag(player))
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is permitted for this player in this region"); player.sendMessage("[mcMMO DEBUG] World Guard xp flag is permitted for this player in this region");
else else
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is not permitted for this player in this region"); player.sendMessage("[mcMMO DEBUG] World Guard xp flag is not permitted for this player in this region");
} }
if(blockState instanceof Furnace) if (blockState instanceof Furnace) {
{
Furnace furnace = (Furnace) blockState; Furnace furnace = (Furnace) blockState;
if(furnace.hasMetadata(mcMMO.furnaceMetadataKey)) if (furnace.hasMetadata(mcMMO.furnaceMetadataKey)) {
{
player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner"); player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner");
Player furnacePlayer = getPlayerFromFurnace(furnace.getBlock()); Player furnacePlayer = getPlayerFromFurnace(furnace.getBlock());
if(furnacePlayer != null) if (furnacePlayer != null) {
{ player.sendMessage("[mcMMO DEBUG] This furnace is owned by player " + furnacePlayer.getName());
player.sendMessage("[mcMMO DEBUG] This furnace is owned by player "+furnacePlayer.getName());
} }
} } else
else
player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner"); player.sendMessage("[mcMMO DEBUG] This furnace does not have a registered owner");
} }
if(ExperienceConfig.getInstance().isExperienceBarsEnabled()) if (ExperienceConfig.getInstance().isExperienceBarsEnabled())
player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled."); player.sendMessage("[mcMMO DEBUG] XP bars are enabled, however you should check per-skill settings to make sure those are enabled.");
} }
} }

View File

@ -1,31 +1,31 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.skills.AdvancedConfig; import com.gmail.nossr50.core.config.skills.AdvancedConfig;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.config.skills.WorldBlacklist; import com.gmail.nossr50.core.config.skills.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.meta.OldName; import com.gmail.nossr50.core.datatypes.meta.OldName;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.interfaces.InteractType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.archery.Archery; import com.gmail.nossr50.core.skills.primary.archery.Archery;
import com.gmail.nossr50.core.skills.primary.fishing.Fishing; import com.gmail.nossr50.core.skills.primary.fishing.Fishing;
import com.gmail.nossr50.core.skills.primary.mining.BlastMining; import com.gmail.nossr50.core.skills.primary.mining.BlastMining;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager; import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.skills.primary.taming.Taming; import com.gmail.nossr50.core.skills.primary.taming.Taming;
import com.gmail.nossr50.core.skills.primary.taming.TamingManager; import com.gmail.nossr50.core.skills.primary.taming.TamingManager;
import com.gmail.nossr50.core.skills.subskills.interfaces.InteractType;
import com.gmail.nossr50.core.util.BlockUtils; import com.gmail.nossr50.core.util.BlockUtils;
import com.gmail.nossr50.core.util.Misc; import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.CombatUtils; import com.gmail.nossr50.core.util.skills.CombatUtils;
import com.gmail.nossr50.core.worldguard.WorldGuardManager; import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils; import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -55,15 +55,13 @@ public class EntityListener implements Listener {
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTargetEntity(EntityTargetLivingEntityEvent event) public void onEntityTargetEntity(EntityTargetLivingEntityEvent event) {
{ if (!ExperienceConfig.getInstance().isEndermanEndermiteFarmingPrevented())
if(!ExperienceConfig.getInstance().isEndermanEndermiteFarmingPrevented())
return; return;
//Prevent entities from giving XP if they target endermite //Prevent entities from giving XP if they target endermite
if(event.getTarget() instanceof Endermite) if (event.getTarget() instanceof Endermite) {
{ if (event.getEntity().getMetadata(mcMMO.entityMetadataKey) == null || event.getEntity().getMetadata(mcMMO.entityMetadataKey).size() <= 0)
if(event.getEntity().getMetadata(mcMMO.entityMetadataKey) == null || event.getEntity().getMetadata(mcMMO.entityMetadataKey).size() <= 0)
event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
} }
} }
@ -71,17 +69,15 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event) { public void onEntityShootBow(EntityShootBowEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if(event.getEntity() instanceof Player) if (event.getEntity() instanceof Player) {
{
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
} }
@ -105,17 +101,15 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onProjectileLaunch(ProjectileLaunchEvent event) { public void onProjectileLaunch(ProjectileLaunchEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if(event.getEntity() instanceof Player) if (event.getEntity() instanceof Player) {
{
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
} }
@ -133,13 +127,12 @@ public class EntityListener implements Listener {
/** /**
* Monitor EntityChangeBlock events. * Monitor EntityChangeBlock events.
* *
* @param event * @param event The event to watch
* The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) { public void onEntityChangeBlock(EntityChangeBlockEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
Block block = event.getBlock(); Block block = event.getBlock();
@ -159,14 +152,12 @@ public class EntityListener implements Listener {
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) { if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
mcMMO.getPlaceStore().setFalse(block); mcMMO.getPlaceStore().setFalse(block);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue); entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
} } else if (isTracked) {
else if (isTracked) {
mcMMO.getPlaceStore().setTrue(block); mcMMO.getPlaceStore().setTrue(block);
} }
} else if ((block.getType() == Material.REDSTONE_ORE)) { } else if ((block.getType() == Material.REDSTONE_ORE)) {
return; return;
} } else {
else {
if (mcMMO.getPlaceStore().isTrue(block)) { if (mcMMO.getPlaceStore().isTrue(block)) {
mcMMO.getPlaceStore().setFalse(block); mcMMO.getPlaceStore().setFalse(block);
} }
@ -176,13 +167,12 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityDamageByEntity events that involve modifying the event. * Handle EntityDamageByEntity events that involve modifying the event.
* *
* @param event * @param event The event to watch
* The event to watch
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if (event instanceof FakeEntityDamageByEntityEvent) { if (event instanceof FakeEntityDamageByEntityEvent) {
@ -193,8 +183,7 @@ public class EntityListener implements Listener {
return; return;
} }
if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey)) if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey)) {
{
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -203,14 +192,12 @@ public class EntityListener implements Listener {
Entity defender = event.getEntity(); Entity defender = event.getEntity();
Entity attacker = event.getDamager(); Entity attacker = event.getDamager();
if(attacker instanceof Player) if (attacker instanceof Player) {
{
Player player = (Player) attacker; Player player = (Player) attacker;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
} }
@ -221,7 +208,7 @@ public class EntityListener implements Listener {
Player attackingPlayer = (Player) attacker; Player attackingPlayer = (Player) attacker;
if (event.getDamage(DamageModifier.ABSORPTION) > 0) { if (event.getDamage(DamageModifier.ABSORPTION) > 0) {
//If friendly fire is off don't allow players to hurt one another //If friendly fire is off don't allow players to hurt one another
if(!Config.getInstance().getPartyFriendlyFire()) if (!Config.getInstance().getPartyFriendlyFire())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -252,7 +239,6 @@ public class EntityListener implements Listener {
} }
if (Misc.isNPCEntity(attacker)) { if (Misc.isNPCEntity(attacker)) {
return; return;
} }
@ -263,15 +249,13 @@ public class EntityListener implements Listener {
if (projectileSource instanceof LivingEntity) { if (projectileSource instanceof LivingEntity) {
attacker = (LivingEntity) projectileSource; attacker = (LivingEntity) projectileSource;
} }
} } else if (attacker instanceof Tameable) {
else if (attacker instanceof Tameable) {
AnimalTamer animalTamer = ((Tameable) attacker).getOwner(); AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
if (animalTamer != null && ((OfflinePlayer) animalTamer).isOnline()) { if (animalTamer != null && ((OfflinePlayer) animalTamer).isOnline()) {
attacker = (Entity) animalTamer; attacker = (Entity) animalTamer;
} }
} } else if (attacker instanceof TNTPrimed && defender instanceof Player) {
else if (attacker instanceof TNTPrimed && defender instanceof Player) {
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) { if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) {
return; return;
} }
@ -292,7 +276,7 @@ public class EntityListener implements Listener {
} }
//Party Friendly Fire //Party Friendly Fire
if(!Config.getInstance().getPartyFriendlyFire()) if (!Config.getInstance().getPartyFriendlyFire())
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -305,17 +289,14 @@ public class EntityListener implements Listener {
/** /**
* This sets entity names back to whatever they are supposed to be * This sets entity names back to whatever they are supposed to be
*/ */
if(!(attacker instanceof Player) && defender instanceof Player) if (!(attacker instanceof Player) && defender instanceof Player) {
{ if (event.getFinalDamage() >= ((LivingEntity) defender).getHealth()) {
if(event.getFinalDamage() >= ((LivingEntity) defender).getHealth())
{
List<MetadataValue> metadataValue = attacker.getMetadata("mcMMO_oldName"); List<MetadataValue> metadataValue = attacker.getMetadata("mcMMO_oldName");
if(metadataValue.size() <= 0) if (metadataValue.size() <= 0)
return; return;
if(metadataValue != null) if (metadataValue != null) {
{
OldName oldName = (OldName) metadataValue.get(0); OldName oldName = (OldName) metadataValue.get(0);
attacker.setCustomName(oldName.asString()); attacker.setCustomName(oldName.asString());
attacker.setCustomNameVisible(false); attacker.setCustomNameVisible(false);
@ -327,22 +308,19 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityDamage events that involve modifying the event. * Handle EntityDamage events that involve modifying the event.
* *
* @param event * @param event The event to modify
* The event to modify
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if(event.getEntity() instanceof Player) if (event.getEntity() instanceof Player) {
{
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
} }
@ -408,19 +386,15 @@ public class EntityListener implements Listener {
mcMMOPlayer.actualizeRecentlyHurt(); mcMMOPlayer.actualizeRecentlyHurt();
} }
} } else if (livingEntity instanceof Tameable) {
else if (livingEntity instanceof Tameable) {
Tameable pet = (Tameable) livingEntity; Tameable pet = (Tameable) livingEntity;
AnimalTamer owner = pet.getOwner(); AnimalTamer owner = pet.getOwner();
if(owner instanceof Player) if (owner instanceof Player) {
{
Player player = (Player) owner; Player player = (Player) owner;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
} }
@ -493,13 +467,12 @@ public class EntityListener implements Listener {
/** /**
* Monitor EntityDeath events. * Monitor EntityDeath events.
* *
* @param event * @param event The event to watch
* The event to watch
*/ */
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeathLowest(EntityDeathEvent event) { public void onEntityDeathLowest(EntityDeathEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
@ -526,13 +499,12 @@ public class EntityListener implements Listener {
/** /**
* Monitor EntityDeath events. * Monitor EntityDeath events.
* *
* @param event * @param event The event to watch
* The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) { public void onEntityDeath(EntityDeathEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
@ -547,13 +519,12 @@ public class EntityListener implements Listener {
/** /**
* Monitor CreatureSpawn events. * Monitor CreatureSpawn events.
* *
* @param event * @param event The event to watch
* The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) { public void onCreatureSpawn(CreatureSpawnEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
@ -583,13 +554,12 @@ public class EntityListener implements Listener {
/** /**
* Handle ExplosionPrime events that involve modifying the event. * Handle ExplosionPrime events that involve modifying the event.
* *
* @param event * @param event The event to modify
* The event to modify
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) { public void onExplosionPrime(ExplosionPrimeEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -607,9 +577,8 @@ public class EntityListener implements Listener {
} }
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -623,13 +592,12 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityExplode events that involve modifying the event. * Handle EntityExplode events that involve modifying the event.
* *
* @param event * @param event The event to modify
* The event to modify
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) { public void onEnitityExplode(EntityExplodeEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -647,9 +615,8 @@ public class EntityListener implements Listener {
} }
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -664,13 +631,12 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityExplode events that involve modifying the event. * Handle EntityExplode events that involve modifying the event.
* *
* @param event * @param event The event to modify
* The event to modify
*/ */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityExplodeMonitor(EntityExplodeEvent event) { public void onEntityExplodeMonitor(EntityExplodeEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -685,13 +651,12 @@ public class EntityListener implements Listener {
/** /**
* Handle FoodLevelChange events that involve modifying the event. * Handle FoodLevelChange events that involve modifying the event.
* *
* @param event * @param event The event to modify
* The event to modify
*/ */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -703,9 +668,8 @@ public class EntityListener implements Listener {
Player player = (Player) entity; Player player = (Player) entity;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -789,13 +753,12 @@ public class EntityListener implements Listener {
/** /**
* Monitor EntityTame events. * Monitor EntityTame events.
* *
* @param event * @param event The event to watch
* The event to watch
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityTame(EntityTameEvent event) { public void onEntityTame(EntityTameEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if (event instanceof FakeEntityTameEvent) { if (event instanceof FakeEntityTameEvent) {
@ -805,9 +768,8 @@ public class EntityListener implements Listener {
Player player = (Player) event.getOwner(); Player player = (Player) event.getOwner();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -824,13 +786,12 @@ public class EntityListener implements Listener {
/** /**
* Handle EntityTarget events. * Handle EntityTarget events.
* *
* @param event * @param event The event to process
* The event to process
*/ */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event) { public void onEntityTarget(EntityTargetEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -843,9 +804,8 @@ public class EntityListener implements Listener {
Player player = (Player) target; Player player = (Player) target;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -867,13 +827,12 @@ public class EntityListener implements Listener {
* Handle PotionSplash events in order to fix broken Splash Potion of * Handle PotionSplash events in order to fix broken Splash Potion of
* Saturation. * Saturation.
* *
* @param event * @param event The event to process
* The event to process
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPotionSplash(PotionSplashEvent event) { public void onPotionSplash(PotionSplashEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) { for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) {
@ -891,7 +850,7 @@ public class EntityListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPigZapEvent(PigZapEvent event) { public void onPigZapEvent(PigZapEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) { if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) {

View File

@ -17,26 +17,26 @@ public class InteractionManager {
/** /**
* Registers subskills with the Interaction registration * Registers subskills with the Interaction registration
*
* @param abstractSubSkill the target subskill to register * @param abstractSubSkill the target subskill to register
*/ */
public static void registerSubSkill(AbstractSubSkill abstractSubSkill) public static void registerSubSkill(AbstractSubSkill abstractSubSkill) {
{
/* INIT MAPS */ /* INIT MAPS */
if(interactRegister == null) if (interactRegister == null)
interactRegister = new HashMap<>(); interactRegister = new HashMap<>();
if(subSkillList == null) if (subSkillList == null)
subSkillList = new ArrayList<>(); subSkillList = new ArrayList<>();
if(subSkillNameMap == null) if (subSkillNameMap == null)
subSkillNameMap = new HashMap<>(); subSkillNameMap = new HashMap<>();
//Store a unique copy of each subskill //Store a unique copy of each subskill
if(!subSkillList.contains(abstractSubSkill)) if (!subSkillList.contains(abstractSubSkill))
subSkillList.add(abstractSubSkill); subSkillList.add(abstractSubSkill);
//Init ArrayList //Init ArrayList
if(interactRegister.get(abstractSubSkill.getInteractType()) == null) if (interactRegister.get(abstractSubSkill.getInteractType()) == null)
interactRegister.put(abstractSubSkill.getInteractType(), new ArrayList<>()); interactRegister.put(abstractSubSkill.getInteractType(), new ArrayList<>());
//Registration array reference //Registration array reference
@ -48,33 +48,32 @@ public class InteractionManager {
String lowerCaseName = abstractSubSkill.getConfigKeyName().toLowerCase(); String lowerCaseName = abstractSubSkill.getConfigKeyName().toLowerCase();
//Register in name map //Register in name map
if(subSkillNameMap.get(lowerCaseName) == null) if (subSkillNameMap.get(lowerCaseName) == null)
subSkillNameMap.put(lowerCaseName, abstractSubSkill); subSkillNameMap.put(lowerCaseName, abstractSubSkill);
System.out.println("[mcMMO] registered subskill: "+ abstractSubSkill.getConfigKeyName()); System.out.println("[mcMMO] registered subskill: " + abstractSubSkill.getConfigKeyName());
} }
/** /**
* Grabs the registered abstract skill by its name * Grabs the registered abstract skill by its name
* Is not case sensitive * Is not case sensitive
*
* @param name name of subskill, not case sensitive * @param name name of subskill, not case sensitive
* @return null if the subskill is not registered * @return null if the subskill is not registered
*/ */
public static AbstractSubSkill getAbstractByName(String name) public static AbstractSubSkill getAbstractByName(String name) {
{
return subSkillNameMap.get(name.toLowerCase()); return subSkillNameMap.get(name.toLowerCase());
} }
/** /**
* Processes the associated Interactions for this event * Processes the associated Interactions for this event
*
* @param event target event * @param event target event
* @param plugin instance of mcMMO plugin * @param plugin instance of mcMMO plugin
* @param curInteractType the associated interaction type * @param curInteractType the associated interaction type
*/ */
public static void processEvent(Event event, mcMMO plugin, InteractType curInteractType) public static void processEvent(Event event, mcMMO plugin, InteractType curInteractType) {
{ for (Interaction interaction : interactRegister.get(curInteractType)) {
for(Interaction interaction : interactRegister.get(curInteractType))
{
interaction.doInteraction(event, plugin); interaction.doInteraction(event, plugin);
} }
} }
@ -82,25 +81,24 @@ public class InteractionManager {
/** /**
* Returns the list that contains all unique instances of registered Interaction classes * Returns the list that contains all unique instances of registered Interaction classes
* Interactions are extensions of abstract classes that represent modifying behaviours in Minecraft through events * Interactions are extensions of abstract classes that represent modifying behaviours in Minecraft through events
*
* @return the unique collection of all registered Interaction classes * @return the unique collection of all registered Interaction classes
*/ */
public static ArrayList<AbstractSubSkill> getSubSkillList() public static ArrayList<AbstractSubSkill> getSubSkillList() {
{
return subSkillList; return subSkillList;
} }
public static boolean hasSubSkill(String name) public static boolean hasSubSkill(String name) {
{
return getAbstractByName(name) != null; return getAbstractByName(name) != null;
} }
public static boolean hasSubSkill(SubSkillType subSkillType) public static boolean hasSubSkill(SubSkillType subSkillType) {
{
return hasSubSkill(subSkillType.getNiceNameNoSpaces(subSkillType)); return hasSubSkill(subSkillType.getNiceNameNoSpaces(subSkillType));
} }
/** /**
* Returns the associative map which contains all registered interactions * Returns the associative map which contains all registered interactions
*
* @return the interact register * @return the interact register
*/ */
public static HashMap<InteractType, ArrayList<Interaction>> getInteractRegister() { public static HashMap<InteractType, ArrayList<Interaction>> getInteractRegister() {

View File

@ -2,19 +2,19 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.config.skills.WorldBlacklist; import com.gmail.nossr50.core.config.skills.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.runnables.player.PlayerUpdateInventoryTask;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType; import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.events.fake.FakeBrewEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.runnables.player.PlayerUpdateInventoryTask;
import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy; import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy;
import com.gmail.nossr50.core.skills.primary.alchemy.AlchemyPotionBrewer; import com.gmail.nossr50.core.skills.primary.alchemy.AlchemyPotionBrewer;
import com.gmail.nossr50.core.util.ItemUtils; import com.gmail.nossr50.core.util.ItemUtils;
import com.gmail.nossr50.core.util.Permissions; import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.SkillUtils; import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.worldguard.WorldGuardManager; import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils; import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.events.fake.FakeBrewEvent;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -42,7 +42,7 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) { public void onInventoryOpen(InventoryOpenEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
@ -57,14 +57,14 @@ public class InventoryListener implements Listener {
return; return;
} }
if(!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() == 0) if (!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() == 0)
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata()); furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata());
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClose(InventoryCloseEvent event) { public void onInventoryClose(InventoryCloseEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
@ -85,7 +85,7 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceBurnEvent(FurnaceBurnEvent event) { public void onFurnaceBurnEvent(FurnaceBurnEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
Block furnaceBlock = event.getBlock(); Block furnaceBlock = event.getBlock();
@ -99,9 +99,8 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock); Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -115,7 +114,7 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) { public void onFurnaceSmeltEvent(FurnaceSmeltEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
Block furnaceBlock = event.getBlock(); Block furnaceBlock = event.getBlock();
@ -128,9 +127,8 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock); Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -144,7 +142,7 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceExtractEvent(FurnaceExtractEvent event) { public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
Block furnaceBlock = event.getBlock(); Block furnaceBlock = event.getBlock();
@ -156,9 +154,8 @@ public class InventoryListener implements Listener {
Player player = getPlayerFromFurnace(furnaceBlock); Player player = getPlayerFromFurnace(furnaceBlock);
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -173,18 +170,16 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryClickEventNormal(InventoryClickEvent event) { public void onInventoryClickEventNormal(InventoryClickEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return; return;
Inventory inventory = event.getInventory(); Inventory inventory = event.getInventory();
if(event.getWhoClicked() instanceof Player) if (event.getWhoClicked() instanceof Player) {
{
Player player = ((Player) event.getWhoClicked()).getPlayer(); Player player = ((Player) event.getWhoClicked()).getPlayer();
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory()); Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock != null) if (furnaceBlock != null) {
{
if (furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() > 0) if (furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() > 0)
furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p); furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p);
@ -211,9 +206,8 @@ public class InventoryListener implements Listener {
Player player = (Player) whoClicked; Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -251,8 +245,7 @@ public class InventoryListener implements Listener {
default: default:
return; return;
} }
} } else if (slot == InventoryType.SlotType.FUEL) {
else if (slot == InventoryType.SlotType.FUEL) {
boolean emptyClicked = AlchemyPotionBrewer.isEmpty(clicked); boolean emptyClicked = AlchemyPotionBrewer.isEmpty(clicked);
if (AlchemyPotionBrewer.isEmpty(cursor)) { if (AlchemyPotionBrewer.isEmpty(cursor)) {
@ -262,8 +255,7 @@ public class InventoryListener implements Listener {
} }
AlchemyPotionBrewer.scheduleCheck(player, stand); AlchemyPotionBrewer.scheduleCheck(player, stand);
} } else if (emptyClicked) {
else if (emptyClicked) {
if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) { if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
int amount = cursor.getAmount(); int amount = cursor.getAmount();
@ -274,8 +266,7 @@ public class InventoryListener implements Listener {
AlchemyPotionBrewer.scheduleUpdate(inventory); AlchemyPotionBrewer.scheduleUpdate(inventory);
AlchemyPotionBrewer.scheduleCheck(player, stand); AlchemyPotionBrewer.scheduleCheck(player, stand);
} } else if (click == ClickType.RIGHT) {
else if (click == ClickType.RIGHT) {
event.setCancelled(true); event.setCancelled(true);
ItemStack one = cursor.clone(); ItemStack one = cursor.clone();
@ -298,7 +289,7 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryDragEvent(InventoryDragEvent event) { public void onInventoryDragEvent(InventoryDragEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return; return;
Inventory inventory = event.getInventory(); Inventory inventory = event.getInventory();
@ -330,9 +321,8 @@ public class InventoryListener implements Listener {
Player player = (Player) whoClicked; Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -349,10 +339,9 @@ public class InventoryListener implements Listener {
// Apparently sometimes vanilla brewing beats our task listener to the actual brew. We handle this by cancelling the vanilla event and finishing our brew ourselves. // Apparently sometimes vanilla brewing beats our task listener to the actual brew. We handle this by cancelling the vanilla event and finishing our brew ourselves.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBrew(BrewEvent event) public void onBrew(BrewEvent event) {
{
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
if (event instanceof FakeBrewEvent) if (event instanceof FakeBrewEvent)
@ -367,7 +356,7 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) { public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getSource().getLocation().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getSource().getLocation().getWorld()))
return; return;
Inventory inventory = event.getDestination(); Inventory inventory = event.getDestination();
@ -415,7 +404,7 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraftItem(CraftItemEvent event) { public void onCraftItem(CraftItemEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getWhoClicked().getWorld()))
return; return;
final HumanEntity whoClicked = event.getWhoClicked(); final HumanEntity whoClicked = event.getWhoClicked();
@ -433,9 +422,8 @@ public class InventoryListener implements Listener {
Player player = (Player) whoClicked; Player player = (Player) whoClicked;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }

View File

@ -1,35 +1,35 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.chat.ChatManager; import com.gmail.nossr50.core.chat.ChatManager;
import com.gmail.nossr50.core.chat.ChatManagerFactory; import com.gmail.nossr50.core.chat.ChatManagerFactory;
import com.gmail.nossr50.core.chat.PartyChatManager; import com.gmail.nossr50.core.chat.PartyChatManager;
import com.gmail.nossr50.core.config.skills.Config; import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.config.skills.WorldBlacklist; import com.gmail.nossr50.core.config.skills.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.chat.ChatMode; import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.party.Party; import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.locale.LocaleLoader; import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.*;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.party.ShareHandler; import com.gmail.nossr50.core.party.ShareHandler;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.core.skills.child.salvage.SalvageManager;
import com.gmail.nossr50.core.skills.primary.fishing.FishingManager; import com.gmail.nossr50.core.skills.primary.fishing.FishingManager;
import com.gmail.nossr50.core.skills.primary.herbalism.HerbalismManager; import com.gmail.nossr50.core.skills.primary.herbalism.HerbalismManager;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager; import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.skills.primary.repair.Repair; import com.gmail.nossr50.core.skills.primary.repair.Repair;
import com.gmail.nossr50.core.skills.primary.repair.RepairManager; import com.gmail.nossr50.core.skills.primary.repair.RepairManager;
import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.core.skills.child.salvage.SalvageManager;
import com.gmail.nossr50.core.skills.primary.taming.TamingManager; import com.gmail.nossr50.core.skills.primary.taming.TamingManager;
import com.gmail.nossr50.util.*; import com.gmail.nossr50.core.util.*;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.skills.SkillUtils; import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.util.sounds.SoundManager; import com.gmail.nossr50.core.util.sounds.SoundManager;
import com.gmail.nossr50.core.util.sounds.SoundType; import com.gmail.nossr50.core.util.sounds.SoundType;
import com.gmail.nossr50.core.worldguard.WorldGuardManager; import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils; import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.*;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -63,15 +63,14 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) { public void onPlayerTeleport(PlayerTeleportEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -94,15 +93,14 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerDeathLowest(PlayerDeathEvent event) { public void onPlayerDeathLowest(PlayerDeathEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
String deathMessage = event.getDeathMessage(); String deathMessage = event.getDeathMessage();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(event.getEntity()))
if(!WorldGuardManager.getInstance().hasMainFlag(event.getEntity()))
return; return;
} }
@ -127,7 +125,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeathMonitor(PlayerDeathEvent event) { public void onPlayerDeathMonitor(PlayerDeathEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
boolean statLossEnabled = HardcoreManager.isStatLossEnabled(); boolean statLossEnabled = HardcoreManager.isStatLossEnabled();
@ -146,9 +144,8 @@ public class PlayerListener implements Listener {
Player killer = killedPlayer.getKiller(); Player killer = killedPlayer.getKiller();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(killedPlayer))
if(!WorldGuardManager.getInstance().hasMainFlag(killedPlayer))
return; return;
} }
@ -202,13 +199,12 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) { public void onPlayerDropItem(PlayerDropItemEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return; return;
} }
@ -233,15 +229,14 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerFishHighest(PlayerFishEvent event) { public void onPlayerFishHighest(PlayerFishEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -266,7 +261,7 @@ public class PlayerListener implements Listener {
if (Permissions.vanillaXpBoost(player, PrimarySkillType.FISHING)) { if (Permissions.vanillaXpBoost(player, PrimarySkillType.FISHING)) {
//Don't modify XP below vanilla values //Don't modify XP below vanilla values
if(fishingManager.handleVanillaXpBoost(event.getExpToDrop()) > 1) if (fishingManager.handleVanillaXpBoost(event.getExpToDrop()) > 1)
event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop())); event.setExpToDrop(fishingManager.handleVanillaXpBoost(event.getExpToDrop()));
} }
return; return;
@ -304,15 +299,14 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFishMonitor(PlayerFishEvent event) { public void onPlayerFishMonitor(PlayerFishEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -334,7 +328,7 @@ public class PlayerListener implements Listener {
return; return;
case CAUGHT_FISH: case CAUGHT_FISH:
if(fishingManager.exploitPrevention(event.getHook().getBoundingBox())) if (fishingManager.exploitPrevention(event.getHook().getBoundingBox()))
return; return;
fishingManager.handleFishing((Item) caught); fishingManager.handleFishing((Item) caught);
fishingManager.setFishingTarget(); fishingManager.setFishingTarget();
@ -363,17 +357,15 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickupItem(EntityPickupItemEvent event) { public void onPlayerPickupItem(EntityPickupItemEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
if(event.getEntity() instanceof Player) if (event.getEntity() instanceof Player) {
{
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -493,15 +485,14 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerInteractLowest(PlayerInteractEvent event) { public void onPlayerInteractLowest(PlayerInteractEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -547,8 +538,7 @@ public class PlayerListener implements Listener {
else if (miningManager.canDetonate()) { else if (miningManager.canDetonate()) {
if (type == Material.TNT) { if (type == Material.TNT) {
event.setCancelled(true); // Don't detonate the TNT if they're too close event.setCancelled(true); // Don't detonate the TNT if they're too close
} } else {
else {
miningManager.remoteDetonation(); miningManager.remoteDetonation();
} }
} }
@ -596,15 +586,14 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteractMonitor(PlayerInteractEvent event) { public void onPlayerInteractMonitor(PlayerInteractEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
Player player = event.getPlayer(); Player player = event.getPlayer();
/* WORLD GUARD MAIN FLAG CHECK */ /* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded()) if (WorldGuardUtils.isWorldGuardLoaded()) {
{ if (!WorldGuardManager.getInstance().hasMainFlag(player))
if(!WorldGuardManager.getInstance().hasMainFlag(player))
return; return;
} }
@ -617,7 +606,7 @@ public class PlayerListener implements Listener {
switch (event.getAction()) { switch (event.getAction()) {
case RIGHT_CLICK_BLOCK: case RIGHT_CLICK_BLOCK:
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) { if (player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
break; break;
} }
@ -675,7 +664,7 @@ public class PlayerListener implements Listener {
break; break;
case RIGHT_CLICK_AIR: case RIGHT_CLICK_AIR:
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) { if (player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
break; break;
} }
@ -714,11 +703,9 @@ public class PlayerListener implements Listener {
if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.WOLF)) { if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.WOLF)) {
tamingManager.summonWolf(); tamingManager.summonWolf();
} } else if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.OCELOT)) {
else if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.OCELOT)) {
tamingManager.summonOcelot(); tamingManager.summonOcelot();
} } else if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.HORSE)) {
else if (type == Config.getInstance().getTamingCOTWMaterial(EntityType.HORSE)) {
tamingManager.summonHorse(); tamingManager.summonHorse();
} }
@ -763,8 +750,7 @@ public class PlayerListener implements Listener {
chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY); chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.PARTY);
((PartyChatManager) chatManager).setParty(party); ((PartyChatManager) chatManager).setParty(party);
} } else if (mcMMOPlayer.isChatEnabled(ChatMode.ADMIN)) {
else if (mcMMOPlayer.isChatEnabled(ChatMode.ADMIN)) {
chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN); chatManager = ChatManagerFactory.getChatManager(plugin, ChatMode.ADMIN);
} }
@ -806,7 +792,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) { public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return; return;
if (!mcMMO.getHolidayManager().isAprilFirst()) { if (!mcMMO.getHolidayManager().isAprilFirst()) {

View File

@ -1,18 +1,18 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.config.skills.Config;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason; import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer; import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.PrimarySkillType; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent; import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent; import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -22,8 +22,7 @@ public class SelfListener implements Listener {
//Used in task scheduling and other things //Used in task scheduling and other things
private final mcMMO plugin; private final mcMMO plugin;
public SelfListener(mcMMO plugin) public SelfListener(mcMMO plugin) {
{
this.plugin = plugin; this.plugin = plugin;
} }
@ -33,14 +32,13 @@ public class SelfListener implements Listener {
PrimarySkillType skill = event.getSkill(); PrimarySkillType skill = event.getSkill();
//Players can gain multiple levels especially during xprate events //Players can gain multiple levels especially during xprate events
for(int i = 0; i < event.getLevelsGained(); i++) for (int i = 0; i < event.getLevelsGained(); i++) {
{
int previousLevelGained = event.getSkillLevel() - i; int previousLevelGained = event.getSkillLevel() - i;
//Send player skill unlock notifications //Send player skill unlock notifications
UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained); UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained);
} }
if(Config.getInstance().getScoreboardsEnabled()) if (Config.getInstance().getScoreboardsEnabled())
ScoreboardManager.handleLevelUp(player, skill); ScoreboardManager.handleLevelUp(player, skill);
if (!Config.getInstance().getLevelUpEffectsEnabled()) { if (!Config.getInstance().getLevelUpEffectsEnabled()) {
@ -54,13 +52,13 @@ public class SelfListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerXp(McMMOPlayerXpGainEvent event) { public void onPlayerXp(McMMOPlayerXpGainEvent event) {
if(Config.getInstance().getScoreboardsEnabled()) if (Config.getInstance().getScoreboardsEnabled())
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill()); ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onAbility(McMMOPlayerAbilityActivateEvent event) { public void onAbility(McMMOPlayerAbilityActivateEvent event) {
if(Config.getInstance().getScoreboardsEnabled()) if (Config.getInstance().getScoreboardsEnabled())
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill()); ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
} }
@ -71,23 +69,19 @@ public class SelfListener implements Listener {
PrimarySkillType primarySkillType = event.getSkill(); PrimarySkillType primarySkillType = event.getSkill();
//WorldGuard XP Check //WorldGuard XP Check
if(event.getXpGainReason() == XPGainReason.PVE || if (event.getXpGainReason() == XPGainReason.PVE ||
event.getXpGainReason() == XPGainReason.PVP || event.getXpGainReason() == XPGainReason.PVP ||
event.getXpGainReason() == XPGainReason.SHARED_PVE || event.getXpGainReason() == XPGainReason.SHARED_PVE ||
event.getXpGainReason() == XPGainReason.SHARED_PVP) event.getXpGainReason() == XPGainReason.SHARED_PVP) {
{ if (WorldGuardUtils.isWorldGuardLoaded()) {
if(WorldGuardUtils.isWorldGuardLoaded()) if (!WorldGuardManager.getInstance().hasXPFlag(player)) {
{
if(!WorldGuardManager.getInstance().hasXPFlag(player))
{
event.setRawXpGained(0); event.setRawXpGained(0);
event.setCancelled(true); event.setCancelled(true);
} }
} }
} }
if (event.getXpGainReason() == XPGainReason.COMMAND) if (event.getXpGainReason() == XPGainReason.COMMAND) {
{
return; return;
} }
@ -124,12 +118,10 @@ public class SelfListener implements Listener {
* Make sure players get a guaranteed minimum of XP * Make sure players get a guaranteed minimum of XP
*/ */
//If there is no guaranteed minimum proceed, otherwise only proceed if newValue would be higher than our guaranteed minimum //If there is no guaranteed minimum proceed, otherwise only proceed if newValue would be higher than our guaranteed minimum
if(guaranteedMinimum <= 0 || newValue > guaranteedMinimum) if (guaranteedMinimum <= 0 || newValue > guaranteedMinimum) {
{
if (newValue > 0) { if (newValue > 0) {
event.setRawXpGained(newValue); event.setRawXpGained(newValue);
} } else {
else {
event.setCancelled(true); event.setCancelled(true);
} }
} else { } else {

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.listeners; package com.gmail.nossr50.listeners;
import com.gmail.nossr50.core.config.skills.WorldBlacklist; import com.gmail.nossr50.core.config.skills.WorldBlacklist;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.core.data.blockmeta.conversion.BlockStoreConversionMain; import com.gmail.nossr50.core.data.blockmeta.conversion.BlockStoreConversionMain;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -31,7 +31,7 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onStructureGrow(StructureGrowEvent event) { public void onStructureGrow(StructureGrowEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return; return;
if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) { if (!mcMMO.getPlaceStore().isTrue(event.getLocation().getBlock())) {
@ -51,7 +51,7 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) { public void onWorldInit(WorldInitEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return; return;
World world = event.getWorld(); World world = event.getWorld();
@ -73,7 +73,7 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldUnload(WorldUnloadEvent event) { public void onWorldUnload(WorldUnloadEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return; return;
mcMMO.getPlaceStore().unloadWorld(event.getWorld()); mcMMO.getPlaceStore().unloadWorld(event.getWorld());
@ -87,7 +87,7 @@ public class WorldListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) { public void onChunkUnload(ChunkUnloadEvent event) {
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getWorld()))
return; return;
Chunk chunk = event.getChunk(); Chunk chunk = event.getChunk();

View File

@ -8,14 +8,13 @@ import com.gmail.nossr50.config.mods.ToolConfigManager;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig; import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
import com.gmail.nossr50.config.skills.repair.RepairConfigManager; import com.gmail.nossr50.config.skills.repair.RepairConfigManager;
import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager; import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
import com.gmail.nossr50.core.config.treasure.TreasureConfig;
import com.gmail.nossr50.core.config.skills.*; import com.gmail.nossr50.core.config.skills.*;
import com.gmail.nossr50.core.config.treasure.TreasureConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.data.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.core.data.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.core.data.database.DatabaseManager; import com.gmail.nossr50.core.data.database.DatabaseManager;
import com.gmail.nossr50.core.data.database.DatabaseManagerFactory; import com.gmail.nossr50.core.data.database.DatabaseManagerFactory;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.subskills.acrobatics.Roll;
import com.gmail.nossr50.core.util.*;
import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.core.party.PartyManager; import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.runnables.CheckDateTask; import com.gmail.nossr50.core.runnables.CheckDateTask;
import com.gmail.nossr50.core.runnables.SaveTimerTask; import com.gmail.nossr50.core.runnables.SaveTimerTask;
@ -26,24 +25,25 @@ import com.gmail.nossr50.core.runnables.player.ClearRegisteredXPGainTask;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.core.runnables.player.PowerLevelUpdatingTask; import com.gmail.nossr50.core.runnables.player.PowerLevelUpdatingTask;
import com.gmail.nossr50.core.runnables.skills.BleedTimerTask; import com.gmail.nossr50.core.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy; import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.child.ChildConfig; import com.gmail.nossr50.core.skills.child.ChildConfig;
import com.gmail.nossr50.core.skills.primary.repair.repairables.Repairable;
import com.gmail.nossr50.core.skills.primary.repair.repairables.RepairableManager;
import com.gmail.nossr50.core.skills.primary.repair.repairables.SimpleRepairableManager;
import com.gmail.nossr50.core.skills.child.salvage.salvageables.Salvageable; import com.gmail.nossr50.core.skills.child.salvage.salvageables.Salvageable;
import com.gmail.nossr50.core.skills.child.salvage.salvageables.SalvageableManager; import com.gmail.nossr50.core.skills.child.salvage.salvageables.SalvageableManager;
import com.gmail.nossr50.core.skills.child.salvage.salvageables.SimpleSalvageableManager; import com.gmail.nossr50.core.skills.child.salvage.salvageables.SimpleSalvageableManager;
import com.gmail.nossr50.util.*; import com.gmail.nossr50.core.skills.primary.alchemy.Alchemy;
import com.gmail.nossr50.core.data.blockmeta.chunkmeta.ChunkManager; import com.gmail.nossr50.core.skills.primary.repair.repairables.Repairable;
import com.gmail.nossr50.core.data.blockmeta.chunkmeta.ChunkManagerFactory; import com.gmail.nossr50.core.skills.primary.repair.repairables.RepairableManager;
import com.gmail.nossr50.core.skills.primary.repair.repairables.SimpleRepairableManager;
import com.gmail.nossr50.core.skills.subskills.acrobatics.Roll;
import com.gmail.nossr50.core.util.*;
import com.gmail.nossr50.core.util.commands.CommandRegistrationManager; import com.gmail.nossr50.core.util.commands.CommandRegistrationManager;
import com.gmail.nossr50.core.util.experience.FormulaManager; import com.gmail.nossr50.core.util.experience.FormulaManager;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.util.skills.RankUtils; import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.upgrade.UpgradeManager; import com.gmail.nossr50.core.util.upgrade.UpgradeManager;
import com.gmail.nossr50.core.worldguard.WorldGuardManager; import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.util.*;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import net.shatteredlands.shatt.backup.ZipLibrary; import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bstats.bukkit.Metrics; import org.bstats.bukkit.Metrics;
@ -61,41 +61,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class mcMMO extends JavaPlugin { public class mcMMO extends JavaPlugin {
/* Managers */
private static ChunkManager placeStore;
private static RepairableManager repairableManager;
private static SalvageableManager salvageableManager;
private static ModManager modManager;
private static DatabaseManager databaseManager;
private static FormulaManager formulaManager;
private static HolidayManager holidayManager;
private static UpgradeManager upgradeManager;
/* Blacklist */
private static WorldBlacklist worldBlacklist;
/* File Paths */
private static String mainDirectory;
private static String flatFileDirectory;
private static String usersFile;
private static String modDirectory;
public static mcMMO p;
// Jar Stuff
public static File mcmmo;
/* Plugin Checks */
private static boolean healthBarPluginEnabled;
// Config Validation Check
public boolean noErrorsInConfigFiles = true;
// XP Event Check
private boolean xpEventEnabled;
private static boolean isRetroModeEnabled;
/* Metadata Values */ /* Metadata Values */
public final static String entityMetadataKey = "mcMMO: Spawned Entity"; public final static String entityMetadataKey = "mcMMO: Spawned Entity";
public final static String blockMetadataKey = "mcMMO: Piston Tracking"; public final static String blockMetadataKey = "mcMMO: Piston Tracking";
@ -115,8 +80,105 @@ public class mcMMO extends JavaPlugin {
public final static String greenThumbDataKey = "mcMMO: Green Thumb"; public final static String greenThumbDataKey = "mcMMO: Green Thumb";
public final static String databaseCommandKey = "mcMMO: Processing Database Command"; public final static String databaseCommandKey = "mcMMO: Processing Database Command";
public final static String bredMetadataKey = "mcMMO: Bred Animal"; public final static String bredMetadataKey = "mcMMO: Bred Animal";
public static mcMMO p;
// Jar Stuff
public static File mcmmo;
public static FixedMetadataValue metadataValue; public static FixedMetadataValue metadataValue;
/* Managers */
private static ChunkManager placeStore;
private static RepairableManager repairableManager;
private static SalvageableManager salvageableManager;
private static ModManager modManager;
private static DatabaseManager databaseManager;
private static FormulaManager formulaManager;
private static HolidayManager holidayManager;
private static UpgradeManager upgradeManager;
/* Blacklist */
private static WorldBlacklist worldBlacklist;
/* File Paths */
private static String mainDirectory;
private static String flatFileDirectory;
private static String usersFile;
private static String modDirectory;
/* Plugin Checks */
private static boolean healthBarPluginEnabled;
private static boolean isRetroModeEnabled;
// Config Validation Check
public boolean noErrorsInConfigFiles = true;
// XP Event Check
private boolean xpEventEnabled;
public static String getMainDirectory() {
return mainDirectory;
}
public static String getFlatFileDirectory() {
return flatFileDirectory;
}
public static String getUsersFilePath() {
return usersFile;
}
public static String getModDirectory() {
return modDirectory;
}
public static FormulaManager getFormulaManager() {
return formulaManager;
}
public static HolidayManager getHolidayManager() {
return holidayManager;
}
public static ChunkManager getPlaceStore() {
return placeStore;
}
public static RepairableManager getRepairableManager() {
return repairableManager;
}
public static SalvageableManager getSalvageableManager() {
return salvageableManager;
}
public static DatabaseManager getDatabaseManager() {
return databaseManager;
}
@Deprecated
public static void setDatabaseManager(DatabaseManager databaseManager) {
mcMMO.databaseManager = databaseManager;
}
public static ModManager getModManager() {
return modManager;
}
public static UpgradeManager getUpgradeManager() {
return upgradeManager;
}
public static boolean isHealthBarPluginEnabled() {
return healthBarPluginEnabled;
}
/**
* Checks if this plugin is using retro mode
* Retro mode is a 0-1000 skill system
* Standard mode is scaled for 1-100
*
* @return true if retro mode is enabled
*/
public static boolean isRetroModeEnabled() {
return isRetroModeEnabled;
}
public static WorldBlacklist getWorldBlacklist() {
return worldBlacklist;
}
/** /**
* Things to be run when the plugin is enabled. * Things to be run when the plugin is enabled.
@ -192,23 +254,21 @@ public class mcMMO extends JavaPlugin {
Metrics metrics; Metrics metrics;
if(Config.getInstance().getIsMetricsEnabled()) { if (Config.getInstance().getIsMetricsEnabled()) {
metrics = new Metrics(this); metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SimplePie("version", () -> getDescription().getVersion())); metrics.addCustomChart(new Metrics.SimplePie("version", () -> getDescription().getVersion()));
if(Config.getInstance().getIsRetroMode()) if (Config.getInstance().getIsRetroMode())
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Standard")); metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Standard"));
else else
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Retro")); metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Retro"));
} }
} } catch (Throwable t) {
catch (Throwable t) {
getLogger().severe("There was an error while enabling mcMMO!"); getLogger().severe("There was an error while enabling mcMMO!");
if (!(t instanceof ExceptionInInitializerError)) { if (!(t instanceof ExceptionInInitializerError)) {
t.printStackTrace(); t.printStackTrace();
} } else {
else {
getLogger().info("Please do not replace the mcMMO jar while the server is running."); getLogger().info("Please do not replace the mcMMO jar while the server is running.");
} }
@ -220,9 +280,8 @@ public class mcMMO extends JavaPlugin {
} }
@Override @Override
public void onLoad() public void onLoad() {
{ if (getServer().getPluginManager().getPlugin("WorldGuard") != null)
if(getServer().getPluginManager().getPlugin("WorldGuard") != null)
WorldGuardManager.getInstance().registerFlags(); WorldGuardManager.getInstance().registerFlags();
} }
@ -238,15 +297,16 @@ public class mcMMO extends JavaPlugin {
PartyManager.saveParties(); // Save our parties PartyManager.saveParties(); // Save our parties
//TODO: Needed? //TODO: Needed?
if(Config.getInstance().getScoreboardsEnabled()) if (Config.getInstance().getScoreboardsEnabled())
ScoreboardManager.teardownAll(); ScoreboardManager.teardownAll();
formulaManager.saveFormula(); formulaManager.saveFormula();
holidayManager.saveAnniversaryFiles(); holidayManager.saveAnniversaryFiles();
placeStore.saveAll(); // Save our metadata placeStore.saveAll(); // Save our metadata
placeStore.cleanUp(); // Cleanup empty metadata stores placeStore.cleanUp(); // Cleanup empty metadata stores
} catch (NullPointerException e) {
e.printStackTrace();
} }
catch (NullPointerException e) { e.printStackTrace(); }
debug("Canceling all tasks..."); debug("Canceling all tasks...");
getServer().getScheduler().cancelTasks(this); // This removes our tasks getServer().getScheduler().cancelTasks(this); // This removes our tasks
@ -257,16 +317,13 @@ public class mcMMO extends JavaPlugin {
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away. // Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
try { try {
ZipLibrary.mcMMOBackup(); ZipLibrary.mcMMOBackup();
} } catch (IOException e) {
catch (IOException e) {
getLogger().severe(e.toString()); getLogger().severe(e.toString());
} } catch (Throwable e) {
catch (Throwable e) {
if (e instanceof NoClassDefFoundError) { if (e instanceof NoClassDefFoundError) {
getLogger().severe("Backup class not found!"); getLogger().severe("Backup class not found!");
getLogger().info("Please do not replace the mcMMO jar while the server is running."); getLogger().info("Please do not replace the mcMMO jar while the server is running.");
} } else {
else {
getLogger().severe(e.toString()); getLogger().severe(e.toString());
} }
} }
@ -276,22 +333,6 @@ public class mcMMO extends JavaPlugin {
debug("Was disabled."); // How informative! debug("Was disabled."); // How informative!
} }
public static String getMainDirectory() {
return mainDirectory;
}
public static String getFlatFileDirectory() {
return flatFileDirectory;
}
public static String getUsersFilePath() {
return usersFile;
}
public static String getModDirectory() {
return modDirectory;
}
public boolean isXPEventEnabled() { public boolean isXPEventEnabled() {
return xpEventEnabled; return xpEventEnabled;
} }
@ -308,47 +349,6 @@ public class mcMMO extends JavaPlugin {
getLogger().info("[Debug] " + message); getLogger().info("[Debug] " + message);
} }
public static FormulaManager getFormulaManager() {
return formulaManager;
}
public static HolidayManager getHolidayManager() {
return holidayManager;
}
public static ChunkManager getPlaceStore() {
return placeStore;
}
public static RepairableManager getRepairableManager() {
return repairableManager;
}
public static SalvageableManager getSalvageableManager() {
return salvageableManager;
}
public static DatabaseManager getDatabaseManager() {
return databaseManager;
}
public static ModManager getModManager() {
return modManager;
}
public static UpgradeManager getUpgradeManager() {
return upgradeManager;
}
@Deprecated
public static void setDatabaseManager(DatabaseManager databaseManager) {
mcMMO.databaseManager = databaseManager;
}
public static boolean isHealthBarPluginEnabled() {
return healthBarPluginEnabled;
}
/** /**
* Setup the various storage file paths * Setup the various storage file paths
*/ */
@ -475,8 +475,7 @@ public class mcMMO extends JavaPlugin {
* Acrobatics skills * Acrobatics skills
*/ */
if(CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS)) if (CoreSkillsConfig.getInstance().isPrimarySkillEnabled(PrimarySkillType.ACROBATICS)) {
{
System.out.println("[mcMMO]" + " enabling Acrobatics Skills"); System.out.println("[mcMMO]" + " enabling Acrobatics Skills");
//TODO: Should do this differently //TODO: Should do this differently
@ -510,8 +509,7 @@ public class mcMMO extends JavaPlugin {
if (purgeIntervalTicks == 0) { if (purgeIntervalTicks == 0) {
new UserPurgeTask().runTaskLaterAsynchronously(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. new UserPurgeTask().runTaskLaterAsynchronously(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
} } else if (purgeIntervalTicks > 0) {
else if (purgeIntervalTicks > 0) {
new UserPurgeTask().runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks); new UserPurgeTask().runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks);
} }
@ -520,8 +518,7 @@ public class mcMMO extends JavaPlugin {
if (kickIntervalTicks == 0) { if (kickIntervalTicks == 0) {
new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
} } else if (kickIntervalTicks > 0) {
else if (kickIntervalTicks > 0) {
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks); new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
} }
@ -564,18 +561,4 @@ public class mcMMO extends JavaPlugin {
InputStream in = getResource(fileName); InputStream in = getResource(fileName);
return in == null ? null : new InputStreamReader(in, Charsets.UTF_8); return in == null ? null : new InputStreamReader(in, Charsets.UTF_8);
} }
/**
* Checks if this plugin is using retro mode
* Retro mode is a 0-1000 skill system
* Standard mode is scaled for 1-100
* @return true if retro mode is enabled
*/
public static boolean isRetroModeEnabled() {
return isRetroModeEnabled;
}
public static WorldBlacklist getWorldBlacklist() {
return worldBlacklist;
}
} }

View File

@ -14,114 +14,6 @@ import java.util.Map.Entry;
public class PotionConfigGenerator { public class PotionConfigGenerator {
public static class Ingredient {
public Material mat;
public int data;
public String name;
public Ingredient(Material mat) {
this.mat = mat;
this.data = 0;
name = mat.name();
}
}
public static class WriteablePotion {
public String name;
public Material mat;
public PotionData data;
public PotionEffect effect;
public String baseName;
public WriteablePotion(PotionData data) {
this(Material.POTION, data);
}
public WriteablePotion(Material type, PotionData data) {
this(type, data, null, getMCName(data.getType()));
}
public WriteablePotion(Material mat, PotionType type, PotionEffect effect, String baseName) {
this(mat, new PotionData(type, false, false), effect, baseName);
}
public WriteablePotion(Material type, PotionData data, PotionEffect effect, String baseName) {
this.data = data;
this.effect = effect;
this.mat = type;
this.baseName = baseName;
this.name = "POTION_OF_" + baseName;
if (mat == Material.SPLASH_POTION) {
this.name = "SPLASH_" + this.name;
}
if (mat == Material.LINGERING_POTION) {
this.name = "LINGERING_" + this.name;
}
if (data.isExtended()) {
this.name += "_EXTENDED";
}
if (data.isUpgraded()) {
this.name += "_II";
}
}
public WriteablePotion(PotionType type) {
this(new PotionData(type, false, false));
}
public WriteablePotion(Material mat, PotionType type) {
this(mat, new PotionData(type, false, false));
}
private static String getMCName(PotionType type) {
switch (type) {
case INSTANT_DAMAGE :
return "HARMING";
case INSTANT_HEAL :
return "HEALING";
case JUMP :
return "LEAPING";
case REGEN :
return "REGENERATION";
case SPEED :
return "SWIFTNESS";
case UNCRAFTABLE :
return "EMPTY";
case LUCK :
case MUNDANE :
case NIGHT_VISION :
case POISON :
case INVISIBILITY :
case SLOWNESS :
case AWKWARD :
case STRENGTH :
case THICK :
case FIRE_RESISTANCE :
case WATER :
case WATER_BREATHING :
case WEAKNESS :
case TURTLE_MASTER:
case SLOW_FALLING:
return type.name();
default :
return "";
}
}
public int hashCode() {
return name.hashCode();
}
public boolean equals(Object obj) {
if (!(obj instanceof WriteablePotion)) {
return false;
}
return name.equals(((WriteablePotion) obj).name);
}
}
public static void main(String[] args) { public static void main(String[] args) {
Map<WriteablePotion, Map<Ingredient, WriteablePotion>> vanillaPotions = new HashMap<>(); Map<WriteablePotion, Map<Ingredient, WriteablePotion>> vanillaPotions = new HashMap<>();
populateVanillaPotions(vanillaPotions); populateVanillaPotions(vanillaPotions);
@ -250,59 +142,59 @@ public class PotionConfigGenerator {
private static String getName(PotionEffectType type) { private static String getName(PotionEffectType type) {
switch (type.getId()) { switch (type.getId()) {
case 1 : case 1:
return "SPEED"; return "SPEED";
case 2 : case 2:
return "SLOW"; return "SLOW";
case 3 : case 3:
return "FAST_DIGGING"; return "FAST_DIGGING";
case 4 : case 4:
return "SLOW_DIGGING"; return "SLOW_DIGGING";
case 5 : case 5:
return "INCREASE_DAMAGE"; return "INCREASE_DAMAGE";
case 6 : case 6:
return "HEAL"; return "HEAL";
case 7 : case 7:
return "HARM"; return "HARM";
case 8 : case 8:
return "JUMP"; return "JUMP";
case 9 : case 9:
return "CONFUSION"; return "CONFUSION";
case 10 : case 10:
return "REGENERATION"; return "REGENERATION";
case 11 : case 11:
return "DAMAGE_RESISTANCE"; return "DAMAGE_RESISTANCE";
case 12 : case 12:
return "FIRE_RESISTANCE"; return "FIRE_RESISTANCE";
case 13 : case 13:
return "WATER_BREATHING"; return "WATER_BREATHING";
case 14 : case 14:
return "INVISIBILITY"; return "INVISIBILITY";
case 15 : case 15:
return "BLINDNESS"; return "BLINDNESS";
case 16 : case 16:
return "NIGHT_VISION"; return "NIGHT_VISION";
case 17 : case 17:
return "HUNGER"; return "HUNGER";
case 18 : case 18:
return "WEAKNESS"; return "WEAKNESS";
case 19 : case 19:
return "POISON"; return "POISON";
case 20 : case 20:
return "WITHER"; return "WITHER";
case 21 : case 21:
return "HEALTH_BOOST"; return "HEALTH_BOOST";
case 22 : case 22:
return "ABSORPTION"; return "ABSORPTION";
case 23 : case 23:
return "SATURATION"; return "SATURATION";
case 24 : case 24:
return "GLOWING"; return "GLOWING";
case 25 : case 25:
return "LEVITATION"; return "LEVITATION";
case 26 : case 26:
return "LUCK"; return "LUCK";
case 27 : case 27:
return "UNLUCK"; return "UNLUCK";
case 28: case 28:
return "SLOW_FALLING"; return "SLOW_FALLING";
@ -310,7 +202,7 @@ public class PotionConfigGenerator {
return "CONDUIT_POWER"; return "CONDUIT_POWER";
case 30: case 30:
return "DOLPHINS_GRACE"; return "DOLPHINS_GRACE";
default : default:
return "UNKNOWN_EFFECT_TYPE_" + type.getId(); return "UNKNOWN_EFFECT_TYPE_" + type.getId();
} }
} }
@ -348,9 +240,9 @@ public class PotionConfigGenerator {
private static void getChildren(WriteablePotion current, HashMap<Ingredient, WriteablePotion> children) { private static void getChildren(WriteablePotion current, HashMap<Ingredient, WriteablePotion> children) {
switch (current.data.getType()) { switch (current.data.getType()) {
case WATER : case WATER:
assert(!current.data.isExtended()); assert (!current.data.isExtended());
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
children.put(new Ingredient(Material.NETHER_WART), new WriteablePotion(current.mat, PotionType.AWKWARD)); children.put(new Ingredient(Material.NETHER_WART), new WriteablePotion(current.mat, PotionType.AWKWARD));
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.WEAKNESS)); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.WEAKNESS));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, PotionType.MUNDANE)); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, PotionType.MUNDANE));
@ -363,9 +255,9 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.GLISTERING_MELON_SLICE), new WriteablePotion(current.mat, PotionType.MUNDANE)); children.put(new Ingredient(Material.GLISTERING_MELON_SLICE), new WriteablePotion(current.mat, PotionType.MUNDANE));
children.put(new Ingredient(Material.GHAST_TEAR), new WriteablePotion(current.mat, PotionType.MUNDANE)); children.put(new Ingredient(Material.GHAST_TEAR), new WriteablePotion(current.mat, PotionType.MUNDANE));
return; return;
case AWKWARD : case AWKWARD:
assert(!current.data.isExtended()); assert (!current.data.isExtended());
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
children.put(new Ingredient(Material.GOLDEN_CARROT), new WriteablePotion(current.mat, PotionType.NIGHT_VISION)); children.put(new Ingredient(Material.GOLDEN_CARROT), new WriteablePotion(current.mat, PotionType.NIGHT_VISION));
children.put(new Ingredient(Material.RABBIT_FOOT), new WriteablePotion(current.mat, PotionType.JUMP)); children.put(new Ingredient(Material.RABBIT_FOOT), new WriteablePotion(current.mat, PotionType.JUMP));
children.put(new Ingredient(Material.MAGMA_CREAM), new WriteablePotion(current.mat, PotionType.FIRE_RESISTANCE)); children.put(new Ingredient(Material.MAGMA_CREAM), new WriteablePotion(current.mat, PotionType.FIRE_RESISTANCE));
@ -396,8 +288,8 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.FERN), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SATURATION, (int) (8 * mod), 0), "SATURATION")); children.put(new Ingredient(Material.FERN), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.SATURATION, (int) (8 * mod), 0), "SATURATION"));
children.put(new Ingredient(Material.APPLE), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HEALTH_BOOST, (int) (1800 * mod), 0), "HEALTH_BOOST")); children.put(new Ingredient(Material.APPLE), new WriteablePotion(current.mat, PotionType.UNCRAFTABLE, new PotionEffect(PotionEffectType.HEALTH_BOOST, (int) (1800 * mod), 0), "HEALTH_BOOST"));
return; return;
case FIRE_RESISTANCE : case FIRE_RESISTANCE:
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
if (current.data.isExtended()) { if (current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.SLOWNESS, true, false))); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.SLOWNESS, true, false)));
} else { } else {
@ -405,14 +297,14 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case INSTANT_DAMAGE : case INSTANT_DAMAGE:
assert(!current.data.isExtended()); assert (!current.data.isExtended());
if (!current.data.isUpgraded()) { if (!current.data.isUpgraded()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true))); children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
} }
return; return;
case INSTANT_HEAL : case INSTANT_HEAL:
assert(!current.data.isExtended()); assert (!current.data.isExtended());
if (!current.data.isUpgraded()) { if (!current.data.isUpgraded()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE)); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true))); children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
@ -420,21 +312,21 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true))); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true)));
} }
return; return;
case INVISIBILITY : case INVISIBILITY:
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
if (!current.data.isExtended()) { if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case JUMP : case JUMP:
if (!current.data.isUpgraded() && !current.data.isExtended()) { if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS)); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true))); children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case NIGHT_VISION : case NIGHT_VISION:
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
if (!current.data.isExtended()) { if (!current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INVISIBILITY)); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INVISIBILITY));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
@ -442,7 +334,7 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INVISIBILITY, true, false))); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INVISIBILITY, true, false)));
} }
return; return;
case POISON : case POISON:
if (!current.data.isUpgraded() && !current.data.isExtended()) { if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE)); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true))); children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
@ -451,25 +343,25 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true))); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.INSTANT_DAMAGE, false, true)));
} }
return; return;
case REGEN : case REGEN:
if (!current.data.isUpgraded() && !current.data.isExtended()) { if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true))); children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case SLOWNESS : case SLOWNESS:
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
if (!current.data.isExtended()) { if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case SLOW_FALLING : case SLOW_FALLING:
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
if (!current.data.isExtended()) { if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case SPEED : case SPEED:
if (!current.data.isUpgraded() && !current.data.isExtended()) { if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS)); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.SLOWNESS));
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true))); children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
@ -478,7 +370,7 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.SLOWNESS, true, false))); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, new PotionData(PotionType.SLOWNESS, true, false)));
} }
return; return;
case STRENGTH : case STRENGTH:
if (!current.data.isUpgraded() && !current.data.isExtended()) { if (!current.data.isUpgraded() && !current.data.isExtended()) {
children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true))); children.put(new Ingredient(Material.GLOWSTONE_DUST), new WriteablePotion(current.mat, new PotionData(current.data.getType(), false, true)));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
@ -490,28 +382,28 @@ public class PotionConfigGenerator {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case WATER_BREATHING : case WATER_BREATHING:
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
if (!current.data.isExtended()) { if (!current.data.isExtended()) {
children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE)); children.put(new Ingredient(Material.FERMENTED_SPIDER_EYE), new WriteablePotion(current.mat, PotionType.INSTANT_DAMAGE));
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case WEAKNESS : case WEAKNESS:
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
if (!current.data.isExtended()) { if (!current.data.isExtended()) {
children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false))); children.put(new Ingredient(Material.REDSTONE), new WriteablePotion(current.mat, new PotionData(current.data.getType(), true, false)));
} }
return; return;
case LUCK : case LUCK:
case MUNDANE : case MUNDANE:
case THICK : case THICK:
case UNCRAFTABLE : case UNCRAFTABLE:
assert(!current.data.isExtended()); assert (!current.data.isExtended());
assert(!current.data.isUpgraded()); assert (!current.data.isUpgraded());
return; return;
default : default:
assert(false); assert (false);
break; break;
} }
} }
@ -620,4 +512,113 @@ public class PotionConfigGenerator {
} }
} }
} }
public static class Ingredient {
public Material mat;
public int data;
public String name;
public Ingredient(Material mat) {
this.mat = mat;
this.data = 0;
name = mat.name();
}
}
public static class WriteablePotion {
public String name;
public Material mat;
public PotionData data;
public PotionEffect effect;
public String baseName;
public WriteablePotion(PotionData data) {
this(Material.POTION, data);
}
public WriteablePotion(Material type, PotionData data) {
this(type, data, null, getMCName(data.getType()));
}
public WriteablePotion(Material mat, PotionType type, PotionEffect effect, String baseName) {
this(mat, new PotionData(type, false, false), effect, baseName);
}
public WriteablePotion(Material type, PotionData data, PotionEffect effect, String baseName) {
this.data = data;
this.effect = effect;
this.mat = type;
this.baseName = baseName;
this.name = "POTION_OF_" + baseName;
if (mat == Material.SPLASH_POTION) {
this.name = "SPLASH_" + this.name;
}
if (mat == Material.LINGERING_POTION) {
this.name = "LINGERING_" + this.name;
}
if (data.isExtended()) {
this.name += "_EXTENDED";
}
if (data.isUpgraded()) {
this.name += "_II";
}
}
public WriteablePotion(PotionType type) {
this(new PotionData(type, false, false));
}
public WriteablePotion(Material mat, PotionType type) {
this(mat, new PotionData(type, false, false));
}
private static String getMCName(PotionType type) {
switch (type) {
case INSTANT_DAMAGE:
return "HARMING";
case INSTANT_HEAL:
return "HEALING";
case JUMP:
return "LEAPING";
case REGEN:
return "REGENERATION";
case SPEED:
return "SWIFTNESS";
case UNCRAFTABLE:
return "EMPTY";
case LUCK:
case MUNDANE:
case NIGHT_VISION:
case POISON:
case INVISIBILITY:
case SLOWNESS:
case AWKWARD:
case STRENGTH:
case THICK:
case FIRE_RESISTANCE:
case WATER:
case WATER_BREATHING:
case WEAKNESS:
case TURTLE_MASTER:
case SLOW_FALLING:
return type.name();
default:
return "";
}
}
public int hashCode() {
return name.hashCode();
}
public boolean equals(Object obj) {
if (!(obj instanceof WriteablePotion)) {
return false;
}
return name.equals(((WriteablePotion) obj).name);
}
}
} }

View File

@ -9,8 +9,8 @@
# #
##### #####
Salvage: Salvage:
- Fishing - Fishing
- Repair - Repair
Smelting: Smelting:
- Mining - Mining
- Repair - Repair

Some files were not shown because too many files have changed in this diff Show More