Fix spelling mistake + Wire up ChimaeraWing

This commit is contained in:
nossr50 2019-06-06 04:19:01 -07:00
parent 240ab0a0af
commit 237311a98f
5 changed files with 37 additions and 67 deletions

View File

@ -284,47 +284,6 @@ public class MainConfig extends ConfigValidated {
return getIntValue(HARDCORE, VAMPIRISM, LEVEL_THRESHOLD);
}
/* Items */
public int getChimaeraUseCost() {
return getIntValue(ITEMS, CHIMAERA_WING, USE_COST);
}
public int getChimaeraRecipeCost() {
return getIntValue(ITEMS, CHIMAERA_WING, RECIPE_COST);
}
public Material getChimaeraItem() {
return Material.matchMaterial(getStringValue(ITEMS, CHIMAERA_WING, ITEM + NAME));
}
public boolean getChimaeraEnabled() {
return getBooleanValue(ITEMS, CHIMAERA_WING, ENABLED);
}
public boolean getChimaeraPreventUseUnderground() {
return getBooleanValue(ITEMS, CHIMAERA_WING, PREVENT_USE_UNDERGROUND);
}
public boolean getChimaeraUseBedSpawn() {
return getBooleanValue(ITEMS, CHIMAERA_WING, USE_BED_SPAWN);
}
public int getChimaeraCooldown() {
return getIntValue(ITEMS, CHIMAERA_WING, COOLDOWN);
}
public int getChimaeraWarmup() {
return getIntValue(ITEMS, CHIMAERA_WING, WARMUP);
}
public int getChimaeraRecentlyHurtCooldown() {
return getIntValue(ITEMS, CHIMAERA_WING, RECENTLY_HURT + COOLDOWN);
}
public boolean getChimaeraSoundEnabled() {
return getBooleanValue(ITEMS, CHIMAERA_WING, SOUND + "_" + ENABLED);
}
/* Particles */
public boolean getAbilityActivationEffectEnabled() {
return getBooleanValue(PARTICLES, ABILITY_ACTIVATION);

View File

@ -17,7 +17,7 @@ public class ConfigItems {
return consumables.getChimaeraWing();
}
public int getUseCost() {
public int getChimaeraWingUseCost() {
return getChimaeraWing().getUseCost();
}
@ -25,11 +25,11 @@ public class ConfigItems {
return getChimaeraWing().getRecipeCost();
}
public String getRecipeMats() {
public String getChimaeraWingRecipeMats() {
return getChimaeraWing().getRecipeMats();
}
public int getWarmup() {
public int getChimaeraWingWarmup() {
return getChimaeraWing().getWarmup();
}
@ -37,7 +37,7 @@ public class ConfigItems {
return getChimaeraWing().getCooldown();
}
public boolean isEnabled() {
public boolean isChimaeraWingEnabled() {
return getChimaeraWing().isEnabled();
}
@ -49,11 +49,11 @@ public class ConfigItems {
return getChimaeraWing().isPreventUndergroundUse();
}
public boolean isUseBedSpawn() {
public boolean doesChimaeraUseBedSpawn() {
return getChimaeraWing().isUseBedSpawn();
}
public boolean isSoundEnabled() {
public boolean isChimaeraWingSoundEnabled() {
return getChimaeraWing().isSoundEnabled();
}
}

View File

@ -515,7 +515,7 @@ public class mcMMO extends JavaPlugin {
private void registerCustomRecipes() {
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
if (MainConfig.getInstance().getChimaeraEnabled()) {
if (mcMMO.getConfigManager().getConfigItems().isChimaeraWingEnabled()) {
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
}
}, 40);

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.runnables.items;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
@ -36,13 +37,13 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
ItemStack inHand = player.getInventory().getItemInMainHand();
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < MainConfig.getInstance().getChimaeraUseCost()) {
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));
return;
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = MainConfig.getInstance().getChimaeraRecentlyHurtCooldown();
int hurtCooldown = mcMMO.getConfigManager().getConfigItems().getRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);

View File

@ -38,7 +38,7 @@ public final class ChimaeraWing {
* @param player Player whose item usage to check
*/
public static void activationCheck(Player player) {
if (!MainConfig.getInstance().getChimaeraEnabled()) {
if (!mcMMO.getConfigManager().getConfigItems().isChimaeraWingEnabled()) {
return;
}
@ -65,13 +65,14 @@ public final class ChimaeraWing {
int amount = inHand.getAmount();
if (amount < MainConfig.getInstance().getChimaeraUseCost()) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.NotEnough", String.valueOf(MainConfig.getInstance().getChimaeraUseCost() - amount), "Item.ChimaeraWing.Name");
if (amount < mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost()) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.NotEnough",
String.valueOf(mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost() - amount), "Item.ChimaeraWing.Name");
return;
}
long lastTeleport = mcMMOPlayer.getChimeraWingLastUse();
int cooldown = MainConfig.getInstance().getChimaeraCooldown();
int cooldown = mcMMO.getConfigManager().getConfigItems().getCooldown();
if (cooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player);
@ -83,7 +84,7 @@ public final class ChimaeraWing {
}
long recentlyHurt = mcMMOPlayer.getRecentlyHurt();
int hurtCooldown = MainConfig.getInstance().getChimaeraRecentlyHurtCooldown();
int hurtCooldown = mcMMO.getConfigManager().getConfigItems().getRecentlyHurtCooldown();
if (hurtCooldown > 0) {
int timeRemaining = SkillUtils.calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player);
@ -96,9 +97,9 @@ public final class ChimaeraWing {
location = player.getLocation();
if (MainConfig.getInstance().getChimaeraPreventUseUnderground()) {
if (mcMMO.getConfigManager().getConfigItems().isPreventUndergroundUse()) {
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - MainConfig.getInstance().getChimaeraUseCost())));
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost())));
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail");
player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0));
@ -110,7 +111,7 @@ public final class ChimaeraWing {
mcMMOPlayer.actualizeTeleportCommenceLocation(player);
long warmup = MainConfig.getInstance().getChimaeraWarmup();
long warmup = mcMMO.getConfigManager().getConfigItems().getChimaeraWingWarmup();
if (warmup > 0) {
NotificationManager.sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup));
@ -123,7 +124,7 @@ public final class ChimaeraWing {
public static void chimaeraExecuteTeleport() {
Player player = mcMMOPlayer.getPlayer();
if (MainConfig.getInstance().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
if (mcMMO.getConfigManager().getConfigItems().doesChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
player.teleport(player.getBedSpawnLocation());
} else {
Location spawnLocation = player.getWorld().getSpawnLocation();
@ -134,12 +135,12 @@ public final class ChimaeraWing {
}
}
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - MainConfig.getInstance().getChimaeraUseCost())));
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost())));
player.updateInventory();
mcMMOPlayer.actualizeChimeraWingLastUse();
mcMMOPlayer.setTeleportCommenceLocation(null);
if (MainConfig.getInstance().getChimaeraSoundEnabled()) {
if (mcMMO.getConfigManager().getConfigItems().isChimaeraWingSoundEnabled()) {
SoundManager.sendSound(player, location, SoundType.CHIMAERA_WING);
}
@ -147,7 +148,12 @@ public final class ChimaeraWing {
}
public static ItemStack getChimaeraWing(int amount) {
ItemStack itemStack = new ItemStack(MainConfig.getInstance().getChimaeraItem(), amount);
Material ingredient = Material.matchMaterial(mcMMO.getConfigManager().getConfigItems().getChimaeraWingRecipeMats());
if(ingredient == null)
ingredient = Material.FEATHER;
ItemStack itemStack = new ItemStack(ingredient, amount);
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(ChatColor.GOLD + LocaleLoader.getString("Item.ChimaeraWing.Name"));
@ -162,11 +168,15 @@ public final class ChimaeraWing {
}
public static ShapelessRecipe getChimaeraWingRecipe() {
Material ingredient = MainConfig.getInstance().getChimaeraItem();
int amount = MainConfig.getInstance().getChimaeraRecipeCost();
Material ingredient = Material.matchMaterial(mcMMO.getConfigManager().getConfigItems().getChimaeraWingRecipeMats());
ShapelessRecipe chimeraWing = new ShapelessRecipe(new NamespacedKey(mcMMO.p, "Chimera"), getChimaeraWing(1));
chimeraWing.addIngredient(amount, ingredient);
return chimeraWing;
if(ingredient == null)
ingredient = Material.FEATHER;
int amount = mcMMO.getConfigManager().getConfigItems().getChimaeraWingUseCost();
ShapelessRecipe chimaeraWing = new ShapelessRecipe(new NamespacedKey(mcMMO.p, "Chimaera"), getChimaeraWing(1));
chimaeraWing.addIngredient(amount, ingredient);
return chimaeraWing;
}
}