use of net.md_5.bungee.event.EventHandler in project FireAPI by FireBlade-Serv.
the class Events method onLogin.
@EventHandler
public void onLogin(PostLoginEvent e) {
final ProxiedPlayer pp = e.getPlayer();
pp.setTabHeader(new TextComponent("§6Fireblade-serv"), new TextComponent("§eplay.fireblade-serv.eu"));
if (!this.instance.getSQL().hasFireAccount(pp.getName())) {
this.instance.getSQL().createFireAccount(pp);
}
PacketSpyAction ps = new PacketSpyAction(pp.getName(), pp.getAddress().getAddress().getHostAddress(), "Connection sur le proxy principal.", SpyAction.PLAYER_JOIN);
ps.setDateToNow();
try {
this.c.sendPacket(ps);
} catch (IOException ex) {
ex.printStackTrace();
}
this.stillconnected.add(pp);
this.instance.getBungeePlugin().getProxy().getScheduler().schedule(this.instance.getBungeePlugin(), new Runnable() {
@Override
public void run() {
if (pp != null) {
if (pp.isConnected() && stillconnected.contains(pp)) {
pp.disconnect(new TextComponent("§cVous mettez trop de temps pour vous connecter !"));
}
}
}
}, 15L, TimeUnit.SECONDS);
if (this.instance.getSQL().getCryptPassword(pp.getName()).equals("§default-not-set")) {
// not registered
pp.sendMessage(new TextComponent(this.instance.getAuthentification().getRegisterMessage()));
this.instance.getAuthentification().getRegisterTitle().send(pp);
} else {
// registered
pp.sendMessage(new TextComponent(this.instance.getAuthentification().getLoginMessage()));
this.instance.getAuthentification().getLoginTitle().send(pp);
}
}
use of net.md_5.bungee.event.EventHandler in project LuckPerms by lucko.
the class BungeeConnectionListener method onPlayerPostLogin.
@EventHandler
public void onPlayerPostLogin(PostLoginEvent e) {
final ProxiedPlayer player = e.getPlayer();
final User user = this.plugin.getUserManager().getIfLoaded(e.getPlayer().getUniqueId());
if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
this.plugin.getLogger().info("Processing post-login for " + player.getUniqueId() + " - " + player.getName());
}
if (user == null) {
if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {
// disconnect the user
this.plugin.getLogger().warn("User " + player.getUniqueId() + " - " + player.getName() + " doesn't have data pre-loaded - cancelling login.");
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
} else {
// just send a message
this.plugin.getBootstrap().getProxy().getScheduler().schedule(this.plugin.getBootstrap(), () -> {
if (!player.isConnected()) {
return;
}
player.sendMessage(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
}, 1, TimeUnit.SECONDS);
}
}
}
use of net.md_5.bungee.event.EventHandler in project LuckPerms by lucko.
the class BungeeConnectionListener method onPlayerQuit.
// Wait until the last priority to unload, so plugins can still perform permission checks on this event
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuit(PlayerDisconnectEvent e) {
ProxiedPlayer player = e.getPlayer();
// Register with the housekeeper, so the User's instance will stick
// around for a bit after they disconnect
this.plugin.getUserManager().getHouseKeeper().registerUsage(player.getUniqueId());
// force a clear of transient nodes
this.plugin.getBootstrap().getScheduler().doAsync(() -> {
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user != null) {
user.clearTransientNodes();
}
});
}
use of net.md_5.bungee.event.EventHandler in project LuckPerms by lucko.
the class BungeePermissionCheckListener method onOtherPermissionCheck.
@EventHandler(priority = EventPriority.HIGHEST)
public void onOtherPermissionCheck(PermissionCheckEvent e) {
if (e.getSender() instanceof ProxiedPlayer) {
return;
}
Objects.requireNonNull(e.getPermission(), "permission");
Objects.requireNonNull(e.getSender(), "sender");
String permission = e.getPermission();
Tristate result = Tristate.fromBoolean(e.hasPermission());
String name = "internal/" + e.getSender().getName();
this.plugin.getVerboseHandler().offerCheckData(CheckOrigin.PLATFORM_PERMISSION_CHECK, name, ContextSet.empty(), permission, result);
this.plugin.getPermissionVault().offer(permission);
}
use of net.md_5.bungee.event.EventHandler in project LuckPerms by lucko.
the class BungeePermissionCheckListener method onPlayerTristateCheck.
@EventHandler
public void onPlayerTristateCheck(TristateCheckEvent e) {
if (!(e.getSender() instanceof ProxiedPlayer)) {
return;
}
Objects.requireNonNull(e.getPermission(), "permission");
Objects.requireNonNull(e.getSender(), "sender");
ProxiedPlayer player = ((ProxiedPlayer) e.getSender());
User user = this.plugin.getUserManager().getIfLoaded(player.getUniqueId());
if (user == null) {
e.setResult(Tristate.UNDEFINED);
return;
}
Contexts contexts = this.plugin.getContextManager().getApplicableContexts(player);
Tristate result = user.getCachedData().getPermissionData(contexts).getPermissionValue(e.getPermission(), CheckOrigin.PLATFORM_LOOKUP_CHECK);
if (result == Tristate.UNDEFINED && this.plugin.getConfiguration().get(ConfigKeys.APPLY_BUNGEE_CONFIG_PERMISSIONS)) {
// just use the result provided by the proxy when the event was created
return;
}
e.setResult(result);
}
Aggregations