本文整理汇总了Java中org.bukkit.event.player.PlayerLoginEvent.Result.ALLOWED属性的典型用法代码示例。如果您正苦于以下问题:Java Result.ALLOWED属性的具体用法?Java Result.ALLOWED怎么用?Java Result.ALLOWED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.event.player.PlayerLoginEvent.Result
的用法示例。
在下文中一共展示了Result.ALLOWED属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerLogin
@EventHandler(ignoreCancelled = false)
public void onPlayerLogin(cn.nukkit.event.player.PlayerLoginEvent event) {
if (canIgnore(PlayerLoginEvent.getHandlerList())) {
return;
}
Player bukkitPlayer = PokkitPlayer.toBukkit(event.getPlayer());
InetAddress address = bukkitPlayer.getAddress().getAddress();
PlayerLoginEvent bukkitEvent = new PlayerLoginEvent(bukkitPlayer, bukkitPlayer.getAddress().getHostName(),
address, event.isCancelled() ? Result.KICK_OTHER : Result.ALLOWED, event.getKickMessage(), address);
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCancelled(bukkitEvent.getResult() != Result.ALLOWED);
event.setKickMessage(bukkitEvent.getKickMessage());
}
示例2: onPlayerLogin
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerLogin(final PlayerLoginEvent event) {
if (event.getResult() == Result.ALLOWED) {
final UUID id = event.getPlayer().getUniqueId();
final String playerIp = event.getAddress().getHostAddress();
if (this.punishmentDb.isIdBanned(id)) {
final Punishment ban = this.punishmentDb.get(id.toString(), PunishmentType.BAN);
final String playerBannedMessage;
if (ban.isPermanent()) {
playerBannedMessage = this.plugin.getMessages().get(MessageId.player_deniedPermBanned, ban.getReason())[0];
} else {
playerBannedMessage = this.plugin.getMessages().get(MessageId.player_deniedTempBanned, ban.getReason(), TimeUtil.toString((ban.getEndDate() - System.currentTimeMillis()) / 1000))[0];
}
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, playerBannedMessage);
} else if (this.punishmentDb.isIpBanned(playerIp)) {
final Punishment ipBan = this.punishmentDb.get(playerIp, PunishmentType.IPBAN);
final String ipBannedMessage;
if (ipBan.isPermanent()) {
ipBannedMessage = this.plugin.getMessages().get(MessageId.player_deniedPermIpBanned, ipBan.getReason())[0];
} else {
ipBannedMessage = this.plugin.getMessages().get(MessageId.player_deniedTempIpBanned, ipBan.getReason(), TimeUtil.toString((ipBan.getEndDate() - System.currentTimeMillis()) / 1000))[0];
}
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ipBannedMessage);
}
}
}
示例3: PlayerLoginDataUpdate
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
@Localized("CRAZYLOGIN.KICKED.NOACCOUNT")
public void PlayerLoginDataUpdate(final PlayerLoginEvent event) {
if (event.getResult() != Result.ALLOWED) {
return;
}
final Player player = event.getPlayer();
final LoginPlayerData data = plugin.getCrazyDatabase().updateEntry(player.getName());
if (!plugin.isBlockingGuestJoinEnabled() || data != null) {
return;
}
event.setResult(Result.KICK_WHITELIST);
event.setKickMessage(plugin.getLocale().getLocaleMessage(player, "KICKED.NOACCOUNT"));
plugin.getCrazyLogger().log("AccessDenied", "Denied access for player " + player.getName() + " @ " + event.getAddress().getHostAddress() + " because of he has no account!");
}
示例4: onPlayerLogin
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(final PlayerLoginEvent event) {
if (event.getResult() == Result.ALLOWED) {
final String playerName = event.getPlayer().getName();
if (!PlayerIdsUtil.isValidMinecraftUserName(playerName)) {
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
event.setKickMessage(this.plugin.getMessages().get(MessageId.general_nicknameFilter_invalid, playerName)[0]);
}
}
}
示例5: onPlayerLoginLast
/**
* Unregisters the player if the login failed.
*
* @param event the PlayerLoginEvent
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLoginLast(final PlayerLoginEvent event) {
if (event.getResult() != Result.ALLOWED) {
this.plugin.getManager().unRegisterPlayer(event.getPlayer());
}
}
示例6: onPlayerLogin
@EventHandler(priority = EventPriority.HIGHEST)
void onPlayerLogin (PlayerLoginEvent event)
{
Player player = event.getPlayer();
//all this is anti-spam code
if(GriefPrevention.instance.config_spam_enabled)
{
//FEATURE: login cooldown to prevent login/logout spam with custom clients
long now = Calendar.getInstance().getTimeInMillis();
//if allowed to join and login cooldown enabled
if(GriefPrevention.instance.config_spam_loginCooldownSeconds > 0 && event.getResult() == Result.ALLOWED && !player.hasPermission("griefprevention.spam"))
{
//determine how long since last login and cooldown remaining
Date lastLoginThisSession = lastLoginThisServerSessionMap.get(player.getUniqueId());
if(lastLoginThisSession != null)
{
long millisecondsSinceLastLogin = now - lastLoginThisSession.getTime();
long secondsSinceLastLogin = millisecondsSinceLastLogin / 1000;
long cooldownRemaining = GriefPrevention.instance.config_spam_loginCooldownSeconds - secondsSinceLastLogin;
//if cooldown remaining
if(cooldownRemaining > 0)
{
//DAS BOOT!
event.setResult(Result.KICK_OTHER);
event.setKickMessage("You must wait " + cooldownRemaining + " seconds before logging-in again.");
event.disallow(event.getResult(), event.getKickMessage());
return;
}
}
}
//if logging-in account is banned, remember IP address for later
if(GriefPrevention.instance.config_smartBan && event.getResult() == Result.KICK_BANNED)
{
this.tempBannedIps.add(new IpBanInfo(event.getAddress(), now + this.MILLISECONDS_IN_DAY, player.getName()));
}
}
//remember the player's ip address
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
playerData.ipAddress = event.getAddress();
}
示例7: onPlayerLogin
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLogin(PlayerLoginEvent event) {
if (event.getResult() == Result.ALLOWED && event.getPlayer() != null)
tgym.afkTimer
.put(event.getPlayer().getName(), System.currentTimeMillis());
}