mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 11:38:29 +01:00
Implemented gamemode methods
This commit is contained in:
parent
5b2c774edc
commit
a9b3a90dc9
@ -19,7 +19,7 @@ public class WorldData {
|
||||
private int m;
|
||||
private boolean n;
|
||||
private int o;
|
||||
private int p;
|
||||
public int p; // CraftBukkit - private -> public
|
||||
private boolean q;
|
||||
|
||||
public WorldData(NBTTagCompound nbttagcompound) {
|
||||
|
@ -822,10 +822,16 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
public GameMode getDefaultGameMode() {
|
||||
return GameMode.SURVIVAL;
|
||||
return GameMode.getByValue(console.worlds.get(0).worldData.p);
|
||||
}
|
||||
|
||||
public void setDefaultGameMode(GameMode mode) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
if (mode == null) {
|
||||
throw new IllegalArgumentException("Mode cannot be null");
|
||||
}
|
||||
|
||||
for (World world : getWorlds()) {
|
||||
((CraftWorld)world).getHandle().worldData.p = mode.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,11 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
private CraftInventoryPlayer inventory;
|
||||
protected final PermissibleBase perm = new PermissibleBase(this);
|
||||
private boolean op;
|
||||
private GameMode mode;
|
||||
|
||||
public CraftHumanEntity(final CraftServer server, final EntityHuman entity) {
|
||||
super(server, entity);
|
||||
mode = server.getDefaultGameMode();
|
||||
this.inventory = new CraftInventoryPlayer(entity.inventory);
|
||||
}
|
||||
|
||||
@ -119,10 +121,14 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
}
|
||||
|
||||
public GameMode getGameMode() {
|
||||
return GameMode.SURVIVAL;
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setGameMode(GameMode mode) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
if (mode == null) {
|
||||
throw new IllegalArgumentException("Mode cannot be null");
|
||||
}
|
||||
|
||||
this.mode = mode;
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,11 @@ import net.minecraft.server.Packet53BlockChange;
|
||||
import net.minecraft.server.Packet54PlayNoteBlock;
|
||||
import net.minecraft.server.Packet61;
|
||||
import net.minecraft.server.Packet6SpawnPosition;
|
||||
import net.minecraft.server.Packet70Bed;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -377,4 +379,21 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
server.getHandle().l(getName().toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode mode) {
|
||||
if (mode == null) {
|
||||
throw new IllegalArgumentException("Mode cannot be null");
|
||||
}
|
||||
|
||||
if (mode != getGameMode()) {
|
||||
getHandle().itemInWorldManager.a(mode.getValue());
|
||||
getHandle().netServerHandler.sendPacket(new Packet70Bed(3, mode.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode() {
|
||||
return GameMode.getByValue(getHandle().itemInWorldManager.a());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user