Archiviert
13
0

Fixin' the problem of AFK people not in bed.

Dieser Commit ist enthalten in:
sk89q 2011-04-11 11:48:31 -07:00
Ursprung 2685de187a
Commit 86c467cb50
3 geänderte Dateien mit 35 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -37,6 +37,7 @@ public abstract class EntityHuman extends EntityLiving {
public double y; public double y;
// CraftBukkit start // CraftBukkit start
public boolean sleeping; public boolean sleeping;
public boolean fauxSleeping;
// CraftBukkit end // CraftBukkit end
private ChunkCoordinates b; private ChunkCoordinates b;
// CraftBukkit start // CraftBukkit start

Datei anzeigen

@ -1808,13 +1808,25 @@ public class World implements IBlockAccess {
while (iterator.hasNext()) { while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next(); EntityHuman entityhuman = (EntityHuman) iterator.next();
if (!entityhuman.F()) { // CraftBukkit start
if (!entityhuman.F() && !entityhuman.fauxSleeping) {
// CraftBukkit end
this.A = false; this.A = false;
break; break;
} }
} }
} }
// CraftBukkit start
// Calls the method that checks to see if players are sleeping
// Called by CraftPlayer.setPermanentSleeping()
public void checkSleepStatus() {
if (!isStatic) {
q();
}
}
// CraftBukkit end
protected void r() { protected void r() {
this.A = false; this.A = false;
Iterator iterator = this.d.iterator(); Iterator iterator = this.d.iterator();
@ -1831,16 +1843,26 @@ public class World implements IBlockAccess {
public boolean s() { public boolean s() {
if (this.A && !this.isStatic) { if (this.A && !this.isStatic) {
Iterator iterator = this.d.iterator(); Iterator iterator = this.d.iterator();
// CraftBukkit start
boolean foundActualSleepers = false;
// This allows us to assume that some people are in bed
// but not really, allowing time to pass in spite of AFKers
EntityHuman entityhuman; EntityHuman entityhuman;
do { do {
if (!iterator.hasNext()) { if (!iterator.hasNext()) {
return true; return foundActualSleepers;
} }
entityhuman = (EntityHuman) iterator.next(); entityhuman = (EntityHuman) iterator.next();
} while (entityhuman.G()); if (entityhuman.G()) {
foundActualSleepers = true;
}
} while (entityhuman.G() || entityhuman.fauxSleeping);
// CraftBukkit end
return false; return false;
} else { } else {

Datei anzeigen

@ -212,4 +212,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void updateInventory() { public void updateInventory() {
getHandle().m(); getHandle().m();
} }
public void setSleepingIgnored(boolean isSleeping) {
getHandle().fauxSleeping = isSleeping;
((CraftWorld)getWorld()).getHandle().checkSleepStatus();
}
public boolean isSleepingIgnored() {
return getHandle().fauxSleeping;
}
} }