Skip to content

Commit

Permalink
minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 30, 2019
1 parent 1e62862 commit f76f29f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
Expand Up @@ -49,13 +49,13 @@ public PlayerClicksBlockScriptEvent() {
instance = this;
}

PlayerClicksBlockScriptEvent instance;
PlayerInteractEvent event;
ItemTag item;
LocationTag location;
ElementTag click_type;
ElementTag hand;
MaterialTag blockMaterial;
public PlayerClicksBlockScriptEvent instance;
public PlayerInteractEvent event;
public ItemTag item;
public LocationTag location;
public ElementTag click_type;
public ElementTag hand;
public MaterialTag blockMaterial;

private boolean couldMatchIn(String lower) {
int index = CoreUtilities.split(lower, ' ').indexOf("in");
Expand Down Expand Up @@ -90,7 +90,6 @@ private boolean runUsingCheck(ScriptPath path) {
else {
using = path.eventArgLowerAt(index + 1);
}

if (!using.equals("hand") && !using.equals("off_hand") && !using.equals("either_hand")) {
Debug.echoError("Invalid USING hand in " + getName() + " for '" + path.event + "' in " + path.container.getName());
return false;
Expand Down Expand Up @@ -137,32 +136,22 @@ public boolean couldMatch(ScriptPath path) {
@Override
public boolean matches(ScriptPath path) {
int index = path.eventArgLowerAt(1).equals("clicks") ? 1 : 2;

if (index == 2
&& !click_type.identify().startsWith(path.eventArgLowerAt(1).toUpperCase())) {
if (index == 2 && !click_type.identify().startsWith(path.eventArgLowerAt(1).toUpperCase())) {
return false;
}

String mat = path.eventArgLowerAt(index + 1);
if (mat.length() > 0
&& !withHelpList.contains(mat)
&& !tryMaterial(blockMaterial, mat)) {
if (mat.length() > 0 && !withHelpList.contains(mat) && !tryMaterial(blockMaterial, mat)) {
return false;
}

if (!nonSwitchWithCheck(path, new ItemTag(event.getItem()))) {
return false;
}

if (!runUsingCheck(path)) {
return false;
}

if (location != null ? !runInCheck(path, location)
: !runInCheck(path, event.getPlayer().getLocation())) {
if (!runInCheck(path, location != null ? location : event.getPlayer().getLocation())) {
return false;
}

return super.matches(path);
}

Expand Down
Expand Up @@ -1714,7 +1714,7 @@ else if (Depends.permissions != null) {
// @returns ListTag
// @description
// Returns the current scores set on the player's Sidebar via the Sidebar command,
// in the same order as <@link tag PlayerTag.sidebar.lines>.
// in the same order as <@link tag PlayerTag.sidebar_lines>.
// -->
registerOnlineOnlyTag("sidebar_scores", (attribute, object) -> {
Sidebar sidebar = SidebarCommand.getSidebar(object);
Expand Down

0 comments on commit f76f29f

Please sign in to comment.