You can only repair items two times, ClansAdmin commands now require admin, Fix durability bug, Fix potion effects making inventory shift

This commit is contained in:
Shaun Bennett 2015-08-27 09:33:44 -07:00
parent a5400b0fef
commit adfc451e9f
7 changed files with 112 additions and 32 deletions

View File

@ -30,9 +30,7 @@
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel target="1.7">
<module name="bungee" target="1.7" />
</bytecodeTargetLevel>
<bytecodeTargetLevel target="1.7" />
</component>
<component name="JavacSettings">
<option name="GENERATE_NO_WARNINGS" value="true" />

View File

@ -126,6 +126,10 @@ public class UtilGear
{
goldSet.add(Material.GOLD_SWORD);
goldSet.add(Material.GOLD_AXE);
goldSet.add(Material.GOLD_HELMET);
goldSet.add(Material.GOLD_CHESTPLATE);
goldSet.add(Material.GOLD_LEGGINGS);
goldSet.add(Material.GOLD_BOOTS);
}
return goldSet.contains(item.getType());

View File

@ -25,6 +25,11 @@ public class ClansAdmin
public void command(Player caller, String[] args)
{
if (Clans.getClientManager().hasRank(caller, Rank.ADMIN))
{
return;
}
if (args.length == 1)
help(caller);

View File

@ -6,19 +6,27 @@ import java.util.TimeZone;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_7_R4.util.CraftMagicNumbers;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemBreakEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.EnumToolMaterial;
import net.minecraft.server.v1_7_R4.Item;
import net.minecraft.server.v1_7_R4.ItemSword;
import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -35,6 +43,7 @@ import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.energy.Energy;
import mineplex.core.explosion.Explosion;
import mineplex.core.gui.SimpleGuiItem;
import mineplex.core.movement.Movement;
import mineplex.core.npc.NpcManager;
import mineplex.core.packethandler.PacketHandler;
@ -679,15 +688,53 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
_worldEvent.onDisable();
}
// @EventHandler
public void itemBreak(PlayerItemBreakEvent event)
{
Bukkit.broadcastMessage("Item Break: " + event.getPlayer());
Thread.dumpStack();
}
// @EventHandler
public void blockBreak(BlockBreakEvent event)
{
Bukkit.broadcastMessage("dur: " + event.getPlayer().getItemInHand().getDurability());
// Item item = ((CraftItemStack) event.getPlayer().getItemInHand()).getHandle().getItem();
Item item = CraftMagicNumbers.getItem(Material.IRON_SWORD);
Class clazz = ItemSword.class;
try
{
java.lang.reflect.Field field = clazz.getDeclaredField("b");
field.setAccessible(true);
EnumToolMaterial material = (EnumToolMaterial) field.get(item);
Bukkit.broadcastMessage("Material: " + material.name());
Bukkit.broadcastMessage("Dur: " + material.a());
}
catch (NoSuchFieldException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
Bukkit.broadcastMessage("name: " + item.getName() + " max dur: " + item.getMaxDurability());
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onJoin(PlayerLoginEvent event)
{
Rank rank = _clientManager.Get(event.getPlayer()).GetRank();
if (/*!rank.Has(Rank.MAPDEV) &&*/ !event.getPlayer().isWhitelisted())
if (!rank.Has(Rank.MAPDEV) && !event.getPlayer().isWhitelisted())
{
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
event.setKickMessage("This server is whitelisted!");
// event.setKickMessage("Only Builder+ can join this server");
// event.setKickMessage("This server is whitelisted!");
event.setKickMessage("Only Builder+ can join this server");
}
}
}

View File

@ -49,6 +49,7 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
public class Gameplay extends MiniPlugin
@ -522,13 +523,7 @@ public class Gameplay extends MiniPlugin
}
int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0);
boolean gold = UtilGear.isGold(item);
boolean canRepair = true;
if (repairs >= 3 && gold)
canRepair = false;
else if (repairs >= 2 && !gold)
canRepair = false;
boolean canRepair = canRepair(item);
if (!canRepair)
{
@ -566,12 +561,32 @@ public class Gameplay extends MiniPlugin
}
//Record
ItemStackFactory.Instance.SetLoreVar(item, "Repaired", "" + repairs + 1);
ItemStackFactory.Instance.SetLoreVar(item, "Repaired", (repairs + 1) + "");
if (!canRepair(item))
{
ItemMeta meta = item.getItemMeta();
meta.getLore().add(ChatColor.BLUE + "Nonfixable");
item.setItemMeta(meta);
}
//Effect
player.playSound(player.getLocation(), Sound.ANVIL_USE, 1f, 1f);
}
private boolean canRepair(ItemStack item)
{
int repairs = ItemStackFactory.Instance.GetLoreVar(item, "Repaired", 0);
boolean gold = UtilGear.isGold(item);
boolean canRepair = true;
if (repairs >= 3 && gold)
canRepair = false;
else if (repairs >= 2 && !gold)
canRepair = false;
return canRepair;
}
public DamageManager getDamageManager()
{
return _damageManager;

View File

@ -187,20 +187,20 @@ public class ItemFactory extends MiniPlugin implements IItemFactory
return;
}
try
{
_itemMaxDurability.setInt(net.minecraft.server.v1_7_R4.Item.getById(newItem.GetType().getId()), 56);
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
}
catch (IllegalAccessException e)
{
e.printStackTrace();
}
// try
// {
// _itemMaxDurability.setInt(net.minecraft.server.v1_7_R4.Item.getById(newItem.GetType().getId()), 56);
// }
// catch (IllegalArgumentException e)
// {
// e.printStackTrace();
// }
// catch (IllegalAccessException e)
// {
// e.printStackTrace();
// }
_items.put(newItem.GetName(), newItem);
_items.put(newItem.GetName(), newItem);
}
public BlockRestore BlockRestore()

View File

@ -2,9 +2,11 @@ package mineplex.minecraft.game.core.condition;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import net.minecraft.server.v1_7_R4.MobEffect;
public class Condition
{
@ -124,14 +126,23 @@ public class Condition
{
PotionEffectType type = PotionEffectType.getByName(_type.toString());
//Remove
_ent.removePotionEffect(type);
boolean remove = false;
for (PotionEffect effect : _ent.getActivePotionEffects())
{
if (effect.getType() == type && effect.getAmplifier() != _mult)
remove = true;
}
// Remove
if (remove)
_ent.removePotionEffect(type);
//Add
PotionEffect effect = new PotionEffect(type, _ticks, _mult, _ambient);
if (_ticks == -1)
_ent.addPotionEffect(new PotionEffect(type, 72000, _mult, _ambient), true);
else
_ent.addPotionEffect(new PotionEffect(type, _ticks, _mult, _ambient), true);
((CraftLivingEntity) _ent).getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient()));
}
catch (Exception e)
{