Skip to content

Commit

Permalink
Merge branch 'develop' into team_gui
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento authored Jan 4, 2024
2 parents 5fcc203 + caade1a commit 37de29b
Show file tree
Hide file tree
Showing 23 changed files with 1,741 additions and 399 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<postgresql.version>42.2.18</postgresql.version>
<hikaricp.version>5.0.1</hikaricp.version>
<!-- More visible way to change dependency versions -->
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.20.3-R0.1-SNAPSHOT</spigot.version>
<!-- Might differ from the last Spigot release for short periods
of time -->
<paper.version>1.20.2-R0.1-SNAPSHOT</paper.version>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/world/bentobox/bentobox/BentoBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,10 @@ public boolean loadSettings() {
getPluginLoader().disablePlugin(this);
return false;
}

log("Saving default panels...");
this.saveResource("panels/island_creation_panel.yml", false);
this.saveResource("panels/language_panel.yml", false);
return true;
}

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/world/bentobox/bentobox/api/addons/Addon.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Logger;
import java.util.regex.Matcher;

import org.bukkit.Bukkit;
import org.bukkit.Server;
Expand Down Expand Up @@ -263,7 +264,7 @@ public File saveResource(String jarResource, File destinationFolder, boolean rep
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
}

jarResource = jarResource.replace("\\", File.separator).replace("/", File.separator);
jarResource = jarResource.replace('\\', '/');
try (JarFile jar = new JarFile(file)) {
JarEntry jarConfig = jar.getJarEntry(jarResource);
if (jarConfig != null) {
Expand All @@ -273,7 +274,9 @@ public File saveResource(String jarResource, File destinationFolder, boolean rep
"The embedded resource '" + jarResource + "' cannot be found in " + jar.getName());
}
// There are two options, use the path of the resource or not
File outFile = new File(destinationFolder, jarResource);
File outFile = new File(destinationFolder,
jarResource.replaceAll("/", Matcher.quoteReplacement(File.separator)));

if (noPath) {
outFile = new File(destinationFolder, outFile.getName());
}
Expand Down Expand Up @@ -308,7 +311,7 @@ public YamlConfiguration getYamlFromJar(String jarResource) throws IOException,
throw new IllegalArgumentException("jarResource cannot be null or empty");
}
YamlConfiguration result = new YamlConfiguration();
jarResource = jarResource.replace("\\", File.separator).replace("/", File.separator);
jarResource = jarResource.replace('\\', '/');
try (JarFile jar = new JarFile(file)) {
JarEntry jarConfig = jar.getJarEntry(jarResource);
if (jarConfig != null) {
Expand All @@ -330,7 +333,7 @@ public InputStream getResource(String jarResource) {
throw new IllegalArgumentException("ResourcePath cannot be null or empty");
}

jarResource = jarResource.replace("\\", File.separator).replace("/", File.separator);
jarResource = jarResource.replace('\\', '/');
try (JarFile jar = new JarFile(file)) {
JarEntry jarConfig = jar.getJarEntry(jarResource);
if (jarConfig != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.managers.BlueprintsManager;
import world.bentobox.bentobox.managers.island.NewIsland;
import world.bentobox.bentobox.panels.IslandCreationPanel;
import world.bentobox.bentobox.panels.customizable.IslandCreationPanel;
import world.bentobox.bentobox.util.Util;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.panels.LanguagePanel;
import world.bentobox.bentobox.panels.customizable.LanguagePanel;
import world.bentobox.bentobox.util.Util;

/**
Expand Down Expand Up @@ -46,7 +46,7 @@ public boolean execute(User user, String label, List<String> args) {
return false;
}
} else {
LanguagePanel.openPanel(user);
LanguagePanel.openPanel(this, user);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import world.bentobox.bentobox.managers.BlueprintsManager;
import world.bentobox.bentobox.managers.island.NewIsland;
import world.bentobox.bentobox.managers.island.NewIsland.Builder;
import world.bentobox.bentobox.panels.IslandCreationPanel;
import world.bentobox.bentobox.panels.customizable.IslandCreationPanel;
import world.bentobox.bentobox.util.Util;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Map;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
Expand All @@ -23,6 +24,7 @@
import world.bentobox.bentobox.database.json.adapters.FlagTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.ItemStackTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.LocationTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.MaterialTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.PotionEffectTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.VectorTypeAdapter;
import world.bentobox.bentobox.database.json.adapters.WorldTypeAdapter;
Expand Down Expand Up @@ -55,6 +57,8 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (Location.class.isAssignableFrom(rawType)) {
// Use our current location adapter for backward compatibility
return (TypeAdapter<T>) new LocationTypeAdapter();
} else if (Material.class.isAssignableFrom(rawType)) {
return (TypeAdapter<T>) new MaterialTypeAdapter();
} else if (Biome.class.isAssignableFrom(rawType)) {
return (TypeAdapter<T>) new BiomeTypeAdapter();
} else if (Enum.class.isAssignableFrom(rawType)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package world.bentobox.bentobox.database.json.adapters;


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

import org.bukkit.Material;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;


/**
* Minecraft 1.20 changed GRASS to SHORT_GRASS. This class provides and backwards compatibility when loading
* databased files stored with previous versions. It can be extended in the future if further enum changes are made.
* @author tastybento
* @since 2.0.0
*/
public final class MaterialTypeAdapter extends TypeAdapter<Material>
{
/**
* Map that contains string value to the actual Material enum object.
*/
final Map<String, Material> materialMap;

public MaterialTypeAdapter() {
this.materialMap = new HashMap<>();

// Put in current values.
Arrays.stream(Material.values()).forEach(mat -> this.materialMap.put(mat.name(), mat));

// Put in renamed material values.
this.materialMap.put("GRASS", Material.SHORT_GRASS);
}

@Override
public Material read(JsonReader input) throws IOException
{
if (JsonToken.NULL.equals(input.peek())) {
input.nextNull();
return null;
}

return this.materialMap.get(input.nextString().toUpperCase());
}

@Override
public void write(JsonWriter output, Material enumValue) throws IOException {
output.value(enumValue != null ? enumValue.name() : null);
}
}

This file was deleted.

68 changes: 0 additions & 68 deletions src/main/java/world/bentobox/bentobox/panels/LanguagePanel.java

This file was deleted.

Loading

0 comments on commit 37de29b

Please sign in to comment.