Converted to generic ThemeParkAudio plugin.
This commit is contained in:
parent
d28c9a5d6a
commit
2deeee7971
31 changed files with 425 additions and 368 deletions
29
.forgejo/workflows/build.yaml
Normal file
29
.forgejo/workflows/build.yaml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
name: Java CI
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: https://gitea.com/actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK 21
|
||||||
|
uses: https://gitea.com/actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 21
|
||||||
|
|
||||||
|
- name: Set up Maven
|
||||||
|
uses: https://gitea.com/actions/setup-maven@v5
|
||||||
|
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B package --file pom.xml
|
||||||
|
|
||||||
|
- name: Upload build artifacts
|
||||||
|
uses: https://gitea.com/actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ThemeParkAudio
|
||||||
|
path: target
|
11
.github/dependabot.yml
vendored
11
.github/dependabot.yml
vendored
|
@ -1,11 +0,0 @@
|
||||||
# To get started with Dependabot version updates, you'll need to specify which
|
|
||||||
# package ecosystems to update and where the package manifests are located.
|
|
||||||
# Please see the documentation for all configuration options:
|
|
||||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
||||||
|
|
||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "maven" # See documentation for possible values
|
|
||||||
directory: "/" # Location of package manifests
|
|
||||||
schedule:
|
|
||||||
interval: "daily"
|
|
|
@ -1,7 +1,6 @@
|
||||||
# McThemeParks Audio
|
# ThemePark Audio Plugin
|
||||||
|
|
||||||
This repository contains the official audio plugin of McThemeParks.
|
The ThemePark Audio Plugin is a plugin for your for ThemePark Minecraft server that allows you to play audio files and control the lights of players from in the server.
|
||||||
This plugin contains all the audio functions for the server.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
34
pom.xml
34
pom.xml
|
@ -4,18 +4,18 @@
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>me.mctp</groupId>
|
<groupId>tech.sbdevelopment</groupId>
|
||||||
<artifactId>MCTPAudio</artifactId>
|
<artifactId>ThemeParkAudio</artifactId>
|
||||||
<version>1.5-SNAPSHOT</version>
|
<version>1.6</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>MCTPAudio</name>
|
<name>ThemeParkAudio</name>
|
||||||
|
|
||||||
<description>The audio plugin of McThemeParks!</description>
|
<description>Audio and light control via your Minecraft server!</description>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<url>https://mcthemeparks.com</url>
|
<url>https://sbdevelopment.tech/</url>
|
||||||
|
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
<pluginRepository>
|
<pluginRepository>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.13.0</version>
|
<version>3.14.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<release>21</release>
|
<release>21</release>
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
|
@ -61,11 +61,11 @@
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>co.aikar.commands</pattern>
|
<pattern>co.aikar.commands</pattern>
|
||||||
<shadedPattern>nl.sbdeveloper.mctpaudio.libs.acf</shadedPattern>
|
<shadedPattern>tech.sbdevelopment.ThemeParkAudio.libs.acf</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>co.aikar.locales</pattern>
|
<pattern>co.aikar.locales</pattern>
|
||||||
<shadedPattern>nl.sbdeveloper.mctpaudio.libs.locales</shadedPattern>
|
<shadedPattern>tech.sbdevelopment.ThemeParkAudio.libs.locales</shadedPattern>
|
||||||
</relocation>
|
</relocation>
|
||||||
</relocations>
|
</relocations>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -104,19 +104,19 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.21.1-R0.1-SNAPSHOT</version>
|
<version>1.21.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.21.1-R0.1-SNAPSHOT</version>
|
<version>1.21.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.java-websocket</groupId>
|
<groupId>org.java-websocket</groupId>
|
||||||
<artifactId>Java-WebSocket</artifactId>
|
<artifactId>Java-WebSocket</artifactId>
|
||||||
<version>1.5.7</version>
|
<version>1.6.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mpatric</groupId>
|
<groupId>com.mpatric</groupId>
|
||||||
|
@ -144,13 +144,19 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.bergerkiller.bukkit</groupId>
|
<groupId>com.bergerkiller.bukkit</groupId>
|
||||||
<artifactId>BKCommonLib</artifactId>
|
<artifactId>BKCommonLib</artifactId>
|
||||||
<version>1.21.1-v1</version>
|
<version>1.21.4-v1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.bergerkiller.bukkit</groupId>
|
<groupId>com.bergerkiller.bukkit</groupId>
|
||||||
<artifactId>TrainCarts</artifactId>
|
<artifactId>TrainCarts</artifactId>
|
||||||
<version>1.21.1-v1</version>
|
<version>1.21.4-v1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.38</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package nl.sbdeveloper.mctpaudio;
|
package nl.sbdeveloper.mctpaudio;
|
||||||
|
|
||||||
import co.aikar.commands.PaperCommandManager;
|
import co.aikar.commands.PaperCommandManager;
|
||||||
import nl.sbdeveloper.mctpaudio.commands.MCTPAudioCMD;
|
import lombok.Getter;
|
||||||
|
import nl.sbdeveloper.mctpaudio.commands.TPAudioCMD;
|
||||||
import nl.sbdeveloper.mctpaudio.listener.LogoutListener;
|
import nl.sbdeveloper.mctpaudio.listener.LogoutListener;
|
||||||
import nl.sbdeveloper.mctpaudio.listener.WGListener;
|
import nl.sbdeveloper.mctpaudio.listener.WGListener;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
||||||
|
@ -11,59 +12,56 @@ import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
public final class ThemeParkAudio extends JavaPlugin {
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
@Getter
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public final class MCTPAudio extends JavaPlugin {
|
|
||||||
private static Plugin instance;
|
private static Plugin instance;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static PaperCommandManager commandManager;
|
private static PaperCommandManager commandManager;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static Client client;
|
private static Client client;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private static Playlist playlist;
|
private static Playlist playlist;
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Bukkit.getLogger().info("[MCTPAudio] Loading...");
|
Bukkit.getLogger().info("[ThemeParkAudio] Loading...");
|
||||||
|
|
||||||
if (!setupPlugins()) {
|
if (!setupPlugins()) {
|
||||||
Bukkit.getLogger().severe("[MCTPAudio] WorldGuard not found! Disabling...");
|
Bukkit.getLogger().severe("[ThemeParkAudio] WorldGuard not found! Disabling...");
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
getConfig().addDefault("Regions.demosound", "https://www.mcthemeparks.com/musicupload/downloads/Berlin/kaad.mp3");
|
|
||||||
getConfig().addDefault("HueRegions.demosound", "255_0_0_254");
|
|
||||||
getConfig().options().copyDefaults(true);
|
getConfig().options().copyDefaults(true);
|
||||||
saveConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
Bukkit.getLogger().info("[MCTPAudio] Connecting with socket...");
|
Bukkit.getLogger().info("[ThemeParkAudio] Connecting with socket...");
|
||||||
client = new Client("ws://116.203.56.13:25564");
|
client = new Client(getConfig().getString("socketUrl"));
|
||||||
client.connect();
|
client.connect();
|
||||||
|
|
||||||
Bukkit.getLogger().info("[MCTPAudio] Loading commands and events...");
|
Bukkit.getLogger().info("[ThemeParkAudio] Loading commands and events...");
|
||||||
commandManager = new PaperCommandManager(this);
|
commandManager = new PaperCommandManager(this);
|
||||||
commandManager.enableUnstableAPI("help");
|
commandManager.enableUnstableAPI("help");
|
||||||
|
|
||||||
commandManager.registerCommand(new MCTPAudioCMD());
|
commandManager.registerCommand(new TPAudioCMD());
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new WGListener(), this);
|
Bukkit.getPluginManager().registerEvents(new WGListener(), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new LogoutListener(), this);
|
Bukkit.getPluginManager().registerEvents(new LogoutListener(), this);
|
||||||
|
|
||||||
Bukkit.getLogger().info("[MCTPAudio] Loading playlist...");
|
Bukkit.getLogger().info("[ThemeParkAudio] Loading playlist...");
|
||||||
playlist = new Playlist();
|
playlist = new Playlist();
|
||||||
|
|
||||||
Bukkit.getLogger().info("[MCTPAudio] Plugin is enabled!");
|
Bukkit.getLogger().info("[ThemeParkAudio] Plugin is enabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
instance = null;
|
instance = null;
|
||||||
Bukkit.getLogger().info("[MCTPAudio] Plugin is disabled!");
|
Bukkit.getLogger().info("[ThemeParkAudio] Plugin is disabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupPlugins() {
|
private boolean setupPlugins() {
|
||||||
|
@ -73,20 +71,4 @@ public final class MCTPAudio extends JavaPlugin {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Plugin getPlugin() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Client getClient() {
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Playlist getPlaylist() {
|
|
||||||
return playlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PaperCommandManager getCommandManager() {
|
|
||||||
return commandManager;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,11 +1,15 @@
|
||||||
package nl.sbdeveloper.mctpaudio.api;
|
package nl.sbdeveloper.mctpaudio.api;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
import nl.sbdeveloper.mctpaudio.socket.messages.MessageTask;
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public enum AudioType {
|
public enum AudioType {
|
||||||
MUSIC, SFX, RADIO
|
MUSIC, SFX, RADIO;
|
||||||
|
|
||||||
|
public MessageTask toMessageTask() {
|
||||||
|
return switch (this) {
|
||||||
|
case MUSIC -> MessageTask.MUSIC;
|
||||||
|
case SFX -> MessageTask.SFX;
|
||||||
|
case RADIO -> MessageTask.RADIO;
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package nl.sbdeveloper.mctpaudio.api;
|
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public enum HueType {
|
|
||||||
LEFT, MID, RIGHT, ALL
|
|
||||||
}
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
package nl.sbdeveloper.mctpaudio.api;
|
||||||
|
|
||||||
|
public enum LightRegion {
|
||||||
|
LEFT, MID, RIGHT, ALL
|
||||||
|
}
|
|
@ -1,20 +1,17 @@
|
||||||
package nl.sbdeveloper.mctpaudio.api.events;
|
package nl.sbdeveloper.mctpaudio.api.events;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class AudioConnectionUpdateEvent extends Event implements Cancellable {
|
public class AudioConnectionUpdateEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@Getter
|
||||||
private final Player player;
|
private final Player player;
|
||||||
|
@Getter
|
||||||
private final boolean connected;
|
private final boolean connected;
|
||||||
|
|
||||||
private boolean cancelled = false;
|
private boolean cancelled = false;
|
||||||
|
@ -25,14 +22,6 @@ public class AudioConnectionUpdateEvent extends Event implements Cancellable {
|
||||||
this.connected = connected;
|
this.connected = connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isConnected() {
|
|
||||||
return connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
|
|
|
@ -3,12 +3,6 @@ package nl.sbdeveloper.mctpaudio.api.maps;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link ArrayList} with shuffle support.
|
* An {@link ArrayList} with shuffle support.
|
||||||
*
|
*
|
||||||
|
@ -34,7 +28,7 @@ public class SongList<E> extends ArrayList<E> {
|
||||||
*/
|
*/
|
||||||
public E getRandom() {
|
public E getRandom() {
|
||||||
int size = size();
|
int size = size();
|
||||||
if (size <= 0) return null;
|
if (size == 0) return null;
|
||||||
return get(r.nextInt(size()));
|
return get(r.nextInt(size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ package nl.sbdeveloper.mctpaudio.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 nl.sbdeveloper.mctpaudio.MCTPAudio;
|
import nl.sbdeveloper.mctpaudio.ThemeParkAudio;
|
||||||
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
||||||
import nl.sbdeveloper.mctpaudio.api.HueType;
|
import nl.sbdeveloper.mctpaudio.api.LightRegion;
|
||||||
import nl.sbdeveloper.mctpaudio.listener.PlayInRegionHandler;
|
import nl.sbdeveloper.mctpaudio.listener.PlayInRegionHandler;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
||||||
import nl.sbdeveloper.mctpaudio.utils.HeadUtil;
|
import nl.sbdeveloper.mctpaudio.utils.HeadUtil;
|
||||||
|
@ -21,15 +21,9 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
@CommandAlias("tpaudio")
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
@CommandPermission("tpa.cmd")
|
||||||
* Proprietary and confidential
|
public class TPAudioCMD extends BaseCommand {
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
@CommandAlias("mctpaudio")
|
|
||||||
@CommandPermission("mctp.audio")
|
|
||||||
public class MCTPAudioCMD extends BaseCommand {
|
|
||||||
@Default
|
@Default
|
||||||
@HelpCommand
|
@HelpCommand
|
||||||
public void onHelp(CommandSender sender, CommandHelp help) {
|
public void onHelp(CommandSender sender, CommandHelp help) {
|
||||||
|
@ -39,30 +33,30 @@ public class MCTPAudioCMD extends BaseCommand {
|
||||||
@Subcommand("toggleradio")
|
@Subcommand("toggleradio")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void toggleRadio(CommandSender sender) {
|
public void toggleRadio(CommandSender sender) {
|
||||||
if (MCTPAudio.getPlaylist().isRunning()) {
|
if (ThemeParkAudio.getPlaylist().isRunning()) {
|
||||||
MCTPAudio.getPlaylist().stop();
|
ThemeParkAudio.getPlaylist().stop();
|
||||||
sender.sendMessage(ChatColor.GRAY + "De auto radio is stopgezet. Zodra het huidige nummer is afgelopen, gebeurt er niks meer.");
|
sender.sendMessage(ChatColor.GRAY + "De automatische radio is stopgezet. Zodra het huidige nummer is afgelopen, gebeurt er niks meer.");
|
||||||
} else {
|
} else {
|
||||||
MCTPAudio.getPlaylist().start();
|
ThemeParkAudio.getPlaylist().start();
|
||||||
sender.sendMessage(ChatColor.GRAY + "De auto radio is weer gestart.");
|
sender.sendMessage(ChatColor.GRAY + "De automatische radio is weer gestart.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("addsong")
|
@Subcommand("addsong")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void onAddSong(CommandSender sender, String url) {
|
public void onAddSong(CommandSender sender, String url) {
|
||||||
List<String> urls = MCTPAudio.getPlugin().getConfig().getStringList("RadioSongs");
|
List<String> urls = ThemeParkAudio.getPlugin().getConfig().getStringList("radioSongs");
|
||||||
urls.add(url);
|
urls.add(url);
|
||||||
MCTPAudio.getPlugin().getConfig().set("RadioSongs", urls);
|
ThemeParkAudio.getPlugin().getConfig().set("radioSongs", urls);
|
||||||
MCTPAudio.getPlugin().saveConfig();
|
ThemeParkAudio.getPlugin().saveConfig();
|
||||||
MCTPAudio.getPlaylist().addSong(url);
|
ThemeParkAudio.getPlaylist().addSong(url);
|
||||||
sender.sendMessage(ChatColor.GRAY + "Nummer toegevoegd aan de lijst.");
|
sender.sendMessage(ChatColor.GRAY + "Nummer toegevoegd aan de automatische radio.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("play")
|
@Subcommand("play")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void onPlay(CommandSender sender, String selector, AudioType type, String url) {
|
public void onPlay(CommandSender sender, String selector, AudioType type, String url) {
|
||||||
ArrayList<Player> players = new ArrayList<>();
|
List<Player> players = new ArrayList<>();
|
||||||
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())) {
|
||||||
|
@ -94,21 +88,21 @@ public class MCTPAudioCMD extends BaseCommand {
|
||||||
data.put("task", type.name());
|
data.put("task", type.name());
|
||||||
data.put("path", url);
|
data.put("path", url);
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
||||||
MCTPAudio.getClient().sendData(data);
|
ThemeParkAudio.getClient().sendData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "Gestart met afspelen!");
|
sender.sendMessage(ChatColor.GRAY + "Gestart met afspelen!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("hue")
|
@Subcommand("light")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void onHue(CommandSender sender, String selector, int r, int g, int b, HueType type, @Optional 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 != null && (brightness < 0 || brightness > 254)) {
|
if (brightness < 0 || brightness > 255) {
|
||||||
sender.sendMessage(ChatColor.GRAY.toString() + brightness + " is geen correcte brightness.");
|
sender.sendMessage(ChatColor.GRAY.toString() + brightness + " is geen geldige brightness.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Player> players = new ArrayList<>();
|
List<Player> players = new ArrayList<>();
|
||||||
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())) {
|
||||||
|
@ -125,11 +119,10 @@ public class MCTPAudioCMD extends BaseCommand {
|
||||||
//CHECK FOR THE REGION SELECTOR -> Then save
|
//CHECK FOR THE REGION SELECTOR -> Then save
|
||||||
if (selector.startsWith("@a") && HeadUtil.getArgument(selector, "region").length() != 0) {
|
if (selector.startsWith("@a") && HeadUtil.getArgument(selector, "region").length() != 0) {
|
||||||
String regionID = HeadUtil.getArgument(selector, "region");
|
String regionID = HeadUtil.getArgument(selector, "region");
|
||||||
String data = r + "_" + g + "_" + b + "_" + type.name();
|
String data = brightness + "_" + r + "_" + g + "_" + b + "_" + w + "_" + region.name();
|
||||||
if (brightness != null) data += "_" + brightness;
|
|
||||||
|
|
||||||
MCTPAudio.getPlugin().getConfig().set("HueRegions." + regionID, data);
|
ThemeParkAudio.getPlugin().getConfig().set("regions.light." + regionID, data);
|
||||||
MCTPAudio.getPlugin().saveConfig();
|
ThemeParkAudio.getPlugin().saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject data;
|
JSONObject data;
|
||||||
|
@ -138,39 +131,39 @@ public class MCTPAudioCMD extends BaseCommand {
|
||||||
|
|
||||||
if (!PinManager.hasPin(p.getUniqueId())) continue;
|
if (!PinManager.hasPin(p.getUniqueId())) continue;
|
||||||
|
|
||||||
data.put("task", "HUE");
|
data.put("task", "LIGHT");
|
||||||
data.put("rgb", r + ":" + g + ":" + b);
|
data.put("rgbw", r + ":" + g + ":" + b + ":" + w);
|
||||||
data.put("type", type.name());
|
data.put("region", region.name());
|
||||||
if (brightness != null) data.put("brightness", brightness);
|
data.put("brightness", brightness);
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
||||||
MCTPAudio.getClient().sendData(data);
|
ThemeParkAudio.getClient().sendData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "Indien de speler(s) is/zijn verbonden met Philips Hue, is de kleur veranderd.");
|
sender.sendMessage(ChatColor.GRAY + "Kleuren aangepast!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("setregion")
|
@Subcommand("setregion")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void onSetRegion(CommandSender sender, String regionName, String url) {
|
public void onSetRegion(CommandSender sender, String regionName, String url) {
|
||||||
MCTPAudio.getPlugin().getConfig().set("Regions." + regionName, url);
|
ThemeParkAudio.getPlugin().getConfig().set("regions.audio." + regionName, url);
|
||||||
MCTPAudio.getPlugin().saveConfig();
|
ThemeParkAudio.getPlugin().saveConfig();
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "De region zal vanaf nu muziek afspelen.");
|
sender.sendMessage(ChatColor.GRAY + "De region zal vanaf nu muziek afspelen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Subcommand("sethueregion")
|
@Subcommand("sethueregion")
|
||||||
// @Description("")
|
@Description("")
|
||||||
// public void onSetHueRegion(CommandSender sender, String regionName, String url) {
|
public void onSetHueRegion(CommandSender sender, String regionName, String url) {
|
||||||
// MCTPAudio.getPlugin().getConfig().set("HueRegions." + regionName, url);
|
ThemeParkAudio.getPlugin().getConfig().set("regions.light." + regionName, url);
|
||||||
// MCTPAudio.getPlugin().saveConfig();
|
ThemeParkAudio.getPlugin().saveConfig();
|
||||||
//
|
|
||||||
// sender.sendMessage(ChatColor.GRAY + "De region zal vanaf nu licht aanpassen.");
|
sender.sendMessage(ChatColor.GRAY + "De region zal vanaf nu licht aanpassen.");
|
||||||
// }
|
}
|
||||||
|
|
||||||
@Subcommand("stop")
|
@Subcommand("stop")
|
||||||
@Description("")
|
@Description("")
|
||||||
public void onStop(CommandSender sender, String selector) {
|
public void onStop(CommandSender sender, String selector) {
|
||||||
ArrayList<Player> players = new ArrayList<>();
|
List<Player> players = new ArrayList<>();
|
||||||
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())) {
|
||||||
|
@ -192,7 +185,7 @@ public class MCTPAudioCMD extends BaseCommand {
|
||||||
|
|
||||||
data.put("task", "STOP");
|
data.put("task", "STOP");
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
||||||
MCTPAudio.getClient().sendData(data);
|
ThemeParkAudio.getClient().sendData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "Gestopt met afspelen!");
|
sender.sendMessage(ChatColor.GRAY + "Gestopt met afspelen!");
|
|
@ -1,23 +1,17 @@
|
||||||
package nl.sbdeveloper.mctpaudio.listener;
|
package nl.sbdeveloper.mctpaudio.listener;
|
||||||
|
|
||||||
import nl.sbdeveloper.mctpaudio.MCTPAudio;
|
import nl.sbdeveloper.mctpaudio.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 org.json.simple.JSONObject;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
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();
|
JSONObject data = new JSONObject();
|
||||||
data.put("task", "LOGOUT");
|
data.put("task", "LOGOUT");
|
||||||
data.put("uuid", e.getPlayer().getUniqueId().toString().replace("-", ""));
|
data.put("uuid", e.getPlayer().getUniqueId().toString().replace("-", ""));
|
||||||
MCTPAudio.getClient().sendData(data);
|
ThemeParkAudio.getClient().sendData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,30 +5,23 @@ import com.mpatric.mp3agic.UnsupportedTagException;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import net.raidstone.wgevents.events.RegionEnteredEvent;
|
import net.raidstone.wgevents.events.RegionEnteredEvent;
|
||||||
import net.raidstone.wgevents.events.RegionLeftEvent;
|
import net.raidstone.wgevents.events.RegionLeftEvent;
|
||||||
import nl.sbdeveloper.mctpaudio.MCTPAudio;
|
import nl.sbdeveloper.mctpaudio.ThemeParkAudio;
|
||||||
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
||||||
import nl.sbdeveloper.mctpaudio.api.events.AudioConnectionUpdateEvent;
|
import nl.sbdeveloper.mctpaudio.api.events.AudioConnectionUpdateEvent;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
||||||
|
import nl.sbdeveloper.mctpaudio.socket.messages.AudioMessage;
|
||||||
import nl.sbdeveloper.mctpaudio.utils.HeadUtil;
|
import nl.sbdeveloper.mctpaudio.utils.HeadUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class handles playing numbers in a region.
|
* This class handles playing numbers in a region.
|
||||||
* This will NOT be used for region much, only if you start playing music in a region with the @a[region=...] selector.
|
* This will NOT be used for region much, only if you start playing music in a region with the @a[region=...] selector.
|
||||||
|
@ -47,7 +40,7 @@ public class PlayInRegionHandler implements Listener {
|
||||||
this.players = players;
|
this.players = players;
|
||||||
|
|
||||||
load();
|
load();
|
||||||
Bukkit.getPluginManager().registerEvents(this, MCTPAudio.getPlugin());
|
Bukkit.getPluginManager().registerEvents(this, ThemeParkAudio.getPlugin());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,34 +64,9 @@ public class PlayInRegionHandler implements Listener {
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(MCTPAudio.getPlugin(), 0L, 1L);
|
}.runTaskTimer(ThemeParkAudio.getPlugin(), 0L, 1L);
|
||||||
|
|
||||||
Player p;
|
AudioMessage.of(AudioType.SFX, url, true).send(players, PinManager::hasPin);
|
||||||
JSONObject data;
|
|
||||||
Iterator<UUID> uuidS = players.iterator();
|
|
||||||
while (uuidS.hasNext()) {
|
|
||||||
p = Bukkit.getPlayer(uuidS.next());
|
|
||||||
if (p == null || !PinManager.hasPin(p.getUniqueId())) {
|
|
||||||
uuidS.remove();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
data = new JSONObject();
|
|
||||||
data.put("task", AudioType.SFX.name());
|
|
||||||
data.put("path", url);
|
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
|
||||||
data.put("play", false);
|
|
||||||
MCTPAudio.getClient().sendData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
startForAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the song for every player.
|
|
||||||
*/
|
|
||||||
private void startForAll() {
|
|
||||||
players.forEach(this::start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void start(UUID pUUID) {
|
private void start(UUID pUUID) {
|
||||||
|
@ -109,20 +77,14 @@ public class PlayInRegionHandler implements Listener {
|
||||||
* Starts the song for a Player.
|
* Starts the song for a Player.
|
||||||
* @param pUUID The player to start it for.
|
* @param pUUID The player to start it for.
|
||||||
*/
|
*/
|
||||||
private void start(UUID pUUID, int ms) {
|
private void start(UUID pUUID, int tick) {
|
||||||
if (!isListening) return;
|
if (!isListening) return;
|
||||||
|
|
||||||
Player p = Bukkit.getPlayer(pUUID);
|
Player p = Bukkit.getPlayer(pUUID);
|
||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
if (!PinManager.hasPin(p.getUniqueId())) return;
|
if (!PinManager.hasPin(p.getUniqueId())) return;
|
||||||
|
|
||||||
JSONObject data = new JSONObject();
|
AudioMessage.of(AudioType.SFX, url, true, tick * 50).send(pUUID);
|
||||||
data.put("task", AudioType.SFX.name());
|
|
||||||
data.put("path", url);
|
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
|
||||||
data.put("play", true);
|
|
||||||
data.put("at", ms);
|
|
||||||
MCTPAudio.getClient().sendData(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,12 +98,7 @@ public class PlayInRegionHandler implements Listener {
|
||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
if (!PinManager.hasPin(p.getUniqueId())) return;
|
if (!PinManager.hasPin(p.getUniqueId())) return;
|
||||||
|
|
||||||
JSONObject data = new JSONObject();
|
AudioMessage.of(AudioType.SFX, url, false).send(pUUID);
|
||||||
data.put("task", AudioType.SFX.name());
|
|
||||||
data.put("path", url);
|
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
|
||||||
data.put("play", false);
|
|
||||||
MCTPAudio.getClient().sendData(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -151,7 +108,7 @@ public class PlayInRegionHandler implements Listener {
|
||||||
if (e.getRegionName().equals(region)) {
|
if (e.getRegionName().equals(region)) {
|
||||||
if (!players.contains(e.getPlayer().getUniqueId())) {
|
if (!players.contains(e.getPlayer().getUniqueId())) {
|
||||||
players.add(e.getPlayer().getUniqueId());
|
players.add(e.getPlayer().getUniqueId());
|
||||||
start(e.getPlayer().getUniqueId(), getMs());
|
start(e.getPlayer().getUniqueId(), currentTick);
|
||||||
} else {
|
} else {
|
||||||
start(e.getPlayer().getUniqueId());
|
start(e.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
|
@ -175,7 +132,7 @@ public class PlayInRegionHandler implements Listener {
|
||||||
if (regionsIn.stream().anyMatch(reg -> reg.getId().equals(region))) {
|
if (regionsIn.stream().anyMatch(reg -> reg.getId().equals(region))) {
|
||||||
players.add(e.getPlayer().getUniqueId());
|
players.add(e.getPlayer().getUniqueId());
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
start(e.getPlayer().getUniqueId(), getMs());
|
start(e.getPlayer().getUniqueId(), currentTick);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!players.contains(e.getPlayer().getUniqueId())) return;
|
if (!players.contains(e.getPlayer().getUniqueId())) return;
|
||||||
|
@ -183,8 +140,4 @@ public class PlayInRegionHandler implements Listener {
|
||||||
players.remove(e.getPlayer().getUniqueId());
|
players.remove(e.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMs() {
|
|
||||||
return Math.round(currentTick * 50);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,13 @@ import com.bergerkiller.bukkit.tc.controller.MinecartMember;
|
||||||
import com.bergerkiller.bukkit.tc.controller.MinecartMemberStore;
|
import com.bergerkiller.bukkit.tc.controller.MinecartMemberStore;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import net.raidstone.wgevents.events.RegionsEnteredEvent;
|
import net.raidstone.wgevents.events.RegionsEnteredEvent;
|
||||||
import nl.sbdeveloper.mctpaudio.MCTPAudio;
|
import nl.sbdeveloper.mctpaudio.ThemeParkAudio;
|
||||||
|
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
||||||
import org.bukkit.Bukkit;
|
import nl.sbdeveloper.mctpaudio.socket.messages.AudioMessage;
|
||||||
|
import nl.sbdeveloper.mctpaudio.socket.messages.LightMessage;
|
||||||
|
import nl.sbdeveloper.mctpaudio.socket.messages.StopAudioMessage;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -19,16 +22,8 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class WGListener implements Listener {
|
public class WGListener implements Listener {
|
||||||
/**
|
/**
|
||||||
|
@ -64,10 +59,10 @@ public class WGListener implements Listener {
|
||||||
if (from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ()) {
|
if (from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ()) {
|
||||||
if (!PinManager.hasPin(player.getUniqueId())) return;
|
if (!PinManager.hasPin(player.getUniqueId())) return;
|
||||||
|
|
||||||
Set<String> list = MCTPAudio.getPlugin().getConfig().getConfigurationSection("Regions").getKeys(false);
|
Set<String> list = ThemeParkAudio.getPlugin().getConfig().getConfigurationSection("regions.audio").getKeys(false);
|
||||||
|
|
||||||
List<String> fromRegions = WGManager.getRegionsIn(from).stream().map(ProtectedRegion::getId).collect(Collectors.toList());
|
List<String> fromRegions = WGManager.getRegionsIn(from).stream().map(ProtectedRegion::getId).toList();
|
||||||
List<String> toRegions = WGManager.getRegionsIn(to).stream().map(ProtectedRegion::getId).collect(Collectors.toList());
|
List<String> toRegions = WGManager.getRegionsIn(to).stream().map(ProtectedRegion::getId).toList();
|
||||||
|
|
||||||
if ((Collections.disjoint(list, fromRegions) && !Collections.disjoint(list, toRegions)) || (!Collections.disjoint(list, fromRegions) && !Collections.disjoint(list, toRegions))) {
|
if ((Collections.disjoint(list, fromRegions) && !Collections.disjoint(list, toRegions)) || (!Collections.disjoint(list, fromRegions) && !Collections.disjoint(list, toRegions))) {
|
||||||
//Walked in a region
|
//Walked in a region
|
||||||
|
@ -91,8 +86,8 @@ public class WGListener implements Listener {
|
||||||
return; //Beide heeft een region, en dat is dezelfde.
|
return; //Beide heeft een region, en dat is dezelfde.
|
||||||
|
|
||||||
if (name.isPresent() && name2.isPresent()) {
|
if (name.isPresent() && name2.isPresent()) {
|
||||||
String regionURL = MCTPAudio.getPlugin().getConfig().getString("Regions." + name.get());
|
String regionURL = ThemeParkAudio.getPlugin().getConfig().getString("regions.audio." + name.get());
|
||||||
String regionURL2 = MCTPAudio.getPlugin().getConfig().getString("Regions." + name2.get());
|
String regionURL2 = ThemeParkAudio.getPlugin().getConfig().getString("regions.audio." + name2.get());
|
||||||
|
|
||||||
if (regionURL.equals(regionURL2))
|
if (regionURL.equals(regionURL2))
|
||||||
return; //Beide heeft een region, niet dezelfde, maar wel met dezelfde muziek.
|
return; //Beide heeft een region, niet dezelfde, maar wel met dezelfde muziek.
|
||||||
|
@ -100,21 +95,13 @@ public class WGListener implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<String> name = toRegions.stream().filter(list::contains).findFirst();
|
Optional<String> name = toRegions.stream().filter(list::contains).findFirst();
|
||||||
if (!name.isPresent()) return;
|
if (name.isEmpty()) return;
|
||||||
String regionURL = MCTPAudio.getPlugin().getConfig().getString("Regions." + name.get());
|
String regionURL = ThemeParkAudio.getPlugin().getConfig().getString("regions.audio." + name.get());
|
||||||
|
|
||||||
JSONObject data = new JSONObject();
|
AudioMessage.of(AudioType.MUSIC, regionURL).send(player.getUniqueId());
|
||||||
data.put("task", "MUSIC");
|
|
||||||
data.put("path", regionURL);
|
|
||||||
data.put("uuid", player.getUniqueId().toString().replace("-", ""));
|
|
||||||
MCTPAudio.getClient().sendData(data);
|
|
||||||
} 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...
|
||||||
JSONObject data = new JSONObject();
|
StopAudioMessage.of(AudioType.MUSIC).send(player.getUniqueId());
|
||||||
data.put("task", "MUSIC");
|
|
||||||
data.put("path", "");
|
|
||||||
data.put("uuid", player.getUniqueId().toString().replace("-", ""));
|
|
||||||
MCTPAudio.getClient().sendData(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,34 +113,18 @@ public class WGListener implements Listener {
|
||||||
public void onRegionEnter(RegionsEnteredEvent e) {
|
public void onRegionEnter(RegionsEnteredEvent e) {
|
||||||
if (e.getPlayer() == null) return;
|
if (e.getPlayer() == null) return;
|
||||||
|
|
||||||
Set<String> list2 = MCTPAudio.getPlugin().getConfig().getConfigurationSection("HueRegions").getKeys(false);
|
Set<String> list2 = ThemeParkAudio.getPlugin().getConfig().getConfigurationSection("regions.light").getKeys(false);
|
||||||
|
|
||||||
if (!Collections.disjoint(list2, e.getRegionsNames())) {
|
if (!Collections.disjoint(list2, e.getRegionsNames())) {
|
||||||
//One element is the same -> In a region
|
//One element is the same -> In a region
|
||||||
|
|
||||||
Optional<String> name = e.getRegionsNames().stream().filter(list2::contains).findFirst();
|
Optional<String> name = e.getRegionsNames().stream().filter(list2::contains).findFirst();
|
||||||
if (!name.isPresent()) return;
|
if (name.isEmpty()) return;
|
||||||
String configData = MCTPAudio.getPlugin().getConfig().getString("HueRegions." + name.get());
|
String configData = ThemeParkAudio.getPlugin().getConfig().getString("regions.light." + name.get());
|
||||||
|
|
||||||
if (configData == null) return;
|
if (configData != null) {
|
||||||
String[] configDataSplit = configData.split("_");
|
LightMessage.of(configData).send(e.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
int r = Integer.parseInt(configDataSplit[0]);
|
|
||||||
int g = Integer.parseInt(configDataSplit[1]);
|
|
||||||
int b = Integer.parseInt(configDataSplit[2]);
|
|
||||||
String type = configDataSplit[3];
|
|
||||||
Integer brightness = null;
|
|
||||||
if (configDataSplit.length == 5) brightness = Integer.parseInt(configDataSplit[4]);
|
|
||||||
|
|
||||||
if (!PinManager.hasPin(e.getPlayer().getUniqueId())) return;
|
|
||||||
|
|
||||||
JSONObject data = new JSONObject();
|
|
||||||
data.put("task", "HUE");
|
|
||||||
data.put("rgb", r + ":" + g + ":" + b);
|
|
||||||
data.put("type", type);
|
|
||||||
if (brightness != null) data.put("brightness", brightness);
|
|
||||||
data.put("uuid", e.getPlayer().getUniqueId().toString().replace("-", ""));
|
|
||||||
MCTPAudio.getClient().sendData(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
package nl.sbdeveloper.mctpaudio.managers;
|
package nl.sbdeveloper.mctpaudio.managers;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PinManager {
|
public class PinManager {
|
||||||
private static final WeakHashMap<UUID, String> pins = new WeakHashMap<>();
|
private static final WeakHashMap<UUID, String> pins = new WeakHashMap<>();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
@ -32,24 +33,19 @@ import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WorldGuard class to make the usage of WorldGuard easy. This is the 1.14.x version!
|
* WorldGuard class to make the usage of WorldGuard easy. This is the 1.14.x version!
|
||||||
*
|
* <br>
|
||||||
* <i>Note that if you do use this in one of your projects, leave this notice.</i>
|
* <i>Note that if you do use this in one of your projects, leave this notice.</i>
|
||||||
* <i>Please do credit me if you do use this in one of your projects.</i>
|
* <i>Please do credit me if you do use this in one of your projects.</i>
|
||||||
*
|
*
|
||||||
* @author SBDeveloper [Fixed 1.13+ support]
|
* @author SBDeveloper [Fixed 1.13+ support]
|
||||||
*/
|
*/
|
||||||
public class WGManager {
|
|
||||||
|
|
||||||
public static WorldGuardPlugin wgp;
|
@UtilityClass
|
||||||
public static WorldEditPlugin wep;
|
public class WGManager {
|
||||||
|
private static WorldGuardPlugin wgp;
|
||||||
|
private static WorldEditPlugin wep;
|
||||||
|
|
||||||
public static boolean hasWorldGuard() {
|
public static boolean hasWorldGuard() {
|
||||||
return wgp != null;
|
return wgp != null;
|
||||||
|
|
|
@ -2,30 +2,25 @@ package nl.sbdeveloper.mctpaudio.radio;
|
||||||
|
|
||||||
import com.mpatric.mp3agic.InvalidDataException;
|
import com.mpatric.mp3agic.InvalidDataException;
|
||||||
import com.mpatric.mp3agic.UnsupportedTagException;
|
import com.mpatric.mp3agic.UnsupportedTagException;
|
||||||
import nl.sbdeveloper.mctpaudio.MCTPAudio;
|
import lombok.Getter;
|
||||||
|
import nl.sbdeveloper.mctpaudio.ThemeParkAudio;
|
||||||
|
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
||||||
import nl.sbdeveloper.mctpaudio.api.maps.SongList;
|
import nl.sbdeveloper.mctpaudio.api.maps.SongList;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
||||||
|
import nl.sbdeveloper.mctpaudio.socket.messages.AudioMessage;
|
||||||
import nl.sbdeveloper.mctpaudio.utils.HeadUtil;
|
import nl.sbdeveloper.mctpaudio.utils.HeadUtil;
|
||||||
import nl.sbdeveloper.mctpaudio.utils.MainUtil;
|
import nl.sbdeveloper.mctpaudio.utils.DiscordUtil;
|
||||||
import nl.sbdeveloper.mctpaudio.utils.WebhookMessage;
|
import nl.sbdeveloper.mctpaudio.utils.WebhookMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class Playlist {
|
public class Playlist {
|
||||||
private final SongList<String> playList = new SongList<>();
|
private final SongList<String> playList = new SongList<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
private BukkitTask currentTimer;
|
private BukkitTask currentTimer;
|
||||||
private int faultCounter = 0;
|
private int faultCounter = 0;
|
||||||
|
@ -42,11 +37,11 @@ public class Playlist {
|
||||||
* Start this playlist
|
* Start this playlist
|
||||||
*/
|
*/
|
||||||
public void start() {
|
public void start() {
|
||||||
for (String URL : MCTPAudio.getPlugin().getConfig().getStringList("RadioSongs")) {
|
for (String URL : ThemeParkAudio.getPlugin().getConfig().getStringList("RadioSongs")) {
|
||||||
addSong(URL);
|
addSong(URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(MCTPAudio.getPlugin(), this::nextSong);
|
Bukkit.getScheduler().runTaskAsynchronously(ThemeParkAudio.getPlugin(), this::nextSong);
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +77,7 @@ public class Playlist {
|
||||||
if (currentTimer != null) return; //A song is playing?
|
if (currentTimer != null) return; //A song is playing?
|
||||||
|
|
||||||
if (faultCounter > 4) {
|
if (faultCounter > 4) {
|
||||||
MCTPAudio.getPlugin(MCTPAudio.class).getLogger().severe("Detected to many IO errors! Stopping the radio...");
|
ThemeParkAudio.getPlugin(ThemeParkAudio.class).getLogger().severe("Detected to many IO errors! Stopping the radio...");
|
||||||
stop(); //FALLBACK! 4 errors occured.
|
stop(); //FALLBACK! 4 errors occured.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +107,7 @@ public class Playlist {
|
||||||
embed.setDescription("A song in the radio does not have MPEG headers. A song without headers cannot be played in the radio because the length cannot be determined. Please fix as soon as possible.\n\nClick on the title to go to the song.");
|
embed.setDescription("A song in the radio does not have MPEG headers. A song without headers cannot be played in the radio because the length cannot be determined. Please fix as soon as possible.\n\nClick on the title to go to the song.");
|
||||||
embed.setUrl(nextURL);
|
embed.setUrl(nextURL);
|
||||||
try {
|
try {
|
||||||
MainUtil.sendMessageDiscord(embed);
|
DiscordUtil.sendMessageDiscord(embed);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +126,7 @@ public class Playlist {
|
||||||
embed.setDescription("A song in the radio does not have MPEG headers. A song without headers cannot be played in the radio because the length cannot be determined. Please fix as soon as possible.\n\nClick on the title to go to the song.");
|
embed.setDescription("A song in the radio does not have MPEG headers. A song without headers cannot be played in the radio because the length cannot be determined. Please fix as soon as possible.\n\nClick on the title to go to the song.");
|
||||||
embed.setUrl(nextURL);
|
embed.setUrl(nextURL);
|
||||||
try {
|
try {
|
||||||
MainUtil.sendMessageDiscord(embed);
|
DiscordUtil.sendMessageDiscord(embed);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -139,25 +134,14 @@ public class Playlist {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send to client
|
AudioMessage.of(AudioType.RADIO, nextURL).broadcast(PinManager::hasPin);
|
||||||
JSONObject data;
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
||||||
data = new JSONObject();
|
|
||||||
|
|
||||||
if (!PinManager.hasPin(p.getUniqueId())) continue;
|
|
||||||
|
|
||||||
data.put("task", "RADIO");
|
|
||||||
data.put("path", nextURL);
|
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
|
||||||
MCTPAudio.getClient().sendData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
Bukkit.getLogger().info("Started song with duration: " + ticks / 20 + " sec.");
|
Bukkit.getLogger().info("Started song with duration: " + ticks / 20 + " sec.");
|
||||||
|
|
||||||
faultCounter = 0;
|
faultCounter = 0;
|
||||||
|
|
||||||
//And started timer, so that it starts a new song if the old one is done
|
//And started timer, so that it starts a new song if the old one is done
|
||||||
currentTimer = Bukkit.getScheduler().runTaskLaterAsynchronously(MCTPAudio.getPlugin(), () -> {
|
currentTimer = Bukkit.getScheduler().runTaskLaterAsynchronously(ThemeParkAudio.getPlugin(), () -> {
|
||||||
currentTimer = null;
|
currentTimer = null;
|
||||||
nextSong();
|
nextSong();
|
||||||
}, ticks);
|
}, ticks);
|
||||||
|
@ -165,13 +149,4 @@ public class Playlist {
|
||||||
//And shuffle the playlist now
|
//And shuffle the playlist now
|
||||||
playList.shuffle();
|
playList.shuffle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the playlist is running
|
|
||||||
*
|
|
||||||
* @return true if running
|
|
||||||
*/
|
|
||||||
public boolean isRunning() {
|
|
||||||
return running;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package nl.sbdeveloper.mctpaudio.socket;
|
package nl.sbdeveloper.mctpaudio.socket;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import nl.sbdeveloper.mctpaudio.MCTPAudio;
|
import nl.sbdeveloper.mctpaudio.ThemeParkAudio;
|
||||||
|
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
||||||
import nl.sbdeveloper.mctpaudio.api.events.AudioConnectionUpdateEvent;
|
import nl.sbdeveloper.mctpaudio.api.events.AudioConnectionUpdateEvent;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
import nl.sbdeveloper.mctpaudio.managers.PinManager;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
||||||
|
import nl.sbdeveloper.mctpaudio.socket.messages.AudioMessage;
|
||||||
|
import nl.sbdeveloper.mctpaudio.socket.messages.AuthenticationMessage;
|
||||||
|
import nl.sbdeveloper.mctpaudio.socket.messages.LightMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.java_websocket.client.WebSocketClient;
|
import org.java_websocket.client.WebSocketClient;
|
||||||
|
@ -19,12 +23,6 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
private final String url;
|
private final String url;
|
||||||
|
|
||||||
|
@ -50,7 +48,7 @@ public class Client {
|
||||||
public void connect() {
|
public void connect() {
|
||||||
if (!this.connected) {
|
if (!this.connected) {
|
||||||
this.connected = true;
|
this.connected = true;
|
||||||
this.controlID = Bukkit.getScheduler().runTaskTimer(MCTPAudio.getPlugin(), () -> {
|
this.controlID = Bukkit.getScheduler().runTaskTimer(ThemeParkAudio.getPlugin(), () -> {
|
||||||
if (!this.connected) {
|
if (!this.connected) {
|
||||||
Bukkit.getScheduler().cancelTask(this.controlID);
|
Bukkit.getScheduler().cancelTask(this.controlID);
|
||||||
this.controlID = 0;
|
this.controlID = 0;
|
||||||
|
@ -100,25 +98,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).collect(Collectors.toList());
|
List<String> regions = WGManager.getRegionsIn(p.getLocation()).stream().map(ProtectedRegion::getId).toList();
|
||||||
Set<String> list = MCTPAudio.getPlugin().getConfig().getConfigurationSection("Regions").getKeys(false);
|
Set<String> list = ThemeParkAudio.getPlugin().getConfig().getConfigurationSection("regions.audio").getKeys(false);
|
||||||
Optional<String> regionName = regions.stream().filter(list::contains).findFirst();
|
Optional<String> regionName = regions.stream().filter(list::contains).findFirst();
|
||||||
regionName.ifPresent(name -> {
|
regionName.ifPresent(name -> {
|
||||||
String regionURL = MCTPAudio.getPlugin().getConfig().getString("Regions." + name);
|
String regionURL = ThemeParkAudio.getPlugin().getConfig().getString("regions.audio." + name);
|
||||||
|
AudioMessage.of(AudioType.MUSIC, regionURL).send(pUUID);
|
||||||
|
});
|
||||||
|
|
||||||
JSONObject data = new JSONObject();
|
Set<String> list2 = ThemeParkAudio.getPlugin().getConfig().getConfigurationSection("regions.light").getKeys(false);
|
||||||
data.put("task", "MUSIC");
|
Optional<String> regionName2 = regions.stream().filter(list2::contains).findFirst();
|
||||||
data.put("path", regionURL);
|
regionName2.ifPresent(name -> {
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
String configData = ThemeParkAudio.getPlugin().getConfig().getString("regions.light." + name);
|
||||||
MCTPAudio.getClient().sendData(data);
|
if (configData != null) {
|
||||||
|
LightMessage.of(configData).send(pUUID);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject reply = new JSONObject();
|
AuthenticationMessage.of(verified).send(pUUID);
|
||||||
reply.put("task", "AUTHENTICATION");
|
|
||||||
reply.put("verified", verified);
|
|
||||||
reply.put("uuid", uuid);
|
|
||||||
this.send(reply.toJSONString());
|
|
||||||
} else if (str.equals("DISCONNECTED")) {
|
} else if (str.equals("DISCONNECTED")) {
|
||||||
String uuid = JSONUtil.getValue(json, "uuid");
|
String uuid = JSONUtil.getValue(json, "uuid");
|
||||||
if (uuid == null || uuid.isEmpty()) return;
|
if (uuid == null || uuid.isEmpty()) return;
|
||||||
|
@ -148,7 +146,7 @@ public class Client {
|
||||||
this.wsc.connect();
|
this.wsc.connect();
|
||||||
|
|
||||||
if (this.taskID == 0) {
|
if (this.taskID == 0) {
|
||||||
this.taskID = Bukkit.getScheduler().runTaskTimerAsynchronously(MCTPAudio.getPlugin(), () -> {
|
this.taskID = Bukkit.getScheduler().runTaskTimerAsynchronously(ThemeParkAudio.getPlugin(), () -> {
|
||||||
if (Client.this.wsc != null && Client.this.wsc.isOpen()) {
|
if (Client.this.wsc != null && Client.this.wsc.isOpen()) {
|
||||||
Client.this.wsc.send("__PING__");
|
Client.this.wsc.send("__PING__");
|
||||||
} else {
|
} else {
|
||||||
|
@ -191,9 +189,9 @@ public class Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendData(JSONObject object) {
|
public void sendData(JSONObject json) {
|
||||||
if (this.wsc != null && this.wsc.isOpen() && object != null && object.toJSONString() != null) {
|
if (this.wsc != null && this.wsc.isOpen()) {
|
||||||
this.wsc.send(object.toJSONString());
|
this.wsc.send(json.toJSONString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
package nl.sbdeveloper.mctpaudio.socket;
|
package nl.sbdeveloper.mctpaudio.socket;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
import org.json.simple.parser.ParseException;
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
@UtilityClass
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class JSONUtil {
|
public class JSONUtil {
|
||||||
public static JSONObject parse(String string) {
|
public static JSONObject parse(String string) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package nl.sbdeveloper.mctpaudio.socket.messages;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import nl.sbdeveloper.mctpaudio.ThemeParkAudio;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public abstract class AbstractMessage {
|
||||||
|
private final MessageTask task;
|
||||||
|
|
||||||
|
public AbstractMessage(MessageTask task) {
|
||||||
|
this.task = task;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(UUID uuid) {
|
||||||
|
send(List.of(uuid), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(List<UUID> uuids) {
|
||||||
|
send(uuids, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void broadcast(@Nullable Function<UUID, Boolean> filter) {
|
||||||
|
send(Bukkit.getOnlinePlayers().stream().map(Entity::getUniqueId).toList(), filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(List<UUID> uuids, @Nullable Function<UUID, Boolean> filter) {
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
data.put("task", getTask());
|
||||||
|
JSONObject extendData = extendJson();
|
||||||
|
if (extendData != null) {
|
||||||
|
data.putAll(extendData);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (UUID uuid : uuids) {
|
||||||
|
if (filter == null || filter.apply(uuid)) {
|
||||||
|
data.put("uuid", uuid.toString().replace("-", ""));
|
||||||
|
ThemeParkAudio.getClient().sendData(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract JSONObject extendJson();
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package nl.sbdeveloper.mctpaudio.socket.messages;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class AudioMessage extends AbstractMessage {
|
||||||
|
private final String path;
|
||||||
|
private final Boolean play;
|
||||||
|
private final Integer at;
|
||||||
|
|
||||||
|
protected AudioMessage(AudioType type, String path, Boolean play, Integer at) {
|
||||||
|
super(type.toMessageTask());
|
||||||
|
this.path = path;
|
||||||
|
this.play = play;
|
||||||
|
this.at = at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AudioMessage of(AudioType type, String path) {
|
||||||
|
return new AudioMessage(type, path, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AudioMessage of(AudioType type, String path, boolean play) {
|
||||||
|
return new AudioMessage(type, path, play, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AudioMessage of(AudioType type, String path, boolean play, int at) {
|
||||||
|
return new AudioMessage(type, path, play, at);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject extendJson() {
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
data.put("path", path);
|
||||||
|
if (play != null) data.put("play", play);
|
||||||
|
if (at != null) data.put("at", at);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package nl.sbdeveloper.mctpaudio.socket.messages;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class AuthenticationMessage extends AbstractMessage {
|
||||||
|
private final boolean verified;
|
||||||
|
|
||||||
|
private AuthenticationMessage(boolean verified) {
|
||||||
|
super(MessageTask.AUTHENTICATION);
|
||||||
|
this.verified = verified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AuthenticationMessage of(boolean verified) {
|
||||||
|
return new AuthenticationMessage(verified);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject extendJson() {
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
data.put("verified", verified);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package nl.sbdeveloper.mctpaudio.socket.messages;
|
||||||
|
|
||||||
|
import nl.sbdeveloper.mctpaudio.api.LightRegion;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class LightMessage extends AbstractMessage {
|
||||||
|
private final int brightness;
|
||||||
|
private final int r, g, b, w;
|
||||||
|
private final LightRegion region;
|
||||||
|
|
||||||
|
private LightMessage(int brightness, int r, int g, int b, int w, LightRegion region) {
|
||||||
|
super(MessageTask.LIGHT);
|
||||||
|
this.brightness = brightness;
|
||||||
|
this.r = r;
|
||||||
|
this.g = g;
|
||||||
|
this.b = b;
|
||||||
|
this.w = w;
|
||||||
|
this.region = region;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LightMessage of(int brightness, int r, int g, int b, int w, LightRegion region) {
|
||||||
|
return new LightMessage(brightness, r, g, b, w, region);
|
||||||
|
}
|
||||||
|
|
||||||
|
private LightMessage(@NotNull String configData) {
|
||||||
|
super(MessageTask.LIGHT);
|
||||||
|
|
||||||
|
String[] configDataSplit = configData.split("_");
|
||||||
|
if (configDataSplit.length != 6) {
|
||||||
|
throw new IllegalArgumentException("Invalid config data: " + configData);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.brightness = Integer.parseInt(configDataSplit[0]);
|
||||||
|
this.r = Integer.parseInt(configDataSplit[1]);
|
||||||
|
this.g = Integer.parseInt(configDataSplit[2]);
|
||||||
|
this.b = Integer.parseInt(configDataSplit[3]);
|
||||||
|
this.w = Integer.parseInt(configDataSplit[4]);
|
||||||
|
this.region = LightRegion.valueOf(configDataSplit[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LightMessage of(@NotNull String configData) {
|
||||||
|
return new LightMessage(configData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject extendJson() {
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
data.put("rgbw", r + "_" + g + "_" + b + "_" + w);
|
||||||
|
data.put("region", region);
|
||||||
|
data.put("brightness", brightness);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package nl.sbdeveloper.mctpaudio.socket.messages;
|
||||||
|
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
public class LogoutMessage extends AbstractMessage {
|
||||||
|
public LogoutMessage() {
|
||||||
|
super(MessageTask.LOGOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected JSONObject extendJson() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package nl.sbdeveloper.mctpaudio.socket.messages;
|
||||||
|
|
||||||
|
public enum MessageTask {
|
||||||
|
AUTHENTICATION, LOGOUT, LIGHT, MUSIC, SFX, RADIO
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package nl.sbdeveloper.mctpaudio.socket.messages;
|
||||||
|
|
||||||
|
import nl.sbdeveloper.mctpaudio.api.AudioType;
|
||||||
|
|
||||||
|
public class StopAudioMessage extends AudioMessage {
|
||||||
|
public StopAudioMessage(AudioType type) {
|
||||||
|
super(type, "", null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static StopAudioMessage of(AudioType type) {
|
||||||
|
return new StopAudioMessage(type);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,11 @@
|
||||||
package nl.sbdeveloper.mctpaudio.utils;
|
package nl.sbdeveloper.mctpaudio.utils;
|
||||||
|
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class MainUtil {
|
@UtilityClass
|
||||||
|
public class DiscordUtil {
|
||||||
public static void sendMessageDiscord(WebhookMessage.EmbedObject embed, String mention) throws IOException {
|
public static void sendMessageDiscord(WebhookMessage.EmbedObject embed, String mention) throws IOException {
|
||||||
WebhookMessage webhookMessage = new WebhookMessage("https://discord.com/api/webhooks/706629612955762778/MztXWVWupAIoTIHwb0XK8ExfOz6nrygB_FEl9EpbFENGUCGobMib_5Apj2rnUSXuMlbR");
|
WebhookMessage webhookMessage = new WebhookMessage("https://discord.com/api/webhooks/706629612955762778/MztXWVWupAIoTIHwb0XK8ExfOz6nrygB_FEl9EpbFENGUCGobMib_5Apj2rnUSXuMlbR");
|
||||||
webhookMessage.setAvatarUrl("https://mcthemeparks.com/musicupload/downloads/Designs/Logo2.png");
|
webhookMessage.setAvatarUrl("https://mcthemeparks.com/musicupload/downloads/Designs/Logo2.png");
|
|
@ -3,6 +3,7 @@ package nl.sbdeveloper.mctpaudio.utils;
|
||||||
import com.mpatric.mp3agic.InvalidDataException;
|
import com.mpatric.mp3agic.InvalidDataException;
|
||||||
import com.mpatric.mp3agic.Mp3File;
|
import com.mpatric.mp3agic.Mp3File;
|
||||||
import com.mpatric.mp3agic.UnsupportedTagException;
|
import com.mpatric.mp3agic.UnsupportedTagException;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
@ -11,15 +12,10 @@ import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the head of a MP3 file.
|
* Read the head of a MP3 file.
|
||||||
*/
|
*/
|
||||||
|
@UtilityClass
|
||||||
public class HeadUtil {
|
public class HeadUtil {
|
||||||
public static String getArgument(String selector, String key) {
|
public static String getArgument(String selector, String key) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package nl.sbdeveloper.mctpaudio.utils;
|
package nl.sbdeveloper.mctpaudio.utils;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
import nl.sbdeveloper.mctpaudio.managers.WGManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -13,14 +14,7 @@ import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/* Copyright (C) McThemeParks - All Rights Reserved
|
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
||||||
* Proprietary and confidential
|
|
||||||
* Written by Stijn Bannink <stijnbannink23@gmail.com>, July 2020
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class SpigotPlayerSelector {
|
public class SpigotPlayerSelector {
|
||||||
|
|
||||||
private final String selector;
|
private final String selector;
|
||||||
|
|
||||||
public SpigotPlayerSelector(String selector) {
|
public SpigotPlayerSelector(String selector) {
|
||||||
|
|
8
src/main/resources/config.yml
Normal file
8
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
socketUrl: "ws://localhost:8080"
|
||||||
|
regions:
|
||||||
|
audio:
|
||||||
|
demo: https://www.mcthemeparks.com/musicupload/downloads/Berlin/kaad.mp3
|
||||||
|
light:
|
||||||
|
demo: 255_255_0_0_0_ALL
|
||||||
|
radioSongs:
|
||||||
|
- https://www.mcthemeparks.com/musicupload/downloads/Berlin/kaad.mp3
|
|
@ -1,6 +1,6 @@
|
||||||
name: MCTPAudio
|
name: MCTPAudio
|
||||||
version: ${project.version}
|
version: ${project.version}
|
||||||
main: nl.sbdeveloper.mctpaudio.MCTPAudio
|
main: nl.sbdeveloper.mctpaudio.ThemeParkAudio
|
||||||
api-version: 1.19
|
api-version: 1.19
|
||||||
depend: [ WorldGuard, Train_Carts ]
|
depend: [ WorldGuard, Train_Carts ]
|
||||||
authors: [ SBDeveloper ]
|
authors: [ SBDeveloper ]
|
||||||
|
|
Loading…
Add table
Reference in a new issue