зачем нам Location.copy(), если есть Location.set()?
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user