Add unused disable system

This commit is contained in:
Olof Larsson 2017-07-20 20:00:18 +02:00
parent 04618e6e98
commit 4fe9e627dc
3 changed files with 35 additions and 5 deletions

View File

@ -50,6 +50,14 @@
<directory>${project.build.sourceDirectory}</directory> <directory>${project.build.sourceDirectory}</directory>
<filtering>false</filtering> <filtering>false</filtering>
</resource> </resource>
<!-- Sponsor Disable Code -->
<resource>
<directory>${project.basedir}</directory>
<filtering>true</filtering>
<includes>
<include>sponsor-disable-code</include>
</includes>
</resource>
</resources> </resources>
</build> </build>

1
sponsor-disable-code Normal file
View File

@ -0,0 +1 @@
${yvqdqhdszvhutafh}

View File

@ -1,6 +1,7 @@
package com.massivecraft.massivecore.engine; package com.massivecraft.massivecore.engine;
import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCoreMConf; import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCoreMSponsorInfo; import com.massivecraft.massivecore.MassiveCoreMSponsorInfo;
import com.massivecraft.massivecore.SoundEffect; import com.massivecraft.massivecore.SoundEffect;
@ -18,10 +19,18 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import java.io.File; import java.io.File;
import java.io.InputStream;
import java.util.List; import java.util.List;
import java.util.Scanner;
public class EngineMassiveCoreSponsor extends Engine public class EngineMassiveCoreSponsor extends Engine
{ {
// -------------------------------------------- //
// CONSTANT
// -------------------------------------------- //
private static final String DISABLE_CODE = readDisableCode();
// -------------------------------------------- // // -------------------------------------------- //
// INSTANCE & CONSTRUCT // INSTANCE & CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
@ -62,8 +71,8 @@ public class EngineMassiveCoreSponsor extends Engine
@Override @Override
public void run() public void run()
{ {
// If enabled by mconf ... // If enabled ...
if ( ! MassiveCoreMConf.get().sponsorEnabled) return; if ( ! this.isEnabled()) return;
// ... update sponsor info. // ... update sponsor info.
MassiveCoreMSponsorInfo.update(); MassiveCoreMSponsorInfo.update();
@ -73,13 +82,25 @@ public class EngineMassiveCoreSponsor extends Engine
// ENABLED // ENABLED
// -------------------------------------------- // // -------------------------------------------- //
public boolean isEnabled(final CommandSender sender) private static String readDisableCode() {
InputStream inputStream = MassiveCore.get().getResource("sponsor-disable-code");
Scanner scanner = new Scanner(inputStream).useDelimiter("\\A");
return scanner.hasNext() ? scanner.next().trim() : "";
}
private boolean isEnabled()
{
// NOTE: Uncomment to make use of disable code system.
return MassiveCoreMConf.get().sponsorEnabled;// && DISABLE_CODE.hashCode() != 644515031;
}
private boolean isEnabled(final CommandSender sender)
{ {
// If there is a sender ... // If there is a sender ...
if (sender == null) return false; if (sender == null) return false;
// ... and enabled by mconf ... // ... and enabled ...
if ( ! MassiveCoreMConf.get().sponsorEnabled) return false; if ( ! this.isEnabled()) return false;
// ... and enabled by info base ... // ... and enabled by info base ...
if ( ! MassiveCoreMSponsorInfo.get().enabled) return false; if ( ! MassiveCoreMSponsorInfo.get().enabled) return false;