diff --git a/pom.xml b/pom.xml
index 4fc48b5b9..c48e504c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -84,7 +84,7 @@
-LOCAL
- 2.7.1
+ 3.0.0
bentobox-world
https://sonarcloud.io
${project.basedir}/lib
diff --git a/src/main/java/world/bentobox/bentobox/BentoBox.java b/src/main/java/world/bentobox/bentobox/BentoBox.java
index 4b556021e..daa0b91dd 100644
--- a/src/main/java/world/bentobox/bentobox/BentoBox.java
+++ b/src/main/java/world/bentobox/bentobox/BentoBox.java
@@ -492,6 +492,7 @@ public boolean loadSettings() {
log("Saving default team_panel...");
this.saveResource("panels/team_panel.yml", false);
}
+
return true;
}
diff --git a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminUnregisterCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminUnregisterCommand.java
index 06cb6a578..f9f631df3 100644
--- a/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminUnregisterCommand.java
+++ b/src/main/java/world/bentobox/bentobox/api/commands/admin/AdminUnregisterCommand.java
@@ -15,6 +15,7 @@
import world.bentobox.bentobox.api.events.island.IslandEvent;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.logs.LogEntry;
+import world.bentobox.bentobox.api.logs.LogEntry.LogType;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.RanksManager;
@@ -115,10 +116,10 @@ void unregisterIsland(User user) {
// Remove all island players that reference this island
targetIsland.getMembers().clear();
if (user.isPlayer()) {
- targetIsland.log(new LogEntry.Builder("UNREGISTER").data("player", targetUUID.toString())
+ targetIsland.log(new LogEntry.Builder(LogType.UNREGISTER).data("player", targetUUID.toString())
.data("admin", user.getUniqueId().toString()).build());
} else {
- targetIsland.log(new LogEntry.Builder("UNREGISTER").data("player", targetUUID.toString())
+ targetIsland.log(new LogEntry.Builder(LogType.UNREGISTER).data("player", targetUUID.toString())
.data("admin", "console").build());
}
user.sendMessage("commands.admin.unregister.unregistered-island", TextVariables.XYZ, Util.xyz(targetIsland.getCenter().toVector()),
diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java
index 9244508c7..f0e3523bd 100644
--- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java
+++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteAcceptCommand.java
@@ -9,6 +9,8 @@
import world.bentobox.bentobox.api.events.island.IslandEvent;
import world.bentobox.bentobox.api.events.team.TeamEvent;
import world.bentobox.bentobox.api.localization.TextVariables;
+import world.bentobox.bentobox.api.logs.LogEntry;
+import world.bentobox.bentobox.api.logs.LogEntry.LogType;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.database.objects.TeamInvite;
@@ -120,6 +122,9 @@ void acceptTrustInvite(User user, TeamInvite invite) {
user.sendMessage("commands.island.team.trust.you-are-trusted", TextVariables.NAME, inviter.getName(),
TextVariables.DISPLAY_NAME, inviter.getDisplayName());
}
+ // Add historu record
+ island.log(new LogEntry.Builder(LogType.TRUSTED).data(user.getUniqueId().toString(), "trusted")
+ .data(invite.getInviter().toString(), "trusted by").build());
}
}
diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommand.java
index 16e23ee5c..0533f65ea 100644
--- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommand.java
+++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamSetownerCommand.java
@@ -12,6 +12,8 @@
import world.bentobox.bentobox.api.events.island.IslandEvent;
import world.bentobox.bentobox.api.events.team.TeamEvent;
import world.bentobox.bentobox.api.localization.TextVariables;
+import world.bentobox.bentobox.api.logs.LogEntry;
+import world.bentobox.bentobox.api.logs.LogEntry.LogType;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.RanksManager;
@@ -91,6 +93,9 @@ protected boolean setOwner(User user, @NonNull UUID targetUUID2) {
IslandEvent.builder().island(island).involvedPlayer(user.getUniqueId()).admin(false)
.reason(IslandEvent.Reason.RANK_CHANGE).rankChange(RanksManager.OWNER_RANK, RanksManager.SUB_OWNER_RANK)
.build();
+ // Add historu record
+ island.log(new LogEntry.Builder(LogType.NEWOWNER).data(targetUUID2.toString(), "new owner")
+ .data(user.getUniqueId().toString(), "old owner").build());
return true;
}
diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommand.java
index 38c0349f7..435bbdee5 100644
--- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommand.java
+++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommand.java
@@ -9,6 +9,8 @@
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.localization.TextVariables;
+import world.bentobox.bentobox.api.logs.LogEntry;
+import world.bentobox.bentobox.api.logs.LogEntry.LogType;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.database.objects.TeamInvite.Type;
@@ -110,6 +112,10 @@ public boolean execute(User user, String label, List args) {
island.setRank(target, RanksManager.TRUSTED_RANK);
user.sendMessage("commands.island.team.trust.success", TextVariables.NAME, target.getName(), TextVariables.DISPLAY_NAME, target.getDisplayName());
target.sendMessage("commands.island.team.trust.you-are-trusted", TextVariables.NAME, user.getName(), TextVariables.DISPLAY_NAME, user.getDisplayName());
+ // Add historu record
+ island.log(new LogEntry.Builder(LogType.TRUSTED).data(targetUUID.toString(), "trusted")
+ .data(user.getUniqueId().toString(), "trusted by").build());
+
}
return true;
} else {
diff --git a/src/main/java/world/bentobox/bentobox/api/logs/LogEntry.java b/src/main/java/world/bentobox/bentobox/api/logs/LogEntry.java
index 583bd24a9..012623479 100644
--- a/src/main/java/world/bentobox/bentobox/api/logs/LogEntry.java
+++ b/src/main/java/world/bentobox/bentobox/api/logs/LogEntry.java
@@ -15,16 +15,21 @@
* An {@link world.bentobox.bentobox.database.objects.adapters.AdapterInterface AdapterInterface} is provided to be able to save/retrieve
* a list of instances of this object to/from the database: {@link world.bentobox.bentobox.database.objects.adapters.LogEntryListAdapter LogEntryListAdapter}.
*
- * @author Poslovitch
+ * @author Poslovitch, tastybento
+ *
*/
public class LogEntry {
@Expose
private final long timestamp;
@Expose
- private final String type;
+ private final LogType type;
@Expose
private final Map data;
+ public enum LogType {
+ REMOVE, ADD, UNREGISTER, BAN, UNOWNED, SPAWN, UNBAN, JOINED, NEWOWNER, TRUSTED, UNKNOWN
+ }
+
private LogEntry(@NonNull Builder builder) {
this.timestamp = builder.timestamp;
this.type = builder.type;
@@ -36,7 +41,7 @@ public long getTimestamp() {
}
@NonNull
- public String getType() {
+ public LogType getType() {
return type;
}
@@ -47,12 +52,12 @@ public Map getData() {
public static class Builder {
private long timestamp;
- private final String type;
+ private final LogType type;
private Map data;
- public Builder(@NonNull String type) {
+ public Builder(LogType type) {
this.timestamp = System.currentTimeMillis();
- this.type = type.toUpperCase(Locale.ENGLISH);
+ this.type = type;
this.data = new LinkedHashMap<>();
}
diff --git a/src/main/java/world/bentobox/bentobox/database/objects/Island.java b/src/main/java/world/bentobox/bentobox/database/objects/Island.java
index e55c6a0ea..663c31cf0 100644
--- a/src/main/java/world/bentobox/bentobox/database/objects/Island.java
+++ b/src/main/java/world/bentobox/bentobox/database/objects/Island.java
@@ -37,6 +37,7 @@
import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.api.logs.LogEntry;
+import world.bentobox.bentobox.api.logs.LogEntry.LogType;
import world.bentobox.bentobox.api.metadata.MetaDataAble;
import world.bentobox.bentobox.api.metadata.MetaDataValue;
import world.bentobox.bentobox.api.user.User;
@@ -327,7 +328,7 @@ public void addMember(@NonNull UUID playerUUID) {
public boolean ban(@NonNull UUID issuer, @NonNull UUID target) {
if (getRank(target) != RanksManager.BANNED_RANK) {
setRank(target, RanksManager.BANNED_RANK);
- log(new LogEntry.Builder("BAN").data("player", target.toString()).data("issuer", issuer.toString())
+ log(new LogEntry.Builder(LogType.BAN).data("player", target.toString()).data("issuer", issuer.toString())
.build());
setChanged();
}
@@ -360,7 +361,7 @@ public Set getBanned() {
*/
public boolean unban(@NonNull UUID issuer, @NonNull UUID target) {
if (members.remove(target) != null) {
- log(new LogEntry.Builder("UNBAN").data("player", target.toString()).data("issuer", issuer.toString())
+ log(new LogEntry.Builder(LogType.UNBAN).data("player", target.toString()).data("issuer", issuer.toString())
.build());
return true;
}
@@ -1132,7 +1133,7 @@ public void setOwner(@Nullable UUID owner) {
this.owner = owner;
if (owner == null) {
- log(new LogEntry.Builder("UNOWNED").build());
+ log(new LogEntry.Builder(LogType.UNOWNED).build());
return;
}
// Defensive code: demote any previous owner
@@ -1281,7 +1282,7 @@ public void setSpawn(boolean isSpawn) {
setFlagsDefaults();
setFlag(Flags.LOCK, RanksManager.VISITOR_RANK);
}
- log(new LogEntry.Builder("SPAWN").data("value", String.valueOf(isSpawn)).build());
+ log(new LogEntry.Builder(LogType.SPAWN).data("value", String.valueOf(isSpawn)).build());
setChanged();
}
diff --git a/src/main/java/world/bentobox/bentobox/database/objects/adapters/AdapterInterface.java b/src/main/java/world/bentobox/bentobox/database/objects/adapters/AdapterInterface.java
index 096e59b07..7c688b9d1 100644
--- a/src/main/java/world/bentobox/bentobox/database/objects/adapters/AdapterInterface.java
+++ b/src/main/java/world/bentobox/bentobox/database/objects/adapters/AdapterInterface.java
@@ -11,16 +11,16 @@
public interface AdapterInterface {
/**
- * Serialize object
- * @param object - object to serialize
- * @return serialized object
+ * Deserialize object
+ * @param object - object to deserialize
+ * @return deserialized object
*/
S deserialize(Object object);
/**
- * Deserialize object
- * @param object - object to deserialize
- * @return deserialized object
+ * Serialize object
+ * @param object - object to serialize
+ * @return serialized object
*/
V serialize(Object object);
}
diff --git a/src/main/java/world/bentobox/bentobox/database/objects/adapters/LogEntryListAdapter.java b/src/main/java/world/bentobox/bentobox/database/objects/adapters/LogEntryListAdapter.java
index a4f8b5954..d3b38f358 100644
--- a/src/main/java/world/bentobox/bentobox/database/objects/adapters/LogEntryListAdapter.java
+++ b/src/main/java/world/bentobox/bentobox/database/objects/adapters/LogEntryListAdapter.java
@@ -5,7 +5,10 @@
import java.util.List;
import java.util.Map;
+import com.google.common.base.Enums;
+
import world.bentobox.bentobox.api.logs.LogEntry;
+import world.bentobox.bentobox.api.logs.LogEntry.LogType;
/**
* @author Poslovitch
@@ -41,7 +44,7 @@ public List deserialize(Object object) {
List