formatting

This commit is contained in:
aPunch 2012-02-23 05:17:15 -06:00
parent 37a88456f9
commit a1ba5dee89
20 changed files with 127 additions and 217 deletions

4
README
View File

@ -1 +1,5 @@
---------- Citizens2 README ----------
Citizens is an NPC plugin for the Bukkit API. It was first released on March 5, 2011, and has since
seen numerous updates. Citizens provides an API itself, which developers can use to create their
own NPC characters.

5
TODO
View File

@ -1,5 +0,0 @@
-Citizens2 TODO List-
-Add NPC templates
-Finish pathfinding API
-Add database support (MySQL and/or SQLite)

Binary file not shown.

View File

@ -14,10 +14,10 @@ import net.citizensnpcs.api.trait.Character;
import net.citizensnpcs.api.trait.DefaultInstanceFactory;
import net.citizensnpcs.api.trait.InstanceFactory;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.builtin.Inventory;
import net.citizensnpcs.api.trait.builtin.Owner;
import net.citizensnpcs.api.trait.builtin.SpawnLocation;
import net.citizensnpcs.api.trait.builtin.Spawned;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.trait.trait.Owner;
import net.citizensnpcs.api.trait.trait.SpawnLocation;
import net.citizensnpcs.api.trait.trait.Spawned;
import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.api.util.DatabaseStorage;
import net.citizensnpcs.api.util.Storage;

View File

@ -7,8 +7,8 @@ import java.util.Map;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.builtin.Owner;
import net.citizensnpcs.api.trait.builtin.SpawnLocation;
import net.citizensnpcs.api.trait.trait.Owner;
import net.citizensnpcs.api.trait.trait.SpawnLocation;
import net.citizensnpcs.npc.CitizensNPCManager;
import net.citizensnpcs.util.Messaging;

View File

@ -1,21 +1,3 @@
// $Id$
/*
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.citizensnpcs.command;
import java.lang.annotation.Retention;
@ -37,6 +19,6 @@ public @interface Command {
String[] modifiers() default "";
String usage() default "";
String permission() default "";
}

View File

@ -1,22 +1,3 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.citizensnpcs.command;
import java.lang.reflect.InvocationTargetException;
@ -33,7 +14,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.builtin.Owner;
import net.citizensnpcs.api.trait.trait.Owner;
import net.citizensnpcs.command.exception.CommandException;
import net.citizensnpcs.command.exception.CommandUsageException;
import net.citizensnpcs.command.exception.NoPermissionsException;

View File

@ -1,9 +1,3 @@
// $Id$
/*
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
* All rights reserved.
*/
package net.citizensnpcs.command;
import java.lang.reflect.Constructor;
@ -13,7 +7,6 @@ import java.util.logging.Level;
import net.citizensnpcs.util.Messaging;
public class Injector {
private Object[] args;
private Class<?>[] argClasses;

View File

@ -5,10 +5,10 @@ import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.Character;
import net.citizensnpcs.api.trait.InstanceFactory;
import net.citizensnpcs.api.trait.builtin.MobType;
import net.citizensnpcs.api.trait.builtin.Owner;
import net.citizensnpcs.api.trait.builtin.SpawnLocation;
import net.citizensnpcs.api.trait.builtin.Spawned;
import net.citizensnpcs.api.trait.trait.MobType;
import net.citizensnpcs.api.trait.trait.Owner;
import net.citizensnpcs.api.trait.trait.SpawnLocation;
import net.citizensnpcs.api.trait.trait.Spawned;
import net.citizensnpcs.command.Command;
import net.citizensnpcs.command.CommandContext;
import net.citizensnpcs.command.Requirements;
@ -41,8 +41,14 @@ public class NPCCommands {
Messaging.send(player, " <a>Type: <e>" + npc.getTrait(MobType.class).getType());
}
@Command(aliases = { "npc" }, usage = "create [name] --type (type) --char (character)", desc = "Create a new NPC",
modifiers = { "create" }, min = 2, max = 5, permission = "npc.create")
@Command(
aliases = { "npc" },
usage = "create [name] --type (type) --char (character)",
desc = "Create a new NPC",
modifiers = { "create" },
min = 2,
max = 5,
permission = "npc.create")
@Requirements
public void createNPC(CommandContext args, Player player, NPC npc) {
String name = args.getString(1);
@ -64,9 +70,8 @@ public class NPCCommands {
if (args.hasValueFlag("char")) {
String character = args.getFlag("char").toLowerCase();
if (characterManager.getInstance(character, create) == null) {
Messaging.sendError(player,
"The character '" + args.getFlag("char") + "' does not exist. " + create.getName()
+ " was created at your location without a character.");
Messaging.sendError(player, "The character '" + args.getFlag("char") + "' does not exist. "
+ create.getName() + " was created at your location without a character.");
success = false;
} else {
create.setCharacter(characterManager.getInstance(character, create));
@ -87,16 +92,27 @@ public class NPCCommands {
Messaging.send(player, successMsg);
}
@Command(aliases = { "npc" }, usage = "despawn", desc = "Despawn an NPC", modifiers = { "despawn" }, min = 1,
max = 1, permission = "npc.despawn")
@Command(
aliases = { "npc" },
usage = "despawn",
desc = "Despawn an NPC",
modifiers = { "despawn" },
min = 1,
max = 1,
permission = "npc.despawn")
public void despawnNPC(CommandContext args, Player player, NPC npc) {
npc.getTrait(Spawned.class).setSpawned(false);
npc.despawn();
Messaging.send(player, ChatColor.GREEN + "You despawned " + StringHelper.wrap(npc.getName()) + ".");
}
@Command(aliases = { "npc" }, usage = "remove (all)", desc = "Remove an NPC", modifiers = { "remove" }, min = 1,
max = 2)
@Command(
aliases = { "npc" },
usage = "remove (all)",
desc = "Remove an NPC",
modifiers = { "remove" },
min = 1,
max = 2)
@Requirements
public void removeNPC(CommandContext args, Player player, NPC npc) {
if (args.argsLength() == 2) {
@ -124,8 +140,14 @@ public class NPCCommands {
Messaging.send(player, "<a>You permanently removed " + StringHelper.wrap(npc.getName()) + ".");
}
@Command(aliases = { "npc" }, usage = "rename [name]", desc = "Rename an NPC", modifiers = { "rename" }, min = 2,
max = 2, permission = "npc.rename")
@Command(
aliases = { "npc" },
usage = "rename [name]",
desc = "Rename an NPC",
modifiers = { "rename" },
min = 2,
max = 2,
permission = "npc.rename")
public void renameNPC(CommandContext args, Player player, NPC npc) {
String oldName = npc.getName();
String newName = args.getString(1);
@ -134,13 +156,18 @@ public class NPCCommands {
newName = newName.substring(0, 15);
}
npc.setName(newName);
Messaging.send(player,
ChatColor.GREEN + "You renamed " + StringHelper.wrap(oldName) + " to " + StringHelper.wrap(newName)
+ ".");
Messaging.send(player, ChatColor.GREEN + "You renamed " + StringHelper.wrap(oldName) + " to "
+ StringHelper.wrap(newName) + ".");
}
@Command(aliases = { "npc" }, usage = "select [id]", desc = "Selects an NPC with the given ID",
modifiers = { "select" }, min = 2, max = 2, permission = "npc.select")
@Command(
aliases = { "npc" },
usage = "select [id]",
desc = "Selects an NPC with the given ID",
modifiers = { "select" },
min = 2,
max = 2,
permission = "npc.select")
@Requirements(ownership = true)
public void selectNPC(CommandContext args, Player player, NPC npc) {
NPC toSelect = npcManager.getNPC(args.getInteger(1));
@ -156,8 +183,13 @@ public class NPCCommands {
Messaging.sendWithNPC(player, Setting.SELECTION_MESSAGE.asString(), toSelect);
}
@Command(aliases = { "npc" }, usage = "character [character]", desc = "Sets the character of an NPC",
modifiers = { "character" }, min = 2, max = 2)
@Command(
aliases = { "npc" },
usage = "character [character]",
desc = "Sets the character of an NPC",
modifiers = { "character" },
min = 2,
max = 2)
public void setNPCCharacter(CommandContext args, Player player, NPC npc) {
String name = args.getString(1).toLowerCase();
Character character = characterManager.getInstance(name, npc);
@ -174,13 +206,19 @@ public class NPCCommands {
Messaging.sendError(player, "You don't have permission to execute that command.");
return;
}
Messaging.send(player,
StringHelper.wrap(npc.getName() + "'s") + " character is now '" + StringHelper.wrap(name) + "'.");
Messaging.send(player, StringHelper.wrap(npc.getName() + "'s") + " character is now '"
+ StringHelper.wrap(name) + "'.");
npc.setCharacter(character);
}
@Command(aliases = { "npc" }, usage = "spawn [id]", desc = "Spawn an existing NPC", modifiers = { "spawn" },
min = 2, max = 2, permission = "npc.spawn")
@Command(
aliases = { "npc" },
usage = "spawn [id]",
desc = "Spawn an existing NPC",
modifiers = { "spawn" },
min = 2,
max = 2,
permission = "npc.spawn")
@Requirements
public void spawnNPC(CommandContext args, Player player, NPC npc) {
NPC respawn = npcManager.getNPC(args.getInteger(1));
@ -204,8 +242,14 @@ public class NPCCommands {
}
}
@Command(aliases = { "npc" }, usage = "tphere", desc = "Teleport an NPC to your location",
modifiers = { "tphere" }, min = 1, max = 1, permission = "npc.tphere")
@Command(
aliases = { "npc" },
usage = "tphere",
desc = "Teleport an NPC to your location",
modifiers = { "tphere" },
min = 1,
max = 1,
permission = "npc.tphere")
public void teleportNPCToPlayer(CommandContext args, Player player, NPC npc) {
// Spawn the NPC if it isn't spawned to prevent NPEs
if (!npc.isSpawned())
@ -215,8 +259,14 @@ public class NPCCommands {
Messaging.send(player, StringHelper.wrap(npc.getName()) + " was teleported to your location.");
}
@Command(aliases = { "npc" }, usage = "tp", desc = "Teleport to an NPC", modifiers = { "tp", "teleport" }, min = 1,
max = 1, permission = "npc.tp")
@Command(
aliases = { "npc" },
usage = "tp",
desc = "Teleport to an NPC",
modifiers = { "tp", "teleport" },
min = 1,
max = 1,
permission = "npc.tp")
public void teleportToNPC(CommandContext args, Player player, NPC npc) {
// Spawn the NPC if it isn't spawned to prevent NPEs
if (!npc.isSpawned())

View File

@ -1,36 +1,17 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.citizensnpcs.command.exception;
public class CommandException extends Exception {
public CommandException() {
super();
}
private static final long serialVersionUID = 870638193072101739L;
public CommandException(String message) {
super(message);
}
public CommandException() {
super();
}
public CommandException(Throwable t) {
super(t);
}
public CommandException(String message) {
super(message);
}
private static final long serialVersionUID = 870638193072101739L;
public CommandException(Throwable t) {
super(t);
}
}

View File

@ -1,35 +1,16 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.citizensnpcs.command.exception;
public class CommandUsageException extends CommandException {
private static final long serialVersionUID = -6761418114414516542L;
private static final long serialVersionUID = -6761418114414516542L;
protected String usage;
protected String usage;
public CommandUsageException(String message, String usage) {
super(message);
this.usage = usage;
}
public CommandUsageException(String message, String usage) {
super(message);
this.usage = usage;
}
public String getUsage() {
return usage;
}
public String getUsage() {
return usage;
}
}

View File

@ -1,22 +1,3 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.citizensnpcs.command.exception;
public class NoPermissionsException extends CommandException {

View File

@ -1,10 +1,9 @@
package net.citizensnpcs.command.exception;
public class RequirementMissingException extends CommandException {
private static final long serialVersionUID = -4299721983654504028L;
public RequirementMissingException(String message) {
super(message);
}
private static final long serialVersionUID = -4299721983654504028L;
public RequirementMissingException(String message) {
super(message);
}
}

View File

@ -1,24 +1,5 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.citizensnpcs.command.exception;
public class UnhandledCommandException extends CommandException {
private static final long serialVersionUID = 3370887306593968091L;
private static final long serialVersionUID = 3370887306593968091L;
}

View File

@ -1,28 +1,9 @@
// $Id$
/*
* WorldEdit
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.citizensnpcs.command.exception;
public class WrappedCommandException extends CommandException {
public WrappedCommandException(Throwable t) {
super(t);
}
private static final long serialVersionUID = -4075721444847778918L;
private static final long serialVersionUID = -4075721444847778918L;
public WrappedCommandException(Throwable t) {
super(t);
}
}

View File

@ -5,9 +5,9 @@ import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.event.NPCDespawnEvent;
import net.citizensnpcs.api.event.NPCSpawnEvent;
import net.citizensnpcs.api.npc.AbstractNPC;
import net.citizensnpcs.api.trait.builtin.Inventory;
import net.citizensnpcs.api.trait.builtin.SpawnLocation;
import net.citizensnpcs.api.trait.builtin.Spawned;
import net.citizensnpcs.api.trait.trait.Inventory;
import net.citizensnpcs.api.trait.trait.SpawnLocation;
import net.citizensnpcs.api.trait.trait.Spawned;
import net.citizensnpcs.npc.ai.CitizensAI;
import net.citizensnpcs.util.Messaging;

View File

@ -9,7 +9,7 @@ import net.citizensnpcs.api.event.NPCSelectEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCManager;
import net.citizensnpcs.api.trait.Character;
import net.citizensnpcs.api.trait.builtin.SpawnLocation;
import net.citizensnpcs.api.trait.trait.SpawnLocation;
import net.citizensnpcs.api.util.Storage;
import net.citizensnpcs.util.ByIdArray;
import net.citizensnpcs.util.NPCBuilder;

View File

@ -88,7 +88,7 @@ public class NPCInventory implements IInventory {
index++;
}
npc.getTrait(net.citizensnpcs.api.trait.builtin.Inventory.class).setContents(bukkitItems);
npc.getTrait(net.citizensnpcs.api.trait.trait.Inventory.class).setContents(bukkitItems);
}
@Override

View File

@ -7,6 +7,7 @@ import net.citizensnpcs.editor.Editor;
import org.bukkit.entity.Player;
public interface WaypointProvider {
public Editor createEditor(Player player);
public void load(DataKey key);

View File

@ -4,7 +4,7 @@ import java.util.logging.Level;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.trait.builtin.Owner;
import net.citizensnpcs.api.trait.trait.Owner;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;