update to 1.18.2, and bug fixes
This commit is contained in:
unurled 2022-03-20 00:35:06 +01:00
parent e217fa80d7
commit 0b861e39bd
30 changed files with 224 additions and 160 deletions

View file

@ -2,7 +2,7 @@ plugins {
id 'java'
id 'maven-publish'
id "com.github.johnrengelman.shadow" version "7.1.2"
id("io.papermc.paperweight.userdev") version "1.3.3"
id("io.papermc.paperweight.userdev") version "1.3.5"
}
apply plugin: "java"
@ -57,16 +57,16 @@ dependencies {
implementation 'org.mongodb:bson:4.5.0'
implementation 'org.mongodb:mongodb-driver-core:4.5.0'
implementation 'de.tr7zw:item-nbt-api-plugin:2.9.0'
compileOnly 'io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT'
compileOnly 'com.comphenix.protocol:ProtocolLib:4.7.0'
compileOnly 'net.luckperms:api:5.3'
implementation 'de.tr7zw:item-nbt-api-plugin:2.9.2'
compileOnly 'io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT'
compileOnly 'com.comphenix.protocol:ProtocolLib:4.8.0'
compileOnly 'net.luckperms:api:5.4'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
compileOnly 'net.essentialsx:EssentialsX:2.19.2'
compileOnly 'net.essentialsx:EssentialsX:2.19.4'
compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Core:2.0.1'
compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit:2.0.1'
compileOnly fileTree(dir: 'libs', include: '*.jar')
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.18.1-R0.1-SNAPSHOT")
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.18.2-R0.1-SNAPSHOT")
}
group = 'gq.unurled'
@ -94,11 +94,10 @@ tasks {
shadowJar {
dependencies {
include dependency('de.tr7zw:item-nbt-api-plugin:2.9.0')
include dependency('org.mongodb:mongodb-driver-sync:4.4.0')
include dependency('org.mongodb:bson:4.4.0')
include dependency('org.mongodb:mongodb-driver-core:4.4.0')
include dependency('org.slf4j:slf4j-api:2.0.0-alpha5')
include dependency('de.tr7zw:item-nbt-api-plugin:2.9.2')
include dependency('org.mongodb:mongodb-driver-sync:4.5.0')
include dependency('org.mongodb:bson:4.5.0')
include dependency('org.mongodb:mongodb-driver-core:4.5.0')
}
relocate("de.tr7zw.changeme", "gq.unurled.libs.de.tr7zw")
relocate("de.tr7zw", "gq.unurled.libs.de.tr7zw")

View file

@ -9,18 +9,19 @@ import gq.unurled.raxen.utils.LuckPerm;
import gq.unurled.raxen.utils.Reload;
import gq.unurled.raxen.utils.Vault;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.bukkit.ChatColor;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Logger;
import static gq.unurled.raxen.utils.Utils.colorTextComp;
public final class Raxen extends JavaPlugin {
private static final String prefix = ChatColor.AQUA + "Rx" + ChatColor.LIGHT_PURPLE + "> ";
private static final TextComponent prefix = colorTextComp("<aqua>Rx</aqua><light_purple>></light_purple> ");
@Getter
private static String version = "0.4.6";
private static String version = "0.4.7";
private final PluginManager pm = getServer().getPluginManager();
private static Raxen plugin;
@ -84,7 +85,7 @@ public final class Raxen extends JavaPlugin {
registerCommands();
registerEvents();
getServer().getConsoleSender().sendMessage(Component.text(prefix +"§aServer Started Successfully!"));
getServer().getConsoleSender().sendMessage(colorTextComp(prefix +"<green>Server Started Successfully!</green>"));
listenerManager.getServerPingEvent().setLoading(false);
}
@ -92,13 +93,13 @@ public final class Raxen extends JavaPlugin {
private void registerCommands() {
commandManager.register();
getServer().getConsoleSender().sendMessage(Component.text(prefix +"§aCommands Registered!"));
getServer().getConsoleSender().sendMessage(colorTextComp(prefix +"<green>Commands Registered!</green>"));
}
private void registerEvents() {
listenerManager.register();
getServer().getConsoleSender().sendMessage(Component.text(prefix +"§aEvents Registered!"));
getServer().getConsoleSender().sendMessage(colorTextComp(prefix +"<green>Events Registered!</green>"));
}
@Override
@ -108,7 +109,7 @@ public final class Raxen extends JavaPlugin {
playerConfig.close();
getServer().getConsoleSender().sendMessage(Component.text(prefix +"§cServer Stopped Successfully!"));
getServer().getConsoleSender().sendMessage(colorTextComp(prefix +"<red>Server Stopped Successfully!</red>"));
}
public static Logger getPluginLogger() {
@ -123,7 +124,7 @@ public final class Raxen extends JavaPlugin {
return plugin;
}
public static String getPrefix() {
public static TextComponent getPrefix() {
return prefix;
}

View file

@ -29,7 +29,7 @@ public class RaxenCommand implements TabExecutor {
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."));
msgPlayer(player, Raxen.getPrefix().append(colorTextComp("<red>You can't execute this command. Insufficient permission.")));
}
switch (args.length) {
case 0 -> msgPl(player, 0);
@ -37,13 +37,14 @@ public class RaxenCommand implements TabExecutor {
switch (args[0]) {
case "mongodb", "mongo", "MONGODB", "MONGO" -> {
//print info about connection
sender.sendMessage(Raxen.getPrefix() + color("&6Printing About Raxen's MongoDB connection..."));
msgPlayer(player, Raxen.getPrefix() + color("&6---------------------------------------------"),
color("&cMONGO DB"));
sender.sendMessage(Raxen.getPrefix().append(colorTextComp("<gold>Printing About Raxen's MongoDB connection...")));
msgPlayer(player, Raxen.getPrefix()
.append(colorTextComp("<gold>---------------------------------------------")));
msgPlayer(player, colorTextComp("<red>MONGO DB<white>"));
msgPlayer(player, StorageManager.getMongo().getMongoClient().getClusterDescription().toString());
msgPlayer(player, StorageManager.getMongo().getMongoDatabase().getName());
msgPlayer(player, StorageManager.getMongo().getMongoCollection().getNamespace().toString());
msgPlayer(player, color("&6---------------------------------------------"));
msgPlayer(player, "<gold>---------------------------------------------");
}
case "v", "version", "ver" -> {
msgPl(player, 0);
@ -59,37 +60,37 @@ public class RaxenCommand implements TabExecutor {
log(String.valueOf(args.length));
switch (args.length) {
case 0 -> {
sender.sendMessage(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"));
TextComponent txt = Component.text(color("&3 - Website: https://unurled.gq"));
msgSender(sender, Raxen.getPrefix() + colorString("<gold>Printing About Raxen..."),
colorString("<gold>---------------------------------------------"),
colorString("<dark_aqua> Raxen "),
colorString("<dark_aqua> - Version: " + Raxen.getVersion()),
colorString("<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>"));
TextComponent txt = Component.text(colorString("<dark_aqua> - Website: https://unurled.gq"));
sender.sendMessage(txt);
sender.sendMessage(color("&6---------------------------------------------"));
sender.sendMessage(colorString("<gold>---------------------------------------------"));
return true;
}
case 1 -> {
switch (args[0]) {
case "mongodb", "mongo", "MONGODB", "MONGO" -> {
//print info about connection
sender.sendMessage(Raxen.getPrefix() + color("&6Printing About Raxen's MongoDB connection..."));
sender.sendMessage(color("&6---------------------------------------------"), color("&cMONGO DB"));
sender.sendMessage(Raxen.getPrefix() + colorString("<gold>Printing About Raxen's MongoDB connection..."));
sender.sendMessage(colorString("<gold>---------------------------------------------"), colorString("<red>MONGO DB"));
sender.sendMessage(StorageManager.getMongo().getMongoClient().getClusterDescription().toString());
sender.sendMessage(StorageManager.getMongo().getMongoDatabase().getName());
sender.sendMessage(StorageManager.getMongo().getMongoCollection().getNamespace().toString());
sender.sendMessage(color("&6---------------------------------------------"));
sender.sendMessage(colorString("<gold>---------------------------------------------"));
return true;
}
case "v", "version", "ver" -> {
sender.sendMessage(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"));
TextComponent txt= Component.text(color("&3 - Website: https://unurled.gq"));
sender.sendMessage(Raxen.getPrefix() + colorString("<gold>Printing About Raxen..."),
colorString("<gold>---------------------------------------------"),
colorString("<dark_aqua> Raxen "),
colorString("<dark_aqua> - Version: " + Raxen.getVersion()),
colorString("<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>"));
TextComponent txt= Component.text(colorString("<dark_aqua> - Website: https://unurled.gq"));
sender.sendMessage(txt);
sender.sendMessage(color("&6---------------------------------------------"));
sender.sendMessage(colorString("<gold>---------------------------------------------"));
return true;
}
case "hemlp", "?", "h" ->
@ -105,15 +106,15 @@ public class RaxenCommand implements TabExecutor {
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"));
TextComponent txt = Component.text(color("&3 - Website: https://unurled.gq"))
msgPlayer(player, Raxen.getPrefix() + "<gold>Printing About Raxen...",
"<gold>---------------------------------------------",
"<dark_aqua> Raxen ",
"<dark_aqua> - Version: " + Raxen.getVersion(),
"<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>");
TextComponent txt = (TextComponent) colorComp("<dark_aqua> - Website: https://unurled.gq")
.clickEvent(ClickEvent.openUrl("https://unurled.gq"));
player.sendMessage(txt);
msgPlayer(player, "", color("&6---------------------------------------------"));
msgPlayer(player, "", "<gold>---------------------------------------------");
}
}

View file

@ -34,7 +34,7 @@ public class ItemListCommand implements TabExecutor {
}
Player player = (Player) sender;
if(!(player.hasPermission("raxen.itemlist.cmd"))) {
msgPlayer(player, color("&cYou'dont have the permission to execute this command."));
msgPlayer(player, colorString("<red>You'dont have the permission to execute this command."));
return true;
}
//openGui logic

View file

@ -4,6 +4,7 @@ import de.tr7zw.nbtapi.NBTItem;
import gq.unurled.raxen.Raxen;
import gq.unurled.raxen.components.player.attributes.Attributes;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -32,16 +33,16 @@ public class NbtCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
if(!(sender instanceof Player)) {
error(color("&cYou can't execute this command as the Console!"));
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),colorString("<red>You can't execute this command as the Console!"));
return true;
}
Player player = (Player) sender;
if(player.getInventory().getItemInMainHand().getType() == Material.AIR || player.getInventory().getItemInMainHand() == null) {
msgPlayer(player,color("&cYou must hold an Item in hand."));
msgPlayer(player,colorString("<red>You must hold an Item in hand."));
return true;
}
switch (args.length) {
case 0, 1 -> msgPlayer(player, color("&cYou must specify an nbt and an int."));
case 0, 1 -> msgPlayer(player, colorString("<red>You must specify an nbt and an int."));
case 2 -> {
debug(main, "'" + args[0] + "'", "'" + args[1] + "'");
ItemStack it = player.getInventory().getItemInMainHand();
@ -62,15 +63,15 @@ public class NbtCommand implements TabExecutor {
ever = true;
} else {
if (yes) {
ct.append(Component.text(color(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a))));
ct.append(Component.text(colorString(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a))));
yes = false;
}
}
}
}
if (!ever) {
lore.add(Component.text(color("&cAttributes:")));
lore.add(Component.text(color(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a))));
lore.add(Component.text(colorString("<red>Attributes:")));
lore.add(Component.text(colorString(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a))));
}
itm.lore(lore);
it.setItemMeta(itm);
@ -89,7 +90,7 @@ public class NbtCommand implements TabExecutor {
attributes.addStrength(player, nbti.getInteger("STRENGTH"));
}
it = nbti.getItem();
msgPlayer(player, Raxen.getPrefix() + color("&fYou successfully added the nbt " + attributes(args[0]) + "&fwith " + args[1] + "&f."));
msgPlayer(player, Raxen.getPrefix() + colorString("<white>You successfully added the nbt " + attributes(args[0]) + "<white>with " + args[1] + "<white>."));
updateSkills(main, player);
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), it);
}

View file

@ -24,7 +24,7 @@ public class ReloadCommand implements TabExecutor {
}
}
Reload.kickAll();
log(color("&cServer stopping!\n Using: /rlpl.\n Please wait a little bit."));
log(colorString("<red>Server stopping!\n Using: /rlpl.\n Please wait a little bit."));
Bukkit.getServer().shutdown();
return false;
}

View file

@ -30,7 +30,7 @@ public class SpawnEntity implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if (!(sender instanceof Player)) {
log(color("&cConsole can't execute this command!"));
log(colorString("<red>Console can't execute this command!"));
return false;
}
Player player = (Player) sender;
@ -41,8 +41,8 @@ public class SpawnEntity implements TabExecutor {
//example command : /entityspawn ZOMBIE "&cHello folks" 50 200
EntityType type = EntityType.valueOf(args[0]);
Entity e = player.getWorld().spawnEntity(player.getLocation(), type, false);
setNameSpacedKeys(e, "&cName", 100, 100,0,50,0,100,0,100,0);
e.setCustomName(color(args[1]));
setNameSpacedKeys(e, "<red>Name", 100, 100,0,50,0,100,0,100,0);
e.customName(colorTextComp(args[1]));
e.setCustomNameVisible(true);
return false;
}

View file

@ -1,6 +1,5 @@
package gq.unurled.raxen.commands.admin;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -11,7 +10,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.List;
import static gq.unurled.raxen.utils.Utils.color;
import static gq.unurled.raxen.utils.Utils.colorTextComp;
import static gq.unurled.raxen.utils.Utils.log;
public class TestGuiCommand implements TabExecutor {
@ -20,7 +19,7 @@ public class TestGuiCommand implements TabExecutor {
if(sender instanceof Player) {
Player player = (Player) sender;
if(player.hasPermission("raxen.test.gui.cmd")) {
player.openInventory(Bukkit.createInventory(null, 54, Component.text(color(args[0]))));
player.openInventory(Bukkit.createInventory(null, 54, colorTextComp(args[0])));
}
}
else {

View file

@ -1,6 +1,7 @@
package gq.unurled.raxen.commands.player;
import gq.unurled.raxen.Raxen;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
@ -23,7 +24,7 @@ public class ClassCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(!(sender instanceof Player)) {
error("The console can't execute this Command!");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"The console can't execute this Command!");
return true;
}
Player player = (Player) sender;

View file

@ -2,7 +2,7 @@ package gq.unurled.raxen.commands.player;
import gq.unurled.raxen.Raxen;
import gq.unurled.raxen.components.player.attributes.Attributes;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
@ -25,7 +25,7 @@ public class SkillsCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String msg, @NotNull String[] args) {
if(!(sender instanceof Player)) {
error("The console can't execute this Command!");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"The console can't execute this Command!");
return true;
}
Player player = (Player) sender;
@ -33,12 +33,12 @@ public class SkillsCommand implements TabExecutor {
switch (args.length) {
case 0:
//open gui
player.sendMessage(Component.text(color("&cGUI not implemented yet..")).append(Component.text(color("&cTry /skill help."))));
player.sendMessage(colorTextComp("<red>GUI not implemented yet..").append(colorTextComp("<red>Try /skill help.")));
break;
case 1:
case 2:
player.sendMessage(Component.text(color("&fUse the command like: "))
.append(Component.text(color("&f/skill &3{health|defense|speed|strength} {add|set|remove} {amount}"))));
player.sendMessage(colorTextComp("<white>Use the command like: ")
.append(colorTextComp("<white>/skill <dark_aqua>{health|defense|speed|strength} {add|set|remove} {amount}")));
break;
case 3:
switch (args[0]) {

View file

@ -22,7 +22,7 @@ public class StorageCommand implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
if(!(sender instanceof Player)) {
error("The console can't execute this Command!");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"The console can't execute this Command!");
return true;
}
Player player = (Player) sender;
@ -39,7 +39,7 @@ public class StorageCommand implements TabExecutor {
case 1:
Player p = Bukkit.getPlayer(args[0]);
if(p == null) {
msgPlayer(player, color("&cYou can't open the Storage of an unknown Player."));
msgPlayer(player, colorString("<red>You can't open the Storage of an unknown Player."));
return true;
}
inv = playerManager.getRaxenPlayer(player).getStorage().getEc().getEc();

View file

@ -1,6 +1,7 @@
package gq.unurled.raxen.components.entity;
import gq.unurled.raxen.Raxen;
import net.kyori.adventure.text.Component;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Entity;
@ -28,7 +29,7 @@ public class RaxenEntity {
public Entity createEntity(EntityType type, String name, Location location) {
Entity e = location.getWorld().spawnEntity(location, type);
e.setCustomNameVisible(true);
e.setCustomName(name);
e.customName(Component.text(name));
return e;
}

View file

@ -5,7 +5,6 @@ import gq.unurled.raxen.Raxen;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@ -15,7 +14,7 @@ import java.util.ArrayList;
import java.util.List;
import static gq.unurled.raxen.components.items.NBT.*;
import static gq.unurled.raxen.utils.Utils.color;
import static gq.unurled.raxen.utils.Utils.colorTextComp;
public class Dager {
@ -27,7 +26,7 @@ public class Dager {
public void buildItem() {
dager = new ItemStack(Material.IRON_SWORD);
ItemMeta itm = dager.getItemMeta();
itm.displayName(Component.text(color("&bDager")));
itm.displayName(colorTextComp("<aqua>Dager"));
itm.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
itm.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS);
itm.setUnbreakable(true);

View file

@ -2,7 +2,6 @@ package gq.unurled.raxen.components.player;
import gq.unurled.raxen.Raxen;
import gq.unurled.raxen.utils.Vault;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
@ -10,8 +9,7 @@ import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.ScoreboardManager;
import static gq.unurled.raxen.utils.Utils.color;
import static gq.unurled.raxen.utils.Utils.debug;
import static gq.unurled.raxen.utils.Utils.*;
public class Scoreboard {
@ -26,17 +24,17 @@ public class Scoreboard {
public void createScorebord(Player player) {
ScoreboardManager manager = Bukkit.getScoreboardManager();
org.bukkit.scoreboard.Scoreboard board = manager.getNewScoreboard();
Objective obj = board.registerNewObjective("Raxen","dummy", Component.text(color("&cElixium")));
Objective obj = board.registerNewObjective("Raxen","dummy", colorTextComp("<red>Elixium"));
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
Score score = obj.getScore(color("&6-------------"));
Score score = obj.getScore(colorString("<gold>-------------"));
score.setScore(4);
Score score1 = obj.getScore(color("&bName:" + player.getName()));
Score score1 = obj.getScore(colorString("<aqua>Name:" + player.getName()));
score1.setScore(3);
Score score2 = obj.getScore(color("&fLocation"));
Score score2 = obj.getScore(colorString("<white>Location"));
score2.setScore(2);
Score score3 = obj.getScore(color("&6Coins: &6" + vault.getBalanceString(player)));
Score score3 = obj.getScore(colorString("<gold>Coins: <gold>" + vault.getBalanceString(player)));
score3.setScore(1);
Score score4 = obj.getScore(color("&eunurled.gq"));
Score score4 = obj.getScore(colorString("<yellow>unurled.gq"));
score4.setScore(0);
player.setScoreboard(board);
}
@ -52,7 +50,7 @@ public class Scoreboard {
}
}
player.getScoreboard().resetScores("Coins");
Score score = objective.getScore(color("&6Coins: &6" + vault.getBalanceString(player)));
Score score = objective.getScore(colorString("<gold>Coins: <gold>" + vault.getBalanceString(player)));
score.setScore(1);
}
}

View file

@ -1,11 +1,10 @@
package gq.unurled.raxen.components.player.classes;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import static gq.unurled.raxen.utils.Utils.color;
import static gq.unurled.raxen.utils.Utils.colorTextComp;
public class Class {
@ -24,7 +23,7 @@ public class Class {
this.name = name;
this.ID = ID;
this.placeHolder = new ItemStack(Material.getMaterial(itemPlaceHolder));
this.placeHolder.getItemMeta().displayName(Component.text(color(colorName)));
this.placeHolder.getItemMeta().displayName(colorTextComp(colorName));
this.max_level = max_level;
}
}

View file

@ -4,6 +4,7 @@ import gq.unurled.raxen.Raxen;
import gq.unurled.raxen.manager.PlayerManager;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@ -51,7 +52,7 @@ public class Classes {
resultClass cla = registerClass(customClass);
pm.addClasses(cla.getClas(), cla.getId());
} else if (listFile[i].listFiles()[a].isDirectory()) {
error("Can't use more than 2 folder to get Class.yml");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Can't use more than 2 folder to get Class.yml");
}
}

View file

@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack;
public class Assassin {
String ID = "ASSASSIN";
String name = "Assassin";
String colorName = "&cAssassin";
String colorName = "<red>Assassin";
Integer max_level = 100;
ItemStack placeHolder;

View file

@ -229,10 +229,10 @@ public class PlayerConfig {
if (st.equals("MONGODB")) {
loadUsingMongoDB(player);
value = "mongodb";
warn("'" + st + "'");
warn(main, "'" + st + "'");
}
else {
warn("'" + st + "'");
warn(main, "'" + st + "'");
value = "yml";
try {
loadUsingYml(player);

View file

@ -3,13 +3,12 @@ package gq.unurled.raxen.listener.player;
import gq.unurled.raxen.Raxen;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerListPingEvent;
import static gq.unurled.raxen.utils.Utils.color;
import static gq.unurled.raxen.utils.Utils.colorTextComp;
public class ServerPingEvent implements Listener {
@ -29,9 +28,9 @@ public class ServerPingEvent implements Listener {
String motd = config.getString("motd");
String motdReload = config.getString("motd-reload");
if (loading) {
e.motd(Component.text(color(motdReload)));
e.motd(colorTextComp(motdReload));
} else {
e.motd(Component.text(color(motd)));
e.motd(colorTextComp(motd));
}
}
}

View file

@ -5,6 +5,7 @@ import gq.unurled.raxen.Raxen;
import gq.unurled.raxen.components.items.NBT;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
@ -45,7 +46,7 @@ public class ItemManager {
customFile.createNewFile();
}
catch (IOException e) {
error("Error in Item Manager saving new File.");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Error in Item Manager saving new File.");
e.printStackTrace();
}
}
@ -56,11 +57,11 @@ public class ItemManager {
e.printStackTrace();
}
List<String> lore = new ArrayList<>();
lore.add("&csuper lore wahou");
lore.add("<red>super lore wahou");
if (customConfig.get("name") == null) {
customConfig.set("id", "minecraft_id_of_item");
customConfig.set("customId", "id_of_item_used_to_identify_it");
customConfig.set("name", "&cName of the Item");
customConfig.set("name", "<red>Name of the Item");
customConfig.set("health", 100);
customConfig.set("defense", 50);
customConfig.set("speed", 100);
@ -100,7 +101,7 @@ public class ItemManager {
}
registerItem(customItem);
} else if (listFile[i].listFiles()[a].isDirectory()) {
error("Can't use more than 2 folder to get Items.yml");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Can't use more than 2 folder to get Items.yml");
}
}
@ -109,13 +110,13 @@ public class ItemManager {
}
private void registerItem(FileConfiguration file) {
debug(file.getString("id"));
debug(main, file.getString("id"));
ItemStack it = new ItemStack(Material.getMaterial((String) file.get("id")));
ItemMeta itm = it.getItemMeta();
itm.displayName(Component.text(color((String) file.get("name"))));
itm.displayName(colorTextComp((String) file.get("name")));
List<Component> lore = new ArrayList<>();
for (String str : (List<String>) Objects.requireNonNull(file.get("lore"))) {
lore.add(Component.text(color(str)));
lore.add(colorTextComp(str));
}
itm.setCustomModelData(file.getConfigurationSection("Pack").getInt("custom_model_data"));
itm.lore(lore);

View file

@ -32,7 +32,7 @@ public class ResourcePackManager {
if(config.getString("resource_pack_url") == null || Objects.equals(config.getString("rssource_pack_url"), "") ||
config.getString("resource_pack_sha1") == null || Objects.equals(config.getString("resource_pack_sha1"), "") ||
Objects.equals(config.getString("resource_pack_url"), "https://mc-packs.net/") || Objects.equals(config.getString("resource_pack_sha1"), "sha1hallo")) {
error("You must specify an resource_pack_url and resource_pack_sha1!");
error(main, "You must specify an resource_pack_url and resource_pack_sha1!");
debug(main, "Resource pack not enabled.");
useRP = false;
} else {

View file

@ -4,6 +4,7 @@ import gq.unurled.raxen.Raxen;
import gq.unurled.raxen.utils.MongoDB;
import gq.unurled.raxen.utils.Mysql;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
@ -37,15 +38,15 @@ public class StorageManager {
debug(main, s);
if(s.equalsIgnoreCase("MONGODB")) {
mongo.connect();
warn("'" + s + "'");
warn(main, "'" + s + "'");
}
if(s.equalsIgnoreCase("MYSQL")) {
error("Currently not implemented, switching to YML");
warn("'" + s + "'");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Currently not implemented, switching to YML");
warn(main, "'" + s + "'");
}
else {
warn("'" + s + "'");
warn(main, "'" + s + "'");
}
}
@ -64,7 +65,7 @@ public class StorageManager {
customFile.createNewFile();
}
catch (IOException e) {
error("Error in Storage Manager saving new File.");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Error in Storage Manager saving new File.");
e.printStackTrace();
}
}
@ -107,7 +108,7 @@ public class StorageManager {
file.createNewFile();
}
catch (IOException e) {
error("Error in Storage Manager saving new File.");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Error in Storage Manager saving new File.");
e.printStackTrace();
}
}
@ -130,7 +131,7 @@ public class StorageManager {
customFile.createNewFile();
}
catch (IOException e) {
error("Error in Storage Manager saving new File.");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Error in Storage Manager saving new File.");
e.printStackTrace();
}
}

View file

@ -2,9 +2,11 @@ package gq.unurled.raxen.utils;
import com.google.gson.Gson;
import de.tr7zw.nbtapi.NBTItem;
import gq.unurled.raxen.Raxen;
import gq.unurled.raxen.components.items.Attributes;
import gq.unurled.raxen.components.items.NBT;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
@ -27,12 +29,12 @@ public class Items {
ItemStack item = new ItemStack(material, amount);
ItemMeta itemMeta = item.getItemMeta();
if(name != null) {
itemMeta.displayName(Component.text(color(name)));
itemMeta.displayName(colorComp(name));
}
if(lore != null) {
List<Component> list = new ArrayList<>();
for(String string : lore) {
list.add(Component.text(color(string)));
list.add(colorComp(string));
}
itemMeta.lore(list);
}
@ -62,7 +64,7 @@ public class Items {
}
public static ItemStack closeItem () {
return createItem(Material.BARRIER, 1, false, false, color("&cCLOSE"));
return createItem(Material.BARRIER, 1, false, false, colorString("<red>CLOSE"));
}
public static ItemStack greyPane() {
@ -208,19 +210,19 @@ public class Items {
public static String attributes(String str) {
String stt = "";
if(str.contains("SPEED")) {
stt = "&fSpeed";
stt = "<white>Speed";
return stt;
}
if(str.contains("STRENGTH")) {
stt = "&4Strength";
stt = "<dark_red>Strength";
return stt;
}
if(str.contains("HEALTH")) {
stt = "&cHealth";
stt = "<red>Health";
return stt;
}
if(str.contains("DEFENSE")) {
stt = "&1Defense";
stt = "<dark_blue>Defense";
return stt;
}
else {
@ -229,7 +231,7 @@ public class Items {
}
}
public static NBTItem setAttributes(String str, Integer nb, NBTItem nbti) {
public static NBTItem setAttributes(Raxen main, String str, Integer nb, NBTItem nbti) {
switch (str) {
case "SPEED":
nbti.setInteger(NBT.SPEED, nb);
@ -244,7 +246,7 @@ public class Items {
case "MANA":
nbti.setInteger(NBT.MANA, nb);
default:
error("Cant set Attributes with an unknown attribute.");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"), "Cant set Attributes with an unknown attribute.");
}
return nbti;
}
@ -301,44 +303,44 @@ public class Items {
NBTItem nbti = new NBTItem(it);
if(nbti.hasKey(NBT.SPEED)) {
if(lore.size() > 2) {
lore.add(2, Component.text(color(attributes("SPEED")) + nbti.getInteger(NBT.SPEED)));
lore.add(2, colorComp(attributes("SPEED")).append(Component.text(nbti.getInteger(NBT.SPEED))));
} else {
lore.add(Component.text(color(attributes("SPEED")) + nbti.getInteger(NBT.SPEED)));
lore.add(colorComp(attributes("SPEED")).append(Component.text(nbti.getInteger(NBT.SPEED))));
}
}
if(nbti.hasKey(NBT.HEALTH)) {
if(lore.size() > 1) {
lore.add(1, Component.text(color(attributes("HEALTH")) + nbti.getInteger(NBT.HEALTH)));
lore.add(1, colorComp(attributes("HEALTH")).append(Component.text(nbti.getInteger(NBT.HEALTH))));
} else {
lore.add(Component.text(color(attributes("HEALTH")) + nbti.getInteger(NBT.HEALTH)));
lore.add(colorComp(attributes("HEALTH")).append(Component.text(nbti.getInteger(NBT.HEALTH))));
}
}
if(nbti.hasKey(NBT.DEFENSE)) {
if(lore.size() > 3) {
lore.add(3, Component.text(color(attributes("DEFENSE")) + nbti.getInteger(NBT.DEFENSE)));
lore.add(3, colorComp(attributes("DEFENSE")).append(Component.text(nbti.getInteger(NBT.DEFENSE))));
} else {
lore.add(Component.text(color(attributes("DEFENSE")) + nbti.getInteger(NBT.DEFENSE)));
lore.add(colorComp(attributes("DEFENSE")).append(Component.text(nbti.getInteger(NBT.DEFENSE))));
}
}
if(nbti.hasKey(NBT.STRENGTH)) {
if(lore.size() > 3) {
lore.add(3, Component.text(color(attributes("STRENGTH")) + nbti.getInteger(NBT.STRENGTH)));
lore.add(3, colorComp(attributes("STRENGTH")).append(Component.text(nbti.getInteger(NBT.STRENGTH))));
} else {
lore.add(Component.text(color(attributes("STRENGTH")) + nbti.getInteger(NBT.STRENGTH)));
lore.add(colorComp(attributes("STRENGTH")).append(Component.text(nbti.getInteger(NBT.STRENGTH))));
}
}
if(nbti.hasKey(NBT.MANA)) {
if(lore.size() > 3) {
lore.add(3, Component.text(color(attributes("MANA")) + nbti.getInteger(NBT.MANA)));
lore.add(3, colorComp(attributes("MANA")).append(Component.text(nbti.getInteger(NBT.MANA))));
} else {
lore.add(Component.text(color(attributes("MANA")) + nbti.getInteger(NBT.MANA)));
lore.add(colorComp(attributes("MANA")).append(Component.text(nbti.getInteger(NBT.MANA))));
}
}
if(nbti.hasKey(NBT.LUCK)) {
if(lore.size() > 3) {
lore.add(3, Component.text(color(attributes("LUCK")) + nbti.getInteger(NBT.LUCK)));
lore.add(3, colorComp(attributes("LUCK")).append(Component.text(nbti.getInteger(NBT.LUCK))));
} else {
lore.add(Component.text(color(attributes("LUCK")) + nbti.getInteger(NBT.LUCK)));
lore.add(colorComp(attributes("LUCK")).append(Component.text(nbti.getInteger(NBT.LUCK))));
}
}
itm.lore(lore);

View file

@ -8,7 +8,8 @@ import com.mongodb.client.MongoDatabase;
import lombok.Getter;
import org.bson.Document;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import static gq.unurled.raxen.utils.Utils.colorTextComp;
public class MongoDB {
@Getter
@ -27,12 +28,12 @@ public class MongoDB {
mongoCollection = mongoDatabase.getCollection("player");
mongoConfigs = mongoDatabase.getCollection("config");
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "MongoDB connected!");
Bukkit.getConsoleSender().sendMessage(colorTextComp("<green>MongoDB connected!"));
}
public void close() {
mongoClient.close();
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "MongoDB disconnected!");
Bukkit.getConsoleSender().sendMessage(colorTextComp("<red>MongoDB disconnected!"));
}
}

View file

@ -16,6 +16,8 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import static gq.unurled.raxen.utils.Utils.colorTextComp;
public class Reload implements Listener {
private static FileConfiguration config = Raxen.getPlugin().getConfig();
@ -23,7 +25,7 @@ public class Reload implements Listener {
public static void kickAll() {
for(Player player : Bukkit.getOnlinePlayers()) {
player.kick(Component.text(Raxen.getPrefix() + "\n§cServer is Restarting\n §cPlease Wait a few Minutes to reconnect."));
player.kick(colorTextComp(Raxen.getPrefix() + "\n<red>Server is Restarting</red>\n <red>Please Wait a few Minutes to reconnect.</red>"));
}
}

View file

@ -2,26 +2,43 @@ package gq.unurled.raxen.utils;
import gq.unurled.raxen.Raxen;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.logging.Logger;
public class Utils {
private static final Logger logger = Raxen.getPluginLogger();
/**
*
* @param stringToComponent a string
* @return a component
*/
public static Component colorComp(String stringToComponent) {
return MiniMessage.miniMessage().deserialize(stringToComponent);
}
public static String color(String string) {
return ChatColor.translateAlternateColorCodes('&', string);
public static TextComponent colorTextComp(String stringToComponent) {
return (TextComponent) MiniMessage.miniMessage().deserialize(stringToComponent);
}
/**
*
* @param string a string
* @return a colored string
*/
public static String colorString(String string) {
return PlainTextComponentSerializer.plainText().serialize(MiniMessage.miniMessage().deserialize(string));
}
public static String decolor(String string) {
return ChatColor.stripColor(color(string));
return MiniMessage.miniMessage().stripTags(string);
}
/**
@ -33,7 +50,7 @@ public class Utils {
FileConfiguration config = main.getConfig();
if(config.getBoolean("debug")) {
for(String string : strings) {
logger.info(string);
main.getLogger().info(string);
}
}
}
@ -47,44 +64,84 @@ public class Utils {
FileConfiguration config = main.getConfig();
if(config.getBoolean("debug")) {
for(String string : strings) {
logger.info(string);
main.getLogger().info(string);
}
}
}
/**
* debug output to console if debug is set to true in config
* @param config main file config
* @param strings ouput to console
*/
public static void debug(FileConfiguration config, String... strings) {
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
if(config.getBoolean("debug")) {
for(String string : strings) {
logger.info(string);
main.getLogger().info(string);
}
}
}
public static void log(String... strings) {
public static void log(Raxen main, String... strings) {
for(String string : strings) {
logger.info(string);
main.getLogger().info(string);
}
}
public static void log(String... strings) {
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
assert main != null;
for(String string : strings) {
main.getLogger().info(string);
}
}
public static void warn(String... strings) {
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
assert main != null;
for(String string : strings) {
logger.warning(string);
main.getLogger().warning(string);
}
}
public static void warn(Raxen main, String... strings) {
for(String string : strings) {
main.getLogger().warning(string);
}
}
public static void error(String... strings) {
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
assert main != null;
for(String string : strings) {
logger.severe(string);
main.getLogger().severe(string);
}
}
public static void error(Raxen main, String... strings) {
for(String string : strings) {
main.getLogger().severe(string);
}
}
public static void msgPlayer(Player player, String... strings) {
for(String string : strings) {
player.sendMessage(Component.text(color(string)));
player.sendMessage(colorComp(string));
}
}
public static void msgPlayer(Player player, TextComponent strings) {
player.sendMessage(colorComp(PlainTextComponentSerializer.plainText().serialize(strings)));
}
public static void msgSender(CommandSender player, TextComponent strings) {
player.sendMessage(colorComp(PlainTextComponentSerializer.plainText().serialize(strings)));
}
public static void msgSender(CommandSender player, String... strings) {
for(String string : strings) {
player.sendMessage(colorComp(string));
}
}
@ -100,11 +157,11 @@ public class Utils {
}
public static Component noPerms() {
return Component.text(color("&cYou don't have the permission to use this feature."));
return colorComp("<red>You don't have the permission to use this feature.");
}
public static Component error() {
return Component.text(color("&cAn Error has occurred. Please retry or contact an Admin."));
return colorComp("<red>An Error has occurred. Please retry or contact an Admin.");
}

View file

@ -3,6 +3,7 @@ package gq.unurled.raxen.utils;
import gq.unurled.raxen.Raxen;
import lombok.Getter;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
@ -27,12 +28,12 @@ public class Vault {
private void setupEconomy() {
if (main.getServer().getPluginManager().getPlugin("Vault") == null) {
error("Need to install plugin Vault. (https://github.com/milkbowl/Vault)");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Need to install plugin Vault. (https://github.com/milkbowl/Vault)");
return;
}
RegisteredServiceProvider<Economy> rsp = main.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
error("Some bug happend in the initialisation of Vault and Raxen.");
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Some bug happend in the initialisation of Vault and Raxen.");
return;
}
econ = rsp.getProvider();

View file

@ -1,5 +1,5 @@
id: "SWORDSMANN"
name: "Swordsmann"
color-name: "&cSwordsmann"
color-name: "<red>Swordsmann"
item_placeholder: "DIAMOND_SWORD"
max_level: 10

View file

@ -14,4 +14,4 @@ Pack:
model: "red_wool"
drop_rate: 100.0
lore:
- '&cSuper lore'
- '<red>Super lore'

View file

@ -1,5 +1,5 @@
world: world
display_name: '&fLvl: {level} {name} &c❤{hp}&f/&c❤{hp_max}'
display_name: '<white>Lvl: {level} {name} <red>❤{hp}</red>/<red>❤{hp_max}'
name: 'example mob'
base_mob: ZOMBIE
ID: EXAMPLE_MOB