Merge upstream into fixed kotlin script changes.

Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
This commit is contained in:
Gabriel Harris-Rouquette 2019-02-16 18:58:54 -08:00
commit a9e81602b4
No known key found for this signature in database
GPG Key ID: F34C08E5B2D67A0A
503 changed files with 12353 additions and 11568 deletions

View File

@ -8,9 +8,14 @@ Key:
- Removal
Version 2.2.0
Salvage config entries are no longer case sensitive
mcMMO has a new config system (WIP)
mcMMO for Bukkit no longer requires Spigot in order to play, you can now use Bukkit instead (WIP)
mcMMO is now abstracted from the Bukkit API in order to support more platforms (WIP)
mcMMO has changed from using maven to gradle!
mcMMO is now a gradle project (this makes it much easier for us to support older versions of MC and other APIs)
Version 2.1.12
Salvage config entries are no longer case sensitive
Fixed a bug where Fishing was not rewarding vanilla XP orbs
Version 2.1.11

View File

@ -30,6 +30,7 @@ object Config {
const val jdbc = "${Deps.Groups.tomcat}:${Deps.Modules.jdbc}:${Versions.jdbc}"
const val juli = "${Deps.Groups.tomcat}:${Deps.Modules.juli}:${Versions.jdbc}"
const val junitDep = "${Deps.Groups.junit}:${Deps.Modules.junit}:${Versions.junit}"
const val flowmath = "${Deps.Groups.flowpowered}:${Deps.Modules.flowmath}:${Versions.flowmath}"
object Bukkit {
object `1_8` {
@ -111,6 +112,7 @@ object Deps {
const val tomcat = "org.apache.tomcat"
const val junit = "junit"
const val checker = "org.checkerframework"
const val flowpowered = "com.flowpowered"
}
object Modules {
@ -137,6 +139,7 @@ object Deps {
const val juli = "tomcat-juli"
const val junit = "junit"
const val checker = "checker-qual"
const val flowmath = "flow-math"
}
}

View File

@ -1,5 +1,6 @@
object Versions {
const val configurate = "3.6" // Latest configurate
const val flowmath = "1.0.4-SNAPSHOT"
const val bukkit18 = "1.8.8-R0.1-SNAPSHOT" // Last bukkit 1.8.8
const val bukkit112 = "1.12.2-R0.1-SNAPSHOT" // Last bukkit 1.12.2
const val bukkit113 = "1.13.2-R0.1-SNAPSHOT" // Latest bukkit

View File

@ -5,7 +5,7 @@ plugins {
}
dependencies {
compileOnly(Bukkit.api) // Spigot API
compileOnly(Bukkit.api) // Bukkit API
compileOnly(Bukkit.nms)
compileOnly(Bukkit.wgLegacy) // WorldGuard

View File

@ -51,4 +51,3 @@ dependencies {
exclude(group = Shadow.Exclude.bstats)
}
}

View File

@ -1,21 +0,0 @@
package com.gmail.nossr50.chat;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import org.bukkit.plugin.Plugin;
public class AdminChatManager extends ChatManager {
protected AdminChatManager(Plugin plugin) {
super(plugin, Config.getInstance().getAdminDisplayNames(), Config.getInstance().getAdminChatPrefix());
}
@Override
public void handleChat(String senderName, String displayName, String message, boolean isAsync) {
handleChat(new McMMOAdminChatEvent(plugin, senderName, displayName, message, isAsync));
}
@Override
protected void sendMessage() {
plugin.getServer().broadcast(message, "mcmmo.chat.adminchat");
}
}

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.FlatfileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.data.database.FlatfileDatabaseManager;
import com.gmail.nossr50.core.data.database.SQLDatabaseManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -21,7 +21,7 @@ public class MHDCommand implements TabExecutor {
SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
player.getProfile().setMobHealthbarType(MainConfig.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;
@ -30,7 +30,7 @@ public class MHDCommand implements TabExecutor {
FlatfileDatabaseManager m = (FlatfileDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
player.getProfile().setMobHealthbarType(MainConfig.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;

View File

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

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
public class McabilityCommand extends ToggleCommand {

View File

@ -2,9 +2,9 @@ package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.database.ConvertDatabaseCommand;
import com.gmail.nossr50.commands.experience.ConvertExperienceCommand;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.core.data.database.DatabaseManagerFactory;
import com.gmail.nossr50.core.datatypes.database.DatabaseType;
import com.gmail.nossr50.core.datatypes.experience.FormulaType;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
@ -22,9 +22,6 @@ public class McconvertCommand implements TabExecutor {
private static final List<String> DATABASE_TYPES;
private static final List<String> SUBCOMMANDS = ImmutableList.of("database", "experience");
private CommandExecutor databaseConvertCommand = new ConvertDatabaseCommand();
private CommandExecutor experienceConvertCommand = new ConvertExperienceCommand();
static {
ArrayList<String> formulaTypes = 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
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (args[0].equalsIgnoreCase("database") || args[0].equalsIgnoreCase("db")) {
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);
}

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
public class McgodCommand extends ToggleCommand {

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.commands.party.PartySubcommandType;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -24,7 +24,7 @@ public class McmmoCommand implements CommandExecutor {
String[] mcSplit = description.split(",");
sender.sendMessage(mcSplit);
if (Config.getInstance().getDonateMessageEnabled()) {
if (MainConfig.getInstance().getDonateMessageEnabled()) {
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "com.gmail.nossr50@com.gmail.com" + ChatColor.GOLD + " Paypal");
}
@ -71,7 +71,7 @@ public class McmmoCommand implements CommandExecutor {
private void displayOtherCommands(CommandSender sender) {
//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;
sender.sendMessage(LocaleLoader.getString("Commands.Other"));

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.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.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
public class McrefreshCommand extends ToggleCommand {

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -31,7 +31,7 @@ public class McscoreboardCommand implements TabExecutor {
}
if (args[0].equalsIgnoreCase("keep")) {
if (!Config.getInstance().getAllowKeepBoard() || !Config.getInstance().getScoreboardsEnabled()) {
if (!MainConfig.getInstance().getAllowKeepBoard() || !MainConfig.getInstance().getScoreboardsEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}

View File

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

View File

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

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import org.bukkit.command.CommandSender;
public class AdminChatCommand extends ChatCommand {

View File

@ -1,15 +1,15 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.chat.ChatManager;
import com.gmail.nossr50.core.chat.ChatManagerFactory;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -21,8 +21,8 @@ import java.util.ArrayList;
import java.util.List;
public abstract class ChatCommand implements TabExecutor {
private ChatMode chatMode;
protected ChatManager chatManager;
private ChatMode chatMode;
public ChatCommand(ChatMode chatMode) {
this.chatMode = chatMode;
@ -47,8 +47,7 @@ public abstract class ChatCommand implements TabExecutor {
if (mcMMOPlayer.isChatEnabled(chatMode)) {
disableChatMode(mcMMOPlayer, sender);
}
else {
} else {
enableChatMode(mcMMOPlayer, sender);
}
@ -119,7 +118,7 @@ public abstract class ChatCommand implements TabExecutor {
return;
}
if (chatMode == ChatMode.PARTY && (mcMMOPlayer.getParty().getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT))) {
if (chatMode == ChatMode.PARTY && (mcMMOPlayer.getParty().getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT))) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
return;
}

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.commands.ToggleCommand;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
public class McChatSpy extends ToggleCommand {

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.chat;
import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.chat.PartyChatManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.chat.ChatMode;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -29,14 +29,13 @@ public class PartyChatCommand extends ChatCommand {
return;
}
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) {
if (party.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.CHAT)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.1"));
return;
}
message = buildChatMessage(args, 0);
}
else {
} else {
if (args.length < 2) {
sender.sendMessage(LocaleLoader.getString("Party.Specify"));
return;

View File

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

View File

@ -1,7 +1,7 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
@ -17,7 +17,7 @@ public class McpurgeCommand implements TabExecutor {
case 0:
mcMMO.getDatabaseManager().purgePowerlessUsers();
if (Config.getInstance().getOldUsersCutoff() != -1) {
if (MainConfig.getInstance().getOldUsersCutoff() != -1) {
mcMMO.getDatabaseManager().purgeOldUsers();
}

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.locale.LocaleLoader;
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.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -26,8 +26,7 @@ public class McremoveCommand implements TabExecutor {
if (mcMMO.getDatabaseManager().removeUser(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.
}

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.database.DatabaseManagerFactory;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -22,7 +22,7 @@ public class MmoshowdbCommand implements TabExecutor {
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (Config.getInstance().getUseMySQL() ? "sql" : "flatfile")));
sender.sendMessage(LocaleLoader.getString("Commands.mmoshowdb", (MainConfig.getInstance().getUseMySQL() ? "sql" : "flatfile")));
return true;
default:

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
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.Permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.experience.XPGainSource;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import org.bukkit.command.CommandSender;
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) {
if (player != null) {
UserManager.getPlayer(player).applyXpGain(skill, value, XPGainReason.COMMAND, XPGainSource.COMMAND);
}
else {
} else {
profile.addXp(skill, value);
profile.scheduleAsyncSave();
}

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.experience.FormulaType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.core.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.FormulaConversionTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

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

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.experience;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.core.datatypes.experience.XPGainReason;
import com.gmail.nossr50.core.datatypes.player.PlayerProfile;
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.Permissions;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

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

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.config.MainConfig;
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.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender;
public class HardcoreCommand extends HardcoreModeCommand {
@ -45,7 +45,7 @@ public class HardcoreCommand extends HardcoreModeCommand {
@Override
protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
MainConfig.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.DeathStatLoss.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
@ -54,8 +54,7 @@ public class HardcoreCommand extends HardcoreModeCommand {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreStatLossEnabled(enable);
}
}
else {
} else {
skill.setHardcoreStatLossEnabled(enable);
}

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -28,8 +28,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
if (checkEnabled(null)) {
disable(null);
}
else {
} else {
enable(null);
}
@ -122,9 +121,14 @@ public abstract class HardcoreModeCommand implements TabExecutor {
}
protected abstract boolean checkTogglePermissions(CommandSender sender);
protected abstract boolean checkModifyPermissions(CommandSender sender);
protected abstract boolean checkEnabled(PrimarySkillType skill);
protected abstract void enable(PrimarySkillType skill);
protected abstract void disable(PrimarySkillType skill);
protected abstract void modify(CommandSender sender, double newPercentage);
}

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.config.MainConfig;
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.mcMMO;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.command.CommandSender;
public class VampirismCommand extends HardcoreModeCommand {
@ -45,7 +45,7 @@ public class VampirismCommand extends HardcoreModeCommand {
@Override
protected void modify(CommandSender sender, double newPercentage) {
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
MainConfig.getInstance().setHardcoreVampirismStatLeechPercentage(newPercentage);
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercentage / 100.0D)));
}
@ -54,8 +54,7 @@ public class VampirismCommand extends HardcoreModeCommand {
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
primarySkillType.setHardcoreVampirismEnabled(enable);
}
}
else {
} else {
skill.setHardcoreVampirismEnabled(enable);
}

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.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.party.PartyManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

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

View File

@ -1,8 +1,8 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.locale.LocaleLoader;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
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.party.alliance.PartyAllianceCommand;
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -38,24 +38,24 @@ public class PartyCommand implements TabExecutor {
PARTY_SUBCOMMANDS = ImmutableList.copyOf(subcommands);
}
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
private CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
private CommandExecutor partyKickCommand = new PartyKickCommand();
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
private CommandExecutor partyLockCommand = new PartyLockCommand();
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
private CommandExecutor partyXpShareCommand = new PartyXpShareCommand();
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
private CommandExecutor partyKickCommand = new PartyKickCommand();
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
private CommandExecutor partyLockCommand = new PartyLockCommand();
private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
private CommandExecutor partyTeleportCommand = new PtpCommand();
private CommandExecutor partyChatCommand = new PartyChatCommand();
private CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
private CommandExecutor partyTeleportCommand = new PtpCommand();
private CommandExecutor partyChatCommand = new PartyChatCommand();
private CommandExecutor partyAllianceCommand = new PartyAllianceCommand();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.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.party.PartyManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

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

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.locale.LocaleLoader;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -65,8 +65,7 @@ public class PartyInfoCommand implements CommandExecutor {
if (isUnlockedFeature(party, partyFeature)) {
unlockedPartyFeatures.add(partyFeature.getLocaleString());
}
else {
} else {
lockedPartyFeatures.add(partyFeature.getFeatureLockedLocaleString());
}
}
@ -79,7 +78,7 @@ public class PartyInfoCommand implements CommandExecutor {
}
private boolean isUnlockedFeature(Party party, PartyFeature partyFeature) {
return party.getLevel() >= Config.getInstance().getPartyFeatureUnlockLevel(partyFeature);
return party.getLevel() >= MainConfig.getInstance().getPartyFeatureUnlockLevel(partyFeature);
}
private void displayShareModeInfo(Player player, Party party) {
@ -123,7 +122,7 @@ public class PartyInfoCommand implements CommandExecutor {
int membersOnline = party.getVisibleMembers(player).size();
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));
}
}

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -46,9 +46,8 @@ public class PartyInviteCommand implements CommandExecutor {
Party playerParty = mcMMOPlayer.getParty();
if(PartyManager.isPartyFull(target, playerParty))
{
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), Config.getInstance().getPartyMaxSize()));
if (PartyManager.isPartyFull(target, playerParty)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.PartyFull.Invite", target.getName(), playerParty.toString(), MainConfig.getInstance().getPartyMaxSize()));
return true;
}

View File

@ -1,14 +1,14 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.ItemShareType;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.ItemShareType;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -19,7 +19,7 @@ public class PartyItemShareCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
if (party.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ITEM_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.4"));
return true;
}
@ -41,19 +41,16 @@ public class PartyItemShareCommand implements CommandExecutor {
if (CommandUtils.shouldEnableToggle(args[2])) {
toggle = true;
}
else if (CommandUtils.shouldDisableToggle(args[2])) {
} else if (CommandUtils.shouldDisableToggle(args[2])) {
toggle = false;
}
else {
} else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<loot | mining | herbalism | woodcutting | misc> <true | false>"));
return true;
}
try {
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>"));
}

View File

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

View File

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

View File

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

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.events.party.McMMOPartyChangeEvent.EventReason;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.events.party.McMMOPartyChangeEvent.EventReason;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

@ -30,20 +30,15 @@ public enum PartySubcommandType {
if (commandName.equalsIgnoreCase("?")) {
return HELP;
}
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
} else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
return QUIT;
}
else if (commandName.equalsIgnoreCase("leader")) {
} else if (commandName.equalsIgnoreCase("leader")) {
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;
}
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
} else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
return ITEMSHARE;
}
else if (commandName.equalsIgnoreCase("ally")) {
} else if (commandName.equalsIgnoreCase("ally")) {
return ALLIANCE;
}

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.ShareMode;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -18,7 +18,7 @@ public class PartyXpShareCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Party party = UserManager.getPlayer((Player) sender).getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
if (party.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.XP_SHARE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.5"));
return true;
}
@ -27,11 +27,9 @@ public class PartyXpShareCommand implements CommandExecutor {
case 2:
if (args[1].equalsIgnoreCase("none") || CommandUtils.shouldDisableToggle(args[1])) {
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);
}
else {
} else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "xpshare", "<NONE | EQUAL>"));
}

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.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.party.PartyManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
@ -21,12 +21,10 @@ import java.util.ArrayList;
import java.util.List;
public class PartyAllianceCommand implements TabExecutor {
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
private Player player;
private Party playerParty;
private Party targetParty;
public static final List<String> ALLIANCE_SUBCOMMANDS = ImmutableList.of("invite", "accept", "disband");
private CommandExecutor partyAllianceInviteCommand = new PartyAllianceInviteCommand();
private CommandExecutor partyAllianceAcceptCommand = new PartyAllianceAcceptCommand();
private CommandExecutor partyAllianceDisbandCommand = new PartyAllianceDisbandCommand();
@ -44,7 +42,7 @@ public class PartyAllianceCommand implements TabExecutor {
switch (args.length) {
case 1:
if (playerParty.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
if (playerParty.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
return true;
}
@ -62,7 +60,7 @@ public class PartyAllianceCommand implements TabExecutor {
case 2:
case 3:
if (playerParty.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
if (playerParty.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.ALLIANCE)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.3"));
return true;
}

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.party.alliance;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

View File

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

View File

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

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.skills.SkillUtils;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -28,7 +28,7 @@ public class PtpAcceptCommand implements CommandExecutor {
return true;
}
if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), Config.getInstance().getPTPCommandTimeout())) {
if (SkillUtils.cooldownExpired(ptpRecord.getTimeout(), MainConfig.getInstance().getPTPCommandTimeout())) {
ptpRecord.removeRequest();
player.sendMessage(LocaleLoader.getString("Commands.ptp.RequestExpired"));
return true;
@ -41,7 +41,7 @@ public class PtpAcceptCommand implements CommandExecutor {
return true;
}
if (Config.getInstance().getPTPCommandWorldPermissions()) {
if (MainConfig.getInstance().getPTPCommandWorldPermissions()) {
World targetWorld = target.getWorld();
World playerWorld = player.getWorld();
@ -49,8 +49,7 @@ public class PtpAcceptCommand implements CommandExecutor {
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
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()));
return true;
}

View File

@ -1,23 +1,23 @@
package com.gmail.nossr50.commands.party.teleport;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.config.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.party.Party;
import com.gmail.nossr50.core.datatypes.party.PartyFeature;
import com.gmail.nossr50.core.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.party.PartyManager;
import com.gmail.nossr50.core.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -36,6 +36,54 @@ public class PtpCommand implements TabExecutor {
private CommandExecutor ptpAcceptAnyCommand = new PtpAcceptAnyCommand();
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 = MainConfig.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
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
@ -45,14 +93,13 @@ public class PtpCommand implements TabExecutor {
Player player = (Player) sender;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(player))
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(player))
return true;
}
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(player.getWorld()))
if (WorldBlacklist.isWorldBlacklisted(player.getWorld()))
return true;
if (!UserManager.hasPlayerDataKey(player)) {
@ -68,7 +115,7 @@ public class PtpCommand implements TabExecutor {
Party party = mcMMOPlayer.getParty();
if (party.getLevel() < Config.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
if (party.getLevel() < MainConfig.getInstance().getPartyFeatureUnlockLevel(PartyFeature.TELEPORT)) {
sender.sendMessage(LocaleLoader.getString("Party.Feature.Disabled.2"));
return true;
}
@ -84,7 +131,7 @@ public class PtpCommand implements TabExecutor {
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = Config.getInstance().getPTPCommandRecentlyHurtCooldown();
int hurtCooldown = MainConfig.getInstance().getPTPCommandRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
@ -104,7 +151,7 @@ public class PtpCommand implements TabExecutor {
return true;
}
int ptpCooldown = Config.getInstance().getPTPCommandCooldown();
int ptpCooldown = MainConfig.getInstance().getPTPCommandCooldown();
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) {
@ -169,55 +216,6 @@ public class PtpCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
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);
}
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", MainConfig.getInstance().getPTPCommandTimeout()));
}
}

View File

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

View File

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

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.config.MainConfig;
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.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -30,10 +30,10 @@ public class MccooldownCommand implements TabExecutor {
case 0:
Player player = (Player) sender;
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getCooldownUseBoard()) {
if (MainConfig.getInstance().getScoreboardsEnabled() && MainConfig.getInstance().getCooldownUseBoard()) {
ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!Config.getInstance().getCooldownUseChat()) {
if (!MainConfig.getInstance().getCooldownUseChat()) {
return true;
}
}
@ -52,8 +52,7 @@ public class MccooldownCommand implements TabExecutor {
if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
}
else {
} else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
}
}

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.config.MainConfig;
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.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -61,8 +61,7 @@ public class McrankCommand implements TabExecutor {
if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
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;
}
@ -88,7 +87,7 @@ public class McrankCommand implements TabExecutor {
private void display(CommandSender sender, String playerName) {
if (sender instanceof Player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
long cooldownMillis = Math.max(MainConfig.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
@ -105,8 +104,8 @@ public class McrankCommand implements TabExecutor {
mcMMOPlayer.actualizeDatabaseATS();
}
boolean useBoard = Config.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
boolean useChat = !useBoard || Config.getInstance().getRankUseChat();
boolean useBoard = MainConfig.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (MainConfig.getInstance().getRankUseBoard());
boolean useChat = !useBoard || MainConfig.getInstance().getRankUseChat();
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
}

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.config.MainConfig;
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.core.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -28,10 +28,10 @@ public class McstatsCommand implements TabExecutor {
case 0:
Player player = (Player) sender;
if (Config.getInstance().getStatsUseBoard() && Config.getInstance().getScoreboardsEnabled()) {
if (MainConfig.getInstance().getStatsUseBoard() && MainConfig.getInstance().getScoreboardsEnabled()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
if (!Config.getInstance().getStatsUseChat()) {
if (!MainConfig.getInstance().getStatsUseChat()) {
return true;
}
}
@ -43,12 +43,11 @@ public class McstatsCommand implements TabExecutor {
CommandUtils.printCombatSkills(player);
CommandUtils.printMiscSkills(player);
int powerLevelCap = Config.getInstance().getPowerLevelCap();
int powerLevelCap = MainConfig.getInstance().getPowerLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
}
else {
} else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
}

View File

@ -1,15 +1,15 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.core.config.MainConfig;
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.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -87,7 +87,7 @@ public class MctopCommand implements TabExecutor {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
long cooldownMillis = Math.max(MainConfig.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000;
@ -113,8 +113,8 @@ public class MctopCommand implements TabExecutor {
}
private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getTopUseBoard());
boolean useChat = !useBoard || Config.getInstance().getTopUseChat();
boolean useBoard = (sender instanceof Player) && (MainConfig.getInstance().getTopUseBoard());
boolean useChat = !useBoard || MainConfig.getInstance().getTopUseChat();
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
}

View File

@ -1,14 +1,14 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.random.RandomChanceSkill;
import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -55,26 +55,25 @@ public class AcrobaticsCommand extends SkillCommand {
AbstractSubSkill abstractSubSkill = InteractionManager.getAbstractByName("Roll");
if(abstractSubSkill != null)
{
if (abstractSubSkill != null) {
double rollChance, graceChance;
//Chance to roll at half
RandomChanceSkill roll_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
RandomChanceSkill roll_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
//Chance to graceful roll
RandomChanceSkill grace_rcs = new RandomChanceSkill(player, SubSkillType.ACROBATICS_ROLL);
grace_rcs.setSkillLevel(grace_rcs.getSkillLevel() * 2); //Double Odds
//Chance Stat Calculations
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
rollChance = RandomChanceUtil.getRandomChanceExecutionChance(roll_rcs);
graceChance = RandomChanceUtil.getRandomChanceExecutionChance(grace_rcs);
//damageThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
String rollStrings[] = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.ACROBATICS_ROLL);
//Format
double rollChanceLucky = rollChance * 1.333D;
double rollChanceLucky = rollChance * 1.333D;
double graceChanceLucky = graceChance * 1.333D;
messages.add(getStatMessage(SubSkillType.ACROBATICS_ROLL, rollStrings[0])

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
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.SubSkillType;
import com.gmail.nossr50.core.skills.primary.alchemy.AlchemyManager;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -18,8 +18,8 @@ public class AlchemyCommand extends SkillCommand {
private String brewSpeed;
private String brewSpeedLucky;
private int tier;
private int ingredientCount;
private int tier;
private int ingredientCount;
private String ingredientList;
private boolean canCatalysis;

View File

@ -1,10 +1,10 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.util.HolidayManager.FakeSkillType;
import com.gmail.nossr50.core.util.Misc;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -16,10 +16,9 @@ import java.util.ArrayList;
import java.util.List;
public class AprilCommand implements TabExecutor {
private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
private String skillName;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.archery.Archery;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;

View File

@ -1,14 +1,14 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.axes.Axes;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
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.SubSkillType;
import com.gmail.nossr50.core.skills.primary.axes.Axes;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;

View File

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

View File

@ -1,18 +1,18 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.core.config.AdvancedConfig;
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.SubSkillType;
import com.gmail.nossr50.core.skills.primary.fishing.Fishing;
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.TextComponentFactory;
import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
@ -57,7 +57,7 @@ public class FishingCommand extends SkillCommand {
if (canTreasureHunt) {
lootTier = fishingManager.getLootTier();
// Item drop rates
// ItemStack drop rates
commonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON) / 100.0);
uncommonTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON) / 100.0);
rareTreasure = percent.format(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE) / 100.0);
@ -74,7 +74,7 @@ public class FishingCommand extends SkillCommand {
}
}
if(totalEnchantChance >= 1)
if (totalEnchantChance >= 1)
magicChance = percent.format(totalEnchantChance / 100.0);
else
magicChance = percent.format(0);
@ -149,7 +149,7 @@ public class FishingCommand extends SkillCommand {
if (canShake) {
messages.add(getStatMessage(SubSkillType.FISHING_SHAKE, shakeChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shakeChanceLucky) : ""));
}
if (canTreasureHunt) {

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -45,7 +45,8 @@ public class HerbalismCommand extends SkillCommand {
// DOUBLE DROPS
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];
doubleDropChanceLucky = doubleDropStrings[1];
}
@ -124,7 +125,7 @@ public class HerbalismCommand extends SkillCommand {
}
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) {

View File

@ -1,14 +1,14 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
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.SubSkillType;
import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -90,7 +90,7 @@ public class MiningCommand extends SkillCommand {
//messages.add(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, RankUtils.getHighestRank(SubSkillType.MINING_BLAST_MINING), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
}
if (canDemoExpert) {
if (canDemoExpert) {
messages.add(getStatMessage(SubSkillType.MINING_DEMOLITIONS_EXPERTISE, blastDamageDecrease));
//messages.add(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
}

View File

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

View File

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

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
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.SubSkillType;
import com.gmail.nossr50.core.skills.child.salvage.Salvage;
import com.gmail.nossr50.core.skills.child.salvage.SalvageManager;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;

View File

@ -1,22 +1,22 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.core.config.AdvancedConfig;
import com.gmail.nossr50.core.config.MainConfig;
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.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.child.FamilyTree;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.StringUtils;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.commands.CommandUtils;
import com.gmail.nossr50.core.util.random.RandomChanceUtil;
import com.gmail.nossr50.core.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.core.util.skills.PerksUtils;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import com.google.common.collect.ImmutableList;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.TextComponent;
@ -33,11 +33,9 @@ import java.util.Set;
public abstract class SkillCommand implements TabExecutor {
protected PrimarySkillType skill;
private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
private String skillName;
private CommandExecutor skillGuideCommand;
public SkillCommand(PrimarySkillType skill) {
@ -46,6 +44,15 @@ public abstract class SkillCommand implements TabExecutor {
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
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
@ -66,9 +73,8 @@ public abstract class SkillCommand implements TabExecutor {
float skillValue = mcMMOPlayer.getSkillLevel(skill);
//Send the players a few blank lines to make finding the top of the skill command easier
if(AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
for(int i = 0; i < 2; i++)
{
if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines())
for (int i = 0; i < 2; i++) {
player.sendMessage("");
}
@ -99,14 +105,13 @@ public abstract class SkillCommand implements TabExecutor {
//Link Header
if(Config.getInstance().getUrlLinksEnabled())
{
if (MainConfig.getInstance().getUrlLinksEnabled()) {
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
TextComponentFactory.sendPlayerUrlHeader(player);
}
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getSkillUseBoard()) {
if (MainConfig.getInstance().getScoreboardsEnabled() && MainConfig.getInstance().getSkillUseBoard()) {
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
}
@ -138,8 +143,7 @@ public abstract class SkillCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Skills.Overhaul.Header", skillName));
if(!skill.isChildSkill())
{
if (!skill.isChildSkill()) {
/*
* NON-CHILD SKILLS
*/
@ -162,17 +166,16 @@ public abstract class SkillCommand implements TabExecutor {
//TODO: Add JSON here
for (PrimarySkillType parent : parents) {
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 = "";
for(int i = 0; i < parentList.size(); i++)
{
if(i+1 < parentList.size())
{
for (int i = 0; i < parentList.size(); i++) {
if (i + 1 < parentList.size()) {
parentMessage += LocaleLoader.getString("Effects.Child.ParentList", parentList.get(i).getName(), mcMMOPlayer.getSkillLevel(parentList.get(i)));
parentMessage += ChatColor.GRAY+", ";
parentMessage += ChatColor.GRAY + ", ";
} else {
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;
if(abilityLengthCap <= 0)
{
if (abilityLengthCap <= 0) {
length = 2 + (int) (skillValue / abilityLengthVar);
}
else {
} else {
length = 2 + (int) (Math.min(abilityLengthCap, skillValue) / abilityLengthVar);
}
@ -245,40 +246,27 @@ public abstract class SkillCommand implements TabExecutor {
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);
}
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 statDescriptionKey = !isExtra ? subSkillType.getLocaleKeyStatDescription() : subSkillType.getLocaleKeyStatExtraDescription();
if(isCustom)
if (isCustom)
//Cast to Object[] to suppress warnings
return LocaleLoader.getString(templateKey, LocaleLoader.getString(statDescriptionKey, (Object[]) vars));
else
{
else {
String[] mergedList = addItemToFirstPositionOfArray(LocaleLoader.getString(statDescriptionKey), vars);
//Cast to Object[] to suppress warnings
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 permissionsCheck(Player player);
@ -291,12 +279,12 @@ public abstract class SkillCommand implements TabExecutor {
/**
* Checks if a player can use a skill
* @param player target player
*
* @param player target player
* @param subSkillType target subskill
* @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);
}
}

View File

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

View File

@ -1,14 +1,14 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.smelting.Smelting;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
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.SubSkillType;
import com.gmail.nossr50.core.skills.child.smelting.Smelting;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;

View File

@ -1,14 +1,14 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.core.config.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.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -70,8 +70,8 @@ public class SwordsCommand extends SkillCommand {
List<String> messages = new ArrayList<String>();
int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer();
double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs();
double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer();
double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs();
if (canCounter) {
messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance)

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.skills.primary.taming.Taming;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;

View File

@ -1,13 +1,13 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
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.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -39,7 +39,8 @@ public class UnarmedCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue) {
// UNARMED_ARROW_DEFLECT
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];
deflectChanceLucky = deflectStrings[1];
}
@ -53,7 +54,8 @@ public class UnarmedCommand extends SkillCommand {
// UNARMED_DISARM
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];
disarmChanceLucky = disarmStrings[1];
}

View File

@ -1,12 +1,12 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.core.locale.LocaleLoader;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SubSkillType;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.TextComponentFactory;
import com.gmail.nossr50.core.util.skills.RankUtils;
import com.gmail.nossr50.core.util.skills.SkillActivationType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
@ -46,7 +46,8 @@ public class WoodcuttingCommand extends SkillCommand {
}
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];
doubleDropChanceLucky = doubleDropStrings[1];
}

View File

@ -1,135 +0,0 @@
package com.gmail.nossr50.config;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Set;
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
public AutoUpdateConfigLoader(String relativePath, String fileName) {
super(relativePath, fileName);
}
public AutoUpdateConfigLoader(String fileName) {
super(fileName);
}
@Override
protected void loadFile() {
super.loadFile();
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResourceAsReader(fileName));
Set<String> configKeys = config.getKeys(true);
Set<String> internalConfigKeys = internalConfig.getKeys(true);
boolean needSave = false;
Set<String> oldKeys = new HashSet<String>(configKeys);
oldKeys.removeAll(internalConfigKeys);
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
newKeys.removeAll(configKeys);
// Don't need a re-save if we have old keys sticking around?
// Would be less saving, but less... correct?
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
needSave = true;
}
for (String key : oldKeys) {
plugin.debug("Detected potentially unused key: " + key);
//config.set(key, null);
}
for (String key : newKeys) {
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));
config.set(key, internalConfig.get(key));
}
if (needSave) {
// Get Bukkit's version of an acceptable config with new keys, and no old keys
String output = config.saveToString();
// Convert to the superior 4 space indentation
output = output.replace(" ", " ");
// Rip out Bukkit's attempt to save comments at the top of the file
while (output.replaceAll("[//s]", "").startsWith("#")) {
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
}
// Read the internal config to get comments, then put them in the new one
try {
// Read internal
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
LinkedHashMap<String, String> comments = new LinkedHashMap<String, String>();
String temp = "";
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("#")) {
temp += line + "\n";
}
else if (line.contains(":")) {
line = line.substring(0, line.indexOf(":") + 1);
if (!temp.isEmpty()) {
if(comments.containsKey(line)) {
int index = 0;
while(comments.containsKey(line + index)) {
index++;
}
line = line + index;
}
comments.put(line, temp);
temp = "";
}
}
}
// Dump to the new one
HashMap<String, Integer> indexed = new HashMap<String, Integer>();
for (String key : comments.keySet()) {
String actualkey = key.substring(0, key.indexOf(":") + 1);
int index = 0;
if(indexed.containsKey(actualkey)) {
index = indexed.get(actualkey);
}
boolean isAtTop = !output.contains("\n" + actualkey);
index = output.indexOf((isAtTop ? "" : "\n") + actualkey, index);
if (index >= 0) {
output = output.substring(0, index) + "\n" + comments.get(key) + output.substring(isAtTop ? index : index + 1);
indexed.put(actualkey, index + comments.get(key).length() + actualkey.length() + 1);
}
}
}
catch (Exception e) {
e.printStackTrace();
}
// Save it
try {
String saveName = fileName;
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
saveName += ".new";
}
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName)));
writer.write(output);
writer.flush();
writer.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@ -1,575 +0,0 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class Config extends AutoUpdateConfigLoader {
private static Config instance;
private Config() {
super("config.yml");
validate();
}
public static Config getInstance() {
if (instance == null) {
instance = new Config();
}
return instance;
}
@Override
protected void loadKeys() {
}
@Override
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
/* General Settings */
if (getSaveInterval() <= 0) {
reason.add("General.Save_Interval should be greater than 0!");
}
/* MySQL Settings */
for (SQLDatabaseManager.PoolIdentifier identifier : SQLDatabaseManager.PoolIdentifier.values()) {
if (getMySQLMaxConnections(identifier) <= 0) {
reason.add("MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
}
if (getMySQLMaxPoolSize(identifier) <= 0) {
reason.add("MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()) + " should be greater than 0!");
}
}
/* Mob Healthbar */
if (getMobHealthbarTime() == 0) {
reason.add("Mob_Healthbar.Display_Time cannot be 0! Set to -1 to disable or set a valid value.");
}
/* Scoreboards */
/*if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
}
if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
}
if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!");
}
if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
}
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
}
if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!");
}
if (!(getRankUseChat() || getRankUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!");
}
if (!(getTopUseChat() || getTopUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Top must be true!");
}
if (!(getStatsUseChat() || getStatsUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!");
}
if (!(getInspectUseChat() || getInspectUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
}*/
/* Database Purging */
if (getPurgeInterval() < -1) {
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
}
if (getOldUsersCutoff() != -1 && getOldUsersCutoff() <= 0) {
reason.add("Database_Purging.Old_User_Cutoff should be greater than 0 or -1!");
}
/* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
}
if (getHardcoreVampirismStatLeechPercentage() < 0.01 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
}
/* Items */
if (getChimaeraUseCost() < 1 || getChimaeraUseCost() > 64) {
reason.add("Items.Chimaera_Wing.Use_Cost only accepts values from 1 to 64!");
}
if (getChimaeraRecipeCost() < 1 || getChimaeraRecipeCost() > 9) {
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 9!");
}
if (getChimaeraItem() == null) {
reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
}
/* Particles */
if (getLevelUpEffectsTier() < 1) {
reason.add("Particles.LevelUp_Tier should be at least 1!");
}
/* PARTY SETTINGS */
if (getAutoPartyKickInterval() < -1) {
reason.add("Party.AutoKick_Interval should be at least -1!");
}
if (getAutoPartyKickTime() < 0) {
reason.add("Party.Old_Party_Member_Cutoff should be at least 0!");
}
if (getPartyShareBonusBase() <= 0) {
reason.add("Party.Sharing.ExpShare_bonus_base should be greater than 0!");
}
if (getPartyShareBonusIncrease() < 0) {
reason.add("Party.Sharing.ExpShare_bonus_increase should be at least 0!");
}
if (getPartyShareBonusCap() <= 0) {
reason.add("Party.Sharing.ExpShare_bonus_cap should be greater than 0!");
}
if (getPartyShareRange() <= 0) {
reason.add("Party.Sharing.Range should be greater than 0!");
}
if (getPartyXpCurveMultiplier() < 1) {
reason.add("Party.Leveling.Xp_Curve_Modifier should be at least 1!");
}
for (PartyFeature partyFeature : PartyFeature.values()) {
if (getPartyFeatureUnlockLevel(partyFeature) < 0) {
reason.add("Party.Leveling." + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "") + "_UnlockLevel should be at least 0!");
}
}
/* Inspect command distance */
if (getInspectDistance() <= 0) {
reason.add("Commands.inspect.Max_Distance should be greater than 0!");
}
if (getTreeFellerThreshold() <= 0) {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getFishingLureModifier() < 0) {
reason.add("Abilities.Fishing.Lure_Modifier should be at least 0!");
}
if (getDetonatorItem() == null) {
reason.add("Skills.Mining.Detonator_Item is invalid!");
}
if (getRepairAnvilMaterial() == null) {
reason.add("Skills.Repair.Anvil_Type is invalid!!");
}
if (getSalvageAnvilMaterial() == null) {
reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
}
if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
reason.add("Cannot use the same item for Repair and Salvage anvils!");
}
if (getTamingCOTWMaterial(EntityType.WOLF) == null) {
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Material is invalid!!");
}
if (getTamingCOTWMaterial(EntityType.OCELOT) == null) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Material is invalid!!");
}
if (getTamingCOTWMaterial(EntityType.HORSE) == null) {
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Material is invalid!!");
}
if (getTamingCOTWCost(EntityType.WOLF) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Item_Amount should be greater than 0!");
}
if (getTamingCOTWCost(EntityType.OCELOT) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Item_Amount should be greater than 0!");
}
if (getTamingCOTWCost(EntityType.HORSE) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Item_Amount should be greater than 0!");
}
if (getTamingCOTWAmount(EntityType.WOLF) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Wolf.Summon_Amount should be greater than 0!");
}
if (getTamingCOTWAmount(EntityType.OCELOT) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Ocelot.Summon_Amount should be greater than 0!");
}
if (getTamingCOTWAmount(EntityType.HORSE) <= 0) {
reason.add("Skills.Taming.Call_Of_The_Wild.Horse.Summon_Amount should be greater than 0!");
}
return noErrorsInConfig(reason);
}
/*
* GENERAL SETTINGS
*/
/* General Settings */
public boolean getIsMetricsEnabled() { return config.getBoolean("Metrics.bstats", true); }
//Retro mode will default the value to true if the config file doesn't contain the entry (server is from a previous mcMMO install)
public boolean getIsRetroMode() { return config.getBoolean("General.RetroMode.Enabled", true); }
public String getLocale() { return config.getString("General.Locale", "en_us"); }
public boolean getMOTDEnabled() { return config.getBoolean("General.MOTD_Enabled", true); }
public boolean getShowProfileLoadedMessage() { return config.getBoolean("General.Show_Profile_Loaded", true); }
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.partychat.Gold_Leader_Name", true); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.partychat.Use_Display_Names", true); }
public String getPartyChatPrefixAlly() { return config.getString("Commands.partychat.Chat_Prefix_Format_Ally", "[[GREEN]](A)[[RESET]]"); }
public String getAdminChatPrefix() { return config.getString("Commands.adminchat.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.adminchat.Use_Display_Names", true); }
public boolean getMatchOfflinePlayers() { return config.getBoolean("Commands.Generic.Match_OfflinePlayers", false); }
public long getDatabasePlayerCooldown() { return config.getLong("Commands.Database.Player_Cooldown", 1750); }
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
public boolean getRefreshChunksEnabled() { return config.getBoolean("General.Refresh_Chunks", false); }
public boolean getMobHealthbarEnabled() { return config.getBoolean("Mob_Healthbar.Enabled", true); }
/* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() {
try {
return MobHealthbarType.valueOf(config.getString("Mob_Healthbar.Display_Type", "HEARTS").toUpperCase().trim());
}
catch (IllegalArgumentException ex) {
return MobHealthbarType.HEARTS;
}
}
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
/* Scoreboards */
public boolean getScoreboardsEnabled() { return config.getBoolean("Scoreboard.UseScoreboards", true); }
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
public int getTipsAmount() { return config.getInt("Scoreboard.Tips_Amount", 5); }
public boolean getShowStatsAfterLogin() { return config.getBoolean("Scoreboard.Show_Stats_After_Login", false); }
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
public boolean getShowAbilityNames() { return config.getBoolean("Scoreboard.Ability_Names", true); }
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
public boolean getRankUseBoard() { return config.getBoolean("Scoreboard.Types.Rank.Board", true); }
public int getRankScoreboardTime() { return config.getInt("Scoreboard.Types.Rank.Display_Time", 10); }
public boolean getTopUseChat() { return config.getBoolean("Scoreboard.Types.Top.Print", true); }
public boolean getTopUseBoard() { return config.getBoolean("Scoreboard.Types.Top.Board", true); }
public int getTopScoreboardTime() { return config.getInt("Scoreboard.Types.Top.Display_Time", 15); }
public boolean getStatsUseChat() { return config.getBoolean("Scoreboard.Types.Stats.Print", true); }
public boolean getStatsUseBoard() { return config.getBoolean("Scoreboard.Types.Stats.Board", true); }
public int getStatsScoreboardTime() { return config.getInt("Scoreboard.Types.Stats.Display_Time", 10); }
public boolean getInspectUseChat() { return config.getBoolean("Scoreboard.Types.Inspect.Print", true); }
public boolean getInspectUseBoard() { return config.getBoolean("Scoreboard.Types.Inspect.Board", true); }
public int getInspectScoreboardTime() { return config.getInt("Scoreboard.Types.Inspect.Display_Time", 25); }
public boolean getCooldownUseChat() { return config.getBoolean("Scoreboard.Types.Cooldown.Print", false); }
public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); }
public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); }
public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); }
public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); }
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
public int getSkillLevelUpTime() { return config.getInt("Scoreboard.Types.Skill.LevelUp_Time", 5); }
/* Database Purging */
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
public int getOldUsersCutoff() { return config.getInt("Database_Purging.Old_User_Cutoff", 6); }
/* Backups */
public boolean getBackupsEnabled() { return config.getBoolean("Backups.Enabled", true); }
public boolean getKeepLast24Hours() { return config.getBoolean("Backups.Keep.Last_24_Hours", true); }
public boolean getKeepDailyLastWeek() { return config.getBoolean("Backups.Keep.Daily_Last_Week", true); }
public boolean getKeepWeeklyPastMonth() { return config.getBoolean("Backups.Keep.Weekly_Past_Months", true); }
/* mySQL */
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
public String getMySQLDatabaseName() { return getStringIncludingInts("MySQL.Database.Name"); }
public String getMySQLUserName() { return getStringIncludingInts("MySQL.Database.User_Name"); }
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
public int getMySQLMaxConnections(SQLDatabaseManager.PoolIdentifier identifier) { return config.getInt("MySQL.Database.MaxConnections." + StringUtils.getCapitalized(identifier.toString()), 30); }
public int getMySQLMaxPoolSize(SQLDatabaseManager.PoolIdentifier identifier) { return config.getInt("MySQL.Database.MaxPoolSize." + StringUtils.getCapitalized(identifier.toString()), 10); }
public boolean getMySQLSSL() { return config.getBoolean("MySQL.Server.SSL", true); }
private String getStringIncludingInts(String key) {
String str = config.getString(key);
if (str == null) {
str = String.valueOf(config.getInt(key));
}
if (str.equals("0")) {
str = "No value set for '" + key + "'";
}
return str;
}
/* Hardcore Mode */
public boolean getHardcoreStatLossEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
public void setHardcoreStatLossEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); }
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
public int getHardcoreDeathStatPenaltyLevelThreshold() { return config.getInt("Hardcore.Death_Stat_Loss.Level_Threshold", 0); }
public boolean getHardcoreVampirismEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), false); }
public void setHardcoreVampirismEnabled(PrimarySkillType primarySkillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(primarySkillType.toString()), enabled); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
public int getHardcoreVampirismLevelThreshold() { return config.getInt("Hardcore.Vampirism.Level_Threshold", 0); }
/* SMP Mods */
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_Mods_Enabled", false); }
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
/* Items */
public int getChimaeraUseCost() { return config.getInt("Items.Chimaera_Wing.Use_Cost", 1); }
public int getChimaeraRecipeCost() { return config.getInt("Items.Chimaera_Wing.Recipe_Cost", 5); }
public Material getChimaeraItem() { return Material.matchMaterial(config.getString("Items.Chimaera_Wing.Item_Name", "Feather")); }
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
public boolean getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
public boolean getChimaeraUseBedSpawn() { return config.getBoolean("Items.Chimaera_Wing.Use_Bed_Spawn", true); }
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
public int getChimaeraWarmup() { return config.getInt("Items.Chimaera_Wing.Warmup", 5); }
public int getChimaeraRecentlyHurtCooldown() { return config.getInt("Items.Chimaera_Wing.RecentlyHurt_Cooldown", 60); }
public boolean getChimaeraSoundEnabled() { return config.getBoolean("Items.Chimaera_Wing.Sound_Enabled", true); }
public boolean getFluxPickaxeSoundEnabled() { return config.getBoolean("Items.Flux_Pickaxe.Sound_Enabled", true); }
/* Particles */
public boolean getAbilityActivationEffectEnabled() { return config.getBoolean("Particles.Ability_Activation", true); }
public boolean getAbilityDeactivationEffectEnabled() { return config.getBoolean("Particles.Ability_Deactivation", true); }
public boolean getBleedEffectEnabled() { return config.getBoolean("Particles.Bleed", true); }
public boolean getDodgeEffectEnabled() { return config.getBoolean("Particles.Dodge", true); }
public boolean getFluxEffectEnabled() { return config.getBoolean("Particles.Flux", true); }
public boolean getGreaterImpactEffectEnabled() { return config.getBoolean("Particles.Greater_Impact", true); }
public boolean getCallOfTheWildEffectEnabled() { return config.getBoolean("Particles.Call_of_the_Wild", true); }
public boolean getLevelUpEffectsEnabled() { return config.getBoolean("Particles.LevelUp_Enabled", true); }
public int getLevelUpEffectsTier() { return config.getInt("Particles.LevelUp_Tier", 100); }
public boolean getLargeFireworks() { return config.getBoolean("Particles.LargeFireworks", true); }
/* PARTY SETTINGS */
public boolean getPartyFriendlyFire() { return config.getBoolean("Party.FriendlyFire", false);}
public int getPartyMaxSize() {return config.getInt("Party.MaxSize", -1); }
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1D); }
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05D); }
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5D); }
public double getPartyShareRange() { return config.getDouble("Party.Sharing.Range", 75.0D); }
public int getPartyLevelCap() {
int cap = config.getInt("Party.Leveling.Level_Cap", 10);
return (cap <= 0) ? Integer.MAX_VALUE : cap;
}
public int getPartyXpCurveMultiplier() { return config.getInt("Party.Leveling.Xp_Curve_Modifier", 3); }
public boolean getPartyXpNearMembersNeeded() { return config.getBoolean("Party.Leveling.Near_Members_Needed", false); }
public boolean getPartyInformAllMembers() { return config.getBoolean("Party.Leveling.Inform_All_Party_Members_On_LevelUp", false); }
public int getPartyFeatureUnlockLevel(PartyFeature partyFeature) { return config.getInt("Party.Leveling." + StringUtils.getPrettyPartyFeatureString(partyFeature).replace(" ", "") + "_UnlockLevel", 0); }
/* Party Teleport Settings */
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
public int getPTPCommandWarmup() { return config.getInt("Commands.ptp.Warmup", 5); }
public int getPTPCommandRecentlyHurtCooldown() { return config.getInt("Commands.ptp.RecentlyHurt_Cooldown", 60); }
public int getPTPCommandTimeout() { return config.getInt("Commands.ptp.Request_Timeout", 300); }
public boolean getPTPCommandConfirmRequired() { return config.getBoolean("Commands.ptp.Accept_Required", true); }
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
/* Inspect command distance */
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30.0D); }
/*
* ABILITY SETTINGS
*/
/* General Settings */
public boolean getUrlLinksEnabled() { return config.getBoolean("Commands.Skills.URL_Links"); }
public boolean getAbilityMessagesEnabled() { return config.getBoolean("Abilities.Messages", true); }
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
public boolean getAbilitiesGateEnabled() { return config.getBoolean("Abilities.Activation.Level_Gate_Abilities"); }
public int getCooldown(SuperAbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
public int getMaxLength(SuperAbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
/* Durability Settings */
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
/* Thresholds */
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
/*
* SKILL SETTINGS
*/
public boolean getDoubleDropsEnabled(PrimarySkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public boolean getDoubleDropsDisabled(PrimarySkillType skill) {
String skillName = StringUtils.getCapitalized(skill.toString());
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
if (section == null)
return false;
Set<String> keys = section.getKeys(false);
boolean disabled = true;
for (String key : keys) {
if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
disabled = false;
break;
}
}
return disabled;
}
/* Axes */
public int getAxesGate() { return config.getInt("Skills.Axes.Ability_Activation_Level_Gate", 10); }
/* Acrobatics */
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
public int getXPAfterTeleportCooldown() { return config.getInt("Skills.Acrobatics.XP_After_Teleport_Cooldown", 5); }
/* Alchemy */
public boolean getEnabledForHoppers() { return config.getBoolean("Skills.Alchemy.Enabled_for_Hoppers", true); }
public boolean getPreventHopperTransferIngredients() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer_Ingredients", false); }
public boolean getPreventHopperTransferBottles() { return config.getBoolean("Skills.Alchemy.Prevent_Hopper_Transfer_Bottles", false); }
/* Fishing */
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
public boolean getFishingOverrideTreasures() { return config.getBoolean("Skills.Fishing.Override_Vanilla_Treasures", true); }
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
public double getFishingLureModifier() { return config.getDouble("Skills.Fishing.Lure_Modifier", 4.0D); }
/* Mining */
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
public int getMiningGate() { return config.getInt("Skills.Mining.Ability_Activation_Level_Gate", 10); }
/* Excavation */
public int getExcavationGate() { return config.getInt("Skills.Excavation.Ability_Activation_Level_Gate", 10); }
/* Repair */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
public boolean getRepairAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Placed_Sounds", true); }
public boolean getRepairAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Repair.Anvil_Use_Sounds", true); }
public Material getRepairAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Repair.Anvil_Material", "IRON_BLOCK")); }
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
/* Salvage */
public boolean getSalvageAnvilMessagesEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Messages", true); }
public boolean getSalvageAnvilPlaceSoundsEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Placed_Sounds", true); }
public boolean getSalvageAnvilUseSoundsEnabled() { return config.getBoolean("Skills.Salvage.Anvil_Use_Sounds", true); }
public Material getSalvageAnvilMaterial() { return Material.matchMaterial(config.getString("Skills.Salvage.Anvil_Material", "GOLD_BLOCK")); }
public boolean getSalvageConfirmRequired() { return config.getBoolean("Skills.Salvage.Confirm_Required", true); }
/* Unarmed */
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
public boolean getUnarmedItemPickupDisabled() { return config.getBoolean("Skills.Unarmed.Item_Pickup_Disabled_Full_Inventory", true); }
public boolean getUnarmedItemsAsUnarmed() { return config.getBoolean("Skills.Unarmed.Items_As_Unarmed", false); }
public int getUnarmedGate() { return config.getInt("Skills.Unarmed.Ability_Activation_Level_Gate", 10); }
/* Swords */
public int getSwordsGate() { return config.getInt("Skills.Swords.Ability_Activation_Level_Gate", 10); }
/* Taming */
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
public int getTamingCOTWCost(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Amount"); }
public int getTamingCOTWAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Summon_Amount"); }
public int getTamingCOTWLength(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ ".Summon_Length"); }
public int getTamingCOTWMaxAmount(EntityType type) { return config.getInt("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type)+ ".Summon_Max_Amount"); }
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
/* Woodcutting */
public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); }
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
public int getWoodcuttingGate() { return config.getInt("Skills.Woodcutting.Ability_Activation_Level_Gate", 10); }
/* AFK Leveling */
public boolean getAcrobaticsPreventAFK() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
public int getAcrobaticsAFKMaxTries() { return config.getInt("Skills.Acrobatics.Max_Tries_At_Same_Location", 3); }
public boolean getHerbalismPreventAFK() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
/* Level Caps */
public int getPowerLevelCap() {
int cap = config.getInt("General.Power_Level_Cap", 0);
return (cap <= 0) ? Integer.MAX_VALUE : cap;
}
public int getLevelCap(PrimarySkillType skill) {
int cap = config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Level_Cap");
return (cap <= 0) ? Integer.MAX_VALUE : cap;
}
/*public int isSuperAbilityUnlocked(PrimarySkillType skill) {
return config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Ability_Activation_Level_Gate");
}*/
public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
/* PVP & PVE Settings */
public boolean getPVPEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
public boolean getPVEEnabled(PrimarySkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
//public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
}

View File

@ -1,89 +0,0 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.util.List;
public abstract class ConfigLoader {
protected static final mcMMO plugin = mcMMO.p;
protected String fileName;
private File configFile;
protected FileConfiguration config;
public ConfigLoader(String relativePath, String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
loadFile();
}
public ConfigLoader(String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), fileName);
loadFile();
}
protected void loadFile() {
if (!configFile.exists()) {
plugin.debug("Creating mcMMO " + fileName + " File...");
try {
plugin.saveResource(fileName, false); // Normal files
}
catch (IllegalArgumentException ex) {
plugin.saveResource(configFile.getParentFile().getName() + File.separator + fileName, false); // Mod files
}
}
else {
plugin.debug("Loading mcMMO " + fileName + " File...");
}
config = YamlConfiguration.loadConfiguration(configFile);
}
protected abstract void loadKeys();
protected boolean validateKeys() {
return true;
}
protected boolean noErrorsInConfig(List<String> issues) {
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
return issues.isEmpty();
}
protected void validate() {
if (validateKeys()) {
plugin.debug("No errors found in " + fileName + "!");
}
else {
plugin.getLogger().warning("Errors were found in " + fileName + "! mcMMO was disabled!");
plugin.getServer().getPluginManager().disablePlugin(plugin);
plugin.noErrorsInConfigFiles = false;
}
}
public File getFile() {
return configFile;
}
public void backup() {
plugin.getLogger().warning("You are using an old version of the " + fileName + " file.");
plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version.");
configFile.renameTo(new File(configFile.getPath() + ".old"));
if (plugin.getResource(fileName) != null) {
plugin.saveResource(fileName, true);
}
plugin.getLogger().warning("Reloading " + fileName + " with new values...");
loadFile();
loadKeys();
}
}

View File

@ -1,59 +0,0 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.util.StringUtils;
public class CoreSkillsConfig extends AutoUpdateConfigLoader {
private static CoreSkillsConfig instance;
public CoreSkillsConfig()
{
super("coreskills.yml");
validate();
}
@Override
protected void loadKeys() {
}
public static CoreSkillsConfig getInstance()
{
if(instance == null)
return new CoreSkillsConfig();
return instance;
}
@Override
protected boolean validateKeys() {
return true;
}
/*
* Skill Settings
*/
/**
* Whether or not a skill is enabled
* Defaults true
* @param abstractSubSkill SubSkill definition to check
* @return true if subskill is enabled
*/
public boolean isSkillEnabled(AbstractSubSkill abstractSubSkill)
{
return config.getBoolean(StringUtils.getCapitalized(abstractSubSkill.getPrimarySkill().toString())+"."+ abstractSubSkill.getConfigKeyName()+".Enabled", true);
}
/**
* Whether or not this primary skill is enabled
* @param primarySkillType target primary skill
* @return true if enabled
*/
public boolean isPrimarySkillEnabled(PrimarySkillType primarySkillType)
{
return config.getBoolean(StringUtils.getCapitalized(primarySkillType.toString())+".Enabled", true);
}
}

View File

@ -1,68 +0,0 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.mcMMO;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.InputStreamReader;
public class HiddenConfig {
private static HiddenConfig instance;
private String fileName;
private YamlConfiguration config;
private boolean chunkletsEnabled;
private int conversionRate;
private boolean useEnchantmentBuffs;
private int uuidConvertAmount;
private int mojangRateLimit;
private long mojangLimitPeriod;
public HiddenConfig(String fileName) {
this.fileName = fileName;
load();
}
public static HiddenConfig getInstance() {
if (instance == null) {
instance = new HiddenConfig("hidden.yml");
}
return instance;
}
public void load() {
InputStreamReader reader = mcMMO.p.getResourceAsReader(fileName);
if (reader != null) {
config = YamlConfiguration.loadConfiguration(reader);
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
conversionRate = config.getInt("Options.ConversionRate", 1);
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
uuidConvertAmount = config.getInt("Options.UUIDConvertAmount", 5);
mojangRateLimit = config.getInt("Options.MojangRateLimit", 50000);
mojangLimitPeriod = config.getLong("Options.MojangLimitPeriod", 600000);
}
}
public boolean getChunkletsEnabled() {
return chunkletsEnabled;
}
public int getConversionRate() {
return conversionRate;
}
public boolean useEnchantmentBuffs() {
return useEnchantmentBuffs;
}
public int getUUIDConvertAmount() {
return uuidConvertAmount;
}
public int getMojangRateLimit() {
return mojangRateLimit;
}
public long getMojangLimitPeriod() {
return mojangLimitPeriod;
}
}

View File

@ -1,70 +0,0 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.util.sounds.SoundType;
public class SoundConfig extends AutoUpdateConfigLoader {
private static SoundConfig instance;
public SoundConfig()
{
super("sounds.yml");
validate();
this.instance = this;
}
@Override
protected void loadKeys() {
}
public static SoundConfig getInstance()
{
if(instance == null)
return new SoundConfig();
return instance;
}
@Override
protected boolean validateKeys() {
for(SoundType soundType : SoundType.values())
{
if(config.getDouble("Sounds."+soundType.toString()+".Volume") < 0)
{
plugin.getLogger().info("[mcMMO] Sound volume cannot be below 0 for "+soundType.toString());
return false;
}
//Sounds with custom pitching don't use pitch values
if(!soundType.usesCustomPitch())
{
if(config.getDouble("Sounds."+soundType.toString()+".Pitch") < 0)
{
plugin.getLogger().info("[mcMMO] Sound pitch cannot be below 0 for "+soundType.toString());
return false;
}
}
}
return true;
}
public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
public float getVolume(SoundType soundType)
{
String key = "Sounds."+soundType.toString()+".Volume";
return (float) config.getDouble(key);
}
public float getPitch(SoundType soundType)
{
String key = "Sounds."+soundType.toString()+".Pitch";
return (float) config.getDouble(key);
}
public boolean getIsEnabled(SoundType soundType)
{
String key = "Sounds."+soundType.toString()+".Enabled";
return config.getBoolean(key, true);
}
}

View File

@ -1,328 +0,0 @@
package com.gmail.nossr50.config.experience;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class ExperienceConfig extends AutoUpdateConfigLoader {
private static ExperienceConfig instance;
private ExperienceConfig() {
super("experience.yml");
validate();
}
public static ExperienceConfig getInstance() {
if (instance == null) {
instance = new ExperienceConfig();
}
return instance;
}
@Override
protected void loadKeys() {}
@Override
protected boolean validateKeys() {
List<String> reason = new ArrayList<String>();
/*
* FORMULA SETTINGS
*/
/* Curve values */
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
if (getMultiplier(FormulaType.LINEAR) <= 0) {
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
}
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
}
/* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) {
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
}
/* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) {
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
}
/* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!");
}
/*
* XP SETTINGS
*/
/* Alchemy */
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
reason.add("Experience.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Archery */
if (getArcheryDistanceMultiplier() < 0) {
reason.add("Experience.Archery.Distance_Multiplier should be at least 0!");
}
/* Combat XP Multipliers */
if (getAnimalsXP() < 0) {
reason.add("Experience.Combat.Multiplier.Animals should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* Fishing */
// TODO: Add validation for each fish type once enum is available.
if (getFishingShakeXP() <= 0) {
reason.add("Experience.Fishing.Shake should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
reason.add("Experience.Repair.Base should be greater than 0!");
}
/* Taming */
if (getTamingXP(EntityType.WOLF) <= 0) {
reason.add("Experience.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXP(EntityType.OCELOT) <= 0) {
reason.add("Experience.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
return noErrorsInConfig(reason);
}
/*
* FORMULA SETTINGS
*/
/* EXPLOIT TOGGLES */
public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
/* Curve settings */
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
/* Curve values */
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
/* Global modifier */
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
/* PVP modifier */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
/* Spawned Mob modifier */
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
/* Skill modifiers */
public double getFormulaSkillModifier(PrimarySkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
/* Custom XP perk */
public double getCustomXpPerkBoost() { return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25); }
/* Diminished Returns */
public float getDiminishedReturnsCap() { return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D); }
public boolean getDiminishedReturnsEnabled() { return config.getBoolean("Diminished_Returns.Enabled", false); }
public int getDiminishedReturnsThreshold(PrimarySkillType skill) { return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000); }
public int getDiminishedReturnsTimeInterval() { return config.getInt("Diminished_Returns.Time_Interval", 10); }
/* Conversion */
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
/* Combat XP Multipliers */
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public boolean hasCombatXP(EntityType entity) {return config.contains("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
/* Materials */
public int getXp(PrimarySkillType skill, Material data)
{
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
/* Materials */
public int getXp(PrimarySkillType skill, BlockData data)
{
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data)
{
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
return config.contains(wildcardString);
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data)
{
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
return config.contains(wildcardString);
}
/*
* Experience Bar Stuff
*/
public boolean isPartyExperienceBarsEnabled()
{
return config.getBoolean("Experience_Bars.Update.Party", true);
}
public boolean isPassiveGainsExperienceBarsEnabled()
{
return config.getBoolean("Experience_Bars.Update.Passive", true);
}
public boolean getDoExperienceBarsAlwaysUpdateTitle()
{
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.Enable", false) || getAddExtraDetails();
}
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType)
{
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Color");
for(BarColor barColor : BarColor.values())
{
if(barColor.toString().equalsIgnoreCase(colorValueFromConfig))
return barColor;
}
//In case the value is invalid
return BarColor.WHITE;
}
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType)
{
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle");
for(BarStyle barStyle : BarStyle.values())
{
if(barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
return barStyle;
}
//In case the value is invalid
return BarStyle.SOLID;
}
/* Acrobatics */
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
public int getRollXPModifier() { return config.getInt("Experience.Acrobatics.Roll", 80); }
public int getFallXPModifier() { return config.getInt("Experience.Acrobatics.Fall", 120); }
public double getFeatherFallXPModifier() { return config.getDouble("Experience.Acrobatics.FeatherFall_Multiplier", 2.0); }
/* Alchemy */
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
/* Archery */
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience.Archery.Distance_Multiplier", 0.025); }
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
/* Taming */
public int getTamingXP(EntityType type)
{
return config.getInt("Experience.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
}
}

View File

@ -1,166 +0,0 @@
package com.gmail.nossr50.config.skills.repair;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.skills.ItemType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.skills.repair.repairables.RepairableFactory;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class RepairConfig extends ConfigLoader {
private List<Repairable> repairables;
public RepairConfig(String fileName) {
super(fileName);
loadKeys();
}
@Override
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
ConfigurationSection section = config.getConfigurationSection("Repairables");
Set<String> keys = section.getKeys(false);
for (String key : keys) {
if (config.contains("Repairables." + key + ".ItemId")) {
backup();
return;
}
// Validate all the things!
List<String> reason = new ArrayList<String>();
// Item Material
Material itemMaterial = Material.matchMaterial(key);
if (itemMaterial == null) {
reason.add("Invalid material: " + key);
}
// Repair Material Type
MaterialType repairMaterialType = MaterialType.OTHER;
String repairMaterialTypeString = config.getString("Repairables." + key + ".MaterialType", "OTHER");
if (!config.contains("Repairables." + key + ".MaterialType") && itemMaterial != null) {
ItemStack repairItem = new ItemStack(itemMaterial);
if (ItemUtils.isWoodTool(repairItem)) {
repairMaterialType = MaterialType.WOOD;
}
else if (ItemUtils.isStoneTool(repairItem)) {
repairMaterialType = MaterialType.STONE;
}
else if (ItemUtils.isStringTool(repairItem)) {
repairMaterialType = MaterialType.STRING;
}
else if (ItemUtils.isLeatherArmor(repairItem)) {
repairMaterialType = MaterialType.LEATHER;
}
else if (ItemUtils.isIronArmor(repairItem) || ItemUtils.isIronTool(repairItem)) {
repairMaterialType = MaterialType.IRON;
}
else if (ItemUtils.isGoldArmor(repairItem) || ItemUtils.isGoldTool(repairItem)) {
repairMaterialType = MaterialType.GOLD;
}
else if (ItemUtils.isDiamondArmor(repairItem) || ItemUtils.isDiamondTool(repairItem)) {
repairMaterialType = MaterialType.DIAMOND;
}
}
else {
try {
repairMaterialType = MaterialType.valueOf(repairMaterialTypeString);
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid MaterialType of " + repairMaterialTypeString);
}
}
// Repair Material
String repairMaterialName = config.getString("Repairables." + key + ".RepairMaterial");
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultMaterial() : Material.matchMaterial(repairMaterialName));
if (repairMaterial == null) {
reason.add(key + " has an invalid repair material: " + repairMaterialName);
}
// Maximum Durability
short maximumDurability = (itemMaterial != null ? itemMaterial.getMaxDurability() : (short) config.getInt("Repairables." + key + ".MaximumDurability"));
if (maximumDurability <= 0) {
maximumDurability = (short) config.getInt("Repairables." + key + ".MaximumDurability");
}
if (maximumDurability <= 0) {
reason.add("Maximum durability of " + key + " must be greater than 0!");
}
// Item Type
ItemType repairItemType = ItemType.OTHER;
String repairItemTypeString = config.getString("Repairables." + key + ".ItemType", "OTHER");
if (!config.contains("Repairables." + key + ".ItemType") && itemMaterial != null) {
ItemStack repairItem = new ItemStack(itemMaterial);
if (ItemUtils.isMinecraftTool(repairItem)) {
repairItemType = ItemType.TOOL;
}
else if (ItemUtils.isArmor(repairItem)) {
repairItemType = ItemType.ARMOR;
}
}
else {
try {
repairItemType = ItemType.valueOf(repairItemTypeString);
}
catch (IllegalArgumentException ex) {
reason.add(key + " has an invalid ItemType of " + repairItemTypeString);
}
}
byte repairMetadata = (byte) config.getInt("Repairables." + key + ".RepairMaterialMetadata", -1);
int minimumLevel = config.getInt("Repairables." + key + ".MinimumLevel");
double xpMultiplier = config.getDouble("Repairables." + key + ".XpMultiplier", 1);
if (minimumLevel < 0) {
reason.add(key + " has an invalid MinimumLevel of " + minimumLevel);
}
// Minimum Quantity
int minimumQuantity = (itemMaterial != null ? SkillUtils.getRepairAndSalvageQuantities(new ItemStack(itemMaterial), repairMaterial, repairMetadata) : config.getInt("Repairables." + key + ".MinimumQuantity", 2));
if (minimumQuantity <= 0 && itemMaterial != null) {
minimumQuantity = config.getInt("Repairables." + key + ".MinimumQuantity", 2);
}
if (minimumQuantity <= 0) {
reason.add("Minimum quantity of " + key + " must be greater than 0!");
}
if (noErrorsInRepairable(reason)) {
Repairable repairable = RepairableFactory.getRepairable(itemMaterial, repairMaterial, repairMetadata, minimumLevel, minimumQuantity, maximumDurability, repairItemType, repairMaterialType, xpMultiplier);
repairables.add(repairable);
}
}
}
protected List<Repairable> getLoadedRepairables() {
return repairables == null ? new ArrayList<Repairable>() : repairables;
}
private boolean noErrorsInRepairable(List<String> issues) {
for (String issue : issues) {
plugin.getLogger().warning(issue);
}
return issues.isEmpty();
}
}

View File

@ -1,42 +0,0 @@
package com.gmail.nossr50.config.skills.repair;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class RepairConfigManager {
private final List<Repairable> repairables = new ArrayList<Repairable>();
public RepairConfigManager(mcMMO plugin) {
Pattern pattern = Pattern.compile("repair\\.(?:.+)\\.yml");
File dataFolder = plugin.getDataFolder();
File vanilla = new File(dataFolder, "repair.vanilla.yml");
if (!vanilla.exists()) {
plugin.saveResource("repair.vanilla.yml", false);
}
for (String fileName : dataFolder.list()) {
if (!pattern.matcher(fileName).matches()) {
continue;
}
File file = new File(dataFolder, fileName);
if (file.isDirectory()) {
continue;
}
RepairConfig rConfig = new RepairConfig(fileName);
repairables.addAll(rConfig.getLoadedRepairables());
}
}
public List<Repairable> getLoadedRepairables() {
return repairables;
}
}

View File

@ -1,42 +0,0 @@
package com.gmail.nossr50.config.skills.salvage;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class SalvageConfigManager {
private final List<Salvageable> salvageables = new ArrayList<Salvageable>();
public SalvageConfigManager(mcMMO plugin) {
Pattern pattern = Pattern.compile("salvage\\.(?:.+)\\.yml");
File dataFolder = plugin.getDataFolder();
File vanilla = new File(dataFolder, "salvage.vanilla.yml");
if (!vanilla.exists()) {
plugin.saveResource("salvage.vanilla.yml", false);
}
for (String fileName : dataFolder.list()) {
if (!pattern.matcher(fileName).matches()) {
continue;
}
File file = new File(dataFolder, fileName);
if (file.isDirectory()) {
continue;
}
SalvageConfig salvageConfig = new SalvageConfig(fileName);
salvageables.addAll(salvageConfig.getLoadedSalvageables());
}
}
public List<Salvageable> getLoadedSalvageables() {
return salvageables;
}
}

View File

@ -1,7 +0,0 @@
package com.gmail.nossr50.datatypes.skills;
public enum ItemType {
ARMOR,
TOOL,
OTHER;
}

View File

@ -1,22 +0,0 @@
package com.gmail.nossr50.datatypes.skills;
public enum ModConfigType {
BLOCKS,
TOOLS,
ARMOR,
UNKNOWN;
public static ModConfigType getModConfigType(String materialName) {
if (materialName.contains("HELM") || (materialName.contains("CHEST") && !materialName.contains("CHESTNUT")) || materialName.contains("LEGS") || materialName.contains("LEGGINGS") || materialName.contains("BOOT")) {
return ARMOR;
}
else if (materialName.contains("PICKAXE") || materialName.contains("AXE") || (materialName.contains("BOW") && !materialName.contains("BOWL")) || materialName.contains("HOE") || materialName.contains("SHOVEL") || materialName.contains("SWORD")) {
return TOOLS;
}
else if (materialName.contains("LOG") || materialName.contains("LEAVES") || materialName.contains("FLOWER") || materialName.contains("PLANT") || materialName.contains("CROP") || materialName.contains("ORE") || materialName.contains("DIRT") || materialName.contains("SAND") || materialName.contains("GRASS")) {
return BLOCKS;
}
return UNKNOWN;
}
}

View File

@ -1,19 +0,0 @@
package com.gmail.nossr50.datatypes.skills;
public class SubSkillFlags {
/*
* Bitwise Flags
* These are so I can flag properties for subskills
* Flags are in the power of 2 because binary is a base-2 system
*/
public static final int ACTIVE = 1; //Active subskills are ones that aren't passive
public static final int SUPERABILITY = 2; // Super abilities are redundantly active
public static final int RNG = 4; //If the subskill makes use of RNG
public static final int PVP = 8; //If the subskill has properties that change in PVP conditions
public static final int TIMED = 16; //If the subskill has a duration or time component
public static final int TARGET_COLLECTION = 32; //If the subskill has multiple target types
public static final int REWARD_COLLECTION = 64; //If the subskill has multiple reward types
public static final int CHARGES = 128;
public static final int LIMITED = 256;
//public static final int RANDOM_ACTIVATION = 128; //If the subskill has random activation
}

View File

@ -1,16 +0,0 @@
package com.gmail.nossr50.events.chat;
import org.bukkit.plugin.Plugin;
/**
* Called when a chat is sent to the admin chat channel
*/
public class McMMOAdminChatEvent extends McMMOChatEvent {
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message) {
super(plugin, sender, displayName, message);
}
public McMMOAdminChatEvent(Plugin plugin, String sender, String displayName, String message, boolean isAsync) {
super(plugin, sender, displayName, message, isAsync);
}
}

View File

@ -1,34 +1,34 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.core.config.MainConfig;
import com.gmail.nossr50.core.config.ChunkConversionOptions;
import com.gmail.nossr50.core.config.WorldBlacklist;
import com.gmail.nossr50.core.data.UserManager;
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.core.skills.PrimarySkillType;
import com.gmail.nossr50.core.skills.SuperAbilityType;
import com.gmail.nossr50.core.skills.ToolType;
import com.gmail.nossr50.core.skills.child.salvage.Salvage;
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.herbalism.Herbalism;
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.repair.Repair;
import com.gmail.nossr50.core.skills.primary.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.core.util.BlockUtils;
import com.gmail.nossr50.core.util.EventUtils;
import com.gmail.nossr50.core.util.ItemUtils;
import com.gmail.nossr50.core.util.Permissions;
import com.gmail.nossr50.core.util.skills.SkillUtils;
import com.gmail.nossr50.core.util.sounds.SoundManager;
import com.gmail.nossr50.core.util.sounds.SoundType;
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
import com.gmail.nossr50.core.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.core.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
@ -62,7 +62,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
BlockFace direction = event.getDirection();
@ -85,7 +85,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
// Get opposite direction so we get correct block
@ -105,14 +105,12 @@ public class BlockListener implements Listener {
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityBlockFormEvent(EntityBlockFormEvent event)
{
public void onEntityBlockFormEvent(EntityBlockFormEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if(BlockUtils.shouldBeWatched(event.getBlock().getState()))
{
if (BlockUtils.shouldBeWatched(event.getBlock().getState())) {
mcMMO.getPlaceStore().setTrue(event.getBlock());
}
}
@ -125,14 +123,14 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onFallingBlock(EntityChangeBlockEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
if (BlockUtils.shouldBeWatched(event.getBlock().getState()) && event.getEntityType().equals(EntityType.FALLING_BLOCK)) {
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 {
List<MetadataValue> values = event.getEntity().getMetadata( "mcMMOBlockFall" );
List<MetadataValue> values = event.getEntity().getMetadata("mcMMOBlockFall");
if (!values.isEmpty()) {
@ -140,8 +138,8 @@ public class BlockListener implements Listener {
Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock();
mcMMO.getPlaceStore().setTrue( event.getBlock() );
mcMMO.getPlaceStore().setFalse( spawn );
mcMMO.getPlaceStore().setTrue(event.getBlock());
mcMMO.getPlaceStore().setFalse(spawn);
}
}
@ -156,7 +154,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPlace(BlockPlaceEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Player player = event.getPlayer();
@ -178,8 +176,7 @@ public class BlockListener implements Listener {
if (blockState.getType() == Repair.anvilMaterial && PrimarySkillType.REPAIR.getPermissions(player)) {
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();
}
}
@ -192,7 +189,7 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockMultiPlace(BlockMultiPlaceEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
Player player = event.getPlayer();
@ -201,8 +198,7 @@ public class BlockListener implements Listener {
return;
}
for (BlockState replacedBlockState : event.getReplacedBlockStates())
{
for (BlockState replacedBlockState : event.getReplacedBlockStates()) {
BlockState blockState = replacedBlockState.getBlock().getState();
/* 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)
public void onBlockGrow(BlockGrowEvent event)
{
public void onBlockGrow(BlockGrowEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
BlockState blockState = event.getBlock().getState();
@ -236,13 +231,12 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
@ -300,8 +294,7 @@ public class BlockListener implements Listener {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState);
}
else {
} else {
woodcuttingManager.woodcuttingBlockCheck(blockState);
}
}
@ -328,13 +321,12 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreakHigher(BlockBreakEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
@ -363,8 +355,7 @@ public class BlockListener implements Listener {
if (herbalismManager.processHylianLuck(blockState)) {
blockState.update(true);
event.setCancelled(true);
}
else if (blockState.getType() == Material.FLOWER_POT) {
} else if (blockState.getType() == Material.FLOWER_POT) {
blockState.setType(Material.AIR);
blockState.update(true);
event.setCancelled(true);
@ -394,13 +385,12 @@ public class BlockListener implements Listener {
BlockState blockState = event.getBlock().getState();
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
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)) {
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);
}
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);
}
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);
}
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);
}
}
@ -443,7 +429,7 @@ public class BlockListener implements Listener {
*
* We don't need to check permissions here because they've already been checked for the ability to even activate.
*/
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
if (mcMMOPlayer.getAbilityMode(SuperAbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && MainConfig.getInstance().getTreeFellerSoundsEnabled()) {
SoundManager.sendSound(player, blockState.getLocation(), SoundType.FIZZ);
}
}
@ -466,13 +452,12 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamageHigher(BlockDamageEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return;
/* WORLD GUARD MAIN FLAG CHECK */
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (!WorldGuardManager.getInstance().hasMainFlag(event.getPlayer()))
return;
}
@ -500,19 +485,16 @@ public class BlockListener implements Listener {
if (mcMMOPlayer.getHerbalismManager().processGreenTerra(blockState)) {
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)) {
event.setInstaBreak(true);
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)) {
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);
SoundManager.sendSound(player, block.getLocation(), SoundType.POP);
}
@ -532,52 +514,45 @@ public class BlockListener implements Listener {
}
public void debugStickDump(Player player, BlockState blockState) {
if(player.getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK)
{
if(mcMMO.getPlaceStore().isTrue(blockState))
if (player.getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) {
if (mcMMO.getPlaceStore().isTrue(blockState))
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");
UserManager.getPlayer(player).getExcavationManager().printExcavationDebug(player, blockState);
}
if(WorldGuardUtils.isWorldGuardLoaded())
{
if(WorldGuardManager.getInstance().hasMainFlag(player))
if (WorldGuardUtils.isWorldGuardLoaded()) {
if (WorldGuardManager.getInstance().hasMainFlag(player))
player.sendMessage("[mcMMO DEBUG] World Guard main flag is permitted for this player in this region");
else
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");
else
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;
if(furnace.hasMetadata(mcMMO.furnaceMetadataKey))
{
if (furnace.hasMetadata(mcMMO.furnaceMetadataKey)) {
player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner");
Player furnacePlayer = getPlayerFromFurnace(furnace.getBlock());
if(furnacePlayer != null)
{
player.sendMessage("[mcMMO DEBUG] This furnace is owned by player "+furnacePlayer.getName());
if (furnacePlayer != null) {
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");
}
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.");
}
}
public void cleanupAbilityTools(Player player, McMMOPlayer mcMMOPlayer, BlockState blockState, ItemStack heldItem) {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
if (ChunkConversionOptions.getInstance().useEnchantmentBuffs()) {
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER))) {
SkillUtils.removeAbilityBuff(heldItem);
}

View File

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

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