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
#Thu Apr 28 21:39:39 BRT 2011
#Sun Jul 31 22:17:12 BRT 2011
detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
detectorBadAppletConstructor=BadAppletConstructor|false
detectorBadResultSetAccess=BadResultSetAccess|true
@@ -120,8 +120,8 @@ detectorVolatileUsage=VolatileUsage|true
detectorWaitInLoop=WaitInLoop|true
detectorWrongMapIterator=WrongMapIterator|true
detectorXMLFactoryBypass=XMLFactoryBypass|true
detector_threshold=2
detector_threshold=3
effort=default
filter_settings=Medium|BAD_PRACTICE,CORRECTNESS,MT_CORRECTNESS,PERFORMANCE,STYLE|false
filter_settings_neg=MALICIOUS_CODE,NOISE,I18N,SECURITY,EXPERIMENTAL|
filter_settings=Low|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,MALICIOUS_CODE,MT_CORRECTNESS,NOISE,PERFORMANCE,SECURITY,STYLE|false
filter_settings_neg=I18N|
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.service.game.scripting.classlistener.Loader;
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.factory.CollectionFactory;
@@ -23,32 +21,22 @@ import com.l2jserver.util.factory.CollectionFactory;
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
public class PluginLoader implements Loader, Unloader {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory
.getLogger(PluginLoader.class);
private final ScriptTemplateService templateService;
@Inject
public PluginLoader(TemplateService templateService) {
this.templateService = (ScriptTemplateService) templateService;
public PluginLoader() {
}
@Override
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
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
*/
@SuppressWarnings({ "unchecked" })
@SuppressWarnings({ "unchecked", "unused" })
private static Set<Class<? extends Template<?>>> getSuitableClasses(
Class<?>[] classes) {
final Set<Class<? extends Template<?>>> suitable = CollectionFactory

View File

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

View File

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

View File

@@ -81,8 +81,9 @@ public class CM_ENTER_WORLD extends AbstractClientPacket {
try {
characterService.enterWorld(id.getObject());
} catch (SpawnPointNotFoundServiceException e) {
conn.sendActionFailed();
} 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
*/
public static final CharacterClass[] TEMPLATE_CLASSES = {
protected static final CharacterClass[] TEMPLATE_CLASSES = {
CharacterClass.HUMAN_FIGHTER, CharacterClass.HUMAN_MYSTIC,
CharacterClass.ELVEN_FIGHTER, CharacterClass.ELVEN_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(template.getID().getID() + 1000000); // npctype id
if (npc instanceof NPC) {
//if (npc instanceof NPC) {
buffer.writeInt((template.isAttackable() ? 0x01 : 0x00));
} else {
buffer.writeInt(0x01);
}
//} else {
// buffer.writeInt(0x01);
//}
buffer.writeInt(npc.getPoint().getX());
buffer.writeInt(npc.getPoint().getY());
buffer.writeInt(npc.getPoint().getZ());

View File

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

View File

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

View File

@@ -99,4 +99,10 @@ public interface ChatChannel {
* @return the chat channel name
*/
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
* the chat channel
* @param message
* the message
* the message object that was created by
* {@link ChatLoggingService}
*/
void onMessage(ChatChannel channel, ChatMessage message);
}

View File

@@ -21,7 +21,7 @@ import com.l2jserver.model.server.ChatMessage;
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.
*
* @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.server.ChatMessage;
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
*
* @author <a href="http://www.rogiel.com">Rogiel</a>
*/
@Depends(DatabaseService.class)
public class DatabaseChatLoggingService extends AbstractService implements
ChatLoggingService {
/**

View File

@@ -28,6 +28,7 @@ import com.l2jserver.model.server.ChatMessage;
import com.l2jserver.model.world.Clan;
import com.l2jserver.model.world.L2Character;
import com.l2jserver.service.AbstractService;
import com.l2jserver.service.AbstractService.Depends;
import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException;
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>
*/
// @Depends(RegionService.class)
@Depends(ChatLoggingService.class)
public class SimpleChatService extends AbstractService implements ChatService {
private final ChatLoggingService chatLoggingService;
@@ -308,6 +309,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() {
return ChatMessageType.SHOUT;
}
@Override
public void dispose() {
privateChannels.remove(character);
}
}
/**
@@ -321,6 +327,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() {
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() {
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() {
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
*/
@SuppressWarnings("unused")
private final ClanID clanID;
/**
@@ -376,6 +396,11 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() {
return ChatMessageType.CLAN;
}
@Override
public void dispose() {
clanChannels.remove(clanID);
}
}
/**
@@ -405,5 +430,10 @@ public class SimpleChatService extends AbstractService implements ChatService {
public ChatMessageType getMessageType() {
return ChatMessageType.ALL;
}
@Override
public void dispose() {
throw new UnsupportedOperationException();
}
}
}

View File

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

View File

@@ -197,7 +197,7 @@ public class ClassFileManager extends
* if something foes wrong
*/
@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 {
Iterable<JavaFileObject> objects = super.list(location, packageName,
kinds, recurse);

View File

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

View File

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