mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-26 02:57:39 +01:00
Merge branch 'master' of http://www.github.com/CitizensDev/Citizens2
This commit is contained in:
commit
ccf0b14547
@ -138,7 +138,7 @@ public class Citizens extends JavaPlugin {
|
||||
saveNPCs();
|
||||
for (NPC npc : npcManager)
|
||||
npc.despawn();
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
Messaging.log("v" + getDescription().getVersion() + " disabled.");
|
||||
@ -230,6 +230,16 @@ public class Citizens extends JavaPlugin {
|
||||
}.start();
|
||||
}
|
||||
|
||||
public void reload() throws NPCLoadException {
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
config.load();
|
||||
for (NPC npc : npcManager)
|
||||
npc.despawn();
|
||||
|
||||
saves.load();
|
||||
setupNPCs();
|
||||
}
|
||||
|
||||
public CitizensNPCManager getNPCManager() {
|
||||
return npcManager;
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package net.citizensnpcs.command.command;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.citizensnpcs.Citizens;
|
||||
import net.citizensnpcs.api.exception.NPCLoadException;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.command.Command;
|
||||
import net.citizensnpcs.command.CommandContext;
|
||||
import net.citizensnpcs.command.Requirements;
|
||||
import net.citizensnpcs.command.ServerCommand;
|
||||
import net.citizensnpcs.util.Messaging;
|
||||
import net.citizensnpcs.util.StringHelper;
|
||||
|
||||
@ -18,16 +21,33 @@ public class AdminCommands {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "citizens" },
|
||||
desc = "Shows basic plugin information",
|
||||
max = 0,
|
||||
permission = "admin")
|
||||
@Requirements
|
||||
@Command(aliases = { "citizens" }, desc = "Show basic plugin information", max = 0, permission = "admin")
|
||||
public void citizens(CommandContext args, Player player, NPC npc) {
|
||||
Messaging.send(player, " " + StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
|
||||
Messaging.send(player, " "
|
||||
+ StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
|
||||
Messaging.send(player, " <7>-- <c>Written by fullwall and aPunch");
|
||||
Messaging.send(player, " <7>-- <c>Source: http://github.com/CitizensDev");
|
||||
Messaging.send(player, " <7>-- <c>Website: " + plugin.getDescription().getWebsite());
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "citizens" },
|
||||
usage = "reload",
|
||||
desc = "Reload Citizens",
|
||||
modifiers = { "reload" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "admin")
|
||||
@ServerCommand
|
||||
public void reload(CommandContext args, CommandSender sender, NPC npc) {
|
||||
// TODO possibly could be made more safe
|
||||
Messaging.send(sender, "<e>Reloading Citizens...");
|
||||
try {
|
||||
plugin.reload();
|
||||
Messaging.send(sender, "<e>Citizens reloaded.");
|
||||
} catch (NPCLoadException e) {
|
||||
Messaging.sendError(sender, "Error occured while reloading, see console.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -167,7 +167,7 @@ public class NPCCommands {
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "select [id]",
|
||||
desc = "Selects an NPC with the given ID",
|
||||
desc = "Select an NPC with the given ID",
|
||||
modifiers = { "select" },
|
||||
min = 2,
|
||||
max = 2,
|
||||
@ -190,7 +190,7 @@ public class NPCCommands {
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "character [character]",
|
||||
desc = "Sets the character of an NPC",
|
||||
desc = "Set the character of an NPC",
|
||||
modifiers = { "character" },
|
||||
min = 2,
|
||||
max = 2)
|
||||
|
@ -32,9 +32,6 @@ public class CitizensNPCManager implements NPCManager {
|
||||
}
|
||||
|
||||
public NPC createNPC(EntityType type, int id, String name, Character character) {
|
||||
if (npcs.contains(id))
|
||||
throw new IllegalArgumentException("An NPC already has the ID '" + id + "'.");
|
||||
|
||||
CitizensNPC npc = npcBuilder.getByType(type, this, id, name);
|
||||
npc.setCharacter(character);
|
||||
npcs.put(npc.getId(), npc);
|
||||
|
@ -8,6 +8,7 @@ import net.citizensnpcs.api.trait.trait.Owner;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
@ -28,23 +29,26 @@ public class Messaging {
|
||||
log(Level.INFO, SPACE.join(msg));
|
||||
}
|
||||
|
||||
public static void send(Player player, Object msg) {
|
||||
player.sendMessage(StringHelper.parseColors(msg.toString()));
|
||||
public static void send(CommandSender sender, Object msg) {
|
||||
sender.sendMessage(StringHelper.parseColors(msg.toString()));
|
||||
}
|
||||
|
||||
public static void sendError(Player player, Object msg) {
|
||||
send(player, ChatColor.RED.toString() + msg);
|
||||
public static void sendError(CommandSender sender, Object msg) {
|
||||
send(sender, ChatColor.RED.toString() + msg);
|
||||
}
|
||||
|
||||
public static void sendWithNPC(Player player, Object msg, NPC npc) {
|
||||
public static void sendWithNPC(CommandSender sender, Object msg, NPC npc) {
|
||||
String send = msg.toString();
|
||||
|
||||
send = send.replace("<player>", player.getName());
|
||||
send = send.replace("<world>", player.getWorld().getName());
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
send = send.replace("<player>", player.getName());
|
||||
send = send.replace("<world>", player.getWorld().getName());
|
||||
}
|
||||
send = send.replace("<owner>", npc.getTrait(Owner.class).getOwner());
|
||||
send = send.replace("<npc>", npc.getName());
|
||||
send = send.replace("<id>", Integer.toString(npc.getId()));
|
||||
|
||||
send(player, send);
|
||||
send(sender, send);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user