mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-18 17:53:00 +01:00
Compare commits
228 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0681c10b9 | ||
|
|
1bf0cd1d15 | ||
|
|
212b42c8b9 | ||
|
|
9c4ff30ce7 | ||
|
|
d7510b83c8 | ||
|
|
9a9e0cc7de | ||
|
|
a8a90ee815 | ||
|
|
7859660ece | ||
|
|
b93dafee63 | ||
|
|
a1a61e9d4a | ||
|
|
464d6bdd35 | ||
|
|
2c613d5b99 | ||
|
|
d1f683b8a5 | ||
|
|
f4bb8ccb7d | ||
|
|
00364afd8f | ||
|
|
f5f07f7016 | ||
|
|
2bdeeb2d6e | ||
|
|
f023529d37 | ||
|
|
b8d37cb223 | ||
|
|
88ed14fe5c | ||
|
|
cd30771775 | ||
|
|
00a5bc5cf3 | ||
|
|
a17d58fe32 | ||
|
|
c21286dbc3 | ||
|
|
7fc99630e0 | ||
|
|
69a5cd1017 | ||
|
|
3129acfc19 | ||
|
|
c3dd777e44 | ||
|
|
c5120b9c72 | ||
|
|
91a18fe7a2 | ||
|
|
62f5185a1b | ||
|
|
f4cb83319e | ||
|
|
c7b3b7a826 | ||
|
|
01fb245da3 | ||
|
|
83e072dad1 | ||
|
|
eb5ac80714 | ||
|
|
b57cc7bd59 | ||
|
|
d532164cd6 | ||
|
|
61ae4826d1 | ||
|
|
be4e62fe9d | ||
|
|
d9346ab260 | ||
|
|
87c4f318a4 | ||
|
|
30b87e8035 | ||
|
|
26a85846fc | ||
|
|
cd40507609 | ||
|
|
a9ea2e0137 | ||
|
|
6964f7adfc | ||
|
|
70231b6ae0 | ||
|
|
9354831729 | ||
|
|
ab7a83b37e | ||
|
|
8dfa8c20f3 | ||
|
|
67499eeff7 | ||
|
|
d43ff6263f | ||
|
|
058dc8c611 | ||
|
|
8871964be0 | ||
|
|
42aa426991 | ||
|
|
7cee94e0b8 | ||
|
|
fa96a6beec | ||
|
|
efc0edf3ef | ||
|
|
f1d785777c | ||
|
|
db0168205d | ||
|
|
2a20ed95fa | ||
|
|
11f1889f1f | ||
|
|
703b5b2f3f | ||
|
|
58a15e61dd | ||
|
|
896f57f0b4 | ||
|
|
34ae64706e | ||
|
|
43fe92fe3f | ||
|
|
31513d52d7 | ||
|
|
70a16fe344 | ||
|
|
4570ffb8f5 | ||
|
|
22f6ed324d | ||
|
|
e29484e14b | ||
|
|
7e21fdd862 | ||
|
|
01e69cdf5e | ||
|
|
9ad7840236 | ||
|
|
e97ec36094 | ||
|
|
ef318eeaec | ||
|
|
3314b18318 | ||
|
|
5f04ecfdd4 | ||
|
|
91d294acff | ||
|
|
283cdeed6c | ||
|
|
a283fce4ec | ||
|
|
f8d525d797 | ||
|
|
80dabad10e | ||
|
|
8181989e98 | ||
|
|
0f7bf13834 | ||
|
|
c1d6e79a41 | ||
|
|
6f073250f4 | ||
|
|
c084ccde40 | ||
|
|
b73a06b9ab | ||
|
|
740c1131ea | ||
|
|
0a798aec30 | ||
|
|
9089e70155 | ||
|
|
f532630d1b | ||
|
|
7b47d32a96 | ||
|
|
3934392219 | ||
|
|
ed6f48b5fe | ||
|
|
729e4a6eac | ||
|
|
9a39dead4f | ||
|
|
cb1eabc3fa | ||
|
|
b30002948c | ||
|
|
d528f11082 | ||
|
|
42a1fdf2df | ||
|
|
394ddd4e51 | ||
|
|
8c7d95f9ea | ||
|
|
422550abfd | ||
|
|
ca9ce1ba1b | ||
|
|
ac1c420cb5 | ||
|
|
05a9e85529 | ||
|
|
ca6ed76e8f | ||
|
|
3d04da39e3 | ||
|
|
127908f104 | ||
|
|
686bcd5308 | ||
|
|
07c66378c0 | ||
|
|
4e7107c8a8 | ||
|
|
3c2d658b37 | ||
|
|
f0b2cc1bab | ||
|
|
d038cbf357 | ||
|
|
c3ea632cb9 | ||
|
|
a31d50924d | ||
|
|
c567e2714a | ||
|
|
a2e342b4fc | ||
|
|
4469637f27 | ||
|
|
f4ecbe7f65 | ||
|
|
dbaab4efe1 | ||
|
|
8c178869b7 | ||
|
|
3c7bcb990e | ||
|
|
f7a5678814 | ||
|
|
646bb32965 | ||
|
|
dce7d8fdd3 | ||
|
|
6dd17312f4 | ||
|
|
9c64f40ea1 | ||
|
|
da6b461408 | ||
|
|
77dce75108 | ||
|
|
37308917d1 | ||
|
|
21d2229572 | ||
|
|
7d372af51e | ||
|
|
a3e0753076 | ||
|
|
a728d1f9c8 | ||
|
|
b893e86f3c | ||
|
|
63cf6e9b3a | ||
|
|
67738d811e | ||
|
|
4d77f6d04d | ||
|
|
3702495038 | ||
|
|
ede08ce5ac | ||
|
|
5571e0bc0c | ||
|
|
73bb73c8ca | ||
|
|
54011fdeb7 | ||
|
|
5b8811bd09 | ||
|
|
c460eec0ab | ||
|
|
bc6233541a | ||
|
|
18aef9d526 | ||
|
|
ccc6fd30f8 | ||
|
|
1ba498c443 | ||
|
|
64f31f2b5a | ||
|
|
b94085c5f4 | ||
|
|
62b90ad552 | ||
|
|
d6d1e0ffed | ||
|
|
ccd103cd88 | ||
|
|
0606f16a11 | ||
|
|
c9e3ea005b | ||
|
|
f009f5803f | ||
|
|
3f8268d848 | ||
|
|
cefec723d0 | ||
|
|
124aa72fd9 | ||
|
|
dbc7277ba9 | ||
|
|
24d8769b5b | ||
|
|
4aecb9756e | ||
|
|
51ca29ab9f | ||
|
|
c6e5264b7b | ||
|
|
73203ce869 | ||
|
|
b80a29ca04 | ||
|
|
5ee440d9a5 | ||
|
|
cda3675dc5 | ||
|
|
caf9c07ba3 | ||
|
|
96e70aa4d2 | ||
|
|
9f1b77a007 | ||
|
|
946b5bb006 | ||
|
|
bebcc40987 | ||
|
|
d6d7f5099f | ||
|
|
bdcc2f644b | ||
|
|
c3ba54a0ce | ||
|
|
1443e2f6b8 | ||
|
|
7799acec05 | ||
|
|
1bbc1f28aa | ||
|
|
8257fd8e7c | ||
|
|
bc58aff362 | ||
|
|
1073954550 | ||
|
|
c3d7a4e3de | ||
|
|
92ae92c116 | ||
|
|
3c10be6d1a | ||
|
|
f18a9bdcc7 | ||
|
|
87f59cd3eb | ||
|
|
819b6fcacb | ||
|
|
246961887e | ||
|
|
54e21333a3 | ||
|
|
c45beec59d | ||
|
|
c88ada489a | ||
|
|
189f23f407 | ||
|
|
9789143c6d | ||
|
|
f4dd7ff483 | ||
|
|
50e05c6320 | ||
|
|
9ba5360bfc | ||
|
|
565ef693ce | ||
|
|
0c1a8eff85 | ||
|
|
32e9de6e9a | ||
|
|
533955a9c7 | ||
|
|
2faa0356a5 | ||
|
|
ee2a5c199a | ||
|
|
bdcc522897 | ||
|
|
71b20bdeaa | ||
|
|
0e85b4776a | ||
|
|
24d2c1bc7a | ||
|
|
1610e932c6 | ||
|
|
31d7bb2332 | ||
|
|
3d9c03c0c8 | ||
|
|
dd94343d92 | ||
|
|
4b93dede33 | ||
|
|
61205989cc | ||
|
|
2559ea61d8 | ||
|
|
eae665c1c5 | ||
|
|
d73521e0a0 | ||
|
|
e8deb0384a | ||
|
|
881f2c023e | ||
|
|
5057a8a7a3 | ||
|
|
b8e9269488 | ||
|
|
76afd5a7ca |
@@ -7,6 +7,41 @@ Key:
|
||||
! Change
|
||||
- Removal
|
||||
|
||||
Version 1.3.11
|
||||
! Changed axes to start with 1 durability damage instead of 5, gain 1 durability damage every 50 levels instead of 30, and only have a 25% chance on hit to damage armor (per armor piece)
|
||||
+ Added compatibility with bow-wielding NPCs from Citizens/NPC mods
|
||||
+ Added compatibility for pvp-prevention plugins for Serrated Strikes
|
||||
= Fixed bug where mcMMO could throw NPE errors if trees cut down were from a custom mod and had an id of 17
|
||||
= Fixed dupe bug where mcMMO would ignore other block-protection plugins for various abilities
|
||||
= Fixed NPE with hardcore mode's vampirism
|
||||
|
||||
Version 1.3.10
|
||||
+ Added 1.3.1 compatibility
|
||||
+ Added permission node for Iron Grip ability (mcmmo.ability.unarmed.irongrip)
|
||||
+ Added ability for custom blocks to drop a range of items.
|
||||
+ Added Ability API functions
|
||||
+ Added 50% & 150% XP boost perks
|
||||
+ Added "lucky" perk for donors
|
||||
= Fixed /inspect not working on offline players
|
||||
= Fixed custom blocks, tools and armors not loading properly
|
||||
= Fixed duplication bug with sticky pistons
|
||||
= Fixed "GenericLabel belonging to mcMMO..." message
|
||||
= Fixed menu exit button not working
|
||||
= Fixed Repair enchant downgrade not working
|
||||
= Fixed NPE caused by Spout players after a /reload
|
||||
= Fixed ConcurrentModificationException on world unload
|
||||
= Fixed players never being removed from memory (memory leak)
|
||||
= Fixed admin chat being seen by everyone
|
||||
= Fixed issue with UTFDataFormatException occurring on occasion when trying to load Chunklets
|
||||
= Fixed ArrayIndexOutOfBounds error caused when trying to use /xplock after logging in but before gaining XP
|
||||
= Fixed custom tools not properly respecting the Ability_Enabled flag.
|
||||
= Fixed "lower tool" messages still being displayed even when ability messages are disabled.
|
||||
= Fixed custom blocks not dropping the proper item with Super Breaker when Silk Touch is used
|
||||
= Fixed custom woodcutting blocks throwing errors.
|
||||
= Fixed possible ClassCastException from catching something other than a mob when using the Shake Mob skill
|
||||
! Changed the format by which Chunklets are stored to be much smaller, and much faster to load
|
||||
! Optimized how player placed blocks are tracked
|
||||
|
||||
Version 1.3.09
|
||||
+ Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)
|
||||
+ Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP)
|
||||
|
||||
15
pom.xml
Normal file → Executable file
15
pom.xml
Normal file → Executable file
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.3.09</version>
|
||||
<version>1.3.12</version>
|
||||
<name>mcMMO</name>
|
||||
<url>https://github.com/mcMMO-Dev/mcMMO</url>
|
||||
<issueManagement>
|
||||
@@ -121,6 +121,13 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.getspout</groupId>
|
||||
<artifactId>spoutpluginapi</artifactId>
|
||||
@@ -128,6 +135,12 @@
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit-dep</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
47
src/main/java/com/gmail/nossr50/api/AbilityAPI.java
Normal file
47
src/main/java/com/gmail/nossr50/api/AbilityAPI.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.gmail.nossr50.api;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class AbilityAPI {
|
||||
|
||||
public static boolean berserkEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.BERSERK);
|
||||
}
|
||||
|
||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.GIGA_DRILL_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean greenTerraEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.GREEN_TERRA);
|
||||
}
|
||||
|
||||
public static boolean serratedStrikesEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SERRATED_STRIKES);
|
||||
}
|
||||
|
||||
public static boolean skullSplitterEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SKULL_SPLIITER);
|
||||
}
|
||||
|
||||
public static boolean superBreakerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.SUPER_BREAKER);
|
||||
}
|
||||
|
||||
public static boolean treeFellerEnabled(Player player) {
|
||||
return Users.getProfile(player).getAbilityMode(AbilityType.TREE_FELLER);
|
||||
}
|
||||
|
||||
public static boolean isAnyAbilityEnabled(Player player) {
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (Users.getProfile(player).getAbilityMode(ability)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addRawXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getProfile(player).addXPOverride(skillType, XP);
|
||||
Users.getPlayer(player).addXPOverride(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getProfile(player).addXPOverrideBonus(skillType, XP);
|
||||
Users.getPlayer(player).addXPOverrideBonus(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public final class ExperienceAPI {
|
||||
* @param XP The amount of XP to add
|
||||
*/
|
||||
public static void addXP(Player player, SkillType skillType, int XP) {
|
||||
Users.getProfile(player).addXP(skillType, XP);
|
||||
Users.getPlayer(player).addXP(skillType, XP);
|
||||
checkXP(player, skillType);
|
||||
}
|
||||
|
||||
@@ -133,6 +133,45 @@ public final class ExperienceAPI {
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public static int getPowerLevel(Player player) {
|
||||
return Users.getProfile(player).getPowerLevel();
|
||||
return Users.getPlayer(player).getPowerLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the level of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the level of
|
||||
* @param skillType The skill to set the level for
|
||||
* @param skillLevel The value to set the level to
|
||||
*/
|
||||
public static void setLevel(Player player, SkillType skillType, int skillLevel) {
|
||||
Users.getProfile(player).modifySkill(skillType, skillLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XP of a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to set the XP of
|
||||
* @param skillType The skill to set the XP for
|
||||
* @param newValue The value to set the XP to
|
||||
*/
|
||||
public static void setXP(Player player, SkillType skillType, int newValue) {
|
||||
Users.getProfile(player).setSkillXPLevel(skillType, newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes XP from a player in a specific skill type.
|
||||
* </br>
|
||||
* This function is designed for API usage.
|
||||
*
|
||||
* @param player The player to change the XP of
|
||||
* @param skillType The skill to change the XP for
|
||||
* @param xp The amount of XP to remove
|
||||
*/
|
||||
public static void removeXP(Player player, SkillType skillType, int xp) {
|
||||
Users.getProfile(player).removeXP(skillType, xp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,11 +11,11 @@ public final class SpoutToolsAPI {
|
||||
|
||||
private SpoutToolsAPI() {}
|
||||
|
||||
public static List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||
public static List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||
public static List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||
public static List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||
public static List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutSwords = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutAxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutPickaxes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutHoes = new ArrayList<ItemStack>();
|
||||
public static final List<ItemStack> spoutShovels = new ArrayList<ItemStack>();
|
||||
|
||||
/**
|
||||
* Add a custom Spout tool to mcMMO for XP gain & ability use.
|
||||
|
||||
@@ -23,7 +23,7 @@ public class CommandHelper {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (player != null && !Permissions.getInstance().permission(player, permission)) {
|
||||
if (!Permissions.getInstance().permission(player, permission)) {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
@@ -49,28 +49,33 @@ public class CommandHelper {
|
||||
*/
|
||||
public static void printGatheringSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasGatheringSkills(inspect)) {
|
||||
PlayerProfile PP = Users.getProfile(inspect);
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
|
||||
if (Permissions.getInstance().excavation(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().fishing(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().herbalism(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().mining(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().woodcutting(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,28 +92,33 @@ public class CommandHelper {
|
||||
*/
|
||||
public static void printCombatSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasCombatSkills(inspect)) {
|
||||
PlayerProfile PP = Users.getProfile(inspect);
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
|
||||
if (Permissions.getInstance().axes(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().archery(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().swords(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().taming(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().unarmed(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,15 +135,21 @@ public class CommandHelper {
|
||||
*/
|
||||
public static void printMiscSkills(Player inspect, CommandSender display) {
|
||||
if (Skills.hasMiscSkills(inspect)) {
|
||||
PlayerProfile PP = Users.getProfile(inspect);
|
||||
PlayerProfile profile = Users.getProfile(inspect);
|
||||
|
||||
if (profile == null) {
|
||||
display.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return;
|
||||
}
|
||||
|
||||
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
|
||||
if (Permissions.getInstance().acrobatics(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().repair(inspect)) {
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
|
||||
display.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,11 @@ public abstract class SkillCommand implements CommandExecutor {
|
||||
player = (Player) sender;
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
skillValue = profile.getSkillLevel(skill);
|
||||
dataCalculations();
|
||||
permissionsCheck();
|
||||
|
||||
@@ -26,7 +26,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
int levels;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
@@ -48,7 +48,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
modifiedPlayer = (Player) sender;
|
||||
levels = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
@@ -57,7 +57,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
PP.addLevels(skill, levels);
|
||||
profile.addLevels(skill, levels);
|
||||
sender.sendMessage(ChatColor.GREEN + "You were awarded " + levels + " levels in " + skillName + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
@@ -70,9 +70,14 @@ public class AddlevelsCommand implements CommandExecutor{
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
PP = Users.getProfile(modifiedPlayer);
|
||||
profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -49,7 +50,8 @@ public class AddxpCommand implements CommandExecutor {
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
profile.addXPOverride(skill, xp);
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
@@ -80,7 +82,13 @@ public class AddxpCommand implements CommandExecutor {
|
||||
case 3:
|
||||
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
|
||||
String playerName = modifiedPlayer.getName();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
@@ -97,7 +105,7 @@ public class AddxpCommand implements CommandExecutor {
|
||||
skill = Skills.getSkillType(args[1]);
|
||||
String message;
|
||||
|
||||
profile.addXPOverride(skill, xp);
|
||||
mcMMOPlayer.addXPOverride(skill, xp);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -16,16 +15,8 @@ import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class InspectCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public InspectCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer target;
|
||||
PlayerProfile PP;
|
||||
String usage = "Proper usage is /inspect <player>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
|
||||
@@ -34,22 +25,21 @@ public class InspectCommand implements CommandExecutor {
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
target = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
PP = Users.getProfile(target);
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (target.isOnline()) {
|
||||
Player player = (Player) target;
|
||||
if (mcmmoPlayer != null) {
|
||||
Player target = mcmmoPlayer.getPlayer();
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), player.getLocation(), 5.0) && !Permissions.getInstance().inspectDistanceBypass((Player) sender)) {
|
||||
if (sender instanceof Player && !sender.isOp() && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.getInstance().inspectDistanceBypass((Player) sender)) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", new Object[] { target.getName() }));
|
||||
CommandHelper.printGatheringSkills(player, sender);
|
||||
CommandHelper.printCombatSkills(player, sender);
|
||||
CommandHelper.printMiscSkills(player, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { PP.getPowerLevel() }));
|
||||
CommandHelper.printGatheringSkills(target, sender);
|
||||
CommandHelper.printCombatSkills(target, sender);
|
||||
CommandHelper.printMiscSkills(target, sender);
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { mcmmoPlayer.getPowerLevel() }));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -59,7 +49,14 @@ public class InspectCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
@@ -67,22 +64,22 @@ public class InspectCommand implements CommandExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", new Object[] { args[0] }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED) }));
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS) }));
|
||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", new Object[] { LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR) }));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@@ -19,7 +19,6 @@ public class McstatsCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
@@ -27,8 +26,13 @@ public class McstatsCommand implements CommandExecutor {
|
||||
CommandHelper.printGatheringSkills(player);
|
||||
CommandHelper.printCombatSkills(player);
|
||||
CommandHelper.printMiscSkills(player);
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(PP.getPowerLevel()) }));
|
||||
|
||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||
|
||||
if (powerLevelCap > 0)
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
|
||||
else
|
||||
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
@@ -18,8 +18,7 @@ import com.gmail.nossr50.util.Users;
|
||||
public class MmoeditCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer modifiedPlayer;
|
||||
PlayerProfile playerProfile;
|
||||
PlayerProfile profile;
|
||||
int newValue;
|
||||
SkillType skill;
|
||||
String skillName;
|
||||
@@ -38,10 +37,10 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (Misc.isInt(args[1])) {
|
||||
modifiedPlayer = (Player) sender;
|
||||
Player player = (Player) sender;
|
||||
newValue = Integer.valueOf(args[1]);
|
||||
skill = Skills.getSkillType(args[0]);
|
||||
playerProfile = Users.getProfile(modifiedPlayer);
|
||||
profile = Users.getProfile(player);
|
||||
|
||||
if (skill.equals(SkillType.ALL)) {
|
||||
skillName = "all skills";
|
||||
@@ -50,7 +49,7 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
skillName = Misc.getCapitalized(skill.toString());
|
||||
}
|
||||
|
||||
playerProfile.modifySkill(skill, newValue);
|
||||
profile.modifySkill(skill, newValue);
|
||||
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
else {
|
||||
@@ -84,27 +83,36 @@ public class MmoeditCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
newValue = Integer.valueOf(args[2]);
|
||||
playerProfile = Users.getProfile(args[0]);
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
if (playerProfile != null) {
|
||||
Player player = playerProfile.getPlayer();
|
||||
if (mcmmoPlayer != null) {
|
||||
profile = mcmmoPlayer.getProfile();
|
||||
|
||||
if (player.isOnline()) {
|
||||
player.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
}
|
||||
}
|
||||
else {
|
||||
playerProfile = new PlayerProfile(null, args[0], false);
|
||||
|
||||
if (!playerProfile.isLoaded()) {
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + args[0] + "."); //TODO: Use locale
|
||||
playerProfile.modifySkill(skill, newValue);
|
||||
playerProfile.save();
|
||||
profile.modifySkill(skill, newValue);
|
||||
mcmmoPlayer.getPlayer().sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
|
||||
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + args[0] + "."); //TODO: Use locale
|
||||
}
|
||||
else {
|
||||
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.modifySkill(skill, newValue);
|
||||
profile.save();
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
||||
@@ -26,7 +26,7 @@ public class MmoupdateCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + "Starting conversion..."); //TODO: Needs more locale.
|
||||
Users.clearUsers();
|
||||
Users.clearAll();
|
||||
convertToMySQL();
|
||||
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.gmail.nossr50.commands.general;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SkillResetCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandHelper.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//ensure they have the skillreset perm
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skillreset")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType skillType = null; //simple initialization
|
||||
|
||||
//make sure there's only one argument. output at least some kind of error if not
|
||||
if (args.length != 1 && args[0] != null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//parse the skilltype that they sent
|
||||
try
|
||||
{
|
||||
skillType = SkillType.valueOf(args[0].toUpperCase().trim()); //ucase needed to match enum since it's case sensitive. trim to be nice
|
||||
}catch(IllegalArgumentException ex)
|
||||
{
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
//reset the values in the hash table and persist them
|
||||
PlayerProfile profile = Users.getProfile((Player)sender);
|
||||
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
profile.resetSkill(skillType);
|
||||
profile.save();
|
||||
|
||||
//display a success message to the user
|
||||
if (skillType == SkillType.ALL)
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||
else
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { args[0] }));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,8 @@ import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class XprateCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
private static int oldrate = Config.getInstance().xpGainMultiplier;
|
||||
public static boolean xpevent = false;
|
||||
private static double oldRate = Config.getInstance().xpGainMultiplier;
|
||||
private static boolean xpEvent = false;
|
||||
|
||||
public XprateCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -33,16 +33,16 @@ public class XprateCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("reset")) {
|
||||
if (xpevent) {
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
|
||||
}
|
||||
|
||||
xpevent = !xpevent;
|
||||
Config.getInstance().xpGainMultiplier = oldrate;
|
||||
xpEvent = !xpEvent;
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
}
|
||||
else {
|
||||
Config.getInstance().xpGainMultiplier = oldrate;
|
||||
Config.getInstance().xpGainMultiplier = oldRate;
|
||||
}
|
||||
}
|
||||
else if (Misc.isInt(args[0])) {
|
||||
@@ -56,10 +56,10 @@ public class XprateCommand implements CommandExecutor {
|
||||
|
||||
case 2:
|
||||
if (Misc.isInt(args[0])) {
|
||||
oldrate = Config.getInstance().xpGainMultiplier;
|
||||
oldRate = Config.getInstance().xpGainMultiplier;
|
||||
|
||||
if (args[1].equalsIgnoreCase("true") || args[1].equalsIgnoreCase("false")) {
|
||||
xpevent = Boolean.valueOf(args[1]);
|
||||
xpEvent = Boolean.valueOf(args[1]);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage3);
|
||||
@@ -67,7 +67,7 @@ public class XprateCommand implements CommandExecutor {
|
||||
|
||||
Config.getInstance().xpGainMultiplier = Misc.getInt(args[0]);
|
||||
|
||||
if (xpevent) {
|
||||
if (xpEvent) {
|
||||
for (Player x : plugin.getServer().getOnlinePlayers()) {
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
|
||||
x.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
@@ -90,4 +90,8 @@ public class XprateCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isXpEventRunning() {
|
||||
return xpEvent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,16 +22,21 @@ public class McabilityCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile((Player) sender);
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (PP.getAbilityUse()) {
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
|
||||
PP.toggleAbilityUse();
|
||||
profile.toggleAbilityUse();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
@@ -44,6 +45,10 @@ public class MccCommand implements CommandExecutor {
|
||||
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
|
||||
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
|
||||
|
||||
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.getInstance().skillReset(player)) {
|
||||
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().mcAbility(player)) {
|
||||
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||
}
|
||||
|
||||
@@ -22,16 +22,21 @@ public class McgodCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerProfile PP = Users.getProfile((Player) sender);
|
||||
PlayerProfile profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (PP.getGodMode()) {
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Disabled"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Enabled"));
|
||||
}
|
||||
|
||||
PP.toggleGodMode();
|
||||
profile.toggleGodMode();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ public class McmmoCommand implements CommandExecutor {
|
||||
|
||||
if (Config.getInstance().getDonateMessageEnabled()) {
|
||||
if (mcMMO.spoutEnabled && sender instanceof SpoutPlayer) {
|
||||
SpoutPlayer sPlayer = (SpoutPlayer) sender;
|
||||
SpoutPlayer spoutPlayer = (SpoutPlayer) sender;
|
||||
|
||||
sPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND);
|
||||
spoutPlayer.sendNotification(ChatColor.YELLOW + "[mcMMO]" + ChatColor.GOLD + " Donate!", ChatColor.GREEN + "mcmmodev@gmail.com", Material.DIAMOND);
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "Donation Info:");
|
||||
|
||||
@@ -23,7 +23,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
OfflinePlayer player;
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /mcrefresh [player]"; //TODO: Needs more locale
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
|
||||
@@ -34,7 +34,7 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
PP = Users.getProfile(player);
|
||||
profile = Users.getProfile(player);
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(usage);
|
||||
@@ -44,10 +44,15 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
|
||||
case 1:
|
||||
player = plugin.getServer().getOfflinePlayer(args[0]);
|
||||
PP = Users.getProfile(player);
|
||||
profile = Users.getProfile(player);
|
||||
String playerName = player.getName();
|
||||
|
||||
if (!PP.isLoaded()) {
|
||||
if (profile == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
@@ -61,10 +66,10 @@ public class McrefreshCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
PP.setRecentlyHurt(0);
|
||||
PP.resetCooldowns();
|
||||
PP.resetToolPrepMode();
|
||||
PP.resetAbilityMode();
|
||||
profile.setRecentlyHurt(0);
|
||||
profile.resetCooldowns();
|
||||
profile.resetToolPrepMode();
|
||||
profile.resetAbilityMode();
|
||||
|
||||
if (player.isOnline()) {
|
||||
((Player) player).sendMessage(LocaleLoader.getString("Ability.Generic.Refresh"));
|
||||
|
||||
@@ -3,9 +3,9 @@ package com.gmail.nossr50.commands.mc;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -14,8 +14,11 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McremoveCommand implements CommandExecutor {
|
||||
@@ -24,7 +27,7 @@ public class McremoveCommand implements CommandExecutor {
|
||||
|
||||
public McremoveCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
this.location = mcMMO.usersFile;
|
||||
this.location = mcMMO.getUsersFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,31 +55,32 @@ public class McremoveCommand implements CommandExecutor {
|
||||
|
||||
/* MySQL */
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
int userId = 0;
|
||||
userId = mcMMO.database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
userId = database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
|
||||
if (userId > 0) {
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "users WHERE "
|
||||
+ tablePrefix + "users.id=" + userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "cooldowns WHERE "
|
||||
+ tablePrefix + "cooldowns.user_id=" + userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "huds WHERE "
|
||||
+ tablePrefix + "huds.user_id=" + userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "skills WHERE "
|
||||
+ tablePrefix + "skills.user_id=" + userId);
|
||||
|
||||
mcMMO.database.write("DELETE FROM "
|
||||
database.write("DELETE FROM "
|
||||
+ databaseName + "."
|
||||
+ tablePrefix + "experience WHERE "
|
||||
+ tablePrefix + "experience.user_id=" + userId);
|
||||
@@ -98,14 +102,24 @@ public class McremoveCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
//Force PlayerProfile stuff to update
|
||||
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
|
||||
|
||||
if (playerProfile != null) {
|
||||
Users.getProfiles().remove(playerProfile);
|
||||
if (mcmmoPlayer != null) {
|
||||
Player player = mcmmoPlayer.getPlayer();
|
||||
SpoutHud spoutHud = mcmmoPlayer.getProfile().getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.removeWidgets();
|
||||
}
|
||||
|
||||
Users.remove(playerName);
|
||||
|
||||
if (player.isOnline()) {
|
||||
Users.addUser((Player) player);
|
||||
Users.addUser(player);
|
||||
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutStuff.reloadSpoutPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,9 +129,12 @@ public class McremoveCommand implements CommandExecutor {
|
||||
private boolean removeFlatFileUser(String playerName) {
|
||||
boolean worked = false;
|
||||
|
||||
BufferedReader in = null;
|
||||
FileWriter out = null;
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
BufferedReader in = new BufferedReader(file);
|
||||
in = new BufferedReader(file);
|
||||
StringBuilder writer = new StringBuilder();
|
||||
String line = "";
|
||||
|
||||
@@ -134,16 +151,32 @@ public class McremoveCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
FileWriter out = new FileWriter(location); //Write out the new file
|
||||
out = new FileWriter(location); //Write out the new file
|
||||
out.write(writer.toString());
|
||||
out.close();
|
||||
|
||||
return worked;
|
||||
}
|
||||
catch (Exception e) {
|
||||
plugin.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
return worked;
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null) {
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return worked;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
@@ -107,7 +108,7 @@ public class MctopCommand implements CommandExecutor {
|
||||
private void flatfileDisplay(int page, String skill, CommandSender sender) {
|
||||
String[] info = Leaderboard.retrieveInfo(skill, page);
|
||||
|
||||
if (skill == "ALL") {
|
||||
if (skill.equals("ALL")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
@@ -134,9 +135,11 @@ public class MctopCommand implements CommandExecutor {
|
||||
|
||||
private void sqlDisplay(int page, String query, CommandSender sender) {
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
HashMap<Integer, ArrayList<String>> userslist = mcMMO.database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
|
||||
if (query == "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing") {
|
||||
HashMap<Integer, ArrayList<String>> userslist = database.read("SELECT " + query + ", user_id FROM " + tablePrefix + "skills WHERE " + query + " > 0 ORDER BY " + query + " DESC ");
|
||||
|
||||
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
@@ -144,11 +147,11 @@ public class MctopCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
for (int i = (page * 10) - 9; i <= (page * 10); i++) {
|
||||
if (i > userslist.size() || mcMMO.database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) {
|
||||
if (i > userslist.size() || database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'") == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> username = mcMMO.database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
HashMap<Integer, ArrayList<String>> username = database.read("SELECT user FROM " + tablePrefix + "users WHERE id = '" + Integer.valueOf(userslist.get(i).get(1)) + "'");
|
||||
sender.sendMessage(String.valueOf(i) + ". " + ChatColor.GREEN + userslist.get(i).get(0) + " - " + ChatColor.WHITE + username.get(1).get(0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ACommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /a <message>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) {
|
||||
@@ -33,15 +33,15 @@ public class ACommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
PP = Users.getProfile((Player) sender);
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (PP.getPartyChatMode()) {
|
||||
PP.togglePartyChat();
|
||||
if (profile.getPartyChatMode()) {
|
||||
profile.togglePartyChat();
|
||||
}
|
||||
|
||||
PP.toggleAdminChat();
|
||||
profile.toggleAdminChat();
|
||||
|
||||
if (PP.getAdminChatMode()) {
|
||||
if (profile.getAdminChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.AdminChat.On"));
|
||||
}
|
||||
else {
|
||||
@@ -55,12 +55,16 @@ public class ACommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
default:
|
||||
String message = args[0];
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
message = message + " " + args [i];
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
@@ -76,9 +80,9 @@ public class ACommand implements CommandExecutor {
|
||||
|
||||
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
|
||||
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
|
||||
p.sendMessage(prefix + message);
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(prefix + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class PCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile PP;
|
||||
PlayerProfile profile;
|
||||
String usage = ChatColor.RED + "Proper usage is /p <party-name> <message>"; //TODO: Needs more locale.
|
||||
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
|
||||
@@ -34,15 +34,15 @@ public class PCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (sender instanceof Player) {
|
||||
PP = Users.getProfile((Player) sender);
|
||||
profile = Users.getProfile((Player) sender);
|
||||
|
||||
if (PP.getAdminChatMode()) {
|
||||
PP.toggleAdminChat();
|
||||
if (profile.getAdminChatMode()) {
|
||||
profile.toggleAdminChat();
|
||||
}
|
||||
|
||||
PP.togglePartyChat();
|
||||
profile.togglePartyChat();
|
||||
|
||||
if (PP.getPartyChatMode()) {
|
||||
if (profile.getPartyChatMode()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Party.Chat.On"));
|
||||
}
|
||||
else {
|
||||
@@ -65,12 +65,16 @@ public class PCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = args[0];
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[0]);
|
||||
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
message = message + " " + args [i];
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
@@ -98,12 +102,16 @@ public class PCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
String message = args[1];
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append(args[1]);
|
||||
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
message = message + " " + args [i];
|
||||
buffer.append(" ");
|
||||
buffer.append(args[i]);
|
||||
}
|
||||
|
||||
String message = buffer.toString();
|
||||
|
||||
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent("Console", args[0], message);
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ public class PtpCommand implements CommandExecutor {
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (PP.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
|
||||
if (profile.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
|
||||
return true;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (PartyManager.getInstance().inSameParty(player, target)) {
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty().getName());
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, profile.getParty().getName());
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@@ -72,6 +72,7 @@ public class PtpCommand implements CommandExecutor {
|
||||
player.teleport(target);
|
||||
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", new Object[] { target.getName() }));
|
||||
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", new Object[] { player.getName() }));
|
||||
profile.setRecentlyHurt(System.currentTimeMillis());
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { target.getName() }));
|
||||
|
||||
@@ -23,7 +23,7 @@ public class AxesCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
impactDamage = String.valueOf(5 + ((int) skillValue / 30));
|
||||
impactDamage = String.valueOf(1 + ((int) skillValue / 50));
|
||||
skullSplitterLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||
greaterImpactDamage = "2";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gmail.nossr50.commands.skills;
|
||||
|
||||
import com.gmail.nossr50.commands.SkillCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
@@ -8,6 +9,7 @@ import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
public class FishingCommand extends SkillCommand {
|
||||
private int lootTier;
|
||||
private String magicChance;
|
||||
private String shakeChance;
|
||||
|
||||
private boolean canTreasureHunt;
|
||||
private boolean canMagicHunt;
|
||||
@@ -21,6 +23,11 @@ public class FishingCommand extends SkillCommand {
|
||||
protected void dataCalculations() {
|
||||
lootTier = Fishing.getFishingLootTier(profile);
|
||||
magicChance = percent.format((float) lootTier / 15);
|
||||
int dropChance = Fishing.getShakeChance(lootTier);
|
||||
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
|
||||
dropChance = (int) (dropChance * 1.25);
|
||||
}
|
||||
shakeChance = String.valueOf(dropChance);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,12 +73,11 @@ public class FishingCommand extends SkillCommand {
|
||||
}
|
||||
|
||||
if (canShake) {
|
||||
//TODO: Do we really need to display this twice? Not like there are any associated stats.
|
||||
if (skillValue < 150) {
|
||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", new Object[] { shakeChance }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,20 +9,13 @@ import org.bukkit.entity.Player;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class MchudCommand implements CommandExecutor {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public MchudCommand (mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
String usage = ChatColor.RED + "Proper usage is /mchud <hud-type>"; //TODO: Locale
|
||||
@@ -37,40 +30,32 @@ public class MchudCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
SpoutHud spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
HUDType hud;
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(args[0])) {
|
||||
playerProfile.setHudType(hudType);
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
|
||||
if (args[0].equalsIgnoreCase("disabled")) {
|
||||
hud = HUDType.DISABLED;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("standard")) {
|
||||
hud = HUDType.STANDARD;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("small")) {
|
||||
hud = HUDType.SMALL;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("retro")) {
|
||||
hud = HUDType.RETRO;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(invalid);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SpoutStuff.playerHUDs.containsKey(player)) {
|
||||
SpoutStuff.playerHUDs.get(player).resetHUD();
|
||||
SpoutStuff.playerHUDs.remove(player);
|
||||
PP.setHUDType(hud);
|
||||
SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage(invalid);
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
player.sendMessage(usage);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Skills;
|
||||
@@ -34,45 +34,54 @@ public class XplockCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile playerProfile = Users.getProfile(player);
|
||||
SpoutHud spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
if (spoutHud == null) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (PP.getXpBarLocked()) {
|
||||
PP.toggleXpBarLocked();
|
||||
if (spoutHud.getXpBarLocked()) {
|
||||
spoutHud.toggleXpBarLocked();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.unlocked"));
|
||||
return true;
|
||||
}
|
||||
|
||||
SkillType lastGained = PP.getLastGained();
|
||||
SkillType lastGained = spoutHud.getLastGained();
|
||||
|
||||
if (lastGained != null) {
|
||||
PP.toggleXpBarLocked();
|
||||
PP.setSkillLock(lastGained);
|
||||
spoutHud.toggleXpBarLocked();
|
||||
spoutHud.setSkillLock(lastGained);
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(lastGained.toString()) }));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(usage);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (Skills.isSkill(args[0])) {
|
||||
if (Permissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
|
||||
PP.setXpBarLocked(true);
|
||||
PP.setSkillLock(Skills.getSkillType(args[0]));
|
||||
SpoutStuff.updateXpBar(player);
|
||||
spoutHud.setXpBarLocked(true);
|
||||
spoutHud.setSkillLock(Skills.getSkillType(args[0]));
|
||||
spoutHud.updateXpBar();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Commands.xplock.locked", new Object[] { Misc.getCapitalized(args[0]) }));
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
player.sendMessage(usage);
|
||||
return true;
|
||||
|
||||
@@ -5,21 +5,27 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
public int xpGainMultiplier = 1;
|
||||
private static Config instance;
|
||||
public double xpGainMultiplier = 1;
|
||||
|
||||
private Config() {
|
||||
super("config.yml");
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static Config getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new Config(mcMMO.p);
|
||||
instance.load();
|
||||
instance = new Config();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {}
|
||||
|
||||
/*
|
||||
* GENERAL SETTINGS
|
||||
*/
|
||||
@@ -71,6 +77,7 @@ public class Config extends ConfigLoader {
|
||||
public boolean getCommandMCCEnabled() { return config.getBoolean("Commands.mcc.Enabled", true); }
|
||||
public boolean getCommandMCGodEnabled() { return config.getBoolean("Commands.mcgod.Enabled", true); }
|
||||
public boolean getCommandMCStatsEnabled() { return config.getBoolean("Commands.mcstats.Enabled", true); }
|
||||
public boolean getCommandSkillResetEnabled() { return config.getBoolean("Commands.skillreset.Enabled", true); }
|
||||
public boolean getCommandMmoeditEnabled() { return config.getBoolean("Commands.mmoedit.Enabled", true); }
|
||||
public boolean getCommandMCRemoveEnabled() { return config.getBoolean("Commands.mcremove.Enable", true); }
|
||||
public boolean getCommandPTPEnabled() { return config.getBoolean("Commands.ptp.Enabled", true); }
|
||||
@@ -145,6 +152,13 @@ public class Config extends ConfigLoader {
|
||||
public int getFishingTierLevelsTier3() { return config.getInt("Fishing.Tier_Levels.Tier3", 400); }
|
||||
public int getFishingTierLevelsTier4() { return config.getInt("Fishing.Tier_Levels.Tier4", 600); }
|
||||
public int getFishingTierLevelsTier5() { return config.getInt("Fishing.Tier_Levels.Tier5", 800); }
|
||||
|
||||
/* Shake */
|
||||
public int getShakeChanceRank1() { return config.getInt("Shake.Chance.Rank_1", 25); }
|
||||
public int getShakeChanceRank2() { return config.getInt("Shake.Chance.Rank_2", 40); }
|
||||
public int getShakeChanceRank3() { return config.getInt("Shake.Chance.Rank_3", 55); }
|
||||
public int getShakeChanceRank4() { return config.getInt("Shake.Chance.Rank_4", 60); }
|
||||
public int getShakeChanceRank5() { return config.getInt("Shake.Chance.Rank_5", 75); }
|
||||
|
||||
/* Herbalism */
|
||||
public int getHerbalismXPSugarCane() { return config.getInt("Experience.Herbalism.Sugar_Cane", 30); }
|
||||
@@ -157,8 +171,12 @@ public class Config extends ConfigLoader {
|
||||
public int getHerbalismXPNetherWart() { return config.getInt("Experience.Herbalism.Nether_Wart", 50); }
|
||||
public int getHerbalismXPLilyPads() { return config.getInt("Experience.Herbalism.Lily_Pads", 100); }
|
||||
public int getHerbalismXPVines() { return config.getInt("Experience.Herbalism.Vines", 10); }
|
||||
public int getHerbalismXPCocoa() { return config.getInt("Experience.Herbalism.Cocoa", 30); }
|
||||
public int getHerbalismXPCarrot() { return config.getInt("Experience.Herbalism.Carrot", 50); }
|
||||
public int getHerbalismXPPotato() { return config.getInt("Experience.Herbalism.Potato", 50); }
|
||||
|
||||
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); }
|
||||
public boolean getHerbalismGreenThumbCobbleWallToMossyWall() { return config.getBoolean("Skills.Herbalism.Green_Thumb.CobbleWall_To_MossyWall", true); }
|
||||
public boolean getHerbalismGreenThumbSmoothbrickToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true); }
|
||||
public boolean getHerbalismGreenThumbDirtToGrass() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); }
|
||||
|
||||
@@ -174,6 +192,9 @@ public class Config extends ConfigLoader {
|
||||
public boolean getVinesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Vines", true); }
|
||||
public boolean getWaterLiliesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Water_Lilies", true); }
|
||||
public boolean getYellowFlowersDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Yellow_Flowers", true); }
|
||||
public boolean getCocoaDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cocoa", true); }
|
||||
public boolean getCarrotDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Carrot", true); }
|
||||
public boolean getPotatoDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Potato", true); }
|
||||
|
||||
public boolean herbalismDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Herbalism");
|
||||
@@ -208,6 +229,7 @@ public class Config extends ConfigLoader {
|
||||
public int getMiningXPSandstone() { return config.getInt("Experience.Mining.Sandstone", 30); }
|
||||
public int getMiningXPEndStone() { return config.getInt("Experience.Mining.End_Stone", 150); }
|
||||
public int getMiningXPMossyStone() { return config.getInt("Experience.Mining.Moss_Stone", 30); }
|
||||
public int getMiningXPEmeraldOre() { return config.getInt("Experience.Mining.Emerald", 1000); }
|
||||
|
||||
public boolean getCoalDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Coal", true); }
|
||||
public boolean getDiamondDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Diamond", true); }
|
||||
@@ -222,6 +244,7 @@ public class Config extends ConfigLoader {
|
||||
public boolean getRedstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Redstone", true); }
|
||||
public boolean getSandstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Sandstone", true); }
|
||||
public boolean getStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Stone", true); }
|
||||
public boolean getEmeraldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Emerald", true); }
|
||||
|
||||
public boolean miningDoubleDropsDisabled() {
|
||||
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Mining");
|
||||
@@ -284,6 +307,10 @@ public class Config extends ConfigLoader {
|
||||
return disabled;
|
||||
}
|
||||
|
||||
/* AFK Leveling */
|
||||
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
|
||||
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
|
||||
|
||||
/* Arcane Forging */
|
||||
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Arcane_Forging.Downgrades.Enabled", true); }
|
||||
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
|
||||
@@ -336,7 +363,7 @@ public class Config extends ConfigLoader {
|
||||
/* General Settings */
|
||||
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
|
||||
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
|
||||
public int getExperienceGainsGlobalMultiplier() { return config.getInt("Experience.Gains.Multiplier.Global", 1); }
|
||||
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
|
||||
|
||||
/* Combat XP Multipliers */
|
||||
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
|
||||
@@ -370,19 +397,4 @@ public class Config extends ConfigLoader {
|
||||
public double getFormulaMultiplierAxes() { return config.getDouble("Experience.Formula.Multiplier.Axes", 1.0); }
|
||||
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
|
||||
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
|
||||
|
||||
/*
|
||||
* CONFIG LOADING
|
||||
*/
|
||||
|
||||
private Config(mcMMO plugin) {
|
||||
super(plugin, "config.yml");
|
||||
saveIfNotExist();
|
||||
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO config.yml File...");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -9,69 +11,69 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public abstract class ConfigLoader {
|
||||
protected static final mcMMO plugin = mcMMO.p;
|
||||
protected String fileName;
|
||||
protected File configFile;
|
||||
protected File dataFolder;
|
||||
protected final mcMMO plugin;
|
||||
protected FileConfiguration config;
|
||||
|
||||
public ConfigLoader(mcMMO plugin, String fileName){
|
||||
this.plugin = plugin;
|
||||
public ConfigLoader(String relativePath, String fileName){
|
||||
this.fileName = fileName;
|
||||
dataFolder = plugin.getDataFolder();
|
||||
configFile = new File(dataFolder, File.separator + fileName);
|
||||
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
public ConfigLoader(String fileName){
|
||||
this.fileName = fileName;
|
||||
configFile = new File(plugin.getDataFolder(), fileName);
|
||||
loadFile();
|
||||
}
|
||||
|
||||
protected void loadFile() {
|
||||
if (!configFile.exists()) {
|
||||
plugin.getLogger().info("Creating mcMMO " + fileName + " File...");
|
||||
createFile();
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().info("Loading mcMMO " + fileName + " File...");
|
||||
}
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load this config file.
|
||||
*/
|
||||
public void load() {
|
||||
if (!configFile.exists()) {
|
||||
dataFolder.mkdir();
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
addDefaults();
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save this config file.
|
||||
*/
|
||||
private void saveConfig() {
|
||||
try {
|
||||
config.save(configFile);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
plugin.getLogger().severe("Could not save config to " + configFile + ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected void saveIfNotExist() {
|
||||
if (!configFile.exists()) {
|
||||
if (plugin.getResource(fileName) != null) {
|
||||
plugin.saveResource(fileName, false);
|
||||
}
|
||||
}
|
||||
rereadFromDisk();
|
||||
}
|
||||
|
||||
protected void rereadFromDisk() {
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the defaults to this config file.
|
||||
*/
|
||||
protected void addDefaults() {
|
||||
config.options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the keys from this config file.
|
||||
*/
|
||||
protected abstract void loadKeys();
|
||||
|
||||
protected void createFile() {
|
||||
if (configFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
configFile.getParentFile().mkdirs();
|
||||
|
||||
InputStream inputStream = plugin.getResource(fileName);
|
||||
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
copyStreamToFile(inputStream, configFile);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
plugin.getLogger().severe("Missing ressource file: '" + fileName + "' please notify the plugin authors");
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyStreamToFile(InputStream inputStream, File file) throws Exception {
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
|
||||
int read = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
|
||||
while ((read = inputStream.read(bytes)) != -1) {
|
||||
outputStream.write(bytes, 0, read);
|
||||
}
|
||||
|
||||
inputStream.close();
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,43 +4,39 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class HiddenConfig extends ConfigLoader {
|
||||
private static String fileName;
|
||||
public class HiddenConfig {
|
||||
private static HiddenConfig instance;
|
||||
private static String fileName;
|
||||
private static YamlConfiguration config;
|
||||
|
||||
private static boolean chunkletsEnabled;
|
||||
private static int conversionRate;
|
||||
|
||||
public HiddenConfig(mcMMO plugin, String fileName) {
|
||||
super(plugin, fileName);
|
||||
public HiddenConfig(String fileName) {
|
||||
HiddenConfig.fileName = fileName;
|
||||
load();
|
||||
}
|
||||
|
||||
|
||||
public static HiddenConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new HiddenConfig(mcMMO.p, "hidden.yml");
|
||||
instance.load();
|
||||
instance = new HiddenConfig("hidden.yml");
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if (plugin.getResource(fileName) != null) {
|
||||
loadKeys();
|
||||
if (mcMMO.p.getResource(fileName) != null) {
|
||||
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
|
||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||
conversionRate = config.getInt("Options.ConversionRate", 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
config = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
||||
|
||||
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
|
||||
}
|
||||
|
||||
public boolean getChunkletsEnabled() {
|
||||
return chunkletsEnabled;
|
||||
}
|
||||
|
||||
public int getConversionRate() {
|
||||
return conversionRate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,39 @@
|
||||
package com.gmail.nossr50.config;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
|
||||
public class SpoutConfig extends ConfigLoader {
|
||||
private static SpoutConfig instance;
|
||||
public HudType defaultHudType;
|
||||
|
||||
private SpoutConfig() {
|
||||
super("spout.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static SpoutConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new SpoutConfig(mcMMO.p);
|
||||
instance.load();
|
||||
instance = new SpoutConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public HUDType defaulthud;
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
// Setup default HUD
|
||||
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
||||
|
||||
private SpoutConfig(mcMMO plugin) {
|
||||
super(plugin, "spout.yml");
|
||||
saveIfNotExist();
|
||||
for (HudType hudType : HudType.values()) {
|
||||
if (hudType.toString().equalsIgnoreCase(temp.toString())) {
|
||||
defaultHudType = hudType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultHudType == null) {
|
||||
defaultHudType = HudType.STANDARD;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowPowerLevel() { return config.getBoolean("HUD.Show_Power_Level", true); }
|
||||
@@ -77,22 +91,4 @@ public class SpoutConfig extends ConfigLoader {
|
||||
public double getRetroHUDFishingRed() { return config.getDouble("HUD.Retro.Colors.Fishing.RED", 0.3); }
|
||||
public double getRetroHUDFishingGreen() { return config.getDouble("HUD.Retro.Colors.Fishing.GREEN", 0.3); }
|
||||
public double getRetroHUDFishingBlue() { return config.getDouble("HUD.Retro.Colors.Fishing.BLUE", 0.75); }
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO spout.yml File...");
|
||||
|
||||
// Setup default HUD
|
||||
String temp = config.getString("Spout.HUD.Default", "STANDARD");
|
||||
|
||||
for (HUDType x : HUDType.values()) {
|
||||
if (x.toString().equalsIgnoreCase(temp.toString())) {
|
||||
defaulthud = x;
|
||||
}
|
||||
}
|
||||
|
||||
if (defaulthud == null) {
|
||||
defaulthud = HUDType.STANDARD;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,29 +5,19 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
||||
|
||||
public class TreasuresConfig extends ConfigLoader{
|
||||
private static TreasuresConfig instance;
|
||||
|
||||
public static TreasuresConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new TreasuresConfig(mcMMO.p);
|
||||
instance.load();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
|
||||
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
|
||||
@@ -41,15 +31,21 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
|
||||
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
|
||||
|
||||
private TreasuresConfig(mcMMO plugin) {
|
||||
super(plugin, "treasures.yml");
|
||||
saveIfNotExist();
|
||||
private TreasuresConfig() {
|
||||
super("treasures.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static TreasuresConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new TreasuresConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO treasures.yml File...");
|
||||
|
||||
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
|
||||
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
|
||||
Set<String> treasureConfigSet = treasureSection.getKeys(false);
|
||||
@@ -194,11 +190,13 @@ public class TreasuresConfig extends ConfigLoader{
|
||||
|
||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
||||
Iterator<String> treasureIterator = treasures.keySet().iterator();
|
||||
// Iterator<String> treasureIterator = treasures.keySet().iterator();
|
||||
Iterator<Entry<String,Treasure>> treasureIterator = treasures.entrySet().iterator();
|
||||
|
||||
while (treasureIterator.hasNext()) {
|
||||
String treasureKey = treasureIterator.next();
|
||||
Treasure treasure = treasures.get(treasureKey);
|
||||
Entry<String,Treasure> nextEntry = treasureIterator.next();
|
||||
String treasureKey = nextEntry.getKey();
|
||||
Treasure treasure = nextEntry.getValue();
|
||||
|
||||
if (treasure instanceof FishingTreasure) {
|
||||
if (!fishingTreasures.contains(treasureKey)) {
|
||||
|
||||
@@ -8,40 +8,37 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomItem;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class CustomArmorConfig extends ModConfigLoader{
|
||||
public class CustomArmorConfig extends ConfigLoader{
|
||||
private static CustomArmorConfig instance;
|
||||
private List<Repairable> repairables;
|
||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||
|
||||
public CustomArmorConfig() {
|
||||
super("ModConfigs", "armor.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomArmorConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomArmorConfig(mcMMO.p);
|
||||
instance = new CustomArmorConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public List<Integer> customBootIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
|
||||
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
|
||||
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
|
||||
|
||||
public CustomArmorConfig(mcMMO plugin) {
|
||||
super(plugin, "armor.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO armor.yml File...");
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadArmor("Boots", customBootIDs);
|
||||
@@ -52,6 +49,10 @@ public class CustomArmorConfig extends ModConfigLoader{
|
||||
|
||||
private void loadArmor(String armorType, List<Integer> idList) {
|
||||
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
|
||||
|
||||
if(armorSection == null)
|
||||
return;
|
||||
|
||||
Set<String> armorConfigSet = armorSection.getKeys(false);
|
||||
Iterator<String> iterator = armorConfigSet.iterator();
|
||||
|
||||
|
||||
@@ -8,48 +8,50 @@ import java.util.Set;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
|
||||
public class CustomBlocksConfig extends ModConfigLoader{
|
||||
public class CustomBlocksConfig extends ConfigLoader {
|
||||
private static CustomBlocksConfig instance;
|
||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
||||
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
||||
|
||||
public CustomBlocksConfig() {
|
||||
super("ModConfigs", "blocks.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomBlocksConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomBlocksConfig(mcMMO.p);
|
||||
instance = new CustomBlocksConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
|
||||
|
||||
public List<ItemStack> customOres = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
|
||||
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
|
||||
|
||||
public List<ItemStack> customItems = new ArrayList<ItemStack>();
|
||||
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
|
||||
|
||||
public CustomBlocksConfig(mcMMO plugin) {
|
||||
super(plugin, "blocks.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO blocks.yml File...");
|
||||
|
||||
loadBlocks("Excavation", customExcavationBlocks);
|
||||
loadBlocks("Herbalism", customHerbalismBlocks);
|
||||
loadBlocks("Mining", customMiningBlocks);
|
||||
loadBlocks("Woodcutting", customWoodcuttingBlocks);
|
||||
loadBlocks("Ability_Blocks", customAbilityBlocks);
|
||||
}
|
||||
|
||||
private void loadBlocks(String skillType, List<ItemStack> blockList) {
|
||||
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
|
||||
|
||||
if(skillSection == null)
|
||||
return;
|
||||
|
||||
Set<String> skillConfigSet = skillSection.getKeys(false);
|
||||
Iterator<String> iterator = skillConfigSet.iterator();
|
||||
|
||||
@@ -63,30 +65,37 @@ public class CustomBlocksConfig extends ModConfigLoader{
|
||||
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
|
||||
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
|
||||
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
|
||||
int dropAmount = config.getInt(skillType + "." + blockName + ".Drop_Item_Amount", 1);
|
||||
int minimumDropAmount = config.getInt(skillType + "." + blockName + ".Min_Drop_Item_Amount", 1);
|
||||
int maxiumDropAmount = config.getInt(skillType + "." + blockName + ".Max_Drop_Item_Amount", 1);
|
||||
|
||||
CustomBlock block;
|
||||
ItemStack itemDrop;
|
||||
ItemStack blockItem;
|
||||
|
||||
if (id == 0) {
|
||||
plugin.getLogger().warning("Missing ID. This block will be skipped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (skillType.equals("Ability_Blocks")) {
|
||||
blockItem = new ItemStack(id, 1, (short) 0, data);
|
||||
blockList.add(blockItem);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dropItem && dropID == 0) {
|
||||
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
|
||||
dropItem = false;
|
||||
}
|
||||
|
||||
CustomBlock block;
|
||||
ItemStack itemDrop;
|
||||
ItemStack blockItem;
|
||||
|
||||
if (dropItem) {
|
||||
itemDrop = new ItemStack(dropID, dropAmount, (short) 0, dropData);
|
||||
itemDrop = new ItemStack(dropID, 1, (short) 0, dropData);
|
||||
}
|
||||
else {
|
||||
itemDrop = new ItemStack(id, dropAmount, (short) 0, data);
|
||||
itemDrop = new ItemStack(id, 1, (short) 0, data);
|
||||
}
|
||||
|
||||
block = new CustomBlock(itemDrop, tier, xp, data, id);
|
||||
block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id);
|
||||
blockItem = new ItemStack(id, 1, (short) 0, data);
|
||||
|
||||
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
|
||||
|
||||
@@ -8,42 +8,39 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
|
||||
public class CustomToolsConfig extends ModConfigLoader {
|
||||
public class CustomToolsConfig extends ConfigLoader {
|
||||
private static CustomToolsConfig instance;
|
||||
|
||||
public static CustomToolsConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomToolsConfig(mcMMO.p);
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public List<Integer> customAxeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customBowIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customHoeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customShovelIDs = new ArrayList<Integer>();
|
||||
public List<Integer> customSwordIDs = new ArrayList<Integer>();
|
||||
|
||||
public List<Integer> customIDs = new ArrayList<Integer>();
|
||||
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
|
||||
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
|
||||
|
||||
private CustomToolsConfig(mcMMO plugin) {
|
||||
super(plugin, "tools.yml");
|
||||
private CustomToolsConfig() {
|
||||
super("ModConfigs", "tools.yml");
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
public static CustomToolsConfig getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new CustomToolsConfig();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadKeys() {
|
||||
plugin.getLogger().info("Loading mcMMO tools.yml File...");
|
||||
repairables = new ArrayList<Repairable>();
|
||||
|
||||
loadTool("Axes", customAxeIDs);
|
||||
@@ -56,6 +53,10 @@ public class CustomToolsConfig extends ModConfigLoader {
|
||||
|
||||
private void loadTool(String toolType, List<Integer> idList) {
|
||||
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
|
||||
|
||||
if(toolSection == null)
|
||||
return;
|
||||
|
||||
Set<String> toolConfigSet = toolSection.getKeys(false);
|
||||
Iterator<String> iterator = toolConfigSet.iterator();
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gmail.nossr50.config.mods;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
|
||||
public abstract class ModConfigLoader extends ConfigLoader{
|
||||
|
||||
public ModConfigLoader(mcMMO plugin, String fileName) {
|
||||
super(plugin, "ModConfigs" + File.separator + fileName);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.gmail.nossr50.config;
|
||||
package com.gmail.nossr50.config.repair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.ConfigLoader;
|
||||
import com.gmail.nossr50.skills.repair.RepairItemType;
|
||||
import com.gmail.nossr50.skills.repair.RepairMaterialType;
|
||||
import com.gmail.nossr50.skills.repair.Repairable;
|
||||
@@ -16,13 +15,8 @@ import com.gmail.nossr50.skills.repair.RepairableFactory;
|
||||
public class RepairConfig extends ConfigLoader {
|
||||
private List<Repairable> repairables;
|
||||
|
||||
public RepairConfig(mcMMO plugin, String fileName) {
|
||||
super(plugin, fileName);
|
||||
this.config = YamlConfiguration.loadConfiguration(this.configFile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
public RepairConfig(String fileName) {
|
||||
super(fileName);
|
||||
loadKeys();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.config;
|
||||
package com.gmail.nossr50.config.repair;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -22,22 +22,18 @@ public class RepairConfigManager {
|
||||
plugin.saveResource("repair.vanilla.yml", false);
|
||||
}
|
||||
|
||||
for (String location : dataFolder.list()) {
|
||||
if (!pattern.matcher(location).matches()) {
|
||||
for (String fileName : dataFolder.list()) {
|
||||
if (!pattern.matcher(fileName).matches()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Loading " + location + " repair config file...");
|
||||
|
||||
File file = new File(dataFolder, location);
|
||||
File file = new File(dataFolder, fileName);
|
||||
|
||||
if (file.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RepairConfig rConfig = new RepairConfig(plugin, location);
|
||||
rConfig.load();
|
||||
|
||||
RepairConfig rConfig = new RepairConfig(fileName);
|
||||
List<Repairable> rConfigRepairables = rConfig.getLoadedRepairables();
|
||||
|
||||
if (rConfigRepairables != null) {
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum HUDType {
|
||||
DISABLED,
|
||||
STANDARD,
|
||||
SMALL,
|
||||
RETRO;
|
||||
}
|
||||
@@ -1,417 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
import org.getspout.spoutapi.gui.GenericGradient;
|
||||
import org.getspout.spoutapi.gui.GenericTexture;
|
||||
import org.getspout.spoutapi.gui.RenderPriority;
|
||||
import org.getspout.spoutapi.gui.Widget;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class HUDmmo {
|
||||
private int center_x = 427 / 2;
|
||||
|
||||
private String playerName;
|
||||
private final mcMMO plugin;
|
||||
|
||||
private Widget xpbar = null;
|
||||
private GenericGradient xpfill = null;
|
||||
private GenericGradient xpbg = null;
|
||||
private GenericGradient xpicon_bg = null;
|
||||
private GenericGradient xpicon_border = null;
|
||||
private GenericTexture xpicon = null;
|
||||
|
||||
public HUDmmo(Player player, mcMMO plugin) {
|
||||
this.playerName = player.getName();
|
||||
this.plugin = plugin;
|
||||
initializeHUD(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the HUD.
|
||||
*
|
||||
* @param player Player whose HUD to initialize
|
||||
*/
|
||||
public void initializeHUD(Player player) {
|
||||
HUDType type = Users.getProfile(player).getHUDType();
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
switch (type) {
|
||||
case RETRO:
|
||||
initializeXpBarDisplayRetro(sPlayer);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
initializeXpBarDisplayStandard(sPlayer);
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
initializeXpBarDisplaySmall(sPlayer);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the XP bar.
|
||||
*
|
||||
* @param type Type of XP bar
|
||||
* @param player Player whose XP bar to update
|
||||
*/
|
||||
public void updateXpBarDisplay(HUDType type, Player player) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
switch (type) {
|
||||
case RETRO:
|
||||
updateXpBarRetro(player, PP);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
updateXpBarStandard(player, PP);
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
updateXpBarStandard(player, PP);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a player's HUD.
|
||||
*/
|
||||
public void resetHUD() {
|
||||
SpoutPlayer sPlayer = SpoutStuff.getSpoutPlayer(playerName);
|
||||
|
||||
if (sPlayer != null) {
|
||||
sPlayer.getMainScreen().removeWidgets(plugin);
|
||||
|
||||
//Reset the objects
|
||||
xpbar = null;
|
||||
xpfill = null;
|
||||
xpbg = null;
|
||||
xpicon = null;
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Retro XP bar.
|
||||
*
|
||||
* @param sPlayer Player to initialize XP bar for
|
||||
*/
|
||||
private void initializeXpBarDisplayRetro(SpoutPlayer sPlayer) {
|
||||
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
|
||||
Color green = new Color(0f, 1f, 0f, 1f);
|
||||
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
|
||||
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
|
||||
|
||||
xpicon = new GenericTexture();
|
||||
xpbar = new GenericGradient();
|
||||
xpfill = new GenericGradient();
|
||||
xpbg = new GenericGradient();
|
||||
|
||||
xpicon_bg = new GenericGradient();
|
||||
xpicon_border = new GenericGradient();
|
||||
|
||||
xpicon_bg.setBottomColor(darkbg);
|
||||
xpicon_bg.setTopColor(darkbg);
|
||||
xpicon_bg.setWidth(4);
|
||||
xpicon_bg.setHeight(4);
|
||||
xpicon_bg.setPriority(RenderPriority.High);
|
||||
xpicon_bg.setX(142);
|
||||
xpicon_bg.setY(10);
|
||||
xpicon_bg.setDirty(true);
|
||||
|
||||
xpicon_border.setBottomColor(border);
|
||||
xpicon_border.setTopColor(border);
|
||||
xpicon_border.setWidth(6);
|
||||
xpicon_border.setHeight(6);
|
||||
xpicon_border.setPriority(RenderPriority.Highest);
|
||||
xpicon_border.setX(141);
|
||||
xpicon_border.setY(9);
|
||||
xpicon_border.setDirty(true);
|
||||
|
||||
xpicon.setWidth(6);
|
||||
xpicon.setHeight(6);
|
||||
xpicon.setX(141);
|
||||
xpicon.setY(9);
|
||||
xpicon.setPriority(RenderPriority.Normal);
|
||||
xpicon.setDirty(true);
|
||||
xpicon.setUrl("Icon_r.png");
|
||||
|
||||
xpbar.setWidth(128);
|
||||
xpbar.setHeight(4);
|
||||
xpbar.setX(149);
|
||||
xpbar.setY(10);
|
||||
((GenericGradient) xpbar).setBottomColor(border);
|
||||
((GenericGradient) xpbar).setTopColor(border);
|
||||
xpbar.setPriority(RenderPriority.Highest);
|
||||
xpbar.setDirty(true);
|
||||
|
||||
xpfill.setWidth(0);
|
||||
xpfill.setHeight(2);
|
||||
xpfill.setX(150);
|
||||
xpfill.setY(11);
|
||||
xpfill.setBottomColor(green);
|
||||
xpfill.setTopColor(green);
|
||||
xpfill.setPriority(RenderPriority.Lowest);
|
||||
xpfill.setDirty(true);
|
||||
|
||||
xpbg.setWidth(126);
|
||||
xpbg.setHeight(2);
|
||||
xpbg.setX(150);
|
||||
xpbg.setY(11);
|
||||
xpbg.setBottomColor(background);
|
||||
xpbg.setTopColor(background);
|
||||
xpbg.setPriority(RenderPriority.Low);
|
||||
xpbg.setDirty(true);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpfill);
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpbg);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon_bg);
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon_border);
|
||||
}
|
||||
}
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Standard XP bar.
|
||||
*
|
||||
* @param sPlayer Player to initialize XP bar for
|
||||
*/
|
||||
public void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
|
||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
xpbar = new GenericTexture();
|
||||
|
||||
((GenericTexture) xpbar).setUrl("xpbar_inc000.png");
|
||||
|
||||
xpbar.setX(SpoutConfig.getInstance().getXPBarXPosition());
|
||||
xpbar.setY(SpoutConfig.getInstance().getXPBarYPosition());
|
||||
xpbar.setHeight(8);
|
||||
xpbar.setWidth(256);
|
||||
xpbar.setPriority(RenderPriority.Lowest);
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
xpicon = new GenericTexture();
|
||||
|
||||
xpicon.setUrl("Icon.png");
|
||||
xpicon.setHeight(16);
|
||||
xpicon.setWidth(32);
|
||||
xpicon.setX(SpoutConfig.getInstance().getXPIconXPosition());
|
||||
xpicon.setY(SpoutConfig.getInstance().getXPIconYPosition());
|
||||
xpicon.setPriority(RenderPriority.High);
|
||||
xpicon.setDirty(true);
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
|
||||
}
|
||||
}
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Small XP bar.
|
||||
*
|
||||
* @param sPlayer Player to initialize XP bar for
|
||||
*/
|
||||
private void initializeXpBarDisplaySmall(SpoutPlayer sPlayer) {
|
||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
xpbar = new GenericTexture();
|
||||
|
||||
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
|
||||
xpbar.setX(center_x - 64);
|
||||
xpbar.setY(SpoutConfig.getInstance().getXPBarYPosition());
|
||||
xpbar.setHeight(4);
|
||||
xpbar.setWidth(128);
|
||||
xpbar.setPriority(RenderPriority.Lowest);
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
xpicon = new GenericTexture();
|
||||
|
||||
xpicon.setUrl("Icon.png");
|
||||
xpicon.setHeight(8);
|
||||
xpicon.setWidth(16);
|
||||
xpicon.setX(center_x - (8 + 64));
|
||||
xpicon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
|
||||
xpicon.setPriority(RenderPriority.High);
|
||||
xpicon.setDirty(true);
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
|
||||
}
|
||||
}
|
||||
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Standard & Small styles.
|
||||
*
|
||||
* @param player Player whose XP bar to update
|
||||
* @param PP Profile of the given player
|
||||
*/
|
||||
private void updateXpBarStandard(Player player, PlayerProfile PP) {
|
||||
if (!SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkillType theType = getType(PP);
|
||||
|
||||
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
|
||||
return;
|
||||
}
|
||||
|
||||
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + ".png");
|
||||
xpicon.setDirty(true);
|
||||
|
||||
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
|
||||
xpbar.setDirty(true);
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Retro styles.
|
||||
*
|
||||
* @param player Player whose XP bar to update
|
||||
* @param PP Profile of the given player
|
||||
*/
|
||||
private void updateXpBarRetro(Player player, PlayerProfile PP) {
|
||||
if (!SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkillType theType = getType(PP);
|
||||
|
||||
if (theType == null) { //Can this ever actually BE null? (Yes, it's null when the player has just logged in. It's not null when they gain XP in anything)
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = getRetroColor(theType);
|
||||
|
||||
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + "_r.png");
|
||||
|
||||
xpfill.setBottomColor(color);
|
||||
xpfill.setTopColor(color);
|
||||
xpfill.setWidth(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.RETRO));
|
||||
xpfill.setDirty(true);
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
private static Color getRetroColor(SkillType type) {
|
||||
switch (type) {
|
||||
case ACROBATICS:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
|
||||
|
||||
case ARCHERY:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
|
||||
|
||||
case AXES:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
|
||||
|
||||
case EXCAVATION:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
|
||||
|
||||
case HERBALISM:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
|
||||
|
||||
case MINING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
|
||||
|
||||
case REPAIR:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
|
||||
|
||||
case SWORDS:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
|
||||
|
||||
case TAMING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
|
||||
|
||||
case UNARMED:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
|
||||
|
||||
case WOODCUTTING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
|
||||
|
||||
case FISHING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
|
||||
|
||||
default:
|
||||
return new Color(0.3f, 0.3f, 0.75f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getUrlBar(Integer number) {
|
||||
char[] num = number.toString().toCharArray();
|
||||
|
||||
switch (num.length) {
|
||||
case 1:
|
||||
return "xpbar_inc00" + number + ".png";
|
||||
|
||||
case 2:
|
||||
return "xpbar_inc0" + number + ".png";
|
||||
|
||||
default:
|
||||
return "xpbar_inc" + number + ".png";
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer getXpInc(int skillxp, int xptolevel, HUDType hud) {
|
||||
double percentage = (double) skillxp / xptolevel;
|
||||
double inc;
|
||||
|
||||
switch (hud) {
|
||||
case RETRO:
|
||||
inc = 0.0079365079365079;
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
inc = 0.0039370078740157;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int) (percentage / inc);
|
||||
}
|
||||
|
||||
private static SkillType getType(PlayerProfile PP) {
|
||||
if (PP.getXpBarLocked()) {
|
||||
return PP.getSkillLock();
|
||||
}
|
||||
else {
|
||||
return PP.getLastGained();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/main/java/com/gmail/nossr50/datatypes/HudType.java
Normal file
12
src/main/java/com/gmail/nossr50/datatypes/HudType.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
public enum HudType {
|
||||
DISABLED,
|
||||
STANDARD,
|
||||
SMALL,
|
||||
RETRO;
|
||||
|
||||
public HudType getNext() {
|
||||
return values()[(ordinal() + 1) % values().length];
|
||||
}
|
||||
}
|
||||
235
src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java
Normal file
235
src/main/java/com/gmail/nossr50/datatypes/McMMOPlayer.java
Normal file
@@ -0,0 +1,235 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McMMOPlayer {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private Party party;
|
||||
private Party invite;
|
||||
|
||||
public McMMOPlayer (Player player) {
|
||||
String playerName = player.getName();
|
||||
this.player = player;
|
||||
this.profile = new PlayerProfile(playerName, true);
|
||||
this.party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of this player.
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
*/
|
||||
private double calculatePartyXPModifier(SkillType skillType) {
|
||||
double bonusModifier = 0.0;
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (party.getLeader().equals(member.getName())) {
|
||||
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||
PlayerProfile partyLeader = Users.getProfile(member);
|
||||
int leaderSkill = partyLeader.getSkillLevel(skillType);
|
||||
int playerSkill = profile.getSkillLevel(skillType);
|
||||
|
||||
if (leaderSkill >= playerSkill) {
|
||||
int difference = leaderSkill - playerSkill;
|
||||
bonusModifier = (difference * 0.75) / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonusModifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, doesn't calculate for XP Rate
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverride(SkillType skillType, int xp) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, type, xp));
|
||||
profile.setSkillXPLevel(type, profile.getSkillXpLevel(type) + xp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this ignores skill modifiers.
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverrideBonus(SkillType skillType, int xp) {
|
||||
int modifiedXp = (int)Math.floor(xp * Config.getInstance().xpGainMultiplier);
|
||||
addXPOverride(skillType, modifiedXp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newvalue The amount of XP to add
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
double bonusModifier = 0;
|
||||
|
||||
if (inParty()) {
|
||||
bonusModifier = calculatePartyXPModifier(skillType);
|
||||
}
|
||||
|
||||
int xp = (int)Math.floor((newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier);
|
||||
|
||||
if (bonusModifier > 0) {
|
||||
if (bonusModifier >= 2) {
|
||||
bonusModifier = 2;
|
||||
}
|
||||
|
||||
double trueBonus = bonusModifier * xp;
|
||||
xp += trueBonus;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
|
||||
if (tool != null) {
|
||||
xp = (int) (xp * tool.getXpMultiplier());
|
||||
}
|
||||
}
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
xp = xp * 4;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
xp = xp * 3;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
xp = (int) (xp * 2.5);
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
xp = xp * 2;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
xp = (int) (xp * 1.5);
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
profile.setSkillXPLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
|
||||
|
||||
SpoutHud spoutHud = profile.getSpoutHud();
|
||||
|
||||
if (spoutHud != null) {
|
||||
spoutHud.setLastGained(skillType);
|
||||
}
|
||||
}
|
||||
|
||||
// Players & Profiles
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public PlayerProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
// Party Stuff
|
||||
|
||||
public void setInvite(Party invite) {
|
||||
this.invite = invite;
|
||||
}
|
||||
|
||||
public Party getInvite() {
|
||||
return invite;
|
||||
}
|
||||
|
||||
public boolean hasPartyInvite() {
|
||||
if (invite != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setParty(Party party) {
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
public Party getParty() {
|
||||
return party;
|
||||
}
|
||||
|
||||
public boolean inParty() {
|
||||
if (party != null) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeParty() {
|
||||
party = null;
|
||||
}
|
||||
|
||||
public void removeInvite() {
|
||||
invite = null;
|
||||
}
|
||||
}
|
||||
@@ -7,28 +7,21 @@ import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class PlayerProfile {
|
||||
|
||||
private String playerName;
|
||||
|
||||
/* HUD */
|
||||
private HUDType hud;
|
||||
private int xpbarinc;
|
||||
private SkillType lastgained;
|
||||
private SkillType skillLock;
|
||||
private SpoutHud spoutHud;
|
||||
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
|
||||
|
||||
/* Party Stuff */
|
||||
private Party party;
|
||||
@@ -36,7 +29,7 @@ public class PlayerProfile {
|
||||
|
||||
/* Toggles */
|
||||
private boolean loaded;
|
||||
private boolean partyhud = true, spoutcraft, xpbarlocked;
|
||||
|
||||
private boolean placedAnvil;
|
||||
private boolean partyChatMode, adminChatMode;
|
||||
private boolean godMode;
|
||||
@@ -45,29 +38,24 @@ public class PlayerProfile {
|
||||
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
|
||||
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
|
||||
pickaxePreparationMode, axePreparationMode;
|
||||
private boolean abilityuse = true;
|
||||
private boolean abilityUse = true;
|
||||
|
||||
/* Timestamps */
|
||||
private int recentlyHurt;
|
||||
private long recentlyHurt;
|
||||
private int respawnATS;
|
||||
|
||||
/* mySQL STUFF */
|
||||
private int userid;
|
||||
private int userId;
|
||||
|
||||
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
||||
private HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
|
||||
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
|
||||
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
|
||||
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
|
||||
|
||||
private Player player;
|
||||
private String playerName;
|
||||
private final static String location = mcMMO.usersFile;
|
||||
private final static String location = mcMMO.getUsersFile();
|
||||
|
||||
public PlayerProfile(Player player, String playerName, boolean addNew) {
|
||||
hud = SpoutConfig.getInstance().defaulthud;
|
||||
this.player = player;
|
||||
public PlayerProfile(String playerName, boolean addNew) {
|
||||
this.playerName = playerName;
|
||||
|
||||
party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
@@ -93,101 +81,113 @@ public class PlayerProfile {
|
||||
}
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
this.playerName = player.getName();
|
||||
}
|
||||
|
||||
public boolean loadMySQL() {
|
||||
userid = mcMMO.database.getInt("SELECT id FROM " + Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
if (userid == 0) {
|
||||
userId = database.getInt("SELECT id FROM " + tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
|
||||
if (userId == 0) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM " + Config.getInstance().getMySQLTablePrefix() + "huds WHERE user_id = " + userid);
|
||||
HashMap<Integer, ArrayList<String>> huds = database.read("SELECT hudtype FROM " + tablePrefix + "huds WHERE user_id = " + userId);
|
||||
|
||||
if (huds.get(1) == null) {
|
||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "huds (user_id) VALUES (" + userid + ")");
|
||||
database.write("INSERT INTO " + tablePrefix + "huds (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
else {
|
||||
if (huds.get(1).get(0) != null) {
|
||||
for (HUDType x : HUDType.values()) {
|
||||
if (x.toString().equals(huds.get(1).get(0))) {
|
||||
hud = x;
|
||||
}
|
||||
for (HudType type : HudType.values()) {
|
||||
if (type.toString().equals(huds.get(1).get(0))) {
|
||||
hudType = type;
|
||||
}
|
||||
}
|
||||
else {
|
||||
hud = SpoutConfig.getInstance().defaulthud;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* I'm still learning MySQL, this is a fix for adding a new table
|
||||
* its not pretty but it works
|
||||
*/
|
||||
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + Config.getInstance().getMySQLTablePrefix() + "cooldowns WHERE user_id = " + userid);
|
||||
HashMap<Integer, ArrayList<String>> cooldowns = database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + tablePrefix + "cooldowns WHERE user_id = " + userId);
|
||||
ArrayList<String> cooldownValues = cooldowns.get(1);
|
||||
|
||||
if(cooldowns.get(1) == null) {
|
||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
|
||||
if (cooldownValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the cooldown table. Their cooldowns will be reset.");
|
||||
}
|
||||
else {
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldowns.get(1).get(0)));
|
||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldowns.get(1).get(1)));
|
||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldowns.get(1).get(2)));
|
||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldowns.get(1).get(3)));
|
||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldowns.get(1).get(4)));
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldowns.get(1).get(5)));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldowns.get(1).get(6)));
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldowns.get(1).get(7)));
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldownValues.get(0)));
|
||||
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldownValues.get(1)));
|
||||
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldownValues.get(2)));
|
||||
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3)));
|
||||
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4)));
|
||||
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5)));
|
||||
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldownValues.get(6)));
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> stats = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "skills WHERE user_id = " + userId);
|
||||
ArrayList<String> statValues = stats.get(1);
|
||||
|
||||
if (statValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the skills table. Their stats will be reset.");
|
||||
}
|
||||
else {
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(statValues.get(0)));
|
||||
skills.put(SkillType.MINING, Integer.valueOf(statValues.get(1)));
|
||||
skills.put(SkillType.REPAIR, Integer.valueOf(statValues.get(2)));
|
||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(statValues.get(3)));
|
||||
skills.put(SkillType.UNARMED, Integer.valueOf(statValues.get(4)));
|
||||
skills.put(SkillType.HERBALISM, Integer.valueOf(statValues.get(5)));
|
||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(statValues.get(6)));
|
||||
skills.put(SkillType.ARCHERY, Integer.valueOf(statValues.get(7)));
|
||||
skills.put(SkillType.SWORDS, Integer.valueOf(statValues.get(8)));
|
||||
skills.put(SkillType.AXES, Integer.valueOf(statValues.get(9)));
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(statValues.get(10)));
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(statValues.get(11)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> experience = database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM " + tablePrefix + "experience WHERE user_id = " + userId);
|
||||
ArrayList<String> experienceValues = experience.get(1);
|
||||
|
||||
if (experienceValues == null) {
|
||||
database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
mcMMO.p.getLogger().warning(playerName + "does not exist in the experience table. Their experience will be reset.");
|
||||
}
|
||||
else {
|
||||
skillsXp.put(SkillType.TAMING, Integer.valueOf(experienceValues.get(0)));
|
||||
skillsXp.put(SkillType.MINING, Integer.valueOf(experienceValues.get(1)));
|
||||
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experienceValues.get(2)));
|
||||
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(experienceValues.get(3)));
|
||||
skillsXp.put(SkillType.UNARMED, Integer.valueOf(experienceValues.get(4)));
|
||||
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(experienceValues.get(5)));
|
||||
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(experienceValues.get(6)));
|
||||
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(experienceValues.get(7)));
|
||||
skillsXp.put(SkillType.SWORDS, Integer.valueOf(experienceValues.get(8)));
|
||||
skillsXp.put(SkillType.AXES, Integer.valueOf(experienceValues.get(9)));
|
||||
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experienceValues.get(10)));
|
||||
skillsXp.put(SkillType.FISHING, Integer.valueOf(experienceValues.get(11)));
|
||||
}
|
||||
|
||||
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + userid);
|
||||
skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
|
||||
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
|
||||
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
|
||||
skills.put(SkillType.WOODCUTTING, Integer.valueOf(stats.get(1).get(3)));
|
||||
skills.put(SkillType.UNARMED, Integer.valueOf(stats.get(1).get(4)));
|
||||
skills.put(SkillType.HERBALISM, Integer.valueOf(stats.get(1).get(5)));
|
||||
skills.put(SkillType.EXCAVATION, Integer.valueOf(stats.get(1).get(6)));
|
||||
skills.put(SkillType.ARCHERY, Integer.valueOf(stats.get(1).get(7)));
|
||||
skills.put(SkillType.SWORDS, Integer.valueOf(stats.get(1).get(8)));
|
||||
skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
|
||||
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
|
||||
skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
|
||||
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + userid);
|
||||
skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0)));
|
||||
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
|
||||
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
|
||||
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(experience.get(1).get(3)));
|
||||
skillsXp.put(SkillType.UNARMED, Integer.valueOf(experience.get(1).get(4)));
|
||||
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(experience.get(1).get(5)));
|
||||
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(experience.get(1).get(6)));
|
||||
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(experience.get(1).get(7)));
|
||||
skillsXp.put(SkillType.SWORDS, Integer.valueOf(experience.get(1).get(8)));
|
||||
skillsXp.put(SkillType.AXES, Integer.valueOf(experience.get(1).get(9)));
|
||||
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experience.get(1).get(10)));
|
||||
skillsXp.put(SkillType.FISHING, Integer.valueOf(experience.get(1).get(11)));
|
||||
loaded = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void addMySQLPlayer() {
|
||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 + ")");
|
||||
userid = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
|
||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
|
||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "skills (user_id) VALUES (" + userid + ")");
|
||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "experience (user_id) VALUES (" + userid + ")");
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
database.write("INSERT INTO " + tablePrefix + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 + ")");
|
||||
userId = database.getInt("SELECT id FROM "+tablePrefix + "users WHERE user = '" + playerName + "'");
|
||||
database.write("INSERT INTO " + tablePrefix + "cooldowns (user_id) VALUES (" + userId + ")");
|
||||
database.write("INSERT INTO " + tablePrefix + "skills (user_id) VALUES (" + userId + ")");
|
||||
database.write("INSERT INTO " + tablePrefix + "experience (user_id) VALUES (" + userId + ")");
|
||||
}
|
||||
|
||||
public boolean load() {
|
||||
@@ -264,9 +264,9 @@ public class PlayerProfile {
|
||||
if (character.length > 32)
|
||||
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
|
||||
if (character.length > 33) {
|
||||
for (HUDType x : HUDType.values()) {
|
||||
if (x.toString().equalsIgnoreCase(character[33])) {
|
||||
hud = x;
|
||||
for (HudType type : HudType.values()) {
|
||||
if (type.toString().equalsIgnoreCase(character[33])) {
|
||||
hudType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -285,7 +285,7 @@ public class PlayerProfile {
|
||||
|
||||
in.close();
|
||||
} catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -295,9 +295,12 @@ public class PlayerProfile {
|
||||
|
||||
// if we are using mysql save to database
|
||||
if (Config.getInstance().getUseMySQL()) {
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "huds SET hudtype = '" + hud.toString() + "' WHERE user_id = " + userid);
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + userid);
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "cooldowns SET "
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
|
||||
database.write("UPDATE " + tablePrefix + "huds SET hudtype = '" + hudType.toString() + "' WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "cooldowns SET "
|
||||
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
||||
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
||||
+ ", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
|
||||
@@ -306,8 +309,8 @@ public class PlayerProfile {
|
||||
+ ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
|
||||
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
||||
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
||||
+ " WHERE user_id = " + userid);
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "skills SET "
|
||||
+ " WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "skills SET "
|
||||
+ " taming = " + skills.get(SkillType.TAMING)
|
||||
+ ", mining = " + skills.get(SkillType.MINING)
|
||||
+ ", repair = " + skills.get(SkillType.REPAIR)
|
||||
@@ -320,8 +323,8 @@ public class PlayerProfile {
|
||||
+ ", axes = " + skills.get(SkillType.AXES)
|
||||
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
|
||||
+ ", fishing = " + skills.get(SkillType.FISHING)
|
||||
+ " WHERE user_id = " + userid);
|
||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "experience SET "
|
||||
+ " WHERE user_id = " + userId);
|
||||
database.write("UPDATE " + tablePrefix + "experience SET "
|
||||
+ " taming = " + skillsXp.get(SkillType.TAMING)
|
||||
+ ", mining = " + skillsXp.get(SkillType.MINING)
|
||||
+ ", repair = " + skillsXp.get(SkillType.REPAIR)
|
||||
@@ -334,7 +337,7 @@ public class PlayerProfile {
|
||||
+ ", axes = " + skillsXp.get(SkillType.AXES)
|
||||
+ ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS)
|
||||
+ ", fishing = " + skillsXp.get(SkillType.FISHING)
|
||||
+ " WHERE user_id = " + userid);
|
||||
+ " WHERE user_id = " + userId);
|
||||
}
|
||||
else {
|
||||
// otherwise save to flatfile
|
||||
@@ -349,7 +352,7 @@ public class PlayerProfile {
|
||||
while ((line = in.readLine()) != null) {
|
||||
//Read the line in and copy it to the output it's not the player
|
||||
//we want to edit
|
||||
if (!line.split(":")[0].equalsIgnoreCase(playerName)) {
|
||||
if (!line.split(":")[0].equals(playerName)) {
|
||||
writer.append(line).append("\r\n");
|
||||
}
|
||||
else {
|
||||
@@ -389,7 +392,7 @@ public class PlayerProfile {
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER)) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER)) + ":");
|
||||
writer.append(hud.toString() + ":");
|
||||
writer.append(hudType.toString() + ":");
|
||||
writer.append(skills.get(SkillType.FISHING) + ":");
|
||||
writer.append(skillsXp.get(SkillType.FISHING) + ":");
|
||||
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING)) + ":");
|
||||
@@ -404,7 +407,7 @@ public class PlayerProfile {
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -449,7 +452,7 @@ public class PlayerProfile {
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(0 + ":"); //DATS
|
||||
out.append(SpoutConfig.getInstance().defaulthud.toString() + ":");//HUD
|
||||
out.append(SpoutConfig.getInstance().defaultHudType.toString() + ":");//HUD
|
||||
out.append(0 + ":"); //Fishing
|
||||
out.append(0 +":"); //FishingXP
|
||||
out.append(0 + ":"); //Blast Mining
|
||||
@@ -459,7 +462,7 @@ public class PlayerProfile {
|
||||
out.newLine();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
mcMMO.p.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,7 +471,7 @@ public class PlayerProfile {
|
||||
*/
|
||||
|
||||
public int getMySQLuserId() {
|
||||
return userid;
|
||||
return userId;
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
@@ -503,61 +506,20 @@ public class PlayerProfile {
|
||||
* HUD Stuff
|
||||
*/
|
||||
|
||||
public void togglePartyHUD() {
|
||||
partyhud = !partyhud;
|
||||
public HudType getHudType() {
|
||||
return hudType;
|
||||
}
|
||||
|
||||
public boolean getPartyHUD() {
|
||||
return partyhud;
|
||||
public SpoutHud getSpoutHud() {
|
||||
return spoutHud;
|
||||
}
|
||||
|
||||
public void toggleSpoutEnabled() {
|
||||
spoutcraft = !spoutcraft;
|
||||
public void setSpoutHud(SpoutHud spoutHud) {
|
||||
this.spoutHud = spoutHud;
|
||||
}
|
||||
|
||||
public HUDType getHUDType() {
|
||||
return hud;
|
||||
}
|
||||
|
||||
public void setHUDType(HUDType type) {
|
||||
hud = type;
|
||||
save();
|
||||
}
|
||||
|
||||
public void setXpBarLocked(boolean locked) {
|
||||
xpbarlocked = locked;
|
||||
}
|
||||
|
||||
public boolean getXpBarLocked() {
|
||||
return xpbarlocked;
|
||||
}
|
||||
|
||||
public void toggleXpBarLocked() {
|
||||
xpbarlocked = !xpbarlocked;
|
||||
}
|
||||
|
||||
public int getXpBarInc() {
|
||||
return xpbarinc;
|
||||
}
|
||||
|
||||
public void setXpBarInc(int newvalue) {
|
||||
xpbarinc = newvalue;
|
||||
}
|
||||
|
||||
public void setSkillLock(SkillType newvalue) {
|
||||
skillLock = newvalue;
|
||||
}
|
||||
|
||||
public SkillType getSkillLock() {
|
||||
return skillLock;
|
||||
}
|
||||
|
||||
public void setLastGained(SkillType newvalue) {
|
||||
lastgained = newvalue;
|
||||
}
|
||||
|
||||
public SkillType getLastGained() {
|
||||
return lastgained;
|
||||
public void setHudType(HudType hudType) {
|
||||
this.hudType = hudType;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -853,22 +815,22 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public boolean getAbilityUse() {
|
||||
return abilityuse;
|
||||
return abilityUse;
|
||||
}
|
||||
|
||||
public void toggleAbilityUse() {
|
||||
abilityuse = !abilityuse;
|
||||
abilityUse = !abilityUse;
|
||||
}
|
||||
|
||||
/*
|
||||
* Recently Hurt
|
||||
*/
|
||||
|
||||
public int getRecentlyHurt() {
|
||||
public long getRecentlyHurt() {
|
||||
return recentlyHurt;
|
||||
}
|
||||
|
||||
public void setRecentlyHurt(int value) {
|
||||
public void setRecentlyHurt(long value) {
|
||||
recentlyHurt = value;
|
||||
}
|
||||
|
||||
@@ -934,96 +896,122 @@ public class PlayerProfile {
|
||||
return skillsXp.get(skillType);
|
||||
}
|
||||
|
||||
public void setSkillXPLevel(SkillType skillType, int newValue) {
|
||||
skillsXp.put(skillType, newValue);
|
||||
}
|
||||
|
||||
public void skillUp(SkillType skillType, int newValue) {
|
||||
skills.put(skillType, skills.get(skillType) + newValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, doesn't calculate for XP Rate
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverride(SkillType skillType, int newValue) {
|
||||
if (skillType.equals(SkillType.ALL)) {
|
||||
for (SkillType x : SkillType.values()) {
|
||||
if (x.equals(SkillType.ALL)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
||||
skillsXp.put(x, skillsXp.get(x) + newValue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
|
||||
lastgained = skillType;
|
||||
}
|
||||
|
||||
public void resetSkill(SkillType skillType)
|
||||
{
|
||||
//do a single skilltype
|
||||
if (skillType != SkillType.ALL)
|
||||
skills.put(skillType, 0);
|
||||
else //do them all
|
||||
{
|
||||
for(SkillType skill : SkillType.values()) //iterate over all items in the enumeration
|
||||
{
|
||||
if (skill != SkillType.ALL) // skip the "all" value
|
||||
skills.put(skill, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this ignores skill modifiers.
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newValue The amount of XP to add
|
||||
*/
|
||||
public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
||||
int xp = newValue * Config.getInstance().xpGainMultiplier;
|
||||
addXPOverride(skillType, xp);
|
||||
}
|
||||
// /**
|
||||
// * Adds XP to the player, doesn't calculate for XP Rate
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newValue The amount of XP to add
|
||||
// */
|
||||
// public void addXPOverride(SkillType skillType, int newValue) {
|
||||
// if (skillType.equals(SkillType.ALL)) {
|
||||
// for (SkillType x : SkillType.values()) {
|
||||
// if (x.equals(SkillType.ALL)) {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
||||
// skillsXp.put(x, skillsXp.get(x) + newValue);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
||||
// skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
|
||||
// spoutHud.setLastGained(skillType);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
*
|
||||
* @param skillType The skill to add XP to
|
||||
* @param newvalue The amount of XP to add
|
||||
*/
|
||||
public void addXP(SkillType skillType, int newValue) {
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
return;
|
||||
}
|
||||
// /**
|
||||
// * Adds XP to the player, this ignores skill modifiers.
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newValue The amount of XP to add
|
||||
// */
|
||||
// public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
||||
// int xp = newValue * Config.getInstance().xpGainMultiplier;
|
||||
// addXPOverride(skillType, xp);
|
||||
// }
|
||||
|
||||
double bonusModifier = 0;
|
||||
|
||||
if (inParty()) {
|
||||
bonusModifier = partyModifier(skillType);
|
||||
}
|
||||
|
||||
int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
||||
|
||||
if (bonusModifier > 0) {
|
||||
if (bonusModifier >= 2) {
|
||||
bonusModifier = 2;
|
||||
}
|
||||
|
||||
double trueBonus = bonusModifier * xp;
|
||||
xp += trueBonus;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
|
||||
if (tool != null) {
|
||||
xp = (int) (xp * tool.getXpMultiplier());
|
||||
}
|
||||
}
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
xp = xp * 4;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
xp = xp * 3;
|
||||
}
|
||||
else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
xp = xp * 2;
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||
lastgained = skillType;
|
||||
}
|
||||
// /**
|
||||
// * Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
||||
// *
|
||||
// * @param skillType The skill to add XP to
|
||||
// * @param newvalue The amount of XP to add
|
||||
// */
|
||||
// public void addXP(SkillType skillType, int newValue) {
|
||||
// if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// double bonusModifier = 0;
|
||||
//
|
||||
// if (inParty()) {
|
||||
// bonusModifier = partyModifier(skillType);
|
||||
// }
|
||||
//
|
||||
// int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
||||
//
|
||||
// if (bonusModifier > 0) {
|
||||
// if (bonusModifier >= 2) {
|
||||
// bonusModifier = 2;
|
||||
// }
|
||||
//
|
||||
// double trueBonus = bonusModifier * xp;
|
||||
// xp += trueBonus;
|
||||
// }
|
||||
//
|
||||
// if (Config.getInstance().getToolModsEnabled()) {
|
||||
// ItemStack item = player.getItemInHand();
|
||||
// CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||
//
|
||||
// if (tool != null) {
|
||||
// xp = (int) (xp * tool.getXpMultiplier());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //TODO: Can we make this so we do perks by doing "mcmmo.perks.xp.[multiplier]" ?
|
||||
// if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||
// xp = xp * 4;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||
// xp = xp * 3;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||
// xp = (int) (xp * 2.5);
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||
// xp = xp * 2;
|
||||
// }
|
||||
// else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||
// xp = (int) (xp * 1.5);
|
||||
// }
|
||||
//
|
||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
// skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||
// spoutHud.setLastGained(skillType);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Remove XP from a skill.
|
||||
@@ -1090,8 +1078,6 @@ public class PlayerProfile {
|
||||
skills.put(skillType, skills.get(skillType) + levels);
|
||||
skillsXp.put(skillType, 0);
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1101,52 +1087,52 @@ public class PlayerProfile {
|
||||
* @return the XP remaining until next level
|
||||
*/
|
||||
public int getXpToLevel(SkillType skillType) {
|
||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve()); //Do we REALLY need to cast to int here?
|
||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the power level of a player.
|
||||
*
|
||||
* @return the power level of the player
|
||||
*/
|
||||
public int getPowerLevel() {
|
||||
int powerLevel = 0;
|
||||
// /**
|
||||
// * Gets the power level of a player.
|
||||
// *
|
||||
// * @return the power level of the player
|
||||
// */
|
||||
// public int getPowerLevel() {
|
||||
// int powerLevel = 0;
|
||||
//
|
||||
// for (SkillType type : SkillType.values()) {
|
||||
// if (type.getPermissions(player)) {
|
||||
// powerLevel += getSkillLevel(type);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return powerLevel;
|
||||
// }
|
||||
|
||||
for (SkillType type : SkillType.values()) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
|
||||
return powerLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the party XP modifier.
|
||||
*
|
||||
* @param skillType Type of skill to check
|
||||
* @return the party bonus multiplier
|
||||
*/
|
||||
private double partyModifier(SkillType skillType) {
|
||||
double bonusModifier = 0.0;
|
||||
|
||||
for (Player member : party.getOnlineMembers()) {
|
||||
if (party.getLeader().equals(member.getName())) {
|
||||
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||
PlayerProfile PartyLeader = Users.getProfile(member);
|
||||
int leaderSkill = PartyLeader.getSkillLevel(skillType);
|
||||
int playerSkill = getSkillLevel(skillType);
|
||||
|
||||
if (leaderSkill >= playerSkill) {
|
||||
int difference = leaderSkill - playerSkill;
|
||||
bonusModifier = (difference * 0.75) / 100.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bonusModifier;
|
||||
}
|
||||
// /**
|
||||
// * Calculate the party XP modifier.
|
||||
// *
|
||||
// * @param skillType Type of skill to check
|
||||
// * @return the party bonus multiplier
|
||||
// */
|
||||
// private double partyModifier(SkillType skillType) {
|
||||
// double bonusModifier = 0.0;
|
||||
//
|
||||
// for (Player member : party.getOnlineMembers()) {
|
||||
// if (party.getLeader().equals(member.getName())) {
|
||||
// if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||
// PlayerProfile PartyLeader = Users.getProfile(member);
|
||||
// int leaderSkill = PartyLeader.getSkillLevel(skillType);
|
||||
// int playerSkill = getSkillLevel(skillType);
|
||||
//
|
||||
// if (leaderSkill >= playerSkill) {
|
||||
// int difference = leaderSkill - playerSkill;
|
||||
// bonusModifier = (difference * 0.75) / 100.0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return bonusModifier;
|
||||
// }
|
||||
|
||||
/*
|
||||
* Party Stuff
|
||||
|
||||
102
src/main/java/com/gmail/nossr50/datatypes/SpoutHud.java
Normal file
102
src/main/java/com/gmail/nossr50/datatypes/SpoutHud.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.popups.Menu;
|
||||
import com.gmail.nossr50.datatypes.popups.XpBar;
|
||||
|
||||
public class SpoutHud {
|
||||
private Player player;
|
||||
private PlayerProfile profile;
|
||||
|
||||
private SkillType lastGained;
|
||||
private SkillType skillLock;
|
||||
private boolean xpBarLocked;
|
||||
|
||||
private Menu menu;
|
||||
private XpBar xpBar;
|
||||
|
||||
public SpoutHud(McMMOPlayer mcMMOPlayer) {
|
||||
this.player = mcMMOPlayer.getPlayer();
|
||||
this.profile = mcMMOPlayer.getProfile();
|
||||
|
||||
initializeXpBar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the HUD.
|
||||
*/
|
||||
public void initializeXpBar() {
|
||||
if (SpoutConfig.getInstance().getXPBarEnabled()) {
|
||||
if (xpBar != null) {
|
||||
xpBar.removeWidgets();
|
||||
}
|
||||
|
||||
xpBar = new XpBar(SpoutManager.getPlayer(player), profile.getHudType());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the XP bar.
|
||||
*/
|
||||
public void updateXpBar() {
|
||||
SkillType skillType = xpBarLocked ? skillLock : lastGained;
|
||||
|
||||
if (skillType == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
xpBar.update(skillType, profile);
|
||||
}
|
||||
|
||||
public boolean isMenuOpened() {
|
||||
return (menu != null) ? true : false;
|
||||
}
|
||||
|
||||
public void openMenu() {
|
||||
menu = new Menu(SpoutManager.getPlayer(player), profile);
|
||||
}
|
||||
|
||||
public void onMenuClose() {
|
||||
menu = null;
|
||||
}
|
||||
|
||||
public void removeWidgets() {
|
||||
if (menu != null) {
|
||||
menu.close();
|
||||
}
|
||||
|
||||
SpoutManager.getPlayer(player).getMainScreen().removeWidgets(mcMMO.p);
|
||||
}
|
||||
|
||||
public SkillType getLastGained() {
|
||||
return lastGained;
|
||||
}
|
||||
|
||||
public void setLastGained(SkillType type) {
|
||||
this.lastGained = type;
|
||||
}
|
||||
|
||||
public boolean getXpBarLocked() {
|
||||
return xpBarLocked;
|
||||
}
|
||||
|
||||
public void setXpBarLocked(boolean locked) {
|
||||
this.xpBarLocked = locked;
|
||||
}
|
||||
|
||||
public void toggleXpBarLocked() {
|
||||
xpBarLocked = !xpBarLocked;
|
||||
}
|
||||
|
||||
public SkillType getSkillLock() {
|
||||
return skillLock;
|
||||
}
|
||||
|
||||
public void setSkillLock(SkillType type) {
|
||||
this.skillLock = type;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class ButtonEscape extends GenericButton {
|
||||
|
||||
public ButtonEscape() {
|
||||
this.setText("EXIT");
|
||||
this.setWidth(60);
|
||||
this.setHeight(20);
|
||||
this.setDirty(true);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
public class ButtonHUDStyle extends ButtonToggle {
|
||||
|
||||
public ButtonHUDStyle(PlayerProfile PP) {
|
||||
super("HUD Type: ", PP.getHUDType().toString(), "Change your HUD style!"); //TODO: Needs more locale
|
||||
}
|
||||
|
||||
public void updateText(PlayerProfile PP) {
|
||||
super.updateText("HUD Type: ", PP.getHUDType().toString()); //TODO: Needs more locale
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
|
||||
public class ButtonPartyToggle extends ButtonToggle {
|
||||
|
||||
public ButtonPartyToggle(PlayerProfile PP) {
|
||||
super("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString(), "Toggle the Party HUD!"); //TODO: Needs more locale
|
||||
}
|
||||
|
||||
public void updateText(PlayerProfile PP) {
|
||||
super.updateText("Party HUD: ", ((Boolean) PP.getPartyHUD()).toString()); //TODO: Needs more locale
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class ButtonToggle extends GenericButton{
|
||||
|
||||
public ButtonToggle(String text1, String text2, String tooltip) {
|
||||
this.setText(text1 + text2);
|
||||
this.setTooltip(tooltip);
|
||||
this.setWidth(120);
|
||||
this.setHeight(20);
|
||||
this.setDirty(true);
|
||||
}
|
||||
|
||||
public void updateText(String text1, String text2) {
|
||||
this.setText(text1 + text2);
|
||||
this.setDirty(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.gmail.nossr50.datatypes.buttons;
|
||||
|
||||
import org.getspout.spoutapi.gui.GenericButton;
|
||||
|
||||
public class McmmoButton extends GenericButton {
|
||||
private Slot slot;
|
||||
|
||||
public McmmoButton(String text, String toolTip) {
|
||||
this.setText(text);
|
||||
this.setTooltip(toolTip);
|
||||
}
|
||||
|
||||
public void connect(Slot slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public void activate() {
|
||||
slot.activate();
|
||||
}
|
||||
|
||||
public interface Slot {
|
||||
public void activate();
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,17 @@ public class CustomBlock {
|
||||
private int xpGain;
|
||||
private int tier;
|
||||
private ItemStack itemDrop;
|
||||
private int minimumDropAmount;
|
||||
private int maximumDropAmount;
|
||||
|
||||
public CustomBlock(ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
|
||||
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
|
||||
this.itemID = itemID;
|
||||
this.dataValue = dataValue;
|
||||
this.xpGain = xpGain;
|
||||
this.tier = tier;
|
||||
this.itemDrop = itemDrop;
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
@@ -56,4 +60,20 @@ public class CustomBlock {
|
||||
public void setItemDrop(ItemStack itemDrop) {
|
||||
this.itemDrop = itemDrop;
|
||||
}
|
||||
|
||||
public int getMinimumDropAmount() {
|
||||
return minimumDropAmount;
|
||||
}
|
||||
|
||||
public void setMinimumDropAmount(int minimumDropAmount) {
|
||||
this.minimumDropAmount = minimumDropAmount;
|
||||
}
|
||||
|
||||
public int getMaximumDropAmount() {
|
||||
return maximumDropAmount;
|
||||
}
|
||||
|
||||
public void setMaximumDropAmount(int maximumDropAmount) {
|
||||
this.maximumDropAmount = maximumDropAmount;
|
||||
}
|
||||
}
|
||||
|
||||
79
src/main/java/com/gmail/nossr50/datatypes/popups/Menu.java
Normal file
79
src/main/java/com/gmail/nossr50/datatypes/popups/Menu.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package com.gmail.nossr50.datatypes.popups;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
import org.getspout.spoutapi.gui.InGameHUD;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.datatypes.buttons.McmmoButton;
|
||||
import com.gmail.nossr50.datatypes.buttons.McmmoButton.Slot;
|
||||
|
||||
public class Menu extends GenericPopup {
|
||||
private McmmoButton hudButton;
|
||||
private McmmoButton escapeButton;
|
||||
private GenericLabel titleLabel = new GenericLabel();
|
||||
private GenericLabel escapeLabel = new GenericLabel();
|
||||
private static int centerX = 427 / 2;
|
||||
private static int centerY = 240 / 2;
|
||||
|
||||
public Menu(final SpoutPlayer spoutPlayer, final PlayerProfile playerProfile) {
|
||||
//240, 427 are the bottom right
|
||||
titleLabel.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
|
||||
titleLabel.setWidth(100);
|
||||
titleLabel.setHeight(100);
|
||||
titleLabel.setX(centerX - 35);
|
||||
titleLabel.setY((centerY / 2) - 20);
|
||||
|
||||
escapeLabel.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
|
||||
escapeLabel.setWidth(100);
|
||||
escapeLabel.setHeight(100);
|
||||
escapeLabel.setX(titleLabel.getX() - 15);
|
||||
escapeLabel.setY(titleLabel.getY() + 10);
|
||||
|
||||
hudButton = new McmmoButton("HUD Type: " + playerProfile.getHudType().toString(), "Change your HUD style!");
|
||||
hudButton.setWidth(120);
|
||||
hudButton.setHeight(20);
|
||||
hudButton.setX(centerX - (hudButton.getWidth() / 2));
|
||||
hudButton.setY(centerY / 2);
|
||||
hudButton.connect(new Slot() {
|
||||
@Override
|
||||
public void activate() {
|
||||
HudType nextHudType = playerProfile.getHudType().getNext();
|
||||
SpoutHud spoutHud = playerProfile.getSpoutHud();
|
||||
|
||||
playerProfile.setHudType(nextHudType);
|
||||
spoutHud.initializeXpBar();
|
||||
spoutHud.updateXpBar();
|
||||
hudButton.setText("HUD Type: " + nextHudType.toString());
|
||||
hudButton.setDirty(true);
|
||||
}
|
||||
});
|
||||
|
||||
escapeButton = new McmmoButton("EXIT", null);
|
||||
escapeButton.setWidth(60);
|
||||
escapeButton.setHeight(20);
|
||||
escapeButton.setX(centerX - (escapeButton.getWidth() / 2));
|
||||
escapeButton.setY((centerY / 2) + (escapeButton.getHeight() * 2) + 5);
|
||||
escapeButton.connect(new Slot() {
|
||||
@Override
|
||||
public void activate() {
|
||||
spoutPlayer.getMainScreen().closePopup();
|
||||
}
|
||||
});
|
||||
|
||||
attachWidget(mcMMO.p, hudButton);
|
||||
attachWidget(mcMMO.p, titleLabel);
|
||||
attachWidget(mcMMO.p, escapeLabel);
|
||||
attachWidget(mcMMO.p, escapeButton);
|
||||
|
||||
InGameHUD inGameHud = spoutPlayer.getMainScreen();
|
||||
|
||||
inGameHud.attachPopupScreen(this);
|
||||
inGameHud.setDirty(true);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.gmail.nossr50.datatypes.popups;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.gui.GenericPopup;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
||||
|
||||
public class PopupMMO extends GenericPopup {
|
||||
|
||||
private ButtonHUDStyle HUDButton = null;
|
||||
private ButtonEscape EscapeButton = null;
|
||||
private GenericLabel mcMMO_label = new GenericLabel();
|
||||
private GenericLabel tip_escape = new GenericLabel();
|
||||
private int center_x = 427 / 2;
|
||||
private int center_y = 240 / 2;
|
||||
|
||||
public PopupMMO(Player player, PlayerProfile PP, mcMMO plugin) {
|
||||
|
||||
//240, 427 are the bottom right
|
||||
mcMMO_label.setText(ChatColor.GOLD + "~mcMMO Menu~"); //TODO: Needs more locale
|
||||
mcMMO_label.setX(center_x - 35);
|
||||
mcMMO_label.setY((center_y / 2) - 20);
|
||||
mcMMO_label.setDirty(true);
|
||||
|
||||
tip_escape.setText(ChatColor.GRAY + "Press ESCAPE to exit!"); //TODO: Needs more locale
|
||||
tip_escape.setX(mcMMO_label.getX() - 15);
|
||||
tip_escape.setY(mcMMO_label.getY() + 10);
|
||||
tip_escape.setDirty(true);
|
||||
|
||||
HUDButton = new ButtonHUDStyle(PP);
|
||||
HUDButton.setX(center_x - (HUDButton.getWidth() / 2));
|
||||
HUDButton.setY(center_y / 2);
|
||||
HUDButton.setDirty(true);
|
||||
|
||||
EscapeButton = new ButtonEscape();
|
||||
EscapeButton.setX(center_x - (EscapeButton.getWidth() / 2));
|
||||
EscapeButton.setY((center_y / 2) + (HUDButton.getHeight() * 2) + 5);
|
||||
EscapeButton.setDirty(true);
|
||||
|
||||
this.attachWidget(plugin, HUDButton);
|
||||
this.attachWidget(plugin, mcMMO_label);
|
||||
this.attachWidget(plugin, tip_escape);
|
||||
this.attachWidget(plugin, EscapeButton);
|
||||
|
||||
this.setDirty(true);
|
||||
}
|
||||
|
||||
public void updateButtons(PlayerProfile PP) {
|
||||
HUDButton.updateText(PP);
|
||||
//PartyButton.updateText(PP);
|
||||
this.setDirty(true);
|
||||
}
|
||||
}
|
||||
320
src/main/java/com/gmail/nossr50/datatypes/popups/XpBar.java
Normal file
320
src/main/java/com/gmail/nossr50/datatypes/popups/XpBar.java
Normal file
@@ -0,0 +1,320 @@
|
||||
package com.gmail.nossr50.datatypes.popups;
|
||||
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
import org.getspout.spoutapi.gui.GenericGradient;
|
||||
import org.getspout.spoutapi.gui.GenericTexture;
|
||||
import org.getspout.spoutapi.gui.InGameHUD;
|
||||
import org.getspout.spoutapi.gui.RenderPriority;
|
||||
import org.getspout.spoutapi.gui.Widget;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.HudType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class XpBar {
|
||||
private SpoutPlayer spoutPlayer;
|
||||
|
||||
private Widget xpBar;
|
||||
private GenericGradient xpFill;
|
||||
private GenericGradient xpBackground;
|
||||
private GenericGradient xpIconBackground;
|
||||
private GenericGradient xpIconBorder;
|
||||
private GenericTexture xpIcon;
|
||||
|
||||
public XpBar(SpoutPlayer spoutPlayer, HudType hudType) {
|
||||
this.spoutPlayer = spoutPlayer;
|
||||
|
||||
switch (hudType) {
|
||||
case RETRO:
|
||||
initializeXpBarRetro();
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
initializeXpBarStandard();
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
initializeXpBarSmall();
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
}
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Retro XP bar.
|
||||
*/
|
||||
private void initializeXpBarRetro() {
|
||||
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
|
||||
Color green = new Color(0f, 1f, 0f, 1f);
|
||||
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
|
||||
|
||||
xpBar = new GenericGradient();
|
||||
xpFill = new GenericGradient();
|
||||
xpBackground = new GenericGradient();
|
||||
|
||||
xpBar.setWidth(128);
|
||||
xpBar.setHeight(4);
|
||||
xpBar.setX(149);
|
||||
xpBar.setY(10);
|
||||
((GenericGradient) xpBar).setBottomColor(border);
|
||||
((GenericGradient) xpBar).setTopColor(border);
|
||||
xpBar.setPriority(RenderPriority.Highest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
xpFill.setWidth(0);
|
||||
xpFill.setHeight(2);
|
||||
xpFill.setX(150);
|
||||
xpFill.setY(11);
|
||||
xpFill.setBottomColor(green);
|
||||
xpFill.setTopColor(green);
|
||||
xpFill.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
|
||||
|
||||
xpBackground.setWidth(126);
|
||||
xpBackground.setHeight(2);
|
||||
xpBackground.setX(150);
|
||||
xpBackground.setY(11);
|
||||
xpBackground.setBottomColor(background);
|
||||
xpBackground.setTopColor(background);
|
||||
xpBackground.setPriority(RenderPriority.Low);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBackground);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
|
||||
|
||||
xpIconBackground = new GenericGradient();
|
||||
xpIconBorder = new GenericGradient();
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIconBackground.setBottomColor(darkbg);
|
||||
xpIconBackground.setTopColor(darkbg);
|
||||
xpIconBackground.setWidth(4);
|
||||
xpIconBackground.setHeight(4);
|
||||
xpIconBackground.setPriority(RenderPriority.High);
|
||||
xpIconBackground.setX(142);
|
||||
xpIconBackground.setY(10);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBackground);
|
||||
|
||||
xpIconBorder.setBottomColor(border);
|
||||
xpIconBorder.setTopColor(border);
|
||||
xpIconBorder.setWidth(6);
|
||||
xpIconBorder.setHeight(6);
|
||||
xpIconBorder.setPriority(RenderPriority.Highest);
|
||||
xpIconBorder.setX(141);
|
||||
xpIconBorder.setY(9);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBorder);
|
||||
|
||||
xpIcon.setWidth(6);
|
||||
xpIcon.setHeight(6);
|
||||
xpIcon.setX(141);
|
||||
xpIcon.setY(9);
|
||||
xpIcon.setPriority(RenderPriority.Normal);
|
||||
xpIcon.setUrl("Icon_r.png");
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Standard XP bar.
|
||||
*/
|
||||
private void initializeXpBarStandard() {
|
||||
xpBar = new GenericTexture();
|
||||
|
||||
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
|
||||
xpBar.setX(SpoutConfig.getInstance().getXPBarXPosition());
|
||||
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
|
||||
xpBar.setHeight(8);
|
||||
xpBar.setWidth(256);
|
||||
xpBar.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIcon.setUrl("Icon.png");
|
||||
xpIcon.setHeight(16);
|
||||
xpIcon.setWidth(32);
|
||||
xpIcon.setX(SpoutConfig.getInstance().getXPIconXPosition());
|
||||
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition());
|
||||
xpIcon.setPriority(RenderPriority.High);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Small XP bar.
|
||||
*/
|
||||
private void initializeXpBarSmall() {
|
||||
xpBar = new GenericTexture();
|
||||
|
||||
((GenericTexture)xpBar).setUrl("xpbar_inc000.png");
|
||||
xpBar.setX(427 / 2 - 64);
|
||||
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
|
||||
xpBar.setHeight(4);
|
||||
xpBar.setWidth(128);
|
||||
xpBar.setPriority(RenderPriority.Lowest);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
|
||||
|
||||
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
|
||||
xpIcon = new GenericTexture();
|
||||
|
||||
xpIcon.setUrl("Icon.png");
|
||||
xpIcon.setHeight(8);
|
||||
xpIcon.setWidth(16);
|
||||
xpIcon.setX(427 / 2 - (8 + 64));
|
||||
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
|
||||
xpIcon.setPriority(RenderPriority.High);
|
||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the XP bar.
|
||||
*
|
||||
* @param skillType
|
||||
* @param playerProfile
|
||||
*/
|
||||
public void update(SkillType skillType, PlayerProfile playerProfile) {
|
||||
switch (playerProfile.getHudType()) {
|
||||
case RETRO:
|
||||
updateXpBarRetro(skillType, playerProfile);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
case SMALL:
|
||||
updateXpBarStandard(skillType, playerProfile);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Standard & Small styles.
|
||||
*
|
||||
* @param skillType
|
||||
* @param playerProfile
|
||||
*/
|
||||
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
|
||||
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + ".png");
|
||||
|
||||
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update XP bar for Retro styles.
|
||||
*
|
||||
* @param skillType
|
||||
*/
|
||||
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
|
||||
Color color = getRetroColor(skillType);
|
||||
|
||||
xpIcon.setUrl(Misc.getCapitalized(skillType.toString()) + "_r.png");
|
||||
|
||||
xpFill.setBottomColor(color);
|
||||
xpFill.setTopColor(color);
|
||||
xpFill.setWidth(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.RETRO));
|
||||
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
|
||||
private static Color getRetroColor(SkillType type) {
|
||||
switch (type) {
|
||||
case ACROBATICS:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
|
||||
|
||||
case ARCHERY:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
|
||||
|
||||
case AXES:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
|
||||
|
||||
case EXCAVATION:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
|
||||
|
||||
case HERBALISM:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
|
||||
|
||||
case MINING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
|
||||
|
||||
case REPAIR:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
|
||||
|
||||
case SWORDS:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
|
||||
|
||||
case TAMING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
|
||||
|
||||
case UNARMED:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
|
||||
|
||||
case WOODCUTTING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
|
||||
|
||||
case FISHING:
|
||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
|
||||
|
||||
default:
|
||||
return new Color(0.3f, 0.3f, 0.75f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getUrlBar(Integer number) {
|
||||
char[] num = number.toString().toCharArray();
|
||||
|
||||
switch (num.length) {
|
||||
case 1:
|
||||
return "xpbar_inc00" + number + ".png";
|
||||
|
||||
case 2:
|
||||
return "xpbar_inc0" + number + ".png";
|
||||
|
||||
default:
|
||||
return "xpbar_inc" + number + ".png";
|
||||
}
|
||||
}
|
||||
|
||||
private static Integer getXpInc(int skillXp, int xpToLevel, HudType hudType) {
|
||||
double percentage = (double) skillXp / xpToLevel;
|
||||
double inc;
|
||||
|
||||
switch (hudType) {
|
||||
case RETRO:
|
||||
inc = 0.0079365079365079;
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
inc = 0.0039370078740157;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (int) (percentage / inc);
|
||||
}
|
||||
|
||||
public void removeWidgets() {
|
||||
InGameHUD inGameHud = spoutPlayer.getMainScreen();
|
||||
|
||||
if (xpBar != null) inGameHud.removeWidget(xpBar);
|
||||
if (xpFill != null) inGameHud.removeWidget(xpFill);
|
||||
if (xpBackground != null) inGameHud.removeWidget(xpBackground);
|
||||
if (xpIconBackground != null) inGameHud.removeWidget(xpIconBackground);
|
||||
if (xpIconBorder != null) inGameHud.removeWidget(xpIconBorder);
|
||||
if (xpIcon != null) inGameHud.removeWidget(xpIcon);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import com.gmail.nossr50.datatypes.ToolType;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.runnables.StickyPistonTracker;
|
||||
import com.gmail.nossr50.skills.gathering.Excavation;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.gathering.Mining;
|
||||
@@ -57,11 +58,15 @@ public class BlockListener implements Listener {
|
||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||
List<Block> blocks = event.getBlocks();
|
||||
BlockFace direction = event.getDirection();
|
||||
// Block that would be air after piston is finished
|
||||
Block futureEmptyBlock = event.getBlock().getRelative(direction);
|
||||
|
||||
for (Block b : blocks) {
|
||||
if (mcMMO.placeStore.isTrue(b)) {
|
||||
b.getRelative(direction).setMetadata("pistonTrack", new FixedMetadataValue(plugin, true));
|
||||
mcMMO.placeStore.setFalse(b);
|
||||
if (b.equals(futureEmptyBlock)) {
|
||||
mcMMO.placeStore.setFalse(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,11 +78,14 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Monitor BlockPhysics events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
*/
|
||||
// Disabled until a better patch can be applied. This does nothing but flag the wrong block.
|
||||
/*
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
//TODO: Figure out how to REMOVE metadata from the location the sand/gravel fell from.
|
||||
@@ -91,6 +99,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Monitor BlockPistonRetract events.
|
||||
@@ -99,11 +108,9 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Block block = event.getRetractLocation().getBlock();
|
||||
|
||||
if (event.isSticky() && mcMMO.placeStore.isTrue(block)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
mcMMO.placeStore.setTrue(event.getBlock().getRelative(event.getDirection()));
|
||||
if (event.isSticky()) {
|
||||
//Needed only because under some circumstances Minecraft doesn't move the block
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new StickyPistonTracker(event), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +127,8 @@ public class BlockListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
int id = block.getTypeId();
|
||||
Material type = block.getType();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
|
||||
if (type.equals(Material.SAND) || type.equals(Material.GRAVEL)) {
|
||||
@@ -154,27 +163,35 @@ public class BlockListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
|
||||
Config configInstance = Config.getInstance();
|
||||
Permissions permInstance = Permissions.getInstance();
|
||||
|
||||
if (event instanceof FakeBlockBreakEvent) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* HERBALISM */
|
||||
if (BlockChecks.canBeGreenTerra(block)) {
|
||||
/* Green Terra */
|
||||
if (PP.getToolPreparationMode(ToolType.HOE) && permInstance.greenTerra(player)) {
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && permInstance.greenTerra(player)) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
|
||||
/* Triple drops */
|
||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
Herbalism.herbalismProcCheck(block, player, event, plugin);
|
||||
}
|
||||
|
||||
@@ -206,15 +223,8 @@ public class BlockListener implements Listener {
|
||||
WoodCutting.woodcuttingBlockCheck(player, block);
|
||||
}
|
||||
|
||||
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
||||
if (ModChecks.isCustomTool(inHand)) {
|
||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
}
|
||||
else {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
|
||||
WoodCutting.treeFeller(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +241,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
//Remove metadata when broken
|
||||
if (mcMMO.placeStore.isTrue(block) && BlockChecks.shouldBeWatched(block)) {
|
||||
if (BlockChecks.shouldBeWatched(block)) {
|
||||
mcMMO.placeStore.setFalse(block);
|
||||
}
|
||||
|
||||
@@ -271,7 +281,15 @@ public class BlockListener implements Listener {
|
||||
final int LEAF_BLOWER_LEVEL = 100;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
Block block = event.getBlock();
|
||||
Material material = block.getType();
|
||||
@@ -283,54 +301,39 @@ public class BlockListener implements Listener {
|
||||
* ABILITY PREPARATION CHECKS
|
||||
*/
|
||||
if (BlockChecks.abilityBlockCheck(block)) {
|
||||
if (PP.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
||||
if (profile.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
|
||||
Skills.abilityCheck(player, SkillType.HERBALISM);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && permInstance.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
||||
else if (profile.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && permInstance.treeFeller(player)) { //TODO: Why are we checking the permissions here?
|
||||
Skills.abilityCheck(player, SkillType.WOODCUTTING);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
|
||||
else if (profile.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.MINING);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
|
||||
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
|
||||
Skills.abilityCheck(player, SkillType.EXCAVATION);
|
||||
}
|
||||
else if (PP.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
|
||||
else if (profile.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
|
||||
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||
}
|
||||
}
|
||||
|
||||
/* TREE FELLER SOUNDS */
|
||||
if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||
if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && profile.getAbilityMode(AbilityType.TREE_FELLER)) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
|
||||
}
|
||||
|
||||
/*
|
||||
* ABILITY TRIGGER CHECKS
|
||||
*/
|
||||
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||
if (ModChecks.isCustomTool(inHand)) {
|
||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
|
||||
Herbalism.greenTerra(player, block);
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
|
||||
if (configInstance.getExcavationRequiresTool()) {
|
||||
if (ItemChecks.isShovel(inHand)) {
|
||||
if (ModChecks.isCustomTool(inHand)) {
|
||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
event.setInstaBreak(true);
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -338,7 +341,7 @@ public class BlockListener implements Listener {
|
||||
Excavation.gigaDrillBreaker(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
else if (profile.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (inHand.getType().equals(Material.AIR)) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
plugin.getServer().getPluginManager().callEvent(armswing);
|
||||
@@ -350,19 +353,11 @@ public class BlockListener implements Listener {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
}
|
||||
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
|
||||
if (configInstance.getMiningRequiresTool()) {
|
||||
if (ItemChecks.isPickaxe(inHand)) {
|
||||
if (ModChecks.isCustomTool(inHand)) {
|
||||
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
event.setInstaBreak(true);
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -370,7 +365,7 @@ public class BlockListener implements Listener {
|
||||
Mining.superBreakerBlockCheck(player, block);
|
||||
}
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
|
||||
else if (profile.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
|
||||
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
|
||||
if (configInstance.getWoodcuttingRequiresTool()) {
|
||||
if (ItemChecks.isAxe(inHand)) {
|
||||
|
||||
@@ -63,6 +63,8 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity attacker = event.getDamager();
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if(attacker.hasMetadata("NPC") || defender.hasMetadata("NPC")) return; // Check if either players is are Citizens NPCs
|
||||
|
||||
if (attacker instanceof Projectile) {
|
||||
attacker = ((Projectile) attacker).getShooter();
|
||||
@@ -75,11 +77,19 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker instanceof Player && defender instanceof Player) {
|
||||
if (PartyManager.getInstance().inSameParty((Player) defender, (Player) attacker)) {
|
||||
event.setCancelled(true);
|
||||
if (defender instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
|
||||
if (!defendingPlayer.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
if (PartyManager.getInstance().inSameParty(defendingPlayer, (Player) attacker)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for invincibility */
|
||||
@@ -106,6 +116,8 @@ public class EntityListener implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
@@ -115,9 +127,18 @@ public class EntityListener implements Listener {
|
||||
if (lEntity instanceof Player) {
|
||||
/* Check for invincibility */
|
||||
Player player = (Player) entity;
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if (PP.getGodMode()) {
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@@ -132,7 +153,7 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
if (event.getDamage() >= 1) {
|
||||
PP.actualizeRecentlyHurt();
|
||||
profile.actualizeRecentlyHurt();
|
||||
}
|
||||
}
|
||||
} else if (lEntity instanceof Tameable) {
|
||||
@@ -154,6 +175,8 @@ public class EntityListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
entity.setFireTicks(0);
|
||||
BleedTimer.remove(entity);
|
||||
@@ -182,7 +205,9 @@ public class EntityListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
@@ -205,7 +230,11 @@ public class EntityListener implements Listener {
|
||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (event.getEntity() instanceof TNTPrimed) {
|
||||
if(entity == null) return;
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
if (plugin.tntIsTracked(id)) {
|
||||
@@ -225,7 +254,10 @@ public class EntityListener implements Listener {
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
|
||||
@@ -242,7 +274,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
if (newFoodLevel > currentFoodLevel) {
|
||||
Material food = player.getItemInHand().getType();
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
|
||||
int foodChange = newFoodLevel - currentFoodLevel;
|
||||
int rankChange = 0;
|
||||
|
||||
@@ -267,6 +299,35 @@ public class EntityListener implements Listener {
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case CARROT_ITEM:
|
||||
/* CARROT RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case POTATO_ITEM:
|
||||
/* POTATO RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
case BAKED_POTATO:
|
||||
/* BAKED POTATO RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case POISONOUS_POTATO:
|
||||
/* POISONOUS POTATO RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
||||
rankChange = 400;
|
||||
break;
|
||||
|
||||
case GOLDEN_CARROT:
|
||||
/* GOLDEN CARROT RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
|
||||
case PUMPKIN_PIE:
|
||||
/* PUMPKIN PIE RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
|
||||
rankChange = 200;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@@ -297,9 +358,11 @@ public class EntityListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.MONITOR)
|
||||
public void onEntityTame(EntityTameEvent event) {
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
EntityType type = event.getEntityType();
|
||||
int xp = 0;
|
||||
|
||||
@@ -316,7 +379,7 @@ public class EntityListener implements Listener {
|
||||
break;
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, PP, SkillType.TAMING, xp);
|
||||
Skills.xpProcessing(player, profile, SkillType.TAMING, xp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ public class HardcoreListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
|
||||
if (player.getKiller() instanceof Player) {
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(player.getKiller(), player);
|
||||
}
|
||||
if (player.getKiller() != null && Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(player.getKiller(), player);
|
||||
}
|
||||
|
||||
Hardcore.invokeStatPenalty(player);
|
||||
|
||||
@@ -3,13 +3,14 @@ package com.gmail.nossr50.listeners;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent.State;
|
||||
@@ -36,7 +37,6 @@ import com.gmail.nossr50.skills.gathering.BlastMining;
|
||||
import com.gmail.nossr50.skills.gathering.Fishing;
|
||||
import com.gmail.nossr50.skills.gathering.Herbalism;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.BlockChecks;
|
||||
import com.gmail.nossr50.util.Item;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -58,18 +58,25 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (PP.getGodMode()) {
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getGodMode()) {
|
||||
if (!Permissions.getInstance().mcgod(player)) {
|
||||
PP.toggleGodMode();
|
||||
profile.toggleGodMode();
|
||||
player.sendMessage(LocaleLoader.getString("Commands.GodMode.Forbidden"));
|
||||
}
|
||||
}
|
||||
|
||||
if (PP.inParty()) {
|
||||
if (profile.inParty()) {
|
||||
if (!Permissions.getInstance().party(player)) {
|
||||
PP.removeParty();
|
||||
profile.removeParty();
|
||||
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
|
||||
}
|
||||
}
|
||||
@@ -83,6 +90,8 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerFish(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Permissions.getInstance().fishing(player)) {
|
||||
State state = event.getState();
|
||||
@@ -93,6 +102,10 @@ public class PlayerListener implements Listener {
|
||||
break;
|
||||
|
||||
case CAUGHT_ENTITY:
|
||||
if (!(event.getCaught() instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Users.getProfile(player).getSkillLevel(SkillType.FISHING) >= 150 && Permissions.getInstance().shakeMob(player)) {
|
||||
Fishing.shakeMob(event);
|
||||
}
|
||||
@@ -111,7 +124,16 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
if (Users.getProfile(event.getPlayer()).getAbilityMode(AbilityType.BERSERK)) {
|
||||
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +145,8 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Users.addUser(event.getPlayer()).actualizeRespawnATS();
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Users.addUser(event.getPlayer()).getProfile().actualizeRespawnATS();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,14 +157,11 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
/* GARBAGE COLLECTION */
|
||||
|
||||
//Remove Spout Stuff
|
||||
if (mcMMO.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
|
||||
SpoutStuff.playerHUDs.remove(player);
|
||||
}
|
||||
|
||||
//Bleed it out
|
||||
BleedTimer.bleedOut(player);
|
||||
}
|
||||
@@ -154,6 +174,8 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
//TODO: Locale ALL the things.
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
|
||||
@@ -189,14 +211,19 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
|
||||
if (XprateCommand.xpevent) {
|
||||
if (XprateCommand.isXpEventRunning()) {
|
||||
player.sendMessage(LocaleLoader.getString("XPRate.Event", new Object[] {Config.getInstance().xpGainMultiplier}));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Users.getProfile(event.getPlayer()).actualizeRespawnATS();
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
|
||||
if (profile != null) {
|
||||
profile.actualizeRespawnATS();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -207,6 +234,7 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Action action = event.getAction();
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
@@ -316,12 +344,19 @@ public class PlayerListener implements Listener {
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (PP.getPartyChatMode()) {
|
||||
Party party = PP.getParty();
|
||||
if (profile == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (profile.getPartyChatMode()) {
|
||||
Party party = profile.getParty();
|
||||
|
||||
if (party == null) {
|
||||
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
|
||||
@@ -347,7 +382,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (PP.getAdminChatMode()) {
|
||||
else if (profile.getAdminChatMode()) {
|
||||
String playerName = player.getName();
|
||||
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
|
||||
plugin.getServer().getPluginManager().callEvent(chatEvent);
|
||||
@@ -360,9 +395,9 @@ public class PlayerListener implements Listener {
|
||||
|
||||
plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage());
|
||||
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
|
||||
p.sendMessage(prefix + chatEvent.getMessage());
|
||||
for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) {
|
||||
otherPlayer.sendMessage(prefix + chatEvent.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,28 +7,20 @@ import org.getspout.spoutapi.event.input.KeyPressedEvent;
|
||||
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
|
||||
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
|
||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
import org.getspout.spoutapi.gui.Button;
|
||||
import org.getspout.spoutapi.gui.ScreenType;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.SpoutConfig;
|
||||
import com.gmail.nossr50.datatypes.HUDType;
|
||||
import com.gmail.nossr50.datatypes.HUDmmo;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.SpoutHud;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
|
||||
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
|
||||
import com.gmail.nossr50.datatypes.popups.PopupMMO;
|
||||
import com.gmail.nossr50.datatypes.buttons.McmmoButton;
|
||||
import com.gmail.nossr50.datatypes.popups.Menu;
|
||||
import com.gmail.nossr50.spout.SpoutStuff;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class SpoutListener implements Listener {
|
||||
private final mcMMO plugin;
|
||||
|
||||
public SpoutListener(mcMMO plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Monitor SpoutCraftEnable events.
|
||||
*
|
||||
@@ -36,19 +28,16 @@ public class SpoutListener implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
PlayerProfile PPs = Users.getProfile(sPlayer);
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(spoutPlayer);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
//TODO: Add custom titles based on skills
|
||||
if (SpoutConfig.getInstance().getShowPowerLevel()) {
|
||||
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" + ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
|
||||
spoutPlayer.setTitle(spoutPlayer.getName() + "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" + ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(mcMMOPlayer.getPowerLevel()));
|
||||
}
|
||||
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
|
||||
|
||||
PPs.toggleSpoutEnabled();
|
||||
}
|
||||
profile.setSpoutHud(new SpoutHud(mcMMOPlayer)); //Setup Party HUD stuff
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,48 +47,10 @@ public class SpoutListener implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onButtonClick(ButtonClickEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(sPlayer);
|
||||
Button button = event.getButton();
|
||||
|
||||
if (event.getButton() instanceof ButtonHUDStyle) {
|
||||
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.remove(sPlayer);
|
||||
|
||||
switch (PP.getHUDType()) {
|
||||
case RETRO:
|
||||
PP.setHUDType(HUDType.STANDARD);
|
||||
break;
|
||||
|
||||
case STANDARD:
|
||||
PP.setHUDType(HUDType.SMALL);
|
||||
break;
|
||||
|
||||
case SMALL:
|
||||
PP.setHUDType(HUDType.DISABLED);
|
||||
break;
|
||||
|
||||
case DISABLED:
|
||||
PP.setHUDType(HUDType.RETRO);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin));
|
||||
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
|
||||
}
|
||||
}
|
||||
else if (event.getButton() instanceof ButtonEscape) {
|
||||
sPlayer.getMainScreen().closePopup();
|
||||
}
|
||||
else if (event.getButton() instanceof ButtonPartyToggle) {
|
||||
PP.togglePartyHUD();
|
||||
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
|
||||
bpt.updateText(PP);
|
||||
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
|
||||
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
|
||||
if (button instanceof McmmoButton) {
|
||||
((McmmoButton) button).activate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,8 +61,11 @@ public class SpoutListener implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onScreenClose(ScreenCloseEvent event) {
|
||||
if (event.getScreen() instanceof PopupMMO) {
|
||||
SpoutStuff.playerScreens.remove(event.getPlayer());
|
||||
if (event.getScreen() instanceof Menu) {
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
|
||||
Users.getProfile(spoutPlayer).getSpoutHud().onMenuClose();
|
||||
spoutPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,23 +76,17 @@ public class SpoutListener implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onKeyPressedEvent(KeyPressedEvent event) {
|
||||
SpoutPlayer sPlayer = event.getPlayer();
|
||||
SpoutPlayer spoutPlayer = event.getPlayer();
|
||||
|
||||
if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
|
||||
if (spoutPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey() == SpoutStuff.keypress) {
|
||||
if (!SpoutStuff.playerScreens.containsKey(sPlayer)) {
|
||||
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
|
||||
SpoutHud spoutHud = Users.getProfile(spoutPlayer).getSpoutHud();
|
||||
|
||||
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
|
||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
}
|
||||
else {
|
||||
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
|
||||
sPlayer.getMainScreen().setDirty(true);
|
||||
if (!spoutHud.isMenuOpened()) {
|
||||
spoutHud.openMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,38 @@
|
||||
package com.gmail.nossr50.listeners;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.blockstoreconversion.BlockStoreConversionMain;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.HashChunkManager;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
ArrayList<BlockStoreConversionMain> converters = new ArrayList<BlockStoreConversionMain>();
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");
|
||||
if(!dataDir.exists()) {
|
||||
dataDir.mkdir();
|
||||
return;
|
||||
}
|
||||
|
||||
if(mcMMO.p == null)
|
||||
return;
|
||||
|
||||
mcMMO.p.getLogger().info("Converting block storage for " + event.getWorld().getName() + " to a new format.");
|
||||
BlockStoreConversionMain converter = new BlockStoreConversionMain(event.getWorld());
|
||||
converter.run();
|
||||
converters.add(converter);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -31,13 +45,8 @@ public class WorldListener implements Listener {
|
||||
mcMMO.placeStore.saveWorld(event.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
mcMMO.placeStore.chunkLoaded(event.getChunk().getX(), event.getChunk().getZ(), event.getChunk().getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getChunk().getWorld());
|
||||
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getWorld());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ import java.util.List;
|
||||
import net.shatteredlands.shatt.backup.ZipLibrary;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.gmail.nossr50.commands.general.AddlevelsCommand;
|
||||
import com.gmail.nossr50.commands.general.AddxpCommand;
|
||||
@@ -22,6 +22,7 @@ import com.gmail.nossr50.commands.general.InspectCommand;
|
||||
import com.gmail.nossr50.commands.general.McstatsCommand;
|
||||
import com.gmail.nossr50.commands.general.MmoeditCommand;
|
||||
import com.gmail.nossr50.commands.general.MmoupdateCommand;
|
||||
import com.gmail.nossr50.commands.general.SkillResetCommand;
|
||||
import com.gmail.nossr50.commands.general.XprateCommand;
|
||||
import com.gmail.nossr50.commands.mc.McabilityCommand;
|
||||
import com.gmail.nossr50.commands.mc.MccCommand;
|
||||
@@ -52,11 +53,11 @@ import com.gmail.nossr50.commands.spout.MchudCommand;
|
||||
import com.gmail.nossr50.commands.spout.XplockCommand;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.config.RepairConfigManager;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.config.mods.CustomToolsConfig;
|
||||
import com.gmail.nossr50.config.repair.RepairConfigManager;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.listeners.BlockListener;
|
||||
import com.gmail.nossr50.listeners.EntityListener;
|
||||
@@ -66,6 +67,7 @@ import com.gmail.nossr50.listeners.WorldListener;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.runnables.BleedTimer;
|
||||
import com.gmail.nossr50.runnables.ChunkletUnloader;
|
||||
import com.gmail.nossr50.runnables.SaveTimer;
|
||||
import com.gmail.nossr50.runnables.SkillMonitor;
|
||||
import com.gmail.nossr50.runnables.SpoutStart;
|
||||
@@ -77,8 +79,9 @@ import com.gmail.nossr50.util.Leaderboard;
|
||||
import com.gmail.nossr50.util.Metrics;
|
||||
import com.gmail.nossr50.util.Metrics.Graph;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.util.blockmeta.ChunkletManager;
|
||||
import com.gmail.nossr50.util.blockmeta.ChunkletManagerFactory;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
||||
|
||||
|
||||
public class mcMMO extends JavaPlugin {
|
||||
|
||||
@@ -91,22 +94,21 @@ public class mcMMO extends JavaPlugin {
|
||||
private HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
||||
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
||||
|
||||
public static File versionFile;
|
||||
public static Database database;
|
||||
private static Database database;
|
||||
public static mcMMO p;
|
||||
|
||||
public static ChunkletManager placeStore;
|
||||
public static ChunkManager placeStore;
|
||||
public static RepairManager repairManager;
|
||||
|
||||
/* Jar Stuff */
|
||||
public static File mcmmo;
|
||||
|
||||
//File Paths
|
||||
public static String mainDirectory;
|
||||
public static String flatFileDirectory;
|
||||
public static String usersFile;
|
||||
public static String leaderboardDirectory;
|
||||
public static String modDirectory;
|
||||
private static String mainDirectory;
|
||||
private static String flatFileDirectory;
|
||||
private static String usersFile;
|
||||
private static String leaderboardDirectory;
|
||||
private static String modDirectory;
|
||||
|
||||
//Spout Check
|
||||
public static boolean spoutEnabled;
|
||||
@@ -127,17 +129,15 @@ public class mcMMO extends JavaPlugin {
|
||||
List<Repairable> repairables = new ArrayList<Repairable>();
|
||||
|
||||
if (configInstance.getToolModsEnabled()) {
|
||||
CustomToolsConfig.getInstance().load();
|
||||
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (configInstance.getArmorModsEnabled()) {
|
||||
CustomArmorConfig.getInstance().load();
|
||||
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
||||
}
|
||||
|
||||
if (configInstance.getBlockModsEnabled()) {
|
||||
CustomBlocksConfig.getInstance().load();
|
||||
CustomBlocksConfig.getInstance();
|
||||
}
|
||||
|
||||
//Load repair configs, make manager, and register them at this time
|
||||
@@ -150,16 +150,16 @@ public class mcMMO extends JavaPlugin {
|
||||
Users.loadUsers();
|
||||
}
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
PluginManager pluginManager = getServer().getPluginManager();
|
||||
|
||||
//Register events
|
||||
pm.registerEvents(playerListener, this);
|
||||
pm.registerEvents(blockListener, this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
pm.registerEvents(worldListener, this);
|
||||
pluginManager.registerEvents(playerListener, this);
|
||||
pluginManager.registerEvents(blockListener, this);
|
||||
pluginManager.registerEvents(entityListener, this);
|
||||
pluginManager.registerEvents(worldListener, this);
|
||||
|
||||
if (configInstance.getHardcoreEnabled()) {
|
||||
pm.registerEvents(hardcoreListener, this);
|
||||
pluginManager.registerEvents(hardcoreListener, this);
|
||||
}
|
||||
|
||||
PluginDescriptionFile pdfFile = getDescription();
|
||||
@@ -183,12 +183,14 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
//Schedule Spout Activation 1 second after start-up
|
||||
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
|
||||
//Periodic save timer (Saves every 10 minutes)
|
||||
//Periodic save timer (Saves every 10 minutes by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
|
||||
//Regen & Cooldown timer (Runs every second)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
||||
//Bleed timer (Runs every two seconds)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
|
||||
//Chunklet unloader (Runs every 20 seconds by default)
|
||||
scheduler.scheduleSyncRepeatingTask(this, new ChunkletUnloader(), 0, ChunkletUnloader.RUN_INTERVAL * 20);
|
||||
|
||||
registerCommands();
|
||||
|
||||
@@ -198,7 +200,7 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
Graph graph = metrics.createGraph("Percentage of servers using timings");
|
||||
|
||||
if (pm.useTimings()) {
|
||||
if (pluginManager.useTimings()) {
|
||||
graph.addPlotter(new Metrics.Plotter("Enabled") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
@@ -223,11 +225,7 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
|
||||
// Get our ChunkletManager
|
||||
placeStore = ChunkletManagerFactory.getChunkletManager();
|
||||
|
||||
for (World world : getServer().getWorlds()) {
|
||||
placeStore.loadWorld(world);
|
||||
}
|
||||
placeStore = ChunkManagerFactory.getChunkManager();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,20 +282,11 @@ public class mcMMO extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
//Make sure to save player information if the server shuts down
|
||||
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
|
||||
playerProfile.save();
|
||||
}
|
||||
|
||||
Users.saveAll(); //Make sure to save player information if the server shuts down
|
||||
PartyManager.getInstance().saveParties();
|
||||
|
||||
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
||||
|
||||
//Save our metadata
|
||||
placeStore.saveAll();
|
||||
|
||||
//Cleanup empty metadata stores
|
||||
placeStore.cleanUp();
|
||||
placeStore.saveAll(); //Save our metadata
|
||||
placeStore.cleanUp(); //Cleanup empty metadata stores
|
||||
|
||||
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
try {
|
||||
@@ -379,6 +368,10 @@ public class mcMMO extends JavaPlugin {
|
||||
getCommand("mcstats").setExecutor(new McstatsCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandSkillResetEnabled()) {
|
||||
getCommand("skillreset").setExecutor(new SkillResetCommand());
|
||||
}
|
||||
|
||||
//Party commands
|
||||
if (configInstance.getCommandAcceptEnabled()) {
|
||||
getCommand("accept").setExecutor(new AcceptCommand(this));
|
||||
@@ -418,7 +411,7 @@ public class mcMMO extends JavaPlugin {
|
||||
}
|
||||
|
||||
if (configInstance.getCommandInspectEnabled()) {
|
||||
getCommand("inspect").setExecutor(new InspectCommand(this));
|
||||
getCommand("inspect").setExecutor(new InspectCommand());
|
||||
}
|
||||
|
||||
if (configInstance.getCommandXPRateEnabled()) {
|
||||
@@ -432,7 +425,7 @@ public class mcMMO extends JavaPlugin {
|
||||
getCommand("xplock").setExecutor(new XplockCommand());
|
||||
}
|
||||
|
||||
getCommand("mchud").setExecutor(new MchudCommand(this));
|
||||
getCommand("mchud").setExecutor(new MchudCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,4 +486,29 @@ public class mcMMO extends JavaPlugin {
|
||||
public void removeFromTNTTracker(int tntID) {
|
||||
tntTracker.remove(tntID);
|
||||
}
|
||||
|
||||
public static String getMainDirectory() {
|
||||
return mainDirectory;
|
||||
}
|
||||
|
||||
public static String getFlatFileDirectory() {
|
||||
return flatFileDirectory;
|
||||
}
|
||||
|
||||
public static String getUsersFile() {
|
||||
return usersFile;
|
||||
}
|
||||
|
||||
public static String getLeaderboardDirectory() {
|
||||
return leaderboardDirectory;
|
||||
}
|
||||
|
||||
public static String getModDirectory() {
|
||||
return modDirectory;
|
||||
}
|
||||
|
||||
public static Database getPlayerDatabase() {
|
||||
return database;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,17 @@ public class PartyManager {
|
||||
* @return true if they are in the same party, false otherwise
|
||||
*/
|
||||
public boolean inSameParty(Player firstPlayer, Player secondPlayer) {
|
||||
if (Users.getProfile(firstPlayer).getParty() == null || Users.getProfile(secondPlayer).getParty() == null
|
||||
|| !Users.getProfile(firstPlayer).getParty().equals(Users.getProfile(secondPlayer).getParty())) {
|
||||
PlayerProfile firstProfile = Users.getProfile(firstPlayer);
|
||||
PlayerProfile secondProfile = Users.getProfile(secondPlayer);
|
||||
|
||||
if (firstProfile == null || secondProfile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Party firstParty = firstProfile.getParty();
|
||||
Party secondParty = secondProfile.getParty();
|
||||
|
||||
if (firstParty == null || secondParty == null || firstParty != secondParty) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public class BleedTimer implements Runnable {
|
||||
for (Entry<LivingEntity, Integer> entry : bleedList.entrySet()) {
|
||||
LivingEntity entity = entry.getKey();
|
||||
|
||||
if (entry.getValue() <= 0 || entity.isDead() || entity == null) {
|
||||
if (entry.getValue() <= 0 || entity.isDead()) {
|
||||
remove(entity);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class ChunkletUnloader implements Runnable {
|
||||
private static Map<Chunk, Integer> unloadedChunks = new HashMap<Chunk, Integer>();
|
||||
private static int minimumInactiveTime = 60; //Should be a multiple of RUN_INTERVAL for best performance
|
||||
public static final int RUN_INTERVAL = 20;
|
||||
|
||||
public static void addToList(Chunk chunk) {
|
||||
//Unfortunately we can't use Map.contains() because Chunks are always new objects
|
||||
//This method isn't efficient enough for me
|
||||
for (Chunk otherChunk : unloadedChunks.keySet()) {
|
||||
if (chunk.getX() == otherChunk.getX() && chunk.getZ() == otherChunk.getZ()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
unloadedChunks.put(chunk, 0);
|
||||
}
|
||||
|
||||
public static void addToList(int cx, int cz, World world) {
|
||||
addToList(world.getChunkAt(cx, cz));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Iterator<Entry<Chunk, Integer>> it = unloadedChunks.entrySet().iterator() ; it.hasNext() ; ) {
|
||||
Entry<Chunk, Integer> entry = it.next();
|
||||
Chunk chunk = entry.getKey();
|
||||
|
||||
if (!chunk.isLoaded()) {
|
||||
int inactiveTime = entry.getValue() + RUN_INTERVAL;
|
||||
|
||||
//Chunklets are unloaded only if their chunk has been unloaded for minimumInactiveTime
|
||||
if (inactiveTime >= minimumInactiveTime) {
|
||||
mcMMO.placeStore.unloadChunk(chunk.getX(), chunk.getZ(), chunk.getWorld());
|
||||
it.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
unloadedChunks.put(entry.getKey(), inactiveTime);
|
||||
}
|
||||
else {
|
||||
//Just remove the entry if the chunk has been reloaded.
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,15 +9,15 @@ import com.gmail.nossr50.util.Skills;
|
||||
|
||||
public class GainXp implements Runnable {
|
||||
private Player player = null;
|
||||
private PlayerProfile PP = null;
|
||||
private PlayerProfile profile = null;
|
||||
private double baseXp = 0;
|
||||
private SkillType skillType = null;
|
||||
private LivingEntity target = null;
|
||||
private int baseHealth = 0;
|
||||
|
||||
public GainXp(Player player, PlayerProfile PP, SkillType skillType, double baseXp, LivingEntity target) {
|
||||
public GainXp(Player player, PlayerProfile profile, SkillType skillType, double baseXp, LivingEntity target) {
|
||||
this.player = player;
|
||||
this.PP = PP;
|
||||
this.profile = profile;
|
||||
this.skillType = skillType;
|
||||
this.baseXp = baseXp;
|
||||
this.target = target;
|
||||
@@ -39,6 +39,6 @@ public class GainXp implements Runnable {
|
||||
damage += health;
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, PP, skillType, (int) (damage * baseXp));
|
||||
Skills.xpProcessing(player, profile, skillType, (int) (damage * baseXp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,34 +10,75 @@ import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class GreenThumbTimer implements Runnable {
|
||||
private Block block;
|
||||
private PlayerProfile PP;
|
||||
private PlayerProfile profile;
|
||||
private Material type;
|
||||
|
||||
public GreenThumbTimer(Block block, PlayerProfile PP) {
|
||||
public GreenThumbTimer(Block block, PlayerProfile profile, Material material) {
|
||||
this.block = block;
|
||||
this.PP = PP;
|
||||
this.profile = profile;
|
||||
this.type = material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
block.setType(Material.CROPS);
|
||||
if(this.block.getType() != this.type)
|
||||
this.block.setType(this.type);
|
||||
|
||||
//This replants the wheat at a certain stage in development based on Herbalism Skill
|
||||
if (!PP.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
if (PP.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
||||
block.setData(CropState.MEDIUM.getData());
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
||||
block.setData(CropState.SMALL.getData());
|
||||
}
|
||||
else if (PP.getSkillLevel(SkillType.HERBALISM) >= 200) {
|
||||
block.setData(CropState.VERY_SMALL.getData());
|
||||
switch(this.type) {
|
||||
case CROPS:
|
||||
case CARROT:
|
||||
case POTATO:
|
||||
//This replants the wheat at a certain stage in development based on Herbalism Skill
|
||||
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
||||
this.block.setData(CropState.MEDIUM.getData());
|
||||
}
|
||||
else if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
||||
this.block.setData(CropState.SMALL.getData());
|
||||
}
|
||||
else if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 200) {
|
||||
this.block.setData(CropState.VERY_SMALL.getData());
|
||||
}
|
||||
else {
|
||||
this.block.setData(CropState.GERMINATED.getData());
|
||||
}
|
||||
}
|
||||
else {
|
||||
block.setData(CropState.GERMINATED.getData());
|
||||
this.block.setData(CropState.MEDIUM.getData());
|
||||
}
|
||||
}
|
||||
else {
|
||||
block.setData(CropState.MEDIUM.getData());
|
||||
break;
|
||||
case NETHER_WARTS:
|
||||
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
||||
this.block.setData((byte) 2);
|
||||
}
|
||||
else if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
||||
this.block.setData((byte) 1);
|
||||
}
|
||||
else {
|
||||
this.block.setData((byte) 0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.block.setData((byte) 2);
|
||||
}
|
||||
break;
|
||||
case COCOA:
|
||||
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
|
||||
if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 600) {
|
||||
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
|
||||
}
|
||||
else if (this.profile.getSkillLevel(SkillType.HERBALISM) >= 400) {
|
||||
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
|
||||
}
|
||||
else {
|
||||
this.block.setData((byte) (this.block.getData() ^ ((byte) 0xc)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class ProfileSaveTask implements Runnable {
|
||||
private McMMOPlayer mcMMOPlayer;
|
||||
private PlayerProfile playerProfile;
|
||||
|
||||
public ProfileSaveTask(PlayerProfile playerProfile) {
|
||||
this.playerProfile = playerProfile;
|
||||
public ProfileSaveTask(McMMOPlayer mcMMOPlayer) {
|
||||
this.mcMMOPlayer = mcMMOPlayer;
|
||||
this.playerProfile = mcMMOPlayer.getProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
playerProfile.save();
|
||||
|
||||
if (!playerProfile.getPlayer().isOnline()) {
|
||||
Users.getProfiles().remove(playerProfile);
|
||||
if (!mcMMOPlayer.getPlayer().isOnline()) {
|
||||
Users.remove(playerProfile.getPlayerName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.io.FileReader;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
public class SQLConversionTask implements Runnable {
|
||||
@@ -17,7 +18,8 @@ public class SQLConversionTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String location = mcMMO.usersFile;
|
||||
Database database = mcMMO.getPlayerDatabase();
|
||||
String location = mcMMO.getUsersFile();
|
||||
|
||||
try {
|
||||
FileReader file = new FileReader(location);
|
||||
@@ -164,7 +166,7 @@ public class SQLConversionTask implements Runnable {
|
||||
}
|
||||
|
||||
//Check to see if the user is in the DB
|
||||
id = mcMMO.database.getInt("SELECT id FROM "
|
||||
id = database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '" + playerName + "'");
|
||||
|
||||
@@ -172,11 +174,11 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Update the skill values
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@@ -192,7 +194,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
@@ -213,32 +215,32 @@ public class SQLConversionTask implements Runnable {
|
||||
theCount++;
|
||||
|
||||
//Create the user in the DB
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "users (user, lastlogin) VALUES ('"
|
||||
+ playerName + "',"
|
||||
+ System.currentTimeMillis() / 1000 + ")");
|
||||
id = mcMMO.database.getInt("SELECT id FROM "
|
||||
id = database.getInt("SELECT id FROM "
|
||||
+ tablePrefix
|
||||
+ "users WHERE user = '"
|
||||
+ playerName + "'");
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "skills (user_id) VALUES (" + id + ")");
|
||||
mcMMO.database.write("INSERT INTO "
|
||||
database.write("INSERT INTO "
|
||||
+ tablePrefix
|
||||
+ "experience (user_id) VALUES (" + id
|
||||
+ ")");
|
||||
//Update the skill values
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET lastlogin = " + 0
|
||||
+ " WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "users SET party = '" + party
|
||||
+ "' WHERE id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "skills SET "
|
||||
+ " taming = taming+" + Misc.getInt(taming)
|
||||
@@ -254,7 +256,7 @@ public class SQLConversionTask implements Runnable {
|
||||
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
|
||||
+ ", fishing = fishing+" + Misc.getInt(fishing)
|
||||
+ " WHERE user_id = " + id);
|
||||
mcMMO.database.write("UPDATE "
|
||||
database.write("UPDATE "
|
||||
+ tablePrefix
|
||||
+ "experience SET "
|
||||
+ " taming = " + Misc.getInt(tamingXP)
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.util.Database;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@@ -16,17 +15,12 @@ public class SQLReconnect implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!Database.isConnected()) {
|
||||
Database.connect();
|
||||
if (Database.isConnected()) {
|
||||
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
|
||||
playerProfile.save(); //Save all profiles
|
||||
}
|
||||
if (Database.checkConnected()) {
|
||||
Users.saveAll(); //Save all profiles
|
||||
Users.clearAll(); //Clear the profiles
|
||||
|
||||
Users.clearUsers(); //Clear the profiles
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.gmail.nossr50.runnables;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
@@ -20,8 +20,8 @@ public class SaveTimer implements Runnable {
|
||||
int count = 1;
|
||||
BukkitScheduler bukkitScheduler = plugin.getServer().getScheduler();
|
||||
|
||||
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
|
||||
bukkitScheduler.scheduleSyncDelayedTask(plugin, new ProfileSaveTask(playerProfile), count);
|
||||
for (McMMOPlayer mcMMOPlayer : Users.getPlayers().values()) {
|
||||
bukkitScheduler.scheduleSyncDelayedTask(plugin, new ProfileSaveTask(mcMMOPlayer), count);
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,14 +22,14 @@ public class SkillMonitor implements Runnable {
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
/*
|
||||
* MONITOR SKILLS
|
||||
*/
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
if (skill.getTool() != null && skill.getAbility() != null) {
|
||||
Skills.monitorSkill(player, PP, curTime, skill);
|
||||
Skills.monitorSkill(player, profile, curTime, skill);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class SkillMonitor implements Runnable {
|
||||
*/
|
||||
for (AbilityType ability : AbilityType.values()) {
|
||||
if (ability.getCooldown() > 0 ) {
|
||||
Skills.watchCooldown(player, PP, curTime, ability);
|
||||
Skills.watchCooldown(player, profile, ability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ public class SpoutStart implements Runnable{
|
||||
|
||||
FileManager FM = SpoutManager.getFileManager();
|
||||
FM.addToPreLoginCache(plugin, SpoutStuff.getFiles());
|
||||
|
||||
//Handle spout players after a /reload
|
||||
SpoutStuff.reloadSpoutPlayers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gmail.nossr50.runnables;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class StickyPistonTracker implements Runnable {
|
||||
BlockPistonRetractEvent event;
|
||||
|
||||
public StickyPistonTracker(BlockPistonRetractEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Block originalBlock = event.getRetractLocation().getBlock();
|
||||
|
||||
if (originalBlock.getType() == Material.AIR && mcMMO.placeStore.isTrue(originalBlock)) {
|
||||
Block newBlock = originalBlock.getRelative(event.getDirection().getOppositeFace());
|
||||
|
||||
mcMMO.placeStore.setFalse(originalBlock);
|
||||
mcMMO.placeStore.setTrue(newBlock);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.gmail.nossr50.runnables.blockstoreconversion;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.Runnable;
|
||||
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class BlockStoreConversionMain implements Runnable {
|
||||
private int taskID, i;
|
||||
private org.bukkit.World world;
|
||||
BukkitScheduler scheduler;
|
||||
File dataDir;
|
||||
File[] xDirs;
|
||||
BlockStoreConversionXDirectory[] converters;
|
||||
|
||||
public BlockStoreConversionMain(org.bukkit.World world) {
|
||||
this.taskID = -1;
|
||||
this.world = world;
|
||||
this.scheduler = mcMMO.p.getServer().getScheduler();
|
||||
this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data");
|
||||
this.converters = new BlockStoreConversionXDirectory[HiddenConfig.getInstance().getConversionRate()];
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if(this.taskID >= 0)
|
||||
return;
|
||||
|
||||
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if(!this.dataDir.exists()) {
|
||||
softStop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.dataDir.isDirectory()) {
|
||||
this.dataDir.delete();
|
||||
softStop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.dataDir.listFiles().length <= 0) {
|
||||
this.dataDir.delete();
|
||||
softStop();
|
||||
return;
|
||||
}
|
||||
|
||||
this.xDirs = this.dataDir.listFiles();
|
||||
|
||||
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.xDirs.length); this.i++) {
|
||||
if(this.converters[this.i] == null)
|
||||
this.converters[this.i] = new BlockStoreConversionXDirectory();
|
||||
|
||||
this.converters[this.i].start(this.world, this.xDirs[this.i]);
|
||||
}
|
||||
|
||||
softStop();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if(this.taskID < 0)
|
||||
return;
|
||||
|
||||
this.scheduler.cancelTask(this.taskID);
|
||||
this.taskID = -1;
|
||||
}
|
||||
|
||||
public void softStop() {
|
||||
stop();
|
||||
|
||||
if(this.dataDir.exists() || this.dataDir.isDirectory()) {
|
||||
start();
|
||||
return;
|
||||
}
|
||||
|
||||
mcMMO.p.getLogger().info("Finished converting the storage for " + world.getName() + ".");
|
||||
|
||||
this.dataDir = null;
|
||||
this.xDirs = null;
|
||||
this.world = null;
|
||||
this.scheduler = null;
|
||||
this.converters = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.gmail.nossr50.runnables.blockstoreconversion;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.Runnable;
|
||||
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.config.HiddenConfig;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class BlockStoreConversionXDirectory implements Runnable {
|
||||
private int taskID, i;
|
||||
private org.bukkit.World world;
|
||||
BukkitScheduler scheduler;
|
||||
File dataDir;
|
||||
File[] zDirs;
|
||||
BlockStoreConversionZDirectory[] converters;
|
||||
|
||||
public BlockStoreConversionXDirectory() {
|
||||
this.taskID = -1;
|
||||
}
|
||||
|
||||
public void start(org.bukkit.World world, File dataDir) {
|
||||
this.world = world;
|
||||
this.scheduler = mcMMO.p.getServer().getScheduler();
|
||||
this.converters = new BlockStoreConversionZDirectory[HiddenConfig.getInstance().getConversionRate()];
|
||||
this.dataDir = dataDir;
|
||||
|
||||
if(this.taskID >= 0)
|
||||
return;
|
||||
|
||||
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if(!this.dataDir.exists()) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.dataDir.isDirectory()) {
|
||||
this.dataDir.delete();
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.dataDir.listFiles().length <= 0) {
|
||||
this.dataDir.delete();
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
this.zDirs = this.dataDir.listFiles();
|
||||
|
||||
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) {
|
||||
if(this.converters[this.i] == null)
|
||||
this.converters[this.i] = new BlockStoreConversionZDirectory();
|
||||
|
||||
this.converters[this.i].start(this.world, this.dataDir, this.zDirs[this.i]);
|
||||
}
|
||||
|
||||
stop();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if(this.taskID < 0)
|
||||
return;
|
||||
|
||||
this.scheduler.cancelTask(this.taskID);
|
||||
this.taskID = -1;
|
||||
|
||||
this.dataDir = null;
|
||||
this.zDirs = null;
|
||||
this.world = null;
|
||||
this.scheduler = null;
|
||||
this.converters = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package com.gmail.nossr50.runnables.blockstoreconversion;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.Runnable;
|
||||
import java.lang.String;
|
||||
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.blockmeta.ChunkletStore;
|
||||
import com.gmail.nossr50.util.blockmeta.PrimitiveChunkletStore;
|
||||
import com.gmail.nossr50.util.blockmeta.PrimitiveExChunkletStore;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.PrimitiveChunkStore;
|
||||
import com.gmail.nossr50.util.blockmeta.HashChunkletManager;
|
||||
import com.gmail.nossr50.util.blockmeta.chunkmeta.HashChunkManager;
|
||||
|
||||
public class BlockStoreConversionZDirectory implements Runnable {
|
||||
public int taskID, cx, cz, x, y, z, y2, xPos, zPos, cxPos, czPos;
|
||||
private String cxs, czs, chunkletName, chunkName;
|
||||
private org.bukkit.World world;
|
||||
private BukkitScheduler scheduler;
|
||||
private File xDir, dataDir;
|
||||
private HashChunkletManager manager;
|
||||
private HashChunkManager newManager;
|
||||
private ChunkletStore tempChunklet;
|
||||
private PrimitiveChunkletStore primitiveChunklet = null;
|
||||
private PrimitiveExChunkletStore primitiveExChunklet = null;
|
||||
private PrimitiveChunkStore currentChunk;
|
||||
private boolean[] oldArray, newArray;
|
||||
|
||||
public BlockStoreConversionZDirectory() {
|
||||
this.taskID = -1;
|
||||
}
|
||||
|
||||
public void start(org.bukkit.World world, File xDir, File dataDir) {
|
||||
this.world = world;
|
||||
this.scheduler = mcMMO.p.getServer().getScheduler();
|
||||
this.manager = new HashChunkletManager();
|
||||
this.newManager = (HashChunkManager) mcMMO.p.placeStore;
|
||||
this.dataDir = dataDir;
|
||||
this.xDir = xDir;
|
||||
|
||||
if(this.taskID >= 0)
|
||||
return;
|
||||
|
||||
this.taskID = this.scheduler.scheduleSyncDelayedTask(mcMMO.p, this, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if(!this.dataDir.exists()) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.dataDir.isDirectory()) {
|
||||
this.dataDir.delete();
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.dataDir.listFiles().length <= 0) {
|
||||
this.dataDir.delete();
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
this.cxs = this.xDir.getName();
|
||||
this.czs = this.dataDir.getName();
|
||||
this.cx = 0;
|
||||
this.cz = 0;
|
||||
|
||||
try {
|
||||
this.cx = Integer.parseInt(this.cxs);
|
||||
this.cz = Integer.parseInt(this.czs);
|
||||
}
|
||||
catch(Exception e) {
|
||||
this.dataDir.delete();
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
this.manager.loadChunk(this.cx, this.cz, this.world);
|
||||
|
||||
for(this.y = 0; this.y < (this.world.getMaxHeight() / 64); this.y++) {
|
||||
this.chunkletName = this.world.getName() + "," + this.cx + "," + this.cz + "," + this.y;
|
||||
this.tempChunklet = this.manager.store.get(this.chunkletName);
|
||||
if(this.tempChunklet instanceof PrimitiveChunkletStore)
|
||||
this.primitiveChunklet = (PrimitiveChunkletStore) this.tempChunklet;
|
||||
else if(this.tempChunklet instanceof PrimitiveExChunkletStore)
|
||||
this.primitiveExChunklet = (PrimitiveExChunkletStore) this.tempChunklet;
|
||||
if(this.tempChunklet == null) {
|
||||
continue;
|
||||
} else {
|
||||
this.chunkName = this.world.getName() + "," + this.cx + "," + this.cz;
|
||||
this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName);
|
||||
|
||||
if(this.currentChunk != null) {
|
||||
this.xPos = this.cx * 16;
|
||||
this.zPos = this.cz * 16;
|
||||
|
||||
for(this.x = 0; this.x < 16; this.x++) {
|
||||
for(this.z = 0; this.z < 16; this.z++) {
|
||||
this.cxPos = this.xPos + this.x;
|
||||
this.czPos = this.zPos + this.z;
|
||||
|
||||
for(this.y2 = (64 * this.y); this.y2 < (64 * this.y + 64); this.y2++) {
|
||||
try {
|
||||
if(!this.manager.isTrue(this.cxPos, this.y2, this.czPos, this.world))
|
||||
continue;
|
||||
|
||||
this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world);
|
||||
}
|
||||
catch(Exception e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
this.newManager.setTrue(this.cx * 16, 0, this.cz * 16, this.world);
|
||||
this.newManager.setFalse(this.cx * 16, 0, this.cz * 16, this.world);
|
||||
this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName);
|
||||
|
||||
for(this.x = 0; this.x < 16; this.x++) {
|
||||
for(this.z = 0; this.z < 16; this.z++) {
|
||||
if(this.primitiveChunklet != null)
|
||||
this.oldArray = this.primitiveChunklet.store[x][z];
|
||||
if(this.primitiveExChunklet != null)
|
||||
this.oldArray = this.primitiveExChunklet.store[x][z];
|
||||
else
|
||||
return;
|
||||
this.newArray = this.currentChunk.store[x][z];
|
||||
if(this.oldArray.length < 64)
|
||||
return;
|
||||
else if(this.newArray.length < ((this.y * 64) + 64))
|
||||
return;
|
||||
System.arraycopy(this.oldArray, 0, this.newArray, (this.y * 64), 64);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.manager.unloadChunk(this.cx, this.cz, this.world);
|
||||
this.newManager.unloadChunk(this.cx, this.cz, this.world);
|
||||
|
||||
for(File yFile : dataDir.listFiles()) {
|
||||
if(!yFile.exists())
|
||||
continue;
|
||||
|
||||
yFile.delete();
|
||||
}
|
||||
|
||||
stop();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if(this.taskID < 0)
|
||||
return;
|
||||
|
||||
this.scheduler.cancelTask(taskID);
|
||||
this.taskID = -1;
|
||||
|
||||
this.cxs = null;
|
||||
this.czs = null;
|
||||
this.chunkletName = null;
|
||||
this.chunkName = null;
|
||||
this.manager = null;
|
||||
this.xDir = null;
|
||||
this.dataDir = null;
|
||||
this.tempChunklet = null;
|
||||
this.primitiveChunklet = null;
|
||||
this.primitiveExChunklet = null;
|
||||
this.currentChunk = null;
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,9 @@ public abstract class AcrobaticsEventHandler {
|
||||
* @return true if the damage is fatal, false otherwise
|
||||
*/
|
||||
protected boolean isFatal(int damage) {
|
||||
if(player == null)
|
||||
return true;
|
||||
|
||||
if (player.getHealth() - damage < 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.acrobatics;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
@@ -26,13 +27,25 @@ public class AcrobaticsManager {
|
||||
* @param event The event to check
|
||||
*/
|
||||
public void rollCheck(EntityDamageEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if (!permissionInstance.roll(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(Config.getInstance().getAcrobaticsAFKDisabled() && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
RollEventHandler eventHandler = new RollEventHandler(this, event);
|
||||
|
||||
if (Acrobatics.getRandom().nextInt(1000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
int randomChance = 1000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Acrobatics.getRandom().nextInt(randomChance) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER);
|
||||
@@ -48,13 +61,22 @@ public class AcrobaticsManager {
|
||||
* @param event The event to check
|
||||
*/
|
||||
public void dodgeCheck(EntityDamageEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if (!permissionInstance.dodge(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
|
||||
|
||||
if (Acrobatics.getRandom().nextInt(4000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
int randomChance = 4000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Acrobatics.getRandom().nextInt(randomChance) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.sendAbilityMessage();
|
||||
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
|
||||
|
||||
@@ -16,10 +16,12 @@ public class DodgeEventHandler extends AcrobaticsEventHandler {
|
||||
calculateModifiedDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Acrobatics.DODGE_MAX_BONUS_LEVEL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateModifiedDamage() {
|
||||
int modifiedDamage = damage / 2;
|
||||
|
||||
@@ -30,15 +32,24 @@ public class DodgeEventHandler extends AcrobaticsEventHandler {
|
||||
this.modifiedDamage = modifiedDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modifyEventDamage() {
|
||||
event.setDamage(modifiedDamage);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendAbilityMessage() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processXPGain(int xp) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
PlayerProfile profile = manager.getProfile();
|
||||
|
||||
if (System.currentTimeMillis() >= profile.getRespawnATS() + 5) {
|
||||
|
||||
@@ -21,6 +21,7 @@ public class RollEventHandler extends AcrobaticsEventHandler {
|
||||
calculateModifiedDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateSkillModifier() {
|
||||
int skillModifer = manager.getSkillLevel();
|
||||
|
||||
@@ -32,6 +33,7 @@ public class RollEventHandler extends AcrobaticsEventHandler {
|
||||
this.skillModifier = skillModifer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void calculateModifiedDamage() {
|
||||
int modifiedDamage = damage - damageThreshold;
|
||||
|
||||
@@ -42,6 +44,7 @@ public class RollEventHandler extends AcrobaticsEventHandler {
|
||||
this.modifiedDamage = modifiedDamage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void modifyEventDamage() {
|
||||
event.setDamage(modifiedDamage);
|
||||
|
||||
@@ -51,7 +54,11 @@ public class RollEventHandler extends AcrobaticsEventHandler {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void sendAbilityMessage() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if (isGraceful) {
|
||||
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
|
||||
}
|
||||
@@ -61,7 +68,11 @@ public class RollEventHandler extends AcrobaticsEventHandler {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void processXPGain(int xpGain) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
|
||||
}
|
||||
|
||||
@@ -69,6 +80,9 @@ public class RollEventHandler extends AcrobaticsEventHandler {
|
||||
* Check if this is a graceful roll.
|
||||
*/
|
||||
private void isGracefulRoll() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if (Permissions.getInstance().gracefulRoll(player)) {
|
||||
this.isGraceful = player.isSneaking();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,11 @@ public class ArcheryManager {
|
||||
public ArcheryManager (Player player) {
|
||||
this.player = player;
|
||||
this.profile = Users.getProfile(player);
|
||||
|
||||
//Compatibility with Citizens, Citizens NPCs won't create a profile so we'll check for it here
|
||||
if(this.profile == null)
|
||||
return;
|
||||
|
||||
this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY);
|
||||
this.permissionsInstance = Permissions.getInstance();
|
||||
}
|
||||
@@ -28,13 +33,25 @@ public class ArcheryManager {
|
||||
* @param livingEntity Entity damaged by the arrow
|
||||
*/
|
||||
public void trackArrows(LivingEntity livingEntity) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.trackArrows(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
|
||||
|
||||
if (Archery.getRandom().nextInt(1000) < eventHandler.skillModifier) {
|
||||
int randomChance = 1000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Archery.getRandom().nextInt(randomChance) < eventHandler.skillModifier) {
|
||||
eventHandler.addToTracker();
|
||||
}
|
||||
}
|
||||
@@ -46,13 +63,25 @@ public class ArcheryManager {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public void dazeCheck(Player defender, EntityDamageEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.daze(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
||||
|
||||
if (Archery.getRandom().nextInt(2000) < eventHandler.skillModifier) {
|
||||
int randomChance = 2000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Archery.getRandom().nextInt(randomChance) < eventHandler.skillModifier) {
|
||||
eventHandler.handleDazeEffect();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
@@ -64,6 +93,12 @@ public class ArcheryManager {
|
||||
* @param event The event to modify.
|
||||
*/
|
||||
public void bonusDamage(EntityDamageEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.archeryBonus(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,15 @@ import org.bukkit.entity.LivingEntity;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
public class TrackedEntity {
|
||||
public class TrackedEntity implements Runnable {
|
||||
private LivingEntity livingEntity;
|
||||
private int arrowCount;
|
||||
private int previousTicksLived;
|
||||
private int taskId;
|
||||
|
||||
public TrackedEntity(LivingEntity livingEntity) {
|
||||
this.livingEntity = livingEntity;
|
||||
new CheckTrackedEntityExistence(this);
|
||||
taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
||||
}
|
||||
|
||||
//LivingEntity.isDead() isn't a reliable way to know if an entity is still active
|
||||
@@ -23,10 +24,9 @@ public class TrackedEntity {
|
||||
if (currentTicksLived == previousTicksLived) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
previousTicksLived = currentTicksLived;
|
||||
return true;
|
||||
}
|
||||
|
||||
previousTicksLived = currentTicksLived;
|
||||
return true;
|
||||
}
|
||||
|
||||
public LivingEntity getLivingEntity() {
|
||||
@@ -41,23 +41,11 @@ public class TrackedEntity {
|
||||
arrowCount++;
|
||||
}
|
||||
|
||||
private class CheckTrackedEntityExistence implements Runnable {
|
||||
private TrackedEntity trackedEntity;
|
||||
private int taskId;
|
||||
|
||||
public CheckTrackedEntityExistence(TrackedEntity trackedEntity) {
|
||||
this.trackedEntity = trackedEntity;
|
||||
|
||||
//Check if the entity is still active every 10 minutes
|
||||
taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!trackedEntity.isActive()) {
|
||||
Archery.removeFromTracker(trackedEntity);
|
||||
Bukkit.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isActive()) {
|
||||
Archery.removeFromTracker(this);
|
||||
Bukkit.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ public class Axes {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void axesBonus(Player attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker == null)
|
||||
return;
|
||||
|
||||
final int MAX_BONUS = 4;
|
||||
|
||||
/* Add 1 DMG for every 50 skill levels */
|
||||
@@ -49,6 +52,9 @@ public class Axes {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void axeCriticalCheck(Player attacker, EntityDamageByEntityEvent event) {
|
||||
if(attacker == null)
|
||||
return;
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (entity instanceof Tameable) {
|
||||
@@ -71,11 +77,17 @@ public class Axes {
|
||||
final double PVP_MODIFIER = 1.5;
|
||||
final int PVE_MODIFIER = 2;
|
||||
|
||||
PlayerProfile PPa = Users.getProfile(attacker);
|
||||
int skillLevel = PPa.getSkillLevel(SkillType.AXES);
|
||||
PlayerProfile attackerProfile = Users.getProfile(attacker);
|
||||
int skillLevel = attackerProfile.getSkillLevel(SkillType.AXES);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(2000) <= skillCheck && !entity.isDead()){
|
||||
int randomChance = 2000;
|
||||
|
||||
if (attacker.hasPermission("mcmmo.perks.lucky.axes")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextInt(randomChance) <= skillCheck && !entity.isDead()){
|
||||
int damage = event.getDamage();
|
||||
|
||||
if (entity instanceof Player){
|
||||
@@ -96,7 +108,10 @@ public class Axes {
|
||||
* @param target The defending entity
|
||||
* @param event The event to modify
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void impact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||
if(attacker == null)
|
||||
return;
|
||||
|
||||
/*
|
||||
* TODO: Finish this skill. The idea is you will greatly damage an opponents armor.
|
||||
@@ -104,17 +119,18 @@ public class Axes {
|
||||
*/
|
||||
if (target instanceof Player) {
|
||||
Player targetPlayer = (Player) target;
|
||||
short durabilityDamage = 5; //Start with 5 durability damage
|
||||
short durabilityDamage = 1; //Start with 1 durability damage
|
||||
|
||||
/* Every 30 Skill Levels you gain 1 durability damage */
|
||||
durabilityDamage += Users.getProfile(attacker).getSkillLevel(SkillType.AXES)/30;
|
||||
durabilityDamage += Users.getProfile(attacker).getSkillLevel(SkillType.AXES)/50;
|
||||
|
||||
if (!hasArmor(targetPlayer)) {
|
||||
applyGreaterImpact(attacker, target, event);
|
||||
}
|
||||
else {
|
||||
for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) {
|
||||
armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece
|
||||
if(Math.random() * 100 > 75)
|
||||
armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece
|
||||
}
|
||||
targetPlayer.updateInventory();
|
||||
}
|
||||
@@ -132,6 +148,9 @@ public class Axes {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
private static void applyGreaterImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||
if(attacker == null)
|
||||
return;
|
||||
|
||||
final int GREATER_IMPACT_CHANCE = 25;
|
||||
final double GREATER_IMPACT_MULTIPLIER = 1.5;
|
||||
|
||||
@@ -139,7 +158,13 @@ public class Axes {
|
||||
return;
|
||||
}
|
||||
|
||||
if (random.nextInt(100) <= GREATER_IMPACT_CHANCE) {
|
||||
int randomChance = 100;
|
||||
|
||||
if (attacker.hasPermission("mcmmo.perks.lucky.axes")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextInt(randomChance) <= GREATER_IMPACT_CHANCE) {
|
||||
event.setDamage(event.getDamage() + 2);
|
||||
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
|
||||
attacker.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
|
||||
@@ -153,6 +178,9 @@ public class Axes {
|
||||
* @return true if the player has armor, false otherwise
|
||||
*/
|
||||
private static boolean hasArmor(Player player) {
|
||||
if(player == null)
|
||||
return false;
|
||||
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
|
||||
if (inventory.getBoots() != null || inventory.getChestplate() != null || inventory.getHelmet() != null || inventory.getLeggings() != null) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.Random;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
@@ -83,6 +82,9 @@ public class BlastMining {
|
||||
* @param event Event whose explosion is being processed
|
||||
*/
|
||||
public static void dropProcessing(Player player, EntityExplodeEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
final int RANK_1_LEVEL = 125;
|
||||
final int RANK_2_LEVEL = 250;
|
||||
final int RANK_3_LEVEL = 375;
|
||||
@@ -173,6 +175,9 @@ public class BlastMining {
|
||||
* @param event Event whose explosion radius is being changed
|
||||
*/
|
||||
public static void biggerBombs(Player player, ExplosionPrimeEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
final int RANK_1_LEVEL = 250;
|
||||
final int RANK_2_LEVEL = 500;
|
||||
final int RANK_3_LEVEL = 750;
|
||||
@@ -211,6 +216,9 @@ public class BlastMining {
|
||||
* @param event Event whose explosion damage is being reduced
|
||||
*/
|
||||
public static void demolitionsExpertise(Player player, EntityDamageEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
final int RANK_1_LEVEL = 500;
|
||||
final int RANK_2_LEVEL = 750;
|
||||
final int RANK_3_LEVEL = 1000;
|
||||
@@ -243,9 +251,12 @@ public class BlastMining {
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void detonate(PlayerInteractEvent event, Player player, mcMMO plugin) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if (PP.getSkillLevel(SkillType.MINING) < 125)
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile.getSkillLevel(SkillType.MINING) < 125)
|
||||
return;
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
@@ -280,8 +291,8 @@ public class BlastMining {
|
||||
AbilityType ability = AbilityType.BLAST_MINING;
|
||||
|
||||
/* Check Cooldown */
|
||||
if (!Skills.cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
|
||||
if (!Skills.cooldownOver(profile.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + Skills.calculateTimeLeft(profile.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -304,7 +315,7 @@ public class BlastMining {
|
||||
/* Disable the original one */
|
||||
block.setType(Material.AIR);
|
||||
|
||||
PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
|
||||
PP.setAbilityInformed(ability, false);
|
||||
profile.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
|
||||
profile.setAbilityInformed(ability, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,14 @@ public class Excavation {
|
||||
* @param player The player who broke the block
|
||||
*/
|
||||
public static void excavationProcCheck(Block block, Player player) {
|
||||
Material type = block.getType();
|
||||
Location loc = block.getLocation();
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int skillLevel = PP.getSkillLevel(SkillType.EXCAVATION);
|
||||
Material type = block.getType();
|
||||
Location location = block.getLocation();
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int skillLevel = profile.getSkillLevel(SkillType.EXCAVATION);
|
||||
ArrayList<ItemStack> is = new ArrayList<ItemStack>();
|
||||
|
||||
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
|
||||
@@ -91,7 +94,13 @@ public class Excavation {
|
||||
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()) {
|
||||
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
|
||||
int randomChance = 100;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.excavation")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
|
||||
xp += treasure.getXp();
|
||||
is.add(treasure.getDrop());
|
||||
}
|
||||
@@ -101,12 +110,12 @@ public class Excavation {
|
||||
//Drop items
|
||||
for (ItemStack x : is) {
|
||||
if (x != null) {
|
||||
Misc.dropItem(loc, x);
|
||||
Misc.dropItem(location, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, PP, SkillType.EXCAVATION, xp);
|
||||
Skills.xpProcessing(player, profile, SkillType.EXCAVATION, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,9 +125,12 @@ public class Excavation {
|
||||
* @param block The block to check
|
||||
*/
|
||||
public static void gigaDrillBreaker(Player player, Block block) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), Config.getInstance().getAbilityToolDamage());
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(block)) {
|
||||
if (!mcMMO.placeStore.isTrue(block) && !Misc.blockBreakSimulate(block, player, true)) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
|
||||
401
src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java
Normal file → Executable file
401
src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java
Normal file → Executable file
@@ -17,6 +17,8 @@ import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Wool;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftSkeleton;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
@@ -37,11 +39,11 @@ public class Fishing {
|
||||
/**
|
||||
* Get the player's current fishing loot tier.
|
||||
*
|
||||
* @param PP The profile of the player
|
||||
* @param profile The profile of the player
|
||||
* @return the player's current fishing rank
|
||||
*/
|
||||
public static int getFishingLootTier(PlayerProfile PP) {
|
||||
int level = PP.getSkillLevel(SkillType.FISHING);
|
||||
public static int getFishingLootTier(PlayerProfile profile) {
|
||||
int level = profile.getSkillLevel(SkillType.FISHING);
|
||||
int fishingTier;
|
||||
|
||||
if (level >= Config.getInstance().getFishingTierLevelsTier5()) {
|
||||
@@ -70,11 +72,14 @@ public class Fishing {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
private static void getFishingResults(Player player, PlayerFishEvent event) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
|
||||
Item theCatch = (Item) event.getCaught();
|
||||
|
||||
switch (getFishingLootTier(PP)) {
|
||||
switch (getFishingLootTier(profile)) {
|
||||
case 1:
|
||||
rewards = TreasuresConfig.getInstance().fishingRewardsTier1;
|
||||
break;
|
||||
@@ -102,8 +107,14 @@ public class Fishing {
|
||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
|
||||
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
||||
|
||||
if (random.nextDouble() * 100 <= treasure.getDropChance()) {
|
||||
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
|
||||
int randomChance = 100;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
|
||||
Users.getPlayer(player).addXP(SkillType.FISHING, treasure.getXp());
|
||||
theCatch.setItemStack(treasure.getDrop());
|
||||
}
|
||||
}
|
||||
@@ -117,7 +128,7 @@ public class Fishing {
|
||||
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, PP, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
||||
Skills.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,7 +138,10 @@ public class Fishing {
|
||||
*/
|
||||
public static void processResults(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
getFishingResults(player, event);
|
||||
Item theCatch = (Item) event.getCaught();
|
||||
@@ -138,20 +152,26 @@ public class Fishing {
|
||||
ItemStack fishingResults = theCatch.getItemStack();
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
|
||||
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
|
||||
if (random.nextInt(100) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
|
||||
|
||||
if (ItemChecks.isEnchantable(fishingResults)) {
|
||||
int randomChance = 100;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
|
||||
for (Enchantment newEnchant : Enchantment.values()) {
|
||||
if (newEnchant.canEnchantItem(fishingResults)) {
|
||||
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
|
||||
|
||||
for (Enchantment oldEnchant : resultEnchantments.keySet()) {
|
||||
if (oldEnchant.conflictsWith(newEnchant)) {
|
||||
return;
|
||||
}
|
||||
if (oldEnchant.conflictsWith(newEnchant))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Actual chance to have an enchantment is related to your fishing skill */
|
||||
if (random.nextInt(15) < Fishing.getFishingLootTier(PP)) {
|
||||
if (random.nextInt(15) < Fishing.getFishingLootTier(profile)) {
|
||||
enchanted = true;
|
||||
int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
|
||||
|
||||
@@ -159,6 +179,9 @@ public class Fishing {
|
||||
randomEnchantLevel = newEnchant.getStartLevel();
|
||||
}
|
||||
|
||||
if(randomEnchantLevel >= 1000)
|
||||
continue;
|
||||
|
||||
fishingResults.addEnchantment(newEnchant, randomEnchantLevel);
|
||||
}
|
||||
}
|
||||
@@ -178,160 +201,254 @@ public class Fishing {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public static void shakeMob(PlayerFishEvent event) {
|
||||
final int DROP_NUMBER = random.nextInt(100);
|
||||
int randomChance = 100;
|
||||
|
||||
if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) {
|
||||
randomChance = (int) (randomChance * 1.25);
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
final PlayerProfile profile = Users.getProfile(player);
|
||||
int lootTier = getFishingLootTier(profile);
|
||||
|
||||
int dropChance = getShakeChance(lootTier);
|
||||
|
||||
if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) {
|
||||
dropChance = (int) (dropChance * 1.25); //With lucky perk on max level tier, its 100%
|
||||
}
|
||||
|
||||
final int DROP_CHANCE = random.nextInt(100);
|
||||
final int DROP_NUMBER = random.nextInt(randomChance) + 1;
|
||||
|
||||
LivingEntity le = (LivingEntity) event.getCaught();
|
||||
EntityType type = le.getType();
|
||||
Location loc = le.getLocation();
|
||||
Location location = le.getLocation();
|
||||
|
||||
switch (type) {
|
||||
case BLAZE:
|
||||
Misc.dropItem(loc, new ItemStack(Material.BLAZE_ROD));
|
||||
break;
|
||||
if (DROP_CHANCE < dropChance) {
|
||||
|
||||
case CAVE_SPIDER:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.SPIDER_EYE));
|
||||
}
|
||||
else {
|
||||
Misc.dropItem(loc, new ItemStack(Material.STRING));
|
||||
}
|
||||
break;
|
||||
switch (type) {
|
||||
case BLAZE:
|
||||
Misc.dropItem(location, new ItemStack(Material.BLAZE_ROD));
|
||||
break;
|
||||
|
||||
case CHICKEN:
|
||||
if (DROP_NUMBER > 66) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.FEATHER));
|
||||
}
|
||||
else if (DROP_NUMBER > 33) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.RAW_CHICKEN));
|
||||
}
|
||||
else {
|
||||
Misc.dropItem(loc, new ItemStack(Material.EGG));
|
||||
}
|
||||
break;
|
||||
case CAVE_SPIDER:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.STRING));
|
||||
}
|
||||
break;
|
||||
|
||||
case COW:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.MILK_BUCKET));
|
||||
}
|
||||
else if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.LEATHER));
|
||||
}
|
||||
else {
|
||||
Misc.dropItem(loc, new ItemStack(Material.RAW_BEEF));
|
||||
}
|
||||
break;
|
||||
case CHICKEN:
|
||||
if (DROP_NUMBER > 66) {
|
||||
Misc.dropItem(location, new ItemStack(Material.FEATHER));
|
||||
} else if (DROP_NUMBER > 33) {
|
||||
Misc.dropItem(location, new ItemStack(Material.RAW_CHICKEN));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.EGG));
|
||||
}
|
||||
break;
|
||||
|
||||
case CREEPER:
|
||||
Misc.dropItem(loc, new ItemStack(Material.SULPHUR));
|
||||
break;
|
||||
case COW:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(location, new ItemStack(Material.MILK_BUCKET));
|
||||
} else if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(location, new ItemStack(Material.LEATHER));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.RAW_BEEF));
|
||||
}
|
||||
break;
|
||||
|
||||
case ENDERMAN:
|
||||
Misc.dropItem(loc, new ItemStack(Material.ENDER_PEARL));
|
||||
break;
|
||||
case CREEPER:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 4));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
||||
}
|
||||
break;
|
||||
|
||||
case GHAST:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.SULPHUR));
|
||||
}
|
||||
else {
|
||||
Misc.dropItem(loc, new ItemStack(Material.GHAST_TEAR));
|
||||
}
|
||||
break;
|
||||
case ENDERMAN:
|
||||
Misc.dropItem(location, new ItemStack(Material.ENDER_PEARL));
|
||||
break;
|
||||
|
||||
case MAGMA_CUBE:
|
||||
Misc.dropItem(loc, new ItemStack(Material.MAGMA_CREAM));
|
||||
break;
|
||||
case GHAST:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.GHAST_TEAR));
|
||||
}
|
||||
break;
|
||||
|
||||
case MUSHROOM_COW:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.MILK_BUCKET));
|
||||
}
|
||||
else if (DROP_NUMBER > 98) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.MUSHROOM_SOUP));
|
||||
}
|
||||
else if (DROP_NUMBER > 66) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.LEATHER));
|
||||
}
|
||||
else if (DROP_NUMBER > 33) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.RAW_BEEF));
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(loc, new ItemStack(Material.RED_MUSHROOM), 3);
|
||||
}
|
||||
break;
|
||||
case IRON_GOLEM:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
|
||||
} else if (DROP_NUMBER > 90) {
|
||||
Misc.dropItem(location, new ItemStack(Material.IRON_INGOT));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.RED_ROSE));
|
||||
}
|
||||
break;
|
||||
|
||||
case PIG:
|
||||
Misc.dropItem(loc, new ItemStack(Material.PORK));
|
||||
break;
|
||||
case MAGMA_CUBE:
|
||||
Misc.dropItem(location, new ItemStack(Material.MAGMA_CREAM));
|
||||
break;
|
||||
|
||||
case PIG_ZOMBIE:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
|
||||
}
|
||||
else {
|
||||
Misc.dropItem(loc, new ItemStack(Material.GOLD_NUGGET));
|
||||
}
|
||||
break;
|
||||
case MUSHROOM_COW:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(location, new ItemStack(Material.MILK_BUCKET));
|
||||
} else if (DROP_NUMBER > 98) {
|
||||
Misc.dropItem(location, new ItemStack(Material.MUSHROOM_SOUP));
|
||||
} else if (DROP_NUMBER > 66) {
|
||||
Misc.dropItem(location, new ItemStack(Material.LEATHER));
|
||||
} else if (DROP_NUMBER > 33) {
|
||||
Misc.dropItem(location, new ItemStack(Material.RAW_BEEF));
|
||||
} else {
|
||||
Misc.dropItems(location, new ItemStack(Material.RED_MUSHROOM), 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case SHEEP:
|
||||
Sheep sheep = (Sheep) le;
|
||||
case PIG:
|
||||
Misc.dropItem(location, new ItemStack(Material.PORK));
|
||||
break;
|
||||
|
||||
if (!sheep.isSheared()) {
|
||||
Wool wool = new Wool();
|
||||
wool.setColor(sheep.getColor());
|
||||
case PIG_ZOMBIE:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.GOLD_NUGGET));
|
||||
}
|
||||
break;
|
||||
|
||||
ItemStack theWool = wool.toItemStack();
|
||||
theWool.setAmount(1 + random.nextInt(6));
|
||||
case SHEEP:
|
||||
final Sheep sheep = (Sheep) le;
|
||||
|
||||
Misc.dropItem(loc, theWool);
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
break;
|
||||
if (!sheep.isSheared()) {
|
||||
final Wool wool = new Wool();
|
||||
wool.setColor(sheep.getColor());
|
||||
|
||||
case SKELETON:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.BONE));
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(loc, new ItemStack(Material.ARROW), 3);
|
||||
}
|
||||
break;
|
||||
final ItemStack theWool = wool.toItemStack();
|
||||
theWool.setAmount(1 + random.nextInt(6));
|
||||
|
||||
case SLIME:
|
||||
Misc.dropItem(loc, new ItemStack(Material.SLIME_BALL));
|
||||
break;
|
||||
Misc.dropItem(location, theWool);
|
||||
sheep.setSheared(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case SNOWMAN:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.PUMPKIN));
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(loc, new ItemStack(Material.SNOW_BALL), 5);
|
||||
}
|
||||
break;
|
||||
case SKELETON:
|
||||
if (((CraftSkeleton) le).getHandle().getSkeletonType() == 1) {
|
||||
if (DROP_NUMBER > 97) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 1));
|
||||
} else if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(location, new ItemStack(Material.BONE));
|
||||
} else {
|
||||
Misc.dropItems(location, new ItemStack(Material.COAL), 3);
|
||||
}
|
||||
} else {
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM));
|
||||
} else if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(location, new ItemStack(Material.BONE));
|
||||
} else {
|
||||
Misc.dropItems(location, new ItemStack(Material.ARROW), 3);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SPIDER:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(loc, new ItemStack(Material.SPIDER_EYE));
|
||||
}
|
||||
else {
|
||||
Misc.dropItem(loc, new ItemStack(Material.STRING));
|
||||
}
|
||||
break;
|
||||
case SLIME:
|
||||
Misc.dropItem(location, new ItemStack(Material.SLIME_BALL));
|
||||
break;
|
||||
|
||||
case SQUID:
|
||||
Misc.dropItem(loc, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
|
||||
break;
|
||||
case SNOWMAN:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
|
||||
} else {
|
||||
Misc.dropItems(location, new ItemStack(Material.SNOW_BALL), 5);
|
||||
}
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
Misc.dropItem(loc, new ItemStack(Material.ROTTEN_FLESH));
|
||||
break;
|
||||
case SPIDER:
|
||||
if (DROP_NUMBER > 50) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.STRING));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
case SQUID:
|
||||
Misc.dropItem(location, new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x0));
|
||||
break;
|
||||
|
||||
case WITCH:
|
||||
final int DROP_NUMBER_2 = random.nextInt(randomChance) + 1;
|
||||
if (DROP_NUMBER > 97) {
|
||||
if (DROP_NUMBER_2 > 66) {
|
||||
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8197));
|
||||
} else if (DROP_NUMBER_2 > 33) {
|
||||
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8195));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8194));
|
||||
}
|
||||
} else {
|
||||
if (DROP_NUMBER_2 > 88) {
|
||||
Misc.dropItem(location, new ItemStack(Material.GLASS_BOTTLE));
|
||||
} else if (DROP_NUMBER_2 > 75) {
|
||||
Misc.dropItem(location, new ItemStack(Material.GLOWSTONE_DUST));
|
||||
} else if (DROP_NUMBER_2 > 63) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
||||
} else if (DROP_NUMBER_2 > 50) {
|
||||
Misc.dropItem(location, new ItemStack(Material.REDSTONE));
|
||||
} else if (DROP_NUMBER_2 > 38) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
|
||||
} else if (DROP_NUMBER_2 > 25) {
|
||||
Misc.dropItem(location, new ItemStack(Material.STICK));
|
||||
} else if (DROP_NUMBER_2 > 13) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SUGAR));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.POTION));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ZOMBIE:
|
||||
if (DROP_NUMBER > 99) {
|
||||
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 2));
|
||||
} else {
|
||||
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Combat.dealDamage(le, 1);
|
||||
}
|
||||
/**
|
||||
* Gets chance of shake success.
|
||||
*
|
||||
* @param rank Treasure hunter rank
|
||||
* @return The chance of a successful shake
|
||||
*/
|
||||
public static int getShakeChance(int lootTier) {
|
||||
switch (lootTier) {
|
||||
case 1:
|
||||
return Config.getInstance().getShakeChanceRank1();
|
||||
|
||||
case 2:
|
||||
return Config.getInstance().getShakeChanceRank2();
|
||||
|
||||
case 3:
|
||||
return Config.getInstance().getShakeChanceRank3();
|
||||
|
||||
case 4:
|
||||
return Config.getInstance().getShakeChanceRank4();
|
||||
|
||||
case 5:
|
||||
return Config.getInstance().getShakeChanceRank5();
|
||||
|
||||
default:
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.gmail.nossr50.config.mods.CustomBlocksConfig;
|
||||
import com.gmail.nossr50.datatypes.AbilityType;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.runnables.GreenThumbTimer;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -61,6 +62,11 @@ public class Herbalism {
|
||||
}
|
||||
else if (Config.getInstance().getHerbalismGreenThumbCobbleToMossy() && type == Material.COBBLESTONE) {
|
||||
block.setType(Material.MOSSY_COBBLESTONE);
|
||||
// Don't award double drops to mossified cobblestone
|
||||
mcMMO.placeStore.setTrue(block);
|
||||
}
|
||||
else if (Config.getInstance().getHerbalismGreenThumbCobbleWallToMossyWall() && type == Material.COBBLE_WALL) {
|
||||
block.setData((byte) 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,15 +80,18 @@ public class Herbalism {
|
||||
* @param plugin mcMMO plugin instance
|
||||
*/
|
||||
public static void herbalismProcCheck(final Block block, Player player, BlockBreakEvent event, mcMMO plugin) {
|
||||
final PlayerProfile PP = Users.getProfile(player);
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
final PlayerProfile profile = Users.getProfile(player);
|
||||
final int MAX_BONUS_LEVEL = 1000;
|
||||
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
|
||||
int id = block.getTypeId();
|
||||
Material type = block.getType();
|
||||
|
||||
Byte data = block.getData();
|
||||
Location loc = block.getLocation();
|
||||
Location location = block.getLocation();
|
||||
Material mat = null;
|
||||
|
||||
int xp = 0;
|
||||
@@ -91,6 +100,12 @@ public class Herbalism {
|
||||
|
||||
boolean customPlant = false;
|
||||
|
||||
int randomChance = 1000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case BROWN_MUSHROOM:
|
||||
case RED_MUSHROOM:
|
||||
@@ -106,7 +121,7 @@ public class Herbalism {
|
||||
if (b.getType().equals(Material.CACTUS)) {
|
||||
mat = Material.CACTUS;
|
||||
if (!mcMMO.placeStore.isTrue(b)) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) {
|
||||
catciDrops++;
|
||||
}
|
||||
xp += Config.getInstance().getHerbalismXPCactus();
|
||||
@@ -137,6 +152,10 @@ public class Herbalism {
|
||||
if (data == (byte) 0x3) {
|
||||
mat = Material.NETHER_STALK;
|
||||
xp = Config.getInstance().getHerbalismXPNetherWart();
|
||||
|
||||
if (Permissions.getInstance().greenThumbNetherwart(player)) {
|
||||
greenThumbWheat(block, player, event, plugin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -162,7 +181,7 @@ public class Herbalism {
|
||||
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
||||
mat = Material.SUGAR_CANE;
|
||||
if (!mcMMO.placeStore.isTrue(b)) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) {
|
||||
caneDrops++;
|
||||
}
|
||||
xp += Config.getInstance().getHerbalismXPSugarCane();
|
||||
@@ -184,6 +203,41 @@ public class Herbalism {
|
||||
xp = Config.getInstance().getHerbalismXPLilyPads();
|
||||
}
|
||||
break;
|
||||
|
||||
case COCOA:
|
||||
if ((((byte) data) & 0x8) == 0x8) {
|
||||
mat = Material.COCOA;
|
||||
xp = Config.getInstance().getHerbalismXPCocoa();
|
||||
|
||||
|
||||
if (Permissions.getInstance().greenThumbCocoa(player)) {
|
||||
greenThumbWheat(block, player, event, plugin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CARROT:
|
||||
if (data == CropState.RIPE.getData()) {
|
||||
mat = Material.CARROT;
|
||||
xp = Config.getInstance().getHerbalismXPCarrot();
|
||||
|
||||
|
||||
if (Permissions.getInstance().greenThumbCarrots(player)) {
|
||||
greenThumbWheat(block, player, event, plugin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POTATO:
|
||||
if (data == CropState.RIPE.getData()) {
|
||||
mat = Material.POTATO;
|
||||
xp = Config.getInstance().getHerbalismXPPotato();
|
||||
|
||||
if (Permissions.getInstance().greenThumbPotatoes(player)) {
|
||||
greenThumbWheat(block, player, event, plugin);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) {
|
||||
@@ -204,91 +258,136 @@ public class Herbalism {
|
||||
is = new ItemStack(ModChecks.getCustomBlock(block).getItemDrop());
|
||||
}
|
||||
else {
|
||||
is = new ItemStack(mat);
|
||||
if (mat == Material.COCOA) {
|
||||
is = new ItemStack(Material.INK_SACK, 1, (short) 3);
|
||||
}
|
||||
else if (mat == Material.CARROT) {
|
||||
is = new ItemStack(Material.CARROT_ITEM, 1, (short) 0);
|
||||
}
|
||||
else if (mat == Material.POTATO) {
|
||||
is = new ItemStack(Material.POTATO_ITEM, 1, (short) 0);
|
||||
}
|
||||
|
||||
else {
|
||||
is = new ItemStack(mat);
|
||||
}
|
||||
}
|
||||
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel) {
|
||||
Config configInstance = Config.getInstance();
|
||||
|
||||
switch (type) {
|
||||
case BROWN_MUSHROOM:
|
||||
if (configInstance.getBrownMushroomsDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case CACTUS:
|
||||
if (configInstance.getCactiDoubleDropsEnabled()) {
|
||||
Misc.dropItems(loc, is, catciDrops);
|
||||
Misc.dropItems(location, is, catciDrops);
|
||||
}
|
||||
break;
|
||||
|
||||
case CROPS:
|
||||
if (configInstance.getWheatDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case MELON_BLOCK:
|
||||
if (configInstance.getMelonsDoubleDropsEnabled()) {
|
||||
Misc.dropItems(loc, is, 3);
|
||||
Misc.randomDropItems(loc, is, 50, 4);
|
||||
Misc.dropItems(location, is, 3);
|
||||
Misc.randomDropItems(location, is, 50, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case NETHER_WARTS:
|
||||
if (configInstance.getNetherWartsDoubleDropsEnabled()) {
|
||||
Misc.dropItems(loc, is, 2);
|
||||
Misc.randomDropItems(loc, is, 50, 3);
|
||||
Misc.dropItems(location, is, 2);
|
||||
Misc.randomDropItems(location, is, 50, 3);
|
||||
}
|
||||
break;
|
||||
|
||||
case PUMPKIN:
|
||||
if (configInstance.getPumpkinsDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case RED_MUSHROOM:
|
||||
if (configInstance.getRedMushroomsDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case SUGAR_CANE_BLOCK:
|
||||
if (configInstance.getSugarCaneDoubleDropsEnabled()) {
|
||||
Misc.dropItems(loc, is, caneDrops);
|
||||
Misc.dropItems(location, is, caneDrops);
|
||||
}
|
||||
break;
|
||||
|
||||
case VINE:
|
||||
if (configInstance.getVinesDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case WATER_LILY:
|
||||
if (configInstance.getWaterLiliesDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case YELLOW_FLOWER:
|
||||
if (configInstance.getYellowFlowersDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, is);
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case COCOA:
|
||||
if (configInstance.getCocoaDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case CARROT:
|
||||
if (configInstance.getCarrotDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
case POTATO:
|
||||
if (configInstance.getPotatoDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, is);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (customPlant) {
|
||||
Misc.dropItem(loc, is);
|
||||
CustomBlock customBlock = ModChecks.getCustomBlock(block);
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
is = customBlock.getItemDrop();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(location, is, minimumDropAmount);
|
||||
Misc.randomDropItems(location, is, 50, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(location, is, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, PP, SkillType.HERBALISM, xp);
|
||||
if(Config.getInstance().getHerbalismAFKDisabled() && player.isInsideVehicle())
|
||||
return;
|
||||
|
||||
Skills.xpProcessing(player, profile, SkillType.HERBALISM, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,21 +401,70 @@ public class Herbalism {
|
||||
private static void greenThumbWheat(Block block, Player player, BlockBreakEvent event, mcMMO plugin) {
|
||||
final int MAX_BONUS_LEVEL = 1500;
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int herbLevel = profile.getSkillLevel(SkillType.HERBALISM);
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
boolean hasSeeds = inventory.contains(Material.SEEDS);
|
||||
Location loc = block.getLocation();
|
||||
boolean hasSeeds = false;
|
||||
Location location = block.getLocation();
|
||||
Material type = block.getType();
|
||||
|
||||
if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
|
||||
switch(type) {
|
||||
case CROPS:
|
||||
hasSeeds = inventory.contains(Material.SEEDS);
|
||||
break;
|
||||
case COCOA:
|
||||
// Broken: Requires an update to bukkit to enable seaching for variable-sized ItemStacks.
|
||||
hasSeeds = inventory.contains(new ItemStack(Material.INK_SACK, 1, (short) 3), 1);
|
||||
break;
|
||||
case CARROT:
|
||||
hasSeeds = inventory.contains(Material.CARROT_ITEM);
|
||||
break;
|
||||
case POTATO:
|
||||
hasSeeds = inventory.contains(Material.POTATO_ITEM);
|
||||
break;
|
||||
case NETHER_WARTS:
|
||||
hasSeeds = inventory.contains(Material.NETHER_STALK);
|
||||
break;
|
||||
}
|
||||
|
||||
int randomChance = 1500;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (hasSeeds && profile.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= herbLevel)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
Misc.dropItem(loc, new ItemStack(Material.WHEAT));
|
||||
Misc.randomDropItems(loc, new ItemStack(Material.SEEDS), 50, 3);
|
||||
switch(type) {
|
||||
case CROPS:
|
||||
Misc.dropItem(location, new ItemStack(Material.WHEAT));
|
||||
Misc.randomDropItems(location, new ItemStack(Material.SEEDS), 50, 3);
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS));
|
||||
break;
|
||||
case COCOA:
|
||||
Misc.dropItem(location, new ItemStack(Material.INK_SACK, 3, (short) 3));
|
||||
inventory.removeItem(new ItemStack(Material.INK_SACK, 1, (short) 3));
|
||||
break;
|
||||
case CARROT:
|
||||
Misc.dropItem(location, new ItemStack(Material.CARROT_ITEM));
|
||||
Misc.randomDropItems(location, new ItemStack(Material.CARROT_ITEM), 50, 3);
|
||||
inventory.removeItem(new ItemStack(Material.POTATO_ITEM));
|
||||
break;
|
||||
case POTATO:
|
||||
Misc.dropItem(location, new ItemStack(Material.POTATO_ITEM));
|
||||
Misc.randomDropItems(location, new ItemStack(Material.POTATO_ITEM), 50, 3);
|
||||
Misc.randomDropItem(location, new ItemStack(Material.POISONOUS_POTATO), 2);
|
||||
inventory.removeItem(new ItemStack(Material.POTATO_ITEM));
|
||||
break;
|
||||
case NETHER_WARTS:
|
||||
Misc.dropItem(location, new ItemStack(Material.NETHER_STALK, 2));
|
||||
Misc.randomDropItems(location, new ItemStack(Material.NETHER_STALK), 50, 2);
|
||||
inventory.removeItem(new ItemStack(Material.NETHER_STALK));
|
||||
break;
|
||||
}
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, PP), 1);
|
||||
|
||||
inventory.removeItem(new ItemStack(Material.SEEDS));
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new GreenThumbTimer(block, profile, type), 1);
|
||||
player.updateInventory(); // Needed until replacement available
|
||||
}
|
||||
}
|
||||
@@ -331,13 +479,19 @@ public class Herbalism {
|
||||
public static void greenThumbBlocks(ItemStack is, Player player, Block block) {
|
||||
final int MAX_BONUS_LEVEL = 1500;
|
||||
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
int skillLevel = PP.getSkillLevel(SkillType.HERBALISM);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int skillLevel = profile.getSkillLevel(SkillType.HERBALISM);
|
||||
int seeds = is.getAmount();
|
||||
|
||||
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
|
||||
|
||||
if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= skillLevel) {
|
||||
int randomChance = 1500;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.herbalism")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= skillLevel) {
|
||||
greenTerraConvert(player, block);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.mods.CustomBlock;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
@@ -32,7 +33,7 @@ public class Mining {
|
||||
* @param block The block to process drops for
|
||||
*/
|
||||
private static void silkTouchDrops(Block block) {
|
||||
Location loc = block.getLocation();
|
||||
Location location = block.getLocation();
|
||||
Material type = block.getType();
|
||||
ItemStack item = new ItemStack(type);
|
||||
Config configInstance = Config.getInstance();
|
||||
@@ -50,44 +51,50 @@ public class Mining {
|
||||
|
||||
case COAL_ORE:
|
||||
if (configInstance.getCoalDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
if (configInstance.getDiamondDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWING_REDSTONE_ORE:
|
||||
case REDSTONE_ORE:
|
||||
if (configInstance.getRedstoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
if (configInstance.getGlowstoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
if (configInstance.getLapisDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
if (configInstance.getStoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case EMERALD_ORE:
|
||||
if (configInstance.getEmeraldDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ModChecks.isCustomMiningBlock(block)) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -100,7 +107,7 @@ public class Mining {
|
||||
* @param block The block to process drops for
|
||||
*/
|
||||
public static void miningDrops(Block block) {
|
||||
Location loc = block.getLocation();
|
||||
Location location = block.getLocation();
|
||||
Material type = block.getType();
|
||||
ItemStack item = new ItemStack(type);
|
||||
Config configInstance = Config.getInstance();
|
||||
@@ -109,20 +116,20 @@ public class Mining {
|
||||
case COAL_ORE:
|
||||
if (configInstance.getCoalDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case DIAMOND_ORE:
|
||||
if (configInstance.getDiamondDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.DIAMOND);
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case ENDER_STONE:
|
||||
if (configInstance.getEndStoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -130,74 +137,92 @@ public class Mining {
|
||||
case REDSTONE_ORE:
|
||||
if (configInstance.getRedstoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.REDSTONE);
|
||||
Misc.dropItems(loc, item, 4);
|
||||
Misc.randomDropItem(loc, item, 50);
|
||||
Misc.dropItems(location, item, 4);
|
||||
Misc.randomDropItem(location, item, 50);
|
||||
}
|
||||
break;
|
||||
|
||||
case GLOWSTONE:
|
||||
if (configInstance.getGlowstoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.GLOWSTONE_DUST);
|
||||
Misc.dropItems(loc, item, 2);
|
||||
Misc.randomDropItems(loc, item, 50, 2);
|
||||
Misc.dropItems(location, item, 2);
|
||||
Misc.randomDropItems(location, item, 50, 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GOLD_ORE:
|
||||
if (configInstance.getGoldDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case IRON_ORE:
|
||||
if (configInstance.getIronDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case LAPIS_ORE:
|
||||
if (configInstance.getLapisDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
|
||||
Misc.dropItems(loc, item, 4);
|
||||
Misc.randomDropItems(loc, item, 50, 4);
|
||||
Misc.dropItems(location, item, 4);
|
||||
Misc.randomDropItems(location, item, 50, 4);
|
||||
}
|
||||
break;
|
||||
|
||||
case MOSSY_COBBLESTONE:
|
||||
if (configInstance.getMossyCobblestoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case NETHERRACK:
|
||||
if (configInstance.getNetherrackDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case OBSIDIAN:
|
||||
if (configInstance.getObsidianDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case SANDSTONE:
|
||||
if (configInstance.getSandstoneDoubleDropsEnabled()) {
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case STONE:
|
||||
if (configInstance.getStoneDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.COBBLESTONE);
|
||||
Misc.dropItem(loc, item);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case EMERALD_ORE:
|
||||
if (configInstance.getEmeraldDoubleDropsEnabled()) {
|
||||
item = new ItemStack(Material.EMERALD);
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ModChecks.isCustomMiningBlock(block)) {
|
||||
CustomBlock customBlock = ModChecks.getCustomBlock(block);
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
item = ModChecks.getCustomBlock(block).getItemDrop();
|
||||
Misc.dropItem(loc, item);
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(location, item, minimumDropAmount);
|
||||
Misc.randomDropItems(location, item, 50, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(location, item, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -210,7 +235,7 @@ public class Mining {
|
||||
* @param block The block to award XP for
|
||||
*/
|
||||
public static void miningXP(Player player, Block block) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
Material type = block.getType();
|
||||
int xp = 0;
|
||||
|
||||
@@ -267,6 +292,10 @@ public class Mining {
|
||||
case STONE:
|
||||
xp += Config.getInstance().getMiningXPStone();
|
||||
break;
|
||||
|
||||
case EMERALD_ORE:
|
||||
xp += Config.getInstance().getMiningXPEmeraldOre();
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ModChecks.isCustomMiningBlock(block)) {
|
||||
@@ -275,7 +304,7 @@ public class Mining {
|
||||
break;
|
||||
}
|
||||
|
||||
Skills.xpProcessing(player, PP, SkillType.MINING, xp);
|
||||
Skills.xpProcessing(player, profile, SkillType.MINING, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -295,7 +324,13 @@ public class Mining {
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||
|
||||
if (random.nextInt(1000) <= skillCheck && Permissions.getInstance().miningDoubleDrops(player)) {
|
||||
int randomChance = 1000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.mining")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextInt(randomChance) <= skillCheck && Permissions.getInstance().miningDoubleDrops(player)) {
|
||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
silkTouchDrops(block);
|
||||
}
|
||||
@@ -322,7 +357,7 @@ public class Mining {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMO.placeStore.isTrue(block)) {
|
||||
if (mcMMO.placeStore.isTrue(block) || Misc.blockBreakSimulate(block, player, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -349,6 +384,7 @@ public class Mining {
|
||||
case GOLD_ORE:
|
||||
case LAPIS_ORE:
|
||||
case REDSTONE_ORE:
|
||||
case EMERALD_ORE:
|
||||
if (tier < 3) {
|
||||
return;
|
||||
}
|
||||
@@ -367,7 +403,7 @@ public class Mining {
|
||||
case NETHERRACK:
|
||||
case SANDSTONE:
|
||||
case STONE:
|
||||
if (mcMMO.placeStore.isTrue(block)) {
|
||||
if (mcMMO.placeStore.isTrue(block) || Misc.blockBreakSimulate(block, player, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -379,6 +415,9 @@ public class Mining {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,12 @@ public class WoodCutting {
|
||||
public static void treeFeller(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block firstBlock = event.getBlock();
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
ArrayList<Block> toBeFelled = new ArrayList<Block>();
|
||||
|
||||
/* NOTE: Tree Feller will cut upwards like how you actually fell trees */
|
||||
processTreeFelling(firstBlock, toBeFelled);
|
||||
removeBlocks(toBeFelled, player, PP);
|
||||
removeBlocks(toBeFelled, player, profile);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,9 +54,9 @@ public class WoodCutting {
|
||||
*
|
||||
* @param toBeFelled List of Blocks to be removed from the tree
|
||||
* @param player The player using the ability
|
||||
* @param PP The PlayerProfile of the player
|
||||
* @param profile The PlayerProfile of the player
|
||||
*/
|
||||
private static void removeBlocks(ArrayList<Block> toBeFelled, Player player, PlayerProfile PP) {
|
||||
private static void removeBlocks(ArrayList<Block> toBeFelled, Player player, PlayerProfile profile) {
|
||||
if (toBeFelled.size() >= Config.getInstance().getTreeFellerThreshold()) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold"));
|
||||
return;
|
||||
@@ -116,7 +116,18 @@ public class WoodCutting {
|
||||
x.setData((byte) 0x0);
|
||||
x.setType(Material.AIR);
|
||||
|
||||
Misc.dropItem(x.getLocation(), item);
|
||||
int minimumDropAmount = block.getMinimumDropAmount();
|
||||
int maximumDropAmount = block.getMaximumDropAmount();
|
||||
|
||||
item = block.getItemDrop();
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(x.getLocation(), item, minimumDropAmount);
|
||||
Misc.randomDropItems(x.getLocation(), item, 50, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(x.getLocation(), item, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
else if (ModChecks.isCustomLeafBlock(x)) {
|
||||
CustomBlock block = ModChecks.getCustomBlock(x);
|
||||
@@ -173,7 +184,7 @@ public class WoodCutting {
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
xp += Config.getInstance().getWoodcuttingXPJungle() / 4; //Nerf XP from Jungle Trees when using Tree Feller
|
||||
xp += Config.getInstance().getWoodcuttingXPJungle() / 2; //Nerf XP from Jungle Trees when using Tree Feller
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -202,7 +213,7 @@ public class WoodCutting {
|
||||
}
|
||||
|
||||
if (Permissions.getInstance().woodcutting(player)) {
|
||||
Skills.xpProcessing(player, PP, SkillType.WOODCUTTING, xp);
|
||||
Skills.xpProcessing(player, profile, SkillType.WOODCUTTING, xp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,6 +261,39 @@ public class WoodCutting {
|
||||
}
|
||||
}
|
||||
|
||||
byte data = currentBlock.getData();
|
||||
|
||||
if((data & 0x4) == 0x4)
|
||||
data ^= 0x4;
|
||||
|
||||
if((data & 0x8) == 0x8)
|
||||
data ^= 0x8;
|
||||
|
||||
if(TreeSpecies.getByData(data) == TreeSpecies.JUNGLE) {
|
||||
Block corner1 = currentBlock.getRelative(1, 0, 1);
|
||||
Block corner2 = currentBlock.getRelative(1, 0, -1);
|
||||
Block corner3 = currentBlock.getRelative(-1, 0, 1);
|
||||
Block corner4 = currentBlock.getRelative(-1, 0, -1);
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(currentBlock)) {
|
||||
if (!isTooAggressive(currentBlock, corner1) && BlockChecks.treeFellerCompatible(corner1) && !toBeFelled.contains(corner1)) {
|
||||
processTreeFelling(corner1, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, corner2) && BlockChecks.treeFellerCompatible(corner2) && !toBeFelled.contains(corner2)) {
|
||||
processTreeFelling(corner2, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, corner3) && BlockChecks.treeFellerCompatible(corner3) && !toBeFelled.contains(corner3)) {
|
||||
processTreeFelling(corner3, toBeFelled);
|
||||
}
|
||||
|
||||
if (!isTooAggressive(currentBlock, corner4) && BlockChecks.treeFellerCompatible(corner4) && !toBeFelled.contains(corner4)) {
|
||||
processTreeFelling(corner4, toBeFelled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (BlockChecks.treeFellerCompatible(yPositive)) {
|
||||
if(!mcMMO.placeStore.isTrue(currentBlock) && !toBeFelled.contains(yPositive)) {
|
||||
processTreeFelling(yPositive, toBeFelled);
|
||||
@@ -287,55 +331,77 @@ public class WoodCutting {
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.WOODCUTTING);
|
||||
byte type = block.getData();
|
||||
|
||||
if((type & 0x4) == 0x4)
|
||||
type ^= 0x4;
|
||||
|
||||
if((type & 0x8) == 0x8)
|
||||
type ^= 0x8;
|
||||
|
||||
Material mat = Material.getMaterial(block.getTypeId());
|
||||
|
||||
Tree tree = (Tree) block.getState().getData();
|
||||
TreeSpecies species = tree.getSpecies();
|
||||
int randomChance = 1000;
|
||||
|
||||
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
|
||||
if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(randomChance) <= skillLevel) && Permissions.getInstance().woodcuttingDoubleDrops(player)) {
|
||||
Config configInstance = Config.getInstance();
|
||||
ItemStack item;
|
||||
Location location;
|
||||
|
||||
if (configInstance.getBlockModsEnabled() && ModChecks.isCustomLogBlock(block)) {
|
||||
item = ModChecks.getCustomBlock(block).getItemDrop();
|
||||
CustomBlock customBlock = ModChecks.getCustomBlock(block);
|
||||
int minimumDropAmount = customBlock.getMinimumDropAmount();
|
||||
int maximumDropAmount = customBlock.getMaximumDropAmount();
|
||||
|
||||
item = customBlock.getItemDrop();
|
||||
location = block.getLocation();
|
||||
Misc.dropItem(location, item);
|
||||
return;
|
||||
|
||||
if (minimumDropAmount != maximumDropAmount) {
|
||||
Misc.dropItems(location, item, minimumDropAmount);
|
||||
Misc.randomDropItems(location, item, 50, maximumDropAmount - minimumDropAmount);
|
||||
}
|
||||
else {
|
||||
Misc.dropItems(location, item, minimumDropAmount);
|
||||
}
|
||||
}
|
||||
else {
|
||||
item = new ItemStack(mat, 1, (short) 0, type);
|
||||
location = block.getLocation();
|
||||
}
|
||||
|
||||
/* Drop the block */
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
if (configInstance.getOakDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
TreeSpecies species = TreeSpecies.getByData(type);
|
||||
|
||||
/* Drop the block */
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
if (configInstance.getOakDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
if (configInstance.getSpruceDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
if (configInstance.getBirchDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
if (configInstance.getJungleDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case REDWOOD:
|
||||
if (configInstance.getSpruceDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case BIRCH:
|
||||
if (configInstance.getBirchDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
case JUNGLE:
|
||||
if (configInstance.getJungleDoubleDropsEnabled()) {
|
||||
Misc.dropItem(location, item);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -347,9 +413,8 @@ public class WoodCutting {
|
||||
* @param block The block being broken
|
||||
*/
|
||||
public static void woodcuttingBlockCheck(Player player, Block block) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int xp = 0;
|
||||
TreeSpecies species = TreeSpecies.getByData(block.getData());
|
||||
|
||||
if (mcMMO.placeStore.isTrue(block)) {
|
||||
return;
|
||||
@@ -359,6 +424,21 @@ public class WoodCutting {
|
||||
xp = ModChecks.getCustomBlock(block).getXpGain();
|
||||
}
|
||||
else {
|
||||
byte type = block.getData();
|
||||
|
||||
if((type & 0x4) == 0x4)
|
||||
type ^= 0x4;
|
||||
|
||||
if((type & 0x8) == 0x8)
|
||||
type ^= 0x8;
|
||||
|
||||
TreeSpecies species = TreeSpecies.getByData(type);
|
||||
|
||||
//Apparently species can be null in certain cases (custom server mods?)
|
||||
//https://github.com/mcMMO-Dev/mcMMO/issues/229
|
||||
if(species == null)
|
||||
return;
|
||||
|
||||
switch (species) {
|
||||
case GENERIC:
|
||||
xp += Config.getInstance().getWoodcuttingXPOak();
|
||||
@@ -382,7 +462,7 @@ public class WoodCutting {
|
||||
}
|
||||
|
||||
WoodCutting.woodCuttingProcCheck(player, block);
|
||||
Skills.xpProcessing(player, PP, SkillType.WOODCUTTING, xp);
|
||||
Skills.xpProcessing(player, profile, SkillType.WOODCUTTING, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,18 +31,18 @@ public class Repair {
|
||||
* Handle the XP gain for repair events.
|
||||
*
|
||||
* @param player Player repairing the item
|
||||
* @param PP PlayerProfile of the repairing player
|
||||
* @param profile PlayerProfile of the repairing player
|
||||
* @param is Item being repaired
|
||||
* @param durabilityBefore Durability of the item before repair
|
||||
* @param modify Amount to modify the durability by
|
||||
* @param boost True if the modifier is a boost, false if the modifier is a reduction
|
||||
*/
|
||||
protected static void xpHandler(Player player, PlayerProfile PP, short durabilityBefore, short durabilityAfter, double modify) {
|
||||
protected static void xpHandler(Player player, PlayerProfile profile, short durabilityBefore, short durabilityAfter, double modify) {
|
||||
short dif = (short) (durabilityBefore - durabilityAfter);
|
||||
|
||||
dif = (short) (dif * modify);
|
||||
|
||||
Skills.xpProcessing(player, PP, SkillType.REPAIR, dif * 10);
|
||||
Skills.xpProcessing(player, profile, SkillType.REPAIR, dif * 10);
|
||||
|
||||
//CLANG CLANG
|
||||
if (mcMMO.spoutEnabled) {
|
||||
@@ -53,11 +53,11 @@ public class Repair {
|
||||
/**
|
||||
* Get current Arcane Forging rank.
|
||||
*
|
||||
* @param skillLevel The skill level of the player whose rank is being checked
|
||||
* @param profile The PlayerProfile of the player to get the rank for
|
||||
* @return The player's current Arcane Forging rank
|
||||
*/
|
||||
public static int getArcaneForgingRank(PlayerProfile PP) {
|
||||
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
|
||||
public static int getArcaneForgingRank(PlayerProfile profile) {
|
||||
int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if (skillLevel >= configInstance.getArcaneForgingRankLevels4()) {
|
||||
return 4;
|
||||
@@ -104,12 +104,18 @@ public class Repair {
|
||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||
Enchantment enchantment = enchant.getKey();
|
||||
|
||||
if (random.nextInt(100) <= getEnchantChance(rank)) {
|
||||
int randomChance = 100;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.repair")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (random.nextInt(randomChance) <= getEnchantChance(rank)) {
|
||||
int enchantLevel = enchant.getValue();
|
||||
|
||||
if (configInstance.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
|
||||
if (random.nextInt(100) <= getDowngradeChance(rank)) {
|
||||
is.addEnchantment(enchantment, enchantLevel--);
|
||||
if (random.nextInt(100) < getDowngradeChance(rank)) {
|
||||
is.addEnchantment(enchantment, --enchantLevel);
|
||||
downgraded = true;
|
||||
}
|
||||
}
|
||||
@@ -223,7 +229,13 @@ public class Repair {
|
||||
|
||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||
|
||||
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && permInstance.repairBonus(player)) {
|
||||
int randomChance = 1000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.repair")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(randomChance) <= skillLevel) && permInstance.repairBonus(player)) {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||
return true;
|
||||
}
|
||||
@@ -238,21 +250,21 @@ public class Repair {
|
||||
* @param anvilID The item ID of the anvil block
|
||||
*/
|
||||
public static void placedAnvilCheck(Player player, int anvilID) {
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (!PP.getPlacedAnvil()) {
|
||||
if (!profile.getPlacedAnvil()) {
|
||||
if (mcMMO.spoutEnabled) {
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
|
||||
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
|
||||
|
||||
if (sPlayer.isSpoutCraftEnabled()) {
|
||||
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(anvilID)); //TODO: Use Locale
|
||||
if (spoutPlayer.isSpoutCraftEnabled()) {
|
||||
spoutPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(anvilID)); //TODO: Use Locale
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil"));
|
||||
}
|
||||
|
||||
PP.togglePlacedAnvil();
|
||||
profile.togglePlacedAnvil();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,10 @@ public class SimpleRepairManager implements RepairManager {
|
||||
@Override
|
||||
public void handleRepair(Player player, ItemStack item) {
|
||||
// Load some variables for use
|
||||
PlayerProfile PP = Users.getProfile(player);
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
short startDurability = item.getDurability();
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
|
||||
int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
|
||||
Repairable repairable = repairables.get(item.getTypeId());
|
||||
|
||||
// Permissions checks on material and item types
|
||||
@@ -147,7 +147,7 @@ public class SimpleRepairManager implements RepairManager {
|
||||
removeOneFrom(inventory, repairItemLocation);
|
||||
|
||||
// Give out XP like candy
|
||||
Repair.xpHandler(player, PP, startDurability, newDurability, repairable.getXpMultiplier());
|
||||
Repair.xpHandler(player, profile, startDurability, newDurability, repairable.getXpMultiplier());
|
||||
|
||||
// Repair the item!
|
||||
item.setDurability(newDurability);
|
||||
|
||||
@@ -24,6 +24,9 @@ public class CounterAttackEventHandler {
|
||||
}
|
||||
|
||||
protected boolean isHoldingSword() {
|
||||
if(player == null)
|
||||
return false;
|
||||
|
||||
return ItemChecks.isSword(player.getItemInHand());
|
||||
}
|
||||
|
||||
@@ -36,6 +39,9 @@ public class CounterAttackEventHandler {
|
||||
}
|
||||
|
||||
protected void sendAbilityMessages() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
|
||||
|
||||
if (attacker instanceof Player) {
|
||||
|
||||
@@ -19,6 +19,9 @@ public class SerratedStrikesEventHandler {
|
||||
}
|
||||
|
||||
protected void applyAbilityEffects() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
Combat.applyAbilityAoE(player, target, damage / Swords.SERRATED_STRIKES_MODIFIER, SkillType.SWORDS);
|
||||
BleedTimer.add(target, Swords.SERRATED_STRIKES_BLEED_TICKS);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,12 @@ public class SwordsManager {
|
||||
* @param defender The defending entity
|
||||
*/
|
||||
public void bleedCheck(LivingEntity defender) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.swordsBleed(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -35,7 +41,13 @@ public class SwordsManager {
|
||||
if (Combat.shouldBeAffected(player, defender)) {
|
||||
BleedEventHandler eventHandler = new BleedEventHandler(this, defender);
|
||||
|
||||
if (Swords.getRandom().nextInt(1000) < eventHandler.skillModifier) {
|
||||
int randomChance = 1000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.swords")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Swords.getRandom().nextInt(randomChance) < eventHandler.skillModifier) {
|
||||
eventHandler.addBleedTicks();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
@@ -43,6 +55,12 @@ public class SwordsManager {
|
||||
}
|
||||
|
||||
public void counterAttackChecks(LivingEntity attacker, int damage) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.counterAttack(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -52,7 +70,13 @@ public class SwordsManager {
|
||||
if (eventHandler.isHoldingSword()) {
|
||||
eventHandler.calculateSkillModifier();
|
||||
|
||||
if (Swords.getRandom().nextInt(2000) < eventHandler.skillModifier) {
|
||||
int randomChance = 2000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.swords")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Swords.getRandom().nextInt(randomChance) < eventHandler.skillModifier) {
|
||||
eventHandler.dealDamage();
|
||||
eventHandler.sendAbilityMessages();
|
||||
}
|
||||
@@ -60,13 +84,19 @@ public class SwordsManager {
|
||||
}
|
||||
|
||||
public void serratedStrikes(LivingEntity target, int damage) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.serratedStrikes(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SerratedStrikesEventHandler eventHandler = new SerratedStrikesEventHandler(this, target, damage);
|
||||
|
||||
eventHandler.applyAbilityEffects();
|
||||
eventHandler.applyAbilityEffects();
|
||||
}
|
||||
|
||||
protected int getSkillLevel() {
|
||||
|
||||
@@ -19,6 +19,9 @@ public class BeastLoreEventHandler {
|
||||
}
|
||||
|
||||
protected void sendInspectMessage() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
|
||||
|
||||
if (beast.isTamed()) {
|
||||
|
||||
@@ -29,10 +29,16 @@ public class CallOfTheWildEventHandler {
|
||||
}
|
||||
|
||||
protected void sendInsufficientAmountMessage() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(inHand.getTypeId()));
|
||||
}
|
||||
|
||||
protected boolean nearbyEntityExists() {
|
||||
if(player == null)
|
||||
return false;
|
||||
|
||||
boolean entityExists = false;
|
||||
|
||||
for (Entity entity : player.getNearbyEntities(40, 40, 40)) {
|
||||
@@ -46,6 +52,9 @@ public class CallOfTheWildEventHandler {
|
||||
}
|
||||
|
||||
protected void sendFailureMessage() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if (type == EntityType.OCELOT) {
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot"));
|
||||
}
|
||||
@@ -55,8 +64,10 @@ public class CallOfTheWildEventHandler {
|
||||
}
|
||||
|
||||
protected void spawnCreature() {
|
||||
// LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
|
||||
LivingEntity entity = player.getWorld().spawnCreature(player.getLocation(), type);
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
|
||||
entity.setMetadata("mcmmoSummoned", new FixedMetadataValue(mcMMO.p, true));
|
||||
|
||||
((Tameable) entity).setOwner(player);
|
||||
@@ -70,6 +81,9 @@ public class CallOfTheWildEventHandler {
|
||||
}
|
||||
|
||||
protected void processResourceCost() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
int newAmount = inHand.getAmount() - summonAmount;
|
||||
|
||||
if (newAmount == 0) {
|
||||
@@ -81,6 +95,9 @@ public class CallOfTheWildEventHandler {
|
||||
}
|
||||
|
||||
protected void sendSuccessMessage() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ public class EnvironmentallyAwareEventHandler {
|
||||
}
|
||||
|
||||
protected void teleportWolf() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if (event.getDamage() > wolf.getHealth()) {
|
||||
return;
|
||||
}
|
||||
@@ -26,6 +29,9 @@ public class EnvironmentallyAwareEventHandler {
|
||||
}
|
||||
|
||||
protected void sendAbilityMessage() {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
player.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,12 +36,24 @@ public class TamingManager {
|
||||
* @param damage The damage being absorbed by the wolf
|
||||
*/
|
||||
public void fastFoodService(Wolf wolf, int damage) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.fastFoodService(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skillLevel >= Taming.FAST_FOOD_SERVICE_ACTIVATION_LEVEL) {
|
||||
if (Taming.getRandom().nextInt(100) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) {
|
||||
int randomChance = 100;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.taming")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Taming.getRandom().nextInt(randomChance) < Taming.FAST_FOOD_SERVICE_ACTIVATION_CHANCE) {
|
||||
FastFoodServiceEventHandler eventHandler = new FastFoodServiceEventHandler(wolf);
|
||||
|
||||
eventHandler.modifyHealth(damage);
|
||||
@@ -55,6 +67,12 @@ public class TamingManager {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public void sharpenedClaws(EntityDamageEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.sharpenedClaws(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -72,13 +90,25 @@ public class TamingManager {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
public void gore(EntityDamageEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.gore(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
|
||||
|
||||
if (Taming.getRandom().nextInt(1000) < eventHandler.skillModifier) {
|
||||
int randomChance = 1000;
|
||||
|
||||
if (player.hasPermission("mcmmo.perks.lucky.taming")) {
|
||||
randomChance = (int) (randomChance * 0.75);
|
||||
}
|
||||
|
||||
if (Taming.getRandom().nextInt(randomChance) < eventHandler.skillModifier) {
|
||||
eventHandler.modifyEventDamage();
|
||||
eventHandler.applyBleed();
|
||||
eventHandler.sendAbilityMessage();
|
||||
@@ -138,6 +168,12 @@ public class TamingManager {
|
||||
* @param livingEntity The entity to examine
|
||||
*/
|
||||
public void beastLore(LivingEntity livingEntity) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.beastLore(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -154,6 +190,12 @@ public class TamingManager {
|
||||
* @param summonAmount The amount of material needed to summon the entity
|
||||
*/
|
||||
private void callOfTheWild(EntityType type, int summonAmount) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.callOfTheWild(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -186,6 +228,12 @@ public class TamingManager {
|
||||
* @param cause The damage cause of the event
|
||||
*/
|
||||
private void environmentallyAware(EntityDamageEvent event, DamageCause cause) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.environmentallyAware(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -218,6 +266,12 @@ public class TamingManager {
|
||||
* @param cause The damage cause of the event
|
||||
*/
|
||||
private void thickFur(EntityDamageEvent event, DamageCause cause) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.thickFur(player)) {
|
||||
return;
|
||||
}
|
||||
@@ -235,6 +289,12 @@ public class TamingManager {
|
||||
* @param event The event to modify
|
||||
*/
|
||||
private void shockProof(EntityDamageEvent event) {
|
||||
if(player == null)
|
||||
return;
|
||||
|
||||
if(permissionsInstance == null)
|
||||
return;
|
||||
|
||||
if (!permissionsInstance.shockProof(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@ package com.gmail.nossr50.skills.unarmed;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class IronGripEventHandler {
|
||||
private UnarmedManager manager;
|
||||
@@ -18,7 +20,7 @@ public class IronGripEventHandler {
|
||||
}
|
||||
|
||||
protected void calculateSkillModifier() {
|
||||
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Unarmed.DISARM_MAX_BONUS_LEVEL);
|
||||
this.skillModifier = Misc.skillCheck(Users.getProfile(defender).getSkillLevel(SkillType.UNARMED), Unarmed.IRON_GRIP_MAX_BONUS_LEVEL);
|
||||
}
|
||||
|
||||
protected void sendAbilityMessages() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user