use of net.md_5.bungee.api.connection.ProxiedPlayer in project SkinsRestorerX by DoNotSpamPls.
the class SkinApplier method applySkin.
public static void applySkin(final ProxiedPlayer p) {
ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
try {
Property textures = (Property) SkinStorage.getOrCreateSkinForPlayer(p.getName());
InitialHandler handler = (InitialHandler) p.getPendingConnection();
if (handler.isOnlineMode()) {
sendUpdateRequest(p, textures);
return;
}
LoginResult profile;
try {
// NEW BUNGEECORD
profile = (net.md_5.bungee.connection.LoginResult) ReflectionUtil.invokeConstructor(LoginResult, new Class<?>[] { String.class, String.class, Property[].class }, p.getUniqueId().toString(), p.getName(), new Property[] { textures });
} catch (Exception e) {
// FALL BACK TO OLD
profile = (net.md_5.bungee.connection.LoginResult) ReflectionUtil.invokeConstructor(LoginResult, new Class<?>[] { String.class, Property[].class }, p.getUniqueId().toString(), new Property[] { textures });
}
Property[] present = profile.getProperties();
Property[] newprops = new Property[present.length + 1];
System.arraycopy(present, 0, newprops, 0, present.length);
newprops[present.length] = textures;
profile.getProperties()[0].setName(newprops[0].getName());
profile.getProperties()[0].setValue(newprops[0].getValue());
profile.getProperties()[0].setSignature(newprops[0].getSignature());
ReflectionUtil.setObject(InitialHandler.class, handler, "loginProfile", profile);
if (SkinsRestorer.getInstance().isMultiBungee())
sendUpdateRequest(p, textures);
else
sendUpdateRequest(p, null);
} catch (Exception e) {
e.printStackTrace();
}
});
}
use of net.md_5.bungee.api.connection.ProxiedPlayer in project SkinsRestorerX by DoNotSpamPls.
the class AdminCommands method execute.
@SuppressWarnings("deprecation")
public void execute(final CommandSender sender, final String[] args) {
if (sender.hasPermission("skinsrestorer.cmds")) {
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
Locale.load();
Config.load(SkinsRestorer.getInstance().getResourceAsStream("config.yml"));
sender.sendMessage(new TextComponent(Locale.RELOAD));
} else if (args.length == 2 && args[0].equalsIgnoreCase("drop")) {
StringBuilder sb = new StringBuilder();
SkinStorage.removeSkinData(sb.toString());
sender.sendMessage(Locale.SKIN_DATA_DROPPED.replace("%player", sb.toString()));
} else if (args.length > 2 && args[0].equalsIgnoreCase("set")) {
final String skin = args[2];
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(args[1]);
if (player == null)
for (ProxiedPlayer pl : ProxyServer.getInstance().getPlayers()) if (pl.getName().startsWith(args[1])) {
player = pl;
break;
}
if (player == null) {
sender.sendMessage(Locale.NOT_ONLINE);
return;
}
final ProxiedPlayer p = player;
ProxyServer.getInstance().getScheduler().runAsync(SkinsRestorer.getInstance(), () -> {
try {
MojangAPI.getUUID(skin);
SkinStorage.setPlayerSkin(p.getName(), skin);
SkinApplier.applySkin(p);
sender.sendMessage(Locale.SKIN_CHANGE_SUCCESS);
} catch (MojangAPI.SkinRequestException e) {
sender.sendMessage(e.getReason());
}
});
} else if (args.length == 1 && args[0].equalsIgnoreCase("config")) {
sender.sendMessage("§e[§2SkinsRestorer§e] §2/sr config has been removed from SkinsRestorer. Farewell!");
} else if (args.length > 0 && args[0].equalsIgnoreCase("props")) {
ProxiedPlayer p;
if (args.length == 1) {
if (!(sender instanceof ProxiedPlayer)) {
sender.sendMessage(Locale.NOT_PLAYER);
}
p = (ProxiedPlayer) sender;
} else {
StringBuilder name = new StringBuilder();
for (int i = 1; i < args.length; i++) if (args.length == 2)
name.append(args[i]);
else if (i + 1 == args.length)
name.append(args[i]);
else
name.append(args[i]).append(" ");
p = ProxyServer.getInstance().getPlayer(name.toString());
if (p == null) {
sender.sendMessage(Locale.NOT_ONLINE);
return;
}
}
InitialHandler h = (InitialHandler) p.getPendingConnection();
LoginResult.Property prop = h.getLoginProfile().getProperties()[0];
if (prop == null) {
sender.sendMessage(Locale.NO_SKIN_DATA);
return;
}
CommandSender cons = ProxyServer.getInstance().getConsole();
cons.sendMessage("\n§aName: §8" + prop.getName());
cons.sendMessage("\n§aValue : §8" + prop.getValue());
cons.sendMessage("\n§aSignature : §8" + prop.getSignature());
byte[] decoded = Base64.getDecoder().decode(prop.getValue());
cons.sendMessage("\n§aValue Decoded: §e" + Arrays.toString(decoded));
sender.sendMessage("\n§e" + Arrays.toString(decoded));
sender.sendMessage("§cMore info in console!");
} else {
if (!Locale.SR_LINE.isEmpty())
sender.sendMessage(Locale.SR_LINE);
sender.sendMessage(Locale.HELP_ADMIN.replace("%ver%", SkinsRestorer.getInstance().getVersion()));
if (!Locale.SR_LINE.isEmpty())
sender.sendMessage(Locale.SR_LINE);
}
} else {
sender.sendMessage(Locale.PLAYER_HAS_NO_PERMISSION);
}
}
use of net.md_5.bungee.api.connection.ProxiedPlayer 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.connection.ProxiedPlayer 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.connection.ProxiedPlayer in project FireAPI by FireBlade-Serv.
the class FireFriends method getOnlineFriends.
public List<ProxiedPlayer> getOnlineFriends(String pp) throws IOException {
Configuration config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(this.file);
List<ProxiedPlayer> connected = new ArrayList<>();
List<String> list = config.getStringList("data." + pp);
for (String names : list) {
try {
ProxiedPlayer player = this.instance.getProxy().getPlayer(names);
if (player != null) {
connected.add(player);
}
} catch (Exception e) {
continue;
}
}
return connected;
}
Aggregations