Eternal Giveaway Fixes
This commit is contained in:
parent
562d7de1a9
commit
3d5e61e0f1
@ -0,0 +1,25 @@
|
||||
package mineplex.core.rankGiveaway.eternal;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
|
||||
public class EternalCommand extends CommandBase<EternalGiveawayManager>
|
||||
{
|
||||
public EternalCommand(EternalGiveawayManager plugin)
|
||||
{
|
||||
super(plugin, Rank.OWNER, "eternaltest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Plugin.attemptToGiveEternal(caller, () ->
|
||||
{
|
||||
Location location = caller.getLocation().add(0.5, 0.5, 0.5);
|
||||
new EternalGiveawayAnimation(Plugin, location, 3000L);
|
||||
});
|
||||
}
|
||||
}
|
@ -37,47 +37,49 @@ public class EternalGiveawayManager extends MiniPlugin
|
||||
ServerCommandManager.getInstance().registerCommandType("EternalGiveawayMessage", EternalGiveawayMessage.class, new GiveawayMessageHandler(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new EternalCommand(this));
|
||||
}
|
||||
|
||||
public void openPumpkin(final Player player, final Runnable onSuccess)
|
||||
{
|
||||
double rand = _random.nextDouble();
|
||||
if (!hasEternal(player) && rand < RANK_FIND_CHANCE)
|
||||
{
|
||||
final int accountId = _clientManager.getAccountId(player);
|
||||
final Region region = getRegion();
|
||||
final String serverName = getServerName();
|
||||
|
||||
// Need to check database that we can give away a rank
|
||||
runAsync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final boolean pass = _repository.canGiveaway(region);
|
||||
|
||||
if (pass && _repository.addEternal(accountId, region, serverName))
|
||||
{
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
giveRank(rank ->
|
||||
{
|
||||
if (rank == Rank.TITAN)
|
||||
{
|
||||
EternalGiveawayMessage message = new EternalGiveawayMessage(player.getName(), _repository.getEternalCount() + 1);
|
||||
message.publish();
|
||||
if (onSuccess != null) onSuccess.run();
|
||||
}
|
||||
}, Rank.ETERNAL, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
attemptToGiveEternal(player, onSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
protected void attemptToGiveEternal(Player player, Runnable onSuccess)
|
||||
{
|
||||
final int accountId = _clientManager.getAccountId(player);
|
||||
final Region region = getRegion();
|
||||
final String serverName = getServerName();
|
||||
|
||||
if (accountId == -1) return;
|
||||
|
||||
// Need to check database that we can give away a rank
|
||||
runAsync(() ->
|
||||
{
|
||||
final boolean pass = _repository.canGiveaway(region);
|
||||
|
||||
if (pass && _repository.addEternal(accountId, region, serverName))
|
||||
{
|
||||
runSync(() -> giveRank(rank ->
|
||||
{
|
||||
if (rank == Rank.ETERNAL)
|
||||
{
|
||||
EternalGiveawayMessage message = new EternalGiveawayMessage(player.getName(), _repository.getEternalCount() + 1);
|
||||
message.publish();
|
||||
if (onSuccess != null) onSuccess.run();
|
||||
}
|
||||
}, Rank.ETERNAL, player));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm that the player doesn't already have ETERNAL rank
|
||||
*/
|
||||
|
@ -37,6 +37,7 @@ import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.rankGiveaway.eternal.EternalGiveawayManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
@ -141,6 +142,8 @@ public class Clans extends JavaPlugin
|
||||
antiHack.setKick(false);
|
||||
Bukkit.getScheduler().runTask(this, antiHack::enableNewAnticheat);
|
||||
|
||||
new EternalGiveawayManager(this, _clientManager, serverStatusManager);
|
||||
|
||||
{
|
||||
// West Shop
|
||||
int maxX = -385;
|
||||
|
@ -37,6 +37,7 @@ import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.profileCache.ProfileCacheManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.rankGiveaway.eternal.EternalGiveawayManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.resourcepack.ResourcePackManager;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
@ -157,6 +158,8 @@ public class ClansHub extends JavaPlugin
|
||||
|
||||
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
|
||||
|
||||
new EternalGiveawayManager(this, clientManager, serverStatusManager);
|
||||
|
||||
CombatManager combatManager = new CombatManager(this);
|
||||
|
||||
DamageManager damage = new DamageManager(this, combatManager, npcManager, disguiseManager, condition);
|
||||
|
@ -50,6 +50,7 @@ import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.profileCache.ProfileCacheManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.rankGiveaway.eternal.EternalGiveawayManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.report.ReportManager;
|
||||
import mineplex.core.report.ReportPlugin;
|
||||
@ -194,6 +195,8 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
|
||||
AprilFoolsManager.Initialize(this, clientManager, disguiseManager);
|
||||
|
||||
new EternalGiveawayManager(this, clientManager, serverStatusManager);
|
||||
|
||||
CombatManager combatManager = new CombatManager(this);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user