@EventHandler
public void onLogin(PlayerLoginEvent event) {
QueuedJoin queuedJoin = getQueuedUserProfile(event.getPlayer());
if (queuedJoin == null) {
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
event.setKickMessage(ChatColor.RED + "Unable to load user profile. Please try again.");
return;
}
PlayerContext playerContext = new PlayerContext(event.getPlayer(), queuedJoin.getUserProfile());
TGM.get().getPlayerManager().addPlayer(playerContext);
for (LoginService loginService : loginServices) {
loginService.login(playerContext);
}
queuedJoins.remove(queuedJoin);
}
java类org.bukkit.event.player.PlayerLoginEvent的实例源码
JoinManager.java 文件源码
项目:Warzone
阅读 16
收藏 0
点赞 0
评论 0
Listeners.java 文件源码
项目:Capatchafy
阅读 25
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent event)
{
if (!Capatchafy.forced && !Capatchafy.configs.config.getBoolean("always-on") && !Capatchafy.enabled)
{
throttleConnections();
}
if (!Capatchafy.enabled) return;
String ip = event.getAddress().toString().replaceAll("/", "");
if (!Capatchafy.configs.isAuthorized(ip))
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.RED + "" + ChatColor.BOLD + "Yikes, we're under attack! Please solve the capatcha.\n" +
ChatColor.WHITE + "Please go to " + ChatColor.GOLD + url + ChatColor.WHITE + " in your web browser and solve the capatcha.\n" +
"Once solved successfully, you will be able to join.");
return;
}
if (Capatchafy.securityLevel == 3)
{
Capatchafy.configs.setAuthorized(ip, false);
}
}
TeamListener.java 文件源码
项目:ProjectAres
阅读 29
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(UserLoginEvent event) {
TeamManager teamManager = teamManagerProvider.get();
Entrant participation = teamManager.getEntrant(event.getUser());
if(participation == null) return;
final int playerCount = (int) onlinePlayers.all()
.stream()
.filter(player -> !player.equals(event.getPlayer()) &&
participation.members().contains(userStore.playerId(player)))
.count();
int maxPlayers = tournament.max_players_per_match();
if(playerCount >= maxPlayers) {
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, new Component(new TranslatableComponent("tourney.kick.maxPlayers", String.valueOf(maxPlayers)), ChatColor.RED));
} else {
if(event.getResult().equals(PlayerLoginEvent.Result.KICK_WHITELIST)) {
event.allow(); // explicitly allow players on teams but not whitelist
}
}
}
PlayerManager.java 文件源码
项目:VanillaPlus
阅读 32
收藏 0
点赞 0
评论 0
@EventHandler
public void playerLogin(PlayerLoginEvent event){
VPPlayer player = preLoad(event.getPlayer());
if(player == null){
ErrorLogger.addError("Couldn't preload " + event.getPlayer());
event.setResult(Result.KICK_OTHER);
return;
}
if(player.isOnline()){
event.setResult(Result.KICK_OTHER);
//player.setOffline();
return;
}
VanillaPlusCore.getChannelManager().init(player);
VPPLoginEvent e = new VPPLoginEvent(player);
e.setResult(Result.ALLOWED);
Bukkit.getServer().getPluginManager().callEvent(e);
event.setResult(e.getResult());
}
InvisiblePlayerFixListener.java 文件源码
项目:SamaGamesCore
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event)
{
//Don't force if player is hided moderator
Bukkit.getScheduler().runTaskLater(pluginAPI, () -> {
if(!pluginAPI.getAPI().getJoinManager().getModeratorsExpected().contains(event.getPlayer().getUniqueId()))
{
try{
sendPlayerToAll(event.getPlayer());
sendAllToPlayer(event.getPlayer());
}catch (Exception e)
{
e.printStackTrace();
}
}
}, 5L);
}
APIPlugin.java 文件源码
项目:SamaGamesCore
阅读 18
收藏 0
点赞 0
评论 0
@EventHandler
public void onLogin(PlayerLoginEvent event)
{
if (!allowJoin)
{
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ChatColor.RED + denyJoinReason);
event.setResult(PlayerLoginEvent.Result.KICK_WHITELIST);
event.setKickMessage(ChatColor.RED + denyJoinReason);
return;
}
if (joinPermission != null && !api.getPermissionsManager().hasPermission(event.getPlayer(), joinPermission))
{
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "Vous n'avez pas la permission de rejoindre ce serveur.");
}
if (!ipWhiteList.contains(event.getRealAddress().getHostAddress()))
{
event.setResult(PlayerLoginEvent.Result.KICK_WHITELIST);
event.setKickMessage(ChatColor.RED + "Erreur de connexion vers le serveur... Merci de bien vouloir ré-essayer plus tard.");
Bukkit.getLogger().log(Level.WARNING, "An user tried to connect from IP " + event.getRealAddress().getHostAddress());
}
}
PlayerLoginListener.java 文件源码
项目:Mega-Walls
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLogin(PlayerLoginEvent e)
{
if (e.getResult() == PlayerLoginEvent.Result.ALLOWED)
{
User user = MWAPI.getOfflineUserHandler().findById(e.getPlayer().getUniqueId());
if (user == null)
{
user = new BasicUser(e.getPlayer().getUniqueId());
MWAPI.getOfflineUserHandler().insert(user);
}
((BasicUserHandler) MWAPI.getUserHandler()).add(user);
}
}
ConditionalPerms.java 文件源码
项目:ConditionalPerms
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void setup(TerminableConsumer consumer) {
Events.subscribe(PlayerLoginEvent.class)
.handler(e -> attachments.put(e.getPlayer().getUniqueId(), e.getPlayer().addAttachment(this)))
.bindWith(consumer);
Events.subscribe(PlayerJoinEvent.class)
.handler(e -> {
refreshPlayer(e.getPlayer());
refreshPlayer(e.getPlayer(), 20L);
})
.bindWith(consumer);
Events.subscribe(PlayerQuitEvent.class)
.handler(e -> e.getPlayer().removeAttachment(attachments.remove(e.getPlayer().getUniqueId())))
.bindWith(consumer);
}
BukkitConnectionListener.java 文件源码
项目:LuckPerms
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLoginMonitor(PlayerLoginEvent e) {
/* Listen to see if the event was cancelled after we initially handled the login
If the connection was cancelled here, we need to do something to clean up the data that was loaded. */
// Check to see if this connection was denied at LOW. Even if it was denied at LOW, their data will still be present.
boolean denied = false;
if (this.deniedLogin.remove(e.getPlayer().getUniqueId())) {
denied = true;
// This is a problem, as they were denied at low priority, but are now being allowed.
if (e.getResult() == PlayerLoginEvent.Result.ALLOWED) {
this.plugin.getLog().severe("Player connection was re-allowed for " + e.getPlayer().getUniqueId());
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, "");
}
}
// Login event was cancelled by another plugin since we first loaded their data
if (denied || e.getResult() != PlayerLoginEvent.Result.ALLOWED) {
return;
}
// everything is going well. login was processed ok, this is just to refresh auto-op status.
this.plugin.refreshAutoOp(this.plugin.getUserManager().getIfLoaded(e.getPlayer().getUniqueId()), e.getPlayer());
}
EffCancelEvent.java 文件源码
项目:Skript
阅读 28
收藏 0
点赞 0
评论 0
@SuppressWarnings("null")
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {
if (isDelayed == Kleenean.TRUE) {
Skript.error("Can't cancel an event anymore after is has already passed", ErrorQuality.SEMANTIC_ERROR);
return false;
}
cancel = matchedPattern == 0;
final Class<? extends Event>[] es = ScriptLoader.getCurrentEvents();
if (es == null)
return false;
for (final Class<? extends Event> e : es) {
if (Cancellable.class.isAssignableFrom(e) || BlockCanBuildEvent.class.isAssignableFrom(e))
return true; // TODO warning if some event(s) cannot be cancelled even though some can (needs a way to be suppressed)
}
if (ScriptLoader.isCurrentEvent(PlayerLoginEvent.class))
Skript.error("A connect event cannot be cancelled, but the player may be kicked ('kick player by reason of \"...\"')", ErrorQuality.SEMANTIC_ERROR);
else
Skript.error(Utils.A(ScriptLoader.getCurrentEventName()) + " event cannot be cancelled", ErrorQuality.SEMANTIC_ERROR);
return false;
}
PlayerListener.java 文件源码
项目:OldBukkit
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
void onJoin(PlayerLoginEvent e) {
if (BanManager.isBanido(e.getPlayer().getName())) {
String[] ban = BanManager.getBan(e.getPlayer().getName()).split(";");
String motivo = ban[2], admin = ban[3];
int tempo = Integer.parseInt(ban[1]);
if (tempo == 0) {
e.disallow(Result.KICK_OTHER, MensagensManager.getMensagem("Ban.Join.Permanente").replace("<admin>", admin).replace("<motivo>", motivo));
return;
}
if (Utils.getTempoRestante(e.getPlayer().getName()) >= tempo) {
BanManager.unbanPlayer(e.getPlayer().getName());
return;
}
long tempoRestante = (tempo - Utils.getTempoRestante(e.getPlayer().getName()));
e.disallow(Result.KICK_OTHER, MensagensManager.getMensagem("Ban.Join.Temporario").replace("<tempo>", Long.toString(tempoRestante)).replace("<admin>", admin).replace("<motivo>", motivo));
} else if (BanManager.isIpBanido(e.getAddress().getHostName())) {
e.disallow(Result.KICK_OTHER, MensagensManager.getMensagem("Ban.Join.Ip_Banido"));
}
}
Static.java 文件源码
项目:K-Security
阅读 27
收藏 0
点赞 0
评论 0
public static void init(JavaPlugin plugin) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
BufferedReader reader = URLs.IP_CHECKER.openBufferedReader();
address = reader.readLine();
} catch (IOException e) {
// Ignore
}
});
Bukkit.getPluginManager().registerEvents(new Listener() {
@EventHandler
public void onLogin(PlayerLoginEvent event) throws UnknownHostException {
String host = event.getHostname();
String addrStr = host.substring(0, host.indexOf(':'));
InetAddress addr = InetAddress.getByName(addrStr);
if (!addr.isLoopbackAddress() && !addr.isSiteLocalAddress()) {
address = addrStr;
event.getHandlers().unregister(this);
}
}
}, plugin);
}
TestBukkit.java 文件源码
项目:ExilePearl
阅读 21
收藏 0
点赞 0
评论 0
/**
* Creates a new player instance and adds it to the server
* @param name The player name
* @param uid The player UUID
* @return The player instance
*/
public static TestPlayer createOnlinePlayer(String name, UUID uid) {
TestPlayer p = TestPlayer.create(name);
final InetSocketAddress address = new InetSocketAddress("localhost", 25565);
final AsyncPlayerPreLoginEvent preLoginEvent = new AsyncPlayerPreLoginEvent(name, address.getAddress(), uid);
getPluginManager().callEvent(preLoginEvent);
if (preLoginEvent.getLoginResult() != Result.ALLOWED) {
return null;
}
final PlayerLoginEvent loginEvent = new PlayerLoginEvent(p, "localhost", address.getAddress());
getPluginManager().callEvent(loginEvent);
if (loginEvent.getResult() != PlayerLoginEvent.Result.ALLOWED) {
return null;
}
final PlayerJoinEvent joinEvent = new PlayerJoinEvent(p, "");
getPluginManager().callEvent(joinEvent);
p.goOnline();
return p;
}
PlayerConnectEvents.java 文件源码
项目:Pokkit
阅读 23
收藏 0
点赞 0
评论 0
@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());
}
UDBListener.java 文件源码
项目:UDB
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent e){
Player player = e.getPlayer();
if(plugin.getPlayerDatabase().isInDatabase(player)){
PlayerDatabase.PlayerData playerData = plugin.getPlayerDatabase().getDataByUUID(player.getUniqueId().toString());
if(playerData.isBanned()){
long elapsed = System.currentTimeMillis() - playerData.getBanTime();
int minutes = (((int) (elapsed / 1000)) / 60);
if(minutes >= plugin.getTempBanTime()){
playerData.setBanned(false);
playerData.setLives(1);
playerData.setSurvivalRecord(Long.toString(System.currentTimeMillis()));
playerData.setBanTime(-1);
} else {
int difference = plugin.getTempBanTime() - minutes;
int hourDiff = difference / 60;
int minDiff = difference - (hourDiff * 60);
String diff = hourDiff +" hours, "+minDiff+" minutes.";
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your UDB ban is not over yet. You still have: "+diff);
}
}
}
}
PlayerLoginListener.java 文件源码
项目:SurvivalCG
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
void onPlayerLogin(PlayerLoginEvent e) {
Player p = e.getPlayer();
DeathManager deathManager = plugin.getManager().getDeathManager();
if(p.hasPermission("scg.hardcore.bypass")) {
return;
}
long bantime = deathManager.getPlayer(p.getName());
if (bantime > System.currentTimeMillis()) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm");
Date date = new Date(bantime);
String msg = plugin.getManager().getSettingsManager().getHcKickMsg().replace("{TIME}", dateFormat.format(date));
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, ColoringUtil.colorText(msg));
}else {
deathManager.unbanPlayer(p.getName());
}
}
TinyProtocol.java 文件源码
项目:MoreMobs
阅读 31
收藏 0
点赞 0
评论 0
private void registerBukkitEvents() {
listener = new Listener() {
@EventHandler(priority = EventPriority.LOWEST)
public final void onPlayerLogin(PlayerLoginEvent e) {
if (closed)
return;
Channel channel = getChannel(e.getPlayer());
if (!uninjectedChannels.contains(channel)) {
injectPlayer(e.getPlayer());
}
}
@EventHandler
public final void onPluginDisable(PluginDisableEvent e) {
if (e.getPlugin().equals(plugin)) {
close();
}
}
};
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
PowerfulPermissionManager.java 文件源码
项目:PowerfulPerms
阅读 22
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLogin(final PlayerLoginEvent e) {
debug("PlayerLoginEvent " + e.getPlayer().getName());
debug("Player world " + e.getPlayer().getWorld().getName());
if (cachedPlayers.containsKey(e.getPlayer().getUniqueId())) {
// Player is cached. Continue load it.s
loadCachedPlayer(e.getPlayer());
} else {
// Player is not cached, Load directly on Bukkit main thread.
debug("onPlayerLogin player isn't cached, loading directly");
loadPlayer(e.getPlayer().getUniqueId(), e.getPlayer().getName(), true, true);
if (e.getResult() == PlayerLoginEvent.Result.ALLOWED)
loadCachedPlayer(e.getPlayer());
}
}
EventListener.java 文件源码
项目:libelula
阅读 35
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onLoginEvent(PlayerLoginEvent e) {
if (plugin.cm.isFrontServer()) {
if (plugin.pm.isBoggedDown(e.getPlayer())) {
e.disallow(PlayerLoginEvent.Result.KICK_OTHER,
plugin.cm.getTarpittingPenaltyMessage());
return;
}
if (!plugin.cm.isPremium()) {
if (plugin.pm.isPremium(e.getPlayer())) {
e.disallow(PlayerLoginEvent.Result.KICK_OTHER,
plugin.cm.getPremiumKickMessage());
return;
}
}
plugin.pm.spawn(e.getPlayer());
}
}
TinyProtocolAPI.java 文件源码
项目:-XclsX-TPAv3-XclsX-
阅读 22
收藏 0
点赞 0
评论 0
private void registerBukkitEvents() {
listener = new Listener() {
@EventHandler(priority = EventPriority.LOWEST)
public final void onPlayerLogin(PlayerLoginEvent e) {
if (closed)
return;
Channel channel = getChannel(e.getPlayer());
if (!uninjectedChannels.contains(channel))
injectPlayer(e.getPlayer());
}
@EventHandler
public final void onPluginDisable(PluginDisableEvent e) {
if (e.getPlugin().equals(plugin)) {
close();
}
}
};
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
TinyProtocol.java 文件源码
项目:SignGUI
阅读 53
收藏 0
点赞 0
评论 0
private void registerBukkitEvents() {
listener = new Listener() {
@EventHandler(priority = EventPriority.LOWEST)
public final void onPlayerLogin(PlayerLoginEvent e) {
if (closed)
return;
Channel channel = getChannel(e.getPlayer());
if (!uninjectedChannels.contains(channel)) {
injectPlayer(e.getPlayer());
}
}
@EventHandler
public final void onPluginDisable(PluginDisableEvent e) {
if (e.getPlugin().equals(plugin)) {
close();
}
}
};
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
TinyProtocol.java 文件源码
项目:-XclsX-TPAv2-XclsX-
阅读 24
收藏 0
点赞 0
评论 0
private void registerBukkitEvents() {
listener = new Listener() {
@EventHandler(priority = EventPriority.LOWEST)
public final void onPlayerLogin(PlayerLoginEvent e) {
if (closed)
return;
Channel channel = getChannel(e.getPlayer());
if (!uninjectedChannels.contains(channel)) {
injectPlayer(e.getPlayer());
}
}
@EventHandler
public final void onPluginDisable(PluginDisableEvent e) {
if (e.getPlugin().equals(plugin)) {
close();
}
}
};
plugin.getServer().getPluginManager().registerEvents(listener, plugin);
}
GlowStoneLoginListenerPlay.java 文件源码
项目:ProtocolSupport
阅读 21
收藏 0
点赞 0
评论 0
@Override
protected void checkBans(PlayerLoginEvent event, Object[] data) {
String name = event.getPlayer().getName();
String hostaddr = event.getAddress().getHostAddress();
final BanList nameBans = server.getBanList(BanList.Type.NAME);
final BanList ipBans = server.getBanList(BanList.Type.IP);
if (nameBans.isBanned(name)) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Banned: " + nameBans.getBanEntry(name).getReason());
} else if (ipBans.isBanned(hostaddr)) {
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "Banned: " + ipBans.getBanEntry(hostaddr).getReason());
} else if (server.hasWhitelist() && !event.getPlayer().isWhitelisted()) {
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not whitelisted on this server.");
} else if (server.getOnlinePlayers().size() >= server.getMaxPlayers()) {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full (" + server.getMaxPlayers() + " players).");
}
}
GameState.java 文件源码
项目:Scapegoat
阅读 24
收藏 0
点赞 0
评论 0
/**
* Triggered when a player TRIES to join the server.
* @param e
*/
@EventHandler
public void onPlayerLogin(PlayerLoginEvent e)
{
Player p = e.getPlayer();
if (plugin.isInMaintenanceMode() && !p.isOp())
{
e.disallow(Result.KICK_OTHER,
ChatColor.YELLOW + plugin.getMaintenanceMessage());
}
else if (SGOnline.getPlayerCount() >= plugin.getMaxPlayers())
{
e.disallow(Result.KICK_FULL, ChatColor.YELLOW
+ "Le serveur est plein !");
}
}
BanListener.java 文件源码
项目:CraftoPlugin
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerLogin(final PlayerLoginEvent event) {
final Optional<CraftoPlayer> player = CraftoPlayer.getPlayer(event.getPlayer());
if (!player.isPresent()) { CraftoMessenger.warnStaff("Cant find craftoplayer instance of " + event.getPlayer().getName() + "!"); return; }
final Collection<Ban> bans = this.module.getBans(player.get());
if (!bans.isEmpty()) {
for (final Ban ban : bans) {
if (!ban.hasExpired()) {
if (ban.isKick()) {
event.disallow(Result.KICK_BANNED, this.module.kick.getKickMessage(ban));
}
else {
CraftoMessenger.warnStaff(player.get().getName() + " versucht zu connecten obwohl er noch gebannt ist.");
event.disallow(Result.KICK_BANNED, this.module.ban.getKickMessage(ban));
}
}
}
}
}
BanListener.java 文件源码
项目:BetterAssociations
阅读 30
收藏 0
点赞 0
评论 0
@EventHandler(priority = EventPriority.LOWEST)
public void tooManyLoggedInAccounts(PlayerLoginEvent event){ // Set to join because if kicked on login ip info isnt tracked.
UUID name = event.getPlayer().getUniqueId();
int count = 0;
int allowed = plugin.getConfig().getInt("banmanager.set.altlimit");
if (allowed == 0) return;
List<UUID> alts = am.getAltsListUUID(name);
Player[] players = Bukkit.getOnlinePlayers();
for (Player p: players)
if(alts.contains(p.getUniqueId())) count++;
if (count > allowed){
String reason = plugin.getConfig().getString("banmanager.set.altlimitreason");
event.setKickMessage(reason);
event.setResult(Result.KICK_BANNED);
}
}
PlayerListener.java 文件源码
项目:CrazyLogin
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
@Permission("crazylogin.warnsession")
@Localized({ "CRAZYLOGIN.KICKED.SESSION.DUPLICATE", "CRAZYLOGIN.SESSION.DUPLICATEWARN $Name$ $IP$" })
public void PlayerLoginSessionCheck(final PlayerLoginEvent event) {
if (plugin.isForceSingleSessionEnabled()) {
final Player player = event.getPlayer();
if (player != null && player.isOnline()) {
if (plugin.isForceSingleSessionSameIPBypassEnabled()) {
final LoginPlayerData data = plugin.getPlayerData(player);
if (data != null) {
if (event.getAddress().getHostAddress().equals(data.getLatestIP())) {
return;
}
}
}
event.setResult(Result.KICK_OTHER);
event.setKickMessage(plugin.getLocale().getLocaleMessage(player, "KICKED.SESSION.DUPLICATE"));
plugin.broadcastLocaleMessage(true, "crazylogin.warnsession", true, "SESSION.DUPLICATEWARN", player.getName(), event.getAddress().getHostAddress());
plugin.sendLocaleMessage("SESSION.DUPLICATEWARN", player, event.getAddress().getHostAddress(), player.getName());
plugin.getCrazyLogger().log("AccessDenied", "Denied access for player " + player.getName() + " @ " + event.getAddress().getHostAddress() + " because of a player with this name being already online");
return;
}
}
}
InventoryLis.java 文件源码
项目:GoldRushPlugin
阅读 18
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerLoginAdd(PlayerLoginEvent e){
Player p = e.getPlayer();
Main.playerList.add(p);
//DB Stuff
PlayerTbl player = Main.db.getPlayer(p.getName());
if(player != null) {
player.setOnline(true);
Main.db.getDB().save(player);
} else {
PlayerTbl newPlayer = new PlayerTbl();
newPlayer.setOnline(true);
newPlayer.setName(p.getName());
Main.db.getDB().save(newPlayer);
}
//End DB Stuff
}
PunishmentListener.java 文件源码
项目:NPlugins
阅读 24
收藏 0
点赞 0
评论 0
@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);
}
}
}
PlayerListener.java 文件源码
项目:SparkTrail
阅读 29
收藏 0
点赞 0
评论 0
@EventHandler
public void onLogin(PlayerLoginEvent event) {
final Player p = event.getPlayer();
if (event.getResult().equals(PlayerLoginEvent.Result.ALLOWED)) {
new BukkitRunnable() {
@Override
public void run() {
if (p != null) {
EffectHolder eh = EffectManager.getInstance().createFromFile(p.getName());
if (eh != null && !eh.getEffects().isEmpty()) {
Lang.sendTo(p, Lang.EFFECTS_LOADED.toString());
}
}
}
}.runTaskLater(SparkTrailPlugin.getInstance(), 20L);
}
}