-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cumulative Armor-Scheduling changes (Rainbow Armor + Radiation update) (
#3892) * armor task continuation * added empty line * requested changes * Dirty bandage fix armor not working in creative * rainbow armor clean up * fixed radiation - not sure if this is the intended way * ugly fix * clean up * requested changes * import order * made tiny uranium radiactive * requested changes * missed import from comment * made it gold * requested changes and actually make solar helmet work * requested cahnges
- Loading branch information
Showing
34 changed files
with
682 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.github.thebusybiscuit.slimefun4.core.attributes; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.potion.PotionEffect; | ||
import org.bukkit.potion.PotionEffectType; | ||
|
||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; | ||
import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils; | ||
|
||
/** | ||
* An enum of potential radiation symptoms. | ||
* A symptom will be applied when the minExposure | ||
* threshold is reached on the {@link Player}'s | ||
* exposure level. | ||
* When the {@link Player} gets above the minExposure threshold | ||
* the {@link PotionEffect} will be applied. | ||
* | ||
* @author Semisol | ||
* | ||
* @see RadiationUtils | ||
*/ | ||
public enum RadiationSymptom { | ||
|
||
SLOW(10, PotionEffectType.SLOW, 3), | ||
WITHER_LOW(25, PotionEffectType.WITHER, 0), | ||
BLINDNESS(50, PotionEffectType.BLINDNESS, 4), | ||
WITHER_HIGH(75, PotionEffectType.WITHER, 3), | ||
IMMINENT_DEATH(100, PotionEffectType.HARM, 49); | ||
|
||
private final int minExposure; | ||
private final PotionEffect potionEffect; | ||
|
||
RadiationSymptom(int minExposure, @Nonnull PotionEffectType type, int level) { | ||
Preconditions.checkNotNull(type, "The effect type cannot be null"); | ||
Preconditions.checkArgument(minExposure > 0, "The minimum exposure must be greater than 0."); | ||
Preconditions.checkArgument(level >= 0, "The status effect level must be non-negative."); | ||
|
||
this.minExposure = minExposure; | ||
this.potionEffect = new PotionEffect(type, Slimefun.getCfg().getOrSetDefault("options.radiation-update-interval", 1) * 20 + 20, level); | ||
} | ||
|
||
/** | ||
* This method applies the symptom to a player. | ||
* | ||
* @param p | ||
* The player | ||
*/ | ||
public void apply(@Nonnull Player p) { | ||
Preconditions.checkNotNull(p, "The player cannot be null"); | ||
p.addPotionEffect(potionEffect); | ||
} | ||
|
||
/** | ||
* This method returns if this symptom | ||
* should be applied. | ||
* | ||
* @param exposure | ||
* Exposure level | ||
* | ||
* @return If the symptom should be applied | ||
*/ | ||
public boolean shouldApply(int exposure) { | ||
return exposure >= minExposure; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/RainbowArmorPiece.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package io.github.thebusybiscuit.slimefun4.implementation.items.armor; | ||
|
||
import java.util.Arrays; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.ParametersAreNonnullByDefault; | ||
|
||
import org.apache.commons.lang.Validate; | ||
import org.bukkit.Color; | ||
import org.bukkit.DyeColor; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.potion.PotionEffect; | ||
|
||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; | ||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; | ||
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; | ||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; | ||
|
||
/** | ||
* Represents a {@link SlimefunArmorPiece} with rainbow properties (leather armor changing color). | ||
* | ||
* @author martinbrom | ||
*/ | ||
public class RainbowArmorPiece extends SlimefunArmorPiece { | ||
|
||
private final Color[] colors; | ||
|
||
/** | ||
* This creates a new {@link RainbowArmorPiece} from the given arguments. | ||
* | ||
* @param itemGroup The {@link ItemGroup} this {@link RainbowArmorPiece} belongs to | ||
* @param item The {@link SlimefunItemStack} that describes the visual features of our {@link RainbowArmorPiece} | ||
* @param recipeType the {@link RecipeType} that determines how this {@link RainbowArmorPiece} is crafted | ||
* @param recipe An Array representing the recipe of this {@link RainbowArmorPiece} | ||
* @param dyeColors An Array representing the {@link DyeColor}s this {@link RainbowArmorPiece} will cycle between | ||
*/ | ||
@ParametersAreNonnullByDefault | ||
public RainbowArmorPiece(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, DyeColor[] dyeColors) { | ||
super(itemGroup, item, recipeType, recipe, new PotionEffect[0]); | ||
|
||
// TODO Change this validation over to our custom validation blocked by https://github.com/baked-libs/dough/pull/184 | ||
Validate.notEmpty(dyeColors, "RainbowArmorPiece colors cannot be empty!"); | ||
|
||
if (!SlimefunTag.LEATHER_ARMOR.isTagged(item.getType())) { | ||
throw new IllegalArgumentException("Rainbow armor needs to be a leather armor piece!"); | ||
} | ||
|
||
colors = Arrays.stream(dyeColors) | ||
.map(DyeColor::getColor) | ||
.toArray(Color[]::new); | ||
} | ||
|
||
/** | ||
* Returns the {@link Color}s this {@link RainbowArmorPiece} cycles between | ||
* | ||
* @return The {@link Color}s of this {@link RainbowArmorPiece} | ||
*/ | ||
public @Nonnull Color[] getColors() { | ||
return colors; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.