Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #73 from CloudNetService/development
Browse files Browse the repository at this point in the history
Merge from development into master branch
  • Loading branch information
byRoadrunner authored Nov 12, 2018
2 parents 7a13480 + 8c58111 commit 6c53839
Show file tree
Hide file tree
Showing 16 changed files with 114 additions and 92 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pipeline {
}
stage('Version') {
steps {
sh 'mvn versions:set -DnewVersion=2.1.12'
sh 'mvn versions:set -DnewVersion=2.1.13'
}
}
stage('Compile') {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ Use of KVM virtualization or dedicated servers is recommended.

### Support

* Spigot-Support » 1.7.10 - 1.13.1
* Spigot-Support » 1.7.10 - 1.13.2
* PaperSpigot, TacoSpigot, Hose, Torch
* BungeeCord-Support » 1.7.10 - 1.13.1
* BungeeCord-Support » 1.7.10 - 1.13.2
* Flexpipe, HexaCord, Waterfall, TraverTine

### Discord
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Function;

/**
* Cloud-Server represents
Expand Down Expand Up @@ -430,17 +431,28 @@ public static CloudServer getInstance()
}

/**
* Updating and sets the NameTags for one target Player
*
* @param player
*/
public void updateNameTags(Player player)
{
this.updateNameTags(player, null);
}

public void updateNameTags(Player player, Function<Player, PermissionGroup> playerPermissionGroupFunction)
{
this.updateNameTags(player, playerPermissionGroupFunction, null);
}

public void updateNameTags(Player player, Function<Player, PermissionGroup> playerPermissionGroupFunction, Function<Player, PermissionGroup> allOtherPlayerPermissionGroupFunction)
{
if (CloudAPI.getInstance().getPermissionPool() == null || !CloudAPI.getInstance().getPermissionPool().isAvailable())
return;

PermissionGroup playerPermissionGroup = CloudServer.getInstance().getCloudPlayers().get(player.getUniqueId())
.getPermissionEntity().getHighestPermissionGroup(CloudAPI.getInstance().getPermissionPool());
PermissionGroup playerPermissionGroup = playerPermissionGroupFunction != null ? playerPermissionGroupFunction.apply(player) : null;

if (playerPermissionGroup == null)
playerPermissionGroup = getCloudPlayers().get(player.getUniqueId())
.getPermissionEntity().getHighestPermissionGroup(CloudAPI.getInstance().getPermissionPool());

initScoreboard(player);

Expand All @@ -451,8 +463,11 @@ public void updateNameTags(Player player)
if (playerPermissionGroup != null)
addTeamEntry(player, all, playerPermissionGroup);

PermissionGroup targetPermissionGroup = CloudServer.getInstance().getCachedPlayer(all.getUniqueId())
.getPermissionEntity().getHighestPermissionGroup(CloudAPI.getInstance().getPermissionPool());
PermissionGroup targetPermissionGroup = allOtherPlayerPermissionGroupFunction != null ? allOtherPlayerPermissionGroupFunction.apply(all) : null;

if (targetPermissionGroup == null)
targetPermissionGroup = getCachedPlayer(all.getUniqueId())
.getPermissionEntity().getHighestPermissionGroup(CloudAPI.getInstance().getPermissionPool());

if (targetPermissionGroup != null)
addTeamEntry(all, player, targetPermissionGroup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public void execute(CommandSender commandSender, String[] args)
switch (args.length)
{
case 1:
if (args[0].equalsIgnoreCase("whitelist"))
{
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "Whitelisted players from " + CloudProxy.getInstance().getProxyGroup().getName());
for (String entry : CloudProxy.getInstance().getProxyGroup().getProxyConfig().getWhitelist())
commandSender.sendMessage("§7- " + entry);
}
if (args[0].equalsIgnoreCase("rl") && commandSender.hasPermission("cloudnet.command.cloud.reload"))
{
CloudAPI.getInstance().sendCloudCommand("reload config");
Expand Down Expand Up @@ -542,6 +548,7 @@ public boolean isAccepted(Template value)
CloudAPI.getInstance().getPrefix() + "§7/cloud toggle maintenance",
CloudAPI.getInstance().getPrefix() + "§7/cloud toggle maintenance <time>",
CloudAPI.getInstance().getPrefix() + "§7/cloud setMaxPlayers <maxonlinecount>",
CloudAPI.getInstance().getPrefix() + "§7/cloud whitelist",
CloudAPI.getInstance().getPrefix() + "§7/cloud whitelist <add : remove> <name>",
CloudAPI.getInstance().getPrefix() + "§7/cloud start <group> <count>",
CloudAPI.getInstance().getPrefix() + "§7/cloud start <group> <template>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ public void handleLogin(LoginEvent e)
e.getConnection().getUniqueId(),
e.getConnection().getName(), e.getConnection().getVersion(),
e.getConnection().getAddress().getAddress().getHostAddress(),
e.getConnection().getAddress().getPort(), e.getConnection().isOnlineMode(), e.getConnection().isLegacy()
e.getConnection().getAddress().getPort(), e.getConnection().isOnlineMode(),
e.getConnection().isLegacy()
);

CloudPlayer cloudPlayer = CloudAPI.getInstance().getNetworkConnection().getPacketManager().sendQuery(new PacketOutPlayerLoginRequest(playerConnection),
Expand Down Expand Up @@ -157,18 +158,20 @@ public void handleLogin(LoginEvent e)
}

ProxyGroup proxyGroup = CloudProxy.getInstance().getProxyGroup();
if (proxyGroup.getProxyConfig().isEnabled())
if (CloudAPI.getInstance().getOnlineCount() >= CloudProxy.getInstance().getProxyGroup().getProxyConfig().getMaxPlayers())
{
PermissionCheckEvent permissionCheckEvent = new PermissionCheckEvent(cloudCommandSender, "cloudnet.fulljoin", false);

if (!ProxyServer.getInstance().getPluginManager().callEvent(permissionCheckEvent).hasPermission())
if (proxyGroup != null)
if (proxyGroup.getProxyConfig().isEnabled())
if (CloudAPI.getInstance().getOnlineCount() >= CloudProxy.getInstance().getProxyGroup().getProxyConfig().getMaxPlayers())
{
e.setCancelled(true);
e.setCancelReason(ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("full-join")));
return;
PermissionCheckEvent permissionCheckEvent = new PermissionCheckEvent(cloudCommandSender, "cloudnet.fulljoin", false);

if (!ProxyServer.getInstance().getPluginManager().callEvent(permissionCheckEvent).hasPermission())
{
e.setCancelled(true);
e.setCancelReason(ChatColor.translateAlternateColorCodes('&', CloudAPI.getInstance().getCloudNetwork().getMessages().getString("full-join")));
return;
}
}
}

CloudProxy.getInstance().getCloudPlayers().put(cloudPlayer.getUniqueId(), cloudPlayer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public abstract class Command
protected String permission;
protected String[] aliases;

protected String description = "Default command discrption";
protected String description = "Default command description";

private Collection<CommandArgument> commandArguments = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ public CloudConfig(ConsoleReader consoleReader) throws Exception
new File("local/servers"),
new File("local/cache"),
new File("groups"),
new File("modules"),
new File("templates")
new File("modules")
})
directory.mkdirs();

Expand Down Expand Up @@ -202,7 +201,7 @@ public CloudConfig load() throws Exception
);
this.formatSplitter = configuration.getString("general.server-name-splitter");
this.networkProperties = configuration.getSection("networkproperties").self;
// configuration.set("general.disabled-modules", new ArrayList<>());

if (!configuration.getSection("general").self.containsKey("disabled-modules"))
{
configuration.set("general.disabled-modules", new ArrayList<>());
Expand Down Expand Up @@ -233,8 +232,7 @@ public CloudConfig load() throws Exception
}.getType());

this.userDocument = Document.loadDocument(usersPath);

/* ============================================================== */

return this;
}

Expand Down
41 changes: 11 additions & 30 deletions cloudnet-core/src/main/java/de/dytanic/cloudnetcore/CloudNet.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,15 @@ public boolean bootstrap() throws Exception
System.out.println("Loading Modules...");
moduleManager.loadModules();
}

for (WrapperMeta wrapperMeta : config.getWrappers())
{
System.out.println("Loading Wrapper " + wrapperMeta.getId() + " @ " + wrapperMeta.getHostName());
this.wrappers.put(wrapperMeta.getId(), new Wrapper(wrapperMeta));
}
//Packet Init

this.users = config.getUsers();

//Groups Loading

NetworkUtils.addAll(this.serverGroups, config.getServerGroups(), new Acceptable<ServerGroup>() {
@Override
public boolean isAccepted(ServerGroup value)
Expand All @@ -162,18 +160,15 @@ public boolean isAccepted(ProxyGroup value)

webServer = new WebServer(optionSet.has("ssl"), config.getWebServerConfig().getAddress(), config.getWebServerConfig().getPort());

//CommandManager Appending
this.initialCommands();
this.initWebHandlers();
this.initPacketHandlers();

//Scheduler Startup
{
Thread thread = new Thread(scheduler);
thread.setDaemon(true);
thread.start();
}
/*=====================================*/

for (ConnectableAddress connectableAddress : config.getAddresses())
new CloudNetServer(optionSet, connectableAddress);
Expand All @@ -182,11 +177,8 @@ public boolean isAccepted(ProxyGroup value)

RUNNING = true;
Runtime.getRuntime().addShutdownHook(new Thread(this));

/*==================================*/

{


if (!optionSet.has("onlyConsole"))
{
CloudStartupHandler cloudStartupHandler = new CloudStartupHandler();
Expand Down Expand Up @@ -217,11 +209,11 @@ public void run()
}

if (!optionSet.has("disable-modules"))
{
System.out.println("Enabling Modules...");
moduleManager.enableModules();
}

moduleManager.enableModules();

//Event Init
eventManager.callEvent(new CloudInitEvent());
new LocalCloudWrapper().run(optionSet);

Expand All @@ -245,10 +237,13 @@ public void reload() throws Exception

databaseManager.save().clear();

this.users = config.getUsers();
this.users.clear();
this.serverGroups.clear();
this.proxyGroups.clear();

this.config.load();

this.users = config.getUsers();

NetworkUtils.addAll(this.serverGroups, config.getServerGroups(), new Acceptable<ServerGroup>() {
public boolean isAccepted(ServerGroup value)
Expand Down Expand Up @@ -358,10 +353,6 @@ public void run()
shutdown();
}

//Command Init

/*===================================================================================================================*/

private void initWebHandlers()
{
webServer.getWebServerProvider().registerHandler(new WebsiteUtils());
Expand Down Expand Up @@ -462,8 +453,6 @@ private void initPacketHandlers()
packetManager.registerHandler(PacketRC.CN_INTERNAL_CHANNELS + 1, PacketInCreateServerLog.class);
}

/*===============================================================================================================*/

@Deprecated
public void setupGroup(ServerGroup serverGroup)
{
Expand Down Expand Up @@ -518,10 +507,6 @@ public void setupProxy(ProxyGroup proxyGroup)
}
}

/*========================================================================================================*/
//Util Methods
/*========================================================================================================*/

public boolean authorization(String name, String token)
{
User user = CollectionWrapper.filter(users, new Acceptable<User>() {
Expand Down Expand Up @@ -1266,8 +1251,6 @@ public void startProxy(ProxyGroup proxyGroup, String url, Collection<ServerInsta
startProxy(proxyGroup, proxyGroup.getMemory(), new String[]{}, url, collection, new Document(), id, uniqueId);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

public void startCloudServer(String serverName, int memory, boolean priorityStop)
{
startCloudServer(serverName, new BasicServerConfig(), memory, priorityStop);
Expand Down Expand Up @@ -1891,8 +1874,6 @@ public void run(Quad<Integer, Integer, ServiceId, Template> obj)
wrapper.startGameServer(serverProcessMeta);
}

/*=====================================================================================*/

public void startProxyAsync(ProxyProcessMeta proxyProcessMeta, Wrapper wrapper)
{
wrapper.startProxyAsync(proxyProcessMeta);
Expand Down Expand Up @@ -2422,4 +2403,4 @@ public void run(Quad<Integer, Integer, ServiceId, Template> obj)
ServerProcessMeta serverProcessMeta = new ServerProcessMeta(newServiceId(serverGroup, wrapper, serverId), memory, prioritystop, url, processParameters, onlineMode, plugins, config, customServerName, startport, serverProperties, template);
wrapper.startGameServerAsync(serverProcessMeta);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void handlePlayerLoginRequest(ProxyServer proxyServer, PlayerConnection c
CloudPlayer cloudPlayer = new CloudPlayer(offlinePlayer, cloudPlayerConnection, proxyServer.getServerId());
cloudPlayer.setPlayerExecutor(CorePlayerExecutor.INSTANCE);

if (cloudPlayer.getFirstLogin() != null) cloudPlayer.setFirstLogin(System.currentTimeMillis());
if (cloudPlayer.getFirstLogin() == null) cloudPlayer.setFirstLogin(System.currentTimeMillis());

CloudNet.getInstance().getEventManager().callEvent(new PlayerInitEvent(cloudPlayer));

Expand Down
7 changes: 7 additions & 0 deletions cloudnet-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
<classifier>linux-x86_64</classifier>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>${dependency.netty.version}</version>
<classifier>osx-x86_64</classifier>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
Expand Down
Loading

0 comments on commit 6c53839

Please sign in to comment.