Compare commits

..

2 Commits

19 changed files with 210 additions and 3 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -8,7 +8,7 @@
<artifactId>effekte-challenge-v2</artifactId> <artifactId>effekte-challenge-v2</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<name>Effekte Challenge V2</name> <name>Effekte</name>
<url>http://www.example.com</url> <url>http://www.example.com</url>
<properties> <properties>

View File

@@ -0,0 +1,28 @@
package com.xonics.ef.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
}

View File

@@ -0,0 +1,59 @@
package com.xonics.ef.classes;
import java.util.List;
import org.bukkit.potion.PotionEffectType;
public abstract 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();
}
}

View File

@@ -0,0 +1,48 @@
package com.xonics.ef.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;
}
}

View File

@@ -0,0 +1,64 @@
package com.xonics.ef.classes;
import org.bukkit.scheduler.BukkitRunnable;
import com.xonics.ef.main;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class Timer {
private static int time;
private static BukkitRunnable task;
private static boolean paused = false;
public static void start() {
if (task != null)
return;
time = 0;
task = new BukkitRunnable() {
@Override
public void run() {
if (paused) {
for (Player p : Bukkit.getOnlinePlayers()) {
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("PAUSED"));
return;
}
}
time++;
for (Player p : Bukkit.getOnlinePlayers()) {
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(getTime()));
}
}
};
task.runTaskTimer(main.getInstance(), 0L, 20L);
}
public static void pause() {
paused = true;
}
public static void resume() {
paused = false;
}
public static void stop() {
task.cancel();
task = null;
time = 0;
paused = false;
}
public static String getTime() {
int stunden = time / 3600;
int minuten = (time % 3600) / 60;
int sekunden = time % 60;
return String.format("%02d:%02d:%02d", stunden, minuten, sekunden);
}
}

View File

@@ -6,9 +6,17 @@ import com.xonics.ef.listeners.PlayerListener;
public class main extends JavaPlugin { public class main extends JavaPlugin {
private static main instance;
public static main getInstance() {
return instance;
}
@Override @Override
public void onEnable() { public void onEnable() {
instance = this;
// Initialize managers // Initialize managers
PluginManager.getInstance().initialize(); PluginManager.getInstance().initialize();

View File

@@ -1,5 +1,5 @@
main: com.xonics.ef.main main: com.xonics.ef.main
version: 1.0.0-SNAPSHOT version: 1.0.0-SNAPSHOT
name: Effekte Challenge V2 name: Effekte
author: xonics author: xonics
api-version: 1.13 api-version: 1.13

View File

@@ -1,5 +1,5 @@
main: com.xonics.ef.main main: com.xonics.ef.main
version: 1.0.0-SNAPSHOT version: 1.0.0-SNAPSHOT
name: Effekte Challenge V2 name: Effekte
author: xonics author: xonics
api-version: 1.13 api-version: 1.13