Upload folder via GUI - src
This commit is contained in:
@@ -2,6 +2,7 @@ package de.nexuslobby.modules;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import io.papermc.paper.scoreboard.numbers.NumberFormat;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@@ -9,6 +10,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scoreboard.*;
|
||||
import org.bukkit.scoreboard.Criteria;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -105,25 +107,56 @@ public class ScoreboardModule implements Module, Listener {
|
||||
player.setScoreboard(board);
|
||||
}
|
||||
|
||||
// Altes Objective entfernen, damit wir die Zeilen aktualisieren können
|
||||
// Dasboard selbst bleibt bestehen (wichtig für Tablist-Teams!)
|
||||
// Altes Objective entfernen
|
||||
Objective oldObj = board.getObjective("lobby");
|
||||
if (oldObj != null) {
|
||||
oldObj.unregister();
|
||||
if (oldObj != null) oldObj.unregister();
|
||||
|
||||
// Alle alten Zeilen-Teams sicher entfernen (großzügige Obergrenze)
|
||||
for (int i = 0; i < Math.max(lines.size() + 5, 32); i++) {
|
||||
Team old = board.getTeam("line_" + i);
|
||||
if (old != null) old.unregister();
|
||||
}
|
||||
|
||||
Objective obj = board.registerNewObjective("lobby", "dummy",
|
||||
translate(player, title));
|
||||
// Paper 1.21: Objective mit Component-Titel registrieren
|
||||
String translatedTitle = translate(player, title);
|
||||
Objective obj = board.registerNewObjective(
|
||||
"lobby",
|
||||
Criteria.DUMMY,
|
||||
net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
|
||||
.legacySection()
|
||||
.deserialize(translatedTitle)
|
||||
);
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = translate(player, lines.get(i));
|
||||
// Zahlen global für dieses Objective ausblenden (Paper 1.20.4+ API)
|
||||
obj.numberFormat(NumberFormat.blank());
|
||||
|
||||
if (line.isEmpty() || line.isBlank()) {
|
||||
line = ChatColor.values()[i % ChatColor.values().length].toString();
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String lineText = translate(player, lines.get(i));
|
||||
|
||||
// Eindeutiger unsichtbarer Entry pro Zeile via Farb-Code
|
||||
String entry = ChatColor.values()[i % ChatColor.values().length].toString()
|
||||
+ ChatColor.RESET;
|
||||
|
||||
// getTeam statt registerNewTeam — verhindert "already in use" Fehler
|
||||
Team team = board.getTeam("line_" + i);
|
||||
if (team == null) team = board.registerNewTeam("line_" + i);
|
||||
team.getEntries().forEach(team::removeEntry);
|
||||
team.addEntry(entry);
|
||||
|
||||
// Text aufteilen falls länger als 64 Zeichen
|
||||
if (lineText.length() > 64) {
|
||||
team.setPrefix(lineText.substring(0, 64));
|
||||
team.setSuffix(lineText.substring(64, Math.min(lineText.length(), 128)));
|
||||
} else {
|
||||
team.setPrefix(lineText);
|
||||
team.setSuffix("");
|
||||
}
|
||||
|
||||
obj.getScore(line).setScore(lines.size() - i);
|
||||
// Score setzen + Zahl pro Eintrag zusätzlich ausblenden
|
||||
org.bukkit.scoreboard.Score score = obj.getScore(entry);
|
||||
score.setScore(lines.size() - i);
|
||||
score.numberFormat(NumberFormat.blank());
|
||||
}
|
||||
|
||||
// Kein player.setScoreboard(board) nötig, da wir das Objekt 'board'
|
||||
|
||||
@@ -159,6 +159,9 @@ public class ASTListener implements Listener {
|
||||
!title.equals("Pose: Körperteil wählen") &&
|
||||
!title.startsWith("Achsen:")) return;
|
||||
|
||||
// Amboss-GUI wird von AnvilRenameGUI selbst verwaltet — hier nicht anfassen
|
||||
if (title.equals("§6Name ändern")) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if (!(event.getWhoClicked() instanceof Player p)) return;
|
||||
|
||||
@@ -175,8 +178,11 @@ public class ASTListener implements Listener {
|
||||
ArmorStandTool tool = ArmorStandTool.get(item);
|
||||
if (tool != null) {
|
||||
tool.execute(as, p);
|
||||
// Menü aktualisieren, falls wir noch im selben Editor sind
|
||||
if (p.getOpenInventory().getTitle().equals(title)) {
|
||||
// Editor nur neu öffnen wenn kein Chat-Input-Modus aktiv ist
|
||||
// und wir wirklich noch im Editor-Inventar sind
|
||||
String newTitle = p.getOpenInventory().getTitle();
|
||||
if (newTitle.equals("Nexus ArmorStand Editor")
|
||||
&& !AST.chatInputMode.containsKey(p.getUniqueId())) {
|
||||
new ArmorStandGUI(as, p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package de.nexuslobby.modules.armorstandtools;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* Chat-basierte Namenseingabe für ArmorStands.
|
||||
* Der Spieler tippt den neuen Namen in den Chat.
|
||||
* Unterstützt & Farb-Codes.
|
||||
*/
|
||||
public class AnvilRenameGUI implements Listener {
|
||||
|
||||
private final Player player;
|
||||
private final ArmorStand armorStand;
|
||||
|
||||
public AnvilRenameGUI(Player player, ArmorStand armorStand) {
|
||||
this.player = player;
|
||||
this.armorStand = armorStand;
|
||||
|
||||
// Listener registrieren
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
|
||||
// Inventar schließen + Anweisung anzeigen
|
||||
player.closeInventory();
|
||||
|
||||
// Title als UI-Feedback (wie AFK-Anzeige)
|
||||
player.sendTitle(
|
||||
"§6§lName eingeben",
|
||||
"§7Schreibe den neuen Namen in den §eChat§7. §8(&-Codes erlaubt)",
|
||||
10, 80, 20
|
||||
);
|
||||
player.sendMessage("§8[§6Nexus§8] §7Gib den neuen §eNamen §7in den Chat ein. §8(&-Farb-Codes erlaubt)");
|
||||
player.sendMessage("§8[§6Nexus§8] §c'abbrechen' §7eingeben zum Abbrechen.");
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Chat-Event — Paper 1.21 AsyncChatEvent
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChat(AsyncChatEvent event) {
|
||||
if (!event.getPlayer().equals(player)) return;
|
||||
|
||||
// Chat-Nachricht abfangen
|
||||
event.setCancelled(true);
|
||||
|
||||
// Plain-Text aus Adventure Component extrahieren
|
||||
String input = PlainTextComponentSerializer.plainText().serialize(event.message()).trim();
|
||||
|
||||
// Zurück auf Haupt-Thread wechseln für Bukkit-API Aufrufe
|
||||
Bukkit.getScheduler().runTask(NexusLobby.getInstance(), () -> {
|
||||
HandlerList.unregisterAll(this);
|
||||
AST.chatInputMode.remove(player.getUniqueId());
|
||||
|
||||
if (input.equalsIgnoreCase("abbrechen")) {
|
||||
player.sendTitle("§c§lAbgebrochen", "", 5, 30, 10);
|
||||
player.sendMessage("§8[§6Nexus§8] §cNamensänderung abgebrochen.");
|
||||
} else {
|
||||
// & → § Farb-Codes
|
||||
String newName = ChatColor.translateAlternateColorCodes('&', input);
|
||||
armorStand.setCustomName(newName);
|
||||
armorStand.setCustomNameVisible(!ChatColor.stripColor(newName).isEmpty());
|
||||
|
||||
player.sendTitle("§a§lName gesetzt!", "§r" + newName, 5, 40, 10);
|
||||
player.sendMessage("§8[§6Nexus§8] §aName gesetzt: " + newName);
|
||||
}
|
||||
|
||||
// Zurück zum ArmorStand-Editor
|
||||
if (armorStand.isValid()) {
|
||||
new ArmorStandGUI(armorStand, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Logout — Listener sauber abmelden
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
if (!event.getPlayer().equals(player)) return;
|
||||
HandlerList.unregisterAll(this);
|
||||
AST.chatInputMode.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
@@ -51,9 +51,9 @@ public enum ArmorStandTool {
|
||||
case GRAV -> as.setGravity(!as.hasGravity());
|
||||
case INVUL -> as.setInvulnerable(!as.isInvulnerable());
|
||||
case SET_NAME -> {
|
||||
p.closeInventory();
|
||||
p.sendMessage("§8[§6Nexus§8] §7Nutze §e/nexuscmd name <Text>");
|
||||
AST.selectedArmorStand.put(p.getUniqueId(), as);
|
||||
AST.chatInputMode.put(p.getUniqueId(), as);
|
||||
new AnvilRenameGUI(p, as); // schließt Inventar intern
|
||||
}
|
||||
case CONV_SETUP -> {
|
||||
// Automatisches Markieren via GUI
|
||||
|
||||
@@ -1,79 +1,70 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Balloon {
|
||||
private final UUID playerUUID;
|
||||
private final LivingEntity balloonEntity;
|
||||
private final ArmorStand headStand;
|
||||
|
||||
private final UUID playerUUID;
|
||||
private final LivingEntity balloonEntity;
|
||||
private final ArmorStand headStand;
|
||||
public Balloon(Player player, Material balloonMaterial) {
|
||||
this.playerUUID = player.getUniqueId();
|
||||
Location loc = player.getLocation().add((double)0.0F, (double)2.0F, (double)0.0F);
|
||||
this.balloonEntity = (LivingEntity)loc.getWorld().spawnEntity(loc, EntityType.PIG);
|
||||
this.balloonEntity.setInvisible(true);
|
||||
this.balloonEntity.setSilent(true);
|
||||
this.balloonEntity.setInvulnerable(true);
|
||||
this.balloonEntity.setGravity(false);
|
||||
this.balloonEntity.setLeashHolder(player);
|
||||
this.balloonEntity.addScoreboardTag("nexus_balloon");
|
||||
this.headStand = (ArmorStand)loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
||||
this.headStand.setVisible(false);
|
||||
this.headStand.setGravity(false);
|
||||
this.headStand.setMarker(true);
|
||||
this.headStand.setHelmet(new ItemStack(balloonMaterial));
|
||||
}
|
||||
|
||||
public Balloon(Player player, Material balloonMaterial) {
|
||||
this.playerUUID = player.getUniqueId();
|
||||
Location loc = player.getLocation().add(0, 2, 0);
|
||||
public void update() {
|
||||
Player player = Bukkit.getPlayer(this.playerUUID);
|
||||
if (player != null && player.isOnline() && this.balloonEntity != null && this.balloonEntity.isValid()) {
|
||||
if (!this.balloonEntity.isLeashed()) {
|
||||
this.remove();
|
||||
} else {
|
||||
Location targetLoc = player.getLocation().clone().add((double)0.0F, (double)2.5F, (double)0.0F);
|
||||
Vector direction = targetLoc.toVector().subtract(this.balloonEntity.getLocation().toVector());
|
||||
double distance = direction.length();
|
||||
if (distance > (double)5.0F) {
|
||||
this.balloonEntity.teleport(targetLoc);
|
||||
} else if (distance > 0.1) {
|
||||
this.balloonEntity.setVelocity(direction.multiply(0.4));
|
||||
}
|
||||
|
||||
// Das unsichtbare Träger-Entity
|
||||
this.balloonEntity = (LivingEntity) loc.getWorld().spawnEntity(loc, EntityType.PIG);
|
||||
this.balloonEntity.setInvisible(true);
|
||||
this.balloonEntity.setSilent(true);
|
||||
this.balloonEntity.setInvulnerable(true);
|
||||
this.balloonEntity.setGravity(false);
|
||||
this.balloonEntity.setLeashHolder(player);
|
||||
// Tag damit GadgetModule Rechtsklicks auf den Ballon abfangen kann
|
||||
this.balloonEntity.addScoreboardTag("nexus_balloon");
|
||||
this.headStand.teleport(this.balloonEntity.getLocation().clone().subtract((double)0.0F, (double)1.5F, (double)0.0F));
|
||||
}
|
||||
} else {
|
||||
this.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Der ArmorStand, der den farbigen Block trägt
|
||||
this.headStand = (ArmorStand) loc.getWorld().spawnEntity(loc, EntityType.ARMOR_STAND);
|
||||
this.headStand.setVisible(false);
|
||||
this.headStand.setGravity(false);
|
||||
this.headStand.setMarker(true);
|
||||
public void remove() {
|
||||
if (this.balloonEntity != null) {
|
||||
this.balloonEntity.setLeashHolder((Entity)null);
|
||||
this.balloonEntity.remove();
|
||||
}
|
||||
|
||||
// Hier wird das übergebene Material gesetzt (z.B. RED_WOOL, BLUE_WOOL etc.)
|
||||
this.headStand.setHelmet(new ItemStack(balloonMaterial));
|
||||
}
|
||||
if (this.headStand != null) {
|
||||
this.headStand.remove();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
Player player = org.bukkit.Bukkit.getPlayer(playerUUID);
|
||||
|
||||
if (player == null || !player.isOnline() || balloonEntity == null || !balloonEntity.isValid()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!balloonEntity.isLeashed()) {
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
Location targetLoc = player.getLocation().clone().add(0, 2.5, 0);
|
||||
Vector direction = targetLoc.toVector().subtract(balloonEntity.getLocation().toVector());
|
||||
double distance = direction.length();
|
||||
|
||||
if (distance > 5) {
|
||||
balloonEntity.teleport(targetLoc);
|
||||
} else if (distance > 0.1) {
|
||||
balloonEntity.setVelocity(direction.multiply(0.4));
|
||||
}
|
||||
|
||||
headStand.teleport(balloonEntity.getLocation().clone().subtract(0, 1.5, 0));
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
if (balloonEntity != null) {
|
||||
balloonEntity.setLeashHolder(null);
|
||||
balloonEntity.remove();
|
||||
}
|
||||
if (headStand != null) {
|
||||
headStand.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
@@ -10,54 +15,40 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class ChickenRain {
|
||||
private static final Set<UUID> activeRains = Collections.synchronizedSet(new HashSet());
|
||||
|
||||
// FIX: Verhindert, dass ein Spieler den Regen mehrfach gleichzeitig starten kann.
|
||||
// Ohne diese Prüfung konnten beliebig viele parallele Tasks gestartet werden,
|
||||
// was zu hunderten gespawnten Entities in Sekunden führte.
|
||||
private static final java.util.Set<java.util.UUID> activeRains =
|
||||
java.util.Collections.synchronizedSet(new java.util.HashSet<>());
|
||||
|
||||
public static void start(Player player) {
|
||||
if (activeRains.contains(player.getUniqueId())) return; // bereits aktiv
|
||||
activeRains.add(player.getUniqueId());
|
||||
new BukkitRunnable() {
|
||||
public static void start(final Player player) {
|
||||
if (!activeRains.contains(player.getUniqueId())) {
|
||||
activeRains.add(player.getUniqueId());
|
||||
(new BukkitRunnable() {
|
||||
int ticks = 0;
|
||||
final Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!player.isOnline() || ticks > 100) { // 100 Ticks = 5 Sekunden
|
||||
activeRains.remove(player.getUniqueId());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Alle 2 Ticks ein Huhn spawnen
|
||||
if (ticks % 2 == 0) {
|
||||
Location spawnLoc = player.getLocation().add(
|
||||
(random.nextDouble() - 0.5) * 4,
|
||||
4.0,
|
||||
(random.nextDouble() - 0.5) * 4
|
||||
);
|
||||
|
||||
Chicken chicken = (Chicken) spawnLoc.getWorld().spawnEntity(spawnLoc, EntityType.CHICKEN);
|
||||
chicken.setBaby();
|
||||
chicken.setInvulnerable(true);
|
||||
|
||||
// Nach 1.5 Sekunden "ploppt" das Huhn
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
if (player.isOnline() && this.ticks <= 100) {
|
||||
if (this.ticks % 2 == 0) {
|
||||
Location spawnLoc = player.getLocation().add((this.random.nextDouble() - (double)0.5F) * (double)4.0F, (double)4.0F, (this.random.nextDouble() - (double)0.5F) * (double)4.0F);
|
||||
Chicken chicken = (Chicken)spawnLoc.getWorld().spawnEntity(spawnLoc, EntityType.CHICKEN);
|
||||
chicken.setBaby();
|
||||
chicken.setInvulnerable(true);
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
if (chicken.isValid()) {
|
||||
chicken.getWorld().spawnParticle(Particle.CLOUD, chicken.getLocation(), 5, 0.2, 0.2, 0.2, 0.1);
|
||||
chicken.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0f, 1.5f);
|
||||
chicken.remove();
|
||||
chicken.getWorld().spawnParticle(Particle.CLOUD, chicken.getLocation(), 5, 0.2, 0.2, 0.2, 0.1);
|
||||
chicken.getWorld().playSound(chicken.getLocation(), Sound.ENTITY_CHICKEN_EGG, 1.0F, 1.5F);
|
||||
chicken.remove();
|
||||
}
|
||||
}, 30L);
|
||||
}
|
||||
ticks++;
|
||||
|
||||
}, 30L);
|
||||
}
|
||||
|
||||
++this.ticks;
|
||||
} else {
|
||||
ChickenRain.activeRains.remove(player.getUniqueId());
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
}).runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,104 +1,100 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FreezeRay {
|
||||
private static final Set<UUID> frozenPlayers = new HashSet();
|
||||
|
||||
private static final Set<UUID> frozenPlayers = new HashSet<>();
|
||||
public static boolean isFrozen(UUID uuid) {
|
||||
return frozenPlayers.contains(uuid);
|
||||
}
|
||||
|
||||
public static boolean isFrozen(UUID uuid) { return frozenPlayers.contains(uuid); }
|
||||
public static void unfreeze(UUID uuid) {
|
||||
frozenPlayers.remove(uuid);
|
||||
}
|
||||
|
||||
/** Beim Disconnect aufrufen, damit kein Ghost-Eintrag bleibt. */
|
||||
public static void unfreeze(UUID uuid) { frozenPlayers.remove(uuid); }
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0F, 1.5F);
|
||||
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
for(double d = (double)0.0F; d < (double)15.0F; d += 0.3) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0f, 1.5f);
|
||||
for(Entity entity : point.getWorld().getNearbyEntities(point, 0.8, 0.8, 0.8)) {
|
||||
if (entity instanceof Player target) {
|
||||
if (target != shooter) {
|
||||
if (GadgetShield.isProtected(target)) {
|
||||
String reason = GadgetShield.isAdminShielded(target) ? "Dieser Spieler hat Gadget-Schutz aktiviert." : "Dieser Spieler ist gerade im Parkour.";
|
||||
shooter.sendMessage("§8[§6Nexus§8] §7" + reason);
|
||||
return;
|
||||
}
|
||||
|
||||
for (double d = 0; d < 15; d += 0.3) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
|
||||
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, 0, 0, 0, 0);
|
||||
|
||||
for (Entity entity : point.getWorld().getNearbyEntities(point, 0.8, 0.8, 0.8)) {
|
||||
if (entity instanceof Player target && target != shooter) {
|
||||
// Schutz: Parkour-Spieler und Admins mit aktivem Gadget-Schutz
|
||||
if (GadgetShield.isProtected(target)) {
|
||||
String reason = GadgetShield.isAdminShielded(target)
|
||||
? "Dieser Spieler hat Gadget-Schutz aktiviert."
|
||||
: "Dieser Spieler ist gerade im Parkour.";
|
||||
shooter.sendMessage("§8[§6Nexus§8] §7" + reason);
|
||||
return;
|
||||
}
|
||||
applyFreeze(target);
|
||||
return;
|
||||
}
|
||||
applyFreeze(target);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyFreeze(Player target) {
|
||||
if (frozenPlayers.contains(target.getUniqueId())) return;
|
||||
}
|
||||
|
||||
frozenPlayers.add(target.getUniqueId());
|
||||
final Location freezeLocation = target.getLocation();
|
||||
|
||||
target.sendMessage("§8[§6Nexus§8] §bDu wurdest eingefroren!");
|
||||
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0f, 0.5f);
|
||||
|
||||
new org.bukkit.scheduler.BukkitRunnable() {
|
||||
private static void applyFreeze(final Player target) {
|
||||
if (!frozenPlayers.contains(target.getUniqueId())) {
|
||||
frozenPlayers.add(target.getUniqueId());
|
||||
final Location freezeLocation = target.getLocation();
|
||||
target.sendMessage("§8[§6Nexus§8] §bDu wurdest eingefroren!");
|
||||
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_GLASS_BREAK, 1.0F, 0.5F);
|
||||
(new BukkitRunnable() {
|
||||
int ticks = 0;
|
||||
@Override
|
||||
|
||||
public void run() {
|
||||
if (!target.isOnline() || ticks >= 60) {
|
||||
frozenPlayers.remove(target.getUniqueId());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
if (target.isOnline() && this.ticks < 60) {
|
||||
if (GadgetShield.isProtected(target)) {
|
||||
FreezeRay.frozenPlayers.remove(target.getUniqueId());
|
||||
this.cancel();
|
||||
} else {
|
||||
target.setVelocity(new Vector(0, 0, 0));
|
||||
Location current = target.getLocation();
|
||||
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
||||
freezeLocation.setYaw(current.getYaw());
|
||||
freezeLocation.setPitch(current.getPitch());
|
||||
target.teleport(freezeLocation);
|
||||
}
|
||||
|
||||
// Falls der Spieler während des Einfrierens geschützt wird → sofort freigeben
|
||||
if (GadgetShield.isProtected(target)) {
|
||||
frozenPlayers.remove(target.getUniqueId());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
Location loc = target.getLocation();
|
||||
|
||||
target.setVelocity(new Vector(0, 0, 0));
|
||||
for(int i = 0; i < 8; ++i) {
|
||||
double angle = (double)i * Math.PI / (double)4.0F;
|
||||
double x = Math.cos(angle) * 0.7;
|
||||
double z = Math.sin(angle) * 0.7;
|
||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, (double)1.0F, z), 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, 0.2, z), 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
}
|
||||
|
||||
Location current = target.getLocation();
|
||||
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
||||
freezeLocation.setYaw(current.getYaw());
|
||||
freezeLocation.setPitch(current.getPitch());
|
||||
target.teleport(freezeLocation);
|
||||
}
|
||||
|
||||
Location loc = target.getLocation();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
double angle = i * Math.PI / 4;
|
||||
double x = Math.cos(angle) * 0.7;
|
||||
double z = Math.sin(angle) * 0.7;
|
||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, 1, z), 1, 0, 0, 0, 0);
|
||||
loc.getWorld().spawnParticle(Particle.SNOWFLAKE, loc.clone().add(x, 0.2, z), 1, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
ticks += 2;
|
||||
this.ticks += 2;
|
||||
}
|
||||
} else {
|
||||
FreezeRay.frozenPlayers.remove(target.getUniqueId());
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 2L);
|
||||
}
|
||||
}).runTaskTimer(NexusLobby.getInstance(), 0L, 2L);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,58 +2,44 @@ package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.modules.parkour.ParkourManager;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Verwaltet den Gadget-Schutz für Admins und Parkour-Spieler.
|
||||
* Eigenständige Klasse – kein Eingriff in GadgetModule nötig.
|
||||
*/
|
||||
public class GadgetShield {
|
||||
private static final Set<UUID> shielded = new HashSet();
|
||||
|
||||
/** UUIDs der Admins, die ihren Gadget-Schutz aktiviert haben */
|
||||
private static final Set<UUID> shielded = new HashSet<>();
|
||||
public static boolean toggle(Player player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (shielded.contains(uuid)) {
|
||||
shielded.remove(uuid);
|
||||
player.sendMessage("§8[§6Nexus§8] §cGadget-Schutz §7deaktiviert.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1.0F, 1.0F);
|
||||
return false;
|
||||
} else {
|
||||
shielded.add(uuid);
|
||||
player.sendMessage("§8[§6Nexus§8] §aGadget-Schutz §7aktiviert. §8Du bist nun immun gegen Gadgets.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1.0F, 1.5F);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schaltet den Gadget-Schutz ein oder aus.
|
||||
* Gibt true zurück wenn der Schutz jetzt aktiv ist.
|
||||
*/
|
||||
public static boolean toggle(Player player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (shielded.contains(uuid)) {
|
||||
shielded.remove(uuid);
|
||||
player.sendMessage("§8[§6Nexus§8] §cGadget-Schutz §7deaktiviert.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||
return false;
|
||||
} else {
|
||||
shielded.add(uuid);
|
||||
player.sendMessage("§8[§6Nexus§8] §aGadget-Schutz §7aktiviert. §8Du bist nun immun gegen Gadgets.");
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1f, 1.5f);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public static boolean isAdminShielded(Player player) {
|
||||
return shielded.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
/** Gibt zurück ob ein Spieler explizit durch den Admin-Schutz geschützt ist. */
|
||||
public static boolean isAdminShielded(Player player) {
|
||||
return shielded.contains(player.getUniqueId());
|
||||
}
|
||||
public static boolean isProtected(Player player) {
|
||||
if (shielded.contains(player.getUniqueId())) {
|
||||
return true;
|
||||
} else {
|
||||
ParkourManager pm = NexusLobby.getInstance().getParkourManager();
|
||||
return pm != null && pm.isIngame(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gibt zurück ob ein Spieler durch irgendeinen Schutz immun gegen Gadgets ist
|
||||
* (Admin-Schutz ODER aktiver Parkour-Run).
|
||||
*/
|
||||
public static boolean isProtected(Player player) {
|
||||
if (shielded.contains(player.getUniqueId())) return true;
|
||||
ParkourManager pm = NexusLobby.getInstance().getParkourManager();
|
||||
return pm != null && pm.isIngame(player);
|
||||
}
|
||||
|
||||
/** Beim Server-Stop / Plugin-Disable aufrufen */
|
||||
public static void clear() {
|
||||
shielded.clear();
|
||||
}
|
||||
public static void clear() {
|
||||
shielded.clear();
|
||||
}
|
||||
}
|
||||
@@ -6,32 +6,20 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class GrapplingHook {
|
||||
public static void pullPlayer(Player player, Location target) {
|
||||
Location playerLoc = player.getLocation();
|
||||
double distance = target.distance(playerLoc);
|
||||
if (!(distance < (double)2.0F) && !(distance > (double)50.0F)) {
|
||||
Vector v = target.toVector().subtract(playerLoc.toVector());
|
||||
v.multiply(0.3);
|
||||
v.setY(v.getY() * 0.6 + (double)0.5F);
|
||||
if (v.length() > (double)2.5F) {
|
||||
v.normalize().multiply((double)2.5F);
|
||||
}
|
||||
|
||||
public static void pullPlayer(Player player, Location target) {
|
||||
Location playerLoc = player.getLocation();
|
||||
|
||||
// Vektor vom Spieler zum Ziel berechnen
|
||||
double distance = target.distance(playerLoc);
|
||||
|
||||
// Wenn das Ziel zu nah oder zu weit weg ist, nichts tun
|
||||
if (distance < 2 || distance > 50) return;
|
||||
|
||||
// Berechnung des Wurfs (Vektor)
|
||||
Vector v = target.toVector().subtract(playerLoc.toVector());
|
||||
|
||||
// Den Vektor normalisieren und skalieren (Stärke des Zugs)
|
||||
v.multiply(0.3); // Basis-Geschwindigkeit
|
||||
v.setY(v.getY() * 0.6 + 0.5); // Etwas mehr Höhe für den Bogen-Effekt
|
||||
|
||||
// Geschwindigkeit begrenzen, damit man nicht aus der Map schießt
|
||||
if (v.length() > 2.5) {
|
||||
v.normalize().multiply(2.5);
|
||||
}
|
||||
|
||||
player.setVelocity(v);
|
||||
|
||||
// Sound-Effekt für das "Ziehen"
|
||||
player.playSound(playerLoc, Sound.ENTITY_WIND_CHARGE_WIND_BURST, 1.0f, 1.2f);
|
||||
player.playSound(playerLoc, Sound.ITEM_TRIDENT_RIPTIDE_1, 0.5f, 1.5f);
|
||||
}
|
||||
player.setVelocity(v);
|
||||
player.playSound(playerLoc, Sound.ENTITY_WIND_CHARGE_WIND_BURST, 1.0F, 1.2F);
|
||||
player.playSound(playerLoc, Sound.ITEM_TRIDENT_RIPTIDE_1, 0.5F, 1.5F);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,19 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class HatManager {
|
||||
public static void setHat(Player player, Material material, String name) {
|
||||
ItemStack hat = new ItemStack(material);
|
||||
ItemMeta meta = hat.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName("§6Hut: " + name);
|
||||
hat.setItemMeta(meta);
|
||||
}
|
||||
|
||||
public static void setHat(Player player, Material material, String name) {
|
||||
ItemStack hat = new ItemStack(material);
|
||||
ItemMeta meta = hat.getItemMeta();
|
||||
if (meta != null) {
|
||||
meta.setDisplayName("§6Hut: " + name);
|
||||
hat.setItemMeta(meta);
|
||||
}
|
||||
player.getInventory().setHelmet(hat);
|
||||
player.sendMessage("§8[§6Nexus§8] §aDu trägst nun: " + name);
|
||||
}
|
||||
|
||||
// Den Gegenstand auf den Kopf setzen
|
||||
player.getInventory().setHelmet(hat);
|
||||
player.sendMessage("§8[§6Nexus§8] §aDu trägst nun: " + name);
|
||||
}
|
||||
|
||||
public static void removeHat(Player player) {
|
||||
player.getInventory().setHelmet(null);
|
||||
}
|
||||
public static void removeHat(Player player) {
|
||||
player.getInventory().setHelmet((ItemStack)null);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
@@ -9,51 +10,45 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class MeteorStrike {
|
||||
public static void launch(Player shooter) {
|
||||
Location target = null;
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
|
||||
public static void launch(Player shooter) {
|
||||
Location target = null;
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
for(double d = (double)0.0F; d < (double)30.0F; d += (double)0.5F) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
target = point;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (double d = 0; d < 30; d += 0.5) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
target = point;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null) return;
|
||||
final Location finalTarget = target.clone().add(0, 0.5, 0);
|
||||
|
||||
finalTarget.getWorld().spawnParticle(Particle.FLAME, finalTarget, 20, 0.5, 0.1, 0.5, 0.05);
|
||||
shooter.sendMessage("§8[§6Nexus§8] §cMeteorit im Anflug...");
|
||||
|
||||
org.bukkit.Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
if (target != null) {
|
||||
Location finalTarget = target.clone().add((double)0.0F, (double)0.5F, (double)0.0F);
|
||||
finalTarget.getWorld().spawnParticle(Particle.FLAME, finalTarget, 20, (double)0.5F, 0.1, (double)0.5F, 0.05);
|
||||
shooter.sendMessage("§8[§6Nexus§8] §cMeteorit im Anflug...");
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
finalTarget.getWorld().spawnParticle(Particle.EXPLOSION_EMITTER, finalTarget, 1);
|
||||
finalTarget.getWorld().spawnParticle(Particle.LAVA, finalTarget, 30, 0.5, 0.5, 0.5, 0.1);
|
||||
finalTarget.getWorld().playSound(finalTarget, Sound.ENTITY_GENERIC_EXPLODE, 1.0f, 0.8f);
|
||||
finalTarget.getWorld().spawnParticle(Particle.LAVA, finalTarget, 30, (double)0.5F, (double)0.5F, (double)0.5F, 0.1);
|
||||
finalTarget.getWorld().playSound(finalTarget, Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 0.8F);
|
||||
|
||||
for (Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, 4, 4, 4)) {
|
||||
if (entity instanceof Player p) {
|
||||
// Schutz: Admins mit Gadget-Schutz und Parkour-Spieler werden nicht weggeschleudert
|
||||
if (GadgetShield.isProtected(p)) {
|
||||
if (GadgetShield.isAdminShielded(p)) {
|
||||
p.sendMessage("§8[§6Nexus§8] §7Dein Gadget-Schutzschild hat den Meteoriten abgelenkt!");
|
||||
} else {
|
||||
p.sendMessage("§8[§6Parkour§8] §7Dein Parkour-Schutzschild hat den Meteoriten abgelenkt!");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Vector v = p.getLocation().toVector()
|
||||
.subtract(finalTarget.toVector())
|
||||
.normalize()
|
||||
.multiply(1.5)
|
||||
.setY(0.5);
|
||||
p.setVelocity(v);
|
||||
p.sendMessage("§cBUMM!");
|
||||
}
|
||||
for(Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, (double)4.0F, (double)4.0F, (double)4.0F)) {
|
||||
if (entity instanceof Player p) {
|
||||
if (GadgetShield.isProtected(p)) {
|
||||
if (GadgetShield.isAdminShielded(p)) {
|
||||
p.sendMessage("§8[§6Nexus§8] §7Dein Gadget-Schutzschild hat den Meteoriten abgelenkt!");
|
||||
} else {
|
||||
p.sendMessage("§8[§6Parkour§8] §7Dein Parkour-Schutzschild hat den Meteoriten abgelenkt!");
|
||||
}
|
||||
} else {
|
||||
Vector v = p.getLocation().toVector().subtract(finalTarget.toVector()).normalize().multiply((double)1.5F).setY((double)0.5F);
|
||||
p.setVelocity(v);
|
||||
p.sendMessage("§cBUMM!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 30L);
|
||||
}
|
||||
|
||||
}, 30L);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.Random;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -10,80 +11,65 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class PaintballGun {
|
||||
private static final Random random = new Random();
|
||||
private static final Random random = new Random();
|
||||
private static final Material[] COLORS;
|
||||
|
||||
// Wir nutzen jetzt Wolle für kräftigere Farben
|
||||
private static final Material[] COLORS = {
|
||||
Material.RED_WOOL, Material.BLUE_WOOL, Material.LIME_WOOL,
|
||||
Material.ORANGE_WOOL, Material.MAGENTA_WOOL, Material.LIGHT_BLUE_WOOL,
|
||||
Material.YELLOW_WOOL, Material.PURPLE_WOOL, Material.PINK_WOOL
|
||||
};
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
Material randomColor = COLORS[random.nextInt(COLORS.length)];
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_CHICKEN_EGG, 1.0F, 2.0F);
|
||||
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
Material randomColor = COLORS[random.nextInt(COLORS.length)];
|
||||
for(double d = (double)0.0F; d < (double)25.0F; d += (double)0.5F) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
point.getWorld().spawnParticle(Particle.ITEM_SNOWBALL, point, 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
Block block = point.getBlock();
|
||||
if (block.getType().isSolid()) {
|
||||
impact(block, randomColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_CHICKEN_EGG, 1.0f, 2.0f);
|
||||
}
|
||||
|
||||
for (double d = 0; d < 25; d += 0.5) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
private static void impact(Block centerBlock, Material color) {
|
||||
Location centerLoc = centerBlock.getLocation();
|
||||
centerLoc.getWorld().playSound(centerLoc, Sound.ENTITY_SLIME_SQUISH, 1.0F, 1.2F);
|
||||
int radius = 2;
|
||||
|
||||
// Flug-Partikel (kleiner Rauch oder Schneeball)
|
||||
point.getWorld().spawnParticle(Particle.ITEM_SNOWBALL, point, 1, 0, 0, 0, 0);
|
||||
|
||||
Block block = point.getBlock();
|
||||
if (block.getType().isSolid()) {
|
||||
impact(block, randomColor);
|
||||
break;
|
||||
for(int x = -radius; x <= radius; ++x) {
|
||||
for(int y = -radius; y <= radius; ++y) {
|
||||
for(int z = -radius; z <= radius; ++z) {
|
||||
if ((double)(x * x + y * y + z * z) <= (double)(radius * radius) + (double)0.5F) {
|
||||
Block target = centerLoc.clone().add((double)x, (double)y, (double)z).getBlock();
|
||||
if (target.getType().isSolid()) {
|
||||
applyColor(target, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void impact(Block centerBlock, Material color) {
|
||||
Location centerLoc = centerBlock.getLocation();
|
||||
centerLoc.getWorld().playSound(centerLoc, Sound.ENTITY_SLIME_SQUISH, 1.0f, 1.2f);
|
||||
}
|
||||
|
||||
int radius = 2; // Radius der Farbkugel
|
||||
private static void applyColor(Block block, Material color) {
|
||||
Location loc = block.getLocation();
|
||||
loc.getWorld().spawnParticle(Particle.BLOCK, loc.clone().add((double)0.5F, (double)0.5F, (double)0.5F), 3, 0.1, 0.1, 0.1, color.createBlockData());
|
||||
|
||||
// Wir gehen alle Blöcke im Würfel um den Einschlag durch
|
||||
for (int x = -radius; x <= radius; x++) {
|
||||
for (int y = -radius; y <= radius; y++) {
|
||||
for (int z = -radius; z <= radius; z++) {
|
||||
for(Player online : Bukkit.getOnlinePlayers()) {
|
||||
online.sendBlockChange(loc, color.createBlockData());
|
||||
}
|
||||
|
||||
// Berechne Distanz für eine Kugelform (statt Würfel)
|
||||
if (x * x + y * y + z * z <= radius * radius + 0.5) {
|
||||
Block target = centerLoc.clone().add(x, y, z).getBlock();
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
for(Player online : Bukkit.getOnlinePlayers()) {
|
||||
online.sendBlockChange(loc, block.getBlockData());
|
||||
}
|
||||
|
||||
// Nur solide Blöcke färben (keine Luft/Gras)
|
||||
if (target.getType().isSolid()) {
|
||||
applyColor(target, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 400L);
|
||||
}
|
||||
|
||||
private static void applyColor(Block block, Material color) {
|
||||
Location loc = block.getLocation();
|
||||
|
||||
// Effekt-Partikel am Block
|
||||
loc.getWorld().spawnParticle(Particle.BLOCK, loc.clone().add(0.5, 0.5, 0.5), 3, 0.1, 0.1, 0.1, color.createBlockData());
|
||||
|
||||
// Block-Änderung an alle senden
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
online.sendBlockChange(loc, color.createBlockData());
|
||||
}
|
||||
|
||||
// Nach 10 Sekunden zurücksetzen
|
||||
Bukkit.getScheduler().runTaskLater(NexusLobby.getInstance(), () -> {
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
online.sendBlockChange(loc, block.getBlockData());
|
||||
}
|
||||
}, 400L);
|
||||
}
|
||||
static {
|
||||
COLORS = new Material[]{Material.RED_WOOL, Material.BLUE_WOOL, Material.LIME_WOOL, Material.ORANGE_WOOL, Material.MAGENTA_WOOL, Material.LIGHT_BLUE_WOOL, Material.YELLOW_WOOL, Material.PURPLE_WOOL, Material.PINK_WOOL};
|
||||
}
|
||||
}
|
||||
@@ -5,27 +5,29 @@ import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ParticleEffect {
|
||||
private final String type;
|
||||
private double angle = 0;
|
||||
private final String type;
|
||||
private double angle = (double)0.0F;
|
||||
|
||||
public ParticleEffect(String type) { this.type = type; }
|
||||
public ParticleEffect(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void update(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
switch (type.toLowerCase()) {
|
||||
case "hearts":
|
||||
player.getWorld().spawnParticle(Particle.HEART, loc.clone().add(0, 2.2, 0), 1, 0.3, 0.3, 0.3, 0);
|
||||
break;
|
||||
case "flames":
|
||||
double x = 0.6 * Math.cos(angle);
|
||||
double z = 0.6 * Math.sin(angle);
|
||||
player.getWorld().spawnParticle(Particle.FLAME, loc.clone().add(x, 0.1, z), 1, 0, 0, 0, 0);
|
||||
angle += 0.2;
|
||||
break;
|
||||
case "cloud":
|
||||
player.getWorld().spawnParticle(Particle.CLOUD, loc.clone().add(0, 2.5, 0), 2, 0.2, 0.05, 0.2, 0);
|
||||
player.getWorld().spawnParticle(Particle.FALLING_WATER, loc.clone().add(0, 2.4, 0), 1, 0.1, 0, 0.1, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
public void update(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
switch (this.type.toLowerCase()) {
|
||||
case "hearts":
|
||||
player.getWorld().spawnParticle(Particle.HEART, loc.clone().add((double)0.0F, 2.2, (double)0.0F), 1, 0.3, 0.3, 0.3, (double)0.0F);
|
||||
break;
|
||||
case "flames":
|
||||
double x = 0.6 * Math.cos(this.angle);
|
||||
double z = 0.6 * Math.sin(this.angle);
|
||||
player.getWorld().spawnParticle(Particle.FLAME, loc.clone().add(x, 0.1, z), 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
this.angle += 0.2;
|
||||
break;
|
||||
case "cloud":
|
||||
player.getWorld().spawnParticle(Particle.CLOUD, loc.clone().add((double)0.0F, (double)2.5F, (double)0.0F), 2, 0.2, 0.05, 0.2, (double)0.0F);
|
||||
player.getWorld().spawnParticle(Particle.FALLING_WATER, loc.clone().add((double)0.0F, 2.4, (double)0.0F), 1, 0.1, (double)0.0F, 0.1, (double)0.0F);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,158 +1,234 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Fox;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Fox.Type;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
public class PetManager implements Listener {
|
||||
private static final Map<UUID, Entity> activePets = new HashMap();
|
||||
private static PetManager instance;
|
||||
|
||||
private static final Map<UUID, Entity> activePets = new HashMap<>();
|
||||
public PetManager() {
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
|
||||
// Singleton-Instanz, damit registerEvents() nur einmal aufgerufen wird
|
||||
private static PetManager instance;
|
||||
public static void register() {
|
||||
if (instance == null) {
|
||||
instance = new PetManager();
|
||||
}
|
||||
|
||||
public PetManager() {
|
||||
Bukkit.getPluginManager().registerEvents(this, NexusLobby.getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registriert den PetManager als Listener, falls noch nicht geschehen.
|
||||
* Muss einmalig beim Plugin-Start aufgerufen werden (z.B. aus GadgetModule.onEnable).
|
||||
*/
|
||||
public static void register() {
|
||||
if (instance == null) {
|
||||
instance = new PetManager();
|
||||
}
|
||||
}
|
||||
public static void unregister() {
|
||||
if (instance != null) {
|
||||
HandlerList.unregisterAll(instance);
|
||||
instance = null;
|
||||
}
|
||||
|
||||
public static void unregister() {
|
||||
if (instance != null) {
|
||||
org.bukkit.event.HandlerList.unregisterAll(instance);
|
||||
instance = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawnt ein echtes Tier-Entity für den Spieler.
|
||||
*/
|
||||
public static void spawnEntityPet(Player player, String type) {
|
||||
removePet(player);
|
||||
public static void spawnEntityPet(Player player, String type) {
|
||||
spawnEntityPet(player, type, false);
|
||||
}
|
||||
|
||||
EntityType entityType;
|
||||
try {
|
||||
entityType = EntityType.valueOf(type);
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.sendMessage("§cFehler: Tier-Typ nicht gefunden.");
|
||||
return;
|
||||
}
|
||||
public static void spawnEntityPet(Player player, String type, boolean baby) {
|
||||
spawnEntityPet(player, type, baby, (String)null);
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Entity pet = player.getWorld().spawnEntity(loc, entityType);
|
||||
public static void spawnEntityPet(Player player, String type, boolean baby, String variantName) {
|
||||
removePet(player);
|
||||
|
||||
pet.setCustomName("§d" + player.getName() + "'s " + capitalize(type.toLowerCase()));
|
||||
pet.setCustomNameVisible(true);
|
||||
pet.setInvulnerable(true);
|
||||
pet.setPersistent(false);
|
||||
EntityType entityType;
|
||||
try {
|
||||
entityType = EntityType.valueOf(type);
|
||||
} catch (IllegalArgumentException var12) {
|
||||
player.sendMessage("§cFehler: Tier-Typ nicht gefunden.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (pet instanceof LivingEntity) {
|
||||
LivingEntity le = (LivingEntity) pet;
|
||||
le.setRemoveWhenFarAway(false);
|
||||
|
||||
// Verhindert, dass das Pet andere angreift
|
||||
if (le instanceof Tameable) {
|
||||
((Tameable) le).setTamed(true);
|
||||
((Tameable) le).setOwner(player);
|
||||
Location loc = player.getLocation();
|
||||
Entity pet = player.getWorld().spawnEntity(loc, entityType);
|
||||
String agePrefix = baby ? "§bBaby " : "";
|
||||
String petName = buildPetDisplayName(type, variantName);
|
||||
pet.setCustomName(agePrefix + petName);
|
||||
pet.setCustomNameVisible(true);
|
||||
pet.setInvulnerable(true);
|
||||
pet.setPersistent(false);
|
||||
applyNeutralPetTeam(pet);
|
||||
if (pet instanceof LivingEntity le) {
|
||||
le.setRemoveWhenFarAway(false);
|
||||
if (le instanceof Ageable ageable) {
|
||||
if (baby) {
|
||||
ageable.setBaby();
|
||||
} else {
|
||||
ageable.setAdult();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
activePets.put(player.getUniqueId(), pet);
|
||||
}
|
||||
if (le instanceof Wolf && variantName != null && !variantName.isEmpty()) {
|
||||
Wolf.Variant variant = resolveWolfVariant(variantName);
|
||||
if (variant != null) {
|
||||
((Wolf)le).setVariant(variant);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Steuert das Folgen der Tiere. Wird vom GadgetModule-Timer aufgerufen.
|
||||
*/
|
||||
public static void updatePets() {
|
||||
for (Map.Entry<UUID, Entity> entry : activePets.entrySet()) {
|
||||
Player owner = Bukkit.getPlayer(entry.getKey());
|
||||
Entity pet = entry.getValue();
|
||||
if (le instanceof Fox && variantName != null && !variantName.isEmpty()) {
|
||||
try {
|
||||
((Fox)le).setFoxType(Type.valueOf(variantName));
|
||||
} catch (IllegalArgumentException var11) {
|
||||
}
|
||||
}
|
||||
|
||||
if (owner == null || !owner.isOnline() || pet.isDead()) {
|
||||
continue;
|
||||
if (le instanceof Tameable) {
|
||||
((Tameable)le).setTamed(true);
|
||||
((Tameable)le).setOwner(player);
|
||||
}
|
||||
}
|
||||
|
||||
activePets.put(player.getUniqueId(), pet);
|
||||
}
|
||||
|
||||
public static void updatePets() {
|
||||
for(Map.Entry<UUID, Entity> entry : activePets.entrySet()) {
|
||||
Player owner = Bukkit.getPlayer((UUID)entry.getKey());
|
||||
Entity pet = (Entity)entry.getValue();
|
||||
if (owner != null && owner.isOnline() && !pet.isDead()) {
|
||||
if (pet.getWorld().equals(owner.getWorld()) && !(pet.getLocation().distance(owner.getLocation()) > (double)10.0F)) {
|
||||
if (pet.getLocation().distance(owner.getLocation()) > (double)3.0F) {
|
||||
Location target = owner.getLocation().clone().add(owner.getLocation().getDirection().multiply((double)-1.5F));
|
||||
target.setY(owner.getLocation().getY());
|
||||
pet.teleport(pet.getLocation().add(target.toVector().subtract(pet.getLocation().toVector()).normalize().multiply(0.2)));
|
||||
Location lookAt = pet.getLocation();
|
||||
lookAt.setDirection(owner.getLocation().toVector().subtract(pet.getLocation().toVector()));
|
||||
pet.teleport(lookAt);
|
||||
}
|
||||
} else {
|
||||
pet.teleport(owner.getLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void removePet(Player player) {
|
||||
if (activePets.containsKey(player.getUniqueId())) {
|
||||
Entity pet = (Entity)activePets.get(player.getUniqueId());
|
||||
removeFromPetTeam(pet);
|
||||
pet.remove();
|
||||
activePets.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void clearAll() {
|
||||
for(Entity pet : activePets.values()) {
|
||||
removeFromPetTeam(pet);
|
||||
pet.remove();
|
||||
}
|
||||
|
||||
activePets.clear();
|
||||
}
|
||||
|
||||
private static String capitalize(String str) {
|
||||
if (str != null && !str.isEmpty()) {
|
||||
String var10000 = str.substring(0, 1).toUpperCase();
|
||||
return var10000 + str.substring(1);
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
private static String buildPetDisplayName(String type, String variantName) {
|
||||
String baseType = capitalize(type.toLowerCase());
|
||||
if (variantName != null && !variantName.isEmpty()) {
|
||||
String variant = capitalize(variantName.toLowerCase());
|
||||
return variant + " " + baseType;
|
||||
} else {
|
||||
return baseType;
|
||||
}
|
||||
}
|
||||
|
||||
private static Wolf.Variant resolveWolfVariant(String variantName) {
|
||||
String keyName = variantName.toLowerCase();
|
||||
NamespacedKey key = NamespacedKey.minecraft(keyName);
|
||||
return (Wolf.Variant)Registry.WOLF_VARIANT.get(key);
|
||||
}
|
||||
|
||||
private static Team getOrCreatePetTeam() {
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
Team team = scoreboard.getTeam("nexus_pets");
|
||||
if (team == null) {
|
||||
team = scoreboard.registerNewTeam("nexus_pets");
|
||||
team.setPrefix("");
|
||||
team.setSuffix("");
|
||||
}
|
||||
|
||||
return team;
|
||||
}
|
||||
|
||||
private static void applyNeutralPetTeam(Entity pet) {
|
||||
Team team = getOrCreatePetTeam();
|
||||
String entry = pet.getUniqueId().toString();
|
||||
if (!team.hasEntry(entry)) {
|
||||
team.addEntry(entry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void removeFromPetTeam(Entity pet) {
|
||||
if (pet != null) {
|
||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
Team team = scoreboard.getTeam("nexus_pets");
|
||||
if (team != null) {
|
||||
String entry = pet.getUniqueId().toString();
|
||||
if (team.hasEntry(entry)) {
|
||||
team.removeEntry(entry);
|
||||
}
|
||||
|
||||
// Wenn das Pet in einer anderen Welt ist oder zu weit weg, teleportiere es
|
||||
if (!pet.getWorld().equals(owner.getWorld()) || pet.getLocation().distance(owner.getLocation()) > 10) {
|
||||
pet.teleport(owner.getLocation());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sanftes Folgen: Wenn das Pet weiter als 3 Blöcke weg ist
|
||||
if (pet.getLocation().distance(owner.getLocation()) > 3) {
|
||||
Location target = owner.getLocation().clone().add(owner.getLocation().getDirection().multiply(-1.5));
|
||||
target.setY(owner.getLocation().getY());
|
||||
@EventHandler
|
||||
public void onPetDamage(EntityDamageEvent event) {
|
||||
if (activePets.containsValue(event.getEntity())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
// Teleportiert das Pet leicht zum Ziel (simuliert Laufen)
|
||||
pet.teleport(pet.getLocation().add(target.toVector().subtract(pet.getLocation().toVector()).normalize().multiply(0.2)));
|
||||
}
|
||||
|
||||
// Blickrichtung anpassen
|
||||
Location lookAt = pet.getLocation();
|
||||
lookAt.setDirection(owner.getLocation().toVector().subtract(pet.getLocation().toVector()));
|
||||
pet.teleport(lookAt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onPetTarget(EntityTargetEvent event) {
|
||||
if (activePets.containsValue(event.getEntity())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public static void removePet(Player player) {
|
||||
if (activePets.containsKey(player.getUniqueId())) {
|
||||
activePets.get(player.getUniqueId()).remove();
|
||||
activePets.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearAll() {
|
||||
for (Entity pet : activePets.values()) {
|
||||
pet.remove();
|
||||
}
|
||||
activePets.clear();
|
||||
}
|
||||
|
||||
private static String capitalize(String str) {
|
||||
if (str == null || str.isEmpty()) return str;
|
||||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
}
|
||||
|
||||
// --- Events um die Pets zu schützen ---
|
||||
|
||||
@EventHandler
|
||||
public void onPetDamage(EntityDamageEvent event) {
|
||||
if (activePets.containsValue(event.getEntity())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPetTarget(EntityTargetEvent event) {
|
||||
if (activePets.containsValue(event.getEntity())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
removePet(event.getPlayer());
|
||||
}
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
removePet(event.getPlayer());
|
||||
}
|
||||
}
|
||||
@@ -1,53 +1,41 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ShieldTask {
|
||||
private static final Map<UUID, Long> pushCooldowns = new HashMap();
|
||||
private static final long PUSH_COOLDOWN_MS = 3000L;
|
||||
|
||||
/**
|
||||
* Cooldown: Ein Spieler darf nur alle 3 Sekunden weggedrückt werden.
|
||||
* Verhindert das permanente "Kleben" am Schutzschild-Träger.
|
||||
*/
|
||||
private static final Map<UUID, Long> pushCooldowns = new HashMap<>();
|
||||
private static final long PUSH_COOLDOWN_MS = 3_000L;
|
||||
public static void handleShield(Player owner) {
|
||||
for(double i = (double)0.0F; i < (Math.PI * 2D); i += (Math.PI / 8D)) {
|
||||
double x = Math.cos(i) * 2.2;
|
||||
double z = Math.sin(i) * 2.2;
|
||||
owner.getWorld().spawnParticle(Particle.WITCH, owner.getLocation().add(x, (double)0.5F, z), 1, (double)0.0F, (double)0.0F, (double)0.0F, (double)0.0F);
|
||||
}
|
||||
|
||||
public static void handleShield(Player owner) {
|
||||
// Erzeuge einen Partikel-Ring um den Spieler
|
||||
for (double i = 0; i < Math.PI * 2; i += Math.PI / 8) {
|
||||
double x = Math.cos(i) * 2.2;
|
||||
double z = Math.sin(i) * 2.2;
|
||||
owner.getWorld().spawnParticle(Particle.WITCH, owner.getLocation().add(x, 0.5, z), 1, 0, 0, 0, 0);
|
||||
}
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
for(Entity entity : owner.getNearbyEntities(2.2, (double)2.0F, 2.2)) {
|
||||
if (entity instanceof Player target) {
|
||||
if (entity != owner && !GadgetShield.isProtected(target)) {
|
||||
long lastPush = (Long)pushCooldowns.getOrDefault(target.getUniqueId(), 0L);
|
||||
if (now - lastPush >= 3000L) {
|
||||
pushCooldowns.put(target.getUniqueId(), now);
|
||||
Vector direction = target.getLocation().toVector().subtract(owner.getLocation().toVector()).normalize();
|
||||
direction.multiply(0.4).setY(0.2);
|
||||
target.setVelocity(direction);
|
||||
target.playSound(target.getLocation(), Sound.ENTITY_CHICKEN_EGG, 0.5F, 0.5F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stoße andere Spieler weg
|
||||
for (Entity entity : owner.getNearbyEntities(2.2, 2.0, 2.2)) {
|
||||
if (!(entity instanceof Player target) || entity == owner) continue;
|
||||
|
||||
// FIX: OP-Admins mit aktivem Gadget-Schutz und Parkour-Spieler sind immun
|
||||
if (GadgetShield.isProtected(target)) continue;
|
||||
|
||||
// FIX: 3-Sekunden-Cooldown – jedes Ziel wird max. 1x alle 3s weggedrückt
|
||||
long lastPush = pushCooldowns.getOrDefault(target.getUniqueId(), 0L);
|
||||
if (now - lastPush < PUSH_COOLDOWN_MS) continue;
|
||||
pushCooldowns.put(target.getUniqueId(), now);
|
||||
|
||||
Vector direction = target.getLocation().toVector()
|
||||
.subtract(owner.getLocation().toVector())
|
||||
.normalize();
|
||||
direction.multiply(0.4).setY(0.2);
|
||||
|
||||
target.setVelocity(direction);
|
||||
target.playSound(target.getLocation(), Sound.ENTITY_CHICKEN_EGG, 0.5f, 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@ package de.nexuslobby.modules.intro;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import de.nexuslobby.api.Module;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -16,7 +14,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -27,13 +24,24 @@ import java.util.*;
|
||||
public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
|
||||
private final Set<UUID> activeIntro = new HashSet<>();
|
||||
|
||||
private final List<Location> points = new ArrayList<>();
|
||||
private final List<String> labels = new ArrayList<>();
|
||||
|
||||
// Abschluss-Titel (konfigurierbar)
|
||||
private String endTitle = "§a§lWillkommen!";
|
||||
private String endSubtitle = "§7Viel Spaß auf NexusLobby";
|
||||
|
||||
private File configFile;
|
||||
private FileConfiguration config;
|
||||
|
||||
// --- Einstellungen ---
|
||||
private final int TICKS_FLUG = 70; // Dauer der Fahrt zwischen zwei Punkten (3.5 Sek)
|
||||
private final int TICKS_PAUSE = 30; // Standzeit an jedem Punkt (1.5 Sek)
|
||||
private final int TICKS_FLUG = 70;
|
||||
private final int TICKS_PAUSE = 30;
|
||||
|
||||
private final int TITLE_FADE_IN = 10;
|
||||
private final int TITLE_STAY = 50;
|
||||
private final int TITLE_FADE_OUT = 10;
|
||||
|
||||
@Override
|
||||
public String getName() { return "Intro"; }
|
||||
@@ -44,7 +52,7 @@ public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
if (NexusLobby.getInstance().getCommand("intro") != null) {
|
||||
NexusLobby.getInstance().getCommand("intro").setExecutor(this);
|
||||
}
|
||||
loadPoints();
|
||||
loadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,23 +61,68 @@ public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
activeIntro.clear();
|
||||
}
|
||||
|
||||
private void loadPoints() {
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Persistenz
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
private void loadConfig() {
|
||||
points.clear();
|
||||
labels.clear();
|
||||
configFile = new File(NexusLobby.getInstance().getDataFolder(), "intro.yml");
|
||||
if (!configFile.exists()) {
|
||||
try { configFile.createNewFile(); } catch (IOException ignored) {}
|
||||
}
|
||||
config = YamlConfiguration.loadConfiguration(configFile);
|
||||
List<?> list = config.getList("points");
|
||||
|
||||
// Abschluss-Titel laden
|
||||
endTitle = config.getString("end-title", "§a§lWillkommen!");
|
||||
endSubtitle = config.getString("end-subtitle", "§7Viel Spaß auf NexusLobby");
|
||||
|
||||
// Punkte laden
|
||||
List<?> list = config.getList("intro-points");
|
||||
if (list != null) {
|
||||
for (Object obj : list) {
|
||||
if (obj instanceof Location loc) points.add(loc);
|
||||
if (obj instanceof Map<?, ?> map) {
|
||||
Object locObj = map.get("location");
|
||||
Object labelObj = map.get("label");
|
||||
if (locObj instanceof Location loc) {
|
||||
points.add(loc);
|
||||
labels.add(labelObj != null ? labelObj.toString() : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rückwärts-Kompatibilität
|
||||
if (points.isEmpty()) {
|
||||
List<?> oldList = config.getList("points");
|
||||
if (oldList != null) {
|
||||
for (Object obj : oldList) {
|
||||
if (obj instanceof Location loc) {
|
||||
points.add(loc);
|
||||
labels.add("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void savePoints() {
|
||||
config.set("points", points);
|
||||
private void saveConfig() {
|
||||
// Abschluss-Titel speichern
|
||||
config.set("end-title", endTitle);
|
||||
config.set("end-subtitle", endSubtitle);
|
||||
|
||||
// Punkte speichern
|
||||
List<Map<String, Object>> data = new ArrayList<>();
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
Map<String, Object> entry = new LinkedHashMap<>();
|
||||
entry.put("location", points.get(i));
|
||||
entry.put("label", labels.get(i));
|
||||
data.add(entry);
|
||||
}
|
||||
config.set("intro-points", data);
|
||||
config.set("points", null);
|
||||
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
@@ -77,6 +130,10 @@ public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Events
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
if (!event.getPlayer().hasPlayedBefore() && points.size() >= 2) {
|
||||
@@ -84,12 +141,9 @@ public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSneak(PlayerToggleSneakEvent event) {
|
||||
if (activeIntro.contains(event.getPlayer().getUniqueId()) && event.isSneaking()) {
|
||||
stopIntro(event.getPlayer(), true);
|
||||
}
|
||||
}
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Befehle
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||
@@ -97,26 +151,52 @@ public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
if (!p.hasPermission("nexuslobby.admin")) return true;
|
||||
|
||||
if (args.length == 0) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus Intro System (Cinematic)");
|
||||
p.sendMessage("§e/intro add §7- Punkt hinzufügen");
|
||||
p.sendMessage("§e/intro clear §7- Alle Punkte löschen");
|
||||
p.sendMessage("§e/intro start §7- Teste die Fahrt");
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
sendHelp(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
|
||||
case "add" -> {
|
||||
String pointLabel = args.length > 1
|
||||
? String.join(" ", Arrays.copyOfRange(args, 1, args.length))
|
||||
: "";
|
||||
points.add(p.getLocation());
|
||||
savePoints();
|
||||
p.sendMessage("§8[§6Nexus§8] §aPunkt #" + points.size() + " wurde gesetzt!");
|
||||
labels.add(pointLabel);
|
||||
saveConfig();
|
||||
if (pointLabel.isEmpty()) {
|
||||
p.sendMessage("§8[§6Nexus§8] §aPunkt §e#" + points.size() + " §awurde gesetzt.");
|
||||
} else {
|
||||
p.sendMessage("§8[§6Nexus§8] §aPunkt §e#" + points.size() + " §amit Text §e\"" + pointLabel + "\" §agesetzt.");
|
||||
}
|
||||
}
|
||||
|
||||
case "clear" -> {
|
||||
points.clear();
|
||||
savePoints();
|
||||
labels.clear();
|
||||
saveConfig();
|
||||
p.sendMessage("§8[§6Nexus§8] §cAlle Intro-Punkte wurden gelöscht.");
|
||||
}
|
||||
|
||||
case "list" -> {
|
||||
if (points.isEmpty()) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cKeine Punkte vorhanden.");
|
||||
return true;
|
||||
}
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lIntro-Punkte (" + points.size() + ")");
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
Location loc = points.get(i);
|
||||
String lbl = labels.get(i).isEmpty() ? "§7(kein Text)" : "§e" + labels.get(i);
|
||||
p.sendMessage("§8#" + (i + 1) + " §7"
|
||||
+ String.format("%.1f", loc.getX()) + ", "
|
||||
+ String.format("%.1f", loc.getY()) + ", "
|
||||
+ String.format("%.1f", loc.getZ())
|
||||
+ " " + lbl);
|
||||
}
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
}
|
||||
|
||||
case "start" -> {
|
||||
if (points.size() < 2) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cDu brauchst mindestens 2 Punkte für eine Fahrt.");
|
||||
@@ -124,18 +204,69 @@ public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
startIntro(p);
|
||||
}
|
||||
}
|
||||
|
||||
// /intro setendtitle <Text> — setzt den großen Abschluss-Titel
|
||||
case "setendtitle" -> {
|
||||
if (args.length < 2) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cBenutzung: §e/intro setendtitle <Text>");
|
||||
p.sendMessage("§7Farbcodes mit §e& §7möglich. Beispiel: §e/intro setendtitle &a&lWillkommen!");
|
||||
return true;
|
||||
}
|
||||
endTitle = colorize(String.join(" ", Arrays.copyOfRange(args, 1, args.length)));
|
||||
saveConfig();
|
||||
p.sendMessage("§8[§6Nexus§8] §aAbschluss-Titel gesetzt: " + endTitle);
|
||||
// Vorschau
|
||||
p.sendTitle(endTitle, endSubtitle, TITLE_FADE_IN, TITLE_STAY, TITLE_FADE_OUT);
|
||||
}
|
||||
|
||||
// /intro setendsubtitle <Text> — setzt den kleinen Abschluss-Untertitel
|
||||
case "setendsubtitle" -> {
|
||||
if (args.length < 2) {
|
||||
p.sendMessage("§8[§6Nexus§8] §cBenutzung: §e/intro setendsubtitle <Text>");
|
||||
p.sendMessage("§7Farbcodes mit §e& §7möglich. Beispiel: §e/intro setendsubtitle &7Viel Spaß!");
|
||||
return true;
|
||||
}
|
||||
endSubtitle = colorize(String.join(" ", Arrays.copyOfRange(args, 1, args.length)));
|
||||
saveConfig();
|
||||
p.sendMessage("§8[§6Nexus§8] §aAbschluss-Untertitel gesetzt: " + endSubtitle);
|
||||
// Vorschau
|
||||
p.sendTitle(endTitle, endSubtitle, TITLE_FADE_IN, TITLE_STAY, TITLE_FADE_OUT);
|
||||
}
|
||||
|
||||
default -> sendHelp(p);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(Player p) {
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
p.sendMessage("§6§lNexus Intro System (Cinematic)");
|
||||
p.sendMessage("§e/intro add [Text] §7- Punkt + optionaler Titel");
|
||||
p.sendMessage("§e/intro clear §7- Alle Punkte löschen");
|
||||
p.sendMessage("§e/intro list §7- Alle Punkte anzeigen");
|
||||
p.sendMessage("§e/intro start §7- Fahrt testen");
|
||||
p.sendMessage("§e/intro setendtitle <Text> §7- Abschluss-Titel setzen");
|
||||
p.sendMessage("§e/intro setendsubtitle <Text> §7- Abschluss-Untertitel setzen");
|
||||
p.sendMessage("§7Aktuell: §r" + endTitle + " §8/ §r" + endSubtitle);
|
||||
p.sendMessage("§8§m------------------------------------");
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Intro-Logik
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
public void startIntro(Player player) {
|
||||
activeIntro.add(player.getUniqueId());
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
|
||||
// Titel für den ersten Punkt sofort anzeigen
|
||||
showTitleForSegment(player, 0);
|
||||
|
||||
new BukkitRunnable() {
|
||||
int currentSegment = 0;
|
||||
int tickInSegment = 0;
|
||||
boolean isPausing = true;
|
||||
int currentSegment = 0;
|
||||
int tickInSegment = 0;
|
||||
boolean isPausing = true;
|
||||
int lastTitleSegment = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -146,79 +277,89 @@ public class IntroModule implements Module, Listener, CommandExecutor {
|
||||
}
|
||||
|
||||
if (currentSegment >= points.size() - 1) {
|
||||
stopIntro(player, false);
|
||||
stopIntro(player);
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
Location start = points.get(currentSegment);
|
||||
Location end = points.get(currentSegment + 1);
|
||||
Location end = points.get(currentSegment + 1);
|
||||
|
||||
if (isPausing) {
|
||||
// Kamera steht am aktuellen Punkt
|
||||
player.teleport(start);
|
||||
tickInSegment++;
|
||||
if (tickInSegment >= TICKS_PAUSE) {
|
||||
isPausing = false;
|
||||
isPausing = false;
|
||||
tickInSegment = 0;
|
||||
}
|
||||
} else {
|
||||
// Kamera fliegt zum nächsten Punkt
|
||||
double progress = (double) tickInSegment / (double) TICKS_FLUG;
|
||||
double smoothT = progress * progress * (3 - 2 * progress);
|
||||
|
||||
// "Smooth Step" für flüssigeres Beschleunigen/Bremsen
|
||||
double smoothT = progress * progress * (3 - 2 * progress);
|
||||
|
||||
Location nextLoc = interpolate(start, end, smoothT);
|
||||
player.teleport(nextLoc);
|
||||
player.teleport(interpolate(start, end, smoothT));
|
||||
|
||||
tickInSegment++;
|
||||
if (tickInSegment >= TICKS_FLUG) {
|
||||
isPausing = true;
|
||||
isPausing = true;
|
||||
tickInSegment = 0;
|
||||
currentSegment++;
|
||||
|
||||
if (currentSegment < points.size() && currentSegment != lastTitleSegment) {
|
||||
showTitleForSegment(player, currentSegment);
|
||||
lastTitleSegment = currentSegment;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
|
||||
new TextComponent("§6§lINTRO-TOUR §8| §ePunkt " + (currentSegment + 1) + " §8| §7Sneak zum Abbrechen"));
|
||||
|
||||
} catch (Exception e) {
|
||||
this.cancel();
|
||||
stopIntro(player, true);
|
||||
stopIntro(player);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 1L);
|
||||
}
|
||||
|
||||
private void showTitleForSegment(Player player, int segmentIndex) {
|
||||
if (segmentIndex < 0 || segmentIndex >= labels.size()) return;
|
||||
String lbl = labels.get(segmentIndex);
|
||||
if (lbl == null || lbl.isEmpty()) return;
|
||||
|
||||
player.sendTitle(
|
||||
"§6§l" + lbl,
|
||||
"§7✦ NexusLobby ✦",
|
||||
TITLE_FADE_IN,
|
||||
TITLE_STAY,
|
||||
TITLE_FADE_OUT
|
||||
);
|
||||
}
|
||||
|
||||
private Location interpolate(Location start, Location end, double t) {
|
||||
double x = start.getX() + (end.getX() - start.getX()) * t;
|
||||
double y = start.getY() + (end.getY() - start.getY()) * t;
|
||||
double z = start.getZ() + (end.getZ() - start.getZ()) * t;
|
||||
|
||||
// Sanfte Drehung
|
||||
float startYaw = start.getYaw();
|
||||
float endYaw = end.getYaw();
|
||||
// Verhindert ruckartige 360-Grad Dreher
|
||||
float diff = (endYaw - startYaw) % 360;
|
||||
if (diff > 180) diff -= 360;
|
||||
float endYaw = end.getYaw();
|
||||
float diff = (endYaw - startYaw) % 360;
|
||||
if (diff > 180) diff -= 360;
|
||||
if (diff < -180) diff += 360;
|
||||
float yaw = startYaw + diff * (float)t;
|
||||
|
||||
float yaw = startYaw + diff * (float) t;
|
||||
float pitch = (float) (start.getPitch() + (end.getPitch() - start.getPitch()) * t);
|
||||
|
||||
return new Location(start.getWorld(), x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
private void stopIntro(Player player, boolean canceled) {
|
||||
private void stopIntro(Player player) {
|
||||
activeIntro.remove(player.getUniqueId());
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
|
||||
if (canceled) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cIntro abgebrochen.");
|
||||
} else {
|
||||
player.sendMessage("§8[§6Nexus§8] §aWillkommen auf dem Netzwerk!");
|
||||
}
|
||||
// Abschluss-Titel — komplett konfigurierbar
|
||||
player.sendTitle(endTitle, endSubtitle, 10, 60, 20);
|
||||
}
|
||||
|
||||
/** Ersetzt &-Farbcodes durch §-Codes */
|
||||
private String colorize(String input) {
|
||||
return input.replace("&", "§");
|
||||
}
|
||||
}
|
||||
@@ -146,20 +146,50 @@ public class ServerSwitcherListener implements Listener, CommandExecutor {
|
||||
int clickedSlot = e.getSlot();
|
||||
ConfigurationSection serversSection = NexusLobby.getInstance().getConfig().getConfigurationSection("compass.servers");
|
||||
|
||||
if (serversSection != null) {
|
||||
for (String serverId : serversSection.getKeys(false)) {
|
||||
String path = "compass.servers." + serverId;
|
||||
int configSlot = NexusLobby.getInstance().getConfig().getInt(path + ".slot", -1);
|
||||
if (serversSection == null) return;
|
||||
|
||||
if (configSlot == clickedSlot) {
|
||||
String command = NexusLobby.getInstance().getConfig().getString(path + ".command");
|
||||
if (command != null && !command.isEmpty()) {
|
||||
p.closeInventory();
|
||||
p.chat("/" + command);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (String serverId : serversSection.getKeys(false)) {
|
||||
String path = "compass.servers." + serverId;
|
||||
int configSlot = NexusLobby.getInstance().getConfig().getInt(path + ".slot", -1);
|
||||
|
||||
if (configSlot != clickedSlot) continue;
|
||||
|
||||
String command = NexusLobby.getInstance().getConfig().getString(path + ".command", "").trim();
|
||||
if (command.isEmpty()) return;
|
||||
|
||||
p.closeInventory();
|
||||
|
||||
// "server <name>" → BungeeCord Connect Plugin-Message
|
||||
if (command.toLowerCase().startsWith("server ")) {
|
||||
String serverName = command.substring(7).trim();
|
||||
connectBungee(p, serverName);
|
||||
} else {
|
||||
// Alle anderen Befehle als Konsolen-Befehl ausführen
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
|
||||
command.replace("%player%", p.getName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sendet den Spieler per BungeeCord Plugin-Message an einen anderen Server.
|
||||
*/
|
||||
private void connectBungee(Player player, String serverName) {
|
||||
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(
|
||||
NexusLobby.getInstance(), "BungeeCord")) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cKein BungeeCord-Kanal registriert.");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
|
||||
java.io.DataOutputStream out = new java.io.DataOutputStream(b);
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(serverName);
|
||||
player.sendPluginMessage(NexusLobby.getInstance(), "BungeeCord", b.toByteArray());
|
||||
player.sendMessage("§8[§6Nexus§8] §7Verbinde mit §e" + serverName + "§7...");
|
||||
} catch (java.io.IOException ex) {
|
||||
player.sendMessage("§8[§6Nexus§8] §cFehler beim Verbinden: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
name: NexusLobby
|
||||
main: de.nexuslobby.NexusLobby
|
||||
version: "1.7"
|
||||
version: "1.8"
|
||||
api-version: "1.21"
|
||||
author: M_Viper
|
||||
description: Modular Lobby Plugin with an invisible Particle-Parkour system.
|
||||
|
||||
Reference in New Issue
Block a user