mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-19 18:33:00 +01:00
Compare commits
2 Commits
dev-capfan
...
1.4.06-rer
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9957ca41a8 | ||
|
|
00e18d4096 |
@@ -7,50 +7,7 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.5.04-SNAPSHOT
|
||||
+ Added option to config.yml to truncate existing player skill levels that exceed the skill level cap
|
||||
+ Falling blocks persist mcMMO natural data
|
||||
= Woodcutting double drops correctly identify acacia and dark oak logs
|
||||
= Skill Reset command now correctly identifies arguments
|
||||
= Hylian Treasure config options are now actually used
|
||||
= Child skills now use parent skills configured skill caps properly
|
||||
! Flux mining now simulates a block break event for other plugins to act upon
|
||||
! Zombie Pigmen spawned from nether portals are now considered spawner mobs
|
||||
! Flux Pickaxe lore now appends to existing lore as opposed to replacing it
|
||||
! Party chat no longer displays colors when logged in server console
|
||||
- Treefeller no longer lowers exp for big trees
|
||||
|
||||
Version 1.5.03
|
||||
= Fixed bug where absorption hearts could be attacked by allied players
|
||||
= Fixed bug where new forms of stone would drop the wrong type when mined with Silk Touch
|
||||
= Fixed bug where blocks would not get tracked correctly when using sticky pistons and slime blocks in certain situations
|
||||
= Fixed bug where config value for Daze damage was ignored
|
||||
= Fixed UUID updater to not lose data on errors
|
||||
= Fixed bug where uuid update could result in large amounts of user data being deleted
|
||||
= Fixed bug where custom potions were missed in potion stage calculation
|
||||
= Fixed piston dupe bugs permanently
|
||||
= Fixed bug involving user name changes
|
||||
= Fixed old user purge to properly calculate months
|
||||
= Fixed bug where Repair would incorrectly check items
|
||||
= Fixed bug where apostrophes in locale files would not read correctly
|
||||
= Fixed bug where treasure data was limited to 255 instead of Short.MAX_VALUE
|
||||
! Moved more user loading calculations to async loading thread to reduce lag on login
|
||||
|
||||
Version 1.5.02
|
||||
+ Added option to config.yml for Chimaera Wings to stop using bed spawn points
|
||||
+ Added option to config.yml to let non-tools in hand count as unarmed
|
||||
+ Added option to experience.yml to control XP gained by killing bred animals
|
||||
+ Added support for 1.8 mobs and features
|
||||
= Fixed bug where no Mining XP was granted when Flux Mining was successful
|
||||
= Fixed bug with UUID conversions in Flatfile
|
||||
= Fixed a couple Dupe bugs that were introduced recently
|
||||
= Fixed bug where MobHealthbarTypes were not saved between server restarts
|
||||
! Changed Flux Mining mechanics. In order to use the ability, you need to infuse a pickaxe with furnace powers first.
|
||||
! Scoreboard tips are only shown a couple of times to the player, instead of once per login session
|
||||
! Changed Archery distance multiplier to be configurable
|
||||
! Archery distance XP bonus cannot exceed indefinitely anymore
|
||||
|
||||
Version 1.5.01
|
||||
Version 1.5.01-dev
|
||||
+ Added new child skill; Salvage
|
||||
+ Added UUID support!
|
||||
+ Added SQL connection pooling and async loading!
|
||||
@@ -99,7 +56,6 @@ Version 1.5.01
|
||||
! Changed Alchemy XP distribution. XP is granted based on the stage of the potion.
|
||||
! Changed behavior of the Blast Mining ability "Demolition Expert"; now only decreases damage for the ability user
|
||||
! Updated for new getOnlinePlayers() behavior
|
||||
! Updated for new blocks and entities
|
||||
! Changed McMMOPlayerDeathPenaltyEvent to get fired after hardcore penalty calculations, use McMMOPlayerPreDeathPenaltyEvent for old behavior
|
||||
! Moved Refresh_Chunks setting from hidden.yml to config.yml
|
||||
- Removed salvage ability from Repair, salvage has it's own (child) skill now
|
||||
|
||||
@@ -10,10 +10,11 @@ The goal of mcMMO is to take core Minecraft game mechanics and expand them into
|
||||
## About the Team
|
||||
|
||||
mcMMO is currently developed by a team of individuals from all over the world.
|
||||
|
||||
### Developers
|
||||
### Glorious Leader
|
||||
[]
|
||||
(https://github.com/gmcferrin)
|
||||
|
||||
### Developers
|
||||
[]
|
||||
(https://github.com/bm01)
|
||||
[]
|
||||
@@ -47,4 +48,4 @@ Required Libraries:
|
||||
* EMetrics
|
||||
* Bukkit
|
||||
|
||||
http://www.spigotmc.org/resources/mcmmo.2445/ for more up to date information.
|
||||
http://dev.bukkit.org/server-mods/mcmmo for more up to date information.
|
||||
|
||||
40
pom.xml
40
pom.xml
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.5.04-SNAPSHOT</version>
|
||||
<version>1.5.01-SNAPSHOT</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -38,14 +38,6 @@
|
||||
<include>*.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}</directory>
|
||||
<includes>
|
||||
<include>LICENSE</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -83,17 +75,12 @@
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.turt2live.metrics:MetricsExtension</include>
|
||||
<include>commons-logging:commons-logging</include>
|
||||
<include>org.apache.tomcat:tomcat-jdbc</include>
|
||||
<include>org.apache.tomcat:tomcat-juli</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.turt2live.metrics</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.metrics.mcstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.apache.commons.logging</pattern>
|
||||
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern>
|
||||
@@ -128,8 +115,12 @@
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>md_5-releases</id>
|
||||
<url>http://repo.md-5.net/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>Plugin MetricsExtension</id>
|
||||
@@ -140,7 +131,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.8-R0.1-SNAPSHOT</version>
|
||||
<version>1.7.10-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
@@ -150,11 +141,6 @@
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.turt2live.metrics</groupId>
|
||||
<artifactId>MetricsExtension</artifactId>
|
||||
<version>0.0.5-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>tomcat-jdbc</artifactId>
|
||||
@@ -164,15 +150,19 @@
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>drtshock-releases</id>
|
||||
<url>https://ci.drtshock.net/plugin/repository/everything/com/gmail/nossr50/mcMMO/</url>
|
||||
<id>md_5-releases</id>
|
||||
<url>http://repo.md-5.net/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>md_5-snapshots</id>
|
||||
<url>http://repo.md-5.net/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<ciManagement>
|
||||
<system>Jenkins</system>
|
||||
<url>https://ci.drtshock.net/job/mcmmo/</url>
|
||||
<url>http://ci.ecocitycraft.com/job/mcMMO</url>
|
||||
</ciManagement>
|
||||
</project>
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@@ -18,6 +16,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public abstract class ExperienceCommand implements TabExecutor {
|
||||
@@ -72,12 +71,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
UUID uuid = null;
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
uuid = player.getUniqueId();
|
||||
}
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
|
||||
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.gmail.nossr50.commands.experience;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@@ -21,6 +19,7 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -30,7 +29,6 @@ import com.google.common.collect.ImmutableList;
|
||||
public class SkillresetCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
SkillType skill;
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
@@ -46,14 +44,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("all")) {
|
||||
skill = null;
|
||||
}
|
||||
else {
|
||||
skill = SkillType.getSkill(args[1]);
|
||||
}
|
||||
|
||||
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill);
|
||||
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), SkillType.getSkill(args[0]));
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
@@ -66,6 +57,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType skill;
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
skill = null;
|
||||
}
|
||||
@@ -78,12 +70,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
|
||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||
if (mcMMOPlayer == null) {
|
||||
UUID uuid = null;
|
||||
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(playerName);
|
||||
if (player != null) {
|
||||
uuid = player.getUniqueId();
|
||||
}
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, uuid, false);
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false);
|
||||
|
||||
if (CommandUtils.unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
@@ -147,7 +134,7 @@ public class SkillresetCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
private boolean validateArguments(CommandSender sender, String skillName) {
|
||||
return skillName.equalsIgnoreCase("all") || !CommandUtils.isInvalidSkill(sender, skillName);
|
||||
return !(CommandUtils.isInvalidSkill(sender, skillName) && !skillName.equalsIgnoreCase("all"));
|
||||
}
|
||||
|
||||
protected static void handleSenderMessage(CommandSender sender, String playerName, SkillType skill) {
|
||||
|
||||
@@ -12,8 +12,6 @@ import java.util.Set;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
|
||||
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
public AutoUpdateConfigLoader(String relativePath, String fileName) {
|
||||
super(relativePath, fileName);
|
||||
@@ -116,13 +114,5 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (String key : configKeys) {
|
||||
if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) {
|
||||
MetricsManager.customConfig();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
/* Scoreboards */
|
||||
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); }
|
||||
@@ -373,21 +372,16 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
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 getFluxPickaxeEnabled() { return config.getBoolean("Items.Flux_Pickaxe.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 getBleedEffectEnabled() { return config.getBoolean("Particles.Bleed", 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); }
|
||||
@@ -498,7 +492,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
/* 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); }
|
||||
|
||||
/* Taming */
|
||||
public Material getTamingCOTWMaterial(EntityType type) { return Material.matchMaterial(config.getString("Skills.Taming.Call_Of_The_Wild." + StringUtils.getPrettyEntityTypeString(type) + ".Item_Material")); }
|
||||
@@ -528,8 +521,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
return (cap <= 0) ? Integer.MAX_VALUE : cap;
|
||||
}
|
||||
|
||||
public boolean getTruncateSkills() { return config.getBoolean("General.TruncateSkills", false); }
|
||||
|
||||
/* PVP & PVE Settings */
|
||||
public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
|
||||
public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
|
||||
|
||||
@@ -72,11 +72,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
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!");
|
||||
@@ -93,11 +88,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/* 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!");
|
||||
@@ -182,7 +172,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
|
||||
/* 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(SkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
|
||||
@@ -209,7 +198,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
|
||||
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
|
||||
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
|
||||
public double getElderGuardianXP() { return config.getDouble("Experience.Combat.Multiplier.Elder_Guardian", 4.0); }
|
||||
|
||||
/* Materials */
|
||||
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
|
||||
@@ -224,9 +212,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
/* 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); }
|
||||
|
||||
/* Excavation */
|
||||
public int getDirtAndSandXp(MaterialData data) {
|
||||
Material type = data.getItemType();
|
||||
@@ -383,5 +368,4 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
|
||||
public int getWoodcuttingTreeXP(TreeSpecies species) { return config.getInt("Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
|
||||
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
|
||||
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
|
||||
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -118,14 +117,11 @@ public class PotionConfig extends ConfigLoader {
|
||||
short dataValue = Short.parseShort(potion_section.getName());
|
||||
|
||||
String name = potion_section.getString("Name");
|
||||
if (name != null) {
|
||||
name = ChatColor.translateAlternateColorCodes('&', name);
|
||||
}
|
||||
|
||||
List<String> lore = new ArrayList<String>();
|
||||
if (potion_section.contains("Lore")) {
|
||||
for (String line : potion_section.getStringList("Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
lore.add(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -57,7 +56,6 @@ public class TreasureConfig extends ConfigLoader {
|
||||
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromPig = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromPigZombie = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromPlayer = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSheep = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSkeleton = new ArrayList<ShakeTreasure>();
|
||||
public List<ShakeTreasure> shakeFromSlime = new ArrayList<ShakeTreasure>();
|
||||
@@ -176,17 +174,12 @@ public class TreasureConfig extends ConfigLoader {
|
||||
else if (materialName.contains("INK_SACK")) {
|
||||
material = Material.INK_SACK;
|
||||
}
|
||||
else if (materialName.contains("INVENTORY")) {
|
||||
// Use magic material BED_BLOCK to know that we're grabbing something from the inventory and not a normal treasure
|
||||
shakeFromPlayer.add(new ShakeTreasure(new ItemStack(Material.BED_BLOCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
material = Material.matchMaterial(materialName);
|
||||
}
|
||||
|
||||
int amount = config.getInt(type + "." + treasureName + ".Amount");
|
||||
short data = (treasureInfo.length == 2) ? Short.parseShort(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
||||
short data = (treasureInfo.length == 2) ? Byte.valueOf(treasureInfo[1]) : (short) config.getInt(type + "." + treasureName + ".Data");
|
||||
|
||||
if (material == null) {
|
||||
reason.add("Invalid material: " + materialName);
|
||||
@@ -243,22 +236,6 @@ public class TreasureConfig extends ConfigLoader {
|
||||
|
||||
try {
|
||||
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
List<String> lore = new ArrayList<String>();
|
||||
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
}
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Potion_Type: " + potionType);
|
||||
@@ -272,22 +249,6 @@ public class TreasureConfig extends ConfigLoader {
|
||||
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
|
||||
|
||||
item = dye.toItemStack(amount);
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
List<String> lore = new ArrayList<String>();
|
||||
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
}
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Dye_Color: " + color);
|
||||
@@ -298,17 +259,13 @@ public class TreasureConfig extends ConfigLoader {
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
|
||||
itemMeta.setDisplayName(config.getString(type + "." + treasureName + ".Custom_Name"));
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Lore")) {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
List<String> lore = new ArrayList<String>();
|
||||
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
|
||||
lore.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
}
|
||||
itemMeta.setLore(lore);
|
||||
itemMeta.setLore(config.getStringList(type + "." + treasureName + ".Lore"));
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
@@ -359,9 +316,6 @@ public class TreasureConfig extends ConfigLoader {
|
||||
else if (type.equals("Shake.PIG_ZOMBIE")) {
|
||||
shakeFromPigZombie.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.PLAYER")) {
|
||||
shakeFromPlayer.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SHEEP")) {
|
||||
shakeFromSheep.add(shakeTreasure);
|
||||
}
|
||||
@@ -481,11 +435,6 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getInventoryStealEnabled() { return config.contains("Shake.PLAYER.INVENTORY"); }
|
||||
public boolean getInventoryStealStacks() { return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks"); }
|
||||
public double getInventoryStealDropChance() { return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance"); }
|
||||
public int getInventoryStealDropLevel() { return config.getInt("Shake.PLAYER.INVENTORY.Drop_Level"); }
|
||||
|
||||
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
||||
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
|
||||
public interface DatabaseManager {
|
||||
// One month in milliseconds
|
||||
public final long PURGE_TIME = 2630000000L * Config.getInstance().getOldUsersCutoff();
|
||||
// One month in seconds
|
||||
public final long PURGE_TIME = 2630000L * Config.getInstance().getOldUsersCutoff();
|
||||
// During convertUsers, how often to output a status
|
||||
public final int progressInterval = 200;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class DatabaseManagerFactory {
|
||||
*/
|
||||
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
||||
try {
|
||||
clazz.getConstructor();
|
||||
clazz.getConstructor((Class<?>) null);
|
||||
customManager = clazz;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
@@ -78,10 +78,10 @@ public class DatabaseManagerFactory {
|
||||
}
|
||||
|
||||
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
|
||||
return customManager.getConstructor().newInstance();
|
||||
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
||||
}
|
||||
|
||||
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
|
||||
return clazz.getConstructor().newInstance();
|
||||
return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumMap;
|
||||
@@ -139,7 +138,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
String name = character[USERNAME];
|
||||
String name = character[0];
|
||||
long lastPlayed = 0;
|
||||
boolean rewrite = false;
|
||||
try {
|
||||
@@ -214,7 +213,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Write out the same file but when we get to the player we want to remove, we skip his line.
|
||||
if (!worked && line.split(":")[USERNAME].equalsIgnoreCase(playerName)) {
|
||||
if (!worked && line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
mcMMO.p.getLogger().info("User found, removing...");
|
||||
worked = true;
|
||||
continue; // Skip the player
|
||||
@@ -273,7 +272,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
while ((line = in.readLine()) != null) {
|
||||
// Read the line in and copy it to the output if it's not the player we want to edit
|
||||
String[] character = line.split(":");
|
||||
if (!(uuid != null && character[UUID_INDEX].equalsIgnoreCase(uuid.toString())) && !character[USERNAME].equalsIgnoreCase(playerName)) {
|
||||
if (!character[41].equalsIgnoreCase(uuid.toString()) && !character[0].equalsIgnoreCase(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
@@ -320,8 +319,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
writer.append(mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
|
||||
writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":");
|
||||
writer.append(uuid != null ? uuid.toString() : "NULL").append(":");
|
||||
writer.append(profile.getScoreboardTipsShown()).append(":");
|
||||
writer.append(uuid.toString()).append(":");
|
||||
writer.append("\r\n");
|
||||
}
|
||||
}
|
||||
@@ -428,7 +426,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
out.append("0:"); // Alchemy
|
||||
out.append("0:"); // AlchemyXp
|
||||
out.append(uuid != null ? uuid.toString() : "NULL").append(":"); // UUID
|
||||
out.append("0:"); // Scoreboard tips shown
|
||||
|
||||
// Add more in the same format as the line above
|
||||
|
||||
out.newLine();
|
||||
@@ -474,20 +472,20 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
// Compare names because we don't have a valid uuid for that player even
|
||||
// if input uuid is not null
|
||||
if (character[UUID_INDEX].equalsIgnoreCase("NULL")) {
|
||||
if (!character[USERNAME].equalsIgnoreCase(playerName)) {
|
||||
if (character[41].equalsIgnoreCase("NULL")) {
|
||||
if (!character[0].equalsIgnoreCase(playerName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// If input uuid is not null then we should compare uuids
|
||||
else if ((uuid != null && !character[UUID_INDEX].equalsIgnoreCase(uuid.toString())) || (uuid == null && !character[USERNAME].equalsIgnoreCase(playerName))) {
|
||||
else if ((uuid != null && !character[41].equalsIgnoreCase(uuid.toString())) || (uuid == null && !character[0].equalsIgnoreCase(playerName))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update playerName in database after name change
|
||||
if (!character[USERNAME].equalsIgnoreCase(playerName)) {
|
||||
mcMMO.p.debug("Name change detected: " + character[USERNAME] + " => " + playerName);
|
||||
character[USERNAME] = playerName;
|
||||
if (!character[0].equalsIgnoreCase(playerName)) {
|
||||
mcMMO.p.debug("Name change detected: " + character[0] + " => " + playerName);
|
||||
character[0] = playerName;
|
||||
}
|
||||
|
||||
return loadFromLine(character);
|
||||
@@ -573,7 +571,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
public boolean saveUserUUID(String userName, UUID uuid) {
|
||||
boolean worked = false;
|
||||
|
||||
int i = 0;
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
@@ -586,18 +583,17 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
if (!worked && character[USERNAME].equalsIgnoreCase(userName)) {
|
||||
if (!worked && character[0].equalsIgnoreCase(userName)) {
|
||||
if (character.length < 42) {
|
||||
mcMMO.p.getLogger().severe("Could not update UUID for " + userName + "!");
|
||||
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
line = line.replace(character[UUID_INDEX], uuid.toString());
|
||||
line = line.replace(character[41], uuid.toString());
|
||||
worked = true;
|
||||
}
|
||||
|
||||
i++;
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
|
||||
@@ -608,7 +604,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
mcMMO.p.getLogger().info(i + " entries written while saving UUID for " + userName);
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
@@ -635,7 +630,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
String usersFilePath = mcMMO.getUsersFilePath();
|
||||
int i = 0;
|
||||
|
||||
synchronized (fileWritingLock) {
|
||||
try {
|
||||
@@ -643,20 +637,19 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line;
|
||||
|
||||
while (((line = in.readLine()) != null)) {
|
||||
while (((line = in.readLine()) != null) && !fetchedUUIDs.isEmpty()) {
|
||||
String[] character = line.split(":");
|
||||
if (!fetchedUUIDs.isEmpty() && fetchedUUIDs.containsKey(character[USERNAME])) {
|
||||
if (fetchedUUIDs.containsKey(character[0])) {
|
||||
if (character.length < 42) {
|
||||
mcMMO.p.getLogger().severe("Could not update UUID for " + character[USERNAME] + "!");
|
||||
mcMMO.p.getLogger().severe("Could not update UUID for " + character[0] + "!");
|
||||
mcMMO.p.getLogger().severe("Database entry is invalid.");
|
||||
continue;
|
||||
}
|
||||
|
||||
character[UUID_INDEX] = fetchedUUIDs.remove(character[USERNAME]).toString();
|
||||
character[41] = fetchedUUIDs.remove(character[0]).toString();
|
||||
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
|
||||
}
|
||||
|
||||
i++;
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
|
||||
@@ -667,7 +660,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
}
|
||||
finally {
|
||||
mcMMO.p.getLogger().info(i + " entries written while saving UUID batch");
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
@@ -703,7 +695,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] character = line.split(":");
|
||||
users.add(character[USERNAME]);
|
||||
users.add(character[0]);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -761,7 +753,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
String[] data = line.split(":");
|
||||
playerName = data[USERNAME];
|
||||
playerName = data[0];
|
||||
int powerLevel = 0;
|
||||
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
|
||||
@@ -857,20 +849,15 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
if (line.charAt(line.length() - 1) != ':') {
|
||||
line = line.concat(":");
|
||||
}
|
||||
boolean updated = false;
|
||||
String[] character = line.split(":");
|
||||
|
||||
// Prevent the same username from being present multiple times
|
||||
if (!usernames.add(character[USERNAME])) {
|
||||
character[USERNAME] = "_INVALID_OLD_USERNAME_'";
|
||||
updated = true;
|
||||
if (character.length < UUID_INDEX + 1 || character[UUID_INDEX].equals("NULL")) {
|
||||
continue;
|
||||
}
|
||||
if (!usernames.add(character[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Prevent the same player from being present multiple times
|
||||
if (character.length >= 42 && (!character[UUID_INDEX].isEmpty() && !character[UUID_INDEX].equals("NULL") && !players.add(character[UUID_INDEX]))) {
|
||||
if (character.length == 42 && (!character[41].isEmpty() && !players.add(character[41]))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -882,54 +869,39 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
String oldVersion = null;
|
||||
|
||||
if (character.length > 33 && !character[33].isEmpty()) {
|
||||
// Removal of Spout Support
|
||||
// Version 1.4.07-dev2
|
||||
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
|
||||
character[33] = "";
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.07";
|
||||
}
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getTruncateSkills()) {
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
int index = getSkillIndex(skill);
|
||||
if (index >= character.length) {
|
||||
continue;
|
||||
}
|
||||
int cap = Config.getInstance().getLevelCap(skill);
|
||||
if (Integer.valueOf(character[index]) > cap) {
|
||||
mcMMO.p.getLogger().warning("Truncating " + skill.getName() + " to configured max level for player " + character[USERNAME]);
|
||||
character[index] = cap + "";
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If they're valid, rewrite them to the file.
|
||||
if (!updated && character.length == 43) {
|
||||
writer.append(line).append("\r\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character.length <= 33) {
|
||||
// Introduction of HUDType
|
||||
// Version 1.1.06
|
||||
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
|
||||
character = Arrays.copyOf(character, character.length + 1);
|
||||
character[character.length - 1] = "";
|
||||
line = line.concat(" :");
|
||||
character = line.split(":");
|
||||
oldVersion = "1.1.06";
|
||||
}
|
||||
|
||||
if (!character[33].isEmpty()) {
|
||||
// Removal of Spout Support
|
||||
// Version 1.4.07-dev2
|
||||
// commit 7bac0e2ca5143bce84dc160617fed97f0b1cb968
|
||||
line = line.replace(character[33], "");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.07";
|
||||
}
|
||||
}
|
||||
|
||||
// If they're valid, rewrite them to the file.
|
||||
if (character.length == 42) {
|
||||
writer.append(line).append("\r\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
StringBuilder newLine = new StringBuilder(line);
|
||||
|
||||
if (character.length <= 35) {
|
||||
// Introduction of Fishing
|
||||
// Version 1.2.00
|
||||
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
|
||||
character = Arrays.copyOf(character, character.length + 2);
|
||||
character[character.length - 1] = "0";
|
||||
character[character.length - 2] = "0";
|
||||
newLine.append(0).append(":");
|
||||
newLine.append(0).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.2.00";
|
||||
}
|
||||
@@ -938,8 +910,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
// Introduction of Blast Mining cooldowns
|
||||
// Version 1.3.00-dev
|
||||
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
|
||||
character = Arrays.copyOf(character, character.length + 1);
|
||||
character[character.length - 1] = "0";
|
||||
newLine.append(0).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.3.00";
|
||||
}
|
||||
@@ -949,8 +920,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
// Version 1.4.00-dev
|
||||
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
|
||||
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
|
||||
character = Arrays.copyOf(character, character.length + 1);
|
||||
character[character.length - 1] = "0";
|
||||
newLine.append("0").append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.00";
|
||||
}
|
||||
@@ -959,8 +929,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
// Addition of mob healthbars
|
||||
// Version 1.4.06
|
||||
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
|
||||
character = Arrays.copyOf(character, character.length + 1);
|
||||
character[character.length - 1] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.06";
|
||||
}
|
||||
@@ -968,9 +937,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
if (character.length <= 39) {
|
||||
// Addition of Alchemy
|
||||
// Version 1.4.08
|
||||
character = Arrays.copyOf(character, character.length + 2);
|
||||
character[character.length - 1] = "0";
|
||||
character[character.length - 2] = "0";
|
||||
newLine.append("0").append(":");
|
||||
newLine.append("0").append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.4.08";
|
||||
}
|
||||
@@ -979,75 +947,61 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
// Addition of UUIDs
|
||||
// Version 1.5.01
|
||||
// Add a value because otherwise it gets removed
|
||||
character = Arrays.copyOf(character, character.length + 1);
|
||||
character[character.length - 1] = "NULL";
|
||||
newLine.append("NULL:");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.5.01";
|
||||
}
|
||||
}
|
||||
if (character.length <= 42) {
|
||||
// Addition of scoreboard tips auto disable
|
||||
// Version 1.5.02
|
||||
character = Arrays.copyOf(character, character.length + 1);
|
||||
character[character.length - 1] = "0";
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.5.02";
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any blanks that shouldn't be there, and validate the other fields
|
||||
String[] newCharacter = newLine.toString().split(":");
|
||||
boolean corrupted = false;
|
||||
|
||||
for (int i = 0; i < character.length; i++) {
|
||||
if (character[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) {
|
||||
for (int i = 0; i < newCharacter.length; i++) {
|
||||
if (newCharacter[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) {
|
||||
corrupted = true;
|
||||
if (i == 37) {
|
||||
character[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
else if (i == 38) {
|
||||
character[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||
|
||||
if (newCharacter.length != 42) {
|
||||
newCharacter = (String[]) ArrayUtils.remove(newCharacter, i);
|
||||
}
|
||||
else {
|
||||
character[i] = "0";
|
||||
if (i == 37) {
|
||||
newCharacter[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
|
||||
}
|
||||
else if (i == 38) {
|
||||
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||
}
|
||||
else {
|
||||
newCharacter[i] = "0";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isInt(character[i]) && i == 38) {
|
||||
if (StringUtils.isInt(newCharacter[i]) && i == 38) {
|
||||
corrupted = true;
|
||||
character[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||
newCharacter[i] = Config.getInstance().getMobHealthbarDefault().toString();
|
||||
}
|
||||
|
||||
if (!StringUtils.isInt(character[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) {
|
||||
if (!StringUtils.isInt(newCharacter[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) {
|
||||
corrupted = true;
|
||||
character[i] = "0";
|
||||
newCharacter[i] = "0";
|
||||
}
|
||||
}
|
||||
|
||||
if (corrupted) {
|
||||
mcMMO.p.debug("Updating corrupted database line for player " + character[USERNAME]);
|
||||
mcMMO.p.debug("Updating corrupted database line for player " + newCharacter[0]);
|
||||
}
|
||||
|
||||
if (oldVersion != null) {
|
||||
mcMMO.p.debug("Updating database line from before version " + oldVersion + " for player " + character[USERNAME]);
|
||||
mcMMO.p.debug("Updating database line from before version " + oldVersion + " for player " + character[0]);
|
||||
}
|
||||
|
||||
updated |= corrupted;
|
||||
updated |= oldVersion != null;
|
||||
|
||||
if (Config.getInstance().getTruncateSkills()) {
|
||||
Map<SkillType, Integer> skills = getSkillMapFromLine(character);
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
int cap = Config.getInstance().getLevelCap(skill);
|
||||
if (skills.get(skill) > cap) {
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
if (corrupted || oldVersion != null) {
|
||||
newLine = new StringBuilder(org.apache.commons.lang.StringUtils.join(newCharacter, ":"));
|
||||
newLine = newLine.append(":");
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
|
||||
}
|
||||
|
||||
writer.append(line).append("\r\n");
|
||||
writer.append(newLine).append("\r\n");
|
||||
}
|
||||
|
||||
// Write the new file
|
||||
@@ -1133,39 +1087,38 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
Map<SkillType, Float> skillsXp = new EnumMap<SkillType, Float>(SkillType.class); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
|
||||
MobHealthbarType mobHealthbarType;
|
||||
int scoreboardTipsShown;
|
||||
|
||||
// TODO on updates, put new values in a try{} ?
|
||||
|
||||
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(character[EXP_TAMING]));
|
||||
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(character[EXP_MINING]));
|
||||
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(character[EXP_REPAIR]));
|
||||
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(character[EXP_WOODCUTTING]));
|
||||
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(character[EXP_UNARMED]));
|
||||
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(character[EXP_HERBALISM]));
|
||||
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(character[EXP_EXCAVATION]));
|
||||
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(character[EXP_ARCHERY]));
|
||||
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(character[EXP_SWORDS]));
|
||||
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(character[EXP_AXES]));
|
||||
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(character[EXP_ACROBATICS]));
|
||||
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(character[EXP_FISHING]));
|
||||
skillsXp.put(SkillType.ALCHEMY, (float) Integer.valueOf(character[EXP_ALCHEMY]));
|
||||
skillsXp.put(SkillType.TAMING, (float) Integer.valueOf(character[25]));
|
||||
skillsXp.put(SkillType.MINING, (float) Integer.valueOf(character[4]));
|
||||
skillsXp.put(SkillType.REPAIR, (float) Integer.valueOf(character[15]));
|
||||
skillsXp.put(SkillType.WOODCUTTING, (float) Integer.valueOf(character[6]));
|
||||
skillsXp.put(SkillType.UNARMED, (float) Integer.valueOf(character[16]));
|
||||
skillsXp.put(SkillType.HERBALISM, (float) Integer.valueOf(character[17]));
|
||||
skillsXp.put(SkillType.EXCAVATION, (float) Integer.valueOf(character[18]));
|
||||
skillsXp.put(SkillType.ARCHERY, (float) Integer.valueOf(character[19]));
|
||||
skillsXp.put(SkillType.SWORDS, (float) Integer.valueOf(character[20]));
|
||||
skillsXp.put(SkillType.AXES, (float) Integer.valueOf(character[21]));
|
||||
skillsXp.put(SkillType.ACROBATICS, (float) Integer.valueOf(character[22]));
|
||||
skillsXp.put(SkillType.FISHING, (float) Integer.valueOf(character[35]));
|
||||
skillsXp.put(SkillType.ALCHEMY, (float) Integer.valueOf(character[40]));
|
||||
|
||||
// Taming - Unused
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[COOLDOWN_SUPER_BREAKER]));
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
||||
// Repair - Unused
|
||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[COOLDOWN_TREE_FELLER]));
|
||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[COOLDOWN_BERSERK]));
|
||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[COOLDOWN_GREEN_TERRA]));
|
||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[COOLDOWN_GIGA_DRILL_BREAKER]));
|
||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28]));
|
||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
|
||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29]));
|
||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27]));
|
||||
// Archery - Unused
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[COOLDOWN_SERRATED_STRIKES]));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[COOLDOWN_SKULL_SPLITTER]));
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31]));
|
||||
// Acrobatics - Unused
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[COOLDOWN_BLAST_MINING]));
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
||||
|
||||
try {
|
||||
mobHealthbarType = MobHealthbarType.valueOf(character[HEALTHBAR]);
|
||||
mobHealthbarType = MobHealthbarType.valueOf(character[38]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
@@ -1173,38 +1126,31 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
UUID uuid;
|
||||
try {
|
||||
uuid = UUID.fromString(character[UUID_INDEX]);
|
||||
uuid = UUID.fromString(character[41]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
uuid = null;
|
||||
}
|
||||
|
||||
try {
|
||||
scoreboardTipsShown = Integer.valueOf(character[SCOREBOARD_TIPS]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
scoreboardTipsShown = 0;
|
||||
}
|
||||
|
||||
return new PlayerProfile(character[USERNAME], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown);
|
||||
return new PlayerProfile(character[0], uuid, skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||
}
|
||||
|
||||
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
||||
Map<SkillType, Integer> skills = new EnumMap<SkillType, Integer>(SkillType.class); // Skill & Level
|
||||
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(character[SKILLS_TAMING]));
|
||||
skills.put(SkillType.MINING, Integer.valueOf(character[SKILLS_MINING]));
|
||||
skills.put(SkillType.REPAIR, Integer.valueOf(character[SKILLS_REPAIR]));
|
||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[SKILLS_WOODCUTTING]));
|
||||
skills.put(SkillType.UNARMED, Integer.valueOf(character[SKILLS_UNARMED]));
|
||||
skills.put(SkillType.HERBALISM, Integer.valueOf(character[SKILLS_HERBALISM]));
|
||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[SKILLS_EXCAVATION]));
|
||||
skills.put(SkillType.ARCHERY, Integer.valueOf(character[SKILLS_ARCHERY]));
|
||||
skills.put(SkillType.SWORDS, Integer.valueOf(character[SKILLS_SWORDS]));
|
||||
skills.put(SkillType.AXES, Integer.valueOf(character[SKILLS_AXES]));
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[SKILLS_ACROBATICS]));
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(character[SKILLS_FISHING]));
|
||||
skills.put(SkillType.ALCHEMY, Integer.valueOf(character[SKILLS_ALCHEMY]));
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
|
||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
|
||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
|
||||
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
|
||||
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
|
||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
|
||||
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
|
||||
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
|
||||
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(character[34]));
|
||||
skills.put(SkillType.ALCHEMY, Integer.valueOf(character[39]));
|
||||
|
||||
return skills;
|
||||
}
|
||||
@@ -1215,78 +1161,4 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
|
||||
@Override
|
||||
public void onDisable() { }
|
||||
|
||||
private int getSkillIndex(SkillType skill) {
|
||||
switch (skill) {
|
||||
case ACROBATICS:
|
||||
return SKILLS_ACROBATICS;
|
||||
case ALCHEMY:
|
||||
return SKILLS_ALCHEMY;
|
||||
case ARCHERY:
|
||||
return SKILLS_ARCHERY;
|
||||
case AXES:
|
||||
return SKILLS_AXES;
|
||||
case EXCAVATION:
|
||||
return SKILLS_EXCAVATION;
|
||||
case FISHING:
|
||||
return SKILLS_FISHING;
|
||||
case HERBALISM:
|
||||
return SKILLS_HERBALISM;
|
||||
case MINING:
|
||||
return SKILLS_MINING;
|
||||
case REPAIR:
|
||||
return SKILLS_REPAIR;
|
||||
case SWORDS:
|
||||
return SKILLS_SWORDS;
|
||||
case TAMING:
|
||||
return SKILLS_TAMING;
|
||||
case UNARMED:
|
||||
return SKILLS_UNARMED;
|
||||
case WOODCUTTING:
|
||||
return SKILLS_WOODCUTTING;
|
||||
default:
|
||||
throw new RuntimeException("Primary Skills only");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int USERNAME = 0;
|
||||
public static int SKILLS_MINING = 1;
|
||||
public static int EXP_MINING = 4;
|
||||
public static int SKILLS_WOODCUTTING = 5;
|
||||
public static int EXP_WOODCUTTING = 6;
|
||||
public static int SKILLS_REPAIR = 7;
|
||||
public static int SKILLS_UNARMED = 8;
|
||||
public static int SKILLS_HERBALISM = 9;
|
||||
public static int SKILLS_EXCAVATION = 10;
|
||||
public static int SKILLS_ARCHERY = 11;
|
||||
public static int SKILLS_SWORDS = 12;
|
||||
public static int SKILLS_AXES = 13;
|
||||
public static int SKILLS_ACROBATICS = 14;
|
||||
public static int EXP_REPAIR = 15;
|
||||
public static int EXP_UNARMED = 16;
|
||||
public static int EXP_HERBALISM = 17;
|
||||
public static int EXP_EXCAVATION = 18;
|
||||
public static int EXP_ARCHERY = 19;
|
||||
public static int EXP_SWORDS = 20;
|
||||
public static int EXP_AXES = 21;
|
||||
public static int EXP_ACROBATICS = 22;
|
||||
public static int SKILLS_TAMING = 24;
|
||||
public static int EXP_TAMING = 25;
|
||||
public static int COOLDOWN_BERSERK = 26;
|
||||
public static int COOLDOWN_GIGA_DRILL_BREAKER = 27;
|
||||
public static int COOLDOWN_TREE_FELLER = 28;
|
||||
public static int COOLDOWN_GREEN_TERRA = 29;
|
||||
public static int COOLDOWN_SERRATED_STRIKES = 30;
|
||||
public static int COOLDOWN_SKULL_SPLITTER = 31;
|
||||
public static int COOLDOWN_SUPER_BREAKER = 32;
|
||||
public static int SKILLS_FISHING = 34;
|
||||
public static int EXP_FISHING = 35;
|
||||
public static int COOLDOWN_BLAST_MINING = 36;
|
||||
public static int LAST_LOGIN = 37;
|
||||
public static int HEALTHBAR = 38;
|
||||
public static int SKILLS_ALCHEMY = 39;
|
||||
public static int EXP_ALCHEMY = 40;
|
||||
public static int UUID_INDEX = 41;
|
||||
public static int SCOREBOARD_TIPS = 42;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
import org.apache.tomcat.jdbc.pool.PoolProperties;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -28,9 +30,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
import org.apache.tomcat.jdbc.pool.PoolProperties;
|
||||
|
||||
public final class SQLDatabaseManager implements DatabaseManager {
|
||||
private static final String ALL_QUERY_VERSION = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy";
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
@@ -133,8 +132,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
massUpdateLock.unlock();
|
||||
}
|
||||
|
||||
@@ -143,7 +156,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
public void purgeOldUsers() {
|
||||
massUpdateLock.lock();
|
||||
mcMMO.p.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000000L) + " months...");
|
||||
mcMMO.p.getLogger().info("Purging inactive users older than " + (PURGE_TIME / 2630000L) + " months...");
|
||||
|
||||
Connection connection = null;
|
||||
Statement statement = null;
|
||||
@@ -164,8 +177,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
massUpdateLock.unlock();
|
||||
}
|
||||
|
||||
@@ -195,8 +222,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (success) {
|
||||
@@ -219,7 +260,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (id == -1) {
|
||||
id = newUser(connection, profile.getPlayerName(), profile.getUniqueId());
|
||||
if (id == -1) {
|
||||
mcMMO.p.getLogger().severe("Failed to create new account for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -228,10 +268,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setInt(1, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update last login for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "skills SET "
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
@@ -254,10 +290,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setInt(14, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update skills for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "experience SET "
|
||||
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
|
||||
@@ -280,10 +312,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setInt(14, id);
|
||||
success &= (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update experience for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = ?, woodcutting = ?, unarmed = ?"
|
||||
@@ -300,28 +328,33 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.setInt(9, id);
|
||||
success = (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update cooldowns for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?, scoreboardtips = ? WHERE user_id = ?");
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
|
||||
statement.setString(1, profile.getMobHealthbarType() == null ? Config.getInstance().getMobHealthbarDefault().name() : profile.getMobHealthbarType().name());
|
||||
statement.setInt(2, profile.getScoreboardTipsShown());
|
||||
statement.setInt(3, id);
|
||||
statement.setInt(2, id);
|
||||
success = (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
if (!success) {
|
||||
mcMMO.p.getLogger().severe("Failed to update hud settings for " + profile.getPlayerName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -337,7 +370,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
try {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
statement = connection.prepareStatement("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT user = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, user LIMIT ?, ?");
|
||||
statement = connection.prepareStatement("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT ?, ?");
|
||||
statement.setInt(1, (pageNumber * statsPerPage) - statsPerPage);
|
||||
statement.setInt(2, statsPerPage);
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -356,9 +389,30 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stats;
|
||||
@@ -375,7 +429,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
connection = getConnection(PoolIdentifier.MISC);
|
||||
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
|
||||
String skillName = skillType.name().toLowerCase();
|
||||
// Get count of all users with higher skill level than player
|
||||
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE user = ?)";
|
||||
@@ -388,7 +441,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
int rank = resultSet.getInt("rank");
|
||||
|
||||
// Ties are settled by alphabetical order
|
||||
sql = "SELECT user, " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
|
||||
"AND " + skillName + " = (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
|
||||
"WHERE user = '" + playerName + "') ORDER BY user";
|
||||
@@ -452,9 +504,30 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return skills;
|
||||
@@ -471,7 +544,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(connection);
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,23 +560,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
PreparedStatement statement = null;
|
||||
|
||||
try {
|
||||
statement = connection.prepareStatement(
|
||||
"UPDATE `" + tablePrefix + "users` "
|
||||
+ "SET user = ? "
|
||||
+ "WHERE user = ?");
|
||||
statement.setString(1, "_INVALID_OLD_USERNAME_");
|
||||
statement.setString(2, playerName);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
statement = connection.prepareStatement("INSERT INTO " + tablePrefix + "users (user, uuid, lastlogin) VALUES (?, ?, UNIX_TIMESTAMP())", Statement.RETURN_GENERATED_KEYS);
|
||||
statement.setString(1, playerName);
|
||||
statement.setString(2, uuid != null ? uuid.toString() : null);
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
resultSet = statement.getGeneratedKeys();
|
||||
|
||||
if (!resultSet.next()) {
|
||||
mcMMO.p.getLogger().severe("Unable to create new user account in DB");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -507,8 +578,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -555,7 +640,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
||||
+ "h.mobhealthbar, h.scoreboardtips, u.uuid, u.user "
|
||||
+ "h.mobhealthbar, u.uuid "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
@@ -569,19 +654,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
if (resultSet.next()) {
|
||||
try {
|
||||
PlayerProfile profile = loadFromResult(playerName, resultSet);
|
||||
String name = resultSet.getString(42); // TODO: Magic Number, make sure it stays updated
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
|
||||
if (!playerName.isEmpty() && !playerName.equals(name)) {
|
||||
statement = connection.prepareStatement(
|
||||
"UPDATE `" + tablePrefix + "users` "
|
||||
+ "SET user = ? "
|
||||
+ "WHERE user = ?");
|
||||
statement.setString(1, "_INVALID_OLD_USERNAME_");
|
||||
statement.setString(2, name);
|
||||
statement.executeUpdate();
|
||||
statement.close();
|
||||
if (!playerName.isEmpty() && !profile.getPlayerName().isEmpty()) {
|
||||
statement = connection.prepareStatement(
|
||||
"UPDATE `" + tablePrefix + "users` "
|
||||
+ "SET user = ?, uuid = ? "
|
||||
@@ -596,7 +672,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return profile;
|
||||
}
|
||||
catch (SQLException e) {
|
||||
printErrors(e);
|
||||
}
|
||||
}
|
||||
resultSet.close();
|
||||
@@ -605,9 +680,30 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Problem, nothing was returned
|
||||
@@ -633,7 +729,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
||||
+ "h.mobhealthbar, h.scoreboardtips, u.uuid "
|
||||
+ "h.mobhealthbar, u.uuid "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
@@ -652,7 +748,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
printErrors(e);
|
||||
// Ignore
|
||||
}
|
||||
convertedUsers++;
|
||||
@@ -663,9 +758,30 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(e);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -689,8 +805,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -729,8 +859,22 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return false;
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,9 +897,30 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(e);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return users;
|
||||
@@ -787,11 +952,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`uuid` varchar(36) NULL DEFAULT NULL,"
|
||||
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
||||
+ "PRIMARY KEY (`id`),"
|
||||
+ "INDEX(`user`(20) ASC),"
|
||||
+ "UNIQUE KEY `user` (`user`),"
|
||||
+ "UNIQUE KEY `uuid` (`uuid`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||
tryClose(createStatement);
|
||||
createStatement.close();
|
||||
}
|
||||
tryClose(resultSet);
|
||||
resultSet.close();
|
||||
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "huds");
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -800,12 +965,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
|
||||
+ "`scoreboardtips` int(10) NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
tryClose(createStatement);
|
||||
createStatement.close();
|
||||
}
|
||||
tryClose(resultSet);
|
||||
resultSet.close();
|
||||
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "cooldowns");
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -827,9 +991,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
tryClose(createStatement);
|
||||
createStatement.close();
|
||||
}
|
||||
tryClose(resultSet);
|
||||
resultSet.close();
|
||||
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "skills");
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -852,9 +1016,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
tryClose(createStatement);
|
||||
createStatement.close();
|
||||
}
|
||||
tryClose(resultSet);
|
||||
resultSet.close();
|
||||
statement.setString(1, Config.getInstance().getMySQLDatabaseName());
|
||||
statement.setString(2, tablePrefix + "experience");
|
||||
resultSet = statement.executeQuery();
|
||||
@@ -877,26 +1041,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
tryClose(createStatement);
|
||||
createStatement.close();
|
||||
}
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
|
||||
for (UpgradeType updateType : UpgradeType.values()) {
|
||||
checkDatabaseStructure(connection, updateType);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getTruncateSkills()) {
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
int cap = Config.getInstance().getLevelCap(skill);
|
||||
if (cap != Integer.MAX_VALUE) {
|
||||
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `" + skill.name().toLowerCase() + "` = " + cap + " WHERE `" + skill.name().toLowerCase() + "` > " + cap);
|
||||
statement.executeUpdate();
|
||||
tryClose(statement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Killing orphans");
|
||||
createStatement = connection.createStatement();
|
||||
createStatement.executeUpdate("DELETE FROM `" + tablePrefix + "experience` WHERE NOT EXISTS (SELECT * FROM `" + tablePrefix + "users` `u` WHERE `" + tablePrefix + "experience`.`user_id` = `u`.`id`)");
|
||||
@@ -908,10 +1061,38 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
tryClose(createStatement);
|
||||
tryClose(connection);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (createStatement != null) {
|
||||
try {
|
||||
createStatement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -984,14 +1165,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
checkUpgradeAddUUIDs(statement);
|
||||
return;
|
||||
|
||||
case ADD_SCOREBOARD_TIPS:
|
||||
checkUpgradeAddScoreboardTips(statement);
|
||||
return;
|
||||
|
||||
case DROP_NAME_UNIQUENESS:
|
||||
checkNameUniqueness(statement);
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1003,7 +1176,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1026,10 +1206,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar, scoreboardtips) VALUES (?, ?, ?)");
|
||||
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar) VALUES (?, ?)");
|
||||
statement.setInt(1, id);
|
||||
statement.setString(2, Config.getInstance().getMobHealthbarDefault().name());
|
||||
statement.setInt(3, 0);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
@@ -1037,7 +1216,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(statement);
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1047,7 +1233,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
|
||||
MobHealthbarType mobHealthbarType;
|
||||
UUID uuid;
|
||||
int scoreboardTipsShown;
|
||||
|
||||
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query
|
||||
// changes (a new skill is added)
|
||||
@@ -1097,19 +1282,12 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
|
||||
|
||||
try {
|
||||
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 1));
|
||||
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2));
|
||||
}
|
||||
catch (Exception e) {
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
}
|
||||
|
||||
try {
|
||||
scoreboardTipsShown = result.getInt(OFFSET_OTHER + 2);
|
||||
}
|
||||
catch (Exception e) {
|
||||
scoreboardTipsShown = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
uuid = UUID.fromString(result.getString(OFFSET_OTHER + 3));
|
||||
}
|
||||
@@ -1117,7 +1295,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
uuid = null;
|
||||
}
|
||||
|
||||
return new PlayerProfile(playerName, uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown);
|
||||
return new PlayerProfile(playerName, uuid, skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||
}
|
||||
|
||||
private void printErrors(SQLException ex) {
|
||||
@@ -1132,27 +1310,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
return DatabaseType.SQL;
|
||||
}
|
||||
|
||||
private void checkNameUniqueness(final Statement statement) throws SQLException {
|
||||
ResultSet resultSet = null;
|
||||
try {
|
||||
resultSet = statement.executeQuery("SHOW INDEXES "
|
||||
+ "FROM `" + tablePrefix + "users` "
|
||||
+ "WHERE Column_name='user' "
|
||||
+ " AND NOT Non_unique");
|
||||
if (!resultSet.next()) {
|
||||
return;
|
||||
}
|
||||
resultSet.close();
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables to drop name uniqueness...");
|
||||
statement.execute("ALTER TABLE `" + tablePrefix + "users` "
|
||||
+ "DROP INDEX `user`,"
|
||||
+ "ADD INDEX `user` (`user`(20) ASC)");
|
||||
} catch (SQLException ex) {
|
||||
} finally {
|
||||
tryClose(resultSet);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpgradeAddAlchemy(final Statement statement) throws SQLException {
|
||||
try {
|
||||
statement.executeQuery("SELECT `alchemy` FROM `" + tablePrefix + "skills` LIMIT 1");
|
||||
@@ -1195,16 +1352,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpgradeAddScoreboardTips(final Statement statement) throws SQLException {
|
||||
try {
|
||||
statement.executeQuery("SELECT `scoreboardtips` FROM `" + tablePrefix + "huds` LIMIT 1");
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for scoreboard tips...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `scoreboardtips` int(10) NOT NULL DEFAULT '0' ;");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpgradeAddSQLIndexes(final Statement statement) throws SQLException {
|
||||
ResultSet resultSet = null;
|
||||
|
||||
@@ -1231,7 +1378,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1261,7 +1415,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new GetUUIDUpdatesRequired().runTaskLaterAsynchronously(mcMMO.p, 100); // wait until after first purge
|
||||
@@ -1286,9 +1447,27 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
} catch (SQLException ex) {
|
||||
printErrors(ex);
|
||||
} finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
tryClose(connection);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
} catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
} catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!names.isEmpty()) {
|
||||
@@ -1325,7 +1504,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1354,12 +1540,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getUserID(final Connection connection, final String playerName, final UUID uuid) {
|
||||
if (uuid != null && cachedUserIDs.containsKey(uuid)) {
|
||||
if (cachedUserIDs.containsKey(uuid)) {
|
||||
return cachedUserIDs.get(uuid);
|
||||
}
|
||||
|
||||
@@ -1368,16 +1561,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
|
||||
try {
|
||||
statement = connection.prepareStatement("SELECT id, user FROM " + tablePrefix + "users WHERE uuid = ? OR (uuid IS NULL AND user = ?)");
|
||||
statement.setString(1, uuid == null ? null : uuid.toString());
|
||||
statement.setString(1, uuid.toString());
|
||||
statement.setString(2, playerName);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
if (resultSet.next()) {
|
||||
int id = resultSet.getInt("id");
|
||||
|
||||
if (uuid != null) {
|
||||
cachedUserIDs.put(uuid, id);
|
||||
}
|
||||
cachedUserIDs.put(uuid, id);
|
||||
|
||||
return id;
|
||||
}
|
||||
@@ -1386,23 +1577,26 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
printErrors(ex);
|
||||
}
|
||||
finally {
|
||||
tryClose(resultSet);
|
||||
tryClose(statement);
|
||||
if (resultSet != null) {
|
||||
try {
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
if (statement != null) {
|
||||
try {
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
private void tryClose(AutoCloseable closeable) {
|
||||
if (closeable != null) {
|
||||
try {
|
||||
closeable.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
@@ -9,7 +9,5 @@ public enum UpgradeType {
|
||||
DROP_SPOUT,
|
||||
ADD_ALCHEMY,
|
||||
ADD_UUIDS,
|
||||
ADD_UUIDS_PARTY,
|
||||
ADD_SCOREBOARD_TIPS,
|
||||
DROP_NAME_UNIQUENESS;
|
||||
ADD_UUIDS_PARTY;
|
||||
}
|
||||
|
||||
@@ -101,6 +101,12 @@ public class McMMOPlayer {
|
||||
this.player = player;
|
||||
playerMetadata = new FixedMetadataValue(mcMMO.p, playerName);
|
||||
this.profile = profile;
|
||||
party = PartyManager.getPlayerParty(playerName, uuid);
|
||||
ptpRecord = new PartyTeleportRecord();
|
||||
|
||||
if (inParty()) {
|
||||
loginParty();
|
||||
}
|
||||
|
||||
if (profile.getUniqueId() == null) {
|
||||
profile.setUniqueId(uuid);
|
||||
@@ -526,15 +532,6 @@ public class McMMOPlayer {
|
||||
* Party Stuff
|
||||
*/
|
||||
|
||||
public void setupPartyData() {
|
||||
party = PartyManager.getPlayerParty(player.getName(), player.getUniqueId());
|
||||
ptpRecord = new PartyTeleportRecord();
|
||||
|
||||
if (inParty()) {
|
||||
loginParty();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPartyInvite(Party invite) {
|
||||
this.invite = invite;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ public class PlayerProfile {
|
||||
|
||||
/* HUDs */
|
||||
private MobHealthbarType mobHealthbarType;
|
||||
private int scoreboardTipsShown;
|
||||
|
||||
/* Skill Data */
|
||||
private final Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
@@ -49,7 +48,6 @@ public class PlayerProfile {
|
||||
this.playerName = playerName;
|
||||
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
scoreboardTipsShown = 0;
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
abilityDATS.put(abilityType, 0);
|
||||
@@ -72,11 +70,10 @@ public class PlayerProfile {
|
||||
this.loaded = isLoaded;
|
||||
}
|
||||
|
||||
public PlayerProfile(String playerName, UUID uuid, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType, int scoreboardTipsShown) {
|
||||
public PlayerProfile(String playerName, UUID uuid, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType) {
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid;
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
|
||||
skills.putAll(levelData);
|
||||
skillsXp.putAll(xpData);
|
||||
@@ -95,7 +92,7 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
// TODO should this part be synchronized?
|
||||
PlayerProfile profileCopy = new PlayerProfile(playerName, uuid, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType, scoreboardTipsShown);
|
||||
PlayerProfile profileCopy = new PlayerProfile(playerName, uuid, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType);
|
||||
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
||||
|
||||
if (changed) {
|
||||
@@ -130,25 +127,9 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public void setMobHealthbarType(MobHealthbarType mobHealthbarType) {
|
||||
changed = true;
|
||||
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
}
|
||||
|
||||
public int getScoreboardTipsShown() {
|
||||
return scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public void setScoreboardTipsShown(int scoreboardTipsShown) {
|
||||
changed = true;
|
||||
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public void increaseTipsShown() {
|
||||
setScoreboardTipsShown(getScoreboardTipsShown() + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cooldowns
|
||||
*/
|
||||
@@ -355,7 +336,7 @@ public class PlayerProfile {
|
||||
int sum = 0;
|
||||
|
||||
for (SkillType parent : parents) {
|
||||
sum += Math.min(getSkillLevel(parent), parent.getMaxLevel());
|
||||
sum += Math.min(getSkillLevel(parent), 1000);
|
||||
}
|
||||
|
||||
return sum / parents.size();
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.gmail.nossr50.datatypes.skills.alchemy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
public enum PotionStage {
|
||||
FIVE(5),
|
||||
@@ -47,27 +44,17 @@ public enum PotionStage {
|
||||
|
||||
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
|
||||
Potion potion = alchemyPotion.toPotion(1);
|
||||
List<PotionEffect> effects = alchemyPotion.getEffects();
|
||||
|
||||
int stage = 1;
|
||||
|
||||
// Check if potion isn't awkward or mundane
|
||||
// Check for custom effects added by mcMMO
|
||||
if (potion.getType() != null || !effects.isEmpty()) {
|
||||
if (potion.getType() != null) {
|
||||
stage++;
|
||||
}
|
||||
|
||||
// Check if potion has a glowstone dust amplifier
|
||||
// Else check if the potion has a custom effect with an amplifier added by mcMMO
|
||||
if (potion.getLevel() > 1) {
|
||||
stage++;
|
||||
}else if(!effects.isEmpty()){
|
||||
for (PotionEffect effect : effects){
|
||||
if(effect.getAmplifier() > 0){
|
||||
stage++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if potion has a redstone dust amplifier
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.BrewingStand;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -21,7 +20,6 @@ import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -51,8 +49,6 @@ 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.SkillUtils;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
@@ -68,6 +64,10 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockFace direction = event.getDirection();
|
||||
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
|
||||
|
||||
@@ -79,14 +79,12 @@ public class BlockListener implements Listener {
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
|
||||
Block nextBlock = b.getRelative(direction);
|
||||
mcMMO.getPlaceStore().setTrue(nextBlock);
|
||||
//b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
||||
b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed because blocks sometimes don't move when two pistons push towards each other
|
||||
//new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
|
||||
new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,64 +94,18 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
// event.isSticky() always returns false
|
||||
// if (!event.isSticky()){
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Sticky piston return PISTON_MOVING_PIECE and normal piston PISTON_BASE
|
||||
if (event.getBlock().getType() != Material.PISTON_MOVING_PIECE) {
|
||||
if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get opposite direction so we get correct block
|
||||
BlockFace direction = event.getDirection().getOppositeFace();
|
||||
Block movedBlock = event.getBlock().getRelative(direction);
|
||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||
|
||||
// If we're pulling a slime block, it might have something attached to it!
|
||||
if (movedBlock.getRelative(direction).getState().getType() == Material.SLIME_BLOCK) {
|
||||
for (Block block : event.getBlocks()) {
|
||||
movedBlock = block.getRelative(direction);
|
||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||
// // Treat the slime blocks as if it is the sticky piston itself, because pulling
|
||||
// // a slime block with a sticky piston is effectively the same as moving a sticky piston.
|
||||
// new StickyPistonTrackerTask(direction, event.getBlock(), block).runTaskLater(plugin, 2);
|
||||
}
|
||||
|
||||
if (!event.isSticky()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block movedBlock = event.getRetractLocation().getBlock();
|
||||
|
||||
// Needed only because under some circumstances Minecraft doesn't move the block
|
||||
//new StickyPistonTrackerTask(direction, event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor falling blocks.
|
||||
*
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onFallingBlock(EntityChangeBlockEvent event) {
|
||||
|
||||
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()));
|
||||
} else {
|
||||
List<MetadataValue> values = event.getEntity().getMetadata( "mcMMOBlockFall" );
|
||||
|
||||
if (!values.isEmpty()) {
|
||||
|
||||
if (values.get(0).value() == null) return;
|
||||
Block spawn = ((org.bukkit.Location) values.get(0).value()).getBlock();
|
||||
|
||||
|
||||
mcMMO.getPlaceStore().setTrue( event.getBlock() );
|
||||
mcMMO.getPlaceStore().setFalse( spawn );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,7 +260,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ItemUtils.isFluxPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
SmeltingManager smeltingManager = UserManager.getPlayer(player).getSmeltingManager();
|
||||
|
||||
if (smeltingManager.canUseFluxMining(blockState)) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
@@ -105,15 +104,13 @@ 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) {
|
||||
Block block = event.getBlock();
|
||||
|
||||
// When the event is fired for the falling block that changes back to a
|
||||
// normal block
|
||||
// When the event is fired for the falling block that changes back to a normal block
|
||||
// event.getBlock().getType() returns AIR
|
||||
if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
|
||||
return;
|
||||
@@ -145,8 +142,7 @@ 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) {
|
||||
@@ -155,24 +151,12 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
double damage = event.getFinalDamage();
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if (damage <= 0) {
|
||||
if (defender instanceof Player && attacker instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
Player attackingPlayer = (Player) attacker;
|
||||
if (event.getDamage(DamageModifier.ABSORPTION) > 0) {
|
||||
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if (defender.hasMetadata(mcMMO.customDamageKey)) {
|
||||
defender.removeMetadata(mcMMO.customDamageKey, plugin);
|
||||
@@ -189,7 +173,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Entity attacker = event.getDamager();
|
||||
|
||||
if (Misc.isNPCEntity(attacker)) {
|
||||
return;
|
||||
@@ -223,8 +207,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// We want to make sure we're not gaining XP or applying abilities
|
||||
// when we hit ourselves
|
||||
// We want to make sure we're not gaining XP or applying abilities when we hit ourselves
|
||||
if (defendingPlayer.equals(attackingPlayer)) {
|
||||
return;
|
||||
}
|
||||
@@ -242,8 +225,7 @@ 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) {
|
||||
@@ -389,8 +371,7 @@ 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) {
|
||||
@@ -414,8 +395,7 @@ 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) {
|
||||
@@ -432,30 +412,23 @@ 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) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
switch (event.getSpawnReason()) {
|
||||
case NETHER_PORTAL:
|
||||
case SPAWNER:
|
||||
case SPAWNER_EGG:
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
|
||||
LivingEntity entity = event.getEntity();
|
||||
Entity passenger = entity.getPassenger();
|
||||
|
||||
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
|
||||
if (passenger != null) {
|
||||
passenger.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
||||
}
|
||||
return;
|
||||
|
||||
case BREEDING:
|
||||
entity.setMetadata(mcMMO.bredMetadataKey, mcMMO.metadataValue);
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -464,8 +437,7 @@ 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) {
|
||||
@@ -475,8 +447,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
@@ -493,8 +464,7 @@ 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) {
|
||||
@@ -504,8 +474,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// We can make this assumption because we (should) be the only ones
|
||||
// using this exact metadata
|
||||
// We can make this assumption because we (should) be the only ones using this exact metadata
|
||||
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
@@ -523,8 +492,7 @@ 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) {
|
||||
@@ -540,8 +508,7 @@ 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) {
|
||||
@@ -566,59 +533,39 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
/*
|
||||
* Some foods have 3 ranks Some foods have 5 ranks The number of ranks
|
||||
* is based on how 'common' the item is We can adjust this quite easily
|
||||
* if we find something is giving too much of a bonus
|
||||
* Some foods have 3 ranks
|
||||
* Some foods have 5 ranks
|
||||
* The number of ranks is based on how 'common' the item is
|
||||
* We can adjust this quite easily if we find something is giving too much of a bonus
|
||||
*/
|
||||
switch (player.getItemInHand().getType()) {
|
||||
case BAKED_POTATO: /*
|
||||
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
||||
* 1000
|
||||
*/
|
||||
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
case CARROT_ITEM: /*
|
||||
* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @
|
||||
* 1000
|
||||
*/
|
||||
case GOLDEN_CARROT: /*
|
||||
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
||||
* 1000
|
||||
*/
|
||||
case MUSHROOM_SOUP: /*
|
||||
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
|
||||
* 1000
|
||||
*/
|
||||
case PUMPKIN_PIE: /*
|
||||
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
|
||||
* 1000
|
||||
*/
|
||||
case BAKED_POTATO: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
case CARROT_ITEM: /* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||
case GOLDEN_CARROT: /* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
case MUSHROOM_SOUP: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
case PUMPKIN_PIE: /* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel1, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POISONOUS_POTATO: /*
|
||||
* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER
|
||||
* @ 1000
|
||||
*/
|
||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POISONOUS_POTATO: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case COOKED_FISH: /*
|
||||
* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @
|
||||
* 1000
|
||||
*/
|
||||
case COOKED_FISH: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
||||
}
|
||||
return;
|
||||
|
||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
|
||||
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
|
||||
}
|
||||
@@ -632,8 +579,7 @@ 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) {
|
||||
@@ -655,8 +601,7 @@ 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) {
|
||||
@@ -674,8 +619,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player,
|
||||
// and the owner is in the same party
|
||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
|
||||
// So we can make some assumptions here, about our casting and our check
|
||||
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire((Player) tameable.getOwner()))) {
|
||||
event.setCancelled(true);
|
||||
@@ -683,11 +627,9 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle PotionSplash events in order to fix broken Splash Potion of
|
||||
* Saturation.
|
||||
* 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) {
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.event.inventory.FurnaceExtractEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
@@ -314,14 +313,6 @@ public class InventoryListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryClickEvent(InventoryClickEvent event) {
|
||||
SkillUtils.removeAbilityBuff(event.getCurrentItem());
|
||||
if (event.getAction() == InventoryAction.HOTBAR_SWAP) {
|
||||
SkillUtils.removeAbilityBuff(event.getWhoClicked().getInventory().getItem(event.getHotbarButton()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onInventoryOpenEvent(InventoryOpenEvent event) {
|
||||
SkillUtils.removeAbilityBuff(event.getPlayer().getItemInHand());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@@ -238,7 +236,7 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
|
||||
case IN_GROUND:
|
||||
Block block = player.getTargetBlock((HashSet<Byte>) null, 100);
|
||||
Block block = player.getTargetBlock(null, 100);
|
||||
|
||||
if (fishingManager.canIceFish(block)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -57,7 +57,7 @@ public final class LocaleLoader {
|
||||
public static String formatString(String string, Object... messageArguments) {
|
||||
if (messageArguments != null) {
|
||||
MessageFormat formatter = new MessageFormat("");
|
||||
formatter.applyPattern(string.replace("'", "''"));
|
||||
formatter.applyPattern(string);
|
||||
string = formatter.format(messageArguments);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
@@ -32,7 +31,6 @@ import com.gmail.nossr50.listeners.InventoryListener;
|
||||
import com.gmail.nossr50.listeners.PlayerListener;
|
||||
import com.gmail.nossr50.listeners.SelfListener;
|
||||
import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.CheckDateTask;
|
||||
import com.gmail.nossr50.runnables.SaveTimerTask;
|
||||
@@ -52,7 +50,6 @@ import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
|
||||
import com.gmail.nossr50.skills.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.HolidayManager;
|
||||
import com.gmail.nossr50.util.LogFilter;
|
||||
@@ -119,8 +116,8 @@ public class mcMMO extends JavaPlugin {
|
||||
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||
public final static String playerDataKey = "mcMMO: Player Data";
|
||||
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
|
||||
public final static String pistonDataKey = "mcMMO: Piston State";
|
||||
public final static String databaseCommandKey = "mcMMO: Processing Database Command";
|
||||
public final static String bredMetadataKey = "mcMMO: Bred Animal";
|
||||
|
||||
public static FixedMetadataValue metadataValue;
|
||||
|
||||
@@ -181,8 +178,6 @@ public class mcMMO extends JavaPlugin {
|
||||
scheduleTasks();
|
||||
CommandRegistrationManager.registerCommands();
|
||||
|
||||
MetricsManager.setup();
|
||||
|
||||
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
||||
|
||||
checkForUpdates();
|
||||
@@ -457,14 +452,6 @@ public class mcMMO extends JavaPlugin {
|
||||
if (Config.getInstance().getChimaeraEnabled()) {
|
||||
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
||||
}
|
||||
|
||||
if (Config.getInstance().getFluxPickaxeEnabled()) {
|
||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.DIAMOND_PICKAXE));
|
||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.GOLD_PICKAXE));
|
||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.IRON_PICKAXE));
|
||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.STONE_PICKAXE));
|
||||
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.WOOD_PICKAXE));
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleTasks() {
|
||||
|
||||
@@ -1,353 +0,0 @@
|
||||
package com.gmail.nossr50.metrics;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
import com.turt2live.metrics.EMetrics;
|
||||
import com.turt2live.metrics.Metrics;
|
||||
import com.turt2live.metrics.Metrics.Graph;
|
||||
import com.turt2live.metrics.data.DataEvent;
|
||||
import com.turt2live.metrics.data.DataTracker;
|
||||
import com.turt2live.metrics.tracker.Tracker;
|
||||
|
||||
public class MetricsManager {
|
||||
private static boolean setup = false;
|
||||
|
||||
private static Tracker chimeraUseTracker;
|
||||
private static Tracker chimeraServerUseTracker;
|
||||
|
||||
private static boolean customConfig = false;
|
||||
|
||||
private static DataTracker tracker;
|
||||
private static EMetrics emetrics;
|
||||
|
||||
public static void setup() {
|
||||
if (setup) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStatsTrackingEnabled()) {
|
||||
try {
|
||||
emetrics = new EMetrics(mcMMO.p);
|
||||
Metrics metrics = emetrics.getMetrics();
|
||||
|
||||
// Timings Graph
|
||||
Graph timingsGraph = metrics.createGraph("Percentage of servers using timings");
|
||||
|
||||
if (mcMMO.p.getServer().getPluginManager().useTimings()) {
|
||||
timingsGraph.addPlotter(new Metrics.Plotter("Enabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
timingsGraph.addPlotter(new Metrics.Plotter("Disabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Donut Version Graph
|
||||
Graph versionDonutGraph = metrics.createGraph("Donut Version");
|
||||
|
||||
boolean haveVersionInformation = false;
|
||||
boolean isOfficialBuild = false;
|
||||
String officialKey = "e14cfacdd442a953343ebd8529138680";
|
||||
|
||||
String version = mcMMO.p.getDescription().getVersion();
|
||||
|
||||
InputStreamReader isr = new InputStreamReader(mcMMO.p.getResource(".jenkins"));
|
||||
BufferedReader br = new BufferedReader(isr);
|
||||
char[] key = new char[32];
|
||||
br.read(key);
|
||||
if (officialKey.equals(String.valueOf(key))) {
|
||||
isOfficialBuild = true;
|
||||
}
|
||||
|
||||
if (version.contains("-")) {
|
||||
String majorVersion = version.substring(0, version.indexOf("-"));
|
||||
String subVersion;
|
||||
|
||||
if (isOfficialBuild) {
|
||||
int startIndex = version.indexOf("-");
|
||||
if (version.substring(startIndex + 1).contains("-")) {
|
||||
subVersion = version.substring(startIndex, version.indexOf("-", startIndex + 1));
|
||||
}
|
||||
else {
|
||||
subVersion = "-release";
|
||||
}
|
||||
}
|
||||
else {
|
||||
subVersion = "-custom";
|
||||
}
|
||||
|
||||
version = majorVersion + "~=~" + subVersion;
|
||||
haveVersionInformation = true;
|
||||
}
|
||||
|
||||
if (haveVersionInformation) {
|
||||
versionDonutGraph.addPlotter(new Metrics.Plotter(version) {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Official v Custom build Graph
|
||||
Graph officialGraph = metrics.createGraph("Built by official ci");
|
||||
|
||||
if (isOfficialBuild) {
|
||||
officialGraph.addPlotter(new Metrics.Plotter("Yes") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
officialGraph.addPlotter(new Metrics.Plotter("No") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Chunkmeta enabled Graph
|
||||
Graph chunkmetaGraph = metrics.createGraph("Uses Chunkmeta");
|
||||
|
||||
if (HiddenConfig.getInstance().getChunkletsEnabled()) {
|
||||
chunkmetaGraph.addPlotter(new Metrics.Plotter("Yes") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
chunkmetaGraph.addPlotter(new Metrics.Plotter("No") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Storage method Graph
|
||||
Graph storageGraph = metrics.createGraph("Storage method");
|
||||
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
storageGraph.addPlotter(new Metrics.Plotter("SQL") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
storageGraph.addPlotter(new Metrics.Plotter("Flatfile") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Locale Graph
|
||||
Graph localeGraph = metrics.createGraph("Locale");
|
||||
|
||||
localeGraph.addPlotter(new Metrics.Plotter(LocaleLoader.getCurrentLocale().getDisplayLanguage(Locale.US)) {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// ExperienceFormulaShape Graph
|
||||
Graph experienceFormulaShapeGraph = metrics.createGraph("Experience Formula Shape Graph");
|
||||
|
||||
experienceFormulaShapeGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getFormulaType().toString()) {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// GlobalMultiplier Graph
|
||||
Graph globalMultiplierGraph = metrics.createGraph("Global Multiplier Graph");
|
||||
|
||||
globalMultiplierGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() + "") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// GlobalCurveModifier Graph
|
||||
Graph globalCurveModifierGraph = metrics.createGraph("Global Curve Modifier Graph");
|
||||
|
||||
globalCurveModifierGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) + "") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// GlobalMultiplierGraph Fuzzy Logic Numbers
|
||||
Graph globalMultiplierGraphFuzzy = metrics.createGraph("Global Multiplier Fuzz");
|
||||
|
||||
if (ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() > 1.0) {
|
||||
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() < 1.0) {
|
||||
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// GlobalCurveModifier Fuzzy Logic Numbers
|
||||
Graph globalCurveMultiplierGraphFuzzy = metrics.createGraph("Global Curve Multiplier Fuzz");
|
||||
|
||||
if (ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) > 20.0) {
|
||||
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) < 20.0) {
|
||||
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Chimera Wing Usage Trackers
|
||||
final String chimeraGraphName = "Chimera Wing Usage";
|
||||
|
||||
chimeraUseTracker = EMetrics.createBasicTracker(chimeraGraphName, "Player use");
|
||||
chimeraServerUseTracker = EMetrics.createEnabledTracker(chimeraGraphName, "Server use");
|
||||
|
||||
emetrics.addTracker(chimeraUseTracker);
|
||||
emetrics.addTracker(chimeraServerUseTracker);
|
||||
|
||||
// Chimera Wing Enabled Graph
|
||||
Graph chimeraGraph = metrics.createGraph("Chimera Wing");
|
||||
|
||||
if (Config.getInstance().getChimaeraEnabled()) {
|
||||
chimeraGraph.addPlotter(new Metrics.Plotter("Enabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
chimeraGraph.addPlotter(new Metrics.Plotter("Disabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Vanilla v Modified config graph
|
||||
Graph customConfigGraph = metrics.createGraph("Modified Configs");
|
||||
|
||||
if (customConfig) {
|
||||
customConfigGraph.addPlotter(new Metrics.Plotter("Edited") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
customConfigGraph.addPlotter(new Metrics.Plotter("Vanilla") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* Debug stuff
|
||||
* tracker = emetrics.getDataTracker();
|
||||
* tracker.enable();
|
||||
* tracker.setFilter(new DataEvent.DataType [] { DataEvent.DataType.SEND_DATA });
|
||||
*/
|
||||
|
||||
emetrics.startMetrics();
|
||||
}
|
||||
catch (IOException e) {
|
||||
mcMMO.p.getLogger().warning("Failed to submit stats.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void chimeraWingUsed() {
|
||||
chimeraUseTracker.increment();
|
||||
chimeraServerUseTracker.increment();
|
||||
}
|
||||
|
||||
public static void customConfig() {
|
||||
customConfig = true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void debug() {
|
||||
emetrics.getMetrics().flush();
|
||||
|
||||
for (DataEvent event : tracker.getEvents()) {
|
||||
String graphName = event.getGraphName();
|
||||
String colName = event.getTrackerName();
|
||||
int value = event.getValueSent();
|
||||
|
||||
System.out.println("Graph: " + graphName + ", Column: " + colName + ", Value: " + value);
|
||||
}
|
||||
|
||||
tracker.resetEvents();
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!mcMMO.getPlaceStore().isTrue(movedBlock.getRelative(direction))) {
|
||||
if (!mcMMO.getPlaceStore().isTrue(movedBlock)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class StickyPistonTrackerTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
// The sticky piston actually pulled the block so move the PlaceStore data
|
||||
mcMMO.getPlaceStore().setFalse(movedBlock.getRelative(direction));
|
||||
mcMMO.getPlaceStore().setTrue(movedBlock);
|
||||
mcMMO.getPlaceStore().setFalse(movedBlock);
|
||||
mcMMO.getPlaceStore().setTrue(block.getRelative(direction));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,6 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
|
||||
catch (Exception e) {
|
||||
// Handle 429
|
||||
if (e.getMessage().contains("429")) {
|
||||
size += userNamesSection.size();
|
||||
try {
|
||||
Thread.sleep(LIMIT_PERIOD);
|
||||
} catch (InterruptedException ex) {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.gmail.nossr50.runnables.party;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public class PartyChatTask extends BukkitRunnable {
|
||||
private Plugin plugin;
|
||||
@@ -45,6 +46,6 @@ public class PartyChatTask extends BukkitRunnable {
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getServer().getConsoleSender().sendMessage(ChatColor.stripColor("[mcMMO] [P]<" + party.getName() + ">" + message));
|
||||
plugin.getServer().getConsoleSender().sendMessage("[mcMMO] [P]<" + party.getName() + ">" + message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
|
||||
// If successful, schedule the apply
|
||||
if (profile.isLoaded()) {
|
||||
new ApplySuccessfulProfile(new McMMOPlayer(player, profile)).runTask(mcMMO.p);
|
||||
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
private class ApplySuccessfulProfile extends BukkitRunnable {
|
||||
private final McMMOPlayer mcMMOPlayer;
|
||||
private final PlayerProfile profile;
|
||||
|
||||
private ApplySuccessfulProfile(McMMOPlayer mcMMOPlayer) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
private ApplySuccessfulProfile(PlayerProfile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
// Synchronized task
|
||||
@@ -74,7 +74,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMOPlayer.setupPartyData();
|
||||
McMMOPlayer mcMMOPlayer = new McMMOPlayer(player, profile);
|
||||
UserManager.track(mcMMOPlayer);
|
||||
mcMMOPlayer.actualizeRespawnATS();
|
||||
ScoreboardManager.setupPlayer(player);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gmail.nossr50.runnables.skills;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@@ -11,20 +11,20 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class KrakenAttackTask extends BukkitRunnable {
|
||||
private LivingEntity kraken;
|
||||
private Creature kraken;
|
||||
private Player player;
|
||||
private Location location;
|
||||
private final boolean GLOBAL_EFFECTS = AdvancedConfig.getInstance().getKrakenGlobalEffectsEnabled();
|
||||
private final String DEFEAT_MESSAGE = AdvancedConfig.getInstance().getPlayerDefeatMessage();
|
||||
private final String ESCAPE_MESSAGE = AdvancedConfig.getInstance().getPlayerEscapeMessage();
|
||||
|
||||
public KrakenAttackTask(LivingEntity kraken2, Player player) {
|
||||
this.kraken = kraken2;
|
||||
public KrakenAttackTask(Creature kraken, Player player) {
|
||||
this.kraken = kraken;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public KrakenAttackTask(LivingEntity kraken2, Player player, Location location) {
|
||||
this.kraken = kraken2;
|
||||
public KrakenAttackTask(Creature kraken, Player player, Location location) {
|
||||
this.kraken = kraken;
|
||||
this.player = player;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@@ -56,29 +56,23 @@ public final class AlchemyPotionBrewer {
|
||||
return item == null || item.getType() == Material.AIR || item.getAmount() == 0;
|
||||
}
|
||||
|
||||
private static void removeIngredient(BrewerInventory inventory, Player player) {
|
||||
private static boolean removeIngredient(BrewerInventory inventory, Player player) {
|
||||
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
||||
|
||||
if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
else if (ingredient.getAmount() <= 1) {
|
||||
inventory.setIngredient(null);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
ingredient.setAmount(ingredient.getAmount() - 1);
|
||||
inventory.setIngredient(ingredient);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasIngredient(BrewerInventory inventory, Player player) {
|
||||
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
||||
|
||||
return !isEmpty(ingredient) && isValidIngredient(player, ingredient);
|
||||
}
|
||||
|
||||
public static boolean isValidIngredient(Player player, ItemStack item) {
|
||||
if (isEmpty(item)) {
|
||||
return false;
|
||||
@@ -105,7 +99,7 @@ public final class AlchemyPotionBrewer {
|
||||
BrewerInventory inventory = ((BrewingStand) brewingStand).getInventory();
|
||||
ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();
|
||||
|
||||
if (!hasIngredient(inventory, player)) {
|
||||
if (!removeIngredient(inventory, player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,8 +129,6 @@ public final class AlchemyPotionBrewer {
|
||||
return;
|
||||
}
|
||||
|
||||
removeIngredient(inventory, player);
|
||||
|
||||
for (AlchemyPotion input : inputList) {
|
||||
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class Archery {
|
||||
@@ -22,7 +21,7 @@ public class Archery {
|
||||
|
||||
public static double dazeBonusDamage = AdvancedConfig.getInstance().getDazeBonusDamage();
|
||||
|
||||
public static final double DISTANCE_XP_MULTIPLIER = ExperienceConfig.getInstance().getArcheryDistanceMultiplier();
|
||||
public static final double DISTANCE_XP_MULTIPLIER = 0.025;
|
||||
|
||||
protected static void incrementTrackerValue(LivingEntity livingEntity) {
|
||||
for (TrackedEntity trackedEntity : trackedEntities) {
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ArcheryManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
applyXpGain((int) (Math.min(firedLocation.distanceSquared(targetLocation), 2500) * Archery.DISTANCE_XP_MULTIPLIER), getXPGainReason(target, damager));
|
||||
applyXpGain((int) (firedLocation.distanceSquared(targetLocation) * Archery.DISTANCE_XP_MULTIPLIER), getXPGainReason(target, damager));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,16 +74,10 @@ public class AxesManager extends SkillManager {
|
||||
|
||||
Player player = getPlayer();
|
||||
|
||||
if (mcMMOPlayer.useChatNotifications()) {
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (UserManager.getPlayer(defender).useChatNotifications()) {
|
||||
defender.sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||
}
|
||||
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
|
||||
|
||||
damage = (damage * Axes.criticalHitPVPModifier) - damage;
|
||||
}
|
||||
|
||||
@@ -110,9 +110,6 @@ public final class Fishing {
|
||||
case PIG_ZOMBIE:
|
||||
return TreasureConfig.getInstance().shakeFromPigZombie;
|
||||
|
||||
case PLAYER:
|
||||
return TreasureConfig.getInstance().shakeFromPlayer;
|
||||
|
||||
case SHEEP:
|
||||
return TreasureConfig.getInstance().shakeFromSheep;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.skills.fishing;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -16,6 +15,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fish;
|
||||
@@ -29,8 +29,6 @@ import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.material.Wool;
|
||||
import org.bukkit.potion.Potion;
|
||||
import org.bukkit.potion.PotionType;
|
||||
@@ -106,7 +104,7 @@ public class FishingManager extends SkillManager {
|
||||
vehicle.remove();
|
||||
}
|
||||
|
||||
player.teleport(player.getTargetBlock((HashSet<Byte>) null, 100).getLocation(), TeleportCause.PLUGIN);
|
||||
player.teleport(player.getTargetBlock(null, 100).getLocation(), TeleportCause.PLUGIN);
|
||||
|
||||
String unleashMessage = AdvancedConfig.getInstance().getPlayerUnleashMessage();
|
||||
|
||||
@@ -137,7 +135,7 @@ public class FishingManager extends SkillManager {
|
||||
player.setItemInHand(null);
|
||||
}
|
||||
|
||||
LivingEntity kraken = (LivingEntity) world.spawnEntity(player.getEyeLocation(), (Misc.getRandom().nextInt(100) == 0 ? EntityType.CHICKEN : EntityType.SQUID));
|
||||
Creature kraken = (Creature) world.spawnEntity(player.getEyeLocation(), (Misc.getRandom().nextInt(100) == 0 ? EntityType.CHICKEN : EntityType.SQUID));
|
||||
kraken.setCustomName(AdvancedConfig.getInstance().getKrakenName());
|
||||
|
||||
if (!kraken.isValid()) {
|
||||
@@ -169,7 +167,7 @@ public class FishingManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block targetBlock = getPlayer().getTargetBlock((HashSet<Byte>) BlockUtils.getTransparentBlocks(), 100);
|
||||
Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
|
||||
|
||||
if (!targetBlock.isLiquid()) {
|
||||
return false;
|
||||
@@ -396,45 +394,6 @@ public class FishingManager extends SkillManager {
|
||||
|
||||
// Extra processing depending on the mob and drop type
|
||||
switch (target.getType()) {
|
||||
case PLAYER:
|
||||
Player targetPlayer = (Player) target;
|
||||
|
||||
switch (drop.getType()) {
|
||||
case SKULL_ITEM:
|
||||
drop.setDurability((short) 3);
|
||||
SkullMeta skullMeta = (SkullMeta) drop.getItemMeta();
|
||||
skullMeta.setOwner(targetPlayer.getName());
|
||||
drop.setItemMeta(skullMeta);
|
||||
break;
|
||||
|
||||
case BED_BLOCK:
|
||||
if (TreasureConfig.getInstance().getInventoryStealEnabled()) {
|
||||
PlayerInventory inventory = targetPlayer.getInventory();
|
||||
int length = inventory.getContents().length;
|
||||
int slot = Misc.getRandom().nextInt(length);
|
||||
drop = inventory.getItem(slot);
|
||||
|
||||
if (drop == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (TreasureConfig.getInstance().getInventoryStealStacks()) {
|
||||
inventory.setItem(slot, null);
|
||||
}
|
||||
else {
|
||||
inventory.setItem(slot, (drop.getAmount() > 1) ? new ItemStack(drop.getType(), drop.getAmount() - 1) : null);
|
||||
drop.setAmount(1);
|
||||
}
|
||||
|
||||
targetPlayer.updateInventory();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) target;
|
||||
|
||||
@@ -478,7 +437,7 @@ public class FishingManager extends SkillManager {
|
||||
}
|
||||
|
||||
Misc.dropItem(target.getLocation(), drop);
|
||||
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1), getPlayer()); // Make it so you can shake a mob no more than 4 times.
|
||||
CombatUtils.dealDamage(target, Math.max(target.getMaxHealth() / 4, 1)); // Make it so you can shake a mob no more than 4 times.
|
||||
applyXpGain(ExperienceConfig.getInstance().getFishingShakeXP(), XPGainReason.PVE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.CropState;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NetherWartsState;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -236,24 +235,15 @@ public class HerbalismManager extends SkillManager {
|
||||
|
||||
Player player = getPlayer();
|
||||
|
||||
if (treasures.isEmpty()) {
|
||||
if (treasures.isEmpty() || !EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
|
||||
return false;
|
||||
}
|
||||
int skillLevel = getSkillLevel();
|
||||
Location location = blockState.getLocation();
|
||||
|
||||
for (HylianTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) {
|
||||
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, false)) {
|
||||
return false;
|
||||
}
|
||||
blockState.setType(Material.AIR);
|
||||
Misc.dropItem(location, treasure.getDrop());
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
blockState.setType(Material.AIR);
|
||||
|
||||
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
|
||||
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ public class Mining {
|
||||
*
|
||||
* @param blockState The {@link BlockState} to check ability activation for
|
||||
*/
|
||||
public static int getBlockXp(BlockState blockState) {
|
||||
protected static int getBlockXp(BlockState blockState) {
|
||||
Material blockType = blockState.getType();
|
||||
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
|
||||
|
||||
@@ -64,8 +64,7 @@ public class Mining {
|
||||
case QUARTZ_ORE:
|
||||
case REDSTONE_ORE:
|
||||
case STONE:
|
||||
case PRISMARINE:
|
||||
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
|
||||
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType));
|
||||
return;
|
||||
|
||||
default:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gmail.nossr50.skills.mining;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@@ -94,7 +93,7 @@ public class MiningManager extends SkillManager {
|
||||
*/
|
||||
public void remoteDetonation() {
|
||||
Player player = getPlayer();
|
||||
Block targetBlock = player.getTargetBlock((HashSet<Byte>) BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
|
||||
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
|
||||
|
||||
if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) {
|
||||
return;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class RepairManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.repairItemType(player, repairable.getRepairItemType())) {
|
||||
if (!Permissions.repairMaterialType(player, repairable.getRepairMaterialType())) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
package com.gmail.nossr50.skills.smelting;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
@@ -22,13 +14,10 @@ import com.gmail.nossr50.datatypes.skills.XPGainReason;
|
||||
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.mining.Mining;
|
||||
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
|
||||
import com.gmail.nossr50.util.BlockUtils;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
|
||||
public class SmeltingManager extends SkillManager {
|
||||
@@ -74,51 +63,17 @@ public class SmeltingManager extends SkillManager {
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!EventUtils.simulateBlockBreak(blockState.getBlock(), player, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We need to distribute Mining XP here, because the block break event gets cancelled
|
||||
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE);
|
||||
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
||||
|
||||
Misc.dropItems(blockState.getLocation(), item, isSecondSmeltSuccessful() ? 2 : 1);
|
||||
|
||||
blockState.setType(Material.AIR);
|
||||
|
||||
if (Config.getInstance().getFluxPickaxeSoundEnabled()) {
|
||||
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
|
||||
}
|
||||
|
||||
ParticleEffectUtils.playFluxEffect(blockState.getLocation());
|
||||
player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getFluxPickaxe(Material material, int amount) {
|
||||
ItemStack itemStack = new ItemStack(material, amount);
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.FluxPickaxe.Name"));
|
||||
|
||||
List<String> itemLore = itemMeta.hasLore() ? itemMeta.getLore() : new ArrayList<String>();
|
||||
itemLore.add("mcMMO Item");
|
||||
itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.1"));
|
||||
itemLore.add(LocaleLoader.getString("Item.FluxPickaxe.Lore.2", Smelting.fluxMiningUnlockLevel));
|
||||
itemMeta.setLore(itemLore);
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
public static FurnaceRecipe getFluxPickaxeRecipe(Material material) {
|
||||
return new FurnaceRecipe(getFluxPickaxe(material, 1), material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increases burn time for furnace fuel.
|
||||
*
|
||||
|
||||
@@ -83,7 +83,7 @@ public class SwordsManager extends SkillManager {
|
||||
}
|
||||
|
||||
if (SkillUtils.activationSuccessful(SecondaryAbility.COUNTER, getPlayer(), getSkillLevel(), activationChance)) {
|
||||
CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier, getPlayer());
|
||||
CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier);
|
||||
|
||||
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||
|
||||
|
||||
@@ -277,7 +277,6 @@ public class TamingManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
location = Misc.getLocationOffset(location, 1);
|
||||
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(location, type);
|
||||
|
||||
FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
|
||||
|
||||
@@ -4,13 +4,18 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
||||
|
||||
@@ -18,11 +23,18 @@ public class TrackedTamingEntity extends BukkitRunnable {
|
||||
private LivingEntity livingEntity;
|
||||
private UUID id;
|
||||
private int length;
|
||||
private Player owner;
|
||||
|
||||
protected TrackedTamingEntity(LivingEntity livingEntity) {
|
||||
this.livingEntity = livingEntity;
|
||||
this.id = livingEntity.getUniqueId();
|
||||
|
||||
AnimalTamer tamer = ((Tameable)livingEntity).getOwner();
|
||||
|
||||
if (tamer != null && tamer instanceof Player) {
|
||||
this.owner = (Player) tamer;
|
||||
}
|
||||
|
||||
int tamingCOTWLength = Config.getInstance().getTamingCOTWLength(livingEntity.getType());
|
||||
|
||||
if (tamingCOTWLength > 0) {
|
||||
@@ -40,7 +52,14 @@ public class TrackedTamingEntity extends BukkitRunnable {
|
||||
CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity);
|
||||
}
|
||||
|
||||
TamingManager.removeFromTracker(this);
|
||||
if (!UserManager.hasPlayerDataKey(owner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(owner);
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
|
||||
tamingManager.removeFromTracker(this);
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
|
||||
@@ -71,14 +71,7 @@ public class Unarmed {
|
||||
}
|
||||
|
||||
// Inventory is full - cancel the item pickup
|
||||
if (dropStack.getAmount() == dropAmount) {
|
||||
return false;
|
||||
} else {
|
||||
drop.remove();
|
||||
dropStack.setAmount(dropAmount);
|
||||
((Item) drop.getWorld().dropItem(drop.getLocation(), dropStack)).setPickupDelay(0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (firstEmpty != -1) {
|
||||
drop.remove();
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.ItemUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
@@ -49,7 +48,7 @@ public class UnarmedManager extends SkillManager {
|
||||
public boolean canDeflect() {
|
||||
Player player = getPlayer();
|
||||
|
||||
return ItemUtils.isUnarmed(player.getItemInHand()) && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT);
|
||||
return player.getItemInHand().getType() == Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT);
|
||||
}
|
||||
|
||||
public boolean canUseBlockCracker() {
|
||||
|
||||
@@ -62,7 +62,13 @@ public final class Woodcutting {
|
||||
species = ((Tree) blockState.getData()).getSpecies();
|
||||
}
|
||||
|
||||
return ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
|
||||
int xp = ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
|
||||
|
||||
if (species == TreeSpecies.JUNGLE && experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
|
||||
xp *= 0.5;
|
||||
}
|
||||
|
||||
return xp;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,15 +86,6 @@ public final class Woodcutting {
|
||||
if (blockState.getData() instanceof Tree) {
|
||||
species = ((Tree) blockState.getData()).getSpecies();
|
||||
}
|
||||
if (blockState.getType() == Material.LOG_2) {
|
||||
byte data = blockState.getRawData();
|
||||
if ((data & 1) != 0) {
|
||||
species = TreeSpecies.ACACIA;
|
||||
}
|
||||
if ((data & 2) != 0) {
|
||||
species = TreeSpecies.DARK_OAK;
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) {
|
||||
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
|
||||
|
||||
@@ -63,18 +63,6 @@ public final class BlockUtils {
|
||||
case DROPPER:
|
||||
case HOPPER:
|
||||
case TRAPPED_CHEST:
|
||||
case IRON_DOOR:
|
||||
case IRON_TRAPDOOR:
|
||||
case ACACIA_DOOR:
|
||||
case SPRUCE_DOOR:
|
||||
case BIRCH_DOOR:
|
||||
case JUNGLE_DOOR:
|
||||
case DARK_OAK_DOOR:
|
||||
case ACACIA_FENCE:
|
||||
case DARK_OAK_FENCE:
|
||||
case BIRCH_FENCE:
|
||||
case JUNGLE_FENCE:
|
||||
case ARMOR_STAND:
|
||||
return false;
|
||||
|
||||
default:
|
||||
@@ -173,8 +161,6 @@ public final class BlockUtils {
|
||||
case SANDSTONE:
|
||||
case STAINED_CLAY:
|
||||
case STONE:
|
||||
case PRISMARINE:
|
||||
case RED_SANDSTONE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.metrics.MetricsManager;
|
||||
import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
@@ -117,7 +116,7 @@ public final class ChimaeraWing {
|
||||
public static void chimaeraExecuteTeleport() {
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
|
||||
if (Config.getInstance().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
|
||||
if (player.getBedSpawnLocation() != null) {
|
||||
player.teleport(player.getBedSpawnLocation());
|
||||
}
|
||||
else {
|
||||
@@ -135,10 +134,6 @@ public final class ChimaeraWing {
|
||||
mcMMOPlayer.actualizeChimeraWingLastUse();
|
||||
mcMMOPlayer.setTeleportCommenceLocation(null);
|
||||
|
||||
if (Config.getInstance().getStatsTrackingEnabled()) {
|
||||
MetricsManager.chimeraWingUsed();
|
||||
}
|
||||
|
||||
if (Config.getInstance().getChimaeraSoundEnabled()) {
|
||||
player.playSound(location, Sound.BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.bukkit.entity.Fish;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -279,4 +280,26 @@ public class EventUtils {
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* There is a bug in CraftBukkit that causes piston events to
|
||||
* fire multiple times. Check this method to see if the piston event
|
||||
* should be processed.
|
||||
*
|
||||
* @param block Block object of the piston block
|
||||
* @param isExtendEvent should be true when called from BlockPistonExtendEvent
|
||||
*
|
||||
* @return true if the PistonEvent should be processed, false otherwise
|
||||
*/
|
||||
public static boolean shouldProcessEvent(Block block, boolean isExtendEvent) {
|
||||
String pistonAction = isExtendEvent ? "EXTEND" : "RETRACT";
|
||||
String lastAction = block.hasMetadata(mcMMO.pistonDataKey) ? block.getMetadata(mcMMO.pistonDataKey).get(0).asString() : "";
|
||||
|
||||
if (!lastAction.equals(pistonAction)) {
|
||||
block.setMetadata(mcMMO.pistonDataKey, new FixedMetadataValue(mcMMO.p, pistonAction));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.bukkit.material.Dye;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.party.ItemWeightConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
|
||||
public final class ItemUtils {
|
||||
@@ -147,20 +146,6 @@ public final class ItemUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item counts as unarmed.
|
||||
*
|
||||
* @param item Item to check
|
||||
* @return true if the item counts as unarmed, false otherwise
|
||||
*/
|
||||
public static boolean isUnarmed(ItemStack item) {
|
||||
if (Config.getInstance().getUnarmedItemsAsUnarmed()) {
|
||||
return !isMinecraftTool(item);
|
||||
}
|
||||
|
||||
return item.getType() == Material.AIR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the item is a helmet.
|
||||
*
|
||||
@@ -709,13 +694,4 @@ public final class ItemUtils {
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
|
||||
}
|
||||
|
||||
public static boolean isFluxPickaxe(ItemStack item) {
|
||||
if (!isMcMMOItem(item)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
return itemMeta.hasDisplayName() && itemMeta.getDisplayName().equals(ChatColor.GOLD + LocaleLoader.getString("Item.FluxPickaxe.Name"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public final class MaterialUtils {
|
||||
case REDSTONE_ORE:
|
||||
case EMERALD_ORE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return mcMMO.getModManager().isCustomOre(data);
|
||||
}
|
||||
|
||||
@@ -144,23 +144,6 @@ public final class Misc {
|
||||
return "UnknownMods";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a random location near the specified location
|
||||
*/
|
||||
public static Location getLocationOffset(Location location, double strength) {
|
||||
double blockX = location.getBlockX();
|
||||
double blockZ = location.getBlockZ();
|
||||
|
||||
double distance;
|
||||
distance = strength * random.nextDouble();
|
||||
blockX = (random.nextBoolean()) ? blockX + (distance) : blockX - (distance);
|
||||
|
||||
distance = strength * random.nextDouble();
|
||||
blockZ = (random.nextBoolean()) ? blockZ + (distance) : blockZ - (distance);
|
||||
|
||||
return new Location(location.getWorld(), blockX, location.getY(), blockZ);
|
||||
}
|
||||
|
||||
public static Random getRandom() {
|
||||
return random;
|
||||
}
|
||||
|
||||
@@ -293,8 +293,8 @@ public class HashChunkManager implements ChunkManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
String key = world.getName() + "," + cx + "," + cz;
|
||||
|
||||
if (!store.containsKey(key)) {
|
||||
@@ -336,8 +336,8 @@ public class HashChunkManager implements ChunkManager {
|
||||
return;
|
||||
}
|
||||
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
|
||||
int ix = Math.abs(x) % 16;
|
||||
int iz = Math.abs(z) % 16;
|
||||
@@ -382,8 +382,8 @@ public class HashChunkManager implements ChunkManager {
|
||||
return;
|
||||
}
|
||||
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
int cx = x / 16;
|
||||
int cz = z / 16;
|
||||
|
||||
int ix = Math.abs(x) % 16;
|
||||
int iz = Math.abs(z) % 16;
|
||||
|
||||
@@ -340,7 +340,7 @@ public class ScoreboardManager {
|
||||
}
|
||||
|
||||
for (String playerName : dirtyPowerLevels) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
continue;
|
||||
|
||||
@@ -199,13 +199,6 @@ public class ScoreboardWrapper {
|
||||
|
||||
// TODO is there any way to do the time that looks acceptable?
|
||||
// player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F));
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
if (profile.getScoreboardTipsShown() >= Config.getInstance().getTipsAmount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tippedKeep) {
|
||||
tippedKeep = true;
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Keep"));
|
||||
@@ -213,7 +206,6 @@ public class ScoreboardWrapper {
|
||||
else if (!tippedClear) {
|
||||
tippedClear = true;
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Clear"));
|
||||
profile.increaseTipsShown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Guardian;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -48,6 +47,7 @@ import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.MobHealthbarUtils;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public final class CombatUtils {
|
||||
@@ -250,7 +250,7 @@ public final class CombatUtils {
|
||||
processAxeCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
else if (ItemUtils.isUnarmed(heldItem)) {
|
||||
else if (heldItem.getType() == Material.AIR) {
|
||||
if (!SkillType.UNARMED.shouldProcess(target)) {
|
||||
return;
|
||||
}
|
||||
@@ -466,7 +466,6 @@ public final class CombatUtils {
|
||||
switch (type) {
|
||||
case BAT:
|
||||
case SQUID:
|
||||
case RABBIT:
|
||||
baseXP = ExperienceConfig.getInstance().getAnimalsXP();
|
||||
break;
|
||||
|
||||
@@ -485,7 +484,6 @@ public final class CombatUtils {
|
||||
case WITCH:
|
||||
case WITHER:
|
||||
case ZOMBIE:
|
||||
case ENDERMITE:
|
||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
||||
break;
|
||||
|
||||
@@ -506,14 +504,6 @@ public final class CombatUtils {
|
||||
}
|
||||
break;
|
||||
|
||||
case GUARDIAN:
|
||||
if (((Guardian) target).isElder()) {
|
||||
baseXP = ExperienceConfig.getInstance().getElderGuardianXP();
|
||||
} else {
|
||||
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
baseXP = 1.0;
|
||||
mcMMO.getModManager().addCustomEntity(target);
|
||||
@@ -525,10 +515,6 @@ public final class CombatUtils {
|
||||
baseXP *= ExperienceConfig.getInstance().getSpawnedMobXpMultiplier();
|
||||
}
|
||||
|
||||
if (target.hasMetadata(mcMMO.bredMetadataKey)) {
|
||||
baseXP *= ExperienceConfig.getInstance().getBredMobXpMultiplier();
|
||||
}
|
||||
|
||||
xpGainReason = XPGainReason.PVE;
|
||||
|
||||
baseXP *= 10;
|
||||
|
||||
@@ -37,14 +37,6 @@ public final class ParticleEffectUtils {
|
||||
playSmokeEffect(player);
|
||||
}
|
||||
|
||||
public static void playFluxEffect(Location location) {
|
||||
if (!Config.getInstance().getFluxEffectEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 1);
|
||||
}
|
||||
|
||||
public static void playSmokeEffect(LivingEntity livingEntity) {
|
||||
Location location = livingEntity.getEyeLocation();
|
||||
World world = livingEntity.getWorld();
|
||||
|
||||
@@ -90,7 +90,7 @@ Skills:
|
||||
# Modifier: Extra damage for arrows that cause a daze (2 damage = 1 heart)
|
||||
ChanceMax: 50.0
|
||||
MaxBonusLevel: 1000
|
||||
BonusDamage: 4.0
|
||||
Modifier: 4.0
|
||||
|
||||
Retrieve:
|
||||
# ChanceMax: Maximum chance of retrieving arrows when on <MaxBonusLevel> or higher
|
||||
|
||||
@@ -20,8 +20,6 @@ General:
|
||||
Update_Check: true
|
||||
Prefer_Beta: false
|
||||
Power_Level_Cap: 0
|
||||
# Should mcMMO truncate levels if you lower your max level cap for a skillname
|
||||
TruncateSkills: false
|
||||
# Should mcMMO print out debug messages?
|
||||
Verbose_Logging: false
|
||||
# Should mcMMO over-write configs to update, or make new ones ending in .new?
|
||||
@@ -47,10 +45,6 @@ Scoreboard:
|
||||
# Show the /mcstats scoreboard automatically after logging in
|
||||
Show_Stats_After_Login: false
|
||||
|
||||
# Show scoreboard tips 5 times. Tips are only displayed once for every login session.
|
||||
# Set to 0 to never show these tips.
|
||||
Tips_Amount: 5
|
||||
|
||||
# Add some more color on the board :-)
|
||||
Rainbows: false
|
||||
|
||||
@@ -213,15 +207,10 @@ Items:
|
||||
Warmup: 5
|
||||
RecentlyHurt_Cooldown: 60
|
||||
Prevent_Use_Underground: true
|
||||
# Attempt to use the bed spawn, if one is available
|
||||
Use_Bed_Spawn: true
|
||||
Use_Cost: 1
|
||||
Recipe_Cost: 5
|
||||
Item_Name: FEATHER
|
||||
Sound_Enabled: true
|
||||
Flux_Pickaxe:
|
||||
Enabled: true
|
||||
Sound_Enabled: true
|
||||
|
||||
#
|
||||
# Settings for Parties
|
||||
@@ -397,8 +386,6 @@ Skills:
|
||||
# When using Unarmed, picked up items will automatically get moved to a free slot instead of going in the slot
|
||||
# of your hand. Should item pickup be disabled when your entire inventory - except for your hand - is full?
|
||||
Item_Pickup_Disabled_Full_Inventory: true
|
||||
# Any attacks made without a tool, i.e. with one's open hand, a block, etc., will count as unarmed.
|
||||
Items_As_Unarmed: false
|
||||
Woodcutting:
|
||||
Tree_Feller_Sounds: true
|
||||
Level_Cap: 0
|
||||
@@ -492,9 +479,8 @@ Particles:
|
||||
LargeFireworks: true
|
||||
|
||||
# Use particle effect when these abilities trigger
|
||||
Bleed: true
|
||||
Dodge: true
|
||||
Flux: true
|
||||
Bleed: true
|
||||
Greater_Impact: true
|
||||
Call_of_the_Wild: true
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@ Experience_Formula:
|
||||
# Experience gained from mobs not naturally spawned will get multiplied by this value. 0 by default.
|
||||
Mobspawners:
|
||||
Multiplier: 0
|
||||
Breeding:
|
||||
Multiplier: 1.0
|
||||
|
||||
# Experience gained will get divided by these values. 1.0 by default, 2.0 means two times less XP gained.
|
||||
Modifier:
|
||||
@@ -118,8 +116,6 @@ Experience:
|
||||
Potion_Stage_3: 60
|
||||
Potion_Stage_4: 120
|
||||
Potion_Stage_5: 0
|
||||
Archery:
|
||||
Distance_Multiplier: 0.025
|
||||
Fishing:
|
||||
Raw_Fish: 800
|
||||
Raw_Salmon: 800
|
||||
@@ -200,8 +196,6 @@ Experience:
|
||||
Sandstone: 30
|
||||
Stained_Clay: 50
|
||||
Stone: 30
|
||||
Red_Sandstone: 100
|
||||
Prismarine: 70
|
||||
Repair:
|
||||
Base: 1000.0
|
||||
Wood: 0.6
|
||||
@@ -247,6 +241,3 @@ Experience:
|
||||
Witch: 0.0
|
||||
Iron_Golem: 2.0
|
||||
Wither_Skeleton: 4.0
|
||||
Endermite: 2.0
|
||||
Guardian: 3.0
|
||||
Elder_Guardian: 4.0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -835,9 +835,6 @@ Item.ChimaeraWing.Name=Chimaera Wing
|
||||
Item.ChimaeraWing.Lore=[[GRAY]]Teleports you to your bed.
|
||||
Item.Generic.Wait=[[RED]]You need to wait before you can use this again! [[YELLOW]]({0}s)
|
||||
Item.Injured.Wait=You were injured recently and must wait to use this. [[YELLOW]]({0}s)
|
||||
Item.FluxPickaxe.Name=Flux Pickaxe
|
||||
Item.FluxPickaxe.Lore.1=[[GRAY]]Has a chance of instantly smelting ores.
|
||||
Item.FluxPickaxe.Lore.2=[[GRAY]]Requires Smelting level {0}+
|
||||
|
||||
#TELEPORTATION
|
||||
Teleport.Commencing=[[GRAY]]Commencing teleport in [[GOLD]]({0}) [[GRAY]]seconds, please stand still...
|
||||
@@ -911,6 +908,7 @@ Smelting.Effect.4=Vanilla XP Boost
|
||||
Smelting.Effect.5=Increase vanilla XP gained while smelting
|
||||
Smelting.Effect.6=Flux Mining
|
||||
Smelting.Effect.7=Chance for ores to be instantly smelted while mining
|
||||
Smelting.FluxMining.Success=[[GREEN]]That ore smelted itself!
|
||||
Smelting.Listener=Smelting:
|
||||
Smelting.SkillName=SMELTING
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ Archery.Effect.2=Stordire (Giocatori)
|
||||
Archery.Effect.3=Disorienta i nemici e infligge {0} Danni
|
||||
Archery.Effect.4=Recupero Frecce
|
||||
Archery.Effect.5=Probabilit\u00e0 di recuperare frecce dai cadaveri
|
||||
Archery.Listener=Arco:
|
||||
Archery.SkillName=ARCO
|
||||
Archery.Skillup=[[YELLOW]]L\'abilit\u00e0 Arco \u00e8 aumentata di {0}. Total ({1})
|
||||
Archery.Listener=Tiro con l\'Arco:
|
||||
Archery.SkillName=TIRO CON L\'ARCO
|
||||
Archery.Skillup=[[YELLOW]]L\'abilit\u00e0 Tiro con l\'Arco \u00e8 aumentata di {0}. Total ({1})
|
||||
Axes.Ability.Bonus.0=Maestria con l\'Ascia
|
||||
Axes.Ability.Bonus.1={0} Danni Bonus
|
||||
Axes.Ability.Bonus.2=Sfonda Armature
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,8 @@ description: >
|
||||
|
||||
author: nossr50
|
||||
authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking]
|
||||
website: www.spigotmc.org/resources/mcmmo.2445/
|
||||
website: http://dev.bukkit.org/server-mods/mcmmo/
|
||||
|
||||
main: com.gmail.nossr50.mcMMO
|
||||
softdepend: [CombatTag, HealthBar]
|
||||
load: STARTUP
|
||||
|
||||
@@ -793,16 +793,6 @@ Shake:
|
||||
XP: 0
|
||||
Drop_Chance: 50.0
|
||||
Drop_Level: 0
|
||||
PLAYER:
|
||||
SKULL_ITEM:
|
||||
Amount: 1
|
||||
XP: 0
|
||||
Drop_Chance: 0.0
|
||||
Drop_Level: 0
|
||||
INVENTORY:
|
||||
Whole_Stacks: false
|
||||
Drop_Chance: 0.0
|
||||
Drop_Level: 0
|
||||
SHEEP:
|
||||
WOOL:
|
||||
Amount: 3
|
||||
|
||||
Reference in New Issue
Block a user