1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-11 09:42:54 +00:00

Several improvements

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-05-19 01:40:53 -03:00
parent 9bb83652e4
commit 2c4af6d91d
263 changed files with 2135 additions and 663 deletions

View File

@@ -71,5 +71,4 @@ public abstract class ID<T> {
return false;
return true;
}
}

View File

@@ -16,12 +16,13 @@
*/
package com.l2jserver.model.id;
import com.l2jserver.model.id.factory.IDFactory;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.model.world.WorldObject;
/**
* {@link ObjectID}s cannot be instantiated directly. This must be done through
* an {@link IDFactory}. The {@link ObjectID} provides a facility
* an {@link IDProvider}. The {@link ObjectID} provides a facility
* {@link #getObject() method} that allows easily fetch this object from
* database without the need to directly use DAOs.
*
@@ -37,7 +38,7 @@ public abstract class ObjectID<T extends WorldObject> extends ID<Integer> {
* @param id
* the raw id
*/
protected ObjectID(int id) {
protected ObjectID(@Assisted int id) {
super(id);
}
@@ -47,4 +48,33 @@ public abstract class ObjectID<T extends WorldObject> extends ID<Integer> {
* @return the {@link WorldObject} if existent, <tt>null</tt> otherwise
*/
public abstract T getObject();
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
// this way we generate an unique hash code for all ObjectID and another
// ID with same id number will still generate another hash code.
result = prime * result + id.hashCode() + ObjectID.class.hashCode();
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
// we have unique id across all objects
// accept all subclasses of ObjectID is a requirement
if (!(obj instanceof ObjectID))
return false;
@SuppressWarnings("rawtypes")
ObjectID other = (ObjectID) obj;
if (other.id != null)
return false;
if (!id.equals(other.id))
return false;
return true;
}
}

View File

@@ -1,69 +0,0 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.l2jserver.model.id.object.allocator.BitSetIDAllocator;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.object.factory.CharacterIDFactory;
import com.l2jserver.model.id.object.factory.CharacterIDFactory.CharacterIDGuiceFactory;
import com.l2jserver.model.id.object.factory.ClanIDFactory;
import com.l2jserver.model.id.object.factory.ClanIDFactory.ClanIDGuiceFactory;
import com.l2jserver.model.id.object.factory.ItemIDFactory;
import com.l2jserver.model.id.object.factory.ItemIDFactory.ItemIDGuiceFactory;
import com.l2jserver.model.id.template.factory.CharacterTemplateIDFactory;
import com.l2jserver.model.id.template.factory.ItemTemplateIDFactory;
import com.l2jserver.model.id.template.factory.SkillTemplateIDFactory;
/**
* Google Guice {@link IDFactory} {@link Module}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class IDFactoryModule extends AbstractModule {
@Override
protected void configure() {
bind(IDAllocator.class).to(BitSetIDAllocator.class)
.in(Scopes.SINGLETON);
// OBJECT IDS
bind(CharacterIDFactory.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(CharacterIDGuiceFactory.class));
bind(ItemIDFactory.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(ItemIDGuiceFactory.class));
bind(ClanIDFactory.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(ClanIDGuiceFactory.class));
// bind(PetIDFactory.class).in(Scopes.SINGLETON);
// install(new FactoryModuleBuilder().build(PetIDGuiceFactory.class));
// MISC OBJECTS
install(new FactoryModuleBuilder().build(AccountIDFactory.class));
install(new FactoryModuleBuilder().build(FortIDFactory.class));
// TEMPLATE IDS
install(new FactoryModuleBuilder().build(ItemTemplateIDFactory.class));
install(new FactoryModuleBuilder().build(SkillTemplateIDFactory.class));
install(new FactoryModuleBuilder()
.build(CharacterTemplateIDFactory.class));
}
}

View File

@@ -0,0 +1,49 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.world.NPC;
import com.l2jserver.service.database.DataAccessObject;
import com.l2jserver.service.game.world.WorldService;
/**
* An {@link ObjectID} instance representing an {@link NPC} object. Since NPC
* instances are stores in run-time only, the search is performed in the
* {@link WorldService} instead of using a {@link DataAccessObject}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public final class NPCID extends ActorID<NPC> {
/**
* {@link WorldService} used to locate objects
*/
private final WorldService worldService;
@Inject
public NPCID(@Assisted int id, WorldService worldService) {
super(id);
this.worldService = worldService;
}
@Override
public NPC getObject() {
return worldService.find(this);
}
}

View File

@@ -134,6 +134,11 @@ public class BitSetIDAllocator implements IDAllocator {
lock.unlock();
}
}
@Override
public void clear() {
ids.clear();
}
/**
* Increases the {@link BitSet} capacity

View File

@@ -59,6 +59,11 @@ public interface IDAllocator {
*/
void release(int id);
/**
* Release all allocated IDs
*/
void clear();
/**
* Get the amount of already allocated IDs
*

View File

@@ -14,49 +14,62 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDFactory} for {@link CharacterID}.
* {@link IDProvider} for {@link CharacterID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class CharacterIDFactory implements ObjectIDFactory<CharacterID> {
public class CharacterIDProvider implements ObjectIDProvider<CharacterID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService} instance. Used to locate existing IDs.
*/
private final WorldIDService idService;
/**
* The Guice Factory
*/
private final CharacterIDGuiceFactory factory;
@Inject
public CharacterIDFactory(IDAllocator allocator,
public CharacterIDProvider(IDAllocator allocator, WorldIDService idService,
CharacterIDGuiceFactory factory) {
super();
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public CharacterID createID() {
return createID(allocator.allocate());
final CharacterID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public CharacterID createID(Integer id) {
return factory.create(id);
CharacterID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(CharacterID id) {
idService.remove(id);
allocator.release(id.getID());
}

View File

@@ -14,48 +14,63 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.object.ClanID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDFactory} for {@link ClanID}.
* {@link IDProvider} for {@link ClanID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ClanIDFactory implements ObjectIDFactory<ClanID> {
public class ClanIDProvider implements ObjectIDProvider<ClanID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService}
*/
private final WorldIDService idService;
/**
* The Guice factory
*/
private final ClanIDGuiceFactory factory;
@Inject
public ClanIDFactory(IDAllocator allocator, ClanIDGuiceFactory factory) {
public ClanIDProvider(IDAllocator allocator, WorldIDService idService,
ClanIDGuiceFactory factory) {
super();
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public ClanID createID() {
return createID(allocator.allocate());
final ClanID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public ClanID createID(Integer id) {
return factory.create(id);
ClanID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(ClanID id) {
idService.remove(id);
allocator.release(id.getID());
}

View File

@@ -14,48 +14,63 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.object.ItemID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDFactory} for {@link ItemID}.
* {@link IDProvider} for {@link ItemID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ItemIDFactory implements ObjectIDFactory<ItemID> {
public class ItemIDProvider implements ObjectIDProvider<ItemID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService}
*/
private final WorldIDService idService;
/**
* The Guice factory
*/
private final ItemIDGuiceFactory factory;
@Inject
public ItemIDFactory(IDAllocator allocator, ItemIDGuiceFactory factory) {
public ItemIDProvider(IDAllocator allocator, WorldIDService idService,
ItemIDGuiceFactory factory) {
super();
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public ItemID createID() {
return createID(allocator.allocate());
final ItemID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public ItemID createID(Integer id) {
return factory.create(id);
ItemID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(ItemID id) {
idService.remove(id);
allocator.release(id.getID());
}

View File

@@ -0,0 +1,92 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.object.NPCID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDProvider} for {@link NPCID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPCIDProvider implements ObjectIDProvider<NPCID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService} instance. Used to locate existing IDs.
*/
private final WorldIDService idService;
/**
* The Guice Factory
*/
private final NPCIDGuiceFactory factory;
@Inject
public NPCIDProvider(IDAllocator allocator, WorldIDService idService,
NPCIDGuiceFactory factory) {
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public NPCID createID() {
final NPCID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public NPCID createID(Integer id) {
NPCID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(NPCID id) {
idService.remove(id);
allocator.release(id.getID());
}
/**
* This is an Google Guice factory. Assistect Inject extension will
* automatically implement it and create the injected instances.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface NPCIDGuiceFactory {
/**
* Creates a new ID instance
*
* @param id
* the numeric ID
* @return the new ID created by injection
*/
NPCID create(@Assisted int id);
}
}

View File

@@ -14,13 +14,13 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.provider.IDProvider;
public interface ObjectIDFactory<T extends ObjectID<?>> extends
IDFactory<Integer, T> {
public interface ObjectIDProvider<T extends ObjectID<?>> extends
IDProvider<Integer, T> {
/**
* Generates a new ID
*

View File

@@ -0,0 +1,77 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.l2jserver.model.id.ObjectID;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* <h1>THIS PROVIDER IS READ ONLY!</h1>
* <p>
* This is an ID resolver that will lookup for IDs in {@link WorldIDService}.
* Since this is only a resolver, only read operations can be performed and
* {@link #createID()} and {@link #destroy(ObjectID)} will throw
* {@link UnsupportedOperationException}.
* <p>
* Another important aspect is that in {@link #createID(Integer)} if the ID is
* not found, it will <b>NOT</b> be created, instead <tt>null</tt> will be
* returned. You must use specific a {@link ObjectIDProvider} for that.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class ObjectIDResolver implements ObjectIDProvider<ObjectID<?>> {
/**
* The {@link WorldIDService}
*/
private final WorldIDService idService;
@Inject
public ObjectIDResolver(WorldIDService idService) {
this.idService = idService;
}
@Override
public ObjectID<?> createID() {
throw new UnsupportedOperationException();
}
@Override
public ObjectID<?> createID(Integer id) {
return idService.resolve(id);
}
/**
* Resolves an integer ID to an {@link ObjectID}. If the ID does not exists
* <tt>null</tt> is returned.
*
* @param <T>
* the ID type
* @param id
* the id
* @return the id found, null if non existent
*/
@SuppressWarnings("unchecked")
public <T extends ObjectID<?>> T resolve(Integer id) {
return (T) createID(id);
}
@Override
public void destroy(ObjectID<?> id) {
throw new UnsupportedOperationException();
}
}

View File

@@ -14,48 +14,63 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.object.factory;
package com.l2jserver.model.id.object.provider;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.object.PetID;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.provider.IDProvider;
import com.l2jserver.service.game.world.id.WorldIDService;
/**
* {@link IDFactory} for {@link PetID}.
* {@link IDProvider} for {@link PetID}.
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class PetIDFactory implements ObjectIDFactory<PetID> {
public class PetIDProvider implements ObjectIDProvider<PetID> {
/**
* The ID allocator
*/
private final IDAllocator allocator;
/**
* The {@link WorldIDService}
*/
private final WorldIDService idService;
/**
* The Guice factory
*/
private final PetIDGuiceFactory factory;
@Inject
public PetIDFactory(IDAllocator allocator, PetIDGuiceFactory factory) {
public PetIDProvider(IDAllocator allocator, WorldIDService idService,
PetIDGuiceFactory factory) {
super();
this.allocator = allocator;
this.idService = idService;
this.factory = factory;
}
@Override
public PetID createID() {
return createID(allocator.allocate());
final PetID id = factory.create(allocator.allocate());
idService.add(id);
return id;
}
@Override
public PetID createID(Integer id) {
return factory.create(id);
PetID idObject = idService.resolve(id);
if (idObject == null) {
idObject = factory.create(id);
idService.add(idObject);
}
return idObject;
}
@Override
public void destroy(PetID id) {
idService.remove(id);
allocator.release(id.getID());
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.AccountID;
@@ -23,5 +23,5 @@ import com.l2jserver.model.id.AccountID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface AccountIDFactory extends IDFactory<String, AccountID> {
public interface AccountIDProvider extends IDProvider<String, AccountID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.CastleID;
@@ -23,5 +23,5 @@ import com.l2jserver.model.id.CastleID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface CastleIDFactory extends IDFactory<Integer, CastleID> {
public interface CastleIDProvider extends IDProvider<Integer, CastleID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.FortID;
@@ -23,5 +23,5 @@ import com.l2jserver.model.id.FortID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface FortIDFactory extends IDFactory<Integer, FortID> {
public interface FortIDProvider extends IDProvider<Integer, FortID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.factory;
package com.l2jserver.model.id.provider;
import com.l2jserver.model.id.ID;
@@ -24,7 +24,7 @@ import com.l2jserver.model.id.ID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface IDFactory<I, T extends ID<?>> {
public interface IDProvider<I, T extends ID<?>> {
/**
* Creates the ID object for an <b>EXISTING</b> ID.
*

View File

@@ -0,0 +1,79 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.provider;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.l2jserver.model.id.object.allocator.BitSetIDAllocator;
import com.l2jserver.model.id.object.allocator.IDAllocator;
import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.id.object.provider.CharacterIDProvider.CharacterIDGuiceFactory;
import com.l2jserver.model.id.object.provider.ClanIDProvider;
import com.l2jserver.model.id.object.provider.ClanIDProvider.ClanIDGuiceFactory;
import com.l2jserver.model.id.object.provider.ItemIDProvider;
import com.l2jserver.model.id.object.provider.ItemIDProvider.ItemIDGuiceFactory;
import com.l2jserver.model.id.object.provider.NPCIDProvider;
import com.l2jserver.model.id.object.provider.NPCIDProvider.NPCIDGuiceFactory;
import com.l2jserver.model.id.object.provider.ObjectIDResolver;
import com.l2jserver.model.id.template.provider.CharacterTemplateIDProvider;
import com.l2jserver.model.id.template.provider.ItemTemplateIDProvider;
import com.l2jserver.model.id.template.provider.NPCTemplateIDProvider;
import com.l2jserver.model.id.template.provider.SkillTemplateIDProvider;
/**
* Google Guice {@link IDProvider} {@link Module}
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class IDProviderModule extends AbstractModule {
@Override
protected void configure() {
bind(IDAllocator.class).to(BitSetIDAllocator.class)
.in(Scopes.SINGLETON);
// OBJECT IDS
bind(ObjectIDResolver.class).in(Scopes.SINGLETON); // read-only!
bind(CharacterIDProvider.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(CharacterIDGuiceFactory.class));
bind(NPCIDProvider.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(NPCIDGuiceFactory.class));
bind(ItemIDProvider.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(ItemIDGuiceFactory.class));
bind(ClanIDProvider.class).in(Scopes.SINGLETON);
install(new FactoryModuleBuilder().build(ClanIDGuiceFactory.class));
// bind(PetIDFactory.class).in(Scopes.SINGLETON);
// install(new FactoryModuleBuilder().build(PetIDGuiceFactory.class));
// MISC OBJECTS
install(new FactoryModuleBuilder().build(AccountIDProvider.class));
install(new FactoryModuleBuilder().build(FortIDProvider.class));
// TEMPLATE IDS
install(new FactoryModuleBuilder().build(ItemTemplateIDProvider.class));
install(new FactoryModuleBuilder().build(SkillTemplateIDProvider.class));
install(new FactoryModuleBuilder()
.build(CharacterTemplateIDProvider.class));
install(new FactoryModuleBuilder().build(NPCTemplateIDProvider.class));
}
}

View File

@@ -27,7 +27,7 @@ import com.l2jserver.service.game.template.TemplateService;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class NPCTemplateID extends ActorTemplateID<NPCTemplate<?>> {
public class NPCTemplateID extends ActorTemplateID<NPCTemplate> {
@Inject
protected NPCTemplateID(@Assisted int id, TemplateService templateService) {
super(id, templateService);

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.factory;
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.template.CharacterTemplateID;
@@ -23,6 +23,6 @@ import com.l2jserver.model.id.template.CharacterTemplateID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface CharacterTemplateIDFactory extends
TemplateIDFactory<CharacterTemplateID> {
public interface CharacterTemplateIDProvider extends
TemplateIDProvider<CharacterTemplateID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.factory;
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.template.ItemTemplateID;
@@ -23,6 +23,6 @@ import com.l2jserver.model.id.template.ItemTemplateID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface ItemTemplateIDFactory extends
TemplateIDFactory<ItemTemplateID> {
public interface ItemTemplateIDProvider extends
TemplateIDProvider<ItemTemplateID> {
}

View File

@@ -0,0 +1,28 @@
/*
* This file is part of l2jserver <l2jserver.com>.
*
* l2jserver 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.
*
* l2jserver 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 l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.template.NPCTemplateID;
/**
* Creates new {@link NPCTemplateID} instances
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface NPCTemplateIDProvider extends
TemplateIDProvider<NPCTemplateID> {
}

View File

@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.factory;
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.template.SkillTemplateID;
@@ -23,6 +23,6 @@ import com.l2jserver.model.id.template.SkillTemplateID;
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public interface SkillTemplateIDFactory extends
TemplateIDFactory<SkillTemplateID> {
public interface SkillTemplateIDProvider extends
TemplateIDProvider<SkillTemplateID> {
}

View File

@@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver. If not, see <http://www.gnu.org/licenses/>.
*/
package com.l2jserver.model.id.template.factory;
package com.l2jserver.model.id.template.provider;
import com.l2jserver.model.id.TemplateID;
import com.l2jserver.model.id.factory.IDFactory;
import com.l2jserver.model.id.provider.IDProvider;
/**
* Creates a new {@link TemplateID}
@@ -27,6 +27,6 @@ import com.l2jserver.model.id.factory.IDFactory;
* @param <T>
* the subclass of {@link TemplateID} that will be createdF
*/
public interface TemplateIDFactory<T extends TemplateID<?>> extends
IDFactory<Integer, T> {
public interface TemplateIDProvider<T extends TemplateID<?>> extends
IDProvider<Integer, T> {
}