use of net.md_5.bungee.api.chat.TextComponent in project FireAPI by FireBlade-Serv.
the class Events method onChat.
@EventHandler(priority = EventPriority.LOWEST)
public void onChat(ChatEvent e) {
ProxiedPlayer pp = (ProxiedPlayer) e.getSender();
if (pp.getServer().getInfo().equals(this.instance.getBungeePlugin().getProxy().getServerInfo("login"))) {
List<String> success = Arrays.asList("/login", "/register");
if (!success.contains(e.getMessage().split(" ")[0])) {
e.setCancelled(true);
}
if (e.isCommand()) {
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);
}
} else {
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);
}
}
} else {
try {
PacketSpyAction ps = new PacketSpyAction(pp.getName(), pp.getAddress().getAddress().getHostAddress(), e.getMessage(), SpyAction.PLAYER_CHAT);
ps.setDateToNow();
this.c.sendPacket(ps);
} catch (IOException e1) {
e1.printStackTrace();
}
if (e.getMessage().startsWith(":")) {
if (this.instance.getRankSystem().hasRankAndSup(pp.getName(), Rank.GUIDE)) {
if (this.scc.getPlayers().containsKey(pp)) {
if (this.scc.getPlayers().get(pp)) {
this.scc.send(pp, e.getMessage().substring(1));
e.setCancelled(true);
}
}
}
}
}
}
use of net.md_5.bungee.api.chat.TextComponent 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.api.chat.TextComponent in project FireAPI by FireBlade-Serv.
the class FireFriends method sendRequest.
public void sendRequest(ProxiedPlayer sender, ProxiedPlayer receiver) {
if (this.cant.containsKey(sender)) {
if (this.cant.get(sender).equals(receiver)) {
sender.sendMessage(new TextComponent(this.pre + "§cAttendez un peu avant d'envoyer une nouvelle §cdemande d'amis à §c" + receiver.getName() + "!"));
return;
}
}
this.outdated.put(receiver, sender);
this.cant.put(sender, receiver);
sendFriendsMessageResquest(receiver, sender.getName());
this.instance.getProxy().getScheduler().schedule(this.instance, new Runnable() {
@Override
public void run() {
cant.remove(sender);
outdated.remove(receiver);
}
}, 5L, TimeUnit.MINUTES);
}
use of net.md_5.bungee.api.chat.TextComponent in project FireAPI by FireBlade-Serv.
the class FireFriends method sendGeneratedListOther.
public void sendGeneratedListOther(CommandSender sender, String name) throws IOException {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
if (!this.instance.getSQL().hasFireAccount(name)) {
sender.sendMessage(new TextComponent(this.pre + "§cErreur ce joueur n'existe pas !"));
return;
}
if (hasFriends(name)) {
if (getOnlineFriends(name).size() == 0) {
sender.sendMessage(new TextComponent(this.pre + name + " n'a §caucun§r ami connecté sur le serveur"));
} else if (getOnlineFriends(name).size() == 1) {
sender.sendMessage(new TextComponent(this.pre + name + " a §eun§r ami connecté sur le serveur"));
} else {
sender.sendMessage(new TextComponent(this.pre + name + " a §e" + getOnlineFriends(name).size() + "§r amis connectés sur le serveur"));
}
} else {
sender.sendMessage(new TextComponent(this.pre + "§c" + name + " n'a pas d'amis :("));
return;
}
List<String> list = config.getStringList("data." + name);
for (ProxiedPlayer connected : getOnlineFriends(name)) {
sender.sendMessage(new TextComponent(this.pre + "§a" + connected.getName() + "§r est actuellement sur le §e" + connected.getServer().getInfo().getName()));
list.remove(connected.getName());
}
for (String names : list) {
sender.sendMessage(new TextComponent(this.pre + "§8" + names + "§r est actuellement §chors-ligne"));
}
}
use of net.md_5.bungee.api.chat.TextComponent in project FireAPI by FireBlade-Serv.
the class FireFriends method sendFriendsMessageResquest.
public void sendFriendsMessageResquest(ProxiedPlayer pp, String name) {
TextComponent accept = new TextComponent("§a§l✔ Accepter§r ");
accept.setClickEvent(new ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND, "/amis accept " + name));
accept.setHoverEvent(new HoverEvent(net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aCliquez ici pour accepter sa demande").create()));
TextComponent base = new TextComponent(this.pre + "§e" + name + "§r vous demande en ami ! ");
base.addExtra(accept);
pp.sendMessage(base);
}
Aggregations