From b39097e01594ccdba18ff13b2557553f7a666141 Mon Sep 17 00:00:00 2001 From: Andrew Wong <42793301+md5sha256@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:57:10 +0800 Subject: [PATCH 1/3] Refactor ticker task to use a thread-safe Set implementation for tickingLocations --- .../implementation/tasks/TickerTask.java | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java index 76589bba84..51541f01cf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java @@ -35,6 +35,7 @@ public class TickerTask implements Runnable { /** * This Map holds all currently actively ticking locations. + * The value of this map (Set entries) MUST be thread-safe and mutable. */ private final Map> tickingLocations = new ConcurrentHashMap<>(); @@ -255,7 +256,7 @@ public Map> getLocations() { public Set getLocations(@Nonnull Chunk chunk) { Validate.notNull(chunk, "The Chunk cannot be null!"); - Set locations = tickingLocations.getOrDefault(new ChunkPosition(chunk), new HashSet<>()); + Set locations = tickingLocations.getOrDefault(new ChunkPosition(chunk), Collections.emptySet()); return Collections.unmodifiableSet(locations); } @@ -269,11 +270,26 @@ public void enableTicker(@Nonnull Location l) { Validate.notNull(l, "Location cannot be null!"); synchronized (tickingLocations) { - tickingLocations - .computeIfAbsent( - new ChunkPosition(l.getWorld(), l.getBlockX() >> 4, l.getBlockZ() >> 4), - k -> new HashSet<>()) - .add(l); + ChunkPosition chunk = new ChunkPosition(l.getWorld(), l.getBlockX() >> 4, l.getBlockZ() >> 4); + + /* + Note that all the values in #tickingLocations must be thread-safe. + Thus, the choice is between the CHM KeySet or a synchronized set. + The CHM KeySet was chosen since it at least permits multiple concurrent + reads without blocking. + */ + Set newValue = ConcurrentHashMap.newKeySet(); + Set oldValue = tickingLocations.putIfAbsent(chunk, newValue); + + /** + * This is faster than doing computeIfAbsent(...) + * on a ConcurrentHashMap because it won't block the Thread for too long + */ + if (oldValue != null) { + oldValue.add(l); + } else { + newValue.add(l); + } } } From e3444ab230bea683d7a58f8d9e695882923bc9ad Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Tue, 10 Sep 2024 16:54:02 +0800 Subject: [PATCH 2/3] chore: bro we already moved --- .github/ISSUE_TEMPLATE/bug-report.yml | 4 ++-- .github/ISSUE_TEMPLATE/translation-report.yml | 4 ++-- .github/PULL_REQUEST_TEMPLATE.md | 2 +- README.md | 18 +++++++++--------- .../guide/options/SlimefunGuideSettings.java | 4 ++-- .../slimefun4/implementation/Slimefun.java | 4 ++-- .../implementation/setup/PostSetup.java | 4 ++-- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 232b0f1851..1cd14b943c 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -10,8 +10,8 @@ body: 感谢你使用 Slimefun 问题反馈系统! 在反馈前, 请确认你已经做了下面这些事情 - - 查看 [Releases](https://github.com/StarWishsama/Slimefun4/releases) 中最新版是否已修复你所遇到的问题 - - 搜索了已有的 [issues](https://github.com/StarWishsama/Slimefun4/issues) 列表中是否有相似问题 + - 查看 [Releases](https://github.com/SlimefunGuguProject/Slimefun4/releases) 中最新版是否已修复你所遇到的问题 + - 搜索了已有的 [issues](https://github.com/SlimefunGuguProject/Slimefun4/issues) 列表中是否有相似问题 如果此问题反馈不符合模板,将会被管理员无条件关闭。 diff --git a/.github/ISSUE_TEMPLATE/translation-report.yml b/.github/ISSUE_TEMPLATE/translation-report.yml index 5b0c8a50b8..47f127634e 100644 --- a/.github/ISSUE_TEMPLATE/translation-report.yml +++ b/.github/ISSUE_TEMPLATE/translation-report.yml @@ -10,8 +10,8 @@ body: 感谢你使用 Slimefun 问题反馈系统! 在反馈前, 请确认你已经做了下面这些事情 - - 查看 [Releases](https://github.com/StarWishsama/Slimefun4/releases) 中最新版是否已修复你所遇到的问题 - - 搜索了已有的 [issues](https://github.com/StarWishsama/Slimefun4/issues) 列表中是否有相似问题 + - 查看 [Releases](https://github.com/SlimefunGuguProject/Slimefun4/releases) 中最新版是否已修复你所遇到的问题 + - 搜索了已有的 [issues](https://github.com/SlimefunGuguProject/Slimefun4/issues) 列表中是否有相似问题 如果此问题反馈不符合模板,将会被管理员无条件关闭。 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 62c59b14cd..8362621b10 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ - + ## 简介 diff --git a/README.md b/README.md index ca8289dc01..d65374d7c4 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ Looking for English (or Original) Version? [**Click here**](https://github.com/Slimefun/Slimefun4/) -想要直接下载吗? [**单击此处**](https://github.com/StarWishsama/Slimefun4/blob/master/README.md#floppy_disk-下载-slimefun4) +想要直接下载吗? [**单击此处**](https://github.com/SlimefunGuguProject/Slimefun4/blob/master/README.md#floppy_disk-下载-slimefun4) 欢迎加入 QQ 交流群:807302496 -下载 [SlimeGlue(粘液胶)](https://github.com/Xzavier0722/SlimeGlue/) 以保证 Slimefun 与领地保护插件的兼容性 +下载 [SlimeGlue(粘液胶)](https://github.com/Xzavier0722/SlimeGlue/) 以保证 Slimefun 与其他保护插件的兼容性 ### 订阅计划 @@ -17,10 +17,10 @@ Looking for English (or Original) Version? [**Click here**](https://github.com/S 了解订阅计划:[订阅计划](https://builds.guizhanss.com/sf-subscription) -![目前版本](https://img.shields.io/github/v/release/StarWishSama/Slimefun4?include_prereleases) -![构建状态](https://builds.guizhanss.com/StarWishsama/Slimefun4/master/badge.svg) -[![Issues](https://img.shields.io/github/issues/StarWishsama/Slimefun4.svg?style=popout)](https://github.com/StarWishsama/Slimefun4/issues) -![下载数](https://img.shields.io/github/downloads/StarWishsama/Slimefun4/total) +![目前版本](https://img.shields.io/github/v/release/SlimefunGuguProject/Slimefun4?include_prereleases) +![构建状态](https://builds.guizhanss.com/SlimefunGuguProject/Slimefun4/master/badge.svg) +[![Issues](https://img.shields.io/github/issues/SlimefunGuguProject/Slimefun4.svg?style=popout)](https://github.com/SlimefunGuguProject/Slimefun4/issues) +![下载数](https://img.shields.io/github/downloads/SlimefunGuguProject/Slimefun4/total) 使用汉化版之后,**禁止**在官方问题追踪器创建新问题! 如果你执意要这么做, 请在反馈时使用**官方**开发版并且使用**英语**提交问题。 @@ -44,7 +44,7 @@ Slimefun 让每个玩家可以自行决定在魔法或科技方面发展。 * **[下载 Slimefun 4](#floppy_disk-下载-slimefun4)** * **[Discord 服务器](#discord)** -* **[Bug 反馈](https://github.com/StarWishsama/Slimefun4/issues)** +* **[Bug 反馈](https://github.com/SlimefunGuguProject/Slimefun4/issues)** * **[官方Wiki](https://github.com/Slimefun/Slimefun4/wiki)** * **[非官方中文 Wiki](https://slimefun-wiki.guizhanss.cn/)** * **[FAQ](https://slimefun-wiki.guizhanss.cn/FAQ)** @@ -68,7 +68,7 @@ Slimefun 4 可以在[鬼斩构建站](https://builds.guizhanss.com)页面中** | **Bug 反馈** | :heavy_check_mark: | :x: | | **在发布前进行测试** | :x: | :heavy_check_mark: | | **有无更新日志** | :x: | :memo: **[更新日志(英文)](https://github.com/Slimefun/Slimefun4/blob/master/CHANGELOG.md)** | -| **下载链接** | :package: **[下载 最新版](https://builds.guizhanss.com/StarWishsama/Slimefun4/master)** | :package: **[下载 "稳定版"](https://builds.guizhanss.com/StarWishsama/Slimefun4/release)** | +| **下载链接** | :package: **[下载 最新版](https://builds.guizhanss.com/SlimefunGuguProject/Slimefun4/master)** | :package: **[下载 "稳定版"](https://builds.guizhanss.com/SlimefunGuguProject/Slimefun4/release)** | **! 建议你使用最新的测试版,可以获得最新的内容更新和 Bug 修复!** @@ -106,7 +106,7 @@ Slimefun 4 可以在[鬼斩构建站](https://builds.guizhanss.com)页面中** 单击下面的徽标加入 Discord 服务器反馈问题和提出意见,或者讨论关于此插件的内容。 Slimefun 官方经常会举办一些社区活动,加入我们了解更多。 **注意**:Slimefun 官方在 Discord 服务器 **不** -接受任何形式的问题反馈,请使用 [问题追踪器](https://github.com/StarWishsama/Slimefun4/issues) 反馈问题! +接受任何形式的问题反馈,请使用 [问题追踪器](https://github.com/SlimefunGuguProject/Slimefun4/issues) 反馈问题! 在加入前请先了解官方 Discord 服务器[重要的规则](https://github.com/Slimefun/Slimefun4/wiki/Discord-Rules)。 不遵守以上规则的人可能会被从服务器中踢出甚至封禁。 diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java index a1e72830d0..6347a2cc2f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java @@ -158,7 +158,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { menu.addMenuClickHandler(6, (pl, slot, item, action) -> { pl.closeInventory(); - ChatUtils.sendURL(pl, "https://github.com/StarwishSama/Slimefun4"); + ChatUtils.sendURL(pl, "https://github.com/SlimefunGuguProject/Slimefun4"); return false; }); @@ -223,7 +223,7 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { menu.addMenuClickHandler(49, (pl, slot, item, action) -> { pl.closeInventory(); - ChatUtils.sendURL(pl, "https://github.com/StarWishsama/Slimefun4/issues"); + ChatUtils.sendURL(pl, "https://github.com/SlimefunGuguProject/Slimefun4/issues"); return false; }); } else { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java index 1198b6a17f..fde30a5094 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java @@ -181,7 +181,7 @@ public final class Slimefun extends JavaPlugin implements SlimefunAddon, ICompat private final CustomItemDataService itemDataService = new CustomItemDataService(this, "slimefun_item"); private final BlockDataService blockDataService = new BlockDataService(this, "slimefun_block"); private final CustomTextureService textureService = new CustomTextureService(new Config(this, "item-models.yml")); - private final GitHubService gitHubService = new GitHubService("StarWishsama/Slimefun4"); + private final GitHubService gitHubService = new GitHubService("SlimefunGuguProject/Slimefun4"); private final UpdaterService updaterService = new UpdaterService(this, getDescription().getVersion(), getFile()); private final MetricsService metricsService = new MetricsService(this); @@ -449,7 +449,7 @@ public JavaPlugin getJavaPlugin() { @Override public String getBugTrackerURL() { - return "https://github.com/StarWishsama/Slimefun4/issues"; + return "https://github.com/SlimefunGuguProject/Slimefun4/issues"; } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java index a0bd90bac8..724ab90b82 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java @@ -86,8 +86,8 @@ public static void loadItems() { sender.sendMessage(""); sender.sendMessage(""); - sender.sendMessage(ChatColor.GREEN + " - 源码: https://github.com/StarWishsama/Slimefun4"); - sender.sendMessage(ChatColor.GREEN + " - Bug 反馈: https://github.com/StarWishsama/Slimefun4/issues"); + sender.sendMessage(ChatColor.GREEN + " - 源码: https://github.com/SlimefunGuguProject/Slimefun4"); + sender.sendMessage(ChatColor.GREEN + " - Bug 反馈: https://github.com/SlimefunGuguProject/Slimefun4/issues"); sender.sendMessage(""); From 0f360b314cc13cb8b51483ec19424049dd12ea8f Mon Sep 17 00:00:00 2001 From: StarWishsama Date: Wed, 11 Sep 2024 22:53:25 +0800 Subject: [PATCH 3/3] chore: update repo owner name --- .../java/net/guizhanss/slimefun4/updater/AutoUpdateTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/guizhanss/slimefun4/updater/AutoUpdateTask.java b/src/main/java/net/guizhanss/slimefun4/updater/AutoUpdateTask.java index 0cbbb7defb..3f4d877fa8 100644 --- a/src/main/java/net/guizhanss/slimefun4/updater/AutoUpdateTask.java +++ b/src/main/java/net/guizhanss/slimefun4/updater/AutoUpdateTask.java @@ -14,7 +14,7 @@ */ public class AutoUpdateTask implements Runnable { - private static final String GITHUB_USER = "StarWishsama"; + private static final String GITHUB_USER = "SlimefunGuguProject"; private static final String GITHUB_REPO = "Slimefun4"; private static final String GITHUB_BRANCH_BETA = "master"; private static final String GITHUB_BRANCH_RELEASE = "release";