-
Notifications
You must be signed in to change notification settings - Fork 7
Development | NetworkPlayer
The NetworkPlayer is the main object in DKBans, you can get information from this player or interact with him.
- Get a player
- Simple getter
- Simple setter
- Properties
- History
- Ban a player
- Kick a player
- Warn a player
- Unban a player
- Report a player
Get information from a player.
//Get a player by his name
NetworkPlayer player = BanSystem.getInstance().getPlayerManager().getPlayer("Dkrieger");
//Get a player by his uuid
NetworkPlayer player = BanSystem.getInstance().getPlayerManager().getPlayer(uuid);
//Get a player by his id
NetworkPlayer player = BanSystem.getInstance().getPlayerManager().getPlayer(1);
//Search a player by a name, uuid or id
NetworkPlayer player = BanSystem.getInstance().getPlayerManager().searchPlayer(1);
String#player.getName(); //Returns the players name
String#player.getColoredName(); //Returns the name with the color before
UUID#player.getUUID(); //Returns the players uuid
Integer#player.getID(); //Returns the players id
String#player.getCountry(); //Returns the players country
Long#player.getLastLogin(); //Returns the last login timestamp
Long#player.getFirstLogin(); //Returns the first login timestamp
Long#player.getOnlineTime(); //Returns the online time
List<OnlineSessions>player.getOnlineSessions(); //Returns the saved online sessions from a player
History#player.getHistory(); //Returns the history from a player
Boolean#player.isTeamChatLoggedIn(); //Returns if the player is logged in to team messages
Boolean#player.isReportLoggedIn(); //Returns if the player receives reports
player.setTeamChatLogin(boolean login) //Set if the player receives team messages
player.setLogin(boolean login) //Set if the player receives reports
You can add custome data to a player.
//Add and save a custom property
player.getProperties().append("MyCustomProperty","Hey");
player.saveProperties();
//Get a a custom property
String#player.getProperties().getString("MyCustomProperty");
Each player has a history wich contains information about bans, unbans or kicks. The history calculates always if the player is banned or not.
You are also able to create custom history entries, more information about history entries here
See here more about the history.
//Get the history from a player
History history = player.getHistory();
List<HistoryEntry>#history.getEntries(); //Get all entries from a history (Bans, Kicks usw.)
List<HistoryEntry>#history.getEntriesSorted(); //Get all entries sorted by the timestamp
List<Bans>#history.getBans(BanType type); //Get all active bans
Ban#historygetBan(BanType type); //Get an active ban
Kick#historygetLastKick(); // Get the last kick
Unban#historygetLastUnban(); //Get the last unban
Boolean#history.isBanned(); //If the player is banned (Chat or Network)
Boolean#history.isBanned(BanType type); //If the player is banned fo a specified type (Chat or Network)
player.resetHistory(); //Reset a history from a player
player.resetHistory(30); //Reset a history entry from a player
DKBans has many options for banning a players. We have only described simple ways, for extended options use the javadocs.
//Ban a player for a configured reason
BanReason reason = BanSystem.getInstance().getReasonProvider().getBanReason(2);
Ban#player.ban(reason,"My message","AntiCheat");
//Ban a player for a custom reason
Ban#player.ban(BanType.NETWORK,30,TimeUnit.DAYS,"Hacking","My message",-1,"AntiCheat");
DKBans has many options for kicking a players. We have only described simple ways, for extended options use the javadocs.
//Kick a player for a configured reason
KickReason reason = BanSystem.getInstance().getReasonProvider().getKickReason(1);
Kick#player.kick(reason,"My message","AntiCheat");
//Kick a player for a custom reason
Kick#player.kick("Insult","My message","AntiCheat");
DKBans has many options for warning a players. We have only described simple ways, for extended options use the javadocs.
//Warn a player for a configured reason
WarnReason reason = BanSystem.getInstance().getReasonProvider().getWarnReason(5);
Warn#player.warn(reason,"My message","AntiCheat");
//Warn a player for a custom reason
Warn#player.warn("Nop","My message","AntiCheat");
DKBans has many options for unbanning a players. We have only described simple ways, for extended options use the javadocs.
//Unban a player for a configured reason
UnbanReason reason = BanSystem.getInstance().getReasonProvider().getUnbanReason(3);
Unban#player.unban(BanType.NETWORK,reason,"My message","AntiCheat");
//Unban a player for a custom reason
Unban#player.unban(BanType.NETWORK,"Nop","My message","AntiCheat");
DKBans has many options for reporting a players. We have only described simple ways, for extended options use the javadocs.
//Report a player for a configured reason
ReportReason reason = BanSystem.getInstance().getReasonProvider().getReportReason(12);
Report#player.report(reason,"My message","AntiCheat-report");
//Report a player for a custom reason
Report#player.unban(reporterUUID,"Hacking","My message");
//Get a report from a reporter
//Deny all reports
player.denyReports();
//Delete all reports
player.deleteReports();