Skip to content

Commit

Permalink
Code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jul 26, 2015
1 parent 9b46dc8 commit 043ab48
Show file tree
Hide file tree
Showing 51 changed files with 79 additions and 93 deletions.
Expand Up @@ -3,7 +3,6 @@
import net.aufdemrand.denizen.objects.dNPC;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.tags.BukkitTagContext;
import net.aufdemrand.denizencore.scripts.ScriptEntry;
import net.aufdemrand.denizencore.scripts.ScriptEntryData;
import net.aufdemrand.denizencore.tags.TagContext;

Expand Down Expand Up @@ -54,8 +53,8 @@ public void transferDataFrom(ScriptEntryData scriptEntryData) {
@Override
public TagContext getTagContext() {
return new BukkitTagContext(player, npc, false, scriptEntry,
scriptEntry != null ? scriptEntry.shouldDebug(): true,
scriptEntry != null ? scriptEntry.getScript(): null);
scriptEntry != null ? scriptEntry.shouldDebug() : true,
scriptEntry != null ? scriptEntry.getScript() : null);
}

@Override
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -5,7 +5,6 @@
import net.aufdemrand.denizen.events.bukkit.ScriptReloadEvent;
import net.aufdemrand.denizen.events.core.*;
import net.aufdemrand.denizen.events.entity.*;
import net.aufdemrand.denizen.events.entity.ItemMergesScriptEvent;
import net.aufdemrand.denizen.events.player.*;
import net.aufdemrand.denizen.events.world.*;
import net.aufdemrand.denizen.flags.FlagManager;
Expand Down
Expand Up @@ -65,10 +65,10 @@ public boolean tryLocation(dLocation location, String comparedto) {
if (comparedto.equals("notable")) {
return true;
}
comparedto = "l@"+comparedto;
comparedto = "l@" + comparedto;
dLocation loc = dLocation.valueOf(comparedto);
if (loc == null) {
dB.echoError("Invalid location in location comparison string: "+comparedto);
dB.echoError("Invalid location in location comparison string: " + comparedto);
return false;
}
return loc.getBlock().equals(location.getBlock());
Expand Down
Expand Up @@ -12,8 +12,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockCanBuildEvent;

import java.util.HashMap;

public class BlockBuiltScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -7,14 +7,11 @@
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.utilities.CoreUtilities;

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBurnEvent;

import java.util.HashMap;

public class BlockBurnsScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -5,9 +5,7 @@
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dMaterial;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.Velocity;
import net.aufdemrand.denizen.utilities.debugging.dB;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.aH;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
Expand All @@ -17,8 +15,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockDispenseEvent;

import java.util.HashMap;


public class BlockDispensesScriptEvent extends BukkitScriptEvent implements Listener {

Expand Down
Expand Up @@ -12,8 +12,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFadeEvent;

import java.util.HashMap;

public class BlockFadesScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -12,8 +12,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityChangeBlockEvent;

import java.util.HashMap;

public class BlockFallsScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -12,8 +12,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFormEvent;

import java.util.HashMap;

public class BlockFormsScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -12,8 +12,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockGrowEvent;

import java.util.HashMap;

public class BlockGrowsScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -14,8 +14,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockIgniteEvent;

import java.util.HashMap;

public class BlockIgnitesScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -12,8 +12,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;

import java.util.HashMap;

public class BlockPhysicsScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -12,8 +12,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockSpreadEvent;

import java.util.HashMap;

public class BlockSpreadsScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -47,6 +47,7 @@ public class EntityTeleportScriptEvent extends BukkitScriptEvent implements List
public EntityTeleportScriptEvent() {
instance = this;
}

public static EntityTeleportScriptEvent instance;
public dEntity entity;
public dLocation from;
Expand Down
Expand Up @@ -4,7 +4,6 @@
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dItem;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dMaterial;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
Expand Down
Expand Up @@ -42,6 +42,7 @@ public class ItemMergesScriptEvent extends BukkitScriptEvent implements Listener
public ItemMergesScriptEvent() {
instance = this;
}

public static ItemMergesScriptEvent instance;
public dItem item;
public dLocation location;
Expand Down
Expand Up @@ -77,7 +77,7 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
String cmd = CoreUtilities.getXthArg(1, lower);
String pTest = cmd.equals("hits") ? CoreUtilities.getXthArg(0, lower): CoreUtilities.getXthArg(4, lower);
String pTest = cmd.equals("hits") ? CoreUtilities.getXthArg(0, lower) : CoreUtilities.getXthArg(4, lower);

if (pTest.length() > 0 && !projectile.matchesEntity(pTest)) {
return false;
Expand Down Expand Up @@ -131,7 +131,7 @@ public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("projectile", projectile);
context.put("location", location);
if (shooter != null ) {
if (shooter != null) {
context.put("shooter", shooter);
}
return context;
Expand Down
Expand Up @@ -61,7 +61,7 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
String cmd = CoreUtilities.getXthArg(1, lower);
String sheep = cmd.equals("dyed") ? CoreUtilities.getXthArg(0, lower): CoreUtilities.getXthArg(3, lower);
String sheep = cmd.equals("dyed") ? CoreUtilities.getXthArg(0, lower) : CoreUtilities.getXthArg(3, lower);
if (!entity.matchesEntity(sheep)) {
return false;
}
Expand Down
Expand Up @@ -56,7 +56,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
List<String> data = CoreUtilities.split(lower, ' ');
for (int index = 3; index < data.size(); index++) {
if (data.get(index).equals("from")) {
if (!data.get(index + 1).equals(CoreUtilities.toLowerCase(origin_world.getName()))){
if (!data.get(index + 1).equals(CoreUtilities.toLowerCase(origin_world.getName()))) {
return false;
}
}
Expand Down
Expand Up @@ -60,14 +60,14 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
String fish = CoreUtilities.getXthArg(2, lower);
if (entity != null && fish.length() > 0) {
if(!entity.matchesEntity(fish)) {
if (!entity.matchesEntity(fish)) {
return false;
}
}
List<String> data = CoreUtilities.split(lower, ' ');
for (int index = 0; index < data.size(); index++) {
if (data.get(index).equals("while")) {
if (!data.get(index+1).equalsIgnoreCase(state.asString())){
if (!data.get(index + 1).equalsIgnoreCase(state.asString())) {
return false;
}
}
Expand Down
Expand Up @@ -45,8 +45,8 @@ public PlayerFlyingScriptEvent() {

@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
return CoreUtilities.getXthArg(2,CoreUtilities.toLowerCase(s)).equals("flying")
|| CoreUtilities.getXthArg(2,CoreUtilities.toLowerCase(s)).equals("flight");
return CoreUtilities.getXthArg(2, CoreUtilities.toLowerCase(s)).equals("flying")
|| CoreUtilities.getXthArg(2, CoreUtilities.toLowerCase(s)).equals("flight");
}

@Override
Expand Down
Expand Up @@ -14,8 +14,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;

import java.util.HashMap;

public class PlayerJumpScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
Expand Down
Expand Up @@ -54,12 +54,12 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
List<String> data = CoreUtilities.split(lower, ' ');
for (int index = 0; index < data.size(); index++) {
if (data.get(index).equals("from")) {
if (aH.getIntegerFrom(data.get(index + 1)) != event.getOldLevel()){
if (aH.getIntegerFrom(data.get(index + 1)) != event.getOldLevel()) {
return false;
}
}
if (data.get(index).equals("to")) {
if (aH.getIntegerFrom(data.get(index + 1)) != event.getNewLevel()){
if (aH.getIntegerFrom(data.get(index + 1)) != event.getNewLevel()) {
return false;
}
}
Expand Down
Expand Up @@ -59,8 +59,8 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
String iTest = CoreUtilities.xthArgEquals(1, lower, "picks") ?
CoreUtilities.getXthArg(3, lower) : CoreUtilities.getXthArg(2, lower);
if(!tryItem(item, iTest)) {
CoreUtilities.getXthArg(3, lower) : CoreUtilities.getXthArg(2, lower);
if (!tryItem(item, iTest)) {
return false;
}
return runInCheck(scriptContainer, s, lower, location);
Expand Down
Expand Up @@ -2,7 +2,10 @@

import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.*;
import net.aufdemrand.denizen.objects.dCuboid;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.objects.dObject;
Expand Down
Expand Up @@ -57,7 +57,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
}

String color = CoreUtilities.getXthArg(3, lower).equals("sheep") ? CoreUtilities.getXthArg(2, lower) : "";
if(color.length() > 0 && !color.equals(CoreUtilities.toLowerCase(((Sheep) entity.getBukkitEntity()).getColor().name()))) {
if (color.length() > 0 && !color.equals(CoreUtilities.toLowerCase(((Sheep) entity.getBukkitEntity()).getColor().name()))) {
return false;
}

Expand Down
Expand Up @@ -45,7 +45,7 @@ public PlayerSneakScriptEvent() {

@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
return CoreUtilities.getXthArg(2,CoreUtilities.toLowerCase(s)).startsWith("sneak");
return CoreUtilities.getXthArg(2, CoreUtilities.toLowerCase(s)).startsWith("sneak");
}

@Override
Expand Down
Expand Up @@ -45,7 +45,7 @@ public PlayerSprintScriptEvent() {

@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
return CoreUtilities.getXthArg(2,CoreUtilities.toLowerCase(s)).startsWith("sprint");
return CoreUtilities.getXthArg(2, CoreUtilities.toLowerCase(s)).startsWith("sprint");
}

@Override
Expand Down
Expand Up @@ -55,7 +55,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
String mat = CoreUtilities.getXthArg(0, lower);
return (mat.equals("liquid") || tryMaterial(material, mat))
&& (runInCheck(scriptContainer, s, lower, location)
|| runInCheck(scriptContainer, s, lower, destination));
|| runInCheck(scriptContainer, s, lower, destination));
}

@Override
Expand Down
Expand Up @@ -4,7 +4,6 @@
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dMaterial;
import net.aufdemrand.denizen.utilities.DenizenAPI;

import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.dList;
import net.aufdemrand.denizencore.objects.dObject;
Expand Down
Expand Up @@ -53,7 +53,7 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
String rCheck = CoreUtilities.getXthArg(2,lower).equals("because") ? CoreUtilities.getXthArg(3,lower):CoreUtilities.getXthArg(5,lower);
String rCheck = CoreUtilities.getXthArg(2, lower).equals("because") ? CoreUtilities.getXthArg(3, lower) : CoreUtilities.getXthArg(5, lower);
if (rCheck.length() > 0 && !rCheck.equals(CoreUtilities.toLowerCase(reason.asString()))) {
return false;
}
Expand Down
Expand Up @@ -11,7 +11,6 @@
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.utilities.CoreUtilities;

import org.bukkit.Bukkit;
import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -61,7 +60,8 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
String block = CoreUtilities.getXthArg(0, lower);
dMaterial mat = dMaterial.valueOf(block);
return cmd.equals("grows")
&& (block.equals("structure") || (mat != null && mat.isStructure())); }
&& (block.equals("structure") || (mat != null && mat.isStructure()));
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
Expand All @@ -71,9 +71,10 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
!struct.equals(CoreUtilities.toLowerCase(structure.asString()))) {
return false;
}
if (CoreUtilities.getXthArg(2,lower).equals("from") && !event.isFromBonemeal()) {
if (CoreUtilities.getXthArg(2, lower).equals("from") && !event.isFromBonemeal()) {
return false;
} else if (CoreUtilities.getXthArg(2,lower).equals("naturally") && event.isFromBonemeal()) {
}
else if (CoreUtilities.getXthArg(2, lower).equals("naturally") && event.isFromBonemeal()) {
return false;
}
return runInCheck(scriptContainer, s, lower, location);
Expand Down
Expand Up @@ -42,7 +42,7 @@ public WeatherChangesScriptEvent() {

@Override
public boolean couldMatch(ScriptContainer scriptContainer, String s) {
return CoreUtilities.getXthArg(0,CoreUtilities.toLowerCase(s)).equals("weather");
return CoreUtilities.getXthArg(0, CoreUtilities.toLowerCase(s)).equals("weather");
}

@Override
Expand All @@ -52,7 +52,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) {
if (!cmd.equals("changes") && !cmd.equals(weather.identifySimple())) {
return false;
}
String wCheck = CoreUtilities.getXthArg(3,lower);
String wCheck = CoreUtilities.getXthArg(3, lower);
if (wCheck.length() > 0 && !wCheck.equals(CoreUtilities.toLowerCase(world.getName()))) {
return false;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public HashMap<String, dObject> getContext() {
@EventHandler
public void onWeatherChanges(WeatherChangeEvent event) {
world = new dWorld(event.getWorld());
weather = new Element(event.toWeatherState()?"rains":"clears");
weather = new Element(event.toWeatherState() ? "rains" : "clears");
this.event = event;
cancelled = event.isCancelled();
fire();
Expand Down

0 comments on commit 043ab48

Please sign in to comment.