mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-02 22:23:18 +00:00
Use internal Essentials instance.
Drops the usage of Towny's Essentials instance.
This commit is contained in:
1 parent
be073a1c49
commit
7b932e2310
5 files changed
+39
-25
No files matched your search
@@ -7,7 +7,7 @@
|
||||
<groupId>com.palmergames.bukkit</groupId>
|
||||
<artifactId>TownyChat</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.99</version>
|
||||
<version>0.100</version>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
@@ -35,7 +35,7 @@
|
||||
<name>GitHub TownyAdvanced Apache Maven Packages</name>
|
||||
<url>https://maven.pkg.github.com/TownyAdvanced</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</distributionManagement>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://github.com/TownyAdvanced/TownyChat.git</connection>
|
||||
|
||||
@@ -429,4 +429,6 @@ v0.99:
|
||||
- Make TownyChat better able to handle broken PAPI placeholders that won't parse.
|
||||
- On the off chance you have put unparse-able placeholders into your chatconfig.yml you will be made aware of them in your log.
|
||||
- This new system should be able to let TownyChat format your chat properly when this occurs.
|
||||
- Update min. Towny version to 0.98.4.0.
|
||||
- Update min. Towny version to 0.98.4.0.
|
||||
v0.100:
|
||||
- Use internal Essentials object instead of the one found in Towny.
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -52,6 +53,7 @@ public class Chat extends JavaPlugin {
|
||||
private static Chat chat = null;
|
||||
private Towny towny = null;
|
||||
private DynmapAPI dynMap = null;
|
||||
private Essentials essentials = null;
|
||||
|
||||
private static Version requiredTownyVersion = Version.fromString("0.98.4.0");
|
||||
public static boolean usingPlaceholderAPI = false;
|
||||
@@ -168,6 +170,11 @@ public class Chat extends JavaPlugin {
|
||||
usingEssentialsDiscord = true;
|
||||
}
|
||||
|
||||
test = pm.getPlugin("Essentials");
|
||||
if (test != null) {
|
||||
this.essentials = (Essentials) test;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void registerEvents() {
|
||||
@@ -241,8 +248,22 @@ public class Chat extends JavaPlugin {
|
||||
return dynMap;
|
||||
}
|
||||
|
||||
public boolean isUsingEssentials() {
|
||||
return essentials != null;
|
||||
}
|
||||
|
||||
public Essentials getEssentials() {
|
||||
return essentials;
|
||||
}
|
||||
|
||||
public boolean isEssentialsMuted(Player player) {
|
||||
if (!isUsingEssentials())
|
||||
return false;
|
||||
return EssentialsIntegration.isMuted(player);
|
||||
}
|
||||
|
||||
public boolean isIgnoredByEssentials(Player sender, Player player) {
|
||||
if (!getTowny().isEssentials())
|
||||
if (!isUsingEssentials())
|
||||
return false;
|
||||
return EssentialsIntegration.ignoredByEssentials(sender, player);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.palmergames.bukkit.TownyChat.channels.channelTypes;
|
||||
import com.palmergames.bukkit.TownyChat.config.ChatSettings;
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Translatable;
|
||||
import com.palmergames.bukkit.towny.object.metadata.StringDataField;
|
||||
@@ -172,16 +171,10 @@ public class TownyChatPlayerListener implements Listener {
|
||||
* @return true if muted by Essentials.
|
||||
*/
|
||||
private boolean isEssentialsMuted(Player player) {
|
||||
if (!plugin.getTowny().isEssentials())
|
||||
return false;
|
||||
try {
|
||||
// Check if essentials has this player muted.
|
||||
if (plugin.getTowny().getEssentials().getUser(player).isMuted()) {
|
||||
TownyMessaging.sendErrorMsg(player, Translatable.of("tc_err_unable_to_talk_essentials_mute"));
|
||||
return true;
|
||||
}
|
||||
} catch (TownyException e) {
|
||||
// Get essentials failed
|
||||
// Check if essentials has this player muted.
|
||||
if (plugin.isEssentialsMuted(player)) {
|
||||
TownyMessaging.sendErrorMsg(player, Translatable.of("tc_err_unable_to_talk_essentials_mute"));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2,19 +2,17 @@ package com.palmergames.bukkit.TownyChat.util;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
||||
import com.palmergames.bukkit.TownyChat.Chat;
|
||||
|
||||
public class EssentialsIntegration {
|
||||
|
||||
public static boolean ignoredByEssentials(Player sender, Player player) {
|
||||
try {
|
||||
com.earth2me.essentials.User targetUser = Towny.getPlugin().getEssentials().getUser(player);
|
||||
com.earth2me.essentials.User senderUser = Towny.getPlugin().getEssentials().getUser(sender);
|
||||
return targetUser.isIgnoredPlayer(senderUser);
|
||||
} catch (TownyException ignored) {
|
||||
// Failed to fetch user so ignore.
|
||||
}
|
||||
return false;
|
||||
com.earth2me.essentials.User targetUser = Chat.getTownyChat().getEssentials().getUser(player);
|
||||
com.earth2me.essentials.User senderUser = Chat.getTownyChat().getEssentials().getUser(sender);
|
||||
return targetUser.isIgnoredPlayer(senderUser);
|
||||
}
|
||||
|
||||
public static boolean isMuted(Player player) {
|
||||
return Chat.getTownyChat().getEssentials().getUser(player).isMuted();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user