Skip to content

Commit

Permalink
Small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Awakned Redstone committed May 28, 2019
1 parent 3135dc5 commit 9141035
Showing 1 changed file with 24 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,49 +43,12 @@ public void onTreeGrow(StructureGrowEvent e) {


if (endLeaves() == null || endLogs() == null || netherLeaves() == null || netherLogs() == null) {
e.setCancelled(true);
double x = e.getLocation().getBlockX();
double y = e.getLocation().getBlockY();
double z = e.getLocation().getBlockZ();
World.Environment dimension = e.getLocation().getWorld().getEnvironment();
String dimensionName = "";

if (dimension == World.Environment.NORMAL) dimensionName = "OVERWORLD";
if (dimension == World.Environment.NETHER) dimensionName = "NETHER";
if (dimension == World.Environment.THE_END) dimensionName = "THE_END";


if (e.isFromBonemeal() && e.getPlayer() != null) e.getPlayer().sendMessage(errorMessage());
if (sendLog()) addon.logError("Can't grow a tree. A invalid material has been detected.\n" +
"Tree location: " +
"\n x= " + x +
"\n y= " + y +
"\n z= " + z +
"\n Dimension= " + dimensionName +
"\n");
warning(e);
return;
}

if (Material.getMaterial(ENDLEAVES()) == null || Material.getMaterial(ENDLOGS()) == null || Material.getMaterial(NETHERLEAVES()) == null || Material.getMaterial(NETHERLOGS()) == null) {
e.setCancelled(true);
double x = e.getLocation().getBlockX();
double y = e.getLocation().getBlockY();
double z = e.getLocation().getBlockZ();
World.Environment dimension = e.getLocation().getWorld().getEnvironment();
String dimensionName = "";

if (dimension == World.Environment.NORMAL) dimensionName = "OVERWORLD";
if (dimension == World.Environment.NETHER) dimensionName = "NETHER";
if (dimension == World.Environment.THE_END) dimensionName = "THE_END";


if (e.isFromBonemeal() && e.getPlayer() != null) e.getPlayer().sendMessage(errorMessage());
if (sendLog()) addon.logError("Can't grow the tree. A invalid material has been detected.\n" +
"Tree location: " +
"\n x= " + x +
"\n y= " + y +
"\n z= " + z +
"\n Dimension= " + dimensionName);
warning(e);
return;
}

Expand Down Expand Up @@ -114,7 +77,7 @@ public void onTreeGrow(StructureGrowEvent e) {
}
}
} catch (Exception exception) {
addon.logError("A Invalid material has been detected. Can't transform the tree.");
warning(e);
}
}

Expand Down Expand Up @@ -164,6 +127,27 @@ private boolean saplingVerification(Material sapling) {
return false;
}

public void warning(StructureGrowEvent e) {
double x = e.getLocation().getBlockX();
double y = e.getLocation().getBlockY();
double z = e.getLocation().getBlockZ();
World.Environment dimension = e.getLocation().getWorld().getEnvironment();
String dimensionName = "";

if (dimension == World.Environment.NORMAL) dimensionName = "OVERWORLD";
if (dimension == World.Environment.NETHER) dimensionName = "NETHER";
if (dimension == World.Environment.THE_END) dimensionName = "THE_END";


if (e.isFromBonemeal() && e.getPlayer() != null) e.getPlayer().sendMessage(errorMessage());
if (sendLog()) addon.logError("Can't grow the tree. A invalid material has been detected.\n" +
"Tree location: " +
"\n x= " + x +
"\n y= " + y +
"\n z= " + z +
"\n Dimension= " + dimensionName);
}

private String endLeaves() {
return addon.getSettings().getEnd_leaves();
}
Expand Down

0 comments on commit 9141035

Please sign in to comment.