Merge branches 'bugfix/report-hotfix' and 'develop' of github.com:Mineplex-LLC/Minecraft-PC into bugfix/report-hotfix

This commit is contained in:
Keir Nellyer 2016-10-04 10:40:43 +01:00
commit c462282632
31 changed files with 1112 additions and 464 deletions

View File

@ -55,8 +55,9 @@ public class SkinData
public final static SkinData SNOWMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk4Nzk5NDIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEzMTgxYWViODQzODk3NzM1ZDQwMmIyNDk2OTQxNmZkYjBjZTM0YTZiOTM3ODE2MjQzNzU2ZTlkYWU1OGUzIn19fQ==", "NZvsNu+HQ5uvGWq6O8VNDGq9A145bmk2IkHiz916uRVPMRqqCI/zwhKWNLlFACE/feuLkhYAois29ec6sVVOtHIoNA+S5q1Mb/Vjc3TJQxzqmx2FZOhJiIttFwYuo9WomQKBqrPMSJ9tpQig4wzoqldeeTjWC3dLz7JeX+gkzinryVjG7NNN9L5hXK5/BBxRcrtwmXJfUlSANyrd8RZW7mEUgU8yxlzdqTu0w7bZLjQNd4vciwoF3NelXDorMIIqiHTkuQesG91Njtu25VCUDK3nXbqEnZw2ZtxB5fT5G2Omm/vkNSRXc0P7iqchVowdYQcMlQUsp65xpkBbFS4LwjzDkYIfLmF++hePb8z72Gz77FxhO5sRLGreSH227McyL/0CtWNKm9ZZIfQtZZjEZTj9+eiJMCloCMg3yWa1VBOiLHzz0wY6gGklccIImPyXEg7E0dIK8qYseJMhmmBNZ8pDOkbUDp3mRlrQ2iyClgQkbuR63j79IBUaCxmsa3NnrAtaJklzd9mzkHXfMBh2XT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ftYPCIxm40GQj6e77asNCAEElGssaUGKO3bjm348+oF9tR/eBOYWJQ8kL46IQLDRoop7UhG4ewY=");
// Comments this out for now, so it doesn't load the player profile
// A better way to do this would check for the properties when getting the skull or the skin

View File

@ -5,11 +5,13 @@ import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.powerplayclub.PowerPlayData;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import java.time.LocalDate;
import java.time.YearMonth;
public class PowerPlayCommand extends CommandBase<BonusManager>
{
@ -37,7 +39,8 @@ public class PowerPlayCommand extends CommandBase<BonusManager>
return;
}
_bonusManager.getPowerPlayClubRepository().Get(player).setSubscribed(true);
PowerPlayData cached = _bonusManager.getPowerPlayClubRepository().getCachedData(player);
cached.getUnclaimedMonths().add(YearMonth.now());
_bonusManager.getPowerPlayClubRepository().addSubscription(_bonusManager.getClientManager().Get(player).getAccountId(), LocalDate.now(), "month");
caller.sendMessage(ChatColor.GREEN + "Gave a month's subscription to " + player.getName());

View File

@ -20,11 +20,11 @@ public class PlayWireButton implements GuiItem
.setTitle(C.cGreen + C.Bold + "Watch an Ad!")
.addLore(
C.cWhite + "You have already redeemed your",
C.cWhite + "250 Shards for watching the Ad!",
C.cWhite + "100 Shards for watching the Ad!",
" ",
C.cWhite + "You can watch it again, but you won't earn any shards!",
" ",
C.cWhite + "You can watch the Ad once every 12 hours.",
C.cWhite + "You can watch the Ad once every hour.",
" ",
C.cWhite + "Ads help us keep Mineplex awesome",
C.cRedB + "Be sure to have your AdBlocker disabled!",
@ -36,10 +36,10 @@ public class PlayWireButton implements GuiItem
private static final ItemStack ENABLED_ICON = new ItemBuilder(Material.TRIPWIRE_HOOK)
.setTitle(C.cGreen + C.Bold + "Watch an Ad!")
.addLore(
C.cYellow + "Earn a 250 Shard Reward",
C.cYellow + "Earn a 100 Shard Reward",
C.cWhite + "by checking out our partner's Advertisement",
" ",
C.cWhite + "You can watch the Ad once every 12 hours.",
C.cWhite + "You can watch the Ad once every hour.",
" ",
C.cWhite + "Ads help us keep Mineplex awesome",
C.cRedB + "Be sure to have your AdBlocker disabled!",

View File

@ -1,13 +1,22 @@
package mineplex.core.bonuses.gui.buttons;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.gui.GuiItem;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.powerplayclub.PowerPlayClubRewards;
import mineplex.core.powerplayclub.PowerPlayData;
import mineplex.core.shop.item.ShopItem;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -15,8 +24,6 @@ import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
public class PowerPlayClubButton implements GuiItem
{
@ -24,6 +31,7 @@ public class PowerPlayClubButton implements GuiItem
private Player _player;
private PowerPlayClubRepository _powerPlayClubRepository;
private InventoryManager _inventoryManager;
private DonationManager _donationManager;
private BonusManager _bonusManager;
public PowerPlayClubButton(Player player, BonusManager manager)
@ -32,6 +40,7 @@ public class PowerPlayClubButton implements GuiItem
_bonusManager = manager;
_powerPlayClubRepository = manager.getPowerPlayClubRepository();
_inventoryManager = manager.getInventoryManager();
_donationManager = manager.getDonationManager();
}
@Override
@ -49,18 +58,18 @@ public class PowerPlayClubButton implements GuiItem
@Override
public void click(ClickType clickType)
{
if (isAvailable() && !_bonusManager.getPowerPlayClubRepository().alreadyClaimed(_player))
if (isAvailable())
{
_player.closeInventory();
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
PowerPlayClubRewards.giveAllItems(_player, _inventoryManager, _powerPlayClubRepository);
PowerPlayClubRewards.giveAllItems(_player, _donationManager, _inventoryManager, _powerPlayClubRepository);
}
else
{
_player.playSound(_player.getLocation(), Sound.ITEM_BREAK, 1, 10);
if (_powerPlayClubRepository.alreadyClaimed(_player))
if (_powerPlayClubRepository.getCachedData(_player).isSubscribed())
{
UtilPlayer.message(_player, F.main("Power Play Club", "Already claimed!"));
UtilPlayer.message(_player, F.main("Power Play Club", "Already claimed! Come back next month!"));
}
else
{
@ -77,58 +86,72 @@ public class PowerPlayClubButton implements GuiItem
private void setItem()
{
ArrayList<String> lore = new ArrayList<>();
Material material;
byte data = 0;
String itemName;
final Material material;
final String itemName;
final List<String> lore;
if (isAvailable())
PowerPlayData cached = _powerPlayClubRepository.getCachedData(_player);
List<YearMonth> unclaimed = cached.getUnclaimedMonths();
if (!unclaimed.isEmpty())
{
// Player has unclaimed rewards, even if s/he's not currently subscribed
material = Material.GOLD_INGOT;
itemName = C.cGreenB + "Power Play Club";
lore.add("");
lore.add(C.Reset + "Click to claim!");
}
else
lore = buildLore(unclaimed);
lore.add(" ");
lore.add(C.cGold + "Click to claim!");
} else if (cached.isSubscribed())
{
// Player is subscribed and has claimed all of his/her rewards
material = Material.REDSTONE_BLOCK;
itemName = C.cRedB + "Power Play Club";
}
lore.add(C.cYellow + "Rewards");
lore.add(" " + C.cWhite + "2 Game Amplifiers");
lore.add(" " + C.cWhite + "1 Omega Chest");
for (PowerPlayClubRewards.PowerPlayClubItem prize : PowerPlayClubRewards.septemberItems())
{
lore.add(" " + C.cWhite + prize.getAmount() + " " + prize.getPrize());
}
//lore.add(" ");
//lore.add(C.cYellow + "Months left: " + C.cWhite + getMonthsLeft(true)); //TODO: figure this out
if (!isAvailable())
lore = new ArrayList<>();
lore.add(C.cRed + "Already claimed!");
// TODO: 'come back later!'
} else
{
// Player isn't subscribed; show them the rewards for this current month and tell them to subscribe
material = Material.REDSTONE_BLOCK;
itemName = C.cRedB + "Power Play Club";
lore = buildLore(Collections.singletonList(YearMonth.now()));
lore.add(" ");
if (_powerPlayClubRepository.alreadyClaimed(_player))
{
lore.add(C.cRed + "Already claimed!");
}
else
{
lore.add(C.cRed + "Get Power Play Club months at");
lore.add(C.cAqua + "mineplex.com/shop");
}
lore.add(C.cRed + "Get Power Play Club months at");
lore.add(C.cAqua + "mineplex.com/shop");
}
_item = new ShopItem(material, data, itemName, lore.toArray(new String[0]), 1, false, false);
_item = new ShopItem(material, (byte)0, itemName, lore.toArray(new String[lore.size()]), 1, false, false);
}
private List<String> buildLore(List<YearMonth> unclaimed)
{
List<String> lore = new ArrayList<>();
lore.add(C.cYellow + "Rewards");
lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed.size()) + " Game Amplifier");
lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed.size()) + " Omega Chest");
PowerPlayClubRewards.rewardsForMonths(unclaimed).forEach(prize ->
{
lore.add(" " + C.cWhite + prize.getPrize());
});
return lore;
}
private boolean isAvailable()
{
return _powerPlayClubRepository.canClaim(_player);
return !_powerPlayClubRepository.getCachedData(_player).getUnclaimedMonths().isEmpty();
}
public static boolean isAvailable(Player player, PowerPlayClubRepository repo)
{
return repo.canClaim(player);
return !repo.getCachedData(player).getUnclaimedMonths().isEmpty();
}
}

View File

@ -1,16 +1,19 @@
package mineplex.core.command;
import com.google.common.collect.Lists;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.List;
public class CommandCenter implements Listener
{
public static CommandCenter Instance;
@ -18,7 +21,9 @@ public class CommandCenter implements Listener
protected JavaPlugin Plugin;
protected CoreClientManager ClientManager;
protected static NautHashMap<String, ICommand> Commands;
private final List<String> BLOCKED_COMMANDS = Lists.newArrayList("pl", "plugins", "ver", "version", "icanhasbukkit");
private final String MESSAGE = C.cRed + "I''m sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.";
public static void Initialize(JavaPlugin plugin)
{
if (Instance == null)
@ -53,7 +58,14 @@ public class CommandCenter implements Listener
commandName = commandName.split(" ")[0];
args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
}
if(BLOCKED_COMMANDS.contains(commandName.toLowerCase()))
{
event.setCancelled(true);
event.getPlayer().sendMessage(MESSAGE);
return;
}
ICommand command = Commands.get(commandName.toLowerCase());
if (command != null)

View File

@ -1,5 +1,9 @@
package mineplex.core.cosmetic.ui.page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
@ -15,6 +19,7 @@ import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.gadgets.morph.MorphWitch;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.HatGadget;
@ -31,10 +36,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
{
public GadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
@ -277,7 +278,15 @@ public class GadgetPage extends ShopPageBase<CosmeticManager, CosmeticShop>
//Standard
if (gadget.ownsGadget(getPlayer()))
{
ItemStack gadgetItemStack = new ItemStack(gadget.getDisplayMaterial(), 1, gadget.getDisplayData());
ItemStack gadgetItemStack;
if (gadget instanceof MorphWitch)
{
gadgetItemStack = ((MorphWitch) gadget).getWitchItem();
}
else
{
gadgetItemStack = new ItemStack(gadget.getDisplayMaterial(), 1, gadget.getDisplayData());
}
ItemMeta meta = gadgetItemStack.getItemMeta();
meta.setDisplayName(C.cGreen + C.Bold + gadget.getName());
if (gadget.getActive().contains(getPlayer()))

View File

@ -5,6 +5,7 @@ import java.util.function.Predicate;
import mineplex.core.gadget.event.PlayerToggleSwimEvent;
import mineplex.core.gadget.gadgets.morph.swim.SwimManager;
import mineplex.core.treasure.TreasureManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -206,6 +207,7 @@ public class GadgetManager extends MiniPlugin
private final HologramManager _hologramManager;
private final OutfitWindUpSuitBoosterManager _boosterManager;
private final IncognitoManager _incognitoManager;
private TreasureManager _treasureManager;
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
@ -341,8 +343,8 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphSnowman(this));
addGadget(new MorphUncleSam(this));
addGadget(new MorphSquid(this));
// Not being added in this update!
//addGadget(new MorphMetalMan(this));
addGadget(new MorphWitch(this));
//addGadget(new MorphMetalMan(this)); // Soon: reward for signup
// Particles
addGadget(new ParticleFoot(this));
@ -1152,4 +1154,14 @@ public class GadgetManager extends MiniPlugin
}
}
}
public void setTreasureManager(TreasureManager treasureManager)
{
_treasureManager = treasureManager;
}
public TreasureManager getTreasureManager()
{
return _treasureManager;
}
}

View File

@ -20,7 +20,7 @@ public class UnlockCosmeticsCommand extends CommandBase<GadgetManager>
public UnlockCosmeticsCommand(GadgetManager plugin)
{
super(plugin, Rank.JNR_DEV, new Rank[]{Rank.SNR_MODERATOR}, "unlockCosmetics");
super(plugin, Rank.JNR_DEV, "unlockCosmetics");
_plugin = plugin;
}

View File

@ -29,7 +29,8 @@ public class MorphMetalMan extends MorphGadget
public MorphMetalMan(GadgetManager manager)
{
super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE),
super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods",
"", C.cWhite + "Left-click to shoot laser beam"}, LineFormat.LORE),
0, Material.IRON_INGOT, (byte) 0);
}
@ -66,7 +67,10 @@ public class MorphMetalMan extends MorphGadget
if (!UtilEvent.isAction(event, UtilEvent.ActionType.L))
return;
if (!Recharge.Instance.use(player, getName(), 1000, false, false, "Cosmetics"))
if (player.getItemInHand().getType() != Material.AIR)
return;
if (!Recharge.Instance.use(player, getName(), 5000, true, false, "Cosmetics"))
return;
// Creates colored laser
@ -94,25 +98,9 @@ public class MorphMetalMan extends MorphGadget
{
color = _playerColors.get(player.getUniqueId());
}
MetalManEffect metalManEffect = new MetalManEffect(player.getEyeLocation(), loc, color, Manager.getPlugin());
MetalManEffect metalManEffect = new MetalManEffect(player.getEyeLocation(), loc, color, this, player);
increaseColor(player.getUniqueId());
metalManEffect.start();
// Creates the explosion and knockback players
loc.getWorld().createExplosion(loc, 0f);
UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers());
HashMap<Player, Double> players = UtilPlayer.getInRadius(loc, 12d);
for (Player ent : players.keySet())
{
if (Manager.collideEvent(player, this, ent))
continue;
double mult = players.get(ent);
//Knockback
UtilAction.velocity(ent, UtilAlg.getTrajectory(loc, ent.getLocation()), 2 * mult, false, 0, 1 + 1 * mult, 10, true);
}
}
public void increaseColor(UUID uuid)
@ -128,7 +116,7 @@ public class MorphMetalMan extends MorphGadget
}
else
{
_playerColors.put(uuid, 0);
_playerColors.put(uuid, 1);
}
}

View File

@ -0,0 +1,158 @@
package mineplex.core.gadget.gadgets.morph;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.*;
import mineplex.core.disguise.disguises.DisguiseWitch;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetSelectLocationEvent;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
public class MorphWitch extends MorphGadget
{
public MorphWitch(GadgetManager manager)
{
super(manager, "Witch Morph", UtilText.splitLinesToArray(new String[]{C.cWhite + "Press sneak to summon your trusty bat and start brewing"}, LineFormat.LORE), 0, Material.SKULL_ITEM, (byte) 3);
}
@Override
public void enableCustom(Player player, boolean message)
{
this.applyArmor(player, message);
DisguiseWitch disguiseWitch = new DisguiseWitch(player);
disguiseWitch.setName(player.getName(), Manager.getClientManager().Get(player).GetRank());
disguiseWitch.setCustomNameVisible(true);
Manager.getDisguiseManager().disguise(disguiseWitch);
}
@Override
public void disableCustom(Player player, boolean message)
{
this.removeArmor(player);
WitchEffectManager witchEffectManager = WitchEffectManager.getManager(player);
if (witchEffectManager != null)
{
witchEffectManager.stop();
}
Manager.getDisguiseManager().undisguise(player);
}
public ItemStack getWitchItem()
{
return SkinData.WITCH.getSkull();
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event)
{
WitchEffectManager witchEffectManager = WitchEffectManager.getManager(event.getPlayer());
if (!Recharge.Instance.usable(event.getPlayer(), "Witch Cauldron", true))
{
return;
}
if (!event.isSneaking())
return;
if (witchEffectManager != null)
{
if (witchEffectManager.hasStarted())
return;
}
if (!isActive(event.getPlayer()))
return;
if (!event.getPlayer().isOnGround())
{
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
// Checks if there is a block under the cauldron
Location cauldronLocation = event.getPlayer().getLocation().clone().add(event.getPlayer().getLocation().getDirection());
cauldronLocation.add(0, 1, 0);
if(cauldronLocation.getBlock().getType() != Material.AIR)
{
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
// Checks if player is opening a treasure chest/close to a treasure area
if (Manager.getTreasureManager() != null)
{
if (Manager.getTreasureManager().isOpening(event.getPlayer()))
{
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
}
// Checks if the player is close to a cactus
for (int x = -3; x < 3; x++)
{
for (int z = -3; z < 3; z++)
{
Location possibleCactus = cauldronLocation.clone().add(x, 0, z);
if (possibleCactus.getBlock().getType() == Material.CACTUS)
{
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
}
}
// Checks if the player is in a Soccer area
GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(event.getPlayer(), this, cauldronLocation.clone().subtract(0, 1, 0));
gadgetSelectLocationEvent.setShowMessage(true);
Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent);
if (gadgetSelectLocationEvent.isCancelled())
{
UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!"));
return;
}
if (!Recharge.Instance.use(event.getPlayer(), "Witch Cauldron", 15000, true, false, "Cosmetics"))
return;
WitchEffectManager newManager = new WitchEffectManager(event.getPlayer(), cauldronLocation);
newManager.start();
}
@EventHandler
public void onUpdate(UpdateEvent updateEvent)
{
if (updateEvent.getType() != UpdateType.TICK)
return;
long currentTime = System.currentTimeMillis();
long delay = 5000;
for (Player player : WitchEffectManager.getPlayers())
{
WitchEffectManager witchEffectManager = WitchEffectManager.getManager(player);
if (witchEffectManager != null)
{
if (witchEffectManager.hasStarted())
{
if (currentTime - witchEffectManager.getStarted() >= delay)
{
witchEffectManager.stop();
}
}
}
}
}
}

View File

@ -0,0 +1,80 @@
package mineplex.core.gadget.gadgets.morph;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import mineplex.core.common.util.UtilServer;
import mineplex.core.gadget.gadgets.particle.unrelated.WitchParticleEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Player;
public class WitchEffectManager
{
private static Map<Player, WitchEffectManager> _managers = new HashMap<>();
private Player _player;
private Bat _bat;
private Location _location;
private long _started = -1;
private WitchParticleEffect _witchParticleEffect;
public WitchEffectManager(Player player, Location location)
{
_player = player;
_location = location;
_managers.put(player, this);
}
public void start()
{
_started = System.currentTimeMillis();
_location.getBlock().setType(Material.CAULDRON);
_location.getBlock().setData((byte) 3);
_location.getWorld().strikeLightning(_location);
Bat bat = _location.getWorld().spawn(_location.clone().add(0, 1, 0), Bat.class);
bat.setCustomName(_player.getName() + "'s Magical Bat");
bat.setCustomNameVisible(true);
_bat = bat;
_witchParticleEffect = new WitchParticleEffect(_location, UtilServer.getPlugin());
_witchParticleEffect.start();
}
public void stop()
{
_bat.remove();
_location.getBlock().setType(Material.AIR);
_managers.remove(_player);
_witchParticleEffect.stop();
}
public boolean hasStarted()
{
return _started != -1;
}
public long getStarted()
{
return _started;
}
public static Set<Player> getPlayers()
{
return _managers.keySet();
}
public static WitchEffectManager getManager(Player player)
{
if (_managers.containsKey(player))
{
return _managers.get(player);
}
return null;
}
}

View File

@ -1,12 +1,15 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
import java.awt.*;
import java.util.HashMap;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.*;
import mineplex.core.common.util.particles.ColoredParticle;
import mineplex.core.common.util.particles.DustSpellColor;
import mineplex.core.gadget.types.Gadget;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class MetalManEffect extends Effect
@ -14,12 +17,18 @@ public class MetalManEffect extends Effect
private int _particles = 100;
private int _color;
private int _count = 0;
private Vector _vector;
private Location _fixedLoc;
private Gadget _gadget;
private Player _player;
public MetalManEffect(Location location, Location target, int color, JavaPlugin javaPlugin)
public MetalManEffect(Location location, Location target, int color, Gadget gadget, Player player)
{
super(20, new EffectLocation(location), javaPlugin);
super(-1, new EffectLocation(location), gadget.Manager.getPlugin());
_color = color;
_gadget = gadget;
_player = player;
setTargetLocation(new EffectLocation(target));
}
@ -35,16 +44,40 @@ public class MetalManEffect extends Effect
link.normalize();
Vector vector = link.multiply(length / _particles);
_vector = vector;
_fixedLoc = location.clone().subtract(_vector);
}
ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST,
new DustSpellColor((_color == 0) ? Color.YELLOW : Color.RED), _effectLocation.getLocation().clone());
Location loc = location.clone().subtract(_vector);
for (int i = 0; i < _particles; i++)
{
loc.add(_vector);
coloredParticle.setLocation(loc);
for (int i = 0; i < 5; i++){
_fixedLoc.add(_vector);
coloredParticle.setLocation(_fixedLoc);
coloredParticle.display(UtilParticle.ViewDist.LONG);
}
if (_fixedLoc.getBlock().getType() != Material.AIR || _count == 1000)
{
explode();
}
_count += 5;
}
private void explode()
{
this.stop();
// Creates the explosion and knockback players
Location loc = _fixedLoc;
loc.getWorld().createExplosion(loc, 0f);
UtilParticle.PlayParticle(UtilParticle.ParticleType.EXPLODE, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers());
HashMap<Player, Double> players = UtilPlayer.getInRadius(loc, 5d);
for (Player ent : players.keySet())
{
if (_gadget.Manager.collideEvent(_player, _gadget, ent))
continue;
double mult = players.get(ent);
//Knockback
UtilAction.velocity(ent, UtilAlg.getTrajectory(loc, ent.getLocation()), 2 * mult, false, 0, 1 + 1 * mult, 10, true);
}
}
}

View File

@ -0,0 +1,25 @@
package mineplex.core.gadget.gadgets.particle.unrelated;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilServer;
import org.bukkit.Location;
import org.bukkit.plugin.java.JavaPlugin;
public class WitchParticleEffect extends Effect
{
public WitchParticleEffect(Location location, JavaPlugin javaPlugin)
{
super(-1, new EffectLocation(location), javaPlugin);
_delay = 5;
}
@Override
public void runEffect()
{
UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, _effectLocation.getLocation().clone(),
1f, 1f, 1f, 0f, 20,
UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers());
}
}

View File

@ -6,6 +6,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.PlayerQuitEvent;
/**
* Listener for the Menu system
@ -13,64 +14,70 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
public class MenuListener implements Listener
{
@EventHandler
public void onClick(InventoryClickEvent event)
{
String name = event.getInventory().getName();
Player player = (Player) event.getWhoClicked();
Menu gui = Menu.get(player.getUniqueId());
@EventHandler
public void onClick(InventoryClickEvent event)
{
String name = event.getInventory().getName();
Player player = (Player) event.getWhoClicked();
Menu gui = Menu.get(player.getUniqueId());
if (gui == null)
{
return;
}
if (gui == null)
{
return;
}
if (!gui.getName().equalsIgnoreCase(name))
{
return;
}
if (!gui.getName().equalsIgnoreCase(name))
{
return;
}
Button button = gui.getButton(event.getRawSlot());
Button button = gui.getButton(event.getRawSlot());
event.setCancelled(true);
event.setResult(Event.Result.DENY);
event.setCancelled(true);
event.setResult(Event.Result.DENY);
if (button == null)
{
return;
}
if (button == null)
{
return;
}
if(button.useItemClick())
{
button.onClick(player, event.getClick(), event.getCurrentItem());
return;
}
if(button.useItemClick())
{
button.onClick(player, event.getClick(), event.getCurrentItem());
return;
}
button.onClick(player, event.getClick());
}
button.onClick(player, event.getClick());
}
@EventHandler
@EventHandler
public void onClose(InventoryCloseEvent event)
{
String name = event.getInventory().getName();
Player player = (Player) event.getPlayer();
Menu gui = Menu.get(player.getUniqueId());
{
String name = event.getInventory().getName();
Player player = (Player) event.getPlayer();
Menu gui = Menu.get(player.getUniqueId());
if (gui == null)
{
return;
}
if (gui == null)
{
return;
}
if (!gui.getName().equalsIgnoreCase(name))
{
return;
}
if (!gui.getName().equalsIgnoreCase(name))
{
return;
}
if(gui.isUseClose())
{
gui.onClose(player);
gui.setUseClose(false);
}
}
if(gui.isUseClose())
{
gui.onClose(player);
gui.setUseClose(false);
}
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
Menu.remove(event.getPlayer().getUniqueId());
}
}

View File

@ -22,7 +22,7 @@ import java.util.UUID;
public class PlayWireManager extends MiniDbClientPlugin<PlayWireClientData>
{
private final long COOL_DOWN = TimeUnit.HOURS.getMilliseconds() * 12;
private final long COOL_DOWN = TimeUnit.HOURS.getMilliseconds();
private static final int REWARD_MESSAGE_DELAY_SECONDS = 10;
private final DonationManager _donationManager;
@ -72,7 +72,7 @@ public class PlayWireManager extends MiniDbClientPlugin<PlayWireClientData>
_repository.attemptPlayWire(player, client, () ->
{
_donationManager.RewardCoinsLater("Watching Ad", player, 250);
_donationManager.RewardCoinsLater("Watching Ad", player, 100);
Bukkit.getScheduler().runTaskLater(getClientManager().getPlugin(), () -> UtilPlayer.message(player, ResponseType.COUNTED.getMessage()), REWARD_MESSAGE_DELAY_SECONDS * 20L);
});
}

View File

@ -1,26 +0,0 @@
package mineplex.core.powerplayclub;
public class PPCPlayerData {
private boolean _subscribed;
private boolean _claimed;
public void setSubscribed(boolean subscribed)
{
_subscribed = subscribed;
}
public void setClaimed(boolean claimed)
{
_claimed = claimed;
}
public boolean hasClaimed()
{
return _claimed;
}
public boolean hasSubscribed()
{
return _subscribed;
}
}

View File

@ -1,26 +1,39 @@
package mineplex.core.powerplayclub;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.serverdata.database.DBPool;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.*;
import java.sql.Date;
import java.time.LocalDate;
import java.util.UUID;
import java.time.YearMonth;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
public class PowerPlayClubRepository implements Listener {
// Data loaded by the first ILoginProcessor, waiting for the second
private final Map<UUID, List<YearMonth>> _stageOneDataClaims = new HashMap<>();
// Cached data produced by combining the first and second ILoginProcessors.
// This data is not guaranteed to be fresh, and should be recalculated before
// giving a player his/her rewards.
private final Map<UUID, PowerPlayData> _cachedPlayerData = new HashMap<>();
private final CoreClientManager _clientManager;
public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager) {
super("PowerPlayClubRepository", plugin);
_clientManager = clientManager;
Bukkit.getPluginManager().registerEvents(this, plugin);
clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor() {
@Override
public String getName() {
@ -29,7 +42,12 @@ public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException {
PowerPlayClubRepository.this.Get(uuid).setClaimed(resultSet.next());
List<YearMonth> claims = new ArrayList<>();
while (resultSet.next())
{
claims.add(YearMonth.of(resultSet.getInt("claimYear"), resultSet.getInt("claimMonth")));
}
_stageOneDataClaims.put(uuid, claims);
}
@Override
@ -46,7 +64,16 @@ public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException {
PowerPlayClubRepository.this.Get(uuid).setSubscribed(resultSet.next());
List<PowerPlayData.Subscription> subscriptions = new ArrayList<>();
while (resultSet.next())
{
LocalDate date = resultSet.getDate("startDate").toLocalDate();
PowerPlayData.SubscriptionDuration duration = PowerPlayData.SubscriptionDuration.valueOf(resultSet.getString("duration").toUpperCase());
subscriptions.add(new PowerPlayData.Subscription(date, duration));
}
// Now that we have the claims from the first processor and subscriptions from this one, combine them
_cachedPlayerData.put(uuid, PowerPlayData.fromSubsAndClaims(subscriptions, _stageOneDataClaims.remove(uuid)));
}
@Override
@ -56,6 +83,13 @@ public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
});
}
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
_stageOneDataClaims.remove(event.getPlayer().getUniqueId()); // Just in case.
_cachedPlayerData.remove(event.getPlayer().getUniqueId());
}
public CompletableFuture<Void> addSubscription(int accountId, LocalDate date, String duration)
{
return CompletableFuture.supplyAsync(() ->
@ -101,35 +135,17 @@ public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
});
}
public boolean alreadyClaimed(Player player)
public CompletableFuture<PowerPlayData> loadData(Player player)
{
return Get(player).hasClaimed();
return loadData(_clientManager.Get(player).getAccountId());
}
public boolean canClaim(Player player)
public CompletableFuture<PowerPlayData> loadData(int accountId)
{
return Get(player).hasSubscribed() && !Get(player).hasClaimed();
return loadSubscriptions(accountId).thenCombine(loadClaimMonths(accountId), PowerPlayData::fromSubsAndClaims);
}
public CompletableFuture<Boolean> hasSubscription(int accountId)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlaySubs WHERE accountId = ?");
statement.setInt(1, accountId);
return statement.executeQuery().next();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
});
}
public CompletableFuture<Boolean> hasClaimed(int accountId)
public CompletableFuture<List<YearMonth>> loadClaimMonths(int accountId)
{
return CompletableFuture.supplyAsync(() ->
{
@ -137,18 +153,58 @@ public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
{
PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlayClaims WHERE accountId = ?");
statement.setInt(1, accountId);
return statement.executeQuery().next();
ResultSet resultSet = statement.executeQuery();
} catch (SQLException e) {
e.printStackTrace();
List<YearMonth> claims = new ArrayList<>();
while (resultSet.next())
{
claims.add(YearMonth.of(resultSet.getInt("claimYear"), resultSet.getInt("claimMonth")));
}
return claims;
} catch (SQLException e)
{
throw new CompletionException(e);
}
return false;
});
}
@Override
protected PPCPlayerData addPlayer(UUID uuid) {
return new PPCPlayerData();
public CompletableFuture<List<PowerPlayData.Subscription>> loadSubscriptions(int accountId)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlaySubs WHERE accountId = ?");
statement.setInt(1, accountId);
ResultSet resultSet = statement.executeQuery();
List<PowerPlayData.Subscription> subscriptions = new ArrayList<>();
while (resultSet.next())
{
LocalDate date = resultSet.getDate("startDate").toLocalDate();
PowerPlayData.SubscriptionDuration duration = PowerPlayData.SubscriptionDuration.valueOf(resultSet.getString("duration").toUpperCase());
subscriptions.add(new PowerPlayData.Subscription(date, duration));
}
return subscriptions;
} catch (SQLException e)
{
throw new CompletionException(e);
}
});
}
public PowerPlayData getCachedData(Player player)
{
return _cachedPlayerData.get(player.getUniqueId());
}
public void putCachedData(Player player, PowerPlayData data)
{
if (player.isOnline())
{
_cachedPlayerData.put(player.getUniqueId(), data);
}
}
}

View File

@ -1,78 +1,42 @@
package mineplex.core.powerplayclub;
import java.time.Month;
import java.time.YearMonth;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableMap;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.skin.SkinData;
import mineplex.core.common.util.BukkitFuture;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.data.Item;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.time.Month;
import java.time.Year;
import java.util.*;
public class PowerPlayClubRewards
{
private static final Map<RewardMonth, List<PowerPlayClubItem>> rewards = new HashMap<>();
public static final int AMPLIFIERS_PER_MONTH = 2;
public static final int CHESTS_PER_MONTH = 1;
static
{
setRewards(2016, Month.SEPTEMBER, new PowerPlayClubItem("Squid Morph", 1, new ItemStack(Material.INK_SACK)));
}
public static List<PowerPlayClubItem> septemberItems() // TODO: figure this out
{
return rewards.values().iterator().next();
}
private static void setRewards(int year, Month month, PowerPlayClubItem... items)
{
rewards.put(new RewardMonth(Year.of(year), month), Arrays.asList(items));
}
private static class RewardMonth
{
private final Year year;
private final Month month;
static RewardMonth of(Year year, Month month)
{
return new RewardMonth(year, month);
}
RewardMonth(Year year, Month month)
{
this.year = year;
this.month = month;
}
@Override
public boolean equals(Object obj) {
if (obj == null || getClass() != obj.getClass()) return false;
RewardMonth that = (RewardMonth) obj;
return Objects.equals(this.year, that.year) && Objects.equals(this.month, that.month);
}
@Override
public int hashCode() {
return Objects.hash(year, month);
}
}
private static final Map<YearMonth, PowerPlayClubItem> rewards = ImmutableMap.<YearMonth, PowerPlayClubItem>builder()
.put(YearMonth.of(2016, Month.SEPTEMBER), new PowerPlayClubItem("Squid Morph", new ItemStack(Material.INK_SACK)))
.put(YearMonth.of(2016, Month.OCTOBER), new PowerPlayClubItem("Witch Morph", SkinData.WITCH.getSkull()))
.build();
public static class PowerPlayClubItem
{
private final String _prize;
private final int _amount;
private final ItemStack _display;
public PowerPlayClubItem(String prize, int amount, ItemStack display)
PowerPlayClubItem(String prize, ItemStack display)
{
_prize = prize;
_amount = amount;
_display = display;
}
@ -81,67 +45,69 @@ public class PowerPlayClubRewards
return _prize;
}
public int getAmount()
{
return _amount;
}
public ItemStack getDisplay()
{
return _display;
}
}
public static List<PowerPlayClubItem> rewardsForMonths(List<YearMonth> months)
{
return months.stream().map(rewards::get).collect(Collectors.toList());
}
public static void giveAllItems(Player player, InventoryManager manager, PowerPlayClubRepository repo)
public static void giveAllItems(Player player, DonationManager donationManager, InventoryManager inventoryManager, PowerPlayClubRepository repo)
{
UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription.."));
repo.attemptClaim(player).thenCompose(BukkitFuture.accept(success ->
repo.attemptClaim(player).thenCompose(success ->
{
if (!success)
{
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
return;
return CompletableFuture.completedFuture(null);
}
repo.Get(player).setClaimed(true);
PowerPlayData cached = repo.getCachedData(player);
List<PowerPlayClubItem> items = rewardsForMonths(cached.getUnclaimedMonths());
for (PowerPlayClubItem item : septemberItems()) // TODO: figure this out
// Give normal power play items
items.forEach(item ->
{
Item fItem = manager.getItem(item.getPrize());
if (fItem == null)
{
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
}
else
{
manager.addItemToInventory(player, fItem.Name, 1);
UtilPlayer.message(player, F.main("Power Play Club", "You received " + item.getAmount() + "x " + F.elem(item.getPrize()) + "."));
}
}
Item gameAmplifier = manager.getItem("Game Booster");
donationManager.PurchaseUnknownSalesPackage(null, player.getName(),
donationManager.getClientManager().Get(player).getAccountId(), item.getPrize(),
GlobalCurrency.TREASURE_SHARD, 0, true);
UtilPlayer.message(player, F.main("Power Play Club", "You received the " +
F.elem(item.getPrize()) + "."));
});
// Give amplifiers and chests
Item gameAmplifier = inventoryManager.getItem("Game Booster");
if (gameAmplifier == null)
{
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
}
else
{
manager.addItemToInventory(player, gameAmplifier.Name, 2);
UtilPlayer.message(player, F.main("Power Play Club", "You received 2x " + F.elem("Game Boosters") + "."));
inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * items.size());
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * items.size()) + "x " + F.elem("Game Amplifier") + "."));
}
Item omegaChest = manager.getItem("Omega Chest");
Item omegaChest = inventoryManager.getItem("Omega Chest");
if (omegaChest == null)
{
UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!"));
}
else
{
manager.addItemToInventory(player, omegaChest.Name, 1);
UtilPlayer.message(player, F.main("Power Play Club", "You received 1x " + F.elem("Omega Chest") + "."));
inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * items.size());
UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * items.size()) + "x " + F.elem("Omega Chest") + "."));
}
}));
// Refresh Power Play data on the server
return repo.loadData(player).thenCompose(BukkitFuture.accept(data -> repo.putCachedData(player, data)));
});
}
}

View File

@ -0,0 +1,116 @@
package mineplex.core.powerplayclub;
import com.google.common.base.Objects;
import java.time.LocalDate;
import java.time.YearMonth;
import java.util.*;
import java.util.stream.Collectors;
public class PowerPlayData
{
private final boolean _subscribed;
private final List<YearMonth> _unclaimedMonths;
static PowerPlayData fromSubsAndClaims(List<Subscription> subscriptions, List<YearMonth> claimedMonths)
{
if (subscriptions.isEmpty())
{
return new PowerPlayData(false, Collections.emptyList());
}
// Build the list of potential claim dates from subscriptions
List<LocalDate> claimDates = subscriptions.stream()
.flatMap(sub -> buildMonths(sub).stream())
.sorted()
.collect(Collectors.toCollection(LinkedList::new));
// Determine if player is subscribed
LocalDate latestSub = claimDates.get(claimDates.size() - 1);
final boolean subscribed = latestSub.plusMonths(1).isAfter(LocalDate.now());
// Remove already-claimed months
Optional<YearMonth> latestClaimed = claimedMonths.stream().collect(Collectors.maxBy(YearMonth::compareTo));
latestClaimed.ifPresent(latest ->
{
while (!claimDates.isEmpty())
{
LocalDate claimDate = claimDates.get(0);
YearMonth claimMonth = YearMonth.from(claimDate);
if (latest.equals(claimMonth) || latest.isAfter(claimMonth))
{
claimDates.remove(0);
} else
{
break;
}
}
});
List<YearMonth> unclaimedMonths = claimDates.stream()
.filter(date -> date.isBefore(LocalDate.now()) || date.equals(LocalDate.now())) // Filter dates yet to come
.map(YearMonth::from)
.distinct()
.collect(Collectors.toList());
return new PowerPlayData(subscribed, unclaimedMonths);
}
private static List<LocalDate> buildMonths(Subscription subscription)
{
switch (subscription._duration)
{
case MONTH:
return Collections.singletonList(subscription._startDate);
case YEAR:
List<LocalDate> months = new ArrayList<>();
for (int i = 0; i < 12; i++)
{
months.add(subscription._startDate.plusMonths(i));
}
return months;
default:
throw new IllegalStateException("Invalid duration");
}
}
static class Subscription {
private final LocalDate _startDate;
private final SubscriptionDuration _duration;
Subscription(LocalDate startDate, SubscriptionDuration duration)
{
_startDate = startDate;
_duration = duration;
}
}
enum SubscriptionDuration {
MONTH, YEAR
}
private PowerPlayData(boolean subscribed, List<YearMonth> unclaimedMonths)
{
_subscribed = subscribed;
_unclaimedMonths = unclaimedMonths;
}
public List<YearMonth> getUnclaimedMonths()
{
return _unclaimedMonths;
}
public boolean isSubscribed()
{
return _subscribed;
}
@Override
public String toString()
{
return Objects.toStringHelper(this).add("subscribed", _subscribed).add("unclaimed", _unclaimedMonths).toString();
}
}

View File

@ -1,6 +1,5 @@
package mineplex.core.treasure;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Lists;
@ -63,6 +62,8 @@ public class TreasureManager extends MiniPlugin
{
_plugin.getServer().getPluginManager().registerEvents(treasureLocation, _plugin);
}
gadgetManager.setTreasureManager(this);
}
private Block[] setup(Block chestBlock)
@ -145,4 +146,9 @@ public class TreasureManager extends MiniPlugin
{
return _clientManager;
}
public List<TreasureLocation> getTreasureLocations()
{
return _treasureLocations;
}
}

View File

@ -398,8 +398,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
{
loadClan(token);
loadClan(token, false);
}
_bannerManager.loadBanners(this);
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "Replay|Restrict");
@ -475,7 +476,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
addCommand(new SpeedCommand(this));
}
public void loadClan(ClanToken clanToken)
public void loadClan(ClanToken clanToken, boolean loadBanner)
{
ClanInfo clan = new ClanInfo(this, clanToken);
_clanMap.put(clanToken.Name, clan);
@ -489,7 +490,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
for (ClanTerritoryToken territoryToken : clanToken.Territories)
_claimMap.put(territoryToken.Chunk, new ClanTerritory(territoryToken));
_bannerManager.loadBanner(clan);
if (loadBanner)
_bannerManager.loadBanner(clan);
}
public void loadClan(ClanToken clanToken)
{
loadClan(clanToken, true);
}
public DisguiseManager getDisguiseManager()

View File

@ -83,6 +83,15 @@ public class BannerManager extends MiniPlugin
_repo.loadBanner(LoadedBanners, clan);
}
/**
* Loads all banners for this clans server
* @param manager The Clans Manager instance triggering this load
*/
public void loadBanners(ClansManager manager)
{
_repo.loadBanners(LoadedBanners, manager);
}
/**
* Saves a banner to the database
* @param banner The banner to save
@ -238,4 +247,4 @@ public class BannerManager extends MiniPlugin
event.getItemDrop().remove();
}
}
}
}

View File

@ -7,6 +7,7 @@ import java.util.List;
import mineplex.core.database.MinecraftRepository;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
@ -26,6 +27,7 @@ public class BannerRepository extends MinecraftRepository
+ "PRIMARY KEY (clanId));";
private static final String GET_BANNER_BY_CLAN = "SELECT * FROM clanBanners WHERE clanId=? LIMIT 1;";
private static final String GET_BANNERS_BY_SERVER = "SELECT clans.name, clanBanners.baseColor, clanBanners.patterns FROM clans INNER JOIN clanBanners ON clans.id=clanBanners.clanId AND clans.serverId=?;";
private static final String INSERT_BANNER = "INSERT INTO clanBanners (clanId, baseColor, patterns) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE baseColor=VALUES(baseColor), patterns=VALUES(patterns);";
private static final String DELETE_BANNER = "DELETE FROM clanBanners WHERE clanId=?;";
@ -82,6 +84,52 @@ public class BannerRepository extends MinecraftRepository
});
}
/**
* Loads all banners for a certain clans server into a given hashmap
* @param map The hashmap to load the banner into
* @param clan The clan whose banner to fetch
*/
public void loadBanners(final HashMap<String, ClanBanner> map, ClansManager clanManager)
{
_bannerManager.runAsync(() ->
{
executeQuery(GET_BANNERS_BY_SERVER, resultSet ->
{
while(resultSet.next())
{
String clanName = resultSet.getString("name");
DyeColor baseColor = DyeColor.valueOf(resultSet.getString("baseColor"));
List<String> patternStrs = Arrays.asList(resultSet.getString("patterns").split("/"));
LinkedList<BannerPattern> patterns = new LinkedList<>();
int layer = 1;
for (String patternStr : patternStrs)
{
if (patternStr.equalsIgnoreCase("Blank"))
{
patterns.add(new BannerPattern(layer));
}
else
{
try
{
DyeColor patternColor = DyeColor.valueOf(patternStr.split(",")[0]);
PatternType patternType = PatternType.valueOf(patternStr.split(",")[1]);
patterns.add(new BannerPattern(layer, patternColor, patternType));
}
catch (Exception e)
{
e.printStackTrace();
patterns.add(new BannerPattern(layer));
}
}
layer++;
}
map.put(clanName, new ClanBanner(_bannerManager, clanManager.getClanMap().get(clanName), baseColor, patterns));
}
}, new ColumnInt("serverId", clanManager.getServerId()));
});
}
/**
* Saves a banner into the database
* @param banner The banner to save
@ -118,9 +166,9 @@ public class BannerRepository extends MinecraftRepository
@Override
protected void initialize()
{
executeUpdate(CREATE);
//executeUpdate(CREATE);
}
@Override
protected void update() {}
}
}

View File

@ -1,5 +1,7 @@
package mineplex.game.clans.clans.siege;
import java.util.Stack;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
@ -43,6 +45,8 @@ public class SiegeManager extends MiniPlugin
private SiegeWeaponRepository _repository;
private long _lastDatabaseSave = -1L;
public SiegeManager(ClansManager clans)
{
super("Siege Manager", clans.getPlugin());
@ -136,8 +140,12 @@ public class SiegeManager extends MiniPlugin
if (event.getType() == UpdateType.SLOW)
{
_outpostManager.saveOutposts();
saveSiegeWeapons();
if (UtilTime.elapsed(_lastDatabaseSave, 10000))
{
_lastDatabaseSave = System.currentTimeMillis();
_outpostManager.saveOutposts();
saveSiegeWeapons();
}
for (Entity entity : Spawn.getSpawnWorld().getEntitiesByClass(ArmorStand.class))
{
@ -184,17 +192,22 @@ public class SiegeManager extends MiniPlugin
private void saveSiegeWeapons()
{
final Stack<Runnable> queue = new Stack<>();
for (final SiegeWeapon weapon : LiveSiegeWeapons.values())
{
final SiegeWeaponToken token = weapon.toToken();
if (UnsyncedSiegeWeapons.containsKey(Integer.valueOf(token.UniqueId)))
continue;
runAsync(() -> {
_repository.updateWeapon(token);
});
queue.push(() -> _repository.updateWeapon(token));
}
runAsync(() -> {
while (!queue.isEmpty())
queue.pop().run();
});
}
@EventHandler
@ -307,5 +320,4 @@ public class SiegeManager extends MiniPlugin
{
return _repository;
}
}

View File

@ -146,25 +146,23 @@ public class SiegeWeaponRepository extends MinecraftRepository
public void insertWeapon(SiegeWeaponToken token)
{
System.out.println("Siege Repo> Inserting new weapon " + token.UniqueId);
_siegeManager.runAsync(() ->
executeUpdate(INSERT_WEAPON,
new ColumnInt("uniqueId", token.UniqueId),
new ColumnInt("serverId", _siegeManager.getClansManager().getServerId()),
new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)),
new ColumnInt("ownerClan", token.OwnerClan.getId()),
new ColumnInt("weaponType", token.WeaponType),
new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnVarChar("entities", 100, ""))
);
executeUpdate(INSERT_WEAPON,
new ColumnInt("uniqueId", token.UniqueId),
new ColumnInt("serverId", _siegeManager.getClansManager().getServerId()),
new ColumnVarChar("location", 30, UtilWorld.locToStr(token.Location)),
new ColumnInt("ownerClan", token.OwnerClan.getId()),
new ColumnInt("weaponType", token.WeaponType),
new ColumnInt("health", token.Health),
new ColumnInt("yaw", token.Yaw),
new ColumnTimestamp("lastFired", new Timestamp(token.LastFired)),
new ColumnVarChar("entities", 100, ""));
}
@Override
protected void initialize()
{
executeUpdate(CREATE);
//executeUpdate(CREATE);
}
@Override

View File

@ -2,6 +2,7 @@ package mineplex.staffServer.customerSupport;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
@ -9,6 +10,7 @@ import java.util.List;
import java.util.Locale;
import java.util.UUID;
import mineplex.core.powerplayclub.PowerPlayData;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -118,8 +120,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
{
_repository.loadBonusLogForAccountId(client.getAccountId(), instance);
boolean powerPlaySub = _powerPlayRepo.hasSubscription(client.getAccountId()).join();
boolean powerPlayClaim = _powerPlayRepo.hasClaimed(client.getAccountId()).join();
PowerPlayData powerPlayData = _powerPlayRepo.loadData(client.getAccountId()).join();
boolean powerPlaySub = powerPlayData.isSubscribed();
boolean powerPlayClaim = powerPlaySub && !powerPlayData.getUnclaimedMonths().contains(YearMonth.now());
runSync(new Runnable()
{

View File

@ -2,7 +2,6 @@ package nautilus.game.arcade;
import mineplex.core.Managers;
import mineplex.core.MiniPlugin;
import mineplex.core.PlayerSelector;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -18,7 +17,6 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilLambda;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.cosmetic.CosmeticManager;
@ -68,8 +66,6 @@ import mineplex.core.teleport.Teleport;
import mineplex.core.thank.ThankManager;
import mineplex.core.timing.TimingManager;
import mineplex.core.titangiveaway.TitanGiveawayManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.valentines.ValentinesGiftManager;
import mineplex.core.youtube.YoutubeManager;
import mineplex.minecraft.game.classcombat.Class.ClassManager;
@ -1960,22 +1956,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
}
}
@EventHandler
public void teleportPlayersToSpawn(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTEST)
return;
PlayerSelector
.selectPlayers(
UtilLambda.and(
PlayerSelector.inWorld(Bukkit.getWorld("world")),
UtilLambda.not(PlayerSelector.within(GetLobby().getSpawn(), 70))
)
)
.forEach(player -> player.teleport(GetLobby().getSpawn()));
}
@EventHandler
public void clearGameTeams(GameStateChangeEvent event)
{

View File

@ -158,6 +158,8 @@ public class Minestrike extends TeamGame
this.DontAllowOverfill = true;
this.AllowEntitySpectate = false;
_scoreObj = Scoreboard.getScoreboard().registerNewObjective("HP", "dummy");
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
@ -1053,7 +1055,12 @@ public class Minestrike extends TeamGame
return;
}
Manager.getCosmeticManager().getGadgetManager().getActive(event.getPlayer(), GadgetType.COSTUME).disable(event.getPlayer());
Gadget activeCostume = Manager.getCosmeticManager().getGadgetManager().getActive(event.getPlayer(), GadgetType.COSTUME);
if (activeCostume != null)
{
activeCostume.disable(event.getPlayer());
}
//Target Team
GameTeam targetTeam = null;

View File

@ -3,6 +3,8 @@ package nautilus.game.arcade.managers;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
@ -26,32 +28,54 @@ import nautilus.game.arcade.game.Game.GameState;
public class IdleManager implements Listener
{
private final ArcadeManager _arcadeManager;
private final Map<Player, Float> _yaw = new HashMap<>();
private final Map<Player, Long> _idle = new HashMap<>();
private final Map<Player, Integer> _beep = new HashMap<>();
private final HashSet<Player> _teleported = new HashSet();
private final Map<UUID, Float> _yaw = new HashMap<>();
private final Map<UUID, Long> _idle = new HashMap<>();
private final Map<UUID, Integer> _beep = new HashMap<>();
private final Set<UUID> _teleported = new HashSet<>();
public IdleManager(ArcadeManager manager)
{
_arcadeManager = manager;
Bukkit.getPluginManager().registerEvents(this, getArcadeManager().getPlugin());
UtilServer.RegisterEvents(this);
}
@EventHandler
public void ChatIdle(final AsyncPlayerChatEvent event)
public void onPlayerQuit(PlayerQuitEvent event)
{
if (!getArcadeManager().IsPlayerKickIdle())
return;
Bukkit.getServer().getScheduler().runTaskLater(getArcadeManager().getPlugin(), new Runnable()
_yaw.remove(event.getPlayer().getUniqueId());
_idle.remove(event.getPlayer().getUniqueId());
_beep.remove(event.getPlayer().getUniqueId());
_teleported.remove(event.getPlayer().getUniqueId());
}
@EventHandler
public void playerTeleport(PlayerTeleportEvent event)
{
_teleported.add(event.getPlayer().getUniqueId());
_arcadeManager.runSyncLater(() ->
{
@Override
public void run()
if (event.getPlayer().isOnline())
{
_idle.put(event.getPlayer(), System.currentTimeMillis());
_yaw.put(event.getPlayer().getUniqueId(), event.getPlayer().getLocation().getYaw());
_teleported.remove(event.getPlayer().getUniqueId());
}
}, 1);
}, 5);
}
@EventHandler
public void idleChat(final AsyncPlayerChatEvent event)
{
if (!_arcadeManager.IsPlayerKickIdle())
return;
_arcadeManager.runSyncLater(() ->
{
if (event.getPlayer().isOnline())
{
_idle.put(event.getPlayer().getUniqueId(), System.currentTimeMillis());
}
}, 1L);
}
@EventHandler
@ -59,100 +83,71 @@ public class IdleManager implements Listener
{
if (event.getType() != UpdateType.FAST)
return;
if (!getArcadeManager().IsPlayerKickIdle())
return;
if (getArcadeManager().GetGame() == null)
if (!_arcadeManager.IsPlayerKickIdle())
return;
for (Player player : UtilServer.getPlayers())
if (_arcadeManager.GetGame() == null)
return;
for (Player player : UtilServer.getPlayersCollection())
{
if (_teleported.contains(player))
if (_teleported.contains(player.getUniqueId()))
continue;
if (!_yaw.containsKey(player) || !_idle.containsKey(player))
if (!_yaw.containsKey(player.getUniqueId()) || !_idle.containsKey(player.getUniqueId()))
{
_yaw.put(player, player.getLocation().getYaw());
_idle.put(player, System.currentTimeMillis());
_yaw.put(player.getUniqueId(), player.getLocation().getYaw());
_idle.put(player.getUniqueId(), System.currentTimeMillis());
}
if (_yaw.get(player) == player.getLocation().getYaw())
{
if (UtilTime.elapsed(_idle.get(player), getArcadeManager().GetGame().IsLive() ? 240000 : 120000))
if (_yaw.get(player.getUniqueId()) == player.getLocation().getYaw())
{
if (UtilTime.elapsed(_idle.get(player.getUniqueId()), _arcadeManager.GetGame().IsLive() ? 240000 : 120000))
{
if (getArcadeManager().GetGame().GetState() != GameState.Recruit && !getArcadeManager().GetGame().IsAlive(player))
if (_arcadeManager.GetGame().GetState() != GameState.Recruit && !_arcadeManager.GetGame().IsAlive(player))
continue;
if (getArcadeManager().GetClients().Get(player).GetRank().has(Rank.MODERATOR))
if (_arcadeManager.GetClients().Get(player).GetRank().has(Rank.MODERATOR))
continue;
//Start Beeps
if (!_beep.containsKey(player))
if (!_beep.containsKey(player.getUniqueId()))
{
_beep.put(player, 20);
_beep.put(player.getUniqueId(), 20);
}
//Countdown
else
{
int count = _beep.get(player);
int count = _beep.get(player.getUniqueId());
if (count == 0)
{
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
getArcadeManager().GetPortal().sendPlayerToServer(player, "Lobby");
_arcadeManager.GetPortal().sendPlayerToServer(player, "Lobby");
}
else
{
float scale = (float) (0.8 + (((double)count/20d)*1.2));
{
float scale = (float) (0.8 + (((double) count / 20d) * 1.2));
player.playSound(player.getLocation(), Sound.NOTE_PLING, scale, scale);
if (count%2 == 0)
if (count % 2 == 0)
{
UtilPlayer.message(player, C.cGold + C.Bold + "You will be AFK removed in " + (count/2) + " seconds...");
UtilPlayer.message(player, C.cGold + C.Bold + "You will be AFK removed in " + (count / 2) + " seconds...");
}
count--;
_beep.put(player, count);
_beep.put(player.getUniqueId(), count);
}
}
}
}
continue;
}
_yaw.put(player, player.getLocation().getYaw());
_idle.put(player, System.currentTimeMillis());
_beep.remove(player);
else
{
_yaw.put(player.getUniqueId(), player.getLocation().getYaw());
_idle.put(player.getUniqueId(), System.currentTimeMillis());
_beep.remove(player.getUniqueId());
}
}
}
@EventHandler
public void playerTeleport(PlayerTeleportEvent event)
{
_teleported.add(event.getPlayer());
_arcadeManager.runSyncLater(new Runnable()
{
@Override
public void run()
{
_yaw.put(event.getPlayer(), event.getPlayer().getLocation().getYaw());
_teleported.remove(event.getPlayer());
}
}, 5);
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
_yaw.remove(event.getPlayer());
_idle.remove(event.getPlayer());
_beep.remove(event.getPlayer());
_teleported.remove(event.getPlayer());
}
public ArcadeManager getArcadeManager()
{
return _arcadeManager;
}
}

View File

@ -1,12 +1,14 @@
package nautilus.game.arcade.managers.lobby;
import com.google.common.collect.Maps;
import mineplex.core.PlayerSelector;
import mineplex.core.account.CoreClient;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlockText;
import mineplex.core.common.util.UtilBlockText.TextAlign;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilLambda;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
@ -126,6 +128,11 @@ public abstract class LobbyManager implements Listener
public abstract void createKits(Game game);
public boolean isMPS()
{
return _manager.GetHost() != null;
}
public void writeGameLine(String text, int line, int id, byte data)
{
Location loc = new Location(_gameText.getWorld(), _gameText.getX(), _gameText.getY(), _gameText.getZ());
@ -243,6 +250,8 @@ public abstract class LobbyManager implements Listener
if (event.getType() == UpdateType.FASTEST)
{
UpdateFirework();
PlayerSelector.selectPlayers(UtilLambda.and(PlayerSelector.inWorld(Bukkit.getWorld("world")), UtilLambda.not(PlayerSelector.within(getSpawn(), 100))))
.forEach(player -> player.teleport(getSpawn()));
}
if (event.getType() == UpdateType.SLOW)

View File

@ -11,6 +11,7 @@ import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.games.deathtag.DeathTag;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.smash.SuperSmash;
import nautilus.game.arcade.game.games.wither.WitherGame;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.KitAvailability;
@ -52,8 +53,7 @@ public class NewGameLobbyManager extends LobbyManager
{
CARL,
AMP,
SPAWN,
;
SPAWN,;
}
private final File CONFIG = new File("world/WorldConfig.dat");
@ -67,7 +67,7 @@ public class NewGameLobbyManager extends LobbyManager
super(manager, null, null, null);
_run = CONFIG.exists();
if(_run)
if (_run)
{
try
{
@ -90,7 +90,7 @@ public class NewGameLobbyManager extends LobbyManager
{
TimingManager.start("TeamGen");
if(!_run)
if (!_run)
{
System.out.println("Cannot generate teams, no WorldConfig.dat file was found, but a NEW.dat file was. If this is a testing server, feel free to ignore this message.");
return;
@ -100,35 +100,35 @@ public class NewGameLobbyManager extends LobbyManager
List<Location> locations = _multipleLocs.get("TEAM");
boolean doShift = true;
if(locations == null)
if (locations == null)
{
locations = Lists.newArrayList();
for(GameTeam team : game.GetTeamList())
for (GameTeam team : game.GetTeamList())
{
String name = team.GetName().toUpperCase() + "_SHEEP";
if(team.GetName().equalsIgnoreCase("Hiders"))
if (team.GetName().equalsIgnoreCase("Hiders"))
{
name = "RED_SHEEP";
}
if(team.GetName().equalsIgnoreCase("Hunters"))
if (team.GetName().equalsIgnoreCase("Hunters"))
{
name = "BLUE_SHEEP";
}
if(team.GetName().equalsIgnoreCase("Withers"))
if (team.GetName().equalsIgnoreCase("Withers"))
{
name = "RED_SHEEP";
}
if(team.GetName().equalsIgnoreCase("Humans"))
if (team.GetName().equalsIgnoreCase("Humans"))
{
name = "GREEN_SHEEP";
}
Location location = _singleLocs.get(name);
if(location == null)
if (location == null)
{
continue;
}
@ -139,15 +139,15 @@ public class NewGameLobbyManager extends LobbyManager
}
}
if(locations.size() == 0)
if (locations.size() == 0)
{
System.out.println("Size is 0!");
return;
}
int shift = 0;
float yaw = 90;
if(doShift)
if (doShift)
{
if (list.size() == 2)
{
@ -160,46 +160,42 @@ public class NewGameLobbyManager extends LobbyManager
}
}
if(game instanceof DeathTag && isGeneratePodiums())
if (game instanceof DeathTag && isGeneratePodiums())
{
int size = list.size();
for(int i = 1; i < size; i++)
for (int i = 1; i < size; i++)
{
list.remove(i);
}
}
if(game instanceof HideSeek)
if (game instanceof HideSeek)
{
Collections.reverse(list);
}
for(int i = 0; i < list.size(); i++)
if (isMPS())
{
yaw = 0;
}
for (int i = 0; i < list.size(); i++)
{
GameTeam team = list.get(i);
Location entLoc = locations.get(i).clone().add(0, 0, shift);
entLoc.setYaw(90);
Location entLoc = locations.get(i).clone();
entLoc.getChunk().load();
if(isGeneratePodiums())
if (isMPS())
{
generatePodium(entLoc, team.GetColorData(), getTeamBlocks());
entLoc.add(shift, 0, 0);
} else
{
entLoc.add(0, 0, shift);
}
Sheep ent = (Sheep) _manager.GetCreature().SpawnEntity(entLoc, EntityType.SHEEP);
ent.setRemoveWhenFarAway(false);
ent.setCustomNameVisible(true);
entLoc.setYaw(yaw);
ent.setColor(DyeColor.getByWoolData(team.GetColorData()));
UtilEnt.Vegetate(ent, true);
UtilEnt.setFakeHead(ent, true);
UtilEnt.ghost(ent, true, false);
team.SetTeamEntity(ent);
getTeams().put(ent, new LobbyEnt(ent, entLoc, team));
entLoc.getChunk().load();
spawnTeamSheep(entLoc, team);
}
TimingManager.stop("TeamGen");
}
@ -209,7 +205,7 @@ public class NewGameLobbyManager extends LobbyManager
{
TimingManager.start("KitGen");
if(!_run)
if (!_run)
{
System.out.println("Cannot generate kits, no WorldConfig.dat file was found, but a NEW.dat file was. If this is a testing server, feel free to ignore this message.");
return;
@ -238,7 +234,7 @@ public class NewGameLobbyManager extends LobbyManager
if (locations == null || locations.size() <= 1)
{
for(Kit kit : kitList)
for (Kit kit : kitList)
{
String name = kit.GetName().toUpperCase().replace(" ", "_");
Location entLoc = _singleLocs.get(name);
@ -248,38 +244,127 @@ public class NewGameLobbyManager extends LobbyManager
{
int shift = 0;
if(!(game instanceof DeathTag) && !(game instanceof WitherGame))
if (!(game instanceof DeathTag) && !(game instanceof WitherGame))
{
Collections.sort(kitList, new KitSorter());
}
if(kitList.size() == 3)
if (kitList.size() == 3)
{
shift = 4;
}
if(kitList.size() == 1)
if (kitList.size() == 1)
{
shift = 6;
}
if(kitList.size() == 2)
if (kitList.size() == 2)
{
shift = 2;
}
if(kitList.size() == 4)
if (kitList.size() == 4)
{
shift = 2;
}
for(int i = 0; i < kitList.size(); i++)
if (isMPS())
{
Location blank = new Location(WORLD, -1, -1, -1);
List<Location> buffer = Lists.newArrayList(locations);
List<Location> removedPos = Lists.newArrayList();
List<Location> removedNeg = Lists.newArrayList();
for (int i = 0; i < locations.size(); i++)
{
Location location = locations.get(i);
if (location.getBlockX() == -17)
{
buffer.set(i, blank);
removedNeg.add(location);
}
}
Collections.reverse(removedNeg);
for (int i = 0; i < buffer.size(); i++)
{
Location locIn = buffer.get(i);
if (!locIn.equals(blank))
{
continue;
}
if (!removedNeg.isEmpty())
{
Location locOut = removedNeg.remove(0);
buffer.set(i, locOut);
}
}
if (game instanceof SuperSmash)
{
for (int i = 0; i < locations.size(); i++)
{
Location location = locations.get(i);
if (location.getBlockX() == 17)
{
buffer.set(i, blank);
removedPos.add(location);
}
}
Collections.reverse(removedPos);
for (int i = 0; i < buffer.size(); i++)
{
Location locIn = buffer.get(i);
if (!locIn.equals(blank))
{
continue;
}
if (!removedPos.isEmpty())
{
Location locOut = removedPos.remove(0);
buffer.set(i, locOut);
}
}
}
removedNeg.clear();
removedPos.clear();
locations = buffer;
}
for (int i = 0; i < kitList.size(); i++)
{
Kit kit = kitList.get(i);
int index = shift == 0 ? i : (locations.size() - 1) - i;
Location entLoc = locations.get(index).clone().subtract(0, 0, shift);
if(isGeneratePodiums())
if (isMPS())
{
index = i;
}
Location entLoc = locations.get(index);
if (entLoc == null)
{
continue;
}
entLoc.clone().subtract(0, 0, shift);
if (isGeneratePodiums())
{
byte data = 4;
@ -300,6 +385,28 @@ public class NewGameLobbyManager extends LobbyManager
TimingManager.stop("KitGen");
}
private void spawnTeamSheep(Location entLoc, GameTeam team)
{
if (isGeneratePodiums())
{
generatePodium(entLoc, team.GetColorData(), getTeamBlocks());
}
Sheep ent = (Sheep) _manager.GetCreature().SpawnEntity(entLoc, EntityType.SHEEP);
ent.setRemoveWhenFarAway(false);
ent.setCustomNameVisible(true);
ent.setColor(DyeColor.getByWoolData(team.GetColorData()));
UtilEnt.Vegetate(ent, true);
UtilEnt.setFakeHead(ent, true);
UtilEnt.ghost(ent, true, false);
team.SetTeamEntity(ent);
getTeams().put(ent, new LobbyEnt(ent, entLoc, team));
}
private void generatePodium(Location loc, byte data, Map<Block, Material> blocks)
{
Location location = loc.clone();
@ -308,9 +415,9 @@ public class NewGameLobbyManager extends LobbyManager
int z = location.getBlockZ();
//Steps
for(int modX = x - 1; modX <= x + 1; modX++)
for (int modX = x - 1; modX <= x + 1; modX++)
{
for(int modZ = z -1; modZ <= z + 1; modZ++)
for (int modZ = z - 1; modZ <= z + 1; modZ++)
{
Location temp = new Location(location.getWorld(), modX, y, modZ);
Block block = temp.getBlock();
@ -320,9 +427,9 @@ public class NewGameLobbyManager extends LobbyManager
}
//Wool
for(int modX = x - 1; modX <= x + 1; modX++)
for (int modX = x - 1; modX <= x + 1; modX++)
{
for(int modY = y -1; modY < y; modY++)
for (int modY = y - 1; modY < y; modY++)
{
for (int modZ = z - 1; modZ <= z + 1; modZ++)
{
@ -337,9 +444,8 @@ public class NewGameLobbyManager extends LobbyManager
private void setKit(Kit kit, Location entLoc)
{
if(entLoc == null)
if (entLoc == null)
{
System.out.println("Null ent loc for " + kit.GetName());
return;
}
@ -349,11 +455,16 @@ public class NewGameLobbyManager extends LobbyManager
float yaw = 90;
if(yawLoc.getBlockX() < 0)
if (yawLoc.getBlockX() < 0)
{
yaw = 270;
}
if (yawLoc.getBlockZ() == 13)
{
yaw = 180;
}
entLoc.setYaw(yaw);
Entity ent = kit.SpawnEntity(entLoc);