mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Update VentureChat to have distanceIsCube option to allow local chat to limit chat in the Y dimension.
This commit is contained in:
parent
fc0b1ddcd1
commit
7a416257ad
@ -306,6 +306,7 @@ channels:
|
||||
autojoin: true
|
||||
default: true
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: g
|
||||
@ -319,6 +320,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: st
|
||||
@ -332,6 +334,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: a
|
||||
@ -345,6 +348,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: d
|
||||
@ -358,6 +362,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: h
|
||||
@ -371,6 +376,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: t
|
||||
@ -384,6 +390,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 230
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: l
|
||||
@ -397,6 +404,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 60
|
||||
bungeecord: true
|
||||
alias: n
|
||||
|
@ -304,6 +304,7 @@ channels:
|
||||
autojoin: true
|
||||
default: true
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: g
|
||||
@ -317,6 +318,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: st
|
||||
@ -330,6 +332,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: a
|
||||
@ -343,6 +346,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: d
|
||||
@ -356,6 +360,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: h
|
||||
@ -369,6 +374,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: t
|
||||
@ -382,6 +388,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 230
|
||||
distanceIsCube: false
|
||||
cooldown: 0
|
||||
bungeecord: false
|
||||
alias: l
|
||||
@ -395,6 +402,7 @@ channels:
|
||||
autojoin: true
|
||||
default: false
|
||||
distance: 0
|
||||
distanceIsCube: false
|
||||
cooldown: 60
|
||||
bungeecord: true
|
||||
alias: n
|
||||
|
@ -43,6 +43,8 @@ public class VentureChatPlaceholders extends PlaceholderHook {
|
||||
return mcp.getCurrentChannel().getCooldown() + "";
|
||||
case "channel_distance":
|
||||
return mcp.getCurrentChannel().getDistance() + "";
|
||||
case "channel_distance_is_cube":
|
||||
return mcp.getCurrentChannel().getDistanceIsCube() ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -20,6 +20,7 @@ public class ChatChannel {
|
||||
private Boolean autojoin;
|
||||
private String alias;
|
||||
private Double distance;
|
||||
private Boolean distanceIsCube;
|
||||
private Boolean filter;
|
||||
private Boolean bungee;
|
||||
private String format;
|
||||
@ -41,6 +42,7 @@ public class ChatChannel {
|
||||
Boolean _defaultchannel = false;
|
||||
String _alias = "";
|
||||
Double _distance = (double) 0;
|
||||
Boolean _distanceIsCube = false;
|
||||
Boolean _autojoin = false;
|
||||
Boolean _bungee = false;
|
||||
String _format = "";
|
||||
@ -69,9 +71,10 @@ public class ChatChannel {
|
||||
_defaultchannel = (Boolean) cs.getBoolean(key + ".default", false);
|
||||
_alias = (String) cs.getString(key + ".alias", "None");
|
||||
_distance = (Double) cs.getDouble(key + ".distance", (double) 0);
|
||||
_distanceIsCube = (Boolean) cs.getBoolean(key + ".distanceIsCube", false);
|
||||
_cooldown = (int) cs.getInt(key + ".cooldown", 0);
|
||||
_autojoin = (Boolean) cs.getBoolean(key + ".autojoin", false);
|
||||
ChatChannel c = new ChatChannel(_name, _color, _chatcolor, _permission, _mutable, _filter, _defaultchannel, _alias, _distance, _autojoin, _bungee, _cooldown, _format);
|
||||
ChatChannel c = new ChatChannel(_name, _color, _chatcolor, _permission, _mutable, _filter, _defaultchannel, _alias, _distance, _distanceIsCube, _autojoin, _bungee, _cooldown, _format);
|
||||
channels[x++] = c;
|
||||
if(_defaultchannel) {
|
||||
defaultChatChannel = c;
|
||||
@ -115,7 +118,7 @@ public class ChatChannel {
|
||||
return joinlist;
|
||||
}
|
||||
|
||||
public ChatChannel(String _Name, String _color, String _chatcolor, String _Permission, Boolean _mutable, Boolean _filter, Boolean _defaultchannel, String _alias, Double _distance, Boolean _autojoin, Boolean _bungee, int _cooldown, String _format) {
|
||||
public ChatChannel(String _Name, String _color, String _chatcolor, String _Permission, Boolean _mutable, Boolean _filter, Boolean _defaultchannel, String _alias, Double _distance, Boolean _distanceIsCube, Boolean _autojoin, Boolean _bungee, int _cooldown, String _format) {
|
||||
name = _Name;
|
||||
permission = "venturechat." + _Permission;
|
||||
mutable = _mutable;
|
||||
@ -124,6 +127,7 @@ public class ChatChannel {
|
||||
setDefaultChannel(_defaultchannel);
|
||||
setAlias(_alias);
|
||||
setDistance(_distance);
|
||||
setDistanceIsCube(_distanceIsCube);
|
||||
setFilter(_filter);
|
||||
setAutojoin(_autojoin);
|
||||
setBungee(_bungee);
|
||||
@ -215,6 +219,10 @@ public class ChatChannel {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public void setDistanceIsCube(Boolean distanceIsCube) { this.distanceIsCube = distanceIsCube; }
|
||||
|
||||
public Boolean getDistanceIsCube() { return distanceIsCube; }
|
||||
|
||||
public Boolean hasDistance() {
|
||||
return distance > 0;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class Chwho extends MineverseCommand {
|
||||
}
|
||||
}
|
||||
if(channel.hasDistance() && sender instanceof Player) {
|
||||
if(!this.isPlayerWithinDistance((Player) sender, p.getPlayer(), channel.getDistance())) {
|
||||
if(!this.isPlayerWithinDistance((Player) sender, p.getPlayer(), channel.getDistance(), channel.getDistanceIsCube())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -203,8 +203,9 @@ public class Chwho extends MineverseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPlayerWithinDistance(Player p1, Player p2, double Distance) {
|
||||
private boolean isPlayerWithinDistance(Player p1, Player p2, double Distance, boolean DistanceIsCube) {
|
||||
Double chDistance = Distance;
|
||||
boolean chDistanceIsCube = DistanceIsCube;
|
||||
Location locreceip;
|
||||
Location locsender = p1.getLocation();
|
||||
Location diff;
|
||||
@ -212,7 +213,7 @@ public class Chwho extends MineverseCommand {
|
||||
locreceip = p2.getLocation();
|
||||
if(locreceip.getWorld() == p1.getWorld()) {
|
||||
diff = locreceip.subtract(locsender);
|
||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance) {
|
||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance || (chDistanceIsCube && Math.abs(diff.getY()) > chDistance)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1049,6 +1049,38 @@ public class Config extends MineverseCommand {
|
||||
break;
|
||||
}
|
||||
}
|
||||
case "distanceIsCube": {
|
||||
try {
|
||||
switch(args[3]) {
|
||||
case "true": {
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[1]).set("distanceIsCube", true);
|
||||
sender.sendMessage(ChatColor.GREEN + "distanceIsCube: has been set to true");
|
||||
plugin.saveConfig();
|
||||
plugin.reloadConfig();
|
||||
Bukkit.getPluginManager().disablePlugin(plugin);
|
||||
Bukkit.getPluginManager().enablePlugin(plugin);
|
||||
break;
|
||||
}
|
||||
case "false": {
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[1]).set("distanceIsCube", false);
|
||||
sender.sendMessage(ChatColor.GREEN + "distanceIsCube: has been set to false");
|
||||
plugin.saveConfig();
|
||||
plugin.reloadConfig();
|
||||
Bukkit.getPluginManager().disablePlugin(plugin);
|
||||
Bukkit.getPluginManager().enablePlugin(plugin);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels [channel] distanceIsCube [true/false]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
sender.sendMessage(ChatColor.GREEN + "distanceIsCube: " + plugin.getConfig().getConfigurationSection("channels." + args[1]).getBoolean("distanceIsCube"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "cooldown": {
|
||||
try {
|
||||
if(Integer.parseInt(args[3]) >= 0) {
|
||||
@ -1125,13 +1157,13 @@ public class Config extends MineverseCommand {
|
||||
}
|
||||
}
|
||||
default: {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels " + args[1] + " [color, chatcolor, mutable, alias, default, autojoin, distance, cooldown, bungeecord, format]");
|
||||
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels " + args[1] + " [color, chatcolor, mutable, alias, default, autojoin, distance, distanceIsCube, cooldown, bungeecord, format]");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels " + args[1] + " [color, chatcolor, mutable, alias, default, autojoin, distance, cooldown, bungeecord, format]");
|
||||
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels " + args[1] + " [color, chatcolor, mutable, alias, default, autojoin, distance, distanceIsCube, cooldown, bungeecord, format]");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1150,6 +1182,7 @@ public class Config extends MineverseCommand {
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[2]).set("default", false);
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[2]).set("autojoin", true);
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[2]).set("distance", 0.0);
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[2]).set("distanceIsCube", false);
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[2]).set("cooldown", 0);
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[2]).set("bungeecord", false);
|
||||
plugin.getConfig().getConfigurationSection("channels." + args[2]).set("servername", false);
|
||||
@ -1218,7 +1251,7 @@ public class Config extends MineverseCommand {
|
||||
sender.sendMessage(ChatColor.GREEN + "/config broadcastafk [true/false]");
|
||||
sender.sendMessage(ChatColor.GREEN + "/config formatcleaner [true/false]");
|
||||
sender.sendMessage(ChatColor.GREEN + "/config broadcast [color, permissions, displaytag]");
|
||||
sender.sendMessage(ChatColor.GREEN + "/config channels [channel] [chatcolor, mutable, permissions, alias, default, autojoin, distance, cooldown, bungeecord, format, create , delete]");
|
||||
sender.sendMessage(ChatColor.GREEN + "/config channels [channel] [chatcolor, mutable, permissions, alias, default, autojoin, distance, distanceIsCube, cooldown, bungeecord, format, create , delete]");
|
||||
sender.sendMessage(ChatColor.GREEN + "/config help");
|
||||
break;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
|
||||
// this event isn't always asynchronous even though the event's name starts with "Async"
|
||||
// blame md_5 for that one (•_•)
|
||||
// blame md_5 for that one (<EFBFBD>_<EFBFBD>)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) {
|
||||
event.setCancelled(true);
|
||||
@ -90,16 +90,16 @@ public class ChatListener implements Listener {
|
||||
mcp.setConversation(null);
|
||||
}
|
||||
else {
|
||||
if(tp.getIgnores().contains(mcp.getUUID())) {
|
||||
if(tp.getIgnores().contains(mcp.getUUID())) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.IGNORING_MESSAGE.toString()
|
||||
.replace("{player}", tp.getName()));
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(!tp.getMessageToggle()) {
|
||||
if(!tp.getMessageToggle()) {
|
||||
mcp.getPlayer().sendMessage(LocalizedMessage.BLOCKING_MESSAGE.toString()
|
||||
.replace("{player}", tp.getName()));
|
||||
event.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
String filtered = chat;
|
||||
@ -234,6 +234,7 @@ public class ChatListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Double chDistance = (double) 0;
|
||||
boolean chDistanceIsCube = false;
|
||||
int chCooldown = 0;
|
||||
String curColor = "";
|
||||
if(eventChannel.hasPermission() && !mcp.getPlayer().hasPermission(eventChannel.getPermission())) {
|
||||
@ -321,6 +322,7 @@ public class ChatListener implements Listener {
|
||||
|
||||
if(eventChannel.hasDistance()) {
|
||||
chDistance = eventChannel.getDistance();
|
||||
chDistanceIsCube = eventChannel.getDistanceIsCube();
|
||||
}
|
||||
|
||||
format = PlaceholderAPI.setBracketPlaceholders(mcp.getPlayer(), Format.FormatStringAll(plugin.getConfig().getConfigurationSection("channels." + eventChannel.getName()).getString("format")));
|
||||
@ -422,7 +424,7 @@ public class ChatListener implements Listener {
|
||||
locreceip = p.getPlayer().getLocation();
|
||||
if(locreceip.getWorld() == mcp.getPlayer().getWorld()) {
|
||||
diff = locreceip.subtract(locsender);
|
||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance) {
|
||||
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance || (chDistanceIsCube && Math.abs(diff.getY()) > chDistance)) {
|
||||
recipients.remove(p.getPlayer());
|
||||
recipientCount--;
|
||||
continue;
|
||||
@ -464,7 +466,7 @@ public class ChatListener implements Listener {
|
||||
|
||||
String globalJSON = Format.convertToJson(mcp, format, chat);
|
||||
String consoleChat = format + chat;
|
||||
String message = consoleChat.replaceAll("(§([a-z0-9]))", "");
|
||||
String message = consoleChat.replaceAll("(<EFBFBD>([a-z0-9]))", "");
|
||||
int hash = message.hashCode();
|
||||
|
||||
//Create VentureChatEvent
|
||||
|
Loading…
x
Reference in New Issue
Block a user