Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed May 4, 2017
1 parent f6bf6ba commit 2b13ddf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/com/wasteofplastic/askyblock/SafeSpotTeleport.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void run() {
// Check for safe spot, but only if it is closer than one we have found already
if (!safeSpotFound || (safeDistance > islandLoc.toVector().distanceSquared(new Vector(x,y,z)))) {
// No safe spot yet, or closer distance
if (checkBlock(chunk,x,y,z)) {
if (checkBlock(chunk,x,y,z, worldHeight)) {
safeChunk = chunk;
safeSpotFound = true;
safeSpotInChunk = new Vector(x,y,z);
Expand Down Expand Up @@ -184,7 +184,7 @@ public void run() {
}
//System.out.print("DEBUG: Portal teleport loc = " + (16 * portalChunk.getX() + x) + "," + (y) + "," + (16 * portalChunk.getZ() + z));
// Now check if this is a safe location
if (checkBlock(portalChunk,x,y,z)) {
if (checkBlock(portalChunk,x,y,z, worldHeight)) {
// Yes, so use this instead of the highest location
//System.out.print("DEBUG: Portal is safe");
safeSpotFound = true;
Expand Down Expand Up @@ -257,15 +257,16 @@ public void run() {
* @param x
* @param y
* @param z
* @param worldHeight
* @return
*/
@SuppressWarnings("deprecation")
private boolean checkBlock(ChunkSnapshot chunk, int x, int y, int z) {
private boolean checkBlock(ChunkSnapshot chunk, int x, int y, int z, int worldHeight) {
int type = chunk.getBlockTypeId(x, y, z);
if (type != 0) { // AIR
int space1 = chunk.getBlockTypeId(x, y + 1, z);
int space2 = chunk.getBlockTypeId(x, y + 2, z);
if ((space1 == 0 && space2 == 0) || (space1 == Material.PORTAL.getId() && space2 == Material.PORTAL.getId())) {
int space1 = chunk.getBlockTypeId(x, Math.min(y + 1, worldHeight), z);
int space2 = chunk.getBlockTypeId(x, Math.min(y + 2, worldHeight), z);
if ((space1 == 0 && space2 == 0) || (space1 == Material.PORTAL.getId() || space2 == Material.PORTAL.getId())) {
// Now there is a chance that this is a safe spot
// Check for safe ground
Material mat = Material.getMaterial(type);
Expand Down
17 changes: 14 additions & 3 deletions src/com/wasteofplastic/askyblock/panels/ControlPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ public void onInventoryClick(InventoryClickEvent event) {
ItemStack clicked = event.getCurrentItem(); // The item that was clicked
Inventory inventory = event.getInventory(); // The inventory that was clicked in
if (inventory.getName() == null) {
if (DEBUG)
plugin.getLogger().info("DEBUG: inventory name is null");
return;
}
// ASkyBlock plugin = ASkyBlock.getPlugin();
Expand All @@ -224,12 +226,16 @@ public void onInventoryClick(InventoryClickEvent event) {
if (inventory.getName().equals(plugin.myLocale(player.getUniqueId()).challengesguiTitle)) {
event.setCancelled(true);
if (event.getClick().equals(ClickType.SHIFT_RIGHT)) {
if (DEBUG)
plugin.getLogger().info("DEBUG: click type shift Right");
inventory.clear();
player.closeInventory();
player.updateInventory();
return;
}
if (event.getSlotType() == SlotType.OUTSIDE) {
if (DEBUG)
plugin.getLogger().info("DEBUG: slot type outside");
inventory.clear();
player.closeInventory();
return;
Expand All @@ -248,6 +254,8 @@ public void onInventoryClick(InventoryClickEvent event) {
// plugin.getLogger().info("DEBUG: Challenges size = " +
// challenges.size());
if (slot >= 0 && slot < challenges.size()) {
if (DEBUG)
plugin.getLogger().info("DEBUG: slot within challenges");
CPItem item = challenges.get(slot);
// TEST
/*
Expand All @@ -269,12 +277,15 @@ public void onInventoryClick(InventoryClickEvent event) {
}*/
// END TEST
//plugin.getLogger().info("DEBUG: CP Item is " + item.getItem().toString());
//plugin.getLogger().info("DEBUG: Clicked is " + clicked.toString());
if (DEBUG) {
plugin.getLogger().info("DEBUG: CP Item is " + item.getItem().toString());
plugin.getLogger().info("DEBUG: Clicked is " + clicked.toString());
}
// Check that it is the top items that are being clicked on
// These two should be identical because it is made before
if (clicked.equals(item.getItem())) {
// plugin.getLogger().info("DEBUG: You clicked on a challenge item");
if (DEBUG)
plugin.getLogger().info("DEBUG: You clicked on a challenge item");
// plugin.getLogger().info("DEBUG: performing /" +
// item.getCommand());
// plugin.getLogger().info("DEBUG: going to " +
Expand Down

0 comments on commit 2b13ddf

Please sign in to comment.