Potatoes and Tornadoes
This commit is contained in:
parent
cc75bafb4c
commit
c150ea6175
@ -5,6 +5,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.CustomTagFix;
|
||||
import mineplex.core.FoodDupeFix;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
@ -47,7 +48,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class Clans extends JavaPlugin
|
||||
{
|
||||
public static final String VERSION = "0.12";
|
||||
public static final String VERSION = "0.13";
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
// Modules
|
||||
@ -115,6 +116,7 @@ public class Clans extends JavaPlugin
|
||||
|
||||
// Enable custom-gear related managers
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
new CustomTagFix(this, packetHandler);
|
||||
GearManager customGear = new GearManager(this, packetHandler, _clientManager, _donationManager);
|
||||
|
||||
HologramManager hologram = new HologramManager(this);
|
||||
|
@ -25,7 +25,7 @@ public class ClansAdmin
|
||||
|
||||
public void command(Player caller, String[] args)
|
||||
{
|
||||
if (!Clans.getClientManager().hasRank(caller, Rank.ADMIN))
|
||||
if (!Clans.getClientManager().hasRank(caller, Rank.ADMIN) && !caller.isOp())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ import mineplex.game.clans.clans.gui.ClanShop;
|
||||
import mineplex.game.clans.clans.loot.LootManager;
|
||||
import mineplex.game.clans.clans.map.ItemMapManager;
|
||||
import mineplex.game.clans.clans.observer.ObserverManager;
|
||||
import mineplex.game.clans.clans.potato.PotatoManager;
|
||||
import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
|
||||
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
|
||||
import mineplex.game.clans.clans.regions.ClansRegions;
|
||||
@ -253,7 +254,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
new ClanEnergyTracker(plugin, this);
|
||||
|
||||
new ClansAlphaManager(this, taskManager);
|
||||
|
||||
|
||||
new PotatoManager(plugin, this);
|
||||
|
||||
new Weapon(plugin, energy);
|
||||
new Gameplay(plugin, this, blockRestore, damageManager);
|
||||
_projectileManager = new ProjectileManager(plugin);
|
||||
@ -604,10 +607,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
}
|
||||
else
|
||||
{
|
||||
String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, false);
|
||||
if (rank.length() > 0) rank += " ";
|
||||
String message = event.getMessage();
|
||||
message = _chat.getFilteredMessage(event.getPlayer(), message);
|
||||
ClanRelation rel = _clanUtility.rel(clan, otherClan);
|
||||
String formatted = rel.getColor(true) + clan.getName() + " " + _clientManager.Get(event.getPlayer()).GetRank().getTag(true, false) + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message;
|
||||
String formatted = rank + rel.getColor(true) + clan.getName() + " " + rel.getColor(false) + event.getPlayer().getName() + " " + C.cWhite + message;
|
||||
other.sendMessage(formatted);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,138 @@
|
||||
package mineplex.game.clans.clans.potato;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.projectile.IThrown;
|
||||
import mineplex.core.projectile.ProjectileUser;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
|
||||
public class PotatoManager extends MiniPlugin implements IThrown
|
||||
{
|
||||
private static final String POTATO_NAME = C.cGray + "POTATO";
|
||||
|
||||
private ClansManager _clansManager;
|
||||
|
||||
public PotatoManager(JavaPlugin plugin, ClansManager clansManager)
|
||||
{
|
||||
super("Potato", plugin);
|
||||
|
||||
_clansManager = clansManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
give(event.getPlayer(), 5);
|
||||
}
|
||||
|
||||
private void give(Player player, int count)
|
||||
{
|
||||
ItemStack potato = new ItemStack(Material.BAKED_POTATO, count);
|
||||
ItemMeta meta = potato.getItemMeta();
|
||||
meta.setDisplayName(POTATO_NAME);
|
||||
potato.setItemMeta(meta);
|
||||
player.getInventory().addItem(potato);
|
||||
}
|
||||
|
||||
public boolean isPotato(ItemStack item)
|
||||
{
|
||||
if (item == null)
|
||||
return false;
|
||||
else if (item.getType() != Material.BAKED_POTATO)
|
||||
return false;
|
||||
else
|
||||
return item.getItemMeta() != null && POTATO_NAME.equals(item.getItemMeta().getDisplayName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void tossPotato(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
ItemStack item = event.getPlayer().getItemInHand();
|
||||
if (isPotato(item))
|
||||
{
|
||||
UtilInv.remove(event.getPlayer(), Material.BAKED_POTATO, (byte) 0, 1);
|
||||
UtilInv.Update(event.getPlayer());
|
||||
|
||||
Item ent = player.getWorld().dropItem(player.getEyeLocation(), ItemStackFactory.Instance.CreateStack(Material.BAKED_POTATO));
|
||||
UtilAction.velocity(ent, player.getLocation().getDirection(), 1.2, false, 0, 0.2, 10, false);
|
||||
_clansManager.getProjectile().AddThrow(ent, player, this, -1, true, true, true, false, 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemDrop(PlayerDropItemEvent event)
|
||||
{
|
||||
ItemStack item = event.getItemDrop().getItemStack();
|
||||
if (isPotato(item))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
ItemStack hand = event.getPlayer().getItemInHand();
|
||||
if (hand != null && isPotato(hand))
|
||||
{
|
||||
hand.setAmount(hand.getAmount() - 1);
|
||||
event.getPlayer().setItemInHand(hand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent event)
|
||||
{
|
||||
Iterator<ItemStack> iterator = event.getDrops().iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
if (isPotato(iterator.next())) iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Collide(LivingEntity target, Block block, ProjectileUser data)
|
||||
{
|
||||
if (target instanceof Player)
|
||||
{
|
||||
Player player = ((Player) target);
|
||||
give(player, 1);
|
||||
}
|
||||
|
||||
data.GetThrown().getWorld().playSound(data.GetThrown().getLocation(), Sound.CHICKEN_EGG_POP, 1f, 1.6f);
|
||||
|
||||
data.GetThrown().remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Idle(ProjectileUser data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Expire(ProjectileUser data)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ public class TntGeneratorManager extends MiniPlugin
|
||||
{
|
||||
public static final Material GENERATOR_MATERIAL = Material.BREWING_STAND;
|
||||
public static final Material GENERATOR_DROP_MATERIAL = Material.BREWING_STAND_ITEM;
|
||||
public static final int TICKS_PER_TNT = 60 * 60 * 10; // 10 Hours
|
||||
public static final int SECONDS_PER_TNT = 60 * 60 * 10; // 10 Hours
|
||||
public static final int MAX_GENERATOR_STOCK = 3;
|
||||
|
||||
private ClansManager _clansManager;
|
||||
@ -82,7 +82,7 @@ public class TntGeneratorManager extends MiniPlugin
|
||||
}
|
||||
else
|
||||
{
|
||||
if (generator.getTicks() >= TICKS_PER_TNT)
|
||||
if (generator.getTicks() >= SECONDS_PER_TNT)
|
||||
{
|
||||
_clansManager.messageClan(clanInfo, F.main("Clans", "Your " + F.elem("TNT Generator") + " has a new TNT available"));
|
||||
generator.setStock(generator.getStock() + 1);
|
||||
@ -149,6 +149,7 @@ public class TntGeneratorManager extends MiniPlugin
|
||||
{
|
||||
destroyGenerator(clan.getGenerator());
|
||||
clan.setGenerator(null);
|
||||
_clansManager.getClanDataAccess().updateGenerator(clan, null);
|
||||
_clansManager.messageClan(clan, F.main("Clans", "Your " + F.elem("TNT Generator") + " has been destroyed by " + F.elem(event.getPlayer().getName())));
|
||||
}
|
||||
|
||||
@ -192,7 +193,7 @@ public class TntGeneratorManager extends MiniPlugin
|
||||
}
|
||||
else
|
||||
{
|
||||
int secondLeft = TICKS_PER_TNT - generator.getTicks();
|
||||
int secondLeft = SECONDS_PER_TNT - generator.getTicks();
|
||||
int msLeft = secondLeft * 1000;
|
||||
UtilTextMiddle.display("", C.cRed + "Next TNT in " + C.cGold + UtilTime.convertString(msLeft, 1, UtilTime.TimeUnit.FIT), event.getPlayer());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user