mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-25 03:55:35 +01:00
NEW sql support for Bungee via plugin, fixes #1836
This commit is contained in:
parent
5befbb1e8c
commit
2bfbc68cfa
@ -12,31 +12,37 @@
|
|||||||
|
|
||||||
package me.blackvein.quests;
|
package me.blackvein.quests;
|
||||||
|
|
||||||
import me.blackvein.quests.actions.IAction;
|
|
||||||
import me.blackvein.quests.actions.ActionFactory;
|
import me.blackvein.quests.actions.ActionFactory;
|
||||||
import me.blackvein.quests.conditions.ICondition;
|
import me.blackvein.quests.actions.IAction;
|
||||||
import me.blackvein.quests.conditions.ConditionFactory;
|
import me.blackvein.quests.conditions.ConditionFactory;
|
||||||
|
import me.blackvein.quests.conditions.ICondition;
|
||||||
import me.blackvein.quests.config.ISettings;
|
import me.blackvein.quests.config.ISettings;
|
||||||
import me.blackvein.quests.dependencies.IDependencies;
|
import me.blackvein.quests.dependencies.IDependencies;
|
||||||
import me.blackvein.quests.module.ICustomObjective;
|
import me.blackvein.quests.module.ICustomObjective;
|
||||||
import me.blackvein.quests.player.IQuester;
|
import me.blackvein.quests.player.IQuester;
|
||||||
import me.blackvein.quests.quests.IQuest;
|
import me.blackvein.quests.quests.IQuest;
|
||||||
import me.blackvein.quests.quests.QuestFactory;
|
import me.blackvein.quests.quests.QuestFactory;
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.conversations.ConversationFactory;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public interface QuestsAPI extends Plugin {
|
public interface QuestsAPI {
|
||||||
|
|
||||||
boolean isLoading();
|
boolean isLoading();
|
||||||
|
|
||||||
String getDetectedServerSoftwareVersion();
|
String getDetectedServerSoftwareVersion();
|
||||||
|
|
||||||
|
File getPluginDataFolder();
|
||||||
|
|
||||||
|
Logger getPluginLogger();
|
||||||
|
|
||||||
|
InputStream getPluginResource(String filename);
|
||||||
|
|
||||||
IDependencies getDependencies();
|
IDependencies getDependencies();
|
||||||
|
|
||||||
ISettings getSettings();
|
ISettings getSettings();
|
||||||
@ -65,12 +71,6 @@ public interface QuestsAPI extends Plugin {
|
|||||||
|
|
||||||
void setQuestNpcIds(final LinkedList<Integer> questNpcIds);
|
void setQuestNpcIds(final LinkedList<Integer> questNpcIds);
|
||||||
|
|
||||||
CommandExecutor getCommandExecutor();
|
|
||||||
|
|
||||||
ConversationFactory getConversationFactory();
|
|
||||||
|
|
||||||
ConversationFactory getNpcConversationFactory();
|
|
||||||
|
|
||||||
QuestFactory getQuestFactory();
|
QuestFactory getQuestFactory();
|
||||||
|
|
||||||
ActionFactory getActionFactory();
|
ActionFactory getActionFactory();
|
||||||
|
@ -36,7 +36,7 @@ public class DenizenAPI_1_0_9 {
|
|||||||
try {
|
try {
|
||||||
script = (boolean)api.containsScriptMethod.invoke(api.scriptRegistry, input);
|
script = (boolean)api.containsScriptMethod.invoke(api.scriptRegistry, input);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#containsScript", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#containsScript", e);
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ public class DenizenAPI_1_0_9 {
|
|||||||
instance = constructor.newInstance(null, input);
|
instance = constructor.newInstance(null, input);
|
||||||
name = (String)instance.getClass().getMethod("getName").invoke(api.scriptContainer);
|
name = (String)instance.getClass().getMethod("getName").invoke(api.scriptContainer);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen ScriptContainer#getName", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen ScriptContainer#getName", e);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ public class DenizenAPI_1_0_9 {
|
|||||||
try {
|
try {
|
||||||
names = (Set<String>)api.getScriptNamesMethod.invoke(api.scriptRegistry);
|
names = (Set<String>)api.getScriptNamesMethod.invoke(api.scriptRegistry);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#_getScriptNames", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#_getScriptNames", e);
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ public class DenizenAPI_1_0_9 {
|
|||||||
try {
|
try {
|
||||||
container = api.getScriptContainerAsMethod.invoke(api.scriptRegistry, scriptName, api.taskScriptContainer);
|
container = api.getScriptContainerAsMethod.invoke(api.scriptRegistry, scriptName, api.taskScriptContainer);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen #getScriptContainerAs", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen #getScriptContainerAs", e);
|
||||||
}
|
}
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ public class DenizenAPI_1_0_9 {
|
|||||||
try {
|
try {
|
||||||
dp = api.mirrorBukkitPlayerMethod.invoke(api.dPlayer, player);
|
dp = api.mirrorBukkitPlayerMethod.invoke(api.dPlayer, player);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen dPlayer#mirrorBukkitPlayer", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen dPlayer#mirrorBukkitPlayer", e);
|
||||||
}
|
}
|
||||||
return dp;
|
return dp;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ public class DenizenAPI_1_0_9 {
|
|||||||
try {
|
try {
|
||||||
dp = api.mirrorCitizensNPCMethod.invoke(api.dNPC, npc);
|
dp = api.mirrorCitizensNPCMethod.invoke(api.dNPC, npc);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen dNPC#mirrorCitizensNPC", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen dNPC#mirrorCitizensNPC", e);
|
||||||
}
|
}
|
||||||
return dp;
|
return dp;
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ public class DenizenAPI_1_0_9 {
|
|||||||
runTaskScript.invoke(tsc, constructor.newInstance(mirrorBukkitPlayer(player), null), null);
|
runTaskScript.invoke(tsc, constructor.newInstance(mirrorBukkitPlayer(player), null), null);
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen TaskScriptContainer#runTaskScript", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen TaskScriptContainer#runTaskScript", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class DenizenAPI_1_1_0 {
|
|||||||
try {
|
try {
|
||||||
script = (boolean)api.containsScriptMethod.invoke(api.scriptRegistry, input);
|
script = (boolean)api.containsScriptMethod.invoke(api.scriptRegistry, input);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#containsScript", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#containsScript", e);
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ public class DenizenAPI_1_1_0 {
|
|||||||
try {
|
try {
|
||||||
names = (Set<String>)api.getScriptNamesMethod.invoke(api.scriptRegistry);
|
names = (Set<String>)api.getScriptNamesMethod.invoke(api.scriptRegistry);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#_getScriptNames", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#_getScriptNames", e);
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ public class DenizenAPI_1_1_0 {
|
|||||||
runTaskScript.invoke(tsc, constructor.newInstance(mirrorBukkitPlayer(player), null), null);
|
runTaskScript.invoke(tsc, constructor.newInstance(mirrorBukkitPlayer(player), null), null);
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen TaskScriptContainer#runTaskScript", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen TaskScriptContainer#runTaskScript", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class DenizenAPI_1_1_1 {
|
|||||||
try {
|
try {
|
||||||
script = (boolean)api.containsScriptMethod.invoke(api.scriptRegistry, input);
|
script = (boolean)api.containsScriptMethod.invoke(api.scriptRegistry, input);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#containsScript", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen ScriptRegistry#containsScript", e);
|
||||||
}
|
}
|
||||||
return script;
|
return script;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ public class DenizenAPI_1_1_1 {
|
|||||||
addEntries.invoke(queue, taskScript.getBaseEntries(entryData.clone()));
|
addEntries.invoke(queue, taskScript.getBaseEntries(entryData.clone()));
|
||||||
queue.start();
|
queue.start();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
quests.getLogger().log(Level.WARNING, "Error invoking Denizen InstantQueue#addEntries", e);
|
quests.getPluginLogger().log(Level.WARNING, "Error invoking Denizen InstantQueue#addEntries", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,9 +126,9 @@ public class Lang {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void init(final QuestsAPI plugin) throws InvalidConfigurationException, IOException {
|
public static void init(final QuestsAPI plugin) throws InvalidConfigurationException, IOException {
|
||||||
final File langFile = new File(plugin.getDataFolder(), File.separator + "lang" + File.separator + iso + File.separator
|
final File langFile = new File(plugin.getPluginDataFolder(), File.separator + "lang" + File.separator + iso + File.separator
|
||||||
+ "strings.yml");
|
+ "strings.yml");
|
||||||
final File langFile_new = new File(plugin.getDataFolder(), File.separator + "lang" + File.separator + iso
|
final File langFile_new = new File(plugin.getPluginDataFolder(), File.separator + "lang" + File.separator + iso
|
||||||
+ File.separator + "strings_new.yml");
|
+ File.separator + "strings_new.yml");
|
||||||
final boolean exists_new = langFile_new.exists();
|
final boolean exists_new = langFile_new.exists();
|
||||||
final LinkedHashMap<String, String> allStrings = new LinkedHashMap<>();
|
final LinkedHashMap<String, String> allStrings = new LinkedHashMap<>();
|
||||||
@ -153,7 +153,7 @@ public class Lang {
|
|||||||
final String value = config_new.getString(key);
|
final String value = config_new.getString(key);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
allStrings.put(key, value);
|
allStrings.put(key, value);
|
||||||
plugin.getLogger().warning("There are new language phrases in /lang/" + iso
|
plugin.getPluginLogger().warning("There are new language phrases in /lang/" + iso
|
||||||
+ "/strings_new.yml for the current version!"
|
+ "/strings_new.yml for the current version!"
|
||||||
+ " You must transfer them to, or regenerate, strings.yml to remove this warning!");
|
+ " You must transfer them to, or regenerate, strings.yml to remove this warning!");
|
||||||
}
|
}
|
||||||
@ -165,19 +165,19 @@ public class Lang {
|
|||||||
config_new.save(langFile_new);
|
config_new.save(langFile_new);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
plugin.getLogger().severe("Failed loading lang files for " + iso
|
plugin.getPluginLogger().severe("Failed loading lang files for " + iso
|
||||||
+ " because they were not found. Using default en-US");
|
+ " because they were not found. Using default en-US");
|
||||||
plugin.getLogger()
|
plugin.getPluginLogger()
|
||||||
.info("If the plugin has not generated language files, ensure Quests has write permissions");
|
.info("If the plugin has not generated language files, ensure Quests has write permissions");
|
||||||
plugin.getLogger()
|
plugin.getPluginLogger()
|
||||||
.info("For help, visit https://github.com/PikaMug/Quests/wiki/Casual-%E2%80%90-Translations");
|
.info("For help, visit https://github.com/PikaMug/Quests/wiki/Casual-%E2%80%90-Translations");
|
||||||
iso = "en-US";
|
iso = "en-US";
|
||||||
plugin.getLogger().info("CodeSource: " + plugin.getClass().getProtectionDomain().getCodeSource()
|
plugin.getPluginLogger().info("CodeSource: " + plugin.getClass().getProtectionDomain().getCodeSource()
|
||||||
.toString());
|
.toString());
|
||||||
plugin.getLogger().info("LocationPath: " + plugin.getClass().getProtectionDomain().getCodeSource()
|
plugin.getPluginLogger().info("LocationPath: " + plugin.getClass().getProtectionDomain().getCodeSource()
|
||||||
.getLocation().getPath());
|
.getLocation().getPath());
|
||||||
final FileConfiguration config = YamlConfiguration.loadConfiguration(new InputStreamReader(Objects
|
final FileConfiguration config = YamlConfiguration.loadConfiguration(new InputStreamReader(Objects
|
||||||
.requireNonNull(plugin.getResource("strings.yml")), StandardCharsets.UTF_8));
|
.requireNonNull(plugin.getPluginResource("strings.yml")), StandardCharsets.UTF_8));
|
||||||
for (final String key : config.getKeys(false)) {
|
for (final String key : config.getKeys(false)) {
|
||||||
allStrings.put(key, config.getString(key));
|
allStrings.put(key, config.getString(key));
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ public class Lang {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
langMap.putAll(allStrings);
|
langMap.putAll(allStrings);
|
||||||
plugin.getLogger().info("Loaded language " + iso + ". Translations via Crowdin");
|
plugin.getPluginLogger().info("Loaded language " + iso + ". Translations via Crowdin");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LangToken {
|
private static class LangToken {
|
||||||
|
54
bungee/pom.xml
Normal file
54
bungee/pom.xml
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
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>
|
||||||
|
<parent>
|
||||||
|
<artifactId>quests-parent</artifactId>
|
||||||
|
<groupId>me.blackvein.quests</groupId>
|
||||||
|
<version>4.2.2</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>quests-bungee</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>bungeecord-repo</id>
|
||||||
|
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
<artifactId>bungeecord-api</artifactId>
|
||||||
|
<version>1.16-R0.5-SNAPSHOT</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.md-5</groupId>
|
||||||
|
<artifactId>bungeecord-api</artifactId>
|
||||||
|
<version>1.16-R0.5-SNAPSHOT</version>
|
||||||
|
<type>javadoc</type>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>Quests-Bungee-${project.version}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
23
bungee/src/main/java/me/blackvein/quests/QuestsBungee.java
Normal file
23
bungee/src/main/java/me/blackvein/quests/QuestsBungee.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package me.blackvein.quests;
|
||||||
|
|
||||||
|
import me.blackvein.quests.listeners.BungeePlayerListener;
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
|
||||||
|
public class QuestsBungee extends Plugin {
|
||||||
|
private static final String CHANNEL = "quests:update";
|
||||||
|
|
||||||
|
private BungeePlayerListener playerListener;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
playerListener = new BungeePlayerListener(this);
|
||||||
|
getProxy().registerChannel(CHANNEL);
|
||||||
|
getProxy().getPluginManager().registerListener(this, playerListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
getProxy().unregisterChannel(CHANNEL);
|
||||||
|
getProxy().getPluginManager().unregisterListener(playerListener);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,52 @@
|
|||||||
|
package me.blackvein.quests.listeners;
|
||||||
|
|
||||||
|
import me.blackvein.quests.QuestsBungee;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
|
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||||
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class BungeePlayerListener implements Listener {
|
||||||
|
private static final String CHANNEL = "quests:update";
|
||||||
|
|
||||||
|
private final QuestsBungee plugin;
|
||||||
|
|
||||||
|
public BungeePlayerListener(QuestsBungee plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLogin(ServerSwitchEvent evt) {
|
||||||
|
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
|
||||||
|
try {
|
||||||
|
dataOutputStream.writeUTF("LoadData:" + evt.getPlayer().getUniqueId());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
dispatchMessage(byteArrayOutputStream.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDisconnect(PlayerDisconnectEvent evt) {
|
||||||
|
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
|
final DataOutputStream dataOutputStream = new DataOutputStream(byteArrayOutputStream);
|
||||||
|
try {
|
||||||
|
dataOutputStream.writeUTF("SaveData:" + evt.getPlayer().getUniqueId());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
dispatchMessage(byteArrayOutputStream.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dispatchMessage(byte[] message) {
|
||||||
|
for (ServerInfo server : plugin.getProxy().getServers().values()) {
|
||||||
|
server.sendData(CHANNEL, message, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
bungee/src/main/resources/bungee.yml
Normal file
5
bungee/src/main/resources/bungee.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
name: QuestsBungee
|
||||||
|
main: me.blackvein.quests.QuestsBungee
|
||||||
|
version: ${project.version}-b${env.BUILD_NUMBER}
|
||||||
|
description: An extensive questing system.
|
||||||
|
author: PikaMug
|
@ -37,6 +37,7 @@ import me.blackvein.quests.exceptions.QuestFormatException;
|
|||||||
import me.blackvein.quests.exceptions.StageFormatException;
|
import me.blackvein.quests.exceptions.StageFormatException;
|
||||||
import me.blackvein.quests.interfaces.ReloadCallback;
|
import me.blackvein.quests.interfaces.ReloadCallback;
|
||||||
import me.blackvein.quests.listeners.BlockListener;
|
import me.blackvein.quests.listeners.BlockListener;
|
||||||
|
import me.blackvein.quests.listeners.BungeeListener;
|
||||||
import me.blackvein.quests.listeners.CommandManager;
|
import me.blackvein.quests.listeners.CommandManager;
|
||||||
import me.blackvein.quests.listeners.ConvoListener;
|
import me.blackvein.quests.listeners.ConvoListener;
|
||||||
import me.blackvein.quests.listeners.ItemListener;
|
import me.blackvein.quests.listeners.ItemListener;
|
||||||
@ -136,6 +137,7 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Quests extends JavaPlugin implements QuestsAPI {
|
public class Quests extends JavaPlugin implements QuestsAPI {
|
||||||
|
|
||||||
@ -159,6 +161,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
private ConditionFactory conditionFactory;
|
private ConditionFactory conditionFactory;
|
||||||
private ConvoListener convoListener;
|
private ConvoListener convoListener;
|
||||||
private BlockListener blockListener;
|
private BlockListener blockListener;
|
||||||
|
private BungeeListener bungeeListener;
|
||||||
private ItemListener itemListener;
|
private ItemListener itemListener;
|
||||||
private NpcListener npcListener;
|
private NpcListener npcListener;
|
||||||
private PlayerListener playerListener;
|
private PlayerListener playerListener;
|
||||||
@ -187,6 +190,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
}
|
}
|
||||||
convoListener = new ConvoListener();
|
convoListener = new ConvoListener();
|
||||||
blockListener = new BlockListener(this);
|
blockListener = new BlockListener(this);
|
||||||
|
bungeeListener = new BungeeListener(this);
|
||||||
itemListener = new ItemListener(this);
|
itemListener = new ItemListener(this);
|
||||||
npcListener = new NpcListener(this);
|
npcListener = new NpcListener(this);
|
||||||
playerListener = new PlayerListener(this);
|
playerListener = new PlayerListener(this);
|
||||||
@ -267,6 +271,9 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
} else if (depends.getPartiesApi() != null) {
|
} else if (depends.getPartiesApi() != null) {
|
||||||
getServer().getPluginManager().registerEvents(getPartiesListener(), this);
|
getServer().getPluginManager().registerEvents(getPartiesListener(), this);
|
||||||
}
|
}
|
||||||
|
if (hasBungeeEnabled()) {
|
||||||
|
getServer().getMessenger().registerIncomingPluginChannel(this, "quests:update", bungeeListener);
|
||||||
|
}
|
||||||
|
|
||||||
// 11 - Attempt to check for updates
|
// 11 - Attempt to check for updates
|
||||||
new UpdateChecker(this, 3711).getVersion(version -> {
|
new UpdateChecker(this, 3711).getVersion(version -> {
|
||||||
@ -276,7 +283,7 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 12 - Delay loading of Quests, Actions and modules
|
// 12 - Delay loading of quests, actions and modules
|
||||||
delayLoadQuestInfo();
|
delayLoadQuestInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,6 +305,18 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
return loading;
|
return loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getPluginDataFolder() {
|
||||||
|
return getDataFolder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Logger getPluginLogger() {
|
||||||
|
return getLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InputStream getPluginResource(String filename) {
|
||||||
|
return getResource(filename);
|
||||||
|
}
|
||||||
|
|
||||||
public String getDetectedServerSoftwareVersion() {
|
public String getDetectedServerSoftwareVersion() {
|
||||||
return bukkitVersion;
|
return bukkitVersion;
|
||||||
}
|
}
|
||||||
@ -727,6 +746,11 @@ public class Quests extends JavaPlugin implements QuestsAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasBungeeEnabled() {
|
||||||
|
final ConfigurationSection section = getServer().spigot().getConfig().getConfigurationSection("settings");
|
||||||
|
return section != null && section.getBoolean("bungeecord");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transfer language files from jar to disk
|
* Transfer language files from jar to disk
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
package me.blackvein.quests.listeners;
|
||||||
|
|
||||||
|
import me.blackvein.quests.Quester;
|
||||||
|
import me.blackvein.quests.Quests;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BungeeListener implements PluginMessageListener {
|
||||||
|
private static final String CHANNEL = "quests:update";
|
||||||
|
|
||||||
|
private final Quests plugin;
|
||||||
|
|
||||||
|
public BungeeListener(final Quests plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte[] bytes) {
|
||||||
|
if (!channel.equalsIgnoreCase(CHANNEL) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
|
||||||
|
final DataInputStream dataInputStream = new DataInputStream(byteArrayInputStream);
|
||||||
|
try {
|
||||||
|
final String input = dataInputStream.readUTF();
|
||||||
|
final UUID uuid = UUID.fromString(input.substring(input.lastIndexOf(":") + 1));
|
||||||
|
if (input.startsWith("SaveData:")) {
|
||||||
|
final Quester quester = plugin.getQuester(uuid);
|
||||||
|
if (quester != null) {
|
||||||
|
plugin.getLogger().info(ChatColor.GREEN + "[Bungee] Saved quester data for UUID " + uuid);
|
||||||
|
quester.saveData();
|
||||||
|
}
|
||||||
|
} else if (input.startsWith("LoadData:")) {
|
||||||
|
final Quester quester = plugin.getQuester(uuid);
|
||||||
|
if (quester != null) {
|
||||||
|
plugin.getLogger().info(ChatColor.GREEN + "[Bungee] Loaded quester data for UUID " + uuid);
|
||||||
|
quester.hasData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -33,9 +33,9 @@ public class NpcEffectThread implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (final Player player : plugin.getServer().getOnlinePlayers()) {
|
for (final Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
|
||||||
final List<Entity> nearby = player.getNearbyEntities(32.0, 32.0, 32.0);
|
final List<Entity> nearby = player.getNearbyEntities(32.0, 32.0, 32.0);
|
||||||
if (!nearby.isEmpty()) {
|
if (!nearby.isEmpty()) {
|
||||||
|
final IQuester quester = plugin.getQuester(player.getUniqueId());
|
||||||
for (final Entity e : nearby) {
|
for (final Entity e : nearby) {
|
||||||
if (plugin.getDependencies().getCitizens() != null
|
if (plugin.getDependencies().getCitizens() != null
|
||||||
&& plugin.getDependencies().getCitizens().getNPCRegistry() != null) {
|
&& plugin.getDependencies().getCitizens().getNPCRegistry() != null) {
|
||||||
|
@ -20,7 +20,6 @@ npc-effects:
|
|||||||
redo-quest: heart
|
redo-quest: heart
|
||||||
show-requirements: true
|
show-requirements: true
|
||||||
show-titles: true
|
show-titles: true
|
||||||
strict-player-movement: 0
|
|
||||||
storage-data:
|
storage-data:
|
||||||
address: localhost:3306
|
address: localhost:3306
|
||||||
database: minecraft
|
database: minecraft
|
||||||
@ -38,6 +37,7 @@ storage-data:
|
|||||||
characterEncoding: utf8
|
characterEncoding: utf8
|
||||||
storage-method:
|
storage-method:
|
||||||
player-data: yaml
|
player-data: yaml
|
||||||
|
strict-player-movement: 0
|
||||||
trial-save: false
|
trial-save: false
|
||||||
top-limit: 150
|
top-limit: 150
|
||||||
translate-names: true
|
translate-names: true
|
||||||
|
Loading…
Reference in New Issue
Block a user