refactoring and code cleanup
All checks were successful
Build / build (push) Successful in 1m27s

This commit is contained in:
unurled 2024-02-29 15:44:28 +01:00
parent 7cc9395cbc
commit 1380e7479a
Signed by: unurled
GPG key ID: FDBC9CBE1F82423F
11 changed files with 45 additions and 77 deletions

View file

@ -50,6 +50,7 @@ public enum Attribute {
return minValue;
}
@SuppressWarnings("SameReturnValue")
public PersistentDataType<Double, Double> getType() {
return PersistentDataType.DOUBLE;
}

View file

@ -17,11 +17,13 @@ import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.EntityEquipment;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("EmptyMethod")
public class CombatManager extends Manager {
@EventHandler
public void onDamage(EntityDamageByBlockEvent e) {
public void onDamage(@NotNull EntityDamageByBlockEvent e) {
// TODO: Implement
// blast enchant :shrug:
// fall damage, fire damage, etc
@ -31,7 +33,7 @@ public class CombatManager extends Manager {
// TODO: Finish this
@EventHandler
public void onDamage(EntityDamageByEntityEvent e) {
public void onDamage(@NotNull EntityDamageByEntityEvent e) {
e.setDamage(0.0);
if (!(e.getDamager() instanceof LivingEntity damager)

View file

@ -38,7 +38,7 @@ public class EntityManager extends Manager {
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent e) {
public void onEntitySpawn(@NotNull EntitySpawnEvent e) {
if (e.getEntity() instanceof Player) return;
if (isSREntity(e.getEntity().getUniqueId())) return;

View file

@ -4,6 +4,7 @@ import java.util.HashMap;
import me.unurled.sacredrealms.sr.managers.Manager;
import org.bukkit.NamespacedKey;
@SuppressWarnings("EmptyMethod")
public class ItemManager extends Manager {
public static final NamespacedKey ID = new NamespacedKey("sr", "id");

View file

@ -1,6 +1,7 @@
package me.unurled.sacredrealms.sr.components.item.abilities;
/** Represents an ability that an item can have. TODO: Implement this class */
@SuppressWarnings("unused")
public class Ability {
private final String name;

View file

@ -40,11 +40,19 @@ public class PlayerManager extends Manager {
return;
}
DataHandler dh = dm.getDataHandler();
}
// save all players
Gson gson =
new GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.registerTypeAdapter(Inventory.class, new InventorySerializer())
.registerTypeAdapter(PotionEffect.class, new PotionEffectSerializer())
.create();
for (SRPlayer player : players.values()) {
dh.set(PLAYER_KEY + player.getUuid(), gson.toJson(player));
}
/** Load the data */
/*@Override
public void loadData() {}*/
players.clear();
}
@Nullable
public SRPlayer getPlayer(UUID uuid) {
@ -89,7 +97,7 @@ public class PlayerManager extends Manager {
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
public void onPlayerQuit(@NotNull PlayerQuitEvent e) {
SRPlayer player = getPlayer(e.getPlayer().getUniqueId());
if (player == null) {
return;