Merge branches 'tridentsxbows' and 'master' of github.com:mcMMO-Dev/mcMMO into tridentsxbows

This commit is contained in:
nossr50
2021-04-07 16:21:02 -07:00
34 changed files with 2803 additions and 1849 deletions

View File

@@ -1,88 +1,94 @@
//package com.gmail.nossr50.api;
//
//import com.gmail.nossr50.datatypes.player.McMMOPlayer;
//import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
//import com.gmail.nossr50.runnables.skills.BleedTimerTask;
//import com.gmail.nossr50.util.player.UserManager;
//import org.bukkit.entity.LivingEntity;
//import org.bukkit.entity.Player;
//
//public final class AbilityAPI {
// private AbilityAPI() {}
//
// public static boolean berserkEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK);
// }
//
// public static boolean gigaDrillBreakerEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
// }
//
// public static boolean greenTerraEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GREEN_TERRA);
// }
//
// public static boolean serratedStrikesEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
// }
//
// public static boolean skullSplitterEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
// }
//
// public static boolean superBreakerEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SUPER_BREAKER);
// }
//
// public static boolean treeFellerEnabled(Player player) {
// return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.TREE_FELLER);
// }
//
// public static boolean isAnyAbilityEnabled(Player player) {
// McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
//
// for (SuperAbilityType ability : SuperAbilityType.values()) {
// if (mcMMOPlayer.getAbilityMode(ability)) {
// return true;
// }
// }
//
// return false;
// }
//
// public static void resetCooldowns(Player player) {
// UserManager.getPlayer(player).resetCooldowns();
// }
//
// public static void setBerserkCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
// }
//
// public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
// }
//
// public static void setGreenTerraCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
// }
//
// public static void setSerratedStrikesCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
// }
//
// public static void setSkullSplitterCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
// }
//
// public static void setSuperBreakerCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
// }
//
// public static void setTreeFellerCooldown(Player player, long cooldown) {
// UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
// }
//
// public static boolean isBleeding(LivingEntity entity) {
// return BleedTimerTask.isBleeding(entity);
// }
//}
package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public final class AbilityAPI {
private AbilityAPI() {}
public static boolean berserkEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.BERSERK);
}
public static boolean gigaDrillBreakerEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GIGA_DRILL_BREAKER);
}
public static boolean greenTerraEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.GREEN_TERRA);
}
public static boolean serratedStrikesEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SERRATED_STRIKES);
}
public static boolean skullSplitterEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SKULL_SPLITTER);
}
public static boolean superBreakerEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.SUPER_BREAKER);
}
public static boolean treeFellerEnabled(Player player) {
return UserManager.getPlayer(player).getAbilityMode(SuperAbilityType.TREE_FELLER);
}
public static boolean isAnyAbilityEnabled(Player player) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
for (SuperAbilityType ability : SuperAbilityType.values()) {
if (mcMMOPlayer.getAbilityMode(ability)) {
return true;
}
}
return false;
}
public static void resetCooldowns(Player player) {
UserManager.getPlayer(player).resetCooldowns();
}
public static void setBerserkCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.BERSERK, cooldown);
}
public static void setGigaDrillBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GIGA_DRILL_BREAKER, cooldown);
}
public static void setGreenTerraCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.GREEN_TERRA, cooldown);
}
public static void setSerratedStrikesCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SERRATED_STRIKES, cooldown);
}
public static void setSkullSplitterCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SKULL_SPLITTER, cooldown);
}
public static void setSuperBreakerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.SUPER_BREAKER, cooldown);
}
public static void setTreeFellerCooldown(Player player, long cooldown) {
UserManager.getPlayer(player).setAbilityDATS(SuperAbilityType.TREE_FELLER, cooldown);
}
public static boolean isBleeding(LivingEntity entity) {
if(entity.isValid()) {
if(entity.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
return true;
}
}
return false;
}
}

View File

@@ -34,7 +34,7 @@ public class McmmoCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
}
mcMMO.getHolidayManager().anniversaryCheck(sender);
// mcMMO.getHolidayManager().anniversaryCheck(sender);
return true;
case 1:

View File

@@ -1,199 +1,199 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
public class AprilCommand implements TabExecutor {
private String skillName;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
skillName = StringUtils.getCapitalized(label);
if (args.length == 0) {
Player player = (Player) sender;
FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
float skillValue = Misc.getRandom().nextInt(99);
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType)));
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000)));
List<String> effectMessages = effectsDisplay(fakeSkillType);
if (!effectMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
for (String message : effectMessages) {
player.sendMessage(message);
}
}
List<String> statsMessages = statsDisplay(fakeSkillType);
if (!statsMessages.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
for (String message : statsMessages) {
player.sendMessage(message);
}
}
player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName));
return true;
}
return true;
}
private String getXPGainString(FakeSkillType fakeSkillType) {
switch (fakeSkillType) {
case MACHO:
return "Get beaten up";
case JUMPING:
return "Kris Kross will make ya Jump Jump";
case THROWING:
return "Chuck your items on the floor";
case WRECKING:
return "I'M GONNA WRECK IT!";
case CRAFTING:
return "Craft apple pies";
case WALKING:
return "Walk around the park";
case SWIMMING:
return "Like a fish on a bicycle";
case FALLING:
return "Faceplant the floor, headbutt the ground";
case CLIMBING:
return "Climb the highest mountain";
case FLYING:
return "I believe I can fly";
case DIVING:
return "Scuba club 4000";
case PIGGY:
return "OINK! OINK!";
default:
return "Sit and wait?";
}
}
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
if (args.length == 1) {
return ImmutableList.of("?");
}
return ImmutableList.of();
}
private List<String> effectsDisplay(FakeSkillType fakeSkillType) {
List<String> messages = new ArrayList<>();
switch (fakeSkillType) {
case MACHO:
messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand"));
break;
case JUMPING:
messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP"));
messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE"));
break;
case THROWING:
messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random"));
break;
case WRECKING:
messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists"));
break;
case CRAFTING:
messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft"));
break;
case WALKING:
messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot"));
break;
case SWIMMING:
messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming"));
break;
case FALLING:
messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously."));
break;
case CLIMBING:
messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster"));
break;
case FLYING:
messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss"));
break;
case DIVING:
messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer"));
break;
case PIGGY:
messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots"));
break;
}
return messages;
}
private List<String> statsDisplay(FakeSkillType fakeSkillType) {
List<String> messages = new ArrayList<>();
switch (fakeSkillType) {
case MACHO:
messages.add(LocaleLoader.formatString("&cDamage Taken: &e{0}%", decimal.format(Misc.getRandom().nextInt(77))));
break;
case JUMPING:
messages.add(LocaleLoader.formatString("&cDouble Jump Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case THROWING:
messages.add(LocaleLoader.formatString("&cDrop Item Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(87))));
break;
case WRECKING:
messages.add(LocaleLoader.formatString("&cWrecking Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(14))));
break;
case CRAFTING:
messages.add(LocaleLoader.formatString("&cCrafting Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case WALKING:
messages.add(LocaleLoader.formatString("&cWalk Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case SWIMMING:
messages.add(LocaleLoader.formatString("&cSwim Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case FALLING:
messages.add(LocaleLoader.formatString("&cSkydiving Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(37))));
break;
case CLIMBING:
messages.add(LocaleLoader.formatString("&cRock Climber Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case FLYING:
messages.add(LocaleLoader.formatString("&cFly Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case DIVING:
messages.add(LocaleLoader.formatString("&cHold Breath Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
break;
case PIGGY:
messages.add(LocaleLoader.formatString("&cCarrot Turbo Boost: &e{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
break;
}
return messages;
}
}
//package com.gmail.nossr50.commands.skills;
//
//import com.gmail.nossr50.locale.LocaleLoader;
//import com.gmail.nossr50.util.HolidayManager.FakeSkillType;
//import com.gmail.nossr50.util.Misc;
//import com.gmail.nossr50.util.commands.CommandUtils;
//import com.gmail.nossr50.util.text.StringUtils;
//import com.google.common.collect.ImmutableList;
//import org.bukkit.command.Command;
//import org.bukkit.command.CommandSender;
//import org.bukkit.command.TabExecutor;
//import org.bukkit.entity.Player;
//import org.jetbrains.annotations.NotNull;
//
//import java.text.DecimalFormat;
//import java.util.ArrayList;
//import java.util.List;
//
//public class AprilCommand implements TabExecutor {
// private String skillName;
//
// protected DecimalFormat percent = new DecimalFormat("##0.00%");
// protected DecimalFormat decimal = new DecimalFormat("##0.00");
//
// @Override
// public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
// if (CommandUtils.noConsoleUsage(sender)) {
// return true;
// }
//
// skillName = StringUtils.getCapitalized(label);
//
// if (args.length == 0) {
// Player player = (Player) sender;
// FakeSkillType fakeSkillType = FakeSkillType.getByName(skillName);
//
// float skillValue = Misc.getRandom().nextInt(99);
//
// player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
// player.sendMessage(LocaleLoader.getString("Commands.XPGain", getXPGainString(fakeSkillType)));
// player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, Misc.getRandom().nextInt(1000), 1000 + Misc.getRandom().nextInt(1000)));
//
//
// List<String> effectMessages = effectsDisplay(fakeSkillType);
//
// if (!effectMessages.isEmpty()) {
// player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
//
// for (String message : effectMessages) {
// player.sendMessage(message);
// }
// }
//
// List<String> statsMessages = statsDisplay(fakeSkillType);
//
// if (!statsMessages.isEmpty()) {
// player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
//
// for (String message : statsMessages) {
// player.sendMessage(message);
// }
// }
//
// player.sendMessage(LocaleLoader.formatString("[[DARK_AQUA]]Guide for {0} available - type /APRIL FOOLS ! :D", skillName));
// return true;
// }
// return true;
// }
//
// private String getXPGainString(FakeSkillType fakeSkillType) {
// switch (fakeSkillType) {
// case MACHO:
// return "Get beaten up";
// case JUMPING:
// return "Kris Kross will make ya Jump Jump";
// case THROWING:
// return "Chuck your items on the floor";
// case WRECKING:
// return "I'M GONNA WRECK IT!";
// case CRAFTING:
// return "Craft apple pies";
// case WALKING:
// return "Walk around the park";
// case SWIMMING:
// return "Like a fish on a bicycle";
// case FALLING:
// return "Faceplant the floor, headbutt the ground";
// case CLIMBING:
// return "Climb the highest mountain";
// case FLYING:
// return "I believe I can fly";
// case DIVING:
// return "Scuba club 4000";
// case PIGGY:
// return "OINK! OINK!";
// default:
// return "Sit and wait?";
// }
// }
//
// @Override
// public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
// if (args.length == 1) {
// return ImmutableList.of("?");
// }
// return ImmutableList.of();
// }
//
// private List<String> effectsDisplay(FakeSkillType fakeSkillType) {
// List<String> messages = new ArrayList<>();
//
// switch (fakeSkillType) {
// case MACHO:
// messages.add(LocaleLoader.getString("Effects.Template", "Punching bag", "Absorb damage, like a bag of sand"));
// break;
// case JUMPING:
// messages.add(LocaleLoader.getString("Effects.Template", "Jump", "PRESS SPACE TO JUMP"));
// messages.add(LocaleLoader.getString("Effects.Template", "Jump Twice", "PRESS SPACE TWICE TO JUMP TWICE"));
// break;
// case THROWING:
// messages.add(LocaleLoader.getString("Effects.Template", "Drop Item", "Randomly drop items, at random"));
// break;
// case WRECKING:
// messages.add(LocaleLoader.getString("Effects.Template", "Ralphinator", "Smash windows with your fists"));
// break;
// case CRAFTING:
// messages.add(LocaleLoader.getString("Effects.Template", "Crafting", "Chance of successful craft"));
// break;
// case WALKING:
// messages.add(LocaleLoader.getString("Effects.Template", "Walk", "Traveling gracefully by foot"));
// break;
// case SWIMMING:
// messages.add(LocaleLoader.getString("Effects.Template", "Swim", "Just keep swimming, swimming, swimming"));
// break;
// case FALLING:
// messages.add(LocaleLoader.getString("Effects.Template", "Skydiving", "Go jump of a cliff. No, seriously."));
// break;
// case CLIMBING:
// messages.add(LocaleLoader.getString("Effects.Template", "Rock Climber", "Use string to climb mountains faster"));
// break;
// case FLYING:
// messages.add(LocaleLoader.getString("Effects.Template", "Fly", "Throw yourself at the ground and miss"));
// break;
// case DIVING:
// messages.add(LocaleLoader.getString("Effects.Template", "Hold Breath", "Press shift to hold your breath longer"));
// break;
// case PIGGY:
// messages.add(LocaleLoader.getString("Effects.Template", "Carrot Turbo", "Supercharge your pigs with carrots"));
// break;
// }
//
// return messages;
// }
//
// private List<String> statsDisplay(FakeSkillType fakeSkillType) {
// List<String> messages = new ArrayList<>();
//
// switch (fakeSkillType) {
// case MACHO:
// messages.add(LocaleLoader.formatString("&cDamage Taken: &e{0}%", decimal.format(Misc.getRandom().nextInt(77))));
// break;
// case JUMPING:
// messages.add(LocaleLoader.formatString("&cDouble Jump Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
// break;
// case THROWING:
// messages.add(LocaleLoader.formatString("&cDrop Item Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(87))));
// break;
// case WRECKING:
// messages.add(LocaleLoader.formatString("&cWrecking Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(14))));
// break;
// case CRAFTING:
// messages.add(LocaleLoader.formatString("&cCrafting Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
// break;
// case WALKING:
// messages.add(LocaleLoader.formatString("&cWalk Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
// break;
// case SWIMMING:
// messages.add(LocaleLoader.formatString("&cSwim Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
// break;
// case FALLING:
// messages.add(LocaleLoader.formatString("&cSkydiving Success: &e{0}%", decimal.format(Misc.getRandom().nextInt(37))));
// break;
// case CLIMBING:
// messages.add(LocaleLoader.formatString("&cRock Climber Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
// break;
// case FLYING:
// messages.add(LocaleLoader.formatString("&cFly Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
// break;
// case DIVING:
// messages.add(LocaleLoader.formatString("&cHold Breath Chance: &e{0}%", decimal.format(Misc.getRandom().nextInt(27))));
// break;
// case PIGGY:
// messages.add(LocaleLoader.formatString("&cCarrot Turbo Boost: &e{0}%", decimal.format(Misc.getRandom().nextInt(80)) + 10));
// break;
// }
//
// return messages;
// }
//}

View File

@@ -2,7 +2,6 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;

View File

@@ -19,15 +19,16 @@ import java.util.List;
public class SwordsCommand extends SkillCommand {
private String counterChance;
private String counterChanceLucky;
private int bleedLength;
private String bleedChance;
private String bleedChanceLucky;
private String serratedStrikesLength;
private String serratedStrikesLengthEndurance;
private String rupturePureTickDamageAgainstPlayers, rupturePureTickDamageAgainstMobs,
ruptureExplosionDamageAgainstPlayers, ruptureExplosionDamageAgainstMobs,
ruptureLengthSecondsAgainstPlayers, ruptureLengthSecondsAgainstMobs, ruptureChanceToApply, ruptureChanceToApplyLucky;
private boolean canCounter;
private boolean canSerratedStrike;
private boolean canBleed;
private boolean canRupture;
public SwordsCommand() {
super(PrimarySkillType.SWORDS);
@@ -43,12 +44,19 @@ public class SwordsCommand extends SkillCommand {
}
// SWORDS_RUPTURE
if (canBleed) {
bleedLength = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
if (canRupture) {
int ruptureRank = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE);
ruptureLengthSecondsAgainstPlayers = String.valueOf(AdvancedConfig.getInstance().getRuptureDurationSeconds(true));
ruptureLengthSecondsAgainstMobs = String.valueOf(AdvancedConfig.getInstance().getRuptureDurationSeconds(false));
String[] bleedStrings = getAbilityDisplayValues(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, player, SubSkillType.SWORDS_RUPTURE);
bleedChance = bleedStrings[0];
bleedChanceLucky = bleedStrings[1];
rupturePureTickDamageAgainstPlayers = String.valueOf(AdvancedConfig.getInstance().getRuptureTickDamage(true, ruptureRank));
rupturePureTickDamageAgainstMobs = String.valueOf(AdvancedConfig.getInstance().getRuptureTickDamage(false, ruptureRank));
ruptureExplosionDamageAgainstPlayers = String.valueOf(AdvancedConfig.getInstance().getRuptureExplosionDamage(true, ruptureRank));
ruptureExplosionDamageAgainstMobs = String.valueOf(AdvancedConfig.getInstance().getRuptureExplosionDamage(false, ruptureRank));
ruptureChanceToApply = String.valueOf(AdvancedConfig.getInstance().getRuptureChanceToApplyOnHit(ruptureRank) + "%");
ruptureChanceToApplyLucky = String.valueOf(AdvancedConfig.getInstance().getRuptureChanceToApplyOnHit(ruptureRank) * 1.33);
}
// SERRATED STRIKES
@@ -61,7 +69,7 @@ public class SwordsCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canBleed = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
canRupture = canUseSubskill(player, SubSkillType.SWORDS_RUPTURE);
canCounter = canUseSubskill(player, SubSkillType.SWORDS_COUNTER_ATTACK);
canSerratedStrike = RankUtils.hasUnlockedSubskill(player, SubSkillType.SWORDS_SERRATED_STRIKES) && Permissions.serratedStrikes(player);
}
@@ -70,22 +78,20 @@ public class SwordsCommand extends SkillCommand {
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<>();
int ruptureTicks = UserManager.getPlayer(player).getSwordsManager().getRuptureBleedTicks();
double ruptureDamagePlayers = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamagePlayer() * 1.5D : AdvancedConfig.getInstance().getRuptureDamagePlayer();
double ruptureDamageMobs = RankUtils.getRank(player, SubSkillType.SWORDS_RUPTURE) >= 3 ? AdvancedConfig.getInstance().getRuptureDamageMobs() * 1.5D : AdvancedConfig.getInstance().getRuptureDamageMobs();
if (canCounter) {
messages.add(getStatMessage(SubSkillType.SWORDS_COUNTER_ATTACK, counterChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterChanceLucky) : ""));
}
if (canBleed) {
messages.add(getStatMessage(SubSkillType.SWORDS_RUPTURE, bleedChance)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
if (canRupture) {
messages.add(getStatMessage(SubSkillType.SWORDS_RUPTURE, ruptureChanceToApply)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ruptureChanceToApplyLucky) : ""));
messages.add(getStatMessage(true, true, SubSkillType.SWORDS_RUPTURE,
String.valueOf(ruptureTicks),
String.valueOf(ruptureDamagePlayers),
String.valueOf(ruptureDamageMobs)));
ruptureLengthSecondsAgainstPlayers,
ruptureLengthSecondsAgainstMobs));
messages.add(LocaleLoader.getString("Swords.SubSkill.Rupture.Stat.TickDamage", rupturePureTickDamageAgainstPlayers, rupturePureTickDamageAgainstMobs));
messages.add(LocaleLoader.getString("Swords.SubSkill.Rupture.Stat.ExplosionDamage", ruptureExplosionDamageAgainstPlayers, ruptureExplosionDamageAgainstMobs));
messages.add(LocaleLoader.getString("Swords.Combat.Rupture.Note"));
}

View File

@@ -310,25 +310,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
}
/* SWORDS */
if (getMaximumProbability(SubSkillType.SWORDS_RUPTURE) < 1) {
reason.add("Skills.Swords.Rupture.ChanceMax should be at least 1!");
}
if (getMaxBonusLevel(SubSkillType.SWORDS_RUPTURE) < 1) {
reason.add("Skills.Swords.Rupture.MaxBonusLevel should be at least 1!");
}
if (getRuptureMaxTicks() < 1) {
reason.add("Skills.Swords.Rupture.MaxTicks should be at least 1!");
}
if (getRuptureMaxTicks() < getRuptureBaseTicks()) {
reason.add("Skills.Swords.Rupture.MaxTicks should be at least Skills.Swords.Rupture.BaseTicks!");
}
if (getRuptureBaseTicks() < 1) {
reason.add("Skills.Swords.Rupture.BaseTicks should be at least 1!");
}
if (getMaximumProbability(SubSkillType.SWORDS_COUNTER_ATTACK) < 1) {
reason.add("Skills.Swords.CounterAttack.ChanceMax should be at least 1!");
@@ -665,13 +646,11 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getGracefulRollDamageThreshold() { return config.getDouble("Skills.Acrobatics.GracefulRoll.DamageThreshold", 14.0D); }
/* ALCHEMY */
/*public int getCatalysisUnlockLevel() { return config.getInt("Skills.Alchemy.Catalysis.UnlockLevel", 100); }*/
public int getCatalysisMaxBonusLevel() { return config.getInt("Skills.Alchemy.Catalysis.MaxBonusLevel", 1000); }
public double getCatalysisMinSpeed() { return config.getDouble("Skills.Alchemy.Catalysis.MinSpeed", 1.0D); }
public double getCatalysisMaxSpeed() { return config.getDouble("Skills.Alchemy.Catalysis.MaxSpeed", 4.0D); }
//public int getConcoctionsTierLevel(Alchemy.Tier tier) { return config.getInt("Skills.Alchemy.Rank_Levels.Rank_" + rank); }
/* ARCHERY */
public double getSkillShotRankDamageMultiplier() { return config.getDouble("Skills.Archery.SkillShot.RankDamageMultiplier", 10.0D); }
@@ -700,7 +679,6 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
//Nothing to configure, everything is already configurable in config.yml
/* FISHING */
//public int getFishingTierLevel(int rank) { return config.getInt("Skills.Fishing.Rank_Levels.Rank_" + rank); }
public double getShakeChance(int rank) { return config.getDouble("Skills.Fishing.ShakeChance.Rank_" + rank); }
public int getFishingVanillaXPModifier(int rank) { return config.getInt("Skills.Fishing.VanillaXPMultiplier.Rank_" + rank); }
@@ -712,9 +690,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getFishingReductionMaxWaitCap() { return config.getInt("Skills.Fishing.MasterAngler.Tick_Reduction_Caps.Max_Wait", 100);}
public int getFishermanDietRankChange() { return config.getInt("Skills.Fishing.FishermansDiet.RankChange", 200); }
/*public int getIceFishingUnlockLevel() { return config.getInt("Skills.Fishing.IceFishing.UnlockLevel", 50); }
public int getMasterAnglerUnlockLevel() {return config.getInt("Skills.Fishing.MasterAngler.UnlockLevel", 125); }*/
public double getMasterAnglerBoatModifier() {return config.getDouble("Skills.Fishing.MasterAngler.BoatModifier", 2.0); }
public double getMasterAnglerBiomeModifier() {return config.getDouble("Skills.Fishing.MasterAngler.BiomeModifier", 2.0); }
@@ -737,23 +713,15 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public double getRepairMasteryMaxBonus() { return config.getDouble("Skills.Repair.RepairMastery.MaxBonusPercentage", 200.0D); }
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery.MaxBonusLevel", 100); }
/* Arcane Forging */
//public int getArcaneForgingRankLevel(int rank) { return config.getInt("Skills.Repair.ArcaneForging.Rank_Levels.Rank_" + rank); }
public boolean getArcaneForgingEnchantLossEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.May_Lose_Enchants", true); }
public double getArcaneForgingKeepEnchantsChance(int rank) { return config.getDouble("Skills.Repair.ArcaneForging.Keep_Enchants_Chance.Rank_" + rank); }
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Skills.Repair.ArcaneForging.Downgrades_Enabled", true); }
public double getArcaneForgingDowngradeChance(int rank) { return config.getDouble("Skills.Repair.ArcaneForging.Downgrades_Chance.Rank_" + rank); }
/* SALVAGE */
//public double getSalvageMaxPercentage() { return config.getDouble("Skills.Salvage.MaxPercentage", 100.0D); }
//public int getSalvageMaxPercentageLevel() { return config.getInt("Skills.Salvage.MaxPercentageLevel", 1000); }
public boolean getArcaneSalvageEnchantDowngradeEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantDowngradeEnabled", true); }
public boolean getArcaneSalvageEnchantLossEnabled() { return config.getBoolean("Skills.Salvage.ArcaneSalvage.EnchantLossEnabled", true); }
//public int getArcaneSalvageRankLevel(int rank) { return config.getInt("Skills.Salvage.ArcaneSalvage.Rank_Levels.Rank_" + rank); }
public double getArcaneSalvageExtractFullEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractFullEnchant.Rank_" + rank); }
public double getArcaneSalvageExtractPartialEnchantsChance(int rank) { return config.getDouble("Skills.Salvage.ArcaneSalvage.ExtractPartialEnchant.Rank_" + rank); }
@@ -765,19 +733,35 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
return config.getInt("Skills.Smelting.FuelEfficiency.Standard.MaxBonusLevel", 100);
}
/*public int getFluxMiningUnlockLevel() { return config.getInt("Skills.Smelting.FluxMining.UnlockLevel", 250); }*/
public double getFluxMiningChance() { return config.getDouble("Skills.Smelting.FluxMining.Chance", 33.0D); }
public int getSmeltingRankLevel(int rank) { return config.getInt("Skills.Smelting.Rank_Levels.Rank_" + rank); }
public int getSmeltingVanillaXPBoostMultiplier(int rank) { return config.getInt("Skills.Smelting.VanillaXPMultiplier.Rank_" + rank); }
/* SWORDS */
public double getRuptureDamagePlayer() { return config.getDouble("Skills.Swords.Rupture.DamagePlayer", 1.0); }
public double getRuptureDamageMobs() { return config.getDouble("Skills.Swords.Rupture.DamageMobs", 2.0); }
public double getRuptureTickDamage(boolean isTargetPlayer, int rank) {
String root = "Skills.Swords.Rupture.Rupture_Mechanics.Tick_Interval_Damage.Against_";
String targetType = isTargetPlayer ? "Players" : "Mobs";
String key = root + targetType + ".Rank_" + rank;
public int getRuptureMaxTicks() { return config.getInt("Skills.Swords.Rupture.MaxTicks", 8); }
public int getRuptureBaseTicks() { return config.getInt("Skills.Swords.Rupture.BaseTicks", 2); }
return config.getDouble(key, 1.0D);
}
public int getRuptureDurationSeconds(boolean isTargetPlayer) {
String root = "Skills.Swords.Rupture.Rupture_Mechanics.Duration_In_Seconds.Against_";
String targetType = isTargetPlayer ? "Players" : "Mobs";
return config.getInt(root + targetType, 5);
}
public double getRuptureExplosionDamage(boolean isTargetPlayer, int rank) {
String root = "Skills.Swords.Rupture.Rupture_Mechanics.Explosion_Damage.Against_";
String targetType = isTargetPlayer ? "Players" : "Mobs";
String key = root + targetType + ".Rank_" + rank;
return config.getDouble(key, 40.0D);
}
public double getRuptureChanceToApplyOnHit(int rank) {
String root = "Skills.Swords.Rupture.Rupture_Mechanics.Chance_To_Apply_On_Hit.Rank_";
return config.getDouble(root + rank, 33);
}
public double getCounterModifier() { return config.getDouble("Skills.Swords.CounterAttack.DamageModifier", 2.0D); }
@@ -785,24 +769,15 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
public int getSerratedStrikesTicks() { return config.getInt("Skills.Swords.SerratedStrikes.RuptureTicks", 5); }
/* TAMING */
//public int getGoreRuptureTicks() { return config.getInt("Skills.Taming.Gore.RuptureTicks", 2); }
public double getGoreModifier() { return config.getDouble("Skills.Taming.Gore.Modifier", 2.0D); }
/*public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood.UnlockLevel", 50); }*/
public double getFastFoodChance() { return config.getDouble("Skills.Taming.FastFoodService.Chance", 50.0D); }
public double getPummelChance() { return config.getDouble("Skills.Taming.Pummel.Chance", 10.0D); }
//public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware.UnlockLevel", 100); }
/*public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur.UnlockLevel", 250); }*/
public double getThickFurModifier() { return config.getDouble("Skills.Taming.ThickFur.Modifier", 2.0D); }
/*public int getHolyHoundUnlock() {return config.getInt("Skills.Taming.HolyHound.UnlockLevel", 375); }*/
/*public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof.UnlockLevel", 500); }*/
public double getShockProofModifier() { return config.getDouble("Skills.Taming.ShockProof.Modifier", 6.0D); }
/*public int getSharpenedClawsUnlock() { return config.getInt("Skills.Taming.SharpenedClaws.UnlockLevel", 750); }*/
public double getSharpenedClawsBonus() { return config.getDouble("Skills.Taming.SharpenedClaws.Bonus", 2.0D); }
public double getMinHorseJumpStrength() { return config.getDouble("Skills.Taming.CallOfTheWild.MinHorseJumpStrength", 0.7D); }

View File

@@ -53,11 +53,11 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
needSave = true;
}
for (String key : oldKeys) {
plugin.debug("Detected potentially unused key: " + key);
//config.set(key, null);
}
//
// for (String key : oldKeys) {
// plugin.debug("Detected potentially unused key: " + key);
// //config.set(key, null);
// }
for (String key : newKeys) {
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));

View File

@@ -243,8 +243,6 @@ public class Config extends AutoUpdateConfigLoader {
* GENERAL SETTINGS
*/
public boolean isAprilFoolsAllowed() { return config.getBoolean("General.AprilFoolsEvent", true); }
/* General Settings */
public boolean getIsMetricsEnabled() { return config.getBoolean("Metrics.bstats", true); }

View File

@@ -25,7 +25,10 @@ public class TreasureConfig extends ConfigLoader {
public static final String FILENAME = "treasures.yml";
public static final String LEVEL_REQUIREMENT_RETRO_MODE = ".Level_Requirement.Retro_Mode";
public static final String LEVEL_REQUIREMENT_STANDARD_MODE = ".Level_Requirement.Standard_Mode";
public static final String WRONG_KEY_VALUE_STANDARD = ".Drop_Level.Standard_Mode";
public static final String WRONG_KEY_VALUE_RETRO = ".Drop_Level.Retro_Mode";
public static final String LEGACY_DROP_LEVEL = ".Drop_Level";
public static final String WRONG_KEY_ROOT = ".Drop_Level";
private static TreasureConfig instance;
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<>();
@@ -65,7 +68,7 @@ public class TreasureConfig extends ConfigLoader {
}
private void loadTreasures(String type) {
boolean updatedFile = false;
boolean shouldWeUpdateFile = false;
boolean isExcavation = type.equals("Excavation");
boolean isHylian = type.equals("Hylian_Luck");
@@ -109,28 +112,38 @@ public class TreasureConfig extends ConfigLoader {
int xp = config.getInt(type + "." + treasureName + ".XP");
double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
int legacyDropLevel = config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1);
DropLevelKeyConversionType conversionType;
//Check for legacy drop level values and convert
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.LEGACY) != -1) {
//Legacy Drop level, needs to be converted
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.LEGACY);
}
//Check for a bad key that was accidentally shipped out to some users
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD) != -1) {
//Partially converted to the new system, I had a dyslexic moment so some configs have this
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.WRONG_KEY_STANDARD);
}
//Check for a bad key that was accidentally shipped out to some users
if(getWrongKeyValue(type, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO) != -1) {
//Partially converted to the new system, I had a dyslexic moment so some configs have this
shouldWeUpdateFile = processAutomaticKeyConversion(type, shouldWeUpdateFile, treasureName, DropLevelKeyConversionType.WRONG_KEY_RETRO);
}
int dropLevel = -1;
if(legacyDropLevel >= 0) {
//Config needs to be updated to be more specific
mcMMO.p.getLogger().info("(" + treasureName + ") Updating Drop_Level in treasures.yml for treasure to match new expected format");
config.set(type + "." + treasureName + LEGACY_DROP_LEVEL, null);
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, legacyDropLevel * 10);
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, legacyDropLevel);
updatedFile = true;
}
if(mcMMO.isRetroModeEnabled()) {
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, 0);
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, -1);
} else {
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, 0);
dropLevel = config.getInt(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, -1);
}
if(dropLevel < 0) {
mcMMO.p.getLogger().info("Treasure drop level wasn't valid, using a default value.");
//Set it to the "max" if we don't have a drop level
dropLevel = 0;
if(dropLevel == -1) {
mcMMO.p.getLogger().severe("Could not find a Level_Requirement entry for treasure " + treasureName);
mcMMO.p.getLogger().severe("Skipping treasure");
continue;
}
if (xp < 0) {
@@ -141,7 +154,6 @@ public class TreasureConfig extends ConfigLoader {
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
}
/*
* Itemstack
*/
@@ -246,7 +258,7 @@ public class TreasureConfig extends ConfigLoader {
}
//Apply our fix
if(updatedFile) {
if(shouldWeUpdateFile) {
try {
config.save(getFile());
} catch (IOException e) {
@@ -255,6 +267,63 @@ public class TreasureConfig extends ConfigLoader {
}
}
private boolean processAutomaticKeyConversion(String type, boolean shouldWeUpdateTheFile, String treasureName, DropLevelKeyConversionType conversionType) {
switch (conversionType) {
case LEGACY:
int legacyDropLevel = getWrongKeyValue(type, treasureName, conversionType); //Legacy only had one value, Retro Mode didn't have a setting
//Config needs to be updated to be more specific
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: Legacy] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
config.set(type + "." + treasureName + LEGACY_DROP_LEVEL, null); //Remove legacy entry
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, legacyDropLevel * 10); //Multiply by 10 for Retro
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, legacyDropLevel);
shouldWeUpdateTheFile = true;
break;
case WRONG_KEY_STANDARD:
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: STANDARD] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
int wrongKeyValueStandard = getWrongKeyValue(type, treasureName, conversionType);
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
if(wrongKeyValueStandard != -1) {
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_STANDARD_MODE, wrongKeyValueStandard);
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, wrongKeyValueStandard * 10); //Multiply by 10 for Retro
}
shouldWeUpdateTheFile = true;
break;
case WRONG_KEY_RETRO:
mcMMO.p.getLogger().info("(" + treasureName + ") [Fixing bad address: RETRO] Converting Drop_Level to Level_Requirement in treasures.yml for treasure to match new expected format");
int wrongKeyValueRetro = getWrongKeyValue(type, treasureName, conversionType);
config.set(type + "." + treasureName + WRONG_KEY_ROOT, null); //We also kill the Retro key here as we have enough information for setting in values if needed
if(wrongKeyValueRetro != -1) {
config.set(type + "." + treasureName + LEVEL_REQUIREMENT_RETRO_MODE, wrongKeyValueRetro);
}
shouldWeUpdateTheFile = true;
break;
}
return shouldWeUpdateTheFile;
}
private int getWrongKeyValue(String type, String treasureName, DropLevelKeyConversionType dropLevelKeyConversionType) {
switch (dropLevelKeyConversionType) {
case LEGACY:
return config.getInt(type + "." + treasureName + LEGACY_DROP_LEVEL, -1);
case WRONG_KEY_STANDARD:
return config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_STANDARD, -1);
case WRONG_KEY_RETRO:
return config.getInt(type + "." + treasureName + WRONG_KEY_VALUE_RETRO, -1);
}
return -1;
}
private enum DropLevelKeyConversionType {
LEGACY,
WRONG_KEY_STANDARD,
WRONG_KEY_RETRO
}
private void AddHylianTreasure(String dropper, HylianTreasure treasure) {
if (!hylianMap.containsKey(dropper))
hylianMap.put(dropper, new ArrayList<>());

View File

@@ -0,0 +1,25 @@
package com.gmail.nossr50.datatypes.meta;
import com.gmail.nossr50.runnables.skills.RuptureTask;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
public class RuptureTaskMeta extends FixedMetadataValue {
private final @NotNull RuptureTask ruptureTask;
/**
* Initializes a FixedMetadataValue with an Object
*
* @param owningPlugin the {@link Plugin} that created this metadata value
* @param ruptureTask the value assigned to this metadata value
*/
public RuptureTaskMeta(@NotNull Plugin owningPlugin, @NotNull RuptureTask ruptureTask) {
super(owningPlugin, ruptureTask);
this.ruptureTask = ruptureTask;
}
public @NotNull RuptureTask getRuptureTimerTask() {
return ruptureTask;
}
}

View File

@@ -530,6 +530,10 @@ public class EntityListener implements Listener {
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return;
if(event.getEntity().hasMetadata(mcMMO.EXPLOSION_FROM_RUPTURE)) {
event.getEntity().removeMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, mcMMO.p);
}
if(event.getEntity() instanceof Player)
{
Player player = (Player) event.getEntity();
@@ -702,7 +706,7 @@ public class EntityListener implements Listener {
*/
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDeathLowest(EntityDeathEvent event) {
mcMMO.getTransientMetadataTools().cleanAllMobMetadata(event.getEntity());
mcMMO.getTransientMetadataTools().cleanAllLivingEntityMetadata(event.getEntity());
}
/**

View File

@@ -546,6 +546,7 @@ public class PlayerListener implements Listener {
//Use a sync save if the server is shutting down to avoid race conditions
//TODO: Actually never sure its possible for this event to fire during server shutdown, should double check that...
UserManager.logout(mcMMOPlayer, mcMMO.isServerShutdownExecuted());
mcMMO.getTransientMetadataTools().cleanAllLivingEntityMetadata(event.getPlayer());
}
/**
@@ -972,16 +973,53 @@ public class PlayerListener implements Listener {
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
/**
* When a {@link Player} attempts to place an {@link ItemStack}
* into an {@link ItemFrame}, we want to make sure to remove any
* Ability buffs from that item.
*
* @param event The {@link PlayerInteractEntityEvent} to handle
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
/*
* We can check for an instance instead of EntityType here, so we are
* ready for the infamous "Glow Item Frame" in 1.17 too!
*/
if (event.getRightClicked() instanceof ItemFrame) {
ItemFrame frame = (ItemFrame) event.getRightClicked();
if (!mcMMO.getHolidayManager().isAprilFirst()) {
return;
// Check for existing items (ignore rotations)
if (frame.getItem().getType() != Material.AIR) {
return;
}
// Get the item the Player is about to place
ItemStack itemInHand;
if (event.getHand() == EquipmentSlot.OFF_HAND) {
itemInHand = event.getPlayer().getInventory().getItemInOffHand();
}
else {
itemInHand = event.getPlayer().getInventory().getItemInMainHand();
}
// and remove any skill ability buffs!
SkillUtils.removeAbilityBuff(itemInHand);
}
mcMMO.getHolidayManager().handleStatisticEvent(event);
}
//
// @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
// public void onPlayerStatisticIncrementEvent(PlayerStatisticIncrementEvent event) {
// /* WORLD BLACKLIST CHECK */
// if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
// return;
//
// if (!mcMMO.getHolidayManager().isAprilFirst()) {
// return;
// }
//
// mcMMO.getHolidayManager().handleStatisticEvent(event);
// }
}

View File

@@ -14,7 +14,7 @@ import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.subskills.acrobatics.Roll;
import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.runnables.CheckDateTask;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.SaveTimerTask;
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
import com.gmail.nossr50.runnables.commands.NotifySquelchReminderTask;
@@ -23,7 +23,6 @@ import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
import com.gmail.nossr50.runnables.player.ClearRegisteredXPGainTask;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.child.ChildConfig;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
@@ -78,7 +77,6 @@ public class mcMMO extends JavaPlugin {
private static ModManager modManager;
private static DatabaseManager databaseManager;
private static FormulaManager formulaManager;
private static HolidayManager holidayManager;
private static UpgradeManager upgradeManager;
private static MaterialMapStore materialMapStore;
private static PlayerLevelUtils playerLevelUtils;
@@ -126,6 +124,8 @@ public class mcMMO extends JavaPlugin {
/* Metadata Values */
public static final String REPLANT_META_KEY = "mcMMO: Recently Replanted";
public static final String EXPLOSION_FROM_RUPTURE = "mcMMO: Rupture Explosion";
public static final String RUPTURE_META_KEY = "mcMMO: RuptureTask";
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
public static final String DODGE_TRACKER = "mcMMO: Dodge Tracker";
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
@@ -149,9 +149,6 @@ public class mcMMO extends JavaPlugin {
public static FixedMetadataValue metadataValue;
public static final String ULTRA_PERMISSONS = "UltraPermissons";
public static final String UP_WARNING_2 = "Stop using " + ULTRA_PERMISSONS + " with mcMMO immediately!";
public static final String UP_WARNING_1 = "mcMMO has detected " + ULTRA_PERMISSONS + " on your server, users have reported a severe plugin conflict between these two plugins which severely degrades server performance";
public static final String UP_WARNING_3 = "The author of UltraPermissions has passed away and its unlikely this issue will ever be solved";
public mcMMO() {
p = this;
@@ -234,7 +231,6 @@ public class mcMMO extends JavaPlugin {
mcMMO.getPartyManager().loadParties();
formulaManager = new FormulaManager();
holidayManager = new HolidayManager();
for (Player player : getServer().getOnlinePlayers()) {
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
@@ -267,18 +263,6 @@ public class mcMMO extends JavaPlugin {
else
metrics.addCustomChart(new SimplePie("leveling_system", () -> "Standard"));
}
if(pluginManager.getPlugin(ULTRA_PERMISSONS) != null) {
Bukkit.getScheduler().runTaskTimer(this, () -> {
getLogger().severe(UP_WARNING_1);
getLogger().severe(UP_WARNING_2);
getLogger().severe(UP_WARNING_3);
Bukkit.broadcastMessage(UP_WARNING_1);
Bukkit.broadcastMessage(UP_WARNING_2);
Bukkit.broadcastMessage(UP_WARNING_3);
}, 0L, 1200L);
}
}
catch (Throwable t) {
@@ -370,7 +354,6 @@ public class mcMMO extends JavaPlugin {
ScoreboardManager.teardownAll();
formulaManager.saveFormula();
holidayManager.saveAnniversaryFiles();
placeStore.closeAll();
}
catch (Exception e) {
@@ -443,10 +426,6 @@ public class mcMMO extends JavaPlugin {
return formulaManager;
}
public static HolidayManager getHolidayManager() {
return holidayManager;
}
public static ChunkManager getPlaceStore() {
return placeStore;
}
@@ -631,9 +610,6 @@ public class mcMMO extends JavaPlugin {
// Cleanup the backups folder
new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
// Bleed timer (Runs every 0.5 seconds)
new BleedTimerTask().runTaskTimer(this, Misc.TICK_CONVERSION_FACTOR, (Misc.TICK_CONVERSION_FACTOR / 2));
// Old & Powerless User remover
long purgeIntervalTicks = Config.getInstance().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR;
@@ -657,10 +633,6 @@ public class mcMMO extends JavaPlugin {
// Update power level tag scoreboards
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
if (getHolidayManager().nearingAprilFirst()) {
new CheckDateTask().runTaskTimer(this, 10L * Misc.TICK_CONVERSION_FACTOR, 60L * 60L * Misc.TICK_CONVERSION_FACTOR);
}
// Clear the registered XP data so players can earn XP again
if (ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
new ClearRegisteredXPGainTask().runTaskTimer(this, 60, 60);

View File

@@ -1,23 +1,23 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AprilTask;
import com.gmail.nossr50.util.Misc;
import org.bukkit.scheduler.BukkitRunnable;
public class CheckDateTask extends BukkitRunnable {
@Override
public void run() {
if (!mcMMO.getHolidayManager().isAprilFirst()) {
return;
}
// Set up jokes
new AprilTask().runTaskTimer(mcMMO.p, 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR);
mcMMO.getHolidayManager().registerAprilCommand();
// Jokes deployed.
this.cancel();
}
}
//package com.gmail.nossr50.runnables;
//
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.runnables.skills.AprilTask;
//import com.gmail.nossr50.util.Misc;
//import org.bukkit.scheduler.BukkitRunnable;
//
//public class CheckDateTask extends BukkitRunnable {
//
// @Override
// public void run() {
// if (!mcMMO.getHolidayManager().isAprilFirst()) {
// return;
// }
//
// // Set up jokes
// new AprilTask().runTaskTimer(mcMMO.p, 60L * Misc.TICK_CONVERSION_FACTOR, 10L * 60L * Misc.TICK_CONVERSION_FACTOR);
// mcMMO.getHolidayManager().registerAprilCommand();
//
// // Jokes deployed.
// this.cancel();
// }
//}

View File

@@ -1,56 +1,56 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.ChatColor;
import org.bukkit.Statistic;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class AprilTask extends BukkitRunnable {
@Override
public void run() {
if (!mcMMO.getHolidayManager().isAprilFirst()) {
this.cancel();
return;
}
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
int random = Misc.getRandom().nextInt(40) + 11;
int betterRandom = Misc.getRandom().nextInt(2000);
if (betterRandom == 0) {
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")");
// fireworksShow(player);
}
for (Statistic statistic : mcMMO.getHolidayManager().movementStatistics) {
if (player.getStatistic(statistic) > 0 && player.getStatistic(statistic) % random == 0) {
mcMMO.getHolidayManager().levelUpApril(player, HolidayManager.FakeSkillType.getByStatistic(statistic));
break;
}
}
}
}
/*private void fireworksShow(final Player player) {
final int firework_amount = 10;
for (int i = 0; i < firework_amount; i++) {
int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
@Override
public void run() {
mcMMO.getHolidayManager().spawnFireworks(player);
}
}, delay);
}
}*/
private String unknown(String string) {
return ChatColor.MAGIC + string + ChatColor.RESET + ChatColor.YELLOW;
}
}
//package com.gmail.nossr50.runnables.skills;
//
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.HolidayManager;
//import com.gmail.nossr50.util.Misc;
//import com.gmail.nossr50.util.sounds.SoundManager;
//import com.gmail.nossr50.util.sounds.SoundType;
//import org.bukkit.ChatColor;
//import org.bukkit.Statistic;
//import org.bukkit.entity.Player;
//import org.bukkit.scheduler.BukkitRunnable;
//
//public class AprilTask extends BukkitRunnable {
//
// @Override
// public void run() {
// if (!mcMMO.getHolidayManager().isAprilFirst()) {
// this.cancel();
// return;
// }
//
// for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
// int random = Misc.getRandom().nextInt(40) + 11;
// int betterRandom = Misc.getRandom().nextInt(2000);
// if (betterRandom == 0) {
// SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
// player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")");
//// fireworksShow(player);
// }
//
// for (Statistic statistic : mcMMO.getHolidayManager().movementStatistics) {
// if (player.getStatistic(statistic) > 0 && player.getStatistic(statistic) % random == 0) {
// mcMMO.getHolidayManager().levelUpApril(player, HolidayManager.FakeSkillType.getByStatistic(statistic));
// break;
// }
// }
// }
// }
//
// /*private void fireworksShow(final Player player) {
// final int firework_amount = 10;
// for (int i = 0; i < firework_amount; i++) {
// int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
// mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
// @Override
// public void run() {
// mcMMO.getHolidayManager().spawnFireworks(player);
// }
// }, delay);
// }
// }*/
//
// private String unknown(String string) {
// return ChatColor.MAGIC + string + ChatColor.RESET + ChatColor.YELLOW;
// }
//}

View File

@@ -1,214 +1,214 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
public class BleedTimerTask extends BukkitRunnable {
private static final @NotNull Map<LivingEntity, BleedContainer> bleedList = new HashMap<>();
private static boolean isIterating = false;
@Override
public void run() {
isIterating = true;
Iterator<Entry<LivingEntity, BleedContainer>> bleedIterator = bleedList.entrySet().iterator();
while (bleedIterator.hasNext()) {
Entry<LivingEntity, BleedContainer> containerEntry = bleedIterator.next();
LivingEntity target = containerEntry.getKey();
int toolTier = containerEntry.getValue().toolTier;
// String debugMessage = "";
// debugMessage += ChatColor.GOLD + "Target ["+target.getName()+"]: " + ChatColor.RESET;
// debugMessage+="RemainingTicks=["+containerEntry.getValue().bleedTicks+"], ";
if (containerEntry.getValue().bleedTicks <= 0 || !target.isValid()) {
if(target instanceof Player)
{
NotificationManager.sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Stopped");
}
bleedIterator.remove();
continue;
}
int armorCount = 0;
double damage;
if (target instanceof Player) {
damage = AdvancedConfig.getInstance().getRuptureDamagePlayer();
//Above Bleed Rank 3 deals 50% more damage
if (containerEntry.getValue().toolTier >= 4 && containerEntry.getValue().bleedRank >= 3)
damage = damage * 1.5;
Player player = (Player) target;
if (!player.isOnline()) {
continue;
}
//Count Armor
for (ItemStack armorPiece : ((Player) target).getInventory().getArmorContents()) {
//We only want to count slots that contain armor.
if (armorPiece != null) {
armorCount++;
}
}
} else {
damage = AdvancedConfig.getInstance().getRuptureDamageMobs();
// debugMessage+="BaseDMG=["+damage+"], ";
//Above Bleed Rank 3 deals 50% more damage
if (containerEntry.getValue().bleedRank >= 3)
{
damage = damage * 1.5;
}
// debugMessage+="Rank4Bonus=["+String.valueOf(containerEntry.getValue().bleedRank >= 3)+"], ";
MobHealthbarUtils.handleMobHealthbars(target, damage, mcMMO.p); //Update health bars
}
// debugMessage+="FullArmor=["+String.valueOf(armorCount > 3)+"], ";
if(armorCount > 3)
{
damage = damage * .75;
}
// debugMessage+="AfterRankAndArmorChecks["+damage+"], ";
//Weapons below Diamond get damage cut in half
if(toolTier < 4)
damage = damage / 2;
// debugMessage+="AfterDiamondCheck=["+String.valueOf(damage)+"], ";
//Wood weapons get damage cut in half again
if(toolTier < 2)
damage = damage / 2;
// debugMessage+="AfterWoodenCheck=["+String.valueOf(damage)+"], ";
double victimHealth = target.getHealth();
// debugMessage+="TargetHealthBeforeDMG=["+String.valueOf(target.getHealth())+"], ";
//Fire a fake event
FakeEntityDamageByEntityEvent fakeEntityDamageByEntityEvent = (FakeEntityDamageByEntityEvent) CombatUtils.sendEntityDamageEvent(containerEntry.getValue().damageSource, target, EntityDamageEvent.DamageCause.CUSTOM, damage);
Bukkit.getPluginManager().callEvent(fakeEntityDamageByEntityEvent);
CombatUtils.dealNoInvulnerabilityTickDamageRupture(target, damage, containerEntry.getValue().damageSource, toolTier);
double victimHealthAftermath = target.getHealth();
// debugMessage+="TargetHealthAfterDMG=["+String.valueOf(target.getHealth())+"], ";
if(victimHealthAftermath <= 0 || victimHealth != victimHealthAftermath)
{
//Play Bleed Sound
SoundManager.worldSendSound(target.getWorld(), target.getLocation(), SoundType.BLEED);
ParticleEffectUtils.playBleedEffect(target);
}
//Lower Bleed Ticks
BleedContainer loweredBleedContainer = copyContainer(containerEntry.getValue());
loweredBleedContainer.bleedTicks -= 1;
// debugMessage+="RemainingTicks=["+loweredBleedContainer.bleedTicks+"]";
containerEntry.setValue(loweredBleedContainer);
// Bukkit.broadcastMessage(debugMessage);
}
isIterating = false;
}
public static @NotNull BleedContainer copyContainer(@NotNull BleedContainer container)
{
LivingEntity target = container.target;
LivingEntity source = container.damageSource;
int bleedTicks = container.bleedTicks;
int bleedRank = container.bleedRank;
int toolTier = container.toolTier;
return new BleedContainer(target, bleedTicks, bleedRank, toolTier, source);
}
/**
* Instantly Bleed out a LivingEntity
*
* @param entity LivingEntity to bleed out
*/
public static void bleedOut(@NotNull LivingEntity entity) {
/*
* Don't remove anything from the list outside of run()
*/
if (bleedList.containsKey(entity)) {
CombatUtils.dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity).bleedTicks * 2, bleedList.get(entity).damageSource);
}
}
/**
* Add a LivingEntity to the bleedList if it is not in it.
*
* @param entity LivingEntity to add
* @param attacker source of the bleed/rupture
* @param ticks Number of bleeding ticks
*/
public static void add(@NotNull LivingEntity entity, @NotNull LivingEntity attacker, int ticks, int bleedRank, int toolTier) {
if (!Bukkit.isPrimaryThread()) {
throw new IllegalStateException("Cannot add bleed task async!");
}
if(isIterating) {
//Used to throw an error here, but in reality all we are really doing is preventing concurrency issues from other plugins being naughty and its not really needed
//I'm not really a fan of silent errors, but I'm sick of seeing people using crazy enchantments come in and report this "bug"
return;
}
// if (isIterating) throw new IllegalStateException("Cannot add task while iterating timers!");
if(toolTier < 4)
ticks = Math.max(1, (ticks / 3));
ticks+=1;
BleedContainer newBleedContainer = new BleedContainer(entity, ticks, bleedRank, toolTier, attacker);
bleedList.put(entity, newBleedContainer);
}
public static boolean isBleedOperationAllowed() {
return !isIterating && Bukkit.isPrimaryThread();
}
public static boolean isBleeding(@NotNull LivingEntity entity) {
return bleedList.containsKey(entity);
}
}
//package com.gmail.nossr50.runnables.skills;
//
//import com.gmail.nossr50.config.AdvancedConfig;
//import com.gmail.nossr50.datatypes.interactions.NotificationType;
//import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.MobHealthbarUtils;
//import com.gmail.nossr50.util.player.NotificationManager;
//import com.gmail.nossr50.util.skills.CombatUtils;
//import com.gmail.nossr50.util.skills.ParticleEffectUtils;
//import com.gmail.nossr50.util.sounds.SoundManager;
//import com.gmail.nossr50.util.sounds.SoundType;
//import org.bukkit.Bukkit;
//import org.bukkit.entity.LivingEntity;
//import org.bukkit.entity.Player;
//import org.bukkit.event.entity.EntityDamageEvent;
//import org.bukkit.inventory.ItemStack;
//import org.bukkit.scheduler.BukkitRunnable;
//import org.jetbrains.annotations.NotNull;
//
//import java.util.HashMap;
//import java.util.Iterator;
//import java.util.Map;
//import java.util.Map.Entry;
//
//public class BleedTimerTask extends BukkitRunnable {
// private static final @NotNull Map<LivingEntity, BleedContainer> bleedList = new HashMap<>();
// private static boolean isIterating = false;
//
// @Override
// public void run() {
// isIterating = true;
// Iterator<Entry<LivingEntity, BleedContainer>> bleedIterator = bleedList.entrySet().iterator();
//
// while (bleedIterator.hasNext()) {
// Entry<LivingEntity, BleedContainer> containerEntry = bleedIterator.next();
// LivingEntity target = containerEntry.getKey();
// int toolTier = containerEntry.getValue().toolTier;
//
//// String debugMessage = "";
//// debugMessage += ChatColor.GOLD + "Target ["+target.getName()+"]: " + ChatColor.RESET;
//
//// debugMessage+="RemainingTicks=["+containerEntry.getValue().bleedTicks+"], ";
//
// if (containerEntry.getValue().bleedTicks <= 0 || !target.isValid()) {
// if(target instanceof Player)
// {
// NotificationManager.sendPlayerInformation((Player) target, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Stopped");
// }
//
// bleedIterator.remove();
// continue;
// }
//
// int armorCount = 0;
//
// double damage;
//
// if (target instanceof Player) {
// damage = AdvancedConfig.getInstance().getRuptureDamagePlayer();
//
// //Above Bleed Rank 3 deals 50% more damage
// if (containerEntry.getValue().toolTier >= 4 && containerEntry.getValue().bleedRank >= 3)
// damage = damage * 1.5;
//
// Player player = (Player) target;
//
// if (!player.isOnline()) {
// continue;
// }
//
// //Count Armor
// for (ItemStack armorPiece : ((Player) target).getInventory().getArmorContents()) {
// //We only want to count slots that contain armor.
// if (armorPiece != null) {
// armorCount++;
// }
// }
//
// } else {
// damage = AdvancedConfig.getInstance().getRuptureDamageMobs();
//
//// debugMessage+="BaseDMG=["+damage+"], ";
//
// //Above Bleed Rank 3 deals 50% more damage
// if (containerEntry.getValue().bleedRank >= 3)
// {
// damage = damage * 1.5;
// }
//
//// debugMessage+="Rank4Bonus=["+String.valueOf(containerEntry.getValue().bleedRank >= 3)+"], ";
//
//
// MobHealthbarUtils.handleMobHealthbars(target, damage, mcMMO.p); //Update health bars
// }
//
//// debugMessage+="FullArmor=["+String.valueOf(armorCount > 3)+"], ";
//
// if(armorCount > 3)
// {
// damage = damage * .75;
// }
//
//// debugMessage+="AfterRankAndArmorChecks["+damage+"], ";
//
// //Weapons below Diamond get damage cut in half
// if(toolTier < 4)
// damage = damage / 2;
//
//// debugMessage+="AfterDiamondCheck=["+String.valueOf(damage)+"], ";
//
// //Wood weapons get damage cut in half again
// if(toolTier < 2)
// damage = damage / 2;
//
//// debugMessage+="AfterWoodenCheck=["+String.valueOf(damage)+"], ";
//
// double victimHealth = target.getHealth();
//
//// debugMessage+="TargetHealthBeforeDMG=["+String.valueOf(target.getHealth())+"], ";
//
// //Fire a fake event
// FakeEntityDamageByEntityEvent fakeEntityDamageByEntityEvent = (FakeEntityDamageByEntityEvent) CombatUtils.sendEntityDamageEvent(containerEntry.getValue().damageSource, target, EntityDamageEvent.DamageCause.CUSTOM, damage);
// Bukkit.getPluginManager().callEvent(fakeEntityDamageByEntityEvent);
//
// CombatUtils.dealNoInvulnerabilityTickDamageRupture(target, damage, containerEntry.getValue().damageSource, toolTier);
//
// double victimHealthAftermath = target.getHealth();
//
//// debugMessage+="TargetHealthAfterDMG=["+String.valueOf(target.getHealth())+"], ";
//
// if(victimHealthAftermath <= 0 || victimHealth != victimHealthAftermath)
// {
// //Play Bleed Sound
// SoundManager.worldSendSound(target.getWorld(), target.getLocation(), SoundType.BLEED);
//
// ParticleEffectUtils.playBleedEffect(target);
// }
//
// //Lower Bleed Ticks
// BleedContainer loweredBleedContainer = copyContainer(containerEntry.getValue());
// loweredBleedContainer.bleedTicks -= 1;
//
//// debugMessage+="RemainingTicks=["+loweredBleedContainer.bleedTicks+"]";
// containerEntry.setValue(loweredBleedContainer);
//
//// Bukkit.broadcastMessage(debugMessage);
// }
// isIterating = false;
// }
//
// public static @NotNull BleedContainer copyContainer(@NotNull BleedContainer container)
// {
// LivingEntity target = container.target;
// LivingEntity source = container.damageSource;
// int bleedTicks = container.bleedTicks;
// int bleedRank = container.bleedRank;
// int toolTier = container.toolTier;
//
// return new BleedContainer(target, bleedTicks, bleedRank, toolTier, source);
// }
//
// /**
// * Instantly Bleed out a LivingEntity
// *
// * @param entity LivingEntity to bleed out
// */
// public static void bleedOut(@NotNull LivingEntity entity) {
// /*
// * Don't remove anything from the list outside of run()
// */
//
// if (bleedList.containsKey(entity)) {
// CombatUtils.dealNoInvulnerabilityTickDamage(entity, bleedList.get(entity).bleedTicks * 2, bleedList.get(entity).damageSource);
// }
// }
//
// /**
// * Add a LivingEntity to the bleedList if it is not in it.
// *
// * @param entity LivingEntity to add
// * @param attacker source of the bleed/rupture
// * @param ticks Number of bleeding ticks
// */
// public static void add(@NotNull LivingEntity entity, @NotNull LivingEntity attacker, int ticks, int bleedRank, int toolTier) {
// if (!Bukkit.isPrimaryThread()) {
// throw new IllegalStateException("Cannot add bleed task async!");
// }
//
// if(isIterating) {
// //Used to throw an error here, but in reality all we are really doing is preventing concurrency issues from other plugins being naughty and its not really needed
// //I'm not really a fan of silent errors, but I'm sick of seeing people using crazy enchantments come in and report this "bug"
// return;
// }
//
//// if (isIterating) throw new IllegalStateException("Cannot add task while iterating timers!");
//
// if(toolTier < 4)
// ticks = Math.max(1, (ticks / 3));
//
// ticks+=1;
//
// BleedContainer newBleedContainer = new BleedContainer(entity, ticks, bleedRank, toolTier, attacker);
// bleedList.put(entity, newBleedContainer);
// }
//
// public static boolean isBleedOperationAllowed() {
// return !isIterating && Bukkit.isPrimaryThread();
// }
//
// public static boolean isBleeding(@NotNull LivingEntity entity) {
// return bleedList.containsKey(entity);
// }
//}

View File

@@ -0,0 +1,137 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.base.Objects;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
public class RuptureTask extends BukkitRunnable {
public static final int DAMAGE_TICK_INTERVAL = 10;
private final @NotNull McMMOPlayer ruptureSource;
private final @NotNull LivingEntity targetEntity;
private final int expireTick;
private int ruptureTick;
private int damageTickTracker;
private final double pureTickDamage; //TODO: Make configurable
private final double explosionDamage; //TODO: Make configurable
public RuptureTask(@NotNull McMMOPlayer ruptureSource, @NotNull LivingEntity targetEntity, double pureTickDamage, double explosionDamage) {
this.ruptureSource = ruptureSource;
this.targetEntity = targetEntity;
this.expireTick = AdvancedConfig.getInstance().getRuptureDurationSeconds(targetEntity instanceof Player) * 20;
this.ruptureTick = 0;
this.damageTickTracker = 0;
this.pureTickDamage = pureTickDamage;
this.explosionDamage = explosionDamage;
}
@Override
public void run() {
//Check validity
if(targetEntity.isValid()) {
ruptureTick += 1; //Advance rupture tick by 1.
damageTickTracker += 1; //Increment damage tick tracker
//Rupture hasn't ended yet
if(ruptureTick < expireTick) {
//Is it time to damage?
if(damageTickTracker >= DAMAGE_TICK_INTERVAL) {
damageTickTracker = 0; //Reset
ParticleEffectUtils.playBleedEffect(targetEntity); //Animate
if(targetEntity.getHealth() > 0.01) {
double healthBeforeRuptureIsApplied = targetEntity.getHealth();
double damagedHealth = healthBeforeRuptureIsApplied - calculateAdjustedTickDamage();
if(damagedHealth <= 0) {
mcMMO.p.getLogger().severe("DEBUG: Miscalculating Rupture tick damage");
} else {
targetEntity.setHealth(damagedHealth); //Hurt entity without the unwanted side effects of damage()
}
}
}
} else {
explode();
}
} else {
targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
this.cancel(); //Task no longer needed
}
}
public void refreshRupture() {
damageTickTracker = DAMAGE_TICK_INTERVAL;
ruptureTick = 0;
}
public void explode() {
targetEntity.setMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, new FixedMetadataValue(mcMMO.p, "null"));
ParticleEffectUtils.playGreaterImpactEffect(targetEntity); //Animate
if(ruptureSource.getPlayer() != null && ruptureSource.getPlayer().isValid()) {
targetEntity.damage(getExplosionDamage(), ruptureSource.getPlayer());
} else {
targetEntity.damage(getExplosionDamage(), null);
}
targetEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, mcMMO.p);
this.cancel(); //Task no longer needed
}
private double calculateAdjustedTickDamage() {
double tickDamage = pureTickDamage;
if(targetEntity.getHealth() <= tickDamage) {
tickDamage = targetEntity.getHealth() - 0.01;
if(tickDamage <= 0) {
tickDamage = 0;
}
}
return tickDamage;
}
private double getExplosionDamage() {
return explosionDamage;
}
@Override
public String toString() {
return "RuptureTask{" +
"ruptureSource=" + ruptureSource +
", targetEntity=" + targetEntity +
", expireTick=" + expireTick +
", ruptureTick=" + ruptureTick +
", damageTickTracker=" + damageTickTracker +
", pureTickDamage=" + pureTickDamage +
", explosionDamage=" + explosionDamage +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RuptureTask that = (RuptureTask) o;
return expireTick == that.expireTick && ruptureTick == that.ruptureTick && damageTickTracker == that.damageTickTracker && Double.compare(that.pureTickDamage, pureTickDamage) == 0 && Double.compare(that.explosionDamage, explosionDamage) == 0 && Objects.equal(ruptureSource, that.ruptureSource) && Objects.equal(targetEntity, that.targetEntity);
}
@Override
public int hashCode() {
return Objects.hashCode(ruptureSource, targetEntity, expireTick, ruptureTick, damageTickTracker, pureTickDamage, explosionDamage);
}
}

View File

@@ -198,7 +198,7 @@ public class FishingManager extends SkillManager {
}
public double getShakeChance() {
return AdvancedConfig.getInstance().getShakeChance(getLootTier());
return AdvancedConfig.getInstance().getShakeChance(RankUtils.getRank(mmoPlayer.getPlayer(), SubSkillType.FISHING_SHAKE));
}
protected int getVanillaXPBoostModifier() {

View File

@@ -38,6 +38,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -109,22 +110,41 @@ public class HerbalismManager extends SkillManager {
mmoPlayer.getPlayer().sendMessage("Bush XP: " + xpReward);
}
// //Check for double drops
// if(checkDoubleDrop(blockState)) {
//
// if(mmoPlayer.isDebugMode()) {
// mmoPlayer.getPlayer().sendMessage("Double Drops succeeded for Berry Bush");
// }
//
// //Add metadata to mark this block for double or triple drops
// markForBonusDrops(blockState);
// }
applyXpGain(xpReward, XPGainReason.PVE, XPGainSource.SELF);
CheckBushAge checkBushAge = new CheckBushAge(blockState.getBlock(), mmoPlayer, xpReward);
checkBushAge.runTaskLater(mcMMO.p, 1);
}
}
}
private class CheckBushAge extends BukkitRunnable {
@NotNull Block block;
@NotNull McMMOPlayer mmoPlayer;
int xpReward;
public CheckBushAge(@NotNull Block block, @NotNull McMMOPlayer mmoPlayer, int xpReward) {
this.block = block;
this.mmoPlayer = mmoPlayer;
this.xpReward = xpReward;
}
@Override
public void run() {
BlockState blockState = block.getState();
if(blockState.getType().toString().equalsIgnoreCase("sweet_berry_bush")) {
if(blockState.getBlockData() instanceof Ageable) {
Ageable ageable = (Ageable) blockState.getBlockData();
if(ageable.getAge() <= 1) {
applyXpGain(xpReward, XPGainReason.PVE, XPGainSource.SELF);
}
}
}
}
}
public boolean canUseHylianLuck() {
if(!RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.HERBALISM_HYLIAN_LUCK))
return false;

View File

@@ -3,8 +3,6 @@ package com.gmail.nossr50.skills.swords;
import com.gmail.nossr50.config.AdvancedConfig;
public class Swords {
public static int bleedMaxTicks = AdvancedConfig.getInstance().getRuptureMaxTicks();
public static double counterAttackModifier = AdvancedConfig.getInstance().getCounterModifier();
public static double serratedStrikesModifier = AdvancedConfig.getInstance().getSerratedStrikesModifier();

View File

@@ -1,11 +1,14 @@
package com.gmail.nossr50.skills.swords;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.meta.RuptureTaskMeta;
import com.gmail.nossr50.datatypes.skills.AbilityToolType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.RuptureTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Permissions;
@@ -60,32 +63,52 @@ public class SwordsManager extends SkillManager {
*
* @param target The defending entity
*/
public void ruptureCheck(@NotNull LivingEntity target) throws IllegalStateException {
if(BleedTimerTask.isBleedOperationAllowed()) {
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.SWORDS_RUPTURE, getPlayer())) {
public void processRupture(@NotNull LivingEntity target) {
if(target.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
RuptureTaskMeta ruptureTaskMeta = (RuptureTaskMeta) target.getMetadata(mcMMO.RUPTURE_META_KEY).get(0);
if (target instanceof Player) {
Player defender = (Player) target;
if(mmoPlayer.isDebugMode()) {
mmoPlayer.getPlayer().sendMessage("Rupture task ongoing for target " + target.toString());
mmoPlayer.getPlayer().sendMessage(ruptureTaskMeta.getRuptureTimerTask().toString());
}
//Don't start or add to a bleed if they are blocking
if(defender.isBlocking())
return;
ruptureTaskMeta.getRuptureTimerTask().refreshRupture();
return; //Don't apply bleed
}
if (NotificationManager.doesPlayerUseNotifications(defender)) {
if(!BleedTimerTask.isBleeding(defender))
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started");
}
}
if (RandomChanceUtil.rollDice(AdvancedConfig.getInstance().getRuptureChanceToApplyOnHit(getRuptureRank()), 100)) {
BleedTimerTask.add(target, getPlayer(), getRuptureBleedTicks(), RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE), getToolTier(getPlayer().getInventory().getItemInMainHand()));
if (target instanceof Player) {
Player defender = (Player) target;
if (mmoPlayer.hasSkillChatNotifications()) {
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding");
//Don't start or add to a bleed if they are blocking
if(defender.isBlocking())
return;
if (NotificationManager.doesPlayerUseNotifications(defender)) {
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding.Started");
}
}
RuptureTask ruptureTask = new RuptureTask(mmoPlayer, target,
AdvancedConfig.getInstance().getRuptureTickDamage(target instanceof Player, getRuptureRank()),
AdvancedConfig.getInstance().getRuptureExplosionDamage(target instanceof Player, getRuptureRank()));
RuptureTaskMeta ruptureTaskMeta = new RuptureTaskMeta(mcMMO.p, ruptureTask);
ruptureTask.runTaskTimer(mcMMO.p, 0, 1);
target.setMetadata(mcMMO.RUPTURE_META_KEY, ruptureTaskMeta);
// if (mmoPlayer.hasSkillChatNotifications()) {
// NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.Bleeding");
// }
}
}
private int getRuptureRank() {
return RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_RUPTURE);
}
public double getStabDamage()
{
int rank = RankUtils.getRank(getPlayer(), SubSkillType.SWORDS_STAB);
@@ -112,14 +135,8 @@ public class SwordsManager extends SkillManager {
return 1;
}
public int getRuptureBleedTicks()
{
int bleedTicks = 2 * RankUtils.getRank(mmoPlayer, SubSkillType.SWORDS_RUPTURE);
if(bleedTicks > Swords.bleedMaxTicks)
bleedTicks = Swords.bleedMaxTicks;
return bleedTicks;
public int getRuptureBleedTicks(boolean isTargetPlayer) {
return AdvancedConfig.getInstance().getRuptureDurationSeconds(isTargetPlayer) / RuptureTask.DAMAGE_TICK_INTERVAL;
}
/**

View File

@@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
@@ -167,21 +166,13 @@ public class TamingManager extends SkillManager {
* @param damage The initial damage
*/
public double gore(@NotNull LivingEntity target, double damage) {
if(BleedTimerTask.isBleedOperationAllowed()) {
if (!RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.TAMING_GORE, getPlayer())) {
return 0;
}
// if (target instanceof Player) {
// NotificationManager.sendPlayerInformation((Player)target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore");
// }
//
// NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.Gore");
BleedTimerTask.add(target, getPlayer(), Taming.goreBleedTicks, 1, 2);
if (target instanceof Player) {
NotificationManager.sendPlayerInformation((Player)target, NotificationType.SUBSKILL_MESSAGE, "Combat.StruckByGore");
}
NotificationManager.sendPlayerInformation(getPlayer(), NotificationType.SUBSKILL_MESSAGE, "Combat.Gore");
damage = (damage * Taming.goreModifier) - damage;
}
damage = (damage * Taming.goreModifier) - damage;
return damage;
}

View File

@@ -1,387 +1,388 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.commands.skills.AprilCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableList;
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Statistic;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
import java.io.*;
import java.util.*;
import java.util.regex.Pattern;
public final class HolidayManager {
private final ArrayList<String> hasCelebrated;
private final int currentYear;
private static final int START_YEAR = 2011;
private static final List<Color> ALL_COLORS;
private static final List<ChatColor> ALL_CHAT_COLORS;
private static final List<ChatColor> CHAT_FORMATS;
public enum FakeSkillType {
MACHO,
JUMPING,
THROWING,
WRECKING,
CRAFTING,
WALKING,
SWIMMING,
FALLING,
CLIMBING,
FLYING,
DIVING,
PIGGY,
UNKNOWN;
public static FakeSkillType getByName(String skillName) {
for (FakeSkillType type : values()) {
if (type.name().equalsIgnoreCase(skillName)) {
return type;
}
}
return null;
}
public static FakeSkillType getByStatistic(Statistic statistic) {
switch (statistic) {
case DAMAGE_TAKEN:
return FakeSkillType.MACHO;
case JUMP:
return FakeSkillType.JUMPING;
case DROP:
return FakeSkillType.THROWING;
case MINE_BLOCK:
case BREAK_ITEM:
return FakeSkillType.WRECKING;
case CRAFT_ITEM:
return FakeSkillType.CRAFTING;
case WALK_ONE_CM:
return FakeSkillType.WALKING;
case SWIM_ONE_CM:
return FakeSkillType.SWIMMING;
case FALL_ONE_CM:
return FakeSkillType.FALLING;
case CLIMB_ONE_CM:
return FakeSkillType.CLIMBING;
case FLY_ONE_CM:
return FakeSkillType.FLYING;
case WALK_UNDER_WATER_ONE_CM:
return FakeSkillType.DIVING;
case PIG_ONE_CM:
return FakeSkillType.PIGGY;
default:
return FakeSkillType.UNKNOWN;
}
}
}
public final Set<Statistic> movementStatistics = EnumSet.of(
Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.WALK_UNDER_WATER_ONE_CM,
Statistic.PIG_ONE_CM);
static {
List<Color> colors = new ArrayList<>();
List<ChatColor> chatColors = new ArrayList<>();
List<ChatColor> chatFormats = new ArrayList<>();
for (ChatColor color : ChatColor.values()) {
if (color.isColor()) {
chatColors.add(color);
}
else {
chatFormats.add(color);
}
}
// for (DyeColor color : DyeColor.values()) {
// colors.add(color.getFireworkColor());
// }
Collections.shuffle(chatColors, Misc.getRandom());
Collections.shuffle(colors, Misc.getRandom());
Collections.shuffle(chatFormats, Misc.getRandom());
ALL_CHAT_COLORS = ImmutableList.copyOf(chatColors);
ALL_COLORS = ImmutableList.copyOf(colors);
CHAT_FORMATS = ImmutableList.copyOf(chatFormats);
}
// This gets called onEnable
public HolidayManager() {
currentYear = Calendar.getInstance().get(Calendar.YEAR);
File anniversaryFile = new File(mcMMO.getFlatFileDirectory(), "anniversary." + currentYear + ".yml");
if (!anniversaryFile.exists()) {
try {
anniversaryFile.createNewFile();
}
catch (IOException ex) {
mcMMO.p.getLogger().severe(ex.toString());
}
}
hasCelebrated = new ArrayList<>();
try {
hasCelebrated.clear();
BufferedReader reader = new BufferedReader(new FileReader(anniversaryFile.getPath()));
String line = reader.readLine();
while (line != null) {
hasCelebrated.add(line);
line = reader.readLine();
}
reader.close();
}
catch (Exception ex) {
mcMMO.p.getLogger().severe(ex.toString());
}
cleanupFiles();
}
private void cleanupFiles() {
File FlatFileDir = new File(mcMMO.getFlatFileDirectory());
File legacy = new File(FlatFileDir, "anniversary.yml");
List<File> toDelete = new ArrayList<>();
if (legacy.exists()) {
toDelete.add(legacy);
}
Pattern pattern = Pattern.compile("anniversary\\.(?:.+)\\.yml");
for (String fileName : FlatFileDir.list()) {
if (!pattern.matcher(fileName).matches() || fileName.equals("anniversary." + currentYear + ".yml")) {
continue;
}
File file = new File(FlatFileDir, fileName);
if (file.isDirectory()) {
continue;
}
toDelete.add(file);
}
for (File file : toDelete) {
if (file.delete()) {
mcMMO.p.debug("Deleted: " + file.getName());
}
}
}
// This gets called onDisable
public void saveAnniversaryFiles() {
mcMMO.p.debug("Saving anniversary files...");
String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary." + currentYear + ".yml";
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(anniversaryFilePath));
for (String player : hasCelebrated) {
writer.write(player);
writer.newLine();
}
writer.close();
}
catch (Exception ex) {
mcMMO.p.getLogger().severe(ex.toString());
}
}
// This gets called from /mcmmo command
public void anniversaryCheck(final CommandSender sender) {
GregorianCalendar anniversaryStart = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 3);
GregorianCalendar anniversaryEnd = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 6);
GregorianCalendar day = new GregorianCalendar();
if (hasCelebrated.contains(sender.getName())) {
return;
}
if (!getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
return;
}
sender.sendMessage(LocaleLoader.getString("Holiday.Anniversary", (currentYear - START_YEAR)));
/*if (sender instanceof Player) {
final int firework_amount = 10;
for (int i = 0; i < firework_amount; i++) {
int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
@Override
public void run() {
spawnFireworks((Player) sender);
}
}, delay);
}
}*/
// else {
/*
* Credit: http://www.geocities.com/spunk1111/
* (good luck finding that in 3 years heh)
* .''. . *''* :_\/_: .
* :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
* .''.: /\ : /)\ ':'* /\ * : '..'. -=:o:=-
* :_\/_:'.:::. ' *''* * '.\'/.'_\(/_ '.':'.'
* : /\ : ::::: *_\/_* -= o =- /)\ '
* '..' ':::' * /\ * .'/.\'. ' *
* * *..* : *
* * * *
* * * *
*/
/*
* Color map
* AAAA D GGGG JJJJJJ K
* AAAAAA DDDDD EEEGGGGGG JJJJJJ KKKKKKK
* BBBBAAAAAA DDD EEEGGGGGG I JJJJJ KKKKKKK
* BBBBBBACCCCC D FFFF G IIIIIIIHHHHH KKKKKKK
* BBBBBB CCCCC FFFFFF IIIIIII HHH K
* BBBB CCCCC FFFFFF IIIIIII H k
* b FFFF I k
* b i k
* b i k
*/
Object[] colorParams = new Object[]{chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose()};
sender.sendMessage(String.format(" %1$s.''. %4$s. %7$s*''* %10$s:_\\/_: %11$s.", colorParams));
sender.sendMessage(String.format(" %1$s:_\\/_: %4$s_\\(/_ %5$s.:.%7$s*_\\/_* %10$s: /\\ : %11$s.'.:.'.", colorParams));
sender.sendMessage(String.format(" %2$s.''.%1$s: /\\ : %4$s/)\\ %5$s':'%7$s* /\\ * %9$s: %10$s'..'. %11$s-=:o:=-", colorParams));
sender.sendMessage(String.format("%2$s:_\\/_:%1$s'%3$s.:::. %4$s' %6$s*''* %7$s* %9$s'.\\'/.'%8$s_\\(/_ %11$s'.':'.'", colorParams));
sender.sendMessage(String.format("%2$s: /\\ : %3$s::::: %6$s*_\\/_* %9$s-= o =-%8$s /)\\ %11$s'", colorParams));
sender.sendMessage(String.format(" %2$s'..' %3$s':::' %6$s* /\\ * %9$s.'/.\\'. %8$s' %11$s*", colorParams));
sender.sendMessage(String.format(" %2$s* %6$s*..* %9$s: %11$s*", colorParams));
sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
// }
hasCelebrated.add(sender.getName());
}
public boolean getDateRange(Date date, Date start, Date end) {
return !(date.before(start) || date.after(end));
}
// public void spawnFireworks(Player player) {
// int power = Misc.getRandom().nextInt(3) + 1;
// Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)];
// double varX = Misc.getRandom().nextGaussian() * 3;
// double varZ = Misc.getRandom().nextGaussian() * 3;
//package com.gmail.nossr50.util;
//
// Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK);
// FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
// FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(fireworkType).trail(Misc.getRandom().nextBoolean()).build();
// fireworkmeta.addEffect(effect);
// fireworkmeta.setPower(power);
// fireworks.setFireworkMeta(fireworkmeta);
//import com.gmail.nossr50.commands.skills.AprilCommand;
//import com.gmail.nossr50.config.Config;
//import com.gmail.nossr50.datatypes.interactions.NotificationType;
//import com.gmail.nossr50.datatypes.player.McMMOPlayer;
//import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
//import com.gmail.nossr50.locale.LocaleLoader;
//import com.gmail.nossr50.mcMMO;
//import com.gmail.nossr50.util.player.NotificationManager;
//import com.gmail.nossr50.util.player.UserManager;
//import com.gmail.nossr50.util.sounds.SoundManager;
//import com.gmail.nossr50.util.sounds.SoundType;
//import com.gmail.nossr50.util.text.StringUtils;
//import com.google.common.collect.ImmutableList;
//import org.bukkit.ChatColor;
//import org.bukkit.Color;
//import org.bukkit.Statistic;
//import org.bukkit.command.CommandSender;
//import org.bukkit.command.PluginCommand;
//import org.bukkit.entity.Player;
//import org.bukkit.event.player.PlayerStatisticIncrementEvent;
//
//import java.io.*;
//import java.util.*;
//import java.util.regex.Pattern;
//
//public final class HolidayManager {
// private final ArrayList<String> hasCelebrated;
// private final int currentYear;
// private static final int START_YEAR = 2011;
//
// private static final List<Color> ALL_COLORS;
// private static final List<ChatColor> ALL_CHAT_COLORS;
// private static final List<ChatColor> CHAT_FORMATS;
//
// public enum FakeSkillType {
// MACHO,
// JUMPING,
// THROWING,
// WRECKING,
// CRAFTING,
// WALKING,
// SWIMMING,
// FALLING,
// CLIMBING,
// FLYING,
// DIVING,
// PIGGY,
// UNKNOWN;
//
// public static FakeSkillType getByName(String skillName) {
// for (FakeSkillType type : values()) {
// if (type.name().equalsIgnoreCase(skillName)) {
// return type;
// }
// }
// return null;
// }
//
// public static FakeSkillType getByStatistic(Statistic statistic) {
// switch (statistic) {
// case DAMAGE_TAKEN:
// return FakeSkillType.MACHO;
// case JUMP:
// return FakeSkillType.JUMPING;
// case DROP:
// return FakeSkillType.THROWING;
// case MINE_BLOCK:
// case BREAK_ITEM:
// return FakeSkillType.WRECKING;
// case CRAFT_ITEM:
// return FakeSkillType.CRAFTING;
// case WALK_ONE_CM:
// return FakeSkillType.WALKING;
// case SWIM_ONE_CM:
// return FakeSkillType.SWIMMING;
// case FALL_ONE_CM:
// return FakeSkillType.FALLING;
// case CLIMB_ONE_CM:
// return FakeSkillType.CLIMBING;
// case FLY_ONE_CM:
// return FakeSkillType.FLYING;
// case WALK_UNDER_WATER_ONE_CM:
// return FakeSkillType.DIVING;
// case PIG_ONE_CM:
// return FakeSkillType.PIGGY;
// default:
// return FakeSkillType.UNKNOWN;
// }
// }
// }
private static List<Color> colorChoose() {
return ALL_COLORS.subList(0, Math.max(Misc.getRandom().nextInt(ALL_COLORS.size() + 1), 1));
}
private static String chatColorChoose() {
StringBuilder ret = new StringBuilder(ALL_CHAT_COLORS.get(Misc.getRandom().nextInt(ALL_CHAT_COLORS.size())).toString());
for (ChatColor chatFormat : CHAT_FORMATS) {
if (Misc.getRandom().nextInt(CHAT_FORMATS.size()) == 0) {
ret.append(chatFormat);
}
}
return ret.toString();
}
public boolean isAprilFirst() {
if(!Config.getInstance().isAprilFoolsAllowed())
return false;
GregorianCalendar aprilFirst = new GregorianCalendar(currentYear, Calendar.APRIL, 1);
GregorianCalendar aprilSecond = new GregorianCalendar(currentYear, Calendar.APRIL, 2);
GregorianCalendar day = new GregorianCalendar();
return getDateRange(day.getTime(), aprilFirst.getTime(), aprilSecond.getTime());
}
public boolean nearingAprilFirst() {
if(!Config.getInstance().isAprilFoolsAllowed())
return false;
GregorianCalendar start = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.MARCH, 28);
GregorianCalendar end = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.APRIL, 2);
GregorianCalendar day = new GregorianCalendar();
return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
}
public void handleStatisticEvent(PlayerStatisticIncrementEvent event) {
Player player = event.getPlayer();
Statistic statistic = event.getStatistic();
int newValue = event.getNewValue();
int modifier;
switch (statistic) {
case DAMAGE_TAKEN:
modifier = 500;
break;
case JUMP:
modifier = 500;
break;
case DROP:
modifier = 200;
break;
case MINE_BLOCK:
case BREAK_ITEM:
modifier = 500;
break;
case CRAFT_ITEM:
modifier = 100;
break;
default:
return;
}
if (newValue % modifier == 0) {
mcMMO.getHolidayManager().levelUpApril(player, FakeSkillType.getByStatistic(statistic));
}
}
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
if(!Config.getInstance().isAprilFoolsAllowed())
return;
final OnlineMMOPlayer mmoPlayer = UserManager.queryPlayer(player);
if (mmoPlayer == null) return;
int levelTotal = Misc.getRandom().nextInt(1 + mmoPlayer.getSkillLevel(PrimarySkillType.MINING)) + 1;
SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
NotificationManager.sendPlayerInformation(player, NotificationType.HOLIDAY, "Holiday.AprilFools.Levelup", StringUtils.getCapitalized(fakeSkillType.toString()), String.valueOf(levelTotal));
// ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
}
public void registerAprilCommand() {
if(!Config.getInstance().isAprilFoolsAllowed())
return;
PluginCommand command = mcMMO.p.getCommand("crafting");
command.setExecutor(new AprilCommand());
}
}
//
// public final Set<Statistic> movementStatistics = EnumSet.of(
// Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
// Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.WALK_UNDER_WATER_ONE_CM,
// Statistic.PIG_ONE_CM);
//
// static {
// List<Color> colors = new ArrayList<>();
// List<ChatColor> chatColors = new ArrayList<>();
// List<ChatColor> chatFormats = new ArrayList<>();
//
// for (ChatColor color : ChatColor.values()) {
// if (color.isColor()) {
// chatColors.add(color);
// }
// else {
// chatFormats.add(color);
// }
// }
//
//// for (DyeColor color : DyeColor.values()) {
//// colors.add(color.getFireworkColor());
//// }
//
// Collections.shuffle(chatColors, Misc.getRandom());
// Collections.shuffle(colors, Misc.getRandom());
// Collections.shuffle(chatFormats, Misc.getRandom());
//
// ALL_CHAT_COLORS = ImmutableList.copyOf(chatColors);
// ALL_COLORS = ImmutableList.copyOf(colors);
// CHAT_FORMATS = ImmutableList.copyOf(chatFormats);
// }
//
// // This gets called onEnable
// public HolidayManager() {
// currentYear = Calendar.getInstance().get(Calendar.YEAR);
//
// File anniversaryFile = new File(mcMMO.getFlatFileDirectory(), "anniversary." + currentYear + ".yml");
//
// if (!anniversaryFile.exists()) {
// try {
// anniversaryFile.createNewFile();
// }
// catch (IOException ex) {
// mcMMO.p.getLogger().severe(ex.toString());
// }
// }
//
// hasCelebrated = new ArrayList<>();
//
// try {
// hasCelebrated.clear();
// BufferedReader reader = new BufferedReader(new FileReader(anniversaryFile.getPath()));
// String line = reader.readLine();
//
// while (line != null) {
// hasCelebrated.add(line);
// line = reader.readLine();
// }
//
// reader.close();
// }
// catch (Exception ex) {
// mcMMO.p.getLogger().severe(ex.toString());
// }
//
// cleanupFiles();
// }
//
// private void cleanupFiles() {
// File FlatFileDir = new File(mcMMO.getFlatFileDirectory());
// File legacy = new File(FlatFileDir, "anniversary.yml");
// List<File> toDelete = new ArrayList<>();
//
// if (legacy.exists()) {
// toDelete.add(legacy);
// }
//
// Pattern pattern = Pattern.compile("anniversary\\.(?:.+)\\.yml");
//
// for (String fileName : FlatFileDir.list()) {
// if (!pattern.matcher(fileName).matches() || fileName.equals("anniversary." + currentYear + ".yml")) {
// continue;
// }
//
// File file = new File(FlatFileDir, fileName);
//
// if (file.isDirectory()) {
// continue;
// }
//
// toDelete.add(file);
// }
//
// for (File file : toDelete) {
// if (file.delete()) {
// mcMMO.p.debug("Deleted: " + file.getName());
// }
// }
// }
//
// // This gets called onDisable
// public void saveAnniversaryFiles() {
// mcMMO.p.debug("Saving anniversary files...");
// String anniversaryFilePath = mcMMO.getFlatFileDirectory() + "anniversary." + currentYear + ".yml";
//
// try {
// BufferedWriter writer = new BufferedWriter(new FileWriter(anniversaryFilePath));
// for (String player : hasCelebrated) {
// writer.write(player);
// writer.newLine();
// }
// writer.close();
// }
// catch (Exception ex) {
// mcMMO.p.getLogger().severe(ex.toString());
// }
// }
//
// // This gets called from /mcmmo command
// public void anniversaryCheck(final CommandSender sender) {
// GregorianCalendar anniversaryStart = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 3);
// GregorianCalendar anniversaryEnd = new GregorianCalendar(currentYear, Calendar.FEBRUARY, 6);
// GregorianCalendar day = new GregorianCalendar();
//
// if (hasCelebrated.contains(sender.getName())) {
// return;
// }
//
// if (!getDateRange(day.getTime(), anniversaryStart.getTime(), anniversaryEnd.getTime())) {
// return;
// }
//
// sender.sendMessage(LocaleLoader.getString("Holiday.Anniversary", (currentYear - START_YEAR)));
// /*if (sender instanceof Player) {
// final int firework_amount = 10;
// for (int i = 0; i < firework_amount; i++) {
// int delay = (int) (Misc.getRandom().nextDouble() * 3 * Misc.TICK_CONVERSION_FACTOR) + 4;
// mcMMO.p.getServer().getScheduler().runTaskLater(mcMMO.p, new Runnable() {
// @Override
// public void run() {
// spawnFireworks((Player) sender);
// }
// }, delay);
// }
// }*/
//// else {
// /*
// * Credit: http://www.geocities.com/spunk1111/
// * (good luck finding that in 3 years heh)
// * .''. . *''* :_\/_: .
// * :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'.
// * .''.: /\ : /)\ ':'* /\ * : '..'. -=:o:=-
// * :_\/_:'.:::. ' *''* * '.\'/.'_\(/_ '.':'.'
// * : /\ : ::::: *_\/_* -= o =- /)\ '
// * '..' ':::' * /\ * .'/.\'. ' *
// * * *..* : *
// * * * *
// * * * *
// */
//
// /*
// * Color map
// * AAAA D GGGG JJJJJJ K
// * AAAAAA DDDDD EEEGGGGGG JJJJJJ KKKKKKK
// * BBBBAAAAAA DDD EEEGGGGGG I JJJJJ KKKKKKK
// * BBBBBBACCCCC D FFFF G IIIIIIIHHHHH KKKKKKK
// * BBBBBB CCCCC FFFFFF IIIIIII HHH K
// * BBBB CCCCC FFFFFF IIIIIII H k
// * b FFFF I k
// * b i k
// * b i k
// */
// Object[] colorParams = new Object[]{chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose(), chatColorChoose()};
// sender.sendMessage(String.format(" %1$s.''. %4$s. %7$s*''* %10$s:_\\/_: %11$s.", colorParams));
// sender.sendMessage(String.format(" %1$s:_\\/_: %4$s_\\(/_ %5$s.:.%7$s*_\\/_* %10$s: /\\ : %11$s.'.:.'.", colorParams));
// sender.sendMessage(String.format(" %2$s.''.%1$s: /\\ : %4$s/)\\ %5$s':'%7$s* /\\ * %9$s: %10$s'..'. %11$s-=:o:=-", colorParams));
// sender.sendMessage(String.format("%2$s:_\\/_:%1$s'%3$s.:::. %4$s' %6$s*''* %7$s* %9$s'.\\'/.'%8$s_\\(/_ %11$s'.':'.'", colorParams));
// sender.sendMessage(String.format("%2$s: /\\ : %3$s::::: %6$s*_\\/_* %9$s-= o =-%8$s /)\\ %11$s'", colorParams));
// sender.sendMessage(String.format(" %2$s'..' %3$s':::' %6$s* /\\ * %9$s.'/.\\'. %8$s' %11$s*", colorParams));
// sender.sendMessage(String.format(" %2$s* %6$s*..* %9$s: %11$s*", colorParams));
// sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
// sender.sendMessage(String.format(" %2$s* %9$s* %11$s*", colorParams));
//// }
//
// hasCelebrated.add(sender.getName());
// }
//
// public boolean getDateRange(Date date, Date start, Date end) {
// return !(date.before(start) || date.after(end));
// }
//
//// public void spawnFireworks(Player player) {
//// int power = Misc.getRandom().nextInt(3) + 1;
//// Type fireworkType = Type.values()[Misc.getRandom().nextInt(Type.values().length)];
//// double varX = Misc.getRandom().nextGaussian() * 3;
//// double varZ = Misc.getRandom().nextGaussian() * 3;
////
//// Firework fireworks = (Firework) player.getWorld().spawnEntity(player.getLocation().add(varX, 0, varZ), EntityType.FIREWORK);
//// FireworkMeta fireworkmeta = fireworks.getFireworkMeta();
//// FireworkEffect effect = FireworkEffect.builder().flicker(Misc.getRandom().nextBoolean()).withColor(colorChoose()).withFade(colorChoose()).with(fireworkType).trail(Misc.getRandom().nextBoolean()).build();
//// fireworkmeta.addEffect(effect);
//// fireworkmeta.setPower(power);
//// fireworks.setFireworkMeta(fireworkmeta);
//// }
//
// private static List<Color> colorChoose() {
// return ALL_COLORS.subList(0, Math.max(Misc.getRandom().nextInt(ALL_COLORS.size() + 1), 1));
// }
//
// private static String chatColorChoose() {
// StringBuilder ret = new StringBuilder(ALL_CHAT_COLORS.get(Misc.getRandom().nextInt(ALL_CHAT_COLORS.size())).toString());
//
// for (ChatColor chatFormat : CHAT_FORMATS) {
// if (Misc.getRandom().nextInt(CHAT_FORMATS.size()) == 0) {
// ret.append(chatFormat);
// }
// }
//
// return ret.toString();
// }
//
// public boolean isAprilFirst() {
// if(!Config.getInstance().isAprilFoolsAllowed())
// return false;
//
// GregorianCalendar aprilFirst = new GregorianCalendar(currentYear, Calendar.APRIL, 1);
// GregorianCalendar aprilSecond = new GregorianCalendar(currentYear, Calendar.APRIL, 2);
// GregorianCalendar day = new GregorianCalendar();
// return getDateRange(day.getTime(), aprilFirst.getTime(), aprilSecond.getTime());
// }
//
// public boolean nearingAprilFirst() {
// if(!Config.getInstance().isAprilFoolsAllowed())
// return false;
//
// GregorianCalendar start = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.MARCH, 28);
// GregorianCalendar end = new GregorianCalendar(Calendar.getInstance().get(Calendar.YEAR), Calendar.APRIL, 2);
// GregorianCalendar day = new GregorianCalendar();
//
// return mcMMO.getHolidayManager().getDateRange(day.getTime(), start.getTime(), end.getTime());
// }
//
// public void handleStatisticEvent(PlayerStatisticIncrementEvent event) {
// Player player = event.getPlayer();
// Statistic statistic = event.getStatistic();
// int newValue = event.getNewValue();
//
// int modifier;
// switch (statistic) {
// case DAMAGE_TAKEN:
// modifier = 500;
// break;
// case JUMP:
// modifier = 500;
// break;
// case DROP:
// modifier = 200;
// break;
// case MINE_BLOCK:
// case BREAK_ITEM:
// modifier = 500;
// break;
// case CRAFT_ITEM:
// modifier = 100;
// break;
// default:
// return;
// }
//
// if (newValue % modifier == 0) {
// mcMMO.getHolidayManager().levelUpApril(player, FakeSkillType.getByStatistic(statistic));
// }
// }
//
// public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
// if(!Config.getInstance().isAprilFoolsAllowed())
// return;
//
// final McMMOPlayer mmoPlayer = UserManager.getPlayer(player);
// if (mmoPlayer == null) return;
//
// int levelTotal = Misc.getRandom().nextInt(1 + mmoPlayer.getSkillLevel(PrimarySkillType.MINING)) + 1;
// SoundManager.sendSound(player, player.getLocation(), SoundType.LEVEL_UP);
// NotificationManager.sendPlayerInformation(player, NotificationType.HOLIDAY, "Holiday.AprilFools.Levelup", StringUtils.getCapitalized(fakeSkillType.toString()), String.valueOf(levelTotal));
//// ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
// }
//
// public void registerAprilCommand() {
// if(!Config.getInstance().isAprilFoolsAllowed())
// return;
//
// PluginCommand command = mcMMO.p.getCommand("crafting");
// command.setExecutor(new AprilCommand());
// }
//}

View File

@@ -131,7 +131,7 @@ public final class MobHealthbarUtils {
return null;
}
int coloredDisplay = (int) Math.ceil(fullDisplay * (healthPercentage / 100.0D));
int coloredDisplay = (int) Math.max(Math.ceil(fullDisplay * (healthPercentage / 100.0D)), 0.5);
int grayDisplay = fullDisplay - coloredDisplay;
StringBuilder healthbar = new StringBuilder(color + "");

View File

@@ -2,16 +2,17 @@ package com.gmail.nossr50.util;
import com.gmail.nossr50.mcMMO;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;
public class TransientMetadataTools {
public static final String OLD_NAME_METAKEY = TransientMetadataTools.OLD_NAME_METAKEY;
private final mcMMO pluginRef;
public TransientMetadataTools(mcMMO pluginRef) {
public TransientMetadataTools(@NotNull mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
public void cleanAllMobMetadata(LivingEntity livingEntity) {
public void cleanAllLivingEntityMetadata(@NotNull LivingEntity livingEntity) {
//Since its not written anywhere, apparently the GC won't touch objects with metadata still present on them
if (livingEntity.hasMetadata(mcMMO.customNameKey)) {
livingEntity.setCustomName(livingEntity.getMetadata(mcMMO.customNameKey).get(0).asString());
@@ -33,6 +34,14 @@ public class TransientMetadataTools {
livingEntity.removeMetadata(mcMMO.travelingBlock, pluginRef);
}
if(livingEntity.hasMetadata(mcMMO.RUPTURE_META_KEY)) {
livingEntity.removeMetadata(mcMMO.RUPTURE_META_KEY, pluginRef);
}
if(livingEntity.hasMetadata(mcMMO.EXPLOSION_FROM_RUPTURE)) {
livingEntity.removeMetadata(mcMMO.EXPLOSION_FROM_RUPTURE, pluginRef);
}
//Cleanup mob metadata
mcMMO.getCompatibilityManager().getPersistentDataLayer().removeMobFlags(livingEntity);
}

View File

@@ -92,10 +92,9 @@ public final class CombatUtils {
mmoPlayer.getSuperAbilityManager().checkAbilityActivation(PrimarySkillType.SWORDS);
}
if(target.getHealth() - event.getFinalDamage() >= 1)
{
if(target.getHealth() - event.getFinalDamage() > 0) {
if (swordsManager.canUseRupture()) {
swordsManager.ruptureCheck(target);
swordsManager.processRupture(target);
}
}
@@ -777,7 +776,7 @@ public final class CombatUtils {
NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
}
UserManager.queryPlayer(attacker).getSwordsManager().ruptureCheck(target);
UserManager.queryPlayer(attacker).getSwordsManager().processRupture(target);
break;
case AXES:

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.util.skills;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.apache.commons.lang.math.RandomUtils;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -27,9 +28,40 @@ public final class ParticleEffectUtils {
return;
}
livingEntity.getWorld().playEffect(livingEntity.getEyeLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE);
Location origin = livingEntity.getEyeLocation().clone();
World world = origin.getWorld();
double x = origin.getX();
double y = origin.getY();
double z = origin.getZ();
double offSetVal = 0.3D;
Location locA = new Location(world, x - offSetVal, y, z);
Location locB = new Location(world, x + offSetVal, y, z);
Location locC = new Location(world, x, y + offSetVal, z);
Location locD = new Location(world, x, y - offSetVal, z);
Location locE = new Location(world, x, y, z + offSetVal);
Location locF = new Location(world, x, y, z - offSetVal);
Location locG = new Location(world, x + offSetVal, y, z + offSetVal);
Location locH = new Location(world, x - offSetVal, y, z - offSetVal);
Location locI = new Location(world, x - offSetVal, y - offSetVal, z - offSetVal);
Location locJ = new Location(world, x + offSetVal, y - offSetVal, z + offSetVal);
Location locK = new Location(world, x - offSetVal, y + offSetVal, z - offSetVal);
Location locL = new Location(world, x - offSetVal, y + offSetVal, z - offSetVal);
Location[] particleLocations = new Location[]{ locA, locB, locC, locD, locE, locF, locG, locH, locI, locJ, locK, locL};
for(Location location : particleLocations) {
if(RandomUtils.nextInt(100) > 30) {
//TODO: Change
livingEntity.getWorld().playEffect(location, Effect.STEP_SOUND, Material.REDSTONE_WIRE);
}
}
}
public static void playDodgeEffect(Player player) {
if (!Config.getInstance().getDodgeEffectEnabled()) {
return;