Skip to content

Commit

Permalink
use RefreshState
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jun 23, 2022
1 parent a75c753 commit b7d22bb
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
Expand Up @@ -76,6 +76,7 @@ public CuboidTag clone() {
cuboid = new CuboidTag();
}
cuboid.noteName = null;
cuboid.priorNoteName = null;
cuboid.flagTracker = null;
cuboid.pairs = new ArrayList<>(pairs.size());
for (LocationPair pair : pairs) {
Expand Down Expand Up @@ -293,7 +294,7 @@ public void regenerate(LocationTag point_1, LocationTag point_2) {

public List<LocationPair> pairs = new ArrayList<>();

public String noteName = null;
public String noteName = null, priorNoteName = null;

public AbstractFlagTracker flagTracker = null;

Expand Down Expand Up @@ -602,12 +603,28 @@ public void makeUnique(String id) {

@Override
public void forget() {
if (noteName == null) {
return;
}
priorNoteName = noteName;
NotedAreaTracker.remove(this);
NoteManager.remove(this);
noteName = null;
flagTracker = null;
}

@Override
public CuboidTag refreshState() {
if (noteName == null && priorNoteName != null) {
Notable note = NoteManager.getSavedObject(priorNoteName);
if (note instanceof CuboidTag) {
return (CuboidTag) note;
}
priorNoteName = null;
}
return this;
}

String prefix = "Cuboid";

@Override
Expand Down
Expand Up @@ -145,7 +145,7 @@ public EllipsoidTag(LocationTag center, LocationTag size) {

public LocationTag size;

public String noteName = null;
public String noteName = null, priorNoteName = null;

public AbstractFlagTracker flagTracker = null;

Expand Down Expand Up @@ -284,11 +284,28 @@ public void makeUnique(String id) {

@Override
public void forget() {
if (noteName == null) {
return;
}
priorNoteName = noteName;
NotedAreaTracker.remove(this);
NoteManager.remove(this);
noteName = null;
flagTracker = null;
}

@Override
public EllipsoidTag refreshState() {
if (noteName == null && priorNoteName != null) {
Notable note = NoteManager.getSavedObject(priorNoteName);
if (note instanceof EllipsoidTag) {
return (EllipsoidTag) note;
}
priorNoteName = null;
}
return this;
}

@Override
public int hashCode() {
if (noteName != null) {
Expand Down
Expand Up @@ -176,7 +176,7 @@ public void setInventory(Inventory inventory) {
this.inventory = inventory;
}

public String noteName;
public String noteName = null, priorNoteName = null;

public void makeUnique(String id) {
InventoryTag toNote = new InventoryTag(inventory, idType, idHolder);
Expand Down Expand Up @@ -205,12 +205,29 @@ public void makeUnique(String id) {

@Override
public void forget() {
if (noteName == null) {
return;
}
priorNoteName = noteName;
NoteManager.remove(this);
InventoryScriptHelper.notedInventories.remove(inventory);
flagTracker = null;
noteName = null;
}

@Override
public InventoryTag refreshState() {
if (noteName == null && priorNoteName != null) {
Notable note = NoteManager.getSavedObject(priorNoteName);
if (note instanceof InventoryTag) {
return (InventoryTag) note;
}
priorNoteName = null;
}
trackTemporaryInventory(this);
return this;
}

@Override
public AbstractFlagTracker getFlagTracker() {
return flagTracker;
Expand Down
Expand Up @@ -68,7 +68,7 @@ public class PolygonTag implements ObjectTag, Cloneable, Notable, Adjustable, Ar

public Corner boxMin = new Corner(), boxMax = new Corner();

public String noteName = null;
public String noteName = null, priorNoteName = null;

public AbstractFlagTracker flagTracker = null;

Expand Down Expand Up @@ -422,12 +422,28 @@ public void makeUnique(String id) {

@Override
public void forget() {
if (noteName == null) {
return;
}
priorNoteName = noteName;
NotedAreaTracker.remove(this);
NoteManager.remove(this);
noteName = null;
flagTracker = null;
}

@Override
public PolygonTag refreshState() {
if (noteName == null && priorNoteName != null) {
Notable note = NoteManager.getSavedObject(priorNoteName);
if (note instanceof PolygonTag) {
return (PolygonTag) note;
}
priorNoteName = null;
}
return this;
}

String prefix = "Polygon";

@Override
Expand Down

0 comments on commit b7d22bb

Please sign in to comment.