Disable Fated giveaway tools for now
This commit is contained in:
parent
b862a30c76
commit
e845f7fca9
@ -1,61 +0,0 @@
|
||||
package mineplex.core.rankGiveaway.fatedgiveaway;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect.Type;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class FatedGiveawayAnimation implements Listener
|
||||
{
|
||||
private Location _location;
|
||||
private Long _duration, _startTime, _worldTime;
|
||||
|
||||
public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start, Long duration)
|
||||
{
|
||||
_location = start.clone();
|
||||
_duration = duration;
|
||||
_startTime = System.currentTimeMillis();
|
||||
Bukkit.getPluginManager().registerEvents(this, manager.getPlugin());
|
||||
}
|
||||
|
||||
public FatedGiveawayAnimation(FatedGiveawayManager manager, Location start)
|
||||
{
|
||||
this(manager, start, 11111L);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void tick(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.TICK)
|
||||
return;
|
||||
|
||||
if (UtilTime.elapsed(_startTime, _duration))
|
||||
{
|
||||
remove();
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.playSound(_location, Sound.ORB_PICKUP, 5, 5);
|
||||
UtilFirework.packetPlayFirework(player, _location, Type.BURST, Color.fromRGB(255, 105, 180), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void remove()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package mineplex.core.rankGiveaway.fatedgiveaway;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.rankGiveaway.redis.FatedGiveawayMessage;
|
||||
import mineplex.core.rankGiveaway.redis.GiveawayMessageHandler;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.commands.ServerCommandManager;
|
||||
|
||||
public class FatedGiveawayManager extends MiniPlugin
|
||||
{
|
||||
|
||||
private static final double RANK_FIND_CHANCE = 0.001;
|
||||
|
||||
private FatedGiveawayRepository _repository;
|
||||
private CoreClientManager _clientManager;
|
||||
private ServerStatusManager _statusManager;
|
||||
private Random _random;
|
||||
|
||||
public FatedGiveawayManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager)
|
||||
{
|
||||
super("Fated Giveaway", plugin);
|
||||
|
||||
_repository = new FatedGiveawayRepository(plugin);
|
||||
_clientManager = clientManager;
|
||||
_statusManager = statusManager;
|
||||
_random = new Random();
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("FatedGiveawayMessage", FatedGiveawayMessage.class, new GiveawayMessageHandler(plugin));
|
||||
}
|
||||
|
||||
public void openPumpkin(final Player player, final Runnable onSuccess)
|
||||
{
|
||||
double rand = _random.nextDouble();
|
||||
if (!hasFated(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.addFated(accountId, region, serverName))
|
||||
{
|
||||
runSync(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
giveRank(new Callback<Rank>()
|
||||
{
|
||||
@Override
|
||||
public void run(Rank rank)
|
||||
{
|
||||
// TODO CHANGE RANK
|
||||
if (rank == Rank.TITAN)
|
||||
{
|
||||
FatedGiveawayMessage message = new FatedGiveawayMessage(player.getName(), _repository.getFatedCount() + 1);
|
||||
message.publish();
|
||||
if (onSuccess != null) onSuccess.run();
|
||||
}
|
||||
}
|
||||
// TODO CHANGE RANK
|
||||
}, Rank.TITAN, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm that the player doesn't already have FATED rank
|
||||
*/
|
||||
private boolean hasFated(Player player)
|
||||
{
|
||||
// TODO CHANGE RANK
|
||||
return _clientManager.hasRank(player, Rank.TITAN);
|
||||
}
|
||||
|
||||
public Region getRegion()
|
||||
{
|
||||
return _statusManager.getRegion();
|
||||
}
|
||||
|
||||
public String getServerName()
|
||||
{
|
||||
return _statusManager.getCurrentServerName();
|
||||
}
|
||||
|
||||
private void giveRank(Callback<Rank> callback, Rank rank, Player player)
|
||||
{
|
||||
_clientManager.Get(player).SetRank(rank, false);
|
||||
_clientManager.getRepository().saveRank(callback, player.getName(), player.getUniqueId(), rank, true);
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package mineplex.core.rankGiveaway.fatedgiveaway;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.Region;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnVarChar;
|
||||
|
||||
public class FatedGiveawayRepository extends MinecraftRepository
|
||||
{
|
||||
private static final String ADD_FATED = "INSERT INTO fatedGiveaway (accountId, region, serverName) VALUES (?, ?, ?)";
|
||||
|
||||
private int _fatedCount;
|
||||
|
||||
public FatedGiveawayRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, DBPool.getAccount());
|
||||
_fatedCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean addFated(int accountId, Region region, String serverName)
|
||||
{
|
||||
return 1 == executeUpdate(ADD_FATED, new ColumnInt("accountId", accountId), new ColumnVarChar("region", 10, region.name()), new ColumnVarChar("serverName", 64, serverName));
|
||||
}
|
||||
|
||||
public boolean canGiveaway(Region region)
|
||||
{
|
||||
try (Connection connection = getConnection();
|
||||
CallableStatement callableStatement = connection.prepareCall("{call check_fatedGiveaway(?, ?, ?)}"))
|
||||
{
|
||||
callableStatement.setString(1, region.name());
|
||||
callableStatement.registerOutParameter(2, Types.BOOLEAN);
|
||||
callableStatement.registerOutParameter(3, Types.INTEGER);
|
||||
callableStatement.executeUpdate();
|
||||
|
||||
boolean pass = callableStatement.getBoolean(2);
|
||||
int fatedCount = callableStatement.getInt(3);
|
||||
|
||||
_fatedCount = fatedCount;
|
||||
return pass;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getFatedCount()
|
||||
{
|
||||
return _fatedCount;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package mineplex.core.rankGiveaway.redis;
|
||||
|
||||
import mineplex.serverdata.commands.ServerCommand;
|
||||
|
||||
public class FatedGiveawayMessage extends ServerCommand
|
||||
{
|
||||
private String _playerName;
|
||||
private int _fatedCount;
|
||||
|
||||
public FatedGiveawayMessage(String playerName, int fatedCount)
|
||||
{
|
||||
_playerName = playerName;
|
||||
_fatedCount = fatedCount;
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public int getFatedCount()
|
||||
{
|
||||
return _fatedCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// Handled in Command Callback
|
||||
}
|
||||
}
|
||||
|
@ -44,22 +44,5 @@ public class GiveawayMessageHandler implements CommandCallback
|
||||
player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1);
|
||||
}
|
||||
}
|
||||
else if (command instanceof FatedGiveawayMessage)
|
||||
{
|
||||
FatedGiveawayMessage message = ((FatedGiveawayMessage) command);
|
||||
String playerName = message.getPlayerName();
|
||||
int count = message.getFatedCount();
|
||||
String countString = count + UtilTime.getDayOfMonthSuffix(count);
|
||||
String chatMessage = C.cPurple + playerName + C.cWhite + " found Fated in a " + C.cPurple + "Thanksgiving Chicken";
|
||||
UtilTextMiddle.display(C.cDPurple + C.Bold + "FATED", chatMessage, 20, 80, 20, UtilServer.getPlayers());
|
||||
World world = UtilServer.getPlayers().length > 0 ? UtilServer.getPlayers()[0].getWorld() : Bukkit.getWorlds().get(0);
|
||||
LightFlicker lightFlicker = new LightFlicker(world);
|
||||
lightFlicker.runTaskTimer(_plugin, 1, 1);
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
{
|
||||
player.playSound(player.getEyeLocation(), Sound.AMBIENCE_CAVE, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.progression.KitProgressionManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager;
|
||||
import mineplex.core.resourcepack.ResourcePackManager;
|
||||
import mineplex.core.scoreboard.MineplexScoreboard;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
@ -345,9 +344,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
_hologramManager = hologramManager;
|
||||
_idleManager = new IdleManager(this);
|
||||
TitanGiveawayManager titanGiveaway = new TitanGiveawayManager(getPlugin(), clientManager, serverStatusManager);
|
||||
FatedGiveawayManager fatedGiveaway = new FatedGiveawayManager(getPlugin(), clientManager, serverStatusManager);
|
||||
|
||||
new HolidayManager(this, titanGiveaway, fatedGiveaway);
|
||||
|
||||
new HolidayManager(this, titanGiveaway);
|
||||
IsHolidayEnabled = true;
|
||||
|
||||
new ValentinesGiftManager(plugin, clientManager, _bonusManager.getRewardManager(), inventoryManager, _cosmeticManager.getGadgetManager(), statsManager);
|
||||
|
@ -45,8 +45,6 @@ import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.particleeffects.HalloweenSmashedEffect;
|
||||
import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayAnimation;
|
||||
import mineplex.core.rankGiveaway.fatedgiveaway.FatedGiveawayManager;
|
||||
import mineplex.core.rankGiveaway.titangiveaway.TitanGiveawayManager;
|
||||
import mineplex.core.reward.RewardPool;
|
||||
import mineplex.core.reward.RewardRarity;
|
||||
@ -102,7 +100,6 @@ public class HolidayManager implements Listener
|
||||
|
||||
private ArcadeManager _arcadeManager;
|
||||
private TitanGiveawayManager _titanManager;
|
||||
private FatedGiveawayManager _fatedManager;
|
||||
|
||||
public HashSet<Block> _active = new HashSet<>();
|
||||
public HashSet<org.bukkit.entity.Entity> _activeEntities = new HashSet<>();
|
||||
@ -120,11 +117,10 @@ public class HolidayManager implements Listener
|
||||
|
||||
private EnumMap<RewardPool.Type, RewardPool> _rewardPools;
|
||||
|
||||
public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager, FatedGiveawayManager fatedManager)
|
||||
public HolidayManager(ArcadeManager arcadeManager, TitanGiveawayManager titanManager)
|
||||
{
|
||||
_arcadeManager = arcadeManager;
|
||||
_titanManager = titanManager;
|
||||
_fatedManager = fatedManager;
|
||||
|
||||
_rewardPools = new EnumMap<>(RewardPool.Type.class);
|
||||
for (RewardPool.Type type : RewardPool.Type.values())
|
||||
@ -617,19 +613,6 @@ public class HolidayManager implements Listener
|
||||
_gems.add(gem);
|
||||
}
|
||||
|
||||
// Fated Giveaway
|
||||
if (player != null)
|
||||
{
|
||||
_fatedManager.openPumpkin(player, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Location location = entity.getLocation().add(0.5, 0.5, 0.5);
|
||||
new FatedGiveawayAnimation(_fatedManager, location, 3000L);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user