public class PunishmentManager extends Object
Constructor and Description |
---|
PunishmentManager() |
Modifier and Type | Method and Description |
---|---|
void |
discard(String name)
Discard a players punishments from the cache.
|
static PunishmentManager |
get()
Get the punishment manager.
|
Punishment |
getBan(String uuid)
Get a players active ban.
|
int |
getCalculationLevel(String uuid,
String layout)
Get punishment-time calculation level.
|
int |
getCurrentWarns(String uuid)
Get how many warnings a player has.
|
Set<Punishment> |
getLoadedHistory()
Get all cached history punishments.
|
Set<Punishment> |
getLoadedPunishments(boolean checkExpired)
Get all cached punishments.
|
Punishment |
getMute(String uuid)
Get a players active mute.
|
Punishment |
getPunishment(int id)
Get an active punishment by id.
|
Punishment |
getPunishmentFromResultSet(ResultSet rs)
Get a Punishment from a
ResultSet |
List<Punishment> |
getPunishments(SQLQuery sqlQuery,
Object... parameters)
Get parsed punishments from the database queried by the given
SQLQuery .The parameters work as described in MessageManager.sendMessage(Object, String, boolean, String...) . |
List<Punishment> |
getPunishments(String target,
PunishmentType put,
boolean current)
Get all punishments which belong to the given uuid or ip.
|
Punishment |
getWarn(int id)
Get an active warning by id.
|
List<Punishment> |
getWarns(String uuid)
Get a players active warnings.
|
boolean |
isBanned(String uuid)
Check whether a player is banned.
|
boolean |
isCached(String target)
Check whether the data for the given uuid, ip or username are currently cached.
|
boolean |
isMuted(String uuid)
Check whether a player is muted.
|
InterimData |
load(String name,
String uuid,
String ip)
Get a users punishments as
InterimData . |
void |
setCached(InterimData data)
Mark the InterimData as cached.
|
void |
setup()
Initially clears out all expired punishments.
|
public static PunishmentManager get()
public void setup()
public InterimData load(String name, String uuid, String ip)
InterimData
. This method is meant to be called if the goal eventually is
to add the users punishments to the cache. If you are just interested in the specific punishments there are
more convenient methods as getBan(String)
, getMute(String)
, getWarns(String)
or getPunishments(String, PunishmentType, boolean)
.name
- the users nameuuid
- the users uuidip
- the users ippublic void discard(String name)
name
- the namepublic List<Punishment> getPunishments(String target, PunishmentType put, boolean current)
target
- the uuid or ip to search forput
- the basic punishment type to search for (PunishmentType.BAN
would also include Tempbans).
Use null
to search for all punishments.current
- if only active punishments should be included.public List<Punishment> getPunishments(SQLQuery sqlQuery, Object... parameters)
SQLQuery
.MessageManager.sendMessage(Object, String, boolean, String...)
.sqlQuery
- the sql queryparameters
- the parameterspublic Punishment getPunishment(int id)
id
- the idpublic Punishment getWarn(int id)
id
- the idpublic List<Punishment> getWarns(String uuid)
uuid
- the players uuidpublic Punishment getBan(String uuid)
uuid
- the players uuid (can also be an IP)null
if not bannedpublic Punishment getMute(String uuid)
uuid
- the players uuidnull
if not mutedpublic boolean isBanned(String uuid)
uuid
- the players uuid (can also be an IP)public boolean isMuted(String uuid)
uuid
- the players uuidpublic boolean isCached(String target)
target
- the target (uuid, ip or username)public void setCached(InterimData data)
InterimData.accept()
to do that.data
- the datapublic int getCalculationLevel(String uuid, String layout)
uuid
- the players uuidlayout
- the time-layout namepublic int getCurrentWarns(String uuid)
uuid
- the players uuidpublic Set<Punishment> getLoadedPunishments(boolean checkExpired)
checkExpired
- whether to look for and remove expired punishmentspublic Punishment getPunishmentFromResultSet(ResultSet rs) throws SQLException
ResultSet
rs
- the result setSQLException
- the sql exceptionpublic Set<Punishment> getLoadedHistory()
Copyright © 2020. All rights reserved.