Support 1.18 + version 1.5.0

This commit is contained in:
Christian Koop 2021-12-20 18:33:51 +01:00
parent d28a9de82f
commit a2a132509c
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
6 changed files with 53 additions and 19 deletions

25
pom.xml
View File

@ -1,11 +1,14 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>UltimateRepairing</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>1.4.9</version>
<version>1.5.0</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>UltimateRepairing-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -16,10 +19,12 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
@ -28,6 +33,7 @@
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/classes/plugin.yml</file>
<replacements>
@ -38,6 +44,7 @@
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
@ -49,14 +56,17 @@
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>com.songoda:SongodaCore</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
@ -67,6 +77,7 @@
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.songoda.core</pattern>
@ -79,12 +90,14 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>https://repository.apache.org/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>public</id>
@ -95,17 +108,19 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17</version>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId>
<version>LATEST</version>
<version>2.6.8</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.List;
public class UltimateRepairing extends SongodaPlugin {
private static UltimateRepairing INSTANCE;
private final Config dataFile = new Config(this, "data.yml");

View File

@ -5,7 +5,6 @@ import com.songoda.ultimaterepairing.UltimateRepairing;
import org.bukkit.entity.Player;
public enum RepairType {
ECONOMY(CompatibleMaterial.SUNFLOWER,
"ultimaterepairing.use.ECO",
"interface.repair.ecoTitle"),

View File

@ -23,7 +23,6 @@ import java.util.Random;
* Created by songoda on 2/25/2017.
*/
public class Methods {
static Random rand = new Random();
public static CompatibleMaterial getRainbowGlass() {
@ -85,6 +84,7 @@ public class Methods {
if (item.getType().name().contains("WOOD"))
return CompatibleMaterial.OAK_WOOD.getMaterial();
}
return Settings.ITEM_ICON.getMaterial(CompatibleMaterial.DIAMOND).getMaterial();
}
@ -93,6 +93,7 @@ public class Methods {
*
* @param inventory The inventory to check
* @param item The item to check for.
*
* @return Whether or not the inventory contains the item.
*/
public static boolean inventoryContains(Inventory inventory, ItemStack item) {
@ -102,10 +103,12 @@ public class Methods {
if (item1 != null && item1.getType() == item.getType() && item1.getDurability() == item.getDurability()) {
count += item1.getAmount();
}
if (count >= item.getAmount()) {
return true;
}
}
return false;
}
@ -132,6 +135,7 @@ public class Methods {
}
}
}
inventory.setContents(items);
}
@ -139,11 +143,14 @@ public class Methods {
* Serializes the location of the block specified.
*
* @param b The block whose location is to be saved.
*
* @return The serialized data.
*/
public static String serializeLocation(Block b) {
if (b == null)
if (b == null) {
return "";
}
return serializeLocation(b.getLocation());
}
@ -151,17 +158,21 @@ public class Methods {
* Serializes the location specified.
*
* @param location The location that is to be saved.
*
* @return The serialized data.
*/
public static String serializeLocation(Location location) {
if (location == null || location.getWorld() == null)
if (location == null || location.getWorld() == null) {
return "";
}
String w = location.getWorld().getName();
double x = location.getX();
double y = location.getY();
double z = location.getZ();
String str = w + ":" + x + ":" + y + ":" + z;
str = str.replace(".0", "").replace("/", "");
str = str.replace(".0", "")
.replace("/", "");
return str;
}
@ -171,20 +182,29 @@ public class Methods {
* Deserializes a location from the string.
*
* @param str The string to parse.
*
* @return The location that was serialized in the string.
*/
public static Location unserializeLocation(String str) {
if (str == null || str.equals(""))
if (str == null || str.equals("")) {
return null;
}
if (serializeCache.containsKey(str)) {
return serializeCache.get(str).clone();
}
String cacheKey = str;
str = str.replace("y:", ":").replace("z:", ":").replace("w:", "").replace("x:", ":").replace("/", ".");
str = str.replace("y:", ":")
.replace("z:", ":")
.replace("w:", "")
.replace("x:", ":")
.replace("/", ".");
List<String> args = Arrays.asList(str.split("\\s*:\\s*"));
World world = Bukkit.getWorld(args.get(0));
double x = Double.parseDouble(args.get(1)), y = Double.parseDouble(args.get(2)), z = Double.parseDouble(args.get(3));
double x = Double.parseDouble(args.get(1)),
y = Double.parseDouble(args.get(2)),
z = Double.parseDouble(args.get(3));
Location location = new Location(world, x, y, z, 0, 0);
serializeCache.put(cacheKey, location.clone());
return location;

View File

@ -5,6 +5,7 @@ softdepend: [HolographicDisplays, Vault]
version: maven-version-number
author: Songoda
api-version: 1.13
commands:
ur:
description: View information on this plugin.