示例#1
0
  @EventHandler(priority = EventPriority.LOW)
  public void onJoin(PlayerJoinEvent event) {
    final Player player = event.getPlayer();
    String prefix =
        ChatColor.translateAlternateColorCodes(
            '&',
            Core.chat.getGroupPrefix(Bukkit.getWorlds().get(0), Core.chat.getPrimaryGroup(player)));
    player.setDisplayName(prefix + player.getName());
    if (!player.hasPermission(
        ConfigUtil.get().getConfig().getString("joinleavemessage.permission"))) {
      event.setJoinMessage(null);
    } else {
      event.setJoinMessage(
          ChatColor.translateAlternateColorCodes(
              '&',
              ConfigUtil.get()
                  .getConfig()
                  .getString("joinleavemessage.join-message")
                  .replaceAll("%player%", player.getDisplayName())));
    }

    if (ConfigUtil.get().getConfig().getBoolean("tp-to-spawn")) {
      Location teleportTo =
          LocationUtil.get().deserialize(ConfigUtil.get().getConfig().getString("spawn.location"));
      event.getPlayer().teleport(teleportTo);
    }

    EconomyUtil.get().createRowForPlayer(player);
  }
示例#2
0
 @EventHandler
 public void onMove(PlayerMoveEvent event) {
   if (ConfigUtil.get().getConfig().getBoolean("tp-to-spawn")) {
     if (event.getTo().getY() <= 0) {
       Location teleportTo =
           LocationUtil.get()
               .deserialize(ConfigUtil.get().getConfig().getString("spawn.location"));
       event.getPlayer().teleport(teleportTo);
     }
   }
 }