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

Commit 9dd24c9

Browse files
authored
Merge pull request #48 from CloudNetService/development
Merge development into master
2 parents 7f68764 + bc5306c commit 9dd24c9

File tree

18 files changed

+109
-106
lines changed

18 files changed

+109
-106
lines changed

Jenkinsfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ pipeline {
44
maven 'Maven3'
55
jdk 'Java8'
66
}
7+
options {
8+
buildDiscarder logRotator(numToKeepStr: '10')
9+
}
710
stages {
811
stage('Clean') {
912
steps {
@@ -12,7 +15,7 @@ pipeline {
1215
}
1316
stage('Version') {
1417
steps {
15-
sh 'mvn versions:set -DnewVersion=2.1.10'
18+
sh 'mvn versions:set -DnewVersion=2.1.11'
1619
}
1720
}
1821
stage('Compile') {

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,16 @@
1111
[![GitHub release](https://img.shields.io/github/release/CloudNetService/CloudNet.svg)](https://github.com/CloudNetService/CloudNet/releases)
1212

1313

14-
# CloudNet | The Cloud Network Environment Technology
14+
# CloudNet | The Cloud Network Environment Technology 2
1515
![Image of CloudNet](https://cdn.discordapp.com/attachments/325383142464552972/354670548292206594/CloudNet.png)
1616

1717

18-
This is the CloudNet project, which has already taken a lot of time and effort for over 6 months.
18+
This is the CloudNet project, which has already taken a lot of time and effort for over 1 year.
1919
Here you can find the most recent commits to the project.
20-
I am absolutely not satisfied by the code and find it horribly awful.
21-
Therefore, soon there will be version 3.0 of CloudNet.
20+
I am absolutely not satisfied by the code and find it horribly awful.
2221

2322
CloudNet is a cloud computing service for Minecraft networks. With a wide range of functionality, it offers both control over Minecraft Servers (Craftbukkit / Spigot / Glowstone) and BungeeCord Proxys.
2423

25-
CloudNet is dynamic, which means that the software automates and "limits" many already clear functionalities based on the pre-configuration or the "CloudDynamicServices" (CDS 2.1)
26-
2724
CloudNet manages server and helps networks to expand through new technologies to help the administration of a Minecraft Network. Another aspect of CloudNet are the unlimited development possibilities because you are able to build your own modules and extensive programming interfaces.
2825
CloudNet supports a wide range of needs and future opportunities, such as a Round Robin DNS management with the CloudFlare company service and the multi-proxy functionality for networks with more than 500 players, the project is important to enable high performance and stabilization for a Minecraft network.
2926

@@ -33,16 +30,15 @@ For general information about CloudNet go to [spigotmc.org](https://www.spigotmc
3330

3431
* Java 8
3532
* Linux/Windows server with a minimum of 2GB DDR3 Memory and 2 vCores
36-
* A FTP/SFTP client to manage your Linux or Windows Server
3733

3834
**The use of Linux containers (LXC) or OpenVZ containers (OVZ) is discouraged. There are many issues with their stability.**
3935
Use of KVM virtualization or dedicated servers is recommended.
4036

4137
### Support
4238

43-
* Spigot-Support » 1.7.x - 1.12.1
39+
* Spigot-Support » 1.7.10 - 1.13.1
4440
* PaperSpigot, TacoSpigot, Hose, Torch
45-
* BungeeCord-Support » 1.7.x - 1.12.1
41+
* BungeeCord-Support » 1.7.10 - 1.13.1
4642
* Flexpipe, HexaCord, Waterfall, TraverTine
4743

4844
### Discord

cloudnet-api/cloudnet-api-bridge/src/main/java/de/dytanic/cloudnet/bridge/internal/command/proxied/CommandCloud.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void execute(CommandSender commandSender, String[] args)
8383
"The information was sent to the cloud");
8484
return;
8585
}
86-
if (args[0].equalsIgnoreCase("statistics") && commandSender.hasPermission("cloudnet.ommand.cloud.statistics"))
86+
if (args[0].equalsIgnoreCase("statistics") && commandSender.hasPermission("cloudnet.command.cloud.statistics"))
8787
{
8888
Document document = CloudAPI.getInstance().getStatistics();
8989

@@ -583,4 +583,4 @@ public Iterable<String> onTabComplete(CommandSender commandSender, String[] args
583583
{
584584
return new LinkedList<>(CloudProxy.getInstance().getCachedServers().keySet());
585585
}
586-
}
586+
}

cloudnet-cord/cloudnet-cloudflare/src/main/java/de/dytanic/cloudnet/cloudflare/database/CloudFlareDatabase.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
import de.dytanic.cloudnet.lib.utility.Return;
1414
import de.dytanic.cloudnet.lib.utility.document.Document;
1515

16-
import java.util.*;
16+
import java.util.Collection;
17+
import java.util.Collections;
18+
import java.util.HashMap;
19+
import java.util.Map;
1720

1821
/**
1922
* Database to store information about the CloudFlare requests and cache.

cloudnet-cord/cloudnet-command/src/main/java/de/dytanic/cloudnet/command/CommandManager.java

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
package de.dytanic.cloudnet.command;
66

77
import de.dytanic.cloudnet.lib.NetworkUtils;
8+
import de.dytanic.cloudnet.lib.utility.Acceptable;
9+
import de.dytanic.cloudnet.lib.utility.CollectionWrapper;
810
import jline.console.completer.Completer;
911
import lombok.Getter;
1012

11-
import java.util.List;
12-
import java.util.Map;
13-
import java.util.Set;
13+
import java.util.*;
1414

1515
/**
1616
* Class that manages commands for the interfaces of CloudNet.
@@ -171,24 +171,34 @@ public int complete(String buffer, int cursor, List<CharSequence> candidates)
171171
{
172172
String[] input = buffer.split(" ");
173173

174-
if (input.length == 0) return cursor;
174+
List<String> responses = new ArrayList<>();
175175

176-
Command command = getCommand(input[0]);
177-
if (command instanceof TabCompletable)
176+
if (buffer.isEmpty() || buffer.indexOf(' ') == -1)
177+
responses.addAll(this.commands.keySet());
178+
else
178179
{
179-
List<String> tabCompletions = ((TabCompletable) command).onTab(input.length - 1, input[input.length - 1]);
180+
Command command = getCommand(input[0]);
180181

181-
candidates.addAll(tabCompletions);
182-
183-
final int lastSpace = buffer.lastIndexOf(' ');
184-
if (lastSpace == -1)
185-
{
186-
return cursor - buffer.length();
187-
} else
182+
if (command instanceof TabCompletable)
188183
{
189-
return cursor - (buffer.length() - lastSpace - 1);
184+
String[] args = buffer.split(" ");
185+
String testString = args[args.length - 1];
186+
187+
responses.addAll(CollectionWrapper.filterMany(((TabCompletable) command).onTab(input.length - 1, input[input.length - 1]), new Acceptable<String>() {
188+
@Override
189+
public boolean isAccepted(String s)
190+
{
191+
return s != null && (testString.isEmpty() || s.toLowerCase().contains(testString.toLowerCase()));
192+
}
193+
}));
190194
}
191195
}
192-
return cursor;
196+
197+
Collections.sort(responses);
198+
199+
candidates.addAll(responses);
200+
int lastSpace = buffer.lastIndexOf(' ');
201+
202+
return (lastSpace == -1) ? cursor - buffer.length() : cursor - (buffer.length() - lastSpace - 1);
193203
}
194204
}

cloudnet-cord/cloudnet-web/src/main/java/de/dytanic/cloudnet/web/client/WebClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private <E> E handleRequest(String url, Type type)
6969
try
7070
{
7171
URLConnection urlConnection = new java.net.URL(url).openConnection();
72+
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
7273
urlConnection.setUseCaches(false);
7374
urlConnection.setConnectTimeout(1000);
7475
urlConnection.connect();
@@ -98,6 +99,7 @@ private String getString(String url, String key)
9899
try
99100
{
100101
URLConnection urlConnection = new java.net.URL(url).openConnection();
102+
urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
101103
urlConnection.setUseCaches(false);
102104
urlConnection.setConnectTimeout(1000);
103105
urlConnection.connect();

cloudnet-core/src/main/java/de/dytanic/cloudnetcore/CloudConfig.java

Lines changed: 23 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,8 @@ private void defaultInitDoc(ConsoleReader consoleReader) throws Exception
157157
break;
158158
}
159159
}
160-
new Document("wrapper", Arrays.asList(new WrapperMeta("Wrapper-1", hostName, "admin")))
161-
//.append("serverGroups", Arrays.asList(new LobbyGroup()))
162-
.append("proxyGroups", Arrays.asList(new BungeeGroup()))
160+
new Document("wrapper", Collections.singletonList(new WrapperMeta("Wrapper-1", hostName, "admin")))
161+
.append("proxyGroups", Collections.singletonList(new BungeeGroup()))
163162
.saveAsConfig(servicePath);
164163

165164
new Document("group", new LobbyGroup()).saveAsConfig(Paths.get("groups/Lobby.json"));
@@ -169,10 +168,10 @@ private void defaultInitUsers(ConsoleReader consoleReader)
169168
{
170169
if (Files.exists(usersPath)) return;
171170

172-
String password = NetworkUtils.randomString(8);
171+
String password = NetworkUtils.randomString(32);
173172
System.out.println("\"admin\" Password: " + password);
174173
System.out.println(NetworkUtils.SPACE_STRING);
175-
new Document().append("users", Arrays.asList(new BasicUser("admin", password, Arrays.asList("*")))).saveAsConfig(usersPath);
174+
new Document().append("users", Collections.singletonList(new BasicUser("admin", password, Arrays.asList("*")))).saveAsConfig(usersPath);
176175
}
177176

178177
public CloudConfig load() throws Exception
@@ -273,20 +272,6 @@ public CloudConfig save(Collection<User> users)
273272

274273
public void createGroup(@NonNull ServerGroup serverGroup)
275274
{
276-
/*
277-
Collection<ServerGroup> groups = this.serviceDocument.getObject("serverGroups", new TypeToken<Collection<ServerGroup>>() {
278-
}.getType());
279-
CollectionWrapper.checkAndRemove(groups, new Acceptable<ServerGroup>() {
280-
@Override
281-
public boolean isAccepted(ServerGroup value)
282-
{
283-
return value.getName().equals(serverGroup.getName());
284-
}
285-
});
286-
287-
groups.add(serverGroup);
288-
this.serviceDocument.append("serverGroups", groups).saveAsConfig(servicePath);
289-
*/
290275

291276
new Document("group", serverGroup).saveAsConfig(Paths.get("groups/" + serverGroup.getName() + ".json"));
292277

@@ -310,20 +295,6 @@ public boolean isAccepted(ProxyGroup value)
310295

311296
public void deleteGroup(ServerGroup serverGroup)
312297
{
313-
/*
314-
Collection<ServerGroup> groups = this.serviceDocument.getObject("serverGroups", new TypeToken<Collection<ServerGroup>>() {
315-
}.getType());
316-
CollectionWrapper.checkAndRemove(groups, new Acceptable<ServerGroup>() {
317-
@Override
318-
public boolean isAccepted(ServerGroup value)
319-
{
320-
return value.getName().equals(serverGroup.getName());
321-
}
322-
});
323-
324-
this.serviceDocument.append("serverGroups", groups).saveAsConfig(servicePath);
325-
*/
326-
327298
new File("groups/" + serverGroup.getName() + ".json").delete();
328299
}
329300

@@ -343,18 +314,6 @@ public boolean isAccepted(ProxyGroup value)
343314

344315
public java.util.Map<String, ServerGroup> getServerGroups()
345316
{
346-
/*
347-
Collection<ServerGroup> collection = serviceDocument.getObject("serverGroups", new TypeToken<Collection<ServerGroup>>() {
348-
}.getType());
349-
return MapWrapper.collectionCatcherHashMap(collection, new Catcher<String, ServerGroup>() {
350-
@Override
351-
public String doCatch(ServerGroup key)
352-
{
353-
return key.getName();
354-
}
355-
});
356-
*/
357-
358317
Map<String, ServerGroup> groups = NetworkUtils.newConcurrentHashMap();
359318

360319
if (serviceDocument.contains("serverGroups"))
@@ -374,19 +333,24 @@ public String doCatch(ServerGroup key)
374333
Document entry;
375334

376335
if (groupsDirectory.isDirectory())
377-
for (File file : groupsDirectory.listFiles())
378-
{
379-
if (file.getName().endsWith(".json"))
380-
try
381-
{
382-
entry = Document.$loadDocument(file);
383-
ServerGroup serverGroup = entry.getObject("group", ServerGroup.TYPE);
384-
groups.put(serverGroup.getName(), serverGroup);
385-
} catch (Throwable ex)
386-
{
387-
System.out.println("Cannot load servergroup file [" + file.getName() + "]");
388-
}
389-
}
336+
{
337+
File[] files = groupsDirectory.listFiles();
338+
339+
if (files != null)
340+
for (File file : files)
341+
{
342+
if (file.getName().endsWith(".json"))
343+
try
344+
{
345+
entry = Document.$loadDocument(file);
346+
ServerGroup serverGroup = entry.getObject("group", ServerGroup.TYPE);
347+
groups.put(serverGroup.getName(), serverGroup);
348+
} catch (Throwable ex)
349+
{
350+
System.out.println("Cannot load servergroup file [" + file.getName() + "]");
351+
}
352+
}
353+
}
390354

391355
return groups;
392356
}
@@ -405,4 +369,4 @@ public String doCatch(ProxyGroup key)
405369
});
406370
}
407371

408-
}
372+
}

cloudnet-core/src/main/java/de/dytanic/cloudnetcore/CloudNet.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ public final class CloudNet implements Executable, Runnable, Reloadable {
102102

103103
public CloudNet(CloudConfig config, CloudLogger cloudNetLogging, OptionSet optionSet, List<String> objective, List<String> args) throws Exception
104104
{
105-
if (instance == null)
106-
this.instance = this;
105+
if (instance == null) instance = this;
107106

108107
this.config = config;
109108
this.logger = cloudNetLogging;
110109
this.preConsoleOutput = objective;
111110
this.optionSet = optionSet;
112111
this.arguments = args;
113112
this.defaultModuleManager = new DefaultModuleManager();
113+
114+
this.logger.getReader().addCompleter(commandManager);
114115
}
115116

116117
@Override

cloudnet-core/src/main/java/de/dytanic/cloudnetcore/command/CommandHelp.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import de.dytanic.cloudnet.command.Command;
88
import de.dytanic.cloudnet.command.CommandSender;
99
import de.dytanic.cloudnet.lib.NetworkUtils;
10-
import de.dytanic.cloudnet.lib.utility.CollectionWrapper;
1110
import de.dytanic.cloudnetcore.CloudNet;
1211

1312
import java.lang.management.ManagementFactory;

cloudnet-core/src/main/java/de/dytanic/cloudnetcore/command/CommandScreen.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66

77
import de.dytanic.cloudnet.command.Command;
88
import de.dytanic.cloudnet.command.CommandSender;
9+
import de.dytanic.cloudnet.command.TabCompletable;
910
import de.dytanic.cloudnet.lib.NetworkUtils;
1011
import de.dytanic.cloudnet.lib.service.ServiceId;
1112
import de.dytanic.cloudnetcore.CloudNet;
1213
import de.dytanic.cloudnetcore.network.components.MinecraftServer;
1314
import de.dytanic.cloudnetcore.network.components.ProxyServer;
1415
import de.dytanic.cloudnetcore.network.components.Wrapper;
1516

16-
public final class CommandScreen extends Command {
17+
import java.util.ArrayList;
18+
import java.util.List;
19+
20+
public final class CommandScreen extends Command implements TabCompletable {
1721

1822
public CommandScreen()
1923
{
@@ -114,4 +118,15 @@ public void onExecuteCommand(CommandSender sender, String[] args)
114118
break;
115119
}
116120
}
121+
122+
@Override
123+
public List<String> onTab(long argsLength, String lastWord)
124+
{
125+
List<String> list = new ArrayList<>(CloudNet.getInstance().getServers().size() + CloudNet.getInstance().getProxys().size());
126+
127+
list.addAll(CloudNet.getInstance().getServers().keySet());
128+
list.addAll(CloudNet.getInstance().getProxys().keySet());
129+
130+
return list;
131+
}
117132
}

0 commit comments

Comments
 (0)