Remove sponsor
This commit is contained in:
parent
cb168c60cb
commit
a28c4b9552
@ -230,7 +230,7 @@ public class MassiveCore extends MassivePlugin
|
|||||||
public List<Class<?>> getClassesActiveColls()
|
public List<Class<?>> getClassesActiveColls()
|
||||||
{
|
{
|
||||||
List<Class<?>> ret = this.getClassesActive(null, Coll.class);
|
List<Class<?>> ret = this.getClassesActive(null, Coll.class);
|
||||||
|
if (!ret.contains(MassiveCoreMConfColl.get().getClass())) ret.add(0, MassiveCoreMConfColl.get().getClass());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,14 +175,6 @@ public class MassiveCoreMConf extends Entity<MassiveCoreMConf>
|
|||||||
|
|
||||||
public boolean debugEnabled = false;
|
public boolean debugEnabled = false;
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// SPONSOR
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// URL connections to http://sponsorinfo.massivecraft.com/
|
|
||||||
|
|
||||||
public long sponsorUpdateMillis = 0;
|
|
||||||
public boolean sponsorEnabled = true;
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// METRICS
|
// METRICS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -1,163 +0,0 @@
|
|||||||
package com.massivecraft.massivecore;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
|
||||||
import com.massivecraft.massivecore.store.Entity;
|
|
||||||
import com.massivecraft.massivecore.util.TimeUnit;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import com.massivecraft.massivecore.util.WebUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MassiveCoreMSponsorInfo extends Entity<MassiveCoreMSponsorInfo>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// META
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
protected static transient MassiveCoreMSponsorInfo i;
|
|
||||||
public static MassiveCoreMSponsorInfo get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// COMMON
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean enabled = true;
|
|
||||||
|
|
||||||
public long enabledToMillis = 2473890400000L;
|
|
||||||
|
|
||||||
public List<String> indicatorFileNames = new MassiveList<>(
|
|
||||||
"/home/smpicnic"
|
|
||||||
);
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSOLE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean consoleEnabled = true;
|
|
||||||
|
|
||||||
public int consoleDelayTicks = 100;
|
|
||||||
|
|
||||||
public List<String> consoleMsgs = new MassiveList<>(
|
|
||||||
"",
|
|
||||||
"<pink>____----====[ <aqua>Sponsored by ServerMiner<pink> ]====----____",
|
|
||||||
"<lime>Get <gold>20% off<lime> a Premium Factions Server at ServerMiner:",
|
|
||||||
"<aqua>https://ServerMiner.com/plugins/Factions-Server-Hosting?p=MassiveCraft",
|
|
||||||
"",
|
|
||||||
"<lime>Factions and MassiveCore is sponsored by ServerMiner.com!",
|
|
||||||
"<lime>They help us fund the development of new plugin features.",
|
|
||||||
"",
|
|
||||||
"<i>Only server operators get this message, not regular players.",
|
|
||||||
"<i>Type <c>/mcore sponsor<i> to disable it.",
|
|
||||||
"" // NOTE: an empty line like this makes sense in console but not for players.
|
|
||||||
);
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INGAME
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public boolean ingameEnabled = true;
|
|
||||||
|
|
||||||
public int ingameDelayTicks = 600;
|
|
||||||
|
|
||||||
public List<String> ingameMsgs = new MassiveList<>(
|
|
||||||
"",
|
|
||||||
"<pink>____----====[ <aqua>Sponsored by ServerMiner<pink> ]====----____",
|
|
||||||
"<lime>Get <gold>20% off<lime> a Premium Factions Server at ServerMiner:",
|
|
||||||
"<aqua>https://ServerMiner.com/plugins/Factions-Server-Hosting?p=MassiveCraft",
|
|
||||||
"",
|
|
||||||
"<lime>Factions and MassiveCore is sponsored by ServerMiner.com!",
|
|
||||||
"<lime>They help us fund the development of new plugin features.",
|
|
||||||
"",
|
|
||||||
"<i>Only server operators get this message, not regular players.",
|
|
||||||
"<i>Type <c>/mcore sponsor<i> to disable it."
|
|
||||||
);
|
|
||||||
|
|
||||||
public List<SoundEffect> ingameSoundEffects = new MassiveList<>(
|
|
||||||
SoundEffect.valueOf(
|
|
||||||
"ENTITY_PLAYER_LEVELUP",
|
|
||||||
1.0F,
|
|
||||||
0.8F
|
|
||||||
),
|
|
||||||
SoundEffect.valueOf(
|
|
||||||
"ENTITY_EXPERIENCE_ORB_PICKUP",
|
|
||||||
1.0F,
|
|
||||||
0.8F
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
public String ingameLink = "https://ServerMiner.com/plugins/Factions-Server-Hosting?p=MassiveCraft";
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UPDATE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static final transient long SPONSOR_INFO_UPDATE_MILLIS = TimeUnit.MILLIS_PER_HOUR;
|
|
||||||
public static final transient URL SPONSOR_INFO_URL;
|
|
||||||
static
|
|
||||||
{
|
|
||||||
URL url = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
url = new URL("http://sponsorinfo.massivecraft.com/2/");
|
|
||||||
}
|
|
||||||
catch (MalformedURLException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
SPONSOR_INFO_URL = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void update()
|
|
||||||
{
|
|
||||||
// If enough time has passed since last update ...
|
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
long last = MassiveCoreMConf.get().sponsorUpdateMillis;
|
|
||||||
long since = now - last;
|
|
||||||
if (since < SPONSOR_INFO_UPDATE_MILLIS) return;
|
|
||||||
|
|
||||||
// ... then mark update ...
|
|
||||||
MassiveCoreMConf.get().sponsorUpdateMillis = now;
|
|
||||||
MassiveCoreMConf.get().changed();
|
|
||||||
|
|
||||||
// ... and start the update.
|
|
||||||
updateInner();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateInner()
|
|
||||||
{
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(MassiveCore.get(), new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
List<String> lines;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
lines = WebUtil.getLines(SPONSOR_INFO_URL);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final String json = Txt.implode(lines, "\n");
|
|
||||||
Bukkit.getScheduler().runTask(MassiveCore.get(), new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
MassiveCoreMSponsorInfo web = MassiveCore.get().getGson().fromJson(json, MassiveCoreMSponsorInfo.class);
|
|
||||||
MassiveCoreMSponsorInfo live = MassiveCoreMSponsorInfo.get();
|
|
||||||
live.load(web);
|
|
||||||
live.changed();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package com.massivecraft.massivecore;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.store.Coll;
|
|
||||||
|
|
||||||
public class MassiveCoreMSponsorInfoColl extends Coll<MassiveCoreMSponsorInfo>
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static MassiveCoreMSponsorInfoColl i = new MassiveCoreMSponsorInfoColl();
|
|
||||||
public static MassiveCoreMSponsorInfoColl get() { return i; }
|
|
||||||
private MassiveCoreMSponsorInfoColl()
|
|
||||||
{
|
|
||||||
super("massivecore_msponsorinfo");
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// STACK TRACEABILITY
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTick()
|
|
||||||
{
|
|
||||||
super.onTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActive(boolean active)
|
|
||||||
{
|
|
||||||
super.setActive(active);
|
|
||||||
|
|
||||||
if ( ! active) return;
|
|
||||||
|
|
||||||
MassiveCoreMSponsorInfo.i = this.get(MassiveCore.INSTANCE, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -215,7 +215,7 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener, Name
|
|||||||
// can only happen after others have been initialised.
|
// can only happen after others have been initialised.
|
||||||
public void activateOne(Object object)
|
public void activateOne(Object object)
|
||||||
{
|
{
|
||||||
boolean debug = MassiveCoreMConf.get() != null && MassiveCoreMConf.get().debugEnabled;
|
boolean debug = true;//MassiveCoreMConf.get() != null && MassiveCoreMConf.get().debugEnabled;
|
||||||
|
|
||||||
// Try collection
|
// Try collection
|
||||||
if (object instanceof Iterable)
|
if (object instanceof Iterable)
|
||||||
@ -425,22 +425,8 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener, Name
|
|||||||
packageName = this.getClass().getPackage().getName() + packageName;
|
packageName = this.getClass().getPackage().getName() + packageName;
|
||||||
|
|
||||||
Predicate predicateCombined = PredicateAnd.get(predicates);
|
Predicate predicateCombined = PredicateAnd.get(predicates);
|
||||||
Predicate<Class<?>> predicateNotAbstract = new Predicate<Class<?>>()
|
Predicate<Class<?>> predicateNotAbstract = type -> !Modifier.isAbstract(type.getModifiers());
|
||||||
{
|
Predicate<Class<?>> predicateSubclass = type -> !Modifier.isAbstract(type.getModifiers());
|
||||||
@Override
|
|
||||||
public boolean apply(Class<?> type)
|
|
||||||
{
|
|
||||||
return !Modifier.isAbstract(type.getModifiers());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Predicate<Class<?>> predicateSubclass = new Predicate<Class<?>>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean apply(Class<?> type)
|
|
||||||
{
|
|
||||||
return superClass.isAssignableFrom(type);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Predicate<Class<?>> predicateSingleton = PredicateIsClassSingleton.get();
|
Predicate<Class<?>> predicateSingleton = PredicateIsClassSingleton.get();
|
||||||
|
|
||||||
return ReflectionUtil.getPackageClasses(packageName, this.getClassLoader(), true, predicateCombined, predicateNotAbstract, predicateSubclass, predicateSingleton);
|
return ReflectionUtil.getPackageClasses(packageName, this.getClassLoader(), true, predicateCombined, predicateNotAbstract, predicateSubclass, predicateSingleton);
|
||||||
|
@ -31,7 +31,6 @@ public class CmdMassiveCore extends MassiveCoreCommand
|
|||||||
public CmdMassiveCoreBuffer cmdMassiveCoreBuffer = new CmdMassiveCoreBuffer();
|
public CmdMassiveCoreBuffer cmdMassiveCoreBuffer = new CmdMassiveCoreBuffer();
|
||||||
public CmdMassiveCoreCmdurl cmdMassiveCoreCmdurl = new CmdMassiveCoreCmdurl();
|
public CmdMassiveCoreCmdurl cmdMassiveCoreCmdurl = new CmdMassiveCoreCmdurl();
|
||||||
public CommandEditAbstract<MassiveCoreMConf, MassiveCoreMConf> cmdMassiveCoreConfig = new CommandEditSingleton<>(MassiveCoreMConf.get()).addRequirements(RequirementHasPerm.get(MassiveCorePerm.CONFIG));
|
public CommandEditAbstract<MassiveCoreMConf, MassiveCoreMConf> cmdMassiveCoreConfig = new CommandEditSingleton<>(MassiveCoreMConf.get()).addRequirements(RequirementHasPerm.get(MassiveCorePerm.CONFIG));
|
||||||
public CmdMassiveCoreSponsor cmdMassiveCoreSponsor = new CmdMassiveCoreSponsor();
|
|
||||||
public CmdMassiveCoreClick cmdMassiveCoreClick = new CmdMassiveCoreClick();
|
public CmdMassiveCoreClick cmdMassiveCoreClick = new CmdMassiveCoreClick();
|
||||||
public MassiveCommandVersion cmdMassiveCoreVersion = new MassiveCommandVersion(MassiveCore.get()).setAliases("v", "version").addRequirements(RequirementHasPerm.get(MassiveCorePerm.VERSION));
|
public MassiveCommandVersion cmdMassiveCoreVersion = new MassiveCommandVersion(MassiveCore.get()).setAliases("v", "version").addRequirements(RequirementHasPerm.get(MassiveCorePerm.VERSION));
|
||||||
|
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
package com.massivecraft.massivecore.cmd;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.MassiveCoreMConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveCorePerm;
|
|
||||||
import com.massivecraft.massivecore.command.MassiveCommandToggle;
|
|
||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
|
||||||
|
|
||||||
public class CmdMassiveCoreSponsor extends MassiveCommandToggle
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static CmdMassiveCoreSponsor i = new CmdMassiveCoreSponsor();
|
|
||||||
public static CmdMassiveCoreSponsor get() { return i; }
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public CmdMassiveCoreSponsor()
|
|
||||||
{
|
|
||||||
// Aliases
|
|
||||||
this.addAliases("sponsor");
|
|
||||||
|
|
||||||
// Requirements
|
|
||||||
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.SPONSOR));
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getValue()
|
|
||||||
{
|
|
||||||
return MassiveCoreMConf.get().sponsorEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setValue(boolean value)
|
|
||||||
{
|
|
||||||
MassiveCoreMConf.get().sponsorEnabled = value;
|
|
||||||
MassiveCoreMConf.get().changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,188 +0,0 @@
|
|||||||
package com.massivecraft.massivecore.engine;
|
|
||||||
|
|
||||||
import com.massivecraft.massivecore.Engine;
|
|
||||||
import com.massivecraft.massivecore.MassiveCore;
|
|
||||||
import com.massivecraft.massivecore.MassiveCoreMConf;
|
|
||||||
import com.massivecraft.massivecore.MassiveCoreMSponsorInfo;
|
|
||||||
import com.massivecraft.massivecore.SoundEffect;
|
|
||||||
import com.massivecraft.massivecore.mixin.MixinDisplayName;
|
|
||||||
import com.massivecraft.massivecore.mixin.MixinMessage;
|
|
||||||
import com.massivecraft.massivecore.mson.Mson;
|
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class EngineMassiveCoreSponsor extends Engine
|
|
||||||
{
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CONSTANT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static final String DISABLE_CODE = readDisableCode();
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INSTANCE & CONSTRUCT
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
private static EngineMassiveCoreSponsor i = new EngineMassiveCoreSponsor();
|
|
||||||
public static EngineMassiveCoreSponsor get() { return i; }
|
|
||||||
public EngineMassiveCoreSponsor()
|
|
||||||
{
|
|
||||||
this.setPeriod(1L);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// OVERRIDE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setActiveInner(boolean active)
|
|
||||||
{
|
|
||||||
if ( ! active) return;
|
|
||||||
|
|
||||||
// We delay informing the console.
|
|
||||||
// This is because the console may not exist when this engine is activated.
|
|
||||||
Bukkit.getScheduler().runTask(this.getPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
ConsoleCommandSender console = IdUtil.getConsole();
|
|
||||||
inform(console);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// UPDATE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
// If enabled ...
|
|
||||||
if ( ! this.isEnabled()) return;
|
|
||||||
|
|
||||||
// ... update sponsor info.
|
|
||||||
MassiveCoreMSponsorInfo.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// ENABLED
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
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 (sender == null) return false;
|
|
||||||
|
|
||||||
// ... and enabled ...
|
|
||||||
if ( ! this.isEnabled()) return false;
|
|
||||||
|
|
||||||
// ... and enabled by info base ...
|
|
||||||
if ( ! MassiveCoreMSponsorInfo.get().enabled) return false;
|
|
||||||
|
|
||||||
// ... and enabled by info time ...
|
|
||||||
long now = System.currentTimeMillis();
|
|
||||||
long to = MassiveCoreMSponsorInfo.get().enabledToMillis;
|
|
||||||
long left = to - now;
|
|
||||||
if (left <= 0) return false;
|
|
||||||
|
|
||||||
// ... and enabled by sender type ...
|
|
||||||
boolean enabledByType = (IdUtil.isConsole(sender) ? MassiveCoreMSponsorInfo.get().consoleEnabled : MassiveCoreMSponsorInfo.get().ingameEnabled);
|
|
||||||
if ( ! enabledByType) return false;
|
|
||||||
|
|
||||||
// ... and enabled by sender operator ...
|
|
||||||
if ( ! sender.isOp()) return false;
|
|
||||||
|
|
||||||
// ... and enabled by in indicator files ...
|
|
||||||
for (String indicatorFileName : MassiveCoreMSponsorInfo.get().indicatorFileNames)
|
|
||||||
{
|
|
||||||
File indicatorFile = new File(indicatorFileName);
|
|
||||||
if (indicatorFile.exists()) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ... then it's actually enabled.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// INFORM
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public void inform(final CommandSender sender)
|
|
||||||
{
|
|
||||||
// Enabled
|
|
||||||
if ( ! this.isEnabled(sender)) return;
|
|
||||||
|
|
||||||
// Schedule
|
|
||||||
int delayTicks = (IdUtil.isConsole(sender) ? MassiveCoreMSponsorInfo.get().consoleDelayTicks : MassiveCoreMSponsorInfo.get().ingameDelayTicks);
|
|
||||||
Bukkit.getScheduler().runTaskLater(this.getPlugin(), new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
informInner(sender);
|
|
||||||
}
|
|
||||||
}, delayTicks);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void informInner(CommandSender sender)
|
|
||||||
{
|
|
||||||
// Enabled
|
|
||||||
if ( ! this.isEnabled(sender)) return;
|
|
||||||
|
|
||||||
// Messages
|
|
||||||
List<String> msgs = (IdUtil.isConsole(sender) ? MassiveCoreMSponsorInfo.get().consoleMsgs : MassiveCoreMSponsorInfo.get().ingameMsgs);
|
|
||||||
String senderVisual = MixinDisplayName.get().getDisplayName(sender, sender);
|
|
||||||
for (String msg : msgs)
|
|
||||||
{
|
|
||||||
String message = Txt.parse(msg);
|
|
||||||
message = message.replace("{p}", senderVisual);
|
|
||||||
Mson mson = Mson.fromParsedMessage(message).link(MassiveCoreMSponsorInfo.get().ingameLink);
|
|
||||||
MixinMessage.get().messageOne(sender, mson);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sound
|
|
||||||
if (sender instanceof Player)
|
|
||||||
{
|
|
||||||
Player player = (Player)sender;
|
|
||||||
SoundEffect.runAll(MassiveCoreMSponsorInfo.get().ingameSoundEffects, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// LISTENER
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
this.inform(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user