mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 17:19:05 +00:00
Add debug logging toggle for sync flow
This commit is contained in:
1 parent
111f16647d
commit
b25f2b786e
24 files changed
+710
-124
No files matched your search
@@ -209,6 +209,7 @@ public class ServerEventsHandler {
|
||||
EnumSyncType.WORKBENCH_RECIPES,
|
||||
EnumSyncAction.RELOAD,
|
||||
-1,
|
||||
SyncController.getCurrentRevision(EnumSyncType.WORKBENCH_RECIPES),
|
||||
SyncController.workbenchNBT()
|
||||
), (EntityPlayerMP) player);
|
||||
}
|
||||
@@ -217,6 +218,7 @@ public class ServerEventsHandler {
|
||||
EnumSyncType.CARPENTRY_RECIPES,
|
||||
EnumSyncAction.RELOAD,
|
||||
-1,
|
||||
SyncController.getCurrentRevision(EnumSyncType.CARPENTRY_RECIPES),
|
||||
SyncController.carpentryNBT()
|
||||
), (EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ServerTickHandler {
|
||||
}
|
||||
|
||||
ProfileController.Instance.login(player);
|
||||
SyncController.syncPlayer(player);
|
||||
SyncController.beginLogin(player);
|
||||
SyncController.syncEffects(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,12 @@ import noppes.npcs.controllers.data.AnimationData;
|
||||
import noppes.npcs.controllers.data.Party;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import kamkeel.npcs.network.enums.EnumSyncType;
|
||||
import noppes.npcs.util.CacheHashMap;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ClientCacheHandler {
|
||||
@@ -27,11 +30,61 @@ public class ClientCacheHandler {
|
||||
public static HashMap<UUID, HashMap<Integer, SkinOverlay>> skinOverlays = new HashMap<>();
|
||||
public static HashMap<UUID, AnimationData> playerAnimations = new HashMap<>();
|
||||
|
||||
private static String activeServerKey = "";
|
||||
private static final Map<String, EnumMap<EnumSyncType, Integer>> clientRevisionCache = new HashMap<>();
|
||||
|
||||
public static Party party;
|
||||
|
||||
public static boolean allowProfiles = true;
|
||||
public static boolean allowParties = true;
|
||||
|
||||
public static void setActiveServer(String serverKey, EnumMap<EnumSyncType, Integer> serverRevisions) {
|
||||
String normalizedKey = serverKey == null ? "" : serverKey;
|
||||
if (!normalizedKey.equals(activeServerKey)) {
|
||||
clientRevisionCache.clear();
|
||||
}
|
||||
activeServerKey = normalizedKey;
|
||||
|
||||
if (activeServerKey.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EnumMap<EnumSyncType, Integer> cached = clientRevisionCache.computeIfAbsent(
|
||||
activeServerKey,
|
||||
ignored -> new EnumMap<>(EnumSyncType.class)
|
||||
);
|
||||
if (serverRevisions != null && !serverRevisions.isEmpty()) {
|
||||
cached.keySet().retainAll(serverRevisions.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
public static EnumMap<EnumSyncType, Integer> getCachedRevisionsForServer(String serverKey) {
|
||||
String key = serverKey == null ? "" : serverKey;
|
||||
if (key.isEmpty()) {
|
||||
return new EnumMap<>(EnumSyncType.class);
|
||||
}
|
||||
EnumMap<EnumSyncType, Integer> revisions = clientRevisionCache.get(key);
|
||||
if (revisions == null) {
|
||||
return new EnumMap<>(EnumSyncType.class);
|
||||
}
|
||||
return new EnumMap<>(revisions);
|
||||
}
|
||||
|
||||
public static void updateClientRevision(EnumSyncType type, int revision) {
|
||||
if (revision < 0) {
|
||||
return;
|
||||
}
|
||||
String key = activeServerKey == null ? "" : activeServerKey;
|
||||
if (key.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
EnumMap<EnumSyncType, Integer> revisions = clientRevisionCache.computeIfAbsent(
|
||||
key,
|
||||
ignored -> new EnumMap<>(EnumSyncType.class)
|
||||
);
|
||||
revisions.put(type, revision);
|
||||
}
|
||||
|
||||
|
||||
public static ImageData getImageData(String directory) {
|
||||
synchronized (imageDataCache) {
|
||||
|
||||
@@ -41,6 +41,8 @@ public class GuiMagicCycleMap extends GuiDiagram {
|
||||
invalidateCache();
|
||||
return;
|
||||
}
|
||||
// TODO: Consumes MagicController's full magic registry to resolve associations; visible only through magic editing GUIs
|
||||
// that require the NPC wand and CustomNpcsPermissions.GLOBAL_MAGIC (or op status) to open.
|
||||
MagicController mc = MagicController.getInstance();
|
||||
// Get magics from the cycle's associations if associations are not null.
|
||||
if (cycle.associations != null) {
|
||||
@@ -67,6 +69,8 @@ public class GuiMagicCycleMap extends GuiDiagram {
|
||||
* Constructor using a cycle ID.
|
||||
*/
|
||||
public GuiMagicCycleMap(GuiNPCInterface parent, int x, int y, int width, int height, int cycleId) {
|
||||
// TODO: Looks up cycle data from MagicController; accessed from the same wand/CustomNpcsPermissions.GLOBAL_MAGIC gated
|
||||
// management screens.
|
||||
this(parent, x, y, width, height, MagicController.getInstance().getCycle(cycleId));
|
||||
}
|
||||
|
||||
|
||||
@@ -236,6 +236,8 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
|
||||
initGui();
|
||||
}
|
||||
if (guibutton.id == 106) {
|
||||
// TODO: Uses ScriptController.Instance.dir (shared script repository); this GUI is gated behind the scripter tool
|
||||
// and CustomNpcsPermissions.TOOL_SCRIPTER so only authorized editors touch the controller-backed scripts.
|
||||
NoppesUtil.openFolder(ScriptController.Instance.dir);
|
||||
}
|
||||
if (guibutton.id == 107) {
|
||||
|
||||
@@ -19,6 +19,8 @@ public class SubGuiMagicCycleViewer extends SubGuiInterface {
|
||||
}
|
||||
|
||||
public SubGuiMagicCycleViewer(int cycleID) {
|
||||
// TODO: Fetches MagicController cycle definitions (global magic data); only staff with the wand and
|
||||
// CustomNpcsPermissions.GLOBAL_MAGIC reach this viewer via the magic management GUIs.
|
||||
this(MagicController.getInstance().getCycle(cycleID));
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,8 @@ public class GuiNPCManageEffects extends GuiNPCInterface2 implements ICustomScro
|
||||
effect.readFromNBT(compound);
|
||||
setSelected(effect.name);
|
||||
if (effect.id != -1) {
|
||||
// TODO: Writes back into the CustomEffectController cache (global effect dataset); only players with the wand and
|
||||
// CustomNpcsPermissions.GLOBAL_EFFECT reach this admin editor.
|
||||
CustomEffectController.getInstance().getCustomEffects().replace(effect.id, effect);
|
||||
}
|
||||
initGui();
|
||||
|
||||
@@ -41,6 +41,8 @@ public class GuiAnvilRecipes extends GuiNPCInterface {
|
||||
setBackground("recipesAnvil.png");
|
||||
this.closeOnEsc = true;
|
||||
|
||||
// TODO: Loads the entire anvil recipe registry from RecipeController; any player can open this reference GUI without
|
||||
// special permissions.
|
||||
recipes.addAll(RecipeController.Instance.anvilRecipes.values());
|
||||
}
|
||||
|
||||
@@ -81,9 +83,12 @@ public class GuiAnvilRecipes extends GuiNPCInterface {
|
||||
|
||||
private List<RecipeAnvil> getSearchList() {
|
||||
if (search.isEmpty()) {
|
||||
// TODO: Returns every anvil recipe from RecipeController for browsing; no CustomNpcsPermissions gate applies.
|
||||
return new ArrayList<RecipeAnvil>(RecipeController.Instance.anvilRecipes.values());
|
||||
}
|
||||
List<RecipeAnvil> list = new ArrayList<RecipeAnvil>();
|
||||
// TODO: Filters across the RecipeController anvil collection; the bench/anvil GUIs are normal gameplay with no
|
||||
// permission checks.
|
||||
for (RecipeAnvil recipe : RecipeController.Instance.anvilRecipes.values()) {
|
||||
ItemStack repairItem = recipe.itemToRepair;
|
||||
if (repairItem == null)
|
||||
|
||||
@@ -39,6 +39,8 @@ public class GuiNpcAnvil extends GuiContainerNPCInterface {
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
// Enable the button if there are any anvil recipes.
|
||||
// TODO: Checks the shared RecipeController anvil list (entire dataset) before enabling; this player crafting GUI is
|
||||
// public, so no CustomNpcsPermissions gate applies here.
|
||||
button.enabled = RecipeController.Instance != null && !RecipeController.Instance.getAnvilList().isEmpty();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(resource);
|
||||
|
||||
@@ -36,6 +36,8 @@ public class GuiNpcCarpentryBench extends GuiContainerNPCInterface {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
|
||||
// TODO: Reads the global RecipeController carpentry list before enabling; this bench is a public crafting block with no
|
||||
// additional permission checks.
|
||||
button.enabled = RecipeController.Instance != null && !RecipeController.Instance.carpentryRecipes.isEmpty();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.renderEngine.bindTexture(resource);
|
||||
|
||||
@@ -39,6 +39,8 @@ public class GuiRecipes extends GuiNPCInterface {
|
||||
this.xSize = 256;
|
||||
setBackground("recipes.png");
|
||||
this.closeOnEsc = true;
|
||||
// TODO: Preloads every carpentry recipe from RecipeController (full dataset); this book is open to any player, so no
|
||||
// explicit permission is checked when accessing it.
|
||||
recipes.addAll(RecipeController.Instance.carpentryRecipes.values());
|
||||
}
|
||||
|
||||
@@ -74,9 +76,13 @@ public class GuiRecipes extends GuiNPCInterface {
|
||||
|
||||
private List<IRecipe> getSearchList() {
|
||||
if (search.isEmpty()) {
|
||||
// TODO: Returns the entire carpentry recipe collection from RecipeController; again this is unrestricted player
|
||||
// content with no CustomNpcsPermissions gating.
|
||||
return new ArrayList<IRecipe>(RecipeController.Instance.carpentryRecipes.values());
|
||||
}
|
||||
List<IRecipe> list = new ArrayList<IRecipe>();
|
||||
// TODO: Iterates over the RecipeController carpentry map to filter recipes; this viewing GUI is available to all
|
||||
// players without special permissions.
|
||||
for (IRecipe recipe : RecipeController.Instance.carpentryRecipes.values()) {
|
||||
if (recipe.getRecipeOutput() == null)
|
||||
continue;
|
||||
|
||||
@@ -94,6 +94,8 @@ public class GuiCNPCInventory extends GuiNPCInterface {
|
||||
PlayerData data = PlayerData.get(mc.thePlayer);
|
||||
if (data != null && data.effectData != null) {
|
||||
for (PlayerEffect pe : data.effectData.getEffects().values()) {
|
||||
// TODO: Pulls specific CustomEffect entries from the global controller; this HUD is part of the base
|
||||
// player inventory so it must work without extra permissions (no CustomNpcsPermissions required).
|
||||
CustomEffect effect = CustomEffectController.getInstance().get(pe.id, pe.index);
|
||||
if (effect != null) {
|
||||
effectBar.entries.add(new GuiEffectBar.EffectEntry(effect, pe));
|
||||
|
||||
@@ -255,6 +255,8 @@ public class GuiModernQuestDialog extends GuiNPCInterface implements IGuiClose {
|
||||
}
|
||||
int fac1ID = quest.factionOptions.factionId;
|
||||
if (fac1ID != -1) {
|
||||
// TODO: Looks up faction display data from the global FactionController; this dialog is part of the standard
|
||||
// player quest flow so no special permissions are needed beyond quest access.
|
||||
String fac1Name = FactionController.getInstance().getFaction(fac1ID).getName();
|
||||
String fac1Color = (quest.factionOptions.decreaseFactionPoints) ? "§c-" : "§a+";
|
||||
int fac1Point = quest.factionOptions.factionPoints;
|
||||
@@ -263,6 +265,8 @@ public class GuiModernQuestDialog extends GuiNPCInterface implements IGuiClose {
|
||||
}
|
||||
int fac2ID = quest.factionOptions.faction2Id;
|
||||
if (fac2ID != -1) {
|
||||
// TODO: Retrieves the second faction's metadata from FactionController as above; normal quest participants reach
|
||||
// this without CustomNpcsPermissions requirements.
|
||||
String fac2Name = FactionController.getInstance().getFaction(fac2ID).getName();
|
||||
String fac2Color = (quest.factionOptions.decreaseFaction2Points) ? "§c-" : "§a+";
|
||||
int fac2Point = quest.factionOptions.faction2Points;
|
||||
|
||||
@@ -79,7 +79,9 @@ public class GuiNpcQuestTypeItem extends GuiContainerNPCInterface implements ITe
|
||||
// map.put(i, item.copy());
|
||||
// }
|
||||
// ((QuestItem)quest.questInterface).items = map;
|
||||
// QuestController.saveQuest(quest);
|
||||
// TODO: Saving would route through the global QuestController, which should stay limited to wand users with
|
||||
// CustomNpcsPermissions.GLOBAL_QUEST or operators when OpsOnly is active.
|
||||
// QuestController.saveQuest(quest);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -307,6 +307,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
|
||||
}
|
||||
|
||||
if (guibutton.id == 106) {
|
||||
// TODO: Opens the ScriptController shared directory; this screen is available only to editors with the scripter
|
||||
// tool and CustomNpcsPermissions.TOOL_SCRIPTER.
|
||||
NoppesUtil.openFolder(ScriptController.Instance.dir);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ public class GuiDialogSelection extends SubGuiInterface implements ICustomScroll
|
||||
setBackground("menubg.png");
|
||||
xSize = 366;
|
||||
ySize = 226;
|
||||
// TODO: Pulls the entire DialogController dialog map (global data); players only reach this via wand-required dialog
|
||||
// editors that enforce PacketUtil.verifyItemPacket and CustomNpcsPermissions.GLOBAL_DIALOG/ops when editing.
|
||||
this.selectedDialog = DialogController.Instance.dialogs.get(dialog);
|
||||
if (selectedDialog != null) {
|
||||
selectedCategory = selectedDialog.category;
|
||||
@@ -59,6 +61,8 @@ public class GuiDialogSelection extends SubGuiInterface implements ICustomScroll
|
||||
HashMap<String, DialogCategory> categoryData = new HashMap<String, DialogCategory>();
|
||||
HashMap<String, Dialog> dialogData = new HashMap<String, Dialog>();
|
||||
|
||||
// TODO: Iterates over every dialog category provided by DialogController; reachable through NPC wand workflows that
|
||||
// require dialog-edit permissions (CustomNpcsPermissions.GLOBAL_DIALOG or op status under OpsOnly).
|
||||
for (DialogCategory category : DialogController.Instance.categories.values()) {
|
||||
categoryData.put(category.title, category);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollL
|
||||
setBackground("menubg.png");
|
||||
xSize = 366;
|
||||
ySize = 226;
|
||||
// TODO: Requires the full QuestController quest map (global dataset); access comes from wand-driven quest editors
|
||||
// that rely on PacketUtil.verifyItemPacket and ultimately CustomNpcsPermissions.GLOBAL_QUEST / server op checks.
|
||||
this.selectedQuest = QuestController.Instance.quests.get(quest);
|
||||
if (selectedQuest != null) {
|
||||
selectedCategory = selectedQuest.category;
|
||||
@@ -59,6 +61,8 @@ public class GuiQuestSelection extends SubGuiInterface implements ICustomScrollL
|
||||
HashMap<String, QuestCategory> categoryData = new HashMap<String, QuestCategory>();
|
||||
HashMap<String, Quest> questData = new HashMap<String, Quest>();
|
||||
|
||||
// TODO: Needs every quest category from QuestController so the selector can populate; opened from NPC wand flows that
|
||||
// demand the editing player satisfy CustomNpcsPermissions.GLOBAL_QUEST (or be OP when OpsOnly is enabled).
|
||||
for (QuestCategory category : QuestController.Instance.categories.values()) {
|
||||
categoryData.put(category.title, category);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user