зачем нам Location.copy(), если есть Location.set()?
This commit is contained in:
@@ -12,10 +12,6 @@ import lombok.Data;
|
|||||||
public class Location {
|
public class Location {
|
||||||
private double x, y, z;
|
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) {
|
public void set(Location location) {
|
||||||
this.x = location.x;
|
this.x = location.x;
|
||||||
this.y = location.y;
|
this.y = location.y;
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ public class InMemoryPlayerManager implements PlayerManager, Runnable {
|
|||||||
SimplePlayer player = new SimplePlayer();
|
SimplePlayer player = new SimplePlayer();
|
||||||
player.setId(rand.nextInt(10000));
|
player.setId(rand.nextInt(10000));
|
||||||
player.setName(name);
|
player.setName(name);
|
||||||
player.setLocation(defaultLocation);
|
player.getLocation().set(defaultLocation);
|
||||||
player.setLook(defaultLook);
|
player.getLook().set(defaultLook);
|
||||||
|
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
players.add(player);
|
players.add(player);
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ import lombok.Data;
|
|||||||
public class Look {
|
public class Look {
|
||||||
private float yaw, pitch;
|
private float yaw, pitch;
|
||||||
|
|
||||||
public static Look copy(Look look) {
|
|
||||||
return new Look(look.yaw, look.pitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set(Look look) {
|
public void set(Look look) {
|
||||||
this.yaw = look.yaw;
|
this.yaw = look.yaw;
|
||||||
this.pitch = look.pitch;
|
this.pitch = look.pitch;
|
||||||
|
|||||||
@@ -16,10 +16,8 @@ public interface Player {
|
|||||||
void setChannel(NetChannel channel);
|
void setChannel(NetChannel channel);
|
||||||
|
|
||||||
Location getLocation();
|
Location getLocation();
|
||||||
void setLocation(Location location);
|
|
||||||
|
|
||||||
Look getLook();
|
Look getLook();
|
||||||
void setLook(Look look);
|
|
||||||
|
|
||||||
boolean isFlying();
|
boolean isFlying();
|
||||||
void setFlying(boolean value);
|
void setFlying(boolean value);
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ public class SimplePlayer implements Player {
|
|||||||
private boolean flying = false;
|
private boolean flying = false;
|
||||||
|
|
||||||
public void setLocation(Location location) {
|
public void setLocation(Location location) {
|
||||||
this.location = Location.copy(location);
|
this.location.set(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLook(Look look) {
|
public void setLook(Look look) {
|
||||||
this.look = Look.copy(look);
|
this.look.set(look);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user