Reformat and add missing attribute

This commit is contained in:
2023-07-24 12:27:29 -05:00
parent a07c68e4b3
commit 57be14698f
14 changed files with 128 additions and 95 deletions

View File

@ -5,17 +5,18 @@ import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
public enum Attributes {
public enum Attributes
{
MAX_HEALTH("generic.max_health", 0),
FOLLOW_RANGE("generic.follow_range", 1),
KNOCKBACK_RESISTANCE("generic.knockback_resistance", 1),
MOVEMENT_SPEED("generic.movement_speed", 1),
FLYING_SPEED("generic.flying_speed", 1),
DAMAGE("generic.attack_damage", 0),
ATTACK_KNOCKBACK("generic.attack_knockback", 0),
ATTACK_SPEED("generic.attack_speed", 1),
ARMOR("generic.armor", 0),
ARMOR_TOUGHNESS("generic.armor_toughness", 0),
FLYING_SPEED("generic.flying_speed", 1),
ATTACK_SPEED("generic.attack_speed", 1),
LUCK("generic.luck", 0),
HORSE_JUMP("horse.jump_strength", 1),
ZOMBIE_REINFORCEMENTS("zombie.spawn_reinforcements", 1);
@ -23,27 +24,34 @@ public enum Attributes {
public final String mcName;
public final int op;
Attributes(String mcName, int op) {
Attributes(String mcName, int op)
{
this.mcName = mcName;
this.op = op;
}
public static Attributes get(String name) {
for (Attributes attr : values()) {
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name)) {
public static Attributes get(String name)
{
for (Attributes attr : values())
{
if (attr.name().equalsIgnoreCase(name) || attr.mcName.equalsIgnoreCase(name))
{
return attr;
}
}
return null;
}
public static String getAttributes() {
public static String getAttributes()
{
return StringUtils.join(values(), ", ");
}
public static List<String> getAttributeList() {
public static List<String> getAttributeList()
{
List<String> attributes = new ArrayList<>();
for (Attributes attr : values()) {
for (Attributes attr : values())
{
attributes.add(attr.name());
}
return attributes;

View File

@ -5,40 +5,55 @@ import net.coreprotect.CoreProtectAPI;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
public class CoreProtectBridge {
public class CoreProtectBridge
{
public static CoreProtect cp = null;
public static CoreProtectAPI api = null;
public static boolean logged = false;
public CoreProtect getCoreProtect() {
try {
public CoreProtect getCoreProtect()
{
try
{
final Plugin pl = Bukkit.getPluginManager().getPlugin("CoreProtect");
if (pl instanceof CoreProtect) {
if (pl instanceof CoreProtect)
{
cp = (CoreProtect) pl;
} else {
if (!logged) { // To stop the console log spam - not persistent on server restarts
}
else
{
if (!logged)
{ // To stop the console log spam - not persistent on server restarts
Bukkit.getLogger().info("CoreProtect not detected, some features will not be logged!");
logged = true;
}
}
} catch (Exception ex) {
}
catch (Exception ex)
{
ex.printStackTrace();
}
return cp;
}
public CoreProtectAPI getAPI() {
public CoreProtectAPI getAPI()
{
final CoreProtect cp = getCoreProtect();
if (cp != null && api == null) {
try {
if (cp != null && api == null)
{
try
{
api = cp.getAPI();
if (!cp.isEnabled() || !api.isEnabled()) {
if (!cp.isEnabled() || !api.isEnabled())
{
Bukkit.getLogger().info("CoreProtect is disabled, some features will not be logged!");
return null;
}
} catch (Exception ex) {
}
catch (Exception ex)
{
ex.printStackTrace();
}
}