Don't send the URL header if url links are disabled

This commit is contained in:
nossr50 2019-01-22 14:11:59 -08:00
parent 726b04f586
commit db3d14fa9f
7 changed files with 91 additions and 10 deletions

14
pom.xml
View File

@ -136,6 +136,10 @@
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
@ -150,6 +154,16 @@
<version>1.13.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>

View File

@ -0,0 +1,66 @@
package com.gmail.nossr50;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
public class WorldGuardManager {
// StateFlag with the name "my-custom-flag", which defaults to "allow"
public static final Flag MCMMO_DISABLE_WG_FLAG = new StateFlag("mcmmo-off", false);
public static final Flag MCMMO_XPOFF_WG_FLAG = new StateFlag("mcmmo-noxp", false);
private static WorldGuardPlugin worldGuardPlugin;
/*public static boolean isWgFlagActive(Location location)
{
if(flagsRegistered)
{
if(getWorldGuard() != null)
{
WorldGuardPlugin worldGuard = getWorldGuard();
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionQuery query = container.createQuery();
ApplicableRegionSet set = query.getApplicableRegions();
*//* if (!query.testState(location, (LocalPlayer)null, MCMMO_DISABLE_WG_FLAG)) {
// Can't build
}*//*
}
}
}
private static WorldGuardPlugin getWorldGuard() {
if(worldGuardPlugin != null)
return worldGuardPlugin;
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
// WorldGuard may not be loaded
if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
return null; // Maybe you want throw an exception instead
}
worldGuardPlugin = (WorldGuardPlugin) plugin;
return worldGuardPlugin;
}
private static void registerFlags()
{
if(getWorldGuard() == null)
return;
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
try {
// register our flag with the registry
registry.register(MCMMO_DISABLE_WG_FLAG);
flagsRegistered = true;
} catch (FlagConflictException e) {
e.printStackTrace();
// some other plugin registered a flag by the same name already.
// you may want to re-register with a different name, but this
// could cause issues with saved flags in region files. it's better
// to print a message to let the server admin know of the conflict
}
}*/
}

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.BlastMining;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;

View File

@ -87,10 +87,15 @@ public abstract class SkillCommand implements TabExecutor {
getStatMessages(player, isLucky, hasEndurance, skillValue);
//Header
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
//Link Header
if(Config.getInstance().getUrlLinksEnabled())
{
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
TextComponentFactory.sendPlayerUrlHeader(player);
}
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getSkillUseBoard()) {
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);

View File

@ -12,6 +12,7 @@ import java.util.ArrayList;
public class WorldBlacklist {
private static ArrayList<String> blacklist;
private mcMMO plugin;
private final String blackListFileName = "world_blacklist.txt";
public WorldBlacklist(mcMMO plugin)
@ -35,6 +36,7 @@ public class WorldBlacklist {
//Load up the blacklist
loadBlacklist(blackListFile);
//registerFlags();
}
private void loadBlacklist(File blackListFile) {
@ -68,6 +70,7 @@ public class WorldBlacklist {
public static boolean isWorldBlacklisted(World world)
{
for(String s : blacklist)
{
if(world.getName().equalsIgnoreCase(s))

View File

@ -1,19 +1,16 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.RankConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.json.McMMOUrl;
import com.gmail.nossr50.datatypes.json.McMMOWebLinks;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.*;
@ -80,9 +77,6 @@ public class TextComponentFactory {
}
public static void sendPlayerUrlHeader(Player player) {
if(!Config.getInstance().getUrlLinksEnabled())
return;
Player.Spigot spigotPlayer = player.spigot();
TextComponent prefix = new TextComponent(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");

View File

@ -14,7 +14,7 @@ author: nossr50
authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking]
website: https://www.mcmmo.org
main: com.gmail.nossr50.mcMMO
softdepend: [CombatTag, HealthBar]
softdepend: [WorldGuard, CombatTag, HealthBar]
load: STARTUP
api-version: 1.13