Undo the essentials stuff for now, look into it another day.

This commit is contained in:
Llm Dl committed 2021-04-28 07:44:57 -05:00
1 parent 5a1c9b6ced
commit c612e22eb0
6 files changed
+27 -45

No files matched your search

+1 -1
View File
@@ -7,7 +7,7 @@ website: http://towny.palmergames.com/towny/townychat/
description: >
TownyChat plugin which hooks into Towny.
depend: [Towny]
softdepend: [CraftIRC, PlaceholderAPI, dynmap, Essentials]
softdepend: [CraftIRC, PlaceholderAPI, dynmap]
############################################################
# +------------------------------------------------------+ #
+1 -13
View File
@@ -1,6 +1,5 @@
package com.palmergames.bukkit.TownyChat;
import com.earth2me.essentials.Essentials;
import com.palmergames.bukkit.TownyChat.Command.ChannelCommand;
import com.palmergames.bukkit.TownyChat.Command.TownyChatCommand;
import com.palmergames.bukkit.TownyChat.Command.commandobjects.ChannelJoinAliasCommand;
@@ -12,7 +11,6 @@ import com.palmergames.bukkit.TownyChat.listener.TownyChatPlayerListener;
import com.palmergames.bukkit.TownyChat.tasks.onLoadedTask;
import com.palmergames.bukkit.TownyChat.util.FileMgmt;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.exceptions.TownyException;
import com.palmergames.bukkit.util.Version;
import org.bukkit.Bukkit;
@@ -46,13 +44,11 @@ public class Chat extends JavaPlugin {
protected PluginManager pm;
private Towny towny = null;
private DynmapAPI dynMap = null;
private Essentials essentials = null;
private static Version requiredTownyVersion = Version.fromString("0.96.5.5");
public static boolean usingPlaceholderAPI = false;
boolean chatConfigError = false;
boolean channelsConfigError = false;
@Override
@@ -88,11 +84,6 @@ public class Chat extends JavaPlugin {
pm.disablePlugin(this);
return;
}
if (towny.isEssentials())
try {
essentials = towny.getEssentials();
} catch (TownyException ignored) {}
getCommand("townychat").setExecutor(new TownyChatCommand(this));
getCommand("channel").setExecutor(new ChannelCommand(this));
@@ -210,15 +201,12 @@ public class Chat extends JavaPlugin {
public Towny getTowny() {
return towny;
}
public DynmapAPI getDynmap() {
return dynMap;
}
public Essentials getEssentials() {
return essentials;
}
private void registerObjectCommands() {
List<Command> commands = new ArrayList<Command>();
for (Channel channel : channels.getAllChannels().values()) { // All channels
@@ -26,7 +26,7 @@ public abstract class Channel {
private boolean hooked=false;
private boolean autojoin=true;
private double spamtime;
private WeakHashMap<Player, Long> Spammers = new WeakHashMap<>();
private WeakHashMap<Player, Long> spammers = new WeakHashMap<>();
protected ConcurrentMap<String, Integer> absentPlayers = null;
protected ConcurrentMap<String, Integer> mutedPlayers = null;
@@ -270,19 +270,20 @@ public abstract class Channel {
long timeNow = System.currentTimeMillis();
long spam = timeNow;
if (Spammers.containsKey(player)) {
spam = Spammers.get(player);
Spammers.remove(player);
if (spammers.containsKey(player)) {
spam = spammers.get(player);
spammers.remove(player);
} else {
// No record found so ensure we don't trigger for spam
spam -= ((getSpam_time() + 1)*1000);
}
if (timeNow - spam < (getSpam_time()*1000)) {
Spammers.put(player, timeNow);
spammers.put(player, spam);
TownyMessaging.sendErrorMsg(player, Translation.of("tc_err_unable_to_talk_you_are_spamming"));
return true;
}
spammers.put(player, timeNow);
return false;
}
@@ -1,5 +1,6 @@
package com.palmergames.bukkit.TownyChat.channels;
import com.earth2me.essentials.User;
import com.palmergames.bukkit.TownyChat.Chat;
import com.palmergames.bukkit.TownyChat.HexFormatter;
import com.palmergames.bukkit.TownyChat.TownyChatFormatter;
@@ -7,11 +8,11 @@ import com.palmergames.bukkit.TownyChat.config.ChatSettings;
import com.palmergames.bukkit.TownyChat.events.AsyncChatHookEvent;
import com.palmergames.bukkit.TownyChat.events.PlayerJoinChatChannelEvent;
import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
import com.palmergames.bukkit.TownyChat.util.EssentialsUtil;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.exceptions.TownyException;
import com.palmergames.bukkit.towny.object.Nation;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
@@ -246,9 +247,12 @@ public class StandardChannel extends Channel {
* @param playerList
* @return Set containing a list of players for this message.
*/
@SuppressWarnings("deprecation")
private Set<Player> findRecipients(Player sender, List<Player> playerList) {
Set<Player> recipients = new HashSet<>();
Set<Player> recipients = new HashSet<>();
boolean bEssentials = plugin.getTowny().isEssentials();
String sendersName = sender.getName();
Channel channel = plugin.getChannelsHandler().getChannel(getName());
// Compile the list of recipients
for (Player player : playerList) {
@@ -269,11 +273,18 @@ public class StandardChannel extends Channel {
*/
if (testDistance(sender, player, getRange())){
/*
* Don't send anything if the player is ignoring the sender.
*/
if (plugin.getEssentials() != null && EssentialsUtil.isUserIgnoringUser(sender, player))
continue;
if (bEssentials) {
try {
User targetUser = plugin.getTowny().getEssentials().getUser(player);
/*
* Don't send this message if the user is ignored
*/
if (targetUser.isIgnoredPlayer(sendersName))
continue;
} catch (TownyException e) {
// Failed to fetch user so ignore.
}
}
// Spy's can leave channels and we'll respect that
if (absentPlayers != null) {
@@ -13,6 +13,7 @@ import com.palmergames.bukkit.towny.exceptions.TownyException;
import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Translation;
import com.palmergames.bukkit.towny.TownyUniverse;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@@ -1,19 +0,0 @@
package com.palmergames.bukkit.TownyChat.util;
import org.bukkit.entity.Player;
import com.palmergames.bukkit.TownyChat.Chat;
public class EssentialsUtil {
static Chat plugin;
public EssentialsUtil(Chat chat) {
plugin = chat;
}
public static boolean isUserIgnoringUser(Player sender, Player receiver) {
if (plugin.getEssentials().getUser(receiver).isIgnoredPlayer(plugin.getEssentials().getUser(sender)))
return true;
return false;
}
}