Skip to content
This repository was archived by the owner on Nov 5, 2019. It is now read-only.

Commit b461532

Browse files
committed
Try to debug unreqwuired .changed calls
1 parent 17526c3 commit b461532

5 files changed

Lines changed: 59 additions & 11 deletions

File tree

src/com/massivecraft/massivecore/MassiveCore.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,14 @@ public void onEnableInner()
259259
// Delete Files (at once and additionally after all plugins loaded)
260260
MassiveCoreTaskDeleteFiles.get().run();
261261
Bukkit.getScheduler().scheduleSyncDelayedTask(this, MassiveCoreTaskDeleteFiles.get());
262+
263+
// Uneccessary call of .changed() for debug
264+
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
265+
@Override
266+
public void run() {
267+
MassiveCoreMConf.get().changed();
268+
}
269+
}, 200L);
262270
}
263271

264272
@Override

src/com/massivecraft/massivecore/MassiveCoreMConf.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public int getTpdelay(Permissible permissible)
132132

133133
@EditorType(TypeBooleanOn.class)
134134
public boolean warnOnLocalAlter = false;
135+
136+
@EditorType(TypeBooleanOn.class)
137+
public boolean advancedLocalPollingDebug = false;
135138

136139
// -------------------------------------------- //
137140
// CLEAN

src/com/massivecraft/massivecore/store/Coll.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.massivecraft.massivecore.mixin.MixinModification;
1010
import com.massivecraft.massivecore.store.migrator.MigratorUtil;
1111
import com.massivecraft.massivecore.util.MUtil;
12-
import com.massivecraft.massivecore.util.ReflectionUtil;
1312
import com.massivecraft.massivecore.util.Txt;
1413
import com.massivecraft.massivecore.xlib.gson.Gson;
1514
import com.massivecraft.massivecore.xlib.gson.JsonElement;
@@ -555,7 +554,13 @@ public Modification syncIdFixed(String id, final Modification suppliedModificati
555554
this.removeIdentifiedModificationFixed(id);
556555
break;
557556
}
558-
557+
558+
E entity = this.getFixed(id);
559+
if (entity != null)
560+
{
561+
entity.setLastStackTraceChanged(null);
562+
}
563+
559564
return modification;
560565
}
561566

@@ -595,7 +600,7 @@ private Modification getActualModification(String id, Modification modification,
595600

596601
private void checkActuallyModifiedFixed(String id)
597602
{
598-
if (!ConfServer.localPollingEnabled || !MassiveCoreMConf.get().warnOnLocalAlter) return;
603+
if (!MStore.isLocalPollingDebugEnabled()) return;
599604

600605
E entity = this.getFixed(id);
601606
boolean modified = this.examineHasLocalAlterFixed(id, entity);
@@ -607,6 +612,7 @@ private void checkActuallyModifiedFixed(String id)
607612
String change = Txt.implode(messages, Txt.parse("<silver> | "));
608613
String message = Txt.parse("<b>[No Modification] %s", change);
609614
this.getPlugin().log(message);
615+
if (entity.getLastStackTraceChanged() != null) this.getPlugin().log(MUtil.getStackTraceString(entity.getLastStackTraceChanged(), true));
610616
}
611617

612618
protected void logModification(E entity, Modification modification)

src/com/massivecraft/massivecore/store/Entity.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package com.massivecraft.massivecore.store;
22

3+
import com.massivecraft.massivecore.ConfServer;
4+
import com.massivecraft.massivecore.MassiveCoreMConf;
5+
import com.massivecraft.massivecore.util.MUtil;
36
import com.massivecraft.massivecore.xlib.gson.JsonObject;
47

8+
import java.util.List;
9+
510
// Self referencing generic.
611
// http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ206
712
public class Entity<E extends Entity<E>> extends EntityInternal<E>
@@ -31,13 +36,20 @@ public String getUniverse()
3136
private volatile transient boolean lastDefault = false;
3237
public boolean getLastDefault() { return this.lastDefault; }
3338
public void setLastDefault(boolean lastDefault) { this.lastDefault = lastDefault; }
34-
39+
40+
private volatile transient List<StackTraceElement> lastStackTraceChanged;
41+
public List<StackTraceElement> getLastStackTraceChanged() { return this.lastStackTraceChanged; }
42+
public void setLastStackTraceChanged(List<StackTraceElement> lastStackTraceChanged) { this.lastStackTraceChanged = lastStackTraceChanged; }
43+
3544
public void clearSyncLogFields()
3645
{
3746
this.lastRaw = null;
3847
this.lastMtime = 0;
3948
this.lastDefault = false;
49+
this.lastStackTraceChanged = null;
4050
}
51+
52+
4153

4254
// -------------------------------------------- //
4355
// ATTACH AND DETACH
@@ -62,6 +74,14 @@ public E detach()
6274
// -------------------------------------------- //
6375
// SYNC AND IO ACTIONS
6476
// -------------------------------------------- //
77+
78+
@Override
79+
public void changed()
80+
{
81+
super.changed();
82+
if (!MStore.isLocalPollingDebugEnabled() || !MassiveCoreMConf.get().advancedLocalPollingDebug) return;
83+
this.lastStackTraceChanged = MUtil.getStackTrace();
84+
}
6585

6686
public Modification sync()
6787
{

src/com/massivecraft/massivecore/store/MStore.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.massivecraft.massivecore.store;
22

33
import com.massivecraft.massivecore.ConfServer;
4+
import com.massivecraft.massivecore.MassiveCoreMConf;
45
import com.massivecraft.massivecore.xlib.gson.JsonElement;
56

67
import java.net.URI;
@@ -75,13 +76,13 @@ public static String resolveAlias(String alias)
7576
if (uri == null) return alias;
7677
return resolveAlias(uri);
7778
}
78-
79+
7980
public static Db getDb(String alias)
8081
{
8182
String uri = resolveAlias(alias);
8283
Db db = uri2db.get(uri);
8384
if (db != null) return db;
84-
85+
8586
try
8687
{
8788
db = getDb(new URI(uri));
@@ -91,23 +92,33 @@ public static Db getDb(String alias)
9192
e.printStackTrace();
9293
return null;
9394
}
94-
95+
9596
uri2db.put(uri, db);
96-
97+
9798
return db;
9899
}
99-
100+
100101
public static Db getDb()
101102
{
102103
return getDb(ConfServer.dburi);
103104
}
104-
105+
105106
public static Db getDb(URI uri)
106107
{
107108
String scheme = uri.getScheme();
108109
Driver driver = getDriver(scheme);
109110
if (driver == null) return null;
110111
return driver.getDb(uri.toString());
111112
}
112-
113+
114+
// -------------------------------------------- //
115+
// OTHER
116+
// -------------------------------------------- //
117+
118+
public static boolean isLocalPollingDebugEnabled()
119+
{
120+
return ConfServer.localPollingEnabled && MassiveCoreMConf.get().warnOnLocalAlter;
121+
}
122+
123+
113124
}

0 commit comments

Comments
 (0)