本文整理汇总了Java中org.bukkit.BanEntry类的典型用法代码示例。如果您正苦于以下问题:Java BanEntry类的具体用法?Java BanEntry怎么用?Java BanEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BanEntry类属于org.bukkit包,在下文中一共展示了BanEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import org.bukkit.BanEntry; //导入依赖的package包/类
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
else if (obj != null && obj instanceof BanEntry)
{
BanEntry banEntry = (BanEntry) obj;
return target.equals(banEntry.getTarget()) && expires.equals(banEntry.getExpiration()) && reason.equals(banEntry.getReason())
&& source.equals(banEntry.getSource()) && created.equals(banEntry.getCreated());
}
else
{
return false;
}
}
示例2: addBan
import org.bukkit.BanEntry; //导入依赖的package包/类
@Override
public BanEntry addBan(String target, String reason, Date expires, String source)
{
final BanEntry entry = new MockBanEntry(target, expires, reason, source);
this.bans.put(target, entry);
return entry;
}
示例3: getBanEntries_OnePersonBanned_SetOfOnePerson
import org.bukkit.BanEntry; //导入依赖的package包/类
@Test
public void getBanEntries_OnePersonBanned_SetOfOnePerson()
{
banList.addBan("target", "reason", new Date(), "source");
Set<BanEntry> entries = banList.getBanEntries();
assertEquals(1, entries.size());
assertEquals("target", entries.iterator().next().getTarget());
}
示例4: getExpirationLong
import org.bukkit.BanEntry; //导入依赖的package包/类
/**
* 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();
}
示例5: getExpirationDate
import org.bukkit.BanEntry; //导入依赖的package包/类
/**
* 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();
}
示例6: getReason
import org.bukkit.BanEntry; //导入依赖的package包/类
/**
* 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();
}
示例7: isBanned
import org.bukkit.BanEntry; //导入依赖的package包/类
/**
* 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;
}
示例8: execute
import org.bukkit.BanEntry; //导入依赖的package包/类
@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
if (!testPermission(sender)) return true;
BanList.Type banType = BanList.Type.NAME;
if (args.length > 0) {
if (args[0].equalsIgnoreCase("ips")) {
banType = BanList.Type.IP;
} else if (!args[0].equalsIgnoreCase("players")) {
sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
return false;
}
}
StringBuilder message = new StringBuilder();
BanEntry[] banlist = Bukkit.getBanList(banType).getBanEntries().toArray(new BanEntry[0]);
for (int x = 0; x < banlist.length; x++) {
if (x != 0) {
if (x == banlist.length - 1) {
message.append(" and ");
} else {
message.append(", ");
}
}
message.append(banlist[x].getTarget());
}
sender.sendMessage("There are " + banlist.length + " total banned players:");
sender.sendMessage(message.toString());
return true;
}
示例9: getBanEntry
import org.bukkit.BanEntry; //导入依赖的package包/类
@Override
public BanEntry getBanEntry(String target) {
BanEntry entry = null;
for (Ban ban : this.banManager.getAllBans()) {
if (ban.getSubject().equalsIgnoreCase(target) && (ban.isIpBan() == isIpBan)) {
entry = new CanaryBanEntry(ban);
}
}
return entry;
}
示例10: addBan
import org.bukkit.BanEntry; //导入依赖的package包/类
@Override
public BanEntry addBan(String target, String reason, Date expires, String source) {
Ban ban = new Ban(Canary.getServer().getPlayer(target), reason, this.isIpBan);
ban.setBanningPlayer(source);
this.banManager.issueBan(ban);
return this.getBanEntry(target);
}
示例11: getBanEntries
import org.bukkit.BanEntry; //导入依赖的package包/类
@Override
public Set<BanEntry> getBanEntries() {
Set<BanEntry> bans = Sets.newHashSet();
for (Ban ban : this.banManager.getAllBans()) {
if (ban.isIpBan() == this.isIpBan) {
bans.add(new CanaryBanEntry(ban));
}
}
return bans;
}
示例12: getIPBans
import org.bukkit.BanEntry; //导入依赖的package包/类
public Set<String> getIPBans() {
Set<String> ipBans = new HashSet<String>();
for (BanEntry entry : this.getBanList(Type.IP).getBanEntries()) {
ipBans.add(entry.getTarget());
}
return ipBans;
}
示例13: getBannedIps
import org.bukkit.BanEntry; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see com.blockhaus2000.ipm.minecraft.IpBanlist#getBannedIps()
*/
@Override
public Set<String> getBannedIps() {
final Set<String> result = new HashSet<String>();
for (final BanEntry banEntry : Bukkit.getServer().getBanList(BanList.Type.IP).getBanEntries()) {
result.add(banEntry.getTarget());
}
return result;
}
示例14: getBannedPlayers
import org.bukkit.BanEntry; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @see com.blockhaus2000.ipm.minecraft.Banlist#getBannedPlayers()
*/
@SuppressWarnings("deprecation")
@Override
public Set<OfflinePlayer> getBannedPlayers() {
final Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
for (final BanEntry banEntry : Bukkit.getServer().getBanList(BanList.Type.NAME).getBanEntries()) {
result.add(InternalPluginManager.getServer().getPlayerManager().getOfflinePlayer(banEntry.getTarget()));
}
return result;
}
示例15: addBan
import org.bukkit.BanEntry; //导入依赖的package包/类
@Override
public BanEntry addBan(String target, String reason, Date expires, String source) {
try {
BanEntry entry = cache.get(target, () -> new PoreBanEntry(target, this));
entry.setCreated(new Date());
entry.setReason(reason);
entry.setExpiration(expires);
entry.setSource(source);
entry.save();
return entry;
} catch (ExecutionException e) {
throw Throwables.propagate(e.getCause());
}
}