|
@@ -1,14 +1,8 @@
|
|
|
package de.Linus122.customoregen;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.HashSet;
|
|
|
+import java.util.AbstractMap;
|
|
|
+import java.util.Map.Entry;
|
|
|
import java.util.Random;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.UUID;
|
|
|
-
|
|
|
-import org.bukkit.Bukkit;
|
|
|
-import org.bukkit.EntityEffect;
|
|
|
-import org.bukkit.Location;
|
|
|
import org.bukkit.Material;
|
|
|
import org.bukkit.block.Block;
|
|
|
import org.bukkit.block.BlockFace;
|
|
@@ -19,14 +13,22 @@ import org.bukkit.event.block.BlockFromToEvent;
|
|
|
|
|
|
|
|
|
public class Events implements Listener {
|
|
|
- @SuppressWarnings({ "deprecation", "unused" })
|
|
|
+ @SuppressWarnings({ "deprecation" })
|
|
|
@EventHandler
|
|
|
public void onFromTo(BlockFromToEvent event){
|
|
|
+ //System.out.println("From: " + event.getBlock().getType().name());
|
|
|
+ //System.out.println("To: " + event.getToBlock().getType().name());
|
|
|
+ //System.out.println("Face: " + event.getFace().name());
|
|
|
+
|
|
|
int id = event.getBlock().getTypeId();
|
|
|
if ((id >= 8) && (id <= 11)){
|
|
|
Block b = event.getToBlock();
|
|
|
+ Entry<Boolean, Boolean> e = generatesCobble(id, b);
|
|
|
+ boolean generatesCobble = e.getKey();
|
|
|
+ boolean stoneGen = e.getValue();
|
|
|
+
|
|
|
int toid = b.getTypeId();
|
|
|
- if ((toid == 0) && (generatesCobble(id, b))){
|
|
|
+ if ((toid == 0) && (generatesCobble)){
|
|
|
GeneratorConfig gc = null;
|
|
|
|
|
|
Player p = Main.getOwner(b.getLocation());
|
|
@@ -56,6 +58,9 @@ public class Events implements Listener {
|
|
|
GeneratorItem winning = getObject(gc);
|
|
|
if(Material.getMaterial(winning.name) == null) return;
|
|
|
//b.setType(Material.getMaterial(winning));
|
|
|
+ if (Material.getMaterial(winning.name).equals(Material.COBBLESTONE) && winning.damage == 0 && stoneGen) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
b.setTypeIdAndData(Material.getMaterial(winning.name).getId() , winning.damage, true);
|
|
|
}
|
|
|
}
|
|
@@ -71,15 +76,26 @@ public class Events implements Listener {
|
|
|
}
|
|
|
private final BlockFace[] faces = { BlockFace.SELF, BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST };
|
|
|
|
|
|
- public boolean generatesCobble(int id, Block b){
|
|
|
+ @SuppressWarnings("deprecation")
|
|
|
+ public Entry<Boolean, Boolean> generatesCobble(int id, Block b){
|
|
|
int mirrorID1 = (id == 8) || (id == 9) ? 10 : 8;
|
|
|
int mirrorID2 = (id == 8) || (id == 9) ? 11 : 9;
|
|
|
+
|
|
|
for(BlockFace face : this.faces){
|
|
|
Block r = b.getRelative(face, 1);
|
|
|
if ((r.getTypeId() == mirrorID1) || (r.getTypeId() == mirrorID2)) {
|
|
|
- return true;
|
|
|
+ Entry<Boolean, Boolean> e = new AbstractMap.SimpleEntry<Boolean, Boolean>(true, false);
|
|
|
+ if (face.equals(BlockFace.UP)) {
|
|
|
+ System.out.println("Stone Gen: true");
|
|
|
+ e.setValue(true);
|
|
|
+ } else {
|
|
|
+ System.out.println("Stone Gen: false");
|
|
|
+ e.setValue(false);
|
|
|
+ }
|
|
|
+ return e;
|
|
|
}
|
|
|
}
|
|
|
- return false;
|
|
|
+ Entry<Boolean, Boolean> e = new AbstractMap.SimpleEntry<Boolean, Boolean>(false, false);
|
|
|
+ return new AbstractMap.SimpleEntry<Boolean, Boolean>(false, false);
|
|
|
}
|
|
|
}
|