mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 10:45:22 +01:00
Started to add Nullable/NonNull annotations
This commit is contained in:
parent
b51178518a
commit
c783fa8e16
9
pom.xml
9
pom.xml
@ -119,6 +119,15 @@
|
||||
<version>2.9.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Static analysis -->
|
||||
<!-- We are using Eclipse's annotations.
|
||||
If you're using IDEA, update your project settings to take these
|
||||
into account for in real time static analysis -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt</groupId>
|
||||
<artifactId>org.eclipse.jdt.annotation</artifactId>
|
||||
<version>2.2.200</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,5 +1,8 @@
|
||||
package world.bentobox.bentobox.api.logs;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -17,7 +20,7 @@ public class LogEntry {
|
||||
private final String type;
|
||||
private final Map<String, Object> data;
|
||||
|
||||
private LogEntry(Builder builder) {
|
||||
private LogEntry(@NonNull Builder builder) {
|
||||
this.timestamp = builder.timestamp;
|
||||
this.type = builder.type;
|
||||
this.data = builder.data;
|
||||
@ -27,10 +30,12 @@ public class LogEntry {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, Object> getData() {
|
||||
return data;
|
||||
}
|
||||
@ -40,7 +45,7 @@ public class LogEntry {
|
||||
private String type;
|
||||
private Map<String, Object> data;
|
||||
|
||||
public Builder(String type) {
|
||||
public Builder(@NonNull String type) {
|
||||
this.timestamp = System.currentTimeMillis();
|
||||
this.type = type.toUpperCase(Locale.ENGLISH);
|
||||
this.data = new LinkedHashMap<>();
|
||||
@ -51,7 +56,7 @@ public class LogEntry {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder data(Map<String, Object> data) {
|
||||
public Builder data(Map<@NonNull String, @Nullable Object> data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
@ -62,7 +67,7 @@ public class LogEntry {
|
||||
* @param value value to set
|
||||
* @return the Builder instance
|
||||
*/
|
||||
public Builder data(String key, Object value) {
|
||||
public Builder data(@NonNull String key, @Nullable Object value) {
|
||||
this.data.put(key, value);
|
||||
return this;
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSet.Builder;
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.flags.Flag;
|
||||
@ -104,7 +106,7 @@ public class Island implements DataObject {
|
||||
|
||||
public Island() {}
|
||||
|
||||
public Island(Location location, UUID owner, int protectionRange) {
|
||||
public Island(@NonNull Location location, UUID owner, int protectionRange) {
|
||||
setOwner(owner);
|
||||
createdDate = System.currentTimeMillis();
|
||||
updatedDate = System.currentTimeMillis();
|
||||
@ -119,7 +121,7 @@ public class Island implements DataObject {
|
||||
* Adds a team member. If player is on banned list, they will be removed from it.
|
||||
* @param playerUUID - the player's UUID
|
||||
*/
|
||||
public void addMember(UUID playerUUID) {
|
||||
public void addMember(@NonNull UUID playerUUID) {
|
||||
setRank(playerUUID, RanksManager.MEMBER_RANK);
|
||||
}
|
||||
|
||||
@ -133,7 +135,7 @@ public class Island implements DataObject {
|
||||
* @param target UUID of the target, must be provided.
|
||||
* @return {@code true} if the target is successfully banned, {@code false} otherwise.
|
||||
*/
|
||||
public boolean ban(UUID issuer, UUID target) {
|
||||
public boolean ban(@Nullable UUID issuer, @NonNull UUID target) {
|
||||
if (target != null) {
|
||||
setRank(target, RanksManager.BANNED_RANK);
|
||||
log(new LogEntry.Builder("BAN").data("player", target).data("issuer", issuer).build());
|
||||
@ -164,7 +166,7 @@ public class Island implements DataObject {
|
||||
* @param target UUID of the target, must be provided.
|
||||
* @return {@code true} if the target is successfully unbanned, {@code false} otherwise.
|
||||
*/
|
||||
public boolean unban(UUID issuer, UUID target) {
|
||||
public boolean unban(@Nullable UUID issuer, @NonNull UUID target) {
|
||||
if (members.remove(target) != null) {
|
||||
log(new LogEntry.Builder("UNBAN").data("player", target).data("issuer", issuer).build());
|
||||
return true;
|
||||
@ -193,7 +195,7 @@ public class Island implements DataObject {
|
||||
* @param flag - flag
|
||||
* @return flag value
|
||||
*/
|
||||
public int getFlag(Flag flag) {
|
||||
public int getFlag(@NonNull Flag flag) {
|
||||
flags.putIfAbsent(flag, flag.getDefaultRank());
|
||||
return flags.get(flag);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user