Skip to content

Commit

Permalink
Merge pull request #31 from Fortifier42/master
Browse files Browse the repository at this point in the history
Update Contexts. (Entity, World + 1 Player [xenmai got no clue how to])
  • Loading branch information
mcmonkey4eva committed Jul 28, 2015
2 parents 9fd8951 + b327a82 commit 58c55fe
Show file tree
Hide file tree
Showing 68 changed files with 744 additions and 427 deletions.
Expand Up @@ -82,14 +82,17 @@ public boolean applyDetermination(ScriptContainer container, String determinatio
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
if (lightning != null) {
context.put("lightning", lightning);
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
context.put("entity", entity);
context.put("cause", cause);
return context;
else if ((name.equals("lightning")) && (lightning != null)) {
return lightning;
}
else if (name.equals("cause")) {
return cause;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -113,15 +113,26 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("cause", cause);
context.put("entity", breaker); // NOTE: Deprecated
context.put("breaker", breaker);
context.put("hanging", hanging);
context.put("cuboids", cuboids);
context.put("location", location);
return context;
public dObject getContext(String name) {
if (name.equals("cause")) {
return cause;
}
else if (name.equals("entity")) { // NOTE: Deprecated
return breaker;
}
else if (name.equals("breaker")) {
return breaker;
}
else if (name.equals("hanging")) {
return hanging;
}
else if (name.equals("cuboids")) { // NOTE: Deprecated
return cuboids;
}
else if (name.equals("location")) {
return location;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -120,14 +120,23 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("cuboids", cuboids); //DEPRECATED
context.put("location", location);
context.put("new_material", new_material);
context.put("old_material", old_material);
return context;
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
else if (name.equals("cuboids")) { // NOTE: Deprecated
return cuboids;
}
else if (name.equals("location")) {
return location;
}
else if (name.equals("new_material")) {
return new_material;
}
else if (name.equals("old_material")) {
return old_material;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -92,11 +92,14 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("duration", duration);
return context;
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
else if (name.equals("duration")) {
return duration;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -91,12 +91,17 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("portal_type", portal_type);
// context.put("blocks", blocks);
return context;
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
else if (name.equals("portal_type")) {
return portal_type;
}
// else if (name.equals("blocks")) {
// return blocks;
// }
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -156,23 +156,31 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("damage", damage);
context.put("final_damage", final_damage);
context.put("cause", cause);
if (damager != null) {
context.put("damager", damager);
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
if (projectile != null) {
context.put("projectile", projectile);
else if (name.equals("damage")) {
return damage;
}
else if (name.equals("final_damage")) {
return final_damage;
}
else if (name.equals("cause")) {
return cause;
}
else if ((name.equals("damager")) && (damager != null)) {
return damager;
}
else if ((name.equals("projectile")) && (projectile != null)) {
return projectile;
}
for (EntityDamageEvent.DamageModifier dm : EntityDamageEvent.DamageModifier.values()) {
context.put("damage_" + dm.name(), new Element(event.getDamage(dm)));
if (name.equals("damage_" + dm.name())) {
return new Element(event.getDamage(dm));
}
}

return context;
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -156,25 +156,26 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
if (damager != null) {
context.put("damager", damager);
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
if (message != null) {
context.put("message", message);
else if ((name.equals("damager")) && (damager != null)) {
return damager;
}
if (inventory != null) {
context.put("inventory", inventory);
else if ((name.equals("message")) && (message != null)) {
return message;
}
if (cause != null) {
context.put("cause", cause);
else if ((name.equals("inventory")) && (inventory != null)) {
return inventory;
}
if (drops != null) {
context.put("drops", drops);
else if ((name.equals("cause")) && (cause != null)) {
return cause;
}
return context;
else if ((name.equals("drops")) && (drops != null)) {
return drops;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -9,6 +9,7 @@
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
import net.aufdemrand.denizencore.utilities.CoreUtilities;

import javax.annotation.OverridingMethodsMustInvokeSuper;
import java.util.HashMap;

public class EntityDespawnScriptEvent extends BukkitScriptEvent {
Expand Down Expand Up @@ -80,10 +81,13 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("cause", cause);
return context;
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
else if (name.equals("cause")) {
return cause;
}
return super.getContext(name);
}
}
Expand Up @@ -83,11 +83,14 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("location", location);
return context;
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
else if (name.equals("location")) {
return location;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -89,11 +89,14 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("vehicle", vehicle);
context.put("entity", entity);
return context;
public dObject getContext(String name) {
if (name.equals("vehicle")) {
return vehicle;
}
else if (name.equals("entity")) {
return entity;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -83,11 +83,14 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("location", location);
return context;
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
else if (name.equals("location")) {
return location;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -89,11 +89,14 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("vehicle", vehicle);
context.put("entity", entity);
return context;
public dObject getContext(String name) {
if (name.equals("vehicle")) {
return vehicle;
}
else if (name.equals("entity")) {
return entity;
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -115,13 +115,20 @@ public ScriptEntryData getScriptEntryData() {
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("location", location);
context.put("blocks", blocks);
context.put("strength", new Element(strength));
return context;
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
else if (name.equals("location")) {
return location;
}
else if (name.equals("blocks")) {
return blocks;
}
else if (name.equals("strength")) {
return new Element(strength);
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down
Expand Up @@ -86,12 +86,17 @@ public boolean applyDetermination(ScriptContainer container, String determinatio
}

@Override
public HashMap<String, dObject> getContext() {
HashMap<String, dObject> context = super.getContext();
context.put("entity", entity);
context.put("radius", new Element(radius));
context.put("fire", new Element(fire));
return context;
public dObject getContext(String name) {
if (name.equals("entity")) {
return entity;
}
else if (name.equals("radius")) {
return new Element(radius);
}
else if (name.equals("fire")) {
return new Element(fire);
}
return super.getContext(name);
}

@EventHandler(ignoreCancelled = true)
Expand Down

0 comments on commit 58c55fe

Please sign in to comment.