diff --git a/ data/plugin/plugin/DisabledPlugin.java b/ data/plugin/plugin/DisabledPlugin.java
new file mode 100644
index 000000000..7a236154d
--- /dev/null
+++ b/ data/plugin/plugin/DisabledPlugin.java
@@ -0,0 +1,19 @@
+package plugin;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation that is used to mark disabled plugins so they will be
+ * ignored by {@link PluginLoader}
+ *
+ * @author Rogiel
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface DisabledPlugin {
+}
diff --git a/ data/plugin/plugin/PluginLoader.java b/ data/plugin/plugin/PluginLoader.java
new file mode 100644
index 000000000..11a62dd5d
--- /dev/null
+++ b/ data/plugin/plugin/PluginLoader.java
@@ -0,0 +1,76 @@
+package plugin;
+
+import java.lang.reflect.Modifier;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.l2jserver.model.template.Template;
+import com.l2jserver.service.game.scripting.classlistener.Loader;
+import com.l2jserver.service.game.scripting.classlistener.Unloader;
+import com.l2jserver.util.ClassUtils;
+import com.l2jserver.util.factory.CollectionFactory;
+
+/**
+ * Utility class that loads all Plugins in classPath of this script context.
+ * Plugin should be public, not abstract, not interface, must have default
+ * constructor annotated with @Inject.
+ *
+ * @author Rogiel
+ */
+public class PluginLoader implements Loader, Unloader {
+ private static final Logger log = LoggerFactory
+ .getLogger(PluginLoader.class);
+
+ @Inject
+ public PluginLoader() {
+
+ }
+
+ @Override
+ public void load(Class>[] classes) {
+ log.debug("Loading plugins from {} classes", classes.length);
+ for (final Class extends Template>> template : getSuitableClasses(classes)) {
+ log.debug("Found loadable plugin class: {}", template);
+ //templateService.addTemplate(template);
+ }
+ }
+
+ @Override
+ public void unload(Class>[] classes) {
+ log.debug("Unloading plugins from {} classes", classes.length);
+ for (final Class extends Template>> template : getSuitableClasses(classes)) {
+ log.debug("Found unloadable plugin class: {}", template);
+ // TODO unloading
+ }
+ }
+
+ /**
+ * Returns list of suitable Template classes to load/unload
+ *
+ * @return list of Template classes to load/unload
+ */
+ @SuppressWarnings({ "unchecked" })
+ private static Set>> getSuitableClasses(
+ Class>[] classes) {
+ final Set>> suitable = CollectionFactory
+ .newSet(null);
+ for (Class> clazz : classes) {
+ if (!ClassUtils.isSubclass(clazz, Template.class))
+ continue;
+ if (Modifier.isAbstract(clazz.getModifiers())
+ || Modifier.isInterface(clazz.getModifiers()))
+ continue;
+ if (!Modifier.isPublic(clazz.getModifiers()))
+ continue;
+ if (clazz.isAnnotationPresent(DisabledPlugin.class))
+ continue;
+
+ suitable.add((Class extends Template>>) clazz);
+ }
+
+ return suitable;
+ }
+}
diff --git a/.classpath b/.classpath
index 25f798655..c87a51abc 100644
--- a/.classpath
+++ b/.classpath
@@ -7,6 +7,7 @@
+
diff --git a/data/script/template/script/template/DisabledTemplate.java b/data/script/template/script/template/DisabledTemplate.java
index a94ce48b9..21e7280af 100644
--- a/data/script/template/script/template/DisabledTemplate.java
+++ b/data/script/template/script/template/DisabledTemplate.java
@@ -7,10 +7,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
- * Marker annotation that is used to mark disabled DAO's so they will be ignored
- * by {@link TemplateLoader}
+ * Marker annotation that is used to mark disabled templates so they will be
+ * ignored by {@link TemplateLoader}
*
- * @author SoulKeeper
+ * @author Rogiel
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
diff --git a/data/script/template/script/template/TemplateLoader.java b/data/script/template/script/template/TemplateLoader.java
index 775f30374..bba9cdee0 100644
--- a/data/script/template/script/template/TemplateLoader.java
+++ b/data/script/template/script/template/TemplateLoader.java
@@ -18,7 +18,7 @@ import com.l2jserver.util.factory.CollectionFactory;
/**
* Utility class that loads all Template's in classPath of this script context.
* Template should be public, not abstract, not interface, must have default
- * no-arg public constructor.
+ * constructor annotated with @Inject.
*
* @author Rogiel
*/
diff --git a/src/main/java/com/l2jserver/model/world/Item.java b/src/main/java/com/l2jserver/model/world/Item.java
index b6aa84502..8c04a58ac 100644
--- a/src/main/java/com/l2jserver/model/world/Item.java
+++ b/src/main/java/com/l2jserver/model/world/Item.java
@@ -2,25 +2,46 @@ package com.l2jserver.model.world;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.template.ItemTemplateID;
+import com.l2jserver.model.world.capability.Dropable;
import com.l2jserver.model.world.capability.Listenable;
import com.l2jserver.model.world.capability.Playable;
import com.l2jserver.model.world.capability.Spawnable;
+import com.l2jserver.model.world.character.CharacterInventory.InventoryLocation;
+import com.l2jserver.model.world.character.CharacterInventory.InventoryPaperdoll;
import com.l2jserver.model.world.item.ItemEvent;
import com.l2jserver.model.world.item.ItemListener;
import com.l2jserver.util.Coordinate;
public class Item extends AbstractObject implements Playable, Spawnable,
- Listenable {
+ Listenable, Dropable {
private final ItemTemplateID templateID;
private CharacterID ownerID;
+ /**
+ * Inventory location of this item
+ */
+ private InventoryLocation location;
+ /**
+ * Paperdoll slot for this item
+ */
+ private InventoryPaperdoll paperdoll;
+ /**
+ * Drop coordinate of this item
+ */
+ private Coordinate coordinate;
+
public Item(ItemTemplateID templateID) {
this.templateID = templateID;
}
@Override
- public void spawn(Coordinate coordinate) {
+ public void drop(Coordinate position) {
+ this.coordinate = position;
+ }
+ @Override
+ public void spawn(Coordinate coordinate) {
+ this.drop(coordinate);
}
@Override
@@ -31,13 +52,44 @@ public class Item extends AbstractObject implements Playable, Spawnable,
@Override
public Coordinate getPosition() {
- // TODO Auto-generated method stub
- return null;
+ return coordinate;
}
@Override
public void setPosition(Coordinate coord) {
+ this.coordinate = coord;
+ }
+ /**
+ * @return the location
+ */
+ public InventoryLocation getLocation() {
+ return location;
+ }
+
+ /**
+ * @param location
+ * the location to set
+ */
+ public void setLocation(InventoryLocation location) {
+ this.location = location;
+ if (location != InventoryLocation.PAPERDOLL)
+ this.paperdoll = null;
+ }
+
+ /**
+ * @return the paperdoll
+ */
+ public InventoryPaperdoll getPaperdoll() {
+ return paperdoll;
+ }
+
+ /**
+ * @param paperdoll
+ * the paperdoll to set
+ */
+ public void setPaperdoll(InventoryPaperdoll paperdoll) {
+ this.paperdoll = paperdoll;
}
/**
diff --git a/src/main/java/com/l2jserver/model/world/character/CharacterInventory.java b/src/main/java/com/l2jserver/model/world/character/CharacterInventory.java
index 77b60c0b6..31f3d87ef 100644
--- a/src/main/java/com/l2jserver/model/world/character/CharacterInventory.java
+++ b/src/main/java/com/l2jserver/model/world/character/CharacterInventory.java
@@ -20,6 +20,13 @@ public class CharacterInventory implements Iterable- {
this.character = character;
}
+ /**
+ * This method will add new items to the inventory. This is normally called
+ * from the DAO object.
+ *
+ * @param items
+ * the items to be added
+ */
public void load(List
- items) {
items.addAll(items);
}
@@ -35,4 +42,12 @@ public class CharacterInventory implements Iterable
- {
public Iterator
- iterator() {
return items.iterator();
}
+
+ public enum InventoryLocation {
+ PAPERDOLL, INVENTORY;
+ }
+
+ public enum InventoryPaperdoll {
+ UNDERWEAR, HEAD, HAIR1, HAIR2, NECK, RIGHT_HAND, LEFT_HAND, RIGHT_EAR, LEFT_EAR, GLOVES, LEGS, LEFT_FEET, RIGHT_FEET, RIGHT_FINGER, LEFT_FINGER, LEFT_BRACELET, RIGHT_BRACELET, DECORATION_1, DECOREATION_2, DECORATION_3, DECORATION_4, DECORATION_5, DECORATION_6, CLOAK, BELT;
+ }
}
diff --git a/src/main/resources/sql/character.sql b/src/main/resources/sql/character.sql
index cba68f644..826adbece 100644
--- a/src/main/resources/sql/character.sql
+++ b/src/main/resources/sql/character.sql
@@ -3,7 +3,7 @@ CREATE TABLE `character` (
`account_id` varchar(50) NOT NULL,
`name` varchar(50) NOT NULL,
`race` enum('HUMAN') NOT NULL,
- `class` enum('HUMAN_FIGHTER','WARRIOR','GLADIATOR','WARLORD','KNIGHT','PALADIN','DARK_AVENGER','ROGUE','REASURE_HUNTER','HAWKEYE','HUMAN_MYSTIC','WIZARD','SORCEROR','NECROMANCER','WARLOCK','CLERIC','BISHOP','PROPHET','ELVEN_FIGHTER','ELVEN_KNIGHT','TEMPLE_KNIGHT','SWORD_SINGER','ELVEN_SCOUT','PLAINS_WALKER','SILVER_RANGER','ELVEN_MYSTIC','ELVEN_WIZARD','SPELLSINGER','ELEMENTAL_SUMMONER','ORACLE','ELDER','DARK_FIGHTER','PALUS_KNIGHT','SHILLIEN_KNIGHT','BLADEDANCER','ASSASSIN','ABYSS_WALKER','PHANTOM_RANGER','DARK_MYSTIC','DARK_WIZARD','SPELLHOWLER','PHANTOM_SUMMONER','SHILLIEN_ORACLE','SHILLIEN_ELDER') NOT NULL DEFAULT 'HUMAN_FIGHTER',
+ `class` enum('HUMAN_FIGHTER','WARRIOR','GLADIATOR','WARLORD','KNIGHT','PALADIN','DARK_AVENGER','ROGUE','TREASURE_HUNTER','HAWKEYE','DUELIST','DREADNOUGHT','phoenixKnight','hellKnight','sagittarius','adventurer','HUMAN_MYSTIC','WIZARD','SORCEROR','NECROMANCER','WARLOCK','CLERIC','BISHOP','PROPHET','ARCHMAGE','SOULTAKER','ARCANA_LORD','CARDINAL','HIEROPHANT','ELVEN_FIGHTER','ELVEN_KNIGHT','TEMPLE_KNIGHT','SWORD_SINGER','ELVEN_SCOUT','PLAINS_WALKER','SILVER_RANGER','EVA_TEMPLAR','SWORD_MUSE','WIND_RIDER','MOONLIGHT_SENTINEL','ELVEN_MYSTIC','ELVEN_WIZARD','SPELLSINGER','ELEMENTAL_SUMMONER','ORACLE','ELDER','MYSTIC_MUSE','ELEMENTAL_MASTER','EVA_SAINT','DARK_FIGHTER','PALUS_KNIGHT','SHILLIEN_KNIGHT','BLADEDANCER','ASSASSIN','ABYSS_WALKER','PHANTOM_RANGER','SHILLIEN_TEMPLAR','spectralDancer','ghostHunter','ghostSentinel','DARK_MYSTIC','DARK_WIZARD','SPELLHOWLER','PHANTOM_SUMMONER','SHILLIEN_ORACLE','SHILLIEN_ELDER','STORM_SCREAMER','SPECTRAL_MASTER','SHILLIEAN_SAINT','ORC_FIGHTER','ORC_RAIDER','DESTROYER','ORC_MONK','TYRANT','TITAN','GRAND_KHAUATARI','ORC_MYSTIC','ORC_SHAMAN','OVERLORD','WARCRYER','DOMINATOR','DOOMCRYER','DWARVEN_FIGHTER','SCAVENGER','BOUNTY_HUNTER','ARTISAN','WARSMITH','FORTUNE_SEEKER','MAESTRO','MALE_SOLDIER','TROOPER','BERSEKER','MALE_SOULBREAKER','DOOMBRINGER','MALE_SOULDHOUND','FEMALE_SOLDIER','WARDER','FEMALE_SOULBREAKER','ARBALESTER','FEMALE_SOULDHOUND','TRICKSTER','INSPECTOR','JUDICATOR') NOT NULL DEFAULT 'HUMAN_FIGHTER',
`sex` enum('MALE','FEMALE') NOT NULL,
`level` int(3) NOT NULL,
`experience` int(15) NOT NULL,
@@ -12,7 +12,7 @@ CREATE TABLE `character` (
`position_y` int(10) NOT NULL,
`position_z` int(10) NOT NULL,
`appearance_hair_style` enum('STYLE_A','STYLE_B','STYLE_C','STYLE_D','STYLE_E') NOT NULL DEFAULT 'STYLE_A',
- `appearance_hair_color` enum('COLOR_A','COLOR_B','COLOR3_C','COLOR_D') NOT NULL DEFAULT 'COLOR_A',
+ `appearance_hair_color` enum('COLOR_A','COLOR_B','COLOR_C','COLOR_D') NOT NULL DEFAULT 'COLOR_A',
`apperance_face` enum('FACE_A','FACE_B','FACE_C') NOT NULL DEFAULT 'FACE_A',
PRIMARY KEY (`character_id`),
KEY `account_id` (`account_id`),