Skip to content

Commit

Permalink
semi-automated codebase cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Apr 29, 2022
1 parent 5080987 commit ffbbf97
Show file tree
Hide file tree
Showing 56 changed files with 84 additions and 104 deletions.
3 changes: 0 additions & 3 deletions plugin/src/main/java/com/denizenscript/denizen/Denizen.java
Expand Up @@ -91,8 +91,6 @@ public static Denizen getInstance() {
public TriggerRegistry triggerRegistry;
public DenizenNPCHelper npcHelper;

public OldEventManager eventManager;

public BukkitWorldScriptHelper worldScriptHelper;

public ItemScriptHelper itemScriptHelper;
Expand Down Expand Up @@ -328,7 +326,6 @@ else if (javaVersion.startsWith("17")) {
}
try {
AdjustCommand.specialAdjustables.put("server", ServerTagBase::adjustServer);
eventManager = new OldEventManager();
// Register all the modern script events
ScriptEventRegistry.registerMainEvents();
// Register Core ObjectTags with the ObjectFetcher
Expand Down
Expand Up @@ -38,7 +38,7 @@ public abstract class BukkitScriptEvent extends ScriptEvent {

// <--[language]
// @name Advanced Object Matchables
// @group Script Events
// @group Object System
// @description
// Script events have a variety of matchable object inputs, and the range of inputs they accept may not always be obvious.
// For example, an event might be "player clicks <block>"... what can "<block>" be filled with?
Expand Down
Expand Up @@ -4,7 +4,6 @@
import com.denizenscript.denizen.objects.LocationTag;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizencore.objects.ObjectTag;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockCookEvent;
Expand Down
Expand Up @@ -6,7 +6,6 @@
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
Expand Down
Expand Up @@ -4,7 +4,6 @@
import com.denizenscript.denizen.objects.ItemTag;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
Expand Down
Expand Up @@ -10,6 +10,7 @@
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ScriptTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -69,7 +70,7 @@ public String getName() {
@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
String determination = determinationObj.toString();
if (determination.toUpperCase().equals("NOT_SIGNING")) {
if (CoreUtilities.toLowerCase(determination).equals("not_signing")) {
event.setSigning(false);
return true;
}
Expand All @@ -82,12 +83,11 @@ else if (ScriptTag.matches(determination)) {
event.setSigning(false);
}
event.setNewBookMeta(bookMeta);
return true;
}
else {
Debug.echoError("Script '" + determination + "' is valid, but not of type 'book'!");
return true;
}
return true;
}
return super.applyDetermination(path, determinationObj);
}
Expand Down
Expand Up @@ -16,6 +16,10 @@ public class ServerPrestartScriptEvent extends BukkitScriptEvent {
//
// @Warning This event uses special pre-loading tricks to fire before everything else. Use extreme caution.
//
// @Examples
// on server prestart:
// - createworld my_extra_world
//
// -->

public ServerPrestartScriptEvent() {
Expand Down
Expand Up @@ -9,7 +9,6 @@
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.scripts.ScriptEntryData;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.TreeType;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
Expand Down
Expand Up @@ -162,7 +162,7 @@ public void NPCPush(NPCPushEvent event) {
}
if (pusher != null) {
new NPCTag(npc).action("push", PlayerTag.mirrorBukkitPlayer(pusher));
pushedTimer = CoreUtilities.monotonicMillis() + (delay * 1000);
pushedTimer = CoreUtilities.monotonicMillis() + ((long) delay * 1000L);
}
} // End push action
if (!pushed && returnable) {
Expand Down
Expand Up @@ -96,7 +96,7 @@ public static ChunkTag valueOf(String string, TagContext context) {
String[] parts = string.split(",");
if (parts.length == 3) {
try {
return new ChunkTag(new WorldTag(parts[2]), Integer.valueOf(parts[0]), Integer.valueOf(parts[1]));
return new ChunkTag(new WorldTag(parts[2]), Integer.parseInt(parts[0]), Integer.parseInt(parts[1]));
}
catch (Exception e) {
if (context == null || context.showErrors()) {
Expand Down
Expand Up @@ -401,7 +401,7 @@ public static void registerTags() {
cause = EntityDamageEvent.DamageCause.valueOf(type.toString().toUpperCase());
}
catch (IllegalArgumentException ex) {
attribute.echoError("Invalid MapTag input to damage_protection - cause '" + type.toString() + "' is not a valid DamageCause.");
attribute.echoError("Invalid MapTag input to damage_protection - cause '" + type + "' is not a valid DamageCause.");
return null;
}
ObjectTag attacker = map.getObject("attacker");
Expand Down
@@ -1,6 +1,5 @@
package com.denizenscript.denizen.objects;

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.nms.interfaces.EntityAnimation;
import com.denizenscript.denizen.nms.interfaces.PlayerHelper;
Expand Down
Expand Up @@ -371,7 +371,7 @@ public String getScriptName() {
}

public void setItemScript(ItemScriptContainer script) {
if (script.contains("NO_ID", String.class) && Boolean.valueOf(script.getString("NO_ID"))) {
if (script.contains("NO_ID", String.class) && Boolean.parseBoolean(script.getString("NO_ID"))) {
return;
}
setItemStack(NMSHandler.itemHelper.addNbtData(getItemStack(), "DenizenItemScript", new StringTag(CoreUtilities.toLowerCase(script.getName()))));
Expand Down
Expand Up @@ -176,8 +176,8 @@ public static LocationTag valueOf(String string, TagContext context) {
{
try {
return new LocationTag(null,
Double.valueOf(split.get(0)),
Double.valueOf(split.get(1)));
Double.parseDouble(split.get(0)),
Double.parseDouble(split.get(1)));
}
catch (Exception e) {
if (context == null || context.showErrors()) {
Expand All @@ -198,18 +198,18 @@ else if (split.size() == 3)
World world = Bukkit.getWorld(worldName);
if (world != null) {
return new LocationTag(world,
Double.valueOf(split.get(0)),
Double.valueOf(split.get(1)));
Double.parseDouble(split.get(0)),
Double.parseDouble(split.get(1)));
}
if (ArgumentHelper.matchesDouble(split.get(2))) {
return new LocationTag(null,
Double.valueOf(split.get(0)),
Double.valueOf(split.get(1)),
Double.valueOf(split.get(2)));
Double.parseDouble(split.get(0)),
Double.parseDouble(split.get(1)),
Double.parseDouble(split.get(2)));
}
LocationTag output = new LocationTag(null,
Double.valueOf(split.get(0)),
Double.valueOf(split.get(1)));
Double.parseDouble(split.get(0)),
Double.parseDouble(split.get(1)));
output.backupWorld = worldName;
return output;
}
Expand All @@ -232,14 +232,14 @@ else if (split.size() == 4)
World world = Bukkit.getWorld(worldName);
if (world != null) {
return new LocationTag(world,
Double.valueOf(split.get(0)),
Double.valueOf(split.get(1)),
Double.valueOf(split.get(2)));
Double.parseDouble(split.get(0)),
Double.parseDouble(split.get(1)),
Double.parseDouble(split.get(2)));
}
LocationTag output = new LocationTag(null,
Double.valueOf(split.get(0)),
Double.valueOf(split.get(1)),
Double.valueOf(split.get(2)));
Double.parseDouble(split.get(0)),
Double.parseDouble(split.get(1)),
Double.parseDouble(split.get(2)));
output.backupWorld = worldName;
return output;
}
Expand All @@ -256,12 +256,12 @@ else if (split.size() == 5)
// x,y,z,pitch,yaw
{
try {
float pitch = Float.valueOf(split.get(3));
float yaw = Float.valueOf(split.get(4));
float pitch = Float.parseFloat(split.get(3));
float yaw = Float.parseFloat(split.get(4));
return new LocationTag((World) null,
Double.valueOf(split.get(0)),
Double.valueOf(split.get(1)),
Double.valueOf(split.get(2)),
Double.parseDouble(split.get(0)),
Double.parseDouble(split.get(1)),
Double.parseDouble(split.get(2)),
yaw, pitch);
}
catch (Exception e) {
Expand All @@ -281,12 +281,12 @@ else if (split.size() == 6)
if (worldName.startsWith("w@")) {
worldName = worldName.substring("w@".length());
}
float pitch = Float.valueOf(split.get(3));
float yaw = Float.valueOf(split.get(4));
float pitch = Float.parseFloat(split.get(3));
float yaw = Float.parseFloat(split.get(4));
return new LocationTag(worldName,
Double.valueOf(split.get(0)),
Double.valueOf(split.get(1)),
Double.valueOf(split.get(2)),
Double.parseDouble(split.get(0)),
Double.parseDouble(split.get(1)),
Double.parseDouble(split.get(2)),
yaw, pitch);
}
catch (Exception e) {
Expand Down Expand Up @@ -3233,9 +3233,9 @@ else if (attribute.startsWith("unexplored_structure", 2) && attribute.hasContext
if (ArgumentHelper.matchesDouble(ints[0])
&& ArgumentHelper.matchesDouble(ints[1])
&& ArgumentHelper.matchesDouble(ints[2])) {
return new LocationTag(object.clone().add(Double.valueOf(ints[0]),
Double.valueOf(ints[1]),
Double.valueOf(ints[2])));
return new LocationTag(object.clone().add(Double.parseDouble(ints[0]),
Double.parseDouble(ints[1]),
Double.parseDouble(ints[2])));
}
}
if (LocationTag.matches(attribute.getParam())) {
Expand All @@ -3260,9 +3260,9 @@ else if (attribute.startsWith("unexplored_structure", 2) && attribute.hasContext
if (ArgumentHelper.matchesDouble(ints[0])
&& ArgumentHelper.matchesDouble(ints[1])
&& ArgumentHelper.matchesDouble(ints[2])) {
return new LocationTag(object.clone().subtract(Double.valueOf(ints[0]),
Double.valueOf(ints[1]),
Double.valueOf(ints[2])));
return new LocationTag(object.clone().subtract(Double.parseDouble(ints[0]),
Double.parseDouble(ints[1]),
Double.parseDouble(ints[2])));
}
}
if (LocationTag.matches(attribute.getParam())) {
Expand Down
@@ -1,6 +1,5 @@
package com.denizenscript.denizen.objects;

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.properties.material.*;
import com.denizenscript.denizen.utilities.VanillaTagHelper;
import com.denizenscript.denizen.utilities.debugging.Debug;
Expand Down
@@ -1,7 +1,6 @@
package com.denizenscript.denizen.objects;

import com.denizenscript.denizen.Denizen;
import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.npc.traits.*;
import com.denizenscript.denizen.scripts.commands.npc.EngageCommand;
import com.denizenscript.denizen.scripts.containers.core.AssignmentScriptContainer;
Expand Down Expand Up @@ -954,7 +953,7 @@ else if (attribute.startsWith("list", 2)) {
// LookClose.toString() returns "LookClose{" + enabled + "}"
String lookclose = citizen.getOrAddTrait(LookClose.class).toString();
lookclose = lookclose.substring(10, lookclose.length() - 1);
return new ElementTag(Boolean.valueOf(lookclose));
return new ElementTag(Boolean.parseBoolean(lookclose));
}
return new ElementTag(false);
});
Expand Down
@@ -1,6 +1,5 @@
package com.denizenscript.denizen.objects;

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.nms.interfaces.AdvancementHelper;
import com.denizenscript.denizen.objects.properties.entity.EntityHealth;
Expand Down Expand Up @@ -603,7 +602,7 @@ public String getObjectType() {

@Override
public String identify() {
return "p@" + offlinePlayer.getUniqueId().toString();
return "p@" + offlinePlayer.getUniqueId();
}

@Override
Expand Down
Expand Up @@ -61,7 +61,7 @@ public static String replaceEssentialsHexColors(char prefix, String input) {
}
converted.append(ChatColor.COLOR_CHAR).append(c);
}
input = input.substring(0, hex) + converted.toString() + input.substring(hex + 8);
input = input.substring(0, hex) + converted + input.substring(hex + 8);
hex = input.indexOf(prefix + "#", hex + 2);
}
return input;
Expand Down
Expand Up @@ -105,7 +105,7 @@ public static void registerTags() {
output.append(", ");
}
}
return new ElementTag(output.toString().substring(0, output.length() - 2));
return new ElementTag(output.substring(0, output.length() - 2));
});

// <--[tag]
Expand Down
Expand Up @@ -68,7 +68,7 @@ public ListTag getAttributes() {
for (AttributeModifier modifier : instance.getModifiers()) {
modifiers.append("/").append(stringify(modifier));
}
list.add(EscapeTagBase.escape(attribute.name()) + "/" + instance.getBaseValue() + modifiers.toString());
list.add(EscapeTagBase.escape(attribute.name()) + "/" + instance.getBaseValue() + modifiers);
}
return list;
}
Expand Down
Expand Up @@ -217,8 +217,8 @@ else if (entity.isLivingEntity()) {
if (mechanism.matches("health_data")) {
if (entity.isLivingEntity()) {
List<String> values = CoreUtilities.split(mechanism.getValue().asString(), '/');
entity.getLivingEntity().setMaxHealth(Double.valueOf(values.get(1)));
entity.getLivingEntity().setHealth(Double.valueOf(values.get(0)));
entity.getLivingEntity().setMaxHealth(Double.parseDouble(values.get(1)));
entity.getLivingEntity().setHealth(Double.parseDouble(values.get(0)));
}
else {
mechanism.echoError("Entity is not alive!");
Expand Down
Expand Up @@ -121,7 +121,7 @@ public static void procMechKey(Mechanism mech, CompoundTagBuilder pose, String n
}
List<FloatTag> rawList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
rawList.add(new FloatTag(Float.valueOf(raw.get(i))));
rawList.add(new FloatTag(Float.parseFloat(raw.get(i))));
}
JNBTListTag list = new JNBTListTag(FloatTag.class, rawList);
pose.put(nmsName, list);
Expand Down
Expand Up @@ -111,7 +111,7 @@ public static void registerTags() {
attribute.echoError("Invalid slot.");
return null;
}
return object.getAttributeModifiersFor(NMSHandler.itemHelper.getDefaultAttributes(object.item.getItemStack(), slot));
return getAttributeModifiersFor(NMSHandler.itemHelper.getDefaultAttributes(object.item.getItemStack(), slot));
});
}

Expand Down
Expand Up @@ -282,11 +282,11 @@ public void adjust(Mechanism mechanism) {
if (ench != null) {
if (item.getBukkitMaterial() == Material.ENCHANTED_BOOK) {
EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
meta.addStoredEnchant(ench, Integer.valueOf(data[1]), true);
meta.addStoredEnchant(ench, Integer.parseInt(data[1]), true);
item.setItemMeta(meta);
}
else {
item.getItemStack().addUnsafeEnchantment(ench, Integer.valueOf(data[1]));
item.getItemStack().addUnsafeEnchantment(ench, Integer.parseInt(data[1]));
item.resetCache();
}
}
Expand Down
Expand Up @@ -6,6 +6,7 @@
import com.denizenscript.denizencore.objects.core.ListTag;
import com.denizenscript.denizencore.objects.properties.Property;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.*;
import org.bukkit.block.data.type.RedstoneWire;
Expand Down Expand Up @@ -155,7 +156,7 @@ public void adjust(Mechanism mechanism) {
wall.setHeight(BlockFace.EAST, Wall.Height.valueOf(list.get(1).toUpperCase()));
wall.setHeight(BlockFace.SOUTH, Wall.Height.valueOf(list.get(2).toUpperCase()));
wall.setHeight(BlockFace.WEST, Wall.Height.valueOf(list.get(3).toUpperCase()));
wall.setUp(list.get(4).toUpperCase().equals("TALL"));
wall.setUp(CoreUtilities.toLowerCase(list.get(4)).equals("tall"));
}
else if (isWire()) {
if (list.size() != 4) {
Expand Down
Expand Up @@ -166,7 +166,7 @@ public void execute(ScriptEntry scriptEntry) {
}
PotionEffect potion = new PotionEffect(effect, duration.getTicksAsInt(), amplifier, amb, showP, icon);
if (!potion.apply(entity.getLivingEntity())) {
Debug.echoError(scriptEntry, "Bukkit was unable to apply '" + potion.getType().getName() + "' to '" + entity.toString() + "'.");
Debug.echoError(scriptEntry, "Bukkit was unable to apply '" + potion.getType().getName() + "' to '" + entity + "'.");
}
}
}
Expand Down

0 comments on commit ffbbf97

Please sign in to comment.