Archived
0

зачем нам Location.copy(), если есть Location.set()?

This commit is contained in:
2018-05-23 15:42:22 +03:00
parent ab43db9765
commit 4a5f5cf721
5 changed files with 4 additions and 14 deletions

View File

@@ -12,10 +12,6 @@ import lombok.Data;
public class Location {
private double x, y, z;
public static Location copy(Location location) {
return new Location(location.x, location.y, location.z);
}
public void set(Location location) {
this.x = location.x;
this.y = location.y;

View File

@@ -35,8 +35,8 @@ public class InMemoryPlayerManager implements PlayerManager, Runnable {
SimplePlayer player = new SimplePlayer();
player.setId(rand.nextInt(10000));
player.setName(name);
player.setLocation(defaultLocation);
player.setLook(defaultLook);
player.getLocation().set(defaultLocation);
player.getLook().set(defaultLook);
synchronized (lock) {
players.add(player);

View File

@@ -12,10 +12,6 @@ import lombok.Data;
public class Look {
private float yaw, pitch;
public static Look copy(Look look) {
return new Look(look.yaw, look.pitch);
}
public void set(Look look) {
this.yaw = look.yaw;
this.pitch = look.pitch;

View File

@@ -16,10 +16,8 @@ public interface Player {
void setChannel(NetChannel channel);
Location getLocation();
void setLocation(Location location);
Look getLook();
void setLook(Look look);
boolean isFlying();
void setFlying(boolean value);

View File

@@ -19,10 +19,10 @@ public class SimplePlayer implements Player {
private boolean flying = false;
public void setLocation(Location location) {
this.location = Location.copy(location);
this.location.set(location);
}
public void setLook(Look look) {
this.look = Look.copy(look);
this.look.set(look);
}
}