Skip to content

Commit

Permalink
delete legacy flag smart event
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 15, 2020
1 parent 2357348 commit e7c05d7
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 206 deletions.
Expand Up @@ -337,7 +337,6 @@ public void onEnable() {
CommonRegistries.registerMainTagHandlers();
eventManager = new OldEventManager();
// Register all the legacy 'Core' SmartEvents.
OldEventManager.registerSmartEvent(new FlagSmartEvent());
OldEventManager.registerSmartEvent(new NPCNavigationSmartEvent());
// Register all the modern script events
ScriptEventRegistry.registerMainEvents();
Expand Down

This file was deleted.

147 changes: 0 additions & 147 deletions plugin/src/main/java/com/denizenscript/denizen/flags/FlagManager.java
Expand Up @@ -4,13 +4,9 @@
import com.denizenscript.denizen.objects.NPCTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.utilities.DenizenAPI;
import com.denizenscript.denizen.utilities.depends.Depends;
import com.denizenscript.denizencore.objects.*;
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData;
import com.denizenscript.denizen.Denizen;
import com.denizenscript.denizen.events.core.FlagSmartEvent;
import com.denizenscript.denizencore.DenizenCore;
import com.denizenscript.denizencore.events.OldEventManager;
import com.denizenscript.denizencore.objects.core.DurationTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.denizencore.objects.core.ListTag;
Expand Down Expand Up @@ -222,52 +218,11 @@ public Value get(int index) {
public void clear() {
String OldOwner = flagOwner;
String OldName = flagName;
ObjectTag OldValue = FlagSmartEvent.isActive() ? (value.size() > 1
? value.asList()
: value.size() == 1 ? new ElementTag(value.get(0).asString()) : new ElementTag("null")) : null;

denizen.getSaves().set(flagPath, null);
denizen.getSaves().set(flagPath + "-expiration", null);
valid = false;
rebuild();

if (FlagSmartEvent.isActive()) {
List<String> world_script_events = new ArrayList<>();

Map<String, ObjectTag> context = new HashMap<>();
PlayerTag player = null;
if (PlayerTag.matches(OldOwner)) {
player = PlayerTag.valueOf(OldOwner, CoreUtilities.basicContext);
}
NPCTag npc = null;
if (Depends.citizens != null && NPCTag.matches(OldOwner)) {
npc = NPCTag.valueOf(OldOwner, CoreUtilities.basicContext);
}

String type;

if (player != null) {
type = "player";
}
else if (npc != null) {
type = "npc";
}
else {
type = "server";
}
world_script_events.add(type + " flag cleared");
world_script_events.add(type + " flag " + OldName + " cleared");

context.put("owner", new ElementTag(OldOwner));
context.put("name", new ElementTag(OldName));
context.put("type", new ElementTag(type));
context.put("old_value", OldValue);

world_script_events.add("flag cleared");

OldEventManager.doEvents(world_script_events,
new BukkitScriptEntryData(player, npc), context);
}
}

/**
Expand Down Expand Up @@ -469,68 +424,13 @@ public int size() {
* if you are extending the usage of Flags yourself.
*/
public void save() {
String oldOwner = flagOwner;
String oldName = flagName;
ObjectTag oldValue = null;
if (FlagSmartEvent.isActive()) {
ListTag oldValueList = value.asList();
oldValue = oldValueList.size() > 1 ? oldValueList
: oldValueList.size() == 1 ? new ElementTag(oldValueList.get(0)) : new ElementTag("null");
}

if (value.values != null) {
denizen.getSaves().set(flagPath, value.values);
}
else {
denizen.getSaves().set(flagPath, value.size == 0 ? null : value.firstValue);
}
denizen.getSaves().set(flagPath + "-expiration", (expiration > 0 ? expiration : null));

if (FlagSmartEvent.isActive()) {
List<String> world_script_events = new ArrayList<>();

Map<String, ObjectTag> context = new HashMap<>();
PlayerTag player = null;
if (PlayerTag.matches(oldOwner)) {
player = PlayerTag.valueOf(oldOwner, CoreUtilities.basicContext);
}
NPCTag npc = null;
if (Depends.citizens != null && NPCTag.matches(oldOwner)) {
npc = NPCTag.valueOf(oldOwner, CoreUtilities.basicContext);
}
EntityTag entity = null;
if (EntityTag.matches(oldOwner)) {
entity = EntityTag.valueOf(oldOwner, CoreUtilities.basicContext);
}

String type;

if (player != null) {
type = "player";
}
else if (npc != null) {
type = "npc";
}
else if (entity != null) {
type = "entity";
}
else {
type = "server";
}
world_script_events.add(type + " flag changed");
world_script_events.add(type + " flag " + oldName + " changed");

context.put("owner", new ElementTag(oldOwner));
context.put("name", new ElementTag(oldName));
context.put("type", new ElementTag(type));
context.put("old_value", oldValue);

world_script_events.add("flag changed");

OldEventManager.doEvents(world_script_events,
new BukkitScriptEntryData(player, npc), context);
}

}

@Override
Expand All @@ -549,58 +449,11 @@ public boolean checkExpired() {
if (expiration > 1 && expiration < DenizenCore.currentTimeMillis) {
String oldOwner = flagOwner;
String oldName = flagName;
ObjectTag oldValue = FlagSmartEvent.isActive() ? (value.size() > 1
? value.asList()
: value.size() == 1 ? new ElementTag(value.get(0).asString()) : new ElementTag("null")) : null;
denizen.getSaves().set(flagPath + "-expiration", null);
denizen.getSaves().set(flagPath, null);
valid = false;
rebuild();
//dB.log('\'' + flagName + "' has expired! " + flagPath);
if (FlagSmartEvent.isActive()) {
List<String> world_script_events = new ArrayList<>();

Map<String, ObjectTag> context = new HashMap<>();
PlayerTag player = null;
if (PlayerTag.matches(oldOwner)) {
player = PlayerTag.valueOf(oldOwner, CoreUtilities.basicContext);
}
NPCTag npc = null;
if (Depends.citizens != null && NPCTag.matches(oldOwner)) {
npc = NPCTag.valueOf(oldOwner, CoreUtilities.basicContext);
}
EntityTag entity = null;
if (EntityTag.matches(oldOwner)) {
entity = EntityTag.valueOf(oldOwner, CoreUtilities.basicContext);
}

String type;

if (player != null) {
type = "player";
}
else if (npc != null) {
type = "npc";
}
else if (entity != null) {
type = "entity";
}
else {
type = "server";
}
world_script_events.add(type + " flag expires");
world_script_events.add(type + " flag " + oldName + " expires");

context.put("owner", new ElementTag(oldOwner));
context.put("name", new ElementTag(oldName));
context.put("type", new ElementTag(type));
context.put("old_value", oldValue);

world_script_events.add("flag expires");

OldEventManager.doEvents(world_script_events,
new BukkitScriptEntryData(player, npc), context);
}
return true;
}
}
Expand Down

0 comments on commit e7c05d7

Please sign in to comment.