Fix games not marked as started

This commit is contained in:
Daniel Saukel 2016-08-24 16:17:28 +02:00
parent ff7e8dbf5f
commit cf557a61e2
2 changed files with 39 additions and 33 deletions

View File

@ -170,52 +170,56 @@ public class EntityListener implements Listener {
DGroup attackerDGroup = null; DGroup attackerDGroup = null;
DGroup attackedDGroup = null; DGroup attackedDGroup = null;
if (attackerEntity instanceof LivingEntity && attackedEntity instanceof LivingEntity) { if (!(attackerEntity instanceof LivingEntity) || !(attackedEntity instanceof LivingEntity)) {
if (attackerEntity instanceof Player && attackedEntity instanceof Player) { return;
attackerPlayer = (Player) attackerEntity; }
attackedPlayer = (Player) attackedEntity;
attackerDGroup = DGroup.getByPlayer(attackerPlayer); if (attackerEntity instanceof Player && attackedEntity instanceof Player) {
attackedDGroup = DGroup.getByPlayer(attackedPlayer); attackerPlayer = (Player) attackerEntity;
attackedPlayer = (Player) attackedEntity;
if (!pvp) { attackerDGroup = DGroup.getByPlayer(attackerPlayer);
attackedDGroup = DGroup.getByPlayer(attackedPlayer);
if (!pvp) {
event.setCancelled(true);
return;
}
if (attackerDGroup != null && attackedDGroup != null) {
if (!friendlyFire && attackerDGroup.equals(attackedDGroup)) {
event.setCancelled(true); event.setCancelled(true);
} return;
if (attackerDGroup != null && attackedDGroup != null) {
if (!friendlyFire && attackerDGroup.equals(attackedDGroup)) {
event.setCancelled(true);
}
}
}
// Check Dogs
if (attackerEntity instanceof Player || attackedEntity instanceof Player) {
for (DGamePlayer dPlayer : DGamePlayer.getByWorld(gameWorld.getWorld())) {
if (dPlayer.getWolf() != null) {
if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) {
event.setCancelled(true);
return;
}
}
} }
} }
}
// Check Dogs
if (attackerEntity instanceof Player || attackedEntity instanceof Player) {
for (DGamePlayer dPlayer : DGamePlayer.getByWorld(gameWorld.getWorld())) { for (DGamePlayer dPlayer : DGamePlayer.getByWorld(gameWorld.getWorld())) {
if (dPlayer.getWolf() != null) { if (dPlayer.getWolf() != null) {
if (attackerEntity instanceof Player || attackedEntity instanceof Player) { if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) {
if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) { event.setCancelled(true);
event.setCancelled(true);
return;
}
} else if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) {
event.setCancelled(false);
return; return;
} }
} }
} }
} }
for (DGamePlayer dPlayer : DGamePlayer.getByWorld(gameWorld.getWorld())) {
if (dPlayer.getWolf() != null) {
if (attackerEntity instanceof Player || attackedEntity instanceof Player) {
if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) {
event.setCancelled(true);
return;
}
} else if (attackerEntity == dPlayer.getWolf() || attackedEntity == dPlayer.getWolf()) {
event.setCancelled(false);
return;
}
}
}
} }
// Deny food in Lobby // Deny food in Lobby

View File

@ -698,6 +698,8 @@ public class DGamePlayer extends DInstancePlayer {
respawn(); respawn();
} }
} }
game.setStarted(true);
} }
public void respawn() { public void respawn() {