Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pl3xmap hook #731

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>modrinth</id>
<url>https://api.modrinth.com/maven/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -122,6 +126,12 @@
<version>1.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>maven.modrinth</groupId>
<artifactId>Pl3xMap</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/kitteh/vanish/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class Settings {
private static int doubleSneakDuringVanishSwitchesGameModeTimeBetweenSneaksInMS = 500;
private static String doubleSneakDuringVanishSwitchesGameModeMessage = "&aGameMode changed!";

private static final int confVersion = 9; // Tracking config version
private static final int confVersion = 10; // Tracking config version

public static boolean getAutoFakeJoinSilent() {
return Settings.autoFakeJoinSilent;
Expand Down Expand Up @@ -109,6 +109,9 @@ static void freshStart(@NonNull VanishPlugin plugin) {
config.set("double-sneak-during-vanish-switches-gamemode.max-ms-time-between-sneaks", 500);
config.set("double-sneak-during-vanish-switches-gamemode.message", "&aGameMode changed!");
}
if (ver <= 9) {
config.set("hooks.pl3xmap", false);
}
config.set("configVersionDoNotTouch.SeriouslyThisWillEraseYourConfig", Settings.confVersion);
plugin.saveConfig();
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/kitteh/vanish/VanishPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ public void run() {
if (this.getConfig().getBoolean("hooks.squaremap", false)) {
this.hookManager.getHook(HookType.squaremap).onEnable();
}
if (this.getConfig().getBoolean("hooks.pl3xmap", false)) {
this.hookManager.getHook(HookType.Pl3xMap).onEnable();
}

final VanishPlugin self = this;

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/kitteh/vanish/hooks/HookManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.kitteh.vanish.hooks.plugins.DiscordSRVHook;
import org.kitteh.vanish.hooks.plugins.DynmapHook;
import org.kitteh.vanish.hooks.plugins.EssentialsHook;
import org.kitteh.vanish.hooks.plugins.Pl3xMapHook;
import org.kitteh.vanish.hooks.plugins.SquaremapHook;
import org.kitteh.vanish.hooks.plugins.VaultHook;

Expand All @@ -39,7 +40,8 @@ public enum HookType {
Essentials(EssentialsHook.class),
Vault(VaultHook.class),
DiscordSRV(DiscordSRVHook.class),
squaremap(SquaremapHook.class);
squaremap(SquaremapHook.class),
Pl3xMap(Pl3xMapHook.class);

private final Class<? extends Hook> clazz;

Expand Down
63 changes: 63 additions & 0 deletions src/main/java/org/kitteh/vanish/hooks/plugins/Pl3xMapHook.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* VanishNoPacket
* Copyright (C) 2011-2022 Matt Baxter
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.kitteh.vanish.hooks.plugins;

import net.pl3x.map.core.Pl3xMap;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.kitteh.vanish.VanishPlugin;
import org.kitteh.vanish.hooks.Hook;

public final class Pl3xMapHook extends Hook {
private boolean enabled = false;

public Pl3xMapHook(final @NonNull VanishPlugin plugin) {
super(plugin);
}

@Override
public void onEnable() {
final Plugin grab = this.plugin.getServer().getPluginManager().getPlugin("Pl3xMap");
if (grab != null && grab.isEnabled()) {
this.plugin.getLogger().info("Now hooking into Pl3xMap");
this.enabled = true;
} else {
this.plugin.getLogger().info("You wanted Pl3xMap support. I could not find Pl3xMap.");
this.enabled = false;
}
}

@Override
public void onVanish(final @NonNull Player player) {
if (this.enabled) {
Pl3xMap.api().getPlayerRegistry()
.optional(player.getUniqueId())
.ifPresent(p -> p.setHidden(true, false));
}
}

@Override
public void onUnvanish(final @NonNull Player player) {
if (this.enabled) {
Pl3xMap.api().getPlayerRegistry()
.optional(player.getUniqueId())
.ifPresent(p -> p.setHidden(false, false));
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ hooks:
dynmap: false
discordsrv: false
squaremap: false
pl3xmap: false
permissionsupdates:
checkonworldchange: false
effects:
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: VanishNoPacket
main: org.kitteh.vanish.VanishPlugin
version: '${vnp-version}'
website: https://kitteh.org
softdepend: [Essentials,dynmap,PlaceholderAPI,Vault,squaremap]
softdepend: [Essentials,dynmap,PlaceholderAPI,Vault,squaremap,Pl3xMap]
author: mbaxter
description: Vanish for the distinguished admin
dev-url: https://dev.bukkit.org/projects/vanish
Expand Down