mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-04 07:27:59 +01:00
Changes
This commit is contained in:
parent
d7c5c60377
commit
e2b0af6ac1
@ -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
|
@Override
|
||||||
public void onImplementationChanged() {
|
public void onImplementationChanged() {
|
||||||
Messaging.severe("Citizens implementation changed, disabling plugin.");
|
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() {
|
private void setupScripting() {
|
||||||
contextClassLoader = Thread.currentThread().getContextClassLoader();
|
contextClassLoader = Thread.currentThread().getContextClassLoader();
|
||||||
Thread.currentThread().setContextClassLoader(getClassLoader());
|
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) {
|
public static void add(Location loc, int id) {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
return;
|
return;
|
||||||
instance.toRespawn.put(instance.toCoord(loc.getChunk()), id);
|
instance.toRespawn.put(instance.toCoord(loc.getChunk()), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EventListen instance;
|
|
||||||
}
|
}
|
@ -153,8 +153,11 @@ public class NPCCommands {
|
|||||||
from.save(key);
|
from.save(key);
|
||||||
copy.load(key);
|
copy.load(key);
|
||||||
|
|
||||||
if (copy.isSpawned() && sender instanceof Player)
|
if (copy.isSpawned() && sender instanceof Player) {
|
||||||
copy.getBukkitEntity().teleport((Player) sender);
|
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()));
|
Messaging.sendF(sender, ChatColor.GREEN + "%s has been copied.", StringHelper.wrap(npc.getName()));
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package net.citizensnpcs.editor;
|
package net.citizensnpcs.editor;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public interface Equipable {
|
public interface Equipable {
|
||||||
|
public void equip(Player equipper, ItemStack toEquip);
|
||||||
public void equip(Player equipper);
|
|
||||||
}
|
}
|
@ -10,6 +10,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class EquipmentEditor extends Editor {
|
public class EquipmentEditor extends Editor {
|
||||||
private final NPC npc;
|
private final NPC npc;
|
||||||
@ -44,7 +45,9 @@ public class EquipmentEditor extends Editor {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (npc instanceof Equipable) {
|
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;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
||||||
|
|
||||||
public CitizensEndermanNPC(int id, String name) {
|
public CitizensEndermanNPC(int id, String name) {
|
||||||
super(id, name, EntityEndermanNPC.class);
|
super(id, name, EntityEndermanNPC.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void equip(Player equipper) {
|
public void equip(Player equipper, ItemStack hand) {
|
||||||
ItemStack hand = equipper.getItemInHand();
|
|
||||||
if (!hand.getType().isBlock()) {
|
if (!hand.getType().isBlock()) {
|
||||||
Messaging.sendError(equipper, "Invalid block!");
|
Messaging.sendError(equipper, "Invalid block!");
|
||||||
return;
|
return;
|
||||||
@ -47,11 +45,7 @@ public class CitizensEndermanNPC extends CitizensMobNPC implements Equipable {
|
|||||||
|
|
||||||
ItemStack set = hand;
|
ItemStack set = hand;
|
||||||
if (set.getType() != Material.AIR) {
|
if (set.getType() != Material.AIR) {
|
||||||
if (hand.getAmount() > 1) {
|
hand.setAmount(hand.getAmount() - 1);
|
||||||
hand.setAmount(hand.getAmount() - 1);
|
|
||||||
} else
|
|
||||||
hand = null;
|
|
||||||
equipper.setItemInHand(hand);
|
|
||||||
set.setAmount(1);
|
set.setAmount(1);
|
||||||
}
|
}
|
||||||
getTrait(Equipment.class).set(0, set);
|
getTrait(Equipment.class).set(0, set);
|
||||||
|
@ -41,8 +41,7 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void equip(Player equipper) {
|
public void equip(Player equipper, ItemStack hand) {
|
||||||
ItemStack hand = equipper.getItemInHand();
|
|
||||||
Equipment trait = getTrait(Equipment.class);
|
Equipment trait = getTrait(Equipment.class);
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
Material type = hand == null ? Material.AIR : hand.getType();
|
Material type = hand == null ? Material.AIR : hand.getType();
|
||||||
@ -105,11 +104,7 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
|
|||||||
clone.setAmount(1);
|
clone.setAmount(1);
|
||||||
trait.set(slot, clone);
|
trait.set(slot, clone);
|
||||||
|
|
||||||
if (hand.getAmount() > 1)
|
hand.setAmount(hand.getAmount() - 1);
|
||||||
hand.setAmount(hand.getAmount() - 1);
|
|
||||||
else
|
|
||||||
hand = null;
|
|
||||||
equipper.setItemInHand(hand);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,21 +28,18 @@ public class CitizensPigNPC extends CitizensMobNPC implements Equipable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void equip(Player equipper) {
|
public void equip(Player equipper, ItemStack hand) {
|
||||||
ItemStack hand = equipper.getItemInHand();
|
|
||||||
if (hand.getType() == Material.SADDLE) {
|
if (hand.getType() == Material.SADDLE) {
|
||||||
if (!getBukkitEntity().hasSaddle()) {
|
if (!getBukkitEntity().hasSaddle()) {
|
||||||
getTrait(Saddle.class).toggle();
|
getTrait(Saddle.class).toggle();
|
||||||
equipper.setItemInHand(null);
|
hand.setAmount(0);
|
||||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is now saddled.");
|
Messaging.send(equipper, StringHelper.wrap(getName()) + " is now saddled.");
|
||||||
}
|
}
|
||||||
} else {
|
} else if (getBukkitEntity().hasSaddle()) {
|
||||||
if (getBukkitEntity().hasSaddle()) {
|
equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(),
|
||||||
equipper.getWorld().dropItemNaturally(getBukkitEntity().getLocation(),
|
new ItemStack(Material.SADDLE, 1));
|
||||||
new ItemStack(Material.SADDLE, 1));
|
getTrait(Saddle.class).toggle();
|
||||||
getTrait(Saddle.class).toggle();
|
Messaging.send(equipper, StringHelper.wrap(getName()) + " is no longer saddled.");
|
||||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is no longer saddled.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ public class CitizensSheepNPC extends CitizensMobNPC implements Equipable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void equip(Player equipper) {
|
public void equip(Player equipper, ItemStack hand) {
|
||||||
ItemStack hand = equipper.getItemInHand();
|
|
||||||
if (hand.getType() == Material.SHEARS) {
|
if (hand.getType() == Material.SHEARS) {
|
||||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is "
|
Messaging.send(equipper, StringHelper.wrap(getName()) + " is "
|
||||||
+ (getTrait(Sheared.class).toggle() ? "now" : "no longer") + " sheared.");
|
+ (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(getName()) + " is now "
|
||||||
+ StringHelper.wrap(color.name().toLowerCase().replace("_", " ")) + ".");
|
+ StringHelper.wrap(color.name().toLowerCase().replace("_", " ")) + ".");
|
||||||
|
|
||||||
if (hand.getAmount() > 1)
|
hand.setAmount(hand.getAmount() - 1);
|
||||||
hand.setAmount(hand.getAmount() - 1);
|
|
||||||
else
|
|
||||||
hand = null;
|
|
||||||
equipper.setItemInHand(hand);
|
|
||||||
} else {
|
} else {
|
||||||
getTrait(WoolColor.class).setColor(DyeColor.WHITE);
|
getTrait(WoolColor.class).setColor(DyeColor.WHITE);
|
||||||
Messaging.send(equipper, StringHelper.wrap(getName()) + " is now " + StringHelper.wrap("white")
|
Messaging.send(equipper, StringHelper.wrap(getName()) + " is now " + StringHelper.wrap("white")
|
||||||
|
@ -35,6 +35,10 @@ public class NMS {
|
|||||||
|
|
||||||
private static Field THREAD_STOPPER;
|
private static Field THREAD_STOPPER;
|
||||||
|
|
||||||
|
public static void attack(EntityLiving handle, EntityLiving target) {
|
||||||
|
handle.k(target);
|
||||||
|
}
|
||||||
|
|
||||||
public static void clearGoals(PathfinderGoalSelector... goalSelectors) {
|
public static void clearGoals(PathfinderGoalSelector... goalSelectors) {
|
||||||
if (NMS.GOAL_FIELD == null || goalSelectors == null)
|
if (NMS.GOAL_FIELD == null || goalSelectors == null)
|
||||||
return;
|
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) {
|
public static void registerEntityClass(Class<? extends Entity> clazz) {
|
||||||
if (ENTITY_CLASS_TO_INT.containsKey(clazz))
|
if (ENTITY_CLASS_TO_INT.containsKey(clazz))
|
||||||
return;
|
return;
|
||||||
@ -160,12 +168,4 @@ public class NMS {
|
|||||||
} catch (Exception e) {
|
} 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