Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bunch of issues + java 16 #251

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 16
uses: actions/setup-java@v2
with:
java-version: 8
java-version: 16
distribution: 'adopt'
- name: Build with Maven
run: mvn package --file pom.xml
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<version>UNOFFICIAL</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -66,7 +66,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.3.0</version>

<configuration>

Expand Down Expand Up @@ -105,14 +105,14 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.slimefun</groupId>
<artifactId>Slimefun4</artifactId>
<version>RC-27</version>
<version>RC-31</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public Berry(@Nullable ItemStack item, String id, PlantType type, String texture
* Returns the identifier of this Berry.
*
* @return the identifier of this Berry
*
* @since 1.7.0, rename of {@link #getName()}.
*/
public String getID() {
return this.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,29 +380,28 @@ public static ItemStack harvestPlant(@Nonnull Block block) {
for (Berry berry : getBerries()) {
if (item.getId().equalsIgnoreCase(berry.getID())) {
switch (berry.getType()) {
case ORE_PLANT:
case DOUBLE_PLANT:
case ORE_PLANT, DOUBLE_PLANT -> {
Block plant = block;

if (Tag.LEAVES.isTagged(block.getType())) {
block = block.getRelative(BlockFace.UP);
} else {
plant = block.getRelative(BlockFace.DOWN);
plant = block.getRelative(BlockFace.SELF);
}

BlockStorage.deleteLocationInfoUnsafely(block.getLocation(), false);
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, Material.OAK_LEAVES);
block.setType(Material.AIR);

plant.setType(Material.OAK_SAPLING);
BlockStorage.deleteLocationInfoUnsafely(block.getRelative(BlockFace.UP).getLocation(), false);
BlockStorage.deleteLocationInfoUnsafely(plant.getLocation(), false);
BlockStorage.store(plant, getItem(berry.toBush()));
return berry.getItem().clone();
default:
}
default -> {
block.setType(Material.OAK_SAPLING);
BlockStorage.deleteLocationInfoUnsafely(block.getLocation(), false);
BlockStorage.store(block, getItem(berry.toBush()));
return berry.getItem().clone();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,10 @@ public ItemUseHandler getItemHandler() {
private boolean isInteractable(@Nonnull Material material) {
// We cannot rely on Material#isInteractable() sadly
// as it would allow the placement of this block on strange items like stairs...
switch (material) {
case ANVIL:
case BREWING_STAND:
case CAKE:
case CHEST:
case HOPPER:
case TRAPPED_CHEST:
case ENDER_CHEST:
case CAULDRON:
case SHULKER_BOX:
return true;
default:
return material.name().equals("BARREL") || material.name().endsWith("_SHULKER_BOX");
}
return switch (material) {
case ANVIL, BREWING_STAND, CAKE, CHEST, HOPPER, TRAPPED_CHEST, ENDER_CHEST, SHULKER_BOX -> true;
default -> material.name().equals("BARREL") || material.name().endsWith("_SHULKER_BOX");
};
}

protected int getFoodValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,43 +165,34 @@ private void growStructure(StructureGrowEvent e) {
for (Berry berry : ExoticGarden.getBerries()) {
if (item.getId().equalsIgnoreCase(berry.toBush())) {
switch (berry.getType()) {
case BUSH:
e.getLocation().getBlock().setType(Material.OAK_LEAVES);
break;
case ORE_PLANT:
case DOUBLE_PLANT:
Block blockAbove = e.getLocation().getBlock().getRelative(BlockFace.UP);
item = BlockStorage.check(blockAbove);
if (item != null) return;

if (!Tag.SAPLINGS.isTagged(blockAbove.getType()) && !Tag.LEAVES.isTagged(blockAbove.getType())) {
switch (blockAbove.getType()) {
case AIR:
case CAVE_AIR:
case SNOW:
break;
default:
return;
case BUSH -> e.getLocation().getBlock().setType(Material.OAK_LEAVES);
case ORE_PLANT, DOUBLE_PLANT -> {
Block blockAbove = e.getLocation().getBlock().getRelative(BlockFace.UP);
item = BlockStorage.check(blockAbove);
if (item != null) return;
if (!Tag.SAPLINGS.isTagged(blockAbove.getType()) && !Tag.LEAVES.isTagged(blockAbove.getType())) {
switch (blockAbove.getType()) {
case AIR, CAVE_AIR, SNOW:
break;
default:
return;
}
}
BlockStorage.store(blockAbove, berry.getItem());
e.getLocation().getBlock().setType(Material.OAK_LEAVES);
blockAbove.setType(Material.PLAYER_HEAD);
Rotatable rotatable = (Rotatable) blockAbove.getBlockData();
rotatable.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]);
blockAbove.setBlockData(rotatable);
PlayerHead.setSkin(blockAbove, PlayerSkin.fromHashCode(berry.getTexture()), true);
}
default -> {
e.getLocation().getBlock().setType(Material.PLAYER_HEAD);
Rotatable s = (Rotatable) e.getLocation().getBlock().getBlockData();
s.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]);
e.getLocation().getBlock().setBlockData(s);
PlayerHead.setSkin(e.getLocation().getBlock(), PlayerSkin.fromHashCode(berry.getTexture()), true);
}

BlockStorage.store(blockAbove, berry.getItem());
e.getLocation().getBlock().setType(Material.OAK_LEAVES);
blockAbove.setType(Material.PLAYER_HEAD);
Rotatable rotatable = (Rotatable) blockAbove.getBlockData();
rotatable.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]);
blockAbove.setBlockData(rotatable);

PlayerHead.setSkin(blockAbove, PlayerSkin.fromHashCode(berry.getTexture()), true);
break;
default:
e.getLocation().getBlock().setType(Material.PLAYER_HEAD);
Rotatable s = (Rotatable) e.getLocation().getBlock().getBlockData();
s.setRotation(faces[ThreadLocalRandom.current().nextInt(faces.length)]);
e.getLocation().getBlock().setBlockData(s);

PlayerHead.setSkin(e.getLocation().getBlock(), PlayerSkin.fromHashCode(berry.getTexture()), true);
break;
}

BlockStorage.deleteLocationInfoUnsafely(e.getLocation(), false);
Expand Down Expand Up @@ -237,7 +228,7 @@ private void growBush(ChunkPopulateEvent e, int x, int z, Berry berry, Random ra
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> current.setType(Material.OAK_LEAVES));
}
break;
case FRUIT:
case FRUIT, ORE_PLANT, DOUBLE_PLANT:
if (isPaper) {
current.setType(Material.PLAYER_HEAD);
Rotatable s = (Rotatable) current.getBlockData();
Expand All @@ -255,27 +246,6 @@ private void growBush(ChunkPopulateEvent e, int x, int z, Berry berry, Random ra
});
}
break;
case ORE_PLANT:
case DOUBLE_PLANT:
if (isPaper) {
current.setType(Material.PLAYER_HEAD);
Rotatable s = (Rotatable) current.getBlockData();
s.setRotation(faces[random.nextInt(faces.length)]);
current.setBlockData(s);
PlayerHead.setSkin(current, PlayerSkin.fromHashCode(berry.getTexture()), true);
}
else {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
BlockStorage.store(current.getRelative(BlockFace.UP), berry.getItem());
current.setType(Material.OAK_LEAVES);
current.getRelative(BlockFace.UP).setType(Material.PLAYER_HEAD);
Rotatable ss = (Rotatable) current.getRelative(BlockFace.UP).getBlockData();
ss.setRotation(faces[random.nextInt(faces.length)]);
current.getRelative(BlockFace.UP).setBlockData(ss);
PlayerHead.setSkin(current.getRelative(BlockFace.UP), PlayerSkin.fromHashCode(berry.getTexture()), true);
});
}
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ public final class NBTConstants {
/**
* Tag type constants.
*/
public static final int TYPE_END = 0,
TYPE_BYTE = 1,
TYPE_SHORT = 2,
TYPE_INT = 3,
TYPE_LONG = 4,
TYPE_FLOAT = 5,
TYPE_DOUBLE = 6,
TYPE_BYTE_ARRAY = 7,
TYPE_STRING = 8,
TYPE_LIST = 9,
TYPE_COMPOUND = 10;
public static final int TYPE_END = 0;
public static final int TYPE_BYTE = 1;
public static final int TYPE_SHORT = 2;
public static final int TYPE_INT = 3;
public static final int TYPE_LONG = 4;
public static final int TYPE_FLOAT = 5;
public static final int TYPE_DOUBLE = 6;
public static final int TYPE_BYTE_ARRAY = 7;
public static final int TYPE_STRING = 8;
public static final int TYPE_LIST = 9;
public static final int TYPE_COMPOUND = 10;

/**
* Default private constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ author: TheBusyBiscuit
description: A Slimefun Addon that adds new Plants and dishes to the game
website: https://github.com/TheBusyBiscuit/ExoticGarden

api-version: '1.13'
api-version: '1.14'
main: io.github.thebusybiscuit.exoticgarden.ExoticGarden

depend:
Expand Down