@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
 public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
   Player p = event.getPlayer();
   if (FlyingPlayer.isFlying(p)) {
     event.setCancelled(p.getGameMode() != GameMode.CREATIVE);
   }
 }
Ejemplo n.º 2
0
  /** Removes chests when they're destroyed. */
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onBreak(final BlockBreakEvent e) {
    if (e.isCancelled()) return;

    Block b = e.getBlock();
    Player p = e.getPlayer();

    // If the chest was a chest
    if (b.getType() == Material.CHEST) {
      Shop shop = plugin.getShopManager().getShop(b.getLocation());
      // If it was a shop
      if (shop != null) {
        if (plugin.lock) {
          // If they owned it or have bypass perms, they can destroy it
          if (!shop.getOwner().equalsIgnoreCase(p.getName())
              && !p.hasPermission("quickshop.other.destroy")) {
            e.setCancelled(true);
            p.sendMessage(MsgUtil.getMessage("no-permission"));
            return;
          }
        }

        // If they're either survival or the owner, they can break it
        if (p.getGameMode() == GameMode.CREATIVE
            && !p.getName().equalsIgnoreCase(shop.getOwner())) {
          e.setCancelled(true);
          p.sendMessage(MsgUtil.getMessage("no-creative-break"));
          return;
        }

        // Cancel their current menu... Doesnt cancel other's menu's.
        Info action = plugin.getShopManager().getActions().get(p.getName());
        if (action != null) {
          action.setAction(ShopAction.CANCELLED);
        }
        shop.delete();
        p.sendMessage(MsgUtil.getMessage("success-removed-shop"));
      }
    } else if (b.getType() == Material.WALL_SIGN) {
      Shop shop = getShopNextTo(e.getBlock().getLocation());
      if (shop != null) { // It is a shop sign we're dealing with.
        if (plugin.lock) {
          // If they're the shop owner or have bypass perms, they can destroy it.
          if (!shop.getOwner().equalsIgnoreCase(p.getName())
              && !e.getPlayer().hasPermission("quickshop.other.destroy")) {
            e.setCancelled(true);
            p.sendMessage(MsgUtil.getMessage("no-permission"));
            return;
          }
        }
        // If they're in creative and not the owner, don't let them (accidents happen)
        if (p.getGameMode() == GameMode.CREATIVE
            && !p.getName().equalsIgnoreCase(shop.getOwner())) {
          e.setCancelled(true);
          p.sendMessage(MsgUtil.getMessage("no-creative-break"));
          return;
        }
      }
    }
  }
Ejemplo n.º 3
0
 /**
  * Handles the gamemode for the specified {@link Player}.
  *
  * @param player The {@link Player}.
  * @param world The world the player is in.
  */
 public void handleGameModeAndFlight(final Player player, final MultiverseWorld world) {
   if (!MVPlayerListener.this.pt.playerCanIgnoreGameModeRestriction(world, player)) {
     // Check that the player is in the new world and they haven't been teleported elsewhere or the
     // event cancelled.
     if (player.getWorld() == world.getCBWorld()) {
       Logging.fine(
           "Handling gamemode for player: %s, Changing to %s",
           player.getName(), world.getGameMode().toString());
       Logging.finest("From World: %s", player.getWorld());
       Logging.finest("To World: %s", world);
       player.setGameMode(world.getGameMode());
       // Check if their flight mode should change
       // TODO need a override permission for this
       if (player.getAllowFlight()
           && !world.getAllowFlight()
           && player.getGameMode() != GameMode.CREATIVE) {
         player.setAllowFlight(false);
         if (player.isFlying()) {
           player.setFlying(false);
         }
       } else if (world.getAllowFlight()) {
         if (player.getGameMode() == GameMode.CREATIVE) {
           player.setAllowFlight(true);
         }
       }
     } else {
       Logging.fine(
           "The gamemode/allowfly was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'",
           player.getName(), player.getWorld().getName(), world.getName());
     }
   } else {
     MVPlayerListener.this.plugin.log(
         Level.FINE, "Player: " + player.getName() + " is IMMUNE to gamemode changes!");
   }
 }
Ejemplo n.º 4
0
 @SuppressWarnings({"deprecation", "rawtypes"})
 public void run() {
   if (deadPlayer.getGameMode() == GameMode.CREATIVE) {
     deadPlayer.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 1));
     deadPlayer.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 1000000, 1));
   }
   if (deadPlayer.getGameMode() == GameMode.SURVIVAL) {
     deadPlayer.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 200, 0));
   }
   deadPlayer.teleport(respawnLoc);
   if (deadPlayer.getGameMode() != GameMode.CREATIVE) {
     inv.clear();
     ItemStack item;
     Iterator iterItems = Var.items.iterator();
     Iterator iterAmounts = Var.amounts.iterator();
     for (int i = 1; i <= Var.itemAmount; i++) {
       if (iterItems.hasNext() && iterAmounts.hasNext()) {
         Object idEntry = iterItems.next();
         Object amountEntry = iterAmounts.next();
         item =
             new ItemStack(
                 Integer.parseInt(idEntry.toString()), Integer.parseInt(amountEntry.toString()));
         inv.setItem(i - 1, item);
       }
     }
     if (Var.helmet != 0) {
       ItemStack helmet = new ItemStack(Var.helmet, 1);
       deadPlayer.getInventory().setHelmet(helmet);
     } else {
       deadPlayer.getInventory().setHelmet(null);
     }
     if (Var.chestplate != 0) {
       ItemStack chestplate = new ItemStack(Var.chestplate, 1);
       deadPlayer.getInventory().setChestplate(chestplate);
     } else {
       deadPlayer.getInventory().setChestplate(null);
     }
     if (Var.leggings != 0) {
       ItemStack leggings = new ItemStack(Var.leggings, 1);
       deadPlayer.getInventory().setLeggings(leggings);
     } else {
       deadPlayer.getInventory().setLeggings(null);
     }
     if (Var.boots != 0) {
       ItemStack boots = new ItemStack(Var.boots, 1);
       deadPlayer.getInventory().setBoots(boots);
     } else {
       deadPlayer.getInventory().setBoots(null);
     }
     deadPlayer.updateInventory();
   }
 }
Ejemplo n.º 5
0
 public static void global_quit(Player pl, final Plugin plugin, final PlayerQuitEvent event) {
   for (LivingEntity bat : pl.getWorld().getEntitiesByClass(Bat.class)) {
     if (bat.hasMetadata("invincible")) {
       if (pl.hasMetadata("batman")) {
         if (((MetadataValue) pl.getMetadata("batman").get(0))
             .asString()
             .toString()
             .contains(
                 ((MetadataValue) bat.getMetadata("invincible").get(0)).asString().toString())) {
           bat.removeMetadata("invincible", plugin);
           bat.damage(1000.0D);
         }
       }
     }
   }
   if (pl.hasMetadata("batman")) {
     pl.removeMetadata("batman", plugin);
   }
   if (pl.hasMetadata("casting")) {
     pl.removeMetadata("casting", plugin);
   }
   if (pl.hasMetadata("using-magic")) {
     pl.removeMetadata("using-magic", plugin);
   }
   if (pl.hasMetadata("satorin0")) {
     pl.removeMetadata("satorin0", plugin);
   }
   if (pl.getGameMode() == GameMode.SPECTATOR) {
     pl.setGameMode(GameMode.SURVIVAL);
   }
   if (pl.hasMetadata("freeze")) {
     pl.removeMetadata("freeze", plugin);
   }
 }
 @Override
 public void exec(
     CommandSender sender, String commandName, String[] args, Player player, boolean isPlayer) {
   if (!isPlayer) {
     sender.sendMessage("This is lost on you");
     return;
   }
   if (player.getGameMode().equals(GameMode.SURVIVAL)) {
     player.setGameMode(GameMode.CREATIVE);
   } else {
     player.setGameMode(GameMode.SURVIVAL);
   }
   this.plugin
       .getLogger()
       .info(player.getName() + " changed game mode to " + player.getGameMode().toString());
 }
Ejemplo n.º 7
0
  public static void createAutoGun(final Player p) {
    if (CreateArenaCommand.creatingArena.get(p) == true) {
      p.sendMessage(Main.codSignature + "§cPlease finish creating your arena first");
      return;
    }

    gunBuilder.put(p, true);
    p.sendMessage(
        Main.codSignature
            + "§7You entered gun creator mode. Type §f/cod guncreator§7 to abort creation");
    p.sendMessage("§21. §aPut the gun item in your hand and right-click");

    gunBuilderStep.put(p, 1);

    gamemode.put(p, p.getGameMode());
    p.setGameMode(GameMode.CREATIVE);

    BukkitRunnable br =
        new BukkitRunnable() {
          @Override
          public void run() {
            if (gunBuilder.get(p)) {
              SendCoolMessages.sendOverActionBar(
                  p, "§7You are in gun creator mode. Type §f/cod guncreator§7 to leave");
            }
          }
        };

    br.runTaskTimer(ThisPlugin.getPlugin(), 0L, 30L);
  }
Ejemplo n.º 8
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onBlockPlace(BlockPlaceEvent event) {
   Player p = event.getPlayer();
   SFPlayer sfp = SFPlayer.getSFPlayer(p);
   if (!p.isOp()) {
     if (plugin.getConfig().getBoolean("features.spawnprotect", true)) {
       boolean inspawn = SFPlugin.isInSpawnProtect(event.getBlock().getLocation(), plugin);
       if (inspawn) {
         event.setCancelled(true);
         p.sendMessage(ChatColor.RED + sfp.translateString("general.inspawnprotect"));
       }
     }
     if (plugin.getConfig().getBoolean("features.bedrockprotect", true)) {
       if (p.getGameMode().equals(GameMode.CREATIVE)) {
         if (!event.isCancelled()) {
           if (event.getBlock().getY() < Double.valueOf(7)
               && event.getBlock().getType().equals(Material.BEDROCK)) {
             event.setCancelled(true);
             p.sendMessage(
                 ChatColor.RED + sfp.translateString("general.bedrockblocked.placement"));
           }
         }
       }
     }
   }
 }
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent event) {
    Player p = event.getPlayer();
    Block b = p.getTargetBlock((Set<Material>) null, p.getGameMode() == GameMode.CREATIVE ? 5 : 4);
    PumpkinCheck check =
        new PumpkinCheck(p.getWorld().getBlockAt(b.getLocation()).getType(), b.getLocation());

    if (targetBlocks.containsKey(p) && targetBlocks.get(p).isPumpkin() && !check.isPumpkin()) {
      Block newBlock = p.getWorld().getBlockAt(targetBlocks.get(p).getLocation());
      byte data = newBlock.getData();

      newBlock.setType(Material.PUMPKIN);
      newBlock.setData(data);
    }

    targetBlocks.put(p, check);

    if (targetBlocks.get(p).isPumpkin()) {
      Block newBlock = p.getWorld().getBlockAt(targetBlocks.get(p).getLocation());
      byte data = newBlock.getData();

      newBlock.setType(Material.JACK_O_LANTERN);
      newBlock.setData(data);
    }
  }
Ejemplo n.º 10
0
 public ArrayList<Player> getInGame() {
   ArrayList<Player> inGame = new ArrayList<Player>();
   for (Player p : Bukkit.getOnlinePlayers()) {
     if (p.getGameMode() == GameMode.SURVIVAL) inGame.add(p);
   }
   return inGame;
 }
Ejemplo n.º 11
0
  public PlayerState(final Player player) {
    name = player.getName();
    debug.i("creating PlayerState of " + name, player);

    fireticks = player.getFireTicks();
    foodlevel = player.getFoodLevel();
    gamemode = player.getGameMode().getValue();
    health = player.getHealth();
    maxhealth = player.getMaxHealth();

    exhaustion = player.getExhaustion();
    experience = player.getExp();
    explevel = player.getLevel();
    saturation = player.getSaturation();

    potionEffects = player.getActivePotionEffects();

    flying = player.isFlying();

    final ArenaPlayer aPlayer = ArenaPlayer.parsePlayer(player.getName());
    final Arena arena = aPlayer.getArena();

    if (arena.getArenaConfig().getBoolean(CFG.CHAT_COLORNICK)) {
      displayname = player.getDisplayName();
    }

    fullReset(arena, player);
    final int time = arena.getArenaConfig().getInt(CFG.GENERAL_TIME);
    if (time != -1) {
      player.setPlayerTime(time, false);
    }
  }
Ejemplo n.º 12
0
  private Boolean canPlayerBypassAFKkick(Player player) {
    if (player.getGameMode() != GameMode.SURVIVAL) {
      return true;
    }

    return false;
  }
  public void setFrozen(boolean freeze) {
    cancel(unfreezeTask);
    unfreezeTask = null;
    freezeLocation = null;

    if (player.getGameMode() != GameMode.CREATIVE) {
      TFM_Util.setFlying(player, false);
    }

    if (!freeze) {
      return;
    }

    freezeLocation = player.getLocation(); // Blockify location
    TFM_Util.setFlying(player, true); // Avoid infinite falling

    unfreezeTask =
        new BukkitRunnable() {
          @Override
          public void run() {
            TFM_Util.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false);
            setFrozen(false);
          }
        }.runTaskLater(TotalFreedomMod.plugin, AUTO_PURGE);
  }
Ejemplo n.º 14
0
  @Override
  public boolean effect(Event event, Player player) {
    int slot = player.getInventory().getHeldItemSlot();

    ItemStack potion = player.getInventory().getItem(slot + 1);
    Location loc = player.getLocation();
    if (potion != null && potion.getType().toString().contains("POTION")) {
      ThrownPotion tp = player.launchProjectile(ThrownPotion.class);
      EffectManager.playSound(loc, "ENTITY_GENERIC_EXPLODE", 0.5f, 2f);

      try {
        tp.setItem(potion);
      } catch (IllegalArgumentException ex) {
        ItemStack pt = potion.clone();
        if (potion.getType().equals(Material.POTION)
            || potion.getType().equals(Material.LINGERING_POTION))
          pt.setType(Material.SPLASH_POTION);
        tp.setItem(pt);
      }

      tp.setBounce(false);
      tp.setVelocity(loc.getDirection().multiply(ProjectileSpeedMultiplier));
      if (!player.getGameMode().equals(GameMode.CREATIVE)) {
        potion.setAmount(potion.getAmount() - 1);
        player.getInventory().setItem(slot + 1, potion);
        player.updateInventory();
      }
      return true;
    } else {
      player.sendMessage(
          ChatColor.RED + "You need a Potion in the slot to the right of the Potion Launcher!");
      player.getWorld().playEffect(loc, Effect.CLICK1, 5);
    }
    return false;
  }
Ejemplo n.º 15
0
 public static void startGame() {
   for (int i = 1; i <= 8; i++) {
     if (i > inqueue.size()) {
       break;
     }
     Player p = Bukkit.getPlayer(inqueue.get(i - 1));
     p.setAllowFlight(false);
     p.setFlying(false);
     if (p.getGameMode() != GameMode.SURVIVAL) {
       p.setGameMode(GameMode.SURVIVAL);
     }
     Location loc = Game.getLocation("Spawn" + i).add(0.5, 1, 0.5);
     p.teleport(loc);
     p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 2));
     invs.put(p.getName(), p.getInventory().getContents());
     armors.put(p.getName(), p.getInventory().getArmorContents());
     p.getInventory().clear();
     p.getInventory().setBoots(null);
     p.getInventory().setLeggings(null);
     p.getInventory().setChestplate(null);
     p.getInventory().setHelmet(null);
     p.updateInventory();
     p.setWalkSpeed(0.2f);
     ParticleEffect.FIREWORKS_SPARK.display(0.5f, 1f, 0.5f, 0.05f, 20, loc, 100);
     ingame.add(p.getName());
   }
   inqueue.removeAll(ingame);
   sendToAll(Game.tag + "§eGame starting.");
   for (int i = 1; i <= inqueue.size(); i++) {
     int util = i - 1;
     Player p = Bukkit.getPlayer(inqueue.get(util));
     p.sendMessage(
         Game.tag + "§eA game has started, you have been moved to §b" + i + "§e in queue.");
   }
 }
Ejemplo n.º 16
0
 @Override
 public void run() {
   for (Entity damagee : affectedWorld.getEntities()) {
     if (StormUtil.isEntityUnderSky(damagee)
         && StormUtil.isSnowy(damagee.getLocation().getBlock().getBiome())) {
       if (StormUtil.isLocationNearBlock(
           damagee.getLocation(), glob.Blizzard_Heating__Blocks, glob.Blizzard_Heat__Radius)) {
         if (glob.Blizzard_Features_Entity__Damaging
             && damagee instanceof LivingEntity
             && !(damagee instanceof Player))
           ((LivingEntity) (damagee)).damage(glob.Blizzard_Entity_Damage__From__Exposure);
         else if (glob.Blizzard_Features_Player__Damaging && damagee instanceof Player) {
           Player dam = (Player) damagee;
           if (!dam.getGameMode().equals(GameMode.CREATIVE)
               && !dam.hasPermission("storm.blizzard.immune")
               && !glob.Blizzard_Heating__Blocks.contains(dam.getItemInHand().getTypeId())) {
             if (dam.getHealth() > 0) {
               dam.addPotionEffect(blindness, true);
               dam.damage(glob.Blizzard_Player_Damage__From__Exposure);
               dam.sendMessage(glob.Blizzard_Messages_On__Player__Damaged__Cold);
               StormUtil.playSound(dam, glob.Blizzard_Sounds_Player__Damage, 1F, 1F);
             }
           }
         }
       }
     }
   }
 }
Ejemplo n.º 17
0
 private void damageEvents(EntityDamageEvent e) {
   if (!(e.getEntity() instanceof Player)) return;
   Player p = (Player) e.getEntity();
   if (p.getGameMode() == GameMode.CREATIVE) return;
   PlayerDetails d = getPlayerDetails(p);
   if (d == null) // make way for hacky plugins!
   return;
   ClassDetails c = MQCoreRPG.classManager.getClassDetail(d.getClassID());
   int amount = c.getDamageFromCause(e.getCause()) + e.getDamage();
   long total = d.getHealth() - amount;
   if (total < 0) total = 0;
   int minecrafthealth = d.getMinecraftHealth(total);
   int minecraftcurrent = p.getHealth();
   e.setDamage(minecraftcurrent - minecrafthealth);
   switch (e.getCause()) {
     case FIRE:
     case CONTACT:
     case LAVA:
     case VOID:
       d.setHealth(total, false);
       break;
     default:
       d.setHealth(total);
       break;
   }
 }
Ejemplo n.º 18
0
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent e) {
    Player p = e.getPlayer();
    Location loc =
        new Location(
            e.getTo().getWorld(),
            (int) e.getTo().getX(),
            (int) e.getTo().getY(),
            (int) e.getTo().getZ());
    if (Main.getInstance().redSpawnArea.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(Area.RED_SPAWN, p));
    }
    if (Main.getInstance().blueSpawnArea.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(Area.BLUE_SPAWN, p));
    }
    if (Main.getInstance().blockspawnAreas.contains(loc)) {
      Bukkit.getPluginManager().callEvent(new AreaWalkEvent(getArea(loc), p));
    }
    if (blockManager.canPickUpBlock(p)) {
      blockManager.pickUpBlock(p);
    }
    if (canGetNeededBlock(p)) {
      if (p.getGameMode() == GameMode.SURVIVAL) {
        gameManager.setCarrying(p, nexusManager.getCurrentNexusColor());
        String[] data = neededBlockMaterial.split(";");
        neededBlock
            .getBlock()
            .setTypeIdAndData(Integer.valueOf(data[0]), Byte.valueOf(data[1]), false);
        neededBlock = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);

        Bukkit.broadcastMessage(
            Color.np(
                "&6The needed block was picked up by the "
                    + teamManager.getTeam(p).getTeamName()
                    + "&6 team!"));
      }
    }
    if ((int) e.getFrom().getX() != (int) e.getTo().getX()
        || (int) e.getFrom().getZ() != (int) e.getTo().getZ()
        || (int) e.getFrom().getY() != (int) e.getTo().getY()) {
      if (getTurret(loc) != null) {
        Bukkit.getPluginManager().callEvent(new TurretWalkEvent(p, getTurret(loc)));
      }
      if (isInTurret(p)) {
        Turret t = getTurret(p);
        if (t.containsUser()) {
          e.getPlayer().teleport(e.getFrom());
        }
      }
    }
    if ((int) e.getFrom().getX() != (int) e.getTo().getX()
        || (int) e.getFrom().getZ() != (int) e.getTo().getZ()) {
      if (!released || stunned.contains(p.getName())) {
        if (GameState.getState() == GameState.INGAME) {
          e.getPlayer().teleport(e.getFrom());
        }
      }
    }
  }
Ejemplo n.º 19
0
 @EventHandler
 public void onPlace(BlockPlaceEvent e) {
   if (!Config.separateInv) return;
   Player p = e.getPlayer();
   if (p.getGameMode() == GameMode.CREATIVE) return; // this doesn't affect us
   if (getWorldGroup(p.getWorld()) == null) return;
   saveInventory(p, p.getInventory());
 }
Ejemplo n.º 20
0
 private void removeFlight(Player p) {
   if (disableFlight && p.getGameMode() != GameMode.CREATIVE) {
     if (p.getAllowFlight()) couldFly.add(p.getName());
     if (p.isFlying()) hadFlight.add(p.getName());
     p.setFlying(false);
     p.setAllowFlight(false);
   }
 }
Ejemplo n.º 21
0
 private void decrementInventory(final Player source, final ItemStack held) {
   // Remove item from inventory.
   if (source.getGameMode() != GameMode.CREATIVE) {
     held.setAmount(held.getAmount() - 1);
     if (held.getAmount() == 0) {
       Util.ReloadItemBar(source, new SpoutItemStack(source.getItemInHand()));
     }
   }
 }
Ejemplo n.º 22
0
  public void reply(Player target, CommandSender commandSender) {
    UserStatus userStatus = new UserStatus();
    User essUser = plugin.essentials.getUser(target);

    // Nick
    userStatus.addRow(new UserStatusRow("Ник: ", target.getName()));
    // HP
    userStatus.addRow(
        new UserStatusRow(
            "Здоровье: ",
            target.getHealth()
                + "/"
                + target.getMaxHealth()
                + " ( +"
                + target.getFoodLevel()
                + " насыщение )"));
    // XP
    userStatus.addRow(
        new UserStatusRow("Уровень: ", target.getExp() + "(уровень " + target.getLevel() + " )"));
    // location
    // TODO: Make output readable
    userStatus.addRow(new UserStatusRow("Местоположение: ", target.getLocation().toString()));
    // balance
    userStatus.addRow(new UserStatusRow("Баланс: ", essUser.getMoney().toString()));
    // IP
    userStatus.addRow(new UserStatusRow("IP: ", target.getAddress().toString()));
    // GameMode
    userStatus.addRow(new UserStatusRow("Игровой режим: ", target.getGameMode().name()));
    // GodMode
    userStatus.addRow(new UserStatusRow("В режиме бога: ", essUser.isGodModeEnabled()));
    // OP
    userStatus.addRow(new UserStatusRow("OP: ", target.isOp()));
    // Fly
    userStatus.addRow(new UserStatusRow("Летает: ", target.isFlying()));
    // AFK
    userStatus.addRow(new UserStatusRow("AFK: ", essUser.isAfk()));
    // InJail
    userStatus.addRow(new UserStatusRow("В тюрьме: ", essUser.isJailed()));
    // InMute
    userStatus.addRow(new UserStatusRow("В муте: ", essUser.isMuted()));
    // InSasVanish
    userStatus.addRow(
        new UserStatusRow(
            "В сас ванише: ",
            ((SasVanish) plugin.sasCommandExecuter.commands.get("sasvanish")).inVanish(target)));
    // PEX
    userStatus.addRow(
        new UserStatusRow(
            "Группы: ", StringUtils.join(PermissionsEx.getUser(target).getGroupsNames(), ", ")));
    // TODO: Display only permissions added customly (not inherited from groups)
    // This commented line displays ALL the permissions of a player
    //        userStatus.addRow(new UserStatusRow("Пермишены: ",
    // StringUtils.join(PermissionsEx.getUser(target).getPermissions(target.getWorld().getName()),
    // ", ")));

    userStatus.send(commandSender);
  }
Ejemplo n.º 23
0
  Esell(Player player, String[] args) {
    HyperConomy hc = HyperConomy.hc;
    LanguageFile L = hc.getLanguageFile();
    ShopFactory s = hc.getShopFactory();
    DataHandler dh = hc.getDataFunctions();
    InventoryManipulation im = hc.getInventoryManipulation();
    try {
      if (player.getGameMode() == GameMode.CREATIVE
          && hc.s().gB("block-selling-in-creative-mode")) {
        player.sendMessage(L.get("CANT_SELL_CREATIVE"));
        return;
      }
      if (s.inAnyShop(player)) {
        HyperPlayer hp = dh.getHyperPlayer(player);
        if (hp.hasSellPermission(s.getShop(player))) {
          String name = args[0];
          if (args[0].equalsIgnoreCase("max")) {
            if (!im.hasenchants(player.getItemInHand())) {
              player.sendMessage(L.get("HAS_NO_ENCHANTMENTS"));
            }
            ArrayList<String> enchants = im.getEnchantments(player.getItemInHand());
            for (String e : enchants) {
              if (s.getShop(player).has(e)) {
                PlayerTransaction pt = new PlayerTransaction(TransactionType.SELL);
                pt.setHyperObject(dh.getHyperObject(e, hp.getEconomy()));
                TransactionResponse response = hp.processTransaction(pt);
                response.sendMessages();
              } else {
                player.sendMessage(L.get("CANT_BE_TRADED"));
              }
            }

          } else {
            if (hc.getDataFunctions().enchantTest(name)) {
              if (s.getShop(player).has(name)) {
                PlayerTransaction pt = new PlayerTransaction(TransactionType.SELL);
                pt.setHyperObject(dh.getHyperObject(name, hp.getEconomy()));
                TransactionResponse response = hp.processTransaction(pt);
                response.sendMessages();
              } else {
                player.sendMessage(L.get("CANT_BE_TRADED"));
              }
            } else {
              player.sendMessage(L.get("ENCHANTMENT_NOT_IN_DATABASE"));
            }
          }
        } else {
          player.sendMessage(L.get("NO_TRADE_PERMISSION"));
        }
      } else {
        player.sendMessage(L.get("MUST_BE_IN_SHOP"));
      }
    } catch (Exception e) {
      player.sendMessage(L.get("ESELL_INVALID"));
    }
  }
Ejemplo n.º 24
0
 public void setDefaultGameMode(GameMode mode) {
   GameMode oldMode = defaultGameMode;
   defaultGameMode = mode;
   for (Player player : getOnlinePlayers()) {
     if (player.getGameMode() == oldMode) {
       player.setGameMode(mode);
     }
   }
   config.set("server.def-game-mode", mode.name());
 }
Ejemplo n.º 25
0
 @SuppressWarnings("deprecation")
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onBlockPlace(BlockPlaceEvent event) {
   Player player = event.getPlayer();
   if (event.getItemInHand().equals(Config.ToolBlock)
       && SessionManager.getSession(player).isUsingTool()) {
     ToolManager.toolSearch(player, event.getBlock());
     if (player.getGameMode() == GameMode.SURVIVAL) player.updateInventory();
     event.setCancelled(true);
   }
 }
Ejemplo n.º 26
0
  @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
  public void onInventoryClick(InventoryClickEvent event) {
    if (!(event.getInventory().getHolder() instanceof Player)) return;
    Player p = (Player) event.getInventory().getHolder();
    ItemStack i = event.getCurrentItem();
    if (p == null) return;
    if (i == null) return;
    if (!p.hasPermission("orbia.keepitems") && !p.getGameMode().equals(GameMode.CREATIVE)) return;

    if (!itemHandler.isCustomItem(i) && remove.contains(i.getType())) p.getInventory().remove(i);
  }
 // Disable GM/GOD PVP
 @EventHandler
 public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
   if (event.getEntity() instanceof Player) {
     if (event.getDamager() instanceof Player) {
       Player player = (Player) event.getDamager();
       if (player.getGameMode() == GameMode.CREATIVE || FOPM_TFM_Util.inGod(player)) {
         TFM_Util.playerMsg(player, "NO GM / GOD PVP!", ChatColor.DARK_RED);
         event.setCancelled(true);
       }
     }
     if (event.getDamager() instanceof Arrow) {
       Arrow arrow = (Arrow) event.getDamager();
       if (arrow.getShooter() instanceof Player) {
         Player player = (Player) arrow.getShooter();
         if (player.getGameMode() == GameMode.CREATIVE || FOPM_TFM_Util.inGod(player)) {
           TFM_Util.playerMsg(player, "NO GM / GOD PVP!", ChatColor.DARK_RED);
           event.setCancelled(true);
         }
       }
     }
   }
 }
Ejemplo n.º 28
0
  @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
  public void onPlayerPickupItem(PlayerPickupItemEvent event) {
    Player p = event.getPlayer();
    ItemStack i = event.getItem().getItemStack();
    if (p == null) return;
    if (i == null) return;
    if (!p.hasPermission("orbia.keepitems") && !p.getGameMode().equals(GameMode.CREATIVE)) return;

    if (!itemHandler.isCustomItem(i) && remove.contains(i.getType())) {
      event.getItem().remove();
      event.setCancelled(true);
    }
  }
Ejemplo n.º 29
0
  @EventHandler
  public static void onFly(PlayerToggleFlightEvent event) {
    Player p = event.getPlayer();
    if (p.getGameMode() != GameMode.CREATIVE && event.isFlying()) {
      event.setCancelled(true);

      Vector jump = p.getLocation().getDirection().multiply(0.4).setY(1.1);
      p.setVelocity(p.getVelocity().add(jump));
      p.setAllowFlight(false);
      p.setFallDistance(1);
      p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 100, 1);
      ParticleEffect.CLOUD.display(1, 1, 1, 1, 20, p.getLocation(), 20);
    }
  }
Ejemplo n.º 30
0
 @Override
 public PlotGamemode getGamemode() {
   switch (player.getGameMode()) {
     case ADVENTURE:
       return PlotGamemode.ADVENTURE;
     case CREATIVE:
       return PlotGamemode.CREATIVE;
     case SPECTATOR:
       return PlotGamemode.SPECTATOR;
     case SURVIVAL:
       return PlotGamemode.SURVIVAL;
   }
   return null;
 }