mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 22:26:46 +01:00
Static Abuse Removal - HardcoreManager
This commit is contained in:
parent
3552457790
commit
f7aaf25d93
@ -17,7 +17,6 @@ import com.gmail.nossr50.skills.repair.RepairManager;
|
||||
import com.gmail.nossr50.skills.salvage.SalvageManager;
|
||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||
import com.gmail.nossr50.util.ChimaeraWing;
|
||||
import com.gmail.nossr50.util.HardcoreManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -130,8 +129,8 @@ public class PlayerListener implements Listener {
|
||||
if (pluginRef.getDynamicSettingsManager().isWorldBlacklisted(event.getEntity().getWorld().getName()))
|
||||
return;
|
||||
|
||||
boolean statLossEnabled = HardcoreManager.isStatLossEnabled();
|
||||
boolean vampirismEnabled = HardcoreManager.isVampirismEnabled();
|
||||
boolean statLossEnabled = pluginRef.getHardcoreManager().isStatLossEnabled();
|
||||
boolean vampirismEnabled = pluginRef.getHardcoreManager().isVampirismEnabled();
|
||||
|
||||
if (!statLossEnabled && !vampirismEnabled) {
|
||||
return;
|
||||
@ -157,11 +156,11 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
if (killer != null && vampirismEnabled) {
|
||||
HardcoreManager.invokeVampirism(killer, killedPlayer);
|
||||
pluginRef.getHardcoreManager().invokeVampirism(killer, killedPlayer);
|
||||
}
|
||||
|
||||
if (statLossEnabled) {
|
||||
HardcoreManager.invokeStatPenalty(killedPlayer);
|
||||
pluginRef.getHardcoreManager().invokeStatPenalty(killedPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,7 @@ public class mcMMO extends JavaPlugin {
|
||||
private MessageOfTheDayUtils messageOfTheDayUtils;
|
||||
private MiscTools miscTools;
|
||||
private ZipLibrary zipLibrary;
|
||||
private HardcoreManager hardcoreManager;
|
||||
|
||||
/* Never-Ending tasks */
|
||||
private BleedTimerTask bleedTimerTask;
|
||||
@ -293,6 +294,9 @@ public class mcMMO extends JavaPlugin {
|
||||
|
||||
//Misc Tools Init
|
||||
miscTools = new MiscTools(this);
|
||||
|
||||
//Init HardcoreManager
|
||||
hardcoreManager = new HardcoreManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -841,4 +845,8 @@ public class mcMMO extends JavaPlugin {
|
||||
public MiscTools getMiscTools() {
|
||||
return miscTools;
|
||||
}
|
||||
|
||||
public HardcoreManager getHardcoreManager() {
|
||||
return hardcoreManager;
|
||||
}
|
||||
}
|
||||
|
@ -3,19 +3,23 @@ package com.gmail.nossr50.util;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class HardcoreManager {
|
||||
private HardcoreManager() {
|
||||
|
||||
private final mcMMO pluginRef;
|
||||
|
||||
public HardcoreManager(mcMMO pluginRef) {
|
||||
this.pluginRef = pluginRef;
|
||||
}
|
||||
|
||||
public static void invokeStatPenalty(Player player) {
|
||||
public void invokeStatPenalty(Player player) {
|
||||
|
||||
if(pluginRef.getWorldGuardUtils().isWorldGuardLoaded()) {
|
||||
if(!WorldGuardManager.getInstance().hasHardcoreFlag(player)) {
|
||||
if(!pluginRef.getWorldGuardManager().hasHardcoreFlag(player)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -33,7 +37,7 @@ public final class HardcoreManager {
|
||||
HashMap<String, Double> experienceChanged = new HashMap<>();
|
||||
|
||||
for (PrimarySkillType primarySkillType : pluginRef.getSkillTools().NON_CHILD_SKILLS) {
|
||||
if (!primarySkillType.getHardcoreStatLossEnabled()) {
|
||||
if (!pluginRef.getSkillTools().getHardcoreStatLossEnabled(primarySkillType)) {
|
||||
levelChanged.put(primarySkillType.toString(), 0);
|
||||
experienceChanged.put(primarySkillType.toString(), 0.0);
|
||||
continue;
|
||||
@ -64,10 +68,10 @@ public final class HardcoreManager {
|
||||
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.HARDCORE_MODE, "Hardcore.DeathStatLoss.PlayerDeath", String.valueOf(totalLevelsLost));
|
||||
}
|
||||
|
||||
public static void invokeVampirism(Player killer, Player victim) {
|
||||
public void invokeVampirism(Player killer, Player victim) {
|
||||
|
||||
if(pluginRef.getWorldGuardUtils().isWorldGuardLoaded()) {
|
||||
if(!WorldGuardManager.getInstance().hasHardcoreFlag(killer) || !WorldGuardManager.getInstance().hasHardcoreFlag(victim)) {
|
||||
if(!pluginRef.getWorldGuardManager().hasHardcoreFlag(killer) || !pluginRef.getWorldGuardManager().hasHardcoreFlag(victim)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -86,7 +90,7 @@ public final class HardcoreManager {
|
||||
HashMap<String, Double> experienceChanged = new HashMap<>();
|
||||
|
||||
for (PrimarySkillType primarySkillType : pluginRef.getSkillTools().NON_CHILD_SKILLS) {
|
||||
if (!primarySkillType.getHardcoreVampirismEnabled()) {
|
||||
if (!pluginRef.getSkillTools().getHardcoreVampirismEnabled(primarySkillType)) {
|
||||
levelChanged.put(primarySkillType.toString(), 0);
|
||||
experienceChanged.put(primarySkillType.toString(), 0.0);
|
||||
continue;
|
||||
@ -130,11 +134,11 @@ public final class HardcoreManager {
|
||||
*
|
||||
* @return true if Stat Loss is enabled for one or more skill types
|
||||
*/
|
||||
public static boolean isStatLossEnabled() {
|
||||
public boolean isStatLossEnabled() {
|
||||
boolean enabled = false;
|
||||
|
||||
for (PrimarySkillType primarySkillType : pluginRef.getSkillTools().NON_CHILD_SKILLS) {
|
||||
if (primarySkillType.getHardcoreStatLossEnabled()) {
|
||||
if (pluginRef.getSkillTools().getHardcoreStatLossEnabled(primarySkillType)) {
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
@ -148,11 +152,11 @@ public final class HardcoreManager {
|
||||
*
|
||||
* @return true if Vampirism is enabled for one or more skill types
|
||||
*/
|
||||
public static boolean isVampirismEnabled() {
|
||||
public boolean isVampirismEnabled() {
|
||||
boolean enabled = false;
|
||||
|
||||
for (PrimarySkillType primarySkillType : pluginRef.getSkillTools().NON_CHILD_SKILLS) {
|
||||
if (primarySkillType.getHardcoreVampirismEnabled()) {
|
||||
if (pluginRef.getSkillTools().getHardcoreVampirismEnabled(primarySkillType)) {
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ public final class MessageOfTheDayUtils {
|
||||
* @param player Target player
|
||||
*/
|
||||
public void displayHardcoreSettings(Player player) {
|
||||
boolean deathStatLossEnabled = HardcoreManager.isStatLossEnabled();
|
||||
boolean vampirismEnabled = HardcoreManager.isVampirismEnabled();
|
||||
boolean deathStatLossEnabled = pluginRef.getHardcoreManager().isStatLossEnabled();
|
||||
boolean vampirismEnabled = pluginRef.getHardcoreManager().isVampirismEnabled();
|
||||
|
||||
if (!deathStatLossEnabled && !vampirismEnabled) {
|
||||
return;
|
||||
|
@ -674,12 +674,12 @@ public class SkillTools {
|
||||
return pluginRef.getConfigManager().getConfigCoreSkills().isPVEEnabled(primarySkillType);
|
||||
}
|
||||
|
||||
public boolean getHardcoreStatLossEnabled() {
|
||||
return pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getSkillToggleMap().get(this);
|
||||
public boolean getHardcoreStatLossEnabled(PrimarySkillType primarySkillType) {
|
||||
return pluginRef.getConfigManager().getConfigHardcore().getDeathPenalty().getSkillToggleMap().get(primarySkillType);
|
||||
}
|
||||
|
||||
public boolean getHardcoreVampirismEnabled() {
|
||||
return pluginRef.getConfigManager().getConfigHardcore().getVampirism().getSkillToggleMap().get(this);
|
||||
public boolean getHardcoreVampirismEnabled(PrimarySkillType primarySkillType) {
|
||||
return pluginRef.getConfigManager().getConfigHardcore().getVampirism().getSkillToggleMap().get(primarySkillType);
|
||||
}
|
||||
|
||||
public ToolType getPrimarySkillToolType(PrimarySkillType primarySkillType) {
|
||||
|
Loading…
Reference in New Issue
Block a user