mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-03 22:21:20 +00:00
Undo the essentials stuff for now, look into it another day.
This commit is contained in:
1 parent
5a1c9b6ced
commit
c612e22eb0
6 files changed
+26
-44
No files matched your search
@@ -7,7 +7,7 @@ website: http://towny.palmergames.com/towny/townychat/
|
|||||||
description: >
|
description: >
|
||||||
TownyChat plugin which hooks into Towny.
|
TownyChat plugin which hooks into Towny.
|
||||||
depend: [Towny]
|
depend: [Towny]
|
||||||
softdepend: [CraftIRC, PlaceholderAPI, dynmap, Essentials]
|
softdepend: [CraftIRC, PlaceholderAPI, dynmap]
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.palmergames.bukkit.TownyChat;
|
package com.palmergames.bukkit.TownyChat;
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
|
||||||
import com.palmergames.bukkit.TownyChat.Command.ChannelCommand;
|
import com.palmergames.bukkit.TownyChat.Command.ChannelCommand;
|
||||||
import com.palmergames.bukkit.TownyChat.Command.TownyChatCommand;
|
import com.palmergames.bukkit.TownyChat.Command.TownyChatCommand;
|
||||||
import com.palmergames.bukkit.TownyChat.Command.commandobjects.ChannelJoinAliasCommand;
|
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.tasks.onLoadedTask;
|
||||||
import com.palmergames.bukkit.TownyChat.util.FileMgmt;
|
import com.palmergames.bukkit.TownyChat.util.FileMgmt;
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
|
||||||
import com.palmergames.bukkit.util.Version;
|
import com.palmergames.bukkit.util.Version;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@@ -46,7 +44,6 @@ public class Chat extends JavaPlugin {
|
|||||||
protected PluginManager pm;
|
protected PluginManager pm;
|
||||||
private Towny towny = null;
|
private Towny towny = null;
|
||||||
private DynmapAPI dynMap = null;
|
private DynmapAPI dynMap = null;
|
||||||
private Essentials essentials = null;
|
|
||||||
|
|
||||||
private static Version requiredTownyVersion = Version.fromString("0.96.5.5");
|
private static Version requiredTownyVersion = Version.fromString("0.96.5.5");
|
||||||
public static boolean usingPlaceholderAPI = false;
|
public static boolean usingPlaceholderAPI = false;
|
||||||
@@ -54,7 +51,6 @@ public class Chat extends JavaPlugin {
|
|||||||
boolean channelsConfigError = false;
|
boolean channelsConfigError = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
@@ -89,11 +85,6 @@ public class Chat extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (towny.isEssentials())
|
|
||||||
try {
|
|
||||||
essentials = towny.getEssentials();
|
|
||||||
} catch (TownyException ignored) {}
|
|
||||||
|
|
||||||
getCommand("townychat").setExecutor(new TownyChatCommand(this));
|
getCommand("townychat").setExecutor(new TownyChatCommand(this));
|
||||||
getCommand("channel").setExecutor(new ChannelCommand(this));
|
getCommand("channel").setExecutor(new ChannelCommand(this));
|
||||||
registerObjectCommands();
|
registerObjectCommands();
|
||||||
@@ -211,14 +202,11 @@ public class Chat extends JavaPlugin {
|
|||||||
return towny;
|
return towny;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DynmapAPI getDynmap() {
|
public DynmapAPI getDynmap() {
|
||||||
return dynMap;
|
return dynMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Essentials getEssentials() {
|
|
||||||
return essentials;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerObjectCommands() {
|
private void registerObjectCommands() {
|
||||||
List<Command> commands = new ArrayList<Command>();
|
List<Command> commands = new ArrayList<Command>();
|
||||||
for (Channel channel : channels.getAllChannels().values()) { // All channels
|
for (Channel channel : channels.getAllChannels().values()) { // All channels
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public abstract class Channel {
|
|||||||
private boolean hooked=false;
|
private boolean hooked=false;
|
||||||
private boolean autojoin=true;
|
private boolean autojoin=true;
|
||||||
private double spamtime;
|
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> absentPlayers = null;
|
||||||
protected ConcurrentMap<String, Integer> mutedPlayers = null;
|
protected ConcurrentMap<String, Integer> mutedPlayers = null;
|
||||||
|
|
||||||
@@ -270,19 +270,20 @@ public abstract class Channel {
|
|||||||
long timeNow = System.currentTimeMillis();
|
long timeNow = System.currentTimeMillis();
|
||||||
long spam = timeNow;
|
long spam = timeNow;
|
||||||
|
|
||||||
if (Spammers.containsKey(player)) {
|
if (spammers.containsKey(player)) {
|
||||||
spam = Spammers.get(player);
|
spam = spammers.get(player);
|
||||||
Spammers.remove(player);
|
spammers.remove(player);
|
||||||
} else {
|
} else {
|
||||||
// No record found so ensure we don't trigger for spam
|
// No record found so ensure we don't trigger for spam
|
||||||
spam -= ((getSpam_time() + 1)*1000);
|
spam -= ((getSpam_time() + 1)*1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeNow - spam < (getSpam_time()*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"));
|
TownyMessaging.sendErrorMsg(player, Translation.of("tc_err_unable_to_talk_you_are_spamming"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
spammers.put(player, timeNow);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.palmergames.bukkit.TownyChat.channels;
|
package com.palmergames.bukkit.TownyChat.channels;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
import com.palmergames.bukkit.TownyChat.Chat;
|
import com.palmergames.bukkit.TownyChat.Chat;
|
||||||
import com.palmergames.bukkit.TownyChat.HexFormatter;
|
import com.palmergames.bukkit.TownyChat.HexFormatter;
|
||||||
import com.palmergames.bukkit.TownyChat.TownyChatFormatter;
|
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.AsyncChatHookEvent;
|
||||||
import com.palmergames.bukkit.TownyChat.events.PlayerJoinChatChannelEvent;
|
import com.palmergames.bukkit.TownyChat.events.PlayerJoinChatChannelEvent;
|
||||||
import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
|
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.Towny;
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
import com.palmergames.bukkit.towny.TownyMessaging;
|
||||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
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.Nation;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
@@ -246,9 +247,12 @@ public class StandardChannel extends Channel {
|
|||||||
* @param playerList
|
* @param playerList
|
||||||
* @return Set containing a list of players for this message.
|
* @return Set containing a list of players for this message.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
private Set<Player> findRecipients(Player sender, List<Player> playerList) {
|
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());
|
Channel channel = plugin.getChannelsHandler().getChannel(getName());
|
||||||
// Compile the list of recipients
|
// Compile the list of recipients
|
||||||
for (Player player : playerList) {
|
for (Player player : playerList) {
|
||||||
@@ -269,11 +273,18 @@ public class StandardChannel extends Channel {
|
|||||||
*/
|
*/
|
||||||
if (testDistance(sender, player, getRange())){
|
if (testDistance(sender, player, getRange())){
|
||||||
|
|
||||||
/*
|
if (bEssentials) {
|
||||||
* Don't send anything if the player is ignoring the sender.
|
try {
|
||||||
*/
|
User targetUser = plugin.getTowny().getEssentials().getUser(player);
|
||||||
if (plugin.getEssentials() != null && EssentialsUtil.isUserIgnoringUser(sender, player))
|
/*
|
||||||
continue;
|
* 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
|
// Spy's can leave channels and we'll respect that
|
||||||
if (absentPlayers != null) {
|
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.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.Translation;
|
import com.palmergames.bukkit.towny.object.Translation;
|
||||||
import com.palmergames.bukkit.towny.TownyUniverse;
|
import com.palmergames.bukkit.towny.TownyUniverse;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user