コード例 #1
0
  public void onEnable() {
    ButtonControlPermissions.initialize(getServer());

    new File(mainDir).mkdir();
    if (!BW.exists()) {
      try {
        BW.createNewFile();
        config.setProperty("Duration.sun", sd);
        config.setProperty("Duration.rain", rd);
        config.setProperty("Duration.thunder", td);
        config.setProperty("Cost.Item", item);
        config.setProperty("iConomy.useiConomy", icon);
        config.setProperty("Buttons.SunnyAnzahl", 0);
        config.setProperty("Buttons.RainAnzahl", 0);
        config.setProperty("Buttons.ThunderAnzahl", 0);
        config.setProperty("Messages.push_a_button", messages[0]);
        config.setProperty("Messages.not_permissions", messages[1]);
        config.setProperty("Messages.sun_comes", messages[2]);
        config.setProperty("Messages.not_enough_money", messages[3]);
        config.setProperty("Messages.rain_comes", messages[4]);
        config.setProperty("Messages.thunder_comes", messages[5]);
        config.setProperty("Messages.rain_set", messages[6]);
        config.setProperty("Messages.thunder_set", messages[7]);
        config.setProperty("Messages.sunny_set", messages[8]);
        config.setProperty("Messages.day_set", messages[9]);
        config.setProperty("Messages.night_set", messages[10]);
        config.setProperty("Messages.day_comes", messages[11]);
        config.setProperty("Messages.night_comes", messages[12]);
        config.setProperty("Messages.not_use", messages[13]);
        config.setProperty("iConomy.account", acc);
        config.setProperty("Cooldown", cooldown);
        config.save();
        System.out.println("[ButtonControl] Config-File created.");
        this.loadFile();
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else {
      loadFile();
    }
    this.PL = new ButtonControlPlayerListener(this);
    this.BL = new ButtonControlBlockListener(this);
    this.SL = new ButtonControlServerListener(this);
    this.WL = new ButtonControlWeatherListener(this);
    PluginManager pm = this.getServer().getPluginManager();
    pm.registerEvent(Event.Type.BLOCK_BREAK, BL, Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_INTERACT, PL, Priority.Normal, this);
    pm.registerEvent(Event.Type.WEATHER_CHANGE, WL, Priority.Highest, this);
    pm.registerEvent(Event.Type.PLUGIN_ENABLE, SL, Priority.Normal, this);
    pm.registerEvent(Event.Type.PLUGIN_DISABLE, SL, Priority.Normal, this);
    PluginDescriptionFile pdf = this.getDescription();
    System.out.println("ButtonControl v" + pdf.getVersion() + " aktiviert.");
  }
コード例 #2
0
  public boolean onCommand(
      CommandSender sender, Command command, String commandLabel, String[] args) {
    String[] split = args;
    String commandName = command.getName().toLowerCase();

    // if (!(sender instanceof Player))return false;

    if (commandName.equals("buttoncontrol") || commandName.equals("bc")) {
      Player player = (Player) sender;
      if (ButtonControlPermissions.canSetButtons(player)) {
        if (split.length == 2 && split[0].equalsIgnoreCase("rain")) {
          // if (args.length != 2) return false;
          push = 1;
          pcost = Integer.parseInt(args[1]);
          sender.sendMessage(ChatColor.RED + messages[0]);
          return true;
        }
        if (split.length == 2 && split[0].equalsIgnoreCase("thunder")) {
          // if (args.length != 2) return false;
          push = 2;
          pcost = Integer.parseInt(args[1]);
          sender.sendMessage(ChatColor.RED + messages[0]);
          return true;
        }
        if (split.length == 2 && split[0].equalsIgnoreCase("sunny")) {
          // if (args.length != 2) return false;
          push = 3;
          pcost = Integer.parseInt(args[1]);
          sender.sendMessage(ChatColor.RED + messages[0]);
          return true;
        }
        if (split.length == 2 && split[0].equalsIgnoreCase("day")) {
          // if (args.length != 2) return false;
          push = 4;
          pcost = Integer.parseInt(args[1]);
          sender.sendMessage(ChatColor.RED + messages[0]);
          return true;
        }
        if (split.length == 2 && split[0].equalsIgnoreCase("night")) {
          // if (args.length != 2) return false;
          push = 5;
          pcost = Integer.parseInt(args[1]);
          sender.sendMessage(ChatColor.RED + messages[0]);
          return true;
        }
      } else {
        sender.sendMessage(messages[1]);
        return true;
      }
    }
    return false;
  }