1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-06 07:32:46 +00:00

Fixed small bugs

Signed-off-by: Rogiel <rogiel@rogiel.com>
This commit is contained in:
2011-07-31 23:18:38 -03:00
parent 7eca70e881
commit 6b79db00c2
18 changed files with 77 additions and 39 deletions

View File

@@ -1,5 +1,5 @@
#FindBugs User Preferences #FindBugs User Preferences
#Thu Apr 28 21:39:39 BRT 2011 #Sun Jul 31 22:17:12 BRT 2011
detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
detectorBadAppletConstructor=BadAppletConstructor|false detectorBadAppletConstructor=BadAppletConstructor|false
detectorBadResultSetAccess=BadResultSetAccess|true detectorBadResultSetAccess=BadResultSetAccess|true
@@ -120,8 +120,8 @@ detectorVolatileUsage=VolatileUsage|true
detectorWaitInLoop=WaitInLoop|true detectorWaitInLoop=WaitInLoop|true
detectorWrongMapIterator=WrongMapIterator|true detectorWrongMapIterator=WrongMapIterator|true
detectorXMLFactoryBypass=XMLFactoryBypass|true detectorXMLFactoryBypass=XMLFactoryBypass|true
detector_threshold=2 detector_threshold=3
effort=default effort=default
filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false filter_settings=Low|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,MALICIOUS_CODE,MT_CORRECTNESS,NOISE,PERFORMANCE,SECURITY,STYLE|false
filter_settings_neg=MALICIOUS_CODE,NOISE,I18N,SECURITY,EXPERIMENTAL| filter_settings_neg=I18N|
run_at_full_build=false run_at_full_build=false

View File

@@ -10,8 +10,6 @@ import com.google.inject.Inject;
import com.l2jserver.model.template.Template; import com.l2jserver.model.template.Template;
import com.l2jserver.service.game.scripting.classlistener.Loader; import com.l2jserver.service.game.scripting.classlistener.Loader;
import com.l2jserver.service.game.scripting.classlistener.Unloader; import com.l2jserver.service.game.scripting.classlistener.Unloader;
import com.l2jserver.service.game.template.ScriptTemplateService;
import com.l2jserver.service.game.template.TemplateService;
import com.l2jserver.util.ClassUtils; import com.l2jserver.util.ClassUtils;
import com.l2jserver.util.factory.CollectionFactory; import com.l2jserver.util.factory.CollectionFactory;
@@ -23,32 +21,22 @@ import com.l2jserver.util.factory.CollectionFactory;
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
public class PluginLoader implements Loader, Unloader { public class PluginLoader implements Loader, Unloader {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory private static final Logger log = LoggerFactory
.getLogger(PluginLoader.class); .getLogger(PluginLoader.class);
private final ScriptTemplateService templateService;
@Inject @Inject
public PluginLoader(TemplateService templateService) { public PluginLoader() {
this.templateService = (ScriptTemplateService) templateService;
} }
@Override @Override
public void load(Class<?>[] classes) { public void load(Class<?>[] classes) {
log.debug("Loading templates from {} classes", classes.length);
for (final Class<? extends Template<?>> template : getSuitableClasses(classes)) {
log.debug("Found loadable template class: {}", template);
templateService.addTemplate(template);
}
} }
@Override @Override
public void unload(Class<?>[] classes) { public void unload(Class<?>[] classes) {
log.debug("Unloading templates from {} classes", classes.length);
for (final Class<? extends Template<?>> template : getSuitableClasses(classes)) {
log.debug("Found unloadable template class: {}", template);
// TODO unloading
}
} }
/** /**
@@ -56,7 +44,7 @@ public class PluginLoader implements Loader, Unloader {
* *
* @return list of Template classes to load/unload * @return list of Template classes to load/unload
*/ */
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked", "unused" })
private static Set<Class<? extends Template<?>>> getSuitableClasses( private static Set<Class<? extends Template<?>>> getSuitableClasses(
Class<?>[] classes) { Class<?>[] classes) {
final Set<Class<? extends Template<?>>> suitable = CollectionFactory final Set<Class<? extends Template<?>>> suitable = CollectionFactory

View File

@@ -140,8 +140,7 @@ public abstract class JDBCClanDAO extends AbstractJDBCDAO<Clan, ClanID> implemen
@Override @Override
protected void parametize(PreparedStatement st, Clan clan) protected void parametize(PreparedStatement st, Clan clan)
throws SQLException { throws SQLException {
int i = 1; st.setInt(1, clan.getID().getID());
st.setInt(i++, clan.getID().getID());
} }
}) > 0; }) > 0;
} }

View File

@@ -57,7 +57,7 @@ public abstract class AbstractDesire implements Desire {
} }
@Override @Override
public int getDesirePower() { public synchronized int getDesirePower() {
return desirePower; return desirePower;
} }

View File

@@ -81,8 +81,9 @@ public class CM_ENTER_WORLD extends AbstractClientPacket {
try { try {
characterService.enterWorld(id.getObject()); characterService.enterWorld(id.getObject());
} catch (SpawnPointNotFoundServiceException e) { } catch (SpawnPointNotFoundServiceException e) {
conn.sendActionFailed();
} catch (AlreadySpawnedServiceException e) { } catch (AlreadySpawnedServiceException e) {
//TODO send an error message here
} }
} }
} }

View File

@@ -45,7 +45,7 @@ public class CM_REQUEST_CHAR_TEMPLATE extends AbstractClientPacket {
/** /**
* List of {@link CharacterClass} templates sent to the client * List of {@link CharacterClass} templates sent to the client
*/ */
public static final CharacterClass[] TEMPLATE_CLASSES = { protected static final CharacterClass[] TEMPLATE_CLASSES = {
CharacterClass.HUMAN_FIGHTER, CharacterClass.HUMAN_MYSTIC, CharacterClass.HUMAN_FIGHTER, CharacterClass.HUMAN_MYSTIC,
CharacterClass.ELVEN_FIGHTER, CharacterClass.ELVEN_MYSTIC, CharacterClass.ELVEN_FIGHTER, CharacterClass.ELVEN_MYSTIC,
CharacterClass.DARK_FIGHTER, CharacterClass.DARK_MYSTIC, CharacterClass.DARK_FIGHTER, CharacterClass.DARK_MYSTIC,

View File

@@ -48,11 +48,11 @@ public class SM_NPC_INFO extends AbstractServerPacket {
buffer.writeInt(npc.getID().getID()); buffer.writeInt(npc.getID().getID());
buffer.writeInt(template.getID().getID() + 1000000); // npctype id buffer.writeInt(template.getID().getID() + 1000000); // npctype id
if (npc instanceof NPC) { //if (npc instanceof NPC) {
buffer.writeInt((template.isAttackable() ? 0x01 : 0x00)); buffer.writeInt((template.isAttackable() ? 0x01 : 0x00));
} else { //} else {
buffer.writeInt(0x01); // buffer.writeInt(0x01);
} //}
buffer.writeInt(npc.getPoint().getX()); buffer.writeInt(npc.getPoint().getX());
buffer.writeInt(npc.getPoint().getY()); buffer.writeInt(npc.getPoint().getY());
buffer.writeInt(npc.getPoint().getZ()); buffer.writeInt(npc.getPoint().getZ());

View File

@@ -16,6 +16,7 @@
*/ */
package com.l2jserver.model.world.character; package com.l2jserver.model.world.character;
import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@@ -136,7 +137,9 @@ public class CharacterShortcutContainer implements Iterable<Shortcut> {
return character; return character;
} }
public static class ShortcutSlotComparator implements Comparator<Shortcut> { public static class ShortcutSlotComparator implements Comparator<Shortcut>, Serializable {
private static final long serialVersionUID = 1L;
@Override @Override
public int compare(Shortcut o1, Shortcut o2) { public int compare(Shortcut o1, Shortcut o2) {
return ((o1.getPage() * o1.getSlot()) - (o2.getPage() * o2 return ((o1.getPage() * o1.getSlot()) - (o2.getPage() * o2

View File

@@ -255,6 +255,7 @@ public class ProxyConfigurationService extends AbstractService implements
if(prop != null) if(prop != null)
return prop; return prop;
} }
return null;
} }
prop = new Properties(); prop = new Properties();
final File file = new File(directory, config.value() + ".properties"); final File file = new File(directory, config.value() + ".properties");

View File

@@ -99,4 +99,10 @@ public interface ChatChannel {
* @return the chat channel name * @return the chat channel name
*/ */
String getChannelName(); String getChannelName();
/**
* Disposes this channel. Channels should only be disposed by its creator if
* there is no more interest in them.
*/
void dispose();
} }

View File

@@ -31,7 +31,8 @@ public interface ChatChannelListener {
* @param channel * @param channel
* the chat channel * the chat channel
* @param message * @param message
* the message * the message object that was created by
* {@link ChatLoggingService}
*/ */
void onMessage(ChatChannel channel, ChatMessage message); void onMessage(ChatChannel channel, ChatMessage message);
} }

View File

@@ -21,7 +21,7 @@ import com.l2jserver.model.server.ChatMessage;
import com.l2jserver.service.Service; import com.l2jserver.service.Service;
/** /**
* This service logs each message sent in the server. Implementarions may choose * This service logs each message sent in the server. Implementations may choose
* to store in a database, plain text, XML or any other form of logging. * to store in a database, plain text, XML or any other form of logging.
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>

View File

@@ -24,12 +24,15 @@ import com.l2jserver.model.id.object.CharacterID;
import com.l2jserver.model.id.object.provider.CharacterIDProvider; import com.l2jserver.model.id.object.provider.CharacterIDProvider;
import com.l2jserver.model.server.ChatMessage; import com.l2jserver.model.server.ChatMessage;
import com.l2jserver.service.AbstractService; import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.database.DatabaseService;
/** /**
* {@link ChatLoggingService} implementation that stores logs in the database * {@link ChatLoggingService} implementation that stores logs in the database
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
@Depends(DatabaseService.class)
public class DatabaseChatLoggingService extends AbstractService implements public class DatabaseChatLoggingService extends AbstractService implements
ChatLoggingService { ChatLoggingService {
/** /**

View File

@@ -28,6 +28,7 @@ import com.l2jserver.model.server.ChatMessage;
import com.l2jserver.model.world.Clan; import com.l2jserver.model.world.Clan;
import com.l2jserver.model.world.L2Character; import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.AbstractService; import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.ServiceStartException; import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException; import com.l2jserver.service.ServiceStopException;
import com.l2jserver.service.game.region.Region; import com.l2jserver.service.game.region.Region;
@@ -39,7 +40,7 @@ import com.l2jserver.util.factory.CollectionFactory;
* *
* @author <a href="http://www.rogiel.com">Rogiel</a> * @author <a href="http://www.rogiel.com">Rogiel</a>
*/ */
// @Depends(RegionService.class) @Depends(ChatLoggingService.class)
public class SimpleChatService extends AbstractService implements ChatService { public class SimpleChatService extends AbstractService implements ChatService {
private final ChatLoggingService chatLoggingService; private final ChatLoggingService chatLoggingService;
@@ -308,6 +309,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() { public ChatMessageType getMessageType() {
return ChatMessageType.SHOUT; return ChatMessageType.SHOUT;
} }
@Override
public void dispose() {
privateChannels.remove(character);
}
} }
/** /**
@@ -321,6 +327,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() { public ChatMessageType getMessageType() {
return ChatMessageType.ALL; return ChatMessageType.ALL;
} }
@Override
public void dispose() {
throw new UnsupportedOperationException("Cannot dispose the Global Chat Channel");
}
} }
/** /**
@@ -334,6 +345,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() { public ChatMessageType getMessageType() {
return ChatMessageType.TRADE; return ChatMessageType.TRADE;
} }
@Override
public void dispose() {
throw new UnsupportedOperationException("Cannot dispose the Trade Chat Channel");
}
} }
/** /**
@@ -347,6 +363,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() { public ChatMessageType getMessageType() {
return ChatMessageType.ANNOUNCEMENT; return ChatMessageType.ANNOUNCEMENT;
} }
@Override
public void dispose() {
throw new UnsupportedOperationException("Cannot dispose the Announcement Chat Channel");
}
} }
/** /**
@@ -359,7 +380,6 @@ public class SimpleChatService extends AbstractService implements ChatService {
/** /**
* The clan ID * The clan ID
*/ */
@SuppressWarnings("unused")
private final ClanID clanID; private final ClanID clanID;
/** /**
@@ -376,6 +396,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() { public ChatMessageType getMessageType() {
return ChatMessageType.CLAN; return ChatMessageType.CLAN;
} }
@Override
public void dispose() {
clanChannels.remove(clanID);
}
} }
/** /**
@@ -405,5 +430,10 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() { public ChatMessageType getMessageType() {
return ChatMessageType.ALL; return ChatMessageType.ALL;
} }
@Override
public void dispose() {
throw new UnsupportedOperationException();
}
} }
} }

View File

@@ -268,7 +268,7 @@ public class ScriptContextImpl implements ScriptContext {
} }
@Override @Override
public ScriptClassLoader getClassLoader() { public synchronized ScriptClassLoader getClassLoader() {
return compilationResult.getClassLoader(); return compilationResult.getClassLoader();
} }

View File

@@ -197,7 +197,7 @@ public class ClassFileManager extends
* if something foes wrong * if something foes wrong
*/ */
@Override @Override
public Iterable<JavaFileObject> list(Location location, String packageName, public synchronized Iterable<JavaFileObject> list(Location location, String packageName,
Set<Kind> kinds, boolean recurse) throws IOException { Set<Kind> kinds, boolean recurse) throws IOException {
Iterable<JavaFileObject> objects = super.list(location, packageName, Iterable<JavaFileObject> objects = super.list(location, packageName,
kinds, recurse); kinds, recurse);

View File

@@ -16,6 +16,7 @@
*/ */
package com.l2jserver.util.calculator; package com.l2jserver.util.calculator;
import java.io.Serializable;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.EnumMap; import java.util.EnumMap;
@@ -264,7 +265,9 @@ public class ComplexCalculator<T extends CalculatorContext, V extends Enum<V>>
} }
public static class FunctionOrderComparator implements public static class FunctionOrderComparator implements
Comparator<Function<?, ?>> { Comparator<Function<?, ?>>, Serializable {
private static final long serialVersionUID = 1L;
public static final FunctionOrderComparator SHARED_INSTANCE = new FunctionOrderComparator(); public static final FunctionOrderComparator SHARED_INSTANCE = new FunctionOrderComparator();
@Override @Override

View File

@@ -16,6 +16,7 @@
*/ */
package com.l2jserver.util.calculator; package com.l2jserver.util.calculator;
import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
@@ -66,7 +67,9 @@ public class SimpleCalculator<T extends CalculatorContext, V extends Enum<V>>
} }
public static class FunctionOrderComparator implements public static class FunctionOrderComparator implements
Comparator<Function<?, ?>> { Comparator<Function<?, ?>>, Serializable {
private static final long serialVersionUID = 1L;
public static final FunctionOrderComparator SHARED_INSTANCE = new FunctionOrderComparator(); public static final FunctionOrderComparator SHARED_INSTANCE = new FunctionOrderComparator();
@Override @Override