Compare commits
4 Commits
hudut
...
e30236d281
| Author | SHA1 | Date | |
|---|---|---|---|
| e30236d281 | |||
| 043a7d0365 | |||
| d9afdeb4cd | |||
| 798483020a |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Effekte Challenge V2/target/*
|
||||||
|
.DS_Store
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.xonics.ef.classes;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.boss.BossBar;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.boss.BarColor;
|
||||||
|
import org.bukkit.boss.BarStyle;
|
||||||
|
import com.xonics.ef.main;
|
||||||
|
|
||||||
|
public class Challenge {
|
||||||
|
|
||||||
|
private boolean isRunning;
|
||||||
|
private List<Player> players;
|
||||||
|
private BukkitRunnable task;
|
||||||
|
private TimeManager tm;
|
||||||
|
|
||||||
|
public Challenge(List<Player> participants, int timer) {
|
||||||
|
this.players = participants;
|
||||||
|
this.isRunning = false;
|
||||||
|
this.tm.setTime(timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Challenge(List<Player> participants) {
|
||||||
|
this(participants, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start() {
|
||||||
|
if (!isRunning) {
|
||||||
|
isRunning = true;
|
||||||
|
BossBar infoBar = Bukkit.createBossBar("Finger an der Gapling Gan", BarColor.RED, BarStyle.SEGMENTED_10);
|
||||||
|
for (Player p : players) {
|
||||||
|
infoBar.addPlayer(p);
|
||||||
|
infoBar.setVisible(true);
|
||||||
|
}
|
||||||
|
Timer.start();
|
||||||
|
EffektRevolver revolver = new EffektRevolver(6);
|
||||||
|
revolver.loadRevolver();
|
||||||
|
this.task = new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
infoBar.setTitle(
|
||||||
|
"Finger an der Gapling Gan in " + tm.getTime() + "s " + revolver.getChamberIndicator());
|
||||||
|
infoBar.setProgress((double) (tm.getInitTime() - tm.getTime()) / tm.getInitTime());
|
||||||
|
|
||||||
|
if (tm.getTime() == 0) {
|
||||||
|
if (!revolver.isEmpty()) {
|
||||||
|
setEffekt(revolver.shoot());
|
||||||
|
} else {
|
||||||
|
revolver.loadRevolver();
|
||||||
|
}
|
||||||
|
tm.resetTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
tm.decreaseTime();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
task.runTaskTimer(main.getInstance(), 0L, 20L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop() {
|
||||||
|
this.task.cancel();
|
||||||
|
this.isRunning = false;
|
||||||
|
Timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessageToParticipants(String msg) {
|
||||||
|
for (Player p : players) {
|
||||||
|
p.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEffekt(Effekt e) {
|
||||||
|
for (Player p : players) {
|
||||||
|
p.addPotionEffect(new PotionEffect(e.getEffect(), tm.getInitTime(), 1));
|
||||||
|
switch (e.getEffektTyp()) {
|
||||||
|
case GOOD:
|
||||||
|
p.sendTitle("§a" + e.getName(), "", 10, 20, 10);
|
||||||
|
break;
|
||||||
|
case BAD:
|
||||||
|
p.sendTitle("§c" + e.getName(), "", 10, 20, 10);
|
||||||
|
break;
|
||||||
|
case NEUTRAL:
|
||||||
|
p.sendTitle("§7" + e.getName(), "", 10, 20, 10);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.xonics.ef.classes;
|
||||||
|
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
public class Effekt {
|
||||||
|
|
||||||
|
private String eName;
|
||||||
|
private PotionEffectType ieffect;
|
||||||
|
private EffektTyp ieTyp;
|
||||||
|
|
||||||
|
public Effekt(String name, PotionEffectType effect, EffektTyp eTyp) {
|
||||||
|
this.eName = name;
|
||||||
|
this.ieffect = effect;
|
||||||
|
this.ieTyp = eTyp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.eName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PotionEffectType getEffect() {
|
||||||
|
return this.ieffect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EffektTyp getEffektTyp() {
|
||||||
|
return this.ieTyp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum EffektTyp {
|
||||||
|
GOOD,
|
||||||
|
BAD,
|
||||||
|
NEUTRAL
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
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("Speed", PotionEffectType.SPEED, EffektTyp.GOOD),
|
||||||
|
new Effekt("Slowness", PotionEffectType.SLOWNESS, EffektTyp.BAD),
|
||||||
|
new Effekt("Jump Boost", PotionEffectType.JUMP_BOOST, EffektTyp.GOOD),
|
||||||
|
new Effekt("Oozing", PotionEffectType.OOZING, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt("Fire Resistance", PotionEffectType.FIRE_RESISTANCE, EffektTyp.GOOD),
|
||||||
|
new Effekt("Instant Damage", PotionEffectType.INSTANT_DAMAGE, EffektTyp.BAD),
|
||||||
|
new Effekt("Instant Health", PotionEffectType.INSTANT_HEALTH, EffektTyp.GOOD),
|
||||||
|
new Effekt("Hunger", PotionEffectType.HUNGER, EffektTyp.BAD),
|
||||||
|
new Effekt("Invisibility", PotionEffectType.INVISIBILITY, EffektTyp.GOOD),
|
||||||
|
new Effekt("Levitation", PotionEffectType.LEVITATION, EffektTyp.BAD),
|
||||||
|
new Effekt("Night Vision", PotionEffectType.NIGHT_VISION, EffektTyp.GOOD),
|
||||||
|
new Effekt("Poison", PotionEffectType.POISON, EffektTyp.BAD),
|
||||||
|
new Effekt("Regeneration", PotionEffectType.REGENERATION, EffektTyp.GOOD),
|
||||||
|
new Effekt("Strength", PotionEffectType.STRENGTH, EffektTyp.GOOD),
|
||||||
|
new Effekt("Weakness", PotionEffectType.WEAKNESS, EffektTyp.BAD),
|
||||||
|
new Effekt("Wither", PotionEffectType.WITHER, EffektTyp.BAD),
|
||||||
|
new Effekt("Infested", PotionEffectType.INFESTED, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt("Haste", PotionEffectType.HASTE, EffektTyp.GOOD),
|
||||||
|
new Effekt("Mining Fatigue", PotionEffectType.MINING_FATIGUE, EffektTyp.BAD),
|
||||||
|
new Effekt("Strength", PotionEffectType.STRENGTH, EffektTyp.GOOD),
|
||||||
|
new Effekt("Nausea", PotionEffectType.NAUSEA, EffektTyp.BAD),
|
||||||
|
new Effekt("Resistance", PotionEffectType.RESISTANCE, EffektTyp.GOOD),
|
||||||
|
new Effekt("Water Breathing", PotionEffectType.WATER_BREATHING, EffektTyp.GOOD),
|
||||||
|
new Effekt("Invisibility", PotionEffectType.INVISIBILITY, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt("Blindness", PotionEffectType.BLINDNESS, EffektTyp.BAD),
|
||||||
|
new Effekt("Night Vision", PotionEffectType.NIGHT_VISION, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt("Hunger", PotionEffectType.HUNGER, EffektTyp.BAD),
|
||||||
|
new Effekt("Health Boost", PotionEffectType.HEALTH_BOOST, EffektTyp.GOOD),
|
||||||
|
new Effekt("Absorption", PotionEffectType.ABSORPTION, EffektTyp.GOOD),
|
||||||
|
new Effekt("Saturation", PotionEffectType.SATURATION, EffektTyp.GOOD),
|
||||||
|
new Effekt("Glowing", PotionEffectType.GLOWING, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt("Luck", PotionEffectType.LUCK, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt("Unluck", PotionEffectType.UNLUCK, EffektTyp.NEUTRAL),
|
||||||
|
new Effekt("Conduit Power", PotionEffectType.CONDUIT_POWER, EffektTyp.GOOD),
|
||||||
|
new Effekt("Dolphins Grace", PotionEffectType.DOLPHINS_GRACE, EffektTyp.GOOD),
|
||||||
|
new Effekt("Bad Omen", PotionEffectType.BAD_OMEN, EffektTyp.BAD),
|
||||||
|
new Effekt("Hero of the Village", 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,60 @@
|
|||||||
|
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>();
|
||||||
|
private String chamberIndicator;
|
||||||
|
|
||||||
|
public EffektRevolver(int roundSlots) {
|
||||||
|
this.roundSlots = roundSlots;
|
||||||
|
this.roundsShot = 0;
|
||||||
|
this.isEmpty = true;
|
||||||
|
this.chamberIndicator = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
this.chamberIndicator += "§7| ";
|
||||||
|
}
|
||||||
|
|
||||||
|
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.roundsShot <= this.roundSlots) {
|
||||||
|
int chamberNumber = this.roundsShot;
|
||||||
|
this.roundsShot++;
|
||||||
|
this.chamberIndicator = this.chamberIndicator.substring(0, this.chamberIndicator.length() - 4);
|
||||||
|
return this.chamber.get(chamberNumber);
|
||||||
|
}
|
||||||
|
this.isEmpty = true;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return this.isEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChamberIndicator() {
|
||||||
|
return this.chamberIndicator;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.xonics.ef.classes;
|
||||||
|
|
||||||
|
public class TimeManager {
|
||||||
|
private int time;
|
||||||
|
private int timeClone;
|
||||||
|
|
||||||
|
public void setTime(int time) {
|
||||||
|
this.time = time;
|
||||||
|
this.timeClone = time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decreaseTime() {
|
||||||
|
this.time--;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void increaseTime() {
|
||||||
|
this.time++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTime() {
|
||||||
|
return this.time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInitTime() {
|
||||||
|
return this.timeClone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTime() {
|
||||||
|
this.time = this.timeClone;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
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 abstract class Timer {
|
||||||
|
|
||||||
|
private static int time;
|
||||||
|
private static BukkitRunnable task;
|
||||||
|
private static boolean paused = false;
|
||||||
|
private static boolean running = false;
|
||||||
|
|
||||||
|
public static void start() {
|
||||||
|
if (task != null)
|
||||||
|
return;
|
||||||
|
time = 0;
|
||||||
|
running = true;
|
||||||
|
|
||||||
|
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;
|
||||||
|
running = 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isPaused() {
|
||||||
|
return paused;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isRunning() {
|
||||||
|
return running;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.xonics.ef.commands;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import com.xonics.ef.classes.Timer;
|
||||||
|
|
||||||
|
public class TimerCommands implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player p = (Player) sender;
|
||||||
|
|
||||||
|
switch (command.getName().toLowerCase()) {
|
||||||
|
case "pause":
|
||||||
|
if (Timer.isPaused()) {
|
||||||
|
p.sendMessage("Der Timer ist bereits pausiert.");
|
||||||
|
} else {
|
||||||
|
Timer.pause();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "resume":
|
||||||
|
if (!Timer.isPaused()) {
|
||||||
|
p.sendMessage("Der Timer läuft bereits.");
|
||||||
|
} else {
|
||||||
|
Timer.resume();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,12 +3,19 @@ package com.xonics.ef.listeners;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
String pName = event.getPlayer().getName();
|
String pName = event.getPlayer().getName();
|
||||||
event.setJoinMessage("§a" + pName + " §7ist dem Spiel beigetreten!");
|
event.setJoinMessage("§a+ §8| §7" + pName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void OnPlayerLeave(PlayerQuitEvent event) {
|
||||||
|
String pName = event.getPlayer().getName();
|
||||||
|
event.setQuitMessage("§c- §8| §7" + pName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,18 +3,31 @@ package com.xonics.ef;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import com.xonics.ef.managers.PluginManager;
|
import com.xonics.ef.managers.PluginManager;
|
||||||
import com.xonics.ef.listeners.PlayerListener;
|
import com.xonics.ef.listeners.PlayerListener;
|
||||||
|
import com.xonics.ef.commands.TimerCommands;
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
// Register listeners
|
// Register listeners
|
||||||
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
|
||||||
|
// Register commands
|
||||||
|
getCommand("pause").setExecutor(new TimerCommands());
|
||||||
|
getCommand("resume").setExecutor(new TimerCommands());
|
||||||
|
|
||||||
getLogger().info("Effekte Challenge V2 has been enabled!");
|
getLogger().info("Effekte Challenge V2 has been enabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,4 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return ChatColor.translateAlternateColorCodes('&', msg);
|
return ChatColor.translateAlternateColorCodes('&', msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add more utility methods here
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,14 @@
|
|||||||
main: com.xonics.ef.main
|
main: com.xonics.ef.main
|
||||||
version: 1.0.0-SNAPSHOT
|
version: 12.0.1
|
||||||
name: Effekte Challenge V2
|
name: Effekte
|
||||||
author: xonics
|
author: xonics
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
commands:
|
||||||
|
pause:
|
||||||
|
description: Pauses the timer
|
||||||
|
usage: /pause
|
||||||
|
permission: timer.pause
|
||||||
|
resume:
|
||||||
|
description: Resumes the timer
|
||||||
|
usage: /resume
|
||||||
|
permission: timer.resume
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
main: com.xonics.ef.main
|
|
||||||
version: 1.0.0-SNAPSHOT
|
|
||||||
name: Effekte Challenge V2
|
|
||||||
author: xonics
|
|
||||||
api-version: 1.13
|
|
||||||
Reference in New Issue
Block a user