') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Rewrite User storage and UUID cache by JRoy · Pull Request #4581 · EssentialsX/Essentials · GitHub
Skip to content

Rewrite User storage and UUID cache - #4581

Merged
mdcfe merged 72 commits into
dev/2.20from
refactor/usermap-rewrite
Sep 4, 2022
Merged

Rewrite User storage and UUID cache#4581
mdcfe merged 72 commits into
dev/2.20from
refactor/usermap-rewrite

Conversation

@JRoy

@JRoyJRoy commented Oct 17, 2021

Copy link
Copy Markdown
Member

A rewrite of user loading, user caching, uuid caching, and user memory management.

Closes#4512
Closes#4342
Closes#4566
Closes#4581


Technical Breakdown of ModernUserMap + ModernUUIDCache

TODO :trollface:


Checklist;

  • Store username history more sanely
  • Rewrite the UUID cache
  • Rewrite the UserMap and replace the old UserMap
  • Add ABI backwards compatibility for certain hot methods in old UserMap

@JRoyJRoy added type: enhancement Features and feature requests. type: bugfix PRs that fix bugs in EssentialsX. module: main Issues or PRs for the main Essentials module labels Oct 17, 2021
@JRoyJRoy added this to the 2.19.1 milestone Oct 17, 2021
@JRoyJRoy mentioned this pull request Oct 17, 2021
@JRoyJRoy changed the title Rewrite UserMapRewrite User storage and UUID cacheOct 17, 2021
@JRoy
JRoy marked this pull request as ready for review October 18, 2021 03:04
@tadhgboyle

Copy link
Copy Markdown
Contributor

:shipit:

pop4959
pop4959 previously approved these changes Oct 28, 2021

@pop4959pop4959 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//noinspection ConstantConditions

JRoy added 10 commits July 26, 2022 18:21
# Conflicts:
#	Essentials/src/main/java/com/earth2me/essentials/commands/Commandessentials.java
Always call ModernUserMap#getUser(Player) during join to ensure the
fetched/created User object has the most up-to-date name on the underlying
Player object. Additionally, ensure that ModernUUIDCache#updateCache is always
called during #getUser and not just when we generate a new User object (which
always never happens by the time the call is made 💀).
Used to create User objects based on player objects for use from when before
Bukkit places the user into its own internal usermap.
Without this, ModernUserMap#loadUncachedUser(UUID) would attempt to fetch
the player from the server only to not return null because we first try to
create a user during PlayerLoginEvent which is before Bukkit puts the player
into its internal usermap.

@mdcfemdcfe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side note: do we want an API interface for ModernUserMap? Just so there's an explicit (and limited) set of methods that plugins should expect to use, otherwise I anticipate people will just call internal methods

Comment threadEssentials/src/main/java/com/earth2me/essentials/api/Economy.java Outdated
@JRoy
JRoy requested a review from mdcfeAugust 25, 2022 21:42
Comment thread.idea/checkstyle-idea.xml Outdated
@mdcfe
mdcfe changed the base branch from 2.x to dev/2.20August 31, 2022 14:29
@JRoy
JRoy requested a review from mdcfeAugust 31, 2022 22:41
@mdcfe
mdcfe merged commit be91573 into dev/2.20Sep 4, 2022
@mdcfe
mdcfe deleted the refactor/usermap-rewrite branch September 4, 2022 14:42
JRoy added a commit that referenced this pull request Sep 4, 2022
Co-authored-by: triagonal <10545540+triagonal@users.noreply.github.com>
Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com>
JRoy added a commit that referenced this pull request Sep 9, 2022
Co-authored-by: triagonal <10545540+triagonal@users.noreply.github.com>
Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com>
@mibby

mibby commented Sep 17, 2022

Copy link
Copy Markdown

@JRoy Not entirely sure where to leave feedback for this but noticed that every time Citizens loads an npc (server restarts, teleporting around), Essentials spams creating a user for them.
https://paste.gg/p/anonymous/e7fd399e9db6436d8ed3c5ee15dae70a/files/febeaa22bd6846a8aa7d8a93acb63b85/raw

EssentialsX-2.20.0-dev+5
https://ci.ender.zone/view/All/job/EssentialsX-Experimental/100007/
Citizens2 dev 2705
https://ci.citizensnpcs.co/job/Citizens2/

@JeffP07

Copy link
Copy Markdown

@JRoy Not entirely sure where to leave feedback for this but noticed that every time Citizens loads an npc (server restarts, teleporting around), Essentials spams creating a user for them. https://paste.gg/p/anonymous/e7fd399e9db6436d8ed3c5ee15dae70a/files/febeaa22bd6846a8aa7d8a93acb63b85/raw

EssentialsX-2.20.0-dev+5 https://ci.ender.zone/view/All/job/EssentialsX-Experimental/100007/ Citizens2 dev 2705 https://ci.citizensnpcs.co/job/Citizens2/

I had this issue and found it was caused by jail.yml having old data that was formatted in a different way than new jails. Since I don't actually use the jails, removing the file contents worked for me.

ressidell pushed a commit to ressidell/Essentials that referenced this pull request Apr 27, 2025
Co-authored-by: triagonal <10545540+triagonal@users.noreply.github.com>
Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com>
rewsdjad1 pushed a commit to rewsdjad1/EssentialsXPlus that referenced this pull request Aug 13, 2026
Co-authored-by: triagonal <10545540+triagonal@users.noreply.github.com>
Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: mainIssues or PRs for the main Essentials moduletype: bugfixPRs that fix bugs in EssentialsX.type: enhancementFeatures and feature requests.

Projects

None yet

9 participants

@JRoy@tadhgboyle@mdcfe@Gilthunderx@mibby@JeffP07@pop4959@darbyjack@triagonal