コード例 #1
0
	public void onPlayerRespawn(final PlayerRespawnEvent event)
	{
		final User user = ess.getUser(event.getPlayer());

		if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty())
		{
			return;
		}

		if (ess.getSettings().getRespawnAtHome())
		{
			Location home;
			final Location bed = user.getBedSpawnLocation();
			if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
			{
				home = bed;
			}
			else
			{
				home = user.getHome(user.getLocation());
			}
			if (home != null)
			{
				event.setRespawnLocation(home);
				return;
			}
		}
		final Location spawn = spawns.getSpawn(user.getGroup());
		if (spawn != null)
		{
			event.setRespawnLocation(spawn);
		}
	}
コード例 #2
0
  @Override
  public void run(Server server, User user, String commandLabel, String[] args) throws Exception {

    if (args.length < 1) {
      throw new NotEnoughArgumentsException();
    }
    charge(user);
    ess.getJail().setJail(user.getLocation(), args[0]);
    user.sendMessage(Util.format("jailSet", args[0]));
  }
コード例 #3
0
ファイル: User.java プロジェクト: jawfy/PluginDevelopment
 @Override
 public void requestTeleport(final User player, final boolean here) {
   teleportRequestTime = System.currentTimeMillis();
   teleportRequester = player == null ? null : player.getBase().getUniqueId();
   teleportRequestHere = here;
   if (player == null) {
     teleportLocation = null;
   } else {
     teleportLocation = here ? player.getLocation() : this.getLocation();
   }
 }
コード例 #4
0
 @Override
 public void alert(final User user, final String item, final String type) {
   final Location loc = user.getLocation();
   final String warnMessage =
       Util.format(
           "alertFormat",
           user.getName(),
           type,
           item,
           loc.getWorld().getName()
               + ","
               + loc.getBlockX()
               + ","
               + loc.getBlockY()
               + ","
               + loc.getBlockZ());
   LOGGER.log(Level.WARNING, warnMessage);
   for (Player p : this.getServer().getOnlinePlayers()) {
     final User alertUser = ess.getUser(p);
     if (alertUser.isAuthorized("essentials.protect.alerts")) {
       alertUser.sendMessage(warnMessage);
     }
   }
 }
コード例 #5
0
	@Override
	public void onPlayerRespawn(final PlayerRespawnEvent event)
	{		
		final User user = ess.getUser(event.getPlayer());

		if (ess.getSettings().getRespawnAtHome())
		{
			Location home = user.getHome(user.getLocation());
			if (home == null)
			{
				home = user.getBedSpawnLocation();
			}
			if (home != null)
			{
				event.setRespawnLocation(home);
				return;
			}
		}
		final Location spawn = spawns.getSpawn(user.getGroup());
		if (spawn != null)
		{
			event.setRespawnLocation(spawn);
		}
	}
コード例 #6
0
ファイル: Kit.java プロジェクト: jojo123456789/Essentials
	public static void expandItems(final IEssentials ess, final User user, final List<String> items) throws Exception
	{
		try
		{
			boolean spew = false;
			for (String d : items)
			{
				final String[] parts = d.split(" ");
				final String[] item = parts[0].split("[:+',;.]", 2);
				final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
				final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
				final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;

				final ItemStack stack = new ItemStack(id, amount, data);
				if (parts.length > 2)
				{
					for (int i = 2; i < parts.length; i++)
					{
						final String[] split = parts[i].split("[:+',;.]", 2);
						if (split.length < 1)
						{
							continue;
						}
						final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
						int level;
						if (split.length > 1)
						{
							level = Integer.parseInt(split[1]);
						}
						else
						{
							level = enchantment.getMaxLevel();
						}
						stack.addEnchantment(enchantment, level);
					}
				}

				final Map<Integer, ItemStack> overfilled;
				if (user.isAuthorized("essentials.oversizedstacks"))
				{
					overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
				}
				else
				{
					overfilled = InventoryWorkaround.addItem(user.getInventory(), true, new ItemStack(id, amount, data));
				}
				for (ItemStack itemStack : overfilled.values())
				{
					user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
					spew = true;
				}
			}
			user.updateInventory();
			if (spew)
			{
				user.sendMessage(_("kitInvFull"));
			}
		}
		catch (Exception e)
		{
			user.updateInventory();
			throw new Exception(_("kitError2"));
		}
	}
コード例 #7
0
 private void updateCompass(final User user) {
   try {
     user.setCompassTarget(user.getHome(user.getLocation()));
   } catch (Exception ex) {
   }
 }
コード例 #8
0
  public void expandItems(final User user, final List<String> items) throws Exception {
    try {
      IText input = new SimpleTextInput(items);
      IText output = new KeywordReplacer(input, user.getSource(), ess);

      boolean spew = false;
      final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
      for (String kitItem : output.getLines()) {
        if (kitItem.startsWith(ess.getSettings().getCurrencySymbol())) {
          BigDecimal value =
              new BigDecimal(
                  kitItem.substring(ess.getSettings().getCurrencySymbol().length()).trim());
          Trade t = new Trade(value, ess);
          t.pay(user, OverflowType.DROP);
          continue;
        }

        if (kitItem.startsWith("/")) {
          String command = kitItem.substring(1);
          String name = user.getName();
          command = command.replace("{player}", name);
          Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
          continue;
        }

        final String[] parts = kitItem.split(" +");
        final ItemStack parseStack =
            ess.getItemDb().get(parts[0], parts.length > 1 ? Integer.parseInt(parts[1]) : 1);

        if (parseStack.getType() == Material.AIR) {
          continue;
        }

        final MetaItemStack metaStack = new MetaItemStack(parseStack);

        if (parts.length > 2) {
          // We pass a null sender here because kits should not do perm checks
          metaStack.parseStringMeta(null, allowUnsafe, parts, 2, ess);
        }

        final Map<Integer, ItemStack> overfilled;
        final boolean allowOversizedStacks = user.isAuthorized("essentials.oversizedstacks");
        if (allowOversizedStacks) {
          overfilled =
              InventoryWorkaround.addOversizedItems(
                  user.getBase().getInventory(),
                  ess.getSettings().getOversizedStackSize(),
                  metaStack.getItemStack());
        } else {
          overfilled =
              InventoryWorkaround.addItems(user.getBase().getInventory(), metaStack.getItemStack());
        }
        for (ItemStack itemStack : overfilled.values()) {
          int spillAmount = itemStack.getAmount();
          if (!allowOversizedStacks) {
            itemStack.setAmount(
                spillAmount < itemStack.getMaxStackSize()
                    ? spillAmount
                    : itemStack.getMaxStackSize());
          }
          while (spillAmount > 0) {
            user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
            spillAmount -= itemStack.getAmount();
          }
          spew = true;
        }
      }
      user.getBase().updateInventory();
      if (spew) {
        user.sendMessage(tl("kitInvFull"));
      }
    } catch (Exception e) {
      user.getBase().updateInventory();
      ess.getLogger().log(Level.WARNING, e.getMessage());
      throw new Exception(tl("kitError2"), e);
    }
  }