From 38b0d063e859c9c29c91ed30dcbdc065eb901abb Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Sun, 22 Oct 2023 19:45:17 -0700 Subject: [PATCH] Clean up mixed indentation --- .../client/LogUncaughtExceptionHandler.java | 14 +- src/games/stendhal/client/OutfitStore.java | 2 +- .../stendhal/client/actions/GMHelpAction.java | 4 +- .../client/actions/ScreenshotAction.java | 16 +- .../stendhal/client/entity/AudibleEntity.java | 34 +- src/games/stendhal/client/entity/NPC.java | 16 +- src/games/stendhal/client/entity/Player.java | 8 +- .../stendhal/client/gui/ProgressBar.java | 4 +- .../client/gui/j2d/TextBoxFactory.java | 20 +- .../client/gui/j2d/entity/RPEntity2DView.java | 2 +- .../stendhal/client/gui/map/MapPanel.java | 4 +- .../client/gui/map/MapPanelController.java | 4 +- .../stendhal/client/gui/stats/StatsPanel.java | 4 +- .../gui/stats/StatsPanelController.java | 20 +- .../client/gui/styled/StyledTableUI.java | 14 +- .../sound/system/processors/ReSampler.java | 36 +- .../stendhal/common/constants/SoundID.java | 10 +- .../common/filter/CollectionFilter.java | 2 +- .../stendhal/common/grammar/Grammar.java | 22 +- .../stendhal/common/parser/CompoundName.java | 20 +- .../stendhal/common/parser/NameSearch.java | 264 +++--- .../stendhal/common/parser/Sentence.java | 130 +-- .../common/parser/SentenceImplementation.java | 146 +-- .../stendhal/common/parser/TriggerList.java | 6 +- .../stendhal/common/parser/WordList.java | 78 +- .../actions/admin/RemoteViewAction.java | 76 +- .../server/actions/admin/SummonAction.java | 8 +- .../actions/chat/ReportErrorAction.java | 8 +- .../core/config/CreaturesXMLLoader.java | 12 +- .../core/engine/StendhalRPRuleProcessor.java | 24 +- .../core/engine/db/PendingAchievementDAO.java | 4 +- .../server/core/events/ZoneEventType.java | 4 +- .../server/core/pathfinder/EntityGuide.java | 12 +- .../server/core/pathfinder/GoToPosition.java | 6 +- .../factory/FriendAchievementFactory.java | 4 +- .../factory/ProductionAchievementFactory.java | 8 +- .../rule/defaultruleset/DefaultCreature.java | 15 +- .../rule/defaultruleset/LowerCaseMap.java | 10 +- .../server/core/scripting/ScriptInJava.java | 6 +- .../stendhal/server/entity/ActiveEntity.java | 2 +- src/games/stendhal/server/entity/Entity.java | 16 +- .../stendhal/server/entity/RPEntity.java | 22 +- .../server/entity/creature/Creature.java | 48 +- .../entity/creature/ItemGuardCreature.java | 18 +- .../entity/item/CaptureTheFlagFlag.java | 14 +- .../entity/item/scroll/InvitationScroll.java | 14 +- .../entity/item/scroll/MarkedScroll.java | 8 +- .../server/entity/mapstuff/chest/Chest.java | 8 +- .../entity/mapstuff/chest/PersonalChest.java | 8 +- .../entity/mapstuff/office/RentedSign.java | 24 +- .../mapstuff/portal/AccessCheckingPortal.java | 366 ++++---- .../portal/AccessCheckingPortalFactory.java | 90 +- .../entity/mapstuff/portal/HousePortal.java | 4 +- .../server/entity/mapstuff/portal/Portal.java | 4 +- .../mapstuff/puzzle/PuzzleBuildingBlock.java | 20 +- .../entity/mapstuff/useable/CoalSource.java | 10 +- .../entity/mapstuff/useable/FishSource.java | 12 +- .../entity/mapstuff/useable/GoldSource.java | 16 +- .../mapstuff/useable/WaterSpringSource.java | 36 +- src/games/stendhal/server/entity/npc/NPC.java | 158 ++-- .../server/entity/npc/PassiveNPC.java | 25 +- .../server/entity/npc/SpeakerNPC.java | 12 +- .../SayNPCNamesForUnstartedQuestsAction.java | 22 +- .../npc/action/SayRequiredItemAction.java | 4 +- .../action/SetHallOfFameToAgeDiffAction.java | 6 +- .../entity/npc/behaviour/impl/Behaviour.java | 10 +- .../behaviour/impl/MonologueBehaviour.java | 2 +- .../behaviour/impl/TransactionBehaviour.java | 12 +- .../KillsQuestSlotNeedUpdateCondition.java | 40 +- .../server/entity/npc/fsm/Engine.java | 20 +- .../server/entity/npc/fsm/Transition.java | 20 +- .../server/entity/player/AfkTimeouter.java | 15 +- .../server/entity/player/PlayerDieer.java | 20 +- .../server/entity/player/UpdateConverter.java | 162 ++-- .../entity/slot/PlayerPortfolioSlot.java | 2 +- .../stendhal/server/script/CreateRaid.java | 4 +- .../stendhal/server/script/DeepInspect.java | 24 +- .../server/script/DumpDeletionCandidates.java | 2 +- src/games/stendhal/server/script/FixDM.java | 12 +- src/games/stendhal/server/script/Herald.java | 64 +- src/games/stendhal/server/script/Maria.java | 10 +- .../stendhal/server/util/EntityHelper.java | 110 +-- .../stendhal/tools/DuplicateTileFinder.java | 10 +- src/games/stendhal/tools/MapUpdater.java | 6 +- .../itemlog/consistency/LogEntry.java | 102 +-- .../itemlog/consistency/LogEntryIterator.java | 24 +- .../loganalyser/util/ResultSetIterator.java | 40 +- .../stendhal/tools/npcparser/TestEnvDlg.java | 866 +++++++++--------- .../tools/npcparser/WordListUpdate.java | 34 +- .../sound/system/ToneGeneratorTest.java | 8 +- .../server/actions/admin/AlterActionTest.java | 6 +- .../server/actions/admin/BanActionTest.java | 10 +- .../actions/equip/DisplaceActionTest.java | 4 +- .../server/actions/equip/DropActionTest.java | 4 +- .../actions/equip/EquipmentActionTest.java | 4 +- .../server/entity/item/StackableItemTest.java | 68 +- .../behaviour/impl/SellerBehaviourTest.java | 42 +- .../journal/ProducerRegisterTest.java | 4 +- .../npc/condition/AndConditionTest.java | 10 +- .../server/entity/player/GagManagerTest.java | 4 +- .../maps/quests/CloakCollector2Test.java | 4 +- .../server/maps/quests/DragonLairTest.java | 4 +- .../server/maps/quests/KillEnemyArmyTest.java | 62 +- .../maps/quests/SuppliesForPhalkTest.java | 20 +- .../maps/quests/WeeklyItemQuestTest.java | 4 +- .../thepiedpiper/AwaitingPhaseTest.java | 12 +- .../thepiedpiper/InactivePhaseTest.java | 9 +- .../thepiedpiper/InvasionPhaseTest.java | 34 +- .../maps/semos/tavern/TradeMangerNPCTest.java | 6 +- .../server/util/ItemCollectionTest.java | 44 +- 110 files changed, 2011 insertions(+), 2007 deletions(-) diff --git a/src/games/stendhal/client/LogUncaughtExceptionHandler.java b/src/games/stendhal/client/LogUncaughtExceptionHandler.java index d208559184e..8c3444c918a 100644 --- a/src/games/stendhal/client/LogUncaughtExceptionHandler.java +++ b/src/games/stendhal/client/LogUncaughtExceptionHandler.java @@ -1,14 +1,14 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** - * * - * 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 2 of the License, or * - * (at your option) any later version. * - * * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + * * ***************************************************************************/ package games.stendhal.client; diff --git a/src/games/stendhal/client/OutfitStore.java b/src/games/stendhal/client/OutfitStore.java index adb8b8ff369..5ce2a7fcc96 100644 --- a/src/games/stendhal/client/OutfitStore.java +++ b/src/games/stendhal/client/OutfitStore.java @@ -136,7 +136,7 @@ private Sprite buildOutfit(final String strcode, final OutfitColor color) { final List lnames = new LinkedList<>(); lnames.addAll(LAYER_NAMES); - // initialize outfit parts to 0 in case some haven't been specified + // initialize outfit parts to 0 in case some haven't been specified for (String n: lnames) { layer_map.put(n, 0); } diff --git a/src/games/stendhal/client/actions/GMHelpAction.java b/src/games/stendhal/client/actions/GMHelpAction.java index 092bd457fc1..583b519bd01 100644 --- a/src/games/stendhal/client/actions/GMHelpAction.java +++ b/src/games/stendhal/client/actions/GMHelpAction.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -40,7 +40,7 @@ class GMHelpAction implements SlashAction { */ @Override public boolean execute(final String[] params, final String remainder) { - List lines; + List lines; if (params[0] == null) { lines = Arrays.asList( "For a detailed reference, visit #https://stendhalgame.org/wiki/Stendhal:Administration", diff --git a/src/games/stendhal/client/actions/ScreenshotAction.java b/src/games/stendhal/client/actions/ScreenshotAction.java index 9d231c67d45..612a91aaade 100644 --- a/src/games/stendhal/client/actions/ScreenshotAction.java +++ b/src/games/stendhal/client/actions/ScreenshotAction.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2011 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -73,13 +73,13 @@ public void done() { Logger.getLogger(ScreenshotAction.class).error(e); } catch (ExecutionException e) { msg = "Failed to save screenshot to " + fileName + " : "; - Throwable cause = e.getCause(); - Logger.getLogger(ScreenshotAction.class).error(e); - if (cause != null) { - msg = cause.getMessage(); - } else { - msg = e.getMessage(); - } + Throwable cause = e.getCause(); + Logger.getLogger(ScreenshotAction.class).error(e); + if (cause != null) { + msg = cause.getMessage(); + } else { + msg = e.getMessage(); + } } ClientSingletonRepository.getUserInterface().addEventLine(new EventLine("", msg, NotificationType.CLIENT)); } diff --git a/src/games/stendhal/client/entity/AudibleEntity.java b/src/games/stendhal/client/entity/AudibleEntity.java index 58367f378cd..737242e9338 100644 --- a/src/games/stendhal/client/entity/AudibleEntity.java +++ b/src/games/stendhal/client/entity/AudibleEntity.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -70,23 +70,23 @@ private String getRandomSoundFromCategory(String groupName) { } private String getSoundFromCategory(String groupName) { - ArrayList soundNameList = mCategorys.get(groupName); + ArrayList soundNameList = mCategorys.get(groupName); - if ((soundNameList != null) && !soundNameList.isEmpty()) { - return soundNameList.get(0); - } + if ((soundNameList != null) && !soundNameList.isEmpty()) { + return soundNameList.get(0); + } - return null; + return null; } private String getSoundFromCategory(String groupName, int index) { - ArrayList soundNameList = mCategorys.get(groupName); + ArrayList soundNameList = mCategorys.get(groupName); - if ((soundNameList != null) && !soundNameList.isEmpty()) { - return soundNameList.get(index); - } + if ((soundNameList != null) && !soundNameList.isEmpty()) { + return soundNameList.get(index); + } - return null; + return null; } @Override @@ -109,12 +109,12 @@ protected void playRandomSoundFromGroup(String groupName, String categoryName, l } protected void playSoundFromCategory(String groupName, String categoryName) { - SoundGroup group = ClientSingletonRepository.getSound().getGroup(groupName); - group.play(getSoundFromCategory(categoryName), 0, mAudibleArea, new Time(), false, true); + SoundGroup group = ClientSingletonRepository.getSound().getGroup(groupName); + group.play(getSoundFromCategory(categoryName), 0, mAudibleArea, new Time(), false, true); } - protected void playSoundFromCategory(String groupName, String categoryName, int index) { - SoundGroup group = ClientSingletonRepository.getSound().getGroup(groupName); - group.play(getSoundFromCategory(categoryName, index), 0, mAudibleArea, new Time(), false, true); - } + protected void playSoundFromCategory(String groupName, String categoryName, int index) { + SoundGroup group = ClientSingletonRepository.getSound().getGroup(groupName); + group.play(getSoundFromCategory(categoryName, index), 0, mAudibleArea, new Time(), false, true); + } } diff --git a/src/games/stendhal/client/entity/NPC.java b/src/games/stendhal/client/entity/NPC.java index 188908edf55..7b77a56c6a3 100644 --- a/src/games/stendhal/client/entity/NPC.java +++ b/src/games/stendhal/client/entity/NPC.java @@ -1,14 +1,14 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** - * * - * 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 2 of the License, or * - * (at your option) any later version. * - * * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + * * ***************************************************************************/ package games.stendhal.client.entity; @@ -56,7 +56,7 @@ public boolean isAttending() { * Initialize this entity for an object. * * @param object - * The object. + * The object. * * @see #release() */ diff --git a/src/games/stendhal/client/entity/Player.java b/src/games/stendhal/client/entity/Player.java index 7b6507c69dd..fa4ab6d9a8d 100644 --- a/src/games/stendhal/client/entity/Player.java +++ b/src/games/stendhal/client/entity/Player.java @@ -1,14 +1,14 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** - * * + * * * 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 2 of the License, or * - * (at your option) any later version. * - * * + * (at your option) any later version. * + * * ***************************************************************************/ package games.stendhal.client.entity; diff --git a/src/games/stendhal/client/gui/ProgressBar.java b/src/games/stendhal/client/gui/ProgressBar.java index 26923b96f11..564c1ec842b 100644 --- a/src/games/stendhal/client/gui/ProgressBar.java +++ b/src/games/stendhal/client/gui/ProgressBar.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -123,7 +123,7 @@ public void cancel() { timer.stop(); // workaround near failures in AWT at openjdk (tested on openjdk-1.6.0.0) try { - this.dispose(); + this.dispose(); } catch(NullPointerException npe) { return; } diff --git a/src/games/stendhal/client/gui/j2d/TextBoxFactory.java b/src/games/stendhal/client/gui/j2d/TextBoxFactory.java index 174ff12d16b..3322f655d3f 100644 --- a/src/games/stendhal/client/gui/j2d/TextBoxFactory.java +++ b/src/games/stendhal/client/gui/j2d/TextBoxFactory.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -191,15 +191,15 @@ private List createFormattedLines(String text, return splitFormatted(formattedString, width); } - /** - * Draw a chat bubble. - * - * @param g2d - * @param fillColor the bacground color of the bubble - * @param outLineColor the color of the bubble outline - * @param width width of the bubble body - * @param height height of the bubble - */ + /** + * Draw a chat bubble. + * + * @param g2d + * @param fillColor the bacground color of the bubble + * @param outLineColor the color of the bubble outline + * @param width width of the bubble body + * @param height height of the bubble + */ private void drawBubble(final Graphics2D g2d, final Color fillColor, final Color outLineColor, final int width, final int height) { /* diff --git a/src/games/stendhal/client/gui/j2d/entity/RPEntity2DView.java b/src/games/stendhal/client/gui/j2d/entity/RPEntity2DView.java index 5e2747c1459..0689d30c308 100644 --- a/src/games/stendhal/client/gui/j2d/entity/RPEntity2DView.java +++ b/src/games/stendhal/client/gui/j2d/entity/RPEntity2DView.java @@ -435,7 +435,7 @@ protected void drawTitle(final Graphics2D g2d, final int x, final int y, final i * The drawn entity height. */ private void drawCombat(final Graphics2D g2d, final int x, - final int y, final int width, final int height) { + final int y, final int width, final int height) { Rectangle2D wrect = entity.getArea(); final Rectangle srect = new Rectangle( (int) (wrect.getX() * IGameScreen.SIZE_UNIT_PIXELS), diff --git a/src/games/stendhal/client/gui/map/MapPanel.java b/src/games/stendhal/client/gui/map/MapPanel.java index fe60fc83581..dfa017b50a8 100644 --- a/src/games/stendhal/client/gui/map/MapPanel.java +++ b/src/games/stendhal/client/gui/map/MapPanel.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -256,7 +256,7 @@ private void updateView() { * @param cd * The collision map. * @param pd - * The protection map. + * The protection map. */ void update(final CollisionDetection cd, final CollisionDetection pd) { // calculate the size and scale of the map diff --git a/src/games/stendhal/client/gui/map/MapPanelController.java b/src/games/stendhal/client/gui/map/MapPanelController.java index 30a9097caa6..8d993716339 100644 --- a/src/games/stendhal/client/gui/map/MapPanelController.java +++ b/src/games/stendhal/client/gui/map/MapPanelController.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -186,7 +186,7 @@ public void refresh() { * @param cd * The collision map. * @param pd - * The protection map. + * The protection map. * @param zone * The zone name. * @param dangerLevel zone danger level diff --git a/src/games/stendhal/client/gui/stats/StatsPanel.java b/src/games/stendhal/client/gui/stats/StatsPanel.java index 5abffc3c49e..817a218137d 100644 --- a/src/games/stendhal/client/gui/stats/StatsPanel.java +++ b/src/games/stendhal/client/gui/stats/StatsPanel.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -241,7 +241,7 @@ void setChoking(final boolean choking) { * Show indicator */ void setStatus(final StatusID ID, final boolean visible) { - statusIcons.setStatus(ID, visible); + statusIcons.setStatus(ID, visible); } /** diff --git a/src/games/stendhal/client/gui/stats/StatsPanelController.java b/src/games/stendhal/client/gui/stats/StatsPanelController.java index 20abbb50cc4..1b768e6f7f7 100644 --- a/src/games/stendhal/client/gui/stats/StatsPanelController.java +++ b/src/games/stendhal/client/gui/stats/StatsPanelController.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -574,15 +574,15 @@ public void run() { } Object value = event.getNewValue(); - final StatusID ID = StatusID.getStatusID(event.getPropertyName()); - final boolean enabled = value != null; - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - panel.setStatus(ID, enabled); - } - }); - } + final StatusID ID = StatusID.getStatusID(event.getPropertyName()); + final boolean enabled = value != null; + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + panel.setStatus(ID, enabled); + } + }); + } } /** diff --git a/src/games/stendhal/client/gui/styled/StyledTableUI.java b/src/games/stendhal/client/gui/styled/StyledTableUI.java index fe0370d0d50..38529634ea8 100644 --- a/src/games/stendhal/client/gui/styled/StyledTableUI.java +++ b/src/games/stendhal/client/gui/styled/StyledTableUI.java @@ -1,13 +1,13 @@ /*************************************************************************** - * (C) Copyright 2013 - Faiumoni e.V * + * (C) Copyright 2013-2023 - Faiumoni e.V * *************************************************************************** *************************************************************************** - * * - * 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 2 of the License, or * - * (at your option) any later version. * - * * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + * * ***************************************************************************/ package games.stendhal.client.gui.styled; diff --git a/src/games/stendhal/client/sound/system/processors/ReSampler.java b/src/games/stendhal/client/sound/system/processors/ReSampler.java index d0425502887..a7f252115e0 100644 --- a/src/games/stendhal/client/sound/system/processors/ReSampler.java +++ b/src/games/stendhal/client/sound/system/processors/ReSampler.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -22,30 +22,32 @@ */ public class ReSampler extends SignalProcessor { -// private final int mNumChannels; - private final int mSampleRate; -// private final int mDelayInSamples; -// private final float[] mBuffer; -// private boolean mStarted = false; + //private final int mNumChannels; + private final int mSampleRate; + //private final int mDelayInSamples; + //private final float[] mBuffer; + //private boolean mStarted = false; ReSampler(Time delay, int channels, int sampleRate) { assert delay.getInSamples(sampleRate) < Integer.MAX_VALUE: "delay time is to long"; -// mNumChannels = channels; - mSampleRate = sampleRate; -// mDelayInSamples = (int)delay.getInSamples(sampleRate); -// mBuffer = new float[(int)(mDelayInSamples * channels)]; + //mNumChannels = channels; + mSampleRate = sampleRate; + //mDelayInSamples = (int)delay.getInSamples(sampleRate); + //mBuffer = new float[(int)(mDelayInSamples * channels)]; } -// public synchronized void start() -// { -// mStarted = true; -// } + /* + public synchronized void start() + { + mStarted = true; + } + */ /** * Modify the PCM audio stream. The audio data is uniform and interleaved. - * + * * @param data the audio data * @param frames the number of sample frames contained in "data" * @param channels number of channels @@ -55,9 +57,9 @@ public class ReSampler extends SignalProcessor protected void modify(float[] data, int frames, int channels, int rate) { - //TODO implement using a pre-allocated buffer to avoid repeated memory allocation and use the delay given in the constructor + //TODO implement using a pre-allocated buffer to avoid repeated memory allocation and use the delay given in the constructor - data = Dsp.convertSampleRate(data, frames, channels, mSampleRate, rate); + data = Dsp.convertSampleRate(data, frames, channels, mSampleRate, rate); super.propagate(data, data.length, channels, rate); } diff --git a/src/games/stendhal/common/constants/SoundID.java b/src/games/stendhal/common/constants/SoundID.java index a5dc2c02001..0f06bee0107 100644 --- a/src/games/stendhal/common/constants/SoundID.java +++ b/src/games/stendhal/common/constants/SoundID.java @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright © 2020 - Arianne * + * Copyright © 2020-2023 - Arianne * *************************************************************************** *************************************************************************** * * @@ -37,10 +37,10 @@ public String toString() { } public static SoundID getById(final String id) { - for(SoundID e : values()) { - if(e.label.equals(id)) return e; - } + for (SoundID e: values()) { + if (e.label.equals(id)) return e; + } - return null; + return null; } } diff --git a/src/games/stendhal/common/filter/CollectionFilter.java b/src/games/stendhal/common/filter/CollectionFilter.java index 375015659f1..d77b5d56277 100644 --- a/src/games/stendhal/common/filter/CollectionFilter.java +++ b/src/games/stendhal/common/filter/CollectionFilter.java @@ -59,7 +59,7 @@ public void filter(final Collection collection) { * @return a filtered copy of the input collection */ @SuppressWarnings("unchecked") - public Collection< ? extends T> filterCopy(final Collection< ? extends T> inputCollection) { + public Collection< ? extends T> filterCopy(final Collection< ? extends T> inputCollection) { Collection outputCollection = null; diff --git a/src/games/stendhal/common/grammar/Grammar.java b/src/games/stendhal/common/grammar/Grammar.java index 0cefbd8eaaf..7f802c2b05e 100644 --- a/src/games/stendhal/common/grammar/Grammar.java +++ b/src/games/stendhal/common/grammar/Grammar.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2009-2015 - Stendhal * + * (C) Copyright 2009-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -389,17 +389,17 @@ public static Expression mergeCompoundNoun(final Expression word1, Expression wo // "teddy bear" -> "teddy" (word1.getMainWord().equals("teddy") && word2.getMainWord().equals("bear"))) { - // transform "ice cream" into the item name "icecream" - if (word1.getMainWord().equals("ice")) { - word1.setNormalized("icecream"); - } + // transform "ice cream" into the item name "icecream" + if (word1.getMainWord().equals("ice")) { + word1.setNormalized("icecream"); + } - return word1; - } else { - word2.mergeLeft(word1, true); + return word1; + } else { + word2.mergeLeft(word1, true); - return word2; - } + return word2; + } } /** @@ -1309,7 +1309,7 @@ public static String normalizeDerivedAdjective(final String word) { } else { return null; } - } + } /** * Check for words with ambiguity between noun and verb. diff --git a/src/games/stendhal/common/parser/CompoundName.java b/src/games/stendhal/common/parser/CompoundName.java index 091d8c2f846..2f14cb32c8c 100644 --- a/src/games/stendhal/common/parser/CompoundName.java +++ b/src/games/stendhal/common/parser/CompoundName.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2010-2017 - Stendhal * + * (C) Copyright 2010-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -20,7 +20,7 @@ * @author Martin Fuchs */ public class CompoundName extends ArrayList { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; private ExpressionType type; @@ -58,15 +58,15 @@ public boolean matches(AbstractList expressions, int idx) { Expression curr = expressions.get(idx); String word = get(i); - // compare the current word in a case insensitive way - if (!curr.getOriginal().equalsIgnoreCase(word)) { - return false; - } + // compare the current word in a case insensitive way + if (!curr.getOriginal().equalsIgnoreCase(word)) { + return false; + } - // don't merge if the break flag is set in-between the compound name - if (i names) { - for(String name : names) { - parsedNames.put(name, ConversationParser.parse(name)); - } - - this.name = null; - this.amount = 1; - } - - private final Map parsedNames = new HashMap(); // map of parsed names to search for - - private String name; // name we found as matching - private int amount; // item count from the matching expression - - /** - * Searches for item to match the given Expression. - * - * @param item - * @return true if we found a match - */ - public boolean search(final Expression item) { - // see if the word matches an item in our list - boolean found = false; - - final String itemName = item.getNormalized(); - - for(Map.Entry e : parsedNames.entrySet()) { - if (e.getValue().matchesNormalized(itemName)) { - name = e.getKey(); - found = true; - break; - } - } - - if (!found) { - // see if instead the end matches, this is deliberately done afterwards because of bug #3285554 - found = searchEndMatch(itemName); - } - - // see if instead the plural matches - if (!found) { - final String pluralName = Grammar.plural(itemName); - if (!pluralName.equals(itemName)) { - for(Map.Entry e : parsedNames.entrySet()) { - if (e.getValue().matchesStartNormalized(pluralName)) { - name = e.getKey(); - found = true; - break; - } - } - } - - // now check for end matches with the plural - if (!found && !pluralName.equals(itemName)) { - found = searchEndMatch(pluralName); - } - } - - if (!found) { - // see if instead the singular matches - final String singularName = Grammar.singular(itemName); - if (!singularName.equals(itemName)) { - for(Map.Entry e : parsedNames.entrySet()) { - if (e.getValue().matchesStartNormalized(singularName)) { - name = e.getKey(); - found = true; - break; - } - } - - // now check for end matches with the singular - if (!found && !singularName.equals(itemName)) { - found = searchEndMatch(singularName); - } - } - - if (!found) { - // special case to handle misspelled "double" plurals - final String singular2 = Grammar.singular(singularName); - if (!singular2.equals(singularName)) { - for(Map.Entry e : parsedNames.entrySet()) { - if (e.getValue().matchesStartNormalized(singular2)) { - name = e.getKey(); - found = true; - break; - } - } - } - - // now check for end matches with the "double singular" - if (!found && !singular2.equals(itemName)) { - found = searchEndMatch(singular2); - } - } - } - - if (found) { - amount = item.getAmount(); - return true; - } else { + NameSearch(final Set names) { + for(String name : names) { + parsedNames.put(name, ConversationParser.parse(name)); + } + + this.name = null; + this.amount = 1; + } + + private final Map parsedNames = new HashMap(); // map of parsed names to search for + + private String name; // name we found as matching + private int amount; // item count from the matching expression + + /** + * Searches for item to match the given Expression. + * + * @param item + * @return true if we found a match + */ + public boolean search(final Expression item) { + // see if the word matches an item in our list + boolean found = false; + + final String itemName = item.getNormalized(); + + for(Map.Entry e : parsedNames.entrySet()) { + if (e.getValue().matchesNormalized(itemName)) { + name = e.getKey(); + found = true; + break; + } + } + + if (!found) { + // see if instead the end matches, this is deliberately done afterwards because of bug #3285554 + found = searchEndMatch(itemName); + } + + // see if instead the plural matches + if (!found) { + final String pluralName = Grammar.plural(itemName); + if (!pluralName.equals(itemName)) { + for(Map.Entry e : parsedNames.entrySet()) { + if (e.getValue().matchesStartNormalized(pluralName)) { + name = e.getKey(); + found = true; + break; + } + } + } + + // now check for end matches with the plural + if (!found && !pluralName.equals(itemName)) { + found = searchEndMatch(pluralName); + } + } + + if (!found) { + // see if instead the singular matches + final String singularName = Grammar.singular(itemName); + if (!singularName.equals(itemName)) { + for(Map.Entry e : parsedNames.entrySet()) { + if (e.getValue().matchesStartNormalized(singularName)) { + name = e.getKey(); + found = true; + break; + } + } + + // now check for end matches with the singular + if (!found && !singularName.equals(itemName)) { + found = searchEndMatch(singularName); + } + } + + if (!found) { + // special case to handle misspelled "double" plurals + final String singular2 = Grammar.singular(singularName); + if (!singular2.equals(singularName)) { + for(Map.Entry e : parsedNames.entrySet()) { + if (e.getValue().matchesStartNormalized(singular2)) { + name = e.getKey(); + found = true; + break; + } + } + } + + // now check for end matches with the "double singular" + if (!found && !singular2.equals(itemName)) { + found = searchEndMatch(singular2); + } + } + } + + if (found) { + amount = item.getAmount(); + return true; + } else { return false; } - } + } - /** - * Check for end matches while searching for item names. - * @param itemName - * @return true if a match was found - */ + /** + * Check for end matches while searching for item names. + * @param itemName + * @return true if a match was found + */ private boolean searchEndMatch(final String itemName) { for(Map.Entry e : parsedNames.entrySet()) { Sentence parsed = e.getValue(); if (itemName.endsWith(parsed.getOriginalText()) || itemName.endsWith(parsed.getNormalized())) { - name = e.getKey(); + name = e.getKey(); return true; } } @@ -147,28 +147,28 @@ private boolean searchEndMatch(final String itemName) { return false; } - /** - * Return true if matching name found. - * - * @return boolean find flag - */ - public boolean found() { - return name != null; - } - - /** - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * - * @return amount of items - */ - public int getAmount() { - return amount; - } + /** + * Return true if matching name found. + * + * @return boolean find flag + */ + public boolean found() { + return name != null; + } + + /** + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * + * @return amount of items + */ + public int getAmount() { + return amount; + } } diff --git a/src/games/stendhal/common/parser/Sentence.java b/src/games/stendhal/common/parser/Sentence.java index 6fbe9564fd7..c8a17b7e143 100644 --- a/src/games/stendhal/common/parser/Sentence.java +++ b/src/games/stendhal/common/parser/Sentence.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -92,7 +92,7 @@ protected Expression[] getExpressionsArrayList() { * @return Expression iterator */ @Override - public Iterator iterator() { + public Iterator iterator() { return expressions.iterator(); } @@ -189,33 +189,33 @@ public Expression getTriggerExpression() { } if (expressions.size() > 1) { - // Test for a list of items - StringBuilder objects = new StringBuilder(); - int simpleObjects = 0; - - for(Expression e : expressions) { - if (e.isObject() && e.getAmount()==1) { - if (simpleObjects > 0) { - objects.append(" and "); - } + // Test for a list of items + StringBuilder objects = new StringBuilder(); + int simpleObjects = 0; + + for(Expression e : expressions) { + if (e.isObject() && e.getAmount()==1) { + if (simpleObjects > 0) { + objects.append(" and "); + } - objects.append(e.getNormalized()); + objects.append(e.getNormalized()); - ++simpleObjects; - } else { - break; - } - } + ++simpleObjects; + } else { + break; + } + } - // If the sentence consists only of a list of single objects (amount=1), - // return it as "A and B and C and ..." - if (simpleObjects == expressions.size()) { - return new Expression(objects.toString(), ExpressionType.OBJECT); - } + // If the sentence consists only of a list of single objects (amount=1), + // return it as "A and B and C and ..." + if (simpleObjects == expressions.size()) { + return new Expression(objects.toString(), ExpressionType.OBJECT); + } } // otherwise just return the first expression - return expressions.get(0); + return expressions.get(0); } /** @@ -248,14 +248,14 @@ public Expression getVerb() { // } else { // return null; // } - Expression verb = null; + Expression verb = null; for(final Expression w : expressions) { if (w.isVerb()) { if (verb == null) { - verb = w; + verb = w; } else { - return null; // more than one verb present + return null; // more than one verb present } } } @@ -279,9 +279,9 @@ public String getVerbString() { for(final Expression w : expressions) { if (w.isVerb()) { if (verb == null) { - verb = w.getNormalized(); + verb = w.getNormalized(); } else { - return null; // more than one verb present + return null; // more than one verb present } } } @@ -324,9 +324,9 @@ public String getSubjectName() { for(final Expression w : expressions) { if (w.isSubject()) { if (name == null) { - name = w.getNormalized(); + name = w.getNormalized(); } else { - return null; // more than one subject present + return null; // more than one subject present } } } @@ -359,19 +359,21 @@ public Expression getObject(final int i) { * @return normalized object name */ public String getObjectName() { -// if (getObjectCount() == 1) { -// return getObject(0).getNormalized(); -// } else { -// return null; -// } + /* + if (getObjectCount() == 1) { + return getObject(0).getNormalized(); + } else { + return null; + } + */ String name = null; for(final Expression w : expressions) { if (w.isObject()) { if (name == null) { - name = w.getNormalized(); + name = w.getNormalized(); } else { - return null; // more than one object present + return null; // more than one object present } } } @@ -433,19 +435,21 @@ public Expression getNumeral(final int i) { * @return numeral */ public Expression getNumeral() { -// if (getNumeralCount() == 1) { -// return getNumeral(0); -// } else { -// return null; -// } - Expression num = null; + /* + if (getNumeralCount() == 1) { + return getNumeral(0); + } else { + return null; + } + */ + Expression num = null; for(final Expression w : expressions) { if (w.isNumeral()) { if (num == null) { - num = w; + num = w; } else { - return null; // more than one numeral present + return null; // more than one numeral present } } } @@ -516,13 +520,13 @@ public String getNormalized() { * Return the expression matcher of the first expression. * @return expression matcher */ - public ExpressionMatcher getMatcher() { - if (!expressions.isEmpty()) { - return expressions.get(0).getMatcher(); - } else { - return null; - } - } + public ExpressionMatcher getMatcher() { + if (!expressions.isEmpty()) { + return expressions.get(0).getMatcher(); + } else { + return null; + } + } /** * Parse the sentence again, using the given conversation context. @@ -531,11 +535,11 @@ public ExpressionMatcher getMatcher() { * @return parsed Sentence */ public Sentence parse(final ConversationContext ctx) { - if (context.equals(ctx)) { - return this; - } else { - return ConversationParser.parse(originalText, ctx); - } + if (context.equals(ctx)) { + return this; + } else { + return ConversationParser.parse(originalText, ctx); + } } /** @@ -544,7 +548,7 @@ public Sentence parse(final ConversationContext ctx) { * @return parsed for matching as source Sentence */ public Sentence parseAsMatchingSource() { - return parse(new ConvCtxForMatchingSource()); + return parse(new ConvCtxForMatchingSource()); } /** @@ -650,7 +654,7 @@ public boolean equalsNormalized(final Sentence other) { * @param other * @return difference String */ - public String diffNormalized(final Sentence other) { + public String diffNormalized(final Sentence other) { final SentenceBuilder ret = new SentenceBuilder(); // loop over all expressions and match them between both sides @@ -842,15 +846,15 @@ public NameSearch findMatchingName(final Set names) { name = getUnknownTypeExpression(0); if (name != null) { - if (!name.hasAmount()) { + if (!name.hasAmount()) { Expression num = getNumeral(0); if (num != null) { - name.setAmount(num.getAmount()); + name.setAmount(num.getAmount()); } - } + } - if (ret.search(name)) { + if (ret.search(name)) { return ret; } } diff --git a/src/games/stendhal/common/parser/SentenceImplementation.java b/src/games/stendhal/common/parser/SentenceImplementation.java index c3184a20e7e..af8c05b44f4 100644 --- a/src/games/stendhal/common/parser/SentenceImplementation.java +++ b/src/games/stendhal/common/parser/SentenceImplementation.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -120,32 +120,32 @@ void classifyWords(final ErrorDrain errors) { boolean entryMissing = false; if (!wordFound) { - WordEntry entry = wl.find(original); - - if (entry == null) { - entryMissing = true; - } else if (entry.getType() != null) { - ExpressionType type = entry.getType(); - - w.setType(type); - wordFound = true; - - if (type.isNumeral()) { - // evaluate numeric expressions - w.setAmount(entry.getValue()); - w.setNormalized(Integer.toString(w.getAmount())); - } else if (type.isPlural()) { - // normalise to the singular form - // If getPlurSing() is null, there is no unique singular form, so use the original string. - if (entry.getPlurSing() != null) { - w.setNormalized(entry.getPlurSing()); - } else { - w.setNormalized(original); - } - } else { - w.setNormalized(entry.getNormalized()); - } - } + WordEntry entry = wl.find(original); + + if (entry == null) { + entryMissing = true; + } else if (entry.getType() != null) { + ExpressionType type = entry.getType(); + + w.setType(type); + wordFound = true; + + if (type.isNumeral()) { + // evaluate numeric expressions + w.setAmount(entry.getValue()); + w.setNormalized(Integer.toString(w.getAmount())); + } else if (type.isPlural()) { + // normalise to the singular form + // If getPlurSing() is null, there is no unique singular form, so use the original string. + if (entry.getPlurSing() != null) { + w.setNormalized(entry.getPlurSing()); + } else { + w.setNormalized(original); + } + } else { + w.setNormalized(entry.getNormalized()); + } + } } if (!wordFound) { @@ -173,12 +173,12 @@ void classifyWords(final ErrorDrain errors) { w.setType(verb.entry.getType()); wordFound = true; } else if (!verb.isPast) { // avoid cases like "rounded" - w.setType(new ExpressionType(ExpressionType.VERB)); + w.setType(new ExpressionType(ExpressionType.VERB)); wordFound = true; } if (wordFound) { - w.setNormalized(verb.entry.getNormalized()); + w.setNormalized(verb.entry.getNormalized()); } } } @@ -188,7 +188,7 @@ void classifyWords(final ErrorDrain errors) { final WordEntry adjective = wl.normalizeAdjective(original); if (adjective != null) { - w.setType(new ExpressionType(ExpressionType.ADJECTIVE)); + w.setType(new ExpressionType(ExpressionType.ADJECTIVE)); w.setNormalized(adjective.getNormalized()); wordFound = true; } @@ -262,7 +262,7 @@ void performaAliasing() { expressions.remove(verb1); sentenceType = SentenceType.QUESTION; } else if (matchesNormalized("you have OBJ for me")) { - // the Sentence matches "do you have OBJ for me?" + // the Sentence matches "do you have OBJ for me?" // remove "you" expressions.remove(subject1); // remove "for" @@ -273,7 +273,7 @@ void performaAliasing() { verb1.setNormalized("buy"); sentenceType = SentenceType.IMPERATIVE; } else if (isYouGiveMe(subject1, verb1, subject2)) { - // the sentence matches "[you] give me(i)" -> "[I] buy" + // the sentence matches "[you] give me(i)" -> "[I] buy" // remove the subjects and replace the verb with "buy" as first word // remove "you" @@ -388,15 +388,15 @@ SentenceType evaluateSentenceType() { // Remove all verbs meaning "do" from the expression list, // since they don't change the sentence meaning. if (first.isNegated()) { - // If the question uses a "don't" expression and there is another verb in the - // sentence, negate this and drop the "don't". - if (getVerbCount() > 1) { - negate = true; - expressions.remove(first); - } + // If the question uses a "don't" expression and there is another verb in the + // sentence, negate this and drop the "don't". + if (getVerbCount() > 1) { + negate = true; + expressions.remove(first); + } } else { - expressions.remove(first); - } + expressions.remove(first); + } } else if (first.getNormalized().equals("it") && second.getNormalized().equals("is") && ((third != null) && (third.getType() != null) && third.getType().isGerund())) { // statement begins with "it is " @@ -411,12 +411,12 @@ SentenceType evaluateSentenceType() { } if (negate) { - // negate the first verb if the sentence did contain a "don't" expression - Expression firstVerb = getVerb(0); + // negate the first verb if the sentence did contain a "don't" expression + Expression firstVerb = getVerb(0); - if (firstVerb != null) { - firstVerb.negate(); - } + if (firstVerb != null) { + firstVerb.negate(); + } } if ((type != SentenceType.UNDEFINED) && (sentenceType == SentenceType.UNDEFINED)) { @@ -431,15 +431,15 @@ SentenceType evaluateSentenceType() { */ void mergeWords() { // use WordList.compoundNames to merge compound names - mergeCompoundNames(); + mergeCompoundNames(); // first merge three word expressions of the form "... of ..." mergeThreeWordExpressions(); // now merge two word expressions from left to right if (mergeTwoWordExpressions() > 0) { - // retry finding three word expressions - mergeThreeWordExpressions(); + // retry finding three word expressions + mergeThreeWordExpressions(); } } @@ -447,12 +447,12 @@ void mergeWords() { * Merge compound names. * @return number of merges performed */ - public int mergeCompoundNames() { - final WordList wl = WordList.getInstance(); + public int mergeCompoundNames() { + final WordList wl = WordList.getInstance(); int changes = 0; // loop until no more simplifications can be made - boolean changed; + boolean changed; do { changed = false; @@ -464,22 +464,22 @@ public int mergeCompoundNames() { if (compName != null) { Expression first = expressions.get(idx); - int wordsMatched = compName.size(); - for(int i=1; i { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** + /** * Create a list of normalized trigger Words from a String list. * * @param strings String list diff --git a/src/games/stendhal/common/parser/WordList.java b/src/games/stendhal/common/parser/WordList.java index 5ecc28159f9..3c0ace8ff93 100644 --- a/src/games/stendhal/common/parser/WordList.java +++ b/src/games/stendhal/common/parser/WordList.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2017 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -87,31 +87,31 @@ private void readFromResources() { final InputStream str = WordList.class.getResourceAsStream(WORDS_FILENAME); - if (str != null) { - try { - final BufferedReader reader = new BufferedReader(new UnicodeSupportingInputStreamReader(str, "UTF-8")); - - try { - read(reader, null); - } catch (final IOException e) { - logger.error("error while reading resource file '"+WORDS_FILENAME+"'", e); - } finally { - try { - reader.close(); - } catch (IOException e) { - logger.error("error while closing reader stream for '"+WORDS_FILENAME+"'", e); - } - } + if (str != null) { + try { + final BufferedReader reader = new BufferedReader(new UnicodeSupportingInputStreamReader(str, "UTF-8")); + + try { + read(reader, null); + } catch (final IOException e) { + logger.error("error while reading resource file '"+WORDS_FILENAME+"'", e); + } finally { + try { + reader.close(); + } catch (IOException e) { + logger.error("error while closing reader stream for '"+WORDS_FILENAME+"'", e); + } + } } finally { - try { - str.close(); - } catch (IOException e) { - logger.warn("exception on closing resource stream", e); - } - } - } else { - logger.error("unable to locate resource file '"+WORDS_FILENAME+"'"); - } + try { + str.close(); + } catch (IOException e) { + logger.warn("exception on closing resource stream", e); + } + } + } else { + logger.error("unable to locate resource file '"+WORDS_FILENAME+"'"); + } } /** @@ -160,7 +160,7 @@ public void read(final BufferedReader reader, final List comments) throw } // calculate the hash value from all word entries -// calculateHash(); + //calculateHash(); } /** @@ -591,18 +591,18 @@ public void registerName(final String name, final String typeString) { * @return compound name or null */ public CompoundName searchCompoundName(AbstractList expressions, int idx) { - Expression first = expressions.get(idx); + Expression first = expressions.get(idx); - Set candidates = compoundNames.get(first.getOriginal().toLowerCase()); + Set candidates = compoundNames.get(first.getOriginal().toLowerCase()); if (candidates != null) { - TreeSet candidatesSortedFromLongestToShortest = new TreeSet(new ArrayLengthDescSorter()); - candidatesSortedFromLongestToShortest.addAll(candidates); - for (CompoundName compName : candidatesSortedFromLongestToShortest) { - if (compName.matches(expressions, idx)) { - return compName; - } - } + TreeSet candidatesSortedFromLongestToShortest = new TreeSet(new ArrayLengthDescSorter()); + candidatesSortedFromLongestToShortest.addAll(candidates); + for (CompoundName compName : candidatesSortedFromLongestToShortest) { + if (compName.matches(expressions, idx)) { + return compName; + } + } } return null; @@ -714,9 +714,11 @@ public void registerVerb(final String verb) { newEntry.setType(new ExpressionType(VERB_DYNAMIC)); words.put(key, newEntry); -// } else if (!checkNameCompatibleLastType(entry, ExpressionType.VERB)) { -// logger.warn("verb name already registered with incompatible expression type: " + -// entry.getNormalizedWithTypeString()); + /* + } else if (!checkNameCompatibleLastType(entry, ExpressionType.VERB)) { + logger.warn("verb name already registered with incompatible expression type: " + + entry.getNormalizedWithTypeString()); + */ } } diff --git a/src/games/stendhal/server/actions/admin/RemoteViewAction.java b/src/games/stendhal/server/actions/admin/RemoteViewAction.java index 61f182787cd..32c6fdc2d16 100644 --- a/src/games/stendhal/server/actions/admin/RemoteViewAction.java +++ b/src/games/stendhal/server/actions/admin/RemoteViewAction.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2016 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** * * @@ -11,57 +11,57 @@ ***************************************************************************/ package games.stendhal.server.actions.admin; - import games.stendhal.common.NotificationType; +import games.stendhal.common.NotificationType; import games.stendhal.server.actions.CommandCenter; import games.stendhal.server.core.engine.SingletonRepository; import games.stendhal.server.entity.player.Player; import games.stendhal.server.events.ViewChangeEvent; import marauroa.common.game.RPAction; - /** - * Sends an remote view event - * - * @author hendrik - */ - public class RemoteViewAction extends AdministrationAction { +/** + * Sends an remote view event + * + * @author hendrik + */ +public class RemoteViewAction extends AdministrationAction { - public static void register() { + public static void register() { CommandCenter.register("remoteview", new RemoteViewAction(), 500); - } + } - /** - * performs the remote view action - * - * @param player the player invoking this action - * @param action RPAction - */ - @Override - public void perform(Player player, RPAction action) { - String target = action.get("target"); - String args = action.get("args"); + /** + * performs the remote view action + * + * @param player the player invoking this action + * @param action RPAction + */ + @Override + public void perform(Player player, RPAction action) { + String target = action.get("target"); + String args = action.get("args"); - if (args.trim().equals("")) { - player.sendPrivateText(NotificationType.ERROR, "Usage: /remoteview [player] x y"); - } + if (args.trim().equals("")) { + player.sendPrivateText(NotificationType.ERROR, "Usage: /remoteview [player] x y"); + } - Player targetPlayer = player; - String x = target; - String y = args; - if (args.trim().indexOf(" ") > -1) { - targetPlayer = SingletonRepository.getRuleProcessor().getPlayer(target); - String[] temp = args.split(" "); - x = temp[0]; - y = temp[1]; - } + Player targetPlayer = player; + String x = target; + String y = args; + if (args.trim().indexOf(" ") > -1) { + targetPlayer = SingletonRepository.getRuleProcessor().getPlayer(target); + String[] temp = args.split(" "); + x = temp[0]; + y = temp[1]; + } - if (targetPlayer == null) { - player.sendPrivateText(NotificationType.ERROR, "Player not online"); - return; - } + if (targetPlayer == null) { + player.sendPrivateText(NotificationType.ERROR, "Player not online"); + return; + } - targetPlayer.addEvent(new ViewChangeEvent(Integer.parseInt(x), Integer.parseInt(y))); - targetPlayer.notifyWorldAboutChanges(); + targetPlayer.addEvent(new ViewChangeEvent(Integer.parseInt(x), Integer.parseInt(y))); + targetPlayer.notifyWorldAboutChanges(); } } diff --git a/src/games/stendhal/server/actions/admin/SummonAction.java b/src/games/stendhal/server/actions/admin/SummonAction.java index e5199d887e0..93a50555914 100644 --- a/src/games/stendhal/server/actions/admin/SummonAction.java +++ b/src/games/stendhal/server/actions/admin/SummonAction.java @@ -118,10 +118,10 @@ public void perform(final Player player, final RPAction action) { return; } - if ("block".equals(action.get(CREATURE))) { - final Block block = new Block(true); - block.setPosition(action.getInt(X), action.getInt(Y)); - player.getZone().add(block); + if ("block".equals(action.get(CREATURE))) { + final Block block = new Block(true); + block.setPosition(action.getInt(X), action.getInt(Y)); + player.getZone().add(block); } try { diff --git a/src/games/stendhal/server/actions/chat/ReportErrorAction.java b/src/games/stendhal/server/actions/chat/ReportErrorAction.java index 9fe16a1873b..1e245ffbaf7 100644 --- a/src/games/stendhal/server/actions/chat/ReportErrorAction.java +++ b/src/games/stendhal/server/actions/chat/ReportErrorAction.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2015 - Stendhal * + * (C) Copyright 2015-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -25,7 +25,7 @@ * handles error reports */ public class ReportErrorAction implements ActionListener { - private final Logger logger = Logger.getLogger(ReportErrorAction.class); + private final Logger logger = Logger.getLogger(ReportErrorAction.class); @Override public void onAction(final Player player, final RPAction action) { @@ -41,8 +41,8 @@ public void onAction(final Player player, final RPAction action) { MDC.remove("context"); logger.error(player.getName() + " (" + username + "):" - + System.getProperty("line.separator") - + action.get(TEXT).replaceAll("\r\n", System.getProperty("line.separator"))); + + System.getProperty("line.separator") + + action.get(TEXT).replaceAll("\r\n", System.getProperty("line.separator"))); MDC.put("context", context); } diff --git a/src/games/stendhal/server/core/config/CreaturesXMLLoader.java b/src/games/stendhal/server/core/config/CreaturesXMLLoader.java index 1400296a3dd..f88d82c62ba 100644 --- a/src/games/stendhal/server/core/config/CreaturesXMLLoader.java +++ b/src/games/stendhal/server/core/config/CreaturesXMLLoader.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -326,8 +326,8 @@ public void startElement(final String namespaceURI, final String lName, final St sounds.add(attrs.getValue("value")); } else if (qName.equals("movement")) { movementSound = attrs.getValue("value"); - } else if (qName.equals("death")) { - deathSound = attrs.getValue("value"); + } else if (qName.equals("death")) { + deathSound = attrs.getValue("value"); } } else if (qName.equals("abilities")) { abilities = true; @@ -346,8 +346,8 @@ public void startElement(final String namespaceURI, final String lName, final St Double value = Double.valueOf(attrs.getValue("value")); susceptibilities.put(type, value); } else if (abilities && qName.equals("statusattack")) { - statusAttack = attrs.getValue("type"); - statusAttackProbability = Double.valueOf(attrs.getValue("value")); + statusAttack = attrs.getValue("type"); + statusAttackProbability = Double.valueOf(attrs.getValue("value")); } } @@ -392,7 +392,7 @@ public void endElement(final String namespaceURI, final String sName, final Stri creature.setCreatureMovementSound(movementSound); if (statusAttack != null) { - creature.setStatusAttack(statusAttack, statusAttackProbability); + creature.setStatusAttack(statusAttack, statusAttackProbability); } list.add(creature); diff --git a/src/games/stendhal/server/core/engine/StendhalRPRuleProcessor.java b/src/games/stendhal/server/core/engine/StendhalRPRuleProcessor.java index ee5dd14bcda..e7fef8a150c 100644 --- a/src/games/stendhal/server/core/engine/StendhalRPRuleProcessor.java +++ b/src/games/stendhal/server/core/engine/StendhalRPRuleProcessor.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2020 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** * * @@ -510,7 +510,7 @@ public synchronized boolean onInit(final RPObject object) { if (object != null) { id = object.get("#db_id"); } else { - id = ""; + id = ""; } logger.error("There has been a severe problem loading player " + id, e); return false; @@ -534,17 +534,17 @@ static void welcome(final Player player) { final URL url = new URL(msg); HttpURLConnection.setFollowRedirects(false); final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - try { - final BufferedReader br = new BufferedReader( + try { + final BufferedReader br = new BufferedReader( new InputStreamReader(connection.getInputStream(), "UTF-8")); - try { - msg = br.readLine(); - } finally { - br.close(); - } - } finally { - connection.disconnect(); - } + try { + msg = br.readLine(); + } finally { + br.close(); + } + } finally { + connection.disconnect(); + } } } } catch (final IOException e) { diff --git a/src/games/stendhal/server/core/engine/db/PendingAchievementDAO.java b/src/games/stendhal/server/core/engine/db/PendingAchievementDAO.java index c7156b753aa..7e1dcbef4f0 100644 --- a/src/games/stendhal/server/core/engine/db/PendingAchievementDAO.java +++ b/src/games/stendhal/server/core/engine/db/PendingAchievementDAO.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2020 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -54,7 +54,7 @@ public Map> getPendingAchievementDetails(DBTransact MapOfMaps map = new MapOfMaps(); String query = "SELECT identifier, param, cnt FROM pending_achievement " + - "JOIN achievement on achievement_id = achievement.id " + + "JOIN achievement on achievement_id = achievement.id " + "WHERE charname = '[charname]';"; Map parameters = new HashMap(); parameters.put("charname", charname); diff --git a/src/games/stendhal/server/core/events/ZoneEventType.java b/src/games/stendhal/server/core/events/ZoneEventType.java index ca90b91fe32..723721ed30d 100644 --- a/src/games/stendhal/server/core/events/ZoneEventType.java +++ b/src/games/stendhal/server/core/events/ZoneEventType.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -36,7 +36,7 @@ public enum ZoneEventType { VISIT_SEMOS_CAVES( "The ground in this cave trembles from the footfalls of GIANTS! The weak should explore no further here. Turn around and run away!"), VISIT_ADOS_CASTLE( - "You sense that great atrocities have happened here. The castle must be overrun with evil creatures, as the sounds of their last victims ring in your ears. It may be wise to stay away."); + "You sense that great atrocities have happened here. The castle must be overrun with evil creatures, as the sounds of their last victims ring in your ears. It may be wise to stay away."); private String message; diff --git a/src/games/stendhal/server/core/pathfinder/EntityGuide.java b/src/games/stendhal/server/core/pathfinder/EntityGuide.java index 272072b0fd4..d1aa6dfd6b1 100644 --- a/src/games/stendhal/server/core/pathfinder/EntityGuide.java +++ b/src/games/stendhal/server/core/pathfinder/EntityGuide.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -76,12 +76,12 @@ public void faceNext(GuidedEntity entity) { * Entity's last position */ public int getPreviousPosition() { - int prevPos = pathPosition - 1; - if (prevPos < 0) { - prevPos = path.getNodeList().size() - 1; - } + int prevPos = pathPosition - 1; + if (prevPos < 0) { + prevPos = path.getNodeList().size() - 1; + } - return prevPos; + return prevPos; } /** diff --git a/src/games/stendhal/server/core/pathfinder/GoToPosition.java b/src/games/stendhal/server/core/pathfinder/GoToPosition.java index 02b4063ab32..1b38796ae8d 100644 --- a/src/games/stendhal/server/core/pathfinder/GoToPosition.java +++ b/src/games/stendhal/server/core/pathfinder/GoToPosition.java @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2003-2022 - Arianne * + * Copyright (C) 2003-2023 - Arianne * *************************************************************************** *************************************************************************** * * @@ -60,13 +60,13 @@ public void finish() */ @Override public void update(Observable o, Object arg) { - // are we at our destination? + // are we at our destination? Node current = new Node(ent.getX(), ent.getY()); if(current.equals(position)) { finish(); } else { // do we need to walk? - path = new FixedPath(Path.searchPath(ent, position.getX(), position.getY()),false); + path = new FixedPath(Path.searchPath(ent, position.getX(), position.getY()),false); if(path.getNodeList().size()==0) { finish(); } else { diff --git a/src/games/stendhal/server/core/rp/achievement/factory/FriendAchievementFactory.java b/src/games/stendhal/server/core/rp/achievement/factory/FriendAchievementFactory.java index 8d0a322e286..386db31e86e 100644 --- a/src/games/stendhal/server/core/rp/achievement/factory/FriendAchievementFactory.java +++ b/src/games/stendhal/server/core/rp/achievement/factory/FriendAchievementFactory.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2022 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -52,7 +52,7 @@ protected Category getCategory() { public Collection createAchievements() { final LinkedList achievements = new LinkedList(); - // TODO: add Pacifist achievement for not participating in pvp for 6 months or more (last_pvp_action_time) + // TODO: add Pacifist achievement for not participating in pvp for 6 months or more (last_pvp_action_time) // Befriend Susi and complete quests for all children achievements.add(createAchievement( diff --git a/src/games/stendhal/server/core/rp/achievement/factory/ProductionAchievementFactory.java b/src/games/stendhal/server/core/rp/achievement/factory/ProductionAchievementFactory.java index 87e14a4e1e6..575acfe3b41 100644 --- a/src/games/stendhal/server/core/rp/achievement/factory/ProductionAchievementFactory.java +++ b/src/games/stendhal/server/core/rp/achievement/factory/ProductionAchievementFactory.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2022 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -48,7 +48,7 @@ public Collection createAchievements() { final ProducerRegister producerRegister = SingletonRepository.getProducerRegister(); - final List foodlist = producerRegister.getProducedItemNames("food"); + final List foodlist = producerRegister.getProducedItemNames("food"); final String[] foods = foodlist.toArray(new String[foodlist.size()]); // may wish to remove mega potion by hand? @@ -67,7 +67,7 @@ public Collection createAchievements() { new QuestStateStartsWithCondition("coal_for_haunchy","waiting;")))); - final List drinklist = producerRegister.getProducedItemNames("drink"); + final List drinklist = producerRegister.getProducedItemNames("drink"); final String[] drinks = drinklist.toArray(new String[drinklist.size()]); // soups and koboldish torcibud are made using quest code so we add extra @@ -84,7 +84,7 @@ public Collection createAchievements() { new QuestCompletedCondition("koboldish_torcibud")))); - final List resourcelist = producerRegister.getProducedItemNames("resource"); + final List resourcelist = producerRegister.getProducedItemNames("resource"); final String[] resources = resourcelist.toArray(new String[resourcelist.size()]); // at time of writing: gold bar, mithril bar, flour, iron diff --git a/src/games/stendhal/server/core/rule/defaultruleset/DefaultCreature.java b/src/games/stendhal/server/core/rule/defaultruleset/DefaultCreature.java index 7d54771769d..8066baff781 100644 --- a/src/games/stendhal/server/core/rule/defaultruleset/DefaultCreature.java +++ b/src/games/stendhal/server/core/rule/defaultruleset/DefaultCreature.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003 - Marauroa * + * (C) Copyright 2003-2013 - Marauroa * *************************************************************************** *************************************************************************** * * @@ -326,8 +326,7 @@ public void setSusceptibilities(final Map susceptibilities) { * Set the damage types. * * @param type - * @param rangedType if null, then melee type is used for both - * attack modes + * @param rangedType if null, then melee type is used for both attack modes */ public void setDamageTypes(Nature type, Nature rangedType) { damageType = type; @@ -432,14 +431,14 @@ public void setCreatureSounds(List sounds) { * @param sound Name of sound */ public void setCreatureDeathSound(String sound) { - this.deathSound = sound; + this.deathSound = sound; } /** * Set a looped sound effect for creature when moving * * @param sound - * desired sound effect + * desired sound effect */ public void setCreatureMovementSound(String sound) { this.movementSound = sound; @@ -451,15 +450,15 @@ public void setCreatureMovementSound(String sound) { * @param probability */ public void setStatusAttack(final String name, final double probability) { - statusAttack = name; - statusAttackProbability = probability; + statusAttack = name; + statusAttackProbability = probability; } /** * Sets the style of shadow to use for this entity. * * @param style - * Name of the style. + * Name of the style. */ public void setShadowStyle(final String style) { shadowStyle = style; diff --git a/src/games/stendhal/server/core/rule/defaultruleset/LowerCaseMap.java b/src/games/stendhal/server/core/rule/defaultruleset/LowerCaseMap.java index bdea59c9748..c6e84e22129 100644 --- a/src/games/stendhal/server/core/rule/defaultruleset/LowerCaseMap.java +++ b/src/games/stendhal/server/core/rule/defaultruleset/LowerCaseMap.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -67,10 +67,10 @@ public V put(final String key, final V value) { @Override public void putAll(final Map< ? extends String, ? extends V> m) { - for (final Iterator< ? extends Map.Entry< ? extends String, ? extends V>> i = m.entrySet().iterator(); i.hasNext();) { - final Map.Entry< ? extends String, ? extends V> e = i.next(); - put(e.getKey(), e.getValue()); - } + for (final Iterator< ? extends Map.Entry< ? extends String, ? extends V>> i = m.entrySet().iterator(); i.hasNext();) { + final Map.Entry< ? extends String, ? extends V> e = i.next(); + put(e.getKey(), e.getValue()); + } } @Override diff --git a/src/games/stendhal/server/core/scripting/ScriptInJava.java b/src/games/stendhal/server/core/scripting/ScriptInJava.java index 4bb921539f5..f08e34401ea 100644 --- a/src/games/stendhal/server/core/scripting/ScriptInJava.java +++ b/src/games/stendhal/server/core/scripting/ScriptInJava.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2012 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -61,8 +61,8 @@ public ScriptInJava(final String scriptname) { * @throws InstantiationException */ private void newInstance() throws MalformedURLException, ClassNotFoundException, - NoSuchMethodException, IllegalAccessException, InvocationTargetException, - InstantiationException { + NoSuchMethodException, IllegalAccessException, InvocationTargetException, + InstantiationException { // Create new class loader // with current dir as CLASSPATH final File file = new File("./data/script"); diff --git a/src/games/stendhal/server/entity/ActiveEntity.java b/src/games/stendhal/server/entity/ActiveEntity.java index 7e655d85f5b..d261d4e7549 100644 --- a/src/games/stendhal/server/entity/ActiveEntity.java +++ b/src/games/stendhal/server/entity/ActiveEntity.java @@ -406,7 +406,7 @@ public double getSpeed() { * Steps taken */ public int getStepsTaken() { - return stepsTaken; + return stepsTaken; } /** diff --git a/src/games/stendhal/server/entity/Entity.java b/src/games/stendhal/server/entity/Entity.java index 8d83ed1d781..443c318776c 100644 --- a/src/games/stendhal/server/entity/Entity.java +++ b/src/games/stendhal/server/entity/Entity.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2018 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** * * @@ -53,8 +53,8 @@ public abstract class Entity extends RPObject implements Killer { private int y; - // Initial coordinates - private Point origin; + // Initial coordinates + private Point origin; /** * Amount of resistance this has with other entities (0-100). @@ -637,10 +637,10 @@ public final void setPosition(final int x, final int y) { final int oldY = this.y; boolean moved = false; - // Set the original position of the entity - if (origin == null) { - origin = new Point(x, y); - } + // Set the original position of the entity + if (origin == null) { + origin = new Point(x, y); + } if (x != oldX) { this.x = x; @@ -666,7 +666,7 @@ public final void setPosition(final int x, final int y) { * @return The initial position of the entity */ public final Point getOrigin() { - return origin; + return origin; } /** diff --git a/src/games/stendhal/server/entity/RPEntity.java b/src/games/stendhal/server/entity/RPEntity.java index 632a9f0f5ce..cb41f8e593f 100644 --- a/src/games/stendhal/server/entity/RPEntity.java +++ b/src/games/stendhal/server/entity/RPEntity.java @@ -262,14 +262,14 @@ protected boolean handlePortal(final Portal portal) { return super.handlePortal(portal); } - public static void generateRPClass() { - try { - stats = Statistics.getStatistics(); - RPEntityRPClass.generateRPClass(ATTR_TITLE); - } catch (final SyntaxException e) { - logger.error("cannot generateRPClass", e); - } - } + public static void generateRPClass() { + try { + stats = Statistics.getStatistics(); + RPEntityRPClass.generateRPClass(ATTR_TITLE); + } catch (final SyntaxException e) { + logger.error("cannot generateRPClass", e); + } + } public RPEntity(final RPObject object) { super(object); @@ -529,7 +529,7 @@ private static void registerNewName(final String newName, final String oldName) * @param defender * The defender. * @param attackingWeaponsValue - * ATK-value of all attacking weapons/spells + * ATK-value of all attacking weapons/spells * @param damageType nature of damage * @param isRanged true if this is a ranged attack, otherwise * false @@ -650,7 +650,7 @@ protected int damageDone(RPEntity defender, double attackingWeaponsValue, Nature * @param defender * The defender. * @param attackingWeaponsValue - * ATK-value of all attacking weapons/spells + * ATK-value of all attacking weapons/spells * @param damageType nature of damage * @return The number of hitpoints that the target should lose. 0 if the * attack was completely blocked by the defender. @@ -1718,7 +1718,7 @@ protected void rewardKillerAnimals(final int oldXP) { * The entity who caused the death */ public final void onDead(final Killer killer) { - onDead(killer, true); + onDead(killer, true); } /** diff --git a/src/games/stendhal/server/entity/creature/Creature.java b/src/games/stendhal/server/entity/creature/Creature.java index 89b4fd6caec..d8b4f295a5e 100644 --- a/src/games/stendhal/server/entity/creature/Creature.java +++ b/src/games/stendhal/server/entity/creature/Creature.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2012 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -377,10 +377,10 @@ public Creature getNewInstance() { */ @Override public final void setDeathSound(String sound) { - if (deathSound == null) { - deathSound = sound; - } - super.setDeathSound(deathSound); + if (deathSound == null) { + deathSound = sound; + } + super.setDeathSound(deathSound); } /** @@ -388,7 +388,7 @@ public final void setDeathSound(String sound) { * @param sound sound effect file name */ public final void setMovementSound(String sound) { - this.movementSound = sound; + this.movementSound = sound; } /** @@ -409,7 +409,7 @@ public void setNoises(final LinkedHashMap> creatureNo */ public void registerObjectsForNotification(final Observer observer) { if(observer!=null) { - registrator.setObserver(observer); + registrator.setObserver(observer); } } @@ -421,7 +421,7 @@ public void registerObjectsForNotification(final Observer observer) { public void registerObjectsForNotification(final List observers) { for(Observer observer : observers) { if(observer!=null) { - registrator.setObserver(observer); + registrator.setObserver(observer); } } } @@ -433,7 +433,7 @@ public void registerObjectsForNotification(final List observers) { */ public void unregisterObjectsForNotification(final Observer observer) { if(observer!=null) { - registrator.removeObserver(observer); + registrator.removeObserver(observer); } } @@ -445,7 +445,7 @@ public void unregisterObjectsForNotification(final Observer observer) { public void unregisterObjectsForNotification(final List observers) { for(Observer observer : observers) { if(observer!=null) { - registrator.removeObserver(observer); + registrator.removeObserver(observer); } } } @@ -454,8 +454,8 @@ public void unregisterObjectsForNotification(final List observers) { * Will notify observers when event will occurred (death). */ public void notifyRegisteredObjects() { - registrator.setChanges(); - registrator.notifyObservers(circumstances); + registrator.setChanges(); + registrator.notifyObservers(circumstances); } public boolean isSpawned() { @@ -508,14 +508,14 @@ private void setAIProfiles(final Map aiProfiles, boolean initSta String statusAttackerProfiles = aiProfiles.get("status_attackers"); if (statusAttackerProfiles != null) { - String[] statusAttackers = statusAttackerProfiles.split(";"); - int statusCount = statusAttackers.length; - for (int index = 0; index < statusCount; index++) { - StatusAttacker statusAttacker = StatusAttackerFactory.get(statusAttackers[index]); - if (statusAttacker != null) { - this.addStatusAttacker(statusAttacker); - } - } + String[] statusAttackers = statusAttackerProfiles.split(";"); + int statusCount = statusAttackers.length; + for (int index = 0; index < statusCount; index++) { + StatusAttacker statusAttacker = StatusAttackerFactory.get(statusAttackers[index]); + if (statusAttacker != null) { + this.addStatusAttacker(statusAttacker); + } + } } } idler = IdleBehaviourFactory.get(aiProfiles); @@ -931,7 +931,7 @@ public void logic() { // this event duration usually is only one turn this.makeNoiseChance(50, "target"); } else { - this.setIdle(); + this.setIdle(); this.makeNoiseChance(100, "idle"); } } @@ -989,9 +989,9 @@ public void makeNoiseChance(int prob, final String state) { * FIXME: doesn't play sound */ private void loopMovementSound() { - movementSoundEvent = new SoundEvent(movementSound, SOUND_RADIUS, 100, SoundLayer.CREATURE_NOISE); - this.addEvent(movementSoundEvent); - this.notifyWorldAboutChanges(); + movementSoundEvent = new SoundEvent(movementSound, SOUND_RADIUS, 100, SoundLayer.CREATURE_NOISE); + this.addEvent(movementSoundEvent); + this.notifyWorldAboutChanges(); } /** diff --git a/src/games/stendhal/server/entity/creature/ItemGuardCreature.java b/src/games/stendhal/server/entity/creature/ItemGuardCreature.java index d16ecf929cb..70185f38bec 100644 --- a/src/games/stendhal/server/entity/creature/ItemGuardCreature.java +++ b/src/games/stendhal/server/entity/creature/ItemGuardCreature.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** * * @@ -74,7 +74,7 @@ public ItemGuardCreature(final Creature copy, final String itemType) { * @param questSlot * the quest slot for the active quest * @param questState - * the state of the quest to check on dead for + * the state of the quest to check on dead for */ public ItemGuardCreature(final Creature copy, final String itemType, final String questSlot, final String questState) { this(copy, itemType, questSlot, questState, 0); @@ -90,9 +90,9 @@ public ItemGuardCreature(final Creature copy, final String itemType, final Strin * @param questSlot * the quest slot for the active quest * @param questState - * the state of the quest to check on dead for + * the state of the quest to check on dead for * @param questIndex - * the index of the quest slot to look in + * the index of the quest slot to look in */ public ItemGuardCreature(final Creature copy, final String itemType, final String questSlot, final String questState, final int questIndex) { this(copy, itemType, null, null, questSlot, questState, questIndex); @@ -112,9 +112,9 @@ public ItemGuardCreature(final Creature copy, final String itemType, final Strin * @param questSlot * the quest slot for the active quest * @param questState - * the state of the quest to check on dead for + * the state of the quest to check on dead for * @param questIndex - * the index of the quest slot to look in + * the index of the quest slot to look in */ public ItemGuardCreature(final Creature copy, final String itemType, final String itemItemdata, final String itemDescr, final String questSlot, final String questState, final int questIndex) { @@ -131,9 +131,9 @@ public ItemGuardCreature(final Creature copy, final String itemType, final Strin final LinkedList ll = new LinkedList(); ll.add("Thou shall not obtain the " + itemType + "!"); // add to all states except death - in death player will get itemType. - noises.put("idle", ll); - noises.put("fight", ll); - noises.put("follow", ll); + noises.put("idle", ll); + noises.put("fight", ll); + noises.put("follow", ll); if (!SingletonRepository.getEntityManager().isItem( itemType)) { diff --git a/src/games/stendhal/server/entity/item/CaptureTheFlagFlag.java b/src/games/stendhal/server/entity/item/CaptureTheFlagFlag.java index 46214217d16..36934d8ef78 100644 --- a/src/games/stendhal/server/entity/item/CaptureTheFlagFlag.java +++ b/src/games/stendhal/server/entity/item/CaptureTheFlagFlag.java @@ -42,26 +42,26 @@ public class CaptureTheFlagFlag extends Item { // this is the detail that you set for the outfit overlay // (and then you have to set a color) - int detailValue = 5; + int detailValue = 5; String colorValue = "0x00ff00"; - // boolean droppable; + //boolean droppable; public CaptureTheFlagFlag(final String name, - final String clazz, - final String subclass, - final Map attributes) { + final String clazz, + final String subclass, + final Map attributes) { super(name, clazz, subclass, attributes); // XXX get a string, map to integer // this.colorValue = NPCAttrUtils.getAttrInt("color", attributes, 3); String colorStr = attributes.get("color"); if (colorStr != null) { - this.colorValue = colorStr; + this.colorValue = colorStr; } - // this.droppable = NPCAttrUtils.getAttr("droppable", attributes); + //this.droppable = NPCAttrUtils.getAttr("droppable", attributes); } diff --git a/src/games/stendhal/server/entity/item/scroll/InvitationScroll.java b/src/games/stendhal/server/entity/item/scroll/InvitationScroll.java index 36026348391..5d43141407b 100644 --- a/src/games/stendhal/server/entity/item/scroll/InvitationScroll.java +++ b/src/games/stendhal/server/entity/item/scroll/InvitationScroll.java @@ -126,7 +126,7 @@ protected boolean useTeleportScroll(final Player player) { return false; } - final String[] info = dest.split(","); + final String[] info = dest.split(","); if (info.length < 2) { player.sendPrivateText("This scroll is so old that it lost its magic."); return false; @@ -148,11 +148,13 @@ private boolean handleTeleportToChurch(final Player player, final String playerN player.sendPrivateText("There does not seem be a marriage going on, at least " + playerName + " is not online at the moment."); return false; } - //TODO: either activate this by finding out how to put 'marriage' in here: - // if (marriage.isMarried(playerName)) { - // player.sendPrivateText("It looks like you missed the wedding, because " + playerName + " is already married."); - // return false; - //} + // TODO: either activate this by finding out how to put 'marriage' in here: + /* + if (marriage.isMarried(playerName)) { + player.sendPrivateText("It looks like you missed the wedding, because " + playerName + " is already married."); + return false; + } + */ // or use sth like (engagedPlayer.isInQuestState("marriage","just_married") || engagedPlayer.isInQuestState("marriage","done")) in the // if statement. return teleportTo(WEDDING_ZONE + " " + WEDDING_SPOT, player); diff --git a/src/games/stendhal/server/entity/item/scroll/MarkedScroll.java b/src/games/stendhal/server/entity/item/scroll/MarkedScroll.java index c970aa2b9e0..5a0971654c5 100644 --- a/src/games/stendhal/server/entity/item/scroll/MarkedScroll.java +++ b/src/games/stendhal/server/entity/item/scroll/MarkedScroll.java @@ -2,7 +2,7 @@ * $Id$ */ /*************************************************************************** - * (C) Copyright 2003 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** * * @@ -100,9 +100,9 @@ protected boolean useTeleportScroll(final Player player) { + "you cannot concentrate on it because you have never been there."); return false; } else { - zone = temp; - x = Integer.parseInt(st.nextToken()); - y = Integer.parseInt(st.nextToken()); + zone = temp; + x = Integer.parseInt(st.nextToken()); + y = Integer.parseInt(st.nextToken()); if (!zone.isTeleportInAllowed(x, y)) { player.sendPrivateText("The strong anti magic aura in the destination area prevents the scroll from working!"); return false; diff --git a/src/games/stendhal/server/entity/mapstuff/chest/Chest.java b/src/games/stendhal/server/entity/mapstuff/chest/Chest.java index cd9ffb31668..37b7c9d5a2e 100644 --- a/src/games/stendhal/server/entity/mapstuff/chest/Chest.java +++ b/src/games/stendhal/server/entity/mapstuff/chest/Chest.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003 - Marauroa * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -85,9 +85,9 @@ public static void generateRPClass() { // @Override - public String getDescriptionName(final boolean definite) { - return Grammar.article_noun(CHEST_RPCLASS_NAME, definite); - } + public String getDescriptionName(final boolean definite) { + return Grammar.article_noun(CHEST_RPCLASS_NAME, definite); + } @Override public void update() { diff --git a/src/games/stendhal/server/entity/mapstuff/chest/PersonalChest.java b/src/games/stendhal/server/entity/mapstuff/chest/PersonalChest.java index fe965865bfb..c9d6272fc04 100644 --- a/src/games/stendhal/server/entity/mapstuff/chest/PersonalChest.java +++ b/src/games/stendhal/server/entity/mapstuff/chest/PersonalChest.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -219,9 +219,9 @@ public boolean onUsed(final RPEntity user) { } @Override - public String getDescriptionName(final boolean definite) { - return Grammar.article_noun(bankName + " chest", definite); - } + public String getDescriptionName(final boolean definite) { + return Grammar.article_noun(bankName + " chest", definite); + } /** * A listener for syncing the slot contents. diff --git a/src/games/stendhal/server/entity/mapstuff/office/RentedSign.java b/src/games/stendhal/server/entity/mapstuff/office/RentedSign.java index cdba7646e7f..be7d7ca16db 100644 --- a/src/games/stendhal/server/entity/mapstuff/office/RentedSign.java +++ b/src/games/stendhal/server/entity/mapstuff/office/RentedSign.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2011 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -59,24 +59,24 @@ public RentedSign(final Player renter, final String text) { * @param rpobject */ public RentedSign(final RPObject rpobject) { - super(rpobject); - store(); - } + super(rpobject); + store(); + } /** * returns the owner. * * @return name of owner */ - public String getRenter() { - return get(RENTER); - } + public String getRenter() { + return get(RENTER); + } - /** - * Returns the timestamp when this entity was created. - * - * @return timestamp in milliseconds - */ + /** + * Returns the timestamp when this entity was created. + * + * @return timestamp in milliseconds + */ public long getTimestamp() { return (long) Float.parseFloat(get(TIMESTAMP)); } diff --git a/src/games/stendhal/server/entity/mapstuff/portal/AccessCheckingPortal.java b/src/games/stendhal/server/entity/mapstuff/portal/AccessCheckingPortal.java index fa1eba8e0bf..ee5c378f660 100644 --- a/src/games/stendhal/server/entity/mapstuff/portal/AccessCheckingPortal.java +++ b/src/games/stendhal/server/entity/mapstuff/portal/AccessCheckingPortal.java @@ -65,35 +65,35 @@ public AccessCheckingPortal() { portalIDCounter += 1; } - /** - * Creates an access checking portal. - * - * @param rejectMessage - * The message to given when rejected. - */ - public AccessCheckingPortal(final String rejectMessage) { - this.rejectedMessage = rejectMessage; + /** + * Creates an access checking portal. + * + * @param rejectMessage + * The message to given when rejected. + */ + public AccessCheckingPortal(final String rejectMessage) { + this.rejectedMessage = rejectMessage; portalID = portalIDCounter; portalIDCounter += 1; - } + } - /** - * - * @param object - */ - public AccessCheckingPortal(final RPObject object) { - super(object); + /** + * + * @param object + */ + public AccessCheckingPortal(final RPObject object) { + super(object); portalID = portalIDCounter; portalIDCounter += 1; - } + } - /** - * - * @return - * Message when password is accepted. - */ + /** + * + * @return + * Message when password is accepted. + */ public String getPasswordAcceptedMessage() { return passwordAcceptedMessage; } @@ -137,7 +137,7 @@ private List getNearbyPlayersThatHaveSpoken() { int dy = py - y; if (Math.abs(dx)true if the user can use the portal. - */ - protected abstract boolean isAllowed(RPEntity user); - - public boolean playerIsPortalUnlocked(final Player player, final Portal portal) { - if (player.getUnlockedPortals().contains(portalID)) { - return true; - } - return false; - } + /** + * Determine if this portal can be used. + * + * @param user + * The user to be checked. + * + * @return true if the user can use the portal. + */ + protected abstract boolean isAllowed(RPEntity user); + + public boolean playerIsPortalUnlocked(final Player player, final Portal portal) { + if (player.getUnlockedPortals().contains(portalID)) { + return true; + } + return false; + } @Override - public void logic() { + public void logic() { // Execute action for password portal if required password is set. if (requiredPassword != null) { List players = getNearbyPlayersThatHaveSpoken(); @@ -244,52 +244,52 @@ public boolean onUsed(final RPEntity user) { return false; } - /** - * Called when the user is rejected. This sends a rejection message to the - * user if set. - * - * @param user - * The rejected user. - */ - protected void rejected(final RPEntity user) { - if (rejectedMessage != null) { - if (!rejectedMessage.trim().equals("")) { - sendMessage(user, rejectedMessage); - } - - if (rejectedAction != null) { - rejectedAction.fire((Player) user, null, null); - } - - if (forceStop) { - if (user instanceof Player) { - ((Player) user).forceStop(); - } else { - user.stop(); - } - } else { - /* - * Suppresses sprite bounce-back in the case of non-resistant portals - */ - if (getResistance() != 0) { - user.stop(); - user.clearPath(); - } - } - } - } - - /** - * Wrapper to send a message to a user, without getting lost. - * - * @param user - * The user to send to. - * @param text - * The message to send. - */ - protected void sendMessage(final RPEntity user, final String text) { - SingletonRepository.getTurnNotifier().notifyInTurns(0, new SendMessage(user, text)); - } + /** + * Called when the user is rejected. This sends a rejection message to the + * user if set. + * + * @param user + * The rejected user. + */ + protected void rejected(final RPEntity user) { + if (rejectedMessage != null) { + if (!rejectedMessage.trim().equals("")) { + sendMessage(user, rejectedMessage); + } + + if (rejectedAction != null) { + rejectedAction.fire((Player) user, null, null); + } + + if (forceStop) { + if (user instanceof Player) { + ((Player) user).forceStop(); + } else { + user.stop(); + } + } else { + /* + * Suppresses sprite bounce-back in the case of non-resistant portals + */ + if (getResistance() != 0) { + user.stop(); + user.clearPath(); + } + } + } + } + + /** + * Wrapper to send a message to a user, without getting lost. + * + * @param user + * The user to send to. + * @param text + * The message to send. + */ + protected void sendMessage(final RPEntity user, final String text) { + SingletonRepository.getTurnNotifier().notifyInTurns(0, new SendMessage(user, text)); + } /** * @@ -298,19 +298,21 @@ protected void sendMessage(final RPEntity user, final String text) { */ public void setInstantAction(final boolean instant) { instantAction = instant; -// logger.info("\nSetting instant action to \"" + Boolean.toString(instant) + "\" for portal at " -// + getZone().getName() + " (" + Integer.toString(getX()) + "," + Integer.toString(getY()) + "\n"); + /* + logger.info("\nSetting instant action to \"" + Boolean.toString(instant) + "\" for portal at " + + getZone().getName() + " (" + Integer.toString(getX()) + "," + Integer.toString(getY()) + "\n"); + */ } - /** - * Set the password accepted message. - * - * @param message - * Optional message to be given when correct password used. - */ - public void setPasswordAcceptedMessage(final String message) { - passwordAcceptedMessage = message; - } + /** + * Set the password accepted message. + * + * @param message + * Optional message to be given when correct password used. + */ + public void setPasswordAcceptedMessage(final String message) { + passwordAcceptedMessage = message; + } /** * Set the password rejected message. @@ -323,90 +325,90 @@ public void setPasswordRejectedMessage(final String message) { } - /** - * Sets the radius at which the portal will "hear" speaking players. - * - * @param radius - * Distance at wich portal listens for players speaking. - */ - public void setListeningRadius(int radius) { - if (radius <= 0) { - radius = 1; - } - listeningRadius = radius; - } - - /** - * Set the rejection message. - * - * @param message The message to give when rejected. - */ - public void setRejectedMessage(final String message) { - rejectedMessage = message; - } - - /** - * - * @param password - */ - public void setRequiredPassword(final String password) { - requiredPassword = password; - } - - /** - * Initiates an action to take on rejection. - * - * @param rejectedAction - * ChatAction to execute. - */ - public void setRejectedAction(ChatAction rejectedAction) { - this.rejectedAction = rejectedAction; - } - - /** - * Sets flag to override continuous movement & force entity to stop. - * - * @param forceStop - * If true, entity is forced to stop movement. - */ - public void setForceStop(final boolean forceStop) { - this.forceStop = forceStop; - } - - /** - * A turn listener that sends a user message. Once sendPrivateText() is - * fixed (via a queue or something) to always work, this can go away. - */ - protected static class SendMessage implements TurnListener { - /** - * The user to send to. - */ - private final RPEntity user; - private final String text; - - /** - * Create a message sending turn listener. - * - * @param user - * The user to send to. - * @param text - * Message to send - */ - public SendMessage(final RPEntity user, final String text) { - this.user = user; - this.text = text; - } - - /** - * This method is called when the turn number is reached. - * - * @param currentTurn - * Current turn number. - */ - @Override - public void onTurnReached(final int currentTurn) { - user.sendPrivateText(this.text); - user.notifyWorldAboutChanges(); - } - } + /** + * Sets the radius at which the portal will "hear" speaking players. + * + * @param radius + * Distance at wich portal listens for players speaking. + */ + public void setListeningRadius(int radius) { + if (radius <= 0) { + radius = 1; + } + listeningRadius = radius; + } + + /** + * Set the rejection message. + * + * @param message The message to give when rejected. + */ + public void setRejectedMessage(final String message) { + rejectedMessage = message; + } + + /** + * + * @param password + */ + public void setRequiredPassword(final String password) { + requiredPassword = password; + } + + /** + * Initiates an action to take on rejection. + * + * @param rejectedAction + * ChatAction to execute. + */ + public void setRejectedAction(ChatAction rejectedAction) { + this.rejectedAction = rejectedAction; + } + + /** + * Sets flag to override continuous movement & force entity to stop. + * + * @param forceStop + * If true, entity is forced to stop movement. + */ + public void setForceStop(final boolean forceStop) { + this.forceStop = forceStop; + } + + /** + * A turn listener that sends a user message. Once sendPrivateText() is + * fixed (via a queue or something) to always work, this can go away. + */ + protected static class SendMessage implements TurnListener { + /** + * The user to send to. + */ + private final RPEntity user; + private final String text; + + /** + * Create a message sending turn listener. + * + * @param user + * The user to send to. + * @param text + * Message to send + */ + public SendMessage(final RPEntity user, final String text) { + this.user = user; + this.text = text; + } + + /** + * This method is called when the turn number is reached. + * + * @param currentTurn + * Current turn number. + */ + @Override + public void onTurnReached(final int currentTurn) { + user.sendPrivateText(this.text); + user.notifyWorldAboutChanges(); + } + } } diff --git a/src/games/stendhal/server/entity/mapstuff/portal/AccessCheckingPortalFactory.java b/src/games/stendhal/server/entity/mapstuff/portal/AccessCheckingPortalFactory.java index 436bc6fe70b..1d5e50b4686 100644 --- a/src/games/stendhal/server/entity/mapstuff/portal/AccessCheckingPortalFactory.java +++ b/src/games/stendhal/server/entity/mapstuff/portal/AccessCheckingPortalFactory.java @@ -72,22 +72,22 @@ public Object create(final ConfigurableFactoryContext ctx) { final boolean ignoreNoDestination = ctx.getBoolean("ignoreNoDestination", false); if (instantAction) { - portal.setInstantAction(instantAction); + portal.setInstantAction(instantAction); } if (passwordAcceptedMessage != null) { - portal.setPasswordAcceptedMessage(passwordAcceptedMessage); + portal.setPasswordAcceptedMessage(passwordAcceptedMessage); } if (passwordRejectedMessage != null) { - portal.setPasswordRejectedMessage(passwordRejectedMessage); + portal.setPasswordRejectedMessage(passwordRejectedMessage); } if (rejectedMessage != null) { portal.setRejectedMessage(rejectedMessage); } if (requiredPassword != null) { - portal.setRequiredPassword(requiredPassword); + portal.setRequiredPassword(requiredPassword); } if (listeningRadius > 0) { - portal.setListeningRadius(listeningRadius); + portal.setListeningRadius(listeningRadius); } if (rejectedAction != null) { portal.setRejectedAction(rejectedAction); @@ -98,47 +98,47 @@ public Object create(final ConfigurableFactoryContext ctx) { return portal; } - /** - * Extract string value from a context. - * - * @param ctx - * The configuration context. - * @param key - * The key to search for. - * @return - * The string value of the key, or null if none. - * @throws IllegalArgumentException - * If the class attribute is missing. - */ - protected String getStringValue(final ConfigurableFactoryContext ctx, final String key) { - return ctx.getString(key, null); - } + /** + * Extract string value from a context. + * + * @param ctx + * The configuration context. + * @param key + * The key to search for. + * @return + * The string value of the key, or null if none. + * @throws IllegalArgumentException + * If the class attribute is missing. + */ + protected String getStringValue(final ConfigurableFactoryContext ctx, final String key) { + return ctx.getString(key, null); + } - /** - * Extract integer value from a context. - * - * @param ctx - * The configuration context. - * @param key - * The key to search for. - * @return - * The integer value of the key, or null if none. - * @throws IllegalArgumentException - * If the class attribute is missing. - */ - protected int getIntValue(final ConfigurableFactoryContext ctx, final String key) { - return ctx.getInt(key, -1); - } + /** + * Extract integer value from a context. + * + * @param ctx + * The configuration context. + * @param key + * The key to search for. + * @return + * The integer value of the key, or null if none. + * @throws IllegalArgumentException + * If the class attribute is missing. + */ + protected int getIntValue(final ConfigurableFactoryContext ctx, final String key) { + return ctx.getInt(key, -1); + } - /** - * Creates a new ChatAction from ConfigurableFactoryContext. - * - * @param ctx - * ConfigurableFactoryContext - * @return - * ChatAction instance - */ - protected ChatAction getRejectedAction(final ConfigurableFactoryContext ctx) { + /** + * Creates a new ChatAction from ConfigurableFactoryContext. + * + * @param ctx + * ConfigurableFactoryContext + * @return + * ChatAction instance + */ + protected ChatAction getRejectedAction(final ConfigurableFactoryContext ctx) { String value = ctx.getString("rejectedAction", null); if (value == null) { return null; @@ -152,5 +152,5 @@ protected ChatAction getRejectedAction(final ConfigurableFactoryContext ctx) { } catch (CompilationFailedException e) { throw new IllegalArgumentException(e); } - } + } } diff --git a/src/games/stendhal/server/entity/mapstuff/portal/HousePortal.java b/src/games/stendhal/server/entity/mapstuff/portal/HousePortal.java index 82ccf72be3d..c3d32cd6ace 100644 --- a/src/games/stendhal/server/entity/mapstuff/portal/HousePortal.java +++ b/src/games/stendhal/server/entity/mapstuff/portal/HousePortal.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -97,7 +97,7 @@ public HousePortal(final RPObject object) { super.setIdentifier(idToObject(PORTAL_REFERENCE)); setRejectedMessage("The door is locked."); - store(); + store(); } /** diff --git a/src/games/stendhal/server/entity/mapstuff/portal/Portal.java b/src/games/stendhal/server/entity/mapstuff/portal/Portal.java index eab62968116..ed4701f0a5a 100644 --- a/src/games/stendhal/server/entity/mapstuff/portal/Portal.java +++ b/src/games/stendhal/server/entity/mapstuff/portal/Portal.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** * * @@ -185,7 +185,7 @@ public boolean loaded() { } public void logic() { - // Sub-classes can implement this + // Sub-classes can implement this } @Override diff --git a/src/games/stendhal/server/entity/mapstuff/puzzle/PuzzleBuildingBlock.java b/src/games/stendhal/server/entity/mapstuff/puzzle/PuzzleBuildingBlock.java index 57348292f05..00f9928a495 100644 --- a/src/games/stendhal/server/entity/mapstuff/puzzle/PuzzleBuildingBlock.java +++ b/src/games/stendhal/server/entity/mapstuff/puzzle/PuzzleBuildingBlock.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2016-2016 - Stendhal * + * (C) Copyright 2016-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -62,15 +62,15 @@ public void defineProperty(String variable, String expression) { PuzzleEventDispatcher.get().parseExpression(this, expression)); Scanner sc = new Scanner(expression); - Pattern pattern = Pattern.compile("\"[^\"]*\"|[A-Za-z0-9._]+"); - String token = sc.findInLine(pattern); - while (token != null) { - if (token.charAt(0) != '"' && token.contains(".")) { - this.dependencies.add(token.substring(0, token.lastIndexOf('.'))); - } - token = sc.findInLine(pattern); - } - sc.close(); + Pattern pattern = Pattern.compile("\"[^\"]*\"|[A-Za-z0-9._]+"); + String token = sc.findInLine(pattern); + while (token != null) { + if (token.charAt(0) != '"' && token.contains(".")) { + this.dependencies.add(token.substring(0, token.lastIndexOf('.'))); + } + token = sc.findInLine(pattern); + } + sc.close(); } } diff --git a/src/games/stendhal/server/entity/mapstuff/useable/CoalSource.java b/src/games/stendhal/server/entity/mapstuff/useable/CoalSource.java index 57385df13da..79f1b965fa6 100644 --- a/src/games/stendhal/server/entity/mapstuff/useable/CoalSource.java +++ b/src/games/stendhal/server/entity/mapstuff/useable/CoalSource.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -143,8 +143,8 @@ protected boolean isSuccessful(final Player player) { @Override protected void onFinished(final Player player, final boolean successful) { if (successful) { - addEvent(new SoundEvent(successSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); - notifyWorldAboutChanges(); + addEvent(new SoundEvent(successSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); + notifyWorldAboutChanges(); final Item item = SingletonRepository.getEntityManager().getItem(itemName); @@ -183,8 +183,8 @@ private void handleRespawn() { @Override protected void onStarted(final Player player) { player.sendPrivateText("You have started to pick for coal."); - addEvent(new SoundEvent(startSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); - notifyWorldAboutChanges(); + addEvent(new SoundEvent(startSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); + notifyWorldAboutChanges(); } /** diff --git a/src/games/stendhal/server/entity/mapstuff/useable/FishSource.java b/src/games/stendhal/server/entity/mapstuff/useable/FishSource.java index 03739a909bc..0d2e968b280 100644 --- a/src/games/stendhal/server/entity/mapstuff/useable/FishSource.java +++ b/src/games/stendhal/server/entity/mapstuff/useable/FishSource.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -174,8 +174,8 @@ protected void onFinished(final Player player, final boolean successful) { player.incHarvestedForItem(itemName, 1); player.sendPrivateText("You caught a fish."); } else { - // TODO: find a sound for failure - //this.addEvent(new SoundEvent(failSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); + // TODO: find a sound for failure + //this.addEvent(new SoundEvent(failSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); this.notifyWorldAboutChanges(); player.sendPrivateText("You didn't get a fish."); @@ -191,9 +191,9 @@ protected void onFinished(final Player player, final boolean successful) { */ @Override protected void onStarted(final Player player) { - // Play a nice fishing sound - addEvent(new SoundEvent(startSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); - notifyWorldAboutChanges(); + // Play a nice fishing sound + addEvent(new SoundEvent(startSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); + notifyWorldAboutChanges(); // some feedback is needed. player.sendPrivateText("You have started fishing."); diff --git a/src/games/stendhal/server/entity/mapstuff/useable/GoldSource.java b/src/games/stendhal/server/entity/mapstuff/useable/GoldSource.java index 5bad2527b9b..03ab9f2ca63 100644 --- a/src/games/stendhal/server/entity/mapstuff/useable/GoldSource.java +++ b/src/games/stendhal/server/entity/mapstuff/useable/GoldSource.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -131,10 +131,10 @@ protected boolean isPrepared(final Player player) { @Override protected boolean isSuccessful(final Player player) { final int random = Rand.roll1D100(); - /* - * Use some karma to help decide if the outcome is successful - */ - return random <= (FINDING_PROBABILITY + player.useKarma(FINDING_PROBABILITY)) * 100; + /* + * Use some karma to help decide if the outcome is successful + */ + return random <= (FINDING_PROBABILITY + player.useKarma(FINDING_PROBABILITY)) * 100; } /** @@ -151,9 +151,9 @@ protected void onFinished(final Player player, final boolean successful) { final Item item = SingletonRepository.getEntityManager().getItem(itemName); if (item != null) { - player.equipOrPutOnGround(item); - player.incMinedForItem(item.getName(), item.getQuantity()); - player.sendPrivateText("You found " + player.equipOrPutOnGround(item); + player.incMinedForItem(item.getName(), item.getQuantity()); + player.sendPrivateText("You found " + Grammar.a_noun(item.getTitle()) + "."); } else { logger.error("could not find item: " + itemName); diff --git a/src/games/stendhal/server/entity/mapstuff/useable/WaterSpringSource.java b/src/games/stendhal/server/entity/mapstuff/useable/WaterSpringSource.java index dbbbcaae4b9..02f79d4a1b2 100644 --- a/src/games/stendhal/server/entity/mapstuff/useable/WaterSpringSource.java +++ b/src/games/stendhal/server/entity/mapstuff/useable/WaterSpringSource.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -103,10 +103,10 @@ protected int getDuration() { */ @Override protected boolean isPrepared(final Player player) { - /* - * The player can fill an empty flask at the spring. - * Check they have it before they can start filling it up. - */ + /* + * The player can fill an empty flask at the spring. + * Check they have it before they can start filling it up. + */ if (player.isEquipped("flask")) { return true; } else { @@ -123,10 +123,10 @@ protected boolean isPrepared(final Player player) { @Override protected boolean isSuccessful(final Player player) { final int random = Rand.roll1D100(); - /* - * Use some karma to help decide if the outcome is successful - * We want to use up quite a bit karma at once, so scale it after - */ + /* + * Use some karma to help decide if the outcome is successful + * We want to use up quite a bit karma at once, so scale it after + */ double karma = player.useKarma(FINDING_PROBABILITY*10); // if player karma is > 0 it will always return at least 20% of FINDING_PROBABILITY*10, or karma, whichever is smaller @@ -154,17 +154,15 @@ protected void onFinished(final Player player, final boolean successful) { final String itemName = items[Rand.rand(items.length)]; final Item item = SingletonRepository.getEntityManager().getItem(itemName); int amount = 1; - if (itemName.equals("water")) - { + if (itemName.equals("water")) { /* * Bound powerful items. */ item.setBoundTo(player.getName()); - } - this.addEvent(new SoundEvent(successSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); - this.notifyWorldAboutChanges(); + this.addEvent(new SoundEvent(successSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); + this.notifyWorldAboutChanges(); player.equipOrPutOnGround(item); @@ -172,8 +170,8 @@ protected void onFinished(final Player player, final boolean successful) { + Grammar.quantityplnoun(amount, itemName, "a")+ "."); } else { - this.addEvent(new SoundEvent(failSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); - this.notifyWorldAboutChanges(); + this.addEvent(new SoundEvent(failSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); + this.notifyWorldAboutChanges(); player.sendPrivateText("Oh no! You spilled the water and let the flask fall into it. Now it's broken."); } @@ -188,9 +186,9 @@ protected void onFinished(final Player player, final boolean successful) { */ @Override protected void onStarted(final Player player) { - // Play a nice sound effect - addEvent(new SoundEvent(startSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); - notifyWorldAboutChanges(); + // Play a nice sound effect + addEvent(new SoundEvent(startSound, SOUND_RADIUS, 100, SoundLayer.AMBIENT_SOUND)); + notifyWorldAboutChanges(); // remove flask from player as they try to fill it. player.drop("flask"); diff --git a/src/games/stendhal/server/entity/npc/NPC.java b/src/games/stendhal/server/entity/npc/NPC.java index 97f012c9d87..abc101bd3df 100644 --- a/src/games/stendhal/server/entity/npc/NPC.java +++ b/src/games/stendhal/server/entity/npc/NPC.java @@ -1,14 +1,14 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003 - Marauroa * + * (C) Copyright 2003-2023 - Marauroa * *************************************************************************** *************************************************************************** - * * - * 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 2 of the License, or * - * (at your option) any later version. * - * * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + * * ***************************************************************************/ package games.stendhal.server.entity.npc; @@ -72,9 +72,9 @@ public abstract class NPC extends DressedEntity { /** * Idling between path cycles */ - protected int pauseTurns = 0; - public int pauseTurnsRemaining = 0; - protected Direction pauseDirection; + protected int pauseTurns = 0; + public int pauseTurnsRemaining = 0; + protected Direction pauseDirection; /** * Possible sound events. @@ -112,7 +112,7 @@ public NPC() { * Set the NPC's idea/thought. * * @param idea - * The idea mnemonic, or null. + * The idea mnemonic, or null. */ public void setIdea(final String idea) { if (idea != null) { @@ -187,13 +187,13 @@ public void say(final String text, final int rangeSquared) { * is not asynchronous, so this thread is blocked until a path is found. * * @param destEntity - * the destination entity + * the destination entity * @param min - * minimum distance to the destination entity + * minimum distance to the destination entity * @param max - * maximum distance to the destination entity + * maximum distance to the destination entity * @param maxPathRadius - * the maximum radius in which a path is searched + * the maximum radius in which a path is searched */ public void setMovement(final Entity destEntity, final double min, final double max, final double maxPathRadius) { @@ -219,11 +219,11 @@ public void setMovement(final Entity destEntity, final double min, final double * Set a random destination as a path. * * @param distance - * The maximum axis distance to move. + * The maximum axis distance to move. * @param x - * The origin X coordinate for placement. + * The origin X coordinate for placement. * @param y - * The origin Y coordinate for placement. + * The origin Y coordinate for placement. */ public void setRandomPathFrom(final int x, final int y, final int distance) { setUsesRandomPath(true); @@ -291,81 +291,81 @@ protected void dropItemsOn(final Corpse corpse) { * Checks if the NPC should remain stationary or begin walking */ public void checkPause() { - if (pauseTurnsRemaining == 0) { - if (hasPath()) { - setSpeed(getBaseSpeed()); - } - - applyMovement(); - } else { - if (!stopped()) { - stop(); - if (pauseDirection != null) { + if (pauseTurnsRemaining == 0) { + if (hasPath()) { + setSpeed(getBaseSpeed()); + } + + applyMovement(); + } else { + if (!stopped()) { + stop(); + if (pauseDirection != null) { setDirection(pauseDirection); } - } + } - pauseTurnsRemaining -= 1; - } + pauseTurnsRemaining -= 1; + } } @Override public void logic() { - if (atMovementRadius()) { - onOutsideMovementRadius(); - } + if (atMovementRadius()) { + onOutsideMovementRadius(); + } if (!hasPath()) { - if (logger.isDebugEnabled()) { - String title = getTitle(); - String zone = getZone().getName(); - String coords = Integer.toString(getX()) + ", " + Integer.toString(getY()); - logger.debug("Moving entity " + title + " at " + zone + " " + coords + " does not have a path"); - } + if (logger.isDebugEnabled()) { + String title = getTitle(); + String zone = getZone().getName(); + String coords = Integer.toString(getX()) + ", " + Integer.toString(getY()); + logger.debug("Moving entity " + title + " at " + zone + " " + coords + " does not have a path"); + } } maybeMakeSound(); checkPause(); - notifyWorldAboutChanges(); + notifyWorldAboutChanges(); } - /** - * Give NPC a random path - */ - public void moveRandomly() { - setRandomPathFrom(getX(), getY(), getMovementRange() / 2); - } - - @Override - public void onFinishedPath() { - super.onFinishedPath(); - - if (usesRandomPath()) { - // FIXME: There is a pause when renewing path - moveRandomly(); - } - - pauseTurnsRemaining = pauseTurns; - } - - /** - * Pause the entity when path is completed. - * Call setDirection() first to specify which - * way entity should face during pause. - * - * @param pause - * Number of turns entity should stay paused - */ - public void setPathCompletedPause(final int pause) { - //setPathCompletedPause(pause, getDirection()); - this.pauseTurns = pause; - } - - public void setPathCompletedPause(final int pause, final Direction dir) { - this.pauseTurns = pause; - this.pauseDirection = dir; - } - - /** + /** + * Give NPC a random path + */ + public void moveRandomly() { + setRandomPathFrom(getX(), getY(), getMovementRange() / 2); + } + + @Override + public void onFinishedPath() { + super.onFinishedPath(); + + if (usesRandomPath()) { + // FIXME: There is a pause when renewing path + moveRandomly(); + } + + pauseTurnsRemaining = pauseTurns; + } + + /** + * Pause the entity when path is completed. + * Call setDirection() first to specify which + * way entity should face during pause. + * + * @param pause + * Number of turns entity should stay paused + */ + public void setPathCompletedPause(final int pause) { + //setPathCompletedPause(pause, getDirection()); + this.pauseTurns = pause; + } + + public void setPathCompletedPause(final int pause, final Direction dir) { + this.pauseTurns = pause; + this.pauseDirection = dir; + } + + /** * Generate a sound event with the probability of SOUND_PROBABILITY, if * the previous sound event happened long enough ago. */ diff --git a/src/games/stendhal/server/entity/npc/PassiveNPC.java b/src/games/stendhal/server/entity/npc/PassiveNPC.java index 01555eb5dfa..d5f17ed2b8b 100644 --- a/src/games/stendhal/server/entity/npc/PassiveNPC.java +++ b/src/games/stendhal/server/entity/npc/PassiveNPC.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2019 - Arianne * + * (C) Copyright 2019-2023 - Arianne * *************************************************************************** *************************************************************************** * * @@ -49,18 +49,17 @@ protected void createPath() { */ public void reversePath() { final EntityGuide guide = getGuide(); - if (!usesRandomPath() && guide.path.isLoop()) { - List reverseNodes = guide.path.getNodeList(); - - // Sets the position for the reversed path - int reversePosition = (guide.path.getNodeList().size() - 1) - guide.getPreviousPosition(); - - Collections.reverse(reverseNodes); - setPath(new FixedPath(reverseNodes, guide.path.isLoop()), reversePosition); - } - else { - stop(); - } + if (!usesRandomPath() && guide.path.isLoop()) { + List reverseNodes = guide.path.getNodeList(); + + // Sets the position for the reversed path + int reversePosition = (guide.path.getNodeList().size() - 1) - guide.getPreviousPosition(); + + Collections.reverse(reverseNodes); + setPath(new FixedPath(reverseNodes, guide.path.isLoop()), reversePosition); + } else { + stop(); + } } /** diff --git a/src/games/stendhal/server/entity/npc/SpeakerNPC.java b/src/games/stendhal/server/entity/npc/SpeakerNPC.java index 11d422aee03..9df1142a59a 100644 --- a/src/games/stendhal/server/entity/npc/SpeakerNPC.java +++ b/src/games/stendhal/server/entity/npc/SpeakerNPC.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2022 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -674,7 +674,7 @@ public void add(final ConversationStates state, final Collection trigger * null or condition that has to return true for this transition * to be considered * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * the new state of the FSM * @param reply @@ -821,10 +821,10 @@ private boolean tell(final Player player, final String text) { public void setCurrentState(final ConversationStates state) { if (state == ConversationStates.ATTENDING) { - setIdea("attending"); - } else { - setIdea("awaiting"); - } + setIdea("attending"); + } else { + setIdea("awaiting"); + } engine.setCurrentState(state); } diff --git a/src/games/stendhal/server/entity/npc/action/SayNPCNamesForUnstartedQuestsAction.java b/src/games/stendhal/server/entity/npc/action/SayNPCNamesForUnstartedQuestsAction.java index b03bf2b80f6..e88c55ca8d2 100644 --- a/src/games/stendhal/server/entity/npc/action/SayNPCNamesForUnstartedQuestsAction.java +++ b/src/games/stendhal/server/entity/npc/action/SayNPCNamesForUnstartedQuestsAction.java @@ -1,5 +1,5 @@ /*************************************************************************** - * (C) Copyright 2003-2022 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -61,23 +61,21 @@ public void fire(final Player player, final Sentence sentence, final EventRaiser // to hold the list of npcs for each region List npcs = SingletonRepository.getStendhalQuestSystem().getNPCNamesForUnstartedQuestsInRegionForLevel(player, region); String verb = "need"; - if (npcs.size()==1) { - verb = "needs"; - } + if (npcs.size()==1) { + verb = "needs"; + } if (npcs.size()>0) { - sb.append("In " + region + " "); - sb.append(Grammar.enumerateCollectionWithHash(npcs)); - sb.append(" " + verb + " your help. "); - } else { - finishedregions.add(region); - } + sb.append("In " + region + " "); + sb.append(Grammar.enumerateCollectionWithHash(npcs)); + sb.append(" " + verb + " your help. "); + } else { + finishedregions.add(region); + } } if (finishedregions.size() > 0) { sb.append("There's no one in " + Grammar.enumerateCollection(finishedregions) + " who'd have a task you can handle, or that you haven't helped already."); } raiser.say(sb.toString().trim()); - - } @Override diff --git a/src/games/stendhal/server/entity/npc/action/SayRequiredItemAction.java b/src/games/stendhal/server/entity/npc/action/SayRequiredItemAction.java index cf0cacf52d0..190a9d77596 100644 --- a/src/games/stendhal/server/entity/npc/action/SayRequiredItemAction.java +++ b/src/games/stendhal/server/entity/npc/action/SayRequiredItemAction.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -66,7 +66,7 @@ public SayRequiredItemAction(final String questname, @Dev(defaultValue="1") fina * @param questname * name of quest-slot to check * @param message - * message with substitution defined for item: [item], [#item], or [the item] + * message with substitution defined for item: [item], [#item], or [the item] */ public SayRequiredItemAction(final String questname, final String message) { this.questname = checkNotNull(questname); diff --git a/src/games/stendhal/server/entity/npc/action/SetHallOfFameToAgeDiffAction.java b/src/games/stendhal/server/entity/npc/action/SetHallOfFameToAgeDiffAction.java index 85461c2866a..84f18ec714e 100644 --- a/src/games/stendhal/server/entity/npc/action/SetHallOfFameToAgeDiffAction.java +++ b/src/games/stendhal/server/entity/npc/action/SetHallOfFameToAgeDiffAction.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -39,7 +39,7 @@ public class SetHallOfFameToAgeDiffAction implements ChatAction { * @param questname * name of quest-slot to read the original age from * @param fametype - * the type in the hall of fame + * the type in the hall of fame */ public SetHallOfFameToAgeDiffAction(final String questname, String fametype) { this.questname = checkNotNull(questname); @@ -55,7 +55,7 @@ public SetHallOfFameToAgeDiffAction(final String questname, String fametype) { * @param index * index of sub state containing the age at start of the quest * @param fametype - * the type in the hall of fame + * the type in the hall of fame */ public SetHallOfFameToAgeDiffAction(final String questname, final int index, String fametype) { this.questname = checkNotNull(questname); diff --git a/src/games/stendhal/server/entity/npc/behaviour/impl/Behaviour.java b/src/games/stendhal/server/entity/npc/behaviour/impl/Behaviour.java index 83c730e9705..183c12c9077 100644 --- a/src/games/stendhal/server/entity/npc/behaviour/impl/Behaviour.java +++ b/src/games/stendhal/server/entity/npc/behaviour/impl/Behaviour.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2011 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -28,15 +28,15 @@ public class Behaviour extends ItemParser { public Behaviour() { - } + } public Behaviour(final Set itemNames) { - super(itemNames); - } + super(itemNames); + } public Behaviour(final String itemName) { super(itemName); - } + } /** * a chat condition that checks whether transactions are possible at all diff --git a/src/games/stendhal/server/entity/npc/behaviour/impl/MonologueBehaviour.java b/src/games/stendhal/server/entity/npc/behaviour/impl/MonologueBehaviour.java index 045e68b993d..c47605b7715 100644 --- a/src/games/stendhal/server/entity/npc/behaviour/impl/MonologueBehaviour.java +++ b/src/games/stendhal/server/entity/npc/behaviour/impl/MonologueBehaviour.java @@ -39,7 +39,7 @@ public final class MonologueBehaviour implements TurnListener { * @param repeatedText * text to repeat * @param minutes - * after how many minutes to repeat text + * after how many minutes to repeat text */ public MonologueBehaviour(final SpeakerNPC speakerNPC, final String[] repeatedText, final int minutes) { diff --git a/src/games/stendhal/server/entity/npc/behaviour/impl/TransactionBehaviour.java b/src/games/stendhal/server/entity/npc/behaviour/impl/TransactionBehaviour.java index 01dcde98446..e274c255f1a 100644 --- a/src/games/stendhal/server/entity/npc/behaviour/impl/TransactionBehaviour.java +++ b/src/games/stendhal/server/entity/npc/behaviour/impl/TransactionBehaviour.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -21,18 +21,18 @@ public abstract class TransactionBehaviour extends Behaviour { public TransactionBehaviour(final String itemName) { - super(itemName); - } + super(itemName); + } public TransactionBehaviour(final Set itemNames) { - super(itemNames); - } + super(itemNames); + } /** * Transacts the deal that is described in BehaviourResult. * * @param res - * result of the Behaviour parsing + * result of the Behaviour parsing * @param seller * The NPC who sells/buys * @param player diff --git a/src/games/stendhal/server/entity/npc/condition/KillsQuestSlotNeedUpdateCondition.java b/src/games/stendhal/server/entity/npc/condition/KillsQuestSlotNeedUpdateCondition.java index 223948b56fd..819f51f8abb 100644 --- a/src/games/stendhal/server/entity/npc/condition/KillsQuestSlotNeedUpdateCondition.java +++ b/src/games/stendhal/server/entity/npc/condition/KillsQuestSlotNeedUpdateCondition.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -49,7 +49,7 @@ public class KillsQuestSlotNeedUpdateCondition implements ChatCondition { private final int questGroupIndex; private final List creatures; private final boolean do_update; - private final Map> allcreatures; + private final Map> allcreatures; /** * Creates a new KillsQuestSlotNeedUpdateCondition. @@ -102,8 +102,8 @@ public boolean fire(final Player player, final Sentence sentence, final Entity n neededcreatures=creatures; } else { // taking from player's quest slot - final String givenEnemies = player.getQuest(questSlot, questGroupIndex); - neededcreatures=allcreatures.get(givenEnemies); + final String givenEnemies = player.getQuest(questSlot, questGroupIndex); + neededcreatures=allcreatures.get(givenEnemies); }; final String temp = player.getQuest(questSlot, questIndex); @@ -131,28 +131,27 @@ public boolean fire(final Player player, final Sentence sentence, final Entity n // check for creatures from list for(String monster:neededcreatures) { if(!mycreatures.contains(monster)) { - if(do_update) { - // adding creature name to user quest slot (tail) - toadd=toadd+","+monster+",0,0,0,0"; - logger.debug("Will add <"+monster+ - "> to player <"+player.getName()+ - "> quest <"+questSlot+ - "> slot <"+Integer.toString(questIndex)+ - ">"); - } - else { - return true; - } + if(do_update) { + // adding creature name to user quest slot (tail) + toadd=toadd+","+monster+",0,0,0,0"; + logger.debug("Will add <"+monster+ + "> to player <"+player.getName()+ + "> quest <"+questSlot+ + "> slot <"+Integer.toString(questIndex)+ + ">"); + } else { + return true; + } } } if(do_update && !toadd.isEmpty()) { - // now adding whole string to player's quest slot + // now adding whole string to player's quest slot String finalcreatures=temp+toadd; logger.debug("new player <"+player.getName()+ - "> quest <"+questSlot+ - "> slot <"+Integer.toString(questIndex)+ - "> value: ("+finalcreatures+")"); + "> quest <"+questSlot+ + "> slot <"+Integer.toString(questIndex)+ + "> value: ("+finalcreatures+")"); player.setQuest(questSlot, questIndex, finalcreatures); } @@ -180,5 +179,4 @@ public boolean equals(final Object obj) { && questSlot.equals(other.questSlot)); } - } diff --git a/src/games/stendhal/server/entity/npc/fsm/Engine.java b/src/games/stendhal/server/entity/npc/fsm/Engine.java index 9734b3d16cc..de534020928 100644 --- a/src/games/stendhal/server/entity/npc/fsm/Engine.java +++ b/src/games/stendhal/server/entity/npc/fsm/Engine.java @@ -94,7 +94,7 @@ private Transition get(final ConversationStates state, final Expression trigger, * @param condition * additional precondition * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * state after the transition * @param reply @@ -121,7 +121,7 @@ public void add(final ConversationStates state, final String triggerString, fina * @param condition * additional precondition * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * state after the transition * @param reply @@ -151,7 +151,7 @@ public void add(final ConversationStates state, final String triggerString, fina * null or condition that has to return true for this transition * to be considered * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * the new state of the FSM * @param reply @@ -183,7 +183,7 @@ public void add(final ConversationStates state, final Collection trigger * null or condition that has to return true for this transition * to be considered * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * the new state of the FSM * @param reply @@ -217,7 +217,7 @@ public void add(final ConversationStates state, final Collection trigger * null or condition that has to return true for this transition * to be considered * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * the new state of the FSM * @param reply @@ -240,12 +240,12 @@ public void addMatching(final ConversationStates state, final String triggerStri * @param triggerStrings * a list of inputs for this transition, must not be null * @param matcher - * Expression matcher + * Expression matcher * @param condition * null or condition that has to return true for this transition * to be considered * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * the new state of the FSM * @param reply @@ -275,7 +275,7 @@ public void addMatching(final ConversationStates state, final Collection * null or condition that has to return true for this transition * to be considered * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * the new state of the FSM * @param reply @@ -302,7 +302,7 @@ public void add(Collection triggerExpressions, final ConversationSta * null or condition that has to return true for this transition * to be considered * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * the new state of the FSM * @param reply @@ -500,7 +500,7 @@ public boolean stepTest(final Player player, final String text) { * to Transitions.matchesNormalizedWithCondition(). */ private static class TransitionSet extends LinkedList { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; @Override public boolean add(final Transition otherTrans) { diff --git a/src/games/stendhal/server/entity/npc/fsm/Transition.java b/src/games/stendhal/server/entity/npc/fsm/Transition.java index 752285a7079..1f8abb6407f 100644 --- a/src/games/stendhal/server/entity/npc/fsm/Transition.java +++ b/src/games/stendhal/server/entity/npc/fsm/Transition.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -71,7 +71,7 @@ public class Transition { * @param condition * additional precondition * @param secondary - * flag to mark secondary transitions to be taken into account after preferred transitions + * flag to mark secondary transitions to be taken into account after preferred transitions * @param nextState * state after the transition * @param reply @@ -104,7 +104,7 @@ public Transition(final ConversationStates currentState, final Collection args) { for (int i = 0; i < entry.getValue(); i++) { if(Rand.roll1D6()==1) { sandbox.add(creature, x + games.stendhal.common.Rand.randUniform(-RADIUS, RADIUS), - y + games.stendhal.common.Rand.randUniform(-RADIUS, RADIUS)); + y + games.stendhal.common.Rand.randUniform(-RADIUS, RADIUS)); } } } else { diff --git a/src/games/stendhal/server/script/DeepInspect.java b/src/games/stendhal/server/script/DeepInspect.java index 5070d566236..7d35226fedf 100644 --- a/src/games/stendhal/server/script/DeepInspect.java +++ b/src/games/stendhal/server/script/DeepInspect.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -168,17 +168,17 @@ private void inspect(final Player admin, final RPObject target) { // Produced items sb.append("Production:\n "); final ProducerRegister producerRegister = SingletonRepository.getProducerRegister(); - final List produceList = new LinkedList(); - - for (String food : producerRegister.getProducedItemNames("food")) { - produceList.add(food); - } - for (String drink : producerRegister.getProducedItemNames("drink")) { - produceList.add(drink); - } - for (String resource : producerRegister.getProducedItemNames("resource")) { - produceList.add(resource); - } + final List produceList = new LinkedList(); + + for (String food : producerRegister.getProducedItemNames("food")) { + produceList.add(food); + } + for (String drink : producerRegister.getProducedItemNames("drink")) { + produceList.add(drink); + } + for (String resource : producerRegister.getProducedItemNames("resource")) { + produceList.add(resource); + } for (String product : produceList) { int quant = player.getQuantityOfProducedItems(product); diff --git a/src/games/stendhal/server/script/DumpDeletionCandidates.java b/src/games/stendhal/server/script/DumpDeletionCandidates.java index 88c5b9f04ea..b96a78e6231 100644 --- a/src/games/stendhal/server/script/DumpDeletionCandidates.java +++ b/src/games/stendhal/server/script/DumpDeletionCandidates.java @@ -35,7 +35,7 @@ public class DumpDeletionCandidates extends ScriptImpl { @Override public void execute(Player admin, List args) { - admin.sendPrivateText("Important: You need to edit the script to define the highest RPObject number."); + admin.sendPrivateText("Important: You need to edit the script to define the highest RPObject number."); for (int i = 1; i < 0; i++) { RPObject object = null; try { diff --git a/src/games/stendhal/server/script/FixDM.java b/src/games/stendhal/server/script/FixDM.java index 605850f5c1c..0c618d2f492 100644 --- a/src/games/stendhal/server/script/FixDM.java +++ b/src/games/stendhal/server/script/FixDM.java @@ -1,6 +1,6 @@ /* $Id$ */ /*************************************************************************** - * (C) Copyright 2003-2010 - Stendhal * + * (C) Copyright 2003-2023 - Stendhal * *************************************************************************** *************************************************************************** * * @@ -57,8 +57,8 @@ public void execute(final Player admin, final List args) { admin.sendPrivateText(target.getTitle() + " had a deathmatch state in " + oldQuestState + " , i.e. a deathmatch was bailed or cancelled? You're going to need to fix his helmet manually, if you're sure it should be. The quest state has been fixed to #done."); target.setQuest(questName, "done"); target.sendPrivateText("Admin " + admin.getTitle() - + " changed your state of the quest '" + questName - + "' from '" + oldQuestState + "' to 'done'. They need to fix your helmet, still."); + + " changed your state of the quest '" + questName + + "' from '" + oldQuestState + "' to 'done'. They need to fix your helmet, still."); return; } else { String newQuestState = "victory;" + questpieces[1] + ";" + questpieces[2]; @@ -67,10 +67,10 @@ public void execute(final Player admin, final List args) { // notify admin and altered player target.sendPrivateText("Try claiming victory again now that " + admin.getTitle() - + " has waved a magic wand."); + + " has waved a magic wand."); admin.sendPrivateText("Changed the state of quest '" + questName - + "' from '" + oldQuestState + "' to '" + newQuestState - + "'. Told " + target.getTitle() + " to claim victory again."); + + "' from '" + oldQuestState + "' to '" + newQuestState + + "'. Told " + target.getTitle() + " to claim victory again."); } } else { admin.sendPrivateText(args.get(0) + " is not logged in"); diff --git a/src/games/stendhal/server/script/Herald.java b/src/games/stendhal/server/script/Herald.java index 3eb843fbd12..938fca4c5de 100644 --- a/src/games/stendhal/server/script/Herald.java +++ b/src/games/stendhal/server/script/Herald.java @@ -45,34 +45,34 @@ public class Herald extends ScriptImpl { // TODO: there is ability of using list of herald names, // it will add to game more fun. - public final String HeraldName = "Patrick"; + public final String HeraldName = "Patrick"; - // after some thinking, i decided to not implement here + // after some thinking, i decided to not implement here // news records to file. private final Logger logger = Logger.getLogger(Herald.class); - private final int REQUIRED_ADMINLEVEL_INFO = 100; - private final int REQUIRED_ADMINLEVEL_SET = 1000; - private final TurnNotifier turnNotifier = TurnNotifier.get(); + private final int REQUIRED_ADMINLEVEL_INFO = 100; + private final int REQUIRED_ADMINLEVEL_SET = 1000; + private final TurnNotifier turnNotifier = TurnNotifier.get(); - //private final String HaveNoTime = "Hi, I have to do my job, so I have no time to speak with you, sorry."; - private final String HiOldFriend = "Oh, you're here! Hi, my old friend, glad to see you."; - private final String TooScared = "Oh, you are crazy, sure. I can't help you, the Emperor will kill us both for that."; - private final String BadJoke = "Joke, yes? I like jokes, but not too much."; - private final String FeelBad = "Oh, I don't know what is wrong with me, I'm not feeling very well... sorry, I can't help you..."; - private final String DontUnderstand = "Sorry, I don't understand you"; - private final String InfoOnly = "Oh, I think I can trust you enough to tell you my current announcements list. "; - private final String WillHelp = "Sure, I will do for you all that you want."+ + //private final String HaveNoTime = "Hi, I have to do my job, so I have no time to speak with you, sorry."; + private final String HiOldFriend = "Oh, you're here! Hi, my old friend, glad to see you."; + private final String TooScared = "Oh, you are crazy, sure. I can't help you, the Emperor will kill us both for that."; + private final String BadJoke = "Joke, yes? I like jokes, but not too much."; + private final String FeelBad = "Oh, I don't know what is wrong with me, I'm not feeling very well... sorry, I can't help you..."; + private final String DontUnderstand = "Sorry, I don't understand you"; + private final String InfoOnly = "Oh, I think I can trust you enough to tell you my current announcements list. "; + private final String WillHelp = "Sure, I will do for you all that you want."+ " Tell me '#speech