Skip to content

Commit

Permalink
Fixed more bugs with bedwars
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Apr 4, 2024
1 parent 2566fec commit acbee4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/main/java/me/lrxh/practice/match/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ public void respawn(UUID playerUUID) {
player.updateInventory();
player.setHealth(player.getMaxHealth());
player.setFoodLevel(20);
player.setGameMode(GameMode.ADVENTURE);

player.setVelocity(player.getVelocity().add(new Vector(0, 0.25, 0)));
player.setAllowFlight(true);
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/me/lrxh/practice/match/MatchListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,23 @@ public void onBlockPlaceEvent(BlockPlaceEvent event) {
} else {
event.setCancelled(true);
}
if(match.getGamePlayer(event.getPlayer()).isRespawned()){
event.setCancelled(true);
}
} else {
if (!event.getPlayer().isOp() || event.getPlayer().getGameMode() != GameMode.CREATIVE) {
event.setCancelled(true);
}
}
}

@EventHandler
public void onFallDamageEvent(EntityDamageEvent event) {
if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
event.setCancelled(true);
}
}

@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockBreakEvent(BlockBreakEvent event) {
Profile profile = Profile.getByUuid(event.getPlayer().getUniqueId());
Expand Down Expand Up @@ -171,6 +181,9 @@ public void onBlockBreakEvent(BlockBreakEvent event) {
if (match.kit.getGameRules().isBedwars() && (event.getBlock().getType().equals(Material.BED_BLOCK) || event.getBlock().getType().equals(Material.BED)) || event.getBlock().getType().equals(Material.ENDER_STONE) || (event.getBlock().getType().equals(Material.WOOD) && event.getBlock().getData() == 0)) {
event.setCancelled(false);
}
if(match.getGamePlayer(event.getPlayer()).isRespawned()){
event.setCancelled(true);
}
} else {
if (!event.getPlayer().isOp() || event.getPlayer().getGameMode() != GameMode.CREATIVE) {
event.setCancelled(true);
Expand Down Expand Up @@ -448,6 +461,7 @@ public void onHungerChange(FoodLevelChangeEvent event) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (!profile.getState().equals(ProfileState.FIGHTING)) return;
if (profile.getMatch().getKit().getGameRules().isSumo()
|| profile.getMatch().getKit().getGameRules().isBedwars()
|| profile.getMatch().getKit().getGameRules().isSpleef()
|| profile.getMatch().getKit().getGameRules().isBoxing()) {
event.setCancelled(true);
Expand Down Expand Up @@ -525,6 +539,9 @@ public void onEntityDamageByEntityLow(EntityDamageByEntityEvent event) {
StringEscapeUtils.unescapeJava("❤")
));
}
if(match.getGamePlayer(attacker).isRespawned()){
event.setCancelled(true);
}
}
}
}
Expand Down

0 comments on commit acbee4e

Please sign in to comment.