-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
name: CustomStructures | ||
version: 1.4.3.1 | ||
main: com.ryandw11.structure.CustomStructures | ||
author: Ryandw11 | ||
description: A plugin which allows you to spawn in custom structures! | ||
depend: [WorldEdit] | ||
softdepend: [MythicMobs] | ||
api-version: 1.13 | ||
commands: | ||
customstructure: | ||
description: Main command. | ||
name: CustomStructures | ||
version: 1.4.3.2 | ||
main: com.ryandw11.structure.CustomStructures | ||
author: Ryandw11 | ||
description: A plugin which allows you to spawn in custom structures! | ||
depend: [WorldEdit] | ||
softdepend: [MythicMobs] | ||
api-version: 1.13 | ||
commands: | ||
customstructure: | ||
description: Main command. | ||
aliases: [cs, cstructure, customs, cws] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,58 @@ | ||
package com.ryandw11.structure.listener; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.World; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.ChunkLoadEvent; | ||
|
||
import com.ryandw11.structure.CustomStructures; | ||
import com.ryandw11.structure.utils.StructurePicker; | ||
|
||
/** | ||
* Class for when a chunk loads. | ||
* @author Ryandw11 | ||
* | ||
*/ | ||
public class ChunkLoad implements Listener{ | ||
|
||
//private CustomStructures plugin; | ||
|
||
public ChunkLoad(){ | ||
//this.plugin = CustomStructures.plugin; | ||
} | ||
|
||
@EventHandler | ||
public void loadevent(ChunkLoadEvent e){ | ||
if(!CustomStructures.enabled) return; | ||
|
||
if(e.isNewChunk()){ //Checks to see if the chunk is new or an old one. | ||
World w = e.getChunk().getWorld(); //Grabs the world | ||
Block b = e.getChunk().getBlock(0, 5, 0); //Grabs the block 0, 5, 0 in that chunk. | ||
|
||
boolean foundLand = false; //True when the block selected is an ideal place for a structure. | ||
Block bb = e.getChunk().getBlock(0, w.getHighestBlockYAt(b.getX(), b.getZ()), 0); //grabs the highest block in that chunk at X = 0 and Z = 0 for that chunk. | ||
int trys = 0; | ||
while (!foundLand){//While land was not found it keeps checking. | ||
if(trys >= 20) return; //added anti crash. | ||
if(bb.getType() != Material.AIR){ | ||
foundLand = true; | ||
} | ||
else{ | ||
bb = bb.getLocation().subtract(0, 1, 0).getBlock(); | ||
} | ||
trys++; | ||
} | ||
|
||
/* | ||
* Schematic handeler | ||
* Runs a BukkitRunnable to prevent the server from crashing. | ||
*/ | ||
StructurePicker s = new StructurePicker(bb, e.getChunk()); | ||
s.runTaskTimer(CustomStructures.plugin, 1, 10); | ||
} | ||
} | ||
} | ||
package com.ryandw11.structure.listener; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.World; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.ChunkLoadEvent; | ||
|
||
import com.ryandw11.structure.CustomStructures; | ||
import com.ryandw11.structure.utils.StructurePicker; | ||
|
||
/** | ||
* Class for when a chunk loads. | ||
* @author Ryandw11 | ||
* | ||
*/ | ||
public class ChunkLoad implements Listener{ | ||
|
||
//private CustomStructures plugin; | ||
|
||
public ChunkLoad(){ | ||
//this.plugin = CustomStructures.plugin; | ||
} | ||
|
||
@EventHandler | ||
public void loadevent(ChunkLoadEvent e){ | ||
if(!CustomStructures.enabled) return; | ||
|
||
if(e.isNewChunk()){ //Checks to see if the chunk is new or an old one. | ||
World w = e.getChunk().getWorld(); //Grabs the world | ||
Block b = e.getChunk().getBlock(0, 5, 0); //Grabs the block 0, 5, 0 in that chunk. | ||
|
||
if(w.getHighestBlockYAt(b.getX(), b.getZ()) == -1) return; | ||
|
||
boolean foundLand = false; //True when the block selected is an ideal place for a structure. | ||
Block bb = e.getChunk().getBlock(0, w.getHighestBlockYAt(b.getX(), b.getZ()), 0); //grabs the highest block in that chunk at X = 0 and Z = 0 for that chunk. | ||
int trys = 0; | ||
while (!foundLand){//While land was not found it keeps checking. | ||
if(trys >= 20) return; //added anti crash. | ||
if(bb.getType() != Material.AIR){ | ||
foundLand = true; | ||
} | ||
else{ | ||
bb = bb.getLocation().subtract(0, 1, 0).getBlock(); | ||
} | ||
trys++; | ||
} | ||
|
||
/* | ||
* Schematic handeler | ||
* Runs a BukkitRunnable to prevent the server from crashing. | ||
*/ | ||
StructurePicker s = new StructurePicker(bb, e.getChunk()); | ||
s.runTaskTimer(CustomStructures.plugin, 1, 10); | ||
} | ||
} | ||
} |