mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-22 02:08:27 +01:00
Folia scheduling support
Plugins that depend on SubServers.Client can make use of our platform-`AgnosticScheduler` to achieve the same results
This commit is contained in:
parent
ecf76a97de
commit
ba80e0a16a
@ -28,7 +28,7 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiBase</artifactId>
|
||||
<version>23w14a</version>
|
||||
<version>23w14b</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -89,7 +89,7 @@
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-resources</phase>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
@ -97,6 +97,9 @@
|
||||
<tasks>
|
||||
<mkdir dir="${project.build.directory}" />
|
||||
<copy file="${basedir}/../../LICENSE" todir="${project.build.directory}/classes" />
|
||||
<copy overwrite="true" todir="${project.build.directory}/classes">
|
||||
<fileset dir="../../out/compile/target/SubServers.Client.Folia/classes" />
|
||||
</copy>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -8,6 +8,7 @@ import net.ME1312.Galaxi.Library.Try;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketInExRunEvent;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.Host;
|
||||
@ -30,6 +31,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static net.ME1312.SubServers.Client.Bukkit.Library.ObjectPermission.permits;
|
||||
@ -54,8 +56,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
}
|
||||
|
||||
public DefaultUIRenderer getRenderer(Player player) {
|
||||
if (!gui.containsKey(player.getUniqueId())) gui.put(player.getUniqueId(), new DefaultUIRenderer(plugin, player.getUniqueId()));
|
||||
return gui.get(player.getUniqueId());
|
||||
return gui.computeIfAbsent(player.getUniqueId(), k -> new DefaultUIRenderer(plugin, player));
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
@ -132,7 +133,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
if (m.getString("message").contains(" ")) {
|
||||
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name.Invalid-Title"), 4 * 20))
|
||||
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name.Invalid"));
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4 * 20);
|
||||
AgnosticScheduler.async.runs(plugin, c -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4, TimeUnit.SECONDS);
|
||||
} else {
|
||||
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
|
||||
plugin.api.getSubServer(m.getString("message"), server -> {
|
||||
@ -140,7 +141,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
gui.setDownloading(null);
|
||||
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name.Exists-Title"), 4 * 20))
|
||||
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Name.Exists"));
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4 * 20);
|
||||
AgnosticScheduler.async.runs(plugin, c -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4, TimeUnit.SECONDS);
|
||||
} else {
|
||||
((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).setName(m.getString("message"));
|
||||
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
|
||||
@ -172,7 +173,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
} else if (!Try.all.run(() -> Integer.parseInt(m.getString("message"))) || Integer.parseInt(m.getString("message")) <= 0 || Integer.parseInt(m.getString("message")) > 65535) {
|
||||
if (!gui.sendTitle(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Port.Invalid-Title"), 4 * 20))
|
||||
player.sendMessage(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Port.Invalid"));
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4 * 20);
|
||||
AgnosticScheduler.async.runs(plugin, c -> gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]), 4, TimeUnit.SECONDS);
|
||||
} else {
|
||||
((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]).setPort(Integer.valueOf(m.getString("message")));
|
||||
gui.hostCreator((UIRenderer.CreatorOptions) gui.lastVisitedObjects[0]);
|
||||
@ -347,7 +348,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Response"));
|
||||
((SubServer) gui.lastVisitedObjects[0]).start(player.getUniqueId(), response -> {
|
||||
gui.setDownloading(plugin.api.getLang("SubServers", "Interface.Server-Admin.Start.Title"));
|
||||
Bukkit.getScheduler().runTaskLater(plugin, gui::reopen, 30);
|
||||
AgnosticScheduler.async.runs(plugin, c -> gui.reopen(), 1500, TimeUnit.MILLISECONDS);
|
||||
});
|
||||
} else gui.reopen();
|
||||
} else if (item.equals(plugin.api.getLang("SubServers", "Interface.Server-Admin.Stop"))) {
|
||||
@ -362,7 +363,7 @@ public class DefaultUIHandler implements UIHandler, Listener {
|
||||
if (listening.value()) if (!json.getString("server").equalsIgnoreCase(((Server) gui.lastVisitedObjects[0]).getName())) {
|
||||
PacketInExRunEvent.callback("SubStoppedEvent", this);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, gui::reopen, 5);
|
||||
AgnosticScheduler.async.runs(plugin, c -> gui.reopen(), 250, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.ME1312.SubServers.Client.Bukkit.Graphic;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Container.Container;
|
||||
import net.ME1312.Galaxi.Library.Container.Value;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.Host;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.Server;
|
||||
@ -32,13 +33,9 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
int lastPage = 1;
|
||||
Runnable lastMenu = null;
|
||||
boolean open = false;
|
||||
final UUID player;
|
||||
private SubPlugin plugin;
|
||||
|
||||
DefaultUIRenderer(SubPlugin plugin, UUID player) {
|
||||
DefaultUIRenderer(SubPlugin plugin, Player player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void newUI() {
|
||||
@ -102,7 +99,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
public void hostMenu(final int page) {
|
||||
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Menu.Title")));
|
||||
plugin.api.getHosts(hosts -> plugin.api.getGroups(groups -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.api.getHosts(hosts -> plugin.api.getGroups(groups -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
setDownloading(null);
|
||||
lastVisitedObjects[0] = null;
|
||||
lastPage = page;
|
||||
@ -227,14 +224,14 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
player.openInventory(inv);
|
||||
open = true;
|
||||
})));
|
||||
}
|
||||
|
||||
public void hostAdmin(final String name) {
|
||||
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Admin.Title").replace("$str$", name)));
|
||||
plugin.api.getHost(name, host -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.api.getHost(name, host -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
windowHistory.add(() -> hostAdmin(name));
|
||||
if (host == null) {
|
||||
if (hasHistory()) back();
|
||||
@ -257,7 +254,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
i++;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(this.player);
|
||||
Player player = this.player;
|
||||
if (!permits(name, player, "subservers.host.%.*", "subservers.host.%.create")) {
|
||||
block = color(7);
|
||||
blockMeta = block.getItemMeta();
|
||||
@ -339,7 +336,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(35, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(this.player).openInventory(inv);
|
||||
player.openInventory(inv);
|
||||
open = true;
|
||||
}
|
||||
}));
|
||||
@ -350,7 +347,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
if (!options.init()) windowHistory.add(() -> hostCreator(options));
|
||||
lastVisitedObjects[0] = options;
|
||||
|
||||
plugin.api.getHost(options.getHost(), host -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.api.getHost(options.getHost(), host -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
if (host == null || !host.isAvailable() || !host.isEnabled()) {
|
||||
lastVisitedObjects[0] = null;
|
||||
if (hasHistory()) back();
|
||||
@ -466,7 +463,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(53, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
player.openInventory(inv);
|
||||
open = true;
|
||||
}
|
||||
}));
|
||||
@ -476,7 +473,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Creator.Edit-Template.Title").replace("$str$", options.getHost())));
|
||||
options.init();
|
||||
lastVisitedObjects[0] = options;
|
||||
plugin.api.getHost(options.getHost(), host -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.api.getHost(options.getHost(), host -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
if (host == null || !host.isAvailable() || !host.isEnabled()) {
|
||||
lastVisitedObjects[0] = null;
|
||||
if (hasHistory()) back();
|
||||
@ -579,7 +576,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
player.openInventory(inv);
|
||||
open = true;
|
||||
}
|
||||
}));
|
||||
@ -587,7 +584,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
public void hostPlugin(final int page, final String name) {
|
||||
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Host-Plugin.Title").replace("$str$", name)));
|
||||
plugin.api.getHost(name, host -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.api.getHost(name, host -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
windowHistory.add(() -> hostPlugin(page, name));
|
||||
if (host == null) {
|
||||
if (hasHistory()) back();
|
||||
@ -687,7 +684,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
player.openInventory(inv);
|
||||
open = true;
|
||||
}
|
||||
}));
|
||||
@ -695,7 +692,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
public void groupMenu(final int page) {
|
||||
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Group-Menu.Title")));
|
||||
plugin.api.getServers(servers -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.api.getServers(servers -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
setDownloading(null);
|
||||
lastVisitedObjects[0] = null;
|
||||
lastPage = page;
|
||||
@ -820,7 +817,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
player.openInventory(inv);
|
||||
open = true;
|
||||
}));
|
||||
}
|
||||
@ -829,7 +826,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
setDownloading(ChatColor.stripColor((host == null)?((group == null)?plugin.api.getLang("SubServers", "Interface.Server-Menu.Title"):((group.length() == 0)?plugin.api.getLang("SubServers", "Interface.Group-SubServer.Title-Ungrouped"):plugin.api.getLang("SubServers", "Interface.Group-SubServer.Title").replace("$str$", group))):plugin.api.getLang("SubServers", "Interface.Host-SubServer.Title").replace("$str$", host)));
|
||||
Value<String> hostname = new Container<String>(host);
|
||||
Value<List<Server>> servercontainer = new Container<List<Server>>(new LinkedList<Server>());
|
||||
Runnable renderer = () -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
Runnable renderer = () -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
setDownloading(null);
|
||||
lastPage = page;
|
||||
|
||||
@ -985,7 +982,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
player.openInventory(inv);
|
||||
open = true;
|
||||
});
|
||||
|
||||
@ -1018,7 +1015,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
public void serverAdmin(final String name) {
|
||||
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.Server-Admin.Title").replace("$str$", name)));
|
||||
BiConsumer<Server, Host> renderer = (server, host) -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
BiConsumer<Server, Host> renderer = (server, host) -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
setDownloading(null);
|
||||
lastVisitedObjects[0] = server;
|
||||
ItemStack block;
|
||||
@ -1038,7 +1035,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
}
|
||||
i = 0;
|
||||
|
||||
Player player = Bukkit.getPlayer(this.player);
|
||||
Player player = this.player;
|
||||
if (host == null || ((SubServer) server).isRunning()) {
|
||||
if (host == null || !permits(server, player, "subservers.subserver.%.*", "subservers.subserver.%.terminate")) {
|
||||
block = color(7);
|
||||
@ -1250,7 +1247,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
|
||||
public void serverPlugin(final int page, final String name) {
|
||||
setDownloading(ChatColor.stripColor(plugin.api.getLang("SubServers", "Interface.SubServer-Plugin.Title").replace("$str$", name)));
|
||||
plugin.api.getServer(name, server -> Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
plugin.api.getServer(name, server -> AgnosticScheduler.following(player).runs(plugin, c -> {
|
||||
windowHistory.add(() -> serverPlugin(page, name));
|
||||
if (server == null) {
|
||||
if (hasHistory()) back();
|
||||
@ -1350,7 +1347,7 @@ public class DefaultUIRenderer extends UIRenderer {
|
||||
inv.setItem(i, block);
|
||||
}
|
||||
|
||||
Bukkit.getPlayer(player).openInventory(inv);
|
||||
player.openInventory(inv);
|
||||
open = true;
|
||||
}
|
||||
}));
|
||||
|
@ -5,6 +5,7 @@ import net.ME1312.Galaxi.Library.Container.Container;
|
||||
import net.ME1312.Galaxi.Library.Try;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.Host;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.Server;
|
||||
@ -14,13 +15,16 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.PrimitiveIterator.OfInt;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -37,9 +41,9 @@ public abstract class UIRenderer {
|
||||
static final HashMap<String, PluginRenderer<Server>> serverPlugins = new HashMap<String, PluginRenderer<Server>>();
|
||||
private ContainedPair<String, Integer> tdownload = null;
|
||||
private final String[] adownload;
|
||||
private int download = -1;
|
||||
private final UUID player;
|
||||
private SubPlugin plugin;
|
||||
private Runnable download = null;
|
||||
final Player player;
|
||||
SubPlugin plugin;
|
||||
|
||||
/**
|
||||
* Creates a new UIRenderer
|
||||
@ -47,7 +51,7 @@ public abstract class UIRenderer {
|
||||
* @param plugin SubPlugin
|
||||
* @param player Player
|
||||
*/
|
||||
public UIRenderer(SubPlugin plugin, UUID player) {
|
||||
public UIRenderer(SubPlugin plugin, Player player) {
|
||||
Util.nullpo(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
@ -197,25 +201,22 @@ public abstract class UIRenderer {
|
||||
* @return Success Status
|
||||
*/
|
||||
public boolean sendTitle(String line1, String line2, int fadein, int stay, int fadeout) {
|
||||
if (USE_TITLES) {
|
||||
if (USE_TITLES && player.isOnline()) {
|
||||
try {
|
||||
Player player = Bukkit.getPlayer(this.player);
|
||||
if (player != null) {
|
||||
if (TAPI_1_11) {
|
||||
if (line1 == null) {
|
||||
player.resetTitle();
|
||||
} else {
|
||||
player.sendTitle(line1, line2, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20);
|
||||
}
|
||||
return true;
|
||||
} else if (TAPI_PLUGIN) {
|
||||
if (line1 == null) {
|
||||
com.connorlinfoot.titleapi.TitleAPI.clearTitle(player);
|
||||
} else {
|
||||
com.connorlinfoot.titleapi.TitleAPI.sendTitle(player, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20, line1, line2);
|
||||
}
|
||||
return true;
|
||||
if (TAPI_1_11) {
|
||||
if (line1 == null) {
|
||||
player.resetTitle();
|
||||
} else {
|
||||
player.sendTitle(line1, line2, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20);
|
||||
}
|
||||
return true;
|
||||
} else if (TAPI_PLUGIN) {
|
||||
if (line1 == null) {
|
||||
com.connorlinfoot.titleapi.TitleAPI.clearTitle(player);
|
||||
} else {
|
||||
com.connorlinfoot.titleapi.TitleAPI.sendTitle(player, (fadein >= 0)?fadein:10, (stay >= 0)?stay:70, (fadeout >= 0)?fadeout:20, line1, line2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
@ -239,50 +240,49 @@ public abstract class UIRenderer {
|
||||
* @param subtitle Subtitle to display (or null to hide)
|
||||
*/
|
||||
public void setDownloading(String subtitle) {
|
||||
if (subtitle != null) {
|
||||
if (!canSendTitle()) {
|
||||
final String text = subtitle;
|
||||
if (download != -1) Bukkit.getScheduler().cancelTask(download);
|
||||
download = Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
if (tdownload != null) Bukkit.getPlayer(player).sendMessage(plugin.api.getLang("SubServers", "Interface.Generic.Downloading").replace("$str$", text));
|
||||
download = -1;
|
||||
}, 50L);
|
||||
return;
|
||||
}
|
||||
if (player.isOnline()) {
|
||||
if (subtitle != null) {
|
||||
if (!canSendTitle()) {
|
||||
final String text = subtitle;
|
||||
if (download != null) download.run();
|
||||
download = AgnosticScheduler.following(player).runs(plugin, cancel -> {
|
||||
if (tdownload != null && player.isOnline()) player.sendMessage(plugin.api.getLang("SubServers", "Interface.Generic.Downloading").replace("$str$", text));
|
||||
download = null;
|
||||
}, 2500, TimeUnit.MILLISECONDS);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!subtitle.startsWith(Character.toString(ChatColor.COLOR_CHAR))) {
|
||||
subtitle = plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Title-Color-Alt") + subtitle;
|
||||
}
|
||||
if (tdownload == null) {
|
||||
tdownload = new ContainedPair<String, Integer>(subtitle, 0);
|
||||
if (!subtitle.startsWith(Character.toString(ChatColor.COLOR_CHAR))) {
|
||||
subtitle = plugin.api.getLang("SubServers", "Interface.Generic.Downloading.Title-Color-Alt") + subtitle;
|
||||
}
|
||||
if (tdownload == null) {
|
||||
tdownload = new ContainedPair<String, Integer>(subtitle, 0);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AgnosticScheduler.following(player).repeats(plugin, cancel -> {
|
||||
if (tdownload != null) {
|
||||
if (++tdownload.value >= adownload.length) {
|
||||
tdownload.value = 0;
|
||||
}
|
||||
|
||||
if (!sendTitle(adownload[tdownload.value], tdownload.key, 0, 10, 5)) {
|
||||
cancel();
|
||||
cancel.run();
|
||||
}
|
||||
} else {
|
||||
sendTitle(null);
|
||||
cancel();
|
||||
cancel.run();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, 1);
|
||||
}, 0, 50, TimeUnit.MILLISECONDS);
|
||||
} else {
|
||||
tdownload.key = subtitle;
|
||||
}
|
||||
} else {
|
||||
tdownload.key = subtitle;
|
||||
}
|
||||
} else {
|
||||
if (tdownload != null) {
|
||||
tdownload = null;
|
||||
}
|
||||
if (download != -1) {
|
||||
Bukkit.getScheduler().cancelTask(download);
|
||||
download = -1;
|
||||
if (tdownload != null) {
|
||||
tdownload = null;
|
||||
}
|
||||
if (download != null) {
|
||||
download.run();
|
||||
download = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,157 @@
|
||||
package net.ME1312.SubServers.Client.Bukkit.Library.Compatibility;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Try;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Folia Regional Scheduling Compatibility Class
|
||||
*/
|
||||
public abstract class AgnosticScheduler {
|
||||
private static final boolean regional = Try.all.get(() -> Class.forName("io.papermc.paper.threadedregions.scheduler.RegionScheduler") != null);
|
||||
|
||||
/**
|
||||
* Provides an asynchronous thread scheduler (in both folia and bukkit)
|
||||
*/
|
||||
public static final AgnosticScheduler async = async();
|
||||
private static native AgnosticScheduler async();
|
||||
|
||||
/**
|
||||
* Provides the folia global region scheduler / bukkit main thread scheduler
|
||||
*/
|
||||
public static final AgnosticScheduler global = global();
|
||||
private static native AgnosticScheduler global();
|
||||
|
||||
/**
|
||||
* Provides a folia region scheduler / bukkit main thread scheduler
|
||||
*
|
||||
* @param block Block
|
||||
* @return Platform-agnostic Scheduler
|
||||
*/
|
||||
public static native AgnosticScheduler at(Block block);
|
||||
|
||||
/**
|
||||
* Provides a folia region scheduler / bukkit main thread scheduler
|
||||
*
|
||||
* @param location Block location
|
||||
* @return Platform-agnostic Scheduler
|
||||
*/
|
||||
public static native AgnosticScheduler at(Location location);
|
||||
/**
|
||||
* Provides a folia region scheduler / bukkit main thread scheduler
|
||||
*
|
||||
* @param world Block world
|
||||
* @param x Block x coordinate
|
||||
* @param z Block z coordinate
|
||||
* @return Platform-agnostic Scheduler
|
||||
*/
|
||||
public static native AgnosticScheduler at(World world, int x, int z);
|
||||
|
||||
/**
|
||||
* Provides a folia region scheduler / bukkit main thread scheduler
|
||||
*
|
||||
* @param chunk Chunk
|
||||
* @return Platform-agnostic Scheduler
|
||||
*/
|
||||
public static native AgnosticScheduler atChunk(Chunk chunk);
|
||||
|
||||
/**
|
||||
* Provides a folia region scheduler / bukkit main thread scheduler
|
||||
*
|
||||
* @param world Chunk world
|
||||
* @param cx Chunk x coordinate
|
||||
* @param cz Chunk z coordinate
|
||||
* @return Platform-agnostic Scheduler
|
||||
*/
|
||||
public static native AgnosticScheduler atChunk(World world, int cx, int cz);
|
||||
|
||||
/**
|
||||
* Provides a folia entity scheduler / bukkit main thread scheduler
|
||||
*
|
||||
* @param entity Entity
|
||||
* @return Platform-agnostic Scheduler
|
||||
*/
|
||||
public static native AgnosticScheduler following(Entity entity);
|
||||
|
||||
/**
|
||||
* Schedules a 1-time task that runs immediately
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @param task Task (consumes a task cancellation runnable)
|
||||
* @return A Runnable that can currently be used to cancel the task
|
||||
*/
|
||||
public abstract Runnable runs(Plugin plugin, Consumer<Runnable> task);
|
||||
|
||||
/**
|
||||
* Schedules a 1-time task that runs after a number of ticks
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @param task Task (consumes a task cancellation runnable)
|
||||
* @param delay Delay in ticks
|
||||
* @return A Runnable that can currently be used to cancel the task
|
||||
*/
|
||||
public abstract Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay);
|
||||
|
||||
/**
|
||||
* Schedules a 1-time task that runs after a number of timeunits
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @param task Task (consumes a task cancellation runnable)
|
||||
* @param delay Delay
|
||||
* @param units Time units
|
||||
* @return A Runnable that can currently be used to cancel the task
|
||||
*/
|
||||
public native Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay, TimeUnit units);
|
||||
|
||||
/**
|
||||
* Schedules a repeating task that runs after a number of ticks
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @param task Task (consumes a task cancellation runnable)
|
||||
* @param repeat Repeat delay in ticks
|
||||
* @return A Runnable that can currently be used to cancel the task
|
||||
*/
|
||||
public native Runnable repeats(Plugin plugin, Consumer<Runnable> task, long repeat);
|
||||
|
||||
/**
|
||||
* Schedules a repeating task that runs after a number of timeunits
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @param task Task (consumes a task cancellation runnable)
|
||||
* @param repeat Repeat delay
|
||||
* @param units Time units
|
||||
* @return A Runnable that can currently be used to cancel the task
|
||||
*/
|
||||
public native Runnable repeats(Plugin plugin, Consumer<Runnable> task, long repeat, TimeUnit units);
|
||||
|
||||
/**
|
||||
* Schedules a repeating task that runs after a number of ticks
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @param task Task (consumes a task cancellation runnable)
|
||||
* @param delay Initial delay in ticks
|
||||
* @param repeat Repeat delay in ticks
|
||||
* @return A Runnable that can currently be used to cancel the task
|
||||
*/
|
||||
public abstract Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat);
|
||||
|
||||
/**
|
||||
* Schedules a repeating task that runs after a number of timeunits
|
||||
*
|
||||
* @param plugin Plugin
|
||||
* @param task Task (consumes a task cancellation runnable)
|
||||
* @param delay Initial delay
|
||||
* @param repeat Repeat delay
|
||||
* @param units Time units
|
||||
* @return A Runnable that can currently be used to cancel the task
|
||||
*/
|
||||
public native Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat, TimeUnit units);
|
||||
}
|
@ -5,7 +5,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.ME1312.SubServers.Client.Bukkit.Library;
|
||||
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -82,7 +83,7 @@ public class Metrics {
|
||||
enabled,
|
||||
this::appendPlatformData,
|
||||
this::appendServiceData,
|
||||
submitDataTask -> Bukkit.getScheduler().runTask(plugin, submitDataTask),
|
||||
submitDataTask -> AgnosticScheduler.global.runs(plugin, c -> submitDataTask.run()),
|
||||
plugin::isEnabled,
|
||||
(message, error) -> this.plugin.getLogger().log(Level.WARNING, message, error),
|
||||
(message) -> this.plugin.getLogger().log(Level.INFO, message),
|
||||
|
@ -8,6 +8,7 @@ import net.ME1312.Galaxi.Library.Merger;
|
||||
import net.ME1312.Galaxi.Library.Try;
|
||||
import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Event.*;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.*;
|
||||
@ -18,13 +19,14 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -36,7 +38,7 @@ public final class Placeholders {
|
||||
private final SubPlugin plugin;
|
||||
public final Cache cache;
|
||||
private MethodHandle papi;
|
||||
private BukkitTask task;
|
||||
private Runnable task;
|
||||
private boolean init;
|
||||
|
||||
/**
|
||||
@ -56,11 +58,11 @@ public final class Placeholders {
|
||||
init = true;
|
||||
papi = Try.all.get(() -> MethodHandles.publicLookup().findStatic(Class.forName("me.clip.placeholderapi.PlaceholderAPI"), "setPlaceholders", MethodType.methodType(String.class, new Class[]{ OfflinePlayer.class, String.class })));
|
||||
Bukkit.getPluginManager().registerEvents(cache.events, plugin);
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
|
||||
AgnosticScheduler.async.runs(plugin, c -> {
|
||||
if (task == null) {
|
||||
int interval = plugin.config.get().getMap("Settings").getInt("PlaceholderAPI-Cache-Interval", 30);
|
||||
int start = interval - new Random().nextInt(interval + 1); // Don't have all servers request at the same time
|
||||
Runnable task = () -> cache.refresh(() -> {
|
||||
Consumer<Runnable> task = c2 -> cache.refresh(() -> {
|
||||
for (Runnable listener : listeners) {
|
||||
try {
|
||||
listener.run();
|
||||
@ -69,17 +71,17 @@ public final class Placeholders {
|
||||
}
|
||||
}
|
||||
});
|
||||
this.task = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, task, 20L * start, 20L * interval);
|
||||
task.run();
|
||||
this.task = AgnosticScheduler.async.repeats(plugin, task, start, interval, TimeUnit.SECONDS);
|
||||
task.accept(null);
|
||||
}
|
||||
}, 120L);
|
||||
}, 6, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (task != null) {
|
||||
try {
|
||||
task.cancel();
|
||||
task.run();
|
||||
} catch (Throwable exception) {}
|
||||
task = null;
|
||||
}
|
||||
@ -650,7 +652,7 @@ public final class Placeholders {
|
||||
}
|
||||
|
||||
private final class Events implements Listener {
|
||||
private HashMap<String, BukkitTask> edits = new HashMap<String, BukkitTask>();
|
||||
private HashMap<String, Runnable> edits = new HashMap<String, Runnable>();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void add(SubAddProxyEvent e) {
|
||||
@ -679,8 +681,8 @@ public final class Placeholders {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void edit(SubEditServerEvent e) {
|
||||
String s = e.getServer().toLowerCase();
|
||||
if (edits.containsKey(s)) edits.get(s).cancel();
|
||||
edits.put(s, Bukkit.getScheduler().runTaskLater(plugin, servers.containsKey(s)? servers.get(s)::refresh : () -> add(s), 120L));
|
||||
if (edits.containsKey(s)) edits.get(s).run();
|
||||
edits.put(s, AgnosticScheduler.async.runs(plugin, servers.containsKey(s)? (c -> servers.get(s).refresh()) : (c -> add(s)), 6, TimeUnit.SECONDS));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
|
@ -5,10 +5,11 @@ import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -55,15 +56,18 @@ public class PacketExControlPlayer implements PacketObjectIn<Integer>, PacketObj
|
||||
String command = data.getString(0x0001);
|
||||
UUID target = (data.contains(0x0002)?data.getUUID(0x0002):null);
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
CommandSender sender = Bukkit.getConsoleSender();
|
||||
if (target != null && (sender = Bukkit.getPlayer(target)) == null) {
|
||||
if (target != null) {
|
||||
final Player player;
|
||||
if ((player = Bukkit.getPlayer(target)) == null) {
|
||||
client.sendPacket(new PacketExControlPlayer(6, tracker));
|
||||
return;
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(sender, command);
|
||||
client.sendPacket(new PacketExControlPlayer(0, tracker));
|
||||
AgnosticScheduler.following(player).runs(plugin, c -> Bukkit.getServer().dispatchCommand(player, command));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
AgnosticScheduler.global.runs(plugin, c -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command));
|
||||
}
|
||||
client.sendPacket(new PacketExControlPlayer(0, tracker));
|
||||
} catch (Throwable e) {
|
||||
client.sendPacket(new PacketExControlPlayer(2, tracker));
|
||||
e.printStackTrace();
|
||||
|
@ -3,6 +3,7 @@ package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -26,7 +27,7 @@ public class PacketInExReload implements PacketObjectIn<Integer> {
|
||||
public void receive(SubDataSender client, ObjectMap<Integer> data) {
|
||||
if (data != null && data.contains(0x0000)) Bukkit.getLogger().warning("SubData > Received request for a plugin reload: " + data.getString(0x0000));
|
||||
// else Bukkit.getLogger().warning("SubData > Received request for a plugin reload");
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
AgnosticScheduler.async.runs(plugin, c -> {
|
||||
try {
|
||||
plugin.reload(true);
|
||||
} catch (Exception e) {
|
||||
|
@ -2,7 +2,6 @@ package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Container.ContainedPair;
|
||||
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
|
||||
import net.ME1312.SubData.Client.SubDataSender;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Event.*;
|
||||
|
@ -13,6 +13,7 @@ import net.ME1312.Galaxi.Library.Util;
|
||||
import net.ME1312.Galaxi.Library.Version.Version;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Graphic.UIRenderer;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketInExRunEvent;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.*;
|
||||
import net.ME1312.SubServers.Client.Common.Network.Packet.PacketCreateServer;
|
||||
@ -32,6 +33,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static net.ME1312.SubServers.Client.Bukkit.Library.ObjectPermission.permits;
|
||||
@ -71,7 +73,7 @@ public final class SubCommand extends Command {
|
||||
sender.sendMessage(ChatColor.WHITE + " " + Bukkit.getName() + ' ' + Bukkit.getVersion() + ChatColor.RESET + ',');
|
||||
sender.sendMessage(ChatColor.WHITE + " SubServers.Client.Bukkit v" + plugin.version.toExtendedString() + ((plugin.api.getPluginBuild() != null)?" (" + plugin.api.getPluginBuild() + ')':""));
|
||||
sender.sendMessage("");
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
AgnosticScheduler.async.runs(plugin, c -> {
|
||||
try {
|
||||
YAMLSection tags = new YAMLSection(plugin.parseJSON("{\"tags\":" + Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://api.github.com/repos/ME1312/SubServers-2/git/refs/tags").openStream(), Charset.forName("UTF-8")))) + '}'));
|
||||
List<Version> versions = new LinkedList<Version>();
|
||||
@ -436,10 +438,10 @@ public final class SubCommand extends Command {
|
||||
PacketInExRunEvent.callback("SubStoppedEvent", this);
|
||||
String name = json.getString("server").toLowerCase();
|
||||
if (listening.containsKey(name)) {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
AgnosticScheduler.async.runs(plugin, c -> {
|
||||
starter.accept(listening.get(name));
|
||||
listening.remove(name);
|
||||
}, 5);
|
||||
}, 250, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
|
@ -15,10 +15,11 @@ import net.ME1312.SubData.Client.Library.DisconnectReason;
|
||||
import net.ME1312.SubData.Client.SubDataClient;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Graphic.DefaultUIHandler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Graphic.UIHandler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.PlaceholderImpl;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Placeholders;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.ConfigUpdater;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Metrics;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Placeholders;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Network.SubProtocol;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -150,7 +151,7 @@ public final class SubPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
new Metrics(this, 2334);
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
|
||||
AgnosticScheduler.async.repeats(this, c -> {
|
||||
try {
|
||||
YAMLSection tags = new YAMLSection(parseJSON("{\"tags\":" + Util.readAll(new BufferedReader(new InputStreamReader(new URL("https://api.github.com/repos/ME1312/SubServers-2/git/refs/tags").openStream(), Charset.forName("UTF-8")))) + '}'));
|
||||
List<Version> versions = new LinkedList<Version>();
|
||||
@ -198,24 +199,22 @@ public final class SubPlugin extends JavaPlugin {
|
||||
if (disconnect == null || (this.reconnect && reconnect > 0 && disconnect.key() != DisconnectReason.PROTOCOL_MISMATCH && disconnect.key() != DisconnectReason.ENCRYPTION_MISMATCH)) {
|
||||
long reset = resetDate;
|
||||
if (disconnect != null) Bukkit.getLogger().info("SubData > Attempting reconnect in " + reconnect + " seconds");
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (reset == resetDate && (subdata.getOrDefault(0, null) == null || subdata.get(0).isClosed())) {
|
||||
SubDataClient open = subprotocol.open(InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getString("Address", "127.0.0.1:4391").split(":")[0]),
|
||||
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getString("Address", "127.0.0.1:4391").split(":")[1]));
|
||||
|
||||
if (subdata.getOrDefault(0, null) != null) subdata.get(0).reconnect(open);
|
||||
subdata.put(0, open);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().info("SubData > Connection was unsuccessful, retrying in " + reconnect + " seconds");
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(SubPlugin.this, this, reconnect * 20L);
|
||||
AgnosticScheduler.async.repeats(this, cancel -> {
|
||||
try {
|
||||
if (reset == resetDate && (subdata.getOrDefault(0, null) == null || subdata.get(0).isClosed())) {
|
||||
SubDataClient open = subprotocol.open(InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getString("Address", "127.0.0.1:4391").split(":")[0]),
|
||||
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getString("Address", "127.0.0.1:4391").split(":")[1]));
|
||||
|
||||
if (subdata.getOrDefault(0, null) != null) subdata.get(0).reconnect(open);
|
||||
subdata.put(0, open);
|
||||
cancel.run();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Bukkit.getLogger().info("SubData > Connection was unsuccessful, retrying in " + reconnect + " seconds");
|
||||
}
|
||||
}, (disconnect == null)?0:reconnect * 20L);
|
||||
}, (disconnect == null)?0:reconnect, reconnect, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
package net.ME1312.SubServers.Client.Bukkit;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Container.Pair;
|
||||
import net.ME1312.Galaxi.Library.Merger;
|
||||
import net.ME1312.SubData.Client.Library.EscapedOutputStream;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Event.SubStartEvent;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Event.SubStartedEvent;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Event.SubStopEvent;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Event.SubStoppedEvent;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.AgnosticScheduler;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.Compatibility.OfflineBlock;
|
||||
import net.ME1312.SubServers.Client.Bukkit.Library.SignState;
|
||||
import net.ME1312.SubServers.Client.Common.Network.API.Host;
|
||||
@ -73,6 +75,7 @@ public class SubSigns implements Listener {
|
||||
|
||||
private void load() throws IOException {
|
||||
if (file.exists()) {
|
||||
Merger merge = new Merger(this::listen);
|
||||
FileInputStream in = new FileInputStream(file);
|
||||
ByteArrayOutputStream string = new ByteArrayOutputStream();
|
||||
ByteBuffer magic = ByteBuffer.allocate(28).order(ByteOrder.BIG_ENDIAN);
|
||||
@ -95,12 +98,18 @@ public class SubSigns implements Listener {
|
||||
Location loaded = location.load();
|
||||
if (loaded == null) {
|
||||
data.put(location, name);
|
||||
} else if (loaded.getBlock().getState() instanceof Sign) {
|
||||
data.put(location, name);
|
||||
signs.put(loaded, translate(name));
|
||||
locations.put(name.toLowerCase(), loaded);
|
||||
} else {
|
||||
Bukkit.getLogger().warning("SubServers > Removed invalid sign data: [\"" + loaded.getWorld().getName() + "\", " + location.x + ", " + location.y + ", " + location.z + "] -> \"" + name + '\"');
|
||||
merge.reserve();
|
||||
AgnosticScheduler.at(loaded).runs(plugin, c -> {
|
||||
if (loaded.getBlock().getState() instanceof Sign) {
|
||||
data.put(location, name);
|
||||
signs.put(loaded, translate(name));
|
||||
locations.put(name.toLowerCase(), loaded);
|
||||
} else {
|
||||
Bukkit.getLogger().warning("SubServers > Removed invalid sign data: [\"" + loaded.getWorld().getName() + "\", " + location.x + ", " + location.y + ", " + location.z + "] -> \"" + name + '\"');
|
||||
}
|
||||
merge.release();
|
||||
});
|
||||
}
|
||||
magic.clear();
|
||||
string.reset();
|
||||
@ -118,7 +127,6 @@ public class SubSigns implements Listener {
|
||||
string.write(b);
|
||||
}
|
||||
}
|
||||
listen();
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +231,7 @@ public class SubSigns implements Listener {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void refresh(Block block, Supplier<?> translator) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
AgnosticScheduler.at(block).runs(plugin, c -> {
|
||||
if (block.getState() instanceof Sign) {
|
||||
Object object = translator.get();
|
||||
String name;
|
||||
|
@ -4,6 +4,7 @@ version: "2.19a"
|
||||
authors: ["ME1312"]
|
||||
softdepend: [TitleAPI, PlaceholderAPI]
|
||||
website: "https://github.com/ME1312/SubServers-2"
|
||||
folia-supported: true
|
||||
#commands:
|
||||
# subservers:
|
||||
# description: "The SubServers Command"
|
||||
|
@ -18,7 +18,7 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiBase</artifactId>
|
||||
<version>23w14a</version>
|
||||
<version>23w14b</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
55
SubServers.Client/Folia/pom.xml
Normal file
55
SubServers.Client/Folia/pom.xml
Normal file
@ -0,0 +1,55 @@
|
||||
<?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>
|
||||
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Client.Folia</artifactId>
|
||||
<version>-PLACEHOLDER</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>paper-repo</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dev.folia</groupId>
|
||||
<artifactId>folia-api</artifactId>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.SubServers</groupId>
|
||||
<artifactId>SubServers.Client.Common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<directory>../../out/compile/target/SubServers.Client.Folia</directory>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,252 @@
|
||||
package net.ME1312.SubServers.Client.Bukkit.Library.Compatibility;
|
||||
|
||||
import net.ME1312.Galaxi.Library.Container.Container;
|
||||
import net.ME1312.Galaxi.Library.Try;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public abstract class AgnosticScheduler {
|
||||
private static final boolean regional = Try.all.get(() -> Class.forName("io.papermc.paper.threadedregions.scheduler.RegionScheduler") != null, false);
|
||||
private static final Runnable empty = () -> {};
|
||||
|
||||
public static final AgnosticScheduler async = ((regional)?
|
||||
new AgnosticScheduler() {
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task) {
|
||||
return Bukkit.getAsyncScheduler().runNow(plugin, t -> task.accept(t::cancel))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay) {
|
||||
return Bukkit.getAsyncScheduler().runDelayed(plugin, t -> task.accept(t::cancel), delay * 50, TimeUnit.MILLISECONDS)::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay, TimeUnit units) {
|
||||
return Bukkit.getAsyncScheduler().runDelayed(plugin, t -> task.accept(t::cancel), delay, units)::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long repeat) {
|
||||
return repeats(plugin, task, repeat *= 50, repeat, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long repeat, TimeUnit units) {
|
||||
return repeats(plugin, task, repeat, repeat, units);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat) {
|
||||
return repeats(plugin, task, delay * 50, repeat * 50, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat, TimeUnit units) {
|
||||
if (repeat != 0) {
|
||||
return Bukkit.getAsyncScheduler().runAtFixedRate(plugin, t -> task.accept(t::cancel), delay, repeat, units)::cancel;
|
||||
} else if (units.ordinal() >= TimeUnit.MILLISECONDS.ordinal()) {
|
||||
return Bukkit.getAsyncScheduler().runAtFixedRate(plugin, t -> task.accept(t::cancel), units.toMillis(delay), 50, TimeUnit.MILLISECONDS)::cancel;
|
||||
} else {
|
||||
return Bukkit.getAsyncScheduler().runAtFixedRate(plugin, t -> task.accept(t::cancel), delay, units.convert(50, TimeUnit.MILLISECONDS), units)::cancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
:
|
||||
new AgnosticScheduler() {
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task) {
|
||||
final Container<Runnable> cancel = new Container<>(empty);
|
||||
return cancel.value = Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> task.accept(cancel.value))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay) {
|
||||
final Container<Runnable> cancel = new Container<>(empty);
|
||||
return cancel.value = Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> task.accept(cancel.value), check(delay, 0))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat) {
|
||||
final Container<Runnable> cancel = new Container<>(empty);
|
||||
return cancel.value = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, () -> task.accept(cancel.value), check(delay, 0), check(repeat, 0))::cancel;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static final AgnosticScheduler global = ((regional)?
|
||||
new AgnosticScheduler() {
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task) {
|
||||
return Bukkit.getGlobalRegionScheduler().run(plugin, t -> task.accept(t::cancel))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay) {
|
||||
return Bukkit.getGlobalRegionScheduler().runDelayed(plugin, t -> task.accept(t::cancel), check(delay, 1))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat) {
|
||||
return Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, t -> task.accept(t::cancel), check(delay, 1), check(repeat, 1))::cancel;
|
||||
}
|
||||
}
|
||||
:
|
||||
new AgnosticScheduler() {
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task) {
|
||||
final Container<Runnable> cancel = new Container<>(empty);
|
||||
return cancel.value = Bukkit.getScheduler().runTask(plugin, () -> task.accept(cancel.value))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay) {
|
||||
final Container<Runnable> cancel = new Container<>(empty);
|
||||
return cancel.value = Bukkit.getScheduler().runTaskLater(plugin, () -> task.accept(cancel.value), check(delay, 0))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat) {
|
||||
final Container<Runnable> cancel = new Container<>(empty);
|
||||
return cancel.value = Bukkit.getScheduler().runTaskTimer(plugin, () -> task.accept(cancel.value), check(delay, 0), check(repeat, 0))::cancel;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static AgnosticScheduler at(Block block) {
|
||||
return atChunk(block.getWorld(), block.getX() >> 4, block.getZ() >> 4);
|
||||
}
|
||||
|
||||
public static AgnosticScheduler at(Location location) {
|
||||
return atChunk(location.getWorld(), location.getBlockX() >> 4, location.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
public static AgnosticScheduler at(World world, int x, int z) {
|
||||
return atChunk(world, x >> 4, z >> 4);
|
||||
}
|
||||
|
||||
public static AgnosticScheduler atChunk(Chunk chunk) {
|
||||
return atChunk(chunk.getWorld(), chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
public static AgnosticScheduler atChunk(World world, int cx, int cz) {
|
||||
return (regional)? new AgnosticScheduler() {
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task) {
|
||||
return Bukkit.getRegionScheduler().run(plugin, world, cx, cz, t -> task.accept(t::cancel))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay) {
|
||||
return Bukkit.getRegionScheduler().runDelayed(plugin, world, cx, cz, t -> task.accept(t::cancel), check(delay, 1))::cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat) {
|
||||
return Bukkit.getRegionScheduler().runAtFixedRate(plugin, world, cx, cz, t -> task.accept(t::cancel), check(delay, 1), check(repeat, 1))::cancel;
|
||||
}
|
||||
} : global;
|
||||
}
|
||||
|
||||
public static AgnosticScheduler following(Entity entity) {
|
||||
return (regional)? new AgnosticScheduler() {
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task) {
|
||||
final io.papermc.paper.threadedregions.scheduler.ScheduledTask value = entity.getScheduler().run(plugin, t -> task.accept(t::cancel), () -> {
|
||||
at(entity.getLocation()).runs(plugin, task);
|
||||
});
|
||||
return (value != null)? value::cancel : at(entity.getLocation()).runs(plugin, task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay) {
|
||||
return runs(plugin, task, delay * 50, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay, TimeUnit units) {
|
||||
return runs(plugin, task, delay = units.toMillis(delay), delay / 50);
|
||||
}
|
||||
|
||||
private Runnable runs(Plugin plugin, Consumer<Runnable> task, long dMS, long dT) {
|
||||
if (dMS < 0) throw new IllegalStateException("Delay may not be < 0");
|
||||
final Instant next = Instant.now().plusMillis(dMS);
|
||||
final io.papermc.paper.threadedregions.scheduler.ScheduledTask value = entity.getScheduler().runDelayed(plugin, t -> task.accept(t::cancel), () -> {
|
||||
at(entity.getLocation()).runs(plugin, task, Math.min(0, Duration.between(Instant.now(), next).toMillis()), TimeUnit.MILLISECONDS);
|
||||
}, (dT == 0)? 1 : dT);
|
||||
return (value != null)? value::cancel : at(entity.getLocation()).runs(plugin, task, dT);
|
||||
}
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long repeat) {
|
||||
final long rMS;
|
||||
return repeats(plugin, task, rMS = repeat * 50, repeat, rMS, repeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long repeat, TimeUnit units) {
|
||||
final long rT;
|
||||
return repeats(plugin, task, repeat = units.toMillis(repeat), rT = repeat / 50, repeat, rT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat) {
|
||||
return repeats(plugin, task, delay * 50, delay, repeat * 50, repeat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat, TimeUnit units) {
|
||||
return repeats(plugin, task, delay = units.toMillis(delay), delay / 50, repeat = units.toMillis(repeat), repeat / 50);
|
||||
}
|
||||
|
||||
private Runnable repeats(Plugin plugin, Consumer<Runnable> task, long dMS, long dT, long rMS, long rT) {
|
||||
if (dMS < 0 || rMS < 0) throw new IllegalStateException("Delay may not be < 0");
|
||||
final Container<Instant> next = new Container<>(Instant.now().plusMillis(dMS));
|
||||
final io.papermc.paper.threadedregions.scheduler.ScheduledTask value = entity.getScheduler().runAtFixedRate(plugin, t -> {
|
||||
next.value = Instant.now().plusMillis(rMS);
|
||||
task.accept(t::cancel);
|
||||
}, () -> {
|
||||
at(entity.getLocation()).repeats(plugin, task, Math.min(0, Duration.between(Instant.now(), next.value).toMillis()), rMS, TimeUnit.MILLISECONDS);
|
||||
}, (dT == 0)? 1 : dT, (rT == 0)? 1 : rT);
|
||||
return (value != null)? value::cancel : at(entity.getLocation()).repeats(plugin, task, dT, rT);
|
||||
}
|
||||
} : global;
|
||||
}
|
||||
|
||||
private static long check(long amount, int minimum) {
|
||||
if (amount < 0) throw new IllegalArgumentException("Delay ticks may not be < 0");
|
||||
return (amount == 0)? minimum : amount;
|
||||
}
|
||||
|
||||
public abstract Runnable runs(Plugin plugin, Consumer<Runnable> task);
|
||||
|
||||
public abstract Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay);
|
||||
|
||||
public Runnable runs(Plugin plugin, Consumer<Runnable> task, long delay, TimeUnit units) {
|
||||
return runs(plugin, task, units.toMillis(delay) / 50);
|
||||
}
|
||||
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long repeat) {
|
||||
return repeats(plugin, task, repeat, repeat);
|
||||
}
|
||||
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long repeat, TimeUnit units) {
|
||||
return repeats(plugin, task, repeat = units.toMillis(repeat) / 50, repeat);
|
||||
}
|
||||
|
||||
public abstract Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat);
|
||||
|
||||
public Runnable repeats(Plugin plugin, Consumer<Runnable> task, long delay, long repeat, TimeUnit units) {
|
||||
return repeats(plugin, task, units.toMillis(delay) / 50, units.toMillis(repeat) / 50);
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@
|
||||
|
||||
<modules>
|
||||
<module>Common</module>
|
||||
<module>Folia</module>
|
||||
<module>Bukkit</module>
|
||||
<module>Sponge</module>
|
||||
<module>Universal</module>
|
||||
|
@ -19,17 +19,17 @@ function __DL() {
|
||||
fi
|
||||
}
|
||||
function __Restore() {
|
||||
if [[ -f "Forge.old.jar.x" ]]; then
|
||||
if [[ -f "Forge.old.jar" ]]; then
|
||||
if [[ -f "Forge.jar" ]]; then
|
||||
rm -Rf Forge.jar
|
||||
fi
|
||||
mv Forge.old.jar.x Forge.jar
|
||||
mv Forge.old.jar Forge.jar
|
||||
fi
|
||||
if [[ -f "mods/Sponge.old.jar.x" ]]; then
|
||||
if [[ -f "mods/Sponge.old.jar" ]]; then
|
||||
if [[ -f "mods/Sponge.jar" ]]; then
|
||||
rm -Rf mods/Sponge.jar
|
||||
fi
|
||||
mv mods/Sponge.old.jar.x mods/Sponge.jar
|
||||
mv mods/Sponge.old.jar mods/Sponge.jar
|
||||
fi
|
||||
}
|
||||
echo Downloading the Minecraft Forge Installer...
|
||||
@ -60,10 +60,10 @@ if [[ $__RETURN -eq 0 ]]; then
|
||||
mv -f "forge-$mcf_version-universal.jar" Forge.jar
|
||||
echo Downloading SpongeForge...
|
||||
if [[ -f "mods/Sponge.jar" ]]; then
|
||||
if [[ -f "mods/Sponge.old.jar.x" ]]; then
|
||||
rm -Rf mods/Sponge.old.jar.x
|
||||
if [[ -f "mods/Sponge.old.jar" ]]; then
|
||||
rm -Rf mods/Sponge.old.jar
|
||||
fi
|
||||
mv mods/Sponge.jar mods/Sponge.old.jar.x
|
||||
mv mods/Sponge.jar mods/Sponge.old.jar
|
||||
fi
|
||||
__DL mods/Sponge.jar "https://repo.spongepowered.org/maven/org/spongepowered/spongeforge/$sp_version/spongeforge-$sp_version.jar"; __RETURN=$?
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
|
@ -15,19 +15,19 @@ function __DL() {
|
||||
fi
|
||||
}
|
||||
function __Restore() {
|
||||
if [[ -f "Purpur.old.jar.x" ]]; then
|
||||
if [[ -f "Purpur.old.jar" ]]; then
|
||||
if [[ -f "Purpur.jar" ]]; then
|
||||
rm -Rf Purpur.jar
|
||||
fi
|
||||
mv Purpur.old.jar.x Purpur.jar
|
||||
mv Purpur.old.jar Purpur.jar
|
||||
fi
|
||||
}
|
||||
echo Downloading Purpur...
|
||||
if [[ -f "Purpur.jar" ]]; then
|
||||
if [[ -f "Purpur.old.jar.x" ]]; then
|
||||
rm -Rf Purpur.old.jar.x
|
||||
if [[ -f "Purpur.old.jar" ]]; then
|
||||
rm -Rf Purpur.old.jar
|
||||
fi
|
||||
mv Purpur.jar Purpur.old.jar.x
|
||||
mv Purpur.jar Purpur.old.jar
|
||||
fi
|
||||
__DL Purpur.jar "https://api.purpurmc.org/v2/purpur/$version/latest/download"; __RETURN=$?
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
|
@ -41,10 +41,10 @@ if [[ -z "$cache" ]] || [[ ! -f "$cache/Spigot-$version.jar" ]] || [[ "$mode" ==
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
echo Copying Finished Jar...
|
||||
if [[ -f "Spigot.jar" ]]; then
|
||||
if [[ -f "Spigot.old.jar.x" ]]; then
|
||||
rm -Rf Spigot.old.jar.x
|
||||
if [[ -f "Spigot.old.jar" ]]; then
|
||||
rm -Rf Spigot.old.jar
|
||||
fi
|
||||
mv Spigot.jar Spigot.old.jar.x
|
||||
mv Spigot.jar Spigot.old.jar
|
||||
fi
|
||||
if [[ ! -z "$cache" ]] && [[ -d "$cache" ]]; then
|
||||
if [[ -f "$cache/Spigot-$version.jar" ]]; then
|
||||
|
@ -15,19 +15,19 @@ function __DL() {
|
||||
fi
|
||||
}
|
||||
function __Restore() {
|
||||
if [[ -f "Sponge.old.jar.x" ]]; then
|
||||
if [[ -f "Sponge.old.jar" ]]; then
|
||||
if [[ -f "Sponge.jar" ]]; then
|
||||
rm -Rf Sponge.jar
|
||||
fi
|
||||
mv Sponge.old.jar.x Sponge.jar
|
||||
mv Sponge.old.jar Sponge.jar
|
||||
fi
|
||||
}
|
||||
echo Downloading SpongeVanilla...
|
||||
if [[ -f "Sponge.jar" ]]; then
|
||||
if [[ -f "Sponge.old.jar.x" ]]; then
|
||||
rm -Rf Sponge.old.jar.x
|
||||
if [[ -f "Sponge.old.jar" ]]; then
|
||||
rm -Rf Sponge.old.jar
|
||||
fi
|
||||
mv Sponge.jar Sponge.old.jar.x
|
||||
mv Sponge.jar Sponge.old.jar
|
||||
fi
|
||||
__DL Sponge.jar "https://repo.spongepowered.org/maven/org/spongepowered/spongevanilla/$sp_version/spongevanilla-$sp_version.jar"; __RETURN=$?
|
||||
if [[ $__RETURN -eq 0 ]]; then
|
||||
|
@ -33,10 +33,10 @@ if [[ -z "$cache" ]] || [[ ! -f "$cache/Vanilla-$version.jar" ]]; then
|
||||
echo Copying Finished Jar...
|
||||
cd ../
|
||||
if [[ -f "Vanilla.jar" ]]; then
|
||||
if [[ -f "Vanilla.old.jar.x" ]]; then
|
||||
rm -Rf Vanilla.old.jar.x
|
||||
if [[ -f "Vanilla.old.jar" ]]; then
|
||||
rm -Rf Vanilla.old.jar
|
||||
fi
|
||||
mv Vanilla.jar Vanilla.old.jar.x
|
||||
mv Vanilla.jar Vanilla.old.jar
|
||||
fi
|
||||
if [[ ! -z "$cache" ]] && [[ -d "$cache" ]]; then
|
||||
cp "VanillaCord/out/$version-bungee.jar" "$cache/Vanilla-$version.jar"
|
||||
|
@ -30,13 +30,13 @@
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiEngine</artifactId>
|
||||
<version>23w14a</version>
|
||||
<version>23w14b</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.ME1312.Galaxi</groupId>
|
||||
<artifactId>GalaxiUI</artifactId>
|
||||
<version>23w14a</version>
|
||||
<version>23w14b</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
Loading…
Reference in New Issue
Block a user