mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO
This commit is contained in:
@ -65,9 +65,8 @@ public class BlockChecks {
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customItems.contains(item)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,9 +113,8 @@ public class BlockChecks {
|
||||
if (block.getTypeId() == Config.getInstance().getRepairAnvilId() || block.getTypeId() == Config.getInstance().getSalvageAnvilId()) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,9 +140,8 @@ public class BlockChecks {
|
||||
if (customBlocksEnabled && ModChecks.isCustomOreBlock(block)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +173,7 @@ public class BlockChecks {
|
||||
* @param block Block to check
|
||||
* @return true if the block is affected, false otherwise
|
||||
*/
|
||||
public static boolean canBeGreenTerra(Block block){
|
||||
public static boolean canBeGreenTerra(Block block) {
|
||||
switch (block.getType()) {
|
||||
case BROWN_MUSHROOM:
|
||||
case CACTUS:
|
||||
@ -198,9 +195,8 @@ public class BlockChecks {
|
||||
if (block.getData() == CropState.RIPE.getData()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
default:
|
||||
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
|
||||
@ -208,9 +204,8 @@ public class BlockChecks {
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,9 +240,8 @@ public class BlockChecks {
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,9 +268,8 @@ public class BlockChecks {
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,18 +292,16 @@ public class BlockChecks {
|
||||
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLog (Block block){
|
||||
if (block.getType().equals(Material.LOG) || (customBlocksEnabled && ModChecks.isCustomLogBlock(block))) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isLog (Block block) {
|
||||
if (block.getType().equals(Material.LOG) || (customBlocksEnabled && ModChecks.isCustomLogBlock(block))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.runnables.GainXp;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
import com.gmail.nossr50.skills.combat.Axes;
|
||||
import com.gmail.nossr50.skills.axes.Axes;
|
||||
import com.gmail.nossr50.skills.swords.Swords;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
@ -335,6 +335,12 @@ public class Combat {
|
||||
}
|
||||
|
||||
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
||||
if (entity instanceof Player) {
|
||||
if (Misc.isNPC((Player) entity)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -66,10 +66,10 @@ public class Database {
|
||||
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
||||
} catch (SQLException ex) {
|
||||
connection = null;
|
||||
if(reconnectAttempt == 0 || reconnectAttempt >= 11) mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
connection = null;
|
||||
if(reconnectAttempt == 0 || reconnectAttempt >= 11) mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||
if (reconnectAttempt == 0 || reconnectAttempt >= 11) mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ public class Database {
|
||||
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
if(!checkConnected()) return;
|
||||
if (!checkConnected()) return;
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
|
@ -172,9 +172,8 @@ public class ItemChecks {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customHelmetIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,9 +195,8 @@ public class ItemChecks {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customChestplateIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,9 +218,8 @@ public class ItemChecks {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customLeggingIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,9 +241,8 @@ public class ItemChecks {
|
||||
if (customArmorEnabled && CustomArmorConfig.getInstance().customBootIDs.contains(is.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,9 +55,8 @@ public class Leaderboard {
|
||||
if (players.contains(p)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
players.add(p);
|
||||
}
|
||||
|
||||
players.add(p);
|
||||
|
||||
if (character.length > 1 && Misc.isInt(character[1])) {
|
||||
Mining.add(new PlayerStat(p, Integer.valueOf(character[1])));
|
||||
@ -302,7 +301,7 @@ public class Leaderboard {
|
||||
}
|
||||
}
|
||||
|
||||
if(!inserted) {
|
||||
if (!inserted) {
|
||||
writer.append(ps.name + ":" + ps.statVal).append("\r\n");
|
||||
}
|
||||
|
||||
|
@ -398,23 +398,22 @@ public class Metrics {
|
||||
|
||||
if (response == null || response.startsWith("ERR")) {
|
||||
throw new IOException(response); //Throw the exception
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if (response.contains("OK This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
}
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
// Is this the first update this hour?
|
||||
if (response.contains("OK This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (response.startsWith("OK")) - We should get "OK" followed by an optional description if everything goes right
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,8 +24,10 @@ public class Misc {
|
||||
|
||||
public static final int TOOL_DURABILITY_LOSS = Config.getInstance().getAbilityToolDamage();
|
||||
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
|
||||
public static final int TIME_CONVERSION_FACTOR = 1000;
|
||||
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
|
||||
|
||||
public static boolean isCitizensNPC(Player player) {
|
||||
public static boolean isNPC(Player player) {
|
||||
if (player == null || Users.getProfile(player) == null || player.hasMetadata("NPC")) {
|
||||
return true;
|
||||
}
|
||||
@ -33,6 +35,14 @@ public class Misc {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void sendSkillMessage(Player player, String message) {
|
||||
for (Player otherPlayer : player.getWorld().getPlayers()) {
|
||||
if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
|
||||
otherPlayer.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a capitalized version of the target string.
|
||||
*
|
||||
@ -82,9 +92,8 @@ public class Misc {
|
||||
if (isInt(string)) {
|
||||
return Integer.parseInt(string);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,9 +112,8 @@ public class Misc {
|
||||
if (le.getNoDamageTicks() > le.getMaximumNoDamageTicks() / 2.0F && event.getDamage() <= le.getLastDamage()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,9 +143,8 @@ public class Misc {
|
||||
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -187,9 +194,8 @@ public class Misc {
|
||||
if (first.distanceSquared(second) < (maxDistance * maxDistance)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,7 +249,7 @@ public class Misc {
|
||||
* @param quantity The amount of items to drop
|
||||
*/
|
||||
public static void randomDropItems(Location location, ItemStack is, int chance, int quantity) {
|
||||
for(int i = 0; i < quantity; i++) {
|
||||
for (int i = 0; i < quantity; i++) {
|
||||
randomDropItem(location, is, chance);
|
||||
}
|
||||
}
|
||||
@ -284,9 +290,8 @@ public class Misc {
|
||||
if (skillLevel > maxLevel) {
|
||||
return maxLevel;
|
||||
}
|
||||
else {
|
||||
return skillLevel;
|
||||
}
|
||||
|
||||
return skillLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -300,8 +305,11 @@ public class Misc {
|
||||
if (levelCap > 0) {
|
||||
return levelCap;
|
||||
}
|
||||
else {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
public static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
}
|
||||
|
@ -154,9 +154,8 @@ public class ModChecks {
|
||||
if (customToolsEnabled && toolInstance.customTools.containsKey(item.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -169,8 +168,7 @@ public class ModChecks {
|
||||
if (customArmorEnabled && armorInstance.customArmor.containsKey(item.getTypeId())) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ public class Page {
|
||||
public static int getTotalPageNumber(String address)
|
||||
{
|
||||
String[] addressSplit = LocaleLoader.getString(address).split("\n");
|
||||
if(addressSplit.length <= 8)
|
||||
if (addressSplit.length <= 8)
|
||||
return 1;
|
||||
else
|
||||
return (addressSplit.length/8)+1;
|
||||
|
||||
return (addressSplit.length/8)+1;
|
||||
}
|
||||
|
||||
public static ArrayList<String> grabPageContents(String header, String address, int pagenum)
|
||||
@ -24,7 +24,7 @@ public class Page {
|
||||
int pageIndexStart = 0;
|
||||
|
||||
//Determine what string to start at
|
||||
if(pagenum > 1)
|
||||
if (pagenum > 1)
|
||||
{
|
||||
pageIndexStart = 8*(pagenum-1);
|
||||
}
|
||||
@ -36,9 +36,9 @@ public class Page {
|
||||
|
||||
//Add targeted strings
|
||||
|
||||
while(allStrings.size() < 9)
|
||||
while (allStrings.size() < 9)
|
||||
{
|
||||
if(pageIndexStart+allStrings.size() > split.length)
|
||||
if (pageIndexStart+allStrings.size() > split.length)
|
||||
allStrings.add("");
|
||||
else
|
||||
allStrings.add(split[pageIndexStart+allStrings.size()-1]);
|
||||
@ -50,7 +50,7 @@ public class Page {
|
||||
|
||||
public static void clearChat(Player player)
|
||||
{
|
||||
for(int x = 0; x < 20; x++)
|
||||
for (int x = 0; x < 20; x++)
|
||||
{
|
||||
player.sendMessage("");
|
||||
}
|
||||
@ -62,31 +62,31 @@ public class Page {
|
||||
player.sendMessage(ChatColor.DARK_AQUA+"Guide for "+capitalized+" available type /"+skilltype.toString().toLowerCase()+" ? [Page#]"); //TODO: Needs more locale.
|
||||
if (args.length >= 1)
|
||||
{
|
||||
if(args[0].equals("?"))
|
||||
if (args[0].equals("?"))
|
||||
{
|
||||
|
||||
String address = "Guides."+capitalized;
|
||||
|
||||
if(args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address))
|
||||
if (args.length > 1 && Misc.isInt(args[1]) && Misc.getInt(args[1]) <= Page.getTotalPageNumber(address))
|
||||
{
|
||||
Page.clearChat(player);
|
||||
for(String target : Page.grabPageContents(capitalized+" Guide", address, Misc.getInt(args[1])))
|
||||
for (String target : Page.grabPageContents(capitalized+" Guide", address, Misc.getInt(args[1])))
|
||||
{
|
||||
player.sendMessage(target);
|
||||
}
|
||||
} else if(args.length == 1)
|
||||
} else if (args.length == 1)
|
||||
{
|
||||
Page.clearChat(player);
|
||||
for(String target : Page.grabPageContents(capitalized+" Guide", address, 1))
|
||||
for (String target : Page.grabPageContents(capitalized+" Guide", address, 1))
|
||||
{
|
||||
player.sendMessage(target);
|
||||
}
|
||||
}
|
||||
else if(args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address))
|
||||
else if (args.length > 1 && Misc.getInt(args[1]) > Page.getTotalPageNumber(address))
|
||||
{
|
||||
player.sendMessage("That page doesn't exist, there are only "+Page.getTotalPageNumber(address)+" total pages"); //TODO: Needs more locale.
|
||||
}
|
||||
else if(args.length > 1 && !Misc.isInt(args[1]))
|
||||
else if (args.length > 1 && !Misc.isInt(args[1]))
|
||||
{
|
||||
player.sendMessage("Not a valid page number!"); //TODO: Needs more locale.
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
||||
public class Permissions {
|
||||
public static boolean hasPermission(CommandSender sender, String perm)
|
||||
{
|
||||
if(sender.hasPermission(perm))
|
||||
if (sender.hasPermission(perm))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -14,7 +14,7 @@ public class Permissions {
|
||||
|
||||
public static boolean hasPermission(Player sender, String perm)
|
||||
{
|
||||
if(sender.hasPermission(perm))
|
||||
if (sender.hasPermission(perm))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -28,11 +26,6 @@ public class Skills {
|
||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||
|
||||
private final static int TIME_CONVERSION_FACTOR = 1000;
|
||||
private final static double MAX_DISTANCE_AWAY = 10.0;
|
||||
|
||||
private final static Random random = new Random();
|
||||
|
||||
/**
|
||||
* Checks to see if the cooldown for an item or ability is expired.
|
||||
*
|
||||
@ -41,7 +34,7 @@ public class Skills {
|
||||
* @param player The player whose cooldown is being checked
|
||||
* @return true if the cooldown is over, false otherwise
|
||||
*/
|
||||
public static boolean cooldownOver(long oldTime, int cooldown, Player player){
|
||||
public static boolean cooldownOver(long oldTime, int cooldown, Player player) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
int adjustedCooldown = cooldown;
|
||||
|
||||
@ -56,12 +49,11 @@ public class Skills {
|
||||
adjustedCooldown = (int) (adjustedCooldown * 0.75);
|
||||
}
|
||||
|
||||
if (currentTime - oldTime >= (adjustedCooldown * TIME_CONVERSION_FACTOR)) {
|
||||
if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,7 +77,7 @@ public class Skills {
|
||||
adjustedCooldown = (int) (adjustedCooldown * 0.75);
|
||||
}
|
||||
|
||||
return (int) (((deactivatedTimeStamp + (adjustedCooldown * TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / TIME_CONVERSION_FACTOR);
|
||||
return (int) (((deactivatedTimeStamp + (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,10 +88,10 @@ public class Skills {
|
||||
* @param ability The ability to watch cooldowns for
|
||||
*/
|
||||
public static void watchCooldown(Player player, PlayerProfile profile, AbilityType ability) {
|
||||
if(player == null || profile == null || ability == null)
|
||||
if (player == null || profile == null || ability == null)
|
||||
return;
|
||||
|
||||
if (!profile.getAbilityInformed(ability) && cooldownOver(profile.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
if (!profile.getAbilityInformed(ability) && cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
profile.setAbilityInformed(ability, true);
|
||||
player.sendMessage(ability.getAbilityRefresh());
|
||||
}
|
||||
@ -145,8 +137,8 @@ public class Skills {
|
||||
*/
|
||||
if (ability.getPermissions(player) && tool.inHand(inHand) && !profile.getToolPreparationMode(tool)) {
|
||||
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
|
||||
if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(profile.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player) + "s)");
|
||||
if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player) + "s)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -178,7 +170,7 @@ public class Skills {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
|
||||
if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
|
||||
profile.setToolPreparationMode(tool, false);
|
||||
|
||||
if (Config.getInstance().getAbilityMessagesEnabled()) {
|
||||
@ -187,16 +179,12 @@ public class Skills {
|
||||
}
|
||||
|
||||
if (ability.getPermissions(player)) {
|
||||
if (profile.getAbilityMode(ability) && (profile.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) <= curTime) {
|
||||
if (profile.getAbilityMode(ability) && (profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) {
|
||||
profile.setAbilityMode(ability, false);
|
||||
profile.setAbilityInformed(ability, false);
|
||||
player.sendMessage(ability.getAbilityOff());
|
||||
|
||||
for (Player nearbyPlayer : player.getWorld().getPlayers()) {
|
||||
if (nearbyPlayer != player && Misc.isNear(player.getLocation(), nearbyPlayer.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
nearbyPlayer.sendMessage(ability.getAbilityPlayerOff(player));
|
||||
}
|
||||
}
|
||||
Misc.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,9 +319,8 @@ public class Skills {
|
||||
if (getSkillType(skillName) != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -350,9 +337,8 @@ public class Skills {
|
||||
|| Permissions.unarmed(player)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -369,9 +355,8 @@ public class Skills {
|
||||
|| Permissions.woodcutting(player)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -384,9 +369,8 @@ public class Skills {
|
||||
if (Permissions.acrobatics(player) || Permissions.repair(player)) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -399,7 +383,7 @@ public class Skills {
|
||||
if (Config.getInstance().getAbilitiesDamageTools()) {
|
||||
if (inHand.containsEnchantment(Enchantment.DURABILITY)) {
|
||||
int level = inHand.getEnchantmentLevel(Enchantment.DURABILITY);
|
||||
if (random.nextInt(level + 1) > 0) {
|
||||
if (Misc.getRandom().nextInt(level + 1) > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -432,8 +416,8 @@ public class Skills {
|
||||
* We show them the too tired message when they take action.
|
||||
*/
|
||||
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
|
||||
if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(profile.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player) + "s)");
|
||||
if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player) + "s)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -459,13 +443,9 @@ public class Skills {
|
||||
if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) {
|
||||
player.sendMessage(ability.getAbilityOn());
|
||||
|
||||
for (Player y : player.getWorld().getPlayers()) {
|
||||
if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
|
||||
y.sendMessage(ability.getAbilityPlayer(player));
|
||||
}
|
||||
}
|
||||
Misc.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
||||
|
||||
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * TIME_CONVERSION_FACTOR));
|
||||
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
profile.setAbilityMode(ability, true);
|
||||
}
|
||||
}
|
||||
@ -526,14 +506,14 @@ public class Skills {
|
||||
* @param xp the amount of XP to gain
|
||||
*/
|
||||
public static void xpProcessing(Player player, PlayerProfile profile, SkillType type, int xp) {
|
||||
if(player == null)
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (type.getPermissions(player)) {
|
||||
if(Users.getPlayer(player) == null)
|
||||
if (Users.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
if((type.getMaxLevel() < profile.getSkillLevel(type) + 1) || (Misc.getPowerLevelCap() < Users.getPlayer(player).getPowerLevel() + 1))
|
||||
if ((type.getMaxLevel() < profile.getSkillLevel(type) + 1) || (Misc.getPowerLevelCap() < Users.getPlayer(player).getPowerLevel() + 1))
|
||||
return;
|
||||
|
||||
Users.getPlayer(player).addXP(type, xp);
|
||||
|
@ -6,10 +6,10 @@ public class ChunkletManagerFactory {
|
||||
public static ChunkletManager getChunkletManager() {
|
||||
HiddenConfig hConfig = HiddenConfig.getInstance();
|
||||
|
||||
if(hConfig.getChunkletsEnabled()) {
|
||||
if (hConfig.getChunkletsEnabled()) {
|
||||
return new HashChunkletManager();
|
||||
} else {
|
||||
return new NullChunkletManager();
|
||||
}
|
||||
|
||||
return new NullChunkletManager();
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,14 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
public void loadChunklet(int cx, int cy, int cz, World world) {
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
File cxDir = new File(dataDir, "" + cx);
|
||||
if(!cxDir.exists()) return;
|
||||
if (!cxDir.exists()) return;
|
||||
File czDir = new File(cxDir, "" + cz);
|
||||
if(!czDir.exists()) return;
|
||||
if (!czDir.exists()) return;
|
||||
File yFile = new File(czDir, "" + cy);
|
||||
if(!yFile.exists()) return;
|
||||
if (!yFile.exists()) return;
|
||||
|
||||
ChunkletStore in = deserializeChunkletStore(yFile);
|
||||
if(in != null) {
|
||||
if (in != null) {
|
||||
store.put(world.getName() + "," + cx + "," + cz + "," + cy, in);
|
||||
}
|
||||
}
|
||||
@ -40,11 +40,11 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
@Override
|
||||
public void unloadChunklet(int cx, int cy, int cz, World world) {
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
if(store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) {
|
||||
if (store.containsKey(world.getName() + "," + cx + "," + cz + "," + cy)) {
|
||||
File cxDir = new File(dataDir, "" + cx);
|
||||
if(!cxDir.exists()) cxDir.mkdir();
|
||||
if (!cxDir.exists()) cxDir.mkdir();
|
||||
File czDir = new File(cxDir, "" + cz);
|
||||
if(!czDir.exists()) czDir.mkdir();
|
||||
if (!czDir.exists()) czDir.mkdir();
|
||||
File yFile = new File(czDir, "" + cy);
|
||||
|
||||
ChunkletStore out = store.get(world.getName() + "," + cx + "," + cz + "," + cy);
|
||||
@ -57,19 +57,19 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
public void loadChunk(int cx, int cz, World world) {
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
File cxDir = new File(dataDir, "" + cx);
|
||||
if(!cxDir.exists()) return;
|
||||
if (!cxDir.exists()) return;
|
||||
File czDir = new File(cxDir, "" + cz);
|
||||
if(!czDir.exists()) return;
|
||||
if (!czDir.exists()) return;
|
||||
|
||||
for(int y = 0; y < 4; y++) {
|
||||
for (int y = 0; y < 4; y++) {
|
||||
File yFile = new File(czDir, "" + y);
|
||||
if(!yFile.exists()) {
|
||||
if (!yFile.exists()) {
|
||||
continue;
|
||||
} else {
|
||||
ChunkletStore in = deserializeChunkletStore(yFile);
|
||||
if(in != null) {
|
||||
store.put(world.getName() + "," + cx + "," + cz + "," + y, in);
|
||||
}
|
||||
}
|
||||
|
||||
ChunkletStore in = deserializeChunkletStore(yFile);
|
||||
if (in != null) {
|
||||
store.put(world.getName() + "," + cx + "," + cz + "," + y, in);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -78,12 +78,12 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
public void unloadChunk(int cx, int cz, World world) {
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
|
||||
for(int y = 0; y < 4; y++) {
|
||||
if(store.containsKey(world.getName() + "," + cx + "," + cz + "," + y)) {
|
||||
for (int y = 0; y < 4; y++) {
|
||||
if (store.containsKey(world.getName() + "," + cx + "," + cz + "," + y)) {
|
||||
File cxDir = new File(dataDir, "" + cx);
|
||||
if(!cxDir.exists()) cxDir.mkdir();
|
||||
if (!cxDir.exists()) cxDir.mkdir();
|
||||
File czDir = new File(cxDir, "" + cz);
|
||||
if(!czDir.exists()) czDir.mkdir();
|
||||
if (!czDir.exists()) czDir.mkdir();
|
||||
File yFile = new File(czDir, "" + y);
|
||||
|
||||
ChunkletStore out = store.get(world.getName() + "," + cx + "," + cz + "," + y);
|
||||
@ -107,16 +107,16 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
public void saveWorld(World world) {
|
||||
String worldName = world.getName();
|
||||
File dataDir = new File(world.getWorldFolder(), "mcmmo_data");
|
||||
if(!dataDir.exists())
|
||||
if (!dataDir.exists())
|
||||
dataDir.mkdirs();
|
||||
|
||||
for(String key : store.keySet()) {
|
||||
for (String key : store.keySet()) {
|
||||
String[] info = key.split(",");
|
||||
if(worldName.equals(info[0])) {
|
||||
if (worldName.equals(info[0])) {
|
||||
File cxDir = new File(dataDir, "" + info[1]);
|
||||
if(!cxDir.exists()) cxDir.mkdir();
|
||||
if (!cxDir.exists()) cxDir.mkdir();
|
||||
File czDir = new File(cxDir, "" + info[2]);
|
||||
if(!czDir.exists()) czDir.mkdir();
|
||||
if (!czDir.exists()) czDir.mkdir();
|
||||
|
||||
File yFile = new File(czDir, "" + info[3]);
|
||||
serializeChunkletStore(store.get(key), yFile);
|
||||
@ -130,9 +130,9 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
|
||||
String worldName = world.getName();
|
||||
|
||||
for(String key : store.keySet()) {
|
||||
for (String key : store.keySet()) {
|
||||
String tempWorldName = key.split(",")[0];
|
||||
if(tempWorldName.equals(worldName)) {
|
||||
if (tempWorldName.equals(worldName)) {
|
||||
store.remove(key);
|
||||
return;
|
||||
}
|
||||
@ -141,14 +141,14 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
|
||||
@Override
|
||||
public void loadWorld(World world) {
|
||||
//for(Chunk chunk : world.getLoadedChunks()) {
|
||||
//for (Chunk chunk : world.getLoadedChunks()) {
|
||||
// this.chunkLoaded(chunk.getX(), chunk.getZ(), world);
|
||||
//}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAll() {
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
saveWorld(world);
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
@Override
|
||||
public void unloadAll() {
|
||||
saveAll();
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
unloadWorld(world);
|
||||
}
|
||||
}
|
||||
@ -253,22 +253,22 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
for(String key : store.keySet()) {
|
||||
if(store.get(key).isEmpty()) {
|
||||
for (String key : store.keySet()) {
|
||||
if (store.get(key).isEmpty()) {
|
||||
String[] info = key.split(",");
|
||||
File dataDir = new File(Bukkit.getWorld(info[0]).getWorldFolder(), "mcmmo_data");
|
||||
|
||||
File cxDir = new File(dataDir, "" + info[1]);
|
||||
if(!cxDir.exists()) continue;
|
||||
if (!cxDir.exists()) continue;
|
||||
File czDir = new File(cxDir, "" + info[2]);
|
||||
if(!czDir.exists()) continue;
|
||||
if (!czDir.exists()) continue;
|
||||
|
||||
File yFile = new File(czDir, "" + info[3]);
|
||||
yFile.delete();
|
||||
|
||||
//Delete empty directories
|
||||
if(czDir.list().length == 0) czDir.delete();
|
||||
if(cxDir.list().length == 0) cxDir.delete();
|
||||
if (czDir.list().length == 0) czDir.delete();
|
||||
if (cxDir.list().length == 0) cxDir.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -282,7 +282,7 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
ObjectOutputStream objOut = null;
|
||||
|
||||
try {
|
||||
if(!location.exists())
|
||||
if (!location.exists())
|
||||
location.createNewFile();
|
||||
fileOut = new FileOutputStream(location);
|
||||
objOut = new ObjectOutputStream(fileOut);
|
||||
@ -374,9 +374,9 @@ public class HashChunkletManager implements ChunkletManager {
|
||||
// IMPORTANT! If ChunkletStoreFactory is going to be returning something other than PrimitiveEx we need to remove this, as it will be breaking time for old maps
|
||||
|
||||
/*
|
||||
if(!(storeIn instanceof PrimitiveExChunkletStore)) {
|
||||
if (!(storeIn instanceof PrimitiveExChunkletStore)) {
|
||||
ChunkletStore tempStore = ChunkletStoreFactory.getChunkletStore();
|
||||
if(storeIn != null) {
|
||||
if (storeIn != null) {
|
||||
tempStore.copyFrom(storeIn);
|
||||
}
|
||||
storeIn = tempStore;
|
||||
|
@ -23,10 +23,10 @@ public class PrimitiveChunkletStore implements ChunkletStore {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
if(store[x][z][y]) return false;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 64; y++) {
|
||||
if (store[x][z][y]) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -35,9 +35,9 @@ public class PrimitiveChunkletStore implements ChunkletStore {
|
||||
|
||||
@Override
|
||||
public void copyFrom(ChunkletStore otherStore) {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 64; y++) {
|
||||
store[x][z][y] = otherStore.isTrue(x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
if(store[x][z][y]) return false;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 64; y++) {
|
||||
if (store[x][z][y]) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,9 +40,9 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
|
||||
|
||||
@Override
|
||||
public void copyFrom(ChunkletStore otherStore) {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 64; y++) {
|
||||
store[x][z][y] = otherStore.isTrue(x, y, z);
|
||||
}
|
||||
}
|
||||
@ -54,13 +54,13 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
|
||||
byte[] buffer = new byte[2304]; // 2304 is 16*16*9
|
||||
int bufferIndex = 0;
|
||||
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
for(int y = 0; y < 64; y++) {
|
||||
if(store[x][z][y]) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < 64; y++) {
|
||||
if (store[x][z][y]) {
|
||||
byte[] temp = constructColumn(x, z);
|
||||
|
||||
for(int i = 0; i < 9; i++) {
|
||||
for (int i = 0; i < 9; i++) {
|
||||
buffer[bufferIndex] = temp[i];
|
||||
bufferIndex++;
|
||||
}
|
||||
@ -81,13 +81,13 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
|
||||
byte[] temp = new byte[9];
|
||||
|
||||
// Could probably reorganize this loop to print nasty things if it does not equal 9 or -1
|
||||
while(in.read(temp, 0, 9) == 9) {
|
||||
while (in.read(temp, 0, 9) == 9) {
|
||||
int x = addressByteX(temp[0]);
|
||||
int z = addressByteZ(temp[0]);
|
||||
boolean[] yColumn = new boolean[64];
|
||||
|
||||
for(int i = 0; i < 8; i++) {
|
||||
for(int j = 0; j < 8; j++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
yColumn[j + (i * 8)] = (temp[i + 1] & (1 << j)) != 0;
|
||||
}
|
||||
}
|
||||
@ -127,13 +127,13 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
|
||||
|
||||
column[0] = makeAddressByte(x, z);
|
||||
|
||||
for (int i = 0; i < 8; i++){
|
||||
for (int i = 0; i < 8; i++) {
|
||||
byte yCompressed = 0x0;
|
||||
int subColumnIndex = 8 * i;
|
||||
int subColumnEnd = subColumnIndex + 8;
|
||||
|
||||
for(int y = subColumnIndex; y < subColumnEnd; y++) {
|
||||
if(store[x][z][y]) {
|
||||
for (int y = subColumnIndex; y < subColumnEnd; y++) {
|
||||
if (store[x][z][y]) {
|
||||
yCompressed |= 1 << (y % 8);
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,10 @@ public class ChunkManagerFactory {
|
||||
public static ChunkManager getChunkManager() {
|
||||
HiddenConfig hConfig = HiddenConfig.getInstance();
|
||||
|
||||
if(hConfig.getChunkletsEnabled()) {
|
||||
if (hConfig.getChunkletsEnabled()) {
|
||||
return new HashChunkManager();
|
||||
} else {
|
||||
return new NullChunkManager();
|
||||
}
|
||||
|
||||
return new NullChunkManager();
|
||||
}
|
||||
}
|
@ -38,12 +38,11 @@ public class HashChunkManager implements ChunkManager {
|
||||
public synchronized void closeAll() {
|
||||
for (UUID uid : regionFiles.keySet()) {
|
||||
HashMap<Long, mcMMOSimpleRegionFile> worldRegions = regionFiles.get(uid);
|
||||
Iterator<mcMMOSimpleRegionFile> itr = worldRegions.values().iterator();
|
||||
while (itr.hasNext()) {
|
||||
mcMMOSimpleRegionFile rf = itr.next();
|
||||
for (Iterator<mcMMOSimpleRegionFile> worldRegionIterator = worldRegions.values().iterator(); worldRegionIterator.hasNext();) {
|
||||
mcMMOSimpleRegionFile rf = worldRegionIterator.next();
|
||||
if (rf != null) {
|
||||
rf.close();
|
||||
itr.remove();
|
||||
worldRegionIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,9 +61,9 @@ public class HashChunkManager implements ChunkManager {
|
||||
Object o = objectStream.readObject();
|
||||
if (o instanceof ChunkStore) {
|
||||
return (ChunkStore) o;
|
||||
} else {
|
||||
throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z);
|
||||
}
|
||||
|
||||
throw new RuntimeException("Wrong class type read for chunk meta data for " + x + ", " + z);
|
||||
} catch (IOException e) {
|
||||
// Assume the format changed
|
||||
return null;
|
||||
@ -144,19 +143,19 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void loadChunk(int cx, int cz, World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
if(store.containsKey(world.getName() + "," + cx + "," + cz))
|
||||
if (store.containsKey(world.getName() + "," + cx + "," + cz))
|
||||
return;
|
||||
|
||||
ChunkStore in = null;
|
||||
|
||||
UUID key = world.getUID();
|
||||
if(!this.oldData.containsKey(key))
|
||||
if (!this.oldData.containsKey(key))
|
||||
this.oldData.put(key, (new File(world.getWorldFolder(), "mcmmo_data")).exists());
|
||||
|
||||
if(this.oldData.containsKey(key) && oldData.get(key))
|
||||
if (this.oldData.containsKey(key) && oldData.get(key))
|
||||
convertChunk(new File(world.getWorldFolder(), "mcmmo_data"), cx, cz, world, true);
|
||||
|
||||
try {
|
||||
@ -164,20 +163,20 @@ public class HashChunkManager implements ChunkManager {
|
||||
}
|
||||
catch(Exception e) {}
|
||||
|
||||
if(in != null) {
|
||||
if (in != null) {
|
||||
store.put(world.getName() + "," + cx + "," + cz, in);
|
||||
|
||||
List<UUID> mobs = in.getSpawnedMobs();
|
||||
List<UUID> pets = in.getSpawnedPets();
|
||||
|
||||
if(mobs.isEmpty() && pets.isEmpty())
|
||||
if (mobs.isEmpty() && pets.isEmpty())
|
||||
return;
|
||||
|
||||
for(LivingEntity entity : world.getLivingEntities()) {
|
||||
if(mobs.contains(entity.getUniqueId()))
|
||||
for (LivingEntity entity : world.getLivingEntities()) {
|
||||
if (mobs.contains(entity.getUniqueId()))
|
||||
addSpawnedMob(entity);
|
||||
|
||||
if(pets.contains(entity.getUniqueId()))
|
||||
if (pets.contains(entity.getUniqueId()))
|
||||
addSpawnedPet(entity);
|
||||
}
|
||||
|
||||
@ -190,24 +189,24 @@ public class HashChunkManager implements ChunkManager {
|
||||
public synchronized void unloadChunk(int cx, int cz, World world) {
|
||||
saveChunk(cx, cz, world);
|
||||
|
||||
if(store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
||||
if (store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
||||
store.remove(world.getName() + "," + cx + "," + cz);
|
||||
|
||||
for(Entity entity : spawnedMobs) {
|
||||
if(!isEntityInChunk(entity, cx, cz, world))
|
||||
for (Entity entity : spawnedMobs) {
|
||||
if (!isEntityInChunk(entity, cx, cz, world))
|
||||
continue;
|
||||
|
||||
mobsToRemove.add(entity);
|
||||
}
|
||||
|
||||
for(Entity entity : spawnedPets) {
|
||||
if(!isEntityInChunk(entity, cx, cz, world))
|
||||
for (Entity entity : spawnedPets) {
|
||||
if (!isEntityInChunk(entity, cx, cz, world))
|
||||
continue;
|
||||
|
||||
mobsToRemove.add(entity);
|
||||
}
|
||||
|
||||
if(safeToRemoveMobs) {
|
||||
if (safeToRemoveMobs) {
|
||||
spawnedMobs.remove(mobsToRemove);
|
||||
spawnedPets.remove(mobsToRemove);
|
||||
mobsToRemove.clear();
|
||||
@ -217,14 +216,14 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void saveChunk(int cx, int cz, World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
boolean unloaded = false;
|
||||
if(!store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
||||
if (!store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||
for(Entity entity : tempSpawnedMobs) {
|
||||
if(!isEntityInChunk(entity, cx, cz, world))
|
||||
for (Entity entity : tempSpawnedMobs) {
|
||||
if (!isEntityInChunk(entity, cx, cz, world))
|
||||
continue;
|
||||
|
||||
loadChunk(cx, cz, world);
|
||||
@ -232,10 +231,10 @@ public class HashChunkManager implements ChunkManager {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!unloaded) {
|
||||
if (!unloaded) {
|
||||
List<Entity> tempSpawnedPets = new ArrayList<Entity>(spawnedPets);
|
||||
for(Entity entity : tempSpawnedPets) {
|
||||
if(!isEntityInChunk(entity, cx, cz, world))
|
||||
for (Entity entity : tempSpawnedPets) {
|
||||
if (!isEntityInChunk(entity, cx, cz, world))
|
||||
continue;
|
||||
|
||||
loadChunk(cx, cz, world);
|
||||
@ -245,31 +244,31 @@ public class HashChunkManager implements ChunkManager {
|
||||
}
|
||||
}
|
||||
|
||||
if(!store.containsKey(world.getName() + "," + cx + "," + cz) && unloaded) {
|
||||
if (!store.containsKey(world.getName() + "," + cx + "," + cz) && unloaded) {
|
||||
ChunkStore cStore = ChunkStoreFactory.getChunkStore(world, cx, cz);
|
||||
store.put(world.getName() + "," + cx + "," + cz, cStore);
|
||||
}
|
||||
|
||||
if(store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
||||
if (store.containsKey(world.getName() + "," + cx + "," + cz)) {
|
||||
ChunkStore out = store.get(world.getName() + "," + cx + "," + cz);
|
||||
|
||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||
for(Entity entity : tempSpawnedMobs) {
|
||||
if(!isEntityInChunk(entity, cx, cz, world))
|
||||
for (Entity entity : tempSpawnedMobs) {
|
||||
if (!isEntityInChunk(entity, cx, cz, world))
|
||||
continue;
|
||||
|
||||
out.addSpawnedMob(entity.getUniqueId());
|
||||
}
|
||||
|
||||
List<Entity> tempSpawnedPets = new ArrayList<Entity>(spawnedPets);
|
||||
for(Entity entity : tempSpawnedPets) {
|
||||
if(!isEntityInChunk(entity, cx, cz, world))
|
||||
for (Entity entity : tempSpawnedPets) {
|
||||
if (!isEntityInChunk(entity, cx, cz, world))
|
||||
continue;
|
||||
|
||||
out.addSpawnedPet(entity.getUniqueId());
|
||||
}
|
||||
|
||||
if(!out.isDirty())
|
||||
if (!out.isDirty())
|
||||
return;
|
||||
|
||||
writeChunkStore(world, cx, cz, out);
|
||||
@ -277,16 +276,16 @@ public class HashChunkManager implements ChunkManager {
|
||||
}
|
||||
|
||||
private boolean isEntityInChunk(Entity entity, int cx, int cz, World world) {
|
||||
if(entity == null || world == null)
|
||||
if (entity == null || world == null)
|
||||
return false;
|
||||
|
||||
if(entity.getLocation().getChunk().getX() != cx)
|
||||
if (entity.getLocation().getChunk().getX() != cx)
|
||||
return false;
|
||||
|
||||
if(entity.getLocation().getChunk().getZ() != cz)
|
||||
if (entity.getLocation().getChunk().getZ() != cz)
|
||||
return false;
|
||||
|
||||
if(entity.getWorld() != world)
|
||||
if (entity.getWorld() != world)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -294,7 +293,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized boolean isChunkLoaded(int cx, int cz, World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
return store.containsKey(world.getName() + "," + cx + "," + cz);
|
||||
@ -305,7 +304,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void chunkUnloaded(int cx, int cz, World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
ChunkletUnloader.addToList(cx, cz, world);
|
||||
@ -313,16 +312,16 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void saveWorld(World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
closeAll();
|
||||
String worldName = world.getName();
|
||||
|
||||
List<String> keys = new ArrayList<String>(store.keySet());
|
||||
for(String key : keys) {
|
||||
for (String key : keys) {
|
||||
String[] info = key.split(",");
|
||||
if(worldName.equals(info[0])) {
|
||||
if (worldName.equals(info[0])) {
|
||||
int cx = 0;
|
||||
int cz = 0;
|
||||
|
||||
@ -338,10 +337,10 @@ public class HashChunkManager implements ChunkManager {
|
||||
}
|
||||
|
||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||
for(Entity entity : tempSpawnedMobs) {
|
||||
for (Entity entity : tempSpawnedMobs) {
|
||||
World entityWorld = entity.getWorld();
|
||||
|
||||
if(world != entityWorld)
|
||||
if (world != entityWorld)
|
||||
continue;
|
||||
|
||||
int cx = entity.getLocation().getChunk().getX();
|
||||
@ -351,10 +350,10 @@ public class HashChunkManager implements ChunkManager {
|
||||
}
|
||||
|
||||
List<Entity> tempSpawnedPets = new ArrayList<Entity>(spawnedPets);
|
||||
for(Entity entity : tempSpawnedPets) {
|
||||
for (Entity entity : tempSpawnedPets) {
|
||||
World entityWorld = entity.getWorld();
|
||||
|
||||
if(world != entityWorld)
|
||||
if (world != entityWorld)
|
||||
continue;
|
||||
|
||||
int cx = entity.getLocation().getChunk().getX();
|
||||
@ -366,16 +365,16 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void unloadWorld(World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
closeAll();
|
||||
String worldName = world.getName();
|
||||
|
||||
List<String> keys = new ArrayList<String>(store.keySet());
|
||||
for(String key : keys) {
|
||||
for (String key : keys) {
|
||||
String[] info = key.split(",");
|
||||
if(worldName.equals(info[0])) {
|
||||
if (worldName.equals(info[0])) {
|
||||
int cx = 0;
|
||||
int cz = 0;
|
||||
|
||||
@ -393,10 +392,10 @@ public class HashChunkManager implements ChunkManager {
|
||||
safeToRemoveMobs = false;
|
||||
|
||||
List<Entity> tempSpawnedMobs = new ArrayList<Entity>(spawnedMobs);
|
||||
for(Entity entity : tempSpawnedMobs) {
|
||||
for (Entity entity : tempSpawnedMobs) {
|
||||
World entityWorld = entity.getWorld();
|
||||
|
||||
if(world != entityWorld)
|
||||
if (world != entityWorld)
|
||||
continue;
|
||||
|
||||
int cx = entity.getLocation().getChunk().getX();
|
||||
@ -406,10 +405,10 @@ public class HashChunkManager implements ChunkManager {
|
||||
}
|
||||
|
||||
List<Entity> tempSpawnedPets = new ArrayList<Entity>(spawnedPets);
|
||||
for(Entity entity : tempSpawnedPets) {
|
||||
for (Entity entity : tempSpawnedPets) {
|
||||
World entityWorld = entity.getWorld();
|
||||
|
||||
if(world != entityWorld)
|
||||
if (world != entityWorld)
|
||||
continue;
|
||||
|
||||
int cx = entity.getLocation().getChunk().getX();
|
||||
@ -432,7 +431,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
public synchronized void saveAll() {
|
||||
closeAll();
|
||||
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
saveWorld(world);
|
||||
}
|
||||
}
|
||||
@ -441,14 +440,14 @@ public class HashChunkManager implements ChunkManager {
|
||||
public synchronized void unloadAll() {
|
||||
closeAll();
|
||||
|
||||
for(World world : Bukkit.getWorlds()) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
unloadWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean isTrue(int x, int y, int z, World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return false;
|
||||
|
||||
int cx = x / 16;
|
||||
@ -472,7 +471,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized boolean isTrue(Block block) {
|
||||
if(block == null)
|
||||
if (block == null)
|
||||
return false;
|
||||
|
||||
return isTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
@ -480,7 +479,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void setTrue(int x, int y, int z, World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
int cx = x / 16;
|
||||
@ -507,7 +506,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void setTrue(Block block) {
|
||||
if(block == null)
|
||||
if (block == null)
|
||||
return;
|
||||
|
||||
setTrue(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
@ -515,7 +514,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void setFalse(int x, int y, int z, World world) {
|
||||
if(world == null)
|
||||
if (world == null)
|
||||
return;
|
||||
|
||||
int cx = x / 16;
|
||||
@ -541,7 +540,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
|
||||
@Override
|
||||
public synchronized void setFalse(Block block) {
|
||||
if(block == null)
|
||||
if (block == null)
|
||||
return;
|
||||
|
||||
setFalse(block.getX(), block.getY(), block.getZ(), block.getWorld());
|
||||
@ -555,21 +554,21 @@ public class HashChunkManager implements ChunkManager {
|
||||
}
|
||||
|
||||
public synchronized void convertChunk(File dataDir, int cx, int cz, World world, boolean actually) {
|
||||
if(!actually)
|
||||
if (!actually)
|
||||
return;
|
||||
if(!dataDir.exists()) return;
|
||||
if (!dataDir.exists()) return;
|
||||
File cxDir = new File(dataDir, "" + cx);
|
||||
if(!cxDir.exists()) return;
|
||||
if (!cxDir.exists()) return;
|
||||
File czDir = new File(cxDir, "" + cz);
|
||||
if(!czDir.exists()) return;
|
||||
if (!czDir.exists()) return;
|
||||
|
||||
boolean conversionSet = false;
|
||||
|
||||
for(BlockStoreConversionZDirectory converter : this.converters) {
|
||||
if(converter == null)
|
||||
for (BlockStoreConversionZDirectory converter : this.converters) {
|
||||
if (converter == null)
|
||||
continue;
|
||||
|
||||
if(converter.taskID >= 0)
|
||||
if (converter.taskID >= 0)
|
||||
continue;
|
||||
|
||||
converter.start(world, cxDir, czDir);
|
||||
@ -577,7 +576,7 @@ public class HashChunkManager implements ChunkManager {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!conversionSet) {
|
||||
if (!conversionSet) {
|
||||
BlockStoreConversionZDirectory converter = new BlockStoreConversionZDirectory();
|
||||
converter.start(world, cxDir, czDir);
|
||||
converters.add(converter);
|
||||
@ -593,22 +592,22 @@ public class HashChunkManager implements ChunkManager {
|
||||
}
|
||||
|
||||
public void addSpawnedMob(Entity entity) {
|
||||
if(!isSpawnedMob(entity))
|
||||
if (!isSpawnedMob(entity))
|
||||
spawnedMobs.add(entity);
|
||||
}
|
||||
|
||||
public void addSpawnedPet(Entity entity) {
|
||||
if(!isSpawnedPet(entity))
|
||||
if (!isSpawnedPet(entity))
|
||||
spawnedPets.add(entity);
|
||||
}
|
||||
|
||||
public void removeSpawnedMob(Entity entity) {
|
||||
if(isSpawnedMob(entity))
|
||||
if (isSpawnedMob(entity))
|
||||
spawnedMobs.remove(entity);
|
||||
}
|
||||
|
||||
public void removeSpawnedPet(Entity entity) {
|
||||
if(isSpawnedPet(entity))
|
||||
if (isSpawnedPet(entity))
|
||||
spawnedPets.remove(entity);
|
||||
}
|
||||
}
|
||||
|
@ -82,10 +82,10 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
for(int y = 0; y < this.worldHeight; y++) {
|
||||
if(store[x][z][y]) return false;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < this.worldHeight; y++) {
|
||||
if (store[x][z][y]) return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -94,9 +94,9 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
|
||||
@Override
|
||||
public void copyFrom(ChunkletStore otherStore) {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
for(int y = 0; y < this.worldHeight; y++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < this.worldHeight; y++) {
|
||||
store[x][z][y] = otherStore.isTrue(x, y, z);
|
||||
}
|
||||
}
|
||||
@ -113,42 +113,42 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
}
|
||||
|
||||
public void addSpawnedMob(UUID id) {
|
||||
if(!isSpawnedMob(id)) {
|
||||
if (!isSpawnedMob(id)) {
|
||||
spawnedMobs.add(id);
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void addSpawnedPet(UUID id) {
|
||||
if(!isSpawnedPet(id)) {
|
||||
if (!isSpawnedPet(id)) {
|
||||
spawnedPets.add(id);
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSpawnedMob(UUID id) {
|
||||
if(isSpawnedMob(id)) {
|
||||
if (isSpawnedMob(id)) {
|
||||
spawnedMobs.remove(id);
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSpawnedPet(UUID id) {
|
||||
if(isSpawnedPet(id)) {
|
||||
if (isSpawnedPet(id)) {
|
||||
spawnedPets.remove(id);
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSpawnedMobs() {
|
||||
if(!spawnedMobs.isEmpty()) {
|
||||
if (!spawnedMobs.isEmpty()) {
|
||||
spawnedMobs.clear();
|
||||
dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearSpawnedPets() {
|
||||
if(!spawnedPets.isEmpty()) {
|
||||
if (!spawnedPets.isEmpty()) {
|
||||
spawnedPets.clear();
|
||||
dirty = true;
|
||||
}
|
||||
@ -204,16 +204,16 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
store = (boolean[][][]) in.readObject();
|
||||
|
||||
if (fileVersionNumber < CURRENT_VERSION) {
|
||||
if(fileVersionNumber < 5)
|
||||
if (fileVersionNumber < 5)
|
||||
fixArray();
|
||||
if(fileVersionNumber < 6) {
|
||||
if (fileVersionNumber < 6) {
|
||||
spawnedMobs = new ArrayList<UUID>();
|
||||
spawnedPets = new ArrayList<UUID>();
|
||||
}
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if(fileVersionNumber >= 6) {
|
||||
if (fileVersionNumber >= 6) {
|
||||
//What do we want to do about this? These casts are unchecked.
|
||||
spawnedMobs = (ArrayList<UUID>) in.readObject();
|
||||
spawnedPets = (ArrayList<UUID>) in.readObject();
|
||||
@ -223,9 +223,9 @@ public class PrimitiveChunkStore implements ChunkStore {
|
||||
private void fixArray() {
|
||||
boolean[][][] temp = this.store;
|
||||
this.store = new boolean[16][16][this.worldHeight];
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
for(int y = 0; y < this.worldHeight; y++) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < this.worldHeight; y++) {
|
||||
try {
|
||||
store[x][z][y] = temp[x][y][z];
|
||||
}
|
||||
|
Reference in New Issue
Block a user