Skip to content

Commit 033b062

Browse files
added compatibility with SuperVanish and PremiumVanish
1 parent 9e2091b commit 033b062

File tree

10 files changed

+108
-30
lines changed

10 files changed

+108
-30
lines changed

CustomJoinAndQuitMessagesOld/CustomJoinAndQuitMessagesOld.iml

+1
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,6 @@
8989
<orderEntry type="library" scope="PROVIDED" name="Maven: net.essentialsx:EssentialsXDiscord:2.19.0" level="project" />
9090
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:discord-webhooks:0.5.6" level="project" />
9191
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
92+
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.LeonMangler:SuperVanish:6.2.6-4" level="project" />
9293
</component>
9394
</module>

CustomJoinAndQuitMessagesOld/pom.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010

1111
<artifactId>CustomJoinAndQuitMessagesOld</artifactId>
12-
<version>1.8.0-release</version>
12+
<version>1.7.8-release</version>
1313

1414
<properties>
1515
<java.version>8</java.version>
@@ -227,6 +227,12 @@
227227
<artifactId>commons-lang3</artifactId>
228228
<version>3.12.0</version>
229229
</dependency>
230+
<dependency>
231+
<groupId>com.github.LeonMangler</groupId>
232+
<artifactId>SuperVanish</artifactId>
233+
<version>6.2.6-4</version>
234+
<scope>provided</scope>
235+
</dependency>
230236
</dependencies>
231237

232238
</project>

CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/config/utils/FileLister.java

-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@
88
import java.io.FilenameFilter;
99
import java.io.IOException;
1010
import java.lang.reflect.Method;
11-
import java.nio.file.DirectoryStream;
12-
import java.nio.file.Files;
13-
import java.nio.file.Path;
1411
import java.util.ArrayList;
1512
import java.util.Enumeration;
1613
import java.util.List;
1714
import java.util.Objects;
1815
import java.util.jar.JarEntry;
1916
import java.util.jar.JarFile;
20-
import java.util.regex.Pattern;
2117

2218

2319
public class FileLister {
@@ -137,7 +133,6 @@ public List<String> list() throws IOException {
137133
}
138134
jar.close();
139135

140-
141136
Logger.debug("List of available languages");
142137
for (String s : result){
143138
Logger.debug(" * " + s);

CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/config/utils/PreConfigLoader.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void loadConfig() {
2525

2626
//Other
2727
Settings.settings_debug = config.getBoolean("Config.Debug");
28-
Settings.update = Objects.equals(config.getString("Config.Update"), "true");
28+
Settings.update = Objects.equals(config.getString("Config.Update.Enabled"), "true");
2929
Settings.c_type = config.getString("Config.Type");
3030
Settings.is_Group_Display = Objects.requireNonNull(config.getString("Config.Type")).equalsIgnoreCase("group");
3131

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package jss.customjoinandquitmessages.hook;
2+
3+
import de.myzelyam.api.vanish.VanishAPI;
4+
import jss.customjoinandquitmessages.utils.EventUtils;
5+
import jss.customjoinandquitmessages.utils.Logger;
6+
import jss.customjoinandquitmessages.utils.Util;
7+
import jss.customjoinandquitmessages.utils.interfaces.IHook;
8+
import org.bukkit.Bukkit;
9+
import org.bukkit.entity.Player;
10+
11+
public class SuperVanishHook implements IHook {
12+
13+
private boolean isEnabled;
14+
15+
public void setup() {
16+
if (!Bukkit.getPluginManager().isPluginEnabled("SuperVanish") || !Bukkit.getPluginManager().isPluginEnabled("PremiumVanish")) {
17+
Logger.warning("&eSuperVanish or PremiumVanish not enabled! - Disable Features...");
18+
this.isEnabled = false;
19+
return;
20+
}
21+
22+
this.isEnabled = true;
23+
Util.sendColorMessage(EventUtils.getStaticConsoleSender(), Util.getPrefix(true) + "&aLoading SuperVanish or PremiumVanish features...");
24+
25+
}
26+
27+
public boolean isEnabled() {
28+
return isEnabled;
29+
}
30+
31+
public boolean isVanishPlayer(Player player){
32+
return VanishAPI.isInvisible(player);
33+
}
34+
}

CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/listener/JoinListener.java

+33-9
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
import com.cryptomorin.xseries.messages.Titles;
55
import github.scarsz.discordsrv.util.DiscordUtil;
66
import jss.customjoinandquitmessages.CustomJoinAndQuitMessages;
7-
import jss.customjoinandquitmessages.hook.DiscordSRVHHook;
8-
import jss.customjoinandquitmessages.hook.EssentialsXDiscordHook;
9-
import jss.customjoinandquitmessages.hook.EssentialsXHook;
10-
import jss.customjoinandquitmessages.hook.LuckPermsHook;
7+
import jss.customjoinandquitmessages.hook.*;
118
import jss.customjoinandquitmessages.json.MessageBuilder;
129
import jss.customjoinandquitmessages.manager.HookManager;
1310
import jss.customjoinandquitmessages.manager.PlayerManager;
@@ -48,6 +45,7 @@ public void onJoinListener(@NotNull PlayerJoinEvent e) {
4845
LuckPermsHook luckPermsHook = HookManager.getInstance().getLuckPermsHook();
4946
EssentialsXDiscordHook essentialsXDiscordHook = HookManager.getInstance().getEssentialsXDiscordHook();
5047
EssentialsXHook essentialsXHook = HookManager.get().getEssentialsXHook();
48+
SuperVanishHook superVanishHook = HookManager.get().getSuperVanishHook();
5149
Player p = e.getPlayer();
5250
String tempGroup;
5351

@@ -92,6 +90,18 @@ public void onJoinListener(@NotNull PlayerJoinEvent e) {
9290
Util.sendColorMessage(p, Util.getVar(p, text));
9391
}
9492

93+
if(Util.isVanished(p)){
94+
e.setJoinMessage(null);
95+
return;
96+
}
97+
98+
if (superVanishHook.isEnabled()){
99+
if (superVanishHook.isVanishPlayer(p)){
100+
e.setJoinMessage(null);
101+
return;
102+
}
103+
}
104+
95105
if (essentialsXHook.isEnabled()) {
96106
if (Settings.hook_essentials_hideplayervanish) {
97107
if (essentialsXHook.isVanish(p)) {
@@ -168,7 +178,7 @@ public void onJoinListener(@NotNull PlayerJoinEvent e) {
168178
String Action_Url = config.getString("Join.ClickEvent.Actions.Url");
169179
String Action_Suggest = config.getString("Join.ClickEvent.Actions.Suggest-Command");
170180

171-
List<String> Action_Dev = config.getStringList("Join.ClickEvent.DevActions");
181+
//List<String> Action_Dev = config.getStringList("Join.ClickEvent.DevActions");
172182

173183
String Title_Text = config.getString("Join.Title.Title");
174184
String SubTitle_Text = config.getString("Join.Title.SubTitle");
@@ -199,7 +209,7 @@ public void onJoinListener(@NotNull PlayerJoinEvent e) {
199209

200210
if (isClick) {
201211

202-
for(String action : Action_Dev){
212+
/*for(String action : Action_Dev){
203213
204214
String[] parts = action.split(":");
205215
String type = parts[0].trim();
@@ -220,9 +230,8 @@ public void onJoinListener(@NotNull PlayerJoinEvent e) {
220230
break;
221231
}
222232
}
223-
messageBuilder.sendToAll();
233+
messageBuilder.sendToAll();*/
224234

225-
/** Temp Disabled
226235
assert isClick_Mode != null;
227236
if (isClick_Mode.equalsIgnoreCase("command")) {
228237
messageBuilder.setExecuteCommand(Action_Command).sendToAll();
@@ -231,7 +240,7 @@ public void onJoinListener(@NotNull PlayerJoinEvent e) {
231240
} else if (isClick_Mode.equalsIgnoreCase("suggest")) {
232241
messageBuilder.setSuggestCommand(Action_Suggest).sendToAll();
233242
}
234-
*/
243+
235244

236245
} else {
237246
messageBuilder.sendToAll();
@@ -300,12 +309,25 @@ public void onQuit(@NotNull PlayerQuitEvent e) {
300309
DiscordSRVHHook discordSRVHHook = HookManager.getInstance().getDiscordSRVHHook();
301310
EssentialsXDiscordHook essentialsXDiscordHook = HookManager.getInstance().getEssentialsXDiscordHook();
302311
EssentialsXHook essentialsXHook = HookManager.get().getEssentialsXHook();
312+
SuperVanishHook superVanishHook = HookManager.get().getSuperVanishHook();
303313
PlayerManager playerManager = new PlayerManager();
304314

305315
boolean isNormal = Settings.c_type.equalsIgnoreCase("normal");
306316
boolean isGroup = Settings.c_type.equalsIgnoreCase("group");
307317
boolean isNone = Settings.c_type.equalsIgnoreCase("none");
308318

319+
if(Util.isVanished(p)){
320+
e.setQuitMessage(null);
321+
return;
322+
}
323+
324+
if (superVanishHook.isEnabled()){
325+
if (superVanishHook.isVanishPlayer(p)){
326+
e.setQuitMessage(null);
327+
return;
328+
}
329+
}
330+
309331
if (essentialsXHook.isEnabled()) {
310332
if (Settings.hook_essentials_hideplayervanish) {
311333
if (essentialsXHook.isVanish(p)) {
@@ -443,4 +465,6 @@ public void onQuit(@NotNull PlayerQuitEvent e) {
443465
}
444466
}
445467

468+
469+
446470
}

CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/manager/HookManager.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class HookManager {
1111
private final EssentialsXDiscordHook essentialsXDiscordHook = new EssentialsXDiscordHook(this);
1212
private final EssentialsXHook essentialsXHook = new EssentialsXHook(this);
1313
private final LuckPermsHook luckPermsHook = new LuckPermsHook();
14+
private final SuperVanishHook superVanishHook = new SuperVanishHook();
1415

1516
public HookManager() {
1617
instance = this;
@@ -26,10 +27,11 @@ public static HookManager get() {
2627

2728
public void load() {
2829
initHooks(new PlaceholderApiHook(this),
29-
new DiscordSRVHHook(this),
30-
new EssentialsXDiscordHook(this),
31-
new EssentialsXHook(this),
32-
luckPermsHook);
30+
discordSRVHHook,
31+
essentialsXDiscordHook,
32+
essentialsXHook,
33+
luckPermsHook,
34+
superVanishHook);
3335
}
3436

3537
private void initHooks(IHook @NotNull ... hooks) {
@@ -53,4 +55,8 @@ public EssentialsXHook getEssentialsXHook() {
5355
public LuckPermsHook getLuckPermsHook() {
5456
return luckPermsHook;
5557
}
58+
59+
public SuperVanishHook getSuperVanishHook() {
60+
return superVanishHook;
61+
}
5662
}

CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.bukkit.Bukkit;
99
import org.bukkit.command.CommandSender;
1010
import org.bukkit.entity.Player;
11+
import org.bukkit.metadata.MetadataValue;
1112
import org.jetbrains.annotations.Contract;
1213
import org.jetbrains.annotations.NotNull;
1314
import org.jetbrains.annotations.Nullable;
@@ -169,6 +170,7 @@ public static void setDisabled(String version) {
169170
sendEnable(prefix, "&5 <||============================================----");
170171
}
171172

173+
@SuppressWarnings("unused")
172174
public static boolean setPerm(@NotNull Player player, String permName){
173175
return player.hasPermission(PERMISSION_PREFIX + permName);
174176
}
@@ -181,4 +183,11 @@ public static void createFolder(@NotNull CustomJoinAndQuitMessages plugin, Strin
181183
}
182184
}
183185

186+
public static boolean isVanished(@NotNull Player player) {
187+
for (MetadataValue meta : player.getMetadata("vanished")) {
188+
if (meta.asBoolean()) return true;
189+
}
190+
return false;
191+
}
192+
184193
}

CustomJoinAndQuitMessagesOld/src/main/resources/config.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ Config:
2222
# |Enabled| Here you can enable or disable this feature
2323
Enabled: true
2424

25+
# !!This feature is not available yet!!
2526
# |GetUpdateFrom| you will get the updates from [spigot | github] what is the difference, here below is the explanation of why
2627
# |Spigot| Get only released updates, and you won't receive beta notifications
2728
# |GitHub| Get only the released and beta updates, and you will be able to receive notifications of both versions
2829
GetUpdateFrom: Spigot
2930

3031
# |Debug| shows you important information about the plugin loading
31-
Debug: true
32+
Debug: false
3233

3334
# |Type| the type is a way of knowing what is being used whether in the [normal] | [group] | [none] format
3435
Type: normal
@@ -127,7 +128,13 @@ Join:
127128

128129
# |Mode| there are three different modes which are [ command | suggest | url ]
129130
Mode: command
130-
131+
132+
# This feature is not available yet
133+
DevActions:
134+
- '[Suggest]: /help'
135+
- '[Execute]: /me hello test'
136+
- '[Open]: https://www.spigotmc.org/resources/custom-join-and-quit-message-1-7-x-1-17-x.57006/'
137+
131138
# |Actions| This is where are the available events that you can use
132139
Actions:
133140

@@ -222,11 +229,6 @@ Quit:
222229
# |Mode| there are three different modes which are [ command | suggest | url ]
223230
Mode: command
224231

225-
DevActions:
226-
- '[Suggest]: /help'
227-
- '[Execute]: /me hola test'
228-
- '[Open]: https://www.spigotmc.org/resources/custom-join-and-quit-message-1-7-x-1-17-x.57006/'
229-
230232
# |Actions| This is where are the available events that you can use
231233
Actions:
232234

CustomJoinAndQuitMessagesOld/src/main/resources/plugin.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ loadbefore: [ Essentials ]
99
softdepend: [
1010
PlaceholderAPI, DiscordSRV,
1111
LuckPerms, EssentialsDiscord,
12-
Essentials
12+
Essentials, SuperVanish,
13+
PremiumVanish
1314
]
1415

1516
commands:
@@ -18,15 +19,15 @@ commands:
1819
aliases:
1920
- cjm
2021
permissions:
21-
cjm.Admin:
22+
cjm.admin:
2223
description: give the all permissions
2324
children:
2425
cjm.update: true
2526
cjm.command.reload: true
2627
cjm.command.help: true
2728
cjm.command.tabcomplete: true
2829
default: op
29-
cjm.Update:
30+
cjm.update:
3031
description: allows you to receive notifications of available updates
3132
default: op
3233
cjm.command.reload:

0 commit comments

Comments
 (0)