Revert most changes and make VentureChat distance always based on a cube shape.

This commit is contained in:
Joseph Warner 2020-06-22 16:19:02 -05:00
parent 7a416257ad
commit 31ddc0791c
7 changed files with 9 additions and 71 deletions

View File

@ -306,7 +306,6 @@ channels:
autojoin: true
default: true
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: g
@ -320,7 +319,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: st
@ -334,7 +332,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: a
@ -348,7 +345,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: d
@ -362,7 +358,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: h
@ -376,7 +371,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: t
@ -390,7 +384,6 @@ channels:
autojoin: true
default: false
distance: 230
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: l
@ -404,7 +397,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 60
bungeecord: true
alias: n

View File

@ -304,7 +304,6 @@ channels:
autojoin: true
default: true
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: g
@ -318,7 +317,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: st
@ -332,7 +330,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: a
@ -346,7 +343,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: d
@ -360,7 +356,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: h
@ -374,7 +369,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: t
@ -388,7 +382,6 @@ channels:
autojoin: true
default: false
distance: 230
distanceIsCube: false
cooldown: 0
bungeecord: false
alias: l
@ -402,7 +395,6 @@ channels:
autojoin: true
default: false
distance: 0
distanceIsCube: false
cooldown: 60
bungeecord: true
alias: n

View File

@ -43,8 +43,6 @@ 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;

View File

@ -20,7 +20,6 @@ public class ChatChannel {
private Boolean autojoin;
private String alias;
private Double distance;
private Boolean distanceIsCube;
private Boolean filter;
private Boolean bungee;
private String format;
@ -42,7 +41,6 @@ public class ChatChannel {
Boolean _defaultchannel = false;
String _alias = "";
Double _distance = (double) 0;
Boolean _distanceIsCube = false;
Boolean _autojoin = false;
Boolean _bungee = false;
String _format = "";
@ -71,10 +69,9 @@ 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, _distanceIsCube, _autojoin, _bungee, _cooldown, _format);
ChatChannel c = new ChatChannel(_name, _color, _chatcolor, _permission, _mutable, _filter, _defaultchannel, _alias, _distance, _autojoin, _bungee, _cooldown, _format);
channels[x++] = c;
if(_defaultchannel) {
defaultChatChannel = c;
@ -118,7 +115,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 _distanceIsCube, 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 _autojoin, Boolean _bungee, int _cooldown, String _format) {
name = _Name;
permission = "venturechat." + _Permission;
mutable = _mutable;
@ -127,7 +124,6 @@ public class ChatChannel {
setDefaultChannel(_defaultchannel);
setAlias(_alias);
setDistance(_distance);
setDistanceIsCube(_distanceIsCube);
setFilter(_filter);
setAutojoin(_autojoin);
setBungee(_bungee);
@ -219,10 +215,6 @@ 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;
}

View File

@ -72,7 +72,7 @@ public class Chwho extends MineverseCommand {
}
}
if(channel.hasDistance() && sender instanceof Player) {
if(!this.isPlayerWithinDistance((Player) sender, p.getPlayer(), channel.getDistance(), channel.getDistanceIsCube())) {
if(!this.isPlayerWithinDistance((Player) sender, p.getPlayer(), channel.getDistance())) {
continue;
}
}
@ -203,9 +203,8 @@ public class Chwho extends MineverseCommand {
}
}
private boolean isPlayerWithinDistance(Player p1, Player p2, double Distance, boolean DistanceIsCube) {
private boolean isPlayerWithinDistance(Player p1, Player p2, double Distance) {
Double chDistance = Distance;
boolean chDistanceIsCube = DistanceIsCube;
Location locreceip;
Location locsender = p1.getLocation();
Location diff;
@ -213,7 +212,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 || (chDistanceIsCube && Math.abs(diff.getY()) > chDistance)) {
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance || Math.abs(diff.getY()) > chDistance) {
return false;
}
}

View File

@ -1049,38 +1049,6 @@ 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) {
@ -1157,13 +1125,13 @@ public class Config extends MineverseCommand {
}
}
default: {
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels " + args[1] + " [color, chatcolor, mutable, alias, default, autojoin, distance, distanceIsCube, cooldown, bungeecord, format]");
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels " + args[1] + " [color, chatcolor, mutable, alias, default, autojoin, distance, cooldown, bungeecord, format]");
break;
}
}
}
catch(Exception e) {
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels " + args[1] + " [color, chatcolor, mutable, alias, default, autojoin, distance, distanceIsCube, cooldown, bungeecord, format]");
sender.sendMessage(ChatColor.RED + "Invalid arguments, /config channels " + args[1] + " [color, chatcolor, mutable, alias, default, autojoin, distance, cooldown, bungeecord, format]");
}
break;
}
@ -1182,7 +1150,6 @@ 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);
@ -1251,7 +1218,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, distanceIsCube, cooldown, bungeecord, format, create , delete]");
sender.sendMessage(ChatColor.GREEN + "/config channels [channel] [chatcolor, mutable, permissions, alias, default, autojoin, distance, cooldown, bungeecord, format, create , delete]");
sender.sendMessage(ChatColor.GREEN + "/config help");
break;
}

View File

@ -234,7 +234,6 @@ 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())) {
@ -322,7 +321,6 @@ 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")));
@ -424,7 +422,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 || (chDistanceIsCube && Math.abs(diff.getY()) > chDistance)) {
if(Math.abs(diff.getX()) > chDistance || Math.abs(diff.getZ()) > chDistance || Math.abs(diff.getY()) > chDistance) {
recipients.remove(p.getPlayer());
recipientCount--;
continue;