diff --git a/lib/NsGameBase_FakeLib.jar b/lib/NsGameBase_FakeLib.jar
new file mode 100644
index 0000000..0bbb377
Binary files /dev/null and b/lib/NsGameBase_FakeLib.jar differ
diff --git a/pom.xml b/pom.xml
index e8d002b..3dd839d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,8 +20,8 @@
UTF-8
UTF-8
- 1.8
- 1.8
+ 17
+ 17
UTF-8
@@ -140,43 +140,56 @@
repo-lanink-cn
https://repo.lanink.cn/
+
+ maven_central
+ Maven Central
+ https://repo.maven.apache.org/maven2/
+
org.jetbrains
annotations
- 24.0.1
+ 24.1.0
provided
org.projectlombok
lombok
- 1.18.26
+ 1.18.34
provided
cn.nukkit
- nukkit
- 1.0-SNAPSHOT
+ Nukkit
+ MOT-SNAPSHOT
provided
cn.lanink
MemoriesOfTime-GameCore
- 1.6.11
+ 1.6.13-PM1E
provided
com.smallaswater
RsNPC
- 2.3.1
+ 2.4.4
provided
+
+
+ NsGameBase
+ NsGameBase
+ 1.0.0
+ system
+ ${project.basedir}/lib/NsGameBase_FakeLib.jar
+
diff --git a/src/main/java/cn/lanink/huntgame/HuntGame.java b/src/main/java/cn/lanink/huntgame/HuntGame.java
index a4aff94..464ffd1 100644
--- a/src/main/java/cn/lanink/huntgame/HuntGame.java
+++ b/src/main/java/cn/lanink/huntgame/HuntGame.java
@@ -17,12 +17,10 @@
import cn.lanink.huntgame.room.IntegralConfig;
import cn.lanink.huntgame.room.animal.AnimalModeRoom;
import cn.lanink.huntgame.room.block.BlockModeRoom;
-import cn.lanink.huntgame.utils.GameCoreDownload;
import cn.lanink.huntgame.utils.MetricsLite;
import cn.lanink.huntgame.utils.RsNpcXVariable;
import cn.lanink.huntgame.utils.update.ConfigUpdateUtils;
import cn.nukkit.Player;
-import cn.nukkit.Server;
import cn.nukkit.entity.data.Skin;
import cn.nukkit.level.Level;
import cn.nukkit.plugin.PluginBase;
@@ -81,6 +79,11 @@ public class HuntGame extends PluginBase {
private final HashMap> rewardCmd = new HashMap<>(); // 积分下限 => 命令列表
private boolean hasTips = false;
+ @Getter
+ private boolean hasNsGB = false;
+
+ private final HashMap> fapRewardIntegral = new HashMap<>();
+ private Integer[] fapRewardBound;
public static HuntGame getInstance() {
return huntGame;
@@ -98,7 +101,7 @@ public void onEnable() {
this.getLogger().info("§l§eVersion: " + this.getVersion());
//检查依赖
- switch (GameCoreDownload.checkAndDownload()) {
+ /*switch (GameCoreDownload.checkAndDownload()) {
case 1:
Server.getInstance().getPluginManager().disablePlugin(this);
return;
@@ -107,7 +110,7 @@ public void onEnable() {
this.getLogger().warning(this.getLanguage().translateString("MemoriesOfTime-GameCore Dependency download complete! It is strongly recommended to restart the server to ensure proper loading!"))
);
break;
- }
+ }*/
this.saveDefaultConfig();
this.config = new Config(this.getDataFolder() + "/config.yml", Config.YAML);
@@ -151,6 +154,14 @@ public void onEnable() {
this.hasTips = true;
} catch (Exception ignored) {
+ }
+ //检查FAP基础插件
+ try {
+ Class.forName("cn.nsgamebase.NsGameBaseMain");
+ ConfigUpdateUtils.checkFapNsGB(this);
+ this.hasNsGB = true;
+ } catch (Exception ignored) {
+
}
this.cmdUser = this.config.getString("cmdUser", "HuntGame").toLowerCase();
@@ -178,6 +189,21 @@ public void onEnable() {
this.rewardBound = this.rewardCmd.keySet().toArray(new Integer[0]);
Arrays.sort(this.rewardBound);
+ if (this.hasNsGB) {
+ Map fapRewardIntegral = this.config.getSection("fapRewardIntegral").getAllMap();
+ for (Map.Entry entry : fapRewardIntegral.entrySet()) {
+ try {
+ int bound = Integer.parseInt(entry.getKey());
+ this.fapRewardIntegral.put(bound, (Map) entry.getValue());
+ } catch (NumberFormatException ignored) {
+ this.getLogger().info("§c Parsing 'fapRewardIntegral' failed!, invalid key '" + entry.getKey() + "' skip it.");
+ } catch (ClassCastException ignored) {
+ this.getLogger().info("§c Parsing 'fapRewardIntegral' failed!, invalid value '" + entry.getValue() + "' skip it.");
+ }
+ }
+ this.fapRewardBound = this.fapRewardIntegral.keySet().toArray(new Integer[0]);
+ }
+
this.getServer().getCommandMap().register("", new UserCommand(this.cmdUser));
this.getServer().getCommandMap().register("", new AdminCommand(this.cmdAdmin));
@@ -338,6 +364,20 @@ public String getCmdAdmin() {
return this.cmdAdmin;
}
+ public Map getfapReward(int points) {
+ if (!this.hasNsGB) {
+ return null;
+ }
+ int idx = Arrays.binarySearch(this.fapRewardBound, points);
+ int bound;
+ if (idx >= 0) {
+ bound = this.fapRewardBound[idx];
+ } else {
+ bound = this.fapRewardBound[-idx - 2];
+ }
+ return this.fapRewardIntegral.get(bound);
+ }
+
public IScoreboard getScoreboard() {
return this.scoreboard;
}
diff --git a/src/main/java/cn/lanink/huntgame/entity/EntityCamouflageBlock.java b/src/main/java/cn/lanink/huntgame/entity/EntityCamouflageBlock.java
index e745c83..e2a7761 100644
--- a/src/main/java/cn/lanink/huntgame/entity/EntityCamouflageBlock.java
+++ b/src/main/java/cn/lanink/huntgame/entity/EntityCamouflageBlock.java
@@ -1,5 +1,6 @@
package cn.lanink.huntgame.entity;
+import cn.lanink.gamecore.utils.NukkitTypeUtils;
import cn.lanink.huntgame.room.block.BlockInfo;
import cn.nukkit.Player;
import cn.nukkit.entity.EntityCreature;
@@ -57,7 +58,13 @@ public EntityCamouflageBlock(FullChunk chunk, CompoundTag nbt, @NonNull Player m
public void setBlockInfo(@NonNull BlockInfo blockInfo) {
this.blockInfo = blockInfo;
- this.setDataProperty(new IntEntityData(DATA_VARIANT, GlobalBlockPalette.getOrCreateRuntimeId(this.blockInfo.getId(), this.blockInfo.getDamage())));
+ int runtimeId = 0;
+ if (NukkitTypeUtils.getNukkitType() == NukkitTypeUtils.NukkitType.MOT) {
+ runtimeId = GlobalBlockPalette.getOrCreateRuntimeId(this.getMaster().protocol, this.blockInfo.getId(), this.blockInfo.getDamage());
+ } else {
+ runtimeId = GlobalBlockPalette.getOrCreateRuntimeId(this.blockInfo.getId(), this.blockInfo.getDamage());
+ }
+ this.setDataProperty(new IntEntityData(DATA_VARIANT, runtimeId));
this.respawnToAll();
}
diff --git a/src/main/java/cn/lanink/huntgame/entity/EntityCamouflageBlockDamage.java b/src/main/java/cn/lanink/huntgame/entity/EntityCamouflageBlockDamage.java
index 00b056b..da4ca33 100644
--- a/src/main/java/cn/lanink/huntgame/entity/EntityCamouflageBlockDamage.java
+++ b/src/main/java/cn/lanink/huntgame/entity/EntityCamouflageBlockDamage.java
@@ -6,10 +6,10 @@
import cn.nukkit.entity.data.Skin;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.nbt.tag.CompoundTag;
-import cn.nukkit.utils.SerializedImage;
import lombok.Getter;
import lombok.Setter;
+import java.util.Base64;
import java.util.HashSet;
/**
@@ -22,8 +22,8 @@ public class EntityCamouflageBlockDamage extends EntityHuman implements IEntityC
public static final Skin EMPTY_SKIN = new Skin();
static {
- EMPTY_SKIN.setSkinData(SerializedImage.fromLegacy(new byte[Skin.DOUBLE_SKIN_SIZE]));
- EMPTY_SKIN.generateSkinId("EntityCamouflageBlock");
+ EMPTY_SKIN.setSkinId("Standard_Custom");
+ EMPTY_SKIN.setSkinData(Base64.getDecoder().decode(Skin.STEVE_SKIN));
}
@Setter
diff --git a/src/main/java/cn/lanink/huntgame/listener/defaults/DefaultGameListener.java b/src/main/java/cn/lanink/huntgame/listener/defaults/DefaultGameListener.java
index 757f771..361f8e8 100644
--- a/src/main/java/cn/lanink/huntgame/listener/defaults/DefaultGameListener.java
+++ b/src/main/java/cn/lanink/huntgame/listener/defaults/DefaultGameListener.java
@@ -9,13 +9,11 @@
import cn.nukkit.Server;
import cn.nukkit.block.Block;
import cn.nukkit.entity.Entity;
+import cn.nukkit.entity.item.EntityFirework;
import cn.nukkit.entity.weather.EntityLightning;
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.EventPriority;
-import cn.nukkit.event.entity.EntityDamageByChildEntityEvent;
-import cn.nukkit.event.entity.EntityDamageEvent;
-import cn.nukkit.event.entity.EntityShootBowEvent;
-import cn.nukkit.event.entity.ProjectileLaunchEvent;
+import cn.nukkit.event.entity.*;
import cn.nukkit.event.inventory.InventoryClickEvent;
import cn.nukkit.event.player.*;
import cn.nukkit.inventory.PlayerInventory;
@@ -37,6 +35,19 @@ public class DefaultGameListener extends BaseGameListener {
private final HuntGame huntGame = HuntGame.getInstance();
+ @EventHandler
+ public void onEntityExplosionPrime(EntityExplosionPrimeEvent event) {
+ /*
+ 禁止HuntGame烟花爆炸伤害
+ */
+ if (event.getEntity() instanceof EntityFirework) {
+ Entity entity = event.getEntity();
+ if (entity.namedTag != null && entity.namedTag.getBoolean("IsHuntGameFirework")) {
+ event.setCancelled();
+ }
+ }
+ }
+
@EventHandler
public void onPlayerChangeSkin(PlayerChangeSkinEvent event) { //此事件仅玩家主动修改皮肤时触发,不需要针对插件修改特判
Player player = event.getPlayer();
diff --git a/src/main/java/cn/lanink/huntgame/room/BaseRoom.java b/src/main/java/cn/lanink/huntgame/room/BaseRoom.java
index 2158190..a98e24f 100644
--- a/src/main/java/cn/lanink/huntgame/room/BaseRoom.java
+++ b/src/main/java/cn/lanink/huntgame/room/BaseRoom.java
@@ -9,6 +9,8 @@
import cn.lanink.huntgame.tasks.WaitTask;
import cn.lanink.huntgame.tasks.game.TimeTask;
import cn.lanink.huntgame.utils.Tools;
+import cn.lanink.huntgame.utils.nsgb.HuntGameDataGamePlayerPojo;
+import cn.nsgamebase.api.GbGameApi;
import cn.nukkit.AdventureSettings;
import cn.nukkit.Player;
import cn.nukkit.Server;
@@ -321,10 +323,30 @@ public synchronized void endGame(PlayerIdentity victory) {
victoryPlayers.forEach((player, points) -> {
Tools.executeCommands(player, huntGame.getVictoryCmd());
Tools.executeCommands(player, huntGame.getRewardCmd(points));
+ if (this.huntGame.isHasNsGB()) {
+ Map integerMap = this.huntGame.getfapReward(points);
+ HuntGameDataGamePlayerPojo pojo = new HuntGameDataGamePlayerPojo();
+ pojo.add("played");
+ int money = integerMap.get("money");
+ int point = integerMap.get("point");
+ int exp = integerMap.get("exp");
+ int maxMultiplier = integerMap.get("maxMultiplier");
+ GbGameApi.saveAndReward(player.getName(), "HuntGame", pojo, money, exp, maxMultiplier);
+ }
});
defeatPlayers.forEach((player, points) -> {
Tools.executeCommands(player, huntGame.getDefeatCmd());
Tools.executeCommands(player, huntGame.getRewardCmd(points));
+ if (this.huntGame.isHasNsGB()) {
+ Map integerMap = this.huntGame.getfapReward(points);
+ HuntGameDataGamePlayerPojo pojo = new HuntGameDataGamePlayerPojo();
+ pojo.add("played");
+ int money = integerMap.get("money");
+ int point = integerMap.get("point");
+ int exp = integerMap.get("exp");
+ int maxMultiplier = integerMap.get("maxMultiplier");
+ GbGameApi.saveAndReward(player.getName(), "HuntGame", pojo, money, exp, maxMultiplier);
+ }
});
}, 1);
}
diff --git a/src/main/java/cn/lanink/huntgame/utils/Tools.java b/src/main/java/cn/lanink/huntgame/utils/Tools.java
index 25f14c4..0623338 100644
--- a/src/main/java/cn/lanink/huntgame/utils/Tools.java
+++ b/src/main/java/cn/lanink/huntgame/utils/Tools.java
@@ -376,6 +376,7 @@ public static void spawnFirework(Position position) {
.putList(new ListTag("Explosions").add(ex)).putByte("Flight",1));
item.setNamedTag(tag);
CompoundTag nbt = new CompoundTag();
+ nbt.putBoolean("IsHuntGameFirework", true);
nbt.putList(new ListTag("Pos")
.add(new DoubleTag("",position.x+0.5D))
.add(new DoubleTag("",position.y+0.5D))
diff --git a/src/main/java/cn/lanink/huntgame/utils/nsgb/HuntGameDataGamePlayerPojo.java b/src/main/java/cn/lanink/huntgame/utils/nsgb/HuntGameDataGamePlayerPojo.java
new file mode 100644
index 0000000..cc80101
--- /dev/null
+++ b/src/main/java/cn/lanink/huntgame/utils/nsgb/HuntGameDataGamePlayerPojo.java
@@ -0,0 +1,10 @@
+package cn.lanink.huntgame.utils.nsgb;
+
+import cn.nsgamebase.entity.pojo.AbstractDataGamePlayerPojo;
+
+/**
+ * @author LT_Name
+ */
+public class HuntGameDataGamePlayerPojo extends AbstractDataGamePlayerPojo {
+
+}
diff --git a/src/main/java/cn/lanink/huntgame/utils/update/ConfigUpdateUtils.java b/src/main/java/cn/lanink/huntgame/utils/update/ConfigUpdateUtils.java
index af59a79..56c4490 100644
--- a/src/main/java/cn/lanink/huntgame/utils/update/ConfigUpdateUtils.java
+++ b/src/main/java/cn/lanink/huntgame/utils/update/ConfigUpdateUtils.java
@@ -96,4 +96,42 @@ private static void update1_X_X_To_1_2_2() {
config.save();
}
+ // 需要在NsGB加载后检查,放到onEnable里
+ public static void checkFapNsGB(HuntGame huntGame) {
+ try {
+ Class.forName("cn.nsgamebase.NsGameBaseMain");
+
+ Config config = getConfig();
+
+ LinkedHashMap fapRewardIntegral = new LinkedHashMap<>();
+
+ LinkedHashMap map1 = new LinkedHashMap<>();
+ map1.put("money", 10);
+ map1.put("point", 0);
+ map1.put("exp", 10);
+ map1.put("maxMultiplier", 1);
+
+ LinkedHashMap map2 = new LinkedHashMap<>();
+ map2.put("money", 100);
+ map2.put("point", 0);
+ map2.put("exp", 100);
+ map2.put("maxMultiplier", 1);
+
+ fapRewardIntegral.put("0", map1);
+ fapRewardIntegral.put("60", map2);
+
+ boolean needSave = false;
+ if (!config.exists("fapRewardIntegral")) {
+ config.set("fapRewardIntegral", fapRewardIntegral);
+ needSave = true;
+ }
+
+ if (needSave) {
+ config.save();
+ }
+ } catch (Exception ignored) {
+
+ }
+ }
+
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 2bfd0ca..1fa722a 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: HuntGame
main: cn.lanink.huntgame.HuntGame
-version: "1.3.1"
+version: "1.3.2-SNAPSHOT"
api: ["1.0.9"]
load: POSTWORLD
author: "LT_Name"