Ejemplo n.º 1
0
 /**
  * Carefully find a player by name. An issue is that CraftBukkit will return a fake OfflinePlayer
  * when queried by name, so let's not do that.
  */
 public PlayerTable getPlayerByName(String name) {
   // First, try an online player
   Player player = plugin.getServer().getPlayerExact(name);
   if (player != null) {
     return getPlayer(player);
   }
   // Then try to get it from our own database.
   return getPlayer(name);
 }
Ejemplo n.º 2
0
 public void updateBan(BanTable ban, Date now) {
   if (!ban.expires()) return;
   if (now.compareTo(ban.getExpiry()) >= 0) {
     plugin
         .getLogger()
         .info(
             Msg.format(
                 "%s [%04d] on %s has expired.",
                 ban.getType().getNiceName(), ban.getId(), ban.getPlayer().getName()));
     ban.setType(ban.getType().lift());
     getDatabase().save(ban);
   }
 }
Ejemplo n.º 3
0
 public PlayerTable getPlayer(OfflinePlayer player) {
   PlayerTable result =
       getDatabase().find(PlayerTable.class).where().eq("uuid", player.getUniqueId()).findUnique();
   if (result == null) {
     result = new PlayerTable(player, new Date());
     getDatabase().save(result);
   } else if (!result.getName().equals(player.getName())) {
     if (player.getName() == null) {
       plugin.getLogger().warning("Unknown for player with UUID " + player.getUniqueId());
       return null;
     }
     result.setName(player.getName());
     getDatabase().save(result);
   }
   return result;
 }
Ejemplo n.º 4
0
 private EbeanServer getDatabase() {
   return plugin.getDatabase();
 }