Skip to content

Commit

Permalink
Improve PlayerLeashesEntity event.
Browse files Browse the repository at this point in the history
Cleaning of dLocation
  • Loading branch information
Fortifier42 committed Feb 2, 2016
1 parent bf0805c commit b5ebd27
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/aufdemrand/denizen/Denizen.java
Expand Up @@ -661,7 +661,7 @@ public void onEnable() {
ScriptEvent.registerScriptEvent(new PlayerJoinsScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerJumpScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerKickedScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerLeashesScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerLeashesEntityScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerLeavesBedScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerLevelsScriptEvent());
ScriptEvent.registerScriptEvent(new PlayerLoginScriptEvent());
Expand Down
Expand Up @@ -3,6 +3,7 @@
import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.ScriptEntryData;
Expand All @@ -13,7 +14,7 @@
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerLeashEntityEvent;

public class PlayerLeashesScriptEvent extends BukkitScriptEvent implements Listener {
public class PlayerLeashesEntityScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
// @Events
Expand All @@ -32,13 +33,13 @@ public class PlayerLeashesScriptEvent extends BukkitScriptEvent implements Liste
//
// -->

public PlayerLeashesScriptEvent() {
public PlayerLeashesEntityScriptEvent() {
instance = this;
}

public static PlayerLeashesScriptEvent instance;
public static PlayerLeashesEntityScriptEvent instance;
public dEntity entity;
public dEntity holder;
public dPlayer holder;
public PlayerLeashEntityEvent event;

@Override
Expand All @@ -63,7 +64,7 @@ public boolean matches(ScriptContainer scriptContainer, String s) {

@Override
public String getName() {
return "PlayerLeashes";
return "PlayerLeashesEntity";
}

@Override
Expand All @@ -83,7 +84,7 @@ public boolean applyDetermination(ScriptContainer container, String determinatio

@Override
public ScriptEntryData getScriptEntryData() {
return new BukkitScriptEntryData(holder.isPlayer() ? holder.getDenizenPlayer() : null, null);
return new BukkitScriptEntryData(holder, null);
}

@Override
Expand All @@ -102,10 +103,10 @@ public void onPlayerLeashes(PlayerLeashEntityEvent event) {
if (dEntity.isNPC(event.getPlayer())) {
return;
}
holder = new dEntity(event.getPlayer());
holder = new dPlayer(event.getPlayer());
entity = new dEntity(event.getEntity());
this.event = event;
cancelled = event.isCancelled();
this.event = event;
fire();
event.setCancelled(cancelled);
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/net/aufdemrand/denizen/objects/dLocation.java
Expand Up @@ -35,7 +35,6 @@
import org.bukkit.material.Button;
import org.bukkit.material.Lever;
import org.bukkit.material.MaterialData;
import org.bukkit.util.*;
import org.bukkit.util.BlockIterator;

import java.util.*;
Expand Down Expand Up @@ -1366,7 +1365,7 @@ public int compare(dEntity ent1, dEntity ent2) {
}
List<dLocation> locs = PathFinder.getPath(this, two);
dList list = new dList();
for (dLocation loc: locs) {
for (dLocation loc : locs) {
list.add(loc.identify());
}
return list.getAttribute(attribute.fulfill(1));
Expand Down Expand Up @@ -1893,10 +1892,10 @@ && getBlock().getType() == Material.COMMAND) {
BlockFace face = BlockFace.SELF;
MaterialData data = getBlock().getState().getData();
if (data instanceof Lever) {
face = ((Lever)data).getAttachedFace();
face = ((Lever) data).getAttachedFace();
}
else if (data instanceof Button) {
face = ((Button)data).getAttachedFace();
face = ((Button) data).getAttachedFace();
}
if (face != BlockFace.SELF) {
return new dLocation(getBlock().getRelative(face).getLocation()).getAttribute(attribute.fulfill(1));
Expand Down

0 comments on commit b5ebd27

Please sign in to comment.