Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Decompiled with CFR 0_118.
- *
- * Could not load the following classes:
- * org.bukkit.ChatColor
- * org.bukkit.Material
- * org.bukkit.Server
- * org.bukkit.World
- * org.bukkit.block.Block
- * org.bukkit.command.Command
- * org.bukkit.command.CommandExecutor
- * org.bukkit.command.CommandSender
- * org.bukkit.command.PluginCommand
- * org.bukkit.configuration.file.FileConfiguration
- * org.bukkit.configuration.file.FileConfigurationOptions
- * org.bukkit.entity.Player
- * org.bukkit.event.EventHandler
- * org.bukkit.event.Listener
- * org.bukkit.event.block.Action
- * org.bukkit.event.player.PlayerInteractEvent
- * org.bukkit.plugin.Plugin
- * org.bukkit.plugin.PluginManager
- * org.bukkit.plugin.java.JavaPlugin
- * pl.islandworld.api.IslandWorldApi
- */
- package pl.iwhr;
- import java.io.File;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.logging.Logger;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.Server;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.command.PluginCommand;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.FileConfigurationOptions;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import pl.islandworld.api.IslandWorldApi;
- import pl.iwhr.listeners.RankListener;
- public class IWHeadRank
- extends JavaPlugin
- implements CommandExecutor,
- Listener {
- public static boolean DEBUG = false;
- private List<String> cList = new ArrayList<String>();
- private Player coordsPlayer = null;
- public void onEnable() {
- File configFile = new File(this.getDataFolder(), "config.yml");
- if (!configFile.exists()) {
- this.saveDefaultConfig();
- this.getLogger().info("Writing default config to file.");
- }
- this.saveOurConfig(configFile);
- if (!IslandWorldApi.isInitialized()) {
- this.showWarn("IslandWorldAPI not ready, cannot start!", true);
- return;
- }
- this.getServer().getPluginManager().registerEvents((Listener)new RankListener(this), (Plugin)this);
- this.getCommand("headrank").setExecutor((CommandExecutor)this);
- this.getServer().getPluginManager().registerEvents((Listener)this, (Plugin)this);
- this.getLogger().info("Plugin enabled");
- }
- public boolean onCommand(CommandSender sender, Command command, String label, String[] split) {
- if (!(sender instanceof Player)) {
- return false;
- }
- Player player = (Player)sender;
- String param1 = null;
- if (split.length >= 1) {
- param1 = split[0];
- }
- if (param1 == null) {
- this.showUsage(player);
- } else if (param1.equalsIgnoreCase("start")) {
- if (player.hasPermission("islandworld.headrank.start")) {
- if (this.coordsPlayer == null) {
- this.cList.clear();
- this.coordsPlayer = player;
- this.showMsg(sender, "Coords gather start");
- } else {
- this.showError(sender, "Player " + (Object)this.coordsPlayer + " already is gathering coords!");
- }
- } else {
- this.showError(sender, "You dont have permission to use that command!");
- }
- } else if (param1.equalsIgnoreCase("stop")) {
- if (player.hasPermission("islandworld.headrank.stop")) {
- if (this.coordsPlayer != null) {
- if (!this.cList.isEmpty()) {
- this.getConfig().set("table-coords", this.cList);
- this.saveConfig();
- this.reloadConfig();
- this.showMsg((CommandSender)player, "Coords saved");
- } else {
- this.showError(sender, "Nothing to write!");
- }
- this.cList.clear();
- this.coordsPlayer = null;
- } else {
- this.showError(sender, "Nobody is gathering coords right now!");
- }
- } else {
- this.showError(sender, "You dont have permission to use that command!");
- }
- } else if (param1.equalsIgnoreCase("world")) {
- if (player.hasPermission("islandworld.headrank.world")) {
- this.getConfig().set("world", (Object)player.getWorld().getName());
- this.saveConfig();
- this.reloadConfig();
- this.showMsg((CommandSender)player, "World saved");
- } else {
- this.showError(sender, "You dont have permission to use that command!");
- }
- }
- return true;
- }
- @EventHandler
- public void onCoordsInteract(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- Action a = event.getAction();
- Block b = event.getClickedBlock();
- if (b != null && player != null && this.coordsPlayer != null && this.coordsPlayer instanceof Player && this.coordsPlayer == player) {
- String option = String.valueOf(b.getX()) + " " + b.getY() + " " + b.getZ();
- if (b.getType() == Material.WALL_SIGN) {
- if (a == Action.LEFT_CLICK_BLOCK) {
- if (!this.cList.contains(option)) {
- this.cList.add(option);
- this.showMsg((CommandSender)player, "Added coord " + option);
- } else {
- this.showError((CommandSender)player, "Coord " + option + " already on list!");
- }
- } else if (a == Action.RIGHT_CLICK_BLOCK) {
- if (this.cList.contains(option)) {
- this.cList.remove(option);
- this.showMsg((CommandSender)player, "Removed coord " + option + " from coord list");
- } else {
- this.showError((CommandSender)player, "Coord " + option + " not on list.");
- }
- }
- } else {
- this.showError((CommandSender)player, "I can save only coords of Signs");
- }
- }
- }
- private void showMsg(CommandSender sender, String text) {
- if (sender != null) {
- sender.sendMessage((Object)ChatColor.GREEN + text);
- }
- }
- public boolean showError(CommandSender sender, String text) {
- if (sender != null) {
- sender.sendMessage((Object)ChatColor.DARK_RED + "IWHR: " + (Object)ChatColor.RED + text);
- }
- return false;
- }
- public void showUsage(Player player) {
- }
- private void showWarn(String msg, boolean isError) {
- this.getLogger().warning("============================");
- if (isError) {
- this.getLogger().warning("ERROR");
- }
- this.getLogger().warning(msg);
- this.getLogger().warning("============================");
- }
- private void saveOurConfig(File file) {
- this.getConfig().options().copyHeader(true);
- this.getConfig().options().copyDefaults(true);
- try {
- this.getConfig().save(file);
- }
- catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement