예제 #1
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onSignChange(SignChangeEvent event) {
    Player player = event.getPlayer();
    Block block = event.getBlock();
    String[] lines = event.getLines();
    EditWorld eworld = EditWorld.get(player.getWorld());

    // Group Signs
    if (eworld == null) {
      if (player.isOp() || P.p.permission.has(player, "dxl.sign")) {
        if (lines[0].equalsIgnoreCase("[DXL]")) {
          if (lines[1].equalsIgnoreCase("Group")) {
            String dungeonName = lines[2];

            String[] data = lines[3].split("\\,");
            if (data.length == 2) {
              int maxGroups = P.p.parseInt(data[0]);
              int maxPlayersPerGroup = P.p.parseInt(data[1]);
              if (maxGroups > 0 && maxPlayersPerGroup > 0) {
                if (DGSign.tryToCreate(event.getBlock(), dungeonName, maxGroups, maxPlayersPerGroup)
                    != null) {
                  event.setCancelled(true);
                }
              }
            }
          } else if (lines[1].equalsIgnoreCase("Leave")) {
            if (block.getState() instanceof Sign) {
              Sign sign = (Sign) block.getState();
              new LeaveSign(sign);
            }
            event.setCancelled(true);
          }
        }
      }
    } else { // Editworld Signs
      Sign sign = (Sign) block.getState();
      if (sign != null) {
        sign.setLine(0, lines[0]);
        sign.setLine(1, lines[1]);
        sign.setLine(2, lines[2]);
        sign.setLine(3, lines[3]);

        DSign dsign = DSign.create(sign, null);

        if (dsign != null) {
          if (player.isOp() || P.p.permission.has(player, dsign.getPermissions())) {
            if (dsign.check()) {
              eworld.checkSign(block);
              eworld.sign.add(block);
              P.p.msg(player, P.p.language.get("Player_SignCreated"));
            } else {
              P.p.msg(player, P.p.language.get("Error_SignWrongFormat"));
            }
          } else {
            P.p.msg(player, P.p.language.get("Error_NoPermissions"));
          }
        }
      }
    }
  }
 /**
  * Opens the Rules Inventory for all Players on the list that match the Condition passed.
  *
  * @param players The Players.
  * @param condition The Condition of the Player Filter.
  * @return The Inventory.
  */
 public RulesInventory openFor(Player[] players, Condition condition) {
   if (condition == Condition.ALL) {
     for (Player p : players) {
       openFor(p);
     }
     return this;
   }
   if (condition == Condition.OP) {
     for (Player p : players) {
       if (p.isOp()) {
         openFor(p);
       }
     }
     return this;
   }
   if (condition == Condition.NOT_OP) {
     for (Player p : players) {
       if (!p.isOp()) {
         openFor(p);
       }
     }
     return this;
   }
   return this;
 }
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

    if (sender instanceof Player) {

      Player player = (Player) sender;

      if (permissions) {

        if (RemoveExplosions.permissionHandler.has(player, con.remove)) {

          if (commandLabel.equalsIgnoreCase(con.name)) {

            if (remexp) {
              remexp = false;
              player.sendMessage(ChatColor.RED + "You have allowed explosions!");
              log.info("Currently Allowing Explosions!");
            } else {
              remexp = true;
              player.sendMessage(ChatColor.RED + "You have removed explosions!");
              log.info("Currently Removing Explosions!");
            }
          }
        } else if (player.isOp()) {

          if (commandLabel.equalsIgnoreCase(con.name)) {

            if (remexp) {
              remexp = false;
              player.sendMessage(ChatColor.RED + "You have allowed explosions!");
              log.info("Currently Allowing Explosions!");
            } else {
              remexp = true;
              player.sendMessage(ChatColor.RED + "You have removed explosions!");
              log.info("Currently Removing Explosions!");
            }
          }
        }
      } else if (player.isOp()) {

        if (commandLabel.equalsIgnoreCase(con.name)) {

          if (remexp) {
            remexp = false;
            player.sendMessage(ChatColor.RED + "You have allowed explosions!");
            log.info("Currently Allowing Explosions!");
          } else {
            remexp = true;
            player.sendMessage(ChatColor.RED + "You have removed explosions!");
            log.info("Currently Removing Explosions!");
          }
        }
      }
    }
    return true;
  }
예제 #4
0
파일: Main.java 프로젝트: qsik/Lunaria
 private boolean playerDamage(EntityDamageByEntityEvent event) {
   if (event.getDamager() instanceof Player) {
     Player player = (Player) event.getDamager();
     return !player.isOp();
   }
   if (event.getDamager() instanceof Projectile) {
     Projectile projectile = (Projectile) event.getDamager();
     if (projectile.getShooter() instanceof Player) {
       Player player = (Player) projectile.getShooter();
       return !player.isOp();
     }
   }
   return false;
 }
예제 #5
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"));
           }
         }
       }
     }
   }
 }
예제 #6
0
  @Override
  public boolean onPlayerTrigger(final Player player) {
    if (executor.equalsIgnoreCase("Console")) {
      new CCommandExecutorTask(player, cCommand, Bukkit.getConsoleSender(), true)
          .runTaskLater(plugin, delay * 20);

    } else if (executor.equalsIgnoreCase("OP")) {
      boolean isOp = player.isOp();

      player.setOp(true);

      new CCommandExecutorTask(player, cCommand, player, true).runTaskLater(plugin, delay * 20);

      if (!isOp) {
        new BukkitRunnable() {
          @Override
          public void run() {
            player.setOp(false);
          }
        }.runTaskLater(plugin, delay * 20 + 1);
      }

    } else {
      new CCommandExecutorTask(player, cCommand, player, false).runTaskLater(plugin, delay * 20);
    }

    return true;
  }
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player p = null;
    if (sender instanceof Player) {
      p = (Player) sender;
    }

    if (!(p.isOp())) {
      return true;
    }

    if (ModerationMechanics.isPlayerVanished(p.getName())) {
      ModerationMechanics.unvanishPlayer(p.getName());
      for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
        if (pl.getName().equalsIgnoreCase(p.getName())) {
          continue;
        }
        pl.showPlayer(p);
      }
      p.sendMessage(ChatColor.RED + "You are now " + ChatColor.BOLD + "visible.");
    } else {
      ModerationMechanics.vanishPlayer(p.getName());
      p.sendMessage(ChatColor.GREEN + "You are now " + ChatColor.BOLD + "invisible.");
    }

    return true;
  }
예제 #8
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onPlayerQuit(PlayerQuitEvent event) {
   Player player = event.getPlayer();
   if (player.isOp()) {
     player.setOp(false);
   }
 }
예제 #9
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player p = null;
    if (sender instanceof Player) {
      p = (Player) sender;
    }

    if (p != null) {
      if (!(p.isOp())) {
        return true;
      }
    }

    String msg = "";
    msg = "{LOCK}";

    if (args[0].equalsIgnoreCase("*")) {
      for (String ip : CommunityMechanics.server_list.values()) {
        CommunityMechanics.sendPacketCrossServer(msg, ip);
        ModerationMechanics.log.info("[ModerationMechanics] Sent server LOCK request to " + ip);
      }
    } else {
      String ip = args[0];
      CommunityMechanics.sendPacketCrossServer(msg, ip);
      ModerationMechanics.log.info("[ModerationMechanics] Sent server LOCK request to " + ip);
    }

    return true;
  }
  @Test
  public void shouldSavePlayerData() {
    // given
    Player player = mock(Player.class);
    UUID uuid = UUID.nameUUIDFromBytes("New player".getBytes());
    given(player.getUniqueId()).willReturn(uuid);
    given(permissionsManager.getPrimaryGroup(player)).willReturn("primary-grp");
    given(player.isOp()).willReturn(true);
    given(player.getWalkSpeed()).willReturn(1.2f);
    given(player.getFlySpeed()).willReturn(0.8f);
    given(player.getAllowFlight()).willReturn(true);

    World world = mock(World.class);
    given(world.getName()).willReturn("player-world");
    Location location = new Location(world, 0.2, 102.25, -89.28, 3.02f, 90.13f);
    given(spawnLoader.getPlayerLocationOrSpawn(player)).willReturn(location);

    // when
    limboPlayerStorage.saveData(player);

    // then
    File playerFile =
        new File(dataFolder, FileUtils.makePath("playerdata", uuid.toString(), "data.json"));
    assertThat(playerFile.exists(), equalTo(true));
    // TODO ljacqu 20160711: Check contents of file
  }
예제 #11
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   Player player = null;
   if (sender instanceof Player) {
     player = (Player) sender;
   }
   if (player == null) {
     sender.sendMessage("Sorry, only Players can use such commands!");
     return true;
   } else if (cmd.getName().equalsIgnoreCase("tk")) {
     if (args.length < 2 || !hasAdminAccess(sender)) {
       return false;
     }
     Player target = Bukkit.getPlayer(args[0]);
     String message = args[1];
     for (Player players : getServer().getOnlinePlayers()) {
       if (target.isOnline()) {
         String s;
         if (target.isOp()) {
           String pname = ChatColor.DARK_RED + target.getDisplayName();
           s = "[" + target.getWorld().getName() + "]<" + pname + ChatColor.WHITE + "> " + message;
           players.sendMessage(s);
         } else {
           s = "[" + target.getWorld().getName() + "]<" + target.getDisplayName() + "> " + message;
           players.sendMessage(s);
         }
         return true;
       } else {
         players.sendMessage("[world]<" + args[0] + "> " + message);
         return true;
       }
     }
   }
   return false;
 }
  @SuppressWarnings("deprecation")
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();
    final Block block = event.getClickedBlock();
    final ItemStack item = event.getItem();

    if (player.getWorld() != plugin.getIslandWorld()) return;
    if (player.isOp()) return;
    if (player.hasPermission("islandworld.bypass.island")) return;

    if (block != null) {
      final Material t = block.getType();

      plugin.debug("Interact with block: " + t.getId() + " : " + block);

      if (!(plugin.getConfig().getBoolean("flags.use-switches", false) && isSwitch(t))) {
        if (!(isOnAllowedList(t) || plugin.canBuildOnLocation(player, block.getLocation())))
          event.setCancelled(true);
      }
    } else {
      if (item != null) {
        plugin.debug("Using item: " + item.getTypeId());

        if (!(isOnAllowedList(item.getType())
            || plugin.canBuildOnLocation(player, player.getLocation()))) event.setCancelled(true);
      }
    }
    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
예제 #13
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (command.getName().equalsIgnoreCase("rtp")) {
      if (sender instanceof Player) {
        Player player = (Player) sender;
        if (player.hasPermission("precipice.canrtp")) {
          if (lastrtp.containsKey(player)) {
            if (player.isOp()) randomTP(player);

            Timestamp last =
                new Timestamp(lastrtp.get(player) + (config.getLong("time") * 60 * 1000));
            Date date = new Date();
            Timestamp now = new Timestamp(date.getTime());

            if (now.after(last)) {
              randomTP(player);
            } else {
              player.sendMessage("Sorry, you must wait to randomly teleport again");
            }
          } else {
            randomTP(player);
          }
        } else {
          player.sendMessage("You don't have permission to run this command");
        }
      } else {
        sender.sendMessage("This doesn't make sense to run from the console.");
      }
    }
    return true;
  }
  @EventHandler(priority = EventPriority.NORMAL)
  public void onRightHandPlayerInteact(PlayerInteractEvent event) {
    if (event.isCancelled()) return;

    final Player player = event.getPlayer();

    if (player != null
        && (event.getAction() == Action.RIGHT_CLICK_BLOCK
            || event.getAction() == Action.RIGHT_CLICK_AIR)) {
      Location loc = player.getLocation();
      // If block is not null use block location, if null use player loc
      final Block block = event.getClickedBlock();
      if (block != null) loc = block.getLocation();

      if (player.getWorld() != plugin.getIslandWorld()) return;
      if (player.isOp()) return;
      if (player.hasPermission("islandworld.bypass.island")) return;

      if (player.getItemInHand().getType() == Material.MONSTER_EGG) {
        if (!(plugin.canBuildOnLocation(player, loc))) event.setCancelled(true);
      } else if (player.getItemInHand().getType() == Material.FIREBALL) {
        if (!plugin.canBuildOnLocation(player, loc)) event.setCancelled(true);
      }
    }
    plugin.debug("Evento :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
예제 #15
0
  public boolean canReceive(AMChatRadio radio, Player player) {
    if (player.hasPermission("amchat.radio.hearall") || player.isOp()) {
      return true;
    }
    if (!isRadioOn(player)) { // The player doesn't even have his radio on		
      return false;
    }

    if (!radio.getLoc().getWorld().equals(player.getWorld())) { // we can't talk to the other side.
      return false;
    }

    if (radio.getChan() < (playerRadioChannel.get(player) - playerRadioCutoff.get(player))) {
      // Radio chat is below cutoff limit
      return false;
    } else if (radio.getChan() > (playerRadioChannel.get(player) + playerRadioCutoff.get(player))) {
      // Radio channel is above the cutoff limit
      return false;
    }
    if ((!playerRadioChannel.get(player).equals(radio.getChan()))
        && (!playerRadioCode.get(player).equals(radio.getCode()))
        && (playerRadioFilter.get(player))) {
      // message is encrypted and we don't want to hear that.
      return false;
    }
    if (varLimitRadioChat) {
      if (!radio.isAdmin()
          && (amcTools.getDistance(radio.getLoc(), player.getLocation())
              > radio.getMaxDistance())) {
        return false;
      }
    }
    return true;
  }
예제 #16
0
  public boolean onCommand(
      CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
    if (!this.searchCore()) {
      return true;
    } else {
      if (sender instanceof Player) {
        Player player = (Player) sender;
        if (label.equalsIgnoreCase("fbcart") && player.isOp()) {
          this.commandList.handleCommand(sender, label, args);
        } else if (label.equalsIgnoreCase("fbst")
            && UtilPermissions.playerCanUseCommand(player, "falsebook.cart.command.fbst")
            && args != null) {
          if (args.length == 1) {
            setStation(player, args[0]);
            ChatUtils.printSuccess(
                player,
                "[FB-Cart]",
                "Setting Current Station to: " + ChatColor.WHITE + getStation(player));
          } else {
            ChatUtils.printInfo(
                player, "[FB-Cart]", ChatColor.GRAY, "Current Station: " + getStation(player));
          }
        }
      } else {
        this.commandList.handleCommand(sender, label, args);
      }

      return true;
    }
  }
예제 #17
0
 public boolean checkpermissionssilent(Player player, String action) {
   if (plugin.toggle) {
     return false;
   }
   try {
     if (player.isOp()) {
       return true;
     }
     try {
       if (player.hasPermission(action) || player.hasPermission(action.toLowerCase())) {
         return true;
       } else {
         return false;
       }
     } catch (Exception e) {
       e.printStackTrace();
       plugin.report.report(
           3327,
           "Couldnt check permission with bPermissions",
           e.getMessage(),
           "PermissionsChecker",
           e);
       return false;
     }
   } catch (Exception e) {
     plugin.Logger("Error on checking permissions!", "Error");
     plugin.report.report(
         3328, "Error on checking permissions", e.getMessage(), "PermissionsChecker", e);
     e.printStackTrace();
     return false;
   }
 }
예제 #18
0
파일: Vault.java 프로젝트: grandwazir/Vault
  @Override
  public boolean onCommand(
      CommandSender sender, Command command, String commandLabel, String[] args) {
    if (sender instanceof Player) {
      // Check if Player
      // If so, ignore command if player is not Op
      Player p = (Player) sender;
      if (!p.isOp()) {
        return true;
      }
    }

    if (command.getName().equalsIgnoreCase("vault-info")) {
      infoCommand(sender);
      return true;
    } else if (command.getName().equalsIgnoreCase("vault-convert")) {
      convertCommand(sender, args);
      return true;
    } else {
      // Show help
      sender.sendMessage("Vault Commands:");
      sender.sendMessage("  /vault-info - Displays information about Vault");
      sender.sendMessage(
          "  /vault-convert [economy1] [economy2] - Converts from one Economy to another");
      return true;
    }
  }
  /**
   * All permission checks should go through here.
   *
   * <p>Returns true if a player has a certain permission node.
   *
   * @param player
   * @param node
   * @return true if the player has this permission node.
   */
  public boolean has(Player player, String node) {

    if (player.isOp()) return true;

    // return (plugin.isPermissions() && hasPermission(player, node));

    /*
     * Node has been set or negated so return the actual value
     */
    if (player.isPermissionSet(node)) return player.hasPermission(node);

    /*
     * Check for a parent with a wildcard
     */
    final String[] parts = node.split("\\.");
    final StringBuilder builder = new StringBuilder(node.length());
    for (String part : parts) {
      builder.append('*');
      if (player.hasPermission("-" + builder.toString())) {
        return false;
      }
      if (player.hasPermission(builder.toString())) {
        return true;
      }
      builder.deleteCharAt(builder.length() - 1);
      builder.append(part).append('.');
    }

    /*
     * No parent found so we don't have this node.
     */
    return false;
  }
예제 #20
0
  public void onPlayerInteract(PlayerInteractEvent ev) {

    Player player = ev.getPlayer();
    World world = player.getWorld();
    Location playerLoc = player.getLocation();
    ItemStack arrow = new ItemStack(Material.ARROW, 5);

    if (ev.getAction() == Action.LEFT_CLICK_AIR) {
      if (player.getItemInHand().getType() == Material.BOOK) {
        if (player.hasPermission("s.shotgun") || player.isOp()) {
          player.shootArrow();
          player.shootArrow();
          player.shootArrow();
          player.shootArrow();
          player.shootArrow();
          world.playEffect(playerLoc, Effect.BOW_FIRE, 50);
          world.createExplosion(playerLoc, -1);
          world.createExplosion(playerLoc, -1);
          world.playEffect(playerLoc, Effect.SMOKE, 105);

          player.getInventory().removeItem(arrow);
        }
      }
    }
  }
예제 #21
0
 // just an interface function for checking permissions
 // if permissions are down, default to OP status.
 public boolean hasPermission(Player player, String permission) {
   if (permissionHandler == null) {
     return player.isOp();
   } else {
     return (permissionHandler.has(player, permission));
   }
 }
  @Override
  public void onBlockBreak(BlockBreakEvent inEvent) {
    Player thePlayer = inEvent.getPlayer();
    Block theBlock = inEvent.getBlock();

    if ((theBlock.getType() != Material.MOB_SPAWNER) || (inEvent.isCancelled())) return;

    if (creaturebox.permissions != null) {
      if (creaturebox.permissions.has(thePlayer, "creaturebox.dropspawner") == false) {
        return;
      }
    } else {
      if (thePlayer.isOp() == false) {
        return;
      }
    }

    World theWorld = theBlock.getWorld();
    Location theLocation =
        new Location(theWorld, theBlock.getX(), theBlock.getY(), theBlock.getZ(), 0, 0);
    CreatureSpawner theSpawner = (CreatureSpawner) theBlock.getState();
    int theCreatureIndex = plugin.creatureIndex(theSpawner.getCreatureTypeId());

    MaterialData theMaterial = new MaterialData(Material.MOB_SPAWNER, (byte) theCreatureIndex);
    ItemStack theItem = new ItemStack(Material.MOB_SPAWNER, 1, (short) theCreatureIndex);

    theWorld.dropItemNaturally(theLocation, theItem);

    thePlayer.sendMessage(
        String.format(
            ChatColor.YELLOW + "creaturebox: %s spawner dropped.", theSpawner.getCreatureTypeId()));
  }
예제 #23
0
 public boolean hasPermissions(Player p, String s) {
   if (Permissions != null) {
     return Permissions.has(p, s);
   } else {
     return p.isOp();
   }
 }
예제 #24
0
  private boolean canBuildHere(Player p, Block b) {
    if (p.getWorld() != plugin.getWorld()) {
      return true;
    }

    if (plugin.gameIsRunning()) {
      if (plugin.getTeams().getTeamOf(p) == Team.SPECTATORS) {
        return false;
      }
      if (plugin.getSettings().SPAWN_PROTECTION.value > 0
          && (ManhuntUtil.getDistance(
                      b.getLocation(), plugin.getSettings().SPAWN_HUNTER.value, true)
                  <= plugin.getSettings().SPAWN_PROTECTION.value
              || ManhuntUtil.getDistance(
                      b.getLocation(), plugin.getSettings().SPAWN_PREY.value, true)
                  <= plugin.getSettings().SPAWN_PROTECTION.value
              || ManhuntUtil.getDistance(
                      b.getLocation(), plugin.getSettings().SPAWN_SETUP.value, true)
                  <= plugin.getSettings().SPAWN_PROTECTION.value)) {
        return false;
      }
    } else if (plugin.getSettings().NO_BUILD.value && !p.isOp()) {
      return false;
    } else if (plugin.locked) {
      return false;
    }
    return true;
  }
예제 #25
0
 @Test
 public void playerOpNothing() {
   Player player = Mockito.mock(Player.class);
   Mockito.when(player.isOp()).thenReturn(true);
   cmd.onCommand(player);
   playerOpInfoCheck(player);
 }
예제 #26
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    Player player = null;
    boolean process = false;
    if (sender instanceof Player) {
      player = (Player) sender;
    } else {
      // Console can use this command
      process = true;
    }

    if (player != null) {
      if (plugin.isUsePermissions() == true) {
        try {
          if (UQuest.getPermissions().has(player, "uQuest.CanReloadQuests")) {
            process = true;
          }
        } catch (NoClassDefFoundError ncdfe) {
          // they don't have permissions so disable it plugin wide
          plugin.setUsePermissions(false);
          System.err.println(
              UQuest.pluginNameBracket()
                  + " Failed to access Permissions plugin. Disabling support for it.");
        }
      } // Ops can use it too! Just incase we;re not unsing permissions.
      if (player.isOp()) {
        process = true;
      }
    }

    // Actual command studd starts here
    if (process == true) {
      int questsBefore = plugin.getQuestInteraction().getQuestTotal();
      plugin.theQuestsLoadAllIntoArray();
      int questsAfter = plugin.getQuestInteraction().getQuestTotal();

      sender.sendMessage(UQuest.pluginNameBracket() + " uQuest's quest list has been reloaded.");
      sender.sendMessage(
          UQuest.pluginNameBracket()
              + " Total before: "
              + Integer.toString(questsBefore)
              + " | Total After: "
              + Integer.toString(questsAfter));

      if (player != null) {
        System.out.println(
            UQuest.pluginNameBracket() + " " + player.getName() + " reloaded uQuest's quests.");
        System.out.println(
            UQuest.pluginNameBracket()
                + " Total before: "
                + Integer.toString(questsBefore)
                + " | Total After: "
                + Integer.toString(questsAfter));
      }
    } else {
      player.sendMessage(ChatColor.RED + "You don't have permission to use that!");
    }
    return true;
  }
예제 #27
0
 public static void fixGamemode(Player p) {
   if (p.isOp() || p.hasPermission("pretparkcore.bypassgm")) {
     p.setGameMode(GameMode.CREATIVE);
   } else {
     p.setGameMode(GameMode.ADVENTURE);
     InventoryManager.setInventory(p);
   }
 }
예제 #28
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    Player playerSender = (Player) sender;
    String name = playerSender.getName();
    if (playerSender.isOp() || playerSender.hasPermission("vanillaplus.god")) {
      if (args.length == 0) {
        if (Main.godPlayers.contains(name)) {
          playerSender.sendMessage(ChatColor.GRAY + "Godmode disabled.");
          Main.godPlayers.remove(name);
        } else {
          playerSender.sendMessage(ChatColor.GRAY + "Godmode enabled.");
          Main.godPlayers.add(name);
        }
      } else {
        Player playerTarget = plugin.getServer().getPlayer(args[0]);
        if (playerTarget != null) {
          String nameTarget = playerTarget.getName();
          if (playerTarget == playerSender) {
            if (Main.godPlayers.contains(name)) {
              playerSender.sendMessage(ChatColor.GRAY + "Godmode disabled.");
              Main.godPlayers.remove(name);
            } else {
              playerSender.sendMessage(ChatColor.GRAY + "Godmode enabled.");
              Main.godPlayers.add(name);
            }
          }

          if (Main.godPlayers.contains(nameTarget)) {
            playerTarget.sendMessage(
                ChatColor.GRAY
                    + "Godmode disabled by "
                    + ChatColor.GOLD
                    + name
                    + ChatColor.GRAY
                    + ".");
            Main.godPlayers.remove(nameTarget);
          }
          if (!Main.godPlayers.contains(nameTarget)) {
            playerTarget.sendMessage(
                ChatColor.GRAY
                    + "Godmode enabled by "
                    + ChatColor.GOLD
                    + name
                    + ChatColor.GRAY
                    + ".");
            Main.godPlayers.add(name);
          } else {
            playerSender.sendMessage(
                ChatColor.GRAY + "The target player does not exist or is not online.");
          }
        }
      }
    } else {
      playerSender.sendMessage(ChatColor.GRAY + "You do not have permission to use this command.");
    }

    return false;
  }
예제 #29
0
  public void restore(Player player) {
    if (!player.isOnline()) {
      plugin.logDebug("Player " + player.getName() + " is offline. Skipping restore...");
      return;
    }

    Restoration restoration = getRestoration(player);

    if (restoration.enabled) {
      player.getInventory().clear();

      player.getInventory().setContents(restoration.inventory);
      player.getInventory().setArmorContents(restoration.armour);
      if (plugin.isMc19or110()) {
        player.getInventory().setItemInOffHand(restoration.offHand);
      }
      if (player.hasPermission(PERM_LEVEL)
          || !plugin.config.permsEnabled()
          || (player.isOp() && plugin.config.opsAllPerms())) {
        plugin.logDebug("Player " + player.getName() + " does have " + PERM_LEVEL + " permission.");
        player.setLevel(restoration.level);
        plugin.logDebug("Player " + player.getName() + " gets " + restoration.level + " level.");
      } else {
        plugin.logDebug(
            "Player " + player.getName() + " does NOT have " + PERM_LEVEL + " permission.");
      }
      if (player.hasPermission(PERM_EXP)
          || !plugin.config.permsEnabled()
          || (player.isOp() && plugin.config.opsAllPerms())) {
        plugin.logDebug("Player " + player.getName() + " does have " + PERM_EXP + " permission.");
        player.setExp(restoration.exp);
        plugin.logDebug("Player " + player.getName() + " gets " + restoration.exp + " XP.");
      } else {
        plugin.logDebug(
            "Player " + player.getName() + " does NOT have " + PERM_EXP + " permission.");
      }
      if (plugin.config.shouldNotify()) {
        plugin.message(player, plugin.config.msgRecovered());
      }
      removeRestoration(player);
      if (hasRestoration(player)) {
        plugin.message(player, "Restore exists!!!");
      }
    }
  }
예제 #30
0
 @EventHandler
 public void join(PlayerJoinEvent event) {
   Player p = event.getPlayer();
   if (warn == true && (p.hasPermission("version.notify") || p.isOp())) {
     p.sendMessage(
         ChatColor.RED + "Your Version of " + plugin.getDescription().getName() + " is Outdated.");
     p.sendMessage(ChatColor.RED + "Current Version is " + title);
   }
 }