Updated Sheep Quest to be 1.8 comptible.

Fixed fissure not working on slabs
Fixed a bug in recharge
Added ability for admins to give other people creative (they lose it when the admin quits)
This commit is contained in:
Chiss 2014-11-05 11:26:39 +11:00
parent 3a6968a60b
commit b00fb0952a
12 changed files with 262 additions and 104 deletions

View File

@ -91,17 +91,6 @@ public class Recharge extends MiniPlugin
}
}
}
/*
public boolean use(Player player, String ability, long recharge, boolean inform)
{
return use(player, ability, ability, recharge, inform, false);
}
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform)
{
return use(player, ability, ability, recharge, inform, false);
}
*/
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem)
{
@ -150,7 +139,12 @@ public class Recharge extends MiniPlugin
public void useForce(Player player, String ability, long recharge)
{
UseRecharge(player, ability, recharge, false, false);
useForce(player, ability, recharge, false);
}
public void useForce(Player player, String ability, long recharge, boolean attachItem)
{
UseRecharge(player, ability, recharge, attachItem, false);
}
public boolean usable(Player player, String ability)
@ -183,10 +177,8 @@ public class Recharge extends MiniPlugin
RechargeEvent rechargeEvent = new RechargeEvent(player, ability, recharge);
UtilServer.getServer().getPluginManager().callEvent(rechargeEvent);
if (attachItem || attachDurability)
Get(player).put(ability, new RechargeData(this, player, ability, player.getItemInHand(), rechargeEvent.GetRecharge(), attachItem, attachDurability));
else
Get(player).put(ability, new RechargeData(System.currentTimeMillis()+rechargeEvent.GetRecharge()));
Get(player).put(ability, new RechargeData(this, player, ability, player.getItemInHand(),
rechargeEvent.GetRecharge(), attachItem, attachDurability));
}
public void recharge(Player player, String ability)
@ -200,8 +192,36 @@ public class Recharge extends MiniPlugin
_recharge.remove(event.getPlayer().getName());
}
public void setDisplayForce(Player player, String ability, boolean displayForce)
{
if (!_recharge.containsKey(player.getName()))
return;
if (!_recharge.get(player.getName()).containsKey(ability))
return;
_recharge.get(player.getName()).get(ability).DisplayForce = displayForce;
}
public void Reset(Player player)
{
_recharge.put(player.getName(), new NautHashMap<String, RechargeData>());
}
public void debug(Player player, String ability)
{
if (!_recharge.containsKey(player.getName()))
{
player.sendMessage("No Recharge Map.");
return;
}
if (!_recharge.get(player.getName()).containsKey(ability))
{
player.sendMessage("Ability Not Found.");
return;
}
_recharge.get(player.getName()).get(ability).debug(player);
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.recharge;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
@ -28,14 +29,10 @@ public class RechargeData
public ItemStack Item;
public boolean DisplayForce = false;
public boolean AttachItem;
public boolean AttachDurability;
public RechargeData(long time)
{
Time = time;
}
public RechargeData(Recharge host, Player player, String name, ItemStack stack, long rechargeTime, boolean attachitem, boolean attachDurability)
{
Host = host;
@ -52,16 +49,16 @@ public class RechargeData
public boolean Update()
{
if (Item != null && Name != null && Player != null)
if ((DisplayForce || Item != null) && Name != null && Player != null)
{
//Holding Recharge Item
double percent = (double)(System.currentTimeMillis() - Time)/(double)Recharge;
if (AttachItem)
if (DisplayForce || AttachItem)
{
try
{
if (Player.getItemInHand().getType() == Item.getType())
if (DisplayForce || (Item != null && UtilGear.isMat(Player.getItemInHand(), Item.getType())))
{
if (!UtilTime.elapsed(Time, Recharge))
{
@ -84,27 +81,10 @@ public class RechargeData
}
}
if (AttachDurability)
if (AttachDurability && Item != null)
{
Item.setDurability((short) (Item.getType().getMaxDurability() - (Item.getType().getMaxDurability() * percent)));
}
/*
ItemMeta itemMeta = Item.getItemMeta();
if (System.currentTimeMillis() < Time)
itemMeta.setDisplayName(C.cRed + C.Bold + Name + ChatColor.RESET + " - " + C.cYellow + C.Bold + UtilTime.MakeStr(Time - System.currentTimeMillis()));
else
itemMeta.setDisplayName(C.cGreen + C.Bold + Name);
Item.setItemMeta(itemMeta);
if (System.currentTimeMillis() < Time)
Item.removeEnchantment(Enchantment.DURABILITY);
else
Item.addEnchantment(Enchantment.DURABILITY, 1);
*/
}
@ -115,4 +95,12 @@ public class RechargeData
{
return Recharge - (System.currentTimeMillis() - Time);
}
public void debug(Player player)
{
player.sendMessage("Recharge: " + Recharge);
player.sendMessage("Time: " + Time);
player.sendMessage("Elapsed: " + (System.currentTimeMillis() - Time));
player.sendMessage("Remaining: " + GetRemaining());
}
}

View File

@ -1,5 +1,6 @@
package mineplex.hub;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
@ -138,6 +139,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
private HashMap<String, Long> _portalTime = new HashMap<String, Long>();
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>();
//Admin
private boolean _gadgetsEnabled = true;
@ -996,4 +999,39 @@ public class HubManager extends MiniClientPlugin<HubClient>
if (!_gadgetsEnabled)
event.setCancelled(true);
}
public void addGameMode(Player caller, Player target)
{
if (!_creativeAdmin.containsKey(caller.getName()))
_creativeAdmin.put(caller.getName(), new ArrayList<String>());
if (target.getGameMode() == GameMode.CREATIVE)
{
_creativeAdmin.get(caller.getName()).add(target.getName());
}
else
{
_creativeAdmin.get(caller.getName()).remove(target.getName());
}
}
@EventHandler
public void clearGameMode(PlayerQuitEvent event)
{
ArrayList<String> creative = _creativeAdmin.remove(event.getPlayer().getName());
if (creative == null)
return;
for (String name : creative)
{
Player player = UtilPlayer.searchExact(name);
if (player == null)
continue;
player.setGameMode(GameMode.SURVIVAL);
UtilPlayer.message(player, F.main("Game Mode", event.getPlayer().getName() + " left the game. Creative Mode: " + F.tf(false)));
}
}
}

View File

@ -5,6 +5,8 @@ import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.hub.HubManager;
public class GameModeCommand extends CommandBase<HubManager>
@ -17,9 +19,27 @@ public class GameModeCommand extends CommandBase<HubManager>
@Override
public void Execute(Player caller, String[] args)
{
if (caller.getGameMode() == GameMode.SURVIVAL)
caller.setGameMode(GameMode.CREATIVE);
Player target = caller;
if (args != null && args.length >= 1)
{
target = UtilPlayer.searchOnline(caller, args[0], true);
if (target == null)
return;
}
if (target.getGameMode() == GameMode.SURVIVAL)
target.setGameMode(GameMode.CREATIVE);
else
caller.setGameMode(GameMode.SURVIVAL);
target.setGameMode(GameMode.SURVIVAL);
if (!target.equals(caller))
{
Plugin.addGameMode(caller, target);
UtilPlayer.message(target, F.main("Game Mode", caller.getName() + " toggled your Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
}
UtilPlayer.message(caller, F.main("Game Mode", target.getName() + " Creative Mode: " + F.tf(target.getGameMode() == GameMode.CREATIVE)));
}
}

View File

@ -70,7 +70,7 @@ public class Fissure extends SkillActive
@Override
public void Skill(Player player, int level)
{
FissureData data = new FissureData(this, player, level, player.getLocation().getDirection(), player.getLocation().add(0, -0.5, 0));
FissureData data = new FissureData(this, player, level, player.getLocation().getDirection(), player.getLocation().add(0, -0.4, 0));
_active.add(data);
//Inform

View File

@ -157,8 +157,6 @@ public class Quiver extends SoloGame
if (Manager.GetCondition().HasCondition(event.GetEvent().getEntity(), ConditionType.FALLING, null))
{
amount = 2;
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 3f, 0.75f);
}
}

View File

@ -36,6 +36,7 @@ import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilTime;
@ -140,8 +141,6 @@ public class SheepGame extends TeamGame
"Most sheep at 5 minutes wins!"
});
this.StrictAntiHack = true;
this.DeathOut = false;
this.DeathSpectateSecs = 8;
@ -233,35 +232,66 @@ public class SheepGame extends TeamGame
UtilFirework.playFirework(sheep.getLocation().add(0, 0.5, 0), FireworkEffect.builder().flicker(false).withColor(Color.WHITE).with(Type.BALL).trail(false).build());
}
// @EventHandler
// public void Stack(PlayerInteractEntityEvent event)
// {
// if (!IsLive())
// return;
//
// if (!(event.getRightClicked() instanceof Sheep))
// return;
//
// if (event.getRightClicked().getVehicle() != null)
// return;
//
// if (!Recharge.Instance.usable(event.getPlayer(), "Sheep Stack", true))
// return;
//
// SheepStack(event.getPlayer(), (Sheep)event.getRightClicked());
// }
@EventHandler
public void Stack(PlayerInteractEntityEvent event)
public void Stack(UpdateEvent event)
{
if (!IsLive())
if (event.getType() != UpdateType.SEC)
return;
if (!(event.getRightClicked() instanceof Sheep))
return;
if (event.getRightClicked().getVehicle() != null)
return;
Player player = event.getPlayer();
for (Player player : GetPlayers(true))
{
if (!Recharge.Instance.usable(player, "Sheep Stack"))
return;
for (Entity ent : player.getWorld().getEntities())
{
if (!(ent instanceof Sheep))
continue;
if (ent.getVehicle() != null)
continue;
if (UtilMath.offset(player, ent) > 2.5)
continue;
if (SheepStack(player, (Sheep)ent))
break;
}
}
}
public boolean SheepStack(Player player, Sheep sheep)
{
if (player.getItemInHand() != null && player.getItemInHand().getType() != Material.SADDLE)
return;
return true;
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
return;
if (player.getGameMode() != GameMode.SURVIVAL)
return true;
if (!IsAlive(event.getPlayer()))
return;
if (!IsAlive(player))
return true;
if (player.getPassenger() != null && player.getPassenger() instanceof Player)
{
DropSheep(player);
DropSheep(player, 500);
}
//Holding too many
@ -275,36 +305,41 @@ public class SheepGame extends TeamGame
if (count >= 3)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot hold more than 3 Sheep!"));
return;
//UtilPlayer.message(player, F.main("Game", "You cannot hold more than 3 Sheep!"));
return true;
}
for (SheepData data : _sheep.values())
{
if (data.Sheep.equals(event.getRightClicked()))
if (data.Sheep.equals(sheep))
{
if (data.Owner != null && data.Owner.equals(GetTeam(event.getPlayer())) && data.IsInsideOwnPen())
if (data.Owner != null && data.Owner.equals(GetTeam(player)) && data.IsInsideOwnPen())
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You have already captured this Sheep!"));
return;
//UtilPlayer.message(player, F.main("Game", "You have already captured this Sheep!"));
return false;
}
data.SetHolder(event.getPlayer());
data.SetHolder(player);
}
}
//Put Wool in Inventory
player.getInventory().setItem(4 + count, ItemStackFactory.Instance.CreateStack(35, ((Sheep)event.getRightClicked()).getColor().getWoolData()));
player.getInventory().setItem(4 + count, ItemStackFactory.Instance.CreateStack(35, ((Sheep)sheep).getColor().getWoolData()));
UtilInv.Update(player);
//Effect
event.getRightClicked().getWorld().playEffect(event.getRightClicked().getLocation(), Effect.STEP_SOUND, 35);
sheep.getWorld().playEffect(sheep.getLocation(), Effect.STEP_SOUND, 35);
//Stack
top.setPassenger(event.getRightClicked());
top.setPassenger(sheep);
//Audio
player.playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 3f);
//Cooldown
Recharge.Instance.useForce(player, "Sheep Stack", 500);
return true;
}
@EventHandler
@ -329,7 +364,7 @@ public class SheepGame extends TeamGame
return;
if (player.getPassenger() != null)
DropSheep(player);
DropSheep(player, 500);
if (!Recharge.Instance.usable(player, "Sheep Stack"))
return;
@ -350,22 +385,25 @@ public class SheepGame extends TeamGame
player.setPassenger(other);
//Audio
player.playSound(player.getLocation(), Sound.VILLAGER_YES, 2f, 3f);
other.playSound(player.getLocation(), Sound.VILLAGER_NO, 2f, 3f);
player.playSound(player.getLocation(), Sound.HORSE_ARMOR, 1f, 1f);
//Inform
UtilPlayer.message(other, F.main("Skill", F.elem(GetTeam(player).GetColor() + player.getName()) + " picked you up."));
UtilPlayer.message(player, F.main("Skill", "You picked up " + F.elem(GetTeam(player).GetColor() + player.getName()) + "."));
UtilPlayer.message(player, F.main("Skill", "You picked up " + F.elem(GetTeam(other).GetColor() + other.getName()) + "."));
}
@EventHandler
public void DeathDrop(PlayerDeathEvent event)
{
DropSheep(event.getEntity());
DropSheep(event.getEntity(), 0);
}
public void DropSheep(Player player)
public void DropSheep(Player player, long cooldown)
{
//Brute can only throw
if (GetKit(player) instanceof KitBrute)
return;
boolean hadSheep = false;
Entity top = player;
@ -388,12 +426,15 @@ public class SheepGame extends TeamGame
//Audio
player.playSound(player.getLocation(), Sound.SHEEP_IDLE, 2f, 1f);
//Recharge
Recharge.Instance.useForce(player, "Sheep Stack", cooldown);
}
@EventHandler
public void Drop(PlayerDropItemEvent event)
{
DropSheep(event.getPlayer());
DropSheep(event.getPlayer(), 500);
}
@EventHandler
@ -454,7 +495,22 @@ public class SheepGame extends TeamGame
}
@EventHandler(priority = EventPriority.LOW)
public void DamagePasson(CustomDamageEvent event)
public void DamageSheepCancel(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
if (event.GetDamagerPlayer(true) != null)
{
if (event.GetDamagerPlayer(true).getPassenger() != null)
{
event.SetCancelled("SQ: Has Passenger");
}
}
}
@EventHandler(priority = EventPriority.LOW)
public void DamagePassOn(CustomDamageEvent event)
{
if (event.IsCancelled())
return;
@ -493,7 +549,7 @@ public class SheepGame extends TeamGame
Player player = event.GetDamageePlayer();
if (player == null) return;
DropSheep(player);
DropSheep(player, 2000);
Bukkit.getPluginManager().callEvent(new DropEnemySheepEvent(event.GetDamagerPlayer(true), player));
}

View File

@ -9,6 +9,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.itemstack.ItemStackFactory;
@ -45,7 +46,8 @@ public class KitArcher extends Kit
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1,
C.cYellow + C.Bold + "Move Near Sheep" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Pick Up Sheep"));
}
@Override

View File

@ -5,8 +5,8 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.kit.Kit;
@ -27,7 +27,7 @@ public class KitBeserker extends Kit
new Perk[]
{
new PerkLeap("Beserker Leap", 1.2, 1.2, 8000)
new PerkDoubleJump("Beserker Jump", 1.2, 1.2, true, 8000, true)
},
EntityType.ZOMBIE,
new ItemStack(Material.IRON_AXE));
@ -37,7 +37,8 @@ public class KitBeserker extends Kit
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_AXE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1,
C.cYellow + C.Bold + "Move Near Sheep" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Pick Up Sheep"));
}
@Override

View File

@ -38,7 +38,8 @@ public class KitBrute extends Kit
public void GiveItems(Player player)
{
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE));
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.SADDLE, (byte)0, 1,
C.cYellow + C.Bold + "Move Near Sheep" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Pick Up Sheep"));
}
@Override

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.kit.perks;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -12,6 +13,7 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.kit.Perk;
@ -21,10 +23,12 @@ public class PerkDoubleJump extends Perk
private double _power;
private double _heightMax;
private boolean _control;
private long _recharge;
private boolean _displayForce;
public PerkDoubleJump(String name, double power, double heightLimit, boolean control)
{
super("Jumper", new String[]
super(name, new String[]
{
C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name
});
@ -32,6 +36,22 @@ public class PerkDoubleJump extends Perk
_power = power;
_heightMax = heightLimit;
_control = control;
_recharge = 0;
_displayForce = false;
}
public PerkDoubleJump(String name, double power, double heightLimit, boolean control, long recharge, boolean displayForce)
{
super(name, new String[]
{
C.cYellow + "Tap Jump Twice" + C.cGray + " to " + C.cGreen + name
});
_power = power;
_heightMax = heightLimit;
_control = control;
_recharge = recharge;
_displayForce = displayForce;
}
@EventHandler
@ -63,6 +83,17 @@ public class PerkDoubleJump extends Perk
//Sound
player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 0);
//Recharge
if (_recharge > 0)
{
Recharge.Instance.useForce(player, GetName(), _recharge);
if (_displayForce)
{
Recharge.Instance.setDisplayForce(player, GetName(), true);
}
}
}
@EventHandler
@ -79,6 +110,9 @@ public class PerkDoubleJump extends Perk
if (!Kit.HasKit(player))
continue;
if (_recharge > 0 && !Recharge.Instance.usable(player, GetName()))
continue;
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))
player.setAllowFlight(true);
}

View File

@ -10,15 +10,19 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextTop;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.projectile.IThrown;
import mineplex.core.projectile.ProjectileUser;
@ -32,22 +36,16 @@ public class PerkThrower extends Perk implements IThrown
{
super("Thrower", new String[]
{
C.cGray + "You can pick up team mates!",
C.cYellow + "Right-Click" + C.cGray + " with Sword to " + C.cGreen + "Throw Sheep",
C.cGray + "You can also pick up team mates!",
C.cYellow + "Drop Weapon" + C.cGray + " to " + C.cGreen + "Throw Sheep / Players",
});
}
@EventHandler
public void Throw(PlayerInteractEvent event)
public void Throw(PlayerDropItemEvent event)
{
if (!UtilEvent.isAction(event, ActionType.R))
return;
Player thrower = event.getPlayer();
if (!UtilGear.isMat(thrower.getItemInHand(), Material.IRON_SWORD))
return;
if (thrower.getPassenger() == null)
return;
@ -73,6 +71,8 @@ public class PerkThrower extends Perk implements IThrown
fThrower.setPassenger(fThroweeStack);
}
}, 2);
UtilPlayer.message(thrower, F.main("Game", "You threw " + UtilEnt.getName(throwee) + "."));
}
//Throw