@Override public final boolean equals(final Object obj) { if (this == obj) { return true; } if (!(obj instanceof Session)) { return false; } Session other = (Session) obj; return this.player.equals(other.player); } }
/** * @return The hash code computed from the id. */ @Override public int hashCode() { return this.id.hashCode(); }
/** * Retrieve an Id from a value. * * @param value Id value to get, positive and negative values are allowed, -1 is WORLD. * @return The Id with the internal value correspond to the parameter. */ public static PlayerId valueOf(final int value) { if (!PlayerId.LIST.containsKey(value)) { PlayerId.LIST.put(value, new PlayerId(value)); } return PlayerId.LIST.get(value); }
@Override public PlayerId from(String s) throws MappingException { ImplementationException.throwForNull(s); try { return PlayerId.valueOf(Integer.parseInt(s)); } catch (final NumberFormatException nfe) { throw new MappingException("Error retrieving id", nfe); } }
/** * @param id Player to check. * @return <code>true</code> if the player is world. */ public boolean isWorld(final PlayerId id) { return Player.WORLD.id.equals(id); }
@Override public final int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((this.player == null) ? 0 : this.player.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Message)) { return false; } Message other = (Message) obj; return this.date == other.date && this.content.equals(other.content) && this.read == other.read && this.receiver.equals(other.receiver) && this.sender.equals(other.sender); } }
@Override public int hashCode() { final int PRIME = 31; int result = 1; result = (int) (PRIME * result + this.date); result = PRIME * result + ((this.content == null) ? 0 : this.content.hashCode()); result = PRIME * result + (this.read ? 1231 : 1237); result = PRIME * result + ((this.receiver == null) ? 0 : this.receiver.hashCode()); result = PRIME * result + ((this.sender == null) ? 0 : this.sender.hashCode()); return result; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } PlayerDto playerDto = (PlayerDto) o; return player.equals(playerDto.player) && login.equals(playerDto.login) && status == playerDto.status; }
@Override public int hashCode() { int result = entity.hashCode(); result = 31 * result + newOwnerId.hashCode(); return result; } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ResourceTransferDto that = (ResourceTransferDto) o; return receiver.equals(that.receiver) && giver.equals(that.giver) && resources.equals(that.resources) && cause == that.cause; }
@Override public final boolean hasSameOwnerAs(final Entity e) { return this.owner.equals(e.getOwner()); }
@Override public int hashCode() { int result = player.hashCode(); result = 31 * result + login.hashCode(); result = 31 * result + status.hashCode(); return result; } }
public boolean isOwned(final PlayerId player) { assert player != null; return this.entity.getOwner().equals(player); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } ChangeOwnerDto that = (ChangeOwnerDto) o; if (!entity.equals(that.entity)) { return false; } return newOwnerId.equals(that.newOwnerId); }
/** * Occurs when 2 entities are no longer colliding, notify the listeners that they are not visible if they were and only if they do not belong to the same player. */ @Override public final void lostCollision(final CollisionResult r) { T viewer = this.manager.findById(r.object1); T unseen = this.manager.findById(r.object2); if (!viewer.getOwner().equals(unseen.getOwner()) && viewer.isSeeing(unseen)) { this.listenerList.forEach(l -> l.noLongerSee(viewer, unseen)); } }