示例#1
0
 @Command(
     aliases = {"alert"},
     desc = "Send out a broadcast message")
 @Require("plume.broadcast.broadcast")
 public void alert(@Sender ICommandSender sender, @Text String msg) {
   Messages.broadcast(Messages.error("SERVER: " + msg));
 }
示例#2
0
  @SuppressWarnings({"unchecked", "ConstantConditions"})
  @Command(
      aliases = "pm",
      desc = "Send private message to target player.",
      usage = "/pm <target player> <message>")
  public void sendPm(@Sender EntityPlayer sender, String target, @Text String message) {

    try {
      UserId userId = profileService.findUserId(target);
      if (!Objects.equals(sender.getDisplayName(), userId.getEntityPlayer().getDisplayName())) {
        userId
            .getEntityPlayer()
            .addChatMessage(
                new ChatComponentText(
                    String.format(
                        "%s(%s - Message from %s%s: %s)",
                        EnumChatFormatting.GRAY,
                        formattedDate,
                        sender.getDisplayName(),
                        EnumChatFormatting.GRAY,
                        message.trim())));
        recipients.put(sender.getUniqueID(), profileService.findUserId(target));
      }
      if (Objects.equals(sender.getDisplayName(), userId.getEntityPlayer().getDisplayName())) {
        sender.addChatMessage(Messages.error(tr("whisper.pm.same-player.error")));
      }
    } catch (ProfileNotFoundException | NullPointerException e) {
      sender.addChatMessage(Messages.error(tr("whisper.pm.no-such-player.error")));
    } catch (ProfileLookupException ignored) {
    }
  }
示例#3
0
 @Command(
     aliases = {"print"},
     desc = "Print an unformatted message to chat")
 @Require("plume.broadcast.print")
 public void print(@Sender ICommandSender sender, @Text String msg) {
   Messages.broadcast(new ChatComponentText(msg));
 }
示例#4
0
  @SubscribeEvent
  public void onPlayerTick(TickEvent.PlayerTickEvent event) {
    if (event.player.worldObj.isRemote) return;

    if (event.phase == TickEvent.Phase.END && event.side == Side.SERVER) {
      for (int i = 0; i < event.player.inventory.mainInventory.length; i++) {
        ItemStack stack = event.player.inventory.mainInventory[i];
        if (stack != null) {
          for (String bannedItem : config.get().bannedItems) {
            if (Item.itemRegistry.getNameForObject(stack.getItem()).equals(bannedItem)) {
              event.player.addChatMessage(
                  Messages.error(stack.getDisplayName() + " is forbidden. Removing..."));
              event.player.inventory.setInventorySlotContents(i, null);

              Slot slot =
                  event.player.openContainer.getSlotFromInventory(event.player.inventory, i);
              ((EntityPlayerMP) event.player)
                  .playerNetServerHandler.sendPacket(
                      new S2FPacketSetSlot(
                          event.player.openContainer.windowId, slot.slotNumber, null));
            }
          }
        }
      }
    }
  }
示例#5
0
 @Command(
     aliases = "r",
     desc = "Reply to the person, that sent you the last message.",
     usage = "/r <message>")
 public void replyToPm(@Sender EntityPlayer sender, @Text String message) {
   try {
     UserId target = (UserId) recipients.get(sender.getUniqueID());
     if (target.getEntityPlayer() != null) {
       target
           .getEntityPlayer()
           .addChatMessage(
               new ChatComponentText(
                   String.format(
                       "%s(%s - Message from %s%s: %s)",
                       EnumChatFormatting.GRAY,
                       formattedDate,
                       sender.getDisplayName(),
                       EnumChatFormatting.GRAY,
                       message.trim())));
     }
   } catch (NullPointerException e) {
     sender.addChatMessage(Messages.error(tr("whisper.r.nobody-to-reply-to")));
   }
 }