feat: implement Effekt, EffektLibrary, and EffektRevolver classes for randomized potion effect management
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package com.xonics.classes;
|
||||||
|
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
public class Effekt {
|
||||||
|
|
||||||
|
private PotionEffectType ieffect;
|
||||||
|
private EffektTyp ieTyp;
|
||||||
|
|
||||||
|
public Effekt(PotionEffectType effect, EffektTyp eTyp) {
|
||||||
|
this.ieffect = effect;
|
||||||
|
this.ieTyp = eTyp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PotionEffectType getEffect() {
|
||||||
|
return this.ieffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EffektTyp getEffektTyp() {
|
||||||
|
return this.ieTyp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum EffektTyp {
|
||||||
|
GOOD,
|
||||||
|
BAD,
|
||||||
|
NEUTRAL
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.xonics.classes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
public class EffektLibrary {
|
||||||
|
|
||||||
|
private static List<Effekt> effects = List.of(
|
||||||
|
new Effekt(PotionEffectType.SPEED, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.SLOWNESS, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.JUMP_BOOST, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.OOZING, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt(PotionEffectType.FIRE_RESISTANCE, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.INSTANT_DAMAGE, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.INSTANT_HEALTH, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.HUNGER, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.INVISIBILITY, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.LEVITATION, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.NIGHT_VISION, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.POISON, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.REGENERATION, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.STRENGTH, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.WEAKNESS, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.WITHER, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.INFESTED, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt(PotionEffectType.HASTE, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.MINING_FATIGUE, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.STRENGTH, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.NAUSEA, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.RESISTANCE, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.WATER_BREATHING, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.INVISIBILITY, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt(PotionEffectType.BLINDNESS, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.NIGHT_VISION, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt(PotionEffectType.HUNGER, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.HEALTH_BOOST, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.ABSORPTION, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.SATURATION, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.GLOWING, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt(PotionEffectType.LUCK, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt(PotionEffectType.UNLUCK, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt(PotionEffectType.CONDUIT_POWER, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.DOLPHINS_GRACE, EffektTyp.GOOD),
|
||||||
|
new Effekt(PotionEffectType.BAD_OMEN, EffektTyp.BAD),
|
||||||
|
new Effekt(PotionEffectType.HERO_OF_THE_VILLAGE, EffektTyp.GOOD));
|
||||||
|
|
||||||
|
public static List<Effekt> getEffects() {
|
||||||
|
return effects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Effekt getEffectByIndex(int index) {
|
||||||
|
return effects.get(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getEffectCount() {
|
||||||
|
return effects.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.xonics.classes;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
public class EffektRevolver {
|
||||||
|
|
||||||
|
private int roundSlots;
|
||||||
|
private int roundsShot;
|
||||||
|
private boolean isEmpty;
|
||||||
|
private ArrayList<Effekt> chamber = new ArrayList<Effekt>();
|
||||||
|
|
||||||
|
public EffektRevolver(int roundSlots) {
|
||||||
|
this.roundSlots = roundSlots;
|
||||||
|
this.roundsShot = 0;
|
||||||
|
this.isEmpty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadRevolver() {
|
||||||
|
if (this.isEmpty) {
|
||||||
|
|
||||||
|
this.roundsShot = 0;
|
||||||
|
|
||||||
|
ArrayList<Integer> randomZahlen = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < EffektLibrary.getEffectCount(); i++) {
|
||||||
|
randomZahlen.add(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.shuffle(randomZahlen);
|
||||||
|
|
||||||
|
for (int i = 0; i < roundSlots; i++) {
|
||||||
|
this.chamber.add(EffektLibrary.getEffectByIndex(randomZahlen.get(i)));
|
||||||
|
}
|
||||||
|
this.isEmpty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Effekt shoot() {
|
||||||
|
if (!this.isEmpty && this.roundsShot < this.roundSlots) {
|
||||||
|
int chamberNumber = this.roundsShot;
|
||||||
|
this.roundsShot++;
|
||||||
|
return this.chamber.get(chamberNumber);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Effekte Challenge V2/target/classes/com/xonics/ef/main.class
Normal file
BIN
Effekte Challenge V2/target/classes/com/xonics/ef/main.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user