Skip to content

Commit

Permalink
fix: some bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedox-die-Ente committed Oct 3, 2024
1 parent 27bf6d1 commit 60c7f78
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 47 deletions.
18 changes: 4 additions & 14 deletions src/main/java/me/fedox/talent/Talent.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package me.fedox.talent;

import lombok.Getter;
import lombok.Setter;
import me.fedox.talent.commands.*;
import me.fedox.talent.listener.AntiListener;
import me.fedox.talent.listener.OtherListener;
import me.fedox.talent.listener.VoteListener;
import me.fedox.talent.utils.Constants;
import me.fedox.talent.utils.GoldenBuzzer;
import me.fedox.talent.utils.ShowManager;
import me.fedox.talent.worker.QueueListener;
Expand Down Expand Up @@ -33,9 +32,6 @@
*/
public final class Talent extends JavaPlugin {

@Getter
@Setter
public static String creatorUUID; // UUID of the creator
@Getter
private static Talent instance; // Singleton instance of the plugin
@Getter
Expand All @@ -57,24 +53,17 @@ public void onEnable() {
loadConfig();
copySongs();

Location soundLoc = new Location(
Bukkit.getWorld(getConfig().getString(Constants.LOCATIONS_SOUND_WORLD)),
getConfig().getDouble(Constants.LOCATIONS_SOUND_X),
getConfig().getDouble(Constants.LOCATIONS_SOUND_Y),
getConfig().getDouble(Constants.LOCATIONS_SOUND_Z)
);

if (!Bukkit.getPluginManager().isPluginEnabled("NoteBlockAPI")) {
getLogger().severe("*** NoteBlockAPI is not installed or not enabled. ***");
return;
}

queueWorker = new QueueWorker(this);
showManager = new ShowManager(this, soundLoc);
showManager = new ShowManager(this);

System.out.println("Cam Locs:");
System.out.println(getCameraLocations());

register();
}

Expand Down Expand Up @@ -103,6 +92,7 @@ public void register() {
Bukkit.getPluginManager().registerEvents(new VoteListener(this), this);
Bukkit.getPluginManager().registerEvents(new AntiListener(), this);
Bukkit.getPluginManager().registerEvents(new QueueListener(), this);
Bukkit.getPluginManager().registerEvents(new OtherListener(), this);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/me/fedox/talent/commands/NextCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
}

Player nextPlayer = queueWorker.nextPlayer();

Bukkit.broadcastMessage(Constants.PLUGIN_PREFIX + "Der nächste Spieler ist " + nextPlayer.getName() + ".");
nextPlayer.teleport(stageLoc);
nextPlayer.playSound(nextPlayer.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/me/fedox/talent/commands/QueueCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
return false;
}

player.sendMessage("§7Du wurdest in die Warteschlange eingereiht.");
player.sendMessage("§7Bitte warte geduldig bis du dran bist, beachte den Server nicht zu verlassen!");
player.sendMessage("§7Falls du doch gehen musst, und wieder kommen möchtest, nutze §a/queue confirm§7 erneut.");

if (queueWorker.isPlayerInQueue(player)) {
player.sendMessage(Constants.PLUGIN_PREFIX + "§cDu bist bereits in der Warteschlange.");
return false;
}

player.sendMessage("§7Du wurdest in die Warteschlange eingereiht.");
player.sendMessage("§7Bitte warte geduldig bis du dran bist, beachte den Server nicht zu verlassen!");
player.sendMessage("§7Falls du doch gehen musst, und wieder kommen möchtest, nutze §a/queue confirm§7 erneut.");

queueWorker.addPlayerToQueue(player);
return true;
}
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/me/fedox/talent/listener/OtherListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package me.fedox.talent.listener;

import me.fedox.talent.Talent;
import me.fedox.talent.utils.Constants;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

/**
* © 2024 Florian O and Fabian W.
* Created on: 10/3/2024 5:08 PM
* <p>
* https://www.youtube.com/watch?v=tjBCjfB3Hq8
*/

public class OtherListener implements Listener {


// queue message

@EventHandler
public void onJoin(PlayerJoinEvent event) {
var config = Talent.getInstance().getConfig();

Location spawnLoc = new Location(
Bukkit.getWorld(config.getString(Constants.LOCATIONS_SPAWN_WORLD)),
config.getDouble(Constants.LOCATIONS_SPAWN_X),
config.getDouble(Constants.LOCATIONS_SPAWN_Y),
config.getDouble(Constants.LOCATIONS_SPAWN_Z),
(float) config.getDouble(Constants.LOCATIONS_SPAWN_YAW),
(float) config.getDouble(Constants.LOCATIONS_SPAWN_PITCH)
);

event.getPlayer().teleport(spawnLoc);

event.setJoinMessage(Constants.PLUGIN_PREFIX + "Der Spieler §a" + event.getPlayer().getName() + " §7hat den Server betreten!");
event.getPlayer().sendMessage(Constants.PLUGIN_PREFIX + "Führe §a/queue §7aus, um dich in die Warteschlange einzutragen.");
}

@EventHandler
public void onQuit(PlayerQuitEvent event) {
event.setQuitMessage(Constants.PLUGIN_PREFIX + "Der Spieler §a" + event.getPlayer().getName() + " §7hat den Server verlassen!");
}

}
34 changes: 5 additions & 29 deletions src/main/java/me/fedox/talent/utils/ShowManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,25 @@ public class ShowManager {

private final Talent plugin;
private final Random random;
private final List<Location> tourLocations;
private List<Location> tourLocations;

/**
* Constructor for ShowManager.
* Initializes the manager with the plugin instance and configuration settings.
*
* @param plugin The Talent plugin instance.
*/
public ShowManager(Talent plugin, Location location) {
public ShowManager(Talent plugin) {
this.plugin = plugin;
this.random = new Random();
this.tourLocations = Talent.getInstance().getCameraLocations();
}

/**
* Starts the end sequence of the show, including sounds, titles, and teleporting winners.
*/
public void startEndSequence() {
tourLocations = Talent.getInstance().getCameraLocations();

for (Player player : Bukkit.getOnlinePlayers()) {
player.playSound(player.getLocation(), Sound.UI_TOAST_CHALLENGE_COMPLETE, 1, 1);
player.sendTitle("§8§k!!! §aVORBEI §8§k!!!", "", 10, 70, 20);
Expand Down Expand Up @@ -299,33 +300,8 @@ private void createAmbientEffects(Location location) {
world.spawnParticle(Particle.END_ROD, location, 50, 5, 5, 5, 0.1);
world.spawnParticle(Particle.TOTEM_OF_UNDYING, location, 30, 3, 3, 3, 0.05);

if (random.nextInt(20) == 0) {
launchFirework(location);
}
}

/**
* Launches a firework at the specified location.
*
* @param location The location to launch the firework at.
*/
private void launchFirework(Location location) {
Firework fw = (Firework) location.getWorld().spawnEntity(location, EntityType.FIREWORK_ROCKET);
FireworkMeta fwm = fw.getFireworkMeta();

FireworkEffect effect = FireworkEffect.builder()
.withColor(Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)))
.withFade(Color.fromRGB(random.nextInt(256), random.nextInt(256), random.nextInt(256)))
.with(FireworkEffect.Type.values()[random.nextInt(FireworkEffect.Type.values().length)])
.trail(true)
.flicker(true)
.build();

fwm.addEffect(effect);
fwm.setPower(1);
fw.setFireworkMeta(fwm);
}

/**
* Ends the tour and teleports all players back to the stage.
*/
Expand Down

0 comments on commit 60c7f78

Please sign in to comment.