mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-16 15:46:14 +01:00
Changes
This commit is contained in:
parent
9d34a6b4f2
commit
b14b4173b9
@ -236,19 +236,6 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private void setupEconomy() {
|
||||
try {
|
||||
RegisteredServiceProvider<Economy> provider = Bukkit.getServicesManager().getRegistration(
|
||||
Economy.class);
|
||||
if (provider != null && provider.getProvider() != null) {
|
||||
Economy economy = provider.getProvider();
|
||||
Bukkit.getPluginManager().registerEvents(new PaymentListener(economy), this);
|
||||
}
|
||||
} catch (NoClassDefFoundError e) {
|
||||
Messaging.log("Unable to use economy handling. Has Vault been enabled?");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onImplementationChanged() {
|
||||
Messaging.severe("Citizens implementation changed, disabling plugin.");
|
||||
@ -293,6 +280,19 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
});
|
||||
}
|
||||
|
||||
private void setupEconomy() {
|
||||
try {
|
||||
RegisteredServiceProvider<Economy> provider = Bukkit.getServicesManager().getRegistration(
|
||||
Economy.class);
|
||||
if (provider != null && provider.getProvider() != null) {
|
||||
Economy economy = provider.getProvider();
|
||||
Bukkit.getPluginManager().registerEvents(new PaymentListener(economy), this);
|
||||
}
|
||||
} catch (NoClassDefFoundError e) {
|
||||
Messaging.log("Unable to use economy handling. Has Vault been enabled?");
|
||||
}
|
||||
}
|
||||
|
||||
private void setupScripting() {
|
||||
contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(getClassLoader());
|
||||
|
@ -288,11 +288,11 @@ public class EventListen implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private static EventListen instance;
|
||||
|
||||
public static void add(Location loc, int id) {
|
||||
if (instance == null)
|
||||
return;
|
||||
instance.toRespawn.put(instance.toCoord(loc.getChunk()), id);
|
||||
}
|
||||
|
||||
private static EventListen instance;
|
||||
}
|
@ -153,8 +153,11 @@ public class NPCCommands {
|
||||
from.save(key);
|
||||
copy.load(key);
|
||||
|
||||
if (copy.isSpawned() && sender instanceof Player)
|
||||
copy.getBukkitEntity().teleport((Player) sender);
|
||||
if (copy.isSpawned() && sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
copy.getBukkitEntity().teleport(player);
|
||||
copy.getTrait(CurrentLocation.class).setLocation(player.getLocation());
|
||||
}
|
||||
|
||||
Messaging.sendF(sender, ChatColor.GREEN + "%s has been copied.", StringHelper.wrap(npc.getName()));
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.citizensnpcs.editor;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface Equipable {
|
||||
|
||||
public void equip(Player equipper);
|
||||
public void equip(Player equipper, ItemStack toEquip);
|
||||
}
|
@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EquipmentEditor extends Editor {
|
||||
private final NPC npc;
|
||||
@ -44,7 +45,9 @@ public class EquipmentEditor extends Editor {
|
||||
return;
|
||||
|
||||
if (npc instanceof Equipable) {
|
||||
((Equipable) npc).equip(event.getPlayer());
|
||||
ItemStack hand = event.getPlayer().getItemInHand();
|
||||
((Equipable) npc).equip(event.getPlayer(), hand);
|
||||
event.getPlayer().setItemInHand(hand.getAmount() > 0 ? hand : null);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,14 +21,12 @@ import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
||||
|
||||
public CitizensEndermanNPC(int id, String name) {
|
||||
super(id, name, EntityEndermanNPC.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void equip(Player equipper) {
|
||||
ItemStack hand = equipper.getItemInHand();
|
||||
public void equip(Player equipper, ItemStack hand) {
|
||||
if (!hand.getType().isBlock()) {
|
||||
Messaging.sendError(equipper, "Invalid block!");
|
||||
return;
|
||||
@ -47,11 +45,7 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
||||
|
||||
ItemStack set = hand;
|
||||
if (set.getType() != Material.AIR) {
|
||||
if (hand.getAmount() > 1) {
|
||||
hand.setAmount(hand.getAmount() - 1);
|
||||
} else
|
||||
hand = null;
|
||||
equipper.setItemInHand(hand);
|
||||
hand.setAmount(hand.getAmount() - 1);
|
||||
set.setAmount(1);
|
||||
}
|
||||
getTrait(Equipment.class).set(0, set);
|
||||
|
@ -41,8 +41,7 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void equip(Player equipper) {
|
||||
ItemStack hand = equipper.getItemInHand();
|
||||
public void equip(Player equipper, ItemStack hand) {
|
||||
Equipment trait = getTrait(Equipment.class);
|
||||
int slot = 0;
|
||||
Material type = hand == null ? Material.AIR : hand.getType();
|
||||
@ -105,11 +104,7 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
|
||||
clone.setAmount(1);
|
||||
trait.set(slot, clone);
|
||||
|
||||
if (hand.getAmount() > 1)
|
||||
hand.setAmount(hand.getAmount() - 1);
|
||||
else
|
||||
hand = null;
|
||||
equipper.setItemInHand(hand);
|
||||
hand.setAmount(hand.getAmount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,21 +28,18 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void equip(Player equipper) {
|
||||
ItemStack hand = equipper.getItemInHand();
|
||||
public void equip(Player equipper, ItemStack hand) {
|
||||
if (hand.getType() == Material.SADDLE) {
|
||||
if (!getBukkitEntity().hasSaddle()) {
|
||||
getTrait(Saddle.class).toggle();
|
||||
equipper.setItemInHand(null);
|
||||
hand.setAmount(0);
|
||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is now saddled.");
|
||||
}
|
||||
} else {
|
||||
if (getBukkitEntity().hasSaddle()) {
|
||||
equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(),
|
||||
new ItemStack(Material.SADDLE, 1));
|
||||
getTrait(Saddle.class).toggle();
|
||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is no longer saddled.");
|
||||
}
|
||||
} else if (getBukkitEntity().hasSaddle()) {
|
||||
equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(),
|
||||
new ItemStack(Material.SADDLE, 1));
|
||||
getTrait(Saddle.class).toggle();
|
||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is no longer saddled.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,7 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void equip(Player equipper) {
|
||||
ItemStack hand = equipper.getItemInHand();
|
||||
public void equip(Player equipper, ItemStack hand) {
|
||||
if (hand.getType() == Material.SHEARS) {
|
||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is "
|
||||
+ (getTrait(Sheared.class).toggle() ? "now" : "no longer") + " sheared.");
|
||||
@ -45,11 +44,7 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
|
||||
StringHelper.wrap(getName()) + " is now "
|
||||
+ StringHelper.wrap(color.name().toLowerCase().replace("_", " ")) + ".");
|
||||
|
||||
if (hand.getAmount() > 1)
|
||||
hand.setAmount(hand.getAmount() - 1);
|
||||
else
|
||||
hand = null;
|
||||
equipper.setItemInHand(hand);
|
||||
hand.setAmount(hand.getAmount() - 1);
|
||||
} else {
|
||||
getTrait(WoolColor.class).setColor(DyeColor.WHITE);
|
||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is now " + StringHelper.wrap("white")
|
||||
|
@ -35,6 +35,10 @@ public class NMS {
|
||||
|
||||
private static Field THREAD_STOPPER;
|
||||
|
||||
public static void attack(EntityLiving handle, EntityLiving target) {
|
||||
handle.k(target);
|
||||
}
|
||||
|
||||
public static void clearGoals(PathfinderGoalSelector... goalSelectors) {
|
||||
if (NMS.GOAL_FIELD == null || goalSelectors == null)
|
||||
return;
|
||||
@ -76,6 +80,10 @@ public class NMS {
|
||||
}
|
||||
}
|
||||
|
||||
public static void look(ControllerLook controllerLook, EntityLiving handle, EntityLiving target) {
|
||||
controllerLook.a(target, 10.0F, handle.bf());
|
||||
}
|
||||
|
||||
public static void registerEntityClass(Class<? extends Entity> clazz) {
|
||||
if (ENTITY_CLASS_TO_INT.containsKey(clazz))
|
||||
return;
|
||||
@ -160,12 +168,4 @@ public class NMS {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void attack(EntityLiving handle, EntityLiving target) {
|
||||
handle.k(target);
|
||||
}
|
||||
|
||||
public static void look(ControllerLook controllerLook, EntityLiving handle, EntityLiving target) {
|
||||
controllerLook.a(target, 10.0F, handle.bf());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user