mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-04 14:38:58 +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>
|
<groupId>com.palmergames.bukkit</groupId>
|
||||||
<artifactId>TownyChat</artifactId>
|
<artifactId>TownyChat</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>0.99</version>
|
<version>0.100</version>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<name>GitHub TownyAdvanced Apache Maven Packages</name>
|
<name>GitHub TownyAdvanced Apache Maven Packages</name>
|
||||||
<url>https://maven.pkg.github.com/TownyAdvanced</url>
|
<url>https://maven.pkg.github.com/TownyAdvanced</url>
|
||||||
</repository>
|
</repository>
|
||||||
</distributionManagement>
|
</distributionManagement>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:https://github.com/TownyAdvanced/TownyChat.git</connection>
|
<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.
|
- 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.
|
- 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.
|
- 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;
|
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;
|
||||||
@@ -52,6 +53,7 @@ public class Chat extends JavaPlugin {
|
|||||||
private static Chat chat = null;
|
private static Chat chat = null;
|
||||||
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.98.4.0");
|
private static Version requiredTownyVersion = Version.fromString("0.98.4.0");
|
||||||
public static boolean usingPlaceholderAPI = false;
|
public static boolean usingPlaceholderAPI = false;
|
||||||
@@ -168,6 +170,11 @@ public class Chat extends JavaPlugin {
|
|||||||
usingEssentialsDiscord = true;
|
usingEssentialsDiscord = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test = pm.getPlugin("Essentials");
|
||||||
|
if (test != null) {
|
||||||
|
this.essentials = (Essentials) test;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerEvents() {
|
public void registerEvents() {
|
||||||
@@ -241,8 +248,22 @@ public class Chat extends JavaPlugin {
|
|||||||
return dynMap;
|
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) {
|
public boolean isIgnoredByEssentials(Player sender, Player player) {
|
||||||
if (!getTowny().isEssentials())
|
if (!isUsingEssentials())
|
||||||
return false;
|
return false;
|
||||||
return EssentialsIntegration.ignoredByEssentials(sender, player);
|
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.TownyChat.config.ChatSettings;
|
||||||
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.TownyException;
|
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
import com.palmergames.bukkit.towny.object.Translatable;
|
import com.palmergames.bukkit.towny.object.Translatable;
|
||||||
import com.palmergames.bukkit.towny.object.metadata.StringDataField;
|
import com.palmergames.bukkit.towny.object.metadata.StringDataField;
|
||||||
@@ -172,16 +171,10 @@ public class TownyChatPlayerListener implements Listener {
|
|||||||
* @return true if muted by Essentials.
|
* @return true if muted by Essentials.
|
||||||
*/
|
*/
|
||||||
private boolean isEssentialsMuted(Player player) {
|
private boolean isEssentialsMuted(Player player) {
|
||||||
if (!plugin.getTowny().isEssentials())
|
// Check if essentials has this player muted.
|
||||||
return false;
|
if (plugin.isEssentialsMuted(player)) {
|
||||||
try {
|
TownyMessaging.sendErrorMsg(player, Translatable.of("tc_err_unable_to_talk_essentials_mute"));
|
||||||
// Check if essentials has this player muted.
|
return true;
|
||||||
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
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,17 @@ package com.palmergames.bukkit.TownyChat.util;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.TownyChat.Chat;
|
||||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
|
||||||
|
|
||||||
public class EssentialsIntegration {
|
public class EssentialsIntegration {
|
||||||
|
|
||||||
public static boolean ignoredByEssentials(Player sender, Player player) {
|
public static boolean ignoredByEssentials(Player sender, Player player) {
|
||||||
try {
|
com.earth2me.essentials.User targetUser = Chat.getTownyChat().getEssentials().getUser(player);
|
||||||
com.earth2me.essentials.User targetUser = Towny.getPlugin().getEssentials().getUser(player);
|
com.earth2me.essentials.User senderUser = Chat.getTownyChat().getEssentials().getUser(sender);
|
||||||
com.earth2me.essentials.User senderUser = Towny.getPlugin().getEssentials().getUser(sender);
|
return targetUser.isIgnoredPlayer(senderUser);
|
||||||
return targetUser.isIgnoredPlayer(senderUser);
|
}
|
||||||
} catch (TownyException ignored) {
|
|
||||||
// Failed to fetch user so ignore.
|
public static boolean isMuted(Player player) {
|
||||||
}
|
return Chat.getTownyChat().getEssentials().getUser(player).isMuted();
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user