/* * Copyright (C) 2015 eccentric_nz * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package me.eccentric_nz.TARDIS.junk; import java.util.HashMap; import me.eccentric_nz.TARDIS.TARDIS; import me.eccentric_nz.TARDIS.commands.admin.TARDISDeleteCommand; import me.eccentric_nz.TARDIS.database.ResultSetCurrentLocation; import me.eccentric_nz.TARDIS.database.ResultSetTardisID; import me.eccentric_nz.TARDIS.destroyers.DestroyData; import me.eccentric_nz.TARDIS.enumeration.COMPASS; import me.eccentric_nz.TARDIS.enumeration.SCHEMATIC; import me.eccentric_nz.TARDIS.utility.TARDISMessage; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.command.CommandSender; /** * * @author eccentric_nz */ public class TARDISJunkDelete { private final TARDIS plugin; public TARDISJunkDelete(TARDIS plugin) { this.plugin = plugin; } public boolean delete(final CommandSender sender) { if (!sender.hasPermission("tardis.admin")) { TARDISMessage.send(sender, "CMD_ADMIN"); return true; } ResultSetTardisID rs = new ResultSetTardisID(plugin); if (rs.fromUUID("00000000-aaaa-bbbb-cccc-000000000000")) { final int id = rs.getTardis_id(); final SCHEMATIC junk = new SCHEMATIC("AIR", "junk", "Junk TARDIS", true, false, false, false, false); // get the current location Location bb_loc = null; Biome biome = null; HashMap<String, Object> wherecl = new HashMap<String, Object>(); wherecl.put("tardis_id", id); ResultSetCurrentLocation rsc = new ResultSetCurrentLocation(plugin, wherecl); if (rsc.resultSet()) { bb_loc = new Location(rsc.getWorld(), rsc.getX(), rsc.getY(), rsc.getZ()); biome = rsc.getBiome(); } if (bb_loc == null) { TARDISMessage.send(sender, "CURRENT_NOT_FOUND"); return true; } // destroy junk TARDIS final DestroyData dd = new DestroyData(plugin, "00000000-aaaa-bbbb-cccc-000000000000"); dd.setChameleon(false); dd.setDirection(COMPASS.SOUTH); dd.setLocation(bb_loc); dd.setHide(false); dd.setOutside(false); dd.setSubmarine(rsc.isSubmarine()); dd.setTardisID(id); dd.setBiome(biome); plugin.getPresetDestroyer().destroyPreset(dd); // destroy the vortex TARDIS final World cw = plugin.getServer().getWorld(plugin.getConfig().getString("creation.default_world_name")); // give the TARDIS time to remove itself as it's not hidden if (cw != null) { plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { @Override public void run() { plugin.getInteriorDestroyer().destroyInner(junk, id, cw, 0, "junk", -999); TARDISDeleteCommand.cleanDatabase(id); TARDISMessage.send(sender, "JUNK_DELETED"); } }, 20L); } } return true; } }