Skip to content

Commit

Permalink
v1.8.0 修改一些问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Sobadfish committed Sep 5, 2022
1 parent 21eaafd commit 1e9cfe7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 43 deletions.
24 changes: 2 additions & 22 deletions src/main/java/org/sobadfish/bedwar/manager/RandomJoinManager.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.sobadfish.bedwar.manager;

import cn.nukkit.Player;
import cn.nukkit.Server;
import org.sobadfish.bedwar.BedWarMain;
import org.sobadfish.bedwar.player.PlayerInfo;
import org.sobadfish.bedwar.room.GameRoom;

Expand Down Expand Up @@ -31,35 +29,19 @@ public static RandomJoinManager newInstance(){

public void nextJoin(PlayerInfo info){
//TODO 匹配下一局 程序分配
info.clear();
if(info.getGameRoom() != null){
info.getGameRoom().getPlayerInfos().remove(info);
}
info.setGameRoom(null);
BedWarMain.getRoomManager().playerJoin.remove(info.getName());
join(new PlayerInfo(info.getPlayer()),null,true);


// info.getGameRoom().quitPlayerInfo(info,true);
join(info,null);
}

public void join(PlayerInfo info, String name){
join(info, name,false);
}

public void join(PlayerInfo info, String name,boolean isNext){
if(info.getGameRoom() != null && info.getGameRoom().getType() != GameRoom.GameType.END){
return;
}
IPlayerInfo iPlayerInfo = new IPlayerInfo();
iPlayerInfo.playerInfo = info;
iPlayerInfo.isNext = isNext;
if(playerInfos.contains(iPlayerInfo)){
info.sendForceMessage("&c取消匹配");
playerInfos.remove(iPlayerInfo);
if(isNext){
info.getPlayer().teleport(Server.getInstance().getDefaultLevel().getSpawnLocation());
info.clear();
}
return;
}

Expand All @@ -80,8 +62,6 @@ public static class IPlayerInfo{

public Date time;

public boolean isNext;

public boolean cancel;

public PlayerInfo getPlayerInfo() {
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/sobadfish/bedwar/panel/items/TeamItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public void onClick(ChestInventoryPanel inventory, Player player) {
private void onLevelUp(PlayerInfo info) {
Player player = (Player) info.getPlayer();
int level = getTeamInfoLevel(info);

GameRoom room = info.getGameRoom();
if (level == effect.getMaxLevel() && effect.equals(new TeamTrap(1))) {
info.sendMessage("&c当前团队存在 &r" + getItem().getCustomName());
Expand All @@ -77,6 +78,7 @@ private void onLevelUp(PlayerInfo info) {
// player.getInventory()) > count * level){

// }
level++;
if (level == 0) {
level = 1;
}
Expand All @@ -89,10 +91,10 @@ private void onLevelUp(PlayerInfo info) {
}
if (room.getRoomConfig().isExp()) {
//由于扣除经验落后一个等级
u = info.reduceExp(count * (level + 1) * rc);
u = info.reduceExp(count * (level) * rc);
errorMessage = "经验不足";
} else {
u = ItemInfo.use(room.getRoomConfig().moneyItem.get(moneyItem), player.getInventory(), count * (level + 1));
u = ItemInfo.use(room.getRoomConfig().moneyItem.get(moneyItem), player.getInventory(), count * (level));
}

if (u) {
Expand Down
36 changes: 17 additions & 19 deletions src/main/java/org/sobadfish/bedwar/room/GameRoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,6 @@ private void onEnd(){
for(PlayerInfo playerInfo:getLivePlayers()){
Utils.spawnFirework(playerInfo.getPosition());
}
if(getRoomConfig().isAutomaticNextRound){
sendMessage("&7即将自动进行下一局");
for(PlayerInfo playerInfo: getInRoomPlayers()){
RandomJoinManager.joinManager.nextJoin(playerInfo);
}
}

if(loadTime == 0){
type = GameType.CLOSE;
Expand Down Expand Up @@ -726,7 +720,7 @@ private boolean isBreadBed(PlayerInfo info, Position position){
Block block = info1.getTeamConfig().getBedPosition().getLevelBlock();
if (block instanceof BlockBed) {
//TODO 判断一下床是否被保护的严实
if(isProtect((BlockBed) position)){
if(isProtect(position)){
info.sendMessage("&c这个床被方块包围,你至少要挖开一角");
return false;
}
Expand All @@ -747,12 +741,11 @@ private boolean isBreadBed(PlayerInfo info, Position position){
return false;
}

private boolean isProtect(BlockBed block) {
private boolean isProtect(Position block) {
List<Block> blocks = new ArrayList<>();
Block block2 = block.getSide(block.getBlockFace());

for(BlockFace fence: BlockFace.values()){
blocks.add(block.getSide(fence));
blocks.add(block2.getSide(fence));
blocks.add(block.getLevelBlock().getSide(fence));
}
for(Block block1: blocks){
if(block1.getId() == 0){
Expand Down Expand Up @@ -832,19 +825,24 @@ public void onDisable(){
Server.getInstance().getPluginManager().callEvent(event);
worldInfo.setClose(true);
//房间结束后的执行逻辑
//TODO 房间被关闭 释放一些资源
for (PlayerInfo info : playerInfos) {
info.clear();
if (info.getPlayer() instanceof Player) {
quitPlayerInfo(info, true);
if(getRoomConfig().isAutomaticNextRound){
sendMessage("&7即将自动进行下一局");
for(PlayerInfo playerInfo: getInRoomPlayers()){
RandomJoinManager.joinManager.nextJoin(playerInfo);
}
//没必要破坏床
}else {
//TODO 房间被关闭 释放一些资源
for (PlayerInfo info : playerInfos) {
info.clear();
if (info.getPlayer() instanceof Player) {
quitPlayerInfo(info, true);
}
//没必要破坏床
// if (info.getTeamInfo() != null) {
// info.getTeamInfo().breakBed();
// }
}
}


//浮空字释放
for(FloatTextInfo floatTextInfo: floatTextInfos){
floatTextInfo.bedWarFloatText.toClose();
Expand Down

0 comments on commit 1e9cfe7

Please sign in to comment.