Skip to content

Commit 38ceb88

Browse files
committed
style: apply spotless code format
1 parent 413c91d commit 38ceb88

File tree

63 files changed

+604
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+604
-412
lines changed

src/main/java/city/norain/slimefun4/EnvironmentChecker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ static boolean checkHybridServer() {
7474
}
7575

7676
static void scheduleSlimeGlueCheck(@Nonnull Slimefun sf) {
77-
Slimefun.getFoliaLib().getScheduler()
77+
Slimefun.getFoliaLib()
78+
.getScheduler()
7879
.runLater(
7980
() -> {
8081
if (Bukkit.getPluginManager().getPlugin("SlimeGlue") == null) {

src/main/java/city/norain/slimefun4/utils/TaskUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public <T> T runSyncMethod(Callable<T> callable) {
2626
return callable.call();
2727
} else {
2828
try {
29-
return Slimefun.getFoliaLib().getPlugin().getServer().getScheduler()
29+
return Slimefun.getFoliaLib()
30+
.getPlugin()
31+
.getServer()
32+
.getScheduler()
3033
.callSyncMethod(Slimefun.instance(), callable)
3134
.get(1, TimeUnit.SECONDS);
3235
} catch (TimeoutException e) {

src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/listener/PlayerChatListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class PlayerChatListener implements Listener {
1313
public void onChat(AsyncPlayerChatEvent e) {
1414
Slimefun.getChatCatcher().pollCatcher(e.getPlayer().getUniqueId()).ifPresent(h -> {
1515
e.setCancelled(true);
16-
Slimefun.runSyncAtEntity(() -> h.accept(e.getMessage()),e.getPlayer());
16+
Slimefun.runSyncAtEntity(() -> h.accept(e.getMessage()), e.getPlayer());
1717
});
1818
}
1919

src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import city.norain.slimefun4.api.menu.UniversalMenu;
44
import city.norain.slimefun4.api.menu.UniversalMenuPreset;
55
import city.norain.slimefun4.utils.InventoryUtil;
6-
import com.tcoded.folialib.wrapper.task.WrappedTask;
76
import city.norain.slimefun4.utils.StringUtil;
7+
import com.tcoded.folialib.wrapper.task.WrappedTask;
88
import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.IDataSourceAdapter;
99
import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback;
1010
import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope;
@@ -24,7 +24,6 @@
2424
import io.github.bakedlibs.dough.collections.Pair;
2525
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
2626
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
27-
import java.util.Arrays;
2827
import java.util.HashMap;
2928
import java.util.HashSet;
3029
import java.util.List;
@@ -46,7 +45,6 @@
4645
import org.bukkit.World;
4746
import org.bukkit.inventory.ItemStack;
4847
import org.bukkit.plugin.Plugin;
49-
import org.bukkit.scheduler.BukkitTask;
5048

5149
/**
5250
* 方块数据控制器
@@ -131,7 +129,8 @@ private void initLoadData() {
131129
case LOAD_ON_STARTUP -> loadLoadedWorlds();
132130
}
133131

134-
Slimefun.getFoliaLib().getScheduler()
132+
Slimefun.getFoliaLib()
133+
.getScheduler()
135134
.runLater(
136135
() -> {
137136
initLoading = true;
@@ -145,7 +144,8 @@ private void initLoadData() {
145144
* 加载所有服务器已加载的世界中的数据
146145
*/
147146
private void loadLoadedWorlds() {
148-
Slimefun.getFoliaLib().getScheduler()
147+
Slimefun.getFoliaLib()
148+
.getScheduler()
149149
.runLater(
150150
() -> {
151151
initLoading = true;
@@ -161,7 +161,8 @@ private void loadLoadedWorlds() {
161161
* 加载所有服务器已加载的世界区块中的数据
162162
*/
163163
private void loadLoadedChunks() {
164-
Slimefun.getFoliaLib().getScheduler()
164+
Slimefun.getFoliaLib()
165+
.getScheduler()
165166
.runLater(
166167
() -> {
167168
initLoading = true;
@@ -189,7 +190,8 @@ public void initDelayedSaving(Plugin p, int delayedSecond, int forceSavePeriod)
189190
}
190191
enableDelayedSaving = true;
191192
this.delayedSecond = delayedSecond;
192-
looperTask = Slimefun.getFoliaLib().getScheduler()
193+
looperTask = Slimefun.getFoliaLib()
194+
.getScheduler()
193195
.runTimerAsync(
194196
new DelayedSavingLooperTask(
195197
forceSavePeriod, () -> new HashMap<>(delayedWriteTasks), delayedWriteTasks::remove),
@@ -1455,7 +1457,8 @@ private void migrateUniversalData(
14551457
.updateUniversalDataUUID(l.getBlock(), String.valueOf(universalData.getUUID()));
14561458
}
14571459
},
1458-
10L,l);
1460+
10L,
1461+
l);
14591462

14601463
kvData.forEach(recordSet -> universalData.setData(
14611464
recordSet.get(FieldKey.DATA_KEY), DataUtils.blockDataDebase64(recordSet.get(FieldKey.DATA_VALUE))));

src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,27 @@ public ErrorReport(T throwable, Location l, SlimefunItem item) {
109109
Slimefun.getDatabaseManager().getBlockDataController().getBlockData(l);
110110

111111
if (blockData == null) {
112-
Slimefun.runSyncAtLocation(() -> Slimefun.getBlockDataService()
113-
.getUniversalDataUUID(l.getBlock())
114-
.ifPresentOrElse(
115-
uuid -> {
116-
var universalData = Slimefun.getDatabaseManager()
117-
.getBlockDataController()
118-
.getUniversalBlockDataFromCache(uuid);
119-
if (universalData != null) {
120-
stream.println(" 数据加载状态: " + universalData.isDataLoaded());
121-
stream.println(" 物品栏: " + (universalData.getMenu() != null));
122-
stream.println(" 数据: ");
123-
universalData
124-
.getAllData()
125-
.forEach((k, v) -> stream.println(" " + k + ": " + v));
126-
} else {
127-
stream.println("该方块没有任何数据.");
128-
}
129-
},
130-
() -> stream.println("该方块没有任何数据.")),l);
112+
Slimefun.runSyncAtLocation(
113+
() -> Slimefun.getBlockDataService()
114+
.getUniversalDataUUID(l.getBlock())
115+
.ifPresentOrElse(
116+
uuid -> {
117+
var universalData = Slimefun.getDatabaseManager()
118+
.getBlockDataController()
119+
.getUniversalBlockDataFromCache(uuid);
120+
if (universalData != null) {
121+
stream.println(" 数据加载状态: " + universalData.isDataLoaded());
122+
stream.println(" 物品栏: " + (universalData.getMenu() != null));
123+
stream.println(" 数据: ");
124+
universalData
125+
.getAllData()
126+
.forEach((k, v) -> stream.println(" " + k + ": " + v));
127+
} else {
128+
stream.println("该方块没有任何数据.");
129+
}
130+
},
131+
() -> stream.println("该方块没有任何数据.")),
132+
l);
131133
} else {
132134
stream.println(" 数据加载状态: " + blockData.isDataLoaded());
133135
stream.println(" 物品栏: " + (blockData.getBlockMenu() != null));

src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -374,33 +374,36 @@ public void addWaypoint(@Nonnull Player p, @Nonnull String name, @Nonnull Locati
374374
return;
375375
}
376376

377-
Slimefun.runSyncAtEntity(() -> {
378-
WaypointCreateEvent event = new WaypointCreateEvent(p, name, l);
379-
Bukkit.getPluginManager().callEvent(event);
380-
381-
if (!event.isCancelled()) {
382-
String id = ChatColor.stripColor(ChatColors.color(event.getName()))
383-
.toUpperCase(Locale.ROOT)
384-
.replace(' ', '_');
385-
386-
for (Waypoint wp : profile.getWaypoints()) {
387-
if (wp.getId().equals(id)) {
388-
Slimefun.getLocalization()
389-
.sendMessage(
390-
p,
391-
"gps.waypoint.duplicate",
392-
true,
393-
msg -> msg.replace("%waypoint%", event.getName()));
394-
return;
377+
Slimefun.runSyncAtEntity(
378+
() -> {
379+
WaypointCreateEvent event = new WaypointCreateEvent(p, name, l);
380+
Bukkit.getPluginManager().callEvent(event);
381+
382+
if (!event.isCancelled()) {
383+
String id = ChatColor.stripColor(ChatColors.color(event.getName()))
384+
.toUpperCase(Locale.ROOT)
385+
.replace(' ', '_');
386+
387+
for (Waypoint wp : profile.getWaypoints()) {
388+
if (wp.getId().equals(id)) {
389+
Slimefun.getLocalization()
390+
.sendMessage(
391+
p,
392+
"gps.waypoint.duplicate",
393+
true,
394+
msg -> msg.replace("%waypoint%", event.getName()));
395+
return;
396+
}
397+
}
398+
399+
profile.addWaypoint(
400+
new Waypoint(p.getUniqueId(), id, event.getLocation(), event.getName()));
401+
402+
SoundEffect.GPS_NETWORK_ADD_WAYPOINT.playFor(p);
403+
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.added", true);
395404
}
396-
}
397-
398-
profile.addWaypoint(new Waypoint(p.getUniqueId(), id, event.getLocation(), event.getName()));
399-
400-
SoundEffect.GPS_NETWORK_ADD_WAYPOINT.playFor(p);
401-
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.added", true);
402-
}
403-
},p);
405+
},
406+
p);
404407
});
405408
}
406409

src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity)
133133
index++;
134134
}
135135

136-
Slimefun.runSyncAtEntity(() -> menu.open(p),p);
136+
Slimefun.runSyncAtEntity(() -> menu.open(p), p);
137137
});
138138
}
139139
}
@@ -240,7 +240,7 @@ private void updateProgress(
240240
source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F);
241241
SoundEffect.TELEPORT_UPDATE_SOUND.playFor(p);
242242
Slimefun.runSyncAtEntity(
243-
() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L,p);
243+
() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L, p);
244244
}
245245
} else {
246246
cancel(uuid, p);
@@ -253,27 +253,29 @@ private void onTeleport(Player p, Location destination, boolean success, boolean
253253
* This needs to run on the main Thread so we force it, as
254254
* the async teleportation might happen on a separate Thread.
255255
*/
256-
Slimefun.runSyncAtEntity(() -> {
257-
if (success) {
258-
// Apply Resistance Effect, if enabled
259-
if (resistance) {
260-
p.addPotionEffect(new PotionEffect(VersionedPotionEffectType.RESISTANCE, 600, 20));
261-
Slimefun.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
262-
}
256+
Slimefun.runSyncAtEntity(
257+
() -> {
258+
if (success) {
259+
// Apply Resistance Effect, if enabled
260+
if (resistance) {
261+
p.addPotionEffect(new PotionEffect(VersionedPotionEffectType.RESISTANCE, 600, 20));
262+
Slimefun.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
263+
}
263264

264-
// Spawn some particles for aesthetic reasons.
265-
Location loc = new Location(
266-
destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ());
267-
destination.getWorld().spawnParticle(Particle.PORTAL, loc, 200, 0.2F, 0.8F, 0.2F);
268-
SoundEffect.TELEPORT_SOUND.playFor(p);
269-
teleporterUsers.remove(p.getUniqueId());
270-
} else {
271-
/*
272-
* Make sure the Player is removed from the actively teleporting
273-
* users and notified about the failed teleportation
274-
*/
275-
cancel(p.getUniqueId(), p);
276-
}
277-
},p);
265+
// Spawn some particles for aesthetic reasons.
266+
Location loc = new Location(
267+
destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ());
268+
destination.getWorld().spawnParticle(Particle.PORTAL, loc, 200, 0.2F, 0.8F, 0.2F);
269+
SoundEffect.TELEPORT_SOUND.playFor(p);
270+
teleporterUsers.remove(p.getUniqueId());
271+
} else {
272+
/*
273+
* Make sure the Player is removed from the actively teleporting
274+
* users and notified about the failed teleportation
275+
*/
276+
cancel(p.getUniqueId(), p);
277+
}
278+
},
279+
p);
278280
}
279281
}

src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,16 @@ public void accept(PlayerProfile profile) {
6868
PLACEHOLDER, research.getName(p))
6969
.replace("%progress%", "0%"));
7070
},
71-
5L, p);
71+
5L,
72+
p);
7273
}
7374

7475
ResearchUnlockEvent event = new ResearchUnlockEvent(p, research);
7576
Bukkit.getPluginManager().callEvent(event);
7677

7778
if (!event.isCancelled()) {
7879
if (isInstant) {
79-
Slimefun.runSyncAtEntity(() -> unlockResearch(p, profile),p);
80+
Slimefun.runSyncAtEntity(() -> unlockResearch(p, profile), p);
8081
} else if (Slimefun.getRegistry()
8182
.getCurrentlyResearchingPlayers()
8283
.add(p.getUniqueId())) {
@@ -95,7 +96,8 @@ public void accept(PlayerProfile profile) {
9596
.getCurrentlyResearchingPlayers()
9697
.remove(p.getUniqueId());
9798
},
98-
(RESEARCH_PROGRESS.length + 1) * 20L, p);
99+
(RESEARCH_PROGRESS.length + 1) * 20L,
100+
p);
99101
}
100102
}
101103
}
@@ -114,7 +116,8 @@ private void sendUpdateMessage(@Nonnull Player p) {
114116
return msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", progress);
115117
});
116118
},
117-
i * 20L, p);
119+
i * 20L,
120+
p);
118121
}
119122
}
120123

src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ default void updateHologram(@Nonnull Block b, @Nonnull String text, Supplier<Boo
4545
return;
4646
}
4747

48-
Slimefun.runSyncAtLocation(() -> {
49-
if (abort.get()) {
50-
return;
51-
}
52-
updateHologram(b, text);
53-
},b.getLocation());
48+
Slimefun.runSyncAtLocation(
49+
() -> {
50+
if (abort.get()) {
51+
return;
52+
}
53+
updateHologram(b, text);
54+
},
55+
b.getLocation());
5456
}
5557

5658
/**

src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ClearDataCommand.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,15 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
5353
if (cleartype.equals("block")) {
5454
controller.removeAllDataInWorldAsync(
5555
world,
56-
() -> Slimefun.runSyncAtEntity(() -> Slimefun.getLocalization()
57-
.sendMessage(sender, "commands.cleardata.success", true, msg -> msg.replace(
58-
"{0}", world.getName())
59-
.replace("{1}", block)), Bukkit.getPlayer(sender.getName())));
56+
() -> Slimefun.runSyncAtEntity(
57+
() -> Slimefun.getLocalization()
58+
.sendMessage(
59+
sender,
60+
"commands.cleardata.success",
61+
true,
62+
msg -> msg.replace("{0}", world.getName())
63+
.replace("{1}", block)),
64+
Bukkit.getPlayer(sender.getName())));
6065
} else if (cleartype.equals("oil")) {
6166
GEOResource oilresource = null;
6267
for (GEOResource resource :
@@ -70,10 +75,15 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
7075
controller.removeFromAllChunkInWorldAsync(
7176
world,
7277
oilresource.getKey().toString().replace(":", "-"),
73-
() -> Slimefun.runSyncAtEntity(() -> Slimefun.getLocalization()
74-
.sendMessage(sender, "commands.cleardata.success", true, msg -> msg.replace(
75-
"{0}", world.getName())
76-
.replace("{1}", oil)),Bukkit.getPlayer(sender.getName())));
78+
() -> Slimefun.runSyncAtEntity(
79+
() -> Slimefun.getLocalization()
80+
.sendMessage(
81+
sender,
82+
"commands.cleardata.success",
83+
true,
84+
msg -> msg.replace("{0}", world.getName())
85+
.replace("{1}", oil)),
86+
Bukkit.getPlayer(sender.getName())));
7787
}
7888
}
7989
}

0 commit comments

Comments
 (0)