Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added logPlayerConnections into config of bridge module #22

Merged
merged 2 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public final class BridgeConfiguration extends BasicJsonDocPropertyable {

private Map<String, String> messages;

private boolean logPlayerConnections;

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public void createConfiguration()
new Pair<>("command-hub-already-in-hub", "&cYou are already connected"),
new Pair<>("command-hub-no-server-found", "&7Hub server cannot be found"),
new Pair<>("server-join-cancel-because-only-proxy", "&7You must connect from a original proxy server")
)
),
true
));

if (this.bridgeConfiguration.getExcludedOnlyProxyWalkableGroups() == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import de.dytanic.cloudnet.driver.event.EventListener;
import de.dytanic.cloudnet.driver.event.events.channel.ChannelMessageReceiveEvent;
import de.dytanic.cloudnet.ext.bridge.BridgeConfiguration;
import de.dytanic.cloudnet.ext.bridge.BridgeConfigurationProvider;
import de.dytanic.cloudnet.ext.bridge.BridgeConstants;
import de.dytanic.cloudnet.ext.bridge.event.*;
import de.dytanic.cloudnet.ext.bridge.node.CloudNetBridgeModule;
Expand All @@ -17,6 +18,11 @@
import java.util.function.Predicate;

public final class NodeCustomChannelMessageListener {
private BridgeConfiguration bridgeConfiguration;

public NodeCustomChannelMessageListener() {
bridgeConfiguration = CloudNetBridgeModule.getInstance().getBridgeConfiguration();
}

@EventListener
public void handle(ChannelMessageReceiveEvent event)
Expand Down Expand Up @@ -45,22 +51,28 @@ public void handle(ChannelMessageReceiveEvent event)
{
NetworkConnectionInfo networkConnectionInfo = event.getData().get("networkConnectionInfo", NetworkConnectionInfo.TYPE);
CloudNetDriver.getInstance().getEventManager().callEvent(new BridgeProxyPlayerLoginRequestEvent(networkConnectionInfo));
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-login-request")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
);

if(bridgeConfiguration.isLogPlayerConnections()) {
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-login-request")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
);
}
}
break;
case BridgeConstants.BRIDGE_EVENT_CHANNEL_MESSAGE_NAME_PROXY_LOGIN_SUCCESS:
{
NetworkConnectionInfo networkConnectionInfo = event.getData().get("networkConnectionInfo", NetworkConnectionInfo.TYPE);
CloudNetDriver.getInstance().getEventManager().callEvent(new BridgeProxyPlayerLoginSuccessEvent(networkConnectionInfo));
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-login-success")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
);

if(bridgeConfiguration.isLogPlayerConnections()) {
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-login-success")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
);
}

/*= -------------------------------------- =*/
//Player
Expand All @@ -71,12 +83,15 @@ public void handle(ChannelMessageReceiveEvent event)
{
NetworkConnectionInfo networkConnectionInfo = event.getData().get("networkConnectionInfo", NetworkConnectionInfo.TYPE);
NetworkServiceInfo networkServiceInfo = event.getData().get("networkServiceInfo", NetworkServiceInfo.class);
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-server-connect-request")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
.replace("%server%", networkServiceInfo.getServerName() + "")
);

if(bridgeConfiguration.isLogPlayerConnections()) {
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-server-connect-request")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
.replace("%server%", networkServiceInfo.getServerName() + "")
);
}

CloudNetDriver.getInstance().getEventManager().callEvent(new BridgeProxyPlayerServerConnectRequestEvent(networkConnectionInfo, networkServiceInfo));
}
Expand All @@ -85,24 +100,30 @@ public void handle(ChannelMessageReceiveEvent event)
{
NetworkConnectionInfo networkConnectionInfo = event.getData().get("networkConnectionInfo", NetworkConnectionInfo.TYPE);
NetworkServiceInfo networkServiceInfo = event.getData().get("networkServiceInfo", NetworkServiceInfo.class);
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-server-switch")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
.replace("%server%", networkServiceInfo.getServerName() + "")
);

if(bridgeConfiguration.isLogPlayerConnections()) {
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-server-switch")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
.replace("%server%", networkServiceInfo.getServerName() + "")
);
}

CloudNetDriver.getInstance().getEventManager().callEvent(new BridgeProxyPlayerServerSwitchEvent(networkConnectionInfo, networkServiceInfo));
}
break;
case BridgeConstants.BRIDGE_EVENT_CHANNEL_MESSAGE_NAME_PROXY_DISCONNECT:
{
NetworkConnectionInfo networkConnectionInfo = event.getData().get("networkConnectionInfo", NetworkConnectionInfo.TYPE);
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-disconnect")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
);

if(bridgeConfiguration.isLogPlayerConnections()) {
System.out.println(LanguageManager.getMessage("module-bridge-player-proxy-disconnect")
.replace("%uniqueId%", networkConnectionInfo.getUniqueId() + "")
.replace("%name%", networkConnectionInfo.getName() + "")
.replace("%proxy%", networkConnectionInfo.getNetworkService().getServerName() + "")
);
}

CloudNetDriver.getInstance().getEventManager().callEvent(new BridgeProxyPlayerDisconnectEvent(networkConnectionInfo));
logoutPlayer(networkConnectionInfo);
Expand All @@ -112,11 +133,14 @@ public void handle(ChannelMessageReceiveEvent event)
{
NetworkPlayerServerInfo networkPlayerServerInfo = event.getData().get("networkPlayerServerInfo", NetworkPlayerServerInfo.TYPE);
NetworkConnectionInfo networkConnectionInfo = event.getData().get("networkConnectionInfo", NetworkConnectionInfo.TYPE);
System.out.println(LanguageManager.getMessage("module-bridge-player-server-login-request")
.replace("%uniqueId%", networkPlayerServerInfo.getUniqueId() + "")
.replace("%name%", networkPlayerServerInfo.getName() + "")
.replace("%server%", networkPlayerServerInfo.getNetworkService().getServerName() + "")
);

if(bridgeConfiguration.isLogPlayerConnections()) {
System.out.println(LanguageManager.getMessage("module-bridge-player-server-login-request")
.replace("%uniqueId%", networkPlayerServerInfo.getUniqueId() + "")
.replace("%name%", networkPlayerServerInfo.getName() + "")
.replace("%server%", networkPlayerServerInfo.getNetworkService().getServerName() + "")
);
}

CloudNetDriver.getInstance().getEventManager().callEvent(new BridgeServerPlayerLoginRequestEvent(networkConnectionInfo, networkPlayerServerInfo));
}
Expand All @@ -125,11 +149,14 @@ public void handle(ChannelMessageReceiveEvent event)
{
NetworkPlayerServerInfo networkPlayerServerInfo = event.getData().get("networkPlayerServerInfo", NetworkPlayerServerInfo.TYPE);
NetworkConnectionInfo networkConnectionInfo = event.getData().get("networkConnectionInfo", NetworkConnectionInfo.TYPE);
System.out.println(LanguageManager.getMessage("module-bridge-player-server-login-success")
.replace("%uniqueId%", networkPlayerServerInfo.getUniqueId() + "")
.replace("%name%", networkPlayerServerInfo.getName() + "")
.replace("%server%", networkPlayerServerInfo.getNetworkService().getServerName() + "")
);

if(bridgeConfiguration.isLogPlayerConnections()) {
System.out.println(LanguageManager.getMessage("module-bridge-player-server-login-success")
.replace("%uniqueId%", networkPlayerServerInfo.getUniqueId() + "")
.replace("%name%", networkPlayerServerInfo.getName() + "")
.replace("%server%", networkPlayerServerInfo.getNetworkService().getServerName() + "")
);
}

CloudNetDriver.getInstance().getEventManager().callEvent(new BridgeServerPlayerLoginSuccessEvent(networkConnectionInfo, networkPlayerServerInfo));
loginPlayer(networkConnectionInfo, networkPlayerServerInfo);
Expand All @@ -139,11 +166,14 @@ public void handle(ChannelMessageReceiveEvent event)
{
NetworkPlayerServerInfo networkPlayerServerInfo = event.getData().get("networkPlayerServerInfo", NetworkPlayerServerInfo.TYPE);
NetworkConnectionInfo networkConnectionInfo = event.getData().get("networkConnectionInfo", NetworkConnectionInfo.TYPE);
System.out.println(LanguageManager.getMessage("module-bridge-player-server-disconnect")
.replace("%uniqueId%", networkPlayerServerInfo.getUniqueId() + "")
.replace("%name%", networkPlayerServerInfo.getName() + "")
.replace("%server%", networkPlayerServerInfo.getNetworkService().getServerName() + "")
);

if(bridgeConfiguration.isLogPlayerConnections()) {
System.out.println(LanguageManager.getMessage("module-bridge-player-server-disconnect")
.replace("%uniqueId%", networkPlayerServerInfo.getUniqueId() + "")
.replace("%name%", networkPlayerServerInfo.getName() + "")
.replace("%server%", networkPlayerServerInfo.getNetworkService().getServerName() + "")
);
}

CloudNetDriver.getInstance().getEventManager().callEvent(new BridgeServerPlayerDisconnectEvent(networkConnectionInfo, networkPlayerServerInfo));
logoutPlayer(networkConnectionInfo);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"group": "de.dytanic.cloudnet.modules",
"name": "CloudNet-Bridge",
"version": "1.0",
"version": "1.1",
"author": "Dytanic",
"website": "https://cloudnetservice.eu",
"description": "Node extension for the CloudNet runtime, which optimize some features",
Expand Down