This commit is contained in:
parent
f474ff3ed6
commit
536cb90868
18 changed files with 188 additions and 156 deletions
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>tech.sbdevelopment</groupId>
|
<groupId>tech.sbdevelopment</groupId>
|
||||||
<artifactId>ThemeParkAudio</artifactId>
|
<artifactId>ThemeParkAudio</artifactId>
|
||||||
<version>1.6</version>
|
<version>1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>ThemeParkAudio</name>
|
<name>ThemeParkAudio</name>
|
||||||
|
|
|
@ -2,10 +2,9 @@ package tech.sbdevelopment.themeparkaudio;
|
||||||
|
|
||||||
import co.aikar.commands.PaperCommandManager;
|
import co.aikar.commands.PaperCommandManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import tech.sbdevelopment.themeparkaudio.commands.TPAudioCMD;
|
import tech.sbdevelopment.themeparkaudio.commands.TPAudioCMD;
|
||||||
import tech.sbdevelopment.themeparkaudio.listener.LogoutListener;
|
import tech.sbdevelopment.themeparkaudio.listener.LogoutListener;
|
||||||
import tech.sbdevelopment.themeparkaudio.listener.WGListener;
|
|
||||||
import tech.sbdevelopment.themeparkaudio.managers.WGManager;
|
|
||||||
import tech.sbdevelopment.themeparkaudio.radio.Playlist;
|
import tech.sbdevelopment.themeparkaudio.radio.Playlist;
|
||||||
import tech.sbdevelopment.themeparkaudio.socket.Client;
|
import tech.sbdevelopment.themeparkaudio.socket.Client;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -25,13 +24,18 @@ public final class ThemeParkAudio extends JavaPlugin {
|
||||||
@Getter
|
@Getter
|
||||||
private static Playlist playlist;
|
private static Playlist playlist;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static boolean regionSupport = false;
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Bukkit.getLogger().info("[ThemeParkAudio] Loading...");
|
Bukkit.getLogger().info("[ThemeParkAudio] Loading...");
|
||||||
|
|
||||||
if (!setupPlugins()) {
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null && Bukkit.getPluginManager().getPlugin("Train_Carts") != null) {
|
||||||
Bukkit.getLogger().severe("[ThemeParkAudio] WorldGuard not found! Disabling...");
|
Bukkit.getLogger().info("[ThemeParkAudio] WorldGuard and TrainCarts found! Loading region support...");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
regionSupport = true;
|
||||||
return;
|
Bukkit.getPluginManager().registerEvents(new tech.sbdevelopment.themeparkaudio.listener.WGListener(), this);
|
||||||
|
} else {
|
||||||
|
Bukkit.getLogger().warning("[ThemeParkAudio] WorldGuard not found! Regions won't work...");
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
@ -47,13 +51,15 @@ public final class ThemeParkAudio extends JavaPlugin {
|
||||||
commandManager = new PaperCommandManager(this);
|
commandManager = new PaperCommandManager(this);
|
||||||
commandManager.enableUnstableAPI("help");
|
commandManager.enableUnstableAPI("help");
|
||||||
|
|
||||||
|
commandManager.getCommandReplacements().addReplacement("tpcommand", getConfig().getString("command"));
|
||||||
commandManager.registerCommand(new TPAudioCMD());
|
commandManager.registerCommand(new TPAudioCMD());
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new WGListener(), this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new LogoutListener(), this);
|
Bukkit.getPluginManager().registerEvents(new LogoutListener(), this);
|
||||||
|
|
||||||
Bukkit.getLogger().info("[ThemeParkAudio] Loading playlist...");
|
if (ThemeParkAudio.getInstance().getConfig().getBoolean("radio")) {
|
||||||
playlist = new Playlist();
|
Bukkit.getLogger().info("[ThemeParkAudio] Loading radio playlist...");
|
||||||
|
playlist = new Playlist();
|
||||||
|
}
|
||||||
|
|
||||||
Bukkit.getLogger().info("[ThemeParkAudio] Plugin is enabled!");
|
Bukkit.getLogger().info("[ThemeParkAudio] Plugin is enabled!");
|
||||||
}
|
}
|
||||||
|
@ -63,12 +69,4 @@ public final class ThemeParkAudio extends JavaPlugin {
|
||||||
instance = null;
|
instance = null;
|
||||||
Bukkit.getLogger().info("[ThemeParkAudio] Plugin is disabled!");
|
Bukkit.getLogger().info("[ThemeParkAudio] Plugin is disabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupPlugins() {
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
|
||||||
WGManager.setWorldGuard(getServer().getPluginManager().getPlugin("WorldGuard"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,15 @@ package tech.sbdevelopment.themeparkaudio.commands;
|
||||||
import co.aikar.commands.BaseCommand;
|
import co.aikar.commands.BaseCommand;
|
||||||
import co.aikar.commands.CommandHelp;
|
import co.aikar.commands.CommandHelp;
|
||||||
import co.aikar.commands.annotation.*;
|
import co.aikar.commands.annotation.*;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
||||||
import tech.sbdevelopment.themeparkaudio.api.AudioType;
|
import tech.sbdevelopment.themeparkaudio.api.AudioType;
|
||||||
import tech.sbdevelopment.themeparkaudio.api.LightRegion;
|
import tech.sbdevelopment.themeparkaudio.api.LightRegion;
|
||||||
import tech.sbdevelopment.themeparkaudio.listener.PlayInRegionHandler;
|
import tech.sbdevelopment.themeparkaudio.listener.PlayInRegionHandler;
|
||||||
import tech.sbdevelopment.themeparkaudio.managers.PinManager;
|
import tech.sbdevelopment.themeparkaudio.managers.PinManager;
|
||||||
|
import tech.sbdevelopment.themeparkaudio.socket.messages.AudioMessage;
|
||||||
|
import tech.sbdevelopment.themeparkaudio.socket.messages.LightMessage;
|
||||||
|
import tech.sbdevelopment.themeparkaudio.socket.messages.StopAudioMessage;
|
||||||
import tech.sbdevelopment.themeparkaudio.utils.HeadUtil;
|
import tech.sbdevelopment.themeparkaudio.utils.HeadUtil;
|
||||||
import tech.sbdevelopment.themeparkaudio.utils.SpigotPlayerSelector;
|
import tech.sbdevelopment.themeparkaudio.utils.SpigotPlayerSelector;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -15,30 +19,47 @@ import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@CommandAlias("tpaudio")
|
@CommandAlias("%tpcommand")
|
||||||
@CommandPermission("tpa.cmd")
|
@CommandPermission("tpa.cmd")
|
||||||
public class TPAudioCMD extends BaseCommand {
|
public class TPAudioCMD extends BaseCommand {
|
||||||
@Default
|
@Subcommand("help")
|
||||||
@HelpCommand
|
@HelpCommand
|
||||||
public void onHelp(CommandSender sender, CommandHelp help) {
|
public void onHelp(CommandSender sender, CommandHelp help) {
|
||||||
help.showHelp();
|
help.showHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Default
|
||||||
|
@Description("Get your audio URL.")
|
||||||
|
public void getAudioUrl(Player sender) {
|
||||||
|
String pin = PinManager.getPIN(sender.getUniqueId());
|
||||||
|
|
||||||
|
String url = ThemeParkAudio.getInstance().getConfig().getString("clientUrl");
|
||||||
|
url = url + "?uuid=" + sender.getUniqueId().toString().replace("-", "") + "&pin=" + pin;
|
||||||
|
|
||||||
|
TextComponent component = new TextComponent(ChatColor.GRAY + "Click here to open our audio client.");
|
||||||
|
component.setClickEvent(new net.md_5.bungee.api.chat.ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.OPEN_URL, url));
|
||||||
|
sender.spigot().sendMessage(component);
|
||||||
|
}
|
||||||
|
|
||||||
@Subcommand("toggleradio")
|
@Subcommand("toggleradio")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void toggleRadio(CommandSender sender) {
|
public void toggleRadio(CommandSender sender) {
|
||||||
|
if (!ThemeParkAudio.getInstance().getConfig().getBoolean("radio")) {
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "The radio is disabled, so it can't be toggled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ThemeParkAudio.getPlaylist().isRunning()) {
|
if (ThemeParkAudio.getPlaylist().isRunning()) {
|
||||||
ThemeParkAudio.getPlaylist().stop();
|
ThemeParkAudio.getPlaylist().stop();
|
||||||
sender.sendMessage(ChatColor.GRAY + "De automatische radio is stopgezet. Zodra het huidige nummer is afgelopen, gebeurt er niks meer.");
|
sender.sendMessage(ChatColor.GRAY + "The automatic radio has been stopped. Once the current song ends, it will not continue.");
|
||||||
} else {
|
} else {
|
||||||
ThemeParkAudio.getPlaylist().start();
|
ThemeParkAudio.getPlaylist().start();
|
||||||
sender.sendMessage(ChatColor.GRAY + "De automatische radio is weer gestart.");
|
sender.sendMessage(ChatColor.GRAY + "The automatic radio has started again.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +71,7 @@ public class TPAudioCMD extends BaseCommand {
|
||||||
ThemeParkAudio.getInstance().getConfig().set("radioSongs", urls);
|
ThemeParkAudio.getInstance().getConfig().set("radioSongs", urls);
|
||||||
ThemeParkAudio.getInstance().saveConfig();
|
ThemeParkAudio.getInstance().saveConfig();
|
||||||
ThemeParkAudio.getPlaylist().addSong(url);
|
ThemeParkAudio.getPlaylist().addSong(url);
|
||||||
sender.sendMessage(ChatColor.GRAY + "Nummer toegevoegd aan de automatische radio.");
|
sender.sendMessage(ChatColor.GRAY + "The song has been added to the radio playlist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("play")
|
@Subcommand("play")
|
||||||
|
@ -60,7 +81,7 @@ public class TPAudioCMD extends BaseCommand {
|
||||||
Player target = Bukkit.getPlayer(selector);
|
Player target = Bukkit.getPlayer(selector);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (!PinManager.hasPin(target.getUniqueId())) {
|
if (!PinManager.hasPin(target.getUniqueId())) {
|
||||||
sender.sendMessage(ChatColor.GRAY + "Die speler is niet verbonden met de client.");
|
sender.sendMessage(ChatColor.GRAY + "The player is not connected to the client.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,36 +90,35 @@ public class TPAudioCMD extends BaseCommand {
|
||||||
SpigotPlayerSelector sel = new SpigotPlayerSelector(selector);
|
SpigotPlayerSelector sel = new SpigotPlayerSelector(selector);
|
||||||
|
|
||||||
if (sel.getArgument("region").length() != 0) {
|
if (sel.getArgument("region").length() != 0) {
|
||||||
|
if (!ThemeParkAudio.isRegionSupport()) {
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Region support is not available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
String regionID = sel.getArgument("region");
|
String regionID = sel.getArgument("region");
|
||||||
new PlayInRegionHandler(regionID, url, sel.getPlayers(sender).stream().map(Entity::getUniqueId).collect(Collectors.toList()));
|
new PlayInRegionHandler(regionID, url, sel.getPlayers(sender).stream().map(Entity::getUniqueId).collect(Collectors.toList()));
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "Gestart met afspelen!");
|
sender.sendMessage(ChatColor.GRAY + "Playback started in region " + regionID + "!");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
players.addAll(sel.getPlayers(sender));
|
players.addAll(sel.getPlayers(sender));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject data;
|
if (type == AudioType.RADIO && !ThemeParkAudio.getInstance().getConfig().getBoolean("radio")) {
|
||||||
for (Player p : players) {
|
sender.sendMessage(ChatColor.GRAY + "The radio is disabled, so it can't be played on.");
|
||||||
data = new JSONObject();
|
return;
|
||||||
|
|
||||||
if (!PinManager.hasPin(p.getUniqueId())) continue;
|
|
||||||
|
|
||||||
data.put("task", type.name());
|
|
||||||
data.put("path", url);
|
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
|
||||||
ThemeParkAudio.getClient().sendData(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "Gestart met afspelen!");
|
AudioMessage.of(type, url).broadcastSelection(players, PinManager::hasPin);
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Playback started!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("light")
|
@Subcommand("light|hue")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void onLight(CommandSender sender, String selector, int r, int g, int b, int w, LightRegion region, @Default("255") Integer brightness) {
|
public void onLight(CommandSender sender, String selector, int r, int g, int b, int w, LightRegion region, @Default("255") Integer brightness) {
|
||||||
if (brightness < 0 || brightness > 255) {
|
if (brightness < 0 || brightness > 255) {
|
||||||
sender.sendMessage(ChatColor.GRAY.toString() + brightness + " is geen geldige brightness.");
|
sender.sendMessage(ChatColor.GRAY.toString() + brightness + " is not a valid brightness value. It must be between 0 and 255.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +126,7 @@ public class TPAudioCMD extends BaseCommand {
|
||||||
Player target = Bukkit.getPlayer(selector);
|
Player target = Bukkit.getPlayer(selector);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (!PinManager.hasPin(target.getUniqueId())) {
|
if (!PinManager.hasPin(target.getUniqueId())) {
|
||||||
sender.sendMessage(ChatColor.GRAY + "Die speler is niet verbonden met de client.");
|
sender.sendMessage(ChatColor.GRAY + "The player is not connected to the client.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,21 +145,15 @@ public class TPAudioCMD extends BaseCommand {
|
||||||
ThemeParkAudio.getInstance().saveConfig();
|
ThemeParkAudio.getInstance().saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject data;
|
LightMessage.of(brightness, r, g, b, w, region).broadcastSelection(players, PinManager::hasPin);
|
||||||
for (Player p : players) {
|
|
||||||
data = new JSONObject();
|
|
||||||
|
|
||||||
|
for (Player p : players) {
|
||||||
if (!PinManager.hasPin(p.getUniqueId())) continue;
|
if (!PinManager.hasPin(p.getUniqueId())) continue;
|
||||||
|
|
||||||
data.put("task", "LIGHT");
|
LightMessage.of(brightness, r, g, b, w, region).send(p.getUniqueId());
|
||||||
data.put("rgbw", r + ":" + g + ":" + b + ":" + w);
|
|
||||||
data.put("region", region.name());
|
|
||||||
data.put("brightness", brightness);
|
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
|
||||||
ThemeParkAudio.getClient().sendData(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "Kleuren aangepast!");
|
sender.sendMessage(ChatColor.GRAY + "Light color has been changed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("setregion")
|
@Subcommand("setregion")
|
||||||
|
@ -148,16 +162,16 @@ public class TPAudioCMD extends BaseCommand {
|
||||||
ThemeParkAudio.getInstance().getConfig().set("regions.audio." + regionName, url);
|
ThemeParkAudio.getInstance().getConfig().set("regions.audio." + regionName, url);
|
||||||
ThemeParkAudio.getInstance().saveConfig();
|
ThemeParkAudio.getInstance().saveConfig();
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "De region zal vanaf nu muziek afspelen.");
|
sender.sendMessage(ChatColor.GRAY + "The region will now play audio.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("sethueregion")
|
@Subcommand("setlightregion|sethueregion")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void onSetHueRegion(CommandSender sender, String regionName, String url) {
|
public void onSetLightRegion(CommandSender sender, String regionName, String url) {
|
||||||
ThemeParkAudio.getInstance().getConfig().set("regions.light." + regionName, url);
|
ThemeParkAudio.getInstance().getConfig().set("regions.light." + regionName, url);
|
||||||
ThemeParkAudio.getInstance().saveConfig();
|
ThemeParkAudio.getInstance().saveConfig();
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "De region zal vanaf nu licht aanpassen.");
|
sender.sendMessage(ChatColor.GRAY + "The region will now control the lights.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("stop")
|
@Subcommand("stop")
|
||||||
|
@ -167,7 +181,7 @@ public class TPAudioCMD extends BaseCommand {
|
||||||
Player target = Bukkit.getPlayer(selector);
|
Player target = Bukkit.getPlayer(selector);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (!PinManager.hasPin(target.getUniqueId())) {
|
if (!PinManager.hasPin(target.getUniqueId())) {
|
||||||
sender.sendMessage(ChatColor.GRAY + "Die speler is niet verbonden met de client.");
|
sender.sendMessage(ChatColor.GRAY + "The player is not connected to the client.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,17 +191,8 @@ public class TPAudioCMD extends BaseCommand {
|
||||||
players.addAll(sel.getPlayers(sender));
|
players.addAll(sel.getPlayers(sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject data;
|
StopAudioMessage.of().broadcastSelection(players, PinManager::hasPin);
|
||||||
for (Player p : players) {
|
|
||||||
data = new JSONObject();
|
|
||||||
|
|
||||||
if (!PinManager.hasPin(p.getUniqueId())) continue;
|
sender.sendMessage(ChatColor.GRAY + "Playback stopped!");
|
||||||
|
|
||||||
data.put("task", "STOP");
|
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
|
||||||
ThemeParkAudio.getClient().sendData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "Gestopt met afspelen!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
package tech.sbdevelopment.themeparkaudio.listener;
|
package tech.sbdevelopment.themeparkaudio.listener;
|
||||||
|
|
||||||
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.json.simple.JSONObject;
|
import tech.sbdevelopment.themeparkaudio.socket.messages.LogoutMessage;
|
||||||
|
|
||||||
public class LogoutListener implements Listener {
|
public class LogoutListener implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDisconnect(PlayerQuitEvent e) {
|
public void onDisconnect(PlayerQuitEvent e) {
|
||||||
JSONObject data = new JSONObject();
|
LogoutMessage.of().send(e.getPlayer().getUniqueId());
|
||||||
data.put("task", "LOGOUT");
|
|
||||||
data.put("uuid", e.getPlayer().getUniqueId().toString().replace("-", ""));
|
|
||||||
ThemeParkAudio.getClient().sendData(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class WGListener implements Listener {
|
||||||
AudioMessage.of(AudioType.MUSIC, regionURL).send(player.getUniqueId());
|
AudioMessage.of(AudioType.MUSIC, regionURL).send(player.getUniqueId());
|
||||||
} else if (!Collections.disjoint(list, fromRegions) && Collections.disjoint(list, toRegions)) {
|
} else if (!Collections.disjoint(list, fromRegions) && Collections.disjoint(list, toRegions)) {
|
||||||
//Not in a region, stop...
|
//Not in a region, stop...
|
||||||
StopAudioMessage.of(AudioType.MUSIC).send(player.getUniqueId());
|
AudioMessage.of(AudioType.MUSIC, "").send(player.getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package tech.sbdevelopment.themeparkaudio.managers;
|
package tech.sbdevelopment.themeparkaudio.managers;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -28,8 +29,13 @@ public class PinManager {
|
||||||
String pin = builder.toString();
|
String pin = builder.toString();
|
||||||
|
|
||||||
pins.put(pUUID, pin);
|
pins.put(pUUID, pin);
|
||||||
|
|
||||||
|
ThemeParkAudio.getInstance().getLogger().info("Assigned pin " + pin + " to " + pUUID);
|
||||||
|
|
||||||
return pin;
|
return pin;
|
||||||
} else {
|
} else {
|
||||||
|
ThemeParkAudio.getInstance().getLogger().info("Pin " + pins.get(pUUID) + " already assigned to " + pUUID);
|
||||||
|
|
||||||
return pins.get(pUUID);
|
return pins.get(pUUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,10 +58,18 @@ public class PinManager {
|
||||||
* @return true/false
|
* @return true/false
|
||||||
*/
|
*/
|
||||||
public static boolean checkPin(UUID pUUID, String pin) {
|
public static boolean checkPin(UUID pUUID, String pin) {
|
||||||
|
ThemeParkAudio.getInstance().getLogger().info("Checking pin " + pin + " for " + pUUID);
|
||||||
|
|
||||||
if (pUUID == null || pin == null || pin.isEmpty()) {
|
if (pUUID == null || pin == null || pin.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pins.forEach((uuid, p) -> {
|
||||||
|
if (pUUID.equals(uuid)) {
|
||||||
|
ThemeParkAudio.getInstance().getLogger().info("Pin " + p + " for " + pUUID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return pins.containsKey(pUUID) && pin.equals(pins.get(pUUID));
|
return pins.containsKey(pUUID) && pin.equals(pins.get(pUUID));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,9 @@ import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldguard.WorldGuard;
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
||||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.flags.Flags;
|
import com.sk89q.worldguard.protection.flags.Flags;
|
||||||
|
@ -25,7 +23,6 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -44,27 +41,6 @@ import java.util.UUID;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class WGManager {
|
public class WGManager {
|
||||||
private static WorldGuardPlugin wgp;
|
|
||||||
private static WorldEditPlugin wep;
|
|
||||||
|
|
||||||
public static boolean hasWorldGuard() {
|
|
||||||
return wgp != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasWorldEdit() {
|
|
||||||
return wep != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean setWorldGuard(Plugin plugin) {
|
|
||||||
wgp = (WorldGuardPlugin) plugin;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean setWorldEdit(Plugin plugin) {
|
|
||||||
wep = (WorldEditPlugin) plugin;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ProtectedRegion createRegion(Player p, String id) throws StorageException {
|
public static ProtectedRegion createRegion(Player p, String id) throws StorageException {
|
||||||
LocalSession l = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(p));
|
LocalSession l = WorldEdit.getInstance().getSessionManager().get(BukkitAdapter.adapt(p));
|
||||||
Region s;
|
Region s;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class Playlist {
|
||||||
* Start this playlist
|
* Start this playlist
|
||||||
*/
|
*/
|
||||||
public void start() {
|
public void start() {
|
||||||
for (String URL : ThemeParkAudio.getInstance().getConfig().getStringList("RadioSongs")) {
|
for (String URL : ThemeParkAudio.getInstance().getConfig().getStringList("radioSongs")) {
|
||||||
addSong(URL);
|
addSong(URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package tech.sbdevelopment.themeparkaudio.socket;
|
package tech.sbdevelopment.themeparkaudio.socket;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|
||||||
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
||||||
import tech.sbdevelopment.themeparkaudio.api.AudioType;
|
import tech.sbdevelopment.themeparkaudio.api.AudioType;
|
||||||
import tech.sbdevelopment.themeparkaudio.api.events.AudioConnectionUpdateEvent;
|
import tech.sbdevelopment.themeparkaudio.api.events.AudioConnectionUpdateEvent;
|
||||||
import tech.sbdevelopment.themeparkaudio.managers.PinManager;
|
import tech.sbdevelopment.themeparkaudio.managers.PinManager;
|
||||||
import tech.sbdevelopment.themeparkaudio.managers.WGManager;
|
|
||||||
import tech.sbdevelopment.themeparkaudio.socket.messages.AudioMessage;
|
import tech.sbdevelopment.themeparkaudio.socket.messages.AudioMessage;
|
||||||
import tech.sbdevelopment.themeparkaudio.socket.messages.AuthenticationMessage;
|
import tech.sbdevelopment.themeparkaudio.socket.messages.AuthenticationMessage;
|
||||||
import tech.sbdevelopment.themeparkaudio.socket.messages.LightMessage;
|
import tech.sbdevelopment.themeparkaudio.socket.messages.LightMessage;
|
||||||
|
@ -14,6 +12,7 @@ import org.bukkit.entity.Player;
|
||||||
import org.java_websocket.client.WebSocketClient;
|
import org.java_websocket.client.WebSocketClient;
|
||||||
import org.java_websocket.handshake.ServerHandshake;
|
import org.java_websocket.handshake.ServerHandshake;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
import tech.sbdevelopment.themeparkaudio.socket.messages.PingMessage;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
@ -97,22 +96,25 @@ public class Client {
|
||||||
AudioConnectionUpdateEvent event = new AudioConnectionUpdateEvent(p, true);
|
AudioConnectionUpdateEvent event = new AudioConnectionUpdateEvent(p, true);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
List<String> regions = WGManager.getRegionsIn(p.getLocation()).stream().map(ProtectedRegion::getId).toList();
|
if (ThemeParkAudio.isRegionSupport()) {
|
||||||
Set<String> list = ThemeParkAudio.getInstance().getConfig().getConfigurationSection("regions.audio").getKeys(false);
|
List<String> regions = tech.sbdevelopment.themeparkaudio.managers.WGManager.getRegionsIn(p.getLocation()).stream().map(com.sk89q.worldguard.protection.regions.ProtectedRegion::getId).toList();
|
||||||
Optional<String> regionName = regions.stream().filter(list::contains).findFirst();
|
|
||||||
regionName.ifPresent(name -> {
|
|
||||||
String regionURL = ThemeParkAudio.getInstance().getConfig().getString("regions.audio." + name);
|
|
||||||
AudioMessage.of(AudioType.MUSIC, regionURL).send(pUUID);
|
|
||||||
});
|
|
||||||
|
|
||||||
Set<String> list2 = ThemeParkAudio.getInstance().getConfig().getConfigurationSection("regions.light").getKeys(false);
|
Set<String> list = ThemeParkAudio.getInstance().getConfig().getConfigurationSection("regions.audio").getKeys(false);
|
||||||
Optional<String> regionName2 = regions.stream().filter(list2::contains).findFirst();
|
Optional<String> regionName = regions.stream().filter(list::contains).findFirst();
|
||||||
regionName2.ifPresent(name -> {
|
regionName.ifPresent(name -> {
|
||||||
String configData = ThemeParkAudio.getInstance().getConfig().getString("regions.light." + name);
|
String regionURL = ThemeParkAudio.getInstance().getConfig().getString("regions.audio." + name);
|
||||||
if (configData != null) {
|
AudioMessage.of(AudioType.MUSIC, regionURL).send(pUUID);
|
||||||
LightMessage.of(configData).send(pUUID);
|
});
|
||||||
}
|
|
||||||
});
|
Set<String> list2 = ThemeParkAudio.getInstance().getConfig().getConfigurationSection("regions.light").getKeys(false);
|
||||||
|
Optional<String> regionName2 = regions.stream().filter(list2::contains).findFirst();
|
||||||
|
regionName2.ifPresent(name -> {
|
||||||
|
String configData = ThemeParkAudio.getInstance().getConfig().getString("regions.light." + name);
|
||||||
|
if (configData != null) {
|
||||||
|
LightMessage.of(configData).send(pUUID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthenticationMessage.of(verified).send(pUUID);
|
AuthenticationMessage.of(verified).send(pUUID);
|
||||||
|
@ -147,7 +149,7 @@ public class Client {
|
||||||
if (this.taskID == 0) {
|
if (this.taskID == 0) {
|
||||||
this.taskID = Bukkit.getScheduler().runTaskTimerAsynchronously(ThemeParkAudio.getInstance(), () -> {
|
this.taskID = Bukkit.getScheduler().runTaskTimerAsynchronously(ThemeParkAudio.getInstance(), () -> {
|
||||||
if (Client.this.wsc != null && Client.this.wsc.isOpen()) {
|
if (Client.this.wsc != null && Client.this.wsc.isOpen()) {
|
||||||
Client.this.wsc.send("__PING__");
|
PingMessage.of().sendService();
|
||||||
} else {
|
} else {
|
||||||
if (Client.this.wsc != null) {
|
if (Client.this.wsc != null) {
|
||||||
Client.this.wsc.closeConnection(404, "Disconnected from socket");
|
Client.this.wsc.closeConnection(404, "Disconnected from socket");
|
||||||
|
@ -188,6 +190,10 @@ public class Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAudioUrl(UUID pUUID) {
|
||||||
|
return this.url;
|
||||||
|
}
|
||||||
|
|
||||||
public void sendData(JSONObject json) {
|
public void sendData(JSONObject json) {
|
||||||
if (this.wsc != null && this.wsc.isOpen()) {
|
if (this.wsc != null && this.wsc.isOpen()) {
|
||||||
this.wsc.send(json.toJSONString());
|
this.wsc.send(json.toJSONString());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package tech.sbdevelopment.themeparkaudio.socket.messages;
|
package tech.sbdevelopment.themeparkaudio.socket.messages;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
@ -19,6 +20,10 @@ public abstract class AbstractMessage {
|
||||||
this.task = task;
|
this.task = task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendService() {
|
||||||
|
send(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
public void send(UUID uuid) {
|
public void send(UUID uuid) {
|
||||||
send(List.of(uuid), null);
|
send(List.of(uuid), null);
|
||||||
}
|
}
|
||||||
|
@ -31,18 +36,24 @@ public abstract class AbstractMessage {
|
||||||
send(Bukkit.getOnlinePlayers().stream().map(Entity::getUniqueId).toList(), filter);
|
send(Bukkit.getOnlinePlayers().stream().map(Entity::getUniqueId).toList(), filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(List<UUID> uuids, @Nullable Function<UUID, Boolean> filter) {
|
public void broadcastSelection(@Nullable List<Player> players, @Nullable Function<UUID, Boolean> filter) {
|
||||||
|
send(players.stream().map(Entity::getUniqueId).toList(), filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(@Nullable List<UUID> uuids, @Nullable Function<UUID, Boolean> filter) {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
data.put("task", getTask());
|
data.put("task", getTask().name().toUpperCase());
|
||||||
JSONObject extendData = extendJson();
|
JSONObject extendData = extendJson();
|
||||||
if (extendData != null) {
|
if (extendData != null) {
|
||||||
data.putAll(extendData);
|
data.putAll(extendData);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (UUID uuid : uuids) {
|
if (uuids != null && !uuids.isEmpty()) {
|
||||||
if (filter == null || filter.apply(uuid)) {
|
for (UUID uuid : uuids) {
|
||||||
data.put("uuid", uuid.toString().replace("-", ""));
|
if (filter == null || filter.apply(uuid)) {
|
||||||
ThemeParkAudio.getClient().sendData(data);
|
data.put("uuid", uuid.toString().replace("-", ""));
|
||||||
|
ThemeParkAudio.getClient().sendData(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,8 +46,11 @@ public class LightMessage extends AbstractMessage {
|
||||||
@Override
|
@Override
|
||||||
protected JSONObject extendJson() {
|
protected JSONObject extendJson() {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
data.put("rgbw", r + "_" + g + "_" + b + "_" + w);
|
data.put("r", r);
|
||||||
data.put("region", region);
|
data.put("g", g);
|
||||||
|
data.put("b", b);
|
||||||
|
data.put("w", w);
|
||||||
|
data.put("region", region.name().toUpperCase());
|
||||||
data.put("brightness", brightness);
|
data.put("brightness", brightness);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,10 @@ public class LogoutMessage extends AbstractMessage {
|
||||||
super(MessageTask.LOGOUT);
|
super(MessageTask.LOGOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static LogoutMessage of() {
|
||||||
|
return new LogoutMessage();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JSONObject extendJson() {
|
protected JSONObject extendJson() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package tech.sbdevelopment.themeparkaudio.socket.messages;
|
package tech.sbdevelopment.themeparkaudio.socket.messages;
|
||||||
|
|
||||||
public enum MessageTask {
|
public enum MessageTask {
|
||||||
AUTHENTICATION, LOGOUT, LIGHT, MUSIC, SFX, RADIO
|
AUTHENTICATION, LOGOUT, LIGHT, MUSIC, SFX, RADIO, PING, STOP
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package tech.sbdevelopment.themeparkaudio.socket.messages;
|
||||||
|
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class PingMessage extends AbstractMessage {
|
||||||
|
public PingMessage() {
|
||||||
|
super(MessageTask.PING);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PingMessage of() {
|
||||||
|
return new PingMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject extendJson() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,18 @@
|
||||||
package tech.sbdevelopment.themeparkaudio.socket.messages;
|
package tech.sbdevelopment.themeparkaudio.socket.messages;
|
||||||
|
|
||||||
import tech.sbdevelopment.themeparkaudio.api.AudioType;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
public class StopAudioMessage extends AudioMessage {
|
public class StopAudioMessage extends AbstractMessage {
|
||||||
public StopAudioMessage(AudioType type) {
|
public StopAudioMessage() {
|
||||||
super(type, "", null, null);
|
super(MessageTask.STOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StopAudioMessage of(AudioType type) {
|
public static StopAudioMessage of() {
|
||||||
return new StopAudioMessage(type);
|
return new StopAudioMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject extendJson() {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package tech.sbdevelopment.themeparkaudio.utils;
|
package tech.sbdevelopment.themeparkaudio.utils;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import tech.sbdevelopment.themeparkaudio.ThemeParkAudio;
|
||||||
import tech.sbdevelopment.themeparkaudio.managers.WGManager;
|
import tech.sbdevelopment.themeparkaudio.managers.WGManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -34,7 +35,7 @@ public class SpigotPlayerSelector {
|
||||||
//get Location
|
//get Location
|
||||||
Location standPoint = getLocation(commandSender);
|
Location standPoint = getLocation(commandSender);
|
||||||
|
|
||||||
if (getArgument("r").length() != 0) {
|
if (!getArgument("r").isEmpty()) {
|
||||||
int radius = Integer.parseInt(getArgument("r"));
|
int radius = Integer.parseInt(getArgument("r"));
|
||||||
Player nearest = Bukkit.getOnlinePlayers().stream()
|
Player nearest = Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
||||||
|
@ -44,7 +45,7 @@ public class SpigotPlayerSelector {
|
||||||
players.add(nearest);
|
players.add(nearest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getArgument("distance").length() != 0) {
|
if (!getArgument("distance").isEmpty()) {
|
||||||
int distance = Integer.parseInt(getArgument("distance"));
|
int distance = Integer.parseInt(getArgument("distance"));
|
||||||
Player nearest = Bukkit.getOnlinePlayers().stream()
|
Player nearest = Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
||||||
|
@ -62,7 +63,12 @@ public class SpigotPlayerSelector {
|
||||||
//everyone
|
//everyone
|
||||||
Location standPoint = getLocation(commandSender);
|
Location standPoint = getLocation(commandSender);
|
||||||
|
|
||||||
if (getArgument("region").length() != 0) {
|
if (!getArgument("region").isEmpty()) {
|
||||||
|
if (!ThemeParkAudio.isRegionSupport()) {
|
||||||
|
commandSender.sendMessage("Region support is not available.");
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
String regionID = getArgument("region");
|
String regionID = getArgument("region");
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
ArrayList<ProtectedRegion> regions = WGManager.getRegionsIn(p.getLocation());
|
ArrayList<ProtectedRegion> regions = WGManager.getRegionsIn(p.getLocation());
|
||||||
|
@ -70,22 +76,22 @@ public class SpigotPlayerSelector {
|
||||||
players.add(p);
|
players.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (getArgument("r").length() != 0) {
|
} else if (!getArgument("r").isEmpty()) {
|
||||||
int radius = Integer.parseInt(getArgument("r"));
|
int radius = Integer.parseInt(getArgument("r"));
|
||||||
players.addAll(Bukkit.getOnlinePlayers().stream()
|
players.addAll(Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
||||||
.filter(player -> radius > player.getLocation().distance(standPoint))
|
.filter(player -> radius > player.getLocation().distance(standPoint))
|
||||||
.collect(Collectors.toList()));
|
.toList());
|
||||||
} else if (getArgument("distance").length() != 0) {
|
} else if (!getArgument("distance").isEmpty()) {
|
||||||
int distance = Integer.parseInt(getArgument("distance"));
|
int distance = Integer.parseInt(getArgument("distance"));
|
||||||
players.addAll(Bukkit.getOnlinePlayers().stream()
|
players.addAll(Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
||||||
.filter(player -> distance > player.getLocation().distance(standPoint))
|
.filter(player -> distance > player.getLocation().distance(standPoint))
|
||||||
.collect(Collectors.toList()));
|
.toList());
|
||||||
} else {
|
} else {
|
||||||
players.addAll(Bukkit.getOnlinePlayers().stream()
|
players.addAll(Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
.filter(player -> player.getLocation().getWorld().getName().equals(standPoint.getWorld().getName()))
|
||||||
.collect(Collectors.toList()));
|
.toList());
|
||||||
}
|
}
|
||||||
} else if (selector.length() <= 16) {
|
} else if (selector.length() <= 16) {
|
||||||
//player
|
//player
|
||||||
|
@ -113,7 +119,7 @@ public class SpigotPlayerSelector {
|
||||||
initialLocation = ((BlockCommandSender) commandSender).getBlock().getLocation();
|
initialLocation = ((BlockCommandSender) commandSender).getBlock().getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getArgument("x").equals("") && !getArgument("y").equals("") && !getArgument("z").equals("")) {
|
if (!getArgument("x").isEmpty() && !getArgument("y").isEmpty() && !getArgument("z").isEmpty()) {
|
||||||
try {
|
try {
|
||||||
int x = Integer.parseInt(getArgument("x"));
|
int x = Integer.parseInt(getArgument("x"));
|
||||||
int y = Integer.parseInt(getArgument("y"));
|
int y = Integer.parseInt(getArgument("y"));
|
||||||
|
@ -129,19 +135,6 @@ public class SpigotPlayerSelector {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getArgument(String key) {
|
public String getArgument(String key) {
|
||||||
StringBuilder result = new StringBuilder();
|
return HeadUtil.getArgument(selector, key);
|
||||||
String[] arguments = selector.split(key + "=");
|
|
||||||
if (arguments.length == 1) return "";
|
|
||||||
for (byte type : arguments[1].getBytes()) {
|
|
||||||
char element = (char) type;
|
|
||||||
if (element == ',' || element == ']') {
|
|
||||||
return result.toString();
|
|
||||||
} else {
|
|
||||||
result.append(element);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.toString().replaceAll("\\.", "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
socketUrl: "ws://localhost:8080"
|
command: "tpaudio"
|
||||||
|
socketUrl: "wss://localhost:8080"
|
||||||
|
clientUrl: "https://localhost:8081"
|
||||||
|
radio: false
|
||||||
regions:
|
regions:
|
||||||
audio:
|
audio:
|
||||||
demo: https://www.mcthemeparks.com/musicupload/downloads/Berlin/kaad.mp3
|
demo: https://www.mcthemeparks.com/musicupload/downloads/Berlin/kaad.mp3
|
||||||
|
|
|
@ -2,7 +2,7 @@ name: ThemeParkAudio
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: tech.sbdevelopment.themeparkaudio.ThemeParkAudio
|
main: tech.sbdevelopment.themeparkaudio.ThemeParkAudio
|
||||||
api-version: 1.21
|
api-version: 1.21
|
||||||
depend: [ WorldGuard, Train_Carts ]
|
softdepend: [ WorldGuard, Train_Carts ]
|
||||||
authors: [ SBDeveloper ]
|
authors: [ SBDeveloper ]
|
||||||
description: Audio and light control from your Minecraft server!
|
description: Audio and light control from your Minecraft server!
|
||||||
website: https://sbdevelopment.tech
|
website: https://sbdevelopment.tech
|
||||||
|
|
Loading…
Add table
Reference in a new issue