- Fixed players not being kicked from treasure chest locations when they are being opened

- Increased the time needed for the Wind Up suit to be charged
 - Added effect for the Wind Up suit to blink between yellow and red when the effect is active
This commit is contained in:
LCastr0 2016-10-21 18:06:13 -02:00
parent 56db128730
commit 0d6ff42a8d
3 changed files with 132 additions and 48 deletions

View File

@ -1,11 +1,12 @@
package mineplex.core.gadget.gadgets.outfit.windupsuit;
import mineplex.core.common.util.*;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.*;
import java.util.HashMap;
import java.util.Iterator;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerMoveEvent;
@ -13,8 +14,17 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import java.util.HashMap;
import java.util.Iterator;
import mineplex.core.common.util.C;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class OutfitWindUpSuit extends OutfitGadget
{
@ -94,17 +104,17 @@ public class OutfitWindUpSuit extends OutfitGadget
if (phase == 0)
{
updateNextColor(color, colors[phase], player, phase);
percentage += 5;
percentage += 1;
}
else if (phase == 1)
{
updateNextColor(color, colors[phase], player, phase);
percentage += 5;
percentage += 1;
}
else if (phase == 2)
{
updateNextColor(color, colors[phase], player, phase);
percentage += 5;
percentage += 1;
}
else if (phase == 3)
{
@ -153,6 +163,10 @@ public class OutfitWindUpSuit extends OutfitGadget
if (_boosterManager.getTicks(player) >= 1800)
{
_boosterManager.removeEffects(player);
for (ItemStack itemStack : player.getEquipment().getArmorContents())
{
UtilColor.applyColor(itemStack, UtilColor.DEFAULT_LEATHER_COLOR);
}
}
else
{
@ -204,9 +218,9 @@ public class OutfitWindUpSuit extends OutfitGadget
private void updateNextColor(Color original, Color finalColor, Player player, int phase)
{
// Makes a really smooth transition between colors
Color nextColor = UtilColor.getNextColor(original, finalColor, 5);
Color nextColor = UtilColor.getNextColor(original, finalColor, 1);
if (nextColor.getRed() == finalColor.getRed() && nextColor.getGreen() == finalColor.getGreen() && nextColor.getBlue() == finalColor.getBlue())
if (compareColors(finalColor, nextColor))
_colorPhase.put(player, phase + 1);
updateColor(player, nextColor);
@ -247,4 +261,27 @@ public class OutfitWindUpSuit extends OutfitGadget
double percent = ((_percentage.get(player) * 100d) / 888d) / 100d;
UtilTextBottom.displayProgress(C.Bold + getSet().getName(), percent, "", player);
}
private boolean compareColors(Color colorA, Color colorB)
{
int rA = colorA.getRed(), rB = colorB.getRed();
int gA = colorA.getGreen(), gB = colorB.getGreen();
int bA = colorA.getBlue(), bB = colorB.getBlue();
int minR = Math.min(rA, rB), maxR = Math.max(rA, rB);
int minG = Math.min(gA, gB), maxG = Math.max(gA, gB);
int minB = Math.min(bA, bB), maxB = Math.max(bA, bB);
if (maxR - minR > 2)
{
return false;
}
if (maxG - minG > 2)
{
return false;
}
if (maxB - minB > 2)
{
return false;
}
return true;
}
}

View File

@ -1,19 +1,5 @@
package mineplex.core.gadget.gadgets.outfit.windupsuit;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.noteblock.INoteVerifier;
import mineplex.core.noteblock.NBSReader;
import mineplex.core.noteblock.NotePlayer;
import mineplex.core.noteblock.NoteSong;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
@ -21,7 +7,28 @@ import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Set;
public class OutfitWindUpSuitBoosterManager
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.noteblock.NBSReader;
import mineplex.core.noteblock.NotePlayer;
import mineplex.core.noteblock.NoteSong;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class OutfitWindUpSuitBoosterManager implements Listener
{
private GadgetManager _gadget;
@ -32,6 +39,7 @@ public class OutfitWindUpSuitBoosterManager
public OutfitWindUpSuitBoosterManager(GadgetManager gadget)
{
_gadget = gadget;
Bukkit.getPluginManager().registerEvents(this, gadget.getPlugin());
}
public void applyEffects(Player player)
@ -121,4 +129,36 @@ public class OutfitWindUpSuitBoosterManager
}
}
/**
* Flickers colors between yellow and red to mimic the invulnerability star from mario
*/
@EventHandler
public void onUpdate(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
_notePlayers.keySet().forEach(player -> flickerColor(player));
}
private void flickerColor(Player player)
{
ItemStack[] playerArmor = player.getEquipment().getArmorContents();
for (ItemStack item : playerArmor)
{
if (item != null)
{
LeatherArmorMeta leatherMeta = (LeatherArmorMeta) item.getItemMeta();
if (leatherMeta.getColor().getRed() == 255 && leatherMeta.getColor().getGreen() == 255)
{
UtilColor.applyColor(item, Color.fromRGB(255, 0, 0));
}
else
{
UtilColor.applyColor(item, Color.fromRGB(255, 255, 0));
}
}
}
}
}

View File

@ -2,22 +2,6 @@ package mineplex.core.treasure;
import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.*;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramInteraction;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.gui.TreasureShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -35,6 +19,30 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramInteraction;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.gui.TreasureShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
public class TreasureLocation implements Listener
{
private TreasureManager _treasureManager;
@ -162,6 +170,7 @@ public class TreasureLocation implements Listener
Treasure treasure = new Treasure(player, rewards, treasureType.getRewardType(), _chestBlock, _chestSpawns, treasureType, _treasureManager.getBlockRestore(), _hologramManager, _statusManager);
_currentTreasure = treasure;
Bukkit.broadcastMessage(_currentTreasure.toString());
UtilTextMiddle.display(treasureType.getName(), "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open", 20, 180, 20, player);
UtilPlayer.message(player, F.main("Treasure", "Choose " + rewards.length + " " + UtilText.plural("Chest", rewards.length) + " To Open"));
@ -296,7 +305,7 @@ public class TreasureLocation implements Listener
public void cancelMove(PlayerMoveEvent event)
{
Player player = event.getPlayer();
if (isTreasureInProgress())
if (_currentTreasure != null)
{
if (_currentTreasure.getPlayer().equals(player))
{
@ -314,10 +323,9 @@ public class TreasureLocation implements Listener
{
Location fromLocation = event.getFrom();
Location toLocation = event.getTo();
if (fromLocation.getWorld().equals(toLocation.getWorld())) return;
if (!fromLocation.getWorld().equals(toLocation.getWorld())) return;
Location centerLocation = _currentTreasure.getCenterBlock().getLocation().add(0.5, 1.5, 0.5);
double toDistanceFromCenter = centerLocation.distanceSquared(toLocation);
if (toDistanceFromCenter <= 16)
{
// Only cancel movement if they are moving towards the center
@ -326,7 +334,6 @@ public class TreasureLocation implements Listener
{
Location spawnLocation = new Location(player.getWorld(), 0, 64, 0);
UtilAction.velocity(player, UtilAlg.getTrajectory(player.getLocation(), spawnLocation).multiply(-1), 1.5, true, 0.8, 0, 1.0, true);
// event.setTo(event.getFrom());
}
}
}