15.8
Innovation: Commands can now be provided with delays (in ticks) Example: /say hi !delay:20 This command is now executed with a delay of one second 20 ticks are one second
This commit is contained in:
parent
de6ecdf7a8
commit
f40c47e6ab
@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="2">
|
||||
|
6
pom.xml
6
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.t2code</groupId>
|
||||
<artifactId>T2CodeLib</artifactId>
|
||||
<version>15.8_dev</version>
|
||||
<version>15.8</version>
|
||||
<!--version>VERSION_snapshot-0</version-->
|
||||
<!--version>VERSION_beta-0</version-->
|
||||
<!--version>VERSION_dev-0</version-->
|
||||
@ -27,8 +27,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -1,25 +1,71 @@
|
||||
package net.t2code.t2codelib.SPIGOT.api.commands;
|
||||
|
||||
import net.t2code.t2codelib.SPIGOT.api.debug.T2Cdebug;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CbungeeCommandSenderReciver;
|
||||
import net.t2code.t2codelib.SPIGOT.system.T2CodeLibMain;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
|
||||
import java.rmi.MarshalledObject;
|
||||
import java.util.Map;
|
||||
|
||||
public class T2Ccmd {
|
||||
public static void console(String cmd) {
|
||||
if (cmd.contains("!onBungee")){
|
||||
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
|
||||
}else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
|
||||
public static void console(String cmdInput) {
|
||||
Map.Entry<String,Integer> map = delay(cmdInput);
|
||||
int delay = map.getValue();
|
||||
String cmd = map.getKey();
|
||||
Bukkit.getScheduler().runTaskLater(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
T2CbungeeCommandSenderReciver.sendToBungee(null, cmd.replace("!onBungee", ""), true);
|
||||
} else Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd);
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
public static void player(Player player, String cmd) {
|
||||
if (cmd.contains("!asConsole")) {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
|
||||
} else console(cmd.replace("!asConsole", ""));
|
||||
} else {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
|
||||
} else player.chat("/" + cmd);
|
||||
}
|
||||
public static void player(Player player, String cmdInput) {
|
||||
Map.Entry<String,Integer> map = delay(cmdInput);
|
||||
int delay = map.getValue();
|
||||
String cmd = map.getKey();
|
||||
Bukkit.getScheduler().runTaskLater(T2CodeLibMain.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (cmd.contains("!asConsole")) {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!asConsole", "").replace("!onBungee", ""), true);
|
||||
} else console(cmd.replace("!asConsole", ""));
|
||||
} else {
|
||||
if (cmd.contains("!onBungee")) {
|
||||
T2CbungeeCommandSenderReciver.sendToBungee(player, cmd.replace("!onBungee", ""), false);
|
||||
} else player.chat("/" + cmd);
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
private static Map.Entry<String, Integer> delay(@NotNull String cmdInput) {
|
||||
T2Cdebug.debugmsg(T2CodeLibMain.getPlugin(), "Input: " + cmdInput);
|
||||
int delay = 0;
|
||||
String cmd;
|
||||
if (cmdInput.contains("!delay:")) {
|
||||
int i = cmdInput.indexOf("!delay:") + 7;
|
||||
String s2 = cmdInput.substring(i);
|
||||
int i2 = 1;
|
||||
if(s2.contains(" ")) {
|
||||
i2 = s2.indexOf(" ");
|
||||
}else{
|
||||
i2 = s2.length();
|
||||
}
|
||||
delay = Integer.parseInt(cmdInput.substring(i, i + i2));
|
||||
cmd = cmdInput.replace("!delay:" + delay, "");
|
||||
|
||||
} else cmd = cmdInput;
|
||||
|
||||
return Map.entry(cmd, delay);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user