mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 04:35:50 +01:00
Add /npc painting
This commit is contained in:
parent
163499f219
commit
4f9506ce7a
@ -11,6 +11,7 @@ import java.util.List;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@ -122,6 +123,7 @@ import net.citizensnpcs.trait.MirrorTrait;
|
|||||||
import net.citizensnpcs.trait.MountTrait;
|
import net.citizensnpcs.trait.MountTrait;
|
||||||
import net.citizensnpcs.trait.OcelotModifiers;
|
import net.citizensnpcs.trait.OcelotModifiers;
|
||||||
import net.citizensnpcs.trait.PacketNPC;
|
import net.citizensnpcs.trait.PacketNPC;
|
||||||
|
import net.citizensnpcs.trait.PaintingTrait;
|
||||||
import net.citizensnpcs.trait.PausePathfindingTrait;
|
import net.citizensnpcs.trait.PausePathfindingTrait;
|
||||||
import net.citizensnpcs.trait.Poses;
|
import net.citizensnpcs.trait.Poses;
|
||||||
import net.citizensnpcs.trait.Powered;
|
import net.citizensnpcs.trait.Powered;
|
||||||
@ -556,6 +558,18 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "configgui",
|
||||||
|
desc = "Display NPC configuration GUI",
|
||||||
|
modifiers = { "configgui" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.configgui")
|
||||||
|
public void configgui(CommandContext args, Player sender, NPC npc) {
|
||||||
|
InventoryMenu.createSelfRegistered(new NPCConfigurator(npc)).present(sender);
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "controllable|control (-m(ount),-y,-n,-o(wner required))",
|
usage = "controllable|control (-m(ount),-y,-n,-o(wner required))",
|
||||||
@ -1036,18 +1050,6 @@ public class NPCCommands {
|
|||||||
Messaging.sendTr(sender, key, npc.getName());
|
Messaging.sendTr(sender, key, npc.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
|
||||||
aliases = { "npc" },
|
|
||||||
usage = "gui",
|
|
||||||
desc = "Display NPC configuration GUI",
|
|
||||||
modifiers = { "gui" },
|
|
||||||
min = 1,
|
|
||||||
max = 1,
|
|
||||||
permission = "citizens.npc.gui")
|
|
||||||
public void gui(CommandContext args, Player sender, NPC npc) {
|
|
||||||
InventoryMenu.createSelfRegistered(new NPCConfigurator(npc)).present(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "hitbox --scale [scale] --width/height [value]",
|
usage = "hitbox --scale [scale] --width/height [value]",
|
||||||
@ -1873,6 +1875,26 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
aliases = { "npc" },
|
||||||
|
usage = "painting (--art art)",
|
||||||
|
desc = "Set painting modifiers",
|
||||||
|
modifiers = { "painting" },
|
||||||
|
min = 1,
|
||||||
|
max = 1,
|
||||||
|
permission = "citizens.npc.painting")
|
||||||
|
@Requirements(selected = true, ownership = true, types = { EntityType.PAINTING })
|
||||||
|
public void painting(CommandContext args, CommandSender sender, NPC npc, @Flag("art") Art art)
|
||||||
|
throws CommandException {
|
||||||
|
PaintingTrait trait = npc.getOrAddTrait(PaintingTrait.class);
|
||||||
|
if (art != null) {
|
||||||
|
trait.setArt(art);
|
||||||
|
Messaging.sendTr(sender, Messages.PAINTING_ART_SET, npc.getName(), Util.prettyEnum(art));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new CommandUsageException();
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "npc" },
|
aliases = { "npc" },
|
||||||
usage = "passive (--set [true|false])",
|
usage = "passive (--set [true|false])",
|
||||||
|
@ -74,6 +74,5 @@ public class NPCConfigurator extends InventoryMenuPage {
|
|||||||
InputMenus.stringSetter(() -> evt.npc.getName(), (input) -> evt.npc.setName(input)));
|
InputMenus.stringSetter(() -> evt.npc.getName(), (input) -> evt.npc.setName(input)));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
unloadEvents();
|
unloadEvents();
|
||||||
}
|
}
|
||||||
for (Trait trait : new ArrayList<Trait>(traits.values())) {
|
for (Trait trait : new ArrayList<Trait>(traits.values())) {
|
||||||
trait.onDespawn();
|
trait.onDespawn(reason);
|
||||||
}
|
}
|
||||||
Messaging.debug("Despawned", this, "DespawnReason." + reason);
|
Messaging.debug("Despawned", this, "DespawnReason." + reason);
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ import net.citizensnpcs.trait.MirrorTrait;
|
|||||||
import net.citizensnpcs.trait.MountTrait;
|
import net.citizensnpcs.trait.MountTrait;
|
||||||
import net.citizensnpcs.trait.OcelotModifiers;
|
import net.citizensnpcs.trait.OcelotModifiers;
|
||||||
import net.citizensnpcs.trait.PacketNPC;
|
import net.citizensnpcs.trait.PacketNPC;
|
||||||
|
import net.citizensnpcs.trait.PaintingTrait;
|
||||||
import net.citizensnpcs.trait.PausePathfindingTrait;
|
import net.citizensnpcs.trait.PausePathfindingTrait;
|
||||||
import net.citizensnpcs.trait.Poses;
|
import net.citizensnpcs.trait.Poses;
|
||||||
import net.citizensnpcs.trait.Powered;
|
import net.citizensnpcs.trait.Powered;
|
||||||
@ -89,6 +90,7 @@ public class CitizensTraitFactory implements TraitFactory {
|
|||||||
registerTrait(TraitInfo.create(HologramTrait.class));
|
registerTrait(TraitInfo.create(HologramTrait.class));
|
||||||
registerTrait(TraitInfo.create(Inventory.class));
|
registerTrait(TraitInfo.create(Inventory.class));
|
||||||
registerTrait(TraitInfo.create(LookClose.class));
|
registerTrait(TraitInfo.create(LookClose.class));
|
||||||
|
registerTrait(TraitInfo.create(PaintingTrait.class));
|
||||||
registerTrait(TraitInfo.create(MirrorTrait.class));
|
registerTrait(TraitInfo.create(MirrorTrait.class));
|
||||||
registerTrait(TraitInfo.create(MountTrait.class));
|
registerTrait(TraitInfo.create(MountTrait.class));
|
||||||
registerTrait(TraitInfo.create(MobType.class).asDefaultTrait());
|
registerTrait(TraitInfo.create(MobType.class).asDefaultTrait());
|
||||||
|
38
main/src/main/java/net/citizensnpcs/trait/PaintingTrait.java
Normal file
38
main/src/main/java/net/citizensnpcs/trait/PaintingTrait.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package net.citizensnpcs.trait;
|
||||||
|
|
||||||
|
import org.bukkit.Art;
|
||||||
|
import org.bukkit.entity.Painting;
|
||||||
|
|
||||||
|
import net.citizensnpcs.api.persistence.Persist;
|
||||||
|
import net.citizensnpcs.api.trait.Trait;
|
||||||
|
import net.citizensnpcs.api.trait.TraitName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persists {@link Painting} metadata.
|
||||||
|
*/
|
||||||
|
@TraitName("paintingtrait")
|
||||||
|
public class PaintingTrait extends Trait {
|
||||||
|
@Persist("art")
|
||||||
|
private Art art;
|
||||||
|
|
||||||
|
public PaintingTrait() {
|
||||||
|
super("paintingtrait");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!(npc.getEntity() instanceof Painting))
|
||||||
|
return;
|
||||||
|
Painting painting = (Painting) npc.getEntity();
|
||||||
|
if (art != null) {
|
||||||
|
painting.setArt(art);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Painting#setArt(Art)
|
||||||
|
*/
|
||||||
|
public void setArt(Art art) {
|
||||||
|
this.art = art;
|
||||||
|
}
|
||||||
|
}
|
@ -357,6 +357,8 @@ public class ShopTrait extends Trait {
|
|||||||
max = Math.min(max, r);
|
max = Math.min(max, r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (max == 0)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
final int repeats = max == Integer.MAX_VALUE ? 1 : max;
|
final int repeats = max == Integer.MAX_VALUE ? 1 : max;
|
||||||
List<Transaction> take = apply(cost, action -> action.take(event.getWhoClicked(), repeats));
|
List<Transaction> take = apply(cost, action -> action.take(event.getWhoClicked(), repeats));
|
||||||
|
@ -288,6 +288,7 @@ public class Messages {
|
|||||||
public static final String OVER_NPC_LIMIT = "citizens.limits.over-npc-limit";
|
public static final String OVER_NPC_LIMIT = "citizens.limits.over-npc-limit";
|
||||||
public static final String OWNER_SET = "citizens.commands.npc.owner.set";
|
public static final String OWNER_SET = "citizens.commands.npc.owner.set";
|
||||||
public static final String OWNER_SET_SERVER = "citizens.commands.npc.owner.set-server";
|
public static final String OWNER_SET_SERVER = "citizens.commands.npc.owner.set-server";
|
||||||
|
public static final String PAINTING_ART_SET = "citizens.commands.npc.painting.art-set";
|
||||||
public static final String PANDA_HIDDEN_GENE_SET = "citizens.commands.npc.panda.hidden-gene-set";
|
public static final String PANDA_HIDDEN_GENE_SET = "citizens.commands.npc.panda.hidden-gene-set";
|
||||||
public static final String PANDA_MAIN_GENE_SET = "citizens.commands.npc.panda.main-gene-set";
|
public static final String PANDA_MAIN_GENE_SET = "citizens.commands.npc.panda.main-gene-set";
|
||||||
public static final String PANDA_ROLLING = "citizens.commands.npc.panda.rolling";
|
public static final String PANDA_ROLLING = "citizens.commands.npc.panda.rolling";
|
||||||
|
@ -221,6 +221,7 @@ citizens.commands.npc.pausepathfinding.pause-range-set=[{0}]] will now pause pat
|
|||||||
citizens.commands.npc.pausepathfinding.pause-ticks-set=[[{0}]] will now pause pathfinding for [[{1}]] ticks at a time.
|
citizens.commands.npc.pausepathfinding.pause-ticks-set=[[{0}]] will now pause pathfinding for [[{1}]] ticks at a time.
|
||||||
citizens.commands.npc.pausepathfinding.rightclick-set=[[{0}]] will now pause pathfinding on right click.
|
citizens.commands.npc.pausepathfinding.rightclick-set=[[{0}]] will now pause pathfinding on right click.
|
||||||
citizens.commands.npc.pausepathfinding.rightclick-unset=[[{0}]] will no longer pause pathfinding on right click.
|
citizens.commands.npc.pausepathfinding.rightclick-unset=[[{0}]] will no longer pause pathfinding on right click.
|
||||||
|
citizens.commands.npc.painting.art-set=[[{0}]]''s art set to [[{1}]].
|
||||||
citizens.commands.npc.playerlist.added=Added [[{0}]] to the player list.
|
citizens.commands.npc.playerlist.added=Added [[{0}]] to the player list.
|
||||||
citizens.commands.npc.playerlist.removed=Removed [[{0}]] from the player list.
|
citizens.commands.npc.playerlist.removed=Removed [[{0}]] from the player list.
|
||||||
citizens.commands.npc.playerfilter.cleared=[[{0}]]''s filter cleared.
|
citizens.commands.npc.playerfilter.cleared=[[{0}]]''s filter cleared.
|
||||||
|
Loading…
Reference in New Issue
Block a user