Skip to content

Commit

Permalink
Begining of 1.4.3
Browse files Browse the repository at this point in the history
I just got motivation to work on the project again so let's go!
- Fixed a NPE when the command /cs test was run with an invalid structure. #25
- Added the ability for structures to spawn based on the ocean floor.  #22

This is just the begining of the update. All features are untested.
  • Loading branch information
ryandw11 committed Nov 12, 2019
1 parent e8ddba9 commit 4846970
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
9 changes: 7 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ Schematics:
SpawnY: top
#If you want air to be placed. True is air will be placed. False is air won't be placed.
PlaceAir: true
#If you want the structure to spawn in water or lava.
spawnInLiquid: false
#Ignore stuff like grass and leaves.
ignorePlants: true
Ocean_Properties:
#If you want the structure to spawn in water or lava.
spawnInLiquid: false
#If the structure picks a spot in the ocean or in a lake it will spawn at the floor of it.
useOceanFloor: true
#If the structure should be randomly rotated.
randomRotation: false
#Whitelisted blocks that the structure can spawn on. Remove this list if you do not want a whitelist.
Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: CustomStructures
version: 1.4.2.1
version: 1.4.3
main: com.ryandw11.structure.CustomStructures
author: Ryandw11
description: A plugin which allows you to spawn in custom structures!
Expand Down
1 change: 1 addition & 0 deletions src/com/ryandw11/structure/commands/SCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String s, String[] a
}
if (!plugin.getConfig().contains("Schematics." + args[1])) {
p.sendMessage(ChatColor.RED + "That schematic does not exist!");
return true;
}
SchematicHandeler sh = new SchematicHandeler();
try {
Expand Down
19 changes: 19 additions & 0 deletions src/com/ryandw11/structure/utils/CSConstants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.ryandw11.structure.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.bukkit.Material;

/**
* Variables containing constant data
* @author Ryandw11
* @since 1.4.3
*
*/
public class CSConstants {
public static List<Material> leafBlocks = new ArrayList<>(Arrays.asList(Material.GRASS, Material.ACACIA_LEAVES, Material.BIRCH_LEAVES,
Material.DARK_OAK_LEAVES, Material.JUNGLE_LEAVES, Material.OAK_LEAVES, Material.SPRUCE_LEAVES, Material.VINE, Material.ACACIA_LOG,
Material.BIRCH_LOG, Material.DARK_OAK_LOG, Material.JUNGLE_LOG, Material.OAK_LOG, Material.SPRUCE_LOG, Material.TALL_GRASS));
}
26 changes: 25 additions & 1 deletion src/com/ryandw11/structure/utils/StructurePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,33 @@ public void run() {
if (!worlds.contains(bl.getWorld().getName()))
return;
}



ConfigurationSection cs = plugin.getConfig().getConfigurationSection("Schematics." + currentSchem);

// Allows the structure to spawn based on the ocean floor. (If the floor is not found than it just returns with the top of the water).
if(cs.getBoolean("Ocean_Properties.useOceanFloor")) {
if(bl.getType() == Material.WATER) {
for(int i = bl.getY(); i <= 4; i--) {
if(ch.getBlock(0, i, 0).getType() != Material.WATER) {
bl = ch.getBlock(0, i, 0);
break;
}
}
}
}

// Allows the structures to no longer spawn on plant life.
if(cs.getBoolean("ignorePlants") && CSConstants.leafBlocks.contains(bl.getType())) {
for(int i = bl.getY(); i <= 4; i--) {
if(!CSConstants.leafBlocks.contains(ch.getBlock(0, i, 0).getType())) {
bl = ch.getBlock(0, i, 0);
break;
}
}
}

//If it can spawn in a boime.
if (!plugin.getConfig().getString("Schematics." + currentSchem + ".Biome").equalsIgnoreCase("all")) {// Checking
// biome
Expand Down Expand Up @@ -99,7 +123,7 @@ public void run() {
}
}
// If it can spawn in a liquid
if (!cs.getBoolean("spawnInLiquid")) {
if (!cs.getBoolean("Ocean_Properties.spawnInLiquid")) {
if (bl.getType() == Material.WATER || bl.getType() == Material.LAVA)
return;
}
Expand Down

0 comments on commit 4846970

Please sign in to comment.