0.0.2: Bug Fixing about the previous Update
This commit is contained in:
parent
8741eecad4
commit
8aac201d7f
10 changed files with 191 additions and 37 deletions
12
pom.xml
12
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
<name>Raxen</name>
|
<name>Raxen</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.16</java.version>
|
<java.version>1.17</java.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>16</source>
|
<source>17</source>
|
||||||
<target>16</target>
|
<target>17</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@ -94,7 +94,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -119,13 +119,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.tr7zw</groupId>
|
<groupId>de.tr7zw</groupId>
|
||||||
<artifactId>nbt-data-api</artifactId>
|
<artifactId>nbt-data-api</artifactId>
|
||||||
<version>2.8.0</version>
|
<version>2.9.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.tr7zw</groupId>
|
<groupId>de.tr7zw</groupId>
|
||||||
<artifactId>nbt-injector</artifactId>
|
<artifactId>nbt-injector</artifactId>
|
||||||
<version>2.8.0</version>
|
<version>2.9.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -21,7 +21,7 @@ public final class Raxen extends JavaPlugin {
|
||||||
|
|
||||||
private static final String prefix = ChatColor.AQUA + "Rx" + ChatColor.LIGHT_PURPLE + "> ";
|
private static final String prefix = ChatColor.AQUA + "Rx" + ChatColor.LIGHT_PURPLE + "> ";
|
||||||
@Getter
|
@Getter
|
||||||
private static final String version = "0.0.1";
|
private static final String version = "0.0.2";
|
||||||
private final PluginManager pm = getServer().getPluginManager();
|
private final PluginManager pm = getServer().getPluginManager();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -117,4 +117,8 @@ public final class Raxen extends JavaPlugin {
|
||||||
public static PlayerConfig getPlayerConfig() {
|
public static PlayerConfig getPlayerConfig() {
|
||||||
return playerConfig;
|
return playerConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Config getConf() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
79
src/main/java/gq/unurled/raxen/commands/RaxenCommand.java
Normal file
79
src/main/java/gq/unurled/raxen/commands/RaxenCommand.java
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
package gq.unurled.raxen.commands;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Utils.color;
|
||||||
|
import static gq.unurled.raxen.utils.Utils.msgPlayer;
|
||||||
|
|
||||||
|
public class RaxenCommand implements TabExecutor {
|
||||||
|
|
||||||
|
private Raxen main;
|
||||||
|
|
||||||
|
public RaxenCommand(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
|
||||||
|
if(sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(!(player.hasPermission("raxen."))) {
|
||||||
|
msgPlayer(player, Raxen.getPrefix() + color("&cYou can't execute this command. Insufficient permission."));
|
||||||
|
}
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
msgPl(player, 0);
|
||||||
|
case 1:
|
||||||
|
switch (args[0]) {
|
||||||
|
case "mongodb":
|
||||||
|
case "mongo":
|
||||||
|
case "MONGODB":
|
||||||
|
case "MONGO":
|
||||||
|
//print info about connection
|
||||||
|
case "v":
|
||||||
|
case "version":
|
||||||
|
case "ver":
|
||||||
|
//print case 0?
|
||||||
|
case "hemlp":
|
||||||
|
case "?":
|
||||||
|
case "h":
|
||||||
|
//print plugin help
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void msgPl(Player player, Integer in) {
|
||||||
|
switch(in) {
|
||||||
|
case 0:
|
||||||
|
msgPlayer(player, Raxen.getPrefix() + color("&6Printing About Raxen..."),
|
||||||
|
color("&6---------------------------------------------"),
|
||||||
|
color("&3 Raxen "),
|
||||||
|
color("&3 - Version: " + Raxen.getVersion()),
|
||||||
|
color("&3 - Author: &l&cU&6n&eu&2r&al&be&3d&r"),
|
||||||
|
color("&3 - Website: https://unurled.gq"));
|
||||||
|
TextComponent txt = Component.text(color("&3 - Website: https://unurled.gq"));
|
||||||
|
txt.clickEvent(ClickEvent.openUrl("https://unurled.gq"));
|
||||||
|
player.sendMessage(txt);
|
||||||
|
msgPlayer(player, "", color("&6---------------------------------------------"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static gq.unurled.raxen.utils.Utils.log;
|
import static gq.unurled.raxen.utils.Utils.log;
|
||||||
|
import static gq.unurled.raxen.utils.Utils.warn;
|
||||||
|
|
||||||
public class PlayerConfig {
|
public class PlayerConfig {
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ public class PlayerConfig {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
this.sto = main.getStorageManager();
|
this.sto = main.getStorageManager();
|
||||||
this.mongoDB = sto.getMongo();
|
this.mongoDB = sto.getMongo();
|
||||||
|
this.mongoDB.connect();
|
||||||
this.mongoCollection = mongoDB.getMongoCollection();
|
this.mongoCollection = mongoDB.getMongoCollection();
|
||||||
this.profileManager = main.getProfileManager();
|
this.profileManager = main.getProfileManager();
|
||||||
}
|
}
|
||||||
|
@ -183,14 +185,14 @@ public class PlayerConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadPlayerConfig(Player player) {
|
public void loadPlayerConfig(Player player) {
|
||||||
switch(sto.getCurrently()) {
|
if (StorageManager.getCurrently().equals("MONGODB")) {
|
||||||
case "MONGODB":
|
loadUsingMongoDB(player);
|
||||||
loadUsingMongoDB(player);
|
warn("'" + StorageManager.getCurrently()+ "'");
|
||||||
case "MYSQL":
|
}
|
||||||
case "YML":
|
else {
|
||||||
loadUsingYml(player);
|
warn("'" + StorageManager.getCurrently()+ "'");
|
||||||
|
loadUsingYml(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Player: " + player.getName() + " data successfully loaded!");
|
log("Player: " + player.getName() + " data successfully loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package gq.unurled.raxen.manager;
|
package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.commands.RaxenCommand;
|
||||||
import gq.unurled.raxen.commands.admin.NbtCommand;
|
import gq.unurled.raxen.commands.admin.NbtCommand;
|
||||||
import gq.unurled.raxen.commands.admin.ReloadCommand;
|
import gq.unurled.raxen.commands.admin.ReloadCommand;
|
||||||
import gq.unurled.raxen.commands.admin.TestGuiCommand;
|
import gq.unurled.raxen.commands.admin.TestGuiCommand;
|
||||||
|
@ -37,6 +38,10 @@ public class CommandManager {
|
||||||
SkillsCommand skillsCommand = new SkillsCommand(main);
|
SkillsCommand skillsCommand = new SkillsCommand(main);
|
||||||
main.getCommand("skills").setTabCompleter(skillsCommand);
|
main.getCommand("skills").setTabCompleter(skillsCommand);
|
||||||
main.getCommand("skills").setExecutor(skillsCommand);
|
main.getCommand("skills").setExecutor(skillsCommand);
|
||||||
|
|
||||||
|
RaxenCommand raxenCommand = new RaxenCommand(main);
|
||||||
|
main.getCommand("raxen").setTabCompleter(raxenCommand);
|
||||||
|
main.getCommand("raxen").setExecutor(raxenCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
import gq.unurled.raxen.utils.MongoDB;
|
import gq.unurled.raxen.utils.MongoDB;
|
||||||
|
import gq.unurled.raxen.utils.Mysql;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
@ -12,8 +13,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import static gq.unurled.raxen.utils.Utils.error;
|
import static gq.unurled.raxen.utils.Utils.*;
|
||||||
import static gq.unurled.raxen.utils.Utils.log;
|
|
||||||
|
|
||||||
public class StorageManager {
|
public class StorageManager {
|
||||||
|
|
||||||
|
@ -24,37 +24,49 @@ public class StorageManager {
|
||||||
private static MongoDB mongo;
|
private static MongoDB mongo;
|
||||||
@Getter
|
@Getter
|
||||||
private static String currently;
|
private static String currently;
|
||||||
|
@Getter
|
||||||
|
private static Mysql mysql;
|
||||||
|
|
||||||
public StorageManager(Raxen main) {
|
public StorageManager(Raxen main) {
|
||||||
this.main = main.getPlugin();
|
this.main = main.getPlugin();
|
||||||
this.config = main.getConfig();
|
this.config = main.getConfig();
|
||||||
|
this.mongo = new MongoDB();
|
||||||
|
this.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void connect() {
|
public static void connect() {
|
||||||
String s = (String) config.get("storage");
|
String s = (String) config.get("storage");
|
||||||
switch(s) {
|
log(s);
|
||||||
case "MONGODB":
|
if(s.equalsIgnoreCase("MONGODB")) {
|
||||||
mongo.connect();
|
mongo.connect();
|
||||||
currently = s;
|
currently = "MONGODB";
|
||||||
case "MYSQL":
|
warn("'" + s + "'");
|
||||||
error("Currently not implemented, switching to YML");
|
}
|
||||||
currently = "YML";
|
|
||||||
case "YML":
|
if(s.equalsIgnoreCase("MYSQL")) {
|
||||||
currently = s;
|
error("Currently not implemented, switching to YML");
|
||||||
|
currently = "YML";
|
||||||
|
warn("'" + s + "'");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
currently = "YML";
|
||||||
|
warn("'" + s + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileConfiguration createYml(Player player) {
|
public static void disconnect() {
|
||||||
String name = player.getName();
|
mysql.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileConfiguration createYml(Player player) {
|
||||||
File customFile;
|
File customFile;
|
||||||
FileConfiguration customConfig;
|
FileConfiguration customConfig;
|
||||||
log(main.getDataFolder() + "/" + player.getUniqueId() + "custom.yml");
|
log(main.getDataFolder() + "/playerInfo/" + player.getUniqueId() + "/playerInfo.yml");
|
||||||
customFile = new File(main.getDataFolder() + "/" + player.getUniqueId(), "playerInfo.yml");
|
customFile = new File(main.getDataFolder() + "/playerInfo/" + player.getUniqueId(), "/playerInfo.yml");
|
||||||
|
|
||||||
if (!customFile.exists()) {
|
if (!customFile.exists()) {
|
||||||
customFile.getParentFile().mkdirs();
|
customFile.getParentFile().mkdirs();
|
||||||
main.saveResource("playerInfo.yml", false);
|
main.saveResource(main.getDataFolder() + "/playerInfo/" + player.getUniqueId() + "/playerInfo.yml", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
customConfig = new YamlConfiguration();
|
customConfig = new YamlConfiguration();
|
||||||
|
|
|
@ -18,14 +18,10 @@ public class MongoDB {
|
||||||
@Getter
|
@Getter
|
||||||
private MongoCollection<Document> mongoCollection;
|
private MongoCollection<Document> mongoCollection;
|
||||||
|
|
||||||
public MongoDB() {
|
|
||||||
this.connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void connect() {
|
public void connect() {
|
||||||
ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017");
|
ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017");
|
||||||
mongoClient = MongoClients.create(connectionString);
|
mongoClient = MongoClients.create(connectionString);
|
||||||
mongoDatabase = mongoClient.getDatabase("Elixium");
|
mongoDatabase = mongoClient.getDatabase("Raxen");
|
||||||
mongoCollection = mongoDatabase.getCollection("player");
|
mongoCollection = mongoDatabase.getCollection("player");
|
||||||
|
|
||||||
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "MongoDB connected!");
|
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "MongoDB connected!");
|
||||||
|
|
46
src/main/java/gq/unurled/raxen/utils/Mysql.java
Normal file
46
src/main/java/gq/unurled/raxen/utils/Mysql.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package gq.unurled.raxen.utils;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.config.Config;
|
||||||
|
import gq.unurled.raxen.manager.StorageManager;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
|
||||||
|
public class Mysql {
|
||||||
|
|
||||||
|
private static String username;
|
||||||
|
private static String password;
|
||||||
|
private static String url;
|
||||||
|
|
||||||
|
private Raxen main;
|
||||||
|
private StorageManager sto;
|
||||||
|
private Config config;
|
||||||
|
|
||||||
|
public Mysql(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.sto = main.getStorageManager();
|
||||||
|
this.config = main.getConf();
|
||||||
|
this.username = (String) config.getConfig().get("username");
|
||||||
|
this.url = (String) config.getConfig().get("url");
|
||||||
|
this.password = (String) config.getConfig().get("password");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String get(Player player, String str) throws SQLException {
|
||||||
|
return "False";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void connect() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void disconnect() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,3 +3,7 @@ motd: "YAY, Super server!"
|
||||||
motd-reload: "Server reloading!"
|
motd-reload: "Server reloading!"
|
||||||
|
|
||||||
storage: "MONGODB" #switch between "MONGODB", "MYSQL"(not implemented), "YML"(currzently making it)
|
storage: "MONGODB" #switch between "MONGODB", "MYSQL"(not implemented), "YML"(currzently making it)
|
||||||
|
#if MYSQL
|
||||||
|
username: "Your-username-here"
|
||||||
|
password: "Your-password-here"
|
||||||
|
url: "url-to-the-server/db_Name"
|
|
@ -3,6 +3,7 @@ version: '${project.version}'
|
||||||
main: gq.unurled.raxen.Raxen
|
main: gq.unurled.raxen.Raxen
|
||||||
api-version: 1.17
|
api-version: 1.17
|
||||||
depend: [ProtocolLib]
|
depend: [ProtocolLib]
|
||||||
|
softdepend: [AureliumSkills, LuckPerms]
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
reloadplugin:
|
reloadplugin:
|
||||||
|
@ -20,6 +21,8 @@ commands:
|
||||||
description: acces player storage
|
description: acces player storage
|
||||||
nbt:
|
nbt:
|
||||||
description: nbt command
|
description: nbt command
|
||||||
|
raxen:
|
||||||
|
description: raxen main command
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
raxen.reload.cmd:
|
raxen.reload.cmd:
|
||||||
|
@ -28,3 +31,6 @@ permissions:
|
||||||
description: testgui command permission
|
description: testgui command permission
|
||||||
raxen.nbt.cmd:
|
raxen.nbt.cmd:
|
||||||
description: nbt command permission
|
description: nbt command permission
|
||||||
|
permission:
|
||||||
|
raxen.raxen.cmd:
|
||||||
|
description: raxen command permssion
|
Loading…
Reference in a new issue