@EventHandler public void onPlayerDeath( PlayerDeathEvent pEvent ) { Player tPlayer = pEvent.getEntity(); if( tPlayer != null ) { incDeathCounter( tPlayer ); if( tPlayer.hasPermission( GTNH_PERM_FULL_MEMBER ) ) return; int tDeathCount = getDeathCounter( tPlayer ); if( tDeathCount >= _mMaxDeathCount ) { Bukkit.getBanList( Type.NAME ).addBan( tPlayer.getName(), "Trial period expired. Contact an Admin", null, null ); tPlayer.kickPlayer( ChatColor.translateAlternateColorCodes( '&', _mMain.mConfig.getString( "Messages.KickMessage" ) ) ); } else tPlayer.sendMessage( ChatColor.translateAlternateColorCodes( '&', String.format( _mMain.mConfig.getString( "Messages.TrialWarning" ), tDeathCount, _mMaxDeathCount ) ) ); } }
@Override public BanList getBanList(Type type) { switch (type) { case IP: return playerList.getIPBans(); case NAME: default: return playerList.getProfileBans(); } }
/** * Gets the expiration date from a ban entry. * * @param target Target to get the expiration date from. * @return Returns the expiration date as a long in milliseconds. */ public long getExpirationLong(String target) { Validate.notNull(target, "Target cannot be null."); final BanEntry entry = Bukkit.getBanList(Type.NAME).getBanEntry(target); Validate.notNull(entry, "Cannot find BanList entry \"" + target + "\""); return entry.getExpiration().getTime(); }
/** * Gets the expiration date from a ban entry. * * @param target Target top get the expiration date from. * @return Returns the expiration date as a long in proper format. */ public Date getExpirationDate(String target) { Validate.notNull(target, "Target cannot be null."); final BanEntry entry = Bukkit.getBanList(Type.NAME).getBanEntry(target); Validate.notNull(entry, "Cannot find BanList entry \"" + target + "\""); return entry.getExpiration(); }
/** * Gets the reason for the ban. * * @param target The target to get the ban reason from. * @return Returns the reason for the ban. */ public String getReason(String target) { Validate.notNull(target, "Target cannot be null."); final BanEntry entry = Bukkit.getBanList(Type.NAME).getBanEntry(target); Validate.notNull(entry, "Cannot find BanList entry \"" + target + "\""); return entry.getReason(); }
/** * Checks if the BanList contains an entry. * * @param target The target to find in the list. * @return True if list contains target, false otherwise. */ public boolean isBanned(String target) { Validate.notNull(target, "Target cannot be null."); final BanEntry entry = Bukkit.getBanList(Type.NAME).getBanEntry(target); if (entry == null) { return false; } return true; }
public static void processEvent(Player player, String exploit) { if (!exploitData.containsKey(exploit.toLowerCase())) { exploitData.put(exploit.toLowerCase(), 0); } exploitData.put(exploit.toLowerCase(), Math.addExact(exploitData.get(exploit.toLowerCase()), 1)); if (AntiExploit.config.getBoolean("AntiExploit.Exploits." + exploit + ".Broadcast") == true) { Bukkit.getServer().broadcastMessage(getMessage(player.getName(), exploit, "Broadcast")); } if (AntiExploit.config.getBoolean("AntiExploit.Exploits." + exploit + ".AlertStaff") == true) { for (Player onlineplayer : Bukkit.getOnlinePlayers()) { if (onlineplayer.hasPermission("AntiExploit.AlertStaff")) { onlineplayer.sendMessage(getMessage(player.getName(), exploit, "AlertStaff")); } } } if (AntiExploit.config.getDouble("AntiExploit.Exploits." + exploit + ".Damage") > 0D) { player.damage(AntiExploit.config.getDouble("AntiExploit.Exploits." + exploit + ".Damage")); } if (AntiExploit.config.getBoolean("AntiExploit.Exploits." + exploit + ".Ban") == true) { Bukkit.getBanList(Type.NAME).addBan(player.getName(), getMessage(player.getName(), exploit, "Ban"), null, "AntiExploit"); } if (AntiExploit.config.getBoolean("AntiExploit.Exploits." + exploit + ".Ban") == true || AntiExploit.config.getBoolean("AntiExploit.Exploits." + exploit + ".Kick") == true) { player.kickPlayer(getMessage(player.getName(), exploit, "Kick")); } return; }
public Set<String> getIPBans() { Set<String> ipBans = new HashSet<String>(); for (BanEntry entry : this.getBanList(Type.IP).getBanEntries()) { ipBans.add(entry.getTarget()); } return ipBans; }
@Override public boolean isTempBanned() { if(Bukkit.getBanList(Type.NAME).isBanned(player)) { Date date = Bukkit.getServer().getBanList(Type.NAME).getBanEntry(player).getExpiration(); if(date != null) { return true; } else { return false; } } return false; }
@Override public void setTempbanned(Long time, String reason, String who) { Date date = new Date(time); Bukkit.getServer().getBanList(Type.NAME).addBan(player, reason, date, who).save(); con.set("tempbanned.isBanned", true); save(); }
@Override public boolean isTempBanned() { if(Bukkit.getBanList(Type.NAME).isBanned(player.getName())) { Date date = Bukkit.getServer().getBanList(Type.NAME).getBanEntry(player.getName()).getExpiration(); if(date != null) { return true; } else { return false; } } return false; }
@Override public BanList getBanList(Type arg0) { // TODO Auto-generated method stub return null; }
@Override public BanList getBanList(Type type) { return null; }
@Override public BanList getBanList(Type arg0) { throw Pokkit.unsupported(); }
public void banIP(String address) { Preconditions.checkNotNull(address, "address"); this.getBanList(Type.IP).addBan(address, null, null, null); }
public BanList getBanList(BanList.Type type) { Preconditions.checkNotNull(type, "type"); return new CanaryBanList(Canary.bans(), type); }
public static BanList getBanList(BanList.Type type) { return null; }
@Override public boolean isPermBanned() { return Bukkit.getServer().getBanList(Type.NAME).isBanned(player); }
@Override public void setPermBanned(String reason, String who) { Bukkit.getServer().getBanList(Type.NAME).addBan(player, reason, null, who).save(); con.set("banned.isBanned", true); save(); }
@Override public String getBanMessage() { return Bukkit.getServer().getBanList(Type.NAME).getBanEntry(player).getReason(); }
@Override public String getTempBanMessage() { return Bukkit.getServer().getBanList(Type.NAME).getBanEntry(player).getReason(); }
@Override public void unban() { Bukkit.getServer().getBanList(Type.NAME).pardon(player); }
@Override public Long getTempbanRemaining() { return Bukkit.getServer().getBanList(Type.NAME).getBanEntry(player).getExpiration().getTime(); }
@Override public boolean isPermBanned() { return Bukkit.getServer().getBanList(Type.NAME).isBanned(player.getName()); }
@Override public void setPermBanned(String reason, String who) { Bukkit.getServer().getBanList(Type.NAME).addBan(player.getName(), reason, null, who).save(); con.set("banned.isBanned", true); }
@Override public String getBanMessage() { return Bukkit.getServer().getBanList(Type.NAME).getBanEntry(player.getName()).getReason(); }
@Override public void setTempbanned(Long time, String reason, String who) { Date date = new Date(time); Bukkit.getServer().getBanList(Type.NAME).addBan(player.getName(), reason, date, who).save(); con.set("tempbanned.isBanned", true); }
@Override public String getTempBanMessage() { return Bukkit.getServer().getBanList(Type.NAME).getBanEntry(player.getName()).getReason(); }
@Override public void unban() { Bukkit.getServer().getBanList(Type.NAME).pardon(player.getName()); }
@Override public Long getTempbanRemaining() { return Bukkit.getServer().getBanList(Type.NAME).getBanEntry(player.getName()).getExpiration().getTime(); }
/** * Unbans a player. * * @param target This is the player to unban. * * <p> * - Note: Add a check in your command method to see if the * banlist contains the target. * </p> */ public void unban(String target) { Validate.notNull(target, "Target cannot be null."); final BanList list = Bukkit.getBanList(Type.NAME); Validate.notNull(list.getBanEntry(target), "Cannot find BanList entry \"" + target + "\""); list.pardon(target); }
/** * Checks if a target is still banned or not. * * @param target This is the player that is being checked for the ban * expire. * @return Returns false if still banned, true otherwise. * * <p> * - Note: Use this method in a login event. To check if a player is * still banned. * </p> */ public boolean isBanExpired(String target) { Validate.notNull(target, "Target cannot be null."); final BanEntry entry = Bukkit.getBanList(Type.NAME).getBanEntry(target); Validate.notNull(entry, "Cannot find BanList entry \"" + target + "\""); final long currentTime = System.currentTimeMillis(); //Gets the current time if (getExpirationLong(target) > currentTime) { return false; } return true; }
BanList getBanList(BanList.Type type);