add javadocs same as previous commit
This commit is contained in:
unurled 2022-04-28 15:07:15 +02:00
parent 84c2c3ded7
commit f82a3481ac
22 changed files with 149 additions and 2 deletions

View file

@ -26,6 +26,9 @@ public class Config {
this.init(); this.init();
} }
/**
* init method, saves config and everything
*/
public void init() { public void init() {
FileConfiguration config = main.getConfig(); FileConfiguration config = main.getConfig();
File configFile = new File(main.getDataFolder() + "/config.yml"); File configFile = new File(main.getDataFolder() + "/config.yml");

View file

@ -53,10 +53,20 @@ public class PlayerConfig {
this.attributes = new Attributes(main); this.attributes = new Attributes(main);
} }
/**
* closes mongo connection
*/
public void close() { public void close() {
mongoDB.close(); mongoDB.close();
} }
/**
* save players stuff to mongo db
* @param player
* @param attributes
* @param invstr
* @param reverse
*/
public void saveUsingMongoDB(@NotNull Player player, Attributes attributes, String invstr, Integer reverse) { public void saveUsingMongoDB(@NotNull Player player, Attributes attributes, String invstr, Integer reverse) {
debug(main, "Saving " + player.getName() + "'s data!"); debug(main, "Saving " + player.getName() + "'s data!");
Document doc = new Document("uuid", player.getUniqueId().toString()) Document doc = new Document("uuid", player.getUniqueId().toString())
@ -95,6 +105,13 @@ public class PlayerConfig {
} }
} }
/**
* save players stuff to yml
* @param player
* @param attributes
* @param invstr
* @param reverse
*/
public void saveUsingYml(Player player, Attributes attributes, String invstr, Integer reverse) { public void saveUsingYml(Player player, Attributes attributes, String invstr, Integer reverse) {
FileConfiguration config = sto.createYml(player); FileConfiguration config = sto.createYml(player);
config.set("name", player.getName()); config.set("name", player.getName());
@ -126,6 +143,10 @@ public class PlayerConfig {
} }
} }
/**
* load player stuff from mongo db
* @param player
*/
public void loadUsingMongoDB(@NotNull Player player) { public void loadUsingMongoDB(@NotNull Player player) {
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first(); Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
if(playerDoc == null) { if(playerDoc == null) {
@ -159,6 +180,11 @@ public class PlayerConfig {
PlayerUtils.updateSkills(main, player); PlayerUtils.updateSkills(main, player);
} }
/**
* load player stuff from yml
* @param player
* @throws IOException
*/
public void loadUsingYml(Player player) throws IOException { public void loadUsingYml(Player player) throws IOException {
FileConfiguration config = sto.createYml(player); FileConfiguration config = sto.createYml(player);
attributes.setAttributes(player, config.getInt("maxHealth"), config.getInt("health"), config.getInt("itemHealth"), attributes.setAttributes(player, config.getInt("maxHealth"), config.getInt("health"), config.getInt("itemHealth"),
@ -183,6 +209,10 @@ public class PlayerConfig {
playerManager.getRaxenPlayer(player).setInventory(inv); playerManager.getRaxenPlayer(player).setInventory(inv);
} }
/**
* saves player stuff
* @param player
*/
public void savePlayerConfig(@NotNull Player player) { public void savePlayerConfig(@NotNull Player player) {
Attributes attributes = new Attributes(main); Attributes attributes = new Attributes(main);
Inventory inv = player.getInventory(); Inventory inv = player.getInventory();
@ -225,6 +255,10 @@ public class PlayerConfig {
debug(main, "Player: " + player.getName() + " data successfully saved!"); debug(main, "Player: " + player.getName() + " data successfully saved!");
} }
/**
* load player stuff
* @param player
*/
public void loadPlayerConfig(Player player) { public void loadPlayerConfig(Player player) {
String st = StorageManager.getConfig().getString("storage"); String st = StorageManager.getConfig().getString("storage");
String value = ""; String value = "";

View file

@ -27,6 +27,11 @@ public class DamageEntity implements Listener {
this.entityNamespacedKey = new EntityNamespacedKey(main); this.entityNamespacedKey = new EntityNamespacedKey(main);
} }
/**
* fired when an entity is damaged by another entity
* calculates the damage and apply it to the entity
* @param e
*/
@EventHandler @EventHandler
public void entityDamageByEntity(EntityDamageByEntityEvent e) { public void entityDamageByEntity(EntityDamageByEntityEvent e) {
if (!(e.getEntity() instanceof LivingEntity) || !(e.getDamager() instanceof LivingEntity)) { if (!(e.getEntity() instanceof LivingEntity) || !(e.getDamager() instanceof LivingEntity)) {
@ -110,6 +115,10 @@ public class DamageEntity implements Listener {
} }
} }
/**
* damage made by blocks on entity
* @param e
*/
@EventHandler @EventHandler
public void entityDamageByBlock(EntityDamageByBlockEvent e) { public void entityDamageByBlock(EntityDamageByBlockEvent e) {
e.setDamage(0); e.setDamage(0);

View file

@ -25,10 +25,15 @@ public class SpawnEvent implements Listener {
this.namespacedKey = new EntityNamespacedKey(main); this.namespacedKey = new EntityNamespacedKey(main);
} }
/**
* when a new entity spawns
* adds all persistent data container
* @param e
*/
@EventHandler @EventHandler
public void Spawn(EntitySpawnEvent e) { public void Spawn(EntitySpawnEvent e) {
if (e.getEntity() instanceof Player) { if (e.getEntity() instanceof Player) {
//player stuff dont want to talk about it; //player stuff dont want to talk about it; already doing it in player join event
debug(main, "Player: " + ((Player) e.getEntity()).getName()); debug(main, "Player: " + ((Player) e.getEntity()).getName());
} else if (e.getEntity().getType() != EntityType.DROPPED_ITEM && e.getEntity().getType() != EntityType.FALLING_BLOCK) { } else if (e.getEntity().getType() != EntityType.DROPPED_ITEM && e.getEntity().getType() != EntityType.FALLING_BLOCK) {
debug(main, e.getEntity().getName()); debug(main, e.getEntity().getName());

View file

@ -22,6 +22,10 @@ public class ArmorEvent implements Listener {
this.main = main; this.main = main;
} }
/**
* when player changes armor, calculates new stats for player and setting it
* @param e
*/
@EventHandler @EventHandler
public void ArmorChangeEvent(PlayerArmorChangeEvent e) { public void ArmorChangeEvent(PlayerArmorChangeEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();

View file

@ -21,6 +21,10 @@ public class ClickBlockEvent implements Listener {
this.gui = new GUI(main); this.gui = new GUI(main);
} }
/**
* use with guis
* @param e
*/
@EventHandler @EventHandler
public void ClickEvent(PlayerInteractEvent e) { public void ClickEvent(PlayerInteractEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();

View file

@ -15,6 +15,10 @@ public class CloseInventoryEvent implements Listener {
private PlayerManager playerManager; private PlayerManager playerManager;
/**
* save enderchest/storage when player close
* @param e
*/
@EventHandler @EventHandler
public void InventoryCloseEvent(InventoryCloseEvent e) { public void InventoryCloseEvent(InventoryCloseEvent e) {
Player player = (Player) e.getPlayer(); Player player = (Player) e.getPlayer();

View file

@ -22,6 +22,10 @@ public class ItemHandEvent implements Listener {
this.main = main; this.main = main;
} }
/**
* when player have something in hand, change and add new stats
* @param e
*/
@EventHandler @EventHandler
public void ItemHeldEvent(PlayerItemHeldEvent e) { public void ItemHeldEvent(PlayerItemHeldEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();

View file

@ -26,6 +26,10 @@ public class JoinEvent implements Listener {
this.playerManager = main.getManager().getPlayerManager(); this.playerManager = main.getManager().getPlayerManager();
} }
/**
* when player joins, load from config all stats
* @param e
*/
@EventHandler @EventHandler
public void PlayerJoinEvent(PlayerJoinEvent e) { public void PlayerJoinEvent(PlayerJoinEvent e) {
Player player = e.getPlayer(); Player player = e.getPlayer();

View file

@ -21,6 +21,11 @@ public class LeaveEvent implements Listener {
} }
/**
* when player leaves, saves everything
* @param e
* @throws IOException
*/
@EventHandler @EventHandler
public void PlayerLeaveEvent(PlayerQuitEvent e) throws IOException { public void PlayerLeaveEvent(PlayerQuitEvent e) throws IOException {
Player player = e.getPlayer(); Player player = e.getPlayer();

View file

@ -22,6 +22,10 @@ public class ServerPingEvent implements Listener {
this.loading = true; this.loading = true;
} }
/**
* set the motd
* @param e
*/
@EventHandler @EventHandler
public void ServerListPingEvent(ServerListPingEvent e) { public void ServerListPingEvent(ServerListPingEvent e) {
FileConfiguration config = this.main.getConfig(); FileConfiguration config = this.main.getConfig();

View file

@ -20,6 +20,10 @@ public class TransactionEvent implements Listener {
this.vault = main.getManager().getLibsManager().getVault(); this.vault = main.getManager().getLibsManager().getVault();
} }
/**
* set scoreboard when money changes
* @param e
*/
@EventHandler @EventHandler
public void transaction(net.essentialsx.api.v2.events.TransactionEvent e) { public void transaction(net.essentialsx.api.v2.events.TransactionEvent e) {
Player player = Bukkit.getPlayer(e.getTarget().getName()); Player player = Bukkit.getPlayer(e.getTarget().getName());

View file

@ -36,6 +36,11 @@ public class EntityManager {
} }
/**
* used to register entities using fileconfigs but rapidly abandoned
* @param file
*/
@Deprecated
public void registerEntityFromConfig(FileConfiguration file) { public void registerEntityFromConfig(FileConfiguration file) {
debug(file.getString("id")); debug(file.getString("id"));
World world = Bukkit.getWorld(file.getString("world")); World world = Bukkit.getWorld(file.getString("world"));

View file

@ -36,6 +36,10 @@ public class ItemManager {
// register(); // register();
} }
/**
* Old system to register all items in the /items/ folder
*/
@Deprecated
private void register() { private void register() {
File folder = new File(main.getDataFolder() + "/Items/"); File folder = new File(main.getDataFolder() + "/Items/");
File[] listFile = folder.listFiles(); File[] listFile = folder.listFiles();
@ -68,6 +72,11 @@ public class ItemManager {
} }
} }
/**
* Old system to register for a file config an item inside.
* @param file
*/
@Deprecated
private void registerItem(@NotNull FileConfiguration file) { private void registerItem(@NotNull FileConfiguration file) {
debug(main, file.getString("id")); debug(main, file.getString("id"));
ItemStack it = new ItemStack(Objects.requireNonNull(Material.getMaterial((String) Objects.requireNonNull(file.get("id"))))); ItemStack it = new ItemStack(Objects.requireNonNull(Material.getMaterial((String) Objects.requireNonNull(file.get("id")))));

View file

@ -47,6 +47,10 @@ public class PlayerManager {
return new RaxenPlayer(main, player); return new RaxenPlayer(main, player);
} }
/**
* add a task to the player action bar.
* @param player
*/
public void registerActionBar(Player player) { public void registerActionBar(Player player) {
PlayerManager pm = main.getManager().getPlayerManager(); PlayerManager pm = main.getManager().getPlayerManager();
BukkitTask task = new BukkitRunnable() { BukkitTask task = new BukkitRunnable() {
@ -62,6 +66,10 @@ public class PlayerManager {
} }
} }
/**
* removes the task of action bar to player
* @param player
*/
public void unRegisterActionBar(Player player) { public void unRegisterActionBar(Player player) {
if(actionBar.containsKey(player.getUniqueId())) { if(actionBar.containsKey(player.getUniqueId())) {
BukkitTask task = actionBar.get(player.getUniqueId()); BukkitTask task = actionBar.get(player.getUniqueId());

View file

@ -34,6 +34,9 @@ public class StorageManager {
this.connect(); this.connect();
} }
/**
* Connects to the storage system (MONGO, YML, MYSQL (not implemented))
*/
public static void connect() { public static void connect() {
String s = (String) config.get("storage"); String s = (String) config.get("storage");
debug(main, s); debug(main, s);
@ -49,10 +52,18 @@ public class StorageManager {
} }
} }
/**
* disconnect mysql db
*/
public static void disconnect() { public static void disconnect() {
mysql.disconnect(); mysql.disconnect();
} }
/**
* create a new yml for the player
* @param player
* @return the created yml
*/
public static @NotNull FileConfiguration createYml(@NotNull Player player) { public static @NotNull FileConfiguration createYml(@NotNull Player player) {
File customFile; File customFile;
FileConfiguration customConfig; FileConfiguration customConfig;
@ -97,6 +108,11 @@ public class StorageManager {
return customConfig; return customConfig;
} }
/**
* create a config yaml with the file
* @param file
* @return a file configuration
*/
public static @NotNull FileConfiguration createYml(@NotNull File file) { public static @NotNull FileConfiguration createYml(@NotNull File file) {
FileConfiguration customConfig; FileConfiguration customConfig;
@ -120,6 +136,11 @@ public class StorageManager {
return customConfig; return customConfig;
} }
/**
* create a config in the path provided
* @param path
* @return the created config file
*/
public static @NotNull FileConfiguration createYml(String path) { public static @NotNull FileConfiguration createYml(String path) {
File customFile; File customFile;
FileConfiguration customConfig; FileConfiguration customConfig;

View file

@ -33,6 +33,9 @@ public class CommandManager {
this.raxenCommand = new RaxenCommand(main); this.raxenCommand = new RaxenCommand(main);
} }
/**
* register/add all the plugin's command
*/
public void register() { public void register() {
main.getCommand("reloadplugin").setExecutor(reloadComand); main.getCommand("reloadplugin").setExecutor(reloadComand);
main.getCommand("reloadplugin").setTabCompleter(reloadComand); main.getCommand("reloadplugin").setTabCompleter(reloadComand);

View file

@ -21,6 +21,9 @@ public class DungeonsManager {
registerDungeons(); registerDungeons();
} }
/**
* register/add all made dungeon to the available plugin list
*/
public void registerDungeons() { public void registerDungeons() {
ForestDungeon forestDungeon = new ForestDungeon(); ForestDungeon forestDungeon = new ForestDungeon();
dungeons.put("FOREST", forestDungeon); dungeons.put("FOREST", forestDungeon);

View file

@ -1,10 +1,11 @@
package gq.unurled.raxen.listener.player; package gq.unurled.raxen.manager.server;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import java.lang.reflect.Field; import java.lang.reflect.Field;
public class EnchantmentManager { public class EnchantmentManager {
public static void registerEnchantment(Enchantment enchantment) { public static void registerEnchantment(Enchantment enchantment) {
boolean registered = true; boolean registered = true;
try { try {

View file

@ -21,6 +21,9 @@ public class ListenerManager {
this.serverPingEvent = new ServerPingEvent(main); this.serverPingEvent = new ServerPingEvent(main);
} }
/**
* register/addd listener events
*/
public void register() { public void register() {
this.pm.registerEvents(new JoinEvent(main), main); this.pm.registerEvents(new JoinEvent(main), main);
this.pm.registerEvents(new LeaveEvent(main), main); this.pm.registerEvents(new LeaveEvent(main), main);

View file

@ -27,6 +27,9 @@ public class ResourcePackManager {
enable(); enable();
} }
/**
* Method to enable the ressourcpack
*/
private void enable() { private void enable() {
if(useRP) { if(useRP) {
if(config.getString("resource_pack_url") == null || Objects.equals(config.getString("rssource_pack_url"), "") || if(config.getString("resource_pack_url") == null || Objects.equals(config.getString("rssource_pack_url"), "") ||

View file

@ -58,6 +58,9 @@ public class WorldManager {
} }
} }
/**
* load all world in the worlds folder
*/
public void load() { public void load() {
if (!pluginFolder.exists()) { if (!pluginFolder.exists()) {
pluginFolder.mkdirs(); pluginFolder.mkdirs();
@ -86,6 +89,10 @@ public class WorldManager {
} }
} }
/**
* load world from the name of it
* @param name
*/
public void loadWorld(String name) { public void loadWorld(String name) {
File world = new File(pluginFolder + "/" + name + "/"); File world = new File(pluginFolder + "/" + name + "/");
if (!world.exists() || !world.isDirectory()) { if (!world.exists() || !world.isDirectory()) {