Skip to content

Commit cfc34db

Browse files
committed
Add /sync to Bungee Console
1 parent 1efe700 commit cfc34db

4 files changed

Lines changed: 107 additions & 2 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="false">
4+
<output url="file:///target" />
5+
<output-test url="file:///test/CommandSyncClient" />
6+
<exclude-output />
7+
<content url="file://$MODULE_DIR$">
8+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
9+
</content>
10+
<orderEntry type="inheritedJdk" />
11+
<orderEntry type="sourceFolder" forTests="false" />
12+
<orderEntry type="library" name="spigot" level="project" />
13+
</component>
14+
</module>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="false">
4+
<output url="file:///target" />
5+
<output-test url="file:///test/CommandSyncServer" />
6+
<exclude-output />
7+
<content url="file://$MODULE_DIR$">
8+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
9+
</content>
10+
<orderEntry type="inheritedJdk" />
11+
<orderEntry type="sourceFolder" forTests="false" />
12+
<orderEntry type="library" name="BungeeCord" level="project" />
13+
</component>
14+
</module>

CommandSyncServer/src/com/fuzzoland/CommandSyncServer/CSS.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Map.Entry;
2020
import java.util.Set;
2121

22+
import net.md_5.bungee.api.ProxyServer;
2223
import net.md_5.bungee.api.plugin.Plugin;
2324

2425
import com.fuzzoland.CommandSyncServer.Metrics.Graph;
@@ -27,10 +28,10 @@ public class CSS extends Plugin {
2728

2829
public ServerSocket server;
2930
public Set<String> c = Collections.synchronizedSet(new HashSet<String>());
30-
public List<String> oq = Collections.synchronizedList(new ArrayList<String>());
31+
public static List<String> oq = Collections.synchronizedList(new ArrayList<String>());
3132
public Map<String, List<String>> pq = Collections.synchronizedMap(new HashMap<String, List<String>>());
3233
public Map<String, Integer> qc = Collections.synchronizedMap(new HashMap<String, Integer>());
33-
public String spacer = "@#@";
34+
public static String spacer = "@#@";
3435
public Debugger debugger;
3536

3637
public void onEnable() {
@@ -72,6 +73,7 @@ public String getColumnName() {
7273
} catch(IOException e) {
7374
e.printStackTrace();
7475
}
76+
ProxyServer.getInstance().getPluginManager().registerCommand(this, new CommandSynchronize());
7577
}
7678

7779
public void onDisable() {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.fuzzoland.CommandSyncServer;
2+
3+
import net.md_5.bungee.api.ChatColor;
4+
import net.md_5.bungee.api.CommandSender;
5+
import net.md_5.bungee.api.plugin.Command;
6+
7+
/**
8+
* Created by David on 7/7/2015.
9+
*
10+
* @author David
11+
*/
12+
@SuppressWarnings("deprecation")
13+
public class CommandSynchronize extends Command {
14+
public CommandSynchronize() {super("bsync", "bsync.use", "bungeesync");}
15+
16+
@Override
17+
public void execute(CommandSender sender, String[] args) {
18+
if(args.length >= 0) {
19+
if(args.length <= 2) {
20+
sender.sendMessage(ChatColor.BLUE + "CommandSync by YoFuzzy3");
21+
if(args.length >= 1) {
22+
if(args[0].equalsIgnoreCase("console")){
23+
sender.sendMessage(ChatColor.GREEN + "/bsync console <server> <command args...>");
24+
sender.sendMessage(ChatColor.GREEN + "/bsync console all <command args...>");
25+
} else if(args[0].equalsIgnoreCase("player")) {
26+
sender.sendMessage(ChatColor.GREEN + "/bsync player <player> <command args...>");
27+
sender.sendMessage(ChatColor.GREEN + "/bsync player all <command args...>");
28+
} else {
29+
sender.sendMessage(ChatColor.RED + "Type /bsync for help.");
30+
}
31+
} else {
32+
sender.sendMessage(ChatColor.GREEN + "/bsync console");
33+
sender.sendMessage(ChatColor.GREEN + "/bsync player");
34+
sender.sendMessage(ChatColor.BLUE + "Type the command for more info.");
35+
}
36+
sender.sendMessage(ChatColor.BLUE + "Visit www.spigotmc.org/resources/commandsync.115 for help.");
37+
} else if(args.length >= 3) {
38+
if(args[0].equalsIgnoreCase("console") || args[0].equalsIgnoreCase("player")) {
39+
String[] newArgs = new String[3];
40+
newArgs[0] = args[0];
41+
newArgs[1] = args[1];
42+
StringBuilder sb = new StringBuilder();
43+
for(int i = 2; i < args.length; i++) {
44+
sb.append(args[i]);
45+
if(i < args.length - 1) {
46+
sb.append("+");
47+
}
48+
}
49+
newArgs[2] = sb.toString();
50+
if(args[1].equalsIgnoreCase("all")) {
51+
makeData(newArgs, false, sender);
52+
} else {
53+
makeData(newArgs, true, sender);
54+
}
55+
} else {
56+
sender.sendMessage(ChatColor.RED + "Type /bsync for help!");
57+
}
58+
}
59+
}
60+
}
61+
62+
private void makeData(String[] args, Boolean single, CommandSender sender) {
63+
String data;
64+
String message = ChatColor.GREEN + "Syncing command /" + args[2].replaceAll("\\+", " ") + " to " + args[0];
65+
if(single) {
66+
data = args[0].toLowerCase() + CSS.spacer + "single" + CSS.spacer + args[2] + CSS.spacer + args[1];
67+
message = message + " [" + args[1] + "]...";
68+
} else {
69+
data = args[0].toLowerCase() + CSS.spacer + args[1].toLowerCase() + CSS.spacer + args[2];
70+
message = message + " [All]...";
71+
}
72+
CSS.oq.add(data);
73+
sender.sendMessage(message);
74+
}
75+
}

0 commit comments

Comments
 (0)