Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.bricedev.wrcp;
- import java.util.Map;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.configuration.ConfigurationSection;
- import org.bukkit.scheduler.BukkitRunnable;
- public class Timer {
- Database data = Database.instance;
- static Timer instance = new Timer();
- LootEvent le = new LootEvent();
- public ConfigurationSection chests() {
- return this.data.data.getConfigurationSection("Chests");
- }
- public void loadchests() {
- for (String s : chests().getKeys(true)) {
- if (!s.contains(".")) {
- World world = Main.pl.getServer().getWorld(chests().getConfigurationSection(s).getString("World"));
- int x = chests().getConfigurationSection(s).getInt("X");
- int y = chests().getConfigurationSection(s).getInt("Y");
- int z = chests().getConfigurationSection(s).getInt("Z");
- Location loc = new Location(world, x, y, z);
- int currenttime = chests().getConfigurationSection(s).getInt("TimeToDelete");
- Main.pl.chests.put(loc, Integer.valueOf(currenttime));
- chests().set(s, null);
- }
- }
- this.data.saveData();
- }
- public void saveChests() {
- int counter = 0;
- for (Map.Entry<Location, Integer> e : Main.pl.chests.entrySet()) {
- Location loc = (Location) e.getKey();
- chests().createSection("Chest" + counter);
- chests().getConfigurationSection("Chest" + counter).set("World", loc.getWorld().getName());
- chests().getConfigurationSection("Chest" + counter).set("X", Integer.valueOf(loc.getBlockX()));
- chests().getConfigurationSection("Chest" + counter).set("Y", Integer.valueOf(loc.getBlockY()));
- chests().getConfigurationSection("Chest" + counter).set("Z", Integer.valueOf(loc.getBlockZ()));
- chests().getConfigurationSection("Chest" + counter).set("TimeToDelete", e.getValue());
- this.data.saveData();
- counter++;
- }
- this.data.saveData();
- }
- public void decrease() {
- new BukkitRunnable() {
- public void run() {
- try {
- for (Map.Entry<Location, Integer> e : Main.pl.chests.entrySet()) {
- int timetodelete = ((Integer) e.getValue()).intValue();
- if (timetodelete > 0) {
- int fixed = timetodelete - 1;
- e.setValue(Integer.valueOf(fixed));
- continue;
- }
- Location loc = (Location) e.getKey();
- Timer.this.le.deleteChest(loc);
- if (Main.pl.getConfig().getBoolean("BroadcastKillMessage")) {
- String string = Main.pl.getConfig().getString("BroadcastMessage").replace("&", "�");
- String x1 = (new StringBuilder(String.valueOf(loc.getBlockX()))).toString();
- String y1 = (new StringBuilder(String.valueOf(loc.getBlockY()))).toString();
- String z1 = (new StringBuilder(String.valueOf(loc.getBlockZ()))).toString();
- String string2 = string.replace("{X}", x1);
- String string3 = string2.replace("{Y}", y1);
- String string4 = string3.replace("{Z}", z1);
- Main.pl.getServer().broadcastMessage(string4);
- }
- }
- } catch (Exception exception) {
- }
- }
- }.runTaskTimer(Main.pl, 20, 20L);
- }
- }package me.bricedev.wrcp;
- import java.util.Map;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.configuration.ConfigurationSection;
- import org.bukkit.scheduler.BukkitRunnable;
- public class Timer {
- Database data = Database.instance;
- static Timer instance = new Timer();
- LootEvent le = new LootEvent();
- public ConfigurationSection chests() {
- return this.data.data.getConfigurationSection("Chests");
- }
- public void loadchests() {
- for (String s : chests().getKeys(true)) {
- if (!s.contains(".")) {
- World world = Main.pl.getServer().getWorld(chests().getConfigurationSection(s).getString("World"));
- int x = chests().getConfigurationSection(s).getInt("X");
- int y = chests().getConfigurationSection(s).getInt("Y");
- int z = chests().getConfigurationSection(s).getInt("Z");
- Location loc = new Location(world, x, y, z);
- int currenttime = chests().getConfigurationSection(s).getInt("TimeToDelete");
- Main.pl.chests.put(loc, Integer.valueOf(currenttime));
- chests().set(s, null);
- }
- }
- this.data.saveData();
- }
- public void saveChests() {
- int counter = 0;
- for (Map.Entry<Location, Integer> e : Main.pl.chests.entrySet()) {
- Location loc = (Location) e.getKey();
- chests().createSection("Chest" + counter);
- chests().getConfigurationSection("Chest" + counter).set("World", loc.getWorld().getName());
- chests().getConfigurationSection("Chest" + counter).set("X", Integer.valueOf(loc.getBlockX()));
- chests().getConfigurationSection("Chest" + counter).set("Y", Integer.valueOf(loc.getBlockY()));
- chests().getConfigurationSection("Chest" + counter).set("Z", Integer.valueOf(loc.getBlockZ()));
- chests().getConfigurationSection("Chest" + counter).set("TimeToDelete", e.getValue());
- this.data.saveData();
- counter++;
- }
- this.data.saveData();
- }
- public void decrease() {
- new BukkitRunnable() {
- public void run() {
- try {
- for (Map.Entry<Location, Integer> e : Main.pl.chests.entrySet()) {
- int timetodelete = ((Integer) e.getValue()).intValue();
- if (timetodelete > 0) {
- int fixed = timetodelete - 1;
- e.setValue(Integer.valueOf(fixed));
- continue;
- }
- Location loc = (Location) e.getKey();
- Timer.this.le.deleteChest(loc);
- if (Main.pl.getConfig().getBoolean("BroadcastKillMessage")) {
- String string = Main.pl.getConfig().getString("BroadcastMessage").replace("&", "�");
- String x1 = (new StringBuilder(String.valueOf(loc.getBlockX()))).toString();
- String y1 = (new StringBuilder(String.valueOf(loc.getBlockY()))).toString();
- String z1 = (new StringBuilder(String.valueOf(loc.getBlockZ()))).toString();
- String string2 = string.replace("{X}", x1);
- String string3 = string2.replace("{Y}", y1);
- String string4 = string3.replace("{Z}", z1);
- Main.pl.getServer().broadcastMessage(string4);
- }
- }
- } catch (Exception exception) {
- }
- }
- }.runTaskTimer(Main.pl, 20, 20L);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement