mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-18 13:21:45 +01:00
added file headers
This commit is contained in:
parent
46a2763a98
commit
4a0d340755
@ -64,6 +64,7 @@ public class Citizens extends JavaPlugin {
|
||||
private final CommandManager cmdManager = new CommandManager();
|
||||
private Settings config;
|
||||
private Storage saves;
|
||||
private Storage templates;
|
||||
private boolean compatible;
|
||||
|
||||
private boolean handleMistake(CommandSender sender, String command, String modifier) {
|
||||
@ -174,7 +175,11 @@ public class Citizens extends JavaPlugin {
|
||||
if (Setting.USE_DATABASE.asBoolean())
|
||||
saves = new DatabaseStorage();
|
||||
else
|
||||
saves = new YamlStorage(getDataFolder() + File.separator + "saves.yml");
|
||||
saves = new YamlStorage(getDataFolder() + File.separator + "saves.yml", "Citizens NPC Storage");
|
||||
|
||||
// Templates
|
||||
templates = new YamlStorage(getDataFolder() + File.separator + "templates.yml", "NPC Templates");
|
||||
templates.load();
|
||||
|
||||
// Register API managers
|
||||
npcManager = new CitizensNPCManager(saves);
|
||||
@ -225,6 +230,14 @@ public class Citizens extends JavaPlugin {
|
||||
return cmdManager;
|
||||
}
|
||||
|
||||
public Storage getStorage() {
|
||||
return saves;
|
||||
}
|
||||
|
||||
public Storage getTemplates() {
|
||||
return templates;
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
cmdManager.setInjector(new Injector(this));
|
||||
|
||||
|
@ -10,7 +10,7 @@ public class Settings {
|
||||
private final YamlStorage config;
|
||||
|
||||
public Settings(Citizens plugin) {
|
||||
config = new YamlStorage(plugin.getDataFolder() + File.separator + "config.yml");
|
||||
config = new YamlStorage(plugin.getDataFolder() + File.separator + "config.yml", "Citizens Configuration");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
15
src/net/citizensnpcs/Template.java
Normal file
15
src/net/citizensnpcs/Template.java
Normal file
@ -0,0 +1,15 @@
|
||||
package net.citizensnpcs;
|
||||
|
||||
import net.citizensnpcs.api.DataKey;
|
||||
|
||||
public class Template {
|
||||
private final DataKey template;
|
||||
|
||||
public Template(DataKey template) {
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void apply(DataKey to) {
|
||||
// TODO
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package net.citizensnpcs.command.command;
|
||||
|
||||
import net.citizensnpcs.Citizens;
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.Template;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.trait.Character;
|
||||
import net.citizensnpcs.api.npc.trait.DefaultInstanceFactory;
|
||||
@ -23,21 +24,23 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
@Requirements(selected = true, ownership = true)
|
||||
public class NPCCommands {
|
||||
private final Citizens plugin;
|
||||
private final CitizensNPCManager npcManager;
|
||||
private final DefaultInstanceFactory<Character> characterManager;
|
||||
|
||||
public NPCCommands(Citizens plugin) {
|
||||
this.plugin = plugin;
|
||||
npcManager = plugin.getNPCManager();
|
||||
characterManager = plugin.getCharacterManager();
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "create [name] --type (type) --char (character)",
|
||||
usage = "create [name] --type (type) --char (character) --temp (template)",
|
||||
desc = "Create a new NPC",
|
||||
modifiers = { "create" },
|
||||
min = 2,
|
||||
max = 4,
|
||||
max = 5,
|
||||
permission = "npc.create")
|
||||
@Requirements
|
||||
public void createNPC(CommandContext args, Player player, NPC npc) {
|
||||
@ -68,6 +71,16 @@ public class NPCCommands {
|
||||
successMsg += " with the character " + StringHelper.wrap(args.getFlag("char"));
|
||||
}
|
||||
}
|
||||
if (args.hasValueFlag("temp")) {
|
||||
String template = args.getFlag("temp");
|
||||
if (!plugin.getTemplates().getKey("templates").keyExists(template)) {
|
||||
Messaging.sendError(player, "The template '" + template
|
||||
+ "' does not exist. Did you type the name incorrectly?");
|
||||
return;
|
||||
}
|
||||
new Template(plugin.getTemplates().getKey("templates." + template)).apply(plugin.getStorage().getKey(
|
||||
"npc." + npc.getId()));
|
||||
}
|
||||
successMsg += " at your location.";
|
||||
|
||||
// Set the owner
|
||||
@ -176,14 +189,8 @@ public class NPCCommands {
|
||||
Messaging.send(player, ChatColor.GREEN + "You teleported to " + StringHelper.wrap(npc.getName()) + ".");
|
||||
}
|
||||
|
||||
@Command(
|
||||
aliases = { "npc" },
|
||||
usage = "lookclose",
|
||||
desc = "Toggle an NPC's look-close state",
|
||||
modifiers = { "lookclose", "look", "rotate" },
|
||||
min = 1,
|
||||
max = 1,
|
||||
permission = "npc.look-close")
|
||||
@Command(aliases = { "npc" }, usage = "lookclose", desc = "Toggle an NPC's look-close state", modifiers = {
|
||||
"lookclose", "look", "rotate" }, min = 1, max = 1, permission = "npc.look-close")
|
||||
public void toggleNPCLookClose(CommandContext args, Player player, NPC npc) {
|
||||
LookClose trait = npc.getTrait(LookClose.class);
|
||||
trait.toggle();
|
||||
|
@ -18,11 +18,12 @@ public class YamlStorage implements Storage {
|
||||
private final FileConfiguration config;
|
||||
private final File file;
|
||||
|
||||
public YamlStorage(String fileName) {
|
||||
public YamlStorage(String fileName, String header) {
|
||||
config = new YamlConfiguration();
|
||||
file = new File(fileName);
|
||||
if (!file.exists()) {
|
||||
create();
|
||||
config.options().header(header);
|
||||
save();
|
||||
} else
|
||||
load();
|
||||
|
Loading…
Reference in New Issue
Block a user