mirror of
https://github.com/arcadiadevs/hubcore.git
synced 2024-11-21 06:05:21 +01:00
Initial commit
This commit is contained in:
parent
76a73ceae6
commit
59859a2fdf
@ -8,6 +8,7 @@
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-simple/1.6.4/slf4j-simple-1.6.4.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/github/cryptomorin/XSeries/5.3.1/XSeries-5.3.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.12/lombok-1.18.12.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/moandjiezana/toml/toml4j/0.7.2/toml4j-0.7.2.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
13
.idea/libraries/Maven__com_google_code_gson_gson_2_8_1.xml
Normal file
13
.idea/libraries/Maven__com_google_code_gson_gson_2_8_1.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.google.code.gson:gson:2.8.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.1/gson-2.8.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.1/gson-2.8.1-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.1/gson-2.8.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: com.moandjiezana.toml:toml4j:0.7.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/moandjiezana/toml/toml4j/0.7.2/toml4j-0.7.2.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/moandjiezana/toml/toml4j/0.7.2/toml4j-0.7.2-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/com/moandjiezana/toml/toml4j/0.7.2/toml4j-0.7.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -17,6 +17,8 @@
|
||||
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-simple:1.6.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.moandjiezana.toml:toml4j:0.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.cryptomorin:XSeries:5.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.12" level="project" />
|
||||
</component>
|
||||
|
5
pom.xml
5
pom.xml
@ -40,6 +40,11 @@
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.6.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.moandjiezana.toml</groupId>
|
||||
<artifactId>toml4j</artifactId>
|
||||
<version>0.7.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.cryptomorin</groupId>
|
||||
<artifactId>XSeries</artifactId>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package os.arcadiadevs.playerservers.hubcore;
|
||||
|
||||
import com.moandjiezana.toml.Toml;
|
||||
import lombok.SneakyThrows;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -11,11 +12,16 @@ import os.arcadiadevs.playerservers.hubcore.events.HubEvents;
|
||||
import os.arcadiadevs.playerservers.hubcore.events.JoinEvent;
|
||||
import os.arcadiadevs.playerservers.hubcore.placeholders.PlayerCount;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PSHubCore extends JavaPlugin {
|
||||
|
||||
public static Plugin PSH;
|
||||
public static Toml multinode;
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
@ -23,6 +29,7 @@ public class PSHubCore extends JavaPlugin {
|
||||
PSH = this;
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
createMultiNodeConfig();
|
||||
|
||||
DataSource ds = new DataSource();
|
||||
ds.registerDataSource();
|
||||
@ -43,6 +50,31 @@ public class PSHubCore extends JavaPlugin {
|
||||
Objects.requireNonNull(getCommand("servers")).setExecutor(new CommandManager());
|
||||
}
|
||||
|
||||
private void createMultiNodeConfig() throws IOException {
|
||||
|
||||
if (!getConfig().getBoolean("multi-node")) {
|
||||
return;
|
||||
}
|
||||
|
||||
File configFile = new File(this.getDataFolder(), "multinode.toml");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
getDataFolder().mkdirs();
|
||||
if (configFile.createNewFile()) {
|
||||
|
||||
try (InputStream fis = getClass().getResourceAsStream("/multinode.toml"); FileOutputStream fos = new FileOutputStream(configFile)) {
|
||||
byte[] buf = new byte[1024];
|
||||
int i;
|
||||
while ((i = fis.read(buf)) != -1) {
|
||||
fos.write(buf, 0, i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().info("[PlayerServers] Failed to load MultiNode file from Jar");
|
||||
}
|
||||
}
|
||||
|
||||
multinode = new Toml().read(new File(this.getDataFolder(), "multinode.toml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
super.onDisable();
|
||||
|
@ -38,7 +38,8 @@ public class DataBase {
|
||||
rs.getString("SERVERID"),
|
||||
rs.getString("PORT"),
|
||||
rs.getString("NAME"),
|
||||
rs.getString("PLAYERNAME"))
|
||||
rs.getString("PLAYERNAME"),
|
||||
rs.getString("NODE"))
|
||||
);
|
||||
}
|
||||
return output;
|
||||
|
@ -2,18 +2,20 @@ package os.arcadiadevs.playerservers.hubcore.database.structures;
|
||||
|
||||
public class DBInfoStructure {
|
||||
|
||||
private String UUID;
|
||||
private String ServerID;
|
||||
private String Port;
|
||||
private String ServerName;
|
||||
private String PlayerName;
|
||||
private final String UUID;
|
||||
private final String ServerID;
|
||||
private final String Port;
|
||||
private final String ServerName;
|
||||
private final String PlayerName;
|
||||
private final String Node;
|
||||
|
||||
public DBInfoStructure(String UUID, String ServerID, String Port, String ServerName, String PlayerName) {
|
||||
public DBInfoStructure(String UUID, String ServerID, String Port, String ServerName, String PlayerName, String node) {
|
||||
this.UUID = UUID;
|
||||
this.ServerID = ServerID;
|
||||
this.Port = Port;
|
||||
this.ServerName = ServerName;
|
||||
this.PlayerName = PlayerName;
|
||||
this.Node = node;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
@ -36,4 +38,8 @@ public class DBInfoStructure {
|
||||
return UUID;
|
||||
}
|
||||
|
||||
public String getNode() {
|
||||
return Node;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,11 +7,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import os.arcadiadevs.playerservers.hubcore.PSHubCore;
|
||||
import os.arcadiadevs.playerservers.hubcore.database.DataBase;
|
||||
import os.arcadiadevs.playerservers.hubcore.database.structures.DBInfoStructure;
|
||||
import os.arcadiadevs.playerservers.hubcore.database.structures.PingInfoStructure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import static os.arcadiadevs.playerservers.hubcore.PSHubCore.PSH;
|
||||
import static os.arcadiadevs.playerservers.hubcore.utils.ColorUtils.translate;
|
||||
@ -19,23 +21,25 @@ import static os.arcadiadevs.playerservers.hubcore.utils.ColorUtils.translate;
|
||||
public class GUIUtils {
|
||||
|
||||
public void openSelector(Player player) {
|
||||
DataBase db = new DataBase();
|
||||
PingUtil pu = new PingUtil();
|
||||
final DataBase db = new DataBase();
|
||||
final PingUtil pu = new PingUtil();
|
||||
|
||||
Inventory gui = Bukkit.createInventory(player, 9*6, ChatColor.GREEN + "Server Selector");
|
||||
final Inventory gui = Bukkit.createInventory(player, 9*6, ChatColor.GREEN + "Server Selector");
|
||||
final Map<String, Object> map = PSHubCore.multinode.getTable("servers").toMap();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(PSH, () -> {
|
||||
for (DBInfoStructure is : db.getServersInfo()) {
|
||||
ItemStack istack;
|
||||
if (pu.isOnline("127.0.0.1", is.getPort())) {
|
||||
final ItemStack istack;
|
||||
if (pu.isOnline(PSH.getConfig().getBoolean("multi-node") ? map.get(is.getNode()).toString() : "127.0.0.1", is.getPort())) {
|
||||
|
||||
PingInfoStructure pus = pu.getData(Integer.parseInt(is.getPort()));
|
||||
final PingInfoStructure pus = pu.getData(Integer.parseInt(is.getPort()));
|
||||
final ArrayList<String> lore = new ArrayList<>();
|
||||
|
||||
istack = new ItemStack(XMaterial.EMERALD_BLOCK.parseMaterial());
|
||||
ItemMeta ir = istack.getItemMeta();
|
||||
final ItemMeta ir = istack.getItemMeta();
|
||||
|
||||
//noinspection ConstantConditions
|
||||
ir.setDisplayName(translate("&a" + is.getPlayerName() + "'s server"));
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(translate("&cPort: &7" + is.getPort()));
|
||||
lore.add(translate("&cUUID: &7" + is.getServerID().split("-")[0]));
|
||||
lore.add(translate(String.format("&cOnline: &7%d/%d", pus.getOnline(), pus.getMax())));
|
||||
@ -48,12 +52,12 @@ public class GUIUtils {
|
||||
}
|
||||
|
||||
for (DBInfoStructure is : db.getServersInfo()) {
|
||||
if (!pu.isOnline("127.0.0.1", is.getPort())) {
|
||||
ItemStack istack = new ItemStack(XMaterial.REDSTONE_BLOCK.parseMaterial());
|
||||
ItemMeta ir = istack.getItemMeta();
|
||||
if (!pu.isOnline(PSH.getConfig().getBoolean("multi-node") ? map.get(is.getNode()).toString() : "127.0.0.1", is.getPort())) {
|
||||
final ItemStack istack = new ItemStack(XMaterial.REDSTONE_BLOCK.parseMaterial());
|
||||
final ItemMeta ir = istack.getItemMeta();
|
||||
final ArrayList<String> lore = new ArrayList<>();
|
||||
//noinspection ConstantConditions
|
||||
ir.setDisplayName(translate("&a" + is.getPlayerName() + "'s server"));
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(translate("&cPort: &7" + is.getPort()));
|
||||
lore.add(translate("&cUUID: &7" + is.getServerID().split("-")[0]));
|
||||
ir.setLore(lore);
|
||||
|
@ -13,4 +13,7 @@ compass-description:
|
||||
- "&7selector or to create your own one"
|
||||
|
||||
disable-weather: true
|
||||
disable-damage: true
|
||||
disable-damage: true
|
||||
|
||||
# EXPERIMENTAL
|
||||
multi-node: false
|
3
src/main/resources/multinode.toml
Normal file
3
src/main/resources/multinode.toml
Normal file
@ -0,0 +1,3 @@
|
||||
# Please copy the content of multinode.toml from PSBungee here.
|
||||
[servers]
|
||||
example = "node1.example.com:25565"
|
@ -1,6 +1,6 @@
|
||||
name: PSHubCore
|
||||
main: os.arcadiadevs.playerservers.hubcore.PSHubCore
|
||||
version: 1.4.3
|
||||
version: 1.4.4
|
||||
author: OpenSource
|
||||
|
||||
softdepend: [PlaceholderAPI]
|
||||
|
@ -13,4 +13,7 @@ compass-description:
|
||||
- "&7selector or to create your own one"
|
||||
|
||||
disable-weather: true
|
||||
disable-damage: true
|
||||
disable-damage: true
|
||||
|
||||
# EXPERIMENTAL
|
||||
multi-node: false
|
3
target/classes/multinode.toml
Normal file
3
target/classes/multinode.toml
Normal file
@ -0,0 +1,3 @@
|
||||
# Please copy the content of multinode.toml from PSBungee here.
|
||||
[servers]
|
||||
example = "node1.example.com:25565"
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: PSHubCore
|
||||
main: os.arcadiadevs.playerservers.hubcore.PSHubCore
|
||||
version: 1.4.3
|
||||
version: 1.4.4
|
||||
author: OpenSource
|
||||
|
||||
softdepend: [PlaceholderAPI]
|
||||
|
Loading…
Reference in New Issue
Block a user