Ejemplo n.º 1
0
  @SuppressWarnings("static-access")
  public void onPlayerJoin(PlayerJoinEvent event) {

    Player player = event.getPlayer();
    plugin.Tools.checkAccount(player);
    if (plugin.SpoutEnabled && plugin.EnableSkillMastery && plugin.EnableCapes) {
      SpoutPlayer sp = (SpoutPlayer) event.getPlayer();
      File CapeFile = new File(plugin.getDataFolder() + "/Data/Cape.data");
      if (plugin.FlatFile.contains(sp.getName(), CapeFile)) {
        AppearanceManager appearM = SpoutManager.getAppearanceManager();
        appearM.setGlobalCloak(
            sp,
            "http://cloud.github.com/downloads/samkio/Levelcraft/"
                + plugin.FlatFile.getString(sp.getName(), CapeFile)
                + ".png");
        return;
      }
      for (Plugin plug : plugin.LevelNames.keySet()) {
        if (!plugin.Permissions.hasLevel(player, plug)) continue;
        if (!(plugin.LevelFunctions.getLevel(player, plug) >= plugin.LevelCap)) continue;
        AppearanceManager appearM = SpoutManager.getAppearanceManager();
        appearM.setGlobalCloak(
            sp,
            "http://cloud.github.com/downloads/samkio/Levelcraft/"
                + plugin.LevelNames.get(plug)
                + ".png");
        return;
      }
    }
  }
Ejemplo n.º 2
0
  public void onButtonClick(ButtonClickEvent event) {
    SpoutPlayer player = event.getPlayer();
    String name = player.getName();

    if (event.getButton().getText().equals("Cancel")) {
      event.getPlayer().getMainScreen().closePopup();
      plugin.openChest(player);
    } else if (event.getButton().getText().equals("O.K")) {
      World world = plugin.death.getWorld(name);
      Location loc = plugin.death.getLoc(name);

      plugin.deposit.remove(player.getName());
      event.getPlayer().getMainScreen().closePopup();

      for (ItemStack item : player.getInventory().getContents()) {
        if (item != null) world.dropItem(loc, item);
      }
      for (int i = 0; i < 36; i++) player.getInventory().clear(i);
    }
  }
Ejemplo n.º 3
0
 @Override
 public void run(SpoutPlayer sp) {
   RushMe.getInstance()
       .getLogger()
       .debugLog(Level.INFO, "Running PacketGrenadeUpdate for " + sp.getName());
   Grenade grenade = GrenadeManager.getGrenade(name);
   if (grenade == null) {
     grenade =
         GrenadeManager.createGrenade(
             name,
             null,
             shortName,
             type,
             startAmount,
             explosionSize,
             timeBeforeExplosion,
             damage,
             stunTime,
             uuid);
   }
   grenade.setAmount(amount);
 }
Ejemplo n.º 4
0
 @Override
 public void onKeyReleasedEvent(KeyReleasedEvent event) {
   SpoutPlayer player = event.getPlayer();
   PlayerOptions.removePressed(player.getName(), event.getKey());
 }
Ejemplo n.º 5
0
  @Override
  public void onKeyPressedEvent(KeyPressedEvent event) {
    if (event.getScreenType() != ScreenType.GAME_SCREEN) {
      return;
    }
    SpoutPlayer player = event.getPlayer();

    PlayerOptions po = PlayerOptions.getPlayer(player);
    String msg = "";

    if (Utils.isValidModifier(event.getKey())) {
      PlayerOptions.addPressed(player.getName(), event.getKey());
      return;
    }

    ChooseMode mode = PlayerOptions.getMode(player);

    boolean valid = Utils.isValidKey(player, event.getKey());
    if (!valid) {
      switch (mode) {
        case SET:
        case GSET:
          player.sendMessage(ChatColor.RED + "That key combination is not valid.");
      }
      return;
    }

    LinkedHashSet<Keyboard> allPressed = PlayerOptions.getPressed(player.getName());
    allPressed.add(event.getKey());

    if (mode == ChooseMode.NONE) {
      if (!Permission.check(player, "SpoutKeyCommands.use")) {
        return;
      }

      PlayerCmd pc = PlayerCmd.get(player, allPressed);
      GlobalCmd gc = GlobalCmd.get(allPressed);
      if (pc == null && gc == null) {
        return;
      }

      String perf = po.getPreferred();

      if (perf.equalsIgnoreCase("global") && gc != null || pc == null) {
        player.performCommand(gc.getCommand());
      } else if (perf.equalsIgnoreCase("personal") && pc != null || pc != null) {
        player.performCommand(pc.getCommand());
      }

      return;
    }

    String cmd = PlayerOptions.getCmd(player);

    PluginManager pm = Bukkit.getServer().getPluginManager();
    String pluginName = SpoutKeyCommands.getInstance().getDescription().getName();

    PlayerCmd pc = null;
    GlobalCmd gc = null;

    switch (mode) {
      case SET:
        if (cmd.equals("")) {
          return;
        }
        msg =
            ChatColor.DARK_AQUA
                + "Command set to: "
                + ChatColor.GREEN
                + Utils.getKeyString(allPressed);

        pc = PlayerCmd.get(player, allPressed);
        if (pc != null) {
          if (!pluginName.equals(pc.getPlugin())) {
            Plugin p = pm.getPlugin(pc.getPlugin());
            if (p != null && p.isEnabled()) {
              msg = ChatColor.RED + "That key is already set by " + pc.getPlugin();
              break;
            }
          }

          pc.setCommand(cmd);
          pc.setPlugin(pluginName);
          SpoutKeyCommands.getInstance().getDatabase().update(pc);
          break;
        }

        pc = new PlayerCmd(allPressed, cmd, player, SpoutKeyCommands.getInstance());
        SpoutKeyCommands.getInstance().getDatabase().save(pc);
        break;

      case GSET:
        if (cmd.equals("")) {
          return;
        }
        msg =
            ChatColor.DARK_AQUA
                + "Global command set to: "
                + ChatColor.GREEN
                + Utils.getKeyString(allPressed);

        gc = GlobalCmd.get(allPressed);
        if (gc != null) {
          if (!pluginName.equals(gc.getPlugin())) {
            Plugin p = pm.getPlugin(gc.getPlugin());
            if (p != null && p.isEnabled()) {
              msg = ChatColor.RED + "That key is already set by " + gc.getPlugin();
              break;
            }
          }

          gc.setCommand(cmd);
          gc.setPlugin(pluginName);
          SpoutKeyCommands.getInstance().getDatabase().update(gc);
          break;
        }

        gc = new GlobalCmd(allPressed, cmd, SpoutKeyCommands.getInstance());
        SpoutKeyCommands.getInstance().getDatabase().save(gc);
        break;

      case UNSET:
        pc = PlayerCmd.get(player, allPressed);
        if (pc == null) {
          msg = ChatColor.RED + "No command on this combination";
          break;
        }

        if (!pluginName.equals(pc.getPlugin())) {
          Plugin p = pm.getPlugin(pc.getPlugin());
          if (p != null && p.isEnabled()) {
            msg = ChatColor.RED + "That key is set by " + pc.getPlugin();
            break;
          }
        }

        SpoutKeyCommands.getInstance().getDatabase().delete(pc);
        msg =
            ChatColor.DARK_AQUA
                + "Command unset from: "
                + ChatColor.GREEN
                + Utils.getKeyString(allPressed);
        break;

      case GUNSET:
        gc = GlobalCmd.get(allPressed);
        if (gc == null) {
          msg = ChatColor.RED + "No global command on this combination";
          break;
        }

        if (!pluginName.equals(gc.getPlugin())) {
          Plugin p = pm.getPlugin(gc.getPlugin());
          if (p != null && p.isEnabled()) {
            msg = ChatColor.RED + "That key is already set by " + gc.getPlugin();
            break;
          }
        }

        SpoutKeyCommands.getInstance().getDatabase().delete(gc);
        msg =
            ChatColor.DARK_AQUA
                + "Global command unset from: "
                + ChatColor.GREEN
                + Utils.getKeyString(allPressed);
        break;
    }

    player.sendMessage(msg);
  }