Update from Git Manager GUI
This commit is contained in:
97
src/main/java/de/nexuslobby/modules/gadgets/FreezeRay.java
Normal file
97
src/main/java/de/nexuslobby/modules/gadgets/FreezeRay.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
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.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FreezeRay {
|
||||
// Auf public gesetzt, damit das GadgetModule im PlayerMoveEvent darauf prüfen kann
|
||||
public static final Set<UUID> frozenPlayers = new HashSet<>();
|
||||
|
||||
public static void shoot(Player shooter) {
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
|
||||
// Sound beim Schießen
|
||||
shooter.getWorld().playSound(start, Sound.ENTITY_SNOW_GOLEM_SHOOT, 1.0f, 1.5f);
|
||||
|
||||
// Wir prüfen in 0.3er Schritten bis zu 15 Blöcke weit
|
||||
for (double d = 0; d < 15; d += 0.3) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
|
||||
// Partikel-Strahl sichtbar machen
|
||||
point.getWorld().spawnParticle(Particle.SNOWFLAKE, point, 1, 0, 0, 0, 0);
|
||||
|
||||
// Prüfung auf Spieler im Umkreis von 0.8 Blöcken (etwas großzügiger)
|
||||
for (Entity entity : point.getWorld().getNearbyEntities(point, 0.8, 0.8, 0.8)) {
|
||||
if (entity instanceof Player target && target != shooter) {
|
||||
applyFreeze(target);
|
||||
return; // Stoppt den Strahl beim ersten Treffer
|
||||
}
|
||||
}
|
||||
|
||||
// Stoppe den Strahl, falls er eine Wand trifft
|
||||
if (point.getBlock().getType().isSolid()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyFreeze(Player target) {
|
||||
if (frozenPlayers.contains(target.getUniqueId())) return;
|
||||
|
||||
frozenPlayers.add(target.getUniqueId());
|
||||
|
||||
// Fixiere die Position für den Stasis-Effekt
|
||||
final Location freezeLocation = target.getLocation();
|
||||
|
||||
// Feedback für getroffenen Spieler
|
||||
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() {
|
||||
int ticks = 0;
|
||||
@Override
|
||||
public void run() {
|
||||
// Sicherheitscheck: Ist der Spieler noch online?
|
||||
if (!target.isOnline() || ticks >= 60) {
|
||||
frozenPlayers.remove(target.getUniqueId());
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// Stasis-Effekt: Bewegung auf 0 setzen und Position fixieren
|
||||
target.setVelocity(new Vector(0, 0, 0));
|
||||
|
||||
// Alle 2 Ticks zurückteleportieren, falls er versucht zu laufen
|
||||
// (Behält die Blickrichtung des Spielers bei)
|
||||
Location current = target.getLocation();
|
||||
if (current.getX() != freezeLocation.getX() || current.getZ() != freezeLocation.getZ()) {
|
||||
freezeLocation.setYaw(current.getYaw());
|
||||
freezeLocation.setPitch(current.getPitch());
|
||||
target.teleport(freezeLocation);
|
||||
}
|
||||
|
||||
// Optischer Käfig (Ring-Effekt)
|
||||
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;
|
||||
}
|
||||
}.runTaskTimer(NexusLobby.getInstance(), 0L, 2L);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,11 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@@ -56,6 +59,37 @@ public class GadgetModule implements Module, Listener {
|
||||
}, 1L, 1L);
|
||||
}
|
||||
|
||||
// Event für die Benutzung der aktiven Gadgets
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
ItemStack item = event.getItem();
|
||||
if (item == null || !item.hasItemMeta()) return;
|
||||
String name = item.getItemMeta().getDisplayName();
|
||||
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (name.equals("§b§lFreeze-Ray")) {
|
||||
FreezeRay.shoot(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
} else if (name.equals("§6§lPaintball-Gun")) {
|
||||
PaintballGun.shoot(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
} else if (name.equals("§c§lMeteorit")) {
|
||||
MeteorStrike.launch(event.getPlayer());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Verhindert Bewegung für eingefrorene Spieler (Stasis)
|
||||
@EventHandler
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (FreezeRay.frozenPlayers.contains(event.getPlayer().getUniqueId())) {
|
||||
if (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event.getTo().getZ()) {
|
||||
event.setTo(event.getFrom().setDirection(event.getTo().getDirection()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSpecialHatEffects(Player p) {
|
||||
ItemStack hat = p.getInventory().getHelmet();
|
||||
if (hat == null || hat.getType() == Material.AIR) return;
|
||||
@@ -162,9 +196,12 @@ public class GadgetModule implements Module, Listener {
|
||||
private void openFunGUI(Player player) {
|
||||
Inventory gui = Bukkit.createInventory(null, 27, FUN_TITLE);
|
||||
fillEdges(gui);
|
||||
gui.setItem(11, createItem(Material.FISHING_ROD, "§b§lEnterhaken", "§7Zieh dich durch die Luft!"));
|
||||
gui.setItem(13, createItem(Material.SHIELD, "§5§lSchutzzone", "§7Halte andere auf Distanz"));
|
||||
gui.setItem(15, createItem(Material.EGG, "§f§lChicken-Rain", "§7Gack-Gack! Hühner überall!"));
|
||||
gui.setItem(10, createItem(Material.FISHING_ROD, "§b§lEnterhaken", "§7Zieh dich durch die Luft!"));
|
||||
gui.setItem(11, createItem(Material.PACKED_ICE, "§b§lFreeze-Ray", "§7Friere andere Spieler ein!"));
|
||||
gui.setItem(12, createItem(Material.GOLDEN_HOE, "§6§lPaintball-Gun", "§7Male die Lobby bunt aus!"));
|
||||
gui.setItem(14, createItem(Material.FIRE_CHARGE, "§c§lMeteorit", "§7Lass es krachen!"));
|
||||
gui.setItem(15, createItem(Material.SHIELD, "§5§lSchutzzone", "§7Halte andere auf Distanz"));
|
||||
gui.setItem(16, createItem(Material.EGG, "§f§lChicken-Rain", "§7Gack-Gack! Hühner überall!"));
|
||||
gui.setItem(22, createItem(Material.ARROW, "§7Zurück", "§8Zum Hauptmenü"));
|
||||
player.openInventory(gui);
|
||||
}
|
||||
@@ -225,6 +262,15 @@ public class GadgetModule implements Module, Listener {
|
||||
} else if (item.getType() == Material.FISHING_ROD) {
|
||||
player.getInventory().addItem(createItem(Material.FISHING_ROD, "§b§lEnterhaken", "§7Rechtsklick zum Katapultieren"));
|
||||
player.closeInventory();
|
||||
} else if (item.getType() == Material.PACKED_ICE) {
|
||||
player.getInventory().addItem(createItem(Material.PACKED_ICE, "§b§lFreeze-Ray", "§7Rechtsklick zum Einfrieren"));
|
||||
player.closeInventory();
|
||||
} else if (item.getType() == Material.GOLDEN_HOE) {
|
||||
player.getInventory().addItem(createItem(Material.GOLDEN_HOE, "§6§lPaintball-Gun", "§7Rechtsklick zum Schießen"));
|
||||
player.closeInventory();
|
||||
} else if (item.getType() == Material.FIRE_CHARGE) {
|
||||
player.getInventory().addItem(createItem(Material.FIRE_CHARGE, "§c§lMeteorit", "§7Rechtsklick zum Markieren"));
|
||||
player.closeInventory();
|
||||
} else if (item.getType() == Material.SHIELD) {
|
||||
if (activeShields.contains(player.getUniqueId())) {
|
||||
activeShields.remove(player.getUniqueId());
|
||||
@@ -261,6 +307,9 @@ public class GadgetModule implements Module, Listener {
|
||||
PetManager.removePet(player);
|
||||
HatManager.removeHat(player);
|
||||
player.getInventory().remove(Material.FISHING_ROD);
|
||||
player.getInventory().remove(Material.PACKED_ICE);
|
||||
player.getInventory().remove(Material.GOLDEN_HOE);
|
||||
player.getInventory().remove(Material.FIRE_CHARGE);
|
||||
player.sendMessage("§8[§6Nexus§8] §cAlle Gadgets abgelegt.");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
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.util.Vector;
|
||||
|
||||
public class MeteorStrike {
|
||||
|
||||
public static void launch(Player shooter) {
|
||||
Location target = null;
|
||||
Location start = shooter.getEyeLocation();
|
||||
Vector direction = start.getDirection();
|
||||
|
||||
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(), () -> {
|
||||
// EXPLOSION_EMITTER ist der moderne Name für HUGE_EXPLOSION
|
||||
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);
|
||||
|
||||
for (Entity entity : finalTarget.getWorld().getNearbyEntities(finalTarget, 4, 4, 4)) {
|
||||
if (entity instanceof Player p) {
|
||||
Vector v = p.getLocation().toVector().subtract(finalTarget.toVector()).normalize().multiply(1.5).setY(0.5);
|
||||
p.setVelocity(v);
|
||||
p.sendMessage("§cBUMM!");
|
||||
}
|
||||
}
|
||||
}, 30L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package de.nexuslobby.modules.gadgets;
|
||||
|
||||
import de.nexuslobby.NexusLobby;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
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();
|
||||
|
||||
// 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);
|
||||
|
||||
for (double d = 0; d < 25; d += 0.5) {
|
||||
Location point = start.clone().add(direction.clone().multiply(d));
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
// 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++) {
|
||||
|
||||
// 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();
|
||||
|
||||
// Nur solide Blöcke färben (keine Luft/Gras)
|
||||
if (target.getType().isSolid()) {
|
||||
applyColor(target, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user