Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Merge Recent Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Xenmai committed Jun 15, 2018
1 parent ba07053 commit 5d57c08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Expand Up @@ -39,10 +39,11 @@ public class ExperienceChangesScriptEvent extends ScriptEvent {
//
// @Context
// player (PlayerTag) returns the player that changed experience.
// old_xp (IntegerTag) returns the old experience value.
// new_xp (IntegerTag) returns the new experience value.
//
// @Determinations
// level (IntegerTag) sets the new experience value.
// xp (IntegerTag) sets the new experience value.
// -->

@Override
Expand All @@ -66,6 +67,8 @@ public boolean matches(ScriptEventData data) {

public PlayerTag player;

public IntegerTag old_xp;

public IntegerTag new_xp;

public ChangeEntityExperienceEvent internal;
Expand All @@ -74,6 +77,7 @@ public boolean matches(ScriptEventData data) {
public HashMap<String, AbstractTagObject> getDefinitions(ScriptEventData data) {
HashMap<String, AbstractTagObject> defs = super.getDefinitions(data);
defs.put("player", player);
defs.put("old_xp", old_xp);
defs.put("new_xp", new_xp);
return defs;
}
Expand All @@ -93,6 +97,7 @@ public void onExperienceChanges(ChangeEntityExperienceEvent evt, @Root Player pl
ExperienceChangesScriptEvent event = (ExperienceChangesScriptEvent) clone();
event.internal = evt;
event.player = new PlayerTag(player);
event.old_xp = new IntegerTag(evt.getOriginalExperience());
event.new_xp = new IntegerTag(evt.getExperience());
event.cancelled = evt.isCancelled();
event.run();
Expand All @@ -101,7 +106,7 @@ public void onExperienceChanges(ChangeEntityExperienceEvent evt, @Root Player pl

@Override
public void applyDetermination(boolean errors, String determination, AbstractTagObject value) {
if (determination.equals("level")) {
if (determination.equals("xp")) {
IntegerTag it = IntegerTag.getFor(this::error, value);
new_xp = it;
internal.setExperience((int) it.getInternal());
Expand Down
Expand Up @@ -45,7 +45,7 @@ public class AdvancementScript extends CommandScript {
// parent (TextTag, only for children advancements), tree_id (TextTag, only for root
// advancements), tree_name (TextTag, only for root advancements, optional),
// position_x (NumberTag), and position_y (NumberTag).
// TODO: Add "Related information" such as criteria formatting, advancement types and examples.
// TODO: Add "Related information" such as advancement types and examples.
// -->

public AdvancementScript(String name, YAMLConfiguration section) {
Expand Down
Expand Up @@ -5,7 +5,6 @@
import org.spongepowered.api.data.DataQuery;
import org.spongepowered.api.data.DataRegistration;
import org.spongepowered.api.data.key.Key;
import org.spongepowered.api.data.key.KeyFactory;
import org.spongepowered.api.data.value.mutable.Value;

public class FlagHelper {
Expand Down

0 comments on commit 5d57c08

Please sign in to comment.