Plugin done?
This commit is contained in:
parent
01f6792719
commit
50a4cf1576
3 changed files with 38 additions and 4 deletions
|
@ -1,8 +1,11 @@
|
||||||
package me.mctp;
|
package me.mctp;
|
||||||
|
|
||||||
import me.mctp.api.AudioType;
|
import me.mctp.api.AudioType;
|
||||||
|
import me.mctp.api.HueType;
|
||||||
import me.mctp.managers.PinManager;
|
import me.mctp.managers.PinManager;
|
||||||
import me.mctp.utils.SpigotPlayerSelector;
|
import me.mctp.utils.SpigotPlayerSelector;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
@ -19,6 +22,11 @@ public class MCTPAudioCmd implements CommandExecutor {
|
||||||
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args) {
|
||||||
if (cmd.getName().equalsIgnoreCase("mctpaudio")) {
|
if (cmd.getName().equalsIgnoreCase("mctpaudio")) {
|
||||||
|
if (!sender.hasPermission("mctp.audio")) {
|
||||||
|
sender.sendMessage(prefix + "You don't have the permission to do this.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// /mctpaudio play SELECTOR TYPE URL
|
// /mctpaudio play SELECTOR TYPE URL
|
||||||
// /mctpaudio stop SELECTOR TYPE
|
// /mctpaudio stop SELECTOR TYPE
|
||||||
if (args.length == 4 && args[0].equalsIgnoreCase("play")) {
|
if (args.length == 4 && args[0].equalsIgnoreCase("play")) {
|
||||||
|
@ -58,7 +66,7 @@ public class MCTPAudioCmd implements CommandExecutor {
|
||||||
|
|
||||||
sender.sendMessage(prefix + "Gestart met afspelen!");
|
sender.sendMessage(prefix + "Gestart met afspelen!");
|
||||||
return true;
|
return true;
|
||||||
} else if (args.length == 5 && args[0].equalsIgnoreCase("hue")) {
|
} else if (args.length == 6 && args[0].equalsIgnoreCase("hue")) {
|
||||||
int r;
|
int r;
|
||||||
int g;
|
int g;
|
||||||
int b;
|
int b;
|
||||||
|
@ -71,6 +79,14 @@ public class MCTPAudioCmd implements CommandExecutor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HueType type;
|
||||||
|
try {
|
||||||
|
type = HueType.valueOf(args[5].toUpperCase());
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
sender.sendMessage(prefix + args[5] + " is geen correcte type.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<Player> players = new ArrayList<>();
|
ArrayList<Player> players = new ArrayList<>();
|
||||||
Player target = Bukkit.getPlayer(args[1]);
|
Player target = Bukkit.getPlayer(args[1]);
|
||||||
if (target != null) {
|
if (target != null) {
|
||||||
|
@ -93,11 +109,21 @@ public class MCTPAudioCmd implements CommandExecutor {
|
||||||
|
|
||||||
data.put("task", "HUE");
|
data.put("task", "HUE");
|
||||||
data.put("rgb", r + ":" + g + ":" + b);
|
data.put("rgb", r + ":" + g + ":" + b);
|
||||||
|
data.put("type", type);
|
||||||
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
data.put("uuid", p.getUniqueId().toString().replace("-", ""));
|
||||||
Main.getClient().sendData(data);
|
Main.getClient().sendData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(prefix + "Gestart met afspelen!");
|
sender.sendMessage(prefix + "Indien de speler(s) is/zijn verbonden met Philips Hue, is de kleur veranderd.");
|
||||||
|
return true;
|
||||||
|
} else if (args.length == 3 && args[0].equalsIgnoreCase("setregion")) {
|
||||||
|
String regionName = args[1];
|
||||||
|
String url = args[1];
|
||||||
|
|
||||||
|
Main.getPlugin().getConfig().set("Regions." + regionName, url);
|
||||||
|
Main.getPlugin().saveConfig();
|
||||||
|
|
||||||
|
sender.sendMessage(prefix + "De region zal vanaf nu muziek afspelen.");
|
||||||
return true;
|
return true;
|
||||||
} else if (args.length == 2 && args[0].equalsIgnoreCase("stop")) {
|
} else if (args.length == 2 && args[0].equalsIgnoreCase("stop")) {
|
||||||
ArrayList<Player> players = new ArrayList<>();
|
ArrayList<Player> players = new ArrayList<>();
|
||||||
|
@ -137,10 +163,12 @@ public class MCTPAudioCmd implements CommandExecutor {
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
String pin = PinManager.getPIN(p.getUniqueId());
|
String pin = PinManager.getPIN(p.getUniqueId());
|
||||||
|
|
||||||
String url = "http://localhost/audio/index";
|
String url = "http://audio.mcthemeparks.eu/";
|
||||||
url = url + "?uuid=" + p.getUniqueId().toString().replace("-", "") + "&pin=" + pin;
|
url = url + "?uuid=" + p.getUniqueId().toString().replace("-", "") + "&pin=" + pin;
|
||||||
|
|
||||||
sender.sendMessage(prefix + "Gebruik: " + url);
|
TextComponent message = new TextComponent(TextComponent.fromLegacyText(prefix + "Klik hierop om te verbinden met de audioclient."));
|
||||||
|
message.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
|
||||||
|
p.spigot().sendMessage(message);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
5
src/me/mctp/api/HueType.java
Normal file
5
src/me/mctp/api/HueType.java
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
package me.mctp.api;
|
||||||
|
|
||||||
|
public enum HueType {
|
||||||
|
LEFT, MID, RIGHT, ALL
|
||||||
|
}
|
|
@ -67,6 +67,7 @@ public class SpigotPlayerSelector {
|
||||||
|
|
||||||
if (getArgument("region").length() != 0) {
|
if (getArgument("region").length() != 0) {
|
||||||
//TODO FIX REGION SELECTOR
|
//TODO FIX REGION SELECTOR
|
||||||
|
throw new UnsupportedOperationException("The region argument is not supported.");
|
||||||
} else if (getArgument("r").length() != 0) {
|
} else if (getArgument("r").length() != 0) {
|
||||||
int radius = Integer.parseInt(getArgument("r"));
|
int radius = Integer.parseInt(getArgument("r"));
|
||||||
players.addAll(Bukkit.getOnlinePlayers().stream()
|
players.addAll(Bukkit.getOnlinePlayers().stream()
|
||||||
|
|
Loading…
Add table
Reference in a new issue