mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Don't send the URL header if url links are disabled
This commit is contained in:
parent
726b04f586
commit
db3d14fa9f
14
pom.xml
14
pom.xml
@ -136,6 +136,10 @@
|
|||||||
<id>CodeMC</id>
|
<id>CodeMC</id>
|
||||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -150,6 +154,16 @@
|
|||||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</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>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit-dep</artifactId>
|
<artifactId>junit-dep</artifactId>
|
||||||
|
66
src/main/java/com/gmail/nossr50/WorldGuardManager.java
Normal file
66
src/main/java/com/gmail/nossr50/WorldGuardManager.java
Normal 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
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.commands.skills;
|
|||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.mining.BlastMining;
|
|
||||||
import com.gmail.nossr50.skills.mining.MiningManager;
|
import com.gmail.nossr50.skills.mining.MiningManager;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.TextComponentFactory;
|
import com.gmail.nossr50.util.TextComponentFactory;
|
||||||
|
@ -87,10 +87,15 @@ public abstract class SkillCommand implements TabExecutor {
|
|||||||
getStatMessages(player, isLucky, hasEndurance, skillValue);
|
getStatMessages(player, isLucky, hasEndurance, skillValue);
|
||||||
|
|
||||||
//Header
|
//Header
|
||||||
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
|
|
||||||
|
|
||||||
//Link Header
|
//Link Header
|
||||||
TextComponentFactory.sendPlayerUrlHeader(player);
|
if(Config.getInstance().getUrlLinksEnabled())
|
||||||
|
{
|
||||||
|
player.sendMessage(LocaleLoader.getString("Overhaul.mcMMO.Header"));
|
||||||
|
TextComponentFactory.sendPlayerUrlHeader(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getSkillUseBoard()) {
|
if (Config.getInstance().getScoreboardsEnabled() && Config.getInstance().getSkillUseBoard()) {
|
||||||
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
|
||||||
|
@ -12,6 +12,7 @@ import java.util.ArrayList;
|
|||||||
public class WorldBlacklist {
|
public class WorldBlacklist {
|
||||||
private static ArrayList<String> blacklist;
|
private static ArrayList<String> blacklist;
|
||||||
private mcMMO plugin;
|
private mcMMO plugin;
|
||||||
|
|
||||||
private final String blackListFileName = "world_blacklist.txt";
|
private final String blackListFileName = "world_blacklist.txt";
|
||||||
|
|
||||||
public WorldBlacklist(mcMMO plugin)
|
public WorldBlacklist(mcMMO plugin)
|
||||||
@ -35,6 +36,7 @@ public class WorldBlacklist {
|
|||||||
|
|
||||||
//Load up the blacklist
|
//Load up the blacklist
|
||||||
loadBlacklist(blackListFile);
|
loadBlacklist(blackListFile);
|
||||||
|
//registerFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBlacklist(File blackListFile) {
|
private void loadBlacklist(File blackListFile) {
|
||||||
@ -68,6 +70,7 @@ public class WorldBlacklist {
|
|||||||
|
|
||||||
public static boolean isWorldBlacklisted(World world)
|
public static boolean isWorldBlacklisted(World world)
|
||||||
{
|
{
|
||||||
|
|
||||||
for(String s : blacklist)
|
for(String s : blacklist)
|
||||||
{
|
{
|
||||||
if(world.getName().equalsIgnoreCase(s))
|
if(world.getName().equalsIgnoreCase(s))
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.config.RankConfig;
|
import com.gmail.nossr50.config.RankConfig;
|
||||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||||
import com.gmail.nossr50.datatypes.json.McMMOUrl;
|
import com.gmail.nossr50.datatypes.json.McMMOUrl;
|
||||||
import com.gmail.nossr50.datatypes.json.McMMOWebLinks;
|
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.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill;
|
||||||
import com.gmail.nossr50.listeners.InteractionManager;
|
import com.gmail.nossr50.listeners.InteractionManager;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.skills.RankUtils;
|
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.ChatColor;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.*;
|
import net.md_5.bungee.api.chat.*;
|
||||||
@ -80,9 +77,6 @@ public class TextComponentFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayerUrlHeader(Player player) {
|
public static void sendPlayerUrlHeader(Player player) {
|
||||||
if(!Config.getInstance().getUrlLinksEnabled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
Player.Spigot spigotPlayer = player.spigot();
|
Player.Spigot spigotPlayer = player.spigot();
|
||||||
|
|
||||||
TextComponent prefix = new TextComponent(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");
|
TextComponent prefix = new TextComponent(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");
|
||||||
|
@ -14,7 +14,7 @@ author: nossr50
|
|||||||
authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking]
|
authors: [GJ, NuclearW, bm01, Glitchfinder, TfT_02, t00thpick1, Riking]
|
||||||
website: https://www.mcmmo.org
|
website: https://www.mcmmo.org
|
||||||
main: com.gmail.nossr50.mcMMO
|
main: com.gmail.nossr50.mcMMO
|
||||||
softdepend: [CombatTag, HealthBar]
|
softdepend: [WorldGuard, CombatTag, HealthBar]
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user