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

View File

@ -11,7 +11,6 @@ import com.dre.brewery.utility.BUtil;
import com.dre.brewery.utility.PermissionUtil;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.mutable.MutableInt;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@ -32,7 +31,7 @@ import java.util.*;
public class 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 Random pukeRand;
@ -576,21 +575,22 @@ public class BPlayer {
if (pTasks.isEmpty()) {
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() {
for (Iterator<Map.Entry<Player, MutableInt>> iter = pTasks.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<Player, MutableInt> entry = iter.next();
for (Iterator<Map.Entry<Player, Integer>> iter = pTasks.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry<Player, Integer> entry = iter.next();
Player player = entry.getKey();
MutableInt count = entry.getValue();
int count = entry.getValue();
if (!player.isValid() || !player.isOnline()) {
iter.remove();
}
puke(player);
count.decrement();
if (count.intValue() <= 0) {
if (count <= 1) {
iter.remove();
} else {
entry.setValue(count - 1);
}
}
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.LegacyUtil;
import com.dre.brewery.utility.Stats;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -331,9 +330,39 @@ public class P extends JavaPlugin {
}
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) {
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.Barrel;
import com.dre.brewery.Brew;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
@ -356,7 +355,7 @@ public class BreweryApi {
public static void addRecipe(BRecipe recipe, boolean saveForever) {
//recipe.setSaveInData(saveForever);
if (saveForever) {
throw new NotImplementedException("SaveForever is not implemented yet");
throw new UnsupportedOperationException("SaveForever is not implemented yet");
}
BRecipe.getAddedRecipes().add(recipe);
recipe.updateAcceptedLists();
@ -424,7 +423,7 @@ public class BreweryApi {
public static void addCauldronRecipe(BCauldronRecipe recipe, boolean saveForever) {
//recipe.setSaveInData(saveForever);
if (saveForever) {
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
BCauldronRecipe.getAddedRecipes().add(recipe);
recipe.updateAcceptedLists();

View File

@ -8,8 +8,6 @@ import com.dre.brewery.recipe.PluginItem;
import com.dre.brewery.recipe.SimpleItem;
import com.dre.brewery.utility.BUtil;
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.Material;
import org.bukkit.World;
@ -24,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
public class BData {
@ -363,7 +362,7 @@ public class BData {
if (woLength > 1) {
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 {
box = BoundingBox.fromPoints(locs);
} catch (Exception e) {
@ -406,11 +405,11 @@ public class BData {
String[] splitted = loc.split("/");
if (splitted.length == 5) {
double x = NumberUtils.toDouble(splitted[0]);
double y = NumberUtils.toDouble(splitted[1]);
double z = NumberUtils.toDouble(splitted[2]);
float pitch = NumberUtils.toFloat(splitted[3]);
float yaw = NumberUtils.toFloat(splitted[4]);
double x = P.p.parseDouble(splitted[0]);
double y = P.p.parseDouble(splitted[1]);
double z = P.p.parseDouble(splitted[2]);
float pitch = P.p.parseFloat(splitted[3]);
float yaw = P.p.parseFloat(splitted[4]);
Location location = new Location(world, x, y, z, yaw, pitch);
initWakeups.add(new Wakeup(location));

View File

@ -81,11 +81,8 @@ public class UpdateChecker implements Runnable {
// Read the response of the query
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
JsonParser parser = new JsonParser();
// 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) {
// 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.object.TownyPermission;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import org.bukkit.Location;
import org.bukkit.Material;
public class TownyBarrel {
public static boolean checkAccess(BarrelAccessEvent event) {
if (!TownySettings.isSwitchMaterial("BREWERY") && !TownySettings.isSwitchMaterial("BARREL")) {
if (P.use1_14) {
Location barrelLoc = event.getSpigot().getLocation();
Material mat = P.use1_14 ? Material.BARREL : Material.CHEST;
try {
if (!TownySettings.isSwitchMaterial(mat, barrelLoc)) {
return true;
} else if (!TownySettings.isSwitchMaterial("CHEST")) {
}
} catch (Exception e) {
//noinspection deprecation
if (!TownySettings.isSwitchMaterial("CHEST")) {
return true;
}
}
Material mat = P.use1_14 ? Material.BARREL : Material.CHEST;
return PlayerCacheUtil.getCachePermission(event.getPlayer(), event.getSpigot().getLocation(), mat, TownyPermission.ActionType.SWITCH);
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.StringParser;
import com.dre.brewery.utility.Tuple;
import org.apache.commons.lang.NotImplementedException;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -717,7 +716,7 @@ public class BRecipe {
}
public void setSaveInData(boolean saveInData) {
throw new NotImplementedException();
throw new UnsupportedOperationException();
//this.saveInData = saveInData;
}

View File

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