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

Commit 5584f54

Browse files
authored
Merge pull request #35 from CloudNetService/development
Merge development with master
2 parents 7744540 + 330f264 commit 5584f54

File tree

25 files changed

+310
-111
lines changed

25 files changed

+310
-111
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pipeline {
1212
}
1313
stage('Version') {
1414
steps {
15-
sh 'mvn versions:set -DnewVersion=2.1.8'
15+
sh 'mvn versions:set -DnewVersion=2.1.9'
1616
}
1717
}
1818
stage('Compile') {

cloudnet-api/cloudnet-api-bridge/src/main/java/de/dytanic/cloudnet/bridge/CloudServer.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,12 @@ private void addTeamEntry(Player target, Player all, PermissionGroup permissionG
470470
String teamName = permissionGroup.getTagId() + permissionGroup.getName();
471471
try
472472
{
473-
if (teamName.getBytes("UTF-8").length > 16)
473+
if (teamName.length() > 16)
474474
{
475475
teamName = shortenStringTo16Bytes(teamName);
476-
CloudAPI.getInstance().dispatchConsoleMessage("In order to prevent issues, the name (+ tagID) of the group " + permissionGroup.getName() + " was temporarily shortened to 16 bytes!");
476+
CloudAPI.getInstance().dispatchConsoleMessage("In order to prevent issues, the name (+ tagID) of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!");
477477
CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the name of the group in your perms.yml");
478-
Bukkit.broadcast("In order to prevent issues, the name (+ tagID) of the group " + permissionGroup.getName() + " was temporarily shortened to 16 bytes!", "cloudnet.notify");
478+
Bukkit.broadcast("In order to prevent issues, the name (+ tagID) of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!", "cloudnet.notify");
479479
Bukkit.broadcast("Please fix this issue by changing the name of the group in your perms.yml", "cloudnet.notify");
480480
}
481481
} catch (UnsupportedEncodingException e)
@@ -488,20 +488,20 @@ private void addTeamEntry(Player target, Player all, PermissionGroup permissionG
488488

489489
try
490490
{
491-
if (permissionGroup.getPrefix().getBytes("UTF-8").length > 16)
491+
if (permissionGroup.getPrefix().length() > 16)
492492
{
493493
permissionGroup.setPrefix(shortenStringTo16Bytes(permissionGroup.getPrefix()));
494-
CloudAPI.getInstance().dispatchConsoleMessage("In order to prevent issues, the prefix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 bytes!");
494+
CloudAPI.getInstance().dispatchConsoleMessage("In order to prevent issues, the prefix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!");
495495
CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the prefix in your perms.yml");
496-
Bukkit.broadcast("In order to prevent issues, the prefix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 bytes!", "cloudnet.notify");
496+
Bukkit.broadcast("In order to prevent issues, the prefix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!", "cloudnet.notify");
497497
Bukkit.broadcast("Please fix this issue by changing the prefix in your perms.yml", "cloudnet.notify");
498498
}
499-
if (permissionGroup.getSuffix().getBytes("UTF-8").length > 16)
499+
if (permissionGroup.getSuffix().length() > 16)
500500
{
501501
permissionGroup.setSuffix(shortenStringTo16Bytes(permissionGroup.getSuffix()));
502-
CloudAPI.getInstance().dispatchConsoleMessage("In order to prevent issues, the suffix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 bytes!");
502+
CloudAPI.getInstance().dispatchConsoleMessage("In order to prevent issues, the suffix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!");
503503
CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the suffix in your perms.yml");
504-
Bukkit.broadcast("In order to prevent issues, the suffix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 bytes!", "cloudnet.notify");
504+
Bukkit.broadcast("In order to prevent issues, the suffix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!", "cloudnet.notify");
505505
Bukkit.broadcast("Please fix this issue by changing the suffix in your perms.yml", "cloudnet.notify");
506506
}
507507
} catch (UnsupportedEncodingException e)
@@ -518,12 +518,7 @@ private void addTeamEntry(Player target, Player all, PermissionGroup permissionG
518518

519519
private String shortenStringTo16Bytes(String input) throws UnsupportedEncodingException
520520
{
521-
String fixedInput = input;
522-
while (fixedInput.getBytes("UTF-8").length > 16)
523-
{
524-
fixedInput = fixedInput.substring(0, fixedInput.length() - 1);
525-
}
526-
return fixedInput;
521+
return input.substring(0, 16);
527522
}
528523

529524
private void initScoreboard(Player all)
@@ -653,4 +648,4 @@ public void onUpdateOnlineCount(int onlineCount)
653648
Bukkit.getPluginManager().callEvent(new BukkitOnlineCountUpdateEvent(onlineCount));
654649
}
655650
}
656-
}
651+
}

cloudnet-api/cloudnet-api-bridge/src/main/java/de/dytanic/cloudnet/bridge/ProxiedBootstrap.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import de.dytanic.cloudnet.bridge.internal.command.proxied.CommandPermissions;
1414
import de.dytanic.cloudnet.bridge.internal.command.proxied.defaults.CommandIp;
1515
import de.dytanic.cloudnet.bridge.internal.listener.proxied.ProxiedListener;
16+
import de.dytanic.cloudnet.bridge.internal.packetio.PacketOutProxyPing;
1617
import de.dytanic.cloudnet.lib.utility.CollectionWrapper;
1718
import de.dytanic.cloudnet.lib.utility.threading.Runnabled;
1819
import net.md_5.bungee.api.ProxyServer;
@@ -82,6 +83,13 @@ public void run()
8283
}
8384
}, 1, TimeUnit.SECONDS);
8485

86+
getProxy().getScheduler().schedule(this, new Runnable() {
87+
@Override
88+
public void run()
89+
{
90+
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutProxyPing());
91+
}
92+
}, 0, 1, TimeUnit.MINUTES);
8593
}
8694

8795
@Override

cloudnet-api/cloudnet-api-bridge/src/main/java/de/dytanic/cloudnet/bridge/internal/command/bukkit/CommandCloudServer.java

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import de.dytanic.cloudnet.bridge.internal.serverselectors.packet.out.PacketOutRemoveSign;
1414
import de.dytanic.cloudnet.lib.NetworkUtils;
1515
import de.dytanic.cloudnet.lib.serverselectors.mob.ServerMob;
16+
import de.dytanic.cloudnet.lib.serverselectors.sign.Position;
1617
import de.dytanic.cloudnet.lib.serverselectors.sign.Sign;
1718
import de.dytanic.cloudnet.lib.utility.Acceptable;
1819
import de.dytanic.cloudnet.lib.utility.CollectionWrapper;
@@ -69,9 +70,8 @@ public boolean isAccepted(MobSelector.MobImpl value)
6970
{
7071
StringBuilder stringBuilder = new StringBuilder();
7172
for (short i = 6; i < args.length; i++)
72-
{
7373
stringBuilder.append(args[i]).append(NetworkUtils.SPACE_STRING);
74-
}
74+
7575
if (stringBuilder.length() > 32)
7676
{
7777
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The display cannot be longe then 32 characters");
@@ -154,6 +154,30 @@ public boolean isAccepted(MobSelector.MobImpl value)
154154
switch (args.length)
155155
{
156156
case 2:
157+
if (args[0].equalsIgnoreCase("copyTo"))
158+
{
159+
if (SignSelector.getInstance() == null)
160+
{
161+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The Module \"SignSelector\" isn't enabled!");
162+
return false;
163+
}
164+
165+
if (CloudAPI.getInstance().getServerGroupMap().containsKey(args[1]))
166+
{
167+
for (Sign sign : SignSelector.getInstance().getSigns().values())
168+
CloudAPI.getInstance().getNetworkConnection().sendPacket(new PacketOutAddSign(new Sign(
169+
sign.getTargetGroup(), new Position(
170+
args[1],
171+
sign.getPosition().getWorld(),
172+
sign.getPosition().getX(),
173+
sign.getPosition().getY(),
174+
sign.getPosition().getZ()
175+
))));
176+
177+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "The signs by this group was successfully copied to the target group.");
178+
}
179+
return true;
180+
}
157181
if (args[0].equalsIgnoreCase("createSign"))
158182
{
159183
if (SignSelector.getInstance() == null)
@@ -300,19 +324,20 @@ public boolean isAccepted(MobSelector.MobImpl value)
300324
default:
301325
if (SignSelector.getInstance() != null)
302326
{
303-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver createSign <targetGroup>");
304-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver removeSign");
305-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver removeSigns <targetGroup>");
327+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs createSign <targetGroup>");
328+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs removeSign");
329+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs removeSigns <targetGroup>");
330+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs copyTo <targetGroup>");
306331
}
307332
if (MobSelector.getInstance() != null)
308333
{
309-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver createMob <entityType> <name> <targetGroup> <itemId> <autoJoin> <displayName>");
310-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver removeMob <name>");
311-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver listMobs");
312-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver moblist");
313-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver setDisplay <name> <display>");
314-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver setItem <name> <itemId>");
315-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cloudserver editMobLine <name> <display>");
334+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs createMob <entityType> <name> <targetGroup> <itemId> <autoJoin> <displayName>");
335+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs removeMob <name>");
336+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs listMobs");
337+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs moblist");
338+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs setDisplay <name> <display>");
339+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs setItem <name> <itemId>");
340+
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "/cs editMobLine <name> <display>");
316341
}
317342
break;
318343
}

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

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,40 +76,6 @@ public void execute(CommandSender commandSender, String[] args)
7676
switch (args.length)
7777
{
7878
case 1:
79-
if (args[0].equalsIgnoreCase("help"))
80-
{
81-
commandSender.sendMessages(
82-
NetworkUtils.SPACE_STRING,
83-
CloudAPI.getInstance().getPrefix() + "All command arguments",
84-
"§7/cloud toggle autoslot",
85-
"§7/cloud toggle maintenance",
86-
"§7/cloud toggle maintenance <time>",
87-
"§7/cloud setMaxPlayers <maxonlinecount>",
88-
"§7/cloud whitelist <add : remove> <name>",
89-
"§7/cloud start <group> <count>",
90-
"§7/cloud start <group> <template>",
91-
"§7/cloud startcs <name> <memory> <priorityStop>",
92-
"§7/cloud cmds (command server) <server> <command>",
93-
"§7/cloud cmdp (command proxy) <proxy> <command>",
94-
"§7/cloud stop <serverId>",
95-
"§7/cloud stopGroup <group>",
96-
"§7/cloud ustopGroup <group>",
97-
"§7/cloud listProxys",
98-
"§7/cloud listOnline",
99-
"§7/cloud listServers",
100-
"§7/cloud log <server>",
101-
"§7/cloud listGroups",
102-
"§7/cloud rl",
103-
"§7/cloud list",
104-
"§7/cloud maintenance <group>",
105-
"§7/cloud copy <server>",
106-
"§7/cloud copy <server> <directory>",
107-
"§7/cloud version",
108-
"§7/cloud statistics",
109-
NetworkUtils.SPACE_STRING
110-
);
111-
return;
112-
}
11379
if (args[0].equalsIgnoreCase("rl") && commandSender.hasPermission("cloudnet.command.cloud.reload"))
11480
{
11581
CloudAPI.getInstance().sendCloudCommand("reload config");
@@ -565,7 +531,36 @@ public boolean isAccepted(Template value)
565531
}
566532
break;
567533
default:
568-
commandSender.sendMessage(CloudAPI.getInstance().getPrefix() + "Use /cloud help");
534+
commandSender.sendMessages(
535+
NetworkUtils.SPACE_STRING,
536+
CloudAPI.getInstance().getPrefix() + "All command arguments",
537+
"§7/cloud toggle autoslot",
538+
"§7/cloud toggle maintenance",
539+
"§7/cloud toggle maintenance <time>",
540+
"§7/cloud setMaxPlayers <maxonlinecount>",
541+
"§7/cloud whitelist <add : remove> <name>",
542+
"§7/cloud start <group> <count>",
543+
"§7/cloud start <group> <template>",
544+
"§7/cloud startcs <name> <memory> <priorityStop>",
545+
"§7/cloud cmds (command server) <server> <command>",
546+
"§7/cloud cmdp (command proxy) <proxy> <command>",
547+
"§7/cloud stop <serverId>",
548+
"§7/cloud stopGroup <group>",
549+
"§7/cloud ustopGroup <group>",
550+
"§7/cloud listProxys",
551+
"§7/cloud listOnline",
552+
"§7/cloud listServers",
553+
"§7/cloud log <server>",
554+
"§7/cloud listGroups",
555+
"§7/cloud rl",
556+
"§7/cloud list",
557+
"§7/cloud maintenance <group>",
558+
"§7/cloud copy <server>",
559+
"§7/cloud copy <server> <directory>",
560+
"§7/cloud version",
561+
"§7/cloud statistics",
562+
NetworkUtils.SPACE_STRING
563+
);
569564
break;
570565
}
571566

cloudnet-api/cloudnet-api-bridge/src/main/java/de/dytanic/cloudnet/bridge/internal/listener/bukkit/BukkitListener.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public void handleFirst(PlayerLoginEvent event)
9898
field.setAccessible(true);
9999
final CloudPermissble cloudPermissble = new CloudPermissble(event.getPlayer());
100100
field.set(event.getPlayer(), cloudPermissble);
101-
cloudPermissble.clearPermissions();
102101
} catch (Exception ex)
103102
{
104103
ex.printStackTrace();

cloudnet-api/cloudnet-api-bridge/src/main/java/de/dytanic/cloudnet/bridge/internal/listener/proxied/ProxiedListener.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public void handleLogin(LoginEvent e)
132132
{
133133
e.setCancelReason(TextComponent.fromLegacyText("§cUnverified login."));
134134
e.setCancelled(true);
135+
return;
135136
}
136137

137138
CommandSender cloudCommandSender = new CloudPlayerCommandSender(cloudPlayer);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package de.dytanic.cloudnet.bridge.internal.packetio;
2+
3+
import de.dytanic.cloudnet.lib.network.protocol.packet.Packet;
4+
import de.dytanic.cloudnet.lib.network.protocol.packet.PacketRC;
5+
import de.dytanic.cloudnet.lib.utility.document.Document;
6+
7+
public final class PacketOutProxyPing extends Packet {
8+
9+
public PacketOutProxyPing()
10+
{
11+
super(PacketRC.INTERNAL - 512, new Document());
12+
}
13+
}

cloudnet-api/cloudnet-api-bridge/src/main/java/de/dytanic/cloudnet/bridge/internal/util/CloudPermissble.java

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,62 +10,70 @@
1010
import org.bukkit.entity.Player;
1111
import org.bukkit.permissions.PermissibleBase;
1212
import org.bukkit.permissions.Permission;
13+
import org.bukkit.permissions.PermissionAttachmentInfo;
1314

15+
import java.util.HashSet;
16+
import java.util.Map;
17+
import java.util.Set;
1418
import java.util.UUID;
1519

1620
/**
1721
* Created by Tareko on 18.08.2017.
1822
*/
1923
public class CloudPermissble extends PermissibleBase {
2024

21-
private UUID unqiueId;
25+
private UUID uniqueId;
2226

23-
public CloudPermissble(Player player)
24-
{
27+
public CloudPermissble(Player player) {
2528
super(player);
26-
this.unqiueId = player.getUniqueId();
29+
this.uniqueId = player.getUniqueId();
2730

2831
player.setOp(false);
2932
}
3033

3134
@Override
32-
public boolean isPermissionSet(String name)
33-
{
35+
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
36+
final Map<String, Boolean> permissions = CloudServer.getInstance().getCloudPlayers().get(this.uniqueId).getPermissionEntity().getPermissions();
37+
Set<PermissionAttachmentInfo> set = new HashSet<>();
38+
for (Map.Entry<String, Boolean> entry : permissions.entrySet()) {
39+
PermissionAttachmentInfo permissionAttachmentInfo = new PermissionAttachmentInfo(this, entry.getKey(), null, entry.getValue());
40+
set.add(permissionAttachmentInfo);
41+
}
42+
return set;
43+
}
44+
45+
@Override
46+
public boolean isPermissionSet(String name) {
3447
return hasPermission(name);
3548
}
3649

3750
@Override
38-
public boolean isPermissionSet(Permission perm)
39-
{
51+
public boolean isPermissionSet(Permission perm) {
4052
return hasPermission(perm.getName());
4153
}
4254

4355
@Override
44-
public boolean hasPermission(Permission perm)
45-
{
56+
public boolean hasPermission(Permission perm) {
4657
return hasPermission(perm.getName());
4758
}
4859

4960
@Override
50-
public boolean hasPermission(String inName)
51-
{
61+
public boolean hasPermission(String inName) {
5262
if (inName.equalsIgnoreCase("bukkit.broadcast.user")) return true;
5363

54-
CloudPlayer cloudPlayer = CloudServer.getInstance().getCloudPlayers().get(this.unqiueId);
64+
CloudPlayer cloudPlayer = CloudServer.getInstance().getCloudPlayers().get(this.uniqueId);
5565
if (cloudPlayer != null)
5666
return cloudPlayer.getPermissionEntity().hasPermission(CloudAPI.getInstance().getPermissionPool(), inName, CloudAPI.getInstance().getGroup());
5767
else
5868
return false;
5969
}
6070

6171
@Override
62-
public boolean isOp()
63-
{
72+
public boolean isOp() {
6473
return false;
6574
}
6675

67-
public UUID getUnqiueId()
68-
{
69-
return unqiueId;
76+
public UUID getUniqueId() {
77+
return uniqueId;
7078
}
7179
}

cloudnet-api/cloudnet-api-core/src/main/java/de/dytanic/cloudnet/api/CloudAPI.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import de.dytanic.cloudnet.lib.player.OfflinePlayer;
2626
import de.dytanic.cloudnet.lib.player.permission.PermissionGroup;
2727
import de.dytanic.cloudnet.lib.player.permission.PermissionPool;
28+
import de.dytanic.cloudnet.lib.scheduler.TaskScheduler;
2829
import de.dytanic.cloudnet.lib.server.*;
2930
import de.dytanic.cloudnet.lib.server.defaults.BasicServerConfig;
3031
import de.dytanic.cloudnet.lib.server.info.ProxyInfo;
@@ -109,6 +110,7 @@ public void bootstrap()
109110
@Deprecated
110111
public void shutdown()
111112
{
113+
TaskScheduler.runtimeScheduler().shutdown();
112114
this.networkConnection.tryDisconnect();
113115
}
114116

0 commit comments

Comments
 (0)