@Override
 public List<String> onTabComplete(
     CommandSender sender, Minigame minigame, String alias, String[] args) {
   if (args.length == 1)
     return MinigameUtils.tabCompleteMatch(
         MinigameUtils.stringToList("true;false;add;remove;list;clear"), args[0]);
   else if (args.length == 2 && args[0].equalsIgnoreCase("remove")) {
     List<String> ls = new ArrayList<String>();
     for (Material m : minigame.getBlockRecorder().getWBBlocks()) {
       ls.add(m.toString());
     }
     return MinigameUtils.tabCompleteMatch(ls, args[1]);
   }
   return null;
 }
예제 #2
0
 @Override
 public boolean displayMenu(MinigamePlayer player, Menu previous) {
   Menu m = new Menu(3, "Flight", player);
   m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, previous), m.getSize() - 9);
   m.addItem(setFly.getMenuItem("Set Flight Mode", Material.FEATHER));
   m.addItem(
       startFly.getMenuItem(
           "Set Flying",
           Material.FEATHER,
           MinigameUtils.stringToList("Set Flight Mode must be;true to use this")));
   m.displayMenu(player);
   return true;
 }
예제 #3
0
 @Override
 public boolean signCreate(SignChangeEvent event) {
   if (plugin.mdata.hasMinigame(event.getLine(2))) {
     event.setLine(1, ChatColor.GREEN + "Bet");
     event.setLine(2, plugin.mdata.getMinigame(event.getLine(2)).getName(false));
     if (event.getLine(3).matches("[0-9]+")) {
       event.setLine(3, "$" + event.getLine(3));
     }
     return true;
   }
   event
       .getPlayer()
       .sendMessage(
           ChatColor.RED
               + "[Minigames] "
               + ChatColor.WHITE
               + MinigameUtils.formStr("minigame.error.noMinigameName", event.getLine(2)));
   return false;
 }
예제 #4
0
  @Override
  public boolean signUse(Sign sign, MinigamePlayer player) {
    Minigame mgm = plugin.mdata.getMinigame(sign.getLine(2));
    if (mgm != null) {
      boolean invOk = true;
      boolean fullInv;
      boolean moneyBet = sign.getLine(3).startsWith("$");

      if (plugin.getConfig().getBoolean("requireEmptyInventory")) {
        fullInv = true;
        ItemStack[] contents = player.getPlayer().getInventory().getContents();
        for (int i = 0; i < contents.length; ++i) {
          // Non money bets can hold an item
          if (!moneyBet && i == player.getPlayer().getInventory().getHeldItemSlot()) {
            continue;
          }

          if (contents[i] != null) {
            invOk = false;
            break;
          }
        }

        for (ItemStack item : player.getPlayer().getInventory().getArmorContents()) {
          if (item != null && item.getType() != Material.AIR) {
            invOk = false;
            break;
          }
        }
      } else {
        fullInv = false;
        invOk =
            (moneyBet
                ? player.getPlayer().getItemInHand().getType() == Material.AIR
                : player.getPlayer().getItemInHand().getType() != Material.AIR);
      }

      if (invOk) {
        if (mgm.isEnabled()
            && (!mgm.getUsePermissions()
                || player
                    .getPlayer()
                    .hasPermission("minigame.join." + mgm.getName(false).toLowerCase()))) {
          if (mgm.isSpectator(player)) {
            return false;
          }

          if (!sign.getLine(3).startsWith("$")) {
            plugin.pdata.joinMinigame(player, plugin.mdata.getMinigame(sign.getLine(2)), true, 0.0);
          } else {
            if (plugin.hasEconomy()) {
              Double bet = Double.parseDouble(sign.getLine(3).replace("$", ""));
              plugin.pdata.joinMinigame(
                  player, plugin.mdata.getMinigame(sign.getLine(2)), true, bet);
              return true;
            } else {
              player.sendMessage(
                  ChatColor.RED
                      + "[Minigames] "
                      + ChatColor.WHITE
                      + MinigameUtils.getLang("minigame.error.noVault"));
            }
          }
        } else if (!mgm.isEnabled()) {
          player.sendMessage(
              ChatColor.AQUA
                  + "[Minigames] "
                  + ChatColor.WHITE
                  + MinigameUtils.getLang("minigame.error.notEnabled"));
        } else if (mgm.getUsePermissions()) {
          player.sendMessage(
              ChatColor.AQUA
                  + "[Minigames] "
                  + ChatColor.WHITE
                  + MinigameUtils.formStr(
                      "minigame.error.noPermission",
                      "minigame.join." + mgm.getName(false).toLowerCase()));
        }
      } else if (!moneyBet) {
        if (fullInv && player.getPlayer().getItemInHand().getType() != Material.AIR) {
          player.sendMessage(
              ChatColor.AQUA
                  + "[Minigames] "
                  + ChatColor.WHITE
                  + MinigameUtils.getLang("sign.emptyInv"));
        } else {
          player.sendMessage(
              ChatColor.RED
                  + "[Minigames] "
                  + ChatColor.WHITE
                  + MinigameUtils.getLang("sign.bet.noBet"));
        }
      } else {
        if (fullInv) {
          player.sendMessage(
              ChatColor.AQUA
                  + "[Minigames] "
                  + ChatColor.WHITE
                  + MinigameUtils.getLang("sign.emptyInv"));
        } else {
          player.sendMessage(
              ChatColor.AQUA
                  + "[Minigames] "
                  + ChatColor.WHITE
                  + MinigameUtils.getLang("sign.emptyHand"));
        }
      }
    } else {
      player.sendMessage(
          ChatColor.RED
              + "[Minigames] "
              + ChatColor.WHITE
              + MinigameUtils.getLang("minigame.error.noMinigame"));
    }
    return false;
  }
예제 #5
0
 @Override
 public String getUsePermissionMessage() {
   return MinigameUtils.getLang("sign.bet.usePermission");
 }