1.14 support, fixes #105
3 changed files with 33 additions and 6 deletions
|
@ -122,6 +122,12 @@ public class ChatProcessing {
|
||||||
|
|
||||||
doFunStuff(sender, e, message);
|
doFunStuff(sender, e, message);
|
||||||
|
|
||||||
|
final String channelidentifier = getChannelID(channel, e.getOrigin());
|
||||||
|
PluginMain.Instance.getServer().getConsoleSender()
|
||||||
|
.sendMessage(String.format("%s <%s§r> %s", channelidentifier, getSenderName(sender, player), message));
|
||||||
|
|
||||||
|
if (Bukkit.getOnlinePlayers().size() == 0) return false; //Don't try to send to nobody (errors on 1.14)
|
||||||
|
|
||||||
ChatPlayer mp;
|
ChatPlayer mp;
|
||||||
if (player != null)
|
if (player != null)
|
||||||
mp = TBMCPlayerBase.getPlayer(player.getUniqueId(), ChatPlayer.class);
|
mp = TBMCPlayerBase.getPlayer(player.getUniqueId(), ChatPlayer.class);
|
||||||
|
@ -144,7 +150,6 @@ public class ChatProcessing {
|
||||||
}).build());
|
}).build());
|
||||||
}
|
}
|
||||||
pingedconsole = false; // Will set it to true onmatch (static constructor)
|
pingedconsole = false; // Will set it to true onmatch (static constructor)
|
||||||
final String channelidentifier = getChannelID(channel, e.getOrigin());
|
|
||||||
|
|
||||||
TellrawPart json = createTellraw(sender, message, player, mp, e.getUser(), channelidentifier, e.getOrigin());
|
TellrawPart json = createTellraw(sender, message, player, mp, e.getUser(), channelidentifier, e.getOrigin());
|
||||||
long combinetime = System.nanoTime();
|
long combinetime = System.nanoTime();
|
||||||
|
@ -191,8 +196,6 @@ public class ChatProcessing {
|
||||||
sender.sendMessage("§cAn error occured while sending the message.");
|
sender.sendMessage("§cAn error occured while sending the message.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PluginMain.Instance.getServer().getConsoleSender()
|
|
||||||
.sendMessage(String.format("%s <%s§r> %s", channelidentifier, getSenderName(sender, player), message));
|
|
||||||
DebugCommand.SendDebugMessage(
|
DebugCommand.SendDebugMessage(
|
||||||
"-- Full ChatProcessing time: " + (System.nanoTime() - processstart) / 1000000f + " ms");
|
"-- Full ChatProcessing time: " + (System.nanoTime() - processstart) / 1000000f + " ms");
|
||||||
DebugCommand.SendDebugMessage("-- ChatFormatter.Combine time: " + combinetime / 1000000f + " ms");
|
DebugCommand.SendDebugMessage("-- ChatFormatter.Combine time: " + combinetime / 1000000f + " ms");
|
||||||
|
|
|
@ -2,6 +2,8 @@ package buttondevteam.chat;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public final class ChatUtils {
|
public final class ChatUtils {
|
||||||
private ChatUtils() {}
|
private ChatUtils() {}
|
||||||
|
|
||||||
|
@ -17,4 +19,18 @@ public final class ChatUtils {
|
||||||
else
|
else
|
||||||
Bukkit.dispatchCommand(PluginMain.Console, command);
|
Bukkit.dispatchCommand(PluginMain.Console, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the string between the start and end strings (exclusive).
|
||||||
|
*
|
||||||
|
* @param str The original string
|
||||||
|
* @param start The start string
|
||||||
|
* @param end The end string
|
||||||
|
* @return The result string
|
||||||
|
*/
|
||||||
|
public static Optional<String> coolSubstring(String str, String start, String end) {
|
||||||
|
int a = str.indexOf(start) + start.length();
|
||||||
|
int b = str.indexOf(end, a);
|
||||||
|
return a != -1 && b != -1 ? Optional.of(str.substring(a, b)) : Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package buttondevteam.chat;
|
package buttondevteam.chat;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import buttondevteam.lib.TBMCChatEvent;
|
import buttondevteam.lib.TBMCChatEvent;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.minecraft.server.v1_12_R1.EntityHuman.EnumChatVisibility;
|
import net.minecraft.server.v1_12_R1.EntityHuman.EnumChatVisibility;
|
||||||
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class VanillaUtils {
|
public class VanillaUtils {
|
||||||
|
@ -15,4 +14,13 @@ public class VanillaUtils {
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*private String version;
|
||||||
|
|
||||||
|
public short getMCVersion() {
|
||||||
|
if (version != null) return version;
|
||||||
|
val v = ChatUtils.coolSubstring(Bukkit.getServer().getVersion().getClass().getPackage().getName(),
|
||||||
|
"org.bukkit.craftbukkit.v", "_R1").orElse("1_8").replace("_", "");
|
||||||
|
return Short.parseShort(v);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue