Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ShakeforProtein committed Dec 12, 2019
1 parent db6b8fb commit 77314f2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.ShakeforProtein</groupId>
<artifactId>TreeboTimed</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>
<packaging>jar</packaging>

<name>TreeboTimed</name>
Expand Down
62 changes: 32 additions & 30 deletions src/main/java/me/shakeforprotein/treebotimed/TreeboTimed.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,41 +66,43 @@ public boolean accept(File dir, String name) {
return name.endsWith(".scm");
}
});
int totalFiles = files.length;
int count = 1;
long timespan = getConfig().getInt("totalInterval") * 20 * 60;
if (totalFiles > 0) {
long interval = timespan / totalFiles;
for (File schematic : files) {
System.out.println("Scheduling pasting schematic - " + schematic.getName().replace(".scm", "") + " - in " + interval * count + " ticks, repeating every " + timespan + " ticks");
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pasteatorigin " + schematic.getAbsolutePath().replace(".scm", ""));
}
}, (interval * count), timespan);
count++;
if (files != null) {
int totalFiles = files.length;
int count = 1;
long timespan = getConfig().getInt("totalInterval") * 20 * 60;
if (totalFiles > 0) {
long interval = timespan / totalFiles;
for (File schematic : files) {
System.out.println("Scheduling pasting schematic - " + schematic.getName().replace(".scm", "") + " - in " + interval * count + " ticks, repeating every " + timespan + " ticks");
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pasteatorigin " + schematic.getAbsolutePath().replace(".scm", ""));
}
}, (interval * count), timespan);
count++;

Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
for (Player p : Bukkit.getOnlinePlayers()) {
int x, y, z = 0;
FileConfiguration yaml = new YamlConfiguration().loadConfiguration(new File(schematic.getName().replace(".scm", ".yml")));
x = yaml.getInt("X");
y = yaml.getInt("Y");
z = yaml.getInt("Z");
if (p.getLocation().getBlockX() > (x - 50) && p.getLocation().getBlockX() < (x + 50)) {
if (p.getLocation().getBlockZ() > (z - 50) && p.getLocation().getBlockZ() < (z + 50)) {
if (p.getLocation().getBlockY() > (y - 15) && p.getLocation().getBlockY() < (y + 50)) {
p.sendMessage(badge + " Resetting farm " + ChatColor.GOLD + schematic.getName().replace(".scm", "") + ChatColor.RESET + " in " + ChatColor.RED + ChatColor.BOLD + "ONE" + ChatColor.RESET + " Minute");
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
for (Player p : Bukkit.getOnlinePlayers()) {
int x, y, z = 0;
FileConfiguration yaml = new YamlConfiguration().loadConfiguration(new File(schematic.getName().replace(".scm", ".yml")));
x = yaml.getInt("X");
y = yaml.getInt("Y");
z = yaml.getInt("Z");
if (p.getLocation().getBlockX() > (x - 50) && p.getLocation().getBlockX() < (x + 50)) {
if (p.getLocation().getBlockZ() > (z - 50) && p.getLocation().getBlockZ() < (z + 50)) {
if (p.getLocation().getBlockY() > (y - 15) && p.getLocation().getBlockY() < (y + 50)) {
p.sendMessage(badge + " Resetting farm " + ChatColor.GOLD + schematic.getName().replace(".scm", "") + ChatColor.RESET + " in " + ChatColor.RED + ChatColor.BOLD + "ONE" + ChatColor.RESET + " Minute");
}
}
}
}
//Bukkit.broadcastMessage(badge + " Resetting farm " + ChatColor.GOLD + schematic.getName().replace(".scm", "") + ChatColor.RESET + " in " + ChatColor.RED + ChatColor.BOLD + "ONE" + ChatColor.RESET + " Minute");
}
//Bukkit.broadcastMessage(badge + " Resetting farm " + ChatColor.GOLD + schematic.getName().replace(".scm", "") + ChatColor.RESET + " in " + ChatColor.RED + ChatColor.BOLD + "ONE" + ChatColor.RESET + " Minute");
}
}, (interval * count) - 1200, timespan);
}, (interval * count) - 1200, timespan);
}
}
}
}
Expand Down

0 comments on commit 77314f2

Please sign in to comment.