DuelEnhancer first test build

This commit is contained in:
NotAlexNoyle committed 2023-05-21 19:02:23 -04:00
1 parent 95911605e3
commit 0a458cdce8
3 files changed
+59 -4

No files matched your search

+1
View File
@@ -79,6 +79,7 @@ tasks.shadowJar.configure {
tasks.withType(JavaCompile).configureEach {
options.compilerArgs += ["-parameters"]
options.compilerArgs.add("-Xlint:deprecation")
options.encoding = 'UTF-8' // Override the system character set with a universal set.
options.fork = true // Enable compilation in a separate daemon process.
+2 -4
View File
@@ -1,11 +1,8 @@
package plugin;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import me.realized.duels.api.Duels;
// Extending this class is standard bukkit boilerplate for any plugin, or else the server software won't load the classes.
public class DuelEnhancerOG extends JavaPlugin {
@@ -13,7 +10,8 @@ public class DuelEnhancerOG extends JavaPlugin {
@Override
public void onEnable() {
Duels api = (Duels) Bukkit.getServer().getPluginManager().getPlugin("Duels");
// Register the Event Listener class.
this.getServer().getPluginManager().registerEvents(new Listeners(), this);
}
+56
View File
@@ -0,0 +1,56 @@
// This is free and unencumbered software released into the public domain.
// Author: NotAlexNoyle (admin@true-og.net)
package plugin;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import me.realized.duels.api.Duels;
import net.md_5.bungee.api.ChatColor;
public class Listeners implements Listener {
// Declare instance of class as static so multiple players can use it.
private static Listeners instance;
// Initialize Duels API.
private static Duels api = (Duels) Bukkit.getServer().getPluginManager().getPlugin("Duels");
// Return instance of class as static so multiple players can use it.
public static Listeners getInstance() {
return instance;
}
// Listen for a player's game mode changing.
@EventHandler
public void onSurvivalMode(PlayerGameModeChangeEvent event) {
// Store player as object for multiple references.
Player player = event.getPlayer();
// Use Duels API to tell if the player whose game mode has changed is spectating a duel.
if(api.getSpectateManager().isSpectating(player)) {
// If the player was put in survival (presumably by WorldGuard), do this...
if(player.getGameMode() == GameMode.SURVIVAL) {
// Inform the player that they will stop spectating the match.
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7[&2True&4OG&7] &6Out of bounds! Your Duel spectating session has ended."));
// Stop the player from spectating the match.
api.getSpectateManager().stopSpectating(player);
}
}
}
}