use of net.md_5.bungee.api.connection.Server in project LuckPerms by lucko.
the class BungeeConnectionListener method onPlayerLogin.
@EventHandler(priority = EventPriority.LOW)
public void onPlayerLogin(LoginEvent e) {
/* Called when the player first attempts a connection with the server.
Listening on LOW priority to allow plugins to modify username / UUID data here. (auth plugins)
Delay the login here, as we want to cache UUID data before the player is connected to a backend bukkit server.
This means that a player will have the same UUID across the network, even if parts of the network are running in
Offline mode. */
/* registers the plugins intent to modify this events state going forward.
this will prevent the event from completing until we're finished handling. */
e.registerIntent(this.plugin.getBootstrap());
final PendingConnection c = e.getConnection();
if (this.plugin.getConfiguration().get(ConfigKeys.DEBUG_LOGINS)) {
this.plugin.getLogger().info("Processing pre-login for " + c.getUniqueId() + " - " + c.getName());
}
this.plugin.getBootstrap().getScheduler().doAsync(() -> {
recordConnection(c.getUniqueId());
/* Actually process the login for the connection.
We do this here to delay the login until the data is ready.
If the login gets cancelled later on, then this will be cleaned up.
This includes:
- loading uuid data
- loading permissions
- creating a user instance in the UserManager for this connection.
- setting up cached data. */
try {
User user = loadUser(c.getUniqueId(), c.getName());
this.plugin.getEventFactory().handleUserLoginProcess(c.getUniqueId(), c.getName(), user);
} catch (Exception ex) {
this.plugin.getLogger().severe("Exception occurred whilst loading data for " + c.getUniqueId() + " - " + c.getName());
ex.printStackTrace();
// there was some error loading
if (this.plugin.getConfiguration().get(ConfigKeys.CANCEL_FAILED_LOGINS)) {
// cancel the login attempt
e.setCancelReason(TextComponent.fromLegacyText(Message.LOADING_ERROR.asString(this.plugin.getLocaleManager())));
e.setCancelled(true);
}
}
// finally, complete our intent to modify state, so the proxy can continue handling the connection.
e.completeIntent(this.plugin.getBootstrap());
});
}
use of net.md_5.bungee.api.connection.Server in project SpecialSource by md-5.
the class JarMapping method loadMappingsDir.
/**
* Load mappings from an MCP directory
*
* @param dirname MCP directory name, local file or remote URL ending in '/'
* @param reverse If true, swap input and output
* @param ignoreCsv If true, ignore fields.csv and methods.csv (but not
* packages.csv)
* @param numericSrgNames If true, load numeric "srg" names (num->mcp
* instead of obf->mcp)
*/
private void loadMappingsDir(String dirname, boolean reverse, boolean ignoreCsv, boolean numericSrgNames) throws IOException {
File dir = new File(dirname);
if (!FileLocator.isHTTPURL(dirname) && !dir.isDirectory()) {
throw new IllegalArgumentException("loadMappingsDir(" + dir + "): not a directory");
}
String sep = System.getProperty("file.separator");
List<File> srgFiles = new ArrayList<File>();
File joinedSrg = FileLocator.getFile(dirname + sep + "joined.srg");
if (joinedSrg.exists()) {
// FML/MCP client/server joined
srgFiles.add(joinedSrg);
} else {
// vanilla MCP separated sides
File serverSrg = FileLocator.getFile(dirname + sep + "server.srg");
File clientSrg = FileLocator.getFile(dirname + sep + "client.srg");
if (serverSrg.exists()) {
srgFiles.add(serverSrg);
}
if (clientSrg.exists()) {
srgFiles.add(clientSrg);
}
}
if (srgFiles.size() == 0) {
throw new IOException("loadMappingsDir(" + dirname + "): no joined.srg, client.srg, or server.srg found");
}
// Read output names through csv mappings, if available & enabled
File fieldsCsv = FileLocator.getFile(dirname + sep + "fields.csv");
File methodsCsv = FileLocator.getFile(dirname + sep + "methods.csv");
// FML repackaging, optional
File packagesCsv = FileLocator.getFile(dirname + sep + "packages.csv");
MinecraftCodersPack outputTransformer;
MappingTransformer inputTransformer;
if (numericSrgNames) {
// Wants numeric "srg" names -> descriptive "csv" names. To accomplish this:
// 1. load obf->mcp (descriptive "csv") as chainMappings
// 2. load again but chaining input (obf) through mcp, and ignoring csv on output
// 3. result: mcp->srg, similar to MCP ./reobfuscate --srgnames
JarMapping chainMappings = new JarMapping();
chainMappings.loadMappingsDir(dirname, reverse, false, /*ignoreCsv*/
false);
inputTransformer = new ChainingTransformer(new JarRemapper(chainMappings));
// keep numeric srg as output
ignoreCsv = true;
} else {
inputTransformer = null;
}
if (fieldsCsv.exists() && methodsCsv.exists()) {
outputTransformer = new MinecraftCodersPack(ignoreCsv ? null : fieldsCsv, ignoreCsv ? null : methodsCsv, packagesCsv);
} else {
outputTransformer = null;
}
for (File srg : srgFiles) {
loadMappings(new BufferedReader(new FileReader(srg)), inputTransformer, outputTransformer, reverse);
}
}
use of net.md_5.bungee.api.connection.Server in project Parties by AlessioDP.
the class BungeeMetrics method startSubmitting.
private void startSubmitting() {
// We use a timer cause want to be independent from the server tps
final Timer timer = new Timer(true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
// The data collection (e.g. for custom graphs) is done sync
// Don't be afraid! The connection to the bStats server is still async, only the stats collection is sync ;)
TaskScheduler scheduler = plugin.getProxy().getScheduler();
scheduler.schedule(plugin, new Runnable() {
@Override
public void run() {
submitData();
}
}, 0L, TimeUnit.SECONDS);
}
}, 1000 * 60 * 2, 1000 * 60 * 30);
// Submit the data every 30 minutes, first time after 2 minutes to give other plugins enough time to start
// WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted!
// WARNING: Just don't do it!
}
use of net.md_5.bungee.api.connection.Server in project Parties by AlessioDP.
the class BungeeListener method onConnect.
@EventHandler
public void onConnect(ServerConnectEvent event) {
/*
* Connect chain starts here,
* this method will sent a PartiesPacket to the player server
*/
if (event.isCancelled())
return;
ProxiedPlayer proxyPlayer = event.getPlayer();
// Return if its not a player
if (proxyPlayer.getServer() == null)
return;
// Return if the player is already in the server
if (proxyPlayer.getServer().getInfo().equals(event.getTarget()))
return;
// Return if the server is not into the follow list
if (!listContains(ConfigMain.follow_listserver, proxyPlayer.getServer().getInfo().getName()))
return;
/*
*
*/
try {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(stream);
// Initialize packet
Packet packet = new Packet(plugin.getDescription().getVersion(), event.getTarget().getName(), ConfigMain.follow_neededrank, ConfigMain.follow_minimumrank);
// Write to the DataOutputStream the data
packet.write(out);
if (proxyPlayer.getServer() != null) {
PartiesBungee.debugLog("Parties packet sent to " + proxyPlayer.getServer().getInfo().getName());
proxyPlayer.getServer().sendData(partiesChannel, stream.toByteArray());
}
} catch (IOException e) {
e.printStackTrace();
}
}
use of net.md_5.bungee.api.connection.Server in project DragonProxy by DragonetMC.
the class DPAddonBungee method onServerSwitch.
@EventHandler
public void onServerSwitch(ServerSwitchEvent event) {
if (!bedrockPlayers.contains(event.getPlayer().getUniqueId()))
return;
// We don't know that another server supports forwarding or not so we disable forwarding for now!
BinaryStream bis = new BinaryStream();
bis.putString("PacketFoward");
bis.putBoolean(false);
event.getPlayer().sendData("DragonProxy", bis.getBuffer());
}
Aggregations