diff --git a/.gitignore b/.gitignore index 48ae4f0..502472c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ \.idea/ \build/ \libs/ -out/ +\out/ diff --git a/build.gradle b/build.gradle index 8f812da..f1126d8 100644 --- a/build.gradle +++ b/build.gradle @@ -54,14 +54,14 @@ subprojects { mavenLocal() mavenCentral() //Mixer's Maven repo was down, so I'm removing it for now. - //maven { - // name = "mixer-snapshots" - // url = "https://maven.mixer.com/content/repositories/snapshots" - //} - //maven { - // name = "mixer-releases" - // url = "https://maven.mixer.com/content/repositories/releases/" - //} + maven { + name = "mixer-snapshots" + url = "https://maven.mixer.com/content/repositories/snapshots" + } + maven { + name = "mixer-releases" + url = "https://maven.mixer.com/content/repositories/releases/" + } } dependencies{ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ba0bf76..fec03a6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,6 @@ -#Thu Apr 12 15:43:11 EDT 2018 +#Sat Jul 20 10:54:44 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip - +distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip diff --git a/mixer-common/src/main/java/pro/kdray/funniray/mixer/Config.java b/mixer-common/src/main/java/pro/kdray/funniray/mixer/Config.java index 8b84413..4a9904a 100644 --- a/mixer-common/src/main/java/pro/kdray/funniray/mixer/Config.java +++ b/mixer-common/src/main/java/pro/kdray/funniray/mixer/Config.java @@ -12,9 +12,17 @@ public class Config { public static String DBUsername = "unused"; public static String DBPassword = "unused"; - public static String subscriberCommand; - public static String resubscriberCommand; + public static String subscribeCommand; + public static String resubscribeCommand; public static String followCommand; public static List bannedWords; + + public static String messagesPrefix = "&6Mixer &8| "; + public static String messagesChatConnect = "&cChat Connected!"; + public static String messagesConnectInteractive = "&aInteractive connected!"; + public static String messagesDisableInteractive = "&cInteractive has been successfully disabled!"; + public static String messagesEstablishedNotConnected = "&cConnection was established but isn't connected!"; + public static String messagesPause = "Buttons have been paused"; + public static String messagesResume = "Buttons have been resumed"; } diff --git a/mixer-common/src/main/java/pro/kdray/funniray/mixer/Main.java b/mixer-common/src/main/java/pro/kdray/funniray/mixer/Main.java index 3e820b2..dbf67c9 100644 --- a/mixer-common/src/main/java/pro/kdray/funniray/mixer/Main.java +++ b/mixer-common/src/main/java/pro/kdray/funniray/mixer/Main.java @@ -13,6 +13,9 @@ import java.util.concurrent.ExecutionException; +import static pro.kdray.funniray.mixer.Config.messagesDisableInteractive; +import static pro.kdray.funniray.mixer.Config.messagesPrefix; + public class Main { private Interactive interactive; @@ -43,7 +46,7 @@ public void setAPIKey(String key) { } public void startChat() throws ExecutionException, InterruptedException { - MixerAPI mixer = new MixerAPI(clientID, APIKey); + MixerAPI mixer = new MixerAPI(APIKey, clientID); MixerUser user = mixer.use(UsersService.class).getCurrent().get(); MixerChat chat = mixer.use(ChatService.class).findOne(user.channel.id).get(); @@ -53,7 +56,7 @@ public void startChat() throws ExecutionException, InterruptedException { } public void startInteractive() throws ExecutionException, InterruptedException { - MixerAPI mixer = new MixerAPI(clientID, APIKey); + MixerAPI mixer = new MixerAPI(APIKey, clientID); MixerUser user = mixer.use(UsersService.class).getCurrent().get(); @@ -61,7 +64,7 @@ public void startInteractive() throws ExecutionException, InterruptedException { } public void startAll() throws ExecutionException, InterruptedException { - MixerAPI mixer = new MixerAPI(clientID, APIKey); + MixerAPI mixer = new MixerAPI(APIKey, clientID); MixerUser user = mixer.use(UsersService.class).getCurrent().get(); MixerChat chat = mixer.use(ChatService.class).findOne(user.channel.id).get(); @@ -89,7 +92,7 @@ public void stopInteractive() { public void shutdown(){ this.stopChat(); this.stopInteractive(); - eventHandler.sendMessage("&9&l[Mixer]&r&9 Successfully disabled interactive."); + eventHandler.sendMessage(messagesPrefix + messagesDisableInteractive); } public Interactive getInteractive() { diff --git a/mixer-common/src/main/java/pro/kdray/funniray/mixer/Utils.java b/mixer-common/src/main/java/pro/kdray/funniray/mixer/Utils.java index 287bcd6..dfa1977 100644 --- a/mixer-common/src/main/java/pro/kdray/funniray/mixer/Utils.java +++ b/mixer-common/src/main/java/pro/kdray/funniray/mixer/Utils.java @@ -9,15 +9,15 @@ public static String getColorFromRank(List roles){ String color = "&4"; if (roles.contains(MixerUser.Role.OWNER)) { - color = "&f"; + color = "&c"; }else if (roles.contains(MixerUser.Role.FOUNDER) || roles.contains(MixerUser.Role.STAFF) || roles.contains(MixerUser.Role.GLOBAL_MOD)){ - color = "&4"; + color = "&3"; }else if (roles.contains(MixerUser.Role.MOD)) { - color = "&a"; + color = "&2"; }else if (roles.contains(MixerUser.Role.SUBSCRIBER)){ color = "&6"; }else if (roles.contains(MixerUser.Role.PRO)){ - color = "&5"; + color = "&d"; }else if (roles.contains(MixerUser.Role.USER)){ color = "&9"; } diff --git a/mixer-common/src/main/java/pro/kdray/funniray/mixer/controls/InteractiveButton.java b/mixer-common/src/main/java/pro/kdray/funniray/mixer/controls/InteractiveButton.java index 2999f92..b84cc4e 100644 --- a/mixer-common/src/main/java/pro/kdray/funniray/mixer/controls/InteractiveButton.java +++ b/mixer-common/src/main/java/pro/kdray/funniray/mixer/controls/InteractiveButton.java @@ -20,6 +20,7 @@ public class InteractiveButton { private String NBT; private String switchWindow; private String runCommand; + private String[] runCommands; private boolean runAsServer = false; private boolean resetScene = false; //TODO: private String move; @@ -61,6 +62,9 @@ public InteractiveButton(ButtonControl control, Interactive handler) { case "runCommand": this.runCommand = meta.get("action").getAsJsonObject().get("value").getAsString(); break; + case "runCommands": + this.runCommand = meta.get("action").getAsJsonObject().get("value").getAsString(); + break; case "runCommandAsServer": this.runCommand = meta.get("action").getAsJsonObject().get("value").getAsString(); this.runAsServer = true; @@ -74,6 +78,9 @@ public InteractiveButton(ButtonControl control, Interactive handler) { if (meta.get("runCommand") != null) this.runCommand = meta.get("runCommand").getAsJsonObject().get("value").getAsString(); + if (meta.get("runCommands") != null) + this.runCommands = meta.get("runCommands").getAsJsonObject().get("value").getAsString().split("\\n"); + if (meta.get("runCommandAsServer") != null) { this.runCommand = meta.get("runCommandAsServer").getAsJsonObject().get("value").getAsString(); this.runAsServer = true; @@ -200,6 +207,23 @@ public boolean onClick(InteractiveParticipant participant){ } } + if (this.runCommands != null) { + for (String tempCommands : runCommands){ + String command = tempCommands + .replace("%CSL%", CSL) + .replace("%SSL%", SSL) + .replace("%HRL%", HRL) + .replace("%presser%", participant.getUsername()); + if (this.runAsServer) { + this.handler.getEventHandler().runCommandAsConsole(command); + didAction = true; + }else{ + this.handler.getEventHandler().runCommand(command); + didAction = true; + } + } + } + if (this.summon != null){ if (this.NBT != null) { this.handler.getEventHandler().summon((this.summon + " ~ ~ ~ " + this.NBT) diff --git a/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Chat.java b/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Chat.java index 21ba078..8cf313b 100644 --- a/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Chat.java +++ b/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Chat.java @@ -13,6 +13,9 @@ import pro.kdray.funniray.mixer.MixerEvents; import pro.kdray.funniray.mixer.Utils; +import static pro.kdray.funniray.mixer.Config.messagesChatConnect; +import static pro.kdray.funniray.mixer.Config.messagesPrefix; + public class Chat { private MixerChatConnectable chatConnectable; @@ -23,7 +26,7 @@ public Chat(MixerAPI mixer, MixerUser user, MixerChat chat, MixerEvents eventHan if (chatConnectable.connect()) { chatConnectable.send(AuthenticateMessage.from(user.channel, user, chat.authkey), new ReplyHandler() { public void onSuccess(AuthenticationReply reply) { - eventHandler.sendMessage("&9&l[Mixer]&r&9 Chat Connected!"); + eventHandler.sendMessage(messagesPrefix + messagesChatConnect); } public void onFailure(Throwable e) { e.printStackTrace(); @@ -34,19 +37,16 @@ public void onFailure(Throwable e) { chatConnectable.on(IncomingMessageEvent.class, event -> { if (event.data.message.isWhisper()) return; - StringBuilder finishedMessage = new StringBuilder("&9&l[Mixer] " + Utils.getColorFromRank(event.data.userRoles) + event.data.userName + "&9&l: &r&7"); + StringBuilder finishedMessage = new StringBuilder(messagesPrefix + Utils.getColorFromRank(event.data.userRoles) + event.data.userName + "&9&l: &r&7"); for (MessageComponent.MessageTextComponent message : event.data.message.message){ finishedMessage.append(message.text.replace("§", "§§").replace("&", "&&7")); } - boolean shouldShow = true; for (String word : Config.bannedWords) { - if (finishedMessage.toString().contains(word)){ - shouldShow = false; + if (!finishedMessage.toString().contains(word)){ + eventHandler.sendMessage(finishedMessage.toString()); break; } } - if (shouldShow) - eventHandler.sendMessage(finishedMessage.toString()); }); this.chatConnectable = chatConnectable; diff --git a/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Constellation.java b/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Constellation.java index f4b9477..5545250 100644 --- a/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Constellation.java +++ b/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Constellation.java @@ -15,6 +15,8 @@ import java.util.ArrayList; import java.util.Random; +import static pro.kdray.funniray.mixer.Config.messagesPrefix; + public class Constellation { private MixerConstellationConnectable constellationConnectable; @@ -57,21 +59,20 @@ public void onFailure(Throwable e) { break; case "subscribed": eventHandler.sendTitle(actionUser+" subscribed!", ""); - eventHandler.sendMessage("&9&l[Mixer] &r&9"+actionUser+" subscribed!"); - eventHandler.runCommandAsConsole(Config.subscriberCommand.replace("%user%", actionUser)); + eventHandler.sendMessage(messagesPrefix+actionUser+" subscribed!"); + eventHandler.runCommandAsConsole(Config.subscribeCommand.replace("%user%", actionUser)); break; case "resubscribed": eventHandler.sendTitle(actionUser+" resubscribed!", ""); - eventHandler.sendMessage("&9&l[Mixer] &r&9"+actionUser+" resubscribed!"); - eventHandler.runCommandAsConsole(Config.resubscriberCommand.replace("%user%", actionUser).replace("%totalMonths%", "" + event.data.payload.get("totalMonths").getAsInt())); + eventHandler.sendMessage(messagesPrefix+actionUser+" resubscribed!"); + eventHandler.runCommandAsConsole(Config.resubscribeCommand.replace("%user%", actionUser).replace("%totalMonths%", "" + event.data.payload.get("totalMonths").getAsInt())); + break; + case "update": + eventHandler.sendTitle("&bMixer Title &7has been updated to:", "&7" + event.data.payload.get("name").getAsString()); + eventHandler.sendMessage(messagesPrefix+"&aTitle has been updated to: " + event.data.payload.get("name").getAsString()); break; - //case "update": - // message = "&9Channel update, new title is "+event.data.payload.get("name").getAsString(); - // eventHandler.sendTitle(message, ""); - // eventHandler.sendMessage("&9&l[Mixer] &r"+message); - // break; default: - eventHandler.sendMessage("&9&l[Mixer]&r&c >>> Unhandled Contellation Event: "+event.toString()); + eventHandler.sendMessage(messagesPrefix+"&cUnhandled Constellation Event: "+event.toString()); } }); diff --git a/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Interactive.java b/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Interactive.java index f00c9d8..dded466 100644 --- a/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Interactive.java +++ b/mixer-common/src/main/java/pro/kdray/funniray/mixer/handlers/Interactive.java @@ -29,6 +29,7 @@ import java.util.concurrent.ExecutionException; import static com.mixer.interactive.GameClient.GROUP_SERVICE_PROVIDER; +import static pro.kdray.funniray.mixer.Config.*; public class Interactive { @@ -75,10 +76,10 @@ public void onParticipantLeave(ParticipantLeaveEvent event){ @Subscribe public void onConnectionEsablished(ConnectionEstablishedEvent event){ try { - if (!client.isConnected()) { - this.eventHandler.sendMessage("&9&l[Mixer]&r&4 Connection was established but isn't connected!"); + if (client.isConnected()) { + this.eventHandler.sendMessage(messagesPrefix + messagesConnectInteractive); }else{ - this.eventHandler.sendMessage("&9&l[Mixer]&r&9 Interactive connected!"); + this.eventHandler.sendMessage(messagesPrefix + messagesEstablishedNotConnected); } Set scenes = new SceneServiceProvider(client).getScenes().get(); @@ -121,7 +122,7 @@ public void onKeyDown(ControlInputEvent event){ try { event.getTransaction().capture(this.client).get(); } catch (InterruptedException | ExecutionException e) { - //Honestly who cares? //e.printStackTrace(); + //e.printStackTrace(); } }); } @@ -133,7 +134,7 @@ public void updateControl(ButtonControl control){ try { client.using(GameClient.CONTROL_SERVICE_PROVIDER).update(control).get(); } catch (InterruptedException | ExecutionException e) { - //I don't really care what happens here + //e.printStackTrace(); } }); } @@ -143,7 +144,7 @@ public void updateControls(Collection controls){ try { client.using(GameClient.CONTROL_SERVICE_PROVIDER).update(controls).get(); } catch (InterruptedException | ExecutionException e) { - //I don't really care what happens here + //e.printStackTrace(); } }); } @@ -206,10 +207,10 @@ public boolean isPaused(){ public void pause(){ if (this.isPause){ switchAllScenes("default"); - eventHandler.sendMessage("&9&l[Mixer]&r&9 Buttons have been unpaused"); + eventHandler.sendMessage(messagesPrefix + messagesResume); }else{ switchAllScenes("pause"); - eventHandler.sendMessage("&9&l[Mixer]&r&9 Buttons have been paused"); + eventHandler.sendMessage(messagesPrefix + messagesPause); } this.isPause = !this.isPause; } diff --git a/mixer-forge-1.12.2/src/main/java/pro/kdray/funniray/mixer/MixerForge.java b/mixer-forge-1.12.2/src/main/java/pro/kdray/funniray/mixer/MixerForge.java index d7b6068..143249f 100644 --- a/mixer-forge-1.12.2/src/main/java/pro/kdray/funniray/mixer/MixerForge.java +++ b/mixer-forge-1.12.2/src/main/java/pro/kdray/funniray/mixer/MixerForge.java @@ -62,7 +62,7 @@ private static void syncConfig(boolean loadConfigFromFile) { //Put SQL data here Property followCommandProp = configuration.get(Configuration.CATEGORY_GENERAL, "followCommand","command"); - Property subscriberCommandProp = configuration.get(Configuration.CATEGORY_GENERAL, "subscriberCommand","command"); + Property subscriberCommandProp = configuration.get(Configuration.CATEGORY_GENERAL, "subscribeCommand","command"); Property resubscriberCommandProp = configuration.get(Configuration.CATEGORY_GENERAL, "resubscriberCommand","command"); Property bannedWordsProp = configuration.get(Configuration.CATEGORY_GENERAL,"bannedWords",new String[]{"put multiple","words to remove from chat here"}); @@ -74,8 +74,8 @@ private static void syncConfig(boolean loadConfigFromFile) { Config.projectID = projectIDProp.getInt(); Config.followCommand = followCommandProp.getString(); - Config.subscriberCommand = subscriberCommandProp.getString(); - Config.resubscriberCommand = resubscriberCommandProp.getString(); + Config.subscribeCommand = subscriberCommandProp.getString(); + Config.resubscribeCommand = resubscriberCommandProp.getString(); Config.bannedWords = Arrays.asList(bannedWordsProp.getStringList()); @@ -86,8 +86,8 @@ private static void syncConfig(boolean loadConfigFromFile) { projectIDProp.set(Config.projectID); followCommandProp.set(Config.followCommand); - subscriberCommandProp.set(Config.subscriberCommand); - resubscriberCommandProp.set(Config.resubscriberCommand); + subscriberCommandProp.set(Config.subscribeCommand); + resubscriberCommandProp.set(Config.resubscribeCommand); bannedWordsProp.set(bannedWordsProp.getStringList()); diff --git a/mixer-forge-1.13.2/src/main/java/pro/kdray/funniray/mixer/MixerConfig.java b/mixer-forge-1.13.2/src/main/java/pro/kdray/funniray/mixer/MixerConfig.java index def99f8..9771eba 100644 --- a/mixer-forge-1.13.2/src/main/java/pro/kdray/funniray/mixer/MixerConfig.java +++ b/mixer-forge-1.13.2/src/main/java/pro/kdray/funniray/mixer/MixerConfig.java @@ -36,8 +36,8 @@ public static void load() { Config.clientID = CONFIG.clientIDValue.get(); Config.shareCode = CONFIG.shareCodeValue.get(); Config.projectID = CONFIG.projectIDValue.get(); - Config.subscriberCommand = CONFIG.subscriberCommandValue.get(); - Config.resubscriberCommand = CONFIG.resubscriberCommandValue.get(); + Config.subscribeCommand = CONFIG.subscriberCommandValue.get(); + Config.resubscribeCommand = CONFIG.resubscriberCommandValue.get(); Config.followCommand = CONFIG.followCommandValue.get(); Config.bannedWords = CONFIG.bannedWordsValue.get(); } @@ -67,7 +67,7 @@ public static class ServerConfig { builder.push("Constellation"); subscriberCommandValue = builder .comment("Command to be ran when someone subscribes. Replaces %user% with the subscriber's username") - .define("subscriberCommand","say %user% has subscribed"); + .define("subscribeCommand","say %user% has subscribed"); resubscriberCommandValue = builder .comment("Command to be ran when someone resubscribes. Replaces %user% with the subscriber's " + "username. Replaces %totalMonths% with the months they have been subscribed for") diff --git a/mixer-nukkit/src/main/java/pro/kdray/funniray/mixer/MixerNukkit.java b/mixer-nukkit/src/main/java/pro/kdray/funniray/mixer/MixerNukkit.java index 3d77aed..9e894d1 100644 --- a/mixer-nukkit/src/main/java/pro/kdray/funniray/mixer/MixerNukkit.java +++ b/mixer-nukkit/src/main/java/pro/kdray/funniray/mixer/MixerNukkit.java @@ -91,8 +91,8 @@ public static void loadConfig() { Config.projectID = configuration.getInt("projectID"); Config.followCommand = configuration.getString("followCommand"); - Config.subscriberCommand = configuration.getString("subscriberCommand"); - Config.resubscriberCommand = configuration.getString("resubscriberCommand"); + Config.subscribeCommand = configuration.getString("subscribeCommand"); + Config.resubscribeCommand = configuration.getString("resubscriberCommand"); Config.bannedWords = configuration.getStringList("bannedWords"); diff --git a/mixer-spigot/build.gradle b/mixer-spigot/build.gradle index b035ee2..a6f9d61 100644 --- a/mixer-spigot/build.gradle +++ b/mixer-spigot/build.gradle @@ -6,7 +6,7 @@ repositories { dependencies { compile project(':mixer-common') - compile name: "spigot-1.14.3" + compile name: "spigot-1.14.4" compile name: "spigot-1.13.2" compile name: "spigot-1.13" compile name: "spigot-1.12.2" diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/MixerSpigot.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/MixerSpigot.java index de07b90..1fb4701 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/MixerSpigot.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/MixerSpigot.java @@ -9,17 +9,17 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import pro.kdray.funniray.mixer.command.*; -import pro.kdray.funniray.mixer.compadibility.NullHandler; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; -import pro.kdray.funniray.mixer.compadibility.v1_10.Handler_1_10_R1; -import pro.kdray.funniray.mixer.compadibility.v1_11.Handler_1_11_R1; -import pro.kdray.funniray.mixer.compadibility.v1_12.Handler_1_12_R1; -import pro.kdray.funniray.mixer.compadibility.v1_13.Handler_1_13_R1; -import pro.kdray.funniray.mixer.compadibility.v1_13.Handler_1_13_R2; -import pro.kdray.funniray.mixer.compadibility.v1_14.Handler_1_14_R1; -import pro.kdray.funniray.mixer.compadibility.v1_9.Handler_1_9_R1; -import pro.kdray.funniray.mixer.compadibility.v1_9.Handler_1_9_R2; -import pro.kdray.funniray.mixer.events.Mixer; +import pro.kdray.funniray.mixer.compatibility.unknown.NullHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.v1_10.Handler_1_10_R1; +import pro.kdray.funniray.mixer.compatibility.v1_11.Handler_1_11_R1; +import pro.kdray.funniray.mixer.compatibility.v1_12.Handler_1_12_R1; +import pro.kdray.funniray.mixer.compatibility.v1_13.Handler_1_13_R1; +import pro.kdray.funniray.mixer.compatibility.v1_13.Handler_1_13_R2; +import pro.kdray.funniray.mixer.compatibility.v1_14.Handler_1_14_R1; +import pro.kdray.funniray.mixer.compatibility.v1_9.Handler_1_9_R1; +import pro.kdray.funniray.mixer.compatibility.v1_9.Handler_1_9_R2; +import pro.kdray.funniray.mixer.events.Actions; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -27,6 +27,12 @@ public final class MixerSpigot extends JavaPlugin { + + private static Main instance; + public static Main getInstance() { + return instance; + } + public static Plugin plugin; public static Main api = null; private static boolean isRunning = false; @@ -42,7 +48,7 @@ public static void startMain(){ isRunning = true; } catch (ExecutionException | InterruptedException e) { e.printStackTrace(); - new Mixer().sendMessage("&4&l[Mixer] &r&cFailed to start interactive, could be due to invalid API key"); + new Actions().sendMessage(plugin.getConfig().getString("messages.prefix") + plugin.getConfig().getString("messages.start-failed")); } }); } @@ -93,7 +99,7 @@ private void getVersion(){ versionHandler = new Handler_1_9_R1(); break; default: - this.getLogger().warning("This version is unsupported, Titles and ActionBars won't work. Current Version\":"+version); + this.getLogger().warning("Plugin will not work on a unsupported version ("+version+")!"); versionHandler = new NullHandler(); } } @@ -139,14 +145,22 @@ public static void loadConfig() { Config.projectID = configuration.getInt("projectID"); Config.followCommand = configuration.getString("followCommand"); - Config.subscriberCommand = configuration.getString("subscriberCommand"); - Config.resubscriberCommand = configuration.getString("resubscriberCommand"); + Config.subscribeCommand = configuration.getString("subscribeCommand"); + Config.resubscribeCommand = configuration.getString("resubscriberCommand"); Config.bannedWords = configuration.getStringList("bannedWords"); + Config.messagesPrefix = configuration.getString("messages.prefix"); + Config.messagesChatConnect = configuration.getString("messages.chat-connect"); + Config.messagesConnectInteractive = configuration.getString("messages.connect-interactive"); + Config.messagesDisableInteractive = configuration.getString("messages.disable-interactive"); + Config.messagesEstablishedNotConnected = configuration.getString("messages.established-not-connected"); + Config.messagesPause = configuration.getString("messages.pause"); + Config.messagesResume = configuration.getString("messages.resume"); + if (!isRunning) { String token = configuration.getString("token"); - api = new Main(token, new Mixer()); + api = new Main(token, new Actions()); } } @@ -161,7 +175,6 @@ public void onEnable() { this.reloadConfig(); loadConfig(); - //registering permissions PluginManager pm = this.getServer().getPluginManager(); Permission basePerm = new Permission(Config.permPrefix + ".*"); @@ -189,6 +202,6 @@ public void onEnable() { } String token = this.getConfig().getString("token"); - api = new Main(token, new Mixer()); + api = new Main(token, new Actions()); } } diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/MainCommand.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/MainCommand.java index bfdfbce..42653da 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/MainCommand.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/MainCommand.java @@ -3,21 +3,27 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; +import org.bukkit.configuration.file.FileConfiguration; import pro.kdray.funniray.mixer.Commands; import pro.kdray.funniray.mixer.MixerSpigot; import java.util.ArrayList; +import static pro.kdray.funniray.mixer.MixerSpigot.plugin; + public class MainCommand extends BukkitCommand { public MainCommand() { super(Commands.MAIN.getName(), Commands.MAIN.getDescription(), Commands.MAIN.getUsage(), new ArrayList<>()); } + FileConfiguration cfg = plugin.getConfig(); + String prefix = cfg.getString("messages.prefix"); + @Override public boolean execute(CommandSender commandSender, String s, String[] strings) { if (!commandSender.hasPermission(Commands.MAIN.getPermission().getNode())) { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer] " + ChatColor.RESET + ChatColor.RED + "You do not have permission to run this command"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.no-permission"))); return true; } switch (strings.length) { @@ -26,7 +32,7 @@ public boolean execute(CommandSender commandSender, String s, String[] strings) case 1: if (strings[0].equals("reload")) { MixerSpigot.reload(); - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer] " + ChatColor.RESET + ChatColor.BLUE + "Reloaded the config"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.reload-config"))); return true; } else { return false; @@ -35,7 +41,7 @@ public boolean execute(CommandSender commandSender, String s, String[] strings) if (strings[0].equals("token")) { MixerSpigot.setConfig("token", strings[1]); MixerSpigot.reload(); - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer] " + ChatColor.RESET + ChatColor.BLUE + "Set token!"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.set-token"))); return true; } else { return false; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Pause.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Pause.java index 604789f..9c1ccf6 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Pause.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Pause.java @@ -3,27 +3,33 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; +import org.bukkit.configuration.file.FileConfiguration; import pro.kdray.funniray.mixer.Commands; import pro.kdray.funniray.mixer.MixerSpigot; import java.util.ArrayList; +import static pro.kdray.funniray.mixer.MixerSpigot.plugin; + public class Pause extends BukkitCommand { public Pause() { super(Commands.PAUSE.getName(), Commands.PAUSE.getDescription(), Commands.PAUSE.getUsage(), new ArrayList<>()); } + FileConfiguration cfg = plugin.getConfig(); + String prefix = cfg.getString("messages.prefix"); + @Override public boolean execute(CommandSender commandSender, String s, String[] strings) { if (!commandSender.hasPermission(Commands.PAUSE.getPermission().getNode())) { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer] " + ChatColor.RESET + ChatColor.RED + "You do not have permission to run this command"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.no-permission"))); return true; } if (MixerSpigot.isRunning()) { MixerSpigot.getApi().getInteractive().pause(); } else { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer]" + ChatColor.RESET + ChatColor.RED + " Interactive isn't running"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.not-running"))); } return true; } diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/ResetScene.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/ResetScene.java index ea95218..c6c6e7b 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/ResetScene.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/ResetScene.java @@ -3,30 +3,36 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; +import org.bukkit.configuration.file.FileConfiguration; import pro.kdray.funniray.mixer.Commands; import pro.kdray.funniray.mixer.MixerSpigot; import java.util.ArrayList; +import static pro.kdray.funniray.mixer.MixerSpigot.plugin; + public class ResetScene extends BukkitCommand { public ResetScene() { super(Commands.RESETSCENE.getName(), Commands.RESETSCENE.getDescription(), Commands.RESETSCENE.getUsage(), new ArrayList<>()); } + FileConfiguration cfg = plugin.getConfig(); + String prefix = cfg.getString("messages.prefix"); + @Override public boolean execute(CommandSender commandSender, String s, String[] strings) { if (!commandSender.hasPermission(Commands.RESETSCENE.getPermission().getNode())) { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer] " + ChatColor.RESET + ChatColor.RED + "You do not have permission to run this command"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.no-permission"))); return true; } if (strings.length == 0) { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer]" + ChatColor.RESET + ChatColor.RED + " You need to provide a valid scene"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.invalid-scene"))); } if (MixerSpigot.isRunning()) { MixerSpigot.getApi().getInteractive().resetScene(strings[0]); } else { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer]" + ChatColor.RESET + ChatColor.RED + " Interactive isn't running"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.not-running"))); } return true; } diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Start.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Start.java index b97391a..d48e590 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Start.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Start.java @@ -3,27 +3,33 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; +import org.bukkit.configuration.file.FileConfiguration; import pro.kdray.funniray.mixer.Commands; import pro.kdray.funniray.mixer.MixerSpigot; import java.util.ArrayList; +import static pro.kdray.funniray.mixer.MixerSpigot.plugin; + public class Start extends BukkitCommand { public Start() { super(Commands.START.getName(), Commands.START.getDescription(), Commands.START.getUsage(), new ArrayList<>()); } + FileConfiguration cfg = plugin.getConfig(); + String prefix = cfg.getString("messages.prefix"); + @Override public boolean execute(CommandSender commandSender, String s, String[] strings) { if (!commandSender.hasPermission(Commands.START.getPermission().getNode())) { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer] " + ChatColor.RESET + ChatColor.RED + "You do not have permission to run this command"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.no-permission"))); return true; } if (!MixerSpigot.isRunning()) { MixerSpigot.startMain(); } else { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer]" + ChatColor.RESET + ChatColor.RED + " Interactive is already running"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.already-running"))); } return true; } diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Stop.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Stop.java index 9ce7cab..075634d 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Stop.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/Stop.java @@ -3,27 +3,33 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; +import org.bukkit.configuration.file.FileConfiguration; import pro.kdray.funniray.mixer.Commands; import pro.kdray.funniray.mixer.MixerSpigot; import java.util.ArrayList; +import static pro.kdray.funniray.mixer.MixerSpigot.plugin; + public class Stop extends BukkitCommand { public Stop() { super(Commands.STOP.getName(), Commands.STOP.getDescription(), Commands.STOP.getUsage(), new ArrayList<>()); } + FileConfiguration cfg = plugin.getConfig(); + String prefix = cfg.getString("messages.prefix"); + @Override public boolean execute(CommandSender commandSender, String s, String[] strings) { if (!commandSender.hasPermission(Commands.STOP.getPermission().getNode())) { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer] " + ChatColor.RESET + ChatColor.RED + "You do not have permission to run this command"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.no-permission"))); return true; } if (MixerSpigot.isRunning()) { MixerSpigot.stopMain(); } else { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer]" + ChatColor.RESET + ChatColor.RED + " Interactive isn't running"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.not-running"))); } return true; } diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/SwitchScene.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/SwitchScene.java index 1f04133..1052d3b 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/SwitchScene.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/command/SwitchScene.java @@ -3,29 +3,35 @@ import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.BukkitCommand; +import org.bukkit.configuration.file.FileConfiguration; import pro.kdray.funniray.mixer.Commands; import pro.kdray.funniray.mixer.MixerSpigot; import java.util.ArrayList; +import static pro.kdray.funniray.mixer.MixerSpigot.plugin; + public class SwitchScene extends BukkitCommand { public SwitchScene() { super(Commands.SWITCHSCENE.getName(), Commands.SWITCHSCENE.getDescription(), Commands.SWITCHSCENE.getUsage(), new ArrayList<>()); } + FileConfiguration cfg = plugin.getConfig(); + String prefix = cfg.getString("messages.prefix"); + @Override public boolean execute(CommandSender commandSender, String s, String[] strings) { if (!commandSender.hasPermission(Commands.SWITCHSCENE.getPermission().getNode())) { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer] " + ChatColor.RESET + ChatColor.RED + "You do not have permission to run this command"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.no-permission"))); return true; } if (strings.length == 0) { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer]" + ChatColor.RESET + ChatColor.RED + " You need to provide a valid scene"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.invalid-scene"))); } if (MixerSpigot.isRunning()) { MixerSpigot.getApi().getInteractive().switchAllScenes(strings[0]); } else { - commandSender.sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "[Mixer]" + ChatColor.RESET + ChatColor.RED + " Interactive isn't running"); + commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + cfg.getString("messages.not-running"))); } return true; } diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/NullHandler.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/unknown/NullHandler.java similarity index 88% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/NullHandler.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/unknown/NullHandler.java index 0a148e1..12f275c 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/NullHandler.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/unknown/NullHandler.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility; +package pro.kdray.funniray.mixer.compatibility.unknown; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/VersionHandler.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/unknown/VersionHandler.java similarity index 85% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/VersionHandler.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/unknown/VersionHandler.java index d35487c..03172cc 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/VersionHandler.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/unknown/VersionHandler.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility; +package pro.kdray.funniray.mixer.compatibility.unknown; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_10/Handler_1_10_R1.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_10/Handler_1_10_R1.java similarity index 96% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_10/Handler_1_10_R1.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_10/Handler_1_10_R1.java index 695e456..a9997f4 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_10/Handler_1_10_R1.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_10/Handler_1_10_R1.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility.v1_10; +package pro.kdray.funniray.mixer.compatibility.v1_10; import net.minecraft.server.v1_10_R1.PacketPlayOutTitle; import net.minecraft.server.v1_10_R1.IChatBaseComponent; @@ -7,7 +7,7 @@ import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; import org.bukkit.entity.Player; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_11/Handler_1_11_R1.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_11/Handler_1_11_R1.java similarity index 96% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_11/Handler_1_11_R1.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_11/Handler_1_11_R1.java index 9d52e69..e4c7f2d 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_11/Handler_1_11_R1.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_11/Handler_1_11_R1.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility.v1_11; +package pro.kdray.funniray.mixer.compatibility.v1_11; import net.minecraft.server.v1_11_R1.IChatBaseComponent; import net.minecraft.server.v1_11_R1.PacketPlayOutChat; @@ -7,7 +7,7 @@ import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; import org.bukkit.entity.Player; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_12/Handler_1_12_R1.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_12/Handler_1_12_R1.java similarity index 97% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_12/Handler_1_12_R1.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_12/Handler_1_12_R1.java index fdcc83e..2b4e72d 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_12/Handler_1_12_R1.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_12/Handler_1_12_R1.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility.v1_12; +package pro.kdray.funniray.mixer.compatibility.v1_12; import net.minecraft.server.v1_12_R1.ChatMessageType; import net.minecraft.server.v1_12_R1.IChatBaseComponent; @@ -8,7 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_13/Handler_1_13_R1.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_13/Handler_1_13_R1.java similarity index 97% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_13/Handler_1_13_R1.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_13/Handler_1_13_R1.java index ff19d57..68d00ee 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_13/Handler_1_13_R1.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_13/Handler_1_13_R1.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility.v1_13; +package pro.kdray.funniray.mixer.compatibility.v1_13; import net.minecraft.server.v1_13_R1.ChatMessageType; import net.minecraft.server.v1_13_R1.IChatBaseComponent; @@ -8,7 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer; import org.bukkit.entity.Player; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_13/Handler_1_13_R2.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_13/Handler_1_13_R2.java similarity index 97% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_13/Handler_1_13_R2.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_13/Handler_1_13_R2.java index 8c2c2bb..1866e37 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_13/Handler_1_13_R2.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_13/Handler_1_13_R2.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility.v1_13; +package pro.kdray.funniray.mixer.compatibility.v1_13; import net.minecraft.server.v1_13_R2.ChatMessageType; import net.minecraft.server.v1_13_R2.IChatBaseComponent; @@ -8,7 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer; import org.bukkit.entity.Player; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_14/Handler_1_14_R1.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_14/Handler_1_14_R1.java similarity index 97% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_14/Handler_1_14_R1.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_14/Handler_1_14_R1.java index 54ade7a..e2ff23b 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_14/Handler_1_14_R1.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_14/Handler_1_14_R1.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility.v1_14; +package pro.kdray.funniray.mixer.compatibility.v1_14; import net.minecraft.server.v1_14_R1.ChatMessageType; import net.minecraft.server.v1_14_R1.IChatBaseComponent; @@ -8,7 +8,7 @@ import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.entity.Player; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_9/Handler_1_9_R1.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_9/Handler_1_9_R1.java similarity index 96% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_9/Handler_1_9_R1.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_9/Handler_1_9_R1.java index be6b3f1..10ec0ca 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_9/Handler_1_9_R1.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_9/Handler_1_9_R1.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility.v1_9; +package pro.kdray.funniray.mixer.compatibility.v1_9; import net.minecraft.server.v1_9_R1.IChatBaseComponent; import net.minecraft.server.v1_9_R1.PacketPlayOutChat; @@ -7,7 +7,7 @@ import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; import org.bukkit.entity.Player; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_9/Handler_1_9_R2.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_9/Handler_1_9_R2.java similarity index 96% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_9/Handler_1_9_R2.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_9/Handler_1_9_R2.java index 93356c1..03a2246 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compadibility/v1_9/Handler_1_9_R2.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/compatibility/v1_9/Handler_1_9_R2.java @@ -1,4 +1,4 @@ -package pro.kdray.funniray.mixer.compadibility.v1_9; +package pro.kdray.funniray.mixer.compatibility.v1_9; import net.minecraft.server.v1_9_R2.IChatBaseComponent; import net.minecraft.server.v1_9_R2.PacketPlayOutChat; @@ -7,7 +7,7 @@ import org.bukkit.ChatColor; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; import org.bukkit.entity.Player; -import pro.kdray.funniray.mixer.compadibility.VersionHandler; +import pro.kdray.funniray.mixer.compatibility.unknown.VersionHandler; import javax.annotation.Nullable; diff --git a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/events/Mixer.java b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/events/Actions.java similarity index 80% rename from mixer-spigot/src/main/java/pro/kdray/funniray/mixer/events/Mixer.java rename to mixer-spigot/src/main/java/pro/kdray/funniray/mixer/events/Actions.java index 7041395..44abce3 100644 --- a/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/events/Mixer.java +++ b/mixer-spigot/src/main/java/pro/kdray/funniray/mixer/events/Actions.java @@ -2,12 +2,16 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import pro.kdray.funniray.mixer.MixerEvents; import pro.kdray.funniray.mixer.MixerSpigot; import pro.kdray.funniray.mixer.Permissions; -public class Mixer implements MixerEvents { +import static pro.kdray.funniray.mixer.MixerSpigot.plugin; + +public class Actions implements MixerEvents { + FileConfiguration cfg = plugin.getConfig(); @Override public void sendMessage(String message) { String formatted = ChatColor.translateAlternateColorCodes('&',message); @@ -35,7 +39,13 @@ public void sendActionBar(String title) { @Override public void summon(String entity) { - runCommandAsConsole("execute %streamer% ~ ~ ~ summon "+entity); + Bukkit.getScheduler().runTask(MixerSpigot.plugin,() -> { + for(Player player:Bukkit.getOnlinePlayers()){ + if (!player.hasPermission(Permissions.RUNCOMMANDS.getNode())) + continue; + Bukkit.getServer().dispatchCommand(player,cfg.getString("actions.summon").replace("%streamer",player.getName()).replace("%entity",entity)); + } + }); } @Override diff --git a/mixer-spigot/src/main/resources/config.yml b/mixer-spigot/src/main/resources/config.yml index 4fe1f96..dca70df 100644 --- a/mixer-spigot/src/main/resources/config.yml +++ b/mixer-spigot/src/main/resources/config.yml @@ -1,5 +1,5 @@ #Look here: https://github.com/funniray/Mixer/wiki/Setting-up-the-project -token: Api key here +token: OAuth token #If you're using the oauth from the wiki, you don't need to touch this clientID: d04e85fd1cb06e4eb9891fc118fe75893eca399955189926 #Retrieved from the sharing panel in the top right of the editor @@ -8,9 +8,30 @@ shareCode: dbzktlsk projectID: 191773 followCommand: command -subscriberCommand: command -resubscriberCommand: command +subscribeCommand: command +resubscribeCommand: command bannedWords: - - "put multiple" - - "words to remove from chat here" \ No newline at end of file + - "blocked words" + +actions: + summon: "execute %player ~ ~ ~ summon %entity" + +messages: + #You can use color codes here :) + prefix: "&6Mixer &8| " + reload-config: "&aConfig reloaded!" + no-permission: "&cYou do not have permission to execute this command!" + start-failed: "&cFailed to start interactive! (Could be due to invalid API key)" + set-token: "&aToken has been successfully set!" + not-running: "&cInteractive is not running!" + already-running: "&cInteractive is already running!" + invalid-scene: "&cYou need to provide a valid scene" + + #MixerAPI related + chat-connect: "&aChat Connected!" + connect-interactive: "&aInteractive connected!" + disable-interactive: "&cInteractive has been disabled!" + established-not-connected: "&cConnection was established but isn't connected!" + pause: "Buttons have been paused" + resume: "Buttons have been resumed" \ No newline at end of file diff --git a/mixer-sponge/src/main/java/pro/kdray/funniray/mixer/MixerSponge.java b/mixer-sponge/src/main/java/pro/kdray/funniray/mixer/MixerSponge.java index af168c0..a656318 100644 --- a/mixer-sponge/src/main/java/pro/kdray/funniray/mixer/MixerSponge.java +++ b/mixer-sponge/src/main/java/pro/kdray/funniray/mixer/MixerSponge.java @@ -10,7 +10,6 @@ import org.slf4j.Logger; import org.spongepowered.api.Game; import org.spongepowered.api.Sponge; -import org.spongepowered.api.command.CommandMapping; import org.spongepowered.api.config.DefaultConfig; import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.game.state.GameStartedServerEvent; @@ -25,7 +24,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Optional; import java.util.concurrent.ExecutionException; @Plugin(id = "mixer-sponge", description = "A Mixer Interactive Plugin", name = "Mixer Interactive Plugin", version = "@version@") @@ -133,8 +131,8 @@ public static void loadConfig() { Config.shareCode = localConfig.getNode("clientID").getString(); Config.followCommand = localConfig.getNode("followCommand").getString(); - Config.subscriberCommand = localConfig.getNode("subscriberCommand").getString(); - Config.resubscriberCommand = localConfig.getNode("resubscriberCommand").getString(); + Config.subscribeCommand = localConfig.getNode("subscribeCommand").getString(); + Config.resubscribeCommand = localConfig.getNode("resubscriberCommand").getString(); try { Config.bannedWords = localConfig.getNode("bannedWords").getList(TypeToken.of(String.class));