Loot tweaks
Music fixes some bug fixes
This commit is contained in:
parent
ed7eeab1a7
commit
91037384f9
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -405,4 +406,20 @@ public class GadgetManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canPlaySongAt(Location location)
|
||||||
|
{
|
||||||
|
for (Gadget gadget : _gadgets.get(GadgetType.MusicDisc))
|
||||||
|
{
|
||||||
|
if (gadget instanceof MusicGadget)
|
||||||
|
{
|
||||||
|
if (!((MusicGadget)gadget).canPlayAt(location))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,10 @@ public class SongData
|
|||||||
{
|
{
|
||||||
if (System.currentTimeMillis() > EndTime)
|
if (System.currentTimeMillis() > EndTime)
|
||||||
{
|
{
|
||||||
|
//Dont end until Jukebox cleaned
|
||||||
|
if (Block.getType() != Material.JUKEBOX && Block.getType() != Material.AIR)
|
||||||
|
return false;
|
||||||
|
|
||||||
Block.setType(Material.AIR);
|
Block.setType(Material.AIR);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@ import java.util.ArrayList;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.gadget.GadgetManager;
|
import mineplex.core.gadget.GadgetManager;
|
||||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||||
|
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||||
import mineplex.core.gadget.gadgets.SongData;
|
import mineplex.core.gadget.gadgets.SongData;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
@ -14,10 +16,11 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
|
|
||||||
public class MusicGadget extends Gadget
|
public class MusicGadget extends Gadget
|
||||||
{
|
{
|
||||||
@ -46,6 +49,12 @@ public class MusicGadget extends Gadget
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!Manager.canPlaySongAt(player.getLocation()))
|
||||||
|
{
|
||||||
|
UtilPlayer.message(player, F.main("Music", "There is already another song playing nearby."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!Recharge.Instance.use(player, "Play Disc", _duration, true, false))
|
if (!Recharge.Instance.use(player, "Play Disc", _duration, true, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -82,4 +91,35 @@ public class MusicGadget extends Gadget
|
|||||||
songIterator.remove();
|
songIterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void gadgetBlockChange(GadgetBlockEvent event)
|
||||||
|
{
|
||||||
|
for (Iterator<Block> iterator = event.getBlocks().iterator(); iterator.hasNext();)
|
||||||
|
{
|
||||||
|
Block block = iterator.next();
|
||||||
|
|
||||||
|
for (SongData data : _songs)
|
||||||
|
{
|
||||||
|
if (data.Block.equals(block))
|
||||||
|
{
|
||||||
|
iterator.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlayAt(Location location)
|
||||||
|
{
|
||||||
|
for (SongData data : _songs)
|
||||||
|
{
|
||||||
|
if (UtilMath.offset(data.Block.getLocation(), location) < 48)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,8 @@ public class RewardManager
|
|||||||
//Increase Value
|
//Increase Value
|
||||||
if (_doubleGadgetValue)
|
if (_doubleGadgetValue)
|
||||||
{
|
{
|
||||||
minValue *= 2;
|
minValue *= 1.5;
|
||||||
maxValue *= 2;
|
maxValue *= 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gadgets
|
// Gadgets
|
||||||
@ -111,8 +111,8 @@ public class RewardManager
|
|||||||
//Increase Value
|
//Increase Value
|
||||||
if (_doubleGadgetValue)
|
if (_doubleGadgetValue)
|
||||||
{
|
{
|
||||||
minValue *= 2;
|
minValue *= 1.5;
|
||||||
maxValue *= 2;
|
maxValue *= 1.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gadgets
|
// Gadgets
|
||||||
|
@ -388,16 +388,20 @@ public class Treasure
|
|||||||
|
|
||||||
public boolean containsBlock(Block block)
|
public boolean containsBlock(Block block)
|
||||||
{
|
{
|
||||||
if (_wallsBlockInfo.contains(block))
|
for (BlockInfo info : _wallsBlockInfo)
|
||||||
|
if (info.getBlock().equals(block))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (_outerRingBlockInfo.contains(block))
|
for (BlockInfo info : _outerRingBlockInfo)
|
||||||
|
if (info.getBlock().equals(block))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (_centerBlockInfo.contains(block))
|
for (BlockInfo info : _centerBlockInfo)
|
||||||
|
if (info.getBlock().equals(block))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (_chestBlockInfo.contains(block))
|
for (BlockInfo info : _chestBlockInfo)
|
||||||
|
if (info.getBlock().equals(block))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -14,7 +14,7 @@ public class TreasureKey extends SalesPackageBase
|
|||||||
{
|
{
|
||||||
public TreasureKey()
|
public TreasureKey()
|
||||||
{
|
{
|
||||||
super("Treasure Key", Material.LEVER, (byte) 0, new String[] { ChatColor.RESET + "Used to open Treasure Chests" }, 1000);
|
super("Treasure Key", Material.TRIPWIRE_HOOK, (byte) 0, new String[] { ChatColor.RESET + "Used to open Treasure Chests" }, 1000);
|
||||||
|
|
||||||
KnownPackage = false;
|
KnownPackage = false;
|
||||||
OneTimePurchaseOnly = false;
|
OneTimePurchaseOnly = false;
|
||||||
|
@ -400,9 +400,11 @@ public class ParkourManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
for (Iterator<Block> iterator = event.getBlocks().iterator(); iterator.hasNext();)
|
for (Iterator<Block> iterator = event.getBlocks().iterator(); iterator.hasNext();)
|
||||||
{
|
{
|
||||||
|
Block block = iterator.next();
|
||||||
|
|
||||||
for (ParkourData data : _parkour)
|
for (ParkourData data : _parkour)
|
||||||
{
|
{
|
||||||
if (data.InBoundary(iterator.next().getLocation()))
|
if (data.InBoundary(block.getLocation()))
|
||||||
{
|
{
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
break;
|
break;
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.FireworkEffect;
|
import org.bukkit.FireworkEffect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -18,6 +19,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import mineplex.core.common.util.C;
|
import mineplex.core.common.util.C;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilFirework;
|
import mineplex.core.common.util.UtilFirework;
|
||||||
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.common.util.UtilServer;
|
import mineplex.core.common.util.UtilServer;
|
||||||
import mineplex.core.common.util.UtilTitle;
|
import mineplex.core.common.util.UtilTitle;
|
||||||
import mineplex.core.pet.PetManager;
|
import mineplex.core.pet.PetManager;
|
||||||
@ -55,11 +57,11 @@ public class GameLootManager implements Listener
|
|||||||
|
|
||||||
//Chest
|
//Chest
|
||||||
_rewardManager.addReward(new InventoryReward(_rewardManager, Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 1,
|
_rewardManager.addReward(new InventoryReward(_rewardManager, Manager.getInventoryManager(), "Treasure Chest", "Treasure Chest", 1, 1,
|
||||||
new ItemStack(Material.CHEST), RewardRarity.COMMON, 2));
|
new ItemStack(Material.CHEST), RewardRarity.COMMON, 3));
|
||||||
|
|
||||||
//Key
|
//Key
|
||||||
_rewardManager.addReward(new InventoryReward(_rewardManager, Manager.getInventoryManager(), "Treasure Key", "Treasure Key", 1, 1,
|
_rewardManager.addReward(new InventoryReward(_rewardManager, Manager.getInventoryManager(), "Treasure Key", "Treasure Key", 1, 1,
|
||||||
new ItemStack(Material.DIAMOND), RewardRarity.UNCOMMON, 500));
|
new ItemStack(Material.DIAMOND), RewardRarity.UNCOMMON, 600));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -120,18 +122,24 @@ public class GameLootManager implements Listener
|
|||||||
|
|
||||||
String outputName = reward.getRarity().getColor() + rewardData.getFriendlyName();
|
String outputName = reward.getRarity().getColor() + rewardData.getFriendlyName();
|
||||||
|
|
||||||
|
String rarityName = "";
|
||||||
|
if (reward.getRarity() != RewardRarity.COMMON)
|
||||||
|
rarityName = " " + reward.getRarity().getColor() + reward.getRarity().getName();
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
System.out.println(F.name(player.getName()) + " found " + reward.getRarity().getName() + " treasure " + outputName);
|
System.out.println(F.name(player.getName()) + " found" + rarityName + " " + outputName);
|
||||||
|
|
||||||
//Self Display
|
//Self Display
|
||||||
UtilTitle.display(C.cDGreen + C.Bold + "Loot", "You found " + outputName, 20, 120, 20, player);
|
UtilTitle.display(C.cGreen + "Game Loot", "You found " + outputName, 20, 120, 20, player);
|
||||||
|
//if (reward.getRarity() == RewardRarity.COMMON)
|
||||||
|
// UtilPlayer.message(player, F.main("Loot", "You found " + rarityName + outputName));
|
||||||
|
|
||||||
Random _random = new Random();
|
Random _random = new Random();
|
||||||
|
|
||||||
//Announce
|
//Announce
|
||||||
if (reward.getRarity() != RewardRarity.COMMON)
|
//if (reward.getRarity() != RewardRarity.COMMON)
|
||||||
{
|
{
|
||||||
Bukkit.broadcastMessage(F.main("Loot", F.name(player.getName()) + " found " + reward.getRarity().getName() + " treasure " + outputName));
|
Bukkit.broadcastMessage(F.main("Loot", F.name(player.getName()) + " found" + rarityName + " " + outputName));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Effect
|
//Effect
|
||||||
@ -148,11 +156,15 @@ public class GameLootManager implements Listener
|
|||||||
{
|
{
|
||||||
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.YELLOW).withFade(Color.WHITE).build();
|
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL).withColor(Color.YELLOW).withFade(Color.WHITE).build();
|
||||||
UtilFirework.playFirework(player.getEyeLocation(), effect);
|
UtilFirework.playFirework(player.getEyeLocation(), effect);
|
||||||
|
|
||||||
|
player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.WITHER_SPAWN, 5F, 1.2F);
|
||||||
}
|
}
|
||||||
else if (reward.getRarity() == RewardRarity.LEGENDARY)
|
else if (reward.getRarity() == RewardRarity.LEGENDARY)
|
||||||
{
|
{
|
||||||
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
|
FireworkEffect effect = FireworkEffect.builder().with(FireworkEffect.Type.BALL_LARGE).withColor(Color.RED).withFade(Color.BLACK).build();
|
||||||
UtilFirework.playFirework(player.getEyeLocation(), effect);
|
UtilFirework.playFirework(player.getEyeLocation(), effect);
|
||||||
|
|
||||||
|
player.getWorld().playSound(player.getEyeLocation().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,5 +181,26 @@ public class GameLootManager implements Listener
|
|||||||
giveReward(event.getPlayer());
|
giveReward(event.getPlayer());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getMessage().startsWith("/lootdebug100"))
|
||||||
|
{
|
||||||
|
event.getPlayer().sendMessage(C.cGreen + C.Bold + "Loot Debug 100...");
|
||||||
|
|
||||||
|
final Player fPlayer = event.getPlayer();
|
||||||
|
|
||||||
|
for (int i=0 ; i<100 ; i++)
|
||||||
|
{
|
||||||
|
UtilServer.getServer().getScheduler().runTaskLater(Manager.GetPlugin(), new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
giveReward(fPlayer);
|
||||||
|
}
|
||||||
|
}, 2 * i);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user