Skip to content

Commit

Permalink
hotfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jsinco committed Jun 9, 2024
1 parent 952dceb commit 294896f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.dre</groupId>
<artifactId>BreweryX</artifactId>
<version>3.2.0</version>
<version>3.2.0-SNAPSHOT</version>
<name>BreweryX</name>

<properties>
Expand Down
5 changes: 3 additions & 2 deletions src/com/dre/brewery/BSealer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
public class BSealer implements InventoryHolder {
public static final NamespacedKey TAG_KEY = new NamespacedKey(BreweryPlugin.getInstance(), "SealingTable");
public static final NamespacedKey LEGACY_TAG_KEY = new NamespacedKey("brewery", "sealingtable");
public static boolean recipeRegistered = false;
public static boolean inventoryHolderWorking = true;

Expand Down Expand Up @@ -110,7 +111,7 @@ public static boolean isBSealer(Block block) {
if (smoker.getCustomName().equals("§e" + BreweryPlugin.getInstance().languageReader.get("Etc_SealingTable"))) {
return true;
} else {
return smoker.getPersistentDataContainer().has(TAG_KEY, PersistentDataType.BYTE);
return smoker.getPersistentDataContainer().has(TAG_KEY, PersistentDataType.BYTE) || smoker.getPersistentDataContainer().has(LEGACY_TAG_KEY, PersistentDataType.BYTE);
}
}
}
Expand Down Expand Up @@ -159,7 +160,7 @@ public static void unregisterRecipe() {
Iterator<Recipe> recipeIterator = BreweryPlugin.getInstance().getServer().recipeIterator();
while (recipeIterator.hasNext()) {
Recipe next = recipeIterator.next();
if (next instanceof ShapedRecipe && ((ShapedRecipe) next).getKey().equals(TAG_KEY)) {
if (next instanceof ShapedRecipe && (((ShapedRecipe) next).getKey().equals(TAG_KEY) || ((ShapedRecipe) next).getKey().equals(LEGACY_TAG_KEY))) {
recipeIterator.remove();
return;
}
Expand Down
13 changes: 13 additions & 0 deletions src/com/dre/brewery/BreweryPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -80,6 +81,18 @@ public class BreweryPlugin extends JavaPlugin {
// Metrics
public Stats stats = new Stats();

@Override
public void onLoad() {
final String path = BreweryPlugin.class.getProtectionDomain().getCodeSource().getLocation().getPath();
final String jarDir = new File(path).getParentFile().getAbsolutePath();

final File breweryFolder = new File(jarDir + File.separator + "Brewery");
final File breweryXFolder = new File(jarDir + File.separator + "BreweryX");
if (breweryFolder.exists() && !breweryXFolder.exists()) {
breweryFolder.renameTo(breweryXFolder);
}
}

@Override
public void onEnable() {
breweryPlugin = this;
Expand Down
3 changes: 2 additions & 1 deletion src/com/dre/brewery/MCBarrel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;

import javax.naming.Name;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -41,7 +42,7 @@ public void open() {
if (inv.getViewers().size() == 1 && inv.getHolder() instanceof org.bukkit.block.Barrel) {
Barrel barrel = (Barrel) inv.getHolder();
PersistentDataContainer data = barrel.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(BreweryPlugin.getInstance(), TAG);
NamespacedKey key = new NamespacedKey(BreweryPlugin.getInstance(), TAG); // TODO: Legacy key this too?
if (!data.has(key, PersistentDataType.LONG)) return;

// Get the difference between the time that is stored on the Barrel and the current stored global mcBarrelTime
Expand Down
6 changes: 5 additions & 1 deletion src/com/dre/brewery/lore/NBTLoadStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
public class NBTLoadStream extends ByteArrayInputStream {
private static final String TAG = "brewdata";
private static final NamespacedKey KEY = new NamespacedKey(BreweryPlugin.getInstance(), TAG);
private static final NamespacedKey LEGACY_KEY = new NamespacedKey("brewery", TAG);

public NBTLoadStream(ItemMeta meta) {
super(getNBTBytes(meta));
}

private static byte[] getNBTBytes(ItemMeta meta) {
byte[] bytes = LegacyUtil.readBytesItem(meta, KEY);
if (bytes == null) {
bytes = LegacyUtil.readBytesItem(meta, LEGACY_KEY);
}
if (bytes == null) {
return new byte[0];
}
Expand All @@ -28,6 +32,6 @@ public boolean hasData() {
}

public static boolean hasDataInMeta(ItemMeta meta) {
return LegacyUtil.hasBytesItem(meta, KEY);
return LegacyUtil.hasBytesItem(meta, KEY) || LegacyUtil.hasBytesItem(meta, LEGACY_KEY);
}
}
2 changes: 1 addition & 1 deletion src/com/dre/brewery/recipe/BRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public static List<RecipeItem> loadIngredients(ConfigurationSection cfg, String
}
}

Material mat = Material.matchMaterial(matParts[0]);
Material mat = BUtil.getMaterialSafely(matParts[0]);
short durability = -1;
if (matParts.length == 2) {
durability = (short) BreweryPlugin.getInstance().parseInt(matParts[1]);
Expand Down
2 changes: 1 addition & 1 deletion src/com/dre/brewery/recipe/RecipeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected static List<Material> loadMaterials(List<String> ingredientsList) {
BreweryPlugin.getInstance().errorLog("Item Amount can not be specified for Custom Items: " + item);
return null;
}
Material mat = Material.matchMaterial(ingredParts[0]);
Material mat = BUtil.getMaterialSafely(ingredParts[0]);

if (mat == null && !BreweryPlugin.use1_14 && ingredParts[0].equalsIgnoreCase("cornflower")) {
// Using this in default custom-items, but will error on < 1.14
Expand Down
2 changes: 1 addition & 1 deletion src/com/dre/brewery/utility/BUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static String playerString(OfflinePlayer player) {


public static Material getMaterialSafely(String name) {
if (name.equals("GRASS")) {
if (name.equalsIgnoreCase("GRASS")) {
return Material.GRASS;
}
return Material.matchMaterial(name);
Expand Down

0 comments on commit 294896f

Please sign in to comment.