Skip to content

Commit

Permalink
Fix 1.7.10 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Trophonix committed May 18, 2020
1 parent d0dfbcf commit a74e2db
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<properties>
<res>${project.basedir}/res/</res>
<revision>3.68.1</revision>
</properties>

<repositories>
Expand Down Expand Up @@ -175,11 +176,18 @@
<artifactId>worldguardwrapper</artifactId>
<version>1.1.6-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.github.Angeschossen</groupId>
<artifactId>LandsAPI</artifactId>
<version>4.5.2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>${basedir}/src/main/java/</sourceDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
<finalName>${project.artifactId}-${revision}</finalName>
<resources>
<resource>
<targetPath>.</targetPath>
Expand Down
25 changes: 18 additions & 7 deletions src/main/java/com/trophonix/tradeplus/util/ItemFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,25 @@ public ItemFactory(String parsable, Material fallback) {

public ItemFactory(String parsable) {
Preconditions.checkNotNull(parsable, "Material cannot be null.");
UMaterial uMat = UMaterial.match(parsable.toUpperCase().replace(" ", "_"));
byte data = -1;
if (parsable.contains(":")) {
String[] split = parsable.split(":");
data = Byte.parseByte(split[1]);
parsable = split[0];
}
parsable = parsable.toUpperCase().replace(" ", "_");
UMaterial uMat;
if (data > -1 && Sounds.version < 113) {
uMat = UMaterial.match(parsable, data);
} else {
uMat = UMaterial.match(parsable);
}
Preconditions.checkNotNull(uMat, "Unknown material [%s]", parsable);
Preconditions.checkArgument(
uMat.getMaterial() != null,
"Unknown material [%s]. Make sure item exists in your version!",
parsable);
material = uMat.getMaterial();
data = uMat.getData();
if (uMat.getMaterial() == null) {

}
this.material = uMat.getMaterial();
this.data = uMat.getData();
}

public ItemFactory(ItemStack stack) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/trophonix/tradeplus/util/UMaterial.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/
interface Versionable {
String VERSION = Bukkit.getVersion();
boolean EIGHT = VERSION.contains("1.8"), NINE = VERSION.contains("1.9"), TEN = VERSION.contains("1.10"), ELEVEN = VERSION.contains("1.11"), TWELVE = VERSION.contains("1.12"), THIRTEEN = VERSION.contains("1.13"), FOURTEEN = VERSION.contains("1.14"), FIFTEEN = VERSION.contains("1.15");
boolean EIGHT = VERSION.contains("1.7") || VERSION.contains("1.8"), NINE = VERSION.contains("1.9"), TEN = VERSION.contains("1.10"), ELEVEN = VERSION.contains("1.11"), TWELVE = VERSION.contains("1.12"), THIRTEEN = VERSION.contains("1.13"), FOURTEEN = VERSION.contains("1.14"), FIFTEEN = VERSION.contains("1.15");
boolean LEGACY = EIGHT || NINE || TEN || ELEVEN || TWELVE;
}

Expand Down Expand Up @@ -390,9 +390,9 @@ public enum UMaterial implements Versionable {
ENCHANTED_BOOK_CHANNELING("ENCHANTED_BOOK", Enchantment.getByName(Enchantment.getByName("CHANNELING") != null ? "CHANNELING" : "PROTECTION_EXPLOSIONS"), 1),
ENCHANTED_BOOK_CURSE_OF_BINDING("ENCHANTED_BOOK", Enchantment.getByName(Enchantment.getByName("BINDING_CURSE") != null ? "BINDING_CURSE" : "PROTECTION_EXPLOSIONS"), 1),
ENCHANTED_BOOK_CURSE_OF_VANISHING("ENCHANTED_BOOK", Enchantment.getByName(Enchantment.getByName("VANISHING_CURSE") != null ? "VANISHING_CURSE" : "PROTECTION_EXPLOSIONS"), 1),
ENCHANTED_BOOK_DEPTH_STRIDER_1("ENCHANTED_BOOK", Enchantment.DEPTH_STRIDER, 1),
ENCHANTED_BOOK_DEPTH_STRIDER_2("ENCHANTED_BOOK", Enchantment.DEPTH_STRIDER, 2),
ENCHANTED_BOOK_DEPTH_STRIDER_3("ENCHANTED_BOOK", Enchantment.DEPTH_STRIDER, 3),
ENCHANTED_BOOK_DEPTH_STRIDER_1("ENCHANTED_BOOK", Enchantment.getByName(Enchantment.getByName("DEPTH_STRIDER") != null ? "DEPTH_STRIDER" : "PROTECTION_EXPLOSIONS"), 1),
ENCHANTED_BOOK_DEPTH_STRIDER_2("ENCHANTED_BOOK", Enchantment.getByName(Enchantment.getByName("DEPTH_STRIDER") != null ? "DEPTH_STRIDER" : "PROTECTION_EXPLOSIONS"), 2),
ENCHANTED_BOOK_DEPTH_STRIDER_3("ENCHANTED_BOOK", Enchantment.getByName(Enchantment.getByName("DEPTH_STRIDER") != null ? "DEPTH_STRIDER" : "PROTECTION_EXPLOSIONS"), 3),
ENCHANTED_BOOK_EFFICIENCY_1("ENCHANTED_BOOK", Enchantment.DIG_SPEED, 1),
ENCHANTED_BOOK_EFFICIENCY_2("ENCHANTED_BOOK", Enchantment.DIG_SPEED, 2),
ENCHANTED_BOOK_EFFICIENCY_3("ENCHANTED_BOOK", Enchantment.DIG_SPEED, 3),
Expand Down

0 comments on commit a74e2db

Please sign in to comment.