Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.7.1 #2556

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
12109eb
Fix parrot interaction condition
Dreeam-qwq Oct 30, 2024
4747c90
Update de.yml
Archerymaister Nov 3, 2024
2c9865d
Update de.yml
Archerymaister Nov 4, 2024
51b9f47
Update de.yml
Archerymaister Nov 5, 2024
6dd87f6
Update to 1.21.3
tastybento Nov 6, 2024
ab47870
Version 2.7.1
tastybento Nov 6, 2024
e761d65
Merge pull request #2543 from Dreeam-qwq/fix/parrot-interact
tastybento Nov 6, 2024
6863f28
Shift API to 1.21 only.
tastybento Nov 6, 2024
9d7dbb7
Merge pull request #2548 from BentoBoxWorld/1.21.3_update
tastybento Nov 6, 2024
d8a7385
Update de.yml
Archerymaister Nov 6, 2024
36a60fa
Merge branch 'BentoBoxWorld:develop' into develop
Archerymaister Nov 6, 2024
cd40d27
Switch distribution management for CI codemc
tastybento Nov 6, 2024
c71bb8a
Merge branch 'develop' into develop
Archerymaister Nov 7, 2024
058fb6e
Use custom server to handle new enums
tastybento Nov 8, 2024
04ebe61
Add a slash to the end of the deploy
tastybento Nov 8, 2024
c77da07
Merge pull request #2550 from BentoBoxWorld/custom_server
tastybento Nov 8, 2024
d5219ed
Merge branch 'develop' into develop
Archerymaister Nov 8, 2024
6b095ab
Rename distro
tastybento Nov 8, 2024
57ce3c5
Merge pull request #2549 from Archerymaister/develop
tastybento Nov 8, 2024
44593bf
Remove debug
tastybento Nov 8, 2024
2ee6d60
Merge branch 'develop' of https://github.com/BentoBoxWorld/BentoBox.g…
tastybento Nov 8, 2024
4008815
Update to use BentoBox logging.
tastybento Nov 9, 2024
6a1561a
Deployment POM changes
tastybento Nov 9, 2024
d339edf
Change to 3.0.0
tastybento Nov 11, 2024
b135484
Adds island history for team members adding and removing
tastybento Nov 11, 2024
3870b20
Merge pull request #2553 from BentoBoxWorld/more_island_history
tastybento Nov 11, 2024
9fcee44
Fix tests
tastybento Nov 11, 2024
626b215
Make island info show min and max world heights
tastybento Nov 13, 2024
f19ca99
Explicitly save panels from Jar.
tastybento Nov 15, 2024
d665398
Save panels explicitly
tastybento Nov 15, 2024
471b198
Merge pull request #2552 from BentoBoxWorld/2.7.0_Short_term_stable
tastybento Nov 15, 2024
48aef16
Merge branch 'develop' into 3.0.0-update
tastybento Nov 15, 2024
0410ddb
Add the protection flag for eggHit.
Noogear Nov 16, 2024
01eaea9
Merge pull request #2555 from BentoBoxWorld/3.0.0-update
tastybento Nov 17, 2024
1f822f2
Merge pull request #2557 from Noogear/fix/eggHit
tastybento Nov 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,9 @@
</issueManagement>

<distributionManagement>
<snapshotRepository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.org/repository/maven-snapshots</url>
</snapshotRepository>
<repository>
<id>codemc-releases</id>
<url>https://repo.codemc.org/repository/maven-releases</url>
<id>bentoboxworld</id>
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
</repository>
</distributionManagement>

Expand Down Expand Up @@ -88,7 +84,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>2.7.0</build.version>
<build.version>3.0.0</build.version>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<server.jars>${project.basedir}/lib</server.jars>
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/world/bentobox/bentobox/BentoBox.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package world.bentobox.bentobox;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.Optional;

Expand Down Expand Up @@ -464,6 +466,32 @@ public boolean loadSettings() {
getPluginLoader().disablePlugin(this);
return false;
}
log("Saving default panels...");

if (!Files.exists(Path.of(this.getDataFolder().getPath(), "panels", "island_creation_panel.yml"))) {
log("Saving default island_creation_panel...");
this.saveResource("panels/island_creation_panel.yml", false);
}

if (!Files.exists(Path.of(this.getDataFolder().getPath(), "panels", "language_panel.yml"))) {
log("Saving default language_panel...");
this.saveResource("panels/language_panel.yml", false);
}

if (!Files.exists(Path.of(this.getDataFolder().getPath(), "panels", "island_homes_panel.yml"))) {
log("Saving default island_homes_panel...");
this.saveResource("panels/island_homes_panel.yml", false);
}

if (!Files.exists(Path.of(this.getDataFolder().getPath(), "panels", "team_invite_panel.yml"))) {
log("Saving default team_invite_panel...");
this.saveResource("panels/team_invite_panel.yml", false);
}

if (!Files.exists(Path.of(this.getDataFolder().getPath(), "panels", "team_panel.yml"))) {
log("Saving default team_panel...");
this.saveResource("panels/team_panel.yml", false);
}

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -110,6 +112,10 @@ public boolean execute(User user, String label, List<String> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.List;
import java.util.logging.Logger;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.eclipse.jdt.annotation.Nullable;

import world.bentobox.bentobox.BentoBox;
Expand Down Expand Up @@ -64,9 +63,9 @@ public T loadConfigObject(String uniqueId) {
return handler.loadObject(uniqueId);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| ClassNotFoundException | IntrospectionException | NoSuchMethodException | SecurityException e) {
logger.severe(() -> "Could not load config object! " + e.getMessage());
BentoBox.getInstance().logError("Could not load config object! " + e.getMessage());
// Required for debugging
logger.severe(ExceptionUtils.getStackTrace(e));
e.printStackTrace();
}

return null;
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/world/bentobox/bentobox/api/logs/LogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> 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;
Expand All @@ -36,7 +41,7 @@ public long getTimestamp() {
}

@NonNull
public String getType() {
public LogType getType() {
return type;
}

Expand All @@ -47,12 +52,12 @@ public Map<String, String> getData() {

public static class Builder {
private long timestamp;
private final String type;
private final LogType type;
private Map<String, String> 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<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@


import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import org.bukkit.Registry;
import org.bukkit.block.Biome;

import com.google.gson.TypeAdapter;
Expand All @@ -32,11 +32,12 @@ public final class BiomeTypeAdapter extends TypeAdapter<Biome>
*/
final Map<String, Biome> biomeMap;

@SuppressWarnings("deprecation")
public BiomeTypeAdapter() {
this.biomeMap = new HashMap<>();

// Put in current values.
Arrays.stream(Biome.values()).forEach(biome -> this.biomeMap.put(biome.name(), biome));
Registry.BIOME.forEach(biome -> this.biomeMap.put(biome.name(), biome));

// Put in renamed biomes values.
this.biomeMap.put("TALL_BIRCH_FOREST", Biome.OLD_GROWTH_BIRCH_FOREST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -360,7 +361,7 @@ public Set<UUID> 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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
public interface AdapterInterface<S,V> {

/**
* 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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,7 +44,7 @@ public List<LogEntry> deserialize(Object object) {
List<Map<String, Object>> serialized = (List<Map<String, Object>>) object;
for (Map<String, Object> entry : serialized) {
long timestamp = (long) entry.get(TIMESTAMP);
String type = (String) entry.get(TYPE);
LogType type = Enums.getIfPresent(LogType.class, (String) entry.get(TYPE)).or(LogType.UNKNOWN);
Map<String, String> data = (Map<String, String>) entry.get(DATA);

result.add(new LogEntry.Builder(type).timestamp(timestamp).data(data).build());
Expand All @@ -62,7 +65,7 @@ public List<Map<String, Object>> serialize(Object object) {
history.forEach(logEntry -> {
Map<String, Object> value = new LinkedHashMap<>();
value.put(TIMESTAMP, logEntry.getTimestamp());
value.put(TYPE, logEntry.getType());
value.put(TYPE, logEntry.getType().name());

if (logEntry.getData() != null) {
value.put(DATA, logEntry.getData());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,13 @@
import java.util.concurrent.CompletableFuture;

import org.bukkit.Bukkit;
import org.bukkit.Keyed;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.EntityType;
Expand Down Expand Up @@ -220,6 +225,14 @@ private void deserializeValue(Method method, T instance, PropertyDescriptor prop
double d = (double) setTo;
float f = (float)d;
method.invoke(instance, f);
} else if (setType.getTypeName().equals("org.bukkit.Sound")) {
Sound s = Registry.SOUNDS
.get(NamespacedKey.fromString(((String) setTo).toLowerCase(Locale.ENGLISH)));
method.invoke(instance, s);
} else if (setType.getTypeName().equals("org.bukkit.block.Biome")) {
Biome b = Registry.BIOME
.get(NamespacedKey.fromString(((String) setTo).toLowerCase(Locale.ENGLISH)));
method.invoke(instance, b);
} else {
method.invoke(instance, setTo);
}
Expand Down Expand Up @@ -369,7 +382,6 @@ public CompletableFuture<Boolean> saveObject(T instance) throws IllegalAccessExc
Method method = propertyDescriptor.getReadMethod();
// Invoke the read method to get the value. We have no idea what type of value it is.
Object value = method.invoke(instance);

String storageLocation = field.getName();

// Check if there is an annotation on the field
Expand Down Expand Up @@ -575,6 +587,10 @@ private Object serialize(@Nullable Object object) {
if (object instanceof Location l) {
return Util.getStringLocation(l);
}
// Keyed interfaces that are replacing enums
if (object instanceof Keyed k) {
return k.getKey().getKey();
}
// Enums
if (object instanceof Enum<?> e) {
//Custom enums are a child of the Enum class. Just get the names of each one.
Expand Down
Loading
Loading