Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuihui1022 committed Aug 5, 2023
1 parent 28dde2e commit 627ed32
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void onEnable() {
Objects.requireNonNull(getCommand("clearbossbar")).setExecutor(new ClearBossbar());
Objects.requireNonNull(getCommand("checkshenquan")).setExecutor(new CheckShenQuan());
Objects.requireNonNull(getCommand("leaveteam")).setExecutor(new LeaveTeam());

getServer().getPluginManager().registerEvents(new onPlayerDeath(), this);
getServer().getPluginManager().registerEvents(new onCommandExecute(), this);
getServer().getPluginManager().registerEvents(new onPlayerQuit(), this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class ShowBossBar {
public BossBar BlueBossBar = null;

public void createBossBar(){
// PlayerUtils.send(teamExecuter.getRedPlayer(), "#AQUA#check if it is null:" + HighVersionQWQ.instance);
Player RedPlayer = teamExecuter.getRedPlayer();
Player BluePlayer = teamExecuter.getBluePlayer();
RedBossBar = Bukkit.createBossBar(RedPlayer.getName(), BarColor.RED, BarStyle.SEGMENTED_6);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
int countRed = checkPlayer(teamExecuter.getRedPlayer());
int countBlue = checkPlayer(teamExecuter.getBluePlayer());
if (countRed != 0){
ChatUtils.broadcast("#AQUA#经由玩家: %s 检测,#RED#红队#AQUA#玩家: %s 涉嫌作弊,犯下了 %d 项罪行,现给予处罚。"
, commandSender, teamExecuter.getRedPlayer(), countRed);
ChatUtils.broadcast("#AQUA#经由玩家: %s 检测,#RED#神权红队#AQUA#玩家: %s 涉嫌Bypass本插件,犯下了 %d 项罪行,现给予处罚。"
, commandSender.getName(), teamExecuter.getRedPlayer().getName(), countRed);
teamExecuter.getRedPlayer().setHealth(0.5);
teamExecuter.getRedPlayer().setFoodLevel(0);
teamExecuter.getRedPlayer().teleport(teamExecuter.getBluePlayer());
}
if (countBlue != 0){
ChatUtils.broadcast("#AQUA#经由玩家: %s 检测,#BLUE#蓝队#AQUA#玩家: %s 涉嫌作弊,犯下了 %d 项罪行,现给予处罚。"
, commandSender, teamExecuter.getBluePlayer(), countBlue);
ChatUtils.broadcast("#AQUA#经由玩家: %s 检测,#BLUE#神权蓝队#AQUA#玩家: %s 涉嫌Bypass本插件,犯下了 %d 项罪行,现给予处罚。"
, commandSender.getName(), teamExecuter.getBluePlayer().getName(), countBlue);
teamExecuter.getBluePlayer().setHealth(0.5);
teamExecuter.getBluePlayer().setFoodLevel(0);
teamExecuter.getBluePlayer().teleport(teamExecuter.getRedPlayer());
}
if (countRed == 0 && countBlue == 0){

}
}
return true;
}
Expand All @@ -43,13 +48,15 @@ public int checkPlayer(Player player){
count++;
player.getVehicle().removePassenger(player);
}
if (player.getWalkSpeed() != 1.0){
if (player.getWalkSpeed() != 0.2F){
System.out.println(player.getWalkSpeed() + " != " + 0.2F);
count++;
player.setWalkSpeed(1.0F);
player.setWalkSpeed(0.2F);
}
if (player.getFlySpeed() != 1.0){
if (player.getFlySpeed() != 0.1F){
System.out.println(player.getFlySpeed() + " != " + 0.1F);
count++;
player.setFlySpeed(1.0F);
player.setFlySpeed(0.1F);
}
if (player.getGameMode() != GameMode.SURVIVAL){
count++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ else if (teamExecuter.getBluePlayer() != null && teamExecuter.getBluePlayer().eq
return true;
}
// 不同玩家加入,但游戏未开始
else if (teamExecuter.getRedPlayer() != null && !HighVersionQWQ.GameStart){
else if (teamExecuter.getBluePlayer() != null && !HighVersionQWQ.GameStart){
ChatUtils.broadcast("#BLUE#检测到有两个玩家试图加入蓝队,已清除原先的蓝队玩家,现在的蓝队玩家是:%s", onJoinTeamPlayer.getName());
teamExecuter.removeRedPlayer();
}
// 不同玩家加入同一支队伍,但游戏已开始
else if (teamExecuter.getRedPlayer() != null && HighVersionQWQ.GameStart){
else if (teamExecuter.getBluePlayer() != null && HighVersionQWQ.GameStart){
ChatUtils.broadcast("#BLUE#有一个玩家试图在游戏开始后加入队伍,已拒绝ta的请求,该玩家ID为:#AQUA#%s", onJoinTeamPlayer.getName());
teamExecuter.showAllTeamMember();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class LeaveTeam implements CommandExecutor {

@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (strings[1].contains("@")){
if (strings.length != 0 && strings[0].contains("@")){
List<Entity> selectEntities = Bukkit.selectEntities(commandSender, strings[1]);
// 判断格式
if (selectEntities.toArray().length != 1){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.server.ServerCommandEvent;
import top.mpt.huihui.highversionqwq.utils.ChatUtils;
import top.mpt.huihui.highversionqwq.utils.PlayerUtils;

import static top.mpt.huihui.highversionqwq.HighVersionQWQ.*;

Expand All @@ -30,4 +30,17 @@ public void onPlayerExecuteCommand(PlayerCommandPreprocessEvent event){
}
}
}
@EventHandler
public void onServerExecuteCommand(ServerCommandEvent event){
if (GameStart){
if (event.getCommand().contains("@") || event.getCommand().contains("*") ||
event.getCommand().contains("**") ||
event.getCommand().contains(teamExecuter.getBluePlayer().getName()) ||
event.getCommand().contains(teamExecuter.getRedPlayer().getName())
){
event.getSender().sendMessage("请求被驳回,不允许场外助攻场内玩家!");
event.setCancelled(true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ public void onPlayerQuitEvent(PlayerQuitEvent event){
Player player = event.getPlayer();
if(!GameStart){
if (teamExecuter.getRedPlayer() != null && teamExecuter.getRedPlayer().equals(player)){
ChatUtils.broadcast("#RED#红队#AQUA#玩家: %s 在比赛开始前陶艺了,已取消其比赛资格。");
ChatUtils.broadcast("#RED#红队#AQUA#玩家: %s 在比赛开始前陶艺了,已取消其比赛资格。"
, player.getName());
teamExecuter.removeRedPlayer();
event.setQuitMessage("陶艺小子LLL");
}
if (teamExecuter.getBluePlayer() != null && teamExecuter.getBluePlayer().equals(player)){
ChatUtils.broadcast("#BLUE#蓝队#AQUA#玩家: %s 在比赛开始前陶艺了,已取消其比赛资格。");
ChatUtils.broadcast("#BLUE#蓝队#AQUA#玩家: %s 在比赛开始前陶艺了,已取消其比赛资格。"
, player.getName());
teamExecuter.removeBluePlayer();
event.setQuitMessage("陶艺小子LLL");
}
}
else {
if (teamExecuter.getRedPlayer().equals(player)){
ChatUtils.broadcast("#RED#红队#AQUA#玩家: %s 在比赛开始后陶艺了,比赛被迫结束。");
ChatUtils.broadcast("#RED#红队#AQUA#玩家: %s 在比赛开始后陶艺了,比赛被迫结束。"
, player.getName());
teamExecuter.removeRedPlayer();
teamExecuter.removeBluePlayer();
event.setQuitMessage("陶艺小子LLL");
}
if (teamExecuter.getBluePlayer().equals(player)){
ChatUtils.broadcast("#BLUE#蓝队#AQUA#玩家: %s 在比赛开始后陶艺了,比赛被迫结束。");
ChatUtils.broadcast("#BLUE#蓝队#AQUA#玩家: %s 在比赛开始后陶艺了,比赛被迫结束。"
, player.getName());
teamExecuter.removeRedPlayer();
teamExecuter.removeBluePlayer();
event.setQuitMessage("陶艺小子LLL");
}
}
}
Expand Down

0 comments on commit 627ed32

Please sign in to comment.