优化datapackSync写法
This commit is contained in:
parent
8c701b0bbb
commit
10574f0e4d
1 changed files with 2 additions and 9 deletions
|
@ -23,7 +23,6 @@ import javax.annotation.Nullable;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
@EventBusSubscriber(modid = Mod.MODID)
|
@EventBusSubscriber(modid = Mod.MODID)
|
||||||
public class GunsTool {
|
public class GunsTool {
|
||||||
|
@ -70,15 +69,9 @@ public class GunsTool {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public static void datapackSync(OnDatapackSyncEvent event) {
|
public static void datapackSync(OnDatapackSyncEvent event) {
|
||||||
AtomicInteger count = new AtomicInteger();
|
initJsonData(event.getPlayerList().getServer().getResourceManager());
|
||||||
event.getRelevantPlayers().forEach(player -> {
|
|
||||||
if (count.get() == 0 && player.getServer() != null) {
|
|
||||||
initJsonData(player.getServer().getResourceManager());
|
|
||||||
}
|
|
||||||
count.getAndIncrement();
|
|
||||||
|
|
||||||
PacketDistributor.sendToPlayer(player, new GunsDataMessage(GunsTool.gunsData));
|
event.getRelevantPlayers().forEach(player -> PacketDistributor.sendToPlayer(player, new GunsDataMessage(GunsTool.gunsData)));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reload(Player player, ItemStack stack, GunData gunData, AmmoType type) {
|
public static void reload(Player player, ItemStack stack, GunData gunData, AmmoType type) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue