Update for 1.19

This commit is contained in:
Sn0wStorm 2022-07-03 17:24:02 +02:00
parent 36d76130f7
commit 45bfc36226
9 changed files with 83 additions and 56 deletions

35
pom.xml
View File

@ -36,7 +36,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version> <version>3.10.1</version>
<configuration> <configuration>
<source>1.8</source> <source>1.8</source>
<target>1.8</target> <target>1.8</target>
@ -74,7 +74,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId> <artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.1</version> <version>3.4.0</version>
<executions> <executions>
<execution> <execution>
<phase>compile</phase> <phase>compile</phase>
@ -110,8 +110,8 @@
</repository> </repository>
<repository> <repository>
<!-- WorldEdit, WorldGuard --> <!-- WorldEdit, WorldGuard -->
<id>sk89q-repo</id> <id>enginehub-maven</id>
<url>https://maven.sk89q.com/repo/</url> <url>https://maven.enginehub.org/repo/</url>
</repository> </repository>
<repository> <repository>
<!-- GriefPrevention, SlimeFun, Towny, Brewery --> <!-- GriefPrevention, SlimeFun, Towny, Brewery -->
@ -135,17 +135,13 @@
<repository> <repository>
<!-- MythicLib (MMOItems) --> <!-- MythicLib (MMOItems) -->
<id>MMOPlugins</id> <id>MMOPlugins</id>
<url>https://mvn.lumine.io/repository/maven-public/</url> <url>https://mvn.lumine.io/repository/maven/</url>
</repository> </repository>
<repository> <repository>
<!-- Shopkeepers --> <!-- Shopkeepers -->
<id>Lichtspiele</id> <id>Lichtspiele</id>
<url>https://nexus.lichtspiele.org/repository/releases/</url> <url>https://nexus.lichtspiele.org/repository/releases/</url>
</repository> </repository>
<repository>
<id>lumine</id>
<url>https://mvn.lumine.io/repository/maven/</url>
</repository>
</repositories> </repositories>
@ -153,7 +149,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version> <version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -170,7 +166,7 @@
<!-- https://bstats.org/getting-started/include-metrics --> <!-- https://bstats.org/getting-started/include-metrics -->
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId> <artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version> <version>3.0.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -201,7 +197,7 @@
<!-- https://dev.bukkit.org/projects/worldedit/files --> <!-- https://dev.bukkit.org/projects/worldedit/files -->
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId> <artifactId>worldedit-bukkit</artifactId>
<version>7.2.5</version> <version>7.2.11-beta-01</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -213,7 +209,7 @@
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId> <artifactId>worldedit-core</artifactId>
<version>7.2.5</version> <version>7.2.11-beta-01</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -239,7 +235,7 @@
<!-- https://www.spigotmc.org/resources/lwc-extended.69551/history --> <!-- https://www.spigotmc.org/resources/lwc-extended.69551/history -->
<groupId>com.griefcraft.lwc</groupId> <groupId>com.griefcraft.lwc</groupId>
<artifactId>LWCX</artifactId> <artifactId>LWCX</artifactId>
<version>2.2.6</version> <version>2.2.8</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -272,7 +268,7 @@
<!-- https://github.com/Slimefun/Slimefun4/releases --> <!-- https://github.com/Slimefun/Slimefun4/releases -->
<groupId>com.github.slimefun</groupId> <groupId>com.github.slimefun</groupId>
<artifactId>Slimefun4</artifactId> <artifactId>Slimefun4</artifactId>
<version>RC-27</version> <version>RC-32</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!--<dependency> <!--<dependency>
@ -283,6 +279,7 @@
<scope>provided</scope> <scope>provided</scope>
</dependency>--> </dependency>-->
<dependency> <dependency>
<!-- https://www.spigotmc.org/resources/mythiclib.90306/history -->
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>MythicLib-dist</artifactId> <artifactId>MythicLib-dist</artifactId>
<version>1.3.1</version> <version>1.3.1</version>
@ -292,28 +289,28 @@
<!-- https://github.com/ChestShop-authors/ChestShop-3/releases --> <!-- https://github.com/ChestShop-authors/ChestShop-3/releases -->
<groupId>com.acrobot.chestshop</groupId> <groupId>com.acrobot.chestshop</groupId>
<artifactId>chestshop</artifactId> <artifactId>chestshop</artifactId>
<version>3.12</version> <version>3.12.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<!-- https://www.spigotmc.org/resources/towny-advanced.72694/history --> <!-- https://www.spigotmc.org/resources/towny-advanced.72694/history -->
<groupId>com.github.TownyAdvanced</groupId> <groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId> <artifactId>Towny</artifactId>
<version>0.97.0.0</version> <version>0.98.3.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<!-- https://www.spigotmc.org/resources/shopkeepers.80756/history --> <!-- https://www.spigotmc.org/resources/shopkeepers.80756/history -->
<groupId>com.nisovin.shopkeepers</groupId> <groupId>com.nisovin.shopkeepers</groupId>
<artifactId>ShopkeepersAPI</artifactId> <artifactId>ShopkeepersAPI</artifactId>
<version>2.12.0</version> <version>2.16.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<!-- https://www.spigotmc.org/resources/blocklocker.3268/history --> <!-- https://www.spigotmc.org/resources/blocklocker.3268/history -->
<groupId>nl.rutgerkok</groupId> <groupId>nl.rutgerkok</groupId>
<artifactId>blocklocker</artifactId> <artifactId>blocklocker</artifactId>
<version>1.9.2</version> <version>1.10.4</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -11,7 +11,6 @@ import com.dre.brewery.utility.BUtil;
import com.dre.brewery.utility.PermissionUtil; import com.dre.brewery.utility.PermissionUtil;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.mutable.MutableInt;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -32,7 +31,7 @@ import java.util.*;
public class BPlayer { public class BPlayer {
private static Map<String, BPlayer> players = new HashMap<>();// Players uuid and BPlayer private static Map<String, BPlayer> players = new HashMap<>();// Players uuid and BPlayer
private static Map<Player, MutableInt> pTasks = new HashMap<>();// Player and count private static Map<Player, Integer> pTasks = new HashMap<>();// Player and count
private static int taskId; private static int taskId;
private static Random pukeRand; private static Random pukeRand;
@ -576,21 +575,22 @@ public class BPlayer {
if (pTasks.isEmpty()) { if (pTasks.isEmpty()) {
taskId = P.p.getServer().getScheduler().scheduleSyncRepeatingTask(P.p, BPlayer::pukeTask, 1L, 1L); taskId = P.p.getServer().getScheduler().scheduleSyncRepeatingTask(P.p, BPlayer::pukeTask, 1L, 1L);
} }
pTasks.put(player, new MutableInt(event.getCount())); pTasks.put(player, event.getCount());
} }
public static void pukeTask() { public static void pukeTask() {
for (Iterator<Map.Entry<Player, MutableInt>> iter = pTasks.entrySet().iterator(); iter.hasNext(); ) { for (Iterator<Map.Entry<Player, Integer>> iter = pTasks.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<Player, MutableInt> entry = iter.next(); Map.Entry<Player, Integer> entry = iter.next();
Player player = entry.getKey(); Player player = entry.getKey();
MutableInt count = entry.getValue(); int count = entry.getValue();
if (!player.isValid() || !player.isOnline()) { if (!player.isValid() || !player.isOnline()) {
iter.remove(); iter.remove();
} }
puke(player); puke(player);
count.decrement(); if (count <= 1) {
if (count.intValue() <= 0) {
iter.remove(); iter.remove();
} else {
entry.setValue(count - 1);
} }
} }
if (pTasks.isEmpty()) { if (pTasks.isEmpty()) {

View File

@ -39,7 +39,6 @@ import com.dre.brewery.recipe.*;
import com.dre.brewery.utility.BUtil; import com.dre.brewery.utility.BUtil;
import com.dre.brewery.utility.LegacyUtil; import com.dre.brewery.utility.LegacyUtil;
import com.dre.brewery.utility.Stats; import com.dre.brewery.utility.Stats;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -331,8 +330,38 @@ public class P extends JavaPlugin {
} }
public int parseInt(String string) { public int parseInt(String string) {
return NumberUtils.toInt(string, 0); if (string == null) {
return 0;
} }
try {
return Integer.parseInt(string);
} catch (NumberFormatException ignored) {
return 0;
}
}
public double parseDouble(String string) {
if (string == null) {
return 0;
}
try {
return Double.parseDouble(string);
} catch (NumberFormatException ignored) {
return 0;
}
}
public float parseFloat(String string) {
if (string == null) {
return 0;
}
try {
return Float.parseFloat(string);
} catch (NumberFormatException ignored) {
return 0;
}
}
public String color(String msg) { public String color(String msg) {
return BUtil.color(msg); return BUtil.color(msg);

View File

@ -7,7 +7,6 @@ import com.dre.brewery.recipe.BCauldronRecipe;
import com.dre.brewery.recipe.BRecipe; import com.dre.brewery.recipe.BRecipe;
import com.dre.brewery.Barrel; import com.dre.brewery.Barrel;
import com.dre.brewery.Brew; import com.dre.brewery.Brew;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@ -356,7 +355,7 @@ public class BreweryApi {
public static void addRecipe(BRecipe recipe, boolean saveForever) { public static void addRecipe(BRecipe recipe, boolean saveForever) {
//recipe.setSaveInData(saveForever); //recipe.setSaveInData(saveForever);
if (saveForever) { if (saveForever) {
throw new NotImplementedException("SaveForever is not implemented yet"); throw new UnsupportedOperationException("SaveForever is not implemented yet");
} }
BRecipe.getAddedRecipes().add(recipe); BRecipe.getAddedRecipes().add(recipe);
recipe.updateAcceptedLists(); recipe.updateAcceptedLists();
@ -424,7 +423,7 @@ public class BreweryApi {
public static void addCauldronRecipe(BCauldronRecipe recipe, boolean saveForever) { public static void addCauldronRecipe(BCauldronRecipe recipe, boolean saveForever) {
//recipe.setSaveInData(saveForever); //recipe.setSaveInData(saveForever);
if (saveForever) { if (saveForever) {
throw new NotImplementedException(); throw new UnsupportedOperationException();
} }
BCauldronRecipe.getAddedRecipes().add(recipe); BCauldronRecipe.getAddedRecipes().add(recipe);
recipe.updateAcceptedLists(); recipe.updateAcceptedLists();

View File

@ -8,8 +8,6 @@ import com.dre.brewery.recipe.PluginItem;
import com.dre.brewery.recipe.SimpleItem; import com.dre.brewery.recipe.SimpleItem;
import com.dre.brewery.utility.BUtil; import com.dre.brewery.utility.BUtil;
import com.dre.brewery.utility.BoundingBox; import com.dre.brewery.utility.BoundingBox;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
@ -24,6 +22,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
public class BData { public class BData {
@ -363,7 +362,7 @@ public class BData {
if (woLength > 1) { if (woLength > 1) {
System.arraycopy(wo, 0, points, st.length, woLength); System.arraycopy(wo, 0, points, st.length, woLength);
} }
int[] locs = ArrayUtils.toPrimitive(Arrays.stream(points).map(s -> P.p.parseInt(s)).toArray(Integer[]::new)); int[] locs = Arrays.stream(points).mapToInt(s -> P.p.parseInt(s)).toArray();
try { try {
box = BoundingBox.fromPoints(locs); box = BoundingBox.fromPoints(locs);
} catch (Exception e) { } catch (Exception e) {
@ -406,11 +405,11 @@ public class BData {
String[] splitted = loc.split("/"); String[] splitted = loc.split("/");
if (splitted.length == 5) { if (splitted.length == 5) {
double x = NumberUtils.toDouble(splitted[0]); double x = P.p.parseDouble(splitted[0]);
double y = NumberUtils.toDouble(splitted[1]); double y = P.p.parseDouble(splitted[1]);
double z = NumberUtils.toDouble(splitted[2]); double z = P.p.parseDouble(splitted[2]);
float pitch = NumberUtils.toFloat(splitted[3]); float pitch = P.p.parseFloat(splitted[3]);
float yaw = NumberUtils.toFloat(splitted[4]); float yaw = P.p.parseFloat(splitted[4]);
Location location = new Location(world, x, y, z, yaw, pitch); Location location = new Location(world, x, y, z, yaw, pitch);
initWakeups.add(new Wakeup(location)); initWakeups.add(new Wakeup(location));

View File

@ -81,11 +81,8 @@ public class UpdateChecker implements Runnable {
// Read the response of the query // Read the response of the query
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
JsonParser parser = new JsonParser();
// Parse the array of files from the query's response // Parse the array of files from the query's response
JsonArray array = parser.parse(reader).getAsJsonArray(); JsonArray array = JsonParser.parseReader(reader).getAsJsonArray();
if (array.size() > 0) { if (array.size() > 0) {
// Get the newest file's details // Get the newest file's details

View File

@ -6,18 +6,24 @@ import com.dre.brewery.api.events.barrel.BarrelAccessEvent;
import com.palmergames.bukkit.towny.TownySettings; import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.object.TownyPermission; import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil; import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
public class TownyBarrel { public class TownyBarrel {
public static boolean checkAccess(BarrelAccessEvent event) { public static boolean checkAccess(BarrelAccessEvent event) {
if (!TownySettings.isSwitchMaterial("BREWERY") && !TownySettings.isSwitchMaterial("BARREL")) { Location barrelLoc = event.getSpigot().getLocation();
if (P.use1_14) {
return true;
} else if (!TownySettings.isSwitchMaterial("CHEST")) {
return true;
}
}
Material mat = P.use1_14 ? Material.BARREL : Material.CHEST; Material mat = P.use1_14 ? Material.BARREL : Material.CHEST;
return PlayerCacheUtil.getCachePermission(event.getPlayer(), event.getSpigot().getLocation(), mat, TownyPermission.ActionType.SWITCH);
try {
if (!TownySettings.isSwitchMaterial(mat, barrelLoc)) {
return true;
}
} catch (Exception e) {
//noinspection deprecation
if (!TownySettings.isSwitchMaterial("CHEST")) {
return true;
}
}
return PlayerCacheUtil.getCachePermission(event.getPlayer(), barrelLoc, mat, TownyPermission.ActionType.SWITCH);
} }
} }

View File

@ -7,7 +7,6 @@ import com.dre.brewery.filedata.BConfig;
import com.dre.brewery.utility.BUtil; import com.dre.brewery.utility.BUtil;
import com.dre.brewery.utility.StringParser; import com.dre.brewery.utility.StringParser;
import com.dre.brewery.utility.Tuple; import com.dre.brewery.utility.Tuple;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -717,7 +716,7 @@ public class BRecipe {
} }
public void setSaveInData(boolean saveInData) { public void setSaveInData(boolean saveInData) {
throw new NotImplementedException(); throw new UnsupportedOperationException();
//this.saveInData = saveInData; //this.saveInData = saveInData;
} }

View File

@ -1,6 +1,5 @@
package com.dre.brewery.utility; package com.dre.brewery.utility;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permissible;
import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.permissions.PermissionAttachmentInfo;
@ -125,10 +124,12 @@ public class PermissionUtil {
if (found.isPresent()) { if (found.isPresent()) {
String permission = found.get().getPermission(); String permission = found.get().getPermission();
int lastDot = permission.lastIndexOf('.'); int lastDot = permission.lastIndexOf('.');
int value = NumberUtils.toInt(permission.substring(lastDot + 1), -1); try {
int value = Integer.parseInt(permission.substring(lastDot + 1));
if (value >= 0) { if (value >= 0) {
return value; return value;
} }
} catch (NumberFormatException ignored) {}
} }
return -1; return -1;
} }