Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
修复逃亡者雷达距离显示问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MossCG committed May 11, 2021
1 parent edc1e6a commit 37fd802
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.mcxk</groupId>
<artifactId>MineHunt</artifactId>
<version>2.1.3</version>
<version>2.1.4</version>
<packaging>jar</packaging>

<name>MineHunt</name>
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/net/mcxk/minehunt/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ public class Game {
@Getter
private boolean CompassUnlocked = plugin.getConfig().getBoolean("CompassUnlocked");


public Game() {
fixConfig();
}

public void switchCompass(boolean unlocked) {
if (this.CompassUnlocked == unlocked) {
return;
Expand Down Expand Up @@ -104,9 +99,6 @@ public boolean playerJoining(Player player) {
return false;
}

public void fixConfig() {
}

public void playerLeaving(Player player) {
if (status == GameStatus.WAITING_PLAYERS) {
this.inGamePlayers.remove(player);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.CompassMeta;
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/net/mcxk/minehunt/watcher/RadarWatcher.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.mcxk.minehunt.watcher;

import lombok.Getter;
import net.mcxk.minehunt.MineHunt;
import net.mcxk.minehunt.game.GameStatus;
import net.mcxk.minehunt.game.PlayerRole;
Expand All @@ -14,8 +15,8 @@

public class RadarWatcher {
private final MineHunt plugin = MineHunt.getInstance();
private final int warnDistance = 200;

@Getter
private final int warnDistance = plugin.getConfig().getInt("WarnDistance");
public RadarWatcher() {
new BukkitRunnable() {
@Override
Expand All @@ -33,13 +34,13 @@ public void run() {
if(runner.getGameMode() == GameMode.SPECTATOR){
continue;
}
double distance = hunter.getLocation().distanceSquared(runner.getLocation());
double distance = hunter.getLocation().distance(runner.getLocation());
TextComponent textComponent;
if (distance > warnDistance) {
textComponent = new TextComponent("200m 内未检测到任何猎人");
textComponent = new TextComponent(plugin.getConfig().getString("WarnDistanceSafe").replace("%wd", String.valueOf(warnDistance)));
textComponent.setColor(ChatColor.GREEN);
} else {
textComponent = new TextComponent("!!警告!! 猎人正在靠近!(距离:%dm)".replace("%d", String.valueOf((int) distance)));
textComponent = new TextComponent(plugin.getConfig().getString("WarnDistanceClose").replace("%d", String.valueOf((int) distance)));
textComponent.setColor(ChatColor.RED);
}
runner.spigot().sendMessage(ChatMessageType.ACTION_BAR, textComponent);
Expand Down
10 changes: 10 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ XRandom: 10
YBasic: 5
YRandom: 10

#逃亡者警告距离
#好气哦我看了半天发现原作者把distance写成了distanceSquared
#也就是原本的是距离xyz的平方和,已修复为正常的距离(应该没问题了)
#建议合理调整方便猎人生存
WarnDistance: 50

#逃亡者警告消息(%wd是警告距离就是上面那个,%d是当前距离)
WarnDistanceSafe: "%wdM 内未检测到猎人"
WarnDistanceClose: "警告! 猎人正在靠近!当前距离:%dM"

#服务器名称(实际上也就结束统计的时候显示一下)
ServerName: "MossMC"

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: MineHunt
version: 2.1.3
version: 2.1.4
main: net.mcxk.minehunt.MineHunt
api-version: 1.16
soft-depend: [ NoteBlockAPI, AdvancedReplay ]
Expand Down

0 comments on commit 37fd802

Please sign in to comment.