From 8cbb3630ecce1e3f63c26c2e3f15d1bbd57f4dbe Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Fri, 20 Sep 2024 08:41:22 +0300 Subject: [PATCH 1/4] Build: Add and configure Maven Spotless plugin for formatting This ensures there is consistent formatting for the whole codebase. I opted to use Palantir's formatting standard as it's already pretty close to the codebase's format and is widely used elsewhere. --- client/pom.xml | 4 ++++ editor/pom.xml | 4 ++++ pom.xml | 21 +++++++++++++++++++++ server/pom.xml | 4 ++++ 4 files changed, 33 insertions(+) diff --git a/client/pom.xml b/client/pom.xml index 9d21ea76..f14845db 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -191,6 +191,10 @@ + + com.diffplug.spotless + spotless-maven-plugin + diff --git a/editor/pom.xml b/editor/pom.xml index a872977b..444344c2 100644 --- a/editor/pom.xml +++ b/editor/pom.xml @@ -58,6 +58,10 @@ + + com.diffplug.spotless + spotless-maven-plugin + diff --git a/pom.xml b/pom.xml index 198787c4..131d755f 100644 --- a/pom.xml +++ b/pom.xml @@ -88,6 +88,27 @@ -XX:+EnableDynamicAgentLoading + + com.diffplug.spotless + spotless-maven-plugin + 2.43.0 + + + + + + + + + + + + 4 + false + + + + diff --git a/server/pom.xml b/server/pom.xml index bb50a78c..fc7199c8 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -98,6 +98,10 @@ + + com.diffplug.spotless + spotless-maven-plugin + From 6e262ce1d8d66ac83af70b557269f1ed584f7438 Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Fri, 20 Sep 2024 08:41:22 +0300 Subject: [PATCH 2/4] Everywhere: Reformat the codebase with Spotless Done by manually running `mvn spotless:apply`. No functional changes. --- client/pom.xml | 48 +- client/src/main/java/agolf/AGolf.java | 1 - client/src/main/java/agolf/GameApplet.java | 30 +- client/src/main/java/agolf/GameContainer.java | 4 +- .../src/main/java/agolf/GolfConnection.java | 173 +++--- .../LobbySelectNumberOfPlayersFetcher.java | 2 - .../src/main/java/agolf/LobbySelectPanel.java | 58 +- client/src/main/java/agolf/Seed.java | 2 - client/src/main/java/agolf/SpriteManager.java | 30 +- .../src/main/java/agolf/SynchronizedBool.java | 3 - .../main/java/agolf/SynchronizedInteger.java | 5 +- .../src/main/java/agolf/TrackCollection.java | 1 - .../main/java/agolf/TrackTestLoginPanel.java | 20 +- .../src/main/java/agolf/game/ChatPanel.java | 35 +- .../main/java/agolf/game/ConfirmButton.java | 12 +- .../java/agolf/game/GameBackgroundCanvas.java | 243 +++++---- .../src/main/java/agolf/game/GameCanvas.java | 500 ++++++++++++------ .../java/agolf/game/GameControlPanel.java | 9 +- .../src/main/java/agolf/game/GamePanel.java | 144 +++-- .../src/main/java/agolf/game/HackedShot.java | 252 ++++++--- .../main/java/agolf/game/PlayerInfoPanel.java | 93 ++-- .../src/main/java/agolf/game/TimerThread.java | 2 - .../main/java/agolf/game/TrackInfoPanel.java | 125 ++++- .../main/java/agolf/lobby/LobbyChatPanel.java | 102 ++-- .../java/agolf/lobby/LobbyControlPanel.java | 15 +- .../agolf/lobby/LobbyDualPlayerPanel.java | 289 ++++++++-- .../agolf/lobby/LobbyGamePasswordPanel.java | 13 +- .../agolf/lobby/LobbyMultiPlayerPanel.java | 313 ++++++++--- .../src/main/java/agolf/lobby/LobbyPanel.java | 34 +- .../agolf/lobby/LobbySinglePlayerPanel.java | 143 ++++- .../agolf/lobby/LobbyTrackListAdminPanel.java | 30 +- .../main/java/com/aapeli/applet/AApplet.java | 247 +++++++-- .../main/java/com/aapeli/applet/AdCanvas.java | 17 +- .../java/com/aapeli/applet/AdCanvasText.java | 19 +- .../java/com/aapeli/applet/ContentPanel.java | 3 - .../java/com/aapeli/applet/LoadingPanel.java | 38 +- .../java/com/aapeli/applet/RetryCanvas.java | 17 +- .../main/java/com/aapeli/bigtext/BigText.java | 111 +++- .../java/com/aapeli/bigtext/MediumText.java | 11 +- .../java/com/aapeli/client/AutoPopups.java | 6 - .../java/com/aapeli/client/BadWordFilter.java | Bin 10095 -> 9831 bytes .../main/java/com/aapeli/client/Class78.java | 2 - .../main/java/com/aapeli/client/Class81.java | 6 +- .../main/java/com/aapeli/client/Class84.java | 2 - .../main/java/com/aapeli/client/Class88.java | 4 - .../main/java/com/aapeli/client/FileUtil.java | 1 - .../com/aapeli/client/FilterTextField.java | 2 - .../java/com/aapeli/client/Frame_Sub3.java | 20 +- .../com/aapeli/client/Frame_Sub3_Sub1.java | 3 - .../com/aapeli/client/Frame_Sub3_Sub3.java | 2 - .../main/java/com/aapeli/client/HtmlLine.java | 3 - .../main/java/com/aapeli/client/HtmlText.java | 2 +- .../main/java/com/aapeli/client/HtmlWord.java | 9 +- .../main/java/com/aapeli/client/IPanel.java | 20 +- .../java/com/aapeli/client/IPanel_Sub40.java | 11 +- .../java/com/aapeli/client/ImageManager.java | 28 +- .../java/com/aapeli/client/ImageResource.java | 1 - .../java/com/aapeli/client/ImageTracker.java | 16 +- .../com/aapeli/client/InputTextField.java | 10 +- .../aapeli/client/InputTextFieldListener.java | 1 - .../com/aapeli/client/LocalizationNode.java | 3 - .../java/com/aapeli/client/Panel_Sub24.java | 28 +- .../java/com/aapeli/client/Parameters.java | 27 +- .../java/com/aapeli/client/SoundClip.java | 3 +- .../java/com/aapeli/client/SoundManager.java | 22 +- .../java/com/aapeli/client/StringDraw.java | 13 +- .../java/com/aapeli/client/TextManager.java | 62 ++- .../main/java/com/aapeli/client/UrlLabel.java | 28 +- .../java/com/aapeli/colorgui/Choicer.java | 20 +- .../java/com/aapeli/colorgui/Class90.java | 2 - .../java/com/aapeli/colorgui/Class92.java | 2 - .../java/com/aapeli/colorgui/Class95.java | 2 - .../java/com/aapeli/colorgui/ColorButton.java | 45 +- .../com/aapeli/colorgui/ColorCheckbox.java | 63 ++- .../aapeli/colorgui/ColorCheckboxGroup.java | 2 +- .../java/com/aapeli/colorgui/ColorList.java | 88 ++- .../com/aapeli/colorgui/ColorListItem.java | 14 +- .../aapeli/colorgui/ColorListItemGroup.java | 1 - .../com/aapeli/colorgui/ColorListNode.java | 46 +- .../com/aapeli/colorgui/ColorSpinner.java | 31 +- .../java/com/aapeli/colorgui/ColorText.java | 1 - .../com/aapeli/colorgui/ColorTextArea.java | 46 +- .../com/aapeli/colorgui/MultiColorList.java | 53 +- .../aapeli/colorgui/MultiColorListItem.java | 7 +- .../java/com/aapeli/colorgui/RadioButton.java | 6 +- .../com/aapeli/colorgui/RadioButtonGroup.java | 4 +- .../java/com/aapeli/colorgui/RoundButton.java | 36 +- .../com/aapeli/colorgui/RoundRadioButton.java | 5 +- .../main/java/com/aapeli/colorgui/TabBar.java | 30 +- .../java/com/aapeli/colorgui/TabBarItem.java | 1 - .../com/aapeli/colorgui/TabBarListener.java | 1 - .../com/aapeli/connection/ConnCipher.java | 36 +- .../com/aapeli/connection/ConnRandom.java | 9 +- .../com/aapeli/connection/GameCipher.java | 15 +- .../aapeli/connection/GamePacketQueue.java | 1 - .../java/com/aapeli/connection/GameQueue.java | 1 - .../aapeli/connection/SocketConnection.java | 64 +-- .../connection/SocketConnectionListener.java | 1 - .../multiuser/ChallengeFloodProtection.java | 10 +- .../java/com/aapeli/multiuser/ChatBase.java | 168 ++++-- .../com/aapeli/multiuser/ChatListener.java | 1 - .../java/com/aapeli/multiuser/ChatLobby.java | 49 +- .../com/aapeli/multiuser/ChatTextArea.java | 23 +- .../aapeli/multiuser/ColorButton_Sub1.java | 3 - .../com/aapeli/multiuser/CopyChatFrame.java | 30 +- .../com/aapeli/multiuser/FloodProtection.java | 11 +- .../com/aapeli/multiuser/GlobalTextArea.java | 32 +- .../java/com/aapeli/multiuser/Languages.java | 65 ++- .../com/aapeli/multiuser/NoChallCheckbox.java | 4 +- .../aapeli/multiuser/StaffActionFrame.java | 73 +-- .../main/java/com/aapeli/multiuser/User.java | 3 - .../java/com/aapeli/multiuser/UserList.java | 114 ++-- .../com/aapeli/multiuser/UserListHandler.java | 1 - .../aapeli/multiuser/UsernameValidator.java | 1 - .../java/com/aapeli/tools/DelayRepaint.java | 1 - .../com/aapeli/tools/EncodedXmlReader.java | 8 +- .../java/com/aapeli/tools/QuickTimer.java | 6 +- .../com/aapeli/tools/QuickTimerListener.java | 1 - .../src/main/java/com/aapeli/tools/Tools.java | 9 +- .../main/java/com/aapeli/tools/XmlUnit.java | 10 +- .../main/java/org/moparforia/client/Game.java | 32 +- .../java/org/moparforia/client/Launcher.java | 66 ++- .../moparforia/client/LauncherCLITest.java | 140 ++--- .../moparforia/client/ResourceLoadTest.java | 14 +- editor/pom.xml | 8 +- .../org/moparforia/editor/EditorPanel.java | 45 +- .../java/org/moparforia/editor/IEditor.java | 7 +- .../main/java/org/moparforia/editor/Map.java | 5 +- .../java/org/moparforia/editor/MapCanvas.java | 38 +- .../org/moparforia/editor/MapCompressor.java | 23 +- .../moparforia/editor/MapDecompressor.java | 68 +-- .../org/moparforia/editor/SpriteManager.java | 157 +++--- .../main/java/org/moparforia/editor/Tile.java | 42 +- .../org/moparforia/editor/TrackEditor.java | 94 ++-- .../editor/TrackPropertiesDialog.java | 86 +-- .../editor/util/RectangleDragSelector.java | 6 +- pom.xml | 114 ++-- server/pom.xml | 8 +- .../java/org/moparforia/server/Converter.java | 8 +- .../java/org/moparforia/server/Launcher.java | 26 +- .../java/org/moparforia/server/Server.java | 80 ++- .../server/event/ClientConnectedEvent.java | 4 +- .../server/event/ClientDisconnectedEvent.java | 3 +- .../org/moparforia/server/event/Event.java | 1 - .../server/event/PacketReceivedEvent.java | 8 +- .../server/event/PlayerConnectedEvent.java | 1 - .../server/event/PlayerDisconnectEvent.java | 4 +- .../moparforia/server/event/TimedEvent.java | 1 - .../java/org/moparforia/server/game/Game.java | 36 +- .../org/moparforia/server/game/GameType.java | 6 +- .../org/moparforia/server/game/Lobby.java | 41 +- .../org/moparforia/server/game/Player.java | 11 +- .../server/game/PlayerCollection.java | 3 +- .../server/game/gametypes/GolfGame.java | 124 +++-- .../game/gametypes/golf/ChampionshipGame.java | 26 +- .../server/game/gametypes/golf/DualGame.java | 68 ++- .../server/game/gametypes/golf/MultiGame.java | 104 ++-- .../game/gametypes/golf/TrainingGame.java | 26 +- .../server/net/ClientChannelHandler.java | 29 +- .../moparforia/server/net/ClientState.java | 2 - .../org/moparforia/server/net/Packet.java | 18 +- .../moparforia/server/net/PacketDecoder.java | 4 +- .../moparforia/server/net/PacketEncoder.java | 12 +- .../moparforia/server/net/PacketHandler.java | 3 +- .../server/net/PacketHandlerFactory.java | 34 +- .../org/moparforia/server/net/PacketType.java | 5 +- .../server/net/packethandlers/EndHandler.java | 9 +- .../net/packethandlers/ErrorDebugHandler.java | 24 +- .../server/net/packethandlers/NewHandler.java | 6 +- .../net/packethandlers/PongHandler.java | 6 +- .../net/packethandlers/QuitHandler.java | 5 +- .../net/packethandlers/ReconnectHandler.java | 9 +- .../net/packethandlers/TlogHandler.java | 6 +- .../net/packethandlers/VersionHandler.java | 10 +- .../net/packethandlers/golf/ChatHandler.java | 31 +- .../net/packethandlers/golf/GameHandler.java | 8 +- .../packethandlers/golf/LanguageHandler.java | 6 +- .../golf/LobbyCreateSinglePlayerHandler.java | 7 +- .../golf/LobbyDualplayerHandler.java | 61 ++- .../net/packethandlers/golf/LobbyHandler.java | 16 +- .../golf/LobbyMultiplayerHandler.java | 27 +- .../golf/LobbySelectHandler.java | 18 +- .../net/packethandlers/golf/LoginHandler.java | 14 +- .../packethandlers/golf/LoginTypeHandler.java | 5 +- .../golf/TrackTestLoginHandler.java | 17 +- .../server/util/StockTrackUploader.java | 150 +++--- .../moparforia/server/LauncherCLITest.java | 25 +- .../org/moparforia/server/ServerTest.java | 17 +- shared/pom.xml | 8 +- .../java/org/moparforia/shared/Tools.java | 12 +- .../org/moparforia/shared/tracks/Track.java | 33 +- .../shared/tracks/TrackCategory.java | 6 +- .../shared/tracks/TrackManager.java | 11 +- .../shared/tracks/TrackSetDifficulty.java | 5 +- .../shared/tracks/TracksLocation.java | 3 +- .../filesystem/FileSystemStatsManager.java | 27 +- .../filesystem/FileSystemTrackManager.java | 45 +- .../filesystem/FileSystemTrackStats.java | 69 ++- .../lineparser/BestTimeLineParser.java | 6 +- .../lineparser/CategoriesLineParser.java | 12 +- .../lineparser/RatingsLineParser.java | 3 +- .../lineparser/ScoreInfoLineParser.java | 3 +- .../lineparser/SimpleLineParser.java | 5 +- .../lineparser/SingleArgumentLineParser.java | 5 +- .../tracks/parsers/GenericTrackParser.java | 14 +- .../tracks/parsers/InvalidTrackVersion.java | 3 +- .../shared/tracks/parsers/LineParser.java | 4 +- .../shared/tracks/parsers/TrackConverter.java | 21 +- .../tracks/parsers/TrackFileParser.java | 44 +- .../shared/tracks/parsers/TrackParser.java | 5 +- .../parsers/VersionedTrackFileParser.java | 56 +- .../shared/tracks/stats/StatsManager.java | 4 +- .../shared/tracks/stats/TrackStats.java | 17 +- .../shared/utils/CollectorUtils.java | 1 - .../shared/tracks/filesystem/Convert.java | 3 +- .../FileSystemStatsManagerTest.java | 29 +- .../FileSystemTrackManagerTest.java | 84 ++- .../shared/tracks/filesystem/VersionTest.java | 10 +- .../tracks/parsers/TrackConverterTest.java | 27 +- .../tracks/util/FileSystemExtension.java | 22 +- 220 files changed, 4560 insertions(+), 2940 deletions(-) diff --git a/client/pom.xml b/client/pom.xml index f14845db..bc5119ec 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -1,16 +1,16 @@ - + 4.0.0 - client - 2.2.1.0-BETA - org.moparforia playforia-minigolf 2.2.1.0-BETA + client + 2.2.1.0-BETA + org.moparforia.client.Launcher Playforia Minigolf Client @@ -87,16 +87,16 @@ 1.9.0 - download-osx-jre - package - - wget - - - ${project.jre.osx.link} - true - ${project.download.directory} - + download-osx-jre + + wget + + package + + ${project.jre.osx.link} + true + ${project.download.directory} + @@ -111,22 +111,22 @@ true ${project.download.directory}/${project.jre.osx.name} + + + org.apache.velocity + velocity-tools + 2.0 + + osx-build - package bundle + package - - - org.apache.velocity - velocity-tools - 2.0 - - @@ -135,10 +135,10 @@ windows-build - package launch4j + package gui ${project.build.directory}/${project.artifactId}-${project.version}.jar @@ -170,8 +170,8 @@ - plantuml-generator-maven-plugin de.elnarion.maven + plantuml-generator-maven-plugin 2.4.1 diff --git a/client/src/main/java/agolf/AGolf.java b/client/src/main/java/agolf/AGolf.java index 282934c9..44575510 100644 --- a/client/src/main/java/agolf/AGolf.java +++ b/client/src/main/java/agolf/AGolf.java @@ -5,5 +5,4 @@ public class AGolf extends GameApplet { public String getAppletInfo() { return "-= AGolf =-\nCopyright (c) 2002-2012 Playforia (www.playforia.info)\nProgramming: Pasi Laaksonen\nGraphics: Janne Matilainen"; } - } diff --git a/client/src/main/java/agolf/GameApplet.java b/client/src/main/java/agolf/GameApplet.java index 82c9f1a2..73065a72 100644 --- a/client/src/main/java/agolf/GameApplet.java +++ b/client/src/main/java/agolf/GameApplet.java @@ -10,11 +10,10 @@ import com.aapeli.client.Parameters; import com.aapeli.client.SoundManager; import com.aapeli.client.TextManager; -import org.moparforia.client.Launcher; - import java.awt.Color; import java.awt.Font; import java.awt.Image; +import org.moparforia.client.Launcher; public class GameApplet extends AApplet { @@ -41,7 +40,6 @@ public class GameApplet extends AApplet { private Image anImage3774; private boolean verbose = false; - public void initApplet(Parameters parameters) { this.syncIsValidSite = new SynchronizedBool(this.isValidSite()); this.setBackground(colourGameBackground); @@ -71,7 +69,7 @@ public void defineImages(ImageManager imageManager, String var2) { imageManager.defineImage("elements.gif"); imageManager.defineImage("special.gif"); imageManager.defineImage("balls.gif"); - imageManager.defineSharedImage("ranking-icons.gif");// TODO + imageManager.defineSharedImage("ranking-icons.gif"); // TODO imageManager.defineSharedImage("language-flags.png"); // TODO imageManager.defineSharedImage("credit-background.jpg"); // TODO imageManager.defineSharedImage("bigtext.gif"); // TODO @@ -82,7 +80,6 @@ public void defineImages(ImageManager imageManager, String var2) { imageManager.defineImage("ad" + i, this.gameContainer.adverts[i]); } } - } public void createImages() { @@ -95,12 +92,11 @@ public void connectToServer() { if (!this.gameContainer.connection.openSocketConnection()) { this.setEndState(END_ERROR_CONNECTION); } - } public void appletReady() { this.gameContainer.autoPopup = new AutoPopups(this); - //this.setGameSettings(false, 0, false, true); // disabled Bad Word Filter! + // this.setGameSettings(false, 0, false, true); // disabled Bad Word Filter! this.setGameSettings(false, 0, true, true); // enabled Bad Word Filter! this.gameContainer.trackCollection = new TrackCollection(); this.anImage3774 = this.createImage(735, 375); @@ -128,7 +124,8 @@ protected void setGameState(int state, int lobbyId) { } /** - * @param activePanel 0 == ?, 1 == login, 2 == lobby selection panel, 3 == in lobby, 4 == in game + * @param activePanel 0 == ?, 1 == login, 2 == lobby selection panel, 3 == in lobby, 4 == in + * game * @param lobbyId game type, single player == 1, dual player == 2, multiplayer == 3 */ protected void setGameState(int activePanel, int lobbyId, int lobbyExtra) { @@ -145,12 +142,14 @@ protected void setGameState(int activePanel, int lobbyId, int lobbyExtra) { } else { this.aBoolean3773 = true; } - //System.out.println(hasSession() + " " + gameContainer.synchronizedTrackTestMode.get()); + // System.out.println(hasSession() + " " + + // gameContainer.synchronizedTrackTestMode.get()); if (Launcher.isUsingCustomServer()) { String username = param.getUsername(); if (username == null) { - TrackTestLoginPanel loginPanel = new TrackTestLoginPanel(this, super.appletWidth, super.appletHeight); + TrackTestLoginPanel loginPanel = + new TrackTestLoginPanel(this, super.appletWidth, super.appletHeight); loginPanel.setLocation(0, 0); this.addToContent(loginPanel); } else { @@ -170,7 +169,8 @@ protected void setGameState(int activePanel, int lobbyId, int lobbyExtra) { if (activePanel == 2) { if (this.gameContainer.lobbySelectionPanel == null) { - this.gameContainer.lobbySelectionPanel = new LobbySelectPanel(this.gameContainer, super.appletWidth, super.appletHeight); + this.gameContainer.lobbySelectionPanel = + new LobbySelectPanel(this.gameContainer, super.appletWidth, super.appletHeight); this.gameContainer.lobbySelectionPanel.setLocation(0, 0); } @@ -198,7 +198,8 @@ protected void setGameState(int activePanel, int lobbyId, int lobbyExtra) { if (activePanel == 3) { this.gameContainer.gamePanel = null; if (this.gameContainer.lobbyPanel == null) { - this.gameContainer.lobbyPanel = new LobbyPanel(this.gameContainer, super.appletWidth, super.appletHeight); + this.gameContainer.lobbyPanel = + new LobbyPanel(this.gameContainer, super.appletWidth, super.appletHeight); this.gameContainer.lobbyPanel.setLocation(0, 0); } @@ -214,13 +215,14 @@ protected void setGameState(int activePanel, int lobbyId, int lobbyExtra) { } if (activePanel == 4) { - this.gameContainer.gamePanel = new GamePanel(this.gameContainer, super.appletWidth, super.appletHeight, this.anImage3774); + this.gameContainer.gamePanel = + new GamePanel(this.gameContainer, super.appletWidth, super.appletHeight, this.anImage3774); this.gameContainer.gamePanel.setLocation(0, 0); this.addToContent(this.gameContainer.gamePanel); } if (activePanel == 5) { - //super.param.showQuitPage(); + // super.param.showQuitPage(); System.exit(0); } else { this.contentReady(); diff --git a/client/src/main/java/agolf/GameContainer.java b/client/src/main/java/agolf/GameContainer.java index 874b0c06..7248ea6f 100644 --- a/client/src/main/java/agolf/GameContainer.java +++ b/client/src/main/java/agolf/GameContainer.java @@ -11,7 +11,7 @@ import com.aapeli.client.TextManager; import com.aapeli.tools.Tools; -public class GameContainer {// some kind of a container for everything +public class GameContainer { // some kind of a container for everything public GameApplet gameApplet; public Parameters params; @@ -33,7 +33,6 @@ public class GameContainer {// some kind of a container for everything public GamePanel gamePanel; public int graphicsQualityIndex; - public GameContainer(GameApplet gameApplet, Parameters params) { this.gameApplet = gameApplet; this.params = params; @@ -50,7 +49,6 @@ protected void destroy() { if (this.connection != null) { this.connection.disconnect(); } - } private void init() { diff --git a/client/src/main/java/agolf/GolfConnection.java b/client/src/main/java/agolf/GolfConnection.java index c4d9abfb..f16691fa 100644 --- a/client/src/main/java/agolf/GolfConnection.java +++ b/client/src/main/java/agolf/GolfConnection.java @@ -1,88 +1,87 @@ package agolf; import com.aapeli.applet.AApplet; -import com.aapeli.connection.SocketConnectionListener; import com.aapeli.connection.SocketConnection; +import com.aapeli.connection.SocketConnectionListener; import com.aapeli.tools.Tools; public class GolfConnection implements SocketConnectionListener { private static final String[] cipherCmds = new String[] { - "status\t", - "basicinfo\t", - "numberofusers\t", - "users\t", - "ownjoin\t", - "joinfromgame\t", - "say\t", - "logintype\t", - "login", - "lobbyselect\t", - "select\t", - "back", - "challenge\t", - "cancel\t", - "accept\t", - "cfail\t", - "nouser", - "nochall", - "cother", - "cbyother", - "refuse", - "afail", - "gsn\t", - "lobby\tnc\t", - "lobby\t", - "lobby", - "tracksetlist\t", - "tracksetlist", - "gamelist\t", - "full\t", - "add\t", - "change\t", - "remove\t", - "gameinfo\t", - "players", - "owninfo\t", - "game\tstarttrack\t", - "game\tstartturn\t", - "game\tstart", - "game\tbeginstroke\t", - "game\tendstroke\t", - "game\tresetvoteskip", - "game\t", - "game", - "quit", - "join\t", - "part\t", - "cspt\t", - "qmpt", - "cspc\t", - "jmpt\t", - "tracklist\t", - "Tiikoni", - "Leonardo", - "Ennaji", - "Hoeg", - "Darwin", - "Dante", - "ConTrick", - "Dewlor", - "Scope", - "SuperGenuis", - "Zwan", - "\tT !\t", - "\tcr\t", - "rnop", - "nop\t", - "error" + "status\t", + "basicinfo\t", + "numberofusers\t", + "users\t", + "ownjoin\t", + "joinfromgame\t", + "say\t", + "logintype\t", + "login", + "lobbyselect\t", + "select\t", + "back", + "challenge\t", + "cancel\t", + "accept\t", + "cfail\t", + "nouser", + "nochall", + "cother", + "cbyother", + "refuse", + "afail", + "gsn\t", + "lobby\tnc\t", + "lobby\t", + "lobby", + "tracksetlist\t", + "tracksetlist", + "gamelist\t", + "full\t", + "add\t", + "change\t", + "remove\t", + "gameinfo\t", + "players", + "owninfo\t", + "game\tstarttrack\t", + "game\tstartturn\t", + "game\tstart", + "game\tbeginstroke\t", + "game\tendstroke\t", + "game\tresetvoteskip", + "game\t", + "game", + "quit", + "join\t", + "part\t", + "cspt\t", + "qmpt", + "cspc\t", + "jmpt\t", + "tracklist\t", + "Tiikoni", + "Leonardo", + "Ennaji", + "Hoeg", + "Darwin", + "Dante", + "ConTrick", + "Dewlor", + "Scope", + "SuperGenuis", + "Zwan", + "\tT !\t", + "\tcr\t", + "rnop", + "nop\t", + "error" }; private GameContainer gameContainer; private SocketConnection socketConnection; private String lastPacketSent; private String lastPacketReceived; - protected GolfConnection(GameContainer var1) { this.gameContainer = var1; this.lastPacketSent = this.lastPacketReceived = null; @@ -95,7 +94,16 @@ public void dataReceived(String packet) { } catch (Exception e) { try { - this.writeData("error-debug\t" + this.gameContainer.gameApplet.getActivePanel() + "\t" + e.toString().trim().replace('\n', '\\') + "\t" + packet.replace('\t', '\\') + "\t" + this.lastPacketReceived.replace('\t', '\\') + "\t" + this.lastPacketSent.replace('\t', '\\')); + this.writeData("error-debug\t" + + this.gameContainer.gameApplet.getActivePanel() + + "\t" + + e.toString().trim().replace('\n', '\\') + + "\t" + + packet.replace('\t', '\\') + + "\t" + + this.lastPacketReceived.replace('\t', '\\') + + "\t" + + this.lastPacketSent.replace('\t', '\\')); } catch (Exception ex) { } @@ -115,11 +123,9 @@ public void connectionLost(int var1) { } } - public void notifyConnectionDown() { - } + public void notifyConnectionDown() {} - public void notifyConnectionUp() { - } + public void notifyConnectionUp() {} protected boolean openSocketConnection() { this.socketConnection = new SocketConnection(this.gameContainer.gameApplet, this, cipherCmds); @@ -159,9 +165,13 @@ private void handlePacket(String cmd) { this.writeData("sessionlocale\t" + var4); } - this.writeData("logintype\t" + (this.gameContainer.synchronizedTrackTestMode.get() ? "ttm" : (this.gameContainer.gameApplet.hasSession() ? "reg" : "nr"))); + this.writeData("logintype\t" + + (this.gameContainer.synchronizedTrackTestMode.get() + ? "ttm" + : (this.gameContainer.gameApplet.hasSession() ? "reg" : "nr"))); } else if (args[0].equals("basicinfo")) { - this.gameContainer.gameApplet.setGameSettings(args[1].equals("t"), Integer.parseInt(args[2]), args[3].equals("t"), args[4].equals("t")); + this.gameContainer.gameApplet.setGameSettings( + args[1].equals("t"), Integer.parseInt(args[2]), args[3].equals("t"), args[4].equals("t")); } else if (args[0].equals("broadcast")) { if (this.gameContainer.lobbyPanel != null) { this.gameContainer.lobbyPanel.broadcastMessage(args[1]); @@ -171,8 +181,7 @@ private void handlePacket(String cmd) { this.gameContainer.gamePanel.broadcastMessage(args[1]); } - } - else if (args[0].equals("status")) { + } else if (args[0].equals("status")) { if (args[1].equals("login")) { if (args.length == 2) { this.gameContainer.gameApplet.setGameState(1); @@ -232,7 +241,8 @@ else if (args[0].equals("status")) { } this.gameContainer.gameApplet.setGameState(3, 1, args[2].equals("1") ? 1 : -1); - //enables tracklistadmin this.aGameContainer_2370.gameApplet.setGameState(3, -1, 1); + // enables tracklistadmin this.aGameContainer_2370.gameApplet.setGameState(3, -1, + // 1); return; } @@ -246,8 +256,7 @@ else if (args[0].equals("status")) { this.gameContainer.lobbySelectionPanel.handlePacket(args); } else if (args[0].equals("lobby")) { this.gameContainer.lobbyPanel.handlePacket(args); - } - else if (args[0].equals("game")) { + } else if (args[0].equals("game")) { this.gameContainer.gamePanel.handlePacket(args); } } diff --git a/client/src/main/java/agolf/LobbySelectNumberOfPlayersFetcher.java b/client/src/main/java/agolf/LobbySelectNumberOfPlayersFetcher.java index d53c4d65..9e2f5683 100644 --- a/client/src/main/java/agolf/LobbySelectNumberOfPlayersFetcher.java +++ b/client/src/main/java/agolf/LobbySelectNumberOfPlayersFetcher.java @@ -7,7 +7,6 @@ class LobbySelectNumberOfPlayersFetcher implements Runnable { private final LobbySelectPanel lobbySelectPanel; private boolean running; - protected LobbySelectNumberOfPlayersFetcher(LobbySelectPanel lobbySelectPanel) { this.lobbySelectPanel = lobbySelectPanel; this.running = true; @@ -26,7 +25,6 @@ public void run() { sleepTime += 5000; } } while (this.running); - } protected void stop() { diff --git a/client/src/main/java/agolf/LobbySelectPanel.java b/client/src/main/java/agolf/LobbySelectPanel.java index d5dbead7..4554c179 100644 --- a/client/src/main/java/agolf/LobbySelectPanel.java +++ b/client/src/main/java/agolf/LobbySelectPanel.java @@ -5,7 +5,6 @@ import com.aapeli.colorgui.ColorButton; import com.aapeli.colorgui.ColorCheckbox; import com.aapeli.tools.Tools; - import java.awt.Color; import java.awt.Graphics; import java.awt.Panel; @@ -18,7 +17,7 @@ public class LobbySelectPanel extends Panel implements ActionListener, MouseListener, ItemListener { - private static final int[] lobbyJoinDelays = new int[]{1000}; + private static final int[] lobbyJoinDelays = new int[] {1000}; private static long[] lobbyJoinAvailableTimestamps; private static boolean playHidden; private GameContainer gameContainer; @@ -37,7 +36,6 @@ public class LobbySelectPanel extends Panel implements ActionListener, MouseList private int[] lobbyNumPlayers; private LobbySelectNumberOfPlayersFetcher lobbySelectNumberOfPlayersFetcher; - protected LobbySelectPanel(GameContainer gameContainer, int width, int height) { this.gameContainer = gameContainer; this.width = width; @@ -64,11 +62,14 @@ public void update(Graphics g) { g.setColor(Color.black); g.setFont(GameApplet.fontSerif26b); if (!this.gameContainer.disableSinglePlayer) { - StringDraw.drawString(g, this.gameContainer.textManager.getGame("LobbySelect_SinglePlayer"), this.width / 6, 70, 0); + StringDraw.drawString( + g, this.gameContainer.textManager.getGame("LobbySelect_SinglePlayer"), this.width / 6, 70, 0); } - StringDraw.drawString(g, this.gameContainer.textManager.getGame("LobbySelect_DualPlayer"), this.width * 3 / 6, 70, 0); - StringDraw.drawString(g, this.gameContainer.textManager.getGame("LobbySelect_MultiPlayer"), this.width * 5 / 6, 70, 0); + StringDraw.drawString( + g, this.gameContainer.textManager.getGame("LobbySelect_DualPlayer"), this.width * 3 / 6, 70, 0); + StringDraw.drawString( + g, this.gameContainer.textManager.getGame("LobbySelect_MultiPlayer"), this.width * 5 / 6, 70, 0); g.setFont(GameApplet.fontDialog12); if (!this.gameContainer.disableSinglePlayer) { this.drawNumPlayers(g, this.width / 6, this.lobbyNumPlayers[0]); @@ -78,11 +79,9 @@ public void update(Graphics g) { this.drawNumPlayers(g, this.width * 5 / 6, this.lobbyNumPlayers[2]); } - public void mouseEntered(MouseEvent evt) { - } + public void mouseEntered(MouseEvent evt) {} - public void mouseExited(MouseEvent evt) { - } + public void mouseExited(MouseEvent evt) {} public void mousePressed(MouseEvent evt) { if (evt.getY() < 390) { @@ -102,14 +101,11 @@ public void mousePressed(MouseEvent evt) { this.selectLobby(3); } } - } - public void mouseReleased(MouseEvent var1) { - } + public void mouseReleased(MouseEvent var1) {} - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} public void actionPerformed(ActionEvent evt) { playHidden = this.checkboxPlayHidden.getState(); @@ -117,10 +113,10 @@ public void actionPerformed(ActionEvent evt) { if (!this.gameContainer.disableSinglePlayer && evtSource == this.buttonSingle) { this.selectLobby(1); - /*} - else if (evtSource == this.buttonDual) { - this.selectLobby(2); - */ + /*} + else if (evtSource == this.buttonDual) { + this.selectLobby(2); + */ } else if (evtSource == this.buttonMulti) { this.selectLobby(3); } else if (evtSource == this.buttonSingleQuick) { @@ -133,7 +129,6 @@ else if (evtSource == this.buttonDual) { if (evtSource == this.buttonQuit) { this.gameContainer.gameApplet.quit(null); } - } } @@ -194,7 +189,6 @@ protected void destroyNumberOfPlayersFetcher() { this.lobbySelectNumberOfPlayersFetcher.stop(); this.lobbySelectNumberOfPlayersFetcher = null; } - } protected void handlePacket(String[] args) { @@ -205,7 +199,6 @@ protected void handlePacket(String[] args) { this.repaint(); } - } protected void writeData(String var1) { @@ -230,10 +223,11 @@ private void create() { this.add(this.buttonSingleQuick); } - //this.buttonDual = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_DualPlayer")); + // this.buttonDual = new + // ColorButton(this.gameContainer.textManager.getGame("LobbySelect_DualPlayer")); this.buttonDual = new ColorButton("Coming soon..."); this.buttonDual.setBounds(this.width * 3 / 6 - 75, this.height - 150, 150, 25); - //this.buttonDual.addActionListener(this); + // this.buttonDual.addActionListener(this); this.add(this.buttonDual); this.buttonMulti = new ColorButton(this.gameContainer.textManager.getGame("LobbySelect_MultiPlayer")); @@ -249,10 +243,14 @@ private void create() { String graphicsOptionText = this.gameContainer.textManager.getGame("LobbySelect_Gfx"); this.choicerGraphics = new Choicer(); - this.choicerGraphics.addItem(graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx0")); - this.choicerGraphics.addItem(graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx1")); - this.choicerGraphics.addItem(graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx2")); - this.choicerGraphics.addItem(graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx3")); + this.choicerGraphics.addItem( + graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx0")); + this.choicerGraphics.addItem( + graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx1")); + this.choicerGraphics.addItem( + graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx2")); + this.choicerGraphics.addItem( + graphicsOptionText + " " + this.gameContainer.textManager.getGame("LobbySelect_Gfx3")); this.choicerGraphics.select(this.gameContainer.graphicsQualityIndex); this.choicerGraphics.setBounds(this.width / 3 - 100, this.height - 10 - 50, 200, 20); this.choicerGraphics.addItemListener(this); @@ -289,12 +287,12 @@ private void drawNumPlayers(Graphics g, int x, int numPlayers) { if (numPlayers >= this.lobbyMaxPlayers && this.gameContainer.gameApplet.getPlayerAccessLevel() == 0) { StringDraw.drawString(g, this.gameContainer.textManager.getGame("LobbySelect_Full"), x, 130, 0); } - } } private boolean selectLobby(int lobbyId) { - if (this.lobbyNumPlayers[lobbyId - 1] >= this.lobbyMaxPlayers && this.gameContainer.gameApplet.getPlayerAccessLevel() == 0) { + if (this.lobbyNumPlayers[lobbyId - 1] >= this.lobbyMaxPlayers + && this.gameContainer.gameApplet.getPlayerAccessLevel() == 0) { return false; } else { this.gameContainer.gameApplet.setGameState(0); diff --git a/client/src/main/java/agolf/Seed.java b/client/src/main/java/agolf/Seed.java index 1f8615ec..d338b2bd 100644 --- a/client/src/main/java/agolf/Seed.java +++ b/client/src/main/java/agolf/Seed.java @@ -1,11 +1,9 @@ package agolf; - public class Seed { private long rnd; - public Seed(long init) { this.rnd = (init ^ 25214903917L) & (1L << 48) - 1L; } diff --git a/client/src/main/java/agolf/SpriteManager.java b/client/src/main/java/agolf/SpriteManager.java index 57b5273e..758af1f7 100644 --- a/client/src/main/java/agolf/SpriteManager.java +++ b/client/src/main/java/agolf/SpriteManager.java @@ -2,7 +2,6 @@ import agolf.game.GameBackgroundCanvas; import com.aapeli.client.ImageManager; - import java.awt.Image; public class SpriteManager { @@ -16,7 +15,6 @@ public class SpriteManager { private int[][][] specialPixelMasks; private int[][] anIntArrayArray968; - protected SpriteManager(ImageManager var1) { this.imageManager = var1; } @@ -36,7 +34,10 @@ protected void loadSprites() { Image var3 = this.imageManager.getIfAvailable(var2); if (var3 != null) { this.imageManager.unDefineImage(var2); - this.anIntArrayArray968[var1] = this.imageManager.getPixels(var3, GameBackgroundCanvas.anIntArray78[var1] * 15, GameBackgroundCanvas.anIntArray79[var1] * 15); + this.anIntArrayArray968[var1] = this.imageManager.getPixels( + var3, + GameBackgroundCanvas.anIntArray78[var1] * 15, + GameBackgroundCanvas.anIntArray79[var1] * 15); } } catch (Exception var4) { this.anIntArrayArray968[var1] = null; @@ -44,12 +45,11 @@ protected void loadSprites() { this.anIntArrayArray968[var1] = null; } } - } /** - * MOTHER FUCKING IMPORTANT. Converts the tile code into an array of pixels - * (presumably 15*15 as a 1-d array) + * MOTHER FUCKING IMPORTANT. Converts the tile code into an array of pixels (presumably 15*15 as + * a 1-d array) * * @param tileCode The Map Tile code to get pixels of. * @return An linear array of the tiles pixels init br0 @@ -79,12 +79,16 @@ public int[] getPixelsFromTileCode(int tileCode) { */ // first check if we're combining 2 elements, then element+special. - return isNoSpecial == 1 ? this.combineElementAndElement(shapeIndex, foregroundElementIndex, backgroundElementIndex) : (isNoSpecial == 2 ? this.combineElementAndSpecial(shapeIndex, foregroundElementIndex) : null); + return isNoSpecial == 1 + ? this.combineElementAndElement(shapeIndex, foregroundElementIndex, backgroundElementIndex) + : (isNoSpecial == 2 ? this.combineElementAndSpecial(shapeIndex, foregroundElementIndex) : null); } } public int[][] getPixelMask(int isSpecial, int shapeOrSpecialIndex) { - return isSpecial == 1 ? this.getShapePixelMask(shapeOrSpecialIndex) : (isSpecial == 2 ? this.getSpecialPixels(shapeOrSpecialIndex) : null); + return isSpecial == 1 + ? this.getShapePixelMask(shapeOrSpecialIndex) + : (isSpecial == 2 ? this.getSpecialPixels(shapeOrSpecialIndex) : null); } public Image[] getBalls() { @@ -95,7 +99,8 @@ public int[][] method1138() { return this.anIntArrayArray968; } - private Image[] parseSpriteSheet(String spriteSheetName, int spriteCount, int spritesPerRow, int spriteWidth, int spriteHeight) { + private Image[] parseSpriteSheet( + String spriteSheetName, int spriteCount, int spritesPerRow, int spriteWidth, int spriteHeight) { Image spriteSheet = this.imageManager.getImage(spriteSheetName); this.imageManager.unDefineImage(spriteSheetName); int sheetWidth = this.imageManager.getWidth(spriteSheet); @@ -112,7 +117,12 @@ private Image[] parseSpriteSheet(String spriteSheetName, int spriteCount, int sp for (int var15 = 0; var15 < spriteHeight; ++var15) { for (int var16 = 0; var16 < spriteWidth; ++var16) { - var14[var15 * spriteWidth + var16] = var9[(var12 * spriteHeight + var12 + 1 + var15) * sheetWidth + var13 * spriteWidth + var13 + 1 + var16]; + var14[var15 * spriteWidth + var16] = var9[ + (var12 * spriteHeight + var12 + 1 + var15) * sheetWidth + + var13 * spriteWidth + + var13 + + 1 + + var16]; } } diff --git a/client/src/main/java/agolf/SynchronizedBool.java b/client/src/main/java/agolf/SynchronizedBool.java index ee2ae7c7..c5e18ea5 100644 --- a/client/src/main/java/agolf/SynchronizedBool.java +++ b/client/src/main/java/agolf/SynchronizedBool.java @@ -1,12 +1,10 @@ package agolf; - public class SynchronizedBool { private int anInt994; private boolean aBoolean995; - public SynchronizedBool() { this(false); } @@ -37,6 +35,5 @@ private void priv_set(boolean var1) { if (Math.random() < 0.5D) { this.anInt994 = -this.anInt994 - 1; } - } } diff --git a/client/src/main/java/agolf/SynchronizedInteger.java b/client/src/main/java/agolf/SynchronizedInteger.java index b6d99f86..77d50c1b 100644 --- a/client/src/main/java/agolf/SynchronizedInteger.java +++ b/client/src/main/java/agolf/SynchronizedInteger.java @@ -1,11 +1,9 @@ package agolf; - public class SynchronizedInteger { private long n; - public SynchronizedInteger() { this(0); } @@ -20,7 +18,8 @@ public synchronized int set(int n) { } public synchronized void add(int i) { - this.set((this.n > 0L ? (int) ((2269700342778490L - this.n) / 31L) : (int) ((this.n + 110157223978885L) / 7L)) + i); + this.set((this.n > 0L ? (int) ((2269700342778490L - this.n) / 31L) : (int) ((this.n + 110157223978885L) / 7L)) + + i); } public synchronized int get() { diff --git a/client/src/main/java/agolf/TrackCollection.java b/client/src/main/java/agolf/TrackCollection.java index 58deb105..45d9eae7 100644 --- a/client/src/main/java/agolf/TrackCollection.java +++ b/client/src/main/java/agolf/TrackCollection.java @@ -6,7 +6,6 @@ public class TrackCollection { private Hashtable tracks = new Hashtable<>(); - public void addTrack(String author, String name, String data) { String key = author + "\t" + name; this.tracks.put(key, data); diff --git a/client/src/main/java/agolf/TrackTestLoginPanel.java b/client/src/main/java/agolf/TrackTestLoginPanel.java index 5dfec463..17a704ae 100644 --- a/client/src/main/java/agolf/TrackTestLoginPanel.java +++ b/client/src/main/java/agolf/TrackTestLoginPanel.java @@ -1,7 +1,6 @@ package agolf; import com.aapeli.multiuser.UsernameValidator; - import java.awt.Button; import java.awt.Color; import java.awt.Graphics; @@ -52,17 +51,15 @@ public void update(Graphics g) { public void actionPerformed(ActionEvent evt) { String username = this.textFieldName.getText().trim(); String password = this.textFieldPassword.getText().trim(); - //String password = ''; + // String password = ''; this.gameApplet.trackTestLogin(username, password); - } - public void keyPressed(KeyEvent evt) { - } + public void keyPressed(KeyEvent evt) {} private void create() { this.setLayout(null); - this.textFieldName = new TextField("");//("(name)"); + this.textFieldName = new TextField(""); // ("(name)"); this.textFieldName.setBounds(this.width / 2 - 75, this.height / 2 - 60, 150, 25); this.textFieldName.setBackground(Color.white); this.textFieldName.setForeground(Color.black); @@ -70,12 +67,12 @@ private void create() { this.add(this.textFieldName); textFieldName.requestFocus(); - this.textFieldPassword = new TextField("");//("(password)"); + this.textFieldPassword = new TextField(""); // ("(password)"); this.textFieldPassword.setBounds(this.width / 2 - 75, this.height / 2 - 10, 150, 25); this.textFieldPassword.setBackground(Color.white); this.textFieldPassword.setForeground(Color.black); textFieldPassword.setEchoChar('*'); - //this.add(this.textFieldPassword); //Don't show this field + // this.add(this.textFieldPassword); //Don't show this field this.buttonOk = new Button("OK"); this.buttonOk.setBounds(this.width / 2 - 75, this.height / 2 + 50, 75, 25); @@ -90,7 +87,7 @@ private void create() { labelName = new Label("Nickname:"); labelName.setBounds(width / 2 - 200, height / 2 - 60, 75, 25); add(labelName); - //No more labels needed + // No more labels needed // labelName2 = new Label(""); // labelName2.setBounds(width / 2 + 80, height / 2 - 60, 75, 25); // labelName2.setForeground(Color.red); @@ -104,11 +101,10 @@ private void create() { // add(labelPassword2); } - public void keyTyped(KeyEvent e) { - } + public void keyTyped(KeyEvent e) {} public void keyReleased(KeyEvent e) { - if(e.getKeyCode() == KeyEvent.VK_ENTER && buttonOk.isEnabled()) { + if (e.getKeyCode() == KeyEvent.VK_ENTER && buttonOk.isEnabled()) { actionPerformed(null); return; } diff --git a/client/src/main/java/agolf/game/ChatPanel.java b/client/src/main/java/agolf/game/ChatPanel.java index bda8df9a..182cc124 100644 --- a/client/src/main/java/agolf/game/ChatPanel.java +++ b/client/src/main/java/agolf/game/ChatPanel.java @@ -6,7 +6,6 @@ import com.aapeli.colorgui.ColorButton; import com.aapeli.multiuser.ChatBase; import com.aapeli.multiuser.ChatTextArea; - import java.awt.Font; import java.awt.Graphics; import java.awt.Panel; @@ -17,7 +16,7 @@ class ChatPanel extends Panel implements KeyListener, ActionListener { - private static final int[] anIntArray330 = new int[]{3, 1, 4, 2}; + private static final int[] anIntArray330 = new int[] {3, 1, 4, 2}; private GameContainer gameContainer; private int width; private int height; @@ -27,7 +26,6 @@ class ChatPanel extends Panel implements KeyListener, ActionListener { private int gameExtra; private boolean created; - protected ChatPanel(GameContainer gameContainer, int width, int height, int gameExtra) { this.gameContainer = gameContainer; this.width = width; @@ -60,21 +58,17 @@ public void keyPressed(KeyEvent evt) { if (evt.getSource() == this.textFieldMessage && evt.getKeyCode() == 10) { this.sendMessage(); } - } - public void keyReleased(KeyEvent evt) { - } + public void keyReleased(KeyEvent evt) {} - public void keyTyped(KeyEvent evt) { - } + public void keyTyped(KeyEvent evt) {} public void actionPerformed(ActionEvent evt) { if (this.gameExtra >= 2) { if (evt.getSource() == this.buttonSay) { this.sendMessage(); } - } } @@ -92,7 +86,7 @@ protected void addMessage(String var1) { } } - protected void addSay(int unused, String name, String message, boolean isLocalPlayer) {// /me action + protected void addSay(int unused, String name, String message, boolean isLocalPlayer) { // /me action if (this.gameExtra >= 2) { if (isLocalPlayer) { this.textAreaChat.addOwnSay(name, message); @@ -145,7 +139,6 @@ protected void printSpecialSettingstoTextArea(String comment, String settings, b this.textAreaChat.addPlainMessage("- Illusion holes"); } } - } } @@ -159,9 +152,15 @@ protected void addBroadcastMessage(String message) { private void create() { this.setLayout(null); - this.textAreaChat = new ChatTextArea(this.gameContainer.textManager, this.gameContainer.badWordFilter, this.width, this.height - 22, new Font("Dialog", Font.PLAIN, 11)); + this.textAreaChat = new ChatTextArea( + this.gameContainer.textManager, + this.gameContainer.badWordFilter, + this.width, + this.height - 22, + new Font("Dialog", Font.PLAIN, 11)); this.textAreaChat.setLocation(0, 0); - this.textFieldMessage = new InputTextField(this.gameContainer.textManager.getGame("GameChat_TypeHere"), 200, true); + this.textFieldMessage = + new InputTextField(this.gameContainer.textManager.getGame("GameChat_TypeHere"), 200, true); this.textFieldMessage.setBounds(0, this.height - 20, this.width - 70, 20); this.buttonSay = new ColorButton(this.gameContainer.textManager.getGame("GameChat_Say")); this.buttonSay.setBounds(this.width - 69, this.height - 20, 69, 20); @@ -189,10 +188,16 @@ private void method323() { } if (var1 != ChatBase.CIDR_NONE) { - ChatBase.setInputByCIDR(var1, this, this.textFieldMessage, this.buttonSay, null, this.gameContainer.textManager, this.gameContainer.params); + ChatBase.setInputByCIDR( + var1, + this, + this.textFieldMessage, + this.buttonSay, + null, + this.gameContainer.textManager, + this.gameContainer.params); } } - } private void sendMessage() { diff --git a/client/src/main/java/agolf/game/ConfirmButton.java b/client/src/main/java/agolf/game/ConfirmButton.java index c24b688a..0a918167 100644 --- a/client/src/main/java/agolf/game/ConfirmButton.java +++ b/client/src/main/java/agolf/game/ConfirmButton.java @@ -32,7 +32,6 @@ class ConfirmButton extends Canvas implements MouseMotionListener, MouseListener private boolean mouseDown; private ActionListener actionListener; - protected ConfirmButton(String text, String confirmText) { this.setFont(fontDialog12); this.setBackground(colourWhite); @@ -97,14 +96,11 @@ public void mouseReleased(MouseEvent evt) { } } - public void mouseClicked(MouseEvent evt) { - } + public void mouseClicked(MouseEvent evt) {} - public void mouseMoved(MouseEvent evt) { - } + public void mouseMoved(MouseEvent evt) {} - public void mouseDragged(MouseEvent evt) { - } + public void mouseDragged(MouseEvent evt) {} public void setFont(Font font) { this.font = font; @@ -141,7 +137,6 @@ protected void fireAction() { if (this.actionListener != null) { this.actionListener.actionPerformed(new ActionEvent(this, 1001, this.text)); } - } private Color saturate(Color colour, int by) { @@ -174,5 +169,4 @@ private Color saturate(Color colour, int by) { return new Color(red, green, blue); } - } diff --git a/client/src/main/java/agolf/game/GameBackgroundCanvas.java b/client/src/main/java/agolf/game/GameBackgroundCanvas.java index 6981d0dc..4b12538a 100644 --- a/client/src/main/java/agolf/game/GameBackgroundCanvas.java +++ b/client/src/main/java/agolf/game/GameBackgroundCanvas.java @@ -2,7 +2,6 @@ import agolf.GameApplet; import agolf.GameContainer; - import java.awt.Canvas; import java.awt.Color; import java.awt.Graphics; @@ -14,9 +13,9 @@ public class GameBackgroundCanvas extends Canvas { protected static final Color aColor75 = new Color(240, 240, 255); private static final String mapChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; private static final String defaultTrackSettings = "fttt14"; - public static final int[] anIntArray78 = new int[]{3, 5, 8, 49}; - public static final int[] anIntArray79 = new int[]{2, 3, 5, 25}; - public static final String[] aStringArray80 = new String[]{"small", "medium", "large", "full"}; + public static final int[] anIntArray78 = new int[] {3, 5, 8, 49}; + public static final int[] anIntArray79 = new int[] {2, 3, 5, 25}; + public static final String[] aStringArray80 = new String[] {"small", "medium", "large", "full"}; public static final int trackAdvertSize = aStringArray80.length; protected GameContainer gameContainer; private Image backgroundImg; @@ -48,7 +47,6 @@ protected GameBackgroundCanvas(GameContainer gameContainer, Image backgroundImag for (int var3 = 0; var3 < trackAdvertSize; ++var3) { this.anIntArrayArray97[var3][0] = this.anIntArrayArray97[var3][1] = -1; } - } public void addNotify() { @@ -70,18 +68,18 @@ public void update(Graphics g) { } protected String[] generateTrackInformation() { - return new String[]{this.trackAuthor, this.trackName, this.trackFirstBest, this.trackLastBest}; + return new String[] {this.trackAuthor, this.trackName, this.trackFirstBest, this.trackLastBest}; } protected int[][] generateTrackStatistics() { - return new int[][]{this.trackStats, this.trackRatings}; + return new int[][] {this.trackStats, this.trackRatings}; } - //this useless func is called when we get start packet - //iniatilize variables - //draws map as grass - //this.gameCanvas.createMap(16777216); - //16777216 == grass + // this useless func is called when we get start packet + // iniatilize variables + // draws map as grass + // this.gameCanvas.createMap(16777216); + // 16777216 == grass protected void createMap(int var1) { if (this.image == null) { this.image = this.createImage(735, 375); @@ -92,10 +90,10 @@ protected void createMap(int var1) { this.graphics = this.image.getGraphics(); } - Image var2 = this.gameContainer.imageManager.createImage(this.gameContainer.spriteManager.getPixelsFromTileCode(var1), 15, 15); + Image var2 = this.gameContainer.imageManager.createImage( + this.gameContainer.spriteManager.getPixelsFromTileCode(var1), 15, 15); this.graphics.setColor(aColor75); - for (int y = 0; y < 25; ++y) { for (int x = 0; x < 49; ++x) { @@ -108,7 +106,6 @@ protected void createMap(int var1) { } } - this.repaint(); } @@ -125,7 +122,9 @@ protected Image getTileAt(int var1, int var2) { if (this.gameContainer.graphicsQualityIndex >= 2) { for (int var4 = 0; var4 < 15; ++var4) { for (int var5 = 0; var5 < 15; ++var5) { - for (int var6 = 1; var6 <= 7 && var1 * 15 + var5 - var6 > 0 && var2 * 15 + var4 - var6 > 0; ++var6) { + for (int var6 = 1; + var6 <= 7 && var1 * 15 + var5 - var6 > 0 && var2 * 15 + var4 - var6 > 0; + ++var6) { if (this.castsShadow(var1 * 15 + var5 - var6, var2 * 15 + var4 - var6)) { this.shiftPixel(imageData, var5, var4, -8, 15); } @@ -148,7 +147,7 @@ protected void collisionMap(int tileX, int tileY) { int foreground = this.trackTiles[tileX][tileY] % 256; int pixel = Integer.MIN_VALUE; - if (special == 1 && (background == 19 || foreground == 19)) { // IF HAX BLOCK + if (special == 1 && (background == 19 || foreground == 19)) { // IF HAX BLOCK this.aBooleanArray98[0] = true; } else if (special == 2 && shape == 2) { this.aBooleanArray98[1] = true; @@ -165,30 +164,32 @@ protected void collisionMap(int tileX, int tileY) { } else if (special == 2) { shape += 24; pixel = mask[x][y] == 1 ? background : shape; - //24 StartPosition + // 24 StartPosition if (shape == 24) { pixel = background; } - //26 Fake Hole + // 26 Fake Hole if (shape == 26) { pixel = background; } - //Teleport Exits + // Teleport Exits if (shape == 33 || shape == 35 || shape == 37 || shape == 39) { pixel = background; } - //Bricks + // Bricks if (shape >= 40 && shape <= 43) { pixel = shape; } - //magnet + // magnet if (shape == 44) { - pixel = background != 12 && background != 13 && background != 14 && background != 15 ? shape : background; + pixel = background != 12 && background != 13 && background != 14 && background != 15 + ? shape + : background; } - //magnet repel + // magnet repel if (shape == 45) { pixel = background; } @@ -199,8 +200,6 @@ protected void collisionMap(int tileX, int tileY) { this.collisionMap[tileX * 15 + x][tileY * 15 + y] = (byte) pixel; } } - - } protected String getTrackComment() { @@ -225,26 +224,26 @@ private boolean parseMapInstruction(String map) throws Exception { StringTokenizer tokenizer = new StringTokenizer(map, "\n"); int requiredLinesParsed = 0; - while(tokenizer.hasMoreTokens()) { + while (tokenizer.hasMoreTokens()) { String line = tokenizer.nextToken(); - if(line.startsWith("V ") && Integer.parseInt(line.substring(2)) == 1) { + if (line.startsWith("V ") && Integer.parseInt(line.substring(2)) == 1) { requiredLinesParsed++; - } else if(line.startsWith("A ")) { + } else if (line.startsWith("A ")) { requiredLinesParsed++; this.trackAuthor = line.substring(2).trim(); - } else if(line.startsWith("N ")) { + } else if (line.startsWith("N ")) { requiredLinesParsed++; this.trackName = line.substring(2).trim(); - } else if(line.startsWith("C ")) { + } else if (line.startsWith("C ")) { this.trackComment = line.substring(2).trim(); - } else if(line.startsWith("S ")) { + } else if (line.startsWith("S ")) { this.trackSettings = line.substring(2).trim(); - if(trackSettings.length() != 6) { + if (trackSettings.length() != 6) { return false; } - } else if(line.startsWith("I ")) { + } else if (line.startsWith("I ")) { StringTokenizer subtknzr = new StringTokenizer(line.substring(2), ","); - if(subtknzr.countTokens() != 4) { + if (subtknzr.countTokens() != 4) { return false; } /* @@ -254,23 +253,23 @@ private boolean parseMapInstruction(String map) throws Exception { * 3 = num of players who got best num of strokes */ this.trackStats = new int[4]; - for(int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { this.trackStats[i] = Integer.parseInt(subtknzr.nextToken()); } - } else if(line.startsWith("B ")) { + } else if (line.startsWith("B ")) { this.trackFirstBest = line.substring(2); - } else if(line.startsWith("L ")) { + } else if (line.startsWith("L ")) { this.trackLastBest = line.substring(2); - } else if(line.startsWith("R ")) { + } else if (line.startsWith("R ")) { StringTokenizer subTokenizer = new StringTokenizer(line.substring(2), ","); - if(subTokenizer.countTokens() != 11) { + if (subTokenizer.countTokens() != 11) { return false; } this.trackRatings = new int[11]; - for(int i = 0; i < 11; i++) { + for (int i = 0; i < 11; i++) { this.trackRatings[i] = Integer.parseInt(subTokenizer.nextToken()); } - } else if(line.startsWith("T ")) { + } else if (line.startsWith("T ")) { requiredLinesParsed++; /* * @@ -294,7 +293,7 @@ private boolean parseMapInstruction(String map) throws Exception { int currentMapIndex = mapChars.indexOf(mapData.charAt(cursorIndex)); - if (currentMapIndex <= 2) { // if input= A,B or C + if (currentMapIndex <= 2) { // if input= A,B or C int mapcursor_one_ahead; int mapcursor_two_ahead; int mapcursor_three_ahead; @@ -311,31 +310,45 @@ private boolean parseMapInstruction(String map) throws Exception { cursorIndex += 3; } - // (currentMapIndex << 24) + (mapcursor_one_ahead << 16) + (mapcursor_two_ahead << 8) + mapcursor_three_ahead; - this.trackTiles[tileX][tileY] = currentMapIndex * 256 * 256 * 256 + mapcursor_one_ahead * 256 * 256 + mapcursor_two_ahead * 256 + mapcursor_three_ahead; + // (currentMapIndex << 24) + (mapcursor_one_ahead << 16) + + // (mapcursor_two_ahead << 8) + mapcursor_three_ahead; + this.trackTiles[tileX][tileY] = currentMapIndex * 256 * 256 * 256 + + mapcursor_one_ahead * 256 * 256 + + mapcursor_two_ahead * 256 + + mapcursor_three_ahead; } else { - if (currentMapIndex == 3) { // if input = D - this.trackTiles[tileX][tileY] = this.trackTiles[tileX - 1][tileY]; // tile to west is same as current + if (currentMapIndex == 3) { // if input = D + this.trackTiles[tileX][tileY] = + this.trackTiles[tileX - 1][tileY]; // tile to west is same as current } if (currentMapIndex == 4) { // if input = E; - this.trackTiles[tileX][tileY] = this.trackTiles[tileX][tileY - 1]; // tile to the north is same as current + this.trackTiles[tileX][tileY] = + this.trackTiles[tileX][tileY - 1]; // tile to the north is same as current } if (currentMapIndex == 5) { // if input = F; - this.trackTiles[tileX][tileY] = this.trackTiles[tileX - 1][tileY - 1]; // tile to the northwest is same as current + this.trackTiles[tileX][tileY] = + this.trackTiles[tileX - 1][tileY - 1]; // tile to the northwest is same as + // current } - if (currentMapIndex == 6) { // if input = G; - this.trackTiles[tileX][tileY] = this.trackTiles[tileX - 2][tileY]; // 2 tiles west is same as current (skip a tile to the left) + if (currentMapIndex == 6) { // if input = G; + this.trackTiles[tileX][tileY] = + this.trackTiles[tileX - 2][tileY]; // 2 tiles west is same as current (skip a + // tile to the left) } if (currentMapIndex == 7) { // if input = H - this.trackTiles[tileX][tileY] = this.trackTiles[tileX][tileY - 2]; // 2 tiles north is same as current (skip the tile above) + this.trackTiles[tileX][tileY] = + this.trackTiles[tileX][tileY - 2]; // 2 tiles north is same as current + // (skip the tile above) } if (currentMapIndex == 8) { // if input= I - this.trackTiles[tileX][tileY] = this.trackTiles[tileX - 2][tileY - 2]; // 2 tiles northwest is same as current (skip the diagonal) + this.trackTiles[tileX][tileY] = + this.trackTiles[tileX - 2][tileY - 2]; // 2 tiles northwest is same as + // current (skip the diagonal) } ++cursorIndex; @@ -360,13 +373,15 @@ private boolean parseMapInstruction(String map) throws Exception { for (int var13 = 0; var13 < var12; ++var13) { var14 = mapChars.indexOf(mapData.charAt(var13 * 5)); - this.anIntArrayArray97[var14][0] = Integer.parseInt(mapData.substring(var13 * 5 + 1, var13 * 5 + 3)); - this.anIntArrayArray97[var14][1] = Integer.parseInt(mapData.substring(var13 * 5 + 3, var13 * 5 + 5)); + this.anIntArrayArray97[var14][0] = + Integer.parseInt(mapData.substring(var13 * 5 + 1, var13 * 5 + 3)); + this.anIntArrayArray97[var14][1] = + Integer.parseInt(mapData.substring(var13 * 5 + 3, var13 * 5 + 5)); } } } } - if(requiredLinesParsed != 4) { + if (requiredLinesParsed != 4) { return false; } @@ -446,14 +461,14 @@ private void checkSolids() { this.collisionMap(x, y); } } - } private void drawMap() { int[] mapPixels = new int[275625]; int[] currentTileImageData = null; int oldTile = -1; - boolean trackTestMode = this.gameContainer.synchronizedTrackTestMode.get(); //controls when to draw starting positions + boolean trackTestMode = + this.gameContainer.synchronizedTrackTestMode.get(); // controls when to draw starting positions int currentTile; int yPixels; @@ -462,7 +477,6 @@ private void drawMap() { for (int tileY = 0; tileY < 25; ++tileY) { for (int tileX = 0; tileX < 49; ++tileX) { - if (this.trackTiles[tileX][tileY] != oldTile) { currentTile = this.trackTiles[tileX][tileY]; @@ -472,30 +486,35 @@ private void drawMap() { int background = currentTile / 256 % 256; if (specialStatus == 2) { - //16777216 == blank tile with grass - //34144256 == teleport blue exit with grass - //34078720 == teleport start with grass - + // 16777216 == blank tile with grass + // 34144256 == teleport blue exit with grass + // 34078720 == teleport start with grass - //0:false => mines invisible 0:true => mines visible + // 0:false => mines invisible 0:true => mines visible - if (!this.trackSpecialSettings[0] && (currentTileSpecialId == 28 || currentTileSpecialId == 30)) { + if (!this.trackSpecialSettings[0] + && (currentTileSpecialId == 28 || currentTileSpecialId == 30)) { currentTile = 16777216 + background * 256; } - //1:false => magnets invisible 1:true => magnets visible + // 1:false => magnets invisible 1:true => magnets visible - if (!this.trackSpecialSettings[1] && (currentTileSpecialId == 44 || currentTileSpecialId == 45)) { + if (!this.trackSpecialSettings[1] + && (currentTileSpecialId == 44 || currentTileSpecialId == 45)) { currentTile = 16777216 + background * 256; } - //2:false => teleport colorless 2:true => normal colors + // 2:false => teleport colorless 2:true => normal colors if (!this.trackSpecialSettings[2]) { - if (currentTileSpecialId == 34 || currentTileSpecialId == 36 || currentTileSpecialId == 38) { + if (currentTileSpecialId == 34 + || currentTileSpecialId == 36 + || currentTileSpecialId == 38) { currentTile = 34078720 + background * 256; } - if (currentTileSpecialId == 35 || currentTileSpecialId == 37 || currentTileSpecialId == 39) { + if (currentTileSpecialId == 35 + || currentTileSpecialId == 37 + || currentTileSpecialId == 39) { currentTile = 34144256 + background * 256; } } @@ -505,27 +524,27 @@ private void drawMap() { oldTile = this.trackTiles[tileX][tileY]; - //draws debug points on starting positions + // draws debug points on starting positions if (trackTestMode && specialStatus == 2) { yPixels = -1; - //Starting Point common + // Starting Point common if (currentTileSpecialId == 24) { yPixels = 16777215; } - //Start blue + // Start blue if (currentTileSpecialId == 48) { yPixels = 11579647; } - //Start red + // Start red if (currentTileSpecialId == 49) { yPixels = 16752800; } - //Start yellow + // Start yellow if (currentTileSpecialId == 50) { yPixels = 16777088; } - //Start green + // Start green if (currentTileSpecialId == 51) { yPixels = 9502608; } @@ -540,10 +559,10 @@ private void drawMap() { } } - for (currentTile = 0; currentTile < 15; ++currentTile) { for (yPixels = 0; yPixels < 15; ++yPixels) { - mapPixels[(tileY * 15 + currentTile) * 735 + tileX * 15 + yPixels] = currentTileImageData[currentTile * 15 + yPixels]; + mapPixels[(tileY * 15 + currentTile) * 735 + tileX * 15 + yPixels] = + currentTileImageData[currentTile * 15 + yPixels]; } } } @@ -557,60 +576,66 @@ private void drawMap() { for (xPixels = 0; xPixels < 735; ++xPixels) { boolean var25; boolean var27; - //creates light and dark spot for solids - //top and left side is brighter - //bottom and right side is darker + // creates light and dark spot for solids + // top and left side is brighter + // bottom and right side is darker if (this.castsShadow(xPixels, yPixels)) { var25 = this.castsShadow(xPixels - 1, yPixels - 1); var27 = this.castsShadow(xPixels + 1, yPixels + 1); - if (!var25 && var27 && !this.castsShadow(xPixels, yPixels - 1) && !this.castsShadow(xPixels - 1, yPixels)) { + if (!var25 + && var27 + && !this.castsShadow(xPixels, yPixels - 1) + && !this.castsShadow(xPixels - 1, yPixels)) { this.shiftPixel(mapPixels, xPixels, yPixels, 128, 735); } else { if (!var25 && var27) { - //shift pixels towards 255/white + // shift pixels towards 255/white this.shiftPixel(mapPixels, xPixels, yPixels, 24, 735); } if (!var27 && var25) { - //shift pixels towards 0/black + // shift pixels towards 0/black this.shiftPixel(mapPixels, xPixels, yPixels, -24, 735); } } - //draws shadow + // draws shadow if (this.gameContainer.graphicsQualityIndex >= 2) { for (var13 = 1; var13 <= 7 && xPixels + var13 < 735 && yPixels + var13 < 375; ++var13) { - if (!this.castsShadow(xPixels + var13, yPixels + var13)) { //dont draw shadow on blocks + if (!this.castsShadow( + xPixels + var13, yPixels + var13)) { // dont draw shadow on blocks var14 = xPixels + var13; var15 = yPixels + var13; - //shift pixels towards black to create shadow + // shift pixels towards black to create shadow this.shiftPixel(mapPixels, var14, var15, -8, 735); } } } } - - //creates light and dark spots to teleport starts + // creates light and dark spots to teleport starts if (this.isTeleportStart(xPixels, yPixels)) { var25 = this.isTeleportStart(xPixels - 1, yPixels - 1); var27 = this.isTeleportStart(xPixels + 1, yPixels + 1); - if (!var25 && var27 && !this.isTeleportStart(xPixels, yPixels - 1) && !this.isTeleportStart(xPixels - 1, yPixels)) { + if (!var25 + && var27 + && !this.isTeleportStart(xPixels, yPixels - 1) + && !this.isTeleportStart(xPixels - 1, yPixels)) { this.shiftPixel(mapPixels, xPixels, yPixels, 16, 735); } else { if (!var25 && var27) { - //shift pixels towards 255/white + // shift pixels towards 255/white this.shiftPixel(mapPixels, xPixels, yPixels, 16, 735); } if (!var27 && var25) { - //shift pixels towards 0/black + // shift pixels towards 0/black this.shiftPixel(mapPixels, xPixels, yPixels, -16, 735); } } } - //creates grain effect on tiles + // creates grain effect on tiles if (this.gameContainer.graphicsQualityIndex >= 2) { var13 = (int) (Math.random() * 11.0D) - 5; this.shiftPixel(mapPixels, xPixels, yPixels, var13, 735); @@ -623,7 +648,9 @@ private void drawMap() { currentTile = -1; for (yPixels = trackAdvertSize - 2; yPixels >= 0 && currentTile == -1; --yPixels) { - if (this.anIntArrayArray97[yPixels][0] >= 0 && this.anIntArrayArray97[yPixels][1] >= 0 && var26[yPixels] != null) { + if (this.anIntArrayArray97[yPixels][0] >= 0 + && this.anIntArrayArray97[yPixels][1] >= 0 + && var26[yPixels] != null) { currentTile = yPixels; } } @@ -649,8 +676,12 @@ private void drawMap() { for (int var22 = var15; var22 < var15 + var19; ++var22) { for (int var23 = var14; var23 < var14 + var18; ++var23) { - if (currentTile < 3 || currentTile == 3 && this.collisionMap[var23][var22] >= 0 && this.collisionMap[var23][var22] <= 15) { - mapPixels[var22 * 735 + var23] = this.method129(mapPixels[var22 * 735 + var23], var26[currentTile][var21 * var18 + var20], var16); + if (currentTile < 3 + || currentTile == 3 + && this.collisionMap[var23][var22] >= 0 + && this.collisionMap[var23][var22] <= 15) { + mapPixels[var22 * 735 + var23] = this.method129( + mapPixels[var22 * 735 + var23], var26[currentTile][var21 * var18 + var20], var16); } ++var20; @@ -667,16 +698,26 @@ private void drawMap() { } private boolean castsShadow(int x, int y) { - //trackSpecialSettings[3] - //3:false => illusion walls shadowless 3:true => illusion walls shadows - return x >= 0 && x < 735 && y >= 0 && y < 375 ? this.collisionMap[x][y] >= 16 && this.collisionMap[x][y] <= 23 && (this.trackSpecialSettings[3] || !this.trackSpecialSettings[3] && this.collisionMap[x][y] != 19) : false; + // trackSpecialSettings[3] + // 3:false => illusion walls shadowless 3:true => illusion walls shadows + return x >= 0 && x < 735 && y >= 0 && y < 375 + ? this.collisionMap[x][y] >= 16 + && this.collisionMap[x][y] <= 23 + && (this.trackSpecialSettings[3] + || !this.trackSpecialSettings[3] && this.collisionMap[x][y] != 19) + : false; } private boolean isTeleportStart(int x, int y) { - return x >= 0 && x < 735 && y >= 0 && y < 375 ? this.collisionMap[x][y] == 32 || this.collisionMap[x][y] == 34 || this.collisionMap[x][y] == 36 || this.collisionMap[x][y] == 38 : false; + return x >= 0 && x < 735 && y >= 0 && y < 375 + ? this.collisionMap[x][y] == 32 + || this.collisionMap[x][y] == 34 + || this.collisionMap[x][y] == 36 + || this.collisionMap[x][y] == 38 + : false; } - //adds offset to r,b,g channels of pixels[x][y] then clamps the value to valid range + // adds offset to r,b,g channels of pixels[x][y] then clamps the value to valid range private void shiftPixel(int[] pixels, int x, int y, int offset, int width) { int pixel = pixels[y * width + x] & 16777215; int red = pixel / 65536 % 256; diff --git a/client/src/main/java/agolf/game/GameCanvas.java b/client/src/main/java/agolf/game/GameCanvas.java index 9498068f..e08bea07 100644 --- a/client/src/main/java/agolf/game/GameCanvas.java +++ b/client/src/main/java/agolf/game/GameCanvas.java @@ -6,7 +6,6 @@ import com.aapeli.client.Parameters; import com.aapeli.client.StringDraw; import com.aapeli.tools.Tools; - import java.awt.Color; import java.awt.Cursor; import java.awt.Font; @@ -22,7 +21,8 @@ import java.util.List; import java.util.StringTokenizer; -public class GameCanvas extends GameBackgroundCanvas implements Runnable, MouseMotionListener, MouseListener, KeyListener { +public class GameCanvas extends GameBackgroundCanvas + implements Runnable, MouseMotionListener, MouseListener, KeyListener { private static final double magicOffset = Math.sqrt(2.0D) / 2.0D; private static final int diagOffset = (int) (6.0D * magicOffset + 0.5D); @@ -57,13 +57,14 @@ public class GameCanvas extends GameBackgroundCanvas implements Runnable, MouseM private double[] speedX; private double[] speedY; private boolean[] aBooleanArray2830; - private SynchronizedBool[] onHoleSync; //not sure + private SynchronizedBool[] onHoleSync; // not sure private boolean isLocalPlayer; - private int playerNamesDisplayMode; // 0 == Hide names, 1 == Show initials, 2 == Show names, 3 == Name + clan + private int playerNamesDisplayMode; // 0 == Hide names, 1 == Show initials, 2 == Show names, 3 == + // Name + clan private boolean[] aBooleanArray2834; private String aString2835; private Seed rngSeed; - private static int[] anIntArray2837 = new int[]{Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE}; + private static int[] anIntArray2837 = new int[] {Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE}; private static int anInt2838 = 2; private int anInt2839; private Image anImage2840; @@ -73,7 +74,7 @@ public class GameCanvas extends GameBackgroundCanvas implements Runnable, MouseM private boolean norandom; // aimbot stuff - final private boolean allowCheating = false; + private final boolean allowCheating = false; private double hackedX = 0; private double hackedY = 0; private boolean isCheating = false; @@ -143,11 +144,15 @@ public void update(Graphics g) { } this.graphics.setColor(whiteColour); - this.drawPlayer(this.graphics, this.currentPlayerID, this.onHoleSync[this.currentPlayerID].get() ? 2.1666666666666665D : 0.0D); + this.drawPlayer( + this.graphics, + this.currentPlayerID, + this.onHoleSync[this.currentPlayerID].get() ? 2.1666666666666665D : 0.0D); } if (isCheating) { - graphics.fillRect((int) (hackedX - 5), (int) (hackedY - 5), 10, 10); // afaik the coords are the centre of ball + graphics.fillRect( + (int) (hackedX - 5), (int) (hackedY - 5), 10, 10); // afaik the coords are the centre of ball } g.drawImage(this.anImage2840, 0, 0, this); @@ -225,11 +230,11 @@ public void run() { if (this.aBooleanArray2830[i] && !this.onHoleSync[i].get()) { for (int j = 0; j < 10; ++j) { - //this moves player + // this moves player this.playerX[i] += this.speedX[i] * 0.1D; this.playerY[i] += this.speedY[i] * 0.1D; - //check if player is going off the map + // check if player is going off the map if (this.playerX[i] < 6.6D) { this.playerX[i] = 6.6D; } @@ -246,17 +251,24 @@ public void run() { this.playerY[i] = 367.9D; } - //checks player vs player collision + // checks player vs player collision int anotherPlayer; if (this.collisionMode == 1 && !onHole[i] && !onLiquidOrSwamp[i]) { for (anotherPlayer = 0; anotherPlayer < this.playerCount; ++anotherPlayer) { - if (i != anotherPlayer && this.aBooleanArray2830[anotherPlayer] && !this.onHoleSync[anotherPlayer].get() && !onHole[anotherPlayer] && !onLiquidOrSwamp[anotherPlayer] && this.handlePlayerCollisions(i, anotherPlayer)) { - //collision is calculated in another function this just makes it less effective + if (i != anotherPlayer + && this.aBooleanArray2830[anotherPlayer] + && !this.onHoleSync[anotherPlayer].get() + && !onHole[anotherPlayer] + && !onLiquidOrSwamp[anotherPlayer] + && this.handlePlayerCollisions(i, anotherPlayer)) { + // collision is calculated in another function this just + // makes it less effective this.speedX[i] *= 0.75D; this.speedY[i] *= 0.75D; this.speedX[anotherPlayer] *= 0.75D; this.speedY[anotherPlayer] *= 0.75D; - var24 = 0; //players moved so we reset this to make sure they move + var24 = 0; // players moved so we reset this to make sure + // they move } } } @@ -281,12 +293,19 @@ public void run() { } int teleCounter = 0; - //32 Blue Teleport Start - //34 Red Teleport Start - //36 Yellow Teleport Start - //38 Green Teleport Start + // 32 Blue Teleport Start + // 34 Red Teleport Start + // 36 Yellow Teleport Start + // 38 Green Teleport Start for (int teleportId = 32; teleportId <= 38; teleportId += 2) { - if (top == teleportId || topright == teleportId || right == teleportId || bottomright == teleportId || bottom == teleportId || bottomleft == teleportId || left == teleportId || topleft == teleportId) { + if (top == teleportId + || topright == teleportId + || right == teleportId + || bottomright == teleportId + || bottom == teleportId + || bottomleft == teleportId + || left == teleportId + || topleft == teleportId) { ++teleCounter; if (!teleported[i]) { this.handleTeleport((teleportId - 32) / 2, i, x, y); @@ -298,13 +317,26 @@ public void run() { if (teleCounter == 0) { teleported[i] = false; } - //28 Mine - //30 Big Mine + // 28 Mine + // 30 Big Mine if (center == 28 || center == 30) { this.handleMines(center == 30, i, x, y, ballGraphic, canvas); } - this.handleWallCollision(i, top, topright, right, bottomright, bottom, bottomleft, left, topleft, x, y, ballGraphic, canvas); + this.handleWallCollision( + i, + top, + topright, + right, + bottomright, + bottom, + bottomleft, + left, + topleft, + x, + y, + ballGraphic, + canvas); } boolean isDownhill = this.handleDownhill(i, center); @@ -315,8 +347,12 @@ public void run() { shouldSpinAroundHole = false; double holeSpeed; - //25 hole - if (center == 25 || super.collisionMap[x][y - 1] == 25 || super.collisionMap[x + 1][y] == 25 || super.collisionMap[x][y + 1] == 25 || super.collisionMap[x - 1][y] == 25) { + // 25 hole + if (center == 25 + || super.collisionMap[x][y - 1] == 25 + || super.collisionMap[x + 1][y] == 25 + || super.collisionMap[x][y + 1] == 25 + || super.collisionMap[x - 1][y] == 25) { holeSpeed = center == 25 ? 1.0D : 0.5D; shouldSpinAroundHole = true; int holeCounter = 0; @@ -388,7 +424,12 @@ public void run() { spinningStuckCounter[i] = 0; } - if (!isDownhill && !isAffectedByMagnet && !shouldSpinAroundHole && !onHole[i] && !onLiquidOrSwamp[i] && !onLiquid) { + if (!isDownhill + && !isAffectedByMagnet + && !shouldSpinAroundHole + && !onHole[i] + && !onLiquidOrSwamp[i] + && !onLiquid) { tempCoord2X[i] = this.playerX[i]; tempCoord2Y[i] = this.playerY[i]; } @@ -434,7 +475,12 @@ public void run() { magnetStuckCounter[i] = 0; } - if (speed < 0.075D && !isDownhill && !isAffectedByMagnet && !shouldSpinAroundHole && !onHole[i] && !onLiquidOrSwamp[i]) { + if (speed < 0.075D + && !isDownhill + && !isAffectedByMagnet + && !shouldSpinAroundHole + && !onHole[i] + && !onLiquidOrSwamp[i]) { this.speedX[i] = this.speedY[i] = 0.0D; if (center != 12 && center != 14 && center != 13 && center != 15) { ++var24; @@ -446,22 +492,22 @@ public void run() { if (onHole[i] || onLiquidOrSwamp[i]) { var10[i] += 0.1D; if (onHole[i] && var10[i] > 2.1666666666666665D || onLiquidOrSwamp[i] && var10[i] > 6.0D) { - //25 hole + // 25 hole if (center == 25) { this.onHoleSync[i].set(true); if (this.isLocalPlayer && this.playerCount > 1) { super.gameContainer.gamePanel.hideSkipButton(); } } else { - //water 12 - //water swamp 14 + // water 12 + // water swamp 14 if (center == 12 || center == 14) { this.playerX[i] = this.onShoreSetting == 0 ? tempCoordX[i] : tempCoord2X[i]; this.playerY[i] = this.onShoreSetting == 0 ? tempCoordY[i] : tempCoord2Y[i]; } - //13 acid - //15 acid swamp + // 13 acid + // 15 acid swamp if (center == 13 || center == 15) { this.resetPosition(i, false); } @@ -519,8 +565,8 @@ public void run() { } } - time = System.currentTimeMillis() - time; //time to render - long var58 = (long) (6 * this.anInt2839) - time;//fps cap ? + time = System.currentTimeMillis() - time; // time to render + long var58 = (long) (6 * this.anInt2839) - time; // fps cap ? if (var23) { if (var22) { var58 = 0L; @@ -563,13 +609,11 @@ public void mouseMoved(MouseEvent var1) { } } - this.repaint(); } @Override - public void mouseDragged(MouseEvent var1) { - } + public void mouseDragged(MouseEvent var1) {} @Override public void mouseEntered(MouseEvent var1) { @@ -595,7 +639,7 @@ public synchronized void mousePressed(MouseEvent event) { this.mouseY = y; double subtractionX = this.playerX[this.currentPlayerID] - (double) x; double subtractionY = this.playerY[this.currentPlayerID] - (double) y; - //checks if mouse is on own ball + // checks if mouse is on own ball if (Math.sqrt(subtractionX * subtractionX + subtractionY * subtractionY) >= 6.5D) { this.removeMouseMotionListener(this); this.removeMouseListener(this); @@ -603,11 +647,10 @@ public synchronized void mousePressed(MouseEvent event) { this.setCursor(cursorDefault); if (super.gameContainer.gamePanel.tryStroke(false)) { super.gameContainer.gamePanel.setBeginStroke(this.currentPlayerID, x, y, this.shootingMode); - //this.doHackedStroke(this.currentPlayerID, true, x, y, this.keyCountMod4); + // this.doHackedStroke(this.currentPlayerID, true, x, y, this.keyCountMod4); this.doStroke(this.currentPlayerID, true, x, y, this.shootingMode); } } - } } } @@ -617,12 +660,10 @@ public void mouseReleased(MouseEvent var1) { if (this.gameState == 1) { var1.consume(); } - } @Override - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} @Override public synchronized void keyPressed(KeyEvent var1) { @@ -646,12 +687,10 @@ public synchronized void keyPressed(KeyEvent var1) { } @Override - public void keyReleased(KeyEvent var1) { - } + public void keyReleased(KeyEvent var1) {} @Override - public void keyTyped(KeyEvent var1) { - } + public void keyTyped(KeyEvent var1) {} protected void init(int playerCount, int waterMode, int collisionMode) { this.playerCount = playerCount; @@ -700,7 +739,6 @@ protected boolean init(String commandLines, String playerStatuses, int gameId) { if (var11 > -1) { gameId = Integer.parseInt(currentCommand.substring(0, var11)); this.aString2835 = currentCommand.substring(var11 + 1); - } } } @@ -725,45 +763,45 @@ protected boolean init(String commandLines, String playerStatuses, int gameId) { int tile = super.trackTiles[x][y] / 65536 % 256 + 24; double screenX = (double) (x * 15) + 7.5D; double screenY = (double) (y * 15) + 7.5D; - //24 Start Position Common + // 24 Start Position Common if (tile == 24) { - double[] startPosition = new double[]{screenX, screenY}; + double[] startPosition = new double[] {screenX, screenY}; startPositions.add(startPosition); } - //48 Start Position Blue - //49 Start Position Red - //50 Start Positiono Yellow - //51 Start Position Green + // 48 Start Position Blue + // 49 Start Position Red + // 50 Start Positiono Yellow + // 51 Start Position Green if (tile >= 48 && tile <= 51) { this.resetPositionX[tile - 48] = screenX; this.resetPositionY[tile - 48] = screenY; } int teleportIndex; - //33 Teleport Exit Blue - //35 Teleport Exit Red - //37 Teleport Exit Yellow - //39 Teleport Exit Green + // 33 Teleport Exit Blue + // 35 Teleport Exit Red + // 37 Teleport Exit Yellow + // 39 Teleport Exit Green if (tile == 33 || tile == 35 || tile == 37 || tile == 39) { teleportIndex = (tile - 33) / 2; - double[] teleporter = new double[]{screenX, screenY}; + double[] teleporter = new double[] {screenX, screenY}; this.teleportExists[teleportIndex].add(teleporter); } - //33 Teleport Start Blue - //35 Teleport Start Red - //37 Teleport Start Yellow - //39 Teleport Start Green + // 33 Teleport Start Blue + // 35 Teleport Start Red + // 37 Teleport Start Yellow + // 39 Teleport Start Green if (tile == 32 || tile == 34 || tile == 36 || tile == 38) { teleportIndex = (tile - 32) / 2; - double[] teleporter = new double[]{screenX, screenY}; + double[] teleporter = new double[] {screenX, screenY}; this.teleportStarts[teleportIndex].add(teleporter); } - //44 magnet attract - //45 magnet repel + // 44 magnet attract + // 45 magnet repel if (tile == 44 || tile == 45) { - int[] magnet = new int[]{(int) (screenX + 0.5D), (int) (screenY + 0.5D), tile}; + int[] magnet = new int[] {(int) (screenX + 0.5D), (int) (screenY + 0.5D), tile}; magnets.add(magnet); } } @@ -785,7 +823,7 @@ protected boolean init(String commandLines, String playerStatuses, int gameId) { } else { this.magnetMap = new short[147][75][2]; - //magnet map is 5times smaller than real one + // magnet map is 5times smaller than real one for (int magnetLoopY = 2; magnetLoopY < 375; magnetLoopY += 5) { for (int magnetLoopX = 2; magnetLoopX < 735; magnetLoopX += 5) { double forceTempY = 0.0D; @@ -802,7 +840,7 @@ protected boolean init(String commandLines, String playerStatuses, int gameId) { force = 127.0D - force; forceTemp2X = (forceTemp2X < 0.0D ? -1.0D : 1.0D) * force * var35; forcetemp2Y = (forcetemp2Y < 0.0D ? -1.0D : 1.0D) * force * (1.0D - var35); - //45 Magnet Repel + // 45 Magnet Repel if (magnet[2] == 45) { forceTemp2X = -forceTemp2X; forcetemp2Y = -forcetemp2Y; @@ -815,7 +853,7 @@ protected boolean init(String commandLines, String playerStatuses, int gameId) { int forceX = (int) forceTempX; int forceY = (int) forceTempY; - //clamp value to what short can hold + // clamp value to what short can hold if (forceX < -0x7ff) { forceX = -0x7ff; } @@ -985,8 +1023,9 @@ private void doHackedStroke(int playerId, boolean isLocalPlayer, int mouseX, int boolean temp_aBoolean2832 = this.isLocalPlayer; boolean temp_aBoolean2843 = this.aBoolean2843; Seed temp_aSeed_2836 = rngSeed.clone(); - // int temp_anInt2816 = super.gameContainer.gamePanel.isValidPlayerID(playerId) ? playerId : -1; - int temp_anInt2816 = playerId; + // int temp_anInt2816 = super.gameContainer.gamePanel.isValidPlayerID(playerId) ? playerId : + // -1; + int temp_anInt2816 = playerId; double[] var6 = getStrokePower(playerId, mouseX, mouseY); temp_aDoubleArray2828[playerId] = var6[0]; @@ -1009,21 +1048,44 @@ private void doHackedStroke(int playerId, boolean isLocalPlayer, int mouseX, int temp_aDoubleArray2829[playerId] = var7; } - var7 = Math.sqrt(temp_aDoubleArray2828[playerId] * temp_aDoubleArray2828[playerId] + temp_aDoubleArray2829[playerId] * temp_aDoubleArray2829[playerId]); + var7 = Math.sqrt(temp_aDoubleArray2828[playerId] * temp_aDoubleArray2828[playerId] + + temp_aDoubleArray2829[playerId] * temp_aDoubleArray2829[playerId]); double var9 = var7 / 6.5D; var9 *= var9; temp_aDoubleArray2828[playerId] += var9 * ((double) (temp_aSeed_2836.next() % 50001) / 100000.0D - 0.25D); temp_aDoubleArray2829[playerId] += var9 * ((double) (temp_aSeed_2836.next() % 50001) / 100000.0D - 0.25D); temp_aBoolean2832 = isLocalPlayer; - //this.gameState = 2; + // this.gameState = 2; temp_aBoolean2843 = false; - - HackedShot hs = new HackedShot(playerCount, onShoreSetting, collisionMode, currentPlayerID, temp_anInt2816, - startPositionX, startPositionY, bounciness, somethingSpeedThing, resetPositionX, resetPositionY, - teleportStarts, teleportExists, magnetMap, playerX, playerY, temp_aDoubleArray2828, - temp_aDoubleArray2829, aBooleanArray2830, onHoleSync, temp_aBoolean2832, aBooleanArray2834, - temp_aSeed_2836, anInt2839, temp_aBoolean2843, super.collisionMap, super.trackTiles); + HackedShot hs = new HackedShot( + playerCount, + onShoreSetting, + collisionMode, + currentPlayerID, + temp_anInt2816, + startPositionX, + startPositionY, + bounciness, + somethingSpeedThing, + resetPositionX, + resetPositionY, + teleportStarts, + teleportExists, + magnetMap, + playerX, + playerY, + temp_aDoubleArray2828, + temp_aDoubleArray2829, + aBooleanArray2830, + onHoleSync, + temp_aBoolean2832, + aBooleanArray2834, + temp_aSeed_2836, + anInt2839, + temp_aBoolean2843, + super.collisionMap, + super.trackTiles); Thread hack = new Thread(hs); hack.start(); try { @@ -1038,7 +1100,6 @@ private void doHackedStroke(int playerId, boolean isLocalPlayer, int mouseX, int hack = null; } - private void resetPosition(int playerId, boolean gameStart) { if (this.resetPositionX[playerId] >= 0.0D && this.resetPositionX[playerId] >= 0.0D) { this.playerX[playerId] = this.resetPositionX[playerId]; @@ -1070,7 +1131,9 @@ private double[] getStrokePower(int playerId, int mouseX, int mouseY) { } double var12 = var10 / sqrtXY; - double[] power = new double[]{((double) mouseX - this.playerX[playerId]) * var12, ((double) mouseY - this.playerY[playerId]) * var12}; + double[] power = new double[] { + ((double) mouseX - this.playerX[playerId]) * var12, ((double) mouseY - this.playerY[playerId]) * var12 + }; return power; } @@ -1169,18 +1232,68 @@ private double calculateFriction(int tile, double speed) { } private double getFriction(int var1) { - return var1 != 0 && (var1 < 4 || var1 > 11) && var1 != 19 && var1 != 47 ? (var1 == 1 ? 0.92D : (var1 == 2 ? 0.8D : (var1 != 3 && var1 != 32 && var1 != 34 && var1 != 36 && var1 != 38 ? (var1 != 12 && var1 != 13 ? (var1 != 14 && var1 != 15 ? (var1 >= 20 && var1 <= 23 ? 0.995D : (var1 == 25 ? 0.96D : (var1 != 28 && var1 != 30 ? (var1 != 29 && var1 != 31 ? (var1 == 44 ? 0.9D : 1.0D) : 0.9D) : 1.0D))) : 0.95D) : 0.0D) : 0.9975D))) : 0.9935D; + return var1 != 0 && (var1 < 4 || var1 > 11) && var1 != 19 && var1 != 47 + ? (var1 == 1 + ? 0.92D + : (var1 == 2 + ? 0.8D + : (var1 != 3 && var1 != 32 && var1 != 34 && var1 != 36 && var1 != 38 + ? (var1 != 12 && var1 != 13 + ? (var1 != 14 && var1 != 15 + ? (var1 >= 20 && var1 <= 23 + ? 0.995D + : (var1 == 25 + ? 0.96D + : (var1 != 28 && var1 != 30 + ? (var1 != 29 && var1 != 31 + ? (var1 == 44 ? 0.9D : 1.0D) + : 0.9D) + : 1.0D))) + : 0.95D) + : 0.0D) + : 0.9975D))) + : 0.9935D; } - private void handleWallCollision(int playerId, int top, int topright, int right, int bottomright, int bottom, int bottomleft, int left, int topleft, int x, int y, Graphics ball, Graphics canvas) { + private void handleWallCollision( + int playerId, + int top, + int topright, + int right, + int bottomright, + int bottom, + int bottomleft, + int left, + int topleft, + int x, + int y, + Graphics ball, + Graphics canvas) { boolean topCollide = top >= 16 && top <= 23 && top != 19 || top == 27 || top >= 40 && top <= 43 || top == 46; - boolean toprightCollide = topright >= 16 && topright <= 23 && topright != 19 || topright == 27 || topright >= 40 && topright <= 43 || topright == 46; - boolean rightCollide = right >= 16 && right <= 23 && right != 19 || right == 27 || right >= 40 && right <= 43 || right == 46; - boolean var17 = bottomright >= 16 && bottomright <= 23 && bottomright != 19 || bottomright == 27 || bottomright >= 40 && bottomright <= 43 || bottomright == 46; - boolean bottomCollide = bottom >= 16 && bottom <= 23 && bottom != 19 || bottom == 27 || bottom >= 40 && bottom <= 43 || bottom == 46; - boolean bottomleftCollide = bottomleft >= 16 && bottomleft <= 23 && bottomleft != 19 || bottomleft == 27 || bottomleft >= 40 && bottomleft <= 43 || bottomleft == 46; - boolean leftcollide = left >= 16 && left <= 23 && left != 19 || left == 27 || left >= 40 && left <= 43 || left == 46; - boolean topleftCollide = topleft >= 16 && topleft <= 23 && topleft != 19 || topleft == 27 || topleft >= 40 && topleft <= 43 || topleft == 46; + boolean toprightCollide = topright >= 16 && topright <= 23 && topright != 19 + || topright == 27 + || topright >= 40 && topright <= 43 + || topright == 46; + boolean rightCollide = + right >= 16 && right <= 23 && right != 19 || right == 27 || right >= 40 && right <= 43 || right == 46; + boolean var17 = bottomright >= 16 && bottomright <= 23 && bottomright != 19 + || bottomright == 27 + || bottomright >= 40 && bottomright <= 43 + || bottomright == 46; + boolean bottomCollide = bottom >= 16 && bottom <= 23 && bottom != 19 + || bottom == 27 + || bottom >= 40 && bottom <= 43 + || bottom == 46; + boolean bottomleftCollide = bottomleft >= 16 && bottomleft <= 23 && bottomleft != 19 + || bottomleft == 27 + || bottomleft >= 40 && bottomleft <= 43 + || bottomleft == 46; + boolean leftcollide = + left >= 16 && left <= 23 && left != 19 || left == 27 || left >= 40 && left <= 43 || left == 46; + boolean topleftCollide = topleft >= 16 && topleft <= 23 && topleft != 19 + || topleft == 27 + || topleft >= 40 && topleft <= 43 + || topleft == 46; if (topCollide && top == 20) { topCollide = false; } @@ -1261,22 +1374,42 @@ private void handleWallCollision(int playerId, int top, int topright, int right, topCollide = false; } - if (topCollide && toprightCollide && rightCollide && (top < 20 || top > 23) && (topright < 20 || topright > 23) && (right < 20 || right > 23)) { + if (topCollide + && toprightCollide + && rightCollide + && (top < 20 || top > 23) + && (topright < 20 || topright > 23) + && (right < 20 || right > 23)) { rightCollide = false; topCollide = false; } - if (rightCollide && var17 && bottomCollide && (right < 20 || right > 23) && (bottomright < 20 || bottomright > 23) && (bottom < 20 || bottom > 23)) { + if (rightCollide + && var17 + && bottomCollide + && (right < 20 || right > 23) + && (bottomright < 20 || bottomright > 23) + && (bottom < 20 || bottom > 23)) { bottomCollide = false; rightCollide = false; } - if (bottomCollide && bottomleftCollide && leftcollide && (bottom < 20 || bottom > 23) && (bottomleft < 20 || bottomleft > 23) && (left < 20 || left > 23)) { + if (bottomCollide + && bottomleftCollide + && leftcollide + && (bottom < 20 || bottom > 23) + && (bottomleft < 20 || bottomleft > 23) + && (left < 20 || left > 23)) { leftcollide = false; bottomCollide = false; } - if (leftcollide && topleftCollide && topCollide && (left < 20 || left > 23) && (topleft < 20 || topleft > 23) && (top < 20 || top > 23)) { + if (leftcollide + && topleftCollide + && topCollide + && (left < 20 || left > 23) + && (topleft < 20 || topleft > 23) + && (top < 20 || top > 23)) { topCollide = false; leftcollide = false; } @@ -1284,29 +1417,61 @@ private void handleWallCollision(int playerId, int top, int topright, int right, double speedEffect; if (!topCollide && !rightCollide && !bottomCollide && !leftcollide) { double temp; - if (toprightCollide && (this.speedX[playerId] > 0.0D && this.speedY[playerId] < 0.0D || this.speedX[playerId] < 0.0D && this.speedY[playerId] < 0.0D && -this.speedY[playerId] > -this.speedX[playerId] || this.speedX[playerId] > 0.0D && this.speedY[playerId] > 0.0D && this.speedX[playerId] > this.speedY[playerId])) { - speedEffect = this.getSpeedEffect(topright, playerId, x + diagOffset, y - diagOffset, ball, canvas, 1, -1); + if (toprightCollide + && (this.speedX[playerId] > 0.0D && this.speedY[playerId] < 0.0D + || this.speedX[playerId] < 0.0D + && this.speedY[playerId] < 0.0D + && -this.speedY[playerId] > -this.speedX[playerId] + || this.speedX[playerId] > 0.0D + && this.speedY[playerId] > 0.0D + && this.speedX[playerId] > this.speedY[playerId])) { + speedEffect = + this.getSpeedEffect(topright, playerId, x + diagOffset, y - diagOffset, ball, canvas, 1, -1); temp = this.speedX[playerId]; this.speedX[playerId] = this.speedY[playerId] * speedEffect; this.speedY[playerId] = temp * speedEffect; } - if (var17 && (this.speedX[playerId] > 0.0D && this.speedY[playerId] > 0.0D || this.speedX[playerId] > 0.0D && this.speedY[playerId] < 0.0D && this.speedX[playerId] > -this.speedY[playerId] || this.speedX[playerId] < 0.0D && this.speedY[playerId] > 0.0D && this.speedY[playerId] > -this.speedX[playerId])) { - speedEffect = this.getSpeedEffect(bottomright, playerId, x + diagOffset, y + diagOffset, ball, canvas, 1, 1); + if (var17 + && (this.speedX[playerId] > 0.0D && this.speedY[playerId] > 0.0D + || this.speedX[playerId] > 0.0D + && this.speedY[playerId] < 0.0D + && this.speedX[playerId] > -this.speedY[playerId] + || this.speedX[playerId] < 0.0D + && this.speedY[playerId] > 0.0D + && this.speedY[playerId] > -this.speedX[playerId])) { + speedEffect = + this.getSpeedEffect(bottomright, playerId, x + diagOffset, y + diagOffset, ball, canvas, 1, 1); temp = this.speedX[playerId]; this.speedX[playerId] = -this.speedY[playerId] * speedEffect; this.speedY[playerId] = -temp * speedEffect; } - if (bottomleftCollide && (this.speedX[playerId] < 0.0D && this.speedY[playerId] > 0.0D || this.speedX[playerId] > 0.0D && this.speedY[playerId] > 0.0D && this.speedY[playerId] > this.speedX[playerId] || this.speedX[playerId] < 0.0D && this.speedY[playerId] < 0.0D && -this.speedX[playerId] > -this.speedY[playerId])) { - speedEffect = this.getSpeedEffect(bottomleft, playerId, x - diagOffset, y + diagOffset, ball, canvas, -1, 1); + if (bottomleftCollide + && (this.speedX[playerId] < 0.0D && this.speedY[playerId] > 0.0D + || this.speedX[playerId] > 0.0D + && this.speedY[playerId] > 0.0D + && this.speedY[playerId] > this.speedX[playerId] + || this.speedX[playerId] < 0.0D + && this.speedY[playerId] < 0.0D + && -this.speedX[playerId] > -this.speedY[playerId])) { + speedEffect = + this.getSpeedEffect(bottomleft, playerId, x - diagOffset, y + diagOffset, ball, canvas, -1, 1); temp = this.speedX[playerId]; this.speedX[playerId] = this.speedY[playerId] * speedEffect; this.speedY[playerId] = temp * speedEffect; } - if (topleftCollide && (this.speedX[playerId] < 0.0D && this.speedY[playerId] < 0.0D || this.speedX[playerId] < 0.0D && this.speedY[playerId] > 0.0D && -this.speedX[playerId] > this.speedY[playerId] || this.speedX[playerId] > 0.0D && this.speedY[playerId] < 0.0D && -this.speedY[playerId] > this.speedX[playerId])) { - speedEffect = this.getSpeedEffect(topleft, playerId, x - diagOffset, y - diagOffset, ball, canvas, -1, -1); + if (topleftCollide + && (this.speedX[playerId] < 0.0D && this.speedY[playerId] < 0.0D + || this.speedX[playerId] < 0.0D + && this.speedY[playerId] > 0.0D + && -this.speedX[playerId] > this.speedY[playerId] + || this.speedX[playerId] > 0.0D + && this.speedY[playerId] < 0.0D + && -this.speedY[playerId] > this.speedX[playerId])) { + speedEffect = + this.getSpeedEffect(topleft, playerId, x - diagOffset, y - diagOffset, ball, canvas, -1, -1); temp = this.speedX[playerId]; this.speedX[playerId] = -this.speedY[playerId] * speedEffect; this.speedY[playerId] = -temp * speedEffect; @@ -1336,37 +1501,38 @@ private void handleWallCollision(int playerId, int top, int topright, int right, return; } } - } - private double getSpeedEffect(int tileId, int playerId, int x, int y, Graphics ball, Graphics canvas, int offsetX, int offsetY) { - //16 Block + private double getSpeedEffect( + int tileId, int playerId, int x, int y, Graphics ball, Graphics canvas, int offsetX, int offsetY) { + // 16 Block if (tileId == 16) { return 0.81D; - //17 Sticky Block + // 17 Sticky Block } else if (tileId == 17) { return 0.05D; - //18 Bouncy Block + // 18 Bouncy Block } else if (tileId == 18) { if (this.bounciness <= 0.0D) { return 0.84D; } else { this.bounciness -= 0.01D; - double speed = Math.sqrt(this.speedX[playerId] * this.speedX[playerId] + this.speedY[playerId] * this.speedY[playerId]); + double speed = Math.sqrt( + this.speedX[playerId] * this.speedX[playerId] + this.speedY[playerId] * this.speedY[playerId]); return this.bounciness * 6.5D / speed; } - //20 Oneway North - //21 Oneway East - //22 Oneway South - //23 Oneway West + // 20 Oneway North + // 21 Oneway East + // 22 Oneway South + // 23 Oneway West } else if (tileId != 20 && tileId != 21 && tileId != 22 && tileId != 23) { - //27 Moveable Block - //46 Sunkable Moveable Block + // 27 Moveable Block + // 46 Sunkable Moveable Block if (tileId != 27 && tileId != 46) { - //40 Full Breakable Block - //41 Three Quater Breakable Block - //42 Half Breakable Block - //43 Quater Breakable Block + // 40 Full Breakable Block + // 41 Three Quater Breakable Block + // 42 Half Breakable Block + // 43 Quater Breakable Block if (tileId != 40 && tileId != 41 && tileId != 42 && tileId != 43) { return 1.0D; } else { @@ -1398,12 +1564,13 @@ private void handleTeleport(int teleportId, int playerId, int x, int y) { if (startLen >= 2) { int var14 = 0; - //????? + // ????? do { i = startLen - 1; random = this.rngSeed.next() % (i + 1); teleportPos = this.teleportStarts[teleportId].get(random); - if (Math.abs(teleportPos[0] - (double) x) >= 15.0D || Math.abs(teleportPos[1] - (double) y) >= 15.0D) { + if (Math.abs(teleportPos[0] - (double) x) >= 15.0D + || Math.abs(teleportPos[1] - (double) y) >= 15.0D) { this.playerX[playerId] = teleportPos[0]; this.playerY[playerId] = teleportPos[1]; return; @@ -1436,34 +1603,42 @@ private void handleTeleport(int teleportId, int playerId, int x, int y) { random = this.rngSeed.next() % (var12 + 1); } - //finally move player to exit position + // finally move player to exit position teleportPos = this.teleportExists[var13].get(random); this.playerX[playerId] = teleportPos[0]; this.playerY[playerId] = teleportPos[1]; } - private void handleMines(boolean isBigMine, int playerId, int screenX, int screenY, Graphics var5, Graphics canvas) { + private void handleMines( + boolean isBigMine, int playerId, int screenX, int screenY, Graphics var5, Graphics canvas) { int mapX = screenX / 15; int mapY = screenY / 15; int special = super.trackTiles[mapX][mapY] / 16777216; int shape = super.trackTiles[mapX][mapY] / 65536 % 256 + 24; int foreground = super.trackTiles[mapX][mapY] / 256 % 256; int background = super.trackTiles[mapX][mapY] % 256; - //28 Mine - //30 Big Mine + // 28 Mine + // 30 Big Mine if (special == 2 && (shape == 28 || shape == 30)) { ++shape; - super.trackTiles[mapX][mapY] = special * 256 * 256 * 256 + (shape - 24) * 256 * 256 + foreground * 256 + background; + super.trackTiles[mapX][mapY] = + special * 256 * 256 * 256 + (shape - 24) * 256 * 256 + foreground * 256 + background; this.drawTile(mapX, mapY, var5, canvas); - //Big Mine will dig a hole around mine + // Big Mine will dig a hole around mine if (isBigMine) { - int[] downhills = new int[]{17039367, 16779264, 17104905, 16778752, -1, 16779776, 17235973, 16778240, 17170443}; + int[] downhills = + new int[] {17039367, 16779264, 17104905, 16778752, -1, 16779776, 17235973, 16778240, 17170443}; int tileIndex = 0; for (int y = mapY - 1; y <= mapY + 1; ++y) { for (int x = mapX - 1; x <= mapX + 1; ++x) { - if (x >= 0 && x < 49 && y >= 0 && y < 25 && (y != mapY || x != mapX) && super.trackTiles[x][y] == 16777216) { + if (x >= 0 + && x < 49 + && y >= 0 + && y < 25 + && (y != mapY || x != mapX) + && super.trackTiles[x][y] == 16777216) { super.trackTiles[x][y] = downhills[tileIndex]; this.drawTile(x, y, var5, canvas); } @@ -1478,7 +1653,8 @@ private void handleMines(boolean isBigMine, int playerId, int screenX, int scree do { this.speedX[playerId] = (double) (-65 + this.rngSeed.next() % 131) / 10.0D; this.speedY[playerId] = (double) (-65 + this.rngSeed.next() % 131) / 10.0D; - speed = Math.sqrt(this.speedX[playerId] * this.speedX[playerId] + this.speedY[playerId] * this.speedY[playerId]); + speed = Math.sqrt(this.speedX[playerId] * this.speedX[playerId] + + this.speedY[playerId] * this.speedY[playerId]); } while (speed < 5.2D); } while (speed > 6.5D); @@ -1486,37 +1662,39 @@ private void handleMines(boolean isBigMine, int playerId, int screenX, int scree this.speedX[playerId] *= 0.8D; this.speedY[playerId] *= 0.8D; } - } } - private boolean handleMovableBlock(int screenX, int screenY, Graphics var3, Graphics canvas, int offsetX, int offsetY, boolean nonSunkable) { + private boolean handleMovableBlock( + int screenX, int screenY, Graphics var3, Graphics canvas, int offsetX, int offsetY, boolean nonSunkable) { int mapX = screenX / 15; int mapY = screenY / 15; int special = super.trackTiles[mapX][mapY] / 16777216; int shape = super.trackTiles[mapX][mapY] / 65536 % 256 + 24; int background = super.trackTiles[mapX][mapY] / 256 % 256; if (special == 2 && (shape == 27 || shape == 46)) { - //where we want to move the block + // where we want to move the block int x1 = mapX + offsetX; int y1 = mapY + offsetY; int canMove = this.canMovableBlockMove(x1, y1); if (canMove == -1) { return false; } else { - //16777216 == special:1 shape:0 fg:0 bg:0 + // 16777216 == special:1 shape:0 fg:0 bg:0 super.trackTiles[mapX][mapY] = 16777216 + background * 256; this.drawTile(mapX, mapY, var3, canvas); // [x,y,background id] - int[] tileWithCoords = this.calculateMovableBlockEndPosition(mapX, mapY, x1, y1, background, canMove, var3, canvas, nonSunkable, 0); - //12 Water - //13 Acid + int[] tileWithCoords = this.calculateMovableBlockEndPosition( + mapX, mapY, x1, y1, background, canMove, var3, canvas, nonSunkable, 0); + // 12 Water + // 13 Acid if (!nonSunkable && (tileWithCoords[2] == 12 || tileWithCoords[2] == 13)) { - //Sunked Movable Block with old background + // Sunked Movable Block with old background super.trackTiles[tileWithCoords[0]][tileWithCoords[1]] = 35061760 + tileWithCoords[2] * 256; } else { - //Movable Block with old background - super.trackTiles[tileWithCoords[0]][tileWithCoords[1]] = 33554432 + ((nonSunkable ? 27 : 46) - 24) * 256 * 256 + tileWithCoords[2] * 256; + // Movable Block with old background + super.trackTiles[tileWithCoords[0]][tileWithCoords[1]] = + 33554432 + ((nonSunkable ? 27 : 46) - 24) * 256 * 256 + tileWithCoords[2] * 256; } this.drawTile(tileWithCoords[0], tileWithCoords[1], var3, canvas); @@ -1534,7 +1712,10 @@ private int canMovableBlockMove(int x, int y) { int background = super.trackTiles[x][y] / 256 % 256; if (special == 1 && shape == 0 && background <= 15) { for (int i = 0; i < this.playerCount; ++i) { - if (this.playerX[i] > (double) (x * 15) && this.playerX[i] < (double) (x * 15 + 15 - 1) && this.playerY[i] > (double) (y * 15) && this.playerY[i] < (double) (y * 15 + 15 - 1)) { + if (this.playerX[i] > (double) (x * 15) + && this.playerX[i] < (double) (x * 15 + 15 - 1) + && this.playerY[i] > (double) (y * 15) + && this.playerY[i] < (double) (y * 15 + 15 - 1)) { return -1; } } @@ -1548,33 +1729,44 @@ private int canMovableBlockMove(int x, int y) { } } - private int[] calculateMovableBlockEndPosition(int x, int y, int x1, int y1, int background, int background1, Graphics var7, Graphics var8, boolean var9, int i) { - int[] xytile = new int[]{x1, y1, background1}; + private int[] calculateMovableBlockEndPosition( + int x, + int y, + int x1, + int y1, + int background, + int background1, + Graphics var7, + Graphics var8, + boolean var9, + int i) { + int[] xytile = new int[] {x1, y1, background1}; if (!var9 && background1 >= 4 && background1 <= 11 && i < 1078) { x = x1; y = y1; background = background1; - //Downhill North + // Downhill North if (background1 == 4 || background1 == 5 || background1 == 11) { --y1; } - //Downhill South + // Downhill South if (background1 == 8 || background1 == 7 || background1 == 9) { ++y1; } - //Downhill East + // Downhill East if (background1 == 5 || background1 == 6 || background1 == 7) { ++x1; } - //Downhill West + // Downhill West if (background1 == 9 || background1 == 10 || background1 == 11) { --x1; } background1 = this.canMovableBlockMove(x1, y1); if (background1 >= 0) { - xytile = this.calculateMovableBlockEndPosition(x, y, x1, y1, background, background1, var7, var8, var9, i + 1); + xytile = this.calculateMovableBlockEndPosition( + x, y, x1, y1, background, background1, var7, var8, var9, i + 1); } } @@ -1591,7 +1783,8 @@ private void handleBreakableBlock(int screenX, int screenY, Graphics var3, Graph if (special == 2 && shape >= 40 && shape <= 43) { ++shape; if (shape <= 43) { - super.trackTiles[mapX][mapY] = special * 256 * 256 * 256 + (shape - 24) * 256 * 256 + background * 256 + foreground; + super.trackTiles[mapX][mapY] = + special * 256 * 256 * 256 + (shape - 24) * 256 * 256 + background * 256 + foreground; } else { super.trackTiles[mapX][mapY] = 16777216 + background * 256 + background; } @@ -1624,7 +1817,10 @@ private void drawPlayer(Graphics g, int playerid, double var3) { if (var3 == 0.0D) { g.drawImage(this.ballSprites[playerid + ballSpriteOffset], x, y, this); - if (this.playerNamesDisplayMode > 0 && this.aBooleanArray2834[playerid] && this.gameState != 2 && this.playerCount > 1) { + if (this.playerNamesDisplayMode > 0 + && this.aBooleanArray2834[playerid] + && this.gameState != 2 + && this.playerCount > 1) { String[] playerName = super.gameContainer.gamePanel.getPlayerName(playerid); if (this.playerNamesDisplayMode == 1) { StringDraw.drawString(g, playerName[0].substring(0, 1), x + 6, y + 13 - 3, 0); @@ -1656,7 +1852,6 @@ private void drawPlayer(Graphics g, int playerid, double var3) { } else { g.drawImage(this.ballSprites[playerid + ballSpriteOffset], x, y, x + var7, y + var7, 0, 0, 13, 13, this); } - } private void method162(boolean var1) { @@ -1665,9 +1860,8 @@ private void method162(boolean var1) { this.setCursor(cursorCrosshair); this.addKeyListener(this); if (var1) { - //this.requestFocus();//todo this is annoying as fuck + // this.requestFocus();//todo this is annoying as fuck } - } private void drawDashedLine(Graphics var1, int var2, int var3, int var4, int var5) { @@ -1686,7 +1880,6 @@ private void drawDashedLine(Graphics var1, int var2, int var3, int var4, int var var9 += var13 * 2.0D; var11 += var15 * 2.0D; } - } private void method164(int var1) { @@ -1713,5 +1906,4 @@ private void method164(int var1) { anIntArray2837[2] = var1; anInt2838 = this.anInt2839; } - } diff --git a/client/src/main/java/agolf/game/GameControlPanel.java b/client/src/main/java/agolf/game/GameControlPanel.java index 71431ab4..215deb1b 100644 --- a/client/src/main/java/agolf/game/GameControlPanel.java +++ b/client/src/main/java/agolf/game/GameControlPanel.java @@ -4,7 +4,6 @@ import agolf.GameContainer; import com.aapeli.colorgui.Choicer; import com.aapeli.colorgui.ColorButton; - import java.awt.Checkbox; import java.awt.Graphics; import java.awt.Panel; @@ -27,7 +26,6 @@ class GameControlPanel extends Panel implements ActionListener, ItemListener { private Checkbox checkboxMaxFps; private boolean skipButtonVisible; - protected GameControlPanel(GameContainer var1, PlayerInfoPanel var2, int var3, int var4) { this.gameContainer = var1; this.playerInfoPanel = var2; @@ -80,9 +78,9 @@ public void actionPerformed(ActionEvent event) { public void itemStateChanged(ItemEvent event) { if (event.getSource() == this.playerNamesDisplayModeChoicer) { - this.gameContainer.gamePanel.setPlayerNamesDisplayMode(this.playerNamesDisplayModeChoicer.getSelectedIndex()); + this.gameContainer.gamePanel.setPlayerNamesDisplayMode( + this.playerNamesDisplayModeChoicer.getSelectedIndex()); } - } protected void setPlayerCount(int var1) { @@ -130,7 +128,8 @@ protected void setState(int state) { this.playerNamesDisplayModeChoicer = new Choicer(); for (int option = 0; option < 4; ++option) { - this.playerNamesDisplayModeChoicer.addItem(this.gameContainer.textManager.getGame("GameControl_Names" + option)); + this.playerNamesDisplayModeChoicer.addItem( + this.gameContainer.textManager.getGame("GameControl_Names" + option)); } this.playerNamesDisplayModeChoicer.select(this.playerCount <= 2 ? 0 : 3); diff --git a/client/src/main/java/agolf/game/GamePanel.java b/client/src/main/java/agolf/game/GamePanel.java index dba1d769..69f5a470 100644 --- a/client/src/main/java/agolf/game/GamePanel.java +++ b/client/src/main/java/agolf/game/GamePanel.java @@ -3,12 +3,11 @@ import agolf.GameApplet; import agolf.GameContainer; import agolf.SynchronizedBool; -import org.moparforia.client.Launcher; - import java.awt.Graphics; import java.awt.Image; import java.awt.Panel; import java.util.StringTokenizer; +import org.moparforia.client.Launcher; public class GamePanel extends Panel { @@ -28,7 +27,6 @@ public class GamePanel extends Panel { private final Object canStrokeLock; private boolean isWaitingForTurnStart; - public GamePanel(GameContainer gameContainer, int width, int height, Image image) { this.gameContainer = gameContainer; this.width = width; @@ -69,8 +67,8 @@ public void handlePacket(String[] args) { int collision = Integer.parseInt(args[11]); int trackScoring = Integer.parseInt(args[12]); int trackScoringEnd = Integer.parseInt(args[13]); - this.isSinglePlayerGame = args[14].equals("t");//todo unsure - //int trackCategory = Launcher.isUsingCustomServer() ? Integer.parseInt(args[15]) : -1; + this.isSinglePlayerGame = args[14].equals("t"); // todo unsure + // int trackCategory = Launcher.isUsingCustomServer() ? Integer.parseInt(args[15]) : -1; byte mode = 0; if (this.gameContainer.synchronizedTrackTestMode.get()) { mode = 1; @@ -90,25 +88,40 @@ public void handlePacket(String[] args) { if (passworded) { settings = this.gameContainer.textManager.getGame("GameChat_GS_Password") + ", "; } else if (permission > 0) { - settings = this.gameContainer.textManager.getGame("GameChat_GS_" + (permission == 1 ? "Reg" : "Vip") + "Only") + ", "; + settings = this.gameContainer.textManager.getGame( + "GameChat_GS_" + (permission == 1 ? "Reg" : "Vip") + "Only") + + ", "; } settings = settings + this.gameContainer.textManager.getGame("GameChat_GS_Players", this.playerCount); settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_Tracks", trackCount); if (trackTypes > 0) { - settings = settings + " (" + this.gameContainer.textManager.getIfAvailable("LobbyReal_TrackTypes" + trackTypes, this.gameContainer.textManager.getGame("LobbyReal_TrackTypesTest")) + ")"; + settings = settings + + " (" + + this.gameContainer.textManager.getIfAvailable( + "LobbyReal_TrackTypes" + trackTypes, + this.gameContainer.textManager.getGame("LobbyReal_TrackTypesTest")) + + ")"; } if (maxStrokes != 20) { if (maxStrokes > 0) { - settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_MaxStrokes", maxStrokes); + settings = settings + + ", " + + this.gameContainer.textManager.getGame("GameChat_GS_MaxStrokes", maxStrokes); } else { - settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_MaxStrokesUnlimited", maxStrokes); + settings = settings + + ", " + + this.gameContainer.textManager.getGame("GameChat_GS_MaxStrokesUnlimited", maxStrokes); } } if (strokeTimeout > 0) { - settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_TimeLimit" + (strokeTimeout < 60 ? "Sec" : "Min"), strokeTimeout < 60 ? strokeTimeout : strokeTimeout / 60); + settings = settings + + ", " + + this.gameContainer.textManager.getGame( + "GameChat_GS_TimeLimit" + (strokeTimeout < 60 ? "Sec" : "Min"), + strokeTimeout < 60 ? strokeTimeout : strokeTimeout / 60); } if (waterEvent == 1) { @@ -124,7 +137,9 @@ public void handlePacket(String[] args) { } if (trackScoringEnd > 0) { - settings = settings + ", " + this.gameContainer.textManager.getGame("GameChat_GS_TrackScoringEnd" + trackScoringEnd); + settings = settings + + ", " + + this.gameContainer.textManager.getGame("GameChat_GS_TrackScoringEnd" + trackScoringEnd); } /*if(trackCategory > -1) { @@ -149,15 +164,14 @@ public void handlePacket(String[] args) { int playerCountIndex = 2; for (int trackTypes = 0; trackTypes < len; ++trackTypes) { - int playerCount = Integer.parseInt(args[playerCountIndex]);//todo lol why u inside the loop tho + int playerCount = Integer.parseInt(args[playerCountIndex]); // todo lol why u inside the loop tho String clan = args[playerCountIndex + 2].equals("-") ? null : args[playerCountIndex + 2]; this.playerInfoPanel.addPlayer(playerCount, args[playerCountIndex + 1], clan, false); this.chatPanel.setUserColour(args[playerCountIndex + 1], playerCount); playerCountIndex += 3; } - } - else if (args[1].equals("owninfo")) { + } else if (args[1].equals("owninfo")) { int currentPlayerID = Integer.parseInt(args[2]); String currentPlayerClan = args[4].equals("-") ? null : args[4]; this.playerInfoPanel.addPlayer(currentPlayerID, args[3], currentPlayerClan, true); @@ -169,11 +183,13 @@ else if (args[1].equals("owninfo")) { this.playerInfoPanel.addPlayer(playerId, args[3], playerClan, false); this.chatPanel.setUserColour(args[3], playerId); if (this.playerCount != 2 || playerId != 1) { - this.chatPanel.addMessage(playerClan != null ? this.gameContainer.textManager.getGame("GameChat_JoinClan", args[3], playerClan) : this.gameContainer.textManager.getGame("GameChat_Join", args[3])); + this.chatPanel.addMessage( + playerClan != null + ? this.gameContainer.textManager.getGame("GameChat_JoinClan", args[3], playerClan) + : this.gameContainer.textManager.getGame("GameChat_Join", args[3])); } - } - else if (args[1].equals("part")) { // player left game + } else if (args[1].equals("part")) { // player left game int playerId = Integer.parseInt(args[2]); boolean changed = this.playerInfoPanel.setPlayerPartStatus(playerId, Integer.parseInt(args[3])); if (changed) { @@ -208,7 +224,7 @@ else if (args[1].equals("part")) { // player left game if (this.aBoolean363) { if (System.currentTimeMillis() > this.aLong364 + 1000L) { this.gameContainer.soundManager.playNotify(); - //this.requestFocus();//todo this is annoying as fuck + // this.requestFocus();//todo this is annoying as fuck } this.gameContainer.gameApplet.showPlayerList(this.playerInfoPanel.getPlayerNames()); @@ -222,29 +238,29 @@ else if (args[1].equals("part")) { // player left game this.playerInfoPanel.reset(); this.trackInfoPanel.resetCurrentTrack(); this.setState(1); - } - else if (args[1].equals("starttrack")) { - // [1] = "startrack", (optional [2] == track test mode), [2 or 3] == player statuses, [3 or 4] == game id, [4 or 5] == track data + } else if (args[1].equals("starttrack")) { + // [1] = "startrack", (optional [2] == track test mode), [2 or 3] == player statuses, [3 + // or 4] == game id, [4 or 5] == track data /* - * game - * starttrack - * t 1908821 - * V 1 - * A Tiikoni - * N Three Passages III - * T B3A12DBQARG20DBQARG12DE11DBTARBERQBAQQ20DBFRQBRARE11DE12DBAQQG20DFG12DE12DEE20DEE12DE12DEE20DEE12DE7DBQARE3DEE20DEE3DBQARE7DE6DBTARBERQBAQQ3DBGRQBRARE18DBTARBHRQF3DBFRQBRARE6DE7DBAQQG3DBSARG20DBSARG3DFG7DE7DEE6DBQARE14DBQARE6DEE7DE7DEE5DBTARBERQBAQQ14DBFRQBRARE5DEE7DE7DEE6DBAQQG14DFG6DEE7DE7DEE6DEE14DEE6DEE7DE7DEE6DEEDDBQARE10DEE6DEE7DE7DEE6DEEDBTARBERQBAQQ10DBGRQBRARE5DEE7DE7DEE6DEEDDBAQQG10DBSARG6DEE7DE7DEE6DEEDDEE13DBQARE3DEE7DE7DEE6DEEDDEE12DBTARBERQBAQQ3DBGRQBRARE6DE7DEE6DEEDDEEDDCBAE9DBAQQG3DBSARG7DE7DEE6DEEDDEE13DEE12DE7DEEDDCAAEDDEEDDEE13DEE12DE7DEE6DEEDDEE13DEE12DE7DEE6DEEDBTARBHRQF13DBGRQBRARE11DE7DEE6DEEDDBSARG13DBSARG12DE6DBTARBHRQF6DBGRQBRARE30DE7DBSARG6DBSARG31D,Ads:A3703B0101C4019 I 456956,1954871,2,17833 B Jerry,1087842155000 L abscission,1369657760469 R 1047,334,392,574,911,2281,1888,1543,1209,871,6559 - - - - V 1 - A {AUTHOR OF TRACK} - N {NAME OF TRACK} - T B3A11DBEAQBAQQ11DBAMMDDBGQMBAQQ11DBAMMDDBGQMBAQQ3DEDDBIALBHLEBGFEBJAFE3DBEAQBGAQB3A10DEEDBGQMBGAQB3A10DEEDBGQMBGAQB3ADCAAEEDDBHKLBALABAFABGGFEDDBEAQBGAQI11DEEBGQMBGAQB3A11DEEBGQMBGAQB3A3DEEDDBGJKBAJABAHABHHGEDBEAQBGAQI12DEBGQMBGAQB3A12DEBGQMBGAQB3A4DEEDDBLAJBGIJBHIHBKAHEBEAQBGAQI5DBEAQBGAQE5DEBGAQB3A5DBEAQBGAQE5DEBGAQB3A5DEE6DBEAQBGAQI5DBEAQBGAQH5DBEAQBGAQI5DBEAQBGAQH5DBEAQBGAQI5DBEAQBGAQBJAME4DBEAQBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIBAMMBLMAEDDBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDEDDBJAMBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDDEDDBGQMBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI3DEDBGQMBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI4DEBGQMBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDBIALBHLEBGFEBJAFBTMQBTQAB3A5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAIDDBHKLBALABAFABGGFBKAMBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQEDBGJKBAJABAHABHHGB3ADFFE5DFFE5DFFE5DFFE5DFFE5DFFEBLAJBGIJBHIHBKAHEDDFFE5DFFE5DFFE5DFFE5DFFE5D3F3DE3DFFE5DFFE5DFFE5DFFE5DFFE5DFFEDBKMAE4DFFE5DFFE5DFFE5DFFE5DFFE5DFFBIAMBAMME5DFFE5DFFE5DFFE5DFFE5DFFE5DFBHQMEE6DFFE5DFFE5DFFE5DFFE5DFFE5DFFEDBIALBHLEBGFEBJAFEDFFEDCBAEDBEAQBAQQFE5DFE5DBEAQBAQQFE5DFE6DBRQAEDBHKLBALABAFABGGFEDDFFEDDBEAQBEQMBAMMBHMQFE10DBEAQBEQMBAMMBHMQFE11DBEAQBEQMEDBGJKBAJABAHABHHGE3DFFEBEAQBEQMBAMMDDFFE8DBEAQBEQMBAMMDDFFE9DBEAQBEQMBAMMEDBLAJBGIJBHIHBKAHE3DBIAMBHMQBSQABEQMBAMM4DFFE6DBEAQBEQMBAMM4DFFE7DBEAQBEQMBAMMDE8DBKMABAMMDBSMQG6DFBAQQ6DBEQMBAMM6DFBAQQ7DBEQMBAMMDD - I {NUMBER OF PLAYERS TO COMLETE?},{NUMBER OF PEOPLE TO ATTEMPT?},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT GOT BEST STROKE} - B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 - L {LAST BEST PAR PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 - R {RATING: 0},{RATING: 1},{RATING: 2},{RATING: 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: 9},{RATING: 10} - */ + * game + * starttrack + * t 1908821 + * V 1 + * A Tiikoni + * N Three Passages III + * T B3A12DBQARG20DBQARG12DE11DBTARBERQBAQQ20DBFRQBRARE11DE12DBAQQG20DFG12DE12DEE20DEE12DE12DEE20DEE12DE7DBQARE3DEE20DEE3DBQARE7DE6DBTARBERQBAQQ3DBGRQBRARE18DBTARBHRQF3DBFRQBRARE6DE7DBAQQG3DBSARG20DBSARG3DFG7DE7DEE6DBQARE14DBQARE6DEE7DE7DEE5DBTARBERQBAQQ14DBFRQBRARE5DEE7DE7DEE6DBAQQG14DFG6DEE7DE7DEE6DEE14DEE6DEE7DE7DEE6DEEDDBQARE10DEE6DEE7DE7DEE6DEEDBTARBERQBAQQ10DBGRQBRARE5DEE7DE7DEE6DEEDDBAQQG10DBSARG6DEE7DE7DEE6DEEDDEE13DBQARE3DEE7DE7DEE6DEEDDEE12DBTARBERQBAQQ3DBGRQBRARE6DE7DEE6DEEDDEEDDCBAE9DBAQQG3DBSARG7DE7DEE6DEEDDEE13DEE12DE7DEEDDCAAEDDEEDDEE13DEE12DE7DEE6DEEDDEE13DEE12DE7DEE6DEEDBTARBHRQF13DBGRQBRARE11DE7DEE6DEEDDBSARG13DBSARG12DE6DBTARBHRQF6DBGRQBRARE30DE7DBSARG6DBSARG31D,Ads:A3703B0101C4019 I 456956,1954871,2,17833 B Jerry,1087842155000 L abscission,1369657760469 R 1047,334,392,574,911,2281,1888,1543,1209,871,6559 + + + + V 1 + A {AUTHOR OF TRACK} + N {NAME OF TRACK} + T B3A11DBEAQBAQQ11DBAMMDDBGQMBAQQ11DBAMMDDBGQMBAQQ3DEDDBIALBHLEBGFEBJAFE3DBEAQBGAQB3A10DEEDBGQMBGAQB3A10DEEDBGQMBGAQB3ADCAAEEDDBHKLBALABAFABGGFEDDBEAQBGAQI11DEEBGQMBGAQB3A11DEEBGQMBGAQB3A3DEEDDBGJKBAJABAHABHHGEDBEAQBGAQI12DEBGQMBGAQB3A12DEBGQMBGAQB3A4DEEDDBLAJBGIJBHIHBKAHEBEAQBGAQI5DBEAQBGAQE5DEBGAQB3A5DBEAQBGAQE5DEBGAQB3A5DEE6DBEAQBGAQI5DBEAQBGAQH5DBEAQBGAQI5DBEAQBGAQH5DBEAQBGAQI5DBEAQBGAQBJAME4DBEAQBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIBAMMBLMAEDDBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDEDDBJAMBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDDEDDBGQMBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI3DEDBGQMBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI4DEBGQMBGAQB3A5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQI5DBEAQBGAQIDBIALBHLEBGFEBJAFBTMQBTQAB3A5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAI5DBTAQBTQAIDDBHKLBALABAFABGGFBKAMBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQE5DBHAQBFAQEDBGJKBAJABAHABHHGB3ADFFE5DFFE5DFFE5DFFE5DFFE5DFFEBLAJBGIJBHIHBKAHEDDFFE5DFFE5DFFE5DFFE5DFFE5D3F3DE3DFFE5DFFE5DFFE5DFFE5DFFE5DFFEDBKMAE4DFFE5DFFE5DFFE5DFFE5DFFE5DFFBIAMBAMME5DFFE5DFFE5DFFE5DFFE5DFFE5DFBHQMEE6DFFE5DFFE5DFFE5DFFE5DFFE5DFFEDBIALBHLEBGFEBJAFEDFFEDCBAEDBEAQBAQQFE5DFE5DBEAQBAQQFE5DFE6DBRQAEDBHKLBALABAFABGGFEDDFFEDDBEAQBEQMBAMMBHMQFE10DBEAQBEQMBAMMBHMQFE11DBEAQBEQMEDBGJKBAJABAHABHHGE3DFFEBEAQBEQMBAMMDDFFE8DBEAQBEQMBAMMDDFFE9DBEAQBEQMBAMMEDBLAJBGIJBHIHBKAHE3DBIAMBHMQBSQABEQMBAMM4DFFE6DBEAQBEQMBAMM4DFFE7DBEAQBEQMBAMMDE8DBKMABAMMDBSMQG6DFBAQQ6DBEQMBAMM6DFBAQQ7DBEQMBAMMDD + I {NUMBER OF PLAYERS TO COMLETE?},{NUMBER OF PEOPLE TO ATTEMPT?},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT GOT BEST STROKE} + B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 + L {LAST BEST PAR PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 + R {RATING: 0},{RATING: 1},{RATING: 2},{RATING: 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: 9},{RATING: 10} + */ this.gameCanvas.restartGame(); boolean trackTestMode1 = args[2].equals("ttm1"); boolean trackTestMode2 = args[2].equals("ttm2"); @@ -271,7 +287,7 @@ else if (args[1].equals("starttrack")) { data = args[commandIndex].substring(2); } - if (command == 'T' && args[commandIndex].charAt(2) == '!') {// a track we already played? + if (command == 'T' && args[commandIndex].charAt(2) == '!') { // a track we already played? args[commandIndex] = "T " + this.gameContainer.trackCollection.getTrack(author, name); hasPlayed = true; } @@ -282,14 +298,14 @@ else if (args[1].equals("starttrack")) { } } - if(Launcher.debug()) - System.out.println("FULL: " + fullInstruction); + if (Launcher.debug()) System.out.println("FULL: " + fullInstruction); if (!hasPlayed) { this.gameContainer.trackCollection.addTrack(author, name, data); } - this.gameCanvas.init(fullInstruction, args[trackTestMode ? 3 : 2], Integer.parseInt(args[trackTestMode ? 4 : 3])); + this.gameCanvas.init( + fullInstruction, args[trackTestMode ? 3 : 2], Integer.parseInt(args[trackTestMode ? 4 : 3])); /* trackinformation [0]=author, [1]=trackname, [2]=firstbest, [3]=lastbest @@ -307,16 +323,29 @@ else if (args[1].equals("starttrack")) { String[] trackInformation = this.gameCanvas.generateTrackInformation(); int[][] trackStats = this.gameCanvas.generateTrackStatistics(); - this.trackInfoPanel.parseTrackInfoStats(trackInformation[0], trackInformation[1], trackStats[0], trackStats[1], trackInformation[2], trackInformation[3], trackTestMode1, trackTestMode2, this.gameCanvas.method134()); + this.trackInfoPanel.parseTrackInfoStats( + trackInformation[0], + trackInformation[1], + trackStats[0], + trackStats[1], + trackInformation[2], + trackInformation[3], + trackTestMode1, + trackTestMode2, + this.gameCanvas.method134()); int trackScoreMultiplier = this.playerInfoPanel.startNextTrack(); if (trackScoreMultiplier > 1) { - this.chatPanel.addMessage(gameContainer.textManager.getGame("GameChat_ScoreMultiNotify", trackScoreMultiplier)); + this.chatPanel.addMessage( + gameContainer.textManager.getGame("GameChat_ScoreMultiNotify", trackScoreMultiplier)); } this.gameControlPanel.displaySkipButton(); // checks if you can skip on first shot if (this.gameContainer.synchronizedTrackTestMode.get()) { - this.chatPanel.printSpecialSettingstoTextArea(this.gameCanvas.getTrackComment(), this.gameCanvas.getTrackSettings(), this.gameCanvas.method120()); + this.chatPanel.printSpecialSettingstoTextArea( + this.gameCanvas.getTrackComment(), + this.gameCanvas.getTrackSettings(), + this.gameCanvas.method120()); } } else if (args[1].equals("startturn")) { @@ -324,7 +353,7 @@ else if (args[1].equals("starttrack")) { int playerId = Integer.parseInt(args[2]); boolean canPlay = this.playerInfoPanel.startTurn(playerId); - //canPlay = true; + // canPlay = true; this.gameCanvas.startTurn(playerId, canPlay, !this.chatPanel.haveFocus()); if (!this.isSinglePlayerGame) { @@ -349,8 +378,7 @@ else if (args[1].equals("starttrack")) { } this.playerInfoPanel.setScores(Integer.parseInt(args[2]), trackScores); - } - else if (args[1].equals("voteskip")) { + } else if (args[1].equals("voteskip")) { this.playerInfoPanel.voteSkip(Integer.parseInt(args[2])); } else if (args[1].equals("resetvoteskip")) { this.playerInfoPanel.voteSkipReset(); @@ -358,11 +386,9 @@ else if (args[1].equals("voteskip")) { this.gameControlPanel.showSkipButton(); } - } - else if (args[1].equals("rfng")) { + } else if (args[1].equals("rfng")) { this.playerInfoPanel.readyForNewGame(Integer.parseInt(args[2])); - } - else if(args[1].equals("end")) { + } else if (args[1].equals("end")) { this.gameCanvas.endGame(); int len = args.length - 2; if (len > 0) { @@ -380,7 +406,7 @@ else if(args[1].equals("end")) { this.playerInfoPanel.setGameOutcome(null); } - this.setState(2);// game state? + this.setState(2); // game state? if (this.isSinglePlayerGame) { this.gameContainer.lobbyPanel.requestTrackSetList(); } @@ -392,7 +418,11 @@ else if(args[1].equals("end")) { protected void sendChatMessage(String message) { String var2 = "say\t" + message; this.gameContainer.connection.writeData("game\t" + var2); - this.chatPanel.addSay(this.playerInfoPanel.playerId, this.playerInfoPanel.playerNames[this.playerInfoPanel.playerId], message, true); + this.chatPanel.addSay( + this.playerInfoPanel.playerId, + this.playerInfoPanel.playerNames[this.playerInfoPanel.playerId], + message, + true); } protected void setBeginStroke(int playerId, int x, int y, int shootingMode) { @@ -476,7 +506,7 @@ protected void rateTrack(int track, int rating) { this.gameContainer.connection.writeData("game\t" + message); } - protected void respondNewGame(int track, boolean accept) {// why track + protected void respondNewGame(int track, boolean accept) { // why track String message = "rejectaccept\t" + track + "\t" + (accept ? "t" : "f"); this.gameContainer.connection.writeData("game\t" + message); } diff --git a/client/src/main/java/agolf/game/HackedShot.java b/client/src/main/java/agolf/game/HackedShot.java index 8a607faf..5e2bbaac 100644 --- a/client/src/main/java/agolf/game/HackedShot.java +++ b/client/src/main/java/agolf/game/HackedShot.java @@ -3,7 +3,6 @@ import agolf.Seed; import agolf.SynchronizedBool; import com.aapeli.tools.Tools; - import java.util.Arrays; import java.util.List; @@ -11,7 +10,7 @@ public class HackedShot implements Runnable { private static final double aDouble2798 = Math.sqrt(2.0D) / 2.0D; private static final int anInt2799 = (int) (6.0D * aDouble2798 + 0.5D); - private static int[] anIntArray2837 = new int[]{Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE}; + private static int[] anIntArray2837 = new int[] {Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE}; private static int anInt2838 = 2; private int anInt2809; @@ -44,35 +43,35 @@ public class HackedShot implements Runnable { protected byte[][] isSolidArrayIThink; protected int[][] mapTiles; - // this actually scares me, but its for science. - public HackedShot(int anInt2809, - int anInt2810, - int anInt2811, - int currentPlayerID, - int anInt2816, - double aDouble2817, - double aDouble2818, - double aDouble2819, - double aDouble2820, - double[] aDoubleArray2821, - double[] aDoubleArray2822, - List[] teleportStarts, - List[] teleportExits, - short[][][] aShortArrayArrayArray2825, - double[] playerX, - double[] playerY, - double[] aDoubleArray2828, - double[] aDoubleArray2829, - boolean[] aBooleanArray2830, - SynchronizedBool[] aSynchronizedBoolArray2831, - boolean aBoolean2832, - boolean[] aBooleanArray2834, - Seed aSeed_2836, - int anInt2839, - boolean aBoolean2843, - byte[][] isSolidArrayIThink, - int[][] mapTiles) { + public HackedShot( + int anInt2809, + int anInt2810, + int anInt2811, + int currentPlayerID, + int anInt2816, + double aDouble2817, + double aDouble2818, + double aDouble2819, + double aDouble2820, + double[] aDoubleArray2821, + double[] aDoubleArray2822, + List[] teleportStarts, + List[] teleportExits, + short[][][] aShortArrayArrayArray2825, + double[] playerX, + double[] playerY, + double[] aDoubleArray2828, + double[] aDoubleArray2829, + boolean[] aBooleanArray2830, + SynchronizedBool[] aSynchronizedBoolArray2831, + boolean aBoolean2832, + boolean[] aBooleanArray2834, + Seed aSeed_2836, + int anInt2839, + boolean aBoolean2843, + byte[][] isSolidArrayIThink, + int[][] mapTiles) { this.anInt2809 = anInt2809; this.anInt2810 = anInt2810; @@ -97,20 +96,19 @@ public HackedShot(int anInt2809, this.aDoubleArray2828 = Arrays.copyOf(aDoubleArray2828, aDoubleArray2828.length); this.aDoubleArray2829 = Arrays.copyOf(aDoubleArray2829, aDoubleArray2829.length); this.aBooleanArray2830 = Arrays.copyOf(aBooleanArray2830, aBooleanArray2830.length); - this.aSynchronizedBoolArray2831 = Arrays.copyOf(aSynchronizedBoolArray2831, aSynchronizedBoolArray2831.length); //unsure bout thsione + this.aSynchronizedBoolArray2831 = + Arrays.copyOf(aSynchronizedBoolArray2831, aSynchronizedBoolArray2831.length); // unsure bout thsione this.aBoolean2832 = aBoolean2832; this.aBooleanArray2834 = Arrays.copyOf(aBooleanArray2834, aBooleanArray2834.length); this.aSeed_2836 = aSeed_2836.clone(); this.anInt2839 = anInt2839; this.aBoolean2843 = aBoolean2843; this.isSolidArrayIThink = Arrays.copyOf(isSolidArrayIThink, isSolidArrayIThink.length); - this.mapTiles = Arrays.copyOf(mapTiles , mapTiles .length); - - + this.mapTiles = Arrays.copyOf(mapTiles, mapTiles.length); } public void run() { - /* Image var1 = this.createImage(735, 375); + /* Image var1 = this.createImage(735, 375); Image var2 = mage; Graphics var3 = var1.getGraphics(); Graphics var4 = this.getGraphics(); @@ -201,7 +199,12 @@ public void run() { int var45; if (this.anInt2811 == 1 && !var15[var43] && !var16[var43]) { for (var45 = 0; var45 < this.anInt2809; ++var45) { - if (var43 != var45 && this.aBooleanArray2830[var45] && !this.aSynchronizedBoolArray2831[var45].get() && !var15[var45] && !var16[var45] && this.method147(var43, var45)) { + if (var43 != var45 + && this.aBooleanArray2830[var45] + && !this.aSynchronizedBoolArray2831[var45].get() + && !var15[var45] + && !var16[var45] + && this.method147(var43, var45)) { this.aDoubleArray2828[var43] *= 0.75D; this.aDoubleArray2829[var43] *= 0.75D; this.aDoubleArray2828[var45] *= 0.75D; @@ -233,7 +236,14 @@ public void run() { var45 = 0; for (int var46 = 32; var46 <= 38; var46 += 2) { - if (var32 == var46 || var31 == var46 || var30 == var46 || var29 == var46 || var28 == var46 || var27 == var46 || var26 == var46 || var25 == var46) { + if (var32 == var46 + || var31 == var46 + || var30 == var46 + || var29 == var46 + || var28 == var46 + || var27 == var46 + || var26 == var46 + || var25 == var46) { ++var45; if (!var17[var43]) { this.method154((var46 - 32) / 2, var43, var35, var34); @@ -261,7 +271,11 @@ public void run() { var20 = false; double var49; - if (var33 == 25 || isSolidArrayIThink[var35][var34 - 1] == 25 || isSolidArrayIThink[var35 + 1][var34] == 25 || isSolidArrayIThink[var35][var34 + 1] == 25 || isSolidArrayIThink[var35 - 1][var34] == 25) { + if (var33 == 25 + || isSolidArrayIThink[var35][var34 - 1] == 25 + || isSolidArrayIThink[var35 + 1][var34] == 25 + || isSolidArrayIThink[var35][var34 + 1] == 25 + || isSolidArrayIThink[var35 - 1][var34] == 25) { var49 = var33 == 25 ? 1.0D : 0.5D; var20 = true; int var51 = 0; @@ -338,7 +352,8 @@ public void run() { var12[var43] = this.playerY[var43]; } - var36 = Math.sqrt(this.aDoubleArray2828[var43] * this.aDoubleArray2828[var43] + this.aDoubleArray2829[var43] * this.aDoubleArray2829[var43]); + var36 = Math.sqrt(this.aDoubleArray2828[var43] * this.aDoubleArray2828[var43] + + this.aDoubleArray2829[var43] * this.aDoubleArray2829[var43]); if (var36 > 0.0D) { double var52 = this.method150(var33, var36); this.aDoubleArray2828[var43] *= var52; @@ -390,11 +405,12 @@ public void run() { if (var15[var43] || var16[var43]) { var10[var43] += 0.1D; - if (var15[var43] && var10[var43] > 2.1666666666666665D || var16[var43] && var10[var43] > 6.0D) { + if (var15[var43] && var10[var43] > 2.1666666666666665D + || var16[var43] && var10[var43] > 6.0D) { if (var33 == 25) { this.aSynchronizedBoolArray2831[var43].set(true); if (this.aBoolean2832 && this.anInt2809 > 1) { - //gameContainer.gamePanel.hideSkipButton(); + // gameContainer.gamePanel.hideSkipButton(); } } else { if (var33 == 12 || var33 == 14) { @@ -430,15 +446,16 @@ public void run() { int var55 = (int) (var14[var43] - 6.5D + 0.5D); int var56 = var54 + 13; int var57 = var55 + 13; - //var3.drawImage(var2, var54, var55, var56, var57, var54, var55, var56, var57, this); + // var3.drawImage(var2, var54, var55, var56, var57, var54, var55, var56, var57, + // this); for (var44 = 0; var44 < this.anInt2809; ++var44) { if (this.aBooleanArray2830[var44] && var44 != this.currentPlayerID) { - //this.method161(var3, var44, var10[var44]); + // this.method161(var3, var44, var10[var44]); } } - //this.method161(var3, this.currentPlayerID, var10[this.currentPlayerID]); + // this.method161(var3, this.currentPlayerID, var10[this.currentPlayerID]); if (this.playerX[var43] < var13[var43]) { var54 = (int) (this.playerX[var43] - 6.5D + 0.5D); } @@ -455,7 +472,8 @@ public void run() { var57 = (int) (this.playerY[var43] - 6.5D + 0.5D) + 13; } - // var4.drawImage(var1, var54, var55, var56, var57, var54, var55, var56, var57, this); + // var4.drawImage(var1, var54, var55, var56, var57, var54, var55, var56, var57, + // this); } } @@ -463,7 +481,6 @@ public void run() { long var58 = 0L; // dont sleep - Tools.sleep(var58); var38 = (int) ((long) var38 + var58); } while (var24 < this.anInt2809 && !this.aBoolean2843); @@ -474,21 +491,22 @@ public void run() { this.method164(var38); this.aSynchronizedBoolArray2831[this.anInt2816].set(false); // FUCKING IMPORTANT OR IT BORKS - //gameContainer.gamePanel.sendEndStroke(this.currentPlayerID, this.aSynchronizedBoolArray2831, this.anInt2816); + // gameContainer.gamePanel.sendEndStroke(this.currentPlayerID, + // this.aSynchronizedBoolArray2831, this.anInt2816); /* if (this.anInt2816 >= 0) { this.aSynchronizedBoolArray2831[this.anInt2816].set(true); } */ - //System.out.println("hacked="+playerX[currentPlayerID]+","+playerY[currentPlayerID]); - //this.aThread2842 = null; + // System.out.println("hacked="+playerX[currentPlayerID]+","+playerY[currentPlayerID]); + // this.aThread2842 = null; // this.repaint(); } } public double[] getHackedCoordintes() { - double[] result = new double[] {playerX[currentPlayerID],playerY[currentPlayerID]}; + double[] result = new double[] {playerX[currentPlayerID], playerY[currentPlayerID]}; return result; } @@ -586,16 +604,22 @@ private void method155(boolean var1, int var2, int var3, int var4) { if (var9 == 2 && (var10 == 28 || var10 == 30)) { ++var10; mapTiles[var7][var8] = var9 * 256 * 256 * 256 + (var10 - 24) * 256 * 256 + var11 * 256 + var12; - //this.drawTile(var7, var8, var5, var6); + // this.drawTile(var7, var8, var5, var6); if (var1) { - int[] var13 = new int[]{17039367, 16779264, 17104905, 16778752, -1, 16779776, 17235973, 16778240, 17170443}; + int[] var13 = + new int[] {17039367, 16779264, 17104905, 16778752, -1, 16779776, 17235973, 16778240, 17170443}; int var14 = 0; for (int var15 = var8 - 1; var15 <= var8 + 1; ++var15) { for (int var16 = var7 - 1; var16 <= var7 + 1; ++var16) { - if (var16 >= 0 && var16 < 49 && var15 >= 0 && var15 < 25 && (var15 != var8 || var16 != var7) && mapTiles[var16][var15] == 16777216) { + if (var16 >= 0 + && var16 < 49 + && var15 >= 0 + && var15 < 25 + && (var15 != var8 || var16 != var7) + && mapTiles[var16][var15] == 16777216) { mapTiles[var16][var15] = var13[var14]; - //this.drawTile(var16, var15, var5, var6); + // this.drawTile(var16, var15, var5, var6); } ++var14; @@ -608,7 +632,8 @@ private void method155(boolean var1, int var2, int var3, int var4) { do { this.aDoubleArray2828[var2] = (double) (-65 + this.aSeed_2836.next() % 131) / 10.0D; this.aDoubleArray2829[var2] = (double) (-65 + this.aSeed_2836.next() % 131) / 10.0D; - var17 = Math.sqrt(this.aDoubleArray2828[var2] * this.aDoubleArray2828[var2] + this.aDoubleArray2829[var2] * this.aDoubleArray2829[var2]); + var17 = Math.sqrt(this.aDoubleArray2828[var2] * this.aDoubleArray2828[var2] + + this.aDoubleArray2829[var2] * this.aDoubleArray2829[var2]); } while (var17 < 5.2D); } while (var17 > 6.5D); @@ -616,11 +641,21 @@ private void method155(boolean var1, int var2, int var3, int var4) { this.aDoubleArray2828[var2] *= 0.8D; this.aDoubleArray2829[var2] *= 0.8D; } - } } - private void method152(int var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9, int var10, int var11) { + private void method152( + int var1, + int var2, + int var3, + int var4, + int var5, + int var6, + int var7, + int var8, + int var9, + int var10, + int var11) { boolean var14 = var2 >= 16 && var2 <= 23 && var2 != 19 || var2 == 27 || var2 >= 40 && var2 <= 43 || var2 == 46; boolean var15 = var3 >= 16 && var3 <= 23 && var3 != 19 || var3 == 27 || var3 >= 40 && var3 <= 43 || var3 == 46; boolean var16 = var4 >= 16 && var4 <= 23 && var4 != 19 || var4 == 27 || var4 >= 40 && var4 <= 43 || var4 == 46; @@ -709,22 +744,42 @@ private void method152(int var1, int var2, int var3, int var4, int var5, int var var14 = false; } - if (var14 && var15 && var16 && (var2 < 20 || var2 > 23) && (var3 < 20 || var3 > 23) && (var4 < 20 || var4 > 23)) { + if (var14 + && var15 + && var16 + && (var2 < 20 || var2 > 23) + && (var3 < 20 || var3 > 23) + && (var4 < 20 || var4 > 23)) { var16 = false; var14 = false; } - if (var16 && var17 && var18 && (var4 < 20 || var4 > 23) && (var5 < 20 || var5 > 23) && (var6 < 20 || var6 > 23)) { + if (var16 + && var17 + && var18 + && (var4 < 20 || var4 > 23) + && (var5 < 20 || var5 > 23) + && (var6 < 20 || var6 > 23)) { var18 = false; var16 = false; } - if (var18 && var19 && var20 && (var6 < 20 || var6 > 23) && (var7 < 20 || var7 > 23) && (var8 < 20 || var8 > 23)) { + if (var18 + && var19 + && var20 + && (var6 < 20 || var6 > 23) + && (var7 < 20 || var7 > 23) + && (var8 < 20 || var8 > 23)) { var20 = false; var18 = false; } - if (var20 && var21 && var14 && (var8 < 20 || var8 > 23) && (var9 < 20 || var9 > 23) && (var2 < 20 || var2 > 23)) { + if (var20 + && var21 + && var14 + && (var8 < 20 || var8 > 23) + && (var9 < 20 || var9 > 23) + && (var2 < 20 || var2 > 23)) { var14 = false; var20 = false; } @@ -732,28 +787,56 @@ private void method152(int var1, int var2, int var3, int var4, int var5, int var double var22; if (!var14 && !var16 && !var18 && !var20) { double var24; - if (var15 && (this.aDoubleArray2828[var1] > 0.0D && this.aDoubleArray2829[var1] < 0.0D || this.aDoubleArray2828[var1] < 0.0D && this.aDoubleArray2829[var1] < 0.0D && -this.aDoubleArray2829[var1] > -this.aDoubleArray2828[var1] || this.aDoubleArray2828[var1] > 0.0D && this.aDoubleArray2829[var1] > 0.0D && this.aDoubleArray2828[var1] > this.aDoubleArray2829[var1])) { + if (var15 + && (this.aDoubleArray2828[var1] > 0.0D && this.aDoubleArray2829[var1] < 0.0D + || this.aDoubleArray2828[var1] < 0.0D + && this.aDoubleArray2829[var1] < 0.0D + && -this.aDoubleArray2829[var1] > -this.aDoubleArray2828[var1] + || this.aDoubleArray2828[var1] > 0.0D + && this.aDoubleArray2829[var1] > 0.0D + && this.aDoubleArray2828[var1] > this.aDoubleArray2829[var1])) { var22 = this.method153(var3, var1, var10 + anInt2799, var11 - anInt2799, 1, -1); var24 = this.aDoubleArray2828[var1]; this.aDoubleArray2828[var1] = this.aDoubleArray2829[var1] * var22; this.aDoubleArray2829[var1] = var24 * var22; } - if (var17 && (this.aDoubleArray2828[var1] > 0.0D && this.aDoubleArray2829[var1] > 0.0D || this.aDoubleArray2828[var1] > 0.0D && this.aDoubleArray2829[var1] < 0.0D && this.aDoubleArray2828[var1] > -this.aDoubleArray2829[var1] || this.aDoubleArray2828[var1] < 0.0D && this.aDoubleArray2829[var1] > 0.0D && this.aDoubleArray2829[var1] > -this.aDoubleArray2828[var1])) { + if (var17 + && (this.aDoubleArray2828[var1] > 0.0D && this.aDoubleArray2829[var1] > 0.0D + || this.aDoubleArray2828[var1] > 0.0D + && this.aDoubleArray2829[var1] < 0.0D + && this.aDoubleArray2828[var1] > -this.aDoubleArray2829[var1] + || this.aDoubleArray2828[var1] < 0.0D + && this.aDoubleArray2829[var1] > 0.0D + && this.aDoubleArray2829[var1] > -this.aDoubleArray2828[var1])) { var22 = this.method153(var5, var1, var10 + anInt2799, var11 + anInt2799, 1, 1); var24 = this.aDoubleArray2828[var1]; this.aDoubleArray2828[var1] = -this.aDoubleArray2829[var1] * var22; this.aDoubleArray2829[var1] = -var24 * var22; } - if (var19 && (this.aDoubleArray2828[var1] < 0.0D && this.aDoubleArray2829[var1] > 0.0D || this.aDoubleArray2828[var1] > 0.0D && this.aDoubleArray2829[var1] > 0.0D && this.aDoubleArray2829[var1] > this.aDoubleArray2828[var1] || this.aDoubleArray2828[var1] < 0.0D && this.aDoubleArray2829[var1] < 0.0D && -this.aDoubleArray2828[var1] > -this.aDoubleArray2829[var1])) { + if (var19 + && (this.aDoubleArray2828[var1] < 0.0D && this.aDoubleArray2829[var1] > 0.0D + || this.aDoubleArray2828[var1] > 0.0D + && this.aDoubleArray2829[var1] > 0.0D + && this.aDoubleArray2829[var1] > this.aDoubleArray2828[var1] + || this.aDoubleArray2828[var1] < 0.0D + && this.aDoubleArray2829[var1] < 0.0D + && -this.aDoubleArray2828[var1] > -this.aDoubleArray2829[var1])) { var22 = this.method153(var7, var1, var10 - anInt2799, var11 + anInt2799, -1, 1); var24 = this.aDoubleArray2828[var1]; this.aDoubleArray2828[var1] = this.aDoubleArray2829[var1] * var22; this.aDoubleArray2829[var1] = var24 * var22; } - if (var21 && (this.aDoubleArray2828[var1] < 0.0D && this.aDoubleArray2829[var1] < 0.0D || this.aDoubleArray2828[var1] < 0.0D && this.aDoubleArray2829[var1] > 0.0D && -this.aDoubleArray2828[var1] > this.aDoubleArray2829[var1] || this.aDoubleArray2828[var1] > 0.0D && this.aDoubleArray2829[var1] < 0.0D && -this.aDoubleArray2829[var1] > this.aDoubleArray2828[var1])) { + if (var21 + && (this.aDoubleArray2828[var1] < 0.0D && this.aDoubleArray2829[var1] < 0.0D + || this.aDoubleArray2828[var1] < 0.0D + && this.aDoubleArray2829[var1] > 0.0D + && -this.aDoubleArray2828[var1] > this.aDoubleArray2829[var1] + || this.aDoubleArray2828[var1] > 0.0D + && this.aDoubleArray2829[var1] < 0.0D + && -this.aDoubleArray2829[var1] > this.aDoubleArray2828[var1])) { var22 = this.method153(var9, var1, var10 - anInt2799, var11 - anInt2799, -1, -1); var24 = this.aDoubleArray2828[var1]; this.aDoubleArray2828[var1] = -this.aDoubleArray2829[var1] * var22; @@ -784,7 +867,6 @@ private void method152(int var1, int var2, int var3, int var4, int var5, int var return; } } - } private double method153(int var1, int var2, int var3, int var4, int var7, int var8) { @@ -797,7 +879,8 @@ private double method153(int var1, int var2, int var3, int var4, int var7, int v return 0.84D; } else { this.aDouble2819 -= 0.01D; - double var9 = Math.sqrt(this.aDoubleArray2828[var2] * this.aDoubleArray2828[var2] + this.aDoubleArray2829[var2] * this.aDoubleArray2829[var2]); + double var9 = Math.sqrt(this.aDoubleArray2828[var2] * this.aDoubleArray2828[var2] + + this.aDoubleArray2829[var2] * this.aDoubleArray2829[var2]); return this.aDouble2819 * 6.5D / var9; } } else if (var1 != 20 && var1 != 21 && var1 != 22 && var1 != 23) { @@ -830,7 +913,7 @@ private boolean method156(int var1, int var2, int var5, int var6, boolean var7) return false; } else { mapTiles[var8][var9] = 16777216 + var12 * 256; - //this.drawTile(var8, var9, var3, var4); + // this.drawTile(var8, var9, var3, var4); int[] var16 = this.method158(var8, var9, var13, var14, var12, var15, var7, 0); if (!var7 && (var16[2] == 12 || var16[2] == 13)) { mapTiles[var16[0]][var16[1]] = 35061760 + var16[2] * 256; @@ -853,7 +936,10 @@ private int method157(int var1, int var2) { int var5 = mapTiles[var1][var2] / 256 % 256; if (var3 == 1 && var4 == 0 && var5 <= 15) { for (int var6 = 0; var6 < this.anInt2809; ++var6) { - if (this.playerX[var6] > (double) (var1 * 15) && this.playerX[var6] < (double) (var1 * 15 + 15 - 1) && this.playerY[var6] > (double) (var2 * 15) && this.playerY[var6] < (double) (var2 * 15 + 15 - 1)) { + if (this.playerX[var6] > (double) (var1 * 15) + && this.playerX[var6] < (double) (var1 * 15 + 15 - 1) + && this.playerY[var6] > (double) (var2 * 15) + && this.playerY[var6] < (double) (var2 * 15 + 15 - 1)) { return -1; } } @@ -868,7 +954,7 @@ private int method157(int var1, int var2) { } private int[] method158(int var1, int var2, int var3, int var4, int var5, int var6, boolean var9, int var10) { - int[] var11 = new int[]{var3, var4, var6}; + int[] var11 = new int[] {var3, var4, var6}; if (!var9 && var6 >= 4 && var6 <= 11 && var10 < 1078) { var1 = var3; var2 = var4; @@ -913,7 +999,7 @@ private void method159(int var1, int var2) { mapTiles[var5][var6] = 16777216 + var9 * 256 + var9; } - //this.drawTile(var5, var6, var3, var4); + // this.drawTile(var5, var6, var3, var4); } } @@ -987,7 +1073,27 @@ private double method150(int var1, double var2) { } private double method151(int var1) { - return var1 != 0 && (var1 < 4 || var1 > 11) && var1 != 19 && var1 != 47 ? (var1 == 1 ? 0.92D : (var1 == 2 ? 0.8D : (var1 != 3 && var1 != 32 && var1 != 34 && var1 != 36 && var1 != 38 ? (var1 != 12 && var1 != 13 ? (var1 != 14 && var1 != 15 ? (var1 >= 20 && var1 <= 23 ? 0.995D : (var1 == 25 ? 0.96D : (var1 != 28 && var1 != 30 ? (var1 != 29 && var1 != 31 ? (var1 == 44 ? 0.9D : 1.0D) : 0.9D) : 1.0D))) : 0.95D) : 0.0D) : 0.9975D))) : 0.9935D; + return var1 != 0 && (var1 < 4 || var1 > 11) && var1 != 19 && var1 != 47 + ? (var1 == 1 + ? 0.92D + : (var1 == 2 + ? 0.8D + : (var1 != 3 && var1 != 32 && var1 != 34 && var1 != 36 && var1 != 38 + ? (var1 != 12 && var1 != 13 + ? (var1 != 14 && var1 != 15 + ? (var1 >= 20 && var1 <= 23 + ? 0.995D + : (var1 == 25 + ? 0.96D + : (var1 != 28 && var1 != 30 + ? (var1 != 29 && var1 != 31 + ? (var1 == 44 ? 0.9D : 1.0D) + : 0.9D) + : 1.0D))) + : 0.95D) + : 0.0D) + : 0.9975D))) + : 0.9935D; } private void method145(int var1, boolean var2) { @@ -1031,6 +1137,4 @@ private void method164(int var1) { anIntArray2837[2] = var1; anInt2838 = this.anInt2839; } - - } diff --git a/client/src/main/java/agolf/game/PlayerInfoPanel.java b/client/src/main/java/agolf/game/PlayerInfoPanel.java index f4c5d185..8a96f5b7 100644 --- a/client/src/main/java/agolf/game/PlayerInfoPanel.java +++ b/client/src/main/java/agolf/game/PlayerInfoPanel.java @@ -4,7 +4,6 @@ import agolf.GameContainer; import agolf.SynchronizedInteger; import com.aapeli.colorgui.Choicer; - import java.awt.Color; import java.awt.Font; import java.awt.Graphics; @@ -24,10 +23,13 @@ class PlayerInfoPanel extends Panel implements ItemListener, MouseListener { private static final Color aColor372 = new Color(128, 208, 128); private static final Color losingComparisonColor = new Color(224, 0, 0); private static final Color leadingComparisonColor = new Color(0, 128, 0); - private static final Color[][] playerColors = new Color[][]{ // first color == player is in game, second == player has left the game - {new Color(0, 0, 255), new Color(128, 128, 255)}, {new Color(255, 0, 0), new Color(255, 128, 128)}, - {new Color(128, 128, 0), new Color(128, 128, 64)}, {new Color(0, 160, 0), new Color(64, 160, 64)} - }; + private static final Color[][] playerColors = + new Color[][] { // first color == player is in game, second == player has left the game + {new Color(0, 0, 255), new Color(128, 128, 255)}, + {new Color(255, 0, 0), new Color(255, 128, 128)}, + {new Color(128, 128, 0), new Color(128, 128, 64)}, + {new Color(0, 160, 0), new Color(64, 160, 64)} + }; private static int scoreComparisonMode; private GameContainer gameContainer; @@ -58,7 +60,6 @@ class PlayerInfoPanel extends Panel implements ItemListener, MouseListener { private TimerThread timerThread; private int timeRemainingForShot; // seconds - protected PlayerInfoPanel(GameContainer gameContainer, int width, int height) { this.gameContainer = gameContainer; this.width = width; @@ -97,11 +98,19 @@ public void update(Graphics g) { comparedResults = this.resultsToCompareScoreAgainst[scoreComparisonMode - 1]; this.graphics.setFont(fontDialog12); this.graphics.setColor(aColor372); - this.graphics.drawString(this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultNick"), 20, 20); + this.graphics.drawString( + this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultNick"), 20, 20); int totalComparisonStrokes = 0; - for (int comparedTrackIndex = 0; comparedTrackIndex <= this.currentTrackIndex && comparedTrackIndex < this.trackCount; ++comparedTrackIndex) { - this.graphics.drawString(comparedResults[comparedTrackIndex] > 0 ? String.valueOf(comparedResults[comparedTrackIndex]) : "?", 130 + comparedTrackIndex * 20, 20); + for (int comparedTrackIndex = 0; + comparedTrackIndex <= this.currentTrackIndex && comparedTrackIndex < this.trackCount; + ++comparedTrackIndex) { + this.graphics.drawString( + comparedResults[comparedTrackIndex] > 0 + ? String.valueOf(comparedResults[comparedTrackIndex]) + : "?", + 130 + comparedTrackIndex * 20, + 20); totalComparisonStrokes += comparedResults[comparedTrackIndex]; } @@ -114,8 +123,10 @@ public void update(Graphics g) { // draw highlight around scores for current track if (this.currentTrackIndex >= 0 && this.currentTrackIndex < this.trackCount) { this.graphics.setColor(currentTrackScoreHighlightColor); - this.graphics.fillRect(130 + this.currentTrackIndex * 20 - 5 + 1, yBaseline - 13, 19, this.playerCount * 15 + 2); - this.graphics.fillRect(130 + this.currentTrackIndex * 20 - 5, yBaseline - 13 + 1, 21, this.playerCount * 15 + 2 - 2); + this.graphics.fillRect( + 130 + this.currentTrackIndex * 20 - 5 + 1, yBaseline - 13, 19, this.playerCount * 15 + 2); + this.graphics.fillRect( + 130 + this.currentTrackIndex * 20 - 5, yBaseline - 13 + 1, 21, this.playerCount * 15 + 2 - 2); } // draw player status text @@ -151,21 +162,28 @@ public void update(Graphics g) { } } - this.graphics.drawString(strokes >= 0 ? String.valueOf(strokes) : this.gameContainer.textManager.getGame("GamePlayerInfo_Skipped"), 130 + track * 20, yOffset); + this.graphics.drawString( + strokes >= 0 + ? String.valueOf(strokes) + : this.gameContainer.textManager.getGame("GamePlayerInfo_Skipped"), + 130 + track * 20, + yOffset); this.graphics.setColor(color); } else if (this.trackScoresMultipliers[track] == 1) { this.graphics.drawString("-", 130 + track * 20 + 5, yOffset); } else { this.graphics.setFont(fontDialog10); this.graphics.setColor(playerColors[player][1]); - this.graphics.drawString("(*" + this.trackScoresMultipliers[track] + ")", 130 + track * 20, yOffset - 1); + this.graphics.drawString( + "(*" + this.trackScoresMultipliers[track] + ")", 130 + track * 20, yOffset - 1); this.graphics.setFont(font); this.graphics.setColor(color); } } // draw sum of player strokes - this.graphics.drawString("= " + this.totalStrokes[player].get(), 130 + this.trackCount * 20 + 15, yOffset); + this.graphics.drawString( + "= " + this.totalStrokes[player].get(), 130 + this.trackCount * 20 + 15, yOffset); String scoreDifference = null; int[] scoreDifferences = this.getScoreDifferences(); @@ -176,7 +194,9 @@ public void update(Graphics g) { scoreDifference = this.gameContainer.textManager.getGame("GamePlayerInfo_Leader"); } } else { - scoreDifference = this.gameContainer.textManager.getGame("GamePlayerInfo_AfterLeader", (scoreDifferences[player] > 0 ? "+" : "") + scoreDifferences[player]); + scoreDifference = this.gameContainer.textManager.getGame( + "GamePlayerInfo_AfterLeader", + (scoreDifferences[player] > 0 ? "+" : "") + scoreDifferences[player]); } if (scoreDifference != null) { @@ -203,7 +223,6 @@ public void update(Graphics g) { } } - if (this.gameOutcome != null) { if (this.gameOutcome[player] == 1) { statusMessage = "GamePlayerInfo_Winner"; @@ -213,7 +232,10 @@ public void update(Graphics g) { } if (statusMessage != null) { - this.graphics.drawString(this.gameContainer.textManager.getGame(statusMessage) + timeRemaining, 130 + this.trackCount * 20 + 15 + 40 + 40, yOffset); + this.graphics.drawString( + this.gameContainer.textManager.getGame(statusMessage) + timeRemaining, + 130 + this.trackCount * 20 + 15 + 40 + 40, + yOffset); } String extraMessage = null; @@ -234,7 +256,10 @@ public void update(Graphics g) { } if (extraMessage != null) { - this.graphics.drawString(this.gameContainer.textManager.getGame(extraMessage), 130 + this.trackCount * 20 + 15 + 40 + 40 + 100, yOffset); + this.graphics.drawString( + this.gameContainer.textManager.getGame(extraMessage), + 130 + this.trackCount * 20 + 15 + 40 + 40 + 100, + yOffset); } } } @@ -247,11 +272,9 @@ public void itemStateChanged(ItemEvent var1) { this.repaint(); } - public void mouseEntered(MouseEvent var1) { - } + public void mouseEntered(MouseEvent var1) {} - public void mouseExited(MouseEvent var1) { - } + public void mouseExited(MouseEvent var1) {} public void mousePressed(MouseEvent var1) { if (var1.getClickCount() == 2) { @@ -265,15 +288,12 @@ public void mousePressed(MouseEvent var1) { var3 += 15; } - } } - public void mouseReleased(MouseEvent var1) { - } + public void mouseReleased(MouseEvent var1) {} - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} protected void init(int playerCount, int trackCount, int maxStrokes, int strokeTimeout, int trackScoring) { this.playerCount = playerCount; @@ -480,12 +500,12 @@ protected void setState(int state) { } } } - } protected void method372() { if (this.trackScoring == 0) { - this.totalStrokes[this.activePlayerId].add(-this.trackStrokes[this.activePlayerId][this.currentTrackIndex].get()); + this.totalStrokes[this.activePlayerId].add( + -this.trackStrokes[this.activePlayerId][this.currentTrackIndex].get()); } this.trackStrokes[this.activePlayerId][this.currentTrackIndex].set(-1); @@ -493,7 +513,7 @@ protected void method372() { } protected String[] getPlayerName(int playerId) { - return new String[]{this.playerNames[playerId], this.playerClans[playerId]}; + return new String[] {this.playerNames[playerId], this.playerClans[playerId]}; } protected String[] getPlayerNames() { @@ -504,10 +524,14 @@ protected void initResultsComparison(int[][] results) { this.resultsToCompareScoreAgainst = results; this.compareResultsChoicer = new Choicer(); this.compareResultsChoicer.addItem(this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultNone")); - this.compareResultsChoicer.addItem(this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultOwn", this.playerNames[0])); - this.compareResultsChoicer.addItem(this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultTop100Average")); - this.compareResultsChoicer.addItem(this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultBestOfDay")); - this.compareResultsChoicer.addItem(this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultBestOfAllTime")); + this.compareResultsChoicer.addItem( + this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultOwn", this.playerNames[0])); + this.compareResultsChoicer.addItem( + this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultTop100Average")); + this.compareResultsChoicer.addItem( + this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultBestOfDay")); + this.compareResultsChoicer.addItem( + this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultBestOfAllTime")); this.compareResultsChoicer.addItem(this.gameContainer.textManager.getGame("GamePlayerInfo_CompareResultIdeal")); this.compareResultsChoicer.select(scoreComparisonMode); this.compareResultsChoicer.setBounds(555, 5, 170, 20); @@ -537,7 +561,6 @@ protected void stopTimer() { this.timerThread.stopRunning(); this.timerThread = null; } - } private int[] getScoreDifferences() { diff --git a/client/src/main/java/agolf/game/TimerThread.java b/client/src/main/java/agolf/game/TimerThread.java index 61d74ba7..7b38396c 100644 --- a/client/src/main/java/agolf/game/TimerThread.java +++ b/client/src/main/java/agolf/game/TimerThread.java @@ -7,7 +7,6 @@ class TimerThread implements Runnable { private final PlayerInfoPanel playerInfoPanel; private boolean running; - protected TimerThread(PlayerInfoPanel playerInfoPanel) { this.playerInfoPanel = playerInfoPanel; this.running = true; @@ -23,7 +22,6 @@ public void run() { this.running = this.playerInfoPanel.run(); } } while (this.running); - } protected void stopRunning() { diff --git a/client/src/main/java/agolf/game/TrackInfoPanel.java b/client/src/main/java/agolf/game/TrackInfoPanel.java index 61bbb5f0..0538bf49 100644 --- a/client/src/main/java/agolf/game/TrackInfoPanel.java +++ b/client/src/main/java/agolf/game/TrackInfoPanel.java @@ -4,7 +4,6 @@ import agolf.GameContainer; import com.aapeli.client.StringDraw; import com.aapeli.colorgui.ColorButton; - import java.awt.Color; import java.awt.Font; import java.awt.Graphics; @@ -19,11 +18,11 @@ class TrackInfoPanel extends Panel implements ActionListener { private static final Font fontDialog14 = new Font("Dialog", Font.PLAIN, 14); private static final Font fontSerif16 = new Font("Serif", Font.PLAIN, 16); private static final Font fontDialog11 = new Font("Dialog", Font.PLAIN, 11); - private static final Color[] voteColours = new Color[]{ - new Color(192, 0, 0), new Color(255, 0, 0), new Color(255, 64, 0), - new Color(255, 128, 0), new Color(255, 192, 0), new Color(255, 255, 0), - new Color(192, 255, 0), new Color(128, 255, 0), new Color(64, 255, 0), - new Color(0, 255, 0), new Color(64, 255, 64) + private static final Color[] voteColours = new Color[] { + new Color(192, 0, 0), new Color(255, 0, 0), new Color(255, 64, 0), + new Color(255, 128, 0), new Color(255, 192, 0), new Color(255, 255, 0), + new Color(192, 255, 0), new Color(128, 255, 0), new Color(64, 255, 0), + new Color(0, 255, 0), new Color(64, 255, 64) }; private GameContainer gameContainer; @@ -58,7 +57,6 @@ class TrackInfoPanel extends Panel implements ActionListener { private Graphics graphics; private boolean created; - protected TrackInfoPanel(GameContainer gameContainer, int width, int height, boolean var4) { this.gameContainer = gameContainer; this.width = width; @@ -101,14 +99,26 @@ public void update(Graphics g) { this.graphics.setColor(GameApplet.colourTextDarkGreen); int xMod = this.showLongAvgResult ? 20 : 0; if (this.currentTrack == -1) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("GameTrackInfo_NumberOfTracks", this.numTracks), this.width / 4 - xMod, 15, 0); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("GameTrackInfo_NumberOfTracks", this.numTracks), + this.width / 4 - xMod, + 15, + 0); } else { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("GameTrackInfo_CurrentTrack", this.currentTrack + 1, this.numTracks), this.width / 4 - xMod, 15, 0); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame( + "GameTrackInfo_CurrentTrack", this.currentTrack + 1, this.numTracks), + this.width / 4 - xMod, + 15, + 0); this.graphics.setColor(GameApplet.colourTextBlack); Font font; - for (font = fontSerif16; this.getFontMetrics(font).stringWidth(this.trackName) / 2 > this.width / 4 - xMod; font = new Font(font.getName(), font.getStyle(), font.getSize() - 1)) { - } + for (font = fontSerif16; + this.getFontMetrics(font).stringWidth(this.trackName) / 2 > this.width / 4 - xMod; + font = new Font(font.getName(), font.getStyle(), font.getSize() - 1)) {} this.graphics.setFont(font); StringDraw.drawString(this.graphics, this.trackName, this.width / 4 - xMod, 35, 0); @@ -119,12 +129,20 @@ public void update(Graphics g) { this.graphics.setFont(fontDialog12); this.graphics.setColor(GameApplet.colourTextBlack); if (this.resultAverage > 0.0D) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("GameTrackInfo_AverageResult" + keySuffix, this.gameContainer.textManager.getNumber(this.resultAverage, 1)), this.width * 3 / 4 - xMod, this.lastBestPlayerName == null ? 15 : 12, 0); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame( + "GameTrackInfo_AverageResult" + keySuffix, + this.gameContainer.textManager.getNumber(this.resultAverage, 1)), + this.width * 3 / 4 - xMod, + this.lastBestPlayerName == null ? 15 : 12, + 0); } String resultBestText; if (this.resultBestNumStrokes > 0) { - resultBestText = this.gameContainer.textManager.getGame("GameTrackInfo_BestResult" + keySuffix, this.resultBestNumStrokes); + resultBestText = this.gameContainer.textManager.getGame( + "GameTrackInfo_BestResult" + keySuffix, this.resultBestNumStrokes); String resultText = resultBestText + " "; if (this.resultBestPercent > 0.0D) { byte roundingPrecision = 0; @@ -140,34 +158,74 @@ public void update(Graphics g) { roundingPrecision = 3; } - resultText = resultText + this.gameContainer.textManager.getGame("GameTrackInfo_BestResultPercent" + keySuffix, this.gameContainer.textManager.getNumber(this.resultBestPercent, roundingPrecision)); + resultText = resultText + + this.gameContainer.textManager.getGame( + "GameTrackInfo_BestResultPercent" + keySuffix, + this.gameContainer.textManager.getNumber( + this.resultBestPercent, roundingPrecision)); } else { - resultText = resultText + this.gameContainer.textManager.getGame("GameTrackInfo_BestResultUnique" + keySuffix); + resultText = resultText + + this.gameContainer.textManager.getGame("GameTrackInfo_BestResultUnique" + keySuffix); } this.graphics.setColor(GameApplet.colourTextDarkGreen); - int textWidth = StringDraw.drawString(this.graphics, resultText, this.width * 3 / 4 - xMod, this.lastBestPlayerName == null ? 35 : 29, 0); + int textWidth = StringDraw.drawString( + this.graphics, + resultText, + this.width * 3 / 4 - xMod, + this.lastBestPlayerName == null ? 35 : 29, + 0); this.graphics.setColor(GameApplet.colourTextBlack); - this.graphics.drawString(resultBestText, this.width * 3 / 4 - xMod - textWidth / 2, this.lastBestPlayerName == null ? 35 : 29); + this.graphics.drawString( + resultBestText, + this.width * 3 / 4 - xMod - textWidth / 2, + this.lastBestPlayerName == null ? 35 : 29); this.graphics.setClip(0, 0, this.width, this.height); this.graphics.setFont(fontDialog11); this.graphics.setColor(GameApplet.colourTextDarkGreen); - resultBestText = this.firstBestPlayerName != null ? this.gameContainer.textManager.getGame("GameTrackInfo_BestResultFirstBy" + keySuffix, this.firstBestPlayerName, this.firstBestPlayerDate) : this.gameContainer.textManager.getGame("GameTrackInfo_BestResultFirstByUnknown" + keySuffix); - StringDraw.drawString(this.graphics, resultBestText, this.width * 3 / 4 - xMod, this.lastBestPlayerName == null ? 55 : 45, 2); + resultBestText = this.firstBestPlayerName != null + ? this.gameContainer.textManager.getGame( + "GameTrackInfo_BestResultFirstBy" + keySuffix, + this.firstBestPlayerName, + this.firstBestPlayerDate) + : this.gameContainer.textManager.getGame( + "GameTrackInfo_BestResultFirstByUnknown" + keySuffix); + StringDraw.drawString( + this.graphics, + resultBestText, + this.width * 3 / 4 - xMod, + this.lastBestPlayerName == null ? 55 : 45, + 2); if (this.lastBestPlayerName != null) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("GameTrackInfo_BestResultLastBy" + keySuffix, this.lastBestPlayerName, this.lastBestPlayerDate), this.width * 3 / 4 - xMod, 60, 2); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame( + "GameTrackInfo_BestResultLastBy" + keySuffix, + this.lastBestPlayerName, + this.lastBestPlayerDate), + this.width * 3 / 4 - xMod, + 60, + 2); } this.graphics.setColor(GameApplet.colourTextBlack); } if (this.hasNotRatedTrack) { - this.graphics.drawString(this.gameContainer.textManager.getGame("GameTrackInfo_GiveRating"), 10, this.height - 4); + this.graphics.drawString( + this.gameContainer.textManager.getGame("GameTrackInfo_GiveRating"), 10, this.height - 4); } if (!this.hasNotRatedTrack && !this.trackPending && this.trackAverageRating >= 0.0D) { this.graphics.setFont(fontDialog12); - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("GameTrackInfo_Rating", this.gameContainer.textManager.getNumber(this.trackAverageRating, 1)), this.width / 4 - xMod, this.height - 4, 0); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame( + "GameTrackInfo_Rating", + this.gameContainer.textManager.getNumber(this.trackAverageRating, 1)), + this.width / 4 - xMod, + this.height - 4, + 0); } if (this.trackPending) { @@ -197,12 +255,11 @@ public void actionPerformed(ActionEvent evt) { } } - if(evtSource == buttonReject || evtSource == buttonAccept) { + if (evtSource == buttonReject || evtSource == buttonAccept) { this.gameContainer.gamePanel.respondNewGame(this.currentTrack, evtSource == this.buttonAccept); this.toggleAcceptRejectButtons(false); this.repaint(); - } - else if (evtSource == this.buttonBack) { + } else if (evtSource == this.buttonBack) { this.gameContainer.gamePanel.backToPrivate(this.currentTrack); this.setBackButtonVisible(false); this.repaint(); @@ -221,7 +278,16 @@ protected void setNumTracks(int numTracks) { this.repaint(); } - protected void parseTrackInfoStats(String trackAuthor, String trackName, int[] parStats, int[] someRatingStats, String firstBest, String lastBest, boolean trackTestMode1, boolean trackTestMode2, boolean var9) { + protected void parseTrackInfoStats( + String trackAuthor, + String trackName, + int[] parStats, + int[] someRatingStats, + String firstBest, + String lastBest, + boolean trackTestMode1, + boolean trackTestMode2, + boolean var9) { ++this.currentTrack; this.trackAuthor = trackAuthor; this.trackName = trackName; @@ -258,10 +324,11 @@ protected void parseTrackInfoStats(String trackAuthor, String trackName, int[] p this.trackRating += 10 * someRatingStats[10]; } - this.trackAverageRating = (double) this.trackRating / (double) this.trackTotalRatings; // i think its average rating + this.trackAverageRating = + (double) this.trackRating / (double) this.trackTotalRatings; // i think its average rating } - if (!this.gameContainer.synchronizedTrackTestMode.get()) { // Toggles some buttons??! + if (!this.gameContainer.synchronizedTrackTestMode.get()) { // Toggles some buttons??! this.setHasNotRatedTrack(true); } else { this.toggleAcceptRejectButtons(trackTestMode1); @@ -315,7 +382,7 @@ private void create() { } private String[] parseBestPlayerInformation(String data) { - String[] bestPlayerInformation = new String[]{null, null}; + String[] bestPlayerInformation = new String[] {null, null}; if (data != null) { int splitPosition = data.indexOf(','); bestPlayerInformation[0] = data.substring(0, splitPosition); diff --git a/client/src/main/java/agolf/lobby/LobbyChatPanel.java b/client/src/main/java/agolf/lobby/LobbyChatPanel.java index 3d6d1d0e..5384ee9f 100644 --- a/client/src/main/java/agolf/lobby/LobbyChatPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyChatPanel.java @@ -15,9 +15,14 @@ class LobbyChatPanel extends ChatLobby implements GlobalChatListener { private GameContainer gameContainer; private int lobbyId; - protected LobbyChatPanel(GameContainer gameContainer, int width, int height, int lobbyId) { - super(gameContainer.params, gameContainer.textManager, gameContainer.imageManager, gameContainer.badWordFilter, width, height); + super( + gameContainer.params, + gameContainer.textManager, + gameContainer.imageManager, + gameContainer.badWordFilter, + width, + height); this.setMessageMaximumLength(200); this.gameContainer = gameContainer; this.lobbyId = lobbyId; @@ -35,8 +40,7 @@ protected LobbyChatPanel(GameContainer gameContainer, int width, int height, int this.addChatListener(this); } - public void localUserSay(String var1) { - } + public void localUserSay(String var1) {} public void localUserSay(int var1, String var2) { this.gameContainer.lobbyPanel.writeData("say\t" + var1 + "\t" + var2); @@ -56,17 +60,19 @@ public void localUserAdminCommand(String var1, String var2, String var3) { protected boolean handlePacket(String[] args) { if (args[1].equals("numberofusers")) { - if ((this.lobbyId != 1 || aBoolean3712) && (this.lobbyId != 2 || aBoolean3713) && (this.lobbyId != 3 || aBoolean3714)) { + if ((this.lobbyId != 1 || aBoolean3712) + && (this.lobbyId != 2 || aBoolean3713) + && (this.lobbyId != 3 || aBoolean3714)) { if (this.lobbyId == 1) { - aBoolean3712 = false;// ?? + aBoolean3712 = false; // ?? } if (this.lobbyId == 2) { - aBoolean3713 = false;// ?? + aBoolean3713 = false; // ?? } if (this.lobbyId == 3) { - aBoolean3714 = false;// ?? + aBoolean3714 = false; // ?? } } else { super.chatTextArea.clear(); @@ -121,7 +127,8 @@ protected boolean handlePacket(String[] args) { } if (lobbyUsers >= 2 && ingameUsers >= 2) { - message = this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyXX", lobbyUsers, ingameUsers); + message = + this.gameContainer.textManager.getGame("LobbyChat_UsersInThisLobbyXX", lobbyUsers, ingameUsers); } super.chatTextArea.addPlainMessage(message); @@ -133,7 +140,9 @@ protected boolean handlePacket(String[] args) { } if (dualLobbyUsers >= 2) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInDualPlayerLobbyX", dualLobbyUsers); + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInDualPlayerLobbyX", dualLobbyUsers); } if (dualLobbyUsers >= 1 && multiLobbyUsers >= 1) { @@ -145,7 +154,9 @@ protected boolean handlePacket(String[] args) { } if (multiLobbyUsers >= 2) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInMultiPlayerLobbyX", multiLobbyUsers); + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInMultiPlayerLobbyX", multiLobbyUsers); } message = message + ")"; @@ -158,7 +169,9 @@ protected boolean handlePacket(String[] args) { } if (singleLobbyUsers >= 2) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInSinglePlayerLobbyX", singleLobbyUsers); + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInSinglePlayerLobbyX", singleLobbyUsers); } if (singleLobbyUsers >= 1 && multiLobbyUsers >= 1) { @@ -170,7 +183,9 @@ protected boolean handlePacket(String[] args) { } if (multiLobbyUsers >= 2) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInMultiPlayerLobbyX", multiLobbyUsers); + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInMultiPlayerLobbyX", multiLobbyUsers); } message = message + ")"; @@ -183,7 +198,9 @@ protected boolean handlePacket(String[] args) { } if (singleLobbyUsers >= 2) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInSinglePlayerLobbyX", singleLobbyUsers); + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInSinglePlayerLobbyX", singleLobbyUsers); } if (singleLobbyUsers >= 1 && dualLobbyUsers >= 1) { @@ -195,7 +212,9 @@ protected boolean handlePacket(String[] args) { } if (dualLobbyUsers >= 2) { - message = message + this.gameContainer.textManager.getGame("LobbyChat_UsersInDualPlayerLobbyX", dualLobbyUsers); + message = message + + this.gameContainer.textManager.getGame( + "LobbyChat_UsersInDualPlayerLobbyX", dualLobbyUsers); } message = message + ")"; @@ -207,8 +226,7 @@ protected boolean handlePacket(String[] args) { super.chatTextArea.addText(); return true; - } - else if(args[1].equals("users")) { + } else if (args[1].equals("users")) { int i = args.length - 2; String[] users = new String[i]; @@ -216,76 +234,72 @@ else if(args[1].equals("users")) { this.setFullUserList(users); return true; - } - else if(args[1].equals("ownjoin")) { + } else if (args[1].equals("ownjoin")) { this.localUserJoin(args[2]); return true; - } - else if(args[1].equals("join") || args[1].equals("joinfromgame")) { + } else if (args[1].equals("join") || args[1].equals("joinfromgame")) { String userData = this.userJoin(args[2]); if (!this.isNoJoinPartMessages()) { - super.chatTextArea.addJoinMessage(this.gameContainer.textManager.getGame("LobbyChat_User" + (args[1].equals("join") ? "Joined" : "ReturnedFromGame"), userData)); + super.chatTextArea.addJoinMessage(this.gameContainer.textManager.getGame( + "LobbyChat_User" + (args[1].equals("join") ? "Joined" : "ReturnedFromGame"), userData)); } return true; - } - else if(args[1].equals("part")) { + } else if (args[1].equals("part")) { this.userLeft(args[2]); int reason = Integer.parseInt(args[3]); - if(reason == 1 && this.lobbyId == 1) { + if (reason == 1 && this.lobbyId == 1) { if (!this.isNoGameMessages()) { - super.chatTextArea.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UserStartedSp", args[2])); + super.chatTextArea.addMessage( + this.gameContainer.textManager.getGame("LobbyChat_UserStartedSp", args[2])); } return true; - } else if(reason == 2 || reason == 3) { + } else if (reason == 2 || reason == 3) { if (!this.isNoGameMessages()) { - String[] reasons = new String[]{null, null, "CreatedMp", "JoinedMp"}; + String[] reasons = new String[] {null, null, "CreatedMp", "JoinedMp"}; String var5; if (args.length == 4) { var5 = this.gameContainer.textManager.getGame("LobbyChat_User" + reasons[reason], args[2]); } else { - var5 = this.gameContainer.textManager.getGame("LobbyChat_User" + reasons[reason], args[2], args[4]); + var5 = this.gameContainer.textManager.getGame( + "LobbyChat_User" + reasons[reason], args[2], args[4]); } super.chatTextArea.addMessage(var5); } return true; - } else if(reason >= 4) { + } else if (reason >= 4) { if (!this.isNoJoinPartMessages()) { - super.chatTextArea.addPartMessage(this.gameContainer.textManager.getGame("LobbyChat_UserLeft" + (reason == 5 ? "ConnectionProblem" : ""), args[2])); + super.chatTextArea.addPartMessage(this.gameContainer.textManager.getGame( + "LobbyChat_UserLeft" + (reason == 5 ? "ConnectionProblem" : ""), args[2])); } return true; } else { return true; } - } - else if(args[1].equals("gsn")) { + } else if (args[1].equals("gsn")) { if (!this.isNoGameMessages()) { - super.chatTextArea.addMessage(this.gameContainer.textManager.getGame("LobbyChat_UsersStartedDp", args[2], args[3])); + super.chatTextArea.addMessage( + this.gameContainer.textManager.getGame("LobbyChat_UsersStartedDp", args[2], args[3])); } return true; - } - else if (args[1].equals("say")) { + } else if (args[1].equals("say")) { this.userSay(Integer.parseInt(args[2]), args[3], args[4]); return true; - } - else if (args[1].equals("sayp")) { + } else if (args[1].equals("sayp")) { this.userSayPrivately(args[2], args[3]); return true; - } - else if (args[1].equals("sheriffsay")) { + } else if (args[1].equals("sheriffsay")) { this.sheriffSay(args[2]); return true; - } - else if (args[1].equals("serversay")) { + } else if (args[1].equals("serversay")) { this.serverSay(args[2]); return true; - } - else if (args[1].equals("nc")) { + } else if (args[1].equals("nc")) { this.getUser(args[2], args[3].equals("t")); return true; } diff --git a/client/src/main/java/agolf/lobby/LobbyControlPanel.java b/client/src/main/java/agolf/lobby/LobbyControlPanel.java index b6de1eee..c4807167 100644 --- a/client/src/main/java/agolf/lobby/LobbyControlPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyControlPanel.java @@ -4,7 +4,6 @@ import agolf.GameContainer; import agolf.LobbySelectPanel; import com.aapeli.colorgui.ColorButton; - import java.awt.Graphics; import java.awt.Panel; import java.awt.event.ActionEvent; @@ -17,11 +16,10 @@ class LobbyControlPanel extends Panel implements ActionListener { private int height; private ColorButton buttonBack; private ColorButton buttonSingle; - //private ColorButton buttonDual; + // private ColorButton buttonDual; private ColorButton buttonMulti; private ColorButton buttonQuit; - protected LobbyControlPanel(GameContainer gameContainer, int width, int height) { this.gameContainer = gameContainer; this.width = width; @@ -55,10 +53,10 @@ public void actionPerformed(ActionEvent evt) { byte lobbyId = 0; if (evtSource == this.buttonSingle) { lobbyId = 1; - /* - } else if (evtSource == this.buttonDual) { - lobbyId = 2; - */ + /* + } else if (evtSource == this.buttonDual) { + lobbyId = 2; + */ } else if (evtSource == this.buttonMulti) { lobbyId = 3; } @@ -67,7 +65,6 @@ public void actionPerformed(ActionEvent evt) { this.gameContainer.gameApplet.setGameState(0); this.gameContainer.lobbyPanel.writeData(LobbySelectPanel.getLobbySelectMessage(lobbyId)); } - } } @@ -77,7 +74,7 @@ protected void setState(int state) { this.remove(this.buttonSingle); } -// this.remove(this.buttonDual); + // this.remove(this.buttonDual); this.remove(this.buttonMulti); if (!this.gameContainer.disableSinglePlayer && state != 1) { this.add(this.buttonSingle); diff --git a/client/src/main/java/agolf/lobby/LobbyDualPlayerPanel.java b/client/src/main/java/agolf/lobby/LobbyDualPlayerPanel.java index fc91187d..7e8db152 100644 --- a/client/src/main/java/agolf/lobby/LobbyDualPlayerPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyDualPlayerPanel.java @@ -9,7 +9,6 @@ import com.aapeli.colorgui.ColorCheckbox; import com.aapeli.multiuser.ChallengeFloodProtection; import com.aapeli.multiuser.NoChallCheckbox; - import java.awt.Color; import java.awt.Graphics; import java.awt.Image; @@ -52,12 +51,13 @@ class LobbyDualPlayerPanel extends IPanel implements ItemListener, ActionListene private ChallengeFloodProtection challengeFloodProtection; private Image image; private Graphics graphics; - //private Choicer choicerTrackCategory; - //private int trackCategory; - //private boolean isUsingCustomServer; + + // private Choicer choicerTrackCategory; + // private int trackCategory; + // private boolean isUsingCustomServer; protected LobbyDualPlayerPanel(GameContainer gameContainer, int width, int height) { - //isUsingCustomServer = Launcher.isUsingCustomServer(); + // isUsingCustomServer = Launcher.isUsingCustomServer(); this.gameContainer = gameContainer; this.width = width; this.height = height; @@ -80,63 +80,225 @@ public void update(Graphics g) { Color colourTextOutline = new Color(102, 204, 255); this.graphics.setColor(GameApplet.colourTextBlack); this.graphics.setFont(GameApplet.fontSerif26b); - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbySelect_DualPlayer"), this.width / 2, 32, 0); + StringDraw.drawString( + this.graphics, this.gameContainer.textManager.getGame("LobbySelect_DualPlayer"), this.width / 2, 32, 0); this.graphics.setFont(GameApplet.fontSerif20); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_ChallengeTitle"), this.width / 2 - 185, 40, 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_ChallengeTitle"), + this.width / 2 - 185, + 40, + 1); byte yPos = 73; byte yPos2 = 23; this.graphics.setFont(GameApplet.fontDialog12); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_TrackCount"), this.width / 2 - 185, yPos, 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_TrackCount"), + this.width / 2 - 185, + yPos, + 1); /*if(isUsingCustomServer) { StringDraw.drawOutlinedString(this.graphics, colourTextOutline, "Track category:", this.width / 2 - 185, yPos + yPos2, 1); }*/ - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), this.width / 2 - 185, yPos + yPos2 * (/*isUsingCustomServer ? 2 :*/ 1), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_MaxStrokes"), this.width / 2 - 185, yPos + yPos2 * (/*isUsingCustomServer ? 3 :*/ 2), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_TimeLimit"), this.width / 2 - 185, yPos + yPos2 * (/*isUsingCustomServer ? 4 :*/ 3), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), this.width / 2 - 185, yPos + yPos2 * (/*isUsingCustomServer ? 5 :*/ 4), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_Collision"), this.width / 2 - 185, yPos + yPos2 * (/*isUsingCustomServer ? 6 :*/ 5), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_Scoring"), this.width / 2 - 185, yPos + yPos2 * (/*isUsingCustomServer ? 7 :*/ 6), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd"), this.width / 2 - 185, yPos + yPos2 * (/*isUsingCustomServer ? 8 :*/ 7), 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), + this.width / 2 - 185, + yPos + yPos2 * (/*isUsingCustomServer ? 2 :*/ 1), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_MaxStrokes"), + this.width / 2 - 185, + yPos + yPos2 * (/*isUsingCustomServer ? 3 :*/ 2), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_TimeLimit"), + this.width / 2 - 185, + yPos + yPos2 * (/*isUsingCustomServer ? 4 :*/ 3), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), + this.width / 2 - 185, + yPos + yPos2 * (/*isUsingCustomServer ? 5 :*/ 4), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_Collision"), + this.width / 2 - 185, + yPos + yPos2 * (/*isUsingCustomServer ? 6 :*/ 5), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_Scoring"), + this.width / 2 - 185, + yPos + yPos2 * (/*isUsingCustomServer ? 7 :*/ 6), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd"), + this.width / 2 - 185, + yPos + yPos2 * (/*isUsingCustomServer ? 8 :*/ 7), + 1); synchronized (synchronizedObject) { if (this.currentState > 0) { int xPos = this.width * 3 / 4 - 15; this.graphics.setFont(GameApplet.fontDialog14b); if (this.currentState == 1) { - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_ChallengingTitle", this.opponentName), xPos, 55, 0); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_ChallengingTitle", this.opponentName), + xPos, + 55, + 0); } if (this.currentState == 2) { - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_ChallengedTitle", this.opponentName), xPos, 55, 0); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_ChallengedTitle", this.opponentName), + xPos, + 55, + 0); } this.graphics.setFont(GameApplet.fontDialog12); yPos = 83; yPos2 = 17; - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_TrackCount"), xPos - 5, yPos, 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, String.valueOf(this.tracksNum), xPos, yPos, -1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_TrackCount"), + xPos - 5, + yPos, + 1); + StringDraw.drawOutlinedString( + this.graphics, colourTextOutline, String.valueOf(this.tracksNum), xPos, yPos, -1); /*if(isUsingCustomServer) { StringDraw.drawOutlinedString(this.graphics, colourTextOutline, "Track category:", xPos - 5, yPos + yPos2, 1); StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_TrackTypes" + this.trackCategory), xPos, yPos + yPos2, -1); }*/ - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), xPos - 5, yPos + yPos2 * (/*isUsingCustomServer ? 2 :*/ 1), 1); - //todo check if challenger is an admin -> and shit (for the custom tracks only thing) - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_TrackTypes" + this.trackType), xPos, yPos + yPos2 * (/*isUsingCustomServer ? 2 :*/ 1), -1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_MaxStrokes"), xPos - 5, yPos + yPos2 * (/*isUsingCustomServer ? 3 :*/ 2), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.maxStrokes == 0 ? this.gameContainer.textManager.getGame("LobbyReal_MaxStrokesUnlimited") : String.valueOf(this.maxStrokes), xPos, yPos + yPos2 * (/*isUsingCustomServer ? 3 :*/ 2), -1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_TimeLimit"), xPos - 5, yPos + yPos2 * (/*isUsingCustomServer ? 4 :*/ 3), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.lobbyPanel.getTime(this.timeLimit), xPos, yPos + yPos2 * (/*isUsingCustomServer ? 4 :*/ 3), -1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), xPos - 5, yPos + yPos2 * (/*isUsingCustomServer ? 5 :*/ 4), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_WaterEvent" + (this.waterEvent + 1)), xPos, yPos + yPos2 * (/*isUsingCustomServer ? 5 :*/ 4), -1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_Collision"), xPos - 5, yPos + yPos2 * (/*isUsingCustomServer ? 6 :*/ 5), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_Collision" + (this.collision + 1)), xPos, yPos + yPos2 * (/*isUsingCustomServer ? 6 :*/ 5), -1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_Scoring"), xPos - 5, yPos + yPos2 * (/*isUsingCustomServer ? 7 :*/ 6), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_Scoring" + (this.scoring + 1)), xPos, yPos + yPos2 * (/*isUsingCustomServer ? 7 :*/ 6), -1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd"), xPos - 5, yPos + yPos2 * (/*isUsingCustomServer ? 8 :*/ 7), 1); - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd" + this.scoringEnd), xPos, yPos + yPos2 * (/*isUsingCustomServer ? 8 :*/ 7), -1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), + xPos - 5, + yPos + yPos2 * (/*isUsingCustomServer ? 2 :*/ 1), + 1); + // todo check if challenger is an admin -> and shit (for the custom tracks only + // thing) + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_TrackTypes" + this.trackType), + xPos, + yPos + yPos2 * (/*isUsingCustomServer ? 2 :*/ 1), + -1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_MaxStrokes"), + xPos - 5, + yPos + yPos2 * (/*isUsingCustomServer ? 3 :*/ 2), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.maxStrokes == 0 + ? this.gameContainer.textManager.getGame("LobbyReal_MaxStrokesUnlimited") + : String.valueOf(this.maxStrokes), + xPos, + yPos + yPos2 * (/*isUsingCustomServer ? 3 :*/ 2), + -1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_TimeLimit"), + xPos - 5, + yPos + yPos2 * (/*isUsingCustomServer ? 4 :*/ 3), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.lobbyPanel.getTime(this.timeLimit), + xPos, + yPos + yPos2 * (/*isUsingCustomServer ? 4 :*/ 3), + -1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), + xPos - 5, + yPos + yPos2 * (/*isUsingCustomServer ? 5 :*/ 4), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_WaterEvent" + (this.waterEvent + 1)), + xPos, + yPos + yPos2 * (/*isUsingCustomServer ? 5 :*/ 4), + -1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_Collision"), + xPos - 5, + yPos + yPos2 * (/*isUsingCustomServer ? 6 :*/ 5), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_Collision" + (this.collision + 1)), + xPos, + yPos + yPos2 * (/*isUsingCustomServer ? 6 :*/ 5), + -1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_Scoring"), + xPos - 5, + yPos + yPos2 * (/*isUsingCustomServer ? 7 :*/ 6), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_Scoring" + (this.scoring + 1)), + xPos, + yPos + yPos2 * (/*isUsingCustomServer ? 7 :*/ 6), + -1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd"), + xPos - 5, + yPos + yPos2 * (/*isUsingCustomServer ? 8 :*/ 7), + 1); + StringDraw.drawOutlinedString( + this.graphics, + colourTextOutline, + this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd" + this.scoringEnd), + xPos, + yPos + yPos2 * (/*isUsingCustomServer ? 8 :*/ 7), + -1); } if (this.extraText != null) { - StringDraw.drawOutlinedString(this.graphics, colourTextOutline, this.extraText, this.width * 3 / 4, this.height - 120, 0); + StringDraw.drawOutlinedString( + this.graphics, colourTextOutline, this.extraText, this.width * 3 / 4, this.height - 120, 0); } } @@ -173,7 +335,6 @@ public void itemStateChanged(ItemEvent evt) { this.gameContainer.lobbyPanel.writeData("nc\t" + (noChallenges ? 't' : 'f')); this.gameContainer.lobbyPanel.getUser(null, noChallenges); } - } } @@ -195,7 +356,8 @@ public void actionPerformed(ActionEvent evt) { } if (!this.challengeFloodProtection.isOkToChallenge(challengeTarget)) { - this.gameContainer.lobbyPanel.addMessage(this.gameContainer.textManager.getShared("Chat_MessageChallengeFlood")); + this.gameContainer.lobbyPanel.addMessage( + this.gameContainer.textManager.getShared("Chat_MessageChallengeFlood")); return; } @@ -212,7 +374,24 @@ public void actionPerformed(ActionEvent evt) { this.trackCategory = this.choicerTrackCategory.getSelectedIndex(); }*/ this.update(1); - this.gameContainer.lobbyPanel.writeData("challenge\t" + this.opponentName + "\t" + this.tracksNum + "\t" + this.trackType + "\t" + this.maxStrokes + "\t" + this.timeLimit + "\t" + this.waterEvent + "\t" + this.collision + "\t" + this.scoring + "\t" + this.scoringEnd /*+ (isUsingCustomServer ? ("\t" + this.trackCategory) : "")*/); + this.gameContainer.lobbyPanel.writeData("challenge\t" + + this.opponentName + + "\t" + + this.tracksNum + + "\t" + + this.trackType + + "\t" + + this.maxStrokes + + "\t" + + this.timeLimit + + "\t" + + this.waterEvent + + "\t" + + this.collision + + "\t" + + this.scoring + + "\t" + + this.scoringEnd /*+ (isUsingCustomServer ? ("\t" + this.trackCategory) : "")*/); return; } } @@ -232,7 +411,6 @@ public void actionPerformed(ActionEvent evt) { if (evtSource == this.buttonRefuse) { this.refuse(); } - } } } @@ -372,18 +550,27 @@ private void create() { /*if(isUsingCustomServer) { choicerTrackCategory = this.gameContainer.lobbyPanel.addChoicerTrackCategory(this, this.width / 2 - 170, 81, 150, 20); }*/ - this.choicerTracksNum = this.gameContainer.lobbyPanel.addChoicerNumTracks(this, this.width / 2 - 170, 58, 50, 20); - this.choicerTrackTypes = this.gameContainer.lobbyPanel.addChoicerTrackTypes(this, this.width / 2 - 170, /*isUsingCustomServer ? 104 :*/ 81, 150, 20); + this.choicerTracksNum = + this.gameContainer.lobbyPanel.addChoicerNumTracks(this, this.width / 2 - 170, 58, 50, 20); + this.choicerTrackTypes = this.gameContainer.lobbyPanel.addChoicerTrackTypes( + this, this.width / 2 - 170, /*isUsingCustomServer ? 104 :*/ 81, 150, 20); this.choicerTrackTypes.addItemListener(this); - this.choicerMaxStrokes = this.gameContainer.lobbyPanel.addChoicerMaxStrokes(this, this.width / 2 - 170, /*isUsingCustomServer ? 127 :*/ 104, 100, 20); - this.choicerTimeLimit = this.gameContainer.lobbyPanel.addChoicerTimeLimit(this, this.width / 2 - 170, /*isUsingCustomServer ? 150 :*/ 127, 100, 20); - this.choicerWaterEvent = this.gameContainer.lobbyPanel.addChoicerWaterEvent(this, this.width / 2 - 170, /*isUsingCustomServer ? 173 :*/ 150, 150, 20); - this.choicerCollision = this.gameContainer.lobbyPanel.addChoicerCollision(this, this.width / 2 - 170, /*isUsingCustomServer ? 196 :*/ 173, 100, 20); - this.choicerScoring = this.gameContainer.lobbyPanel.addChoicerScoring(this, this.width / 2 - 170, /*isUsingCustomServer ? 219 :*/ 196, 150, 20); - this.choicerScoringEnd = this.gameContainer.lobbyPanel.addChoicerScoringEnd(this, this.width / 2 - 170, /*isUsingCustomServer ? 242 :*/ 219, 100, 20); + this.choicerMaxStrokes = this.gameContainer.lobbyPanel.addChoicerMaxStrokes( + this, this.width / 2 - 170, /*isUsingCustomServer ? 127 :*/ 104, 100, 20); + this.choicerTimeLimit = this.gameContainer.lobbyPanel.addChoicerTimeLimit( + this, this.width / 2 - 170, /*isUsingCustomServer ? 150 :*/ 127, 100, 20); + this.choicerWaterEvent = this.gameContainer.lobbyPanel.addChoicerWaterEvent( + this, this.width / 2 - 170, /*isUsingCustomServer ? 173 :*/ 150, 150, 20); + this.choicerCollision = this.gameContainer.lobbyPanel.addChoicerCollision( + this, this.width / 2 - 170, /*isUsingCustomServer ? 196 :*/ 173, 100, 20); + this.choicerScoring = this.gameContainer.lobbyPanel.addChoicerScoring( + this, this.width / 2 - 170, /*isUsingCustomServer ? 219 :*/ 196, 150, 20); + this.choicerScoringEnd = this.gameContainer.lobbyPanel.addChoicerScoringEnd( + this, this.width / 2 - 170, /*isUsingCustomServer ? 242 :*/ 219, 100, 20); this.buttonChallenge = new ColorButton(this.gameContainer.textManager.getGame("LobbyReal_Challenge")); this.buttonChallenge.setBackground(GameApplet.colourButtonGreen); - this.buttonChallenge.setBounds(this.width / 2 - 170, this.height - 15 - 25 + (/*isUsingCustomServer ? 10 :*/ 0), 100, 25); + this.buttonChallenge.setBounds( + this.width / 2 - 170, this.height - 15 - 25 + (/*isUsingCustomServer ? 10 :*/ 0), 100, 25); this.buttonChallenge.addActionListener(this); this.add(this.buttonChallenge); this.buttonCancel = new ColorButton(this.gameContainer.textManager.getGame("LobbyReal_Cancel")); @@ -399,10 +586,12 @@ private void create() { this.buttonRefuse.setBounds(this.width * 3 / 4 + 10, this.height - 40 - 25, 100, 25); this.buttonRefuse.addActionListener(this); int var1 = this.width * 3 / 4 - this.width / 8 - 10; - this.checkboxBeep = new ColorCheckbox(this.gameContainer.textManager.getGame("LobbyReal_BeepOnChallenge"), true); + this.checkboxBeep = + new ColorCheckbox(this.gameContainer.textManager.getGame("LobbyReal_BeepOnChallenge"), true); this.checkboxBeep.setBounds(var1, this.height - 10 - 18 - 5 - 18, this.width / 4 + 20, 18); this.add(this.checkboxBeep); - this.checkboxNoChallenges = new NoChallCheckbox(this.gameContainer.textManager.getGame("LobbyReal_NoChallengesToMe")); + this.checkboxNoChallenges = + new NoChallCheckbox(this.gameContainer.textManager.getGame("LobbyReal_NoChallengesToMe")); this.checkboxNoChallenges.setBounds(var1, this.height - 10 - 18, this.width / 4 + 20, 18); this.checkboxNoChallenges.addItemListener(this); this.add(this.checkboxNoChallenges); diff --git a/client/src/main/java/agolf/lobby/LobbyGamePasswordPanel.java b/client/src/main/java/agolf/lobby/LobbyGamePasswordPanel.java index 73919d74..d50b6568 100644 --- a/client/src/main/java/agolf/lobby/LobbyGamePasswordPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyGamePasswordPanel.java @@ -3,7 +3,6 @@ import agolf.GameApplet; import agolf.GameContainer; import com.aapeli.colorgui.ColorButton; - import java.awt.Graphics; import java.awt.Panel; import java.awt.TextField; @@ -22,8 +21,8 @@ class LobbyGamePasswordPanel extends Panel implements KeyListener, ActionListene private ColorButton buttonCancel; private boolean emptyField; - - protected LobbyGamePasswordPanel(GameContainer gameContainer, LobbyMultiPlayerPanel lobbyMultiPlayerPanel, int gameId) { + protected LobbyGamePasswordPanel( + GameContainer gameContainer, LobbyMultiPlayerPanel lobbyMultiPlayerPanel, int gameId) { this.gameContainer = gameContainer; this.lobbyMultiPlayerPanel = lobbyMultiPlayerPanel; this.gameId = gameId; @@ -58,14 +57,11 @@ public void keyPressed(KeyEvent evt) { this.joinGame(); } } - } - public void keyReleased(KeyEvent var1) { - } + public void keyReleased(KeyEvent var1) {} - public void keyTyped(KeyEvent var1) { - } + public void keyTyped(KeyEvent var1) {} public void actionPerformed(ActionEvent evt) { Object evtSource = evt.getSource(); @@ -76,7 +72,6 @@ public void actionPerformed(ActionEvent evt) { if (evtSource == this.buttonCancel) { this.lobbyMultiPlayerPanel.joinMultiPlayerGame(this.gameId, null); } - } private void create() { diff --git a/client/src/main/java/agolf/lobby/LobbyMultiPlayerPanel.java b/client/src/main/java/agolf/lobby/LobbyMultiPlayerPanel.java index c6f346ba..5def7cb3 100644 --- a/client/src/main/java/agolf/lobby/LobbyMultiPlayerPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyMultiPlayerPanel.java @@ -10,7 +10,6 @@ import com.aapeli.colorgui.MultiColorList; import com.aapeli.colorgui.MultiColorListItem; import com.aapeli.colorgui.MultiColorListListener; - import java.awt.Color; import java.awt.Graphics; import java.awt.Image; @@ -44,10 +43,11 @@ class LobbyMultiPlayerPanel extends Panel implements ItemListener, ActionListene private LobbyGamePasswordPanel lobbyGamePasswordPanel; private Image image; private Graphics graphics; - //private boolean isUsingCustomServer; + + // private boolean isUsingCustomServer; protected LobbyMultiPlayerPanel(GameContainer gameContainer, int width, int height) { - //isUsingCustomServer = Launcher.isUsingCustomServer(); + // isUsingCustomServer = Launcher.isUsingCustomServer(); this.gameContainer = gameContainer; this.width = width; this.height = height; @@ -76,74 +76,214 @@ public void update(Graphics g) { Color var2 = new Color(76, 229, 255); this.graphics.setColor(GameApplet.colourTextBlack); this.graphics.setFont(GameApplet.fontSerif26b); - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbySelect_MultiPlayer"), this.width / 2, 35, 0); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbySelect_MultiPlayer"), + this.width / 2, + 35, + 0); this.graphics.setFont(GameApplet.fontSerif20); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_CreateTitle"), this.width / 2 - 165, 50, 1); - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_JoinTitle"), this.width * 3 / 4, 60, 0); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_CreateTitle"), + this.width / 2 - 165, + 50, + 1); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_JoinTitle"), + this.width * 3 / 4, + 60, + 0); byte yPos = 86; this.graphics.setFont(GameApplet.fontDialog12); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_PlayerCount"), this.width / 2 - 185, yPos, 1); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_TrackCount"), this.width / 2 - 185, yPos + 24, 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_PlayerCount"), + this.width / 2 - 185, + yPos, + 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_TrackCount"), + this.width / 2 - 185, + yPos + 24, + 1); if (this.gameContainer.gameApplet.isEmailVerified()) { - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_GameName"), this.width / 2 - 185, yPos + 50, 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_GameName"), + this.width / 2 - 185, + yPos + 50, + 1); } - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_GamePassword"), this.width / 2 - 185, yPos + 72, 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_GamePassword"), + this.width / 2 - 185, + yPos + 72, + 1); if (this.gameContainer.gameApplet.isEmailVerified()) { - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_OnlyFor"), this.width / 2 - 185, yPos + 94, 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_OnlyFor"), + this.width / 2 - 185, + yPos + 94, + 1); } - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), this.width / 2 - 185, yPos + 117, 1); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_MaxStrokes"), this.width / 2 - 185, yPos + 140, 1); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_TimeLimit"), this.width / 2 - 185, yPos + 163, 1); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), this.width / 2 - 185, yPos + 186, 1); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_Collision"), this.width / 2 - 185, yPos + 209, 1); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_Scoring"), this.width / 2 - 185, yPos + 232, 1); - StringDraw.drawOutlinedString(this.graphics, var2, this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd"), this.width / 2 - 185, yPos + 255, 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), + this.width / 2 - 185, + yPos + 117, + 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_MaxStrokes"), + this.width / 2 - 185, + yPos + 140, + 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_TimeLimit"), + this.width / 2 - 185, + yPos + 163, + 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), + this.width / 2 - 185, + yPos + 186, + 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_Collision"), + this.width / 2 - 185, + yPos + 209, + 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_Scoring"), + this.width / 2 - 185, + yPos + 232, + 1); + StringDraw.drawOutlinedString( + this.graphics, + var2, + this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd"), + this.width / 2 - 185, + yPos + 255, + 1); if (this.lobbyGamePasswordPanel == null) { int[] gameData = this.getSelectedGameData(); if (gameData != null) { int yPos2 = 220; this.graphics.setFont(GameApplet.fontDialog11); if (gameData[3] != 0) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), this.width - 170, yPos2, 1); - this.graphics.drawString(this.gameContainer.textManager.getIfAvailable("LobbyReal_TrackTypes" + gameData[3], this.gameContainer.textManager.getGame("LobbyReal_TrackTypesTest")), this.width - 165, yPos2); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), + this.width - 170, + yPos2, + 1); + this.graphics.drawString( + this.gameContainer.textManager.getIfAvailable( + "LobbyReal_TrackTypes" + gameData[3], + this.gameContainer.textManager.getGame("LobbyReal_TrackTypesTest")), + this.width - 165, + yPos2); yPos2 += 15; } if (gameData[4] != 20) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_MaxStrokes"), this.width - 170, yPos2, 1); - this.graphics.drawString(gameData[4] == 0 ? this.gameContainer.textManager.getGame("LobbyReal_MaxStrokesUnlimited") : String.valueOf(gameData[4]), this.width - 165, yPos2); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_MaxStrokes"), + this.width - 170, + yPos2, + 1); + this.graphics.drawString( + gameData[4] == 0 + ? this.gameContainer.textManager.getGame("LobbyReal_MaxStrokesUnlimited") + : String.valueOf(gameData[4]), + this.width - 165, + yPos2); yPos2 += 15; } if (gameData[5] > 0) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_TimeLimit"), this.width - 170, yPos2, 1); - this.graphics.drawString(this.gameContainer.lobbyPanel.getTime(gameData[5]), this.width - 165, yPos2); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_TimeLimit"), + this.width - 170, + yPos2, + 1); + this.graphics.drawString( + this.gameContainer.lobbyPanel.getTime(gameData[5]), this.width - 165, yPos2); yPos2 += 15; } if (gameData[6] == 1) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), this.width - 170, yPos2, 1); - this.graphics.drawString(this.gameContainer.textManager.getGame("LobbyReal_WaterEvent2"), this.width - 165, yPos2); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), + this.width - 170, + yPos2, + 1); + this.graphics.drawString( + this.gameContainer.textManager.getGame("LobbyReal_WaterEvent2"), this.width - 165, yPos2); yPos2 += 15; } if (gameData[7] == 0) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_Collision"), this.width - 170, yPos2, 1); - this.graphics.drawString(this.gameContainer.textManager.getGame("LobbyReal_Collision1"), this.width - 165, yPos2); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_Collision"), + this.width - 170, + yPos2, + 1); + this.graphics.drawString( + this.gameContainer.textManager.getGame("LobbyReal_Collision1"), this.width - 165, yPos2); yPos2 += 15; } if (gameData[8] == 1) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_Scoring"), this.width - 170, yPos2, 1); - this.graphics.drawString(this.gameContainer.textManager.getGame("LobbyReal_Scoring2"), this.width - 165, yPos2); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_Scoring"), + this.width - 170, + yPos2, + 1); + this.graphics.drawString( + this.gameContainer.textManager.getGame("LobbyReal_Scoring2"), this.width - 165, yPos2); yPos2 += 15; } if (gameData[9] > 0) { - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd"), this.width - 170, yPos2, 1); - this.graphics.drawString(this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd" + gameData[9]), this.width - 165, yPos2); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd"), + this.width - 170, + yPos2, + 1); + this.graphics.drawString( + this.gameContainer.textManager.getGame("LobbyReal_ScoringEnd" + gameData[9]), + this.width - 165, + yPos2); yPos2 += 15; } } @@ -151,7 +291,12 @@ public void update(Graphics g) { if (this.joinError > 0) { this.graphics.setColor(GameApplet.colourTextRed); - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbyReal_JoinError" + this.joinError), this.width * 3 / 4, this.height - 15, 0); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbyReal_JoinError" + this.joinError), + this.width * 3 / 4, + this.height - 15, + 0); } g.drawImage(this.image, 0, 0, this); @@ -181,7 +326,6 @@ public void itemStateChanged(ItemEvent evt) { if (evtSource == this.trackList) { this.repaint(); } - } } @@ -200,7 +344,30 @@ public void actionPerformed(ActionEvent evt) { gamePassword = "-"; } - this.gameContainer.lobbyPanel.writeData("cmpt\t" + gameName + "\t" + gamePassword + "\t" + this.choicerPermission.getSelectedIndex() + "\t" + (this.choicerNumPlayers.getSelectedIndex() + 2) + "\t" + (this.choicerNumTracks.getSelectedIndex() + 1) + "\t" + this.choicerTrackTypes.getSelectedIndex() + "\t" + (this.choicerMaxStrokes.getSelectedIndex() + 1) * 5 + "\t" + LobbyPanel.gameTimeLimits[this.choicerTimeLimit.getSelectedIndex()] + "\t" + this.choicerWaterEvent.getSelectedIndex() + "\t" + this.choicerCollision.getSelectedIndex() + "\t" + this.choicerScoring.getSelectedIndex() + "\t" + this.choicerScoringEnd.getSelectedIndex()); + this.gameContainer.lobbyPanel.writeData("cmpt\t" + + gameName + + "\t" + + gamePassword + + "\t" + + this.choicerPermission.getSelectedIndex() + + "\t" + + (this.choicerNumPlayers.getSelectedIndex() + 2) + + "\t" + + (this.choicerNumTracks.getSelectedIndex() + 1) + + "\t" + + this.choicerTrackTypes.getSelectedIndex() + + "\t" + + (this.choicerMaxStrokes.getSelectedIndex() + 1) * 5 + + "\t" + + LobbyPanel.gameTimeLimits[this.choicerTimeLimit.getSelectedIndex()] + + "\t" + + this.choicerWaterEvent.getSelectedIndex() + + "\t" + + this.choicerCollision.getSelectedIndex() + + "\t" + + this.choicerScoring.getSelectedIndex() + + "\t" + + this.choicerScoringEnd.getSelectedIndex()); } else { if (evtSource == this.buttonJoin) { this.joinError = 0; @@ -212,7 +379,6 @@ public void actionPerformed(ActionEvent evt) { attemptJoinGame(gameData); } - } } } @@ -275,7 +441,8 @@ protected void create() { this.choicerNumPlayers.select(1); this.choicerNumPlayers.setBounds(this.width / 2 - 170, 71, 50, 20); this.add(this.choicerNumPlayers); - this.choicerNumTracks = this.gameContainer.lobbyPanel.addChoicerNumTracks(this, this.width / 2 - 170, 95, 50, 20); + this.choicerNumTracks = + this.gameContainer.lobbyPanel.addChoicerNumTracks(this, this.width / 2 - 170, 95, 50, 20); this.textFieldGameName = new FilterTextField(this.gameContainer.textManager, "-", 15); this.textFieldGameName.setBounds(this.width / 2 - 170, 121, 150, 20); this.textFieldGameName.setBackground(Color.white); @@ -299,24 +466,38 @@ protected void create() { /*if(isUsingCustomServer) { this.choicerTrackCategory = this.gameContainer.lobbyPanel.addChoicerTrackCategory(this, this.width / 2 - 170, 188, 150, 20); }*/ - this.choicerTrackTypes = this.gameContainer.lobbyPanel.addChoicerTrackTypes(this, this.width / 2 - 170, /*isUsingCustomServer ? 211 :*/ 188, 150, 20); + this.choicerTrackTypes = this.gameContainer.lobbyPanel.addChoicerTrackTypes( + this, this.width / 2 - 170, /*isUsingCustomServer ? 211 :*/ 188, 150, 20); this.choicerTrackTypes.addItemListener(this); - this.choicerMaxStrokes = this.gameContainer.lobbyPanel.addChoicerMaxStrokes(this, this.width / 2 - 170, /*isUsingCustomServer ? 234 :*/ 211, 100, 20); - this.choicerTimeLimit = this.gameContainer.lobbyPanel.addChoicerTimeLimit(this, this.width / 2 - 170, /*isUsingCustomServer ? 257 :*/ 234, 100, 20); - this.choicerWaterEvent = this.gameContainer.lobbyPanel.addChoicerWaterEvent(this, this.width / 2 - 170, /*isUsingCustomServer ? 280 :*/ 257, 150, 20); - this.choicerCollision = this.gameContainer.lobbyPanel.addChoicerCollision(this, this.width / 2 - 170, /*isUsingCustomServer ? 303 :*/ 280, 100, 20); - this.choicerScoring = this.gameContainer.lobbyPanel.addChoicerScoring(this, this.width / 2 - 170, /*isUsingCustomServer ? 326 :*/ 303, 150, 20); - this.choicerScoringEnd = this.gameContainer.lobbyPanel.addChoicerScoringEnd(this, this.width / 2 - 170, /*isUsingCustomServer ? 349 :*/ 326, 100, 20); + this.choicerMaxStrokes = this.gameContainer.lobbyPanel.addChoicerMaxStrokes( + this, this.width / 2 - 170, /*isUsingCustomServer ? 234 :*/ 211, 100, 20); + this.choicerTimeLimit = this.gameContainer.lobbyPanel.addChoicerTimeLimit( + this, this.width / 2 - 170, /*isUsingCustomServer ? 257 :*/ 234, 100, 20); + this.choicerWaterEvent = this.gameContainer.lobbyPanel.addChoicerWaterEvent( + this, this.width / 2 - 170, /*isUsingCustomServer ? 280 :*/ 257, 150, 20); + this.choicerCollision = this.gameContainer.lobbyPanel.addChoicerCollision( + this, this.width / 2 - 170, /*isUsingCustomServer ? 303 :*/ 280, 100, 20); + this.choicerScoring = this.gameContainer.lobbyPanel.addChoicerScoring( + this, this.width / 2 - 170, /*isUsingCustomServer ? 326 :*/ 303, 150, 20); + this.choicerScoringEnd = this.gameContainer.lobbyPanel.addChoicerScoringEnd( + this, this.width / 2 - 170, /*isUsingCustomServer ? 349 :*/ 326, 100, 20); this.buttonCreate = new ColorButton(this.gameContainer.textManager.getGame("LobbyReal_CreateGame")); this.buttonCreate.setBackground(GameApplet.colourButtonGreen); - this.buttonCreate.setBounds(this.width / 2 - 170, /*isUsingCustomServer ? 372 :*/ 365, 100, /*isUsingCustomServer ? 20 :*/ 25); + this.buttonCreate.setBounds( + this.width / 2 - 170, /*isUsingCustomServer ? 372 :*/ 365, 100, /*isUsingCustomServer ? 20 :*/ 25); this.buttonCreate.addActionListener(this); this.add(this.buttonCreate); - String[] listTitles = new String[]{this.gameContainer.textManager.getGame("LobbyReal_ListTitleUserLimit"), this.gameContainer.textManager.getGame("LobbyReal_ListTitleGame"), this.gameContainer.textManager.getGame("LobbyReal_ListTitlePlayers"), this.gameContainer.textManager.getGame("LobbyReal_ListTitleTracks")}; - int[] var3 = new int[]{0, 0, 2, 3}; + String[] listTitles = new String[] { + this.gameContainer.textManager.getGame("LobbyReal_ListTitleUserLimit"), + this.gameContainer.textManager.getGame("LobbyReal_ListTitleGame"), + this.gameContainer.textManager.getGame("LobbyReal_ListTitlePlayers"), + this.gameContainer.textManager.getGame("LobbyReal_ListTitleTracks") + }; + int[] var3 = new int[] {0, 0, 2, 3}; this.trackList = new MultiColorList(listTitles, var3, 1, this.width / 2 - 40, 125); this.trackList.setLocation(this.width / 2 + 20, 75); - this.trackList.setBackgroundImage(this.gameContainer.imageManager.getImage("bg-lobby-multi-fade"), this.width / 2 + 20, 75); + this.trackList.setBackgroundImage( + this.gameContainer.imageManager.getImage("bg-lobby-multi-fade"), this.width / 2 + 20, 75); this.trackList.setSelectable(1); this.trackList.addItemListener(this); trackList.setListListener(this); @@ -340,7 +521,8 @@ private void askPassword(int gameId) { private void gameListFull(String[] args) { // lobby gamelist full 1 1595122 test f 0 3 -1 10 0 25 90 0 1 0 1 1 - // lobby gamelist full 2 1595122 test f 0 3 -1 10 0 25 90 0 1 0 1 1 1595167 sdm t 0 3 -1 6 1 20 120 0 0 0 0 1 + // lobby gamelist full 2 1595122 test f 0 3 -1 10 0 25 90 0 1 0 1 1 1595167 sdm t 0 3 -1 6 1 + // 20 120 0 0 0 0 1 int numGames = Integer.parseInt(args[3]); int defaultGameId = numGames != 1 ? this.getSelectedGameId() : Integer.parseInt(args[4]); this.trackList.removeAllItems(); @@ -361,15 +543,15 @@ private void gameListAdd(String[] args, int offset, int defaultGameId) { int permission = Integer.parseInt(args[offset + 3]); int maxPlayers = Integer.parseInt(args[offset + 4]); int numTracks = Integer.parseInt(args[offset + 6]); - int trackTypes = Integer.parseInt(args[offset + 7]);// unsure - int maxStrokes = Integer.parseInt(args[offset + 8]);// unsure - int timeLimit = Integer.parseInt(args[offset + 9]);// unsure - int waterEvent = Integer.parseInt(args[offset + 10]);// unsure - int collision = Integer.parseInt(args[offset + 11]);// unsure - int scoring = Integer.parseInt(args[offset + 12]);// unsure - int scoringEnd = Integer.parseInt(args[offset + 13]);// unsure + int trackTypes = Integer.parseInt(args[offset + 7]); // unsure + int maxStrokes = Integer.parseInt(args[offset + 8]); // unsure + int timeLimit = Integer.parseInt(args[offset + 9]); // unsure + int waterEvent = Integer.parseInt(args[offset + 10]); // unsure + int collision = Integer.parseInt(args[offset + 11]); // unsure + int scoring = Integer.parseInt(args[offset + 12]); // unsure + int scoringEnd = Integer.parseInt(args[offset + 13]); // unsure int numPlayers = Integer.parseInt(args[offset + 14]); - //int trackCategory = isUsingCustomServer ? Integer.parseInt(args[offset + 15]) : -1; + // int trackCategory = isUsingCustomServer ? Integer.parseInt(args[offset + 15]) : -1; byte colourIndex = MultiColorListItem.COLOR_BLACK; boolean bold = false; String[] cols = new String[4]; @@ -393,8 +575,19 @@ private void gameListAdd(String[] args, int offset, int defaultGameId) { trackInfo = new int[]{id, passworded ? 1 : 0, permission, trackTypes, maxStrokes, timeLimit, waterEvent, collision, scoring, scoringEnd, trackCategory}; } else {*/ - trackInfo = new int[]{id, passworded ? 1 : 0, permission, trackTypes, maxStrokes, timeLimit, waterEvent, collision, scoring, scoringEnd}; - //} + trackInfo = new int[] { + id, + passworded ? 1 : 0, + permission, + trackTypes, + maxStrokes, + timeLimit, + waterEvent, + collision, + scoring, + scoringEnd + }; + // } MultiColorListItem track = new MultiColorListItem(colourIndex, bold, cols, trackInfo, id == defaultGameId); this.trackList.addItem(track); } @@ -414,7 +607,6 @@ private void gameListRemove(String[] args) { this.joinError = 0; this.repaint(); } - } private void removeTrack(int var1) { @@ -428,7 +620,6 @@ private void removeTrack(int var1) { return; } } - } } } diff --git a/client/src/main/java/agolf/lobby/LobbyPanel.java b/client/src/main/java/agolf/lobby/LobbyPanel.java index ff5e093e..e7f8eeb4 100644 --- a/client/src/main/java/agolf/lobby/LobbyPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyPanel.java @@ -4,14 +4,13 @@ import agolf.GameContainer; import com.aapeli.colorgui.Choicer; import com.aapeli.multiuser.User; -import org.moparforia.client.Launcher; - import java.awt.Graphics; import java.awt.Panel; +import org.moparforia.client.Launcher; public class LobbyPanel extends Panel { - protected static final int[] gameTimeLimits = new int[]{10, 20, 30, 45, 60, 90, 120}; + protected static final int[] gameTimeLimits = new int[] {10, 20, 30, 45, 60, 90, 120}; private static final int numGameTimeLimits = gameTimeLimits.length; private GameContainer gameContainer; private int width; @@ -27,7 +26,6 @@ public class LobbyPanel extends Panel { private LobbyTrackListAdminPanel lobbyTrackListAdminPanel; public static boolean aBoolean465; - public LobbyPanel(GameContainer gameContainer, int width, int height) { this.gameContainer = gameContainer; this.width = width; @@ -57,7 +55,8 @@ public void selectLobby(int lobbyId, int lobbyExtra) { this.removeAll(); if (lobbyId == 1) { if (this.lobbySinglePlayerPanel == null) { - this.lobbySinglePlayerPanel = new LobbySinglePlayerPanel(this.gameContainer, this.width, this.height - 130); + this.lobbySinglePlayerPanel = + new LobbySinglePlayerPanel(this.gameContainer, this.width, this.height - 130); this.lobbySinglePlayerPanel.setLocation(0, 0); } @@ -88,7 +87,8 @@ public void selectLobby(int lobbyId, int lobbyExtra) { if (lobbyId == 3) { if (this.lobbyMultiPlayerPanel == null) { - this.lobbyMultiPlayerPanel = new LobbyMultiPlayerPanel(this.gameContainer, this.width, this.height - 130); + this.lobbyMultiPlayerPanel = + new LobbyMultiPlayerPanel(this.gameContainer, this.width, this.height - 130); this.lobbyMultiPlayerPanel.setLocation(0, 0); } @@ -103,7 +103,8 @@ public void selectLobby(int lobbyId, int lobbyExtra) { if (lobbyId == -1) { if (this.lobbyTrackListAdminPanel == null) { - this.lobbyTrackListAdminPanel = new LobbyTrackListAdminPanel(this.gameContainer, this.width, this.height, lobbyExtra == 1); + this.lobbyTrackListAdminPanel = + new LobbyTrackListAdminPanel(this.gameContainer, this.width, this.height, lobbyExtra == 1); this.lobbyTrackListAdminPanel.setLocation(0, 0); } @@ -136,14 +137,12 @@ public void method395() { if (this.activeLobby == -1) { this.lobbyTrackListAdminPanel.setRefreshTrackList(); } - } public void setJoinError(int var1) { if (this.lobbyMultiPlayerPanel != null) { this.lobbyMultiPlayerPanel.setJoinError(var1); } - } public void requestTrackSetList() { @@ -188,9 +187,7 @@ public void handlePacket(String[] args) { dummy = true; } - if (dummy) { - } - + if (dummy) {} } public void broadcastMessage(String message) { @@ -205,7 +202,6 @@ public void broadcastMessage(String message) { if (this.lobbyChatPanelMulti != null) { this.lobbyChatPanelMulti.broadcastMessage(message); } - } protected void writeData(String var1) { @@ -250,15 +246,15 @@ protected Choicer addChoicerTrackTypes(Panel container, int x, int y, int width, } boolean b = this.gameContainer.gameApplet.getPlayerAccessLevel() == 2; - if (b && !Launcher.isUsingCustomServer()) {//todo <-- + if (b && !Launcher.isUsingCustomServer()) { // todo <-- c.addItem(this.gameContainer.textManager.getGame("LobbyReal_TrackTypes7") + " (A)"); c.addItem("Only best (A)"); c.addItem("Only pend (A)"); } - //if(Launcher.isUsingCustomServer()) { + // if(Launcher.isUsingCustomServer()) { // c.addItem("Only custom"); - //} + // } c.select(1); c.setBounds(x, y, width, height); @@ -336,7 +332,7 @@ protected Choicer addChoicerScoringEnd(Panel container, int x, int y, int width, protected Choicer addChoicerTrackCategory(Panel container, int x, int y, int width, int height) { Choicer c = new Choicer(); c.addItem("Official"); - //c.addItem("Custom"); + // c.addItem("Custom"); c.select(0); c.setBounds(x, y, width, height); container.add(c); @@ -344,7 +340,9 @@ protected Choicer addChoicerTrackCategory(Panel container, int x, int y, int wid } protected String getTime(int var1) { - return var1 == 0 ? this.gameContainer.textManager.getGame("LobbyReal_TimeLimitNo") : this.gameContainer.textManager.getTime(var1); + return var1 == 0 + ? this.gameContainer.textManager.getGame("LobbyReal_TimeLimitNo") + : this.gameContainer.textManager.getTime(var1); } protected void addMessage(String var1) { diff --git a/client/src/main/java/agolf/lobby/LobbySinglePlayerPanel.java b/client/src/main/java/agolf/lobby/LobbySinglePlayerPanel.java index fa9b408d..95afa2e6 100644 --- a/client/src/main/java/agolf/lobby/LobbySinglePlayerPanel.java +++ b/client/src/main/java/agolf/lobby/LobbySinglePlayerPanel.java @@ -8,8 +8,6 @@ import com.aapeli.colorgui.MultiColorList; import com.aapeli.colorgui.MultiColorListItem; import com.aapeli.colorgui.MultiColorListListener; -import org.moparforia.client.Launcher; - import java.awt.Color; import java.awt.Graphics; import java.awt.Image; @@ -19,6 +17,7 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.StringTokenizer; +import org.moparforia.client.Launcher; class LobbySinglePlayerPanel extends Panel implements ItemListener, ActionListener, MultiColorListListener { @@ -35,7 +34,7 @@ class LobbySinglePlayerPanel extends Panel implements ItemListener, ActionListen private boolean requestTrackSetList; private Image image; private Graphics graphics; - //private Choicer choicerTrackCategory; + // private Choicer choicerTrackCategory; private boolean isUsingCustomServer; protected LobbySinglePlayerPanel(GameContainer var1, int var2, int var3) { @@ -70,39 +69,100 @@ public void update(Graphics g) { Color championshipOutlineColour = new Color(0, 205, 0); this.graphics.setColor(GameApplet.colourTextBlack); this.graphics.setFont(GameApplet.fontSerif26b); - StringDraw.drawString(this.graphics, this.gameContainer.textManager.getGame("LobbySelect_SinglePlayer"), this.width / 2, 37, 0); + StringDraw.drawString( + this.graphics, + this.gameContainer.textManager.getGame("LobbySelect_SinglePlayer"), + this.width / 2, + 37, + 0); byte yPos = -45; this.graphics.setFont(GameApplet.fontSerif20); - StringDraw.drawOutlinedString(this.graphics, trainingOutlineColour, this.gameContainer.textManager.getGame("LobbyReal_TrainingTitle"), this.width / 4, 170 + yPos, 0); - StringDraw.drawOutlinedString(this.graphics, championshipOutlineColour, this.gameContainer.textManager.getGame("LobbyReal_ChampionshipTitle"), this.width * 3 / 4, 195 + yPos - 15 - 15, 0); + StringDraw.drawOutlinedString( + this.graphics, + trainingOutlineColour, + this.gameContainer.textManager.getGame("LobbyReal_TrainingTitle"), + this.width / 4, + 170 + yPos, + 0); + StringDraw.drawOutlinedString( + this.graphics, + championshipOutlineColour, + this.gameContainer.textManager.getGame("LobbyReal_ChampionshipTitle"), + this.width * 3 / 4, + 195 + yPos - 15 - 15, + 0); this.graphics.setFont(GameApplet.fontDialog12); yPos = -45; /*if(isUsingCustomServer) { StringDraw.drawOutlinedString(this.graphics, trainingOutlineColour, "Track category:", this.width / 2 - 190, 235 + yPos, 1); }*/ - StringDraw.drawOutlinedString(this.graphics, trainingOutlineColour, this.gameContainer.textManager.getGame("LobbyReal_TrackCount"), this.width / 2 - 190, 205 + yPos, 1); - StringDraw.drawOutlinedString(this.graphics, trainingOutlineColour, this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), this.width / 2 - 190, (/*isUsingCustomServer ? 265 :*/ 235) + yPos, 1); - StringDraw.drawOutlinedString(this.graphics, trainingOutlineColour, this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), this.width / 2 - 190, (/*isUsingCustomServer ? 295 :*/ 265) + yPos, 1); + StringDraw.drawOutlinedString( + this.graphics, + trainingOutlineColour, + this.gameContainer.textManager.getGame("LobbyReal_TrackCount"), + this.width / 2 - 190, + 205 + yPos, + 1); + StringDraw.drawOutlinedString( + this.graphics, + trainingOutlineColour, + this.gameContainer.textManager.getGame("LobbyReal_TrackTypes"), + this.width / 2 - 190, + (/*isUsingCustomServer ? 265 :*/ 235) + yPos, + 1); + StringDraw.drawOutlinedString( + this.graphics, + trainingOutlineColour, + this.gameContainer.textManager.getGame("LobbyReal_WaterEvent"), + this.width / 2 - 190, + (/*isUsingCustomServer ? 295 :*/ 265) + yPos, + 1); if (this.choicerWaterEvent.getSelectedIndex() == 1) { this.graphics.setColor(GameApplet.colourTextRed); - StringDraw.drawOutlinedString(this.graphics, trainingOutlineColour, this.gameContainer.textManager.getGame("LobbyReal_WaterEventWarning"), this.width / 2 - 190 + 20, (/*isUsingCustomServer ? 325 :*/ 295) + yPos, 0); + StringDraw.drawOutlinedString( + this.graphics, + trainingOutlineColour, + this.gameContainer.textManager.getGame("LobbyReal_WaterEventWarning"), + this.width / 2 - 190 + 20, + (/*isUsingCustomServer ? 325 :*/ 295) + yPos, + 0); this.graphics.setColor(GameApplet.colourTextBlack); } if (this.selectedTrackData != null) { this.graphics.setFont(GameApplet.fontDialog11); StringTokenizer trackData = new StringTokenizer(this.selectedTrackData, "\t"); - String[] trackInfoTitles = new String[]{"LobbyReal_TS_AllTimeBest", "LobbyReal_TS_MonthBest", "LobbyReal_TS_WeekBest", "LobbyReal_TS_DayBest"}; - int[] trackInfoYPos = new int[]{370, 385, 400, 415}; + String[] trackInfoTitles = new String[] { + "LobbyReal_TS_AllTimeBest", "LobbyReal_TS_MonthBest", "LobbyReal_TS_WeekBest", "LobbyReal_TS_DayBest" + }; + int[] trackInfoYPos = new int[] {370, 385, 400, 415}; for (int index = 0; index < 4; ++index) { String strokes = trackData.nextToken(); String recordHolder = trackData.nextToken(); - StringDraw.drawOutlinedString(this.graphics, championshipOutlineColour, this.gameContainer.textManager.getGame(trackInfoTitles[index]), this.width - 240, trackInfoYPos[index] + yPos, 1); + StringDraw.drawOutlinedString( + this.graphics, + championshipOutlineColour, + this.gameContainer.textManager.getGame(trackInfoTitles[index]), + this.width - 240, + trackInfoYPos[index] + yPos, + 1); if (!recordHolder.equals("0")) { - StringDraw.drawOutlinedString(this.graphics, championshipOutlineColour, recordHolder + " (" + strokes + ")", this.width - 235, trackInfoYPos[index] + yPos, -1); + StringDraw.drawOutlinedString( + this.graphics, + championshipOutlineColour, + recordHolder + " (" + strokes + ")", + this.width - 235, + trackInfoYPos[index] + yPos, + -1); } else { - StringDraw.drawOutlinedString(this.graphics, championshipOutlineColour, "-", this.width - 235, trackInfoYPos[index] + yPos, -1); + StringDraw.drawOutlinedString( + this.graphics, + championshipOutlineColour, + "-", + this.width - 235, + trackInfoYPos[index] + yPos, + -1); } } } @@ -126,7 +186,14 @@ public void actionPerformed(ActionEvent evt) { Object var2 = evt.getSource(); if (var2 == this.buttonStartTraining) { this.gameContainer.gameApplet.setGameState(0); - this.gameContainer.lobbyPanel.writeData("cspt\t" + (this.choicerTracksNum.getSelectedIndex() + 1) + "\t" + this.choicerTrackTypes.getSelectedIndex() + "\t" + this.choicerWaterEvent.getSelectedIndex() /*+ (isUsingCustomServer ? ("\t" + this.choicerTrackCategory.getSelectedIndex()) : "")*/); + this.gameContainer.lobbyPanel.writeData( + "cspt\t" + + (this.choicerTracksNum.getSelectedIndex() + 1) + + "\t" + + this.choicerTrackTypes.getSelectedIndex() + + "\t" + + this.choicerWaterEvent + .getSelectedIndex() /*+ (isUsingCustomServer ? ("\t" + this.choicerTrackCategory.getSelectedIndex()) : "")*/); } else { if (var2 == this.buttonStartChampionship) { String var3 = this.getSelectedTrackSetData(); @@ -134,7 +201,6 @@ public void actionPerformed(ActionEvent evt) { startChampionship(Integer.parseInt(var3.substring(0, var3.indexOf(9)))); } } - } } } @@ -148,7 +214,11 @@ protected boolean handlePacket(String[] args) { for (int off = 0; off < numTrackSets; ++off) { String setName = args[2 + off * 11]; int setDifficulty = Integer.parseInt(args[3 + off * 11]); - String[] var7 = new String[]{isUsingCustomServer ? setName : this.gameContainer.textManager.getGame("LobbyReal_TS_" + setName), this.gameContainer.textManager.getGame("LobbyReal_TS_Level" + setDifficulty), args[4 + off * 11]}; + String[] var7 = new String[] { + isUsingCustomServer ? setName : this.gameContainer.textManager.getGame("LobbyReal_TS_" + setName), + this.gameContainer.textManager.getGame("LobbyReal_TS_Level" + setDifficulty), + args[4 + off * 11] + }; if (setDifficulty == 1) { var3 = 2; } else if (setDifficulty == 2) { @@ -157,7 +227,21 @@ protected boolean handlePacket(String[] args) { var3 = 1; } - String var8 = args[5 + off * 11] + "\t" + args[6 + off * 11] + "\t" + args[7 + off * 11] + "\t" + args[8 + off * 11] + "\t" + args[9 + off * 11] + "\t" + args[10 + off * 11] + "\t" + args[11 + off * 11] + "\t" + args[12 + off * 11]; + String var8 = args[5 + off * 11] + + "\t" + + args[6 + off * 11] + + "\t" + + args[7 + off * 11] + + "\t" + + args[8 + off * 11] + + "\t" + + args[9 + off * 11] + + "\t" + + args[10 + off * 11] + + "\t" + + args[11 + off * 11] + + "\t" + + args[12 + off * 11]; boolean var9; if (var9 = off == numTrackSets - 1) { this.selectedTrackData = var8; @@ -183,7 +267,6 @@ protected void requestTrackSetList() { if (this.requestTrackSetList) { this.gameContainer.lobbyPanel.writeData("tracksetlist"); } - } private void create() { @@ -191,20 +274,28 @@ private void create() { /*if(isUsingCustomServer) { this.choicerTrackCategory = this.gameContainer.lobbyPanel.addChoicerTrackCategory(this, this.width / 2 - 170, 175, 150, 20); }*/ - this.choicerTracksNum = this.gameContainer.lobbyPanel.addChoicerNumTracks(this, this.width / 2 - 170, 145, 50, 20); - this.choicerTrackTypes = this.gameContainer.lobbyPanel.addChoicerTrackTypes(this, this.width / 2 - 170, /*isUsingCustomServer ? 205 :*/ 175, 150, 20); - this.choicerWaterEvent = this.gameContainer.lobbyPanel.addChoicerWaterEvent(this, this.width / 2 - 170, /*isUsingCustomServer ? 235 :*/ 205, 150, 20); + this.choicerTracksNum = + this.gameContainer.lobbyPanel.addChoicerNumTracks(this, this.width / 2 - 170, 145, 50, 20); + this.choicerTrackTypes = this.gameContainer.lobbyPanel.addChoicerTrackTypes( + this, this.width / 2 - 170, /*isUsingCustomServer ? 205 :*/ 175, 150, 20); + this.choicerWaterEvent = this.gameContainer.lobbyPanel.addChoicerWaterEvent( + this, this.width / 2 - 170, /*isUsingCustomServer ? 235 :*/ 205, 150, 20); this.choicerWaterEvent.addItemListener(this); this.buttonStartTraining = new ColorButton(this.gameContainer.textManager.getGame("LobbyReal_Start")); this.buttonStartTraining.setBackground(GameApplet.colourButtonGreen); this.buttonStartTraining.setBounds(this.width / 2 - 170, /*isUsingCustomServer ? 300 :*/ 270, 100, 25); this.buttonStartTraining.addActionListener(this); this.add(this.buttonStartTraining); - String[] trackSetListTitles = new String[]{this.gameContainer.textManager.getGame("LobbyReal_TS_TitleName"), this.gameContainer.textManager.getGame("LobbyReal_TS_TitleDifficulty"), this.gameContainer.textManager.getGame("LobbyReal_TS_TitleTracks")}; - int[] var2 = new int[]{0, 0, 4}; + String[] trackSetListTitles = new String[] { + this.gameContainer.textManager.getGame("LobbyReal_TS_TitleName"), + this.gameContainer.textManager.getGame("LobbyReal_TS_TitleDifficulty"), + this.gameContainer.textManager.getGame("LobbyReal_TS_TitleTracks") + }; + int[] var2 = new int[] {0, 0, 4}; this.trackSetList = new MultiColorList(trackSetListTitles, var2, 1, 250, 130); this.trackSetList.setLocation(this.width - 290, 130); - this.trackSetList.setBackgroundImage(this.gameContainer.imageManager.getImage("bg-lobby-single-fade"), this.width - 290, 130); + this.trackSetList.setBackgroundImage( + this.gameContainer.imageManager.getImage("bg-lobby-single-fade"), this.width - 290, 130); this.trackSetList.setSelectable(1); this.trackSetList.addItemListener(this); trackSetList.setListListener(this); diff --git a/client/src/main/java/agolf/lobby/LobbyTrackListAdminPanel.java b/client/src/main/java/agolf/lobby/LobbyTrackListAdminPanel.java index 508048c5..ba5c4e63 100644 --- a/client/src/main/java/agolf/lobby/LobbyTrackListAdminPanel.java +++ b/client/src/main/java/agolf/lobby/LobbyTrackListAdminPanel.java @@ -6,7 +6,6 @@ import com.aapeli.colorgui.ColorButton; import com.aapeli.colorgui.MultiColorList; import com.aapeli.colorgui.MultiColorListItem; - import java.awt.Checkbox; import java.awt.Graphics; import java.awt.Panel; @@ -31,7 +30,6 @@ class LobbyTrackListAdminPanel extends Panel implements ActionListener, ItemList private Checkbox checkboxSafeMode; private ColorButton buttonQuit; - protected LobbyTrackListAdminPanel(GameContainer gameContainer, int width, int height, boolean enableSafeMode) { this.gameContainer = gameContainer; this.width = width; @@ -55,8 +53,10 @@ public void update(Graphics var1) { var1.fillRect(0, 0, this.width, this.height); var1.setFont(GameApplet.fontDialog12); var1.setColor(GameApplet.colourTextBlack); - StringDraw.drawString(var1, "Tracks: " + this.trackList.getItemCount(), this.width / 2 - 100 - 10 + 60, 405, 0); - StringDraw.drawString(var1, "Selected: " + this.trackList.getSelectedItemCount(), this.width / 2 - 100 - 10 + 60, 425, 0); + StringDraw.drawString( + var1, "Tracks: " + this.trackList.getItemCount(), this.width / 2 - 100 - 10 + 60, 405, 0); + StringDraw.drawString( + var1, "Selected: " + this.trackList.getSelectedItemCount(), this.width / 2 - 100 - 10 + 60, 425, 0); } } @@ -128,8 +128,7 @@ protected boolean handlePacket(String[] args) { this.createTrackList(trackList, true); this.repaint(); return true; - } - else if (args[1].equals("tracklist")) { + } else if (args[1].equals("tracklist")) { len = args.length - 2; trackList = new String[len / 2][2]; @@ -149,7 +148,6 @@ protected void setRefreshTrackList() { this.refreshTrackList(); refreshTrackList = false; } - } private void create(boolean enableSafeMode) { @@ -158,8 +156,9 @@ private void create(boolean enableSafeMode) { this.buttonRefresh.setBackground(GameApplet.colourButtonBlue); this.buttonRefresh.addActionListener(this); this.add(this.buttonRefresh); - String[] checkboxTitles = new String[]{"Private", "Pending", "Public", "Trackset"}; - boolean[] checkboxValues = new boolean[]{!enableSafeMode, enableSafeMode ? true : true, !enableSafeMode, !enableSafeMode}; + String[] checkboxTitles = new String[] {"Private", "Pending", "Public", "Trackset"}; + boolean[] checkboxValues = + new boolean[] {!enableSafeMode, enableSafeMode ? true : true, !enableSafeMode, !enableSafeMode}; this.checkboxTracks = new Checkbox[4]; for (int index = 0; index < 4; ++index) { @@ -222,7 +221,6 @@ private void refreshTrackList() { });*/ this.gameContainer.lobbyPanel.writeData("tracklist\t" + params); } - } private void createTrackList(String[][] tracksInfo, boolean isAdmin) { @@ -231,11 +229,11 @@ private void createTrackList(String[][] tracksInfo, boolean isAdmin) { String[] listTitles; int[] var4; if (isAdmin) { - listTitles = new String[]{"Status", "Author", "Track", "Rating"}; - var4 = new int[]{0, 0, 0, 5}; + listTitles = new String[] {"Status", "Author", "Track", "Rating"}; + var4 = new int[] {0, 0, 0, 5}; this.trackList = new MultiColorList(listTitles, var4, 2, 450, 250); } else { - listTitles = new String[]{"Status", "Track"}; + listTitles = new String[] {"Status", "Track"}; var4 = new int[2]; this.trackList = new MultiColorList(listTitles, var4, 1, 450, 250); } @@ -273,18 +271,18 @@ private void createTrackList(String[][] tracksInfo, boolean isAdmin) { tracksInfo[index][0] = "TrackSet"; } - //Status", "Author", "Track", "Rating + // Status", "Author", "Track", "Rating MultiColorListItem listItem; if (isAdmin) { - listItem = new MultiColorListItem(colour, tracksInfo[index], tracksInfo[index][1] + ":" + tracksInfo[index][2]); + listItem = new MultiColorListItem( + colour, tracksInfo[index], tracksInfo[index][1] + ":" + tracksInfo[index][2]); } else { listItem = new MultiColorListItem(colour, tracksInfo[index], tracksInfo[index][1]); } this.trackList.addItem(listItem); } - } private String[] randomize(String[] array) { diff --git a/client/src/main/java/com/aapeli/applet/AApplet.java b/client/src/main/java/com/aapeli/applet/AApplet.java index f115c95a..bbadba24 100644 --- a/client/src/main/java/com/aapeli/applet/AApplet.java +++ b/client/src/main/java/com/aapeli/applet/AApplet.java @@ -9,7 +9,6 @@ import com.aapeli.tools.QuickTimer; import com.aapeli.tools.QuickTimerListener; import com.aapeli.tools.Tools; - import java.applet.Applet; import java.awt.Color; import java.awt.Component; @@ -96,11 +95,9 @@ public void start() { Thread t = new Thread(this); t.start(); } - } - public void stop() { - } + public void stop() {} public void destroy() { this.destroyed = true; @@ -184,43 +181,155 @@ public void update(Graphics graphics) { if (this.endState == END_ERROR_CONNECTION) { byte textYOffset = -20; this.appletGraphics.setFont(fontDialog15); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, this.textManager.getShared("Message_CE_ConnectionError"), 40,80 + textYOffset, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE_ConnectionError"), + 40, + 80 + textYOffset, + -1); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, this.textManager.getShared("Message_CE_PossibleReasons"), 40,125 + textYOffset, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE_PossibleReasons"), + 40, + 125 + textYOffset, + -1); if (!this.ready) { this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, "- " + this.textManager.getShared("Message_CE0_1_Short"), 40,160 + textYOffset, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + "- " + this.textManager.getShared("Message_CE0_1_Short"), + 40, + 160 + textYOffset, + -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, this.textManager.getShared("Message_CE0_1_Long", this.param.getServerIp(), "" + this.param.getServerPort()), 50, 180 + textYOffset, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared( + "Message_CE0_1_Long", + this.param.getServerIp(), + "" + this.param.getServerPort()), + 50, + 180 + textYOffset, + -1, + this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, "- " + this.textManager.getShared("Message_CE0_2_Short"), 40,245 + textYOffset, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + "- " + this.textManager.getShared("Message_CE0_2_Short"), + 40, + 245 + textYOffset, + -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, this.textManager.getShared("Message_CE0_2_Long"), 50,265 + textYOffset, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE0_2_Long"), + 50, + 265 + textYOffset, + -1, + this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, "- " + this.textManager.getShared("Message_CE0_3_Short"), 40,305 + textYOffset, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + "- " + this.textManager.getShared("Message_CE0_3_Short"), + 40, + 305 + textYOffset, + -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, this.textManager.getShared("Message_CE0_3_Long"), 50,325 + textYOffset, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE0_3_Long"), + 50, + 325 + textYOffset, + -1, + this.appletWidth - 50 - 50); } else { this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, "- " + this.textManager.getShared("Message_CE1_1_Short"), 40,160 + textYOffset, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + "- " + this.textManager.getShared("Message_CE1_1_Short"), + 40, + 160 + textYOffset, + -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, this.textManager.getShared("Message_CE1_1_Long"), 50,180 + textYOffset, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE1_1_Long"), + 50, + 180 + textYOffset, + -1, + this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, "- " + this.textManager.getShared("Message_CE1_2_Short"), 40,235 + textYOffset, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + "- " + this.textManager.getShared("Message_CE1_2_Short"), + 40, + 235 + textYOffset, + -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, this.textManager.getShared("Message_CE1_2_Long"), 50,255 + textYOffset, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE1_2_Long"), + 50, + 255 + textYOffset, + -1, + this.appletWidth - 50 - 50); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, "- " + this.textManager.getShared("Message_CE1_3_Short"), 40,305 + textYOffset, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + "- " + this.textManager.getShared("Message_CE1_3_Short"), + 40, + 305 + textYOffset, + -1); this.appletGraphics.setFont(fontDialog11); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, this.textManager.getShared("Message_CE1_3_Long"), 50,325 + textYOffset, -1, this.appletWidth - 50 - 50); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_CE1_3_Long"), + 50, + 325 + textYOffset, + -1, + this.appletWidth - 50 - 50); } } else if (this.endState == END_THROWABLE) { this.appletGraphics.setFont(fontDialog15); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, this.textManager.getShared("Message_PE_ProgramError"), 50,100, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_PE_ProgramError"), + 50, + 100, + -1); this.appletGraphics.setFont(fontDialog12); - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, this.textManager.getShared("Message_PE_GameClosed"), 50,150, -1, this.appletWidth - 70 - 50); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_PE_GameClosed"), + 50, + 150, + -1, + this.appletWidth - 70 - 50); this.appletGraphics.setFont(fontDialog12b); - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, this.textManager.getShared("Message_PE_ErrorDesc", this.aThrowable2553.toString()), 50, 235, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + this.textManager.getShared("Message_PE_ErrorDesc", this.aThrowable2553.toString()), + 50, + 235, + -1); } else { String endText = this.textManager.getShared("Message_WaitWhile"); String endTextHelp = null; @@ -260,21 +369,60 @@ public void update(Graphics graphics) { this.appletGraphics.setFont(fontDialog15); if (this.endTextLocation == TEXT_CENTER) { - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, endText, this.appletWidth / 2, this.appletHeight / 2 - 10, 0); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + endText, + this.appletWidth / 2, + this.appletHeight / 2 - 10, + 0); } else if (this.endTextLocation == TEXT_LOWERLEFT) { - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, endText, this.appletWidth / 12, this.appletHeight - 120, -1); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + endText, + this.appletWidth / 12, + this.appletHeight - 120, + -1); } else if (this.endTextLocation == TEXT_LOWERMIDDLE) { - StringDraw.drawOutlinedString(this.appletGraphics, outlineColor, endText, this.appletWidth / 2, this.appletHeight - 120, 0); + StringDraw.drawOutlinedString( + this.appletGraphics, + outlineColor, + endText, + this.appletWidth / 2, + this.appletHeight - 120, + 0); } if (endTextHelp != null) { this.appletGraphics.setFont(fontDialog12); if (this.endTextLocation == TEXT_CENTER) { - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, endTextHelp, this.appletWidth / 2, this.appletHeight / 2 + 30, 0, (int) ((double) this.appletWidth * 0.8D)); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + endTextHelp, + this.appletWidth / 2, + this.appletHeight / 2 + 30, + 0, + (int) ((double) this.appletWidth * 0.8D)); } else if (this.endTextLocation == TEXT_LOWERLEFT) { - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, endTextHelp, this.appletWidth / 12, this.appletHeight - 80, -1, (int) ((double) this.appletWidth * 0.6D)); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + endTextHelp, + this.appletWidth / 12, + this.appletHeight - 80, + -1, + (int) ((double) this.appletWidth * 0.6D)); } else if (this.endTextLocation == TEXT_LOWERMIDDLE) { - StringDraw.drawOutlinedStringWithMaxWidth(this.appletGraphics, outlineColor, endTextHelp, this.appletWidth / 2, this.appletHeight - 80, 0, (int) ((double) this.appletWidth * 0.5D)); + StringDraw.drawOutlinedStringWithMaxWidth( + this.appletGraphics, + outlineColor, + endTextHelp, + this.appletWidth / 2, + this.appletHeight - 80, + 0, + (int) ((double) this.appletWidth * 0.5D)); } } } @@ -372,7 +520,8 @@ public void run() { this.printSUD("Creating sound manager"); } - this.loadingPanel.setLoadingMessage(this.textManager.getShared("Loader_LoadingGfxSfx") + (adInfo != null ? adInfo : "")); + this.loadingPanel.setLoadingMessage( + this.textManager.getShared("Loader_LoadingGfxSfx") + (adInfo != null ? adInfo : "")); this.soundManager = new SoundManager(this, true, this.isDebug()); if (startupDebug) { this.soundManager.enableSUD(); @@ -414,7 +563,8 @@ public void run() { return; } - this.loadingPanel.setActualProgress(0.7D + this.imageManager.getImageLoadProgress() * 0.15D); + this.loadingPanel.setActualProgress( + 0.7D + this.imageManager.getImageLoadProgress() * 0.15D); } int time5 = (int) (System.currentTimeMillis() - startTime); @@ -450,7 +600,8 @@ public void run() { this.printSUD("Connecting to server..."); } - this.loadingPanel.setLoadingMessage(this.textManager.getShared("Message_Connecting") + (adInfo != null ? adInfo : "")); + this.loadingPanel.setLoadingMessage(this.textManager.getShared("Message_Connecting") + + (adInfo != null ? adInfo : "")); this.loadingPanel.setActualProgress(1.0D); this.connectToServer(); if (startupDebug) { @@ -483,8 +634,11 @@ public void run() { this.printSUD("...done"); } - this.sendLoadTimes(readyTime, finishedTime, time1, time2, time3, time4, time5, time6); - this.writeMetadataLog1("clientconnect", "loadtime:i:" + readyTime + "^loadertime:i:" + finishedTime); + this.sendLoadTimes( + readyTime, finishedTime, time1, time2, time3, time4, time5, time6); + this.writeMetadataLog1( + "clientconnect", + "loadtime:i:" + readyTime + "^loadertime:i:" + finishedTime); this.loadingPanel.displayButtons(); if (this.endState == 0 && !this.destroyed) { this.remove(this.loadingPanel); @@ -497,7 +651,11 @@ public void run() { this.contentPanel = new ContentPanel(this); if (this.backgroundImageKey != null) { - this.contentPanel.setBackground(this.imageManager, this.backgroundImageKey, this.backgroundXOffset, this.backgroundYOffset); + this.contentPanel.setBackground( + this.imageManager, + this.backgroundImageKey, + this.backgroundXOffset, + this.backgroundYOffset); } this.contentPanel.setVisible(false); @@ -533,7 +691,6 @@ public void actionPerformed(ActionEvent action) { e.printStackTrace(); } } - } public void qtFinished() { @@ -605,14 +762,12 @@ public void clearContent() { if (this.endState == 0) { this.contentPanel.destroy(); } - } public void addToContent(Component component) { if (this.endState == 0) { this.contentPanel.add(component); } - } public void contentReady() { @@ -620,20 +775,16 @@ public void contentReady() { this.contentPanel.makeVisible(); this.revalidate(); } - } - /** - * SUD == startup debug - */ + /** SUD == startup debug */ public void printSUD(String var1) { System.out.println("SUD(" + System.currentTimeMillis() + "): " + var1); } public abstract void initApplet(Parameters parameters); - public void textsLoadedNotify(TextManager var1) { - } + public void textsLoadedNotify(TextManager var1) {} public abstract void defineSounds(SoundManager soundManager); @@ -641,8 +792,7 @@ public void textsLoadedNotify(TextManager var1) { public abstract void createImages(); - public void defineSecImages(ImageManager imageManager, String var2) { - } + public void defineSecImages(ImageManager imageManager, String var2) {} public abstract void connectToServer(); @@ -669,7 +819,6 @@ public void waitAndRemoveSplash(int millis, boolean noRepaint) { if (!noRepaint) { this.repaint(); } - } } @@ -700,14 +849,12 @@ public void writeMetadataLog0(String dataType, String data) { if (this.socketConnection != null) { this.socketConnection.writeMetadataLog(0, dataType, data); } - } public void writeMetadataLog1(String dataType, String data) { if (this.socketConnection != null) { this.socketConnection.writeMetadataLog(1, dataType, data); } - } private void removeLoadingPanel() { @@ -718,10 +865,10 @@ private void removeLoadingPanel() { var1 = null; this.loadingPanel = null; } - } - private void sendLoadTimes(int readyTime, int finishedTime, int time1, int time2, int time3, int time4, int time5, int time6) { + private void sendLoadTimes( + int readyTime, int finishedTime, int time1, int time2, int time3, int time4, int time5, int time6) { if (this.isDebug()) { System.out.println("AApplet.sendLoadTimes(" + readyTime + "," + finishedTime + ")"); } @@ -760,7 +907,6 @@ private void sendLoadTimes(int readyTime, int finishedTime, int time1, int time2 this.getAppletContext().showDocument(url); } catch (Exception e) { } - } private String getSystemProperty(String key) { @@ -782,6 +928,5 @@ private void resetPopupTimer() { if (var1 != null) { var1.stopAll(); } - } } diff --git a/client/src/main/java/com/aapeli/applet/AdCanvas.java b/client/src/main/java/com/aapeli/applet/AdCanvas.java index e67dc007..7923966e 100644 --- a/client/src/main/java/com/aapeli/applet/AdCanvas.java +++ b/client/src/main/java/com/aapeli/applet/AdCanvas.java @@ -1,7 +1,6 @@ package com.aapeli.applet; import com.aapeli.client.Parameters; - import java.awt.Canvas; import java.awt.Color; import java.awt.Cursor; @@ -31,7 +30,6 @@ class AdCanvas extends Canvas implements MouseListener { private boolean aBoolean125; private long aLong126; - private AdCanvas(AApplet var1, URL var2, List var3, URL var4, String var5, int var6) { this.gameApplet = var1; this.anURL117 = var2; @@ -76,24 +74,19 @@ public void update(Graphics var1) { var1.drawLine(0, 19, 19, 0); } } - } - public void mouseEntered(MouseEvent var1) { - } + public void mouseEntered(MouseEvent var1) {} - public void mouseExited(MouseEvent var1) { - } + public void mouseExited(MouseEvent var1) {} public void mousePressed(MouseEvent var1) { this.gameApplet.getAppletContext().showDocument(this.anURL119, this.aString120); } - public void mouseReleased(MouseEvent var1) { - } + public void mouseReleased(MouseEvent var1) {} - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} protected static AdCanvas create(AApplet applet, Parameters parameters) { try { @@ -130,7 +123,7 @@ protected static AdCanvas create(AApplet applet, Parameters parameters) { } protected void method212() { - this.anImage122 = Toolkit.getDefaultToolkit().createImage(anURL117);//this.gameApplet.getImage(this.anURL117); + this.anImage122 = Toolkit.getDefaultToolkit().createImage(anURL117); // this.gameApplet.getImage(this.anURL117); } protected boolean method213() { diff --git a/client/src/main/java/com/aapeli/applet/AdCanvasText.java b/client/src/main/java/com/aapeli/applet/AdCanvasText.java index d17a5c20..0c14cb61 100644 --- a/client/src/main/java/com/aapeli/applet/AdCanvasText.java +++ b/client/src/main/java/com/aapeli/applet/AdCanvasText.java @@ -1,7 +1,6 @@ package com.aapeli.applet; import com.aapeli.client.StringDraw; - import java.awt.Color; import java.awt.Font; import java.awt.Graphics; @@ -18,8 +17,8 @@ class AdCanvasText { private Font fontDialog; private int anInt1310; - - private AdCanvasText(int var1, int var2, int var3, int var4, Color var5, Color var6, int size, boolean bold, String var9) { + private AdCanvasText( + int var1, int var2, int var3, int var4, Color var5, Color var6, int size, boolean bold, String var9) { this.anInt1303 = var1; this.anInt1304 = var2; this.anInt1305 = var4; @@ -33,7 +32,6 @@ private AdCanvasText(int var1, int var2, int var3, int var4, Color var5, Color v } else if (var3 == 0) { this.anInt1310 = 0; } - } protected static AdCanvasText method1547(String var0) { @@ -60,11 +58,18 @@ protected void method1548(Graphics var1) { var1.setFont(this.fontDialog); var1.setColor(this.aColor1306); if (this.anInt1305 > 0) { - StringDraw.drawOutlinedStringWithMaxWidth(var1, this.aColor1307, this.aString1308, this.anInt1303, this.anInt1304, this.anInt1310, this.anInt1305); + StringDraw.drawOutlinedStringWithMaxWidth( + var1, + this.aColor1307, + this.aString1308, + this.anInt1303, + this.anInt1304, + this.anInt1310, + this.anInt1305); } else { - StringDraw.drawOutlinedString(var1, this.aColor1307, this.aString1308, this.anInt1303, this.anInt1304, this.anInt1310); + StringDraw.drawOutlinedString( + var1, this.aColor1307, this.aString1308, this.anInt1303, this.anInt1304, this.anInt1310); } - } private static Color hex2Color(String hex, boolean noThrow) throws Exception { diff --git a/client/src/main/java/com/aapeli/applet/ContentPanel.java b/client/src/main/java/com/aapeli/applet/ContentPanel.java index 82980cbc..c38e73b5 100644 --- a/client/src/main/java/com/aapeli/applet/ContentPanel.java +++ b/client/src/main/java/com/aapeli/applet/ContentPanel.java @@ -1,10 +1,8 @@ package com.aapeli.applet; import com.aapeli.client.IPanel; - import java.awt.Dimension; - class ContentPanel extends IPanel { protected ContentPanel(AApplet applet) { @@ -24,6 +22,5 @@ protected void makeVisible() { if (this.getComponentCount() > 0) { this.setVisible(true); } - } } diff --git a/client/src/main/java/com/aapeli/applet/LoadingPanel.java b/client/src/main/java/com/aapeli/applet/LoadingPanel.java index b8db3e27..bbf2029f 100644 --- a/client/src/main/java/com/aapeli/applet/LoadingPanel.java +++ b/client/src/main/java/com/aapeli/applet/LoadingPanel.java @@ -4,7 +4,6 @@ import com.aapeli.client.TextManager; import com.aapeli.colorgui.RoundButton; import com.aapeli.tools.Tools; - import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -38,7 +37,6 @@ class LoadingPanel extends Panel implements Runnable, ActionListener { private RoundButton paymentOptionsButton; private int startGameClicked; - protected LoadingPanel(AApplet applet) { this.gameApplet = applet; this.loadingMessage = null; @@ -154,7 +152,6 @@ public void actionPerformed(ActionEvent action) { this.gameApplet.setEndState(AApplet.END_QUIT_BUYCOINS); this.parameters.showCreditPurchasePage(false); } - } protected void init(Parameters parameters, TextManager textManager) { @@ -226,7 +223,8 @@ protected void displayButtons() { this.startGameButton.addActionListener(this); this.add(this.startGameButton); if (this.parameters.isCreditPurchasePageAvailable()) { - this.paymentOptionsButton = new RoundButton(this.textManager.getShared("Loader_Button_MorePaymentOptions")); + this.paymentOptionsButton = + new RoundButton(this.textManager.getShared("Loader_Button_MorePaymentOptions")); this.paymentOptionsButton.setBounds(this.gameApplet.appletWidth / 2 - 15 - width, 10, width, 35); this.paymentOptionsButton.setBackground(new Color(96, 96, 255)); this.paymentOptionsButton.setForeground(Color.black); @@ -266,7 +264,8 @@ protected synchronized void destroy() { this.gameApplet = null; } - private void drawGradient(Graphics var1, Color color, int top, int bottom, int var5, int var6, int var7, int var8, boolean var9) { + private void drawGradient( + Graphics var1, Color color, int top, int bottom, int var5, int var6, int var7, int var8, boolean var9) { int red = color.getRed(); int green = color.getGreen(); int blue = color.getBlue(); @@ -305,10 +304,20 @@ private void drawGradient(Graphics var1, Color color, int top, int bottom, int v } else { this.drawGradient2(var1, var5, var6, var7, var8, topRed, btmRed, topGreen, btmGreen, topBlue, btmBlue); } - } - private void drawGradient(Graphics var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9, int var10, int var11) { + private void drawGradient( + Graphics var1, + int var2, + int var3, + int var4, + int var5, + int var6, + int var7, + int var8, + int var9, + int var10, + int var11) { for (int var17 = var2; var17 < var3; ++var17) { double var12 = 1.0D * (double) (var17 - var2) / (double) (var3 - var2); int var14 = (int) ((double) var6 + (double) (var7 - var6) * var12); @@ -317,10 +326,20 @@ private void drawGradient(Graphics var1, int var2, int var3, int var4, int var5, var1.setColor(new Color(var14, var15, var16)); var1.drawLine(var4, var17, var5 - 1, var17); } - } - private void drawGradient2(Graphics var1, int var2, int var3, int var4, int var5, int var6, int var7, int var8, int var9, int var10, int var11) { + private void drawGradient2( + Graphics var1, + int var2, + int var3, + int var4, + int var5, + int var6, + int var7, + int var8, + int var9, + int var10, + int var11) { int var20 = -1; for (int var21 = var2; var21 < var3; ++var21) { @@ -348,7 +367,6 @@ private void drawGradient2(Graphics var1, int var2, int var3, int var4, int var5 } } } - } private void drawLoadingMessage(Graphics g, Font font, String s) { diff --git a/client/src/main/java/com/aapeli/applet/RetryCanvas.java b/client/src/main/java/com/aapeli/applet/RetryCanvas.java index 86155510..8e39ad82 100644 --- a/client/src/main/java/com/aapeli/applet/RetryCanvas.java +++ b/client/src/main/java/com/aapeli/applet/RetryCanvas.java @@ -71,7 +71,10 @@ public void update(Graphics graphics) { this.drawButton(this.graphics, this.canvasWidth, this.canvasHeight); this.graphics.setColor(textColor); this.graphics.setFont(dialog12); - this.graphics.drawString(this.message, this.canvasWidth / 2 - this.getFontMetrics(dialog12).stringWidth(this.message) / 2, this.canvasHeight / 2 + dialog12.getSize() * 3 / 8 + 1); + this.graphics.drawString( + this.message, + this.canvasWidth / 2 - this.getFontMetrics(dialog12).stringWidth(this.message) / 2, + this.canvasHeight / 2 + dialog12.getSize() * 3 / 8 + 1); graphics.drawImage(this.image, 0, 0, this); } @@ -107,17 +110,13 @@ public void mouseReleased(MouseEvent e) { ActionEvent action = new ActionEvent(this, 1001, this.message); this.listener.actionPerformed(action); } - } - public void mouseClicked(MouseEvent e) { - } + public void mouseClicked(MouseEvent e) {} - public void mouseMoved(MouseEvent e) { - } + public void mouseMoved(MouseEvent e) {} - public void mouseDragged(MouseEvent e) { - } + public void mouseDragged(MouseEvent e) {} private Color translateColor(Color color, int offset) { int r = this.translateColor(color.getRed(), offset); @@ -165,7 +164,6 @@ private void method220(Graphics graphics, Color background, int width, int heigh graphics.setColor(new Color(r, g, b)); graphics.drawLine(0, y, width - 1, y); } - } private void drawButton(Graphics graphics, int width, int height) { @@ -181,5 +179,4 @@ private void drawButton(Graphics graphics, int width, int height) { graphics.drawLine(0, 0, width - 1, 0); graphics.drawLine(0, 0, 0, height - 1); } - } diff --git a/client/src/main/java/com/aapeli/bigtext/BigText.java b/client/src/main/java/com/aapeli/bigtext/BigText.java index 66fe135a..4934b92b 100644 --- a/client/src/main/java/com/aapeli/bigtext/BigText.java +++ b/client/src/main/java/com/aapeli/bigtext/BigText.java @@ -1,7 +1,6 @@ package com.aapeli.bigtext; import com.aapeli.client.ImageManager; - import java.applet.Applet; import java.awt.Color; import java.awt.Component; @@ -20,7 +19,12 @@ public class BigText { public static final int VALIGN_BOTTOM = 1; protected static final Color aColor1312 = Color.white; private static final String aString1313 = "ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ 1234567890:!?/&Ü+-*%<>()ÁÉÑ'\"¿¡ÍÓÚØ"; - protected static final int[] anIntArray1314 = new int[]{0, 23, 47, 71, 95, 116, 136, 160, 183, 195, 219, 243, 264, 299, 323, 347, 370, 394, 418, 442, 465, 489, 513, 542, 566, 590, 614, 637, 661, 685, 700, 714, 736, 756, 777, 798, 819, 839, 859, 881, 901, 913, 924, 949, 972, 1002, 1027, 1051, 1071, 1097, 1126, 1149, 1172, 1186, 1200, 1225, 1246, 1270, 1281, 1303, 1328, 1339, 1354, 1378, 1402}; + protected static final int[] anIntArray1314 = new int[] { + 0, 23, 47, 71, 95, 116, 136, 160, 183, 195, 219, 243, 264, 299, 323, 347, 370, 394, 418, 442, 465, 489, 513, + 542, 566, 590, 614, 637, 661, 685, 700, 714, 736, 756, 777, 798, 819, 839, 859, 881, 901, 913, 924, 949, 972, + 1002, 1027, 1051, 1071, 1097, 1126, 1149, 1172, 1186, 1200, 1225, 1246, 1270, 1281, 1303, 1328, 1339, 1354, + 1378, 1402 + }; protected static final int anInt1315 = anIntArray1314.length; private static ImageManager anImageManager1316; private static int[] anIntArray1317; @@ -155,10 +159,10 @@ private void method1551(String var1, Color var2, int[] var3, int[] var4, int var this.method1552(var7[var17], var7[var17] + var8[var17], var16, var18, var12, var14, var3, var5); var16 += var8[var17]; } - } - private void method1552(int var1, int var2, int var3, double var4, double var6, double var8, int[] var10, int var11) { + private void method1552( + int var1, int var2, int var3, double var4, double var6, double var8, int[] var10, int var11) { int var14 = var1; for (int var15 = var3; var14 < var2; ++var15) { @@ -171,11 +175,13 @@ private void method1552(int var1, int var2, int var3, double var4, double var6, ++var14; } - } private int method1553(int var1, int var2, double var3, double var5, double var7) { - return (var2 << 24) + ((int) ((double) ((var1 & 16711680) >> 16) * var3) << 16) + ((int) ((double) ((var1 & 65280) >> 8) * var5) << 8) + (int) ((double) (var1 & 255) * var7); + return (var2 << 24) + + ((int) ((double) ((var1 & 16711680) >> 16) * var3) << 16) + + ((int) ((double) ((var1 & 65280) >> 8) * var5) << 8) + + (int) ((double) (var1 & 255) * var7); } private void method1554(String var1, Color var2, int var3, Component var4) { @@ -235,11 +241,93 @@ private void method1554(String var1, Color var2, int var3, Component var4) { } private boolean method1555(int var1, int var2) { - return this.method1556(var1 - 1, var2 - 2) ? true : (this.method1556(var1, var2 - 2) ? true : (this.method1556(var1 + 1, var2 - 2) ? true : (this.method1556(var1 - 2, var2 - 1) ? true : (this.method1556(var1 - 1, var2 - 1) ? true : (this.method1556(var1, var2 - 1) ? true : (this.method1556(var1 + 1, var2 - 1) ? true : (this.method1556(var1 + 2, var2 - 1) ? true : (this.method1556(var1 - 2, var2) ? true : (this.method1556(var1 - 1, var2) ? true : (this.method1556(var1 + 1, var2) ? true : (this.method1556(var1 + 2, var2) ? true : (this.method1556(var1 - 2, var2 + 1) ? true : (this.method1556(var1 - 1, var2 + 1) ? true : (this.method1556(var1, var2 + 1) ? true : (this.method1556(var1 + 1, var2 + 1) ? true : (this.method1556(var1 + 2, var2 + 1) ? true : (this.method1556(var1 - 1, var2 + 2) ? true : (this.method1556(var1, var2 + 2) ? true : this.method1556(var1 + 1, var2 + 2))))))))))))))))))); + return this.method1556(var1 - 1, var2 - 2) + ? true + : (this.method1556(var1, var2 - 2) + ? true + : (this.method1556(var1 + 1, var2 - 2) + ? true + : (this.method1556(var1 - 2, var2 - 1) + ? true + : (this.method1556(var1 - 1, var2 - 1) + ? true + : (this.method1556(var1, var2 - 1) + ? true + : (this.method1556(var1 + 1, var2 - 1) + ? true + : (this.method1556(var1 + 2, var2 - 1) + ? true + : (this.method1556(var1 - 2, var2) + ? true + : (this.method1556(var1 - 1, var2) + ? true + : (this.method1556( + var1 + 1, var2) + ? true + : (this.method1556( + var1 + + 2, + var2) + ? true + : (this + .method1556( + var1 + - 2, + var2 + + 1) + ? true + : (this + .method1556( + var1 + - 1, + var2 + + 1) + ? true + : (this + .method1556( + var1, + var2 + + 1) + ? true + : (this + .method1556( + var1 + + 1, + var2 + + 1) + ? true + : (this + .method1556( + var1 + + 2, + var2 + + 1) + ? true + : (this + .method1556( + var1 + - 1, + var2 + + 2) + ? true + : (this + .method1556( + var1, + var2 + + 2) + ? true + : this + .method1556( + var1 + + 1, + var2 + + 2))))))))))))))))))); } private boolean method1556(int var1, int var2) { - return var1 >= 0 && var1 < this.anInt1322 && var2 >= 0 && var2 < this.anInt1323 ? this.aBooleanArray1319[var2 * this.anInt1322 + var1] : false; + return var1 >= 0 && var1 < this.anInt1322 && var2 >= 0 && var2 < this.anInt1323 + ? this.aBooleanArray1319[var2 * this.anInt1322 + var1] + : false; } private void method1557(double var1, double var3, double var5) { @@ -250,7 +338,6 @@ private void method1557(double var1, double var3, double var5) { int var9 = (int) (((long) var8 & 4278190080L) >> 24); this.anIntArray1320[var10] = this.method1553(var8, var9, var1, var3, var5); } - } private void method1558(int var1, Component var2) { @@ -267,10 +354,12 @@ private void method1558(int var1, Component var2) { int var5 = this.anIntArray1320.length; for (int var6 = 0; var6 < var5; ++var6) { - this.anIntArray1320[var6] = (int) ((this.aBooleanArray1319[var6] ? var3 : 0L) + ((long) this.anIntArray1320[var6] & 16777215L)); + this.anIntArray1320[var6] = (int) ((this.aBooleanArray1319[var6] ? var3 : 0L) + + ((long) this.anIntArray1320[var6] & 16777215L)); } - this.anImage1321 = anImageManager1316.createImage(this.anIntArray1320, this.anInt1322, this.anInt1323, var2); + this.anImage1321 = + anImageManager1316.createImage(this.anIntArray1320, this.anInt1322, this.anInt1323, var2); } } } diff --git a/client/src/main/java/com/aapeli/bigtext/MediumText.java b/client/src/main/java/com/aapeli/bigtext/MediumText.java index 6f3e572c..e6b18ef6 100644 --- a/client/src/main/java/com/aapeli/bigtext/MediumText.java +++ b/client/src/main/java/com/aapeli/bigtext/MediumText.java @@ -7,7 +7,6 @@ public class MediumText extends BigText { private static int[] anIntArray3591; private static int[] anIntArray3592; - protected static void method1559(int[] var0) { anIntArray3591 = new int[17900]; @@ -44,8 +43,14 @@ private static int method1560(int[] var0, int var1, int var2) { long var5 = var0[var2 * 1432 + var1 + 1]; long var7 = var0[(var2 + 1) * 1432 + var1]; long var9 = var0[(var2 + 1) * 1432 + var1 + 1]; - long var11 = ((var3 & 4278190080L) >> 24) + ((var5 & 4278190080L) >> 24) + ((var7 & 4278190080L) >> 24) + ((var9 & 4278190080L) >> 24); - long var13 = ((var3 & 16711680L) >> 16) + ((var5 & 16711680L) >> 16) + ((var7 & 16711680L) >> 16) + ((var9 & 16711680L) >> 16); + long var11 = ((var3 & 4278190080L) >> 24) + + ((var5 & 4278190080L) >> 24) + + ((var7 & 4278190080L) >> 24) + + ((var9 & 4278190080L) >> 24); + long var13 = ((var3 & 16711680L) >> 16) + + ((var5 & 16711680L) >> 16) + + ((var7 & 16711680L) >> 16) + + ((var9 & 16711680L) >> 16); long var15 = ((var3 & 65280L) >> 8) + ((var5 & 65280L) >> 8) + ((var7 & 65280L) >> 8) + ((var9 & 65280L) >> 8); long var17 = (var3 & 255L) + (var5 & 255L) + (var7 & 255L) + (var9 & 255L); long var19 = (var11 + 2L) / 4L; diff --git a/client/src/main/java/com/aapeli/client/AutoPopups.java b/client/src/main/java/com/aapeli/client/AutoPopups.java index 28ae8974..af09f612 100644 --- a/client/src/main/java/com/aapeli/client/AutoPopups.java +++ b/client/src/main/java/com/aapeli/client/AutoPopups.java @@ -10,7 +10,6 @@ public class AutoPopups { private long aLong1330; private static final String aString1331 = "facebook"; - public AutoPopups(AApplet var1) { if (!var1.param.getSiteName().equalsIgnoreCase("facebook")) { this.aClass78_1327 = new Class78(var1); @@ -24,7 +23,6 @@ public AutoPopups(Parameters var1, TextManager var2, ImageManager var3) { if (!var1.getSiteName().equalsIgnoreCase("facebook")) { this.aClass88_1328 = new Class88(var1, var2, var3); } - } public ColorButton getTellFriendButton() { @@ -49,7 +47,6 @@ public void personalRecord() { if (this.aClass78_1327 != null && this.aClass78_1327.method1600()) { this.method1562(); } - } } } @@ -60,7 +57,6 @@ public void rankingChanged(int var1, int var2) { if (this.aClass78_1327 != null && this.aClass78_1327.method1601(var1, var2)) { this.method1562(); } - } } } @@ -74,7 +70,6 @@ public void close() { if (this.aClass88_1328 != null) { this.aClass88_1328.method1701(); } - } } @@ -85,5 +80,4 @@ private boolean method1561() { private void method1562() { this.aLong1330 = System.currentTimeMillis(); } - } diff --git a/client/src/main/java/com/aapeli/client/BadWordFilter.java b/client/src/main/java/com/aapeli/client/BadWordFilter.java index 7d33919e91c37d660437b66ee8d7c9d63863788e..bd164f1463135447be459941ee92a5d8941f31af 100644 GIT binary patch delta 2312 zcmb_eO>7%g5SAS~w%2Pr>-E}RuXp$PKR-_DjT0x4>y}nXZAEB`h=i(uAR;M^Fo{Uh zN>wmYB!oC1wP8*bqDUa5N=T?Zlmj=UO2CCCaN-84P&uHcC&VdbX4l!xCj4Aj$$sXLgH#2W{=j_Aj>lqKXsp^}@^EfUPJRIEg3~k=ML<7uv&fqv}%9>Y)W8RZtw$8Ec z0~_AggL^ah-TQRFoOGI~Xuv{`;8MQQ^M<4Rpl8CReAXu<*n0l-Vx`^AS6Tj|DWD}G znc(N2Ut3*Te$A+ljhYK^%g5t}2#u}Gt z_6%(Fituc29mjfhF9^1Df%RXRU#+uNi!EPnx9Q*yy++tp=x`te`tg_ULnUUrR&O-n z)xZ=y3Ci$gAZLyYEGUVbZGCBZjUoJG6SjgQXyZ-S z*|$SS;EPb9do~1*LkW!6(#*jN+&SJh)ZsXo3M;V9DW-}J(QpaI!cAeH3Z)U_c{f~# zufkP$7*=I_m-dK^C3ck6hy|Tj8?N1sJwq^3r)PC>?egj}yD;CrwAeIP5#TD{AGI~s zRFfa%P<#FVMj~DW+V@SF2Q#Z9d{n-DbIR$&OQMvJf!EeyKWyUroOhUJ^3+&%JRwE96T4~19}F?V7Tyc|=Z6KlCr@NIW@ zwBoXiCL443H~tdVL~Xxu*pia5#v~P$QKj5A1~9o&629*n=pC;z!=BdQNuOj_ttRxt zDdD_5-;y(MPf&rAv#=|OCVAy}yi43{{1{3nR0*Dv18_U8nshygCk>aIPP`=1;}B;_ zNF5XPr>;l-Y>{%8Nz8E z?j(nB_B9i^2FtZreUu99z9xZ?8W?wZyx%{2<4_*aYayuuq(%@(_cm=LMDe6VsHTrN z`8r&!lpDKPw`2uAO`m{Y)8sKH7qBuLAsZXEF?a9CW!+x+M;aHf(GzeclZSRDYbNZY zOdQ8D$pNE=rD8Nm<_rU6^kSlk)JRZK5^z+>TWaHGMUf2GlmNPPLs8(aQZpN6S7}kE zm7yVuVPD~y$u;u}D_Mnfqs9brO?q{rThOz9V~nKj0wW_{Vo}e+pc=s?8CbDuj@MNm ze5i^flZs1Qf}b@X=vsDC&;4C2t^%hJsX(ndHAdYB z9MbJuL=&)rN)%FK2YPswNeZ|E-5h=3YHhu|1YJabv*!Ip1>DRnr_cS nkgk(v1K`)edu3g5;JO#Zu+!b&lo|Y1J_l2kL93@bT!;G$xl%9} literal 10095 zcmeHNTXWmS74CCp@(1#?;X@3@5+e}cMYXNe@ic8`lJ+6)^ug9R5DAKiV1NZdS&FIT zXY?_bCTWwlX`9PTleW_t;*a%wd&4dOij851Eb=Jsypd;7a(q8M36tpU zFylnC#ZerM*d$7Vn2q9KK4-54<6orN_|+)R!;C$}VvLSi7M%up$mV&F>luP23&hp+ zydJy5T6=ES^LzclaG%9&x%%Y!)dvpy!Rn*pS8Vm!>QAe0SKq9@SbfP>pRPV>bMvFS0jRUp;JHjp-0fm&+xi|G4b38{)uq3sw&f zmDlcOS#VCS+b51m_=E{xlBBKW?bZ%!-9EtifZxCL@FD%fGrxHWcNmjb`GP;~3cBU) z5|2wF5;sJyM&y9FJmME|UOvJc=TRFMad!C7k`vun-rzhve&$3pap>~(O%v#c1^A`I)fB0!MI+?eW5n!c~4bppsP3uQ#$_s`)Cz>#<;ITWDRbW)p z>|iQh*0|kUWb+UXw%KW4U@E-U(KW~Kl2H1|Q=n-eBw-9fAO}P^q_o^TuLa5Rg5ct` zJK--EK|KG-agt`?yB+wc#N#;etI5^JzMEdxJe_+3zG2 z_go35O~GA3Ol`z76}7AjW|oqcHG4H{68*I-iO{;#lHZZpdjB4?35#2qS}Mr1I9bW- z#9?xrPo1`nm}Wg2_{sSjKx2uZb?56tlDj$JGHi6e#)0gTRdyexNghPWTxCwDOptbY zA@EbZBK}BG7E1elEbE%fa=j5Q5hY^GsYL;@R79b&S9^nK%fft-CA^Lq!G<@a2QE0Y zN_dbnCY0ksIYqyhDof2K{9|CPo_Tg&P48Dy9m2>&feZ-cm2*qcK_tX^WigqEYHp_= zF%HA>aJHvv^U`a?n#epok$F4`qF$qAWp(HRJ-tKrJWXaVyuigQhiuP7Sar}WzZ1-6 zVKR0s5Da=w+eCnxaKS?INY$e1t;vq=-A)PPUNbw}5Zc9xp@aeFo2SCWR^q>4qaYtm zne)T5Q8>$^ls7p2nypGku7N;_KE15^kQ4|}X`2G#k|2pg43xE9~mwpG`@k0s=bOAu0Kw9t70PXPs#Na|+6gH+F*hW#&@ubxe}i(kB&?UC`_)bJb)yO`~xs z%+N&jP6+`!x%1p4;h$6ALJP=-R@v58MWP8h0>+r4iz#`&^gRe05+59@Tlpv%hi5;V zIN-wFOId^+sNm?an>-=cqoT?is1^a$7XjtVfT|}7OvOQBh@?tAF5UMLUuNnMR8|4Q z5ZT;#BOW&RVSk+;44)9Jg%3o{CLqdGVFz28rl2v2?RN6Cgoy$MB(x%6(1qFi+{E+& zNcXfLooO99_sn^qgJ03LDqPFH)($<_^NAIw(_cWo)yvvEt}FscvR=JQ#oT7ci<)Qb zUGW{P>K4{Ud$`h^cBFXwJJs0HvHCykk{Y}v3Jr9WxTM{T@`3PCKG@p>MkORys+NnF z{xZTE(gzXCzDb3+9U-u@%E2;5x<-k#pblEuU-i*hd3I*RYaGC#inc7A#la{nqsg zKNw*HJ70RGA&0`8!jP16%W7%#THw%xH*IFsvDkL>YIfwVv#qEtN(G}dJ2hR(bXMOg z2eB1ltK^p|$tq;xL53nt6Q5xgPiQCk!m7ZS*>>QyIwTo>Qy{Y51~M1h@G1%`EL<7) zgNm6|f^p>+V^1XkE8T;c`fP{1yj`N5-U>4*t}FWO5^$KV-T|8EtL?W>rcoR+2fN2L zTVb{qQ*H{GpKAlt@*u_`J>V)AkbdG@lZ?c7$@b;5Rv3EGmVoe>YiAz8Q=IwUnrnU< zsJ9xPY5-TIx4Ctv-j_mB%EtQZS5>6-C{@gG70I~b6-Ce}9$qTm1RpNOexnN%8=e&) ztOPH8ONl3LR@aqz!L4sUDh}#O)A$FW%eNotNqw0p0`t07dJtVtZ-`xmJ;rL#S8^yr z4NzkF>`N_mJ*lpUFNlF~G`F9Wytqo4DeNdWtQA*M`6z7z`hK7oT}unD|B7nnPYd9s z4rN`+9(P!C|Ds5tw5)Mbp86MK|fI1XI^Wv~tf@6EJ2- z@l>u_A2~{oJqf_eBXyI|b_!OaUmo9s?ZTTJv|VU78VaJU6~1u>0I{aRftgCewGHHf zQO5_ODY>kg(EK~tS6R2I_<#TK#;p!4X&8}(R3+}R17y*`f3Z2YEoc7$ysJ(~{XGG2 zj)USu+~`{!F{*7wIOtDae{`BX&$7wZ0Bm#I==!)Hci>;Db#61OB zC8KL46rpMf^$r{c#P3kuY7EQ8d)ScMAE?fc-KLV*?b5~xG!bQ|JG37C=CUA#q*)Et zFRcJkdD1tjE|_d~FLfwMM+Bf_fNpE89x93 diff --git a/client/src/main/java/com/aapeli/client/Class78.java b/client/src/main/java/com/aapeli/client/Class78.java index b600dbb3..13f8b802 100644 --- a/client/src/main/java/com/aapeli/client/Class78.java +++ b/client/src/main/java/com/aapeli/client/Class78.java @@ -8,7 +8,6 @@ class Class78 { private Frame_Sub3_Sub1 frame; private boolean aBoolean1365; - protected Class78(AApplet var1) { this.anAApplet1363 = var1; this.aBoolean1365 = false; @@ -65,7 +64,6 @@ protected void method1602() { } } catch (Exception var2) { } - } protected void method1603() { diff --git a/client/src/main/java/com/aapeli/client/Class81.java b/client/src/main/java/com/aapeli/client/Class81.java index 20b2064a..8551b915 100644 --- a/client/src/main/java/com/aapeli/client/Class81.java +++ b/client/src/main/java/com/aapeli/client/Class81.java @@ -83,15 +83,15 @@ private boolean method1613(char var1) { } private boolean method1614(String var1) { - return this.method1617(new String[]{"<" + var1 + ">"}); + return this.method1617(new String[] {"<" + var1 + ">"}); } private boolean method1615(String var1, String var2) { - return this.method1617(new String[]{"<" + var1 + ">", "<" + var2 + ">"}); + return this.method1617(new String[] {"<" + var1 + ">", "<" + var2 + ">"}); } private boolean method1616(String var1, String var2, String var3) { - return this.method1617(new String[]{"<" + var1 + ">", "<" + var2 + ">", "<" + var3 + ">"}); + return this.method1617(new String[] {"<" + var1 + ">", "<" + var2 + ">", "<" + var3 + ">"}); } private boolean method1617(String[] var1) { diff --git a/client/src/main/java/com/aapeli/client/Class84.java b/client/src/main/java/com/aapeli/client/Class84.java index 778b1679..d31128da 100644 --- a/client/src/main/java/com/aapeli/client/Class84.java +++ b/client/src/main/java/com/aapeli/client/Class84.java @@ -13,7 +13,6 @@ class Class84 implements Runnable { private boolean aBoolean1414; private final IPanel anIPanel1415; - protected Class84(IPanel var1, IPanel var2, ImageManager var3, String var4, int var5, int var6, boolean var7) { this.anIPanel1415 = var1; this.anIPanel1408 = var2; @@ -39,7 +38,6 @@ public void run() { if (this.aBoolean1414) { this.anIPanel1408.setBackground(var1, this.anInt1411, this.anInt1412); } - } protected void method1653() { diff --git a/client/src/main/java/com/aapeli/client/Class88.java b/client/src/main/java/com/aapeli/client/Class88.java index 988b5660..ac27e8d0 100644 --- a/client/src/main/java/com/aapeli/client/Class88.java +++ b/client/src/main/java/com/aapeli/client/Class88.java @@ -1,7 +1,6 @@ package com.aapeli.client; import com.aapeli.colorgui.ColorButton; - import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -41,7 +40,6 @@ protected Class88(Parameters var1, TextManager var2, ImageManager var3) { if (this.aString1504 == null || this.aString1505 == null) { this.anInt1506 = 0; } - } public void actionPerformed(ActionEvent var1) { @@ -50,7 +48,6 @@ public void actionPerformed(ActionEvent var1) { } else { this.aFrame_Sub3_Sub3_1508.toFront(); } - } protected ColorButton method1699() { @@ -97,7 +94,6 @@ protected void method1701() { } } catch (Exception var2) { } - } protected boolean method1702(String[] var1, String var2, int var3, int var4, int var5) { diff --git a/client/src/main/java/com/aapeli/client/FileUtil.java b/client/src/main/java/com/aapeli/client/FileUtil.java index 1b10334b..417df4cf 100644 --- a/client/src/main/java/com/aapeli/client/FileUtil.java +++ b/client/src/main/java/com/aapeli/client/FileUtil.java @@ -7,7 +7,6 @@ class FileUtil { protected static final String RESOURCE_DIR = "/Shared/Client/src/"; protected static final String LANGUAGE_DIR = "/L10N/"; - protected static final boolean isFileUrl(URL url) { return url.getProtocol().equalsIgnoreCase("file") ? url.toString().indexOf("fs01") <= 0 : false; } diff --git a/client/src/main/java/com/aapeli/client/FilterTextField.java b/client/src/main/java/com/aapeli/client/FilterTextField.java index a43b3344..14ff54b3 100644 --- a/client/src/main/java/com/aapeli/client/FilterTextField.java +++ b/client/src/main/java/com/aapeli/client/FilterTextField.java @@ -7,7 +7,6 @@ public class FilterTextField extends InputTextField { private BadWordFilter aBadWordFilter3528; private BadWordFilter aBadWordFilter3529; - public FilterTextField(TextManager var1, String var2, int var3) { this(var1, var2, var3, false); } @@ -18,7 +17,6 @@ public FilterTextField(TextManager var1, String var2, int var3, boolean var4) { if (var4) { this.aBadWordFilter3529 = new BadWordFilter(var1, false, "#"); } - } public void focusLost(FocusEvent var1) { diff --git a/client/src/main/java/com/aapeli/client/Frame_Sub3.java b/client/src/main/java/com/aapeli/client/Frame_Sub3.java index a8964216..bee9ba18 100644 --- a/client/src/main/java/com/aapeli/client/Frame_Sub3.java +++ b/client/src/main/java/com/aapeli/client/Frame_Sub3.java @@ -18,7 +18,6 @@ abstract class Frame_Sub3 extends Frame implements WindowListener { private int anInt189; private Color aColor190; - protected Frame_Sub3(TextManager var1) { this.aTextManager187 = var1; this.anInt188 = this.anInt189 = 0; @@ -38,30 +37,23 @@ public void update(Graphics var1) { var1.setColor(this.aColor190); var1.fillRect(0, 0, this.anInt188, this.anInt189); } - } - public void windowOpened(WindowEvent var1) { - } + public void windowOpened(WindowEvent var1) {} - public void windowClosed(WindowEvent var1) { - } + public void windowClosed(WindowEvent var1) {} public void windowClosing(WindowEvent var1) { this.close(); } - public void windowActivated(WindowEvent var1) { - } + public void windowActivated(WindowEvent var1) {} - public void windowDeactivated(WindowEvent var1) { - } + public void windowDeactivated(WindowEvent var1) {} - public void windowIconified(WindowEvent var1) { - } + public void windowIconified(WindowEvent var1) {} - public void windowDeiconified(WindowEvent var1) { - } + public void windowDeiconified(WindowEvent var1) {} protected void method238(Component var1, String var2, Panel var3) { this.setTitle(var2); diff --git a/client/src/main/java/com/aapeli/client/Frame_Sub3_Sub1.java b/client/src/main/java/com/aapeli/client/Frame_Sub3_Sub1.java index 56f54f7e..3b95b38b 100644 --- a/client/src/main/java/com/aapeli/client/Frame_Sub3_Sub1.java +++ b/client/src/main/java/com/aapeli/client/Frame_Sub3_Sub1.java @@ -1,7 +1,6 @@ package com.aapeli.client; import com.aapeli.applet.AApplet; - import java.awt.Component; class Frame_Sub3_Sub1 extends Frame_Sub3 { @@ -9,7 +8,6 @@ class Frame_Sub3_Sub1 extends Frame_Sub3 { private Class78 aClass78_2884; private IPanel_Sub40 anIPanel_Sub40_2885; - protected Frame_Sub3_Sub1(AApplet var1, Class78 var2, int var3, int var4) { super(var1.textManager); this.aClass78_2884 = var2; @@ -31,5 +29,4 @@ protected void close() { this.anIPanel_Sub40_2885 = null; this.aClass78_2884 = null; } - } diff --git a/client/src/main/java/com/aapeli/client/Frame_Sub3_Sub3.java b/client/src/main/java/com/aapeli/client/Frame_Sub3_Sub3.java index d3aa5b3d..3134c2ed 100644 --- a/client/src/main/java/com/aapeli/client/Frame_Sub3_Sub3.java +++ b/client/src/main/java/com/aapeli/client/Frame_Sub3_Sub3.java @@ -8,7 +8,6 @@ class Frame_Sub3_Sub3 extends Frame_Sub3 { private Panel_Sub24 aPanel_Sub24_2891; private static final String aString2892 = "TellFriend_Title"; - protected Frame_Sub3_Sub3(TextManager var1, ImageManager var2, Class88 var3) { super(var1); this.aClass88_2890 = var3; @@ -25,5 +24,4 @@ protected void close() { this.aPanel_Sub24_2891 = null; this.aClass88_2890 = null; } - } diff --git a/client/src/main/java/com/aapeli/client/HtmlLine.java b/client/src/main/java/com/aapeli/client/HtmlLine.java index 78e24a43..967eff0e 100644 --- a/client/src/main/java/com/aapeli/client/HtmlLine.java +++ b/client/src/main/java/com/aapeli/client/HtmlLine.java @@ -14,7 +14,6 @@ class HtmlLine { private int height; private final HtmlText aHtmlText1371; - protected HtmlLine(HtmlText htmlText, Graphics graphics, int var3, boolean var4) { this.aHtmlText1371 = htmlText; this.anInt1366 = var3; @@ -49,7 +48,6 @@ protected void addWord(String text, Font font, int length) { if (fontSize > this.height) { this.height = fontSize; } - } } @@ -78,6 +76,5 @@ protected void draw(Graphics graphics, int x, int y) { HtmlWord word = this.words.get(wordsLength); word.draw(graphics, x, y); } - } } diff --git a/client/src/main/java/com/aapeli/client/HtmlText.java b/client/src/main/java/com/aapeli/client/HtmlText.java index 5f7fb5d6..5fb389ec 100644 --- a/client/src/main/java/com/aapeli/client/HtmlText.java +++ b/client/src/main/java/com/aapeli/client/HtmlText.java @@ -7,6 +7,7 @@ public class HtmlText { private List lines; + public HtmlText(Graphics graphics, int var2, String text) { this.lines = this.createLines(graphics, var2, text); } @@ -81,6 +82,5 @@ private void method1591(HtmlLine var1, List var2) { if (!var1.isEmpty()) { var2.add(var1); } - } } diff --git a/client/src/main/java/com/aapeli/client/HtmlWord.java b/client/src/main/java/com/aapeli/client/HtmlWord.java index 69cfdce1..baf62956 100644 --- a/client/src/main/java/com/aapeli/client/HtmlWord.java +++ b/client/src/main/java/com/aapeli/client/HtmlWord.java @@ -11,7 +11,6 @@ class HtmlWord { private int length; private final HtmlLine htmlLine; - protected HtmlWord(HtmlLine htmlLine, String word, Font font, int start, int length) { this.htmlLine = htmlLine; this.word = word; @@ -21,7 +20,13 @@ protected HtmlWord(HtmlLine htmlLine, String word, Font font, int start, int len } public String toString() { - return "[HtmlWord: 'word'=\"" + this.word + "\" 'font'=\"" + this.font.toString() + "\" 'relx'=" + this.start + "]"; + return "[HtmlWord: 'word'=\"" + + this.word + + "\" 'font'=\"" + + this.font.toString() + + "\" 'relx'=" + + this.start + + "]"; } protected int getLength() { diff --git a/client/src/main/java/com/aapeli/client/IPanel.java b/client/src/main/java/com/aapeli/client/IPanel.java index 61f63f7c..1ce01bae 100644 --- a/client/src/main/java/com/aapeli/client/IPanel.java +++ b/client/src/main/java/com/aapeli/client/IPanel.java @@ -17,7 +17,6 @@ public class IPanel extends Panel { private Object anObject648 = new Object(); public static int anInt649; - public void paint(Graphics graphics) { this.update(graphics); } @@ -55,7 +54,6 @@ public void setBackground(ImageManager imageManager, String imageKey, int xOffse this.aClass84_647 = new Class84(this, this, imageManager, imageKey, xOffset, yOffset, false); } } - } public void setSharedBackground(ImageManager var1, String var2, int var3, int var4) { @@ -80,7 +78,6 @@ public void drawBackground(Graphics var1) { var1.setColor(var2.getBackground()); var1.fillRect(0, 0, var3.width, var3.height); } - } public boolean drawBackgroundImage(Graphics graphics) { @@ -92,7 +89,17 @@ public boolean drawBackgroundImage(Graphics graphics) { int backgroundImageXOffset = (Integer) backgroundData[1]; int backgroundImageYOffset = (Integer) backgroundData[2]; Dimension size = this.getSize(); - graphics.drawImage(backgroundImage, 0, 0, size.width, size.height, -backgroundImageXOffset, -backgroundImageYOffset, -backgroundImageXOffset + size.width, -backgroundImageYOffset + size.height, null); + graphics.drawImage( + backgroundImage, + 0, + 0, + size.width, + size.height, + -backgroundImageXOffset, + -backgroundImageYOffset, + -backgroundImageXOffset + size.width, + -backgroundImageYOffset + size.height, + null); return true; } } @@ -110,14 +117,15 @@ public void recursiveRepaint() { component.repaint(); } } - } } } public Object[] getBackgroundAndLocation(int var1, int var2) { if (this.backgroundImage != null) { - return new Object[]{this.backgroundImage, this.backgroundImageXOffset + var1, this.backgroundImageYOffset + var2}; + return new Object[] { + this.backgroundImage, this.backgroundImageXOffset + var1, this.backgroundImageYOffset + var2 + }; } else { Container var3 = this.getParent(); if (var3 == null) { diff --git a/client/src/main/java/com/aapeli/client/IPanel_Sub40.java b/client/src/main/java/com/aapeli/client/IPanel_Sub40.java index ef3180aa..c7364f0c 100644 --- a/client/src/main/java/com/aapeli/client/IPanel_Sub40.java +++ b/client/src/main/java/com/aapeli/client/IPanel_Sub40.java @@ -2,7 +2,6 @@ import com.aapeli.applet.AApplet; import com.aapeli.colorgui.RoundButton; - import java.awt.Color; import java.awt.Font; import java.awt.Graphics; @@ -25,7 +24,6 @@ class IPanel_Sub40 extends IPanel implements ActionListener { private RoundButton aRoundButton3216; private RoundButton aRoundButton3217; - protected IPanel_Sub40(AApplet var1, Frame_Sub3_Sub1 var2, int var3, int var4) { this.anAApplet3210 = var1; this.aFrame_Sub3_Sub1_3211 = var2; @@ -71,17 +69,19 @@ public void actionPerformed(ActionEvent var1) { this.anAApplet3210.setEndState(AApplet.END_QUIT_REGISTER); this.anAApplet3210.param.showRegisterPage(); } - } protected String method820() { - return this.anInt3212 == 0 ? this.anAApplet3210.textManager.getShared("GameFin_W_GameOver") : (this.anInt3212 == 1 ? this.anAApplet3210.textManager.getShared("GameFin_R_Congratulations") : "-"); + return this.anInt3212 == 0 + ? this.anAApplet3210.textManager.getShared("GameFin_W_GameOver") + : (this.anInt3212 == 1 ? this.anAApplet3210.textManager.getShared("GameFin_R_Congratulations") : "-"); } private void method821() { this.setLayout(null); if (this.anInt3212 == 0) { - this.aRoundButton3215 = new RoundButton(this.anAApplet3210.textManager.getShared("GameFin_W_CreateAccount")); + this.aRoundButton3215 = + new RoundButton(this.anAApplet3210.textManager.getShared("GameFin_W_CreateAccount")); this.aRoundButton3215.setBounds(210, 225, 220, 30); this.aRoundButton3215.setBackground(aColor3207); this.aRoundButton3215.addActionListener(this); @@ -98,6 +98,5 @@ private void method821() { this.aRoundButton3217.addActionListener(this); this.add(this.aRoundButton3217); } - } } diff --git a/client/src/main/java/com/aapeli/client/ImageManager.java b/client/src/main/java/com/aapeli/client/ImageManager.java index 1701f498..59cc3824 100644 --- a/client/src/main/java/com/aapeli/client/ImageManager.java +++ b/client/src/main/java/com/aapeli/client/ImageManager.java @@ -2,7 +2,6 @@ import com.aapeli.applet.AApplet; import com.aapeli.tools.Tools; - import java.applet.Applet; import java.awt.Component; import java.awt.Image; @@ -21,7 +20,6 @@ public final class ImageManager { private final boolean isDebug; private final ImageTracker imageTracker; - public ImageManager(Applet applet) { this(applet, "src/main/resources/picture/", true); } @@ -38,7 +36,8 @@ public ImageManager(Applet applet, String imageDir, boolean isDebug) { this.applet = applet; this.isDebug = isDebug; - // TODO: Remove this code if it doesn't cause any problems in a few releases, I rewritten the functionality + // TODO: Remove this code if it doesn't cause any problems in a few releases, I rewritten + // the functionality this.validImageDir = true; if (imageDir != null && imageDir.length() > 0) { this.validImageDir = false; @@ -65,7 +64,8 @@ public String defineImage(String imageAlias, String imageFileName) { System.out.println("ImageManager.defineImage(\"" + imageAlias + "\",\"" + imageFileName + "\")"); } - Image var3 = Toolkit.getDefaultToolkit().createImage(this.getClass().getResource("/picture/agolf/" +getAlias(imageFileName))); + Image var3 = Toolkit.getDefaultToolkit() + .createImage(this.getClass().getResource("/picture/agolf/" + getAlias(imageFileName))); this.imageTracker.registerImage(imageAlias, var3); return imageAlias; } @@ -79,7 +79,8 @@ public String defineSharedImage(String imageAlias, String imageFileName) { System.out.println("ImageManager.defineSharedImage(\"" + imageAlias + "\",\"" + imageFileName + "\")"); } - Image var3 = Toolkit.getDefaultToolkit().createImage(this.getClass().getResource("/picture/shared/" +getAlias(imageFileName))); + Image var3 = Toolkit.getDefaultToolkit() + .createImage(this.getClass().getResource("/picture/shared/" + getAlias(imageFileName))); this.imageTracker.method1624(imageAlias, var3); return imageAlias; } @@ -167,8 +168,8 @@ public Image getShared(String var1, boolean var2) { } catch (Exception ex) { } var4 = Toolkit.getDefaultToolkit().createImage(url); - //todo var4 = this.anApplet1354.getImage(var6, var1); - //var4 = this.applet.getImage(var6, var1); + // todo var4 = this.anApplet1354.getImage(var6, var1); + // var4 = this.applet.getImage(var6, var1); this.imageTracker.method1624(var3, var4); } } @@ -236,7 +237,15 @@ public Image[][] separateImages(Image var1, int var2, int var3) { int var6 = var4 / var2; int var7 = var5 / var3; if (this.isDebug && (var4 % var2 > 0 || var5 % var3 > 0)) { - System.out.println("ImageManager.separateImages(...," + var2 + "," + var3 + "): Warning! Source image can not be divided to " + var2 + "*" + var3 + " blocks"); + System.out.println("ImageManager.separateImages(...," + + var2 + + "," + + var3 + + "): Warning! Source image can not be divided to " + + var2 + + "*" + + var3 + + " blocks"); Thread.dumpStack(); } @@ -305,11 +314,10 @@ protected void method1594(URL var1) { String var2 = var1.toString(); synchronized (this) { if (!this.imageTracker.containsCImage(var2)) { - //todo Image var4 = this.applet.getImage(var1); + // todo Image var4 = this.applet.getImage(var1); Image var4 = Toolkit.getDefaultToolkit().createImage(var1); this.imageTracker.method1625(var2, var4); } - } } diff --git a/client/src/main/java/com/aapeli/client/ImageResource.java b/client/src/main/java/com/aapeli/client/ImageResource.java index 2600e65a..0f3c8546 100644 --- a/client/src/main/java/com/aapeli/client/ImageResource.java +++ b/client/src/main/java/com/aapeli/client/ImageResource.java @@ -9,7 +9,6 @@ class ImageResource { private int anInt1406; private final ImageTracker aImageTracker_1407; - protected ImageResource(ImageTracker var1, String var2, Image var3) { this.aImageTracker_1407 = var1; this.aString1404 = var2; diff --git a/client/src/main/java/com/aapeli/client/ImageTracker.java b/client/src/main/java/com/aapeli/client/ImageTracker.java index 1c86845e..35de88e6 100644 --- a/client/src/main/java/com/aapeli/client/ImageTracker.java +++ b/client/src/main/java/com/aapeli/client/ImageTracker.java @@ -2,7 +2,6 @@ import com.aapeli.applet.AApplet; import com.aapeli.tools.Tools; - import java.applet.Applet; import java.awt.Image; import java.util.ArrayList; @@ -122,7 +121,6 @@ protected void method1636(String var1) { if (this.imageTable.remove(var1) == null) { this.method1646(var1); } - } } @@ -146,18 +144,20 @@ protected void removeAllImageResources() { } } - for (Image image: this.imageTable.values()) { + for (Image image : this.imageTable.values()) { try { image.flush(); - } catch (Exception e) {} + } catch (Exception e) { + } } this.imageTable.clear(); this.imageTable = null; - for (ImageResource imageResource: this.imageResourceTable) { + for (ImageResource imageResource : this.imageResourceTable) { try { imageResource.method1652(); - } catch (Exception e) {} + } catch (Exception e) { + } } this.imageResourceTable.clear(); @@ -260,7 +260,8 @@ private boolean method1645() { } if (this.aBoolean1397) { - System.out.println("ImageTracker: Loaded image \"" + imageAlias + "\", moving from 'notloaded' to 'loaded'"); + System.out.println( + "ImageTracker: Loaded image \"" + imageAlias + "\", moving from 'notloaded' to 'loaded'"); } synchronized (this) { @@ -289,6 +290,5 @@ private synchronized void method1647(String var1) { if (var2 != null && !var2.method1651()) { this.imageResourceTable.add(var2); } - } } diff --git a/client/src/main/java/com/aapeli/client/InputTextField.java b/client/src/main/java/com/aapeli/client/InputTextField.java index c2a32cc5..8803a28b 100644 --- a/client/src/main/java/com/aapeli/client/InputTextField.java +++ b/client/src/main/java/com/aapeli/client/InputTextField.java @@ -30,7 +30,6 @@ public class InputTextField extends TextField implements FocusListener, KeyListe private int inputTextLength; private List listeners; - public InputTextField(int var1) { this("", var1, false); } @@ -135,12 +134,11 @@ public void keyTyped(KeyEvent evt) { public void actionPerformed(ActionEvent evt) { if (evt.getSource() == this) { synchronized (this) { - for (InputTextFieldListener listener: this.listeners) { + for (InputTextFieldListener listener : this.listeners) { listener.enterPressed(); } } } - } public String getInputText() { @@ -243,13 +241,13 @@ private synchronized void keyInput() { } if (this.inputTextLength == 0 && textLen > 0) { - for (InputTextFieldListener listener: this.listeners) { + for (InputTextFieldListener listener : this.listeners) { listener.startedTyping(); } } if (this.inputTextLength > 0 && textLen == 0) { - for (InputTextFieldListener listener: this.listeners) { + for (InputTextFieldListener listener : this.listeners) { listener.clearedField(); } } @@ -323,7 +321,6 @@ private void method966(char chr) { this.method967(text, var4, 1, var2); } - } private void method967(String var1, int var2, int var3, String var4) { @@ -333,5 +330,4 @@ private void method967(String var1, int var2, int var3, String var4) { this.setCaretPosition(var2 - var3 + var5); } } - } diff --git a/client/src/main/java/com/aapeli/client/InputTextFieldListener.java b/client/src/main/java/com/aapeli/client/InputTextFieldListener.java index ae5ee3f7..08ef92f5 100644 --- a/client/src/main/java/com/aapeli/client/InputTextFieldListener.java +++ b/client/src/main/java/com/aapeli/client/InputTextFieldListener.java @@ -1,6 +1,5 @@ package com.aapeli.client; - public interface InputTextFieldListener { void startedTyping(); diff --git a/client/src/main/java/com/aapeli/client/LocalizationNode.java b/client/src/main/java/com/aapeli/client/LocalizationNode.java index 59d16f56..90e1d9a6 100644 --- a/client/src/main/java/com/aapeli/client/LocalizationNode.java +++ b/client/src/main/java/com/aapeli/client/LocalizationNode.java @@ -11,7 +11,6 @@ class LocalizationNode { private String zero; private final TextManager textManager; - protected LocalizationNode(TextManager textManager, String language, XmlUnit unit, boolean reversed) { this.textManager = textManager; this.language = language.substring(0, 2).toLowerCase(); @@ -23,7 +22,6 @@ protected LocalizationNode(TextManager textManager, String language, XmlUnit uni this.plural = Tools.reverse(this.plural); this.zero = Tools.reverse(this.zero); } - } protected String getLocalization(int quantity) { @@ -41,5 +39,4 @@ protected String getLocalization(int quantity) { return this.singular; } - } diff --git a/client/src/main/java/com/aapeli/client/Panel_Sub24.java b/client/src/main/java/com/aapeli/client/Panel_Sub24.java index accd3655..8bcec5f1 100644 --- a/client/src/main/java/com/aapeli/client/Panel_Sub24.java +++ b/client/src/main/java/com/aapeli/client/Panel_Sub24.java @@ -2,7 +2,6 @@ import com.aapeli.colorgui.ColorButton; import com.aapeli.tools.DelayRepaint; - import java.awt.Color; import java.awt.Font; import java.awt.Graphics; @@ -86,14 +85,18 @@ public void update(Graphics var1) { this.aGraphics642.setColor(aColor617); if (this.anInt638 == 0) { this.aGraphics642.setFont(aFont623); - StringDraw.drawStringWithMaxWidth(this.aGraphics642, this.aTextManager628.getShared("TellFriend_Info"), 10, 25, -1, 480); + StringDraw.drawStringWithMaxWidth( + this.aGraphics642, this.aTextManager628.getShared("TellFriend_Info"), 10, 25, -1, 480); this.aGraphics642.setFont(aFont624); - StringDraw.drawStringWithMaxWidth(this.aGraphics642, this.aTextManager628.getShared("TellFriend_EmailTitle"), 10, 90, -1, 480); + StringDraw.drawStringWithMaxWidth( + this.aGraphics642, this.aTextManager628.getShared("TellFriend_EmailTitle"), 10, 90, -1, 480); this.aGraphics642.setFont(aFont625); - StringDraw.drawStringWithMaxWidth(this.aGraphics642, this.aTextManager628.getShared("TellFriend_MessageTitle"), 200, 90, -1, 480); + StringDraw.drawStringWithMaxWidth( + this.aGraphics642, this.aTextManager628.getShared("TellFriend_MessageTitle"), 200, 90, -1, 480); } else if (this.anInt638 == 1) { this.aGraphics642.setFont(aFont626); - StringDraw.drawStringWithMaxWidth(this.aGraphics642, this.aTextManager628.getShared("TellFriend_EmailSent"), 290, 122, 0, 340); + StringDraw.drawStringWithMaxWidth( + this.aGraphics642, this.aTextManager628.getShared("TellFriend_EmailSent"), 290, 122, 0, 340); var3 = this.anImageManager629.getShared("tf-char-sent.gif", true); if (var3 != null) { this.aGraphics642.drawImage(var3, 40, 60, this); @@ -102,7 +105,8 @@ public void update(Graphics var1) { } } else { this.aGraphics642.setFont(aFont627); - StringDraw.drawStringWithMaxWidth(this.aGraphics642, this.aTextManager628.getShared("TellFriend_EmailNotSent"), 310, 92, 0, 340); + StringDraw.drawStringWithMaxWidth( + this.aGraphics642, this.aTextManager628.getShared("TellFriend_EmailNotSent"), 310, 92, 0, 340); var3 = this.anImageManager629.getShared("tf-char-error.gif", true); if (var3 != null) { this.aGraphics642.drawImage(var3, 50, 120, this); @@ -127,7 +131,6 @@ public void update(Graphics var1) { if (var2) { new DelayRepaint(this); } - } public synchronized void actionPerformed(ActionEvent var1) { @@ -144,7 +147,10 @@ public synchronized void actionPerformed(ActionEvent var1) { if (var2 == this.anInputTextFieldArray632[var3]) { if (var3 < this.anInt639) { for (var4 = 0; var4 < this.anInt639; ++var4) { - if (this.anInputTextFieldArray632[var4].getInputText(false).length() == 0) { + if (this.anInputTextFieldArray632[var4] + .getInputText(false) + .length() + == 0) { this.anInputTextFieldArray632[var4].requestFocus(); return; } @@ -215,13 +221,11 @@ public synchronized void actionPerformed(ActionEvent var1) { if (var2 == this.aColorButton637) { this.aFrame_Sub3_Sub3_631.close(); } - } } } - public void focusGained(FocusEvent var1) { - } + public void focusGained(FocusEvent var1) {} public synchronized void focusLost(FocusEvent var1) { for (int var3 = 0; var3 < this.anInt639; ++var3) { @@ -230,7 +234,6 @@ public synchronized void focusLost(FocusEvent var1) { this.anInputTextFieldArray632[var3].setBackground(this.method484(var2) ? Color.white : aColor618); } } - } private void method480() { @@ -314,7 +317,6 @@ private void method482(boolean var1) { if (var1) { this.anInputTextFieldArray632[this.anInt639 - 1].requestFocus(); } - } private InputTextField method483() { diff --git a/client/src/main/java/com/aapeli/client/Parameters.java b/client/src/main/java/com/aapeli/client/Parameters.java index 16896e73..49bce241 100644 --- a/client/src/main/java/com/aapeli/client/Parameters.java +++ b/client/src/main/java/com/aapeli/client/Parameters.java @@ -2,7 +2,6 @@ import com.aapeli.applet.AApplet; import com.aapeli.tools.Tools; - import java.applet.Applet; import java.applet.AppletContext; import java.net.MalformedURLException; @@ -12,7 +11,7 @@ public final class Parameters { private static final String LOCALHOST = "127.0.0.1"; - //private static final String aString1416 = "192.168.1.23"; + // private static final String aString1416 = "192.168.1.23"; private static final String ENGLISH_LANGUAGE = "en"; private static final String PLAYFORIA_SITE_NAME = "playforia"; private static final String PLAYFORIA_QUIT_PAGE = "http://www.playforia.com/"; @@ -57,7 +56,6 @@ public final class Parameters { private String aString1457; private boolean debug; - public Parameters(Applet applet) { this(applet, false); } @@ -79,13 +77,13 @@ public static boolean getBooleanValue(String key) { if (key == null) { return false; } - return key.equalsIgnoreCase("true") || - key.equalsIgnoreCase("t") || - key.equalsIgnoreCase("yes") || - key.equalsIgnoreCase("y") || - key.equals("1") || - key.equals("1.0") || - key.equals("1,0"); + return key.equalsIgnoreCase("true") + || key.equalsIgnoreCase("t") + || key.equalsIgnoreCase("yes") + || key.equalsIgnoreCase("y") + || key.equals("1") + || key.equals("1.0") + || key.equals("1,0"); } public String getParameter(String key) { @@ -234,7 +232,6 @@ public void showPlayerList(String[] nicks, String var2) { this.anInt1455 = 1; } catch (Exception e) { } - } public void showPlayerListWinners(boolean[] winners) { @@ -273,7 +270,6 @@ public void showPlayerListWinners(boolean[] winners) { this.anInt1455 = 2; } catch (Exception e) { } - } public void removePlayerListWinners() { @@ -290,7 +286,6 @@ public void removePlayerList() { this.anInt1455 = 0; } catch (Exception e) { } - } public boolean showRegisterPage() { @@ -716,7 +711,10 @@ private URL toURL(String s) { private void showPlayerList(String[] nicks, boolean[] winners, String subgame) { if (this.debug) { - System.out.println("Parameters.showPlayerList(...): " + (nicks != null ? "nicks.length=" + nicks.length : "null") + ", " + (winners != null ? "winners.length=" + winners.length : "null")); + System.out.println("Parameters.showPlayerList(...): " + + (nicks != null ? "nicks.length=" + nicks.length : "null") + + ", " + + (winners != null ? "winners.length=" + winners.length : "null")); } if (this.urlUserListPage != null) { @@ -765,7 +763,6 @@ private void showPlayerList(String[] nicks, boolean[] winners, String subgame) { this.showUrl(var9, this.urlTargetUserList); } - } } } diff --git a/client/src/main/java/com/aapeli/client/SoundClip.java b/client/src/main/java/com/aapeli/client/SoundClip.java index 5a97c480..568669ad 100755 --- a/client/src/main/java/com/aapeli/client/SoundClip.java +++ b/client/src/main/java/com/aapeli/client/SoundClip.java @@ -13,7 +13,6 @@ class SoundClip { private AudioClip audioClip; private boolean defined; - protected SoundClip(Applet applet, URL dir, String file, boolean debug) { this.applet = applet; this.dir = dir; @@ -33,7 +32,7 @@ protected void defineClip() { System.out.println("SoundClip.defineClip(): 'dir'=\"" + this.dir + "\", 'file'=\"" + this.file + "\""); } - //todo this.audioClip = this.applet.getAudioClip(this.dir, this.file); + // todo this.audioClip = this.applet.getAudioClip(this.dir, this.file); URL url = dir; try { url = new URL(dir, file); diff --git a/client/src/main/java/com/aapeli/client/SoundManager.java b/client/src/main/java/com/aapeli/client/SoundManager.java index 976ab32f..98792948 100644 --- a/client/src/main/java/com/aapeli/client/SoundManager.java +++ b/client/src/main/java/com/aapeli/client/SoundManager.java @@ -1,7 +1,6 @@ package com.aapeli.client; import com.aapeli.applet.AApplet; - import java.applet.AudioClip; import java.net.URL; import java.util.Hashtable; @@ -11,7 +10,8 @@ public final class SoundManager implements Runnable { private static final String[] methodLookup = {"stop", "play", "loop"}; private AApplet applet; private URL sharedSoundDir; - private final boolean loadSoundClipsOnRegister; // if false, users must call startLoading() to bulk load all registered sound clips + private final boolean loadSoundClipsOnRegister; // if false, users must call startLoading() to bulk load all + // registered sound clips private final boolean debug; private boolean startupDebug; private Hashtable clientSounds; @@ -19,7 +19,6 @@ public final class SoundManager implements Runnable { private boolean clipLoaderThreadRunning; public int audioChoicerIndex; - public SoundManager(AApplet applet) { this(applet, true, false); } @@ -42,7 +41,6 @@ public SoundManager(AApplet applet, boolean loadClipsOnRegister, boolean debug) if (loadClipsOnRegister) { this.loadAllSoundClips(); } - } @Override @@ -54,14 +52,14 @@ public void run() { boolean anySoundClipsNotDefined; do { anySoundClipsNotDefined = false; - for (SoundClip soundClip: this.clientSounds.values()) { + for (SoundClip soundClip : this.clientSounds.values()) { if (!soundClip.isDefined()) { soundClip.defineClip(); anySoundClipsNotDefined = true; } } - for (SoundClip soundClip: this.sharedSounds.values()) { + for (SoundClip soundClip : this.sharedSounds.values()) { if (!soundClip.isDefined()) { soundClip.defineClip(); anySoundClipsNotDefined = true; @@ -73,7 +71,6 @@ public void run() { if (this.debug) { System.out.println("SoundManager.run(): Thread finished"); } - } public void defineSharedSoundClip(String filename) { @@ -96,7 +93,6 @@ public void defineSharedSoundClip(String clipName, String soundFile) { if (this.loadSoundClipsOnRegister) { this.loadAllSoundClips(); } - } public void startLoading() { @@ -251,10 +247,15 @@ private void handleSharedSoundClip(String clipName, int methodIndex) { audioClip.loop(); } } else if (this.debug) { - System.out.println("SoundManager." + methodLookup[methodIndex] + "(\"" + clipName + "\"): AudioClip not ready!"); + System.out.println("SoundManager." + + methodLookup[methodIndex] + + "(\"" + + clipName + + "\"): AudioClip not ready!"); } } else if (this.debug) { - System.out.println("SoundManager." + methodLookup[methodIndex] + "(\"" + clipName + "\"): SoundClip not found!"); + System.out.println( + "SoundManager." + methodLookup[methodIndex] + "(\"" + clipName + "\"): SoundClip not found!"); Thread.dumpStack(); } } catch (Exception var5) { @@ -262,6 +263,5 @@ private void handleSharedSoundClip(String clipName, int methodIndex) { } catch (Error var6) { System.out.println("SoundManager: Unexpected error \"" + var6 + "\" when playing \"" + clipName + "\""); } - } } diff --git a/client/src/main/java/com/aapeli/client/StringDraw.java b/client/src/main/java/com/aapeli/client/StringDraw.java index c80eae18..d29244e4 100644 --- a/client/src/main/java/com/aapeli/client/StringDraw.java +++ b/client/src/main/java/com/aapeli/client/StringDraw.java @@ -17,14 +17,15 @@ public class StringDraw { public static final int ALIGN_CENTER_LEFT_ALWAYS_VISIBLE = -2; public static final int ALIGN_CENTER_RIGHT_ALWAYS_VISIBLE = 2; - public static int drawString(Graphics g, String text, int x, int y, int alignment) { return drawOutlinedString(g, null, text, x, y, alignment); } public static int drawOutlinedString(Graphics g, Color outlineColor, String text, int x, int y, int alignment) { int textWidth = getStringWidth(g, text); - if (alignment == ALIGN_CENTER || alignment == ALIGN_CENTER_LEFT_ALWAYS_VISIBLE || alignment == ALIGN_CENTER_RIGHT_ALWAYS_VISIBLE) { + if (alignment == ALIGN_CENTER + || alignment == ALIGN_CENTER_LEFT_ALWAYS_VISIBLE + || alignment == ALIGN_CENTER_RIGHT_ALWAYS_VISIBLE) { x -= textWidth / 2; } @@ -67,7 +68,8 @@ public static int[] drawStringWithMaxWidth(Graphics g, String text, int var2, in return drawOutlinedStringWithMaxWidth(g, null, text, var2, var3, var4, var5); } - public static int[] drawOutlinedStringWithMaxWidth(Graphics g, Color outlineColor, String text, int x, int y, int alignment, int maxWidth) { + public static int[] drawOutlinedStringWithMaxWidth( + Graphics g, Color outlineColor, String text, int x, int y, int alignment, int maxWidth) { Font font = g.getFont(); FontMetrics fontMetrics = g.getFontMetrics(font); List lines = createLines(fontMetrics, text, maxWidth); @@ -77,11 +79,11 @@ public static int[] drawOutlinedStringWithMaxWidth(Graphics g, Color outlineColo lineHeight += 2; } - int[] linesData = new int[]{lines.size(), 0, 0}; // 0 == number of lines, 1 == height, 2 == width + int[] linesData = new int[] {lines.size(), 0, 0}; // 0 == number of lines, 1 == height, 2 == width linesData[1] = linesData[0] * lineHeight; linesData[2] = 0; - for (String line: lines) { + for (String line : lines) { int lineWidth = drawOutlinedString(g, outlineColor, line, x, y, alignment); if (lineWidth > linesData[2]) { linesData[2] = lineWidth; @@ -162,7 +164,6 @@ private static void createLinesPrivate(List lines, String text, FontMetr createLinesPrivate(lines, newText, fontMetrics, maximumWidth); } } - } private static String splitAtSpace(String line) { diff --git a/client/src/main/java/com/aapeli/client/TextManager.java b/client/src/main/java/com/aapeli/client/TextManager.java index d886e961..56d1aa52 100644 --- a/client/src/main/java/com/aapeli/client/TextManager.java +++ b/client/src/main/java/com/aapeli/client/TextManager.java @@ -3,7 +3,6 @@ import com.aapeli.tools.EncodedXmlReader; import com.aapeli.tools.Tools; import com.aapeli.tools.XmlUnit; - import java.applet.Applet; import java.io.BufferedReader; import java.io.FileNotFoundException; @@ -64,7 +63,6 @@ public TextManager(Parameters parameters, boolean loadTextsInSeparateThread, boo } else { this.loadTexts(parameters.getApplet()); } - } private TextManager(boolean debug) { @@ -85,7 +83,6 @@ public void run() { if (this.debug) { System.out.println("TextManager.run(): Finished loading texts"); } - } public String getGame(String key) { @@ -106,47 +103,48 @@ public String getIfAvailable(String key, String fallback) { } public String getGame(String key, String argument1) { - String[] arguments = new String[]{argument1}; + String[] arguments = new String[] {argument1}; return this.getGame(key, arguments); } public String getGame(String key, String var2, String var3) { - String[] arguments = new String[]{var2, var3}; + String[] arguments = new String[] {var2, var3}; return this.getGame(key, arguments); } public String getGame(String key, String argument2, String argument3, String argument4) { - String[] arguments = new String[]{argument2, argument3, argument4}; + String[] arguments = new String[] {argument2, argument3, argument4}; return this.getGame(key, arguments); } public String getGame(String key, String argument2, String argument3, String argument4, String argument5) { - String[] arguments = new String[]{argument2, argument3, argument4, argument5}; + String[] arguments = new String[] {argument2, argument3, argument4, argument5}; return this.getGame(key, arguments); } - public String getGame(String key, String argument2, String argument3, String argument4, String argument5, String argument6) { - String[] arguments = new String[]{argument2, argument3, argument4, argument5, argument6}; + public String getGame( + String key, String argument2, String argument3, String argument4, String argument5, String argument6) { + String[] arguments = new String[] {argument2, argument3, argument4, argument5, argument6}; return this.getGame(key, arguments); } public String getGame(String key, int argument2) { - String[] arguments = new String[]{"" + argument2}; + String[] arguments = new String[] {"" + argument2}; return this.getGame(key, arguments); } public String getGame(String key, int argument2, int argument3) { - String[] arguments = new String[]{"" + argument2, "" + argument3}; + String[] arguments = new String[] {"" + argument2, "" + argument3}; return this.getGame(key, arguments); } public String getGame(String key, int argument2, int argument3, int argument4) { - String[] arguments = new String[]{"" + argument2, "" + argument3, "" + argument4}; + String[] arguments = new String[] {"" + argument2, "" + argument3, "" + argument4}; return this.getGame(key, arguments); } public String getGame(String key, int argument2, int argument3, int argument4, int argument5) { - String[] arguments = new String[]{"" + argument2, "" + argument3, "" + argument4, "" + argument5}; + String[] arguments = new String[] {"" + argument2, "" + argument3, "" + argument4, "" + argument5}; return this.getGame(key, arguments); } @@ -244,7 +242,10 @@ public String getTime(long time, boolean var3) { result = result + seconds; if (includeSecondFraction) { - result = result + this.getShared("SeparatorSecondFraction") + (secondFraction < 10 ? "0" : "") + secondFraction; + result = result + + this.getShared("SeparatorSecondFraction") + + (secondFraction < 10 ? "0" : "") + + secondFraction; } return result; @@ -278,27 +279,27 @@ public String getShared(String key) { } public String getShared(String key, String argument) { - String[] arguments = new String[]{argument}; + String[] arguments = new String[] {argument}; return this.getShared(key, arguments); } public String getShared(String key, String argument1, String argument2) { - String[] arguments = new String[]{argument1, argument2}; + String[] arguments = new String[] {argument1, argument2}; return this.getShared(key, arguments); } public String getShared(String key, String argument2, String argument3, String argument4) { - String[] arguments = new String[]{argument2, argument3, argument4}; + String[] arguments = new String[] {argument2, argument3, argument4}; return this.getShared(key, arguments); } public String getShared(String key, String argument2, String argument3, String argument4, String argument5) { - String[] arguments = new String[]{argument2, argument3, argument4, argument5}; + String[] arguments = new String[] {argument2, argument3, argument4, argument5}; return this.getShared(key, arguments); } public String getWithQuantity(String key, int quantity) { - return this.getGame(key, new String[]{"" + quantity}, quantity); + return this.getGame(key, new String[] {"" + quantity}, quantity); } public String getWithQuantity(String key, String[] arguments, int quantity) { @@ -313,7 +314,6 @@ public void waitLoadingFinished() { while (!this.isLoadingFinished()) { Tools.sleep(50L); } - } public Parameters getParameters() { @@ -457,8 +457,8 @@ private String method1726(long n, boolean separateThousands) { } /** - * - * @param mode -- 0 == just date, no time, standard format; 1 == just date, no time, locale format; 2 == + * @param mode -- 0 == just date, no time, standard format; 1 == just date, no time, locale + * format; 2 == */ private String getDate(long timestamp, int mode) { Calendar calendar = Calendar.getInstance(); @@ -564,7 +564,6 @@ private void loadTexts(Applet applet) { } else { this.loadLocaleFiles(applet); } - } private void loadLocaleFiles(Applet applet) { @@ -609,18 +608,22 @@ private Hashtable loadLocalizationTable(URL baseUrl) { int equalSignLocation = line.indexOf('='); if (equalSignLocation <= 0) { if (this.debug) { - System.out.println("Missing '='-character in \"" + this.language + "\"-locale file: \"" + line + "\""); + System.out.println( + "Missing '='-character in \"" + this.language + "\"-locale file: \"" + line + "\""); Thread.dumpStack(); } } else { String key = line.substring(0, equalSignLocation).trim(); if (key.length() == 0) { if (this.debug) { - System.out.println("Empty key in \"" + this.language + "\"-locale file: \"" + line + "\""); + System.out.println( + "Empty key in \"" + this.language + "\"-locale file: \"" + line + "\""); Thread.dumpStack(); } } else { - localizationTable.put(key.toLowerCase(), line.substring(equalSignLocation + 1).trim()); + localizationTable.put( + key.toLowerCase(), + line.substring(equalSignLocation + 1).trim()); } } } @@ -698,7 +701,7 @@ private void loadLanguageFiles(Applet applet) { } private Hashtable readTable(String fileUrl) { - EncodedXmlReader reader = new EncodedXmlReader(fileUrl, /*this.aBoolean1519*/true); + EncodedXmlReader reader = new EncodedXmlReader(fileUrl, /*this.aBoolean1519*/ true); XmlUnit unit = reader.readXmlUnit(); if (unit == null) { System.out.println("Failed to read localization file '" + fileUrl + "'"); @@ -709,7 +712,10 @@ private Hashtable readTable(String fileUrl) { Hashtable table = new Hashtable<>(); for (XmlUnit child : children) { - table.put(child.getAttribute("key").toLowerCase(), new LocalizationNode(this, this.language, child, Tools.getBoolean(child.getAttribute("reverse")))); + table.put( + child.getAttribute("key").toLowerCase(), + new LocalizationNode( + this, this.language, child, Tools.getBoolean(child.getAttribute("reverse")))); } return table; diff --git a/client/src/main/java/com/aapeli/client/UrlLabel.java b/client/src/main/java/com/aapeli/client/UrlLabel.java index 04f9a009..a477b9c0 100644 --- a/client/src/main/java/com/aapeli/client/UrlLabel.java +++ b/client/src/main/java/com/aapeli/client/UrlLabel.java @@ -20,7 +20,7 @@ public class UrlLabel extends IPanel implements MouseListener { public static final int ALIGN_RIGHT = 1; public static final int TARGET_SAME = 0; public static final int TARGET_NEW = 1; - private static final String[] urlTargets = new String[]{"_top", "_blank"}; + private static final String[] urlTargets = new String[] {"_top", "_blank"}; private static final Cursor defaultCursor = new Cursor(Cursor.DEFAULT_CURSOR); private static final Cursor handCursor = new Cursor(Cursor.HAND_CURSOR); private static final Font fontDialog11 = new Font("Dialog", Font.PLAIN, 11); @@ -43,7 +43,6 @@ public class UrlLabel extends IPanel implements MouseListener { private String urlTarget; private static final String aString3247 = "Dialog"; - public UrlLabel(Applet applet) { this(applet, fontDialog11, null, null); } @@ -74,7 +73,17 @@ public void update(Graphics graphics) { int width = size.width; int height = size.height; if (this.backgroundImage != null) { - graphics.drawImage(this.backgroundImage, 0, 0, width, height, this.backgroundImageOffsetX, this.backgroundImageOffsetY, this.backgroundImageOffsetX + width, this.backgroundImageOffsetY + height, this); + graphics.drawImage( + this.backgroundImage, + 0, + 0, + width, + height, + this.backgroundImageOffsetX, + this.backgroundImageOffsetY, + this.backgroundImageOffsetX + width, + this.backgroundImageOffsetY + height, + this); } else if (!this.drawBackgroundImage(graphics)) { graphics.setColor(this.backgroundColor != null ? this.backgroundColor : this.getBackground()); graphics.fillRect(0, 0, width, height); @@ -107,25 +116,20 @@ public void update(Graphics graphics) { graphics.setColor(this.foregroundMainColor); graphics.drawString(this.suffix, x + this.prefixWidth + this.linkTextWidth, y); } - } } - public void mouseEntered(MouseEvent var1) { - } + public void mouseEntered(MouseEvent var1) {} - public void mouseExited(MouseEvent var1) { - } + public void mouseExited(MouseEvent var1) {} - public void mousePressed(MouseEvent var1) { - } + public void mousePressed(MouseEvent var1) {} public void mouseReleased(MouseEvent var1) { this.applet.getAppletContext().showDocument(this.url, this.urlTarget); } - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} public void setText(String text, String url) { if (text == null) { diff --git a/client/src/main/java/com/aapeli/colorgui/Choicer.java b/client/src/main/java/com/aapeli/colorgui/Choicer.java index e8561940..30fc9575 100644 --- a/client/src/main/java/com/aapeli/colorgui/Choicer.java +++ b/client/src/main/java/com/aapeli/colorgui/Choicer.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.IPanel; - import java.awt.Choice; import java.awt.Color; import java.awt.Dimension; @@ -21,7 +20,6 @@ public class Choicer extends IPanel implements ComponentListener, ItemListener, private List listeners; private Object synchronizationObject = new Object(); - public Choicer() { this.choice.setBackground(Color.white); this.choice.setForeground(Color.black); @@ -33,14 +31,11 @@ public Choicer() { this.addComponentListener(this); } - public void componentHidden(ComponentEvent e) { - } + public void componentHidden(ComponentEvent e) {} - public void componentShown(ComponentEvent e) { - } + public void componentShown(ComponentEvent e) {} - public void componentMoved(ComponentEvent e) { - } + public void componentMoved(ComponentEvent e) {} public void componentResized(ComponentEvent e) { Object synchronizationObject = this.synchronizationObject; @@ -51,7 +46,6 @@ public void componentResized(ComponentEvent e) { } else { this.colorSpinner.setSize(size); } - } } @@ -59,7 +53,7 @@ public void itemStateChanged(ItemEvent e) { synchronized (this.listeners) { if (!this.listeners.isEmpty()) { e = new ItemEvent(this, e.getID(), e.getItem(), e.getStateChange()); - for (ItemListener listener: this.listeners) { + for (ItemListener listener : this.listeners) { listener.itemStateChanged(e); } } @@ -82,7 +76,6 @@ public void setBackground(Color color) { } else { this.colorSpinner.setBackground(color); } - } } @@ -95,7 +88,6 @@ public void setForeground(Color color) { } else { this.colorSpinner.setForeground(color); } - } } @@ -111,7 +103,6 @@ public void addItem(String text) { } else { this.colorSpinner.addItem(text); } - } } @@ -123,7 +114,6 @@ public void removeItem(int i) { } else { this.colorSpinner.removeItem(i); } - } } @@ -153,7 +143,6 @@ public void setSelectedIndex(int i) { } else { this.colorSpinner.setSelectedIndex(i); } - } } @@ -216,6 +205,5 @@ private void moveToSpinnerIfNecessary(String text) { return; } } - } } diff --git a/client/src/main/java/com/aapeli/colorgui/Class90.java b/client/src/main/java/com/aapeli/colorgui/Class90.java index 67c33d67..b460ce2c 100644 --- a/client/src/main/java/com/aapeli/colorgui/Class90.java +++ b/client/src/main/java/com/aapeli/colorgui/Class90.java @@ -8,7 +8,6 @@ class Class90 implements Runnable { private boolean aBoolean1534; private final ColorButton aColorButton1535; - protected Class90(ColorButton var1, ColorButton var2) { this.aColorButton1535 = var1; this.aColorButton1533 = var2; @@ -25,7 +24,6 @@ public void run() { this.aColorButton1533.innerSetFlashState(var1); } } while (this.aBoolean1534); - } protected void method1738() { diff --git a/client/src/main/java/com/aapeli/colorgui/Class92.java b/client/src/main/java/com/aapeli/colorgui/Class92.java index c98cce29..b24c1082 100644 --- a/client/src/main/java/com/aapeli/colorgui/Class92.java +++ b/client/src/main/java/com/aapeli/colorgui/Class92.java @@ -9,7 +9,6 @@ class Class92 implements Runnable { private boolean aBoolean1551; private final ColorSpinner aColorSpinner1552; - protected Class92(ColorSpinner var1, ColorSpinner var2, int var3) { this.aColorSpinner1552 = var1; this.aColorSpinner1549 = var2; @@ -25,7 +24,6 @@ public void run() { if (this.aBoolean1551) { this.aColorSpinner1549.method846(); } - } protected void method1746() { diff --git a/client/src/main/java/com/aapeli/colorgui/Class95.java b/client/src/main/java/com/aapeli/colorgui/Class95.java index 1f9d3df5..254a02a8 100644 --- a/client/src/main/java/com/aapeli/colorgui/Class95.java +++ b/client/src/main/java/com/aapeli/colorgui/Class95.java @@ -8,7 +8,6 @@ class Class95 implements Runnable { private boolean aBoolean1578; private final RoundButton aRoundButton1579; - protected Class95(RoundButton var1, RoundButton var2) { this.aRoundButton1579 = var1; this.aRoundButton1577 = var2; @@ -25,7 +24,6 @@ public void run() { this.aRoundButton1577.innerSetFlashState(var1); } } while (this.aBoolean1578); - } protected void method1755() { diff --git a/client/src/main/java/com/aapeli/colorgui/ColorButton.java b/client/src/main/java/com/aapeli/colorgui/ColorButton.java index 38dc9a27..b73e87eb 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorButton.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorButton.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.IPanel; - import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -101,7 +100,17 @@ public void update(Graphics var1) { if (this.anImage3260 != null && this.anImage3261 != null) { Image var17 = var5 ? this.anImage3261 : this.anImage3260; if (!this.aBoolean3271) { - this.aGraphics3282.drawImage(var17, 0, 0, var3, var4, this.anInt3265, this.anInt3266, this.anInt3265 + var3, this.anInt3266 + var4, this); + this.aGraphics3282.drawImage( + var17, + 0, + 0, + var3, + var4, + this.anInt3265, + this.anInt3266, + this.anInt3265 + var3, + this.anInt3266 + var4, + this); } else { this.aGraphics3282.drawImage(var17, 0, 0, var3, var4, this); } @@ -121,7 +130,11 @@ public void update(Graphics var1) { this.drawBorder(this.aGraphics3282, var3, var4); if (this.anImage3262 != null) { - this.aGraphics3282.drawImage(this.isNormalState() ? this.anImage3262 : this.anImage3263, this.anInt3267 > 0 ? var3 / 2 - this.anInt3267 / 2 : 0, this.anInt3268 > 0 ? var4 / 2 - this.anInt3268 / 2 : 0, this); + this.aGraphics3282.drawImage( + this.isNormalState() ? this.anImage3262 : this.anImage3263, + this.anInt3267 > 0 ? var3 / 2 - this.anInt3267 / 2 : 0, + this.anInt3268 > 0 ? var4 / 2 - this.anInt3268 / 2 : 0, + this); } int var16 = var3 / 2; @@ -191,17 +204,13 @@ public void mouseReleased(MouseEvent var1) { if (var2) { this.processActionEvent(); } - } - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} - public void mouseMoved(MouseEvent var1) { - } + public void mouseMoved(MouseEvent var1) {} - public void mouseDragged(MouseEvent var1) { - } + public void mouseDragged(MouseEvent var1) {} public void setBackground(Color var1) { if (var1 == null) { @@ -283,7 +292,6 @@ public void setIconImage(Image var1) { } else { this.setIconImage(null, -1, -1); } - } public void setIconImage(Image var1, int var2, int var3) { @@ -342,7 +350,9 @@ public void click() { } public Dimension getPreferredSize() { - return new Dimension(13 + this.getFontMetrics(this.aFont3274).stringWidth(this.aString3272) + 13, 5 + this.aFont3274.getSize() + 5); + return new Dimension( + 13 + this.getFontMetrics(this.aFont3274).stringWidth(this.aString3272) + 13, + 5 + this.aFont3274.getSize() + 5); } public void addActionListener(ActionListener var1) { @@ -377,18 +387,15 @@ public void setFlashing(boolean var1) { this.aBoolean3286 = false; this.repaint(); } - } public Image createBuffer(int var1, int var2) { return this.createImage(var1, var2); } - public void graphicsCreated(Graphics var1) { - } + public void graphicsCreated(Graphics var1) {} - public void baseBackgroundDrawn(Graphics var1) { - } + public void baseBackgroundDrawn(Graphics var1) {} public boolean isNormalState() { return !this.aBoolean3278; @@ -450,7 +457,6 @@ public void drawBorder(Graphics var1, int var2, int var3) { var1.drawLine(0, 0, 0, var3 - 1); var1.drawLine(1, 0, 1, var3 - 2); } - } } @@ -460,7 +466,7 @@ public int drawIcon(Graphics var1, Image var2, int var3) { } public Color[] getLightAndDarkBorderColors() { - return new Color[]{this.aColor3257, this.aColor3258}; + return new Color[] {this.aColor3257, this.aColor3258}; } private Color method826(Color var1, int var2) { @@ -521,7 +527,6 @@ private void method827(Graphics var1, Color var2, int var3, int var4) { var1.setColor(new Color(var9, var10, var11)); var1.drawLine(var5, var12, var3 - 1 - var5, var12); } - } private int method828(int var1, int var2) { diff --git a/client/src/main/java/com/aapeli/colorgui/ColorCheckbox.java b/client/src/main/java/com/aapeli/colorgui/ColorCheckbox.java index 925d0681..c8a79a06 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorCheckbox.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorCheckbox.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.IPanel; - import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -42,7 +41,6 @@ public class ColorCheckbox extends IPanel implements ItemSelectable, MouseListen private int anInt3308; private int anInt3309; - public ColorCheckbox() { this(null, false); } @@ -81,12 +79,23 @@ public void update(Graphics var1) { } if (this.anImage3297 != null) { - this.aGraphics3307.drawImage(this.anImage3297, 0, 0, var3, var4, this.anInt3298, this.anInt3299, this.anInt3298 + var3, this.anInt3299 + var4, this); + this.aGraphics3307.drawImage( + this.anImage3297, + 0, + 0, + var3, + var4, + this.anInt3298, + this.anInt3299, + this.anInt3298 + var3, + this.anInt3299 + var4, + this); } else { this.drawBackground(this.aGraphics3307); } - Font var5 = this.aString3300 != null ? this.method837(this.aFont3291, this.aString3300, var3 - (var4 + 4)) : null; + Font var5 = + this.aString3300 != null ? this.method837(this.aFont3291, this.aString3300, var3 - (var4 + 4)) : null; int var6 = 0; int var7; if (this.anInt3301 == 0 || this.anInt3301 == 1) { @@ -100,7 +109,15 @@ public void update(Graphics var1) { var7 = var4 - 4; if (this.aColorCheckboxGroup3304 == null) { - this.method840(this.aGraphics3307, var6 + 2, 2, var7, var7, this.method839(this.aColor3293), this.method839(this.aColor3295), this.method839(this.aColor3296)); + this.method840( + this.aGraphics3307, + var6 + 2, + 2, + var7, + var7, + this.method839(this.aColor3293), + this.method839(this.aColor3295), + this.method839(this.aColor3296)); } else { this.aGraphics3307.setColor(this.method839(this.aColor3293)); this.aGraphics3307.fillRect(var6 + 3, 3, var7 - 2, var7 - 2); @@ -124,11 +141,16 @@ public void update(Graphics var1) { int var9 = var8 - 1; int var10 = var7 - var8 - 2; this.aGraphics3307.drawLine(var6 + 4 + var8, 4 + var7 - 2, var6 + 4 + var8 - var9, 4 + var7 - 2 - var9); - this.aGraphics3307.drawLine(var6 + 4 + var8, 4 + var7 - 2 - 1, var6 + 4 + var8 - var9, 4 + var7 - 2 - var9 - 1); - this.aGraphics3307.drawLine(var6 + 4 + var8, 4 + var7 - 2 - 2, var6 + 4 + var8 - var9, 4 + var7 - 2 - var9 - 2); - this.aGraphics3307.drawLine(var6 + 4 + var8, 4 + var7 - 2, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10); - this.aGraphics3307.drawLine(var6 + 4 + var8, 4 + var7 - 2 - 1, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10 - 1); - this.aGraphics3307.drawLine(var6 + 4 + var8, 4 + var7 - 2 - 2, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10 - 2); + this.aGraphics3307.drawLine( + var6 + 4 + var8, 4 + var7 - 2 - 1, var6 + 4 + var8 - var9, 4 + var7 - 2 - var9 - 1); + this.aGraphics3307.drawLine( + var6 + 4 + var8, 4 + var7 - 2 - 2, var6 + 4 + var8 - var9, 4 + var7 - 2 - var9 - 2); + this.aGraphics3307.drawLine( + var6 + 4 + var8, 4 + var7 - 2, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10); + this.aGraphics3307.drawLine( + var6 + 4 + var8, 4 + var7 - 2 - 1, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10 - 1); + this.aGraphics3307.drawLine( + var6 + 4 + var8, 4 + var7 - 2 - 2, var6 + 4 + var8 + var10, 4 + var7 - 2 - var10 - 2); } else { var7 -= 6; this.aGraphics3307.fillRect(var6 + 6, 5, var7 - 2, var7); @@ -145,17 +167,13 @@ public void update(Graphics var1) { var1.drawImage(this.anImage3306, 0, 0, this); } - public void mouseEntered(MouseEvent var1) { - } + public void mouseEntered(MouseEvent var1) {} - public void mouseExited(MouseEvent var1) { - } + public void mouseExited(MouseEvent var1) {} - public void mousePressed(MouseEvent var1) { - } + public void mousePressed(MouseEvent var1) {} - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} public void mouseReleased(MouseEvent var1) { boolean var2 = !this.aBoolean3302; @@ -181,7 +199,7 @@ public Object[] getSelectedObjects() { if (!this.aBoolean3302) { return null; } else { - Object[] var1 = new Object[]{this}; + Object[] var1 = new Object[] {this}; return var1; } } @@ -284,7 +302,10 @@ public void realSetState(boolean var1) { } private Color method835(Color var1, int var2) { - return new Color(this.method836(var1.getRed(), var2), this.method836(var1.getGreen(), var2), this.method836(var1.getBlue(), var2)); + return new Color( + this.method836(var1.getRed(), var2), + this.method836(var1.getGreen(), var2), + this.method836(var1.getBlue(), var2)); } private int method836(int var1, int var2) { @@ -364,7 +385,5 @@ private void method840(Graphics var1, int var2, int var3, int var4, int var5, Co var1.drawLine(var2, var3, var2 + var4 - 2, var3); var1.drawLine(var2, var3, var2, var3 + var5 - 1); } - } - } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorCheckboxGroup.java b/client/src/main/java/com/aapeli/colorgui/ColorCheckboxGroup.java index 74a9110b..12e49420 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorCheckboxGroup.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorCheckboxGroup.java @@ -8,7 +8,7 @@ public final class ColorCheckboxGroup { private List checkboxes = new ArrayList<>(); protected void addCheckbox(ColorCheckbox checkbox) { - synchronized(this.checkboxes) { + synchronized (this.checkboxes) { this.checkboxes.add(checkbox); } } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorList.java b/client/src/main/java/com/aapeli/colorgui/ColorList.java index 5465bdcc..d35cc7b7 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorList.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorList.java @@ -19,7 +19,8 @@ import java.util.ArrayList; import java.util.List; -public final class ColorList extends Panel implements ComponentListener, AdjustmentListener, MouseListener, ItemSelectable { +public final class ColorList extends Panel + implements ComponentListener, AdjustmentListener, MouseListener, ItemSelectable { public static final int SELECTABLE_NONE = 0; public static final int SELECTABLE_ONE = 1; @@ -64,7 +65,6 @@ public final class ColorList extends Panel implements ComponentListener, Adjustm private int imageHeight; private List listeners; - public ColorList(int width, int height) { this(width, height, FontConstants.font, 0, 0); } @@ -128,7 +128,17 @@ public void update(Graphics g) { this.imageGraphics.setColor(backgroundColor); this.imageGraphics.fillRect(0, 0, this.width, this.height); } else { - this.imageGraphics.drawImage(this.backgroundImage, 0, 0, this.width, this.height, this.backgroundImageoffsetX, this.backgroundImageOffsetY, this.backgroundImageoffsetX + this.width, this.backgroundImageOffsetY + this.height, this); + this.imageGraphics.drawImage( + this.backgroundImage, + 0, + 0, + this.width, + this.height, + this.backgroundImageoffsetX, + this.backgroundImageOffsetY, + this.backgroundImageoffsetX + this.width, + this.backgroundImageOffsetY + this.height, + this); } ColorListItemGroup currentGroup = null; @@ -137,7 +147,17 @@ public void update(Graphics g) { int y = 0; ColorListNode node; if (this.title != null) { - node = new ColorListNode(1, y, this.width - 2, this.rowHeight, this.iconWidth, this.backgroundImage != null, this.fontBold, this.titleColor, this.title, null); + node = new ColorListNode( + 1, + y, + this.width - 2, + this.rowHeight, + this.iconWidth, + this.backgroundImage != null, + this.fontBold, + this.titleColor, + this.title, + null); this.nodes.add(node); node.draw(this.imageGraphics, this); y += this.rowHeight; @@ -156,7 +176,17 @@ public void update(Graphics g) { if (hasMultipleGroups) { ColorListItemGroup group = item.getGroup(); if (group != currentGroup) { - node = new ColorListNode(1, y, this.width - 2, this.rowHeight, this.iconWidth, this.backgroundImage != null, this.fontBold, Color.darkGray, group.getText(), group.getIcon()); + node = new ColorListNode( + 1, + y, + this.width - 2, + this.rowHeight, + this.iconWidth, + this.backgroundImage != null, + this.fontBold, + Color.darkGray, + group.getText(), + group.getIcon()); this.nodes.add(node); node.draw(this.imageGraphics, this); currentGroup = group; @@ -166,7 +196,16 @@ public void update(Graphics g) { } } - node = new ColorListNode(1, y, this.width - 2, this.rowHeight, this.iconWidth, this.backgroundImage != null, this.font, this.fontBold, item); + node = new ColorListNode( + 1, + y, + this.width - 2, + this.rowHeight, + this.iconWidth, + this.backgroundImage != null, + this.font, + this.fontBold, + item); this.nodes.add(node); node.draw(this.imageGraphics, this); y += this.rowHeight; @@ -193,7 +232,7 @@ public void update(Graphics g) { private boolean hasMultipleGroups() { ColorListItemGroup group = null; - for (ColorListItem colorListItem: this.items) { + for (ColorListItem colorListItem : this.items) { ColorListItemGroup group2 = colorListItem.getGroup(); if (group2 != null) { if (group != null && group2 != group) { @@ -207,14 +246,11 @@ private boolean hasMultipleGroups() { return false; } - public void componentShown(ComponentEvent e) { - } + public void componentShown(ComponentEvent e) {} - public void componentHidden(ComponentEvent e) { - } + public void componentHidden(ComponentEvent e) {} - public void componentMoved(ComponentEvent e) { - } + public void componentMoved(ComponentEvent e) {} public void componentResized(ComponentEvent e) { Dimension size = this.getSize(); @@ -284,17 +320,13 @@ public synchronized void mousePressed(MouseEvent e) { } } - public void mouseReleased(MouseEvent e) { - } + public void mouseReleased(MouseEvent e) {} - public void mouseClicked(MouseEvent e) { - } + public void mouseClicked(MouseEvent e) {} - public void mouseEntered(MouseEvent e) { - } + public void mouseEntered(MouseEvent e) {} - public void mouseExited(MouseEvent e) { - } + public void mouseExited(MouseEvent e) {} public synchronized void addItemListener(ItemListener listener) { this.listeners.add(listener); @@ -315,7 +347,6 @@ public void setSelectable(int selectable) { } else if (selectable == SELECTABLE_ONE && this.getSelectedItemCount() > 1) { this.removeAllSelections(); } - } public void setSorted(boolean sorted) { @@ -394,7 +425,9 @@ public synchronized void addItem(ColorListItem item) { this.items.add(position, item); int scrollbarValue = this.scrollbar.getValue(); int scrollbarOffset = position < scrollbarValue ? 1 : 0; - if (scrollbarOffset == 0 && scrollbarValue > 0 && scrollbarValue + this.scrollbar.getVisibleAmount() == this.scrollbar.getMaximum()) { + if (scrollbarOffset == 0 + && scrollbarValue > 0 + && scrollbarValue + this.scrollbar.getVisibleAmount() == this.scrollbar.getMaximum()) { scrollbarOffset = 1; } @@ -471,7 +504,7 @@ public synchronized void removeAllSelections() { } public int[] getLastClickedMouseXY() { - return new int[]{this.lastMouseClickX, this.lastMouseClickY}; + return new int[] {this.lastMouseClickX, this.lastMouseClickY}; } private synchronized void configureScrollbar(boolean scrollToBottom, int offset) { @@ -552,7 +585,9 @@ private synchronized int getPositionFor(ColorListItem item) { } else { int groupSortValue = this.getGroupSortValue(item); int groupPosition = this.getGroupStartPosition(groupSortValue, itemsCount); - return groupPosition == itemsCount ? itemsCount : this.getPositionFor(item, groupSortValue, groupPosition, itemsCount); + return groupPosition == itemsCount + ? itemsCount + : this.getPositionFor(item, groupSortValue, groupPosition, itemsCount); } } @@ -662,10 +697,9 @@ private String getNormalizedSortKey(String itemText) { private synchronized void itemPressed(ColorListItem item, int eventId, int newState) { if (this.listeners.size() != 0) { ItemEvent event = new ItemEvent(this, eventId, item, newState); - for (ItemListener itemListener: this.listeners) { + for (ItemListener itemListener : this.listeners) { itemListener.itemStateChanged(event); } } } - } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorListItem.java b/client/src/main/java/com/aapeli/colorgui/ColorListItem.java index 08822ce4..493978f6 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorListItem.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorListItem.java @@ -14,7 +14,17 @@ public class ColorListItem { public static final int COLOR_CYAN = 6; public static final int COLOR_GRAY = 7; public static final int COLOR_WHITE = 8; - private static final Color[] colors = new Color[]{new Color(0, 0, 0), new Color(240, 0, 0), new Color(0, 160, 0), new Color(0, 0, 255), new Color(144, 144, 0), new Color(176, 0, 176), new Color(0, 160, 176), new Color(112, 112, 112), new Color(255, 255, 255)}; + private static final Color[] colors = new Color[] { + new Color(0, 0, 0), + new Color(240, 0, 0), + new Color(0, 160, 0), + new Color(0, 0, 255), + new Color(144, 144, 0), + new Color(176, 0, 176), + new Color(0, 160, 176), + new Color(112, 112, 112), + new Color(255, 255, 255) + }; private Image icon; private Color color; private boolean bold; @@ -27,7 +37,6 @@ public class ColorListItem { private ColorListItemGroup group; private ColorList colorList; - public ColorListItem(String text) { this(null, 0, false, text, null, false); } @@ -150,5 +159,4 @@ public void setColorListReference(ColorList colorList) { public ColorList getColorListReference() { return this.colorList; } - } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorListItemGroup.java b/client/src/main/java/com/aapeli/colorgui/ColorListItemGroup.java index 93c8d655..db63e450 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorListItemGroup.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorListItemGroup.java @@ -8,7 +8,6 @@ public class ColorListItemGroup { private Image icon; private int sortValue; - public ColorListItemGroup(String text, Image icon, int sortValue) { this.text = text; this.icon = icon; diff --git a/client/src/main/java/com/aapeli/colorgui/ColorListNode.java b/client/src/main/java/com/aapeli/colorgui/ColorListNode.java index bfcc1a95..7baf2b45 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorListNode.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorListNode.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.StringDraw; - import java.awt.Color; import java.awt.Font; import java.awt.Graphics; @@ -23,11 +22,17 @@ class ColorListNode { private Image icon; private boolean hasIcon; - - /** - * Node for items (e.g. players) - */ - protected ColorListNode(int x, int y, int width, int height, int iconWidth, boolean hasBackgroundImage, Font font, Font fontBold, ColorListItem item) { + /** Node for items (e.g. players) */ + protected ColorListNode( + int x, + int y, + int width, + int height, + int iconWidth, + boolean hasBackgroundImage, + Font font, + Font fontBold, + ColorListItem item) { this.x = x; this.y = y; this.width = width; @@ -40,10 +45,18 @@ protected ColorListNode(int x, int y, int width, int height, int iconWidth, bool this.hasIcon = false; } - /** - * Node for groups (e.g. languages) - */ - protected ColorListNode(int x, int y, int width, int height, int iconWidth, boolean hasBackgroundImage, Font font, Color color, String text, Image icon) { + /** Node for groups (e.g. languages) */ + protected ColorListNode( + int x, + int y, + int width, + int height, + int iconWidth, + boolean hasBackgroundImage, + Font font, + Color color, + String text, + Image icon) { this.x = x; this.y = y; this.width = width; @@ -81,7 +94,14 @@ private void drawItem(Graphics g, ColorList colorList) { color = this.getForegroundColor(color); } - this.drawText(g, colorList, this.item.getIcon(), color, this.item.isBold() ? this.fontBold : this.font, this.item.getText(), this.item.getIconAfterText()); + this.drawText( + g, + colorList, + this.item.getIcon(), + color, + this.item.isBold() ? this.fontBold : this.font, + this.item.getText(), + this.item.getIconAfterText()); } private void drawGroup(Graphics g, ColorList colorList) { @@ -93,7 +113,8 @@ private void drawGroup(Graphics g, ColorList colorList) { this.drawText(g, colorList, this.icon, this.color, this.font, this.text, null); } - private void drawText(Graphics g, ColorList colorList, Image icon, Color color, Font font, String text, Image iconAfterText) { + private void drawText( + Graphics g, ColorList colorList, Image icon, Color color, Font font, String text, Image iconAfterText) { int x = 4; if (icon != null) { g.drawImage(icon, x, this.y + this.height / 2 - icon.getHeight(colorList) / 2, colorList); @@ -108,7 +129,6 @@ private void drawText(Graphics g, ColorList colorList, Image icon, Color color, x += 4; g.drawImage(iconAfterText, x, this.y + this.height / 2 - iconAfterText.getHeight(colorList) / 2, colorList); } - } private Color getForegroundColor(Color backgroundColor) { diff --git a/client/src/main/java/com/aapeli/colorgui/ColorSpinner.java b/client/src/main/java/com/aapeli/colorgui/ColorSpinner.java index 80c81100..592b822d 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorSpinner.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorSpinner.java @@ -2,7 +2,6 @@ import com.aapeli.client.IPanel; import com.aapeli.client.StringDraw; - import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -36,7 +35,6 @@ public final class ColorSpinner extends IPanel implements MouseListener, MouseMo private int anInt3324; private Object anObject3325; - public ColorSpinner() { this.aBoolean3313 = this.aBoolean3314 = false; this.aBoolean3315 = false; @@ -73,7 +71,11 @@ public void update(Graphics var1) { this.aGraphics3320.drawLine(0, var4 - 1, var3 - 1, var4 - 1); this.aGraphics3320.setColor(this.method844(var5, var6)); double var7 = 1.0D * (double) (var3 - var4 * 2) / (double) this.items.size(); - this.aGraphics3320.drawLine((int) ((double) var4 + (double) this.anInt3311 * var7 + 0.5D), var4 - 2, (int) ((double) var4 + (double) (this.anInt3311 + 1) * var7 + 0.5D), var4 - 2); + this.aGraphics3320.drawLine( + (int) ((double) var4 + (double) this.anInt3311 * var7 + 0.5D), + var4 - 2, + (int) ((double) var4 + (double) (this.anInt3311 + 1) * var7 + 0.5D), + var4 - 2); } this.aGraphics3320.setColor(this.method842(var5, 24)); @@ -176,11 +178,9 @@ public void mouseReleased(MouseEvent var1) { this.aBoolean3314 = false; } - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} - public void mouseMoved(MouseEvent var1) { - } + public void mouseMoved(MouseEvent var1) {} public void mouseDragged(MouseEvent var1) { synchronized (this.anObject3325) { @@ -199,14 +199,13 @@ public void mouseDragged(MouseEvent var1) { this.repaint(); this.method845(); } - } } } public Object[] getSelectedObjects() { String var1 = this.getSelectedItem(); - return var1 == null ? null : new Object[]{var1}; + return var1 == null ? null : new Object[] {var1}; } public int addItem(String var1) { @@ -313,10 +312,14 @@ private void method841(Graphics var1, int var2, int var3, int var4, int var5, bo var1.fillRect(var2, var3, var4, var5); double var9 = (double) var2 + (double) var4 / 3.0D + 0.5D; double var11 = (double) var2 + (double) var4 * 2.0D / 3.0D - 0.5D; - int[] var13 = new int[]{(int) (var6 ? var11 : var9), (int) (var6 ? var11 : var9), (int) (var6 ? var9 : var11)}; - int[] var14 = new int[]{(int) ((double) var3 + (double) var5 / 3.0D), (int) ((double) var3 + (double) var5 * 2.0D / 3.0D), (int) ((double) var3 + (double) var5 / 2.0D)}; - int[] var15 = new int[]{var13[0] + (var6 ? 1 : -1), var13[1] + (var6 ? 1 : -1), var13[2] + (var6 ? -1 : 1)}; - int[] var16 = new int[]{var14[0] - 1, var14[1] + 1, var14[2]}; + int[] var13 = new int[] {(int) (var6 ? var11 : var9), (int) (var6 ? var11 : var9), (int) (var6 ? var9 : var11)}; + int[] var14 = new int[] { + (int) ((double) var3 + (double) var5 / 3.0D), + (int) ((double) var3 + (double) var5 * 2.0D / 3.0D), + (int) ((double) var3 + (double) var5 / 2.0D) + }; + int[] var15 = new int[] {var13[0] + (var6 ? 1 : -1), var13[1] + (var6 ? 1 : -1), var13[2] + (var6 ? -1 : 1)}; + int[] var16 = new int[] {var14[0] - 1, var14[1] + 1, var14[2]}; Color var17 = this.getForeground(); var1.setColor(this.method844(var8, var17)); var1.fillPolygon(var15, var16, 3); @@ -381,7 +384,6 @@ private void method845() { } else { this.aClass92_3323 = new Class92(this, this, this.anInt3324); } - } } } @@ -395,5 +397,4 @@ protected void method846() { } } } - } diff --git a/client/src/main/java/com/aapeli/colorgui/ColorText.java b/client/src/main/java/com/aapeli/colorgui/ColorText.java index dfd32ac8..9efaa79b 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorText.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorText.java @@ -9,7 +9,6 @@ class ColorText { private String text; private boolean bold; - public ColorText(Color color, String text, boolean bold) { this.created = System.currentTimeMillis(); this.color = color; diff --git a/client/src/main/java/com/aapeli/colorgui/ColorTextArea.java b/client/src/main/java/com/aapeli/colorgui/ColorTextArea.java index 3ee004e1..f26ac1a5 100644 --- a/client/src/main/java/com/aapeli/colorgui/ColorTextArea.java +++ b/client/src/main/java/com/aapeli/colorgui/ColorTextArea.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.IPanel; - import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -32,7 +31,17 @@ public class ColorTextArea extends IPanel implements ComponentListener, Adjustme public static final int BORDER_NONE = 0; public static final int BORDER_BEVELED = 1; public static final int BORDER_NONE_ROUNDCORNER = 2; - private static final Color[] colors = new Color[]{new Color(0, 0, 0), new Color(224, 0, 0), new Color(0, 160, 0), new Color(0, 0, 240), new Color(160, 128, 0), new Color(160, 0, 160), new Color(0, 144, 160), new Color(112, 112, 112), new Color(255, 255, 255)}; + private static final Color[] colors = new Color[] { + new Color(0, 0, 0), + new Color(224, 0, 0), + new Color(0, 160, 0), + new Color(0, 0, 240), + new Color(160, 128, 0), + new Color(160, 0, 160), + new Color(0, 144, 160), + new Color(112, 112, 112), + new Color(255, 255, 255) + }; private static final Color backgroundImageBorderColor = new Color(255, 255, 255); private static final Color borderLight = new Color(192, 192, 192); private static final Color borderDark = new Color(64, 64, 64); @@ -111,7 +120,17 @@ public void update(Graphics g) { } } else { this.drawBackground(this.graphics); - this.graphics.drawImage(this.backgroundImage, 0, 0, this.width, this.height, this.backgroundOffsetX, this.backgroundOffsetY, this.backgroundOffsetX + this.width, this.backgroundOffsetY + this.height, this); + this.graphics.drawImage( + this.backgroundImage, + 0, + 0, + this.width, + this.height, + this.backgroundOffsetX, + this.backgroundOffsetY, + this.backgroundOffsetX + this.width, + this.backgroundOffsetY + this.height, + this); } synchronized (this.synchronizationObject) { @@ -145,14 +164,11 @@ public void update(Graphics g) { g.drawImage(this.image, 0, 0, this); } - public void componentShown(ComponentEvent e) { - } + public void componentShown(ComponentEvent e) {} - public void componentHidden(ComponentEvent e) { - } + public void componentHidden(ComponentEvent e) {} - public void componentMoved(ComponentEvent e) { - } + public void componentMoved(ComponentEvent e) {} public void componentResized(ComponentEvent e) { Dimension size = this.getSize(); @@ -218,7 +234,14 @@ public String[] getTextWithTimestamps() { calendar.setTime(new Date(colorText.getCreated())); int hour = calendar.get(Calendar.HOUR_OF_DAY); int minute = calendar.get(Calendar.MINUTE); - textWithTimestamps[i] = "[" + (hour < 10 ? "0" : "") + hour + ":" + (minute < 10 ? "0" : "") + minute + "] " + colorText.getText(); + textWithTimestamps[i] = "[" + + (hour < 10 ? "0" : "") + + hour + + ":" + + (minute < 10 ? "0" : "") + + minute + + "] " + + colorText.getText(); } } } @@ -351,7 +374,8 @@ private void updateScrollWindow(int scrollbarPosition, boolean scrollToBottom) { this.hasScrollbar = true; } else { int currentScrollbarOffset = this.scrollbar.getValue(); - if (!scrollToBottom && currentScrollbarOffset + this.scrollWindowNumberOfLines < scrollbarPosition) { + if (!scrollToBottom + && currentScrollbarOffset + this.scrollWindowNumberOfLines < scrollbarPosition) { newScrollbarOffset = currentScrollbarOffset; } } diff --git a/client/src/main/java/com/aapeli/colorgui/MultiColorList.java b/client/src/main/java/com/aapeli/colorgui/MultiColorList.java index d7cb5cd2..a01b9900 100644 --- a/client/src/main/java/com/aapeli/colorgui/MultiColorList.java +++ b/client/src/main/java/com/aapeli/colorgui/MultiColorList.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.StringDraw; - import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; @@ -20,7 +19,7 @@ import java.util.List; public class MultiColorList extends Panel implements AdjustmentListener, MouseListener, ItemSelectable { -//todo refactor + // todo refactor public static final int SELECTABLE_NONE = 0; public static final int SELECTABLE_ONE = 1; public static final int SELECTABLE_MULTI = 2; @@ -116,7 +115,17 @@ public synchronized void update(Graphics var1) { this.aGraphics712.setColor(this.aColor691); this.aGraphics712.fillRect(0, 0, this.anInt700, this.anInt701); } else { - this.aGraphics712.drawImage(this.anImage688, 0, 0, this.anInt700, this.anInt701, this.anInt689, this.anInt690, this.anInt689 + this.anInt700, this.anInt690 + this.anInt701, this); + this.aGraphics712.drawImage( + this.anImage688, + 0, + 0, + this.anInt700, + this.anInt701, + this.anInt689, + this.anInt690, + this.anInt689 + this.anInt700, + this.anInt690 + this.anInt701, + this); } this.anIntArray704 = null; @@ -141,7 +150,13 @@ public synchronized void update(Graphics var1) { if (this.aString694 != null) { this.aGraphics712.setFont(FontConstants.font); - StringDraw.drawStringWithMaxWidth(this.aGraphics712, this.aString694, this.anInt700 / 2, this.anInt701 / 2, 0, this.anInt700 * 9 / 10); + StringDraw.drawStringWithMaxWidth( + this.aGraphics712, + this.aString694, + this.anInt700 / 2, + this.anInt701 / 2, + 0, + this.anInt700 * 9 / 10); } } else { Color[] var16 = new Color[this.anInt703 + 1]; @@ -184,7 +199,11 @@ public synchronized void update(Graphics var1) { for (int var14 = 0; var14 < this.anInt698; ++var14) { if (var9[var13][var14] != null) { - this.aGraphics712.drawImage(var9[var13][var14], 3 + this.anIntArray704[var14] + 1, var15 - var3 + (8 - var9[var13][var14].getHeight(null) / 2) + 1, this); + this.aGraphics712.drawImage( + var9[var13][var14], + 3 + this.anIntArray704[var14] + 1, + var15 - var3 + (8 - var9[var13][var14].getHeight(null) / 2) + 1, + this); } else if (var8[var13][var14] != null) { this.aGraphics712.drawString(var8[var13][var14], 3 + this.anIntArray704[var14], var15); } @@ -279,7 +298,7 @@ public synchronized void mousePressed(MouseEvent evt) { this.method962(var5, var8, var9); this.repaint(); - if(isDoubleClick && listListener != null) { + if (isDoubleClick && listListener != null) { listListener.mouseDoubleClicked(var5); } } @@ -287,17 +306,13 @@ public synchronized void mousePressed(MouseEvent evt) { } } - public void mouseReleased(MouseEvent var1) { - } + public void mouseReleased(MouseEvent var1) {} - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} - public void mouseEntered(MouseEvent var1) { - } + public void mouseEntered(MouseEvent var1) {} - public void mouseExited(MouseEvent var1) { - } + public void mouseExited(MouseEvent var1) {} public void adjustmentValueChanged(AdjustmentEvent var1) { this.repaint(); @@ -322,7 +337,6 @@ public void setSelectable(int var1) { } else if (var1 == 1 && this.getSelectedItemCount() > 1) { this.unselectAll(); } - } public void setBackgroundImage(Image var1, int var2, int var3) { @@ -379,7 +393,8 @@ public synchronized void addItem(MultiColorListItem var1) { if (this.anInt698 == 0) { this.anInt698 = var2; } else if (var2 != this.anInt698) { - System.out.println("Error: MultiColorList.addItem(...): ccount = " + var2 + " != " + this.anInt698 + " = noc"); + System.out.println( + "Error: MultiColorList.addItem(...): ccount = " + var2 + " != " + this.anInt698 + " = noc"); return; } @@ -440,7 +455,6 @@ public synchronized void removeItem(MultiColorListItem var1) { this.method955(var3); this.repaint(); } - } public synchronized void removeAllItems() { @@ -499,7 +513,7 @@ public synchronized void reSort() { } public int[] getLastClickedMouseXY() { - int[] var1 = new int[]{this.anInt707, this.anInt708}; + int[] var1 = new int[] {this.anInt707, this.anInt708}; return var1; } @@ -513,7 +527,6 @@ public void setSortOrder(int var1, int var2) { if (var2 == this.anInt699) { this.reSort(); } - } private synchronized void method955(int var1) { @@ -714,7 +727,7 @@ private synchronized void method961(boolean var1) { private synchronized void method962(MultiColorListItem var1, int var2, int var3) { if (this.listeners.size() != 0) { ItemEvent var4 = new ItemEvent(this, var2, var1, var3); - for (ItemListener listener: this.listeners) { + for (ItemListener listener : this.listeners) { listener.itemStateChanged(var4); } } diff --git a/client/src/main/java/com/aapeli/colorgui/MultiColorListItem.java b/client/src/main/java/com/aapeli/colorgui/MultiColorListItem.java index 2f43249a..3290ff00 100644 --- a/client/src/main/java/com/aapeli/colorgui/MultiColorListItem.java +++ b/client/src/main/java/com/aapeli/colorgui/MultiColorListItem.java @@ -15,9 +15,9 @@ public class MultiColorListItem { public static final int COLOR_GRAY = 7; public static final int COLOR_WHITE = 8; private static final Color[] colours = new Color[] { - new Color(0, 0, 0), new Color(240, 0, 0), new Color(0, 160, 0), - new Color(0, 0, 255), new Color(144, 144, 0), new Color(176, 0, 176), - new Color(0, 160, 176), new Color(112, 112, 112), new Color(255, 255, 255) + new Color(0, 0, 0), new Color(240, 0, 0), new Color(0, 160, 0), + new Color(0, 0, 255), new Color(144, 144, 0), new Color(176, 0, 176), + new Color(0, 160, 176), new Color(112, 112, 112), new Color(255, 255, 255) }; private Color colour; @@ -28,7 +28,6 @@ public class MultiColorListItem { private Object data; private boolean selected; - public MultiColorListItem(String[] strings) { this(colours[0], false, strings, null, false); } diff --git a/client/src/main/java/com/aapeli/colorgui/RadioButton.java b/client/src/main/java/com/aapeli/colorgui/RadioButton.java index 4643334f..39769c1a 100644 --- a/client/src/main/java/com/aapeli/colorgui/RadioButton.java +++ b/client/src/main/java/com/aapeli/colorgui/RadioButton.java @@ -11,7 +11,6 @@ public class RadioButton extends ColorButton { private boolean aBoolean4724; private boolean aBoolean4725; - public RadioButton() { this(null, null); } @@ -50,11 +49,9 @@ public void mousePressed(MouseEvent var1) { if (this.setState(!this.aBoolean4723)) { this.processActionEvent(); } - } - public void mouseReleased(MouseEvent var1) { - } + public void mouseReleased(MouseEvent var1) {} public boolean setState(boolean var1) { if (this.aBoolean4723 == var1) { @@ -130,7 +127,6 @@ public void drawBorder(Graphics var1, int var2, int var3) { var1.drawLine(0, 1, 0, var3 - 1); var1.drawLine(var2 - 1, 1, var2 - 1, var3 - 1); } - } } } diff --git a/client/src/main/java/com/aapeli/colorgui/RadioButtonGroup.java b/client/src/main/java/com/aapeli/colorgui/RadioButtonGroup.java index 2867fbf9..7c0bdbc7 100644 --- a/client/src/main/java/com/aapeli/colorgui/RadioButtonGroup.java +++ b/client/src/main/java/com/aapeli/colorgui/RadioButtonGroup.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.IPanel; - import java.util.ArrayList; import java.util.List; @@ -10,7 +9,6 @@ public final class RadioButtonGroup { private List buttons; private boolean aBoolean1590; - public RadioButtonGroup() { this(false); } @@ -42,7 +40,7 @@ protected boolean method1758(boolean var1) { } private void method1759() { - for (IPanel var2: this.buttons) { + for (IPanel var2 : this.buttons) { if (var2 instanceof RadioButton) { ((RadioButton) var2).realSetState(false); } else { diff --git a/client/src/main/java/com/aapeli/colorgui/RoundButton.java b/client/src/main/java/com/aapeli/colorgui/RoundButton.java index 33b594cd..55122674 100644 --- a/client/src/main/java/com/aapeli/colorgui/RoundButton.java +++ b/client/src/main/java/com/aapeli/colorgui/RoundButton.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.IPanel; - import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -42,7 +41,6 @@ public class RoundButton extends IPanel implements MouseMotionListener, MouseLis private boolean aBoolean3401; private static final String aString3402 = "Dialog"; - public RoundButton() { this(null, null, null); } @@ -104,7 +102,8 @@ public void update(Graphics var1) { } if (this.aString3387 != null) { - this.aGraphics3397.setColor(var5 ? this.aColor3384 : this.method873(this.aColor3384, this.aColor3383, 0.25D)); + this.aGraphics3397.setColor( + var5 ? this.aColor3384 : this.method873(this.aColor3384, this.aColor3383, 0.25D)); Font var11 = this.method875(this.aFont3388, this.aString3387, var3 - 2); Font var7 = null; int var8 = var4 / 2 + var11.getSize() * 3 / 8 + 1; @@ -117,10 +116,18 @@ public void update(Graphics var1) { } this.aGraphics3397.setFont(var11); - this.drawText(this.aGraphics3397, this.aString3387, var3 / 2 - this.getFontMetrics(var11).stringWidth(this.aString3387) / 2, var8); + this.drawText( + this.aGraphics3397, + this.aString3387, + var3 / 2 - this.getFontMetrics(var11).stringWidth(this.aString3387) / 2, + var8); if (this.aString3389 != null) { this.aGraphics3397.setFont(var7); - this.drawText(this.aGraphics3397, this.aString3389, var3 / 2 - this.getFontMetrics(var7).stringWidth(this.aString3389) / 2, var9); + this.drawText( + this.aGraphics3397, + this.aString3389, + var3 / 2 - this.getFontMetrics(var7).stringWidth(this.aString3389) / 2, + var9); } } @@ -149,17 +156,13 @@ public void mouseReleased(MouseEvent var1) { if (var2) { this.processActionEvent(); } - } - public void mouseClicked(MouseEvent var1) { - } + public void mouseClicked(MouseEvent var1) {} - public void mouseMoved(MouseEvent var1) { - } + public void mouseMoved(MouseEvent var1) {} - public void mouseDragged(MouseEvent var1) { - } + public void mouseDragged(MouseEvent var1) {} public void setBackground(Color var1) { if (var1 == null) { @@ -213,7 +216,11 @@ public void setBorderColor(Color var1) { } public Dimension getPreferredSize() { - return this.anImage3391 == null ? new Dimension(13 + this.getFontMetrics(this.aFont3388).stringWidth(this.aString3387) + 13, 5 + this.aFont3388.getSize() + 5) : new Dimension(this.anImage3391.getWidth(null), this.anImage3391.getHeight(null)); + return this.anImage3391 == null + ? new Dimension( + 13 + this.getFontMetrics(this.aFont3388).stringWidth(this.aString3387) + 13, + 5 + this.aFont3388.getSize() + 5) + : new Dimension(this.anImage3391.getWidth(null), this.anImage3391.getHeight(null)); } public void addActionListener(ActionListener var1) { @@ -253,7 +260,6 @@ public void setFlashing(boolean var1) { this.aBoolean3401 = false; this.repaint(); } - } public void processActionEvent() { @@ -329,7 +335,6 @@ private void method871(Graphics var1, Color var2, int var3, int var4, boolean va } } } - } private Color method872(Color var1, int var2, int var3) { @@ -422,5 +427,4 @@ public void innerSetFlashState(boolean var1) { this.aBoolean3401 = var1; this.repaint(); } - } diff --git a/client/src/main/java/com/aapeli/colorgui/RoundRadioButton.java b/client/src/main/java/com/aapeli/colorgui/RoundRadioButton.java index a30ad624..bbb7dfa4 100644 --- a/client/src/main/java/com/aapeli/colorgui/RoundRadioButton.java +++ b/client/src/main/java/com/aapeli/colorgui/RoundRadioButton.java @@ -9,7 +9,6 @@ public class RoundRadioButton extends RoundButton { private boolean aBoolean4734; private boolean aBoolean4735; - public RoundRadioButton() { this(null, null); } @@ -37,11 +36,9 @@ public void mousePressed(MouseEvent var1) { if (this.setState(!this.aBoolean4733)) { this.processActionEvent(); } - } - public void mouseReleased(MouseEvent var1) { - } + public void mouseReleased(MouseEvent var1) {} public boolean setState(boolean var1) { if (this.aBoolean4733 == var1) { diff --git a/client/src/main/java/com/aapeli/colorgui/TabBar.java b/client/src/main/java/com/aapeli/colorgui/TabBar.java index 30c26a41..cf9143eb 100644 --- a/client/src/main/java/com/aapeli/colorgui/TabBar.java +++ b/client/src/main/java/com/aapeli/colorgui/TabBar.java @@ -1,7 +1,6 @@ package com.aapeli.colorgui; import com.aapeli.client.IPanel; - import java.awt.Color; import java.awt.Component; import java.awt.Dimension; @@ -41,7 +40,6 @@ public class TabBar extends IPanel implements ComponentListener, ActionListener private List listeners; private Object anObject3425 = new Object(); - public TabBar(int var1, int var2) { this.anInt3408 = var1; this.anInt3409 = var2; @@ -77,7 +75,17 @@ public void update(Graphics var1) { } else if (this.anInt3416 == 0 && this.anInt3417 == 0) { var1.drawImage(this.anImage3415, 0, 0, this); } else { - var1.drawImage(this.anImage3415, 0, 0, this.anInt3408, this.anInt3409, this.anInt3416, this.anInt3417, this.anInt3416 + this.anInt3408, this.anInt3417 + this.anInt3409, this); + var1.drawImage( + this.anImage3415, + 0, + 0, + this.anInt3408, + this.anInt3409, + this.anInt3416, + this.anInt3417, + this.anInt3416 + this.anInt3408, + this.anInt3417 + this.anInt3409, + this); } if (this.anInt3422 != 0) { @@ -89,17 +97,13 @@ public void update(Graphics var1) { var1.drawRect(0, this.anInt3423 - 1, this.anInt3408 - 1, this.anInt3409 - this.anInt3423); } } - } - public void componentShown(ComponentEvent var1) { - } + public void componentShown(ComponentEvent var1) {} - public void componentHidden(ComponentEvent var1) { - } + public void componentHidden(ComponentEvent var1) {} - public void componentMoved(ComponentEvent var1) { - } + public void componentMoved(ComponentEvent var1) {} public void componentResized(ComponentEvent var1) { Dimension var2 = this.getSize(); @@ -145,7 +149,6 @@ public void setButtonFont(Font var1) { for (int var3 = 0; var3 < this.anInt3420; ++var3) { this.method880(var3).setFont(var1); } - } } @@ -157,7 +160,6 @@ public void setButtonBackground(Color var1) { for (int var3 = 0; var3 < this.anInt3420; ++var3) { this.method880(var3).setBackground(var1); } - } } @@ -169,7 +171,6 @@ public void setButtonForeground(Color var1) { for (int var3 = 0; var3 < this.anInt3420; ++var3) { this.method880(var3).setForeground(var1); } - } } @@ -187,7 +188,6 @@ public void setBorder(int var1) { for (int var3 = 0; var3 < this.anInt3420; ++var3) { this.method880(var3).setBorder(var1); } - } } @@ -361,7 +361,6 @@ private void method877() { var9.setSize(this.anInt3408 - var6 - var6, this.anInt3409 - this.anInt3423 - var6); } } - } private int method878(ActionEvent var1) { @@ -390,5 +389,4 @@ private void method879(int var1) { private RadioButton method880(int var1) { return this.getTabBarItemByIndex(var1).getButton(); } - } diff --git a/client/src/main/java/com/aapeli/colorgui/TabBarItem.java b/client/src/main/java/com/aapeli/colorgui/TabBarItem.java index 019a3ae2..cbb47f10 100644 --- a/client/src/main/java/com/aapeli/colorgui/TabBarItem.java +++ b/client/src/main/java/com/aapeli/colorgui/TabBarItem.java @@ -10,7 +10,6 @@ public final class TabBarItem { private int anInt1593; private boolean aBoolean1594; - public TabBarItem(TabBar var1, String var2, Component var3) { this(var1, null, var2, var3); } diff --git a/client/src/main/java/com/aapeli/colorgui/TabBarListener.java b/client/src/main/java/com/aapeli/colorgui/TabBarListener.java index 3bc96822..f5ca70ce 100644 --- a/client/src/main/java/com/aapeli/colorgui/TabBarListener.java +++ b/client/src/main/java/com/aapeli/colorgui/TabBarListener.java @@ -1,6 +1,5 @@ package com.aapeli.colorgui; - public interface TabBarListener { void selectedTabChanged(int var1); diff --git a/client/src/main/java/com/aapeli/connection/ConnCipher.java b/client/src/main/java/com/aapeli/connection/ConnCipher.java index db3fb7ab..fc4ccb33 100644 --- a/client/src/main/java/com/aapeli/connection/ConnCipher.java +++ b/client/src/main/java/com/aapeli/connection/ConnCipher.java @@ -7,9 +7,8 @@ public class ConnCipher { private int[][] randomsAscii; private int[][] randomsOther; - public ConnCipher(int magic) { - this.magic = magic;// :-) + this.magic = magic; // :-) this.seed = -1; this.randomsAscii = new int[2][125]; this.randomsOther = new int[2][1920]; @@ -35,9 +34,9 @@ public void initialise(int newSeed) { ConnRandom random = new ConnRandom(newSeed); int rand; - for (int index = 1; index <= 125;) { + for (int index = 1; index <= 125; ) { rand = random.nextInt(1, 125); - while(this.randomsAscii[1][rand - 1] >= 0) { + while (this.randomsAscii[1][rand - 1] >= 0) { rand = random.nextInt(1, 125); } this.randomsAscii[0][index - 1] = rand; @@ -45,16 +44,15 @@ public void initialise(int newSeed) { index++; } - for (int index = 128; index <= 2047;) { + for (int index = 128; index <= 2047; ) { rand = random.nextInt(128, 2047); - while(this.randomsOther[1][rand - 128] >= 0) { + while (this.randomsOther[1][rand - 128] >= 0) { rand = random.nextInt(128, 2047); } this.randomsOther[0][index - 128] = rand; this.randomsOther[1][rand - 128] = index; index++; } - } protected void reset() { @@ -70,27 +68,27 @@ public String encrypt(String input) { StringBuilder output = new StringBuilder(inputLength + 2); int firstRandom = (int) (1.0D + Math.random() * 125.0D); int lastRandom = (int) (1.0D + Math.random() * 125.0D); - int randMod = magicMod(firstRandom, 1, inputLength + 1);// kek + int randMod = magicMod(firstRandom, 1, inputLength + 1); // kek output.append((char) this.increment(firstRandom)); - int seedling = this.seed % 99 - 49 + firstRandom - lastRandom;// lolol + int seedling = this.seed % 99 - 49 + firstRandom - lastRandom; // lolol for (int index = 0; index < inputLength; ++index) { if (randMod == index + 1) { output.append((char) this.increment(lastRandom)); } int curChar = inputChars[index]; - if (curChar >= 1 && curChar <= 127) {// ascii + if (curChar >= 1 && curChar <= 127) { // ascii if (curChar != '\n' && curChar != '\r') { curChar = this.decrement(curChar); curChar = magicMod(curChar, seedling, 1, 125); ++seedling; curChar = this.randomsAscii[0][curChar - 1]; curChar = this.increment(curChar); - if (curChar >= 14 && curChar <= 127) {// '\r' + 1 + if (curChar >= 14 && curChar <= 127) { // '\r' + 1 curChar = magicMod(curChar, this.magic - 9, 14, 127); } } - } else if (curChar >= 128 && curChar <= 2047) {// other + } else if (curChar >= 128 && curChar <= 2047) { // other curChar = magicMod(curChar, seedling, 128, 2047); seedling += 2; curChar = this.randomsOther[0][curChar - 128]; @@ -127,9 +125,9 @@ public String decrypt(String input) { } int curChar = inputChars[index]; - if (curChar >= 1 && curChar <= 127) {// ascii + if (curChar >= 1 && curChar <= 127) { // ascii if (curChar != '\n' && curChar != '\r') { - if (curChar >= 14 && curChar <= 127) {// '\r' + 1 + if (curChar >= 14 && curChar <= 127) { // '\r' + 1 curChar = magicMod(curChar, 9 - this.magic, 14, 127); } @@ -139,7 +137,7 @@ public String decrypt(String input) { --seedling; curChar = this.increment(curChar); } - } else if (curChar >= 128 && curChar <= 2047) {// other + } else if (curChar >= 128 && curChar <= 2047) { // other curChar = this.randomsOther[1][curChar - 128]; curChar = magicMod(curChar, seedling, 128, 2047); seedling -= 2; @@ -181,10 +179,10 @@ private static int magicMod(int val1, int val2, int min, int max) { } /* - >>> [ f(i, 1, len("HURR") + 1) for i in range(-5, 6) ] - [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5] - */ - private static int magicMod(int val, int min, int max) {// ( °͜ʖ °) + >>> [ f(i, 1, len("HURR") + 1) for i in range(-5, 6) ] + [5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5] + */ + private static int magicMod(int val, int min, int max) { // ( °͜ʖ °) max -= min; val -= min; int modulus = max + 1; diff --git a/client/src/main/java/com/aapeli/connection/ConnRandom.java b/client/src/main/java/com/aapeli/connection/ConnRandom.java index 324b34ff..1442003e 100644 --- a/client/src/main/java/com/aapeli/connection/ConnRandom.java +++ b/client/src/main/java/com/aapeli/connection/ConnRandom.java @@ -1,13 +1,12 @@ package com.aapeli.connection; - class ConnRandom { // http://www.math.utah.edu/~beebe/java/random/README // http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/Random.java - private final static long multiplier = 0x5DEECE66DL; - private final static long append = 0xBL; - private final static long mask = (1L << 48) - 1; + private static final long multiplier = 0x5DEECE66DL; + private static final long append = 0xBL; + private static final long mask = (1L << 48) - 1; private long nextseed; @@ -35,6 +34,6 @@ private int nextInt() { // http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/Random.java#Random.next%28int%29 private int next() { this.nextseed = this.nextseed * multiplier + append & mask; - return (int) (this.nextseed >>> 16);// next seed for 32 bits + return (int) (this.nextseed >>> 16); // next seed for 32 bits } } diff --git a/client/src/main/java/com/aapeli/connection/GameCipher.java b/client/src/main/java/com/aapeli/connection/GameCipher.java index c7ef6f4e..16f61268 100644 --- a/client/src/main/java/com/aapeli/connection/GameCipher.java +++ b/client/src/main/java/com/aapeli/connection/GameCipher.java @@ -1,11 +1,9 @@ package com.aapeli.connection; - public class GameCipher { private String[] cmds; - public GameCipher(String[] cmds) { this.cmds = this.sortCmds(cmds); } @@ -25,7 +23,7 @@ protected int getConnCipherMagic() { return cmdsLengthMod; } - public String encrypt(String input) {// encrypt values found in this.cmds + public String encrypt(String input) { // encrypt values found in this.cmds char flagChar = this.findUnusedFlagChar(input); if (flagChar == 0) { return " " + input; @@ -37,7 +35,10 @@ public String encrypt(String input) {// encrypt values found in this.cmds while ((lastIndex = input.indexOf(this.cmds[cmdIndex], lastIndex)) >= 0) { if (!this.containsChar(input, lastIndex, flagChar)) { - input = input.substring(0, lastIndex) + flagChar + (char) (' ' + cmdIndex) + input.substring(lastIndex + this.cmds[cmdIndex].length()); + input = input.substring(0, lastIndex) + + flagChar + + (char) (' ' + cmdIndex) + + input.substring(lastIndex + this.cmds[cmdIndex].length()); lastIndex += 2; } else { ++lastIndex; @@ -58,7 +59,9 @@ public String decrypt(String input) { } else { int charIndex; while ((charIndex = input.indexOf(firstChar)) >= 0) { - input = input.substring(0, charIndex) + this.cmds[input.charAt(charIndex + 1) - 32] + input.substring(charIndex + 2); + input = input.substring(0, charIndex) + + this.cmds[input.charAt(charIndex + 1) - 32] + + input.substring(charIndex + 2); } return input; @@ -109,7 +112,7 @@ private char findUnusedFlagChar(String input) { } private boolean containsChar(String input, int pos, char c) { - //return pos == 0 ? false : input.charAt(pos - 1) == c; + // return pos == 0 ? false : input.charAt(pos - 1) == c; return pos != 0 && input.charAt(pos - 1) == c; } } diff --git a/client/src/main/java/com/aapeli/connection/GamePacketQueue.java b/client/src/main/java/com/aapeli/connection/GamePacketQueue.java index 3d2fb723..9e17b8bf 100644 --- a/client/src/main/java/com/aapeli/connection/GamePacketQueue.java +++ b/client/src/main/java/com/aapeli/connection/GamePacketQueue.java @@ -12,7 +12,6 @@ class GamePacketQueue implements Runnable { private boolean running; private Thread thread; - protected GamePacketQueue(SocketConnection socketConnection, SocketConnectionListener socketConnectionListener) { this.socketConnection = socketConnection; this.socketConnectionListener = socketConnectionListener; diff --git a/client/src/main/java/com/aapeli/connection/GameQueue.java b/client/src/main/java/com/aapeli/connection/GameQueue.java index 914d68f9..33cbbc68 100644 --- a/client/src/main/java/com/aapeli/connection/GameQueue.java +++ b/client/src/main/java/com/aapeli/connection/GameQueue.java @@ -10,7 +10,6 @@ class GameQueue { private ConnCipher connCipher = new ConnCipher((int) (Math.random() * 19.0D)); protected long sendSeqNum; - protected GameQueue() { this.connCipher.initialise(ConnCipher.getRandomSeed()); this.sendSeqNum = 0L; diff --git a/client/src/main/java/com/aapeli/connection/SocketConnection.java b/client/src/main/java/com/aapeli/connection/SocketConnection.java index 8e1a7b3a..23fc6235 100644 --- a/client/src/main/java/com/aapeli/connection/SocketConnection.java +++ b/client/src/main/java/com/aapeli/connection/SocketConnection.java @@ -2,8 +2,6 @@ import com.aapeli.applet.AApplet; import com.aapeli.client.Parameters; -import org.moparforia.client.Launcher; - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; @@ -15,6 +13,7 @@ import java.net.Socket; import java.util.ArrayList; import java.util.List; +import org.moparforia.client.Launcher; public final class SocketConnection implements Runnable { @@ -35,7 +34,7 @@ public final class SocketConnection implements Runnable { /* Other Constants */ public static final int CIPHER_MAGIC_DEFAULT = 4; - + private AApplet gameApplet; private Parameters params; private SocketConnectionListener socketConnectionListener; @@ -57,16 +56,21 @@ public final class SocketConnection implements Runnable { private ConnCipher connCipher; private Thread thread; - - public SocketConnection(AApplet gameApplet, SocketConnectionListener socketConnectionListener, String[] gameCipherCmds) { + public SocketConnection( + AApplet gameApplet, SocketConnectionListener socketConnectionListener, String[] gameCipherCmds) { this(gameApplet, gameApplet.param, socketConnectionListener, gameCipherCmds); } - public SocketConnection(Parameters params, SocketConnectionListener socketConnectionListener, String[] gameCipherCmds) { + public SocketConnection( + Parameters params, SocketConnectionListener socketConnectionListener, String[] gameCipherCmds) { this(null, params, socketConnectionListener, gameCipherCmds); } - private SocketConnection(AApplet gameApplet, Parameters params, SocketConnectionListener socketConnectionListener, String[] gameCipherCmds) { + private SocketConnection( + AApplet gameApplet, + Parameters params, + SocketConnectionListener socketConnectionListener, + String[] gameCipherCmds) { this.gameApplet = gameApplet; this.params = params; this.socketConnectionListener = socketConnectionListener; @@ -75,8 +79,7 @@ private SocketConnection(AApplet gameApplet, Parameters params, SocketConnection } int connCipherMagic = CIPHER_MAGIC_DEFAULT; - if(Launcher.isUsingCustomServer()) - gameCipherCmds = null; + if (Launcher.isUsingCustomServer()) gameCipherCmds = null; if (gameCipherCmds != null) { this.gameCipher = new GameCipher(gameCipherCmds); connCipherMagic = this.gameCipher.getConnCipherMagic(); @@ -149,8 +152,7 @@ public void writeData(String data) { if (this.state == STATE_OPENING) { throw new IllegalStateException("Connection not yet open"); } else if (this.state != STATE_DISCONNECTED) { - if(Launcher.debug()) - System.out.println("CLIENT> WRITE \"d " + gameQueue.sendSeqNum + " " + data + "\""); + if (Launcher.debug()) System.out.println("CLIENT> WRITE \"d " + gameQueue.sendSeqNum + " " + data + "\""); if (this.gameCipher != null) { data = this.gameCipher.encrypt(data); } @@ -218,7 +220,6 @@ private void handleGame() { if (this.state == STATE_CONNECTED) { this.handleConnection(); } - } private void handleConnection() { @@ -226,7 +227,6 @@ private void handleConnection() { if (this.state == STATE_CONNECTED) { this.checkConnActivity(); } - } private void handleGameQueue() { @@ -234,7 +234,6 @@ private void handleGameQueue() { if (this.state == STATE_CONNECTED) { this.processMetadataLogs(); } - } private void processGameQueueDisconnect() { @@ -248,7 +247,6 @@ private void processGameQueueDisconnect() { this.disconnect(); } } while (this.state == STATE_CONNECTED); - } private void processMetadataLogs() { @@ -291,7 +289,6 @@ private void disconnect() { this.state = STATE_DISCONNECTED; this.disconnectReason = DISCONNECT_REASON_NORETRY; } - } private boolean writeLineC(String cmd) { // C: Command @@ -308,10 +305,8 @@ private boolean writeLineS(String str) { // S: String private boolean writeLine(String line) { try { - if(!line.startsWith("d ") && Launcher.debug()) - System.out.println("CLIENT> WRITE \"" + line + "\""); - if(!Launcher.isUsingCustomServer()) - line = this.connCipher.encrypt(line); + if (!line.startsWith("d ") && Launcher.debug()) System.out.println("CLIENT> WRITE \"" + line + "\""); + if (!Launcher.isUsingCustomServer()) line = this.connCipher.encrypt(line); this.sockOut.write(line); this.sockOut.newLine(); this.sockOut.flush(); @@ -328,13 +323,13 @@ private void readInput() { char cmdtype = cmd.charAt(0); cmd = cmd.substring(2); int firstSpace; - if (cmdtype == 'h') {// not sure what - firstSpace = Integer.parseInt(cmd);// it's always 1... ALWAYS + if (cmdtype == 'h') { // not sure what + firstSpace = Integer.parseInt(cmd); // it's always 1... ALWAYS if (firstSpace != 1) { this.state = STATE_DISCONNECTED; this.disconnectReason = DISCONNECT_REASON_VERSION; } - } else if (cmdtype == 'c') {// connection related + } else if (cmdtype == 'c') { // connection related if (cmd.startsWith("io ")) { this.connCipher.initialise(Integer.parseInt(cmd.substring(3))); } else if (cmd.startsWith("crt ")) { @@ -361,10 +356,14 @@ private void readInput() { } else if (cmdtype == 'p') { if (cmd.startsWith("kickban ") && this.gameApplet != null) { firstSpace = Integer.parseInt(cmd.substring(8)); - this.gameApplet.setEndState(firstSpace == 1 ? AApplet.END_ERROR_KICK_NOW - : (firstSpace == 2 ? AApplet.END_ERROR_KICKBAN_NOW - : (firstSpace == 3 ? AApplet.END_ERROR_BAN_INIT - : AApplet.END_ERROR_TOOMANYIP_INIT))); + this.gameApplet.setEndState( + firstSpace == 1 + ? AApplet.END_ERROR_KICK_NOW + : (firstSpace == 2 + ? AApplet.END_ERROR_KICKBAN_NOW + : (firstSpace == 3 + ? AApplet.END_ERROR_BAN_INIT + : AApplet.END_ERROR_TOOMANYIP_INIT))); } } else if (cmdtype == 's') { if (cmd.startsWith("json ")) { @@ -384,14 +383,13 @@ private void readInput() { cmd = this.gameCipher.decrypt(cmd); } - if(Launcher.debug()) + if (Launcher.debug()) System.out.println("CLIENT> READ \"d " + numServerSentPaketz + " " + cmd + "\""); this.gamePacketQueue.addGamePacket(cmd); ++this.numReceivedGamePackets; } } } - } } @@ -399,10 +397,8 @@ private String readLine() { try { String line = this.sockIn.readLine(); if (line != null) { - if(!Launcher.isUsingCustomServer()) - line = this.connCipher.decrypt(line); - if(!line.startsWith("d ") && Launcher.debug()) - System.out.println("CLIENT> READ \"" + line + "\""); + if (!Launcher.isUsingCustomServer()) line = this.connCipher.decrypt(line); + if (!line.startsWith("d ") && Launcher.debug()) System.out.println("CLIENT> READ \"" + line + "\""); return line; } } catch (InterruptedIOException ex) { @@ -419,7 +415,6 @@ private void checkConnActivity() { if (time > this.connActivityTime + 20000L) { this.disconnect(); } - } private void reconnect() { @@ -474,6 +469,5 @@ private void close() { this.socket = null; } - } } diff --git a/client/src/main/java/com/aapeli/connection/SocketConnectionListener.java b/client/src/main/java/com/aapeli/connection/SocketConnectionListener.java index 73134f7f..ce3db2b3 100644 --- a/client/src/main/java/com/aapeli/connection/SocketConnectionListener.java +++ b/client/src/main/java/com/aapeli/connection/SocketConnectionListener.java @@ -1,6 +1,5 @@ package com.aapeli.connection; - public interface SocketConnectionListener { void dataReceived(String data); diff --git a/client/src/main/java/com/aapeli/multiuser/ChallengeFloodProtection.java b/client/src/main/java/com/aapeli/multiuser/ChallengeFloodProtection.java index a192d5db..7cf58891 100644 --- a/client/src/main/java/com/aapeli/multiuser/ChallengeFloodProtection.java +++ b/client/src/main/java/com/aapeli/multiuser/ChallengeFloodProtection.java @@ -1,14 +1,12 @@ package com.aapeli.multiuser; - public class ChallengeFloodProtection { - private static final int[] anIntArray1655 = new int[]{1500, 4750, 14500, 30000}; + private static final int[] anIntArray1655 = new int[] {1500, 4750, 14500, 30000}; private static final int anInt1656 = anIntArray1655.length; private String[] aStringArray1657; private long[] aLongArray1658; - public ChallengeFloodProtection() { this.aStringArray1657 = new String[anInt1656]; this.aLongArray1658 = new long[anInt1656]; @@ -17,7 +15,6 @@ public ChallengeFloodProtection() { this.aStringArray1657[var1] = null; this.aLongArray1658[var1] = 0L; } - } public boolean isOkToChallenge(String var1) { @@ -25,7 +22,9 @@ public boolean isOkToChallenge(String var1) { synchronized (this) { int var5; for (var5 = 0; var5 < anInt1656; ++var5) { - if (this.aStringArray1657[var5] != null && this.aStringArray1657[var5].equals(var1) && var2 < this.aLongArray1658[var5] + (long) anIntArray1655[var5]) { + if (this.aStringArray1657[var5] != null + && this.aStringArray1657[var5].equals(var1) + && var2 < this.aLongArray1658[var5] + (long) anIntArray1655[var5]) { return false; } } @@ -40,5 +39,4 @@ public boolean isOkToChallenge(String var1) { return true; } } - } diff --git a/client/src/main/java/com/aapeli/multiuser/ChatBase.java b/client/src/main/java/com/aapeli/multiuser/ChatBase.java index 6f0db97f..531bf811 100644 --- a/client/src/main/java/com/aapeli/multiuser/ChatBase.java +++ b/client/src/main/java/com/aapeli/multiuser/ChatBase.java @@ -10,7 +10,6 @@ import com.aapeli.client.UrlLabel; import com.aapeli.colorgui.ColorButton; import com.aapeli.colorgui.RoundButton; - import java.awt.Color; import java.awt.Component; import java.awt.Container; @@ -25,7 +24,8 @@ import java.util.ArrayList; import java.util.List; -public abstract class ChatBase extends IPanel implements ComponentListener, UserListHandler, ActionListener, InputTextFieldListener { +public abstract class ChatBase extends IPanel + implements ComponentListener, UserListHandler, ActionListener, InputTextFieldListener { public static final int CIDR_NONE = 0; public static final int CIDR_UNREG = 1; @@ -56,15 +56,66 @@ public abstract class ChatBase extends IPanel implements ComponentListener, User private List chatListeners; private Object synchronizedObject; - public ChatBase(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean useSmallFont, boolean var6, int width, int height) { - this(parameters, textManager, imageManager, badWordFilter, true, true, useSmallFont, var6, false, width, height); - } - - public ChatBase(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean var5, boolean var6, boolean useSmallFont, boolean var8, int width, int height) { - this(parameters, textManager, imageManager, badWordFilter, var5, var6, useSmallFont, var8, false, width, height); - } - - public ChatBase(Parameters params, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean var5, boolean var6, boolean useSmallFont, boolean var8, boolean shouldNotWriteWelcomeMessage, int width, int height) { + public ChatBase( + Parameters parameters, + TextManager textManager, + ImageManager imageManager, + BadWordFilter badWordFilter, + boolean useSmallFont, + boolean var6, + int width, + int height) { + this( + parameters, + textManager, + imageManager, + badWordFilter, + true, + true, + useSmallFont, + var6, + false, + width, + height); + } + + public ChatBase( + Parameters parameters, + TextManager textManager, + ImageManager imageManager, + BadWordFilter badWordFilter, + boolean var5, + boolean var6, + boolean useSmallFont, + boolean var8, + int width, + int height) { + this( + parameters, + textManager, + imageManager, + badWordFilter, + var5, + var6, + useSmallFont, + var8, + false, + width, + height); + } + + public ChatBase( + Parameters params, + TextManager textManager, + ImageManager imageManager, + BadWordFilter badWordFilter, + boolean var5, + boolean var6, + boolean useSmallFont, + boolean var8, + boolean shouldNotWriteWelcomeMessage, + int width, + int height) { this.param = params; this.textManager = textManager; this.imageManager = imageManager; @@ -83,18 +134,25 @@ public ChatBase(Parameters params, TextManager textManager, ImageManager imageMa public void update(Graphics g) { if (this.image != null) { - g.drawImage(this.image, 0, 0, this.width, this.height, this.anInt2351, this.anInt2352, this.anInt2351 + this.width, this.anInt2352 + this.height, this); + g.drawImage( + this.image, + 0, + 0, + this.width, + this.height, + this.anInt2351, + this.anInt2352, + this.anInt2351 + this.width, + this.anInt2352 + this.height, + this); } else { this.drawBackground(g); } - } - public void componentShown(ComponentEvent var1) { - } + public void componentShown(ComponentEvent var1) {} - public void componentHidden(ComponentEvent var1) { - } + public void componentHidden(ComponentEvent var1) {} public void componentMoved(ComponentEvent var1) { if (this.image != null) { @@ -103,7 +161,6 @@ public void componentMoved(ComponentEvent var1) { int var4 = var2.y - this.anInt2354; this.setBackgroundImage(this.image, this.anInt2351 + var3, this.anInt2352 + var4); } - } public void componentResized(ComponentEvent event) { @@ -123,7 +180,6 @@ public void adminCommand(String var1, String var2) { for (ChatListener chatListener : var3) { chatListener.localUserAdminCommand(var1, var2); } - } public void adminCommand(String var1, String var2, String var3) { @@ -132,14 +188,12 @@ public void adminCommand(String var1, String var2, String var3) { for (ChatListener chatListener : var4) { chatListener.localUserAdminCommand(var1, var2, var3); } - } public void actionPerformed(ActionEvent event) { if (event.getSource() == this.sayButton) { this.sendMessage(); } - } public void startedTyping() { @@ -154,8 +208,23 @@ public void enterPressed() { this.sendMessage(); } - public static UrlLabel setInputByCIDR(int var0, Container var1, InputTextField var2, Component var3, UrlLabel var4, TextManager var5, Parameters var6) { - return getSignupMessage(var0, var1, var2, var3, var4, var5.getShared("Chat_NoGuestChatAndRegNote"), var5.getShared("Chat_NoUnconfirmedChatNote"), var6); + public static UrlLabel setInputByCIDR( + int var0, + Container var1, + InputTextField var2, + Component var3, + UrlLabel var4, + TextManager var5, + Parameters var6) { + return getSignupMessage( + var0, + var1, + var2, + var3, + var4, + var5.getShared("Chat_NoGuestChatAndRegNote"), + var5.getShared("Chat_NoUnconfirmedChatNote"), + var6); } public void setBackground(Color var1) { @@ -178,7 +247,6 @@ public void setForeground(Color var1) { if (this.signupMessage != null) { this.signupMessage.setForeground(var1); } - } public void setBackgroundImage(Image var1, int var2, int var3) { @@ -213,7 +281,6 @@ public void clearOutput() { } else { this.gui_globaloutput.clear(); } - } } @@ -265,21 +332,18 @@ public void userSay(String var1, String var2) { if (!this.isUserIgnored(var1)) { this.chatTextArea.addSay(var1, var2); } - } public void userSay(int var1, String var2, String var3) { if (!this.isUserIgnored(var2)) { this.gui_globaloutput.method916(var1, var2, var3); } - } public void userSayPrivately(String var1, String var2) { if (!this.isUserIgnored(var1)) { this.chatTextArea.addSayPrivately(var1, this.aString2355, var2); } - } public void sheriffSay(String text) { @@ -289,7 +353,6 @@ public void sheriffSay(String text) { } else { this.gui_globaloutput.method918(text); } - } } @@ -316,7 +379,11 @@ public void serverSay(String var1) { } if (var4.length() > 1) { - if ((var12.equals("ServerSay_SheriffGaveWarning") || var12.equals("ServerSay_SheriffMutedUser") || var12.equals("ServerSay_SheriffUnMutedUser")) && var3 != null && !this.userList.isUser(var3)) { + if ((var12.equals("ServerSay_SheriffGaveWarning") + || var12.equals("ServerSay_SheriffMutedUser") + || var12.equals("ServerSay_SheriffUnMutedUser")) + && var3 != null + && !this.userList.isUser(var3)) { return; } @@ -338,7 +405,6 @@ public void serverSay(String var1) { } else { this.gui_globaloutput.method919(var1); } - } } } @@ -351,7 +417,6 @@ public void broadcastMessage(String message) { } else { this.gui_globaloutput.method921(message); } - } } @@ -463,7 +528,6 @@ protected void method889(User var1, String var2) { } else { this.gui_globaloutput.method917(var1.getLanguage(), var2); } - } } @@ -480,11 +544,18 @@ protected void method890(User var1, User var2, String var3) { this.gui_globaloutput.method917(var6, var3); } } - } } - private static UrlLabel getSignupMessage(int chatDisabledStatus, Container container, InputTextField inputTextField, Component sayButton, UrlLabel signupMessage, String registrationNeededText, String confirmationNeededText, Parameters parameters) { + private static UrlLabel getSignupMessage( + int chatDisabledStatus, + Container container, + InputTextField inputTextField, + Component sayButton, + UrlLabel signupMessage, + String registrationNeededText, + String confirmationNeededText, + Parameters parameters) { if (chatDisabledStatus == 0) { if (signupMessage != null) { signupMessage.setVisible(false); @@ -499,7 +570,11 @@ private static UrlLabel getSignupMessage(int chatDisabledStatus, Container conta Point inputFieldLocation = inputTextField.getLocation(); Point sayButtonLocation = sayButton.getLocation(); Dimension sayButtonSize = sayButton.getSize(); - signupMessage.setBounds(inputFieldLocation.x, inputFieldLocation.y, sayButtonLocation.x + sayButtonSize.width - inputFieldLocation.x, sayButtonLocation.y + sayButtonSize.height - inputFieldLocation.y); + signupMessage.setBounds( + inputFieldLocation.x, + inputFieldLocation.y, + sayButtonLocation.x + sayButtonSize.width - inputFieldLocation.x, + sayButtonLocation.y + sayButtonSize.height - inputFieldLocation.y); signupMessage.setBackground(container.getBackground()); signupMessage.setForeground(container.getForeground()); container.add(signupMessage); @@ -521,9 +596,15 @@ private static UrlLabel getSignupMessage(int chatDisabledStatus, Container conta } } - private void init(boolean var1, boolean var2, boolean useSmallFont, boolean var4, boolean shouldNotWriteWelcomeMessage) { + private void init( + boolean var1, boolean var2, boolean useSmallFont, boolean var4, boolean shouldNotWriteWelcomeMessage) { this.setLayout(null); - this.chatTextArea = new ChatTextArea(this.textManager, this.badWordFilter, 200, 100, useSmallFont ? ChatTextArea.SMALL_FONT : ChatTextArea.DEFAULT_FONT); + this.chatTextArea = new ChatTextArea( + this.textManager, + this.badWordFilter, + 200, + 100, + useSmallFont ? ChatTextArea.SMALL_FONT : ChatTextArea.DEFAULT_FONT); if (shouldDisplayChatInputHelp && !shouldNotWriteWelcomeMessage) { this.chatTextArea.addWelcomeMessage(this.textManager.getShared("Chat_Welcome")); } @@ -594,7 +675,6 @@ private void sendMessage() { this.chatTextArea.addOwnSay(this.aString2355, message); } - } } } @@ -618,6 +698,14 @@ private ChatListener[] getChatListenersCopy() { } private void paintSignupMessage() { - this.signupMessage = getSignupMessage(this.chatDisabledStatus, this, this.inputTextField, this.sayButton, this.signupMessage, this.getRegisterationNeededText(), this.getConfirmationNeededText(), this.param); + this.signupMessage = getSignupMessage( + this.chatDisabledStatus, + this, + this.inputTextField, + this.sayButton, + this.signupMessage, + this.getRegisterationNeededText(), + this.getConfirmationNeededText(), + this.param); } } diff --git a/client/src/main/java/com/aapeli/multiuser/ChatListener.java b/client/src/main/java/com/aapeli/multiuser/ChatListener.java index f7de35f6..64f25124 100644 --- a/client/src/main/java/com/aapeli/multiuser/ChatListener.java +++ b/client/src/main/java/com/aapeli/multiuser/ChatListener.java @@ -1,6 +1,5 @@ package com.aapeli.multiuser; - public interface ChatListener { void localUserSay(String var1); diff --git a/client/src/main/java/com/aapeli/multiuser/ChatLobby.java b/client/src/main/java/com/aapeli/multiuser/ChatLobby.java index 404f4c8c..704bdc3e 100644 --- a/client/src/main/java/com/aapeli/multiuser/ChatLobby.java +++ b/client/src/main/java/com/aapeli/multiuser/ChatLobby.java @@ -5,7 +5,6 @@ import com.aapeli.client.Parameters; import com.aapeli.client.TextManager; import com.aapeli.colorgui.ColorCheckbox; - import java.awt.Color; import java.awt.Image; import java.awt.Point; @@ -16,15 +15,36 @@ public class ChatLobby extends ChatBase { private ColorCheckbox noGameMessagesChatbox; private boolean shouldMuteMessagesIfUserListSet; - public ChatLobby(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, int width, int height) { + public ChatLobby( + Parameters parameters, + TextManager textManager, + ImageManager imageManager, + BadWordFilter badWordFilter, + int width, + int height) { this(parameters, textManager, imageManager, badWordFilter, false, false, width, height); } - public ChatLobby(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean useSmallFont, int width, int height) { + public ChatLobby( + Parameters parameters, + TextManager textManager, + ImageManager imageManager, + BadWordFilter badWordFilter, + boolean useSmallFont, + int width, + int height) { this(parameters, textManager, imageManager, badWordFilter, useSmallFont, false, width, height); } - public ChatLobby(Parameters parameters, TextManager textManager, ImageManager imageManager, BadWordFilter badWordFilter, boolean useSmallFont, boolean var6, int width, int height) { + public ChatLobby( + Parameters parameters, + TextManager textManager, + ImageManager imageManager, + BadWordFilter badWordFilter, + boolean useSmallFont, + boolean var6, + int width, + int height) { super(parameters, textManager, imageManager, badWordFilter, useSmallFont, var6, width, height); this.createSettingsCheckBoxes(); this.resizeLayout(); @@ -40,7 +60,6 @@ public void setBackground(Color var1) { if (this.noGameMessagesChatbox != null) { this.noGameMessagesChatbox.setBackground(var1); } - } public void setForeground(Color var1) { @@ -52,7 +71,6 @@ public void setForeground(Color var1) { if (this.noGameMessagesChatbox != null) { this.noGameMessagesChatbox.setForeground(var1); } - } public void setBackgroundImage(Image var1, int var2, int var3) { @@ -86,7 +104,10 @@ public String userJoin(String var1) { public String userJoin(String var1, boolean var2) { User var3 = this.addToUserListNew(var1, false); if (!this.noJoinAndPartMessagesCheckbox.getState()) { - this.method889(var3, super.textManager.getShared("Chat_Lobby_User" + (var2 ? "ReturnedFromGame" : "Joined"), var3.getNick())); + this.method889( + var3, + super.textManager.getShared( + "Chat_Lobby_User" + (var2 ? "ReturnedFromGame" : "Joined"), var3.getNick())); } return var3.getNick(); @@ -99,9 +120,9 @@ public void userLeft(String var1) { public void userLeft(String var1, boolean var2) { User var3 = super.userList.removeAndReturnUser(var1); if (var3 != null && !this.noJoinAndPartMessagesCheckbox.getState()) { - this.method889(var3, super.textManager.getShared("Chat_Lobby_UserLeft" + (var2 ? "ConnectionProblem" : ""), var1)); + this.method889( + var3, super.textManager.getShared("Chat_Lobby_UserLeft" + (var2 ? "ConnectionProblem" : ""), var1)); } - } public void userLeftCreatedGame(String var1, String var2) { @@ -109,7 +130,6 @@ public void userLeftCreatedGame(String var1, String var2) { if (var3 != null && !this.noGameMessagesChatbox.getState()) { this.method889(var3, super.textManager.getShared("Chat_Lobby_UserCreatedGame", var1, var2)); } - } public void userLeftJoinedGame(String var1, String var2) { @@ -117,7 +137,6 @@ public void userLeftJoinedGame(String var1, String var2) { if (var3 != null && !this.noGameMessagesChatbox.getState()) { this.method889(var3, super.textManager.getShared("Chat_Lobby_UserJoinedGame", var1, var2)); } - } public void userLeftWatchingGame(String var1, String var2) { @@ -125,7 +144,6 @@ public void userLeftWatchingGame(String var1, String var2) { if (var3 != null && !this.noGameMessagesChatbox.getState()) { this.method889(var3, super.textManager.getShared("Chat_Lobby_UserWathicngGame", var1, var2)); } - } public void usersLeftStartedGame(String var1, String var2, String var3) { @@ -141,7 +159,6 @@ public void usersLeftStartedGame(String var1, String var2, String var3) { this.method890(var4, var5, var6); } - } public void usersLeftStartedGame(String var1, String var2) { @@ -169,7 +186,8 @@ public String getSelectedNickForChallenge() { } public boolean[] getCheckBoxStates() { - boolean[] var1 = new boolean[]{this.noJoinAndPartMessagesCheckbox.getState(), this.noGameMessagesChatbox.getState()}; + boolean[] var1 = + new boolean[] {this.noJoinAndPartMessagesCheckbox.getState(), this.noGameMessagesChatbox.getState()}; return var1; } @@ -258,7 +276,8 @@ public void resizeLayout() { } private void createSettingsCheckBoxes() { - this.noJoinAndPartMessagesCheckbox = new ColorCheckbox(super.textManager.getShared("Chat_Lobby_NoJoinPartMessages")); + this.noJoinAndPartMessagesCheckbox = + new ColorCheckbox(super.textManager.getShared("Chat_Lobby_NoJoinPartMessages")); this.add(this.noJoinAndPartMessagesCheckbox); this.noGameMessagesChatbox = new ColorCheckbox(super.textManager.getShared("Chat_Lobby_NoGameMessages")); this.add(this.noGameMessagesChatbox); diff --git a/client/src/main/java/com/aapeli/multiuser/ChatTextArea.java b/client/src/main/java/com/aapeli/multiuser/ChatTextArea.java index 70573823..d4a6cb7b 100644 --- a/client/src/main/java/com/aapeli/multiuser/ChatTextArea.java +++ b/client/src/main/java/com/aapeli/multiuser/ChatTextArea.java @@ -3,7 +3,6 @@ import com.aapeli.client.BadWordFilter; import com.aapeli.client.TextManager; import com.aapeli.colorgui.ColorTextArea; - import java.awt.Font; import java.util.Hashtable; @@ -131,7 +130,10 @@ private void addMessage(int var1, String text) { private void method856(int var1, String var2, String var3, boolean var4) { var3 = this.method860(var3, var4); if (var3.length() > 4 && var3.toLowerCase().startsWith("/me ")) { - this.addText(this.method859(var2, var1), this.textManager.getShared("Chat_UserAction", var2, var3.substring(4)), var4); + this.addText( + this.method859(var2, var1), + this.textManager.getShared("Chat_UserAction", var2, var3.substring(4)), + var4); } else { this.addText(this.method859(var2, var1), this.textManager.getShared("Chat_UserSay", var2, var3), var4); } @@ -139,7 +141,8 @@ private void method856(int var1, String var2, String var3, boolean var4) { private void method857(int var1, String var2, String var3, String var4, boolean var5) { var4 = this.method860(var4, var5); - this.addText(this.method859(var2, var1), this.textManager.getShared("Chat_UserSayPrivate", var2, var3, var4), var5); + this.addText( + this.method859(var2, var1), this.textManager.getShared("Chat_UserSayPrivate", var2, var3, var4), var5); } private int method858(int var1) { @@ -163,7 +166,19 @@ private String method861(String var1) { int var4 = var2.length; for (int var5 = 0; var5 < var4; ++var5) { - if (var2[var5] < 32 || var2[var5] == 127 || var2[var5] >= 128 && var2[var5] <= 159 || var2[var5] == 8232 || var2[var5] == 8233 || var2[var5] == '\ufff9' || var2[var5] == '\ufffa' || var2[var5] == '\ufffb' || var2[var5] == 8206 || var2[var5] == 8207 || var2[var5] == 8234 || var2[var5] == 8238 || var2[var5] == '\uf0da') { + if (var2[var5] < 32 + || var2[var5] == 127 + || var2[var5] >= 128 && var2[var5] <= 159 + || var2[var5] == 8232 + || var2[var5] == 8233 + || var2[var5] == '\ufff9' + || var2[var5] == '\ufffa' + || var2[var5] == '\ufffb' + || var2[var5] == 8206 + || var2[var5] == 8207 + || var2[var5] == 8234 + || var2[var5] == 8238 + || var2[var5] == '\uf0da') { var2[var5] = 32; var3 = true; } diff --git a/client/src/main/java/com/aapeli/multiuser/ColorButton_Sub1.java b/client/src/main/java/com/aapeli/multiuser/ColorButton_Sub1.java index bda1e5dd..134f5f92 100644 --- a/client/src/main/java/com/aapeli/multiuser/ColorButton_Sub1.java +++ b/client/src/main/java/com/aapeli/multiuser/ColorButton_Sub1.java @@ -1,7 +1,6 @@ package com.aapeli.multiuser; import com.aapeli.colorgui.ColorButton; - import java.awt.Color; import java.awt.Graphics; @@ -9,7 +8,6 @@ class ColorButton_Sub1 extends ColorButton { private boolean aBoolean4726 = false; - protected ColorButton_Sub1(String var1) { super(var1); } @@ -36,7 +34,6 @@ public void drawBorder(Graphics var1, int var2, int var3) { var1.drawLine(var2 - 1, var3 - 1, 1, var3 - 1); var1.drawLine(var2 - 1, var3 - 1, var2 - 1, 1); } - } public void setPixelRoundedUpperCorners() { diff --git a/client/src/main/java/com/aapeli/multiuser/CopyChatFrame.java b/client/src/main/java/com/aapeli/multiuser/CopyChatFrame.java index a2f9be72..12607fce 100644 --- a/client/src/main/java/com/aapeli/multiuser/CopyChatFrame.java +++ b/client/src/main/java/com/aapeli/multiuser/CopyChatFrame.java @@ -1,7 +1,6 @@ package com.aapeli.multiuser; import com.aapeli.colorgui.ColorTextArea; - import java.awt.Color; import java.awt.Component; import java.awt.Dimension; @@ -18,15 +17,11 @@ class CopyChatFrame extends Frame implements ComponentListener, WindowListener { private TextArea textArea; + public void componentHidden(ComponentEvent e) {} - public void componentHidden(ComponentEvent e) { - } - - public void componentShown(ComponentEvent e) { - } + public void componentShown(ComponentEvent e) {} - public void componentMoved(ComponentEvent e) { - } + public void componentMoved(ComponentEvent e) {} public void componentResized(ComponentEvent e) { Dimension d = this.getSize(); @@ -34,27 +29,21 @@ public void componentResized(ComponentEvent e) { this.textArea.setBounds(i.left, i.top, d.width - i.left - i.right, d.height - i.top - i.bottom); } - public void windowOpened(WindowEvent e) { - } + public void windowOpened(WindowEvent e) {} - public void windowClosed(WindowEvent e) { - } + public void windowClosed(WindowEvent e) {} public void windowClosing(WindowEvent e) { this.dispose(); } - public void windowActivated(WindowEvent e) { - } + public void windowActivated(WindowEvent e) {} - public void windowDeactivated(WindowEvent e) { - } + public void windowDeactivated(WindowEvent e) {} - public void windowIconified(WindowEvent e) { - } + public void windowIconified(WindowEvent e) {} - public void windowDeiconified(WindowEvent e) { - } + public void windowDeiconified(WindowEvent e) {} protected void create(Component parent, ColorTextArea colorTextArea) { this.setTitle("Sheriff: Copy of chat"); @@ -102,5 +91,4 @@ private String getChatText(ColorTextArea colorTextArea) { return sb.toString(); } - } diff --git a/client/src/main/java/com/aapeli/multiuser/FloodProtection.java b/client/src/main/java/com/aapeli/multiuser/FloodProtection.java index e1af94eb..2b19b852 100644 --- a/client/src/main/java/com/aapeli/multiuser/FloodProtection.java +++ b/client/src/main/java/com/aapeli/multiuser/FloodProtection.java @@ -1,15 +1,13 @@ package com.aapeli.multiuser; - public class FloodProtection { - private static final int[] anIntArray1659 = new int[]{200, 1500, 4500, 10000, 18000}; + private static final int[] anIntArray1659 = new int[] {200, 1500, 4500, 10000, 18000}; private static final int anInt1660 = anIntArray1659.length; private double aDouble1661; private String[] aStringArray1662; private long[] aLongArray1663; - public FloodProtection() { this(1.0D); } @@ -23,7 +21,6 @@ public FloodProtection(double var1) { this.aStringArray1662[var3] = null; this.aLongArray1663[var3] = 0L; } - } public boolean isOkToSay(String var1) { @@ -33,7 +30,10 @@ public boolean isOkToSay(String var1) { int var7; for (var7 = 0; var7 < anInt1660; ++var7) { double var4 = (double) anIntArray1659[var7] * this.aDouble1661; - if (var1 != null && this.aStringArray1662[var7] != null && (this.aStringArray1662[var7].startsWith(var1) || var1.startsWith(this.aStringArray1662[var7]))) { + if (var1 != null + && this.aStringArray1662[var7] != null + && (this.aStringArray1662[var7].startsWith(var1) + || var1.startsWith(this.aStringArray1662[var7]))) { var4 *= 2.0D; } @@ -73,5 +73,4 @@ private String method1813(String var1) { return var4.toString(); } } - } diff --git a/client/src/main/java/com/aapeli/multiuser/GlobalTextArea.java b/client/src/main/java/com/aapeli/multiuser/GlobalTextArea.java index dc037c2e..c1bd9c65 100644 --- a/client/src/main/java/com/aapeli/multiuser/GlobalTextArea.java +++ b/client/src/main/java/com/aapeli/multiuser/GlobalTextArea.java @@ -4,7 +4,6 @@ import com.aapeli.colorgui.TabBar; import com.aapeli.colorgui.TabBarItem; import com.aapeli.colorgui.TabBarListener; - import java.awt.Color; import java.awt.Dimension; import java.awt.event.ComponentEvent; @@ -21,7 +20,6 @@ final class GlobalTextArea extends IPanel implements ComponentListener, TabBarLi private TabBar aTabBar2367; private Object anObject2368; - protected GlobalTextArea(ChatBase var1, ChatTextArea var2, int var3) { this.aChatBase2361 = var1; this.anObject2368 = new Object(); @@ -38,14 +36,11 @@ protected GlobalTextArea(ChatBase var1, ChatTextArea var2, int var3) { this.addComponentListener(this); } - public void componentShown(ComponentEvent var1) { - } + public void componentShown(ComponentEvent var1) {} - public void componentHidden(ComponentEvent var1) { - } + public void componentHidden(ComponentEvent var1) {} - public void componentMoved(ComponentEvent var1) { - } + public void componentMoved(ComponentEvent var1) {} public void componentResized(ComponentEvent var1) { Object var2 = this.anObject2368; @@ -58,7 +53,6 @@ public void componentResized(ComponentEvent var1) { } else { this.aTabBar2367.setSize(this.anInt2363, this.anInt2364); } - } } @@ -100,7 +94,6 @@ protected void method918(String var1) { for (ChatTextArea chatTextArea : var2) { chatTextArea.addSheriffSay(var1); } - } protected void method919(String var1) { @@ -109,7 +102,6 @@ protected void method919(String var1) { for (ChatTextArea chatTextArea : var2) { chatTextArea.addServerSay(var1); } - } protected void method920(String var1) { @@ -118,7 +110,6 @@ protected void method920(String var1) { for (ChatTextArea chatTextArea : var2) { chatTextArea.addLocalizedServerSay(var1); } - } protected void method921(String var1) { @@ -127,7 +118,6 @@ protected void method921(String var1) { for (ChatTextArea chatTextArea : var2) { chatTextArea.addBroadcastMessage(var1); } - } public void clear() { @@ -136,7 +126,6 @@ public void clear() { for (ChatTextArea chatTextArea : var1) { chatTextArea.clear(); } - } private ChatTextArea method922(int var1) { @@ -164,8 +153,14 @@ private ChatTextArea method922(int var1) { if (var3 != null) { return (ChatTextArea) var3.getComponent(); } else { - ChatTextArea var4 = (ChatTextArea) this.aTabBar2367.getTabBarItemByIndex(0).getComponent(); - var4 = new ChatTextArea(var4.getTextManager(), var4.getBadWordFilter(), this.anInt2363, this.anInt2364 - 15, var4.getFont()); + ChatTextArea var4 = + (ChatTextArea) this.aTabBar2367.getTabBarItemByIndex(0).getComponent(); + var4 = new ChatTextArea( + var4.getTextManager(), + var4.getBadWordFilter(), + this.anInt2363, + this.anInt2364 - 15, + var4.getFont()); var4.setLocation(0, 15); this.method923(var1, var4); return var4; @@ -175,7 +170,8 @@ private ChatTextArea method922(int var1) { private void method923(int var1, ChatTextArea var2) { var2.setBorderStyle(0); - TabBarItem var3 = new TabBarItem(this.aTabBar2367, this.aLanguages2362.getFlag(var1), this.aLanguages2362.getName(var1), var2); + TabBarItem var3 = new TabBarItem( + this.aTabBar2367, this.aLanguages2362.getFlag(var1), this.aLanguages2362.getName(var1), var2); var3.setTabID(var1); var3.setComponentAutoSize(true); this.aTabBar2367.addTab(var3); @@ -185,7 +181,7 @@ private ChatTextArea[] method924() { Object var1 = this.anObject2368; synchronized (this.anObject2368) { if (this.aTabBar2367 == null) { - return new ChatTextArea[]{this.aChatTextArea2365}; + return new ChatTextArea[] {this.aChatTextArea2365}; } else { TabBarItem[] var2 = this.aTabBar2367.getTabBarItems(); int var3 = var2.length; diff --git a/client/src/main/java/com/aapeli/multiuser/Languages.java b/client/src/main/java/com/aapeli/multiuser/Languages.java index 9a12a385..27943ca0 100644 --- a/client/src/main/java/com/aapeli/multiuser/Languages.java +++ b/client/src/main/java/com/aapeli/multiuser/Languages.java @@ -2,17 +2,72 @@ import com.aapeli.client.ImageManager; import com.aapeli.client.TextManager; - import java.awt.Image; public final class Languages { public static final int LANGUAGE_UNKNOWN = 0; public static final String[][] languageData = { - {"null", "-", }, {"bg", "null", }, {"de", "null", }, {"en", "null", }, {"es", "null", }, - {"et", "ee", }, {"fi", "null", }, {"fr", "null", }, {"hu", "null", }, {"it", "null", }, - {"lv", "null", }, {"nl", "null", }, {"no", "null", }, {"pl", "null", }, {"pt", "null", }, - {"ro", "null", }, {"ru", "null", }, {"sv", "se", }, {"tr", "null", }, {"lt", "null", }, + { + "null", "-", + }, + { + "bg", "null", + }, + { + "de", "null", + }, + { + "en", "null", + }, + { + "es", "null", + }, + { + "et", "ee", + }, + { + "fi", "null", + }, + { + "fr", "null", + }, + { + "hu", "null", + }, + { + "it", "null", + }, + { + "lv", "null", + }, + { + "nl", "null", + }, + { + "no", "null", + }, + { + "pl", "null", + }, + { + "pt", "null", + }, + { + "ro", "null", + }, + { + "ru", "null", + }, + { + "sv", "se", + }, + { + "tr", "null", + }, + { + "lt", "null", + }, }; private TextManager textManager; private ImageManager imageManager; diff --git a/client/src/main/java/com/aapeli/multiuser/NoChallCheckbox.java b/client/src/main/java/com/aapeli/multiuser/NoChallCheckbox.java index 0196621e..03031163 100644 --- a/client/src/main/java/com/aapeli/multiuser/NoChallCheckbox.java +++ b/client/src/main/java/com/aapeli/multiuser/NoChallCheckbox.java @@ -1,21 +1,19 @@ package com.aapeli.multiuser; import com.aapeli.colorgui.ColorCheckbox; - import java.awt.event.MouseEvent; public class NoChallCheckbox extends ColorCheckbox { private long[] aLongArray4727; - public NoChallCheckbox(String var1) { this(var1, false); } public NoChallCheckbox(String var1, boolean var2) { super(var1, var2); - this.aLongArray4727 = new long[]{0L, 0L, 0L, 0L}; + this.aLongArray4727 = new long[] {0L, 0L, 0L, 0L}; } public void mouseReleased(MouseEvent var1) { diff --git a/client/src/main/java/com/aapeli/multiuser/StaffActionFrame.java b/client/src/main/java/com/aapeli/multiuser/StaffActionFrame.java index f16e610c..eeb6ce3d 100644 --- a/client/src/main/java/com/aapeli/multiuser/StaffActionFrame.java +++ b/client/src/main/java/com/aapeli/multiuser/StaffActionFrame.java @@ -5,7 +5,6 @@ import com.aapeli.client.TextManager; import com.aapeli.colorgui.ColorButton; import com.aapeli.colorgui.ColorCheckbox; - import java.awt.Choice; import java.awt.Color; import java.awt.Component; @@ -29,9 +28,10 @@ class StaffActionFrame extends Frame implements WindowListener, ItemListener, Ke private static final Color colourBackground = new Color(224, 224, 224); private static final Color colourBackground2 = new Color(208, 208, 208); private static final Color colourText = new Color(0, 0, 0); - private static final String[] banPresetOptions = {"Presets...", "1 hour", "2 hours", "3 hours", "6 hours", - "12 hours", "1 day", "2 days", "4 days", "~1 week"}; - private static final int[] banPresetTimes = new int[]{0, 60, 120, 180, 360, 720, 1440, 2880, 5760, 9999}; + private static final String[] banPresetOptions = { + "Presets...", "1 hour", "2 hours", "3 hours", "6 hours", "12 hours", "1 day", "2 days", "4 days", "~1 week" + }; + private static final int[] banPresetTimes = new int[] {0, 60, 120, 180, 360, 720, 1440, 2880, 5760, 9999}; private static final int banPresetTimesCount = banPresetOptions.length; private int width; private int height; @@ -50,8 +50,8 @@ class StaffActionFrame extends Frame implements WindowListener, ItemListener, Ke private ColorButton btnAction; private ColorButton btnCancel; - - protected StaffActionFrame(TextManager textManager, UserListHandler userListHandler, int actionType, String targetNick) { + protected StaffActionFrame( + TextManager textManager, UserListHandler userListHandler, int actionType, String targetNick) { this.textManager = textManager; this.userListHandler = userListHandler; this.actionType = actionType; @@ -80,36 +80,41 @@ public void update(Graphics g) { g.setColor(colourText); if (this.actionType == 3) { - StringDraw.drawStringWithMaxWidth(g, "Mute target user so none of his messages are visible to others. Muted user is not notified about this, therefore user may think that other people still see his messages. Mute will stay until user leave this gameserver and returns.", this.insets.left + 10, 100, -1, this.width - this.insets.right - 10 - this.insets.left - 10); + StringDraw.drawStringWithMaxWidth( + g, + "Mute target user so none of his messages are visible to others. Muted user is not notified about this, therefore user may think that other people still see his messages. Mute will stay until user leave this gameserver and returns.", + this.insets.left + 10, + 100, + -1, + this.width - this.insets.right - 10 - this.insets.left - 10); } if (this.actionType == 4) { - StringDraw.drawStringWithMaxWidth(g, "(Message is displayed to all users after chat is cleared. To avoid any confusion, it's highly recommended that some message is provided.)", this.insets.left + 10, 135, -1, this.width - this.insets.right - 10 - this.insets.left - 10); + StringDraw.drawStringWithMaxWidth( + g, + "(Message is displayed to all users after chat is cleared. To avoid any confusion, it's highly recommended that some message is provided.)", + this.insets.left + 10, + 135, + -1, + this.width - this.insets.right - 10 - this.insets.left - 10); } - } - public void windowOpened(WindowEvent evt) { - } + public void windowOpened(WindowEvent evt) {} - public void windowClosed(WindowEvent evt) { - } + public void windowClosed(WindowEvent evt) {} public void windowClosing(WindowEvent evt) { this.destroy(); } - public void windowActivated(WindowEvent evt) { - } + public void windowActivated(WindowEvent evt) {} - public void windowDeactivated(WindowEvent evt) { - } + public void windowDeactivated(WindowEvent evt) {} - public void windowIconified(WindowEvent evt) { - } + public void windowIconified(WindowEvent evt) {} - public void windowDeiconified(WindowEvent evt) { - } + public void windowDeiconified(WindowEvent evt) {} public void itemStateChanged(ItemEvent evt) { Object evtSource = evt.getSource(); @@ -139,21 +144,17 @@ public void itemStateChanged(ItemEvent evt) { this.cboxBan.setState(true); } } - } public void keyPressed(KeyEvent evt) { if (evt.getSource() == this.textFieldMessage && evt.getKeyCode() == KeyEvent.VK_ENTER) { this.sendAction(); } - } - public void keyReleased(KeyEvent evt) { - } + public void keyReleased(KeyEvent evt) {} - public void keyTyped(KeyEvent evt) { - } + public void keyTyped(KeyEvent evt) {} public void actionPerformed(ActionEvent evt) { Object source = evt.getSource(); @@ -164,7 +165,6 @@ public void actionPerformed(ActionEvent evt) { if (source == this.btnCancel) { this.destroy(); } - } protected void show(Component parent, boolean isAdmin) { @@ -190,7 +190,9 @@ protected void show(Component parent, boolean isAdmin) { this.setResizable(false); Point parentLocation = parent.getLocationOnScreen(); Dimension parentSize = parent.getSize(); - this.setLocation(parentLocation.x + parentSize.width / 2 - this.width / 2, parentLocation.y + parentSize.height / 2 - this.height / 2); + this.setLocation( + parentLocation.x + parentSize.width / 2 - this.width / 2, + parentLocation.y + parentSize.height / 2 - this.height / 2); this.configureColors(this, true); this.setLayout(null); String actionLabel = null; @@ -229,7 +231,8 @@ protected void show(Component parent, boolean isAdmin) { this.choiceBanPresets.addItem(banPresetOptions[i]); } - this.choiceBanPresets.setBounds(this.width - this.insets.right - 15 - 100, this.insets.top + 10 + 25 + 20, 100, 20); + this.choiceBanPresets.setBounds( + this.width - this.insets.right - 15 - 100, this.insets.top + 10 + 25 + 20, 100, 20); this.choiceBanPresets.setBackground(Color.white); this.choiceBanPresets.setForeground(Color.black); this.choiceBanPresets.select(0); @@ -262,7 +265,8 @@ protected void show(Component parent, boolean isAdmin) { this.choiceDefaultMessages.addItem("Bad nickname"); this.choiceDefaultMessages.addItem("Sex messages"); this.choiceDefaultMessages.addItem("Cursing/Flooding"); - this.choiceDefaultMessages.setBounds(this.insets.left + 10 + 80 + 5 + 140 + 5, this.insets.top + 10 + 25 + 20 + 25 + 5, 170, 23); + this.choiceDefaultMessages.setBounds( + this.insets.left + 10 + 80 + 5 + 140 + 5, this.insets.top + 10 + 25 + 20 + 25 + 5, 170, 23); this.choiceDefaultMessages.setBackground(Color.white); this.choiceDefaultMessages.setForeground(Color.black); this.choiceDefaultMessages.select(0); @@ -325,7 +329,9 @@ private String getDefaultMessages(int messageIndex) { return this.textManager.getShared("SDM_BadNick" + (isRegistered ? "Reg" : "Worm")); } else { - return messageIndex == 2 ? this.textManager.getShared("SDM_SexMessages") : (messageIndex == 3 ? this.textManager.getShared("SDM_BadMessages") : null); + return messageIndex == 2 + ? this.textManager.getShared("SDM_SexMessages") + : (messageIndex == 3 ? this.textManager.getShared("SDM_BadMessages") : null); } } @@ -355,7 +361,8 @@ private void sendAction() { targetNick = this.textFieldNickname.getInputText(false); String message = this.textFieldMessage.getInputText(false); if (targetNick.length() > 0 && message.length() > 0) { - this.userListHandler.adminCommand("message" + (this.cboxAddIP.getState() ? "ip" : ""), targetNick, message); + this.userListHandler.adminCommand( + "message" + (this.cboxAddIP.getState() ? "ip" : ""), targetNick, message); } } else if (this.actionType == 3) { targetNick = this.textFieldNickname.getInputText(false); diff --git a/client/src/main/java/com/aapeli/multiuser/User.java b/client/src/main/java/com/aapeli/multiuser/User.java index fc97c887..d525df08 100644 --- a/client/src/main/java/com/aapeli/multiuser/User.java +++ b/client/src/main/java/com/aapeli/multiuser/User.java @@ -3,7 +3,6 @@ import com.aapeli.client.ImageManager; import com.aapeli.colorgui.ColorList; import com.aapeli.colorgui.ColorListItem; - import java.awt.Image; public final class User { @@ -24,7 +23,6 @@ public final class User { private String profilePage; public static boolean aBoolean1684; - public User(String nick, boolean isLocal, boolean isRegistered, boolean isVip, boolean isSheriff) { this(nick, isLocal, isRegistered, isVip, isSheriff, -1); } @@ -104,7 +102,6 @@ public void setAfterNickIcon(Image icon) { if (colorList != null) { colorList.repaint(); } - } public Image getAfterNickIcon() { diff --git a/client/src/main/java/com/aapeli/multiuser/UserList.java b/client/src/main/java/com/aapeli/multiuser/UserList.java index 81298c6d..f9548828 100644 --- a/client/src/main/java/com/aapeli/multiuser/UserList.java +++ b/client/src/main/java/com/aapeli/multiuser/UserList.java @@ -9,7 +9,6 @@ import com.aapeli.colorgui.ColorListItemGroup; import com.aapeli.colorgui.ColorTextArea; import com.aapeli.tools.Tools; - import java.awt.CheckboxMenuItem; import java.awt.Color; import java.awt.Dimension; @@ -91,12 +90,25 @@ public class UserList extends IPanel implements ComponentListener, ItemListener, private Languages languages; private Hashtable languageGroups; - - public UserList(UserListHandler handler, TextManager textManager, ImageManager imageManager, boolean showRankingIcons, boolean addSendPrivately, boolean addIgnoreUser) { + public UserList( + UserListHandler handler, + TextManager textManager, + ImageManager imageManager, + boolean showRankingIcons, + boolean addSendPrivately, + boolean addIgnoreUser) { this(handler, textManager, imageManager, showRankingIcons, addSendPrivately, addIgnoreUser, 100, 200); } - public UserList(UserListHandler handler, TextManager textManager, ImageManager imageManager, boolean showRankingIcons, boolean addSendPrivately, boolean addIgnoreUser, int width, int height) { + public UserList( + UserListHandler handler, + TextManager textManager, + ImageManager imageManager, + boolean showRankingIcons, + boolean addSendPrivately, + boolean addIgnoreUser, + int width, + int height) { this.userListHandler = handler; this.textManager = textManager; this.imageManager = imageManager; @@ -135,25 +147,36 @@ public void paint(Graphics g) { public void update(Graphics g) { if (this.backgroundImage != null) { - g.drawImage(this.backgroundImage, 0, 0, this.width, this.height, this.backgroundImageOffsetX, this.backgroundImageOffsetY, this.backgroundImageOffsetX + this.width, this.backgroundImageOffsetY + this.height, this); + g.drawImage( + this.backgroundImage, + 0, + 0, + this.width, + this.height, + this.backgroundImageOffsetX, + this.backgroundImageOffsetY, + this.backgroundImageOffsetX + this.width, + this.backgroundImageOffsetY + this.height, + this); } else { this.drawBackground(g); } - } - public void componentShown(ComponentEvent e) { - } + public void componentShown(ComponentEvent e) {} - public void componentHidden(ComponentEvent e) { - } + public void componentHidden(ComponentEvent e) {} public void componentMoved(ComponentEvent e) { if (this.backgroundImage != null) { Point location = this.getLocation(); int newX = location.x - this.lastX; int newY = location.y - this.lastY; - this.setBackgroundImage(this.backgroundImage, this.playersListBackgroundImage, this.backgroundImageOffsetX + newX, this.backgroundImageOffsetY + newY); + this.setBackgroundImage( + this.backgroundImage, + this.playersListBackgroundImage, + this.backgroundImageOffsetX + newX, + this.backgroundImageOffsetY + newY); } this.repaint(); @@ -171,10 +194,15 @@ public void componentResized(ComponentEvent e) { } int width = this.width; - int height = this.height - (ignoreUserCheckBoxExists ? 18 : 0) - (sendPrivatelyCheckBoxExists ? 18 : 0) - (!ignoreUserCheckBoxExists && !sendPrivatelyCheckBoxExists ? 0 : 2) - (this.rankingsShown ? 11 : 0); + int height = this.height + - (ignoreUserCheckBoxExists ? 18 : 0) + - (sendPrivatelyCheckBoxExists ? 18 : 0) + - (!ignoreUserCheckBoxExists && !sendPrivatelyCheckBoxExists ? 0 : 2) + - (this.rankingsShown ? 11 : 0); this.playersList.setBounds(0, this.rankingsShown ? 11 : 0, width, height); if (sendPrivatelyCheckBoxExists) { - this.sendPrivatelyCheckbox.setBounds(0, this.height - 18 - (ignoreUserCheckBoxExists ? 18 : 0), this.width, 18); + this.sendPrivatelyCheckbox.setBounds( + 0, this.height - 18 - (ignoreUserCheckBoxExists ? 18 : 0), this.width, 18); } if (ignoreUserCheckBoxExists) { @@ -234,13 +262,14 @@ public void itemStateChanged(ItemEvent e) { if (user.isLocal()) { this.resetCheckBoxes(); } else { - user.setGettingPrivateMessages(this.sendPrivatelyCheckbox != null ? this.sendPrivatelyCheckbox.getState() : false); - user.setIgnore(this.ignoreUserCheckbox != null ? this.ignoreUserCheckbox.getState() : false); + user.setGettingPrivateMessages( + this.sendPrivatelyCheckbox != null ? this.sendPrivatelyCheckbox.getState() : false); + user.setIgnore( + this.ignoreUserCheckbox != null ? this.ignoreUserCheckbox.getState() : false); selectedPlayer.setColor(this.getUserColor(user)); this.playersList.repaint(); } } - } } } @@ -268,12 +297,17 @@ public void actionPerformed(ActionEvent e) { this.showStaffActionFrame(1, this.selectedUser.getNick()); } else if (source == this.sheriffSendMessageMenuItem) { this.showStaffActionFrame(2, this.selectedUser.getNick()); - } else if (source != this.sheriffMute5minutesMenuItem && source != this.sheriffMute15minutesMenuItem && source != this.sheriffMute1hourMenuItem && source != this.sheriffMute6hoursMenuItem && source != this.sheriffMute1dayMenuItem) { + } else if (source != this.sheriffMute5minutesMenuItem + && source != this.sheriffMute15minutesMenuItem + && source != this.sheriffMute1hourMenuItem + && source != this.sheriffMute6hoursMenuItem + && source != this.sheriffMute1dayMenuItem) { if (source == this.clearEveryUserChatMenuItem) { this.showStaffActionFrame(4, null); } else if (source == this.sheriffCopyChatMenuItem) { CopyChatFrame copyChatFrame = new CopyChatFrame(); - copyChatFrame.create(this.imageManager.getApplet(), this.chat != null ? this.chat.chatTextArea : this.chatOutput); + copyChatFrame.create( + this.imageManager.getApplet(), this.chat != null ? this.chat.chatTextArea : this.chatOutput); } else if (source == this.adminGetUserInfoMenuItem) { this.userListHandler.adminCommand("info", this.selectedUser.getNick()); } else if (source == this.adminUnmuteUserMenuItem) { @@ -297,7 +331,6 @@ public void actionPerformed(ActionEvent e) { this.userListHandler.adminCommand("mute", this.selectedUser.getNick(), "" + muteTime); } - } public static String getNickFromUserInfo(String userData) { @@ -342,7 +375,6 @@ public void setCheckBoxesVisible(boolean checkBoxesVisible) { if (this.ignoreUserCheckbox != null) { this.ignoreUserCheckbox.setVisible(checkBoxesVisible); } - } public void setBackground(Color color) { @@ -367,14 +399,14 @@ public void setForeground(Color color) { if (this.ignoreUserCheckbox != null) { this.ignoreUserCheckbox.setForeground(color); } - } public void setBackgroundImage(Image image, int backgroundImageOffsetX, int backgroundImageOffsetY) { this.setBackgroundImage(image, null, backgroundImageOffsetX, backgroundImageOffsetY); } - public void setBackgroundImage(Image image, Image playersListBackground, int backgroundImageOffsetX, int backgroundImageOffsetY) { + public void setBackgroundImage( + Image image, Image playersListBackground, int backgroundImageOffsetX, int backgroundImageOffsetY) { this.backgroundImage = image; this.playersListBackgroundImage = playersListBackground; this.backgroundImageOffsetX = backgroundImageOffsetX; @@ -385,17 +417,20 @@ public void setBackgroundImage(Image image, Image playersListBackground, int bac Point location; if (playersListBackground != null) { location = this.playersList.getLocation(); - this.playersList.setBackgroundImage(playersListBackground, backgroundImageOffsetX + location.x, backgroundImageOffsetY + location.y); + this.playersList.setBackgroundImage( + playersListBackground, backgroundImageOffsetX + location.x, backgroundImageOffsetY + location.y); } if (this.sendPrivatelyCheckbox != null) { location = this.sendPrivatelyCheckbox.getLocation(); - this.sendPrivatelyCheckbox.setBackgroundImage(image, backgroundImageOffsetX + location.x, backgroundImageOffsetY + location.y); + this.sendPrivatelyCheckbox.setBackgroundImage( + image, backgroundImageOffsetX + location.x, backgroundImageOffsetY + location.y); } if (this.ignoreUserCheckbox != null) { location = this.ignoreUserCheckbox.getLocation(); - this.ignoreUserCheckbox.setBackgroundImage(image, backgroundImageOffsetX + location.x, backgroundImageOffsetY + location.y); + this.ignoreUserCheckbox.setBackgroundImage( + image, backgroundImageOffsetX + location.x, backgroundImageOffsetY + location.y); } this.repaint(); @@ -403,7 +438,8 @@ public void setBackgroundImage(Image image, Image playersListBackground, int bac public void setListBackgroundImage(Image image, int backgroundImageOffsetX, int backgroundImageOffsetY) { Point location = this.playersList.getLocation(); - this.playersList.setBackgroundImage(image, backgroundImageOffsetX + location.x, backgroundImageOffsetY + location.y); + this.playersList.setBackgroundImage( + image, backgroundImageOffsetX + location.x, backgroundImageOffsetY + location.y); } public User addUser(String userData, boolean isLocal) { @@ -416,7 +452,7 @@ public User addUser(String userData, boolean userIsLocal, int color) { } else { // 3:im the man111^r^111^fi_FI^-^- int colonIndex = userData.indexOf(':'); - userData = userData.substring(colonIndex + 1);// looks like the number is skipped + userData = userData.substring(colonIndex + 1); // looks like the number is skipped StringTokenizer tokenizer = new StringTokenizer(userData, "^"); String username = Tools.changeFromSaveable(tokenizer.nextToken()); String elevation = tokenizer.nextToken(); @@ -465,7 +501,8 @@ public void addUser(User user) { displayedNick = displayedNick + " " + this.textManager.getShared("UserList_Sheriff"); } - ColorListItem colorListItem = new ColorListItem(this.getRankingIcon(user), this.getUserColor(user), user.isRegistered(), displayedNick, user, false); + ColorListItem colorListItem = new ColorListItem( + this.getRankingIcon(user), this.getUserColor(user), user.isRegistered(), displayedNick, user, false); colorListItem.setValue(user.getRating()); if (user.isSheriff()) { colorListItem.setSortOverride(true); @@ -556,7 +593,6 @@ public void removeUser(String nick) { } } } - } public User removeAndReturnUser(String nick) { @@ -612,7 +648,6 @@ public void setSorting(int sorting) { this.sortByNicknameButton.setBackground(columnHeaderDefaultColor); } } - } public int getSorting() { @@ -647,7 +682,6 @@ public void usePixelRoundedButtonsAndCheckBoxes() { if (this.ignoreUserCheckbox != null) { this.ignoreUserCheckbox.setBoxPixelRoundedCorners(true); } - } private static boolean isUserDataType3(String userData) { @@ -661,19 +695,22 @@ private void showRightClickMenu(User user, int x, int y) { } this.rightClickMenu = new PopupMenu(); - this.openProfileMenuItem = this.createButtonMenuItem(this.rightClickMenu, this.textManager.getShared("UserList_OpenPlayerCard")); + this.openProfileMenuItem = + this.createButtonMenuItem(this.rightClickMenu, this.textManager.getShared("UserList_OpenPlayerCard")); this.openProfileMenuItem.setEnabled(user.isRegistered() || user.getProfilePage() != null); if (this.sendPrivatelyCheckbox != null || this.ignoreUserCheckbox != null) { this.rightClickMenu.addSeparator(); } if (this.sendPrivatelyCheckbox != null) { - this.sendPrivatelyMenuItem = this.createCheckboxMenuItem(this.rightClickMenu, this.sendPrivatelyCheckbox.getLabel(), user.isGettingPrivateMessages()); + this.sendPrivatelyMenuItem = this.createCheckboxMenuItem( + this.rightClickMenu, this.sendPrivatelyCheckbox.getLabel(), user.isGettingPrivateMessages()); this.sendPrivatelyMenuItem.setEnabled(!user.isLocal()); } if (this.ignoreUserCheckbox != null) { - this.ignoreUserMenuItem = this.createCheckboxMenuItem(this.rightClickMenu, this.ignoreUserCheckbox.getLabel(), user.isIgnore()); + this.ignoreUserMenuItem = this.createCheckboxMenuItem( + this.rightClickMenu, this.ignoreUserCheckbox.getLabel(), user.isIgnore()); this.ignoreUserMenuItem.setEnabled(!user.isLocal()); } @@ -765,7 +802,11 @@ private void init(boolean addSendPrivately, boolean addIgnoreUser) { } int width = this.width; - int height = this.height - (addIgnoreUser ? 18 : 0) - (addSendPrivately ? 18 : 0) - (!addIgnoreUser && !addSendPrivately ? 0 : 2) - (this.rankingsShown ? 11 : 0); + int height = this.height + - (addIgnoreUser ? 18 : 0) + - (addSendPrivately ? 18 : 0) + - (!addIgnoreUser && !addSendPrivately ? 0 : 2) + - (this.rankingsShown ? 11 : 0); if (this.rankingsShown) { this.playersList = new ColorList(width, height, 11, 11); } else { @@ -790,7 +831,6 @@ private void init(boolean addSendPrivately, boolean addIgnoreUser) { this.ignoreUserCheckbox.addItemListener(this); this.add(this.ignoreUserCheckbox); } - } private void resetCheckBoxes() { @@ -801,7 +841,6 @@ private void resetCheckBoxes() { if (this.ignoreUserCheckbox != null) { this.ignoreUserCheckbox.setState(false); } - } private Image getRankingIcon(User user) { @@ -842,7 +881,6 @@ private synchronized void removeUser(User user) { } else { this.ignoredUsers.remove(nick); } - } private boolean openProfilePage(User user) { diff --git a/client/src/main/java/com/aapeli/multiuser/UserListHandler.java b/client/src/main/java/com/aapeli/multiuser/UserListHandler.java index a93f2b4a..bc1a70ac 100644 --- a/client/src/main/java/com/aapeli/multiuser/UserListHandler.java +++ b/client/src/main/java/com/aapeli/multiuser/UserListHandler.java @@ -1,6 +1,5 @@ package com.aapeli.multiuser; - public interface UserListHandler { void openPlayerCard(String var1); diff --git a/client/src/main/java/com/aapeli/multiuser/UsernameValidator.java b/client/src/main/java/com/aapeli/multiuser/UsernameValidator.java index 2d3e6fdb..65f7f831 100644 --- a/client/src/main/java/com/aapeli/multiuser/UsernameValidator.java +++ b/client/src/main/java/com/aapeli/multiuser/UsernameValidator.java @@ -8,6 +8,5 @@ public class UsernameValidator { public static boolean isValidUsername(String username) { boolean invalid = INVALID_USERNAME_PATTERN.matcher(username).find(); return !invalid; - } } diff --git a/client/src/main/java/com/aapeli/tools/DelayRepaint.java b/client/src/main/java/com/aapeli/tools/DelayRepaint.java index aa6a24f1..8d9352c0 100644 --- a/client/src/main/java/com/aapeli/tools/DelayRepaint.java +++ b/client/src/main/java/com/aapeli/tools/DelayRepaint.java @@ -6,7 +6,6 @@ public class DelayRepaint implements QuickTimerListener { private Component component; - public DelayRepaint(Component cmp) { this(cmp, 500); } diff --git a/client/src/main/java/com/aapeli/tools/EncodedXmlReader.java b/client/src/main/java/com/aapeli/tools/EncodedXmlReader.java index 78c2ad6b..0e1ea53f 100644 --- a/client/src/main/java/com/aapeli/tools/EncodedXmlReader.java +++ b/client/src/main/java/com/aapeli/tools/EncodedXmlReader.java @@ -12,7 +12,6 @@ public class EncodedXmlReader { private String xmlURL; private boolean isDebug; - public EncodedXmlReader(String fileURL) { this(fileURL, false); } @@ -28,7 +27,8 @@ public XmlUnit readXmlUnit() { return XmlUnit.parseString(xmlData, true, true); } catch (Exception ex) { if (this.isDebug) { - System.out.println("EncodedXmlReader.readXmlUnit(): Failed to read or parse xml-file \"" + this.xmlURL + "\""); + System.out.println( + "EncodedXmlReader.readXmlUnit(): Failed to read or parse xml-file \"" + this.xmlURL + "\""); ex.printStackTrace(); } @@ -50,15 +50,13 @@ private String readFile() throws Exception { InputStream instream = url.openStream(); */ - InputStream instream = this.getClass().getResourceAsStream(url.getFile()); - PushbackInputStream in = new PushbackInputStream(instream, 3); int char1 = in.read(); int char2 = in.read(); int char3 = in.read(); - if (char1 == 239 && char2 == 187 && char3 == 191) {// ??? wtf //239=ï 187=» 191=¿ + if (char1 == 239 && char2 == 187 && char3 == 191) { // ??? wtf //239=ï 187=» 191=¿ encoding = "UTF-8"; } else { in.unread(char3); diff --git a/client/src/main/java/com/aapeli/tools/QuickTimer.java b/client/src/main/java/com/aapeli/tools/QuickTimer.java index c5a74da4..d4a77642 100644 --- a/client/src/main/java/com/aapeli/tools/QuickTimer.java +++ b/client/src/main/java/com/aapeli/tools/QuickTimer.java @@ -10,7 +10,6 @@ public class QuickTimer implements Runnable { private boolean stopped; private static final String aString1730 = "QuickTimer.start() called after QuickTimer.stopAll() was called"; - public QuickTimer(int var1) { this(var1, null, false); } @@ -30,7 +29,6 @@ private QuickTimer(int var1, QuickTimerListener var2, boolean var3) { if (var3) { this.start(); } - } public QuickTimer(QuickTimerListener var1, int var2) { @@ -40,12 +38,11 @@ public QuickTimer(QuickTimerListener var1, int var2) { public void run() { Tools.sleep(this.anInt1727); if (!this.stopped) { - for (QuickTimerListener var2: this.listeners) { + for (QuickTimerListener var2 : this.listeners) { if (var2 != null) { var2.qtFinished(); } } - } } @@ -74,5 +71,4 @@ public void start() { public void stopAll() { this.stopped = true; } - } diff --git a/client/src/main/java/com/aapeli/tools/QuickTimerListener.java b/client/src/main/java/com/aapeli/tools/QuickTimerListener.java index c3e8a648..fb48da29 100644 --- a/client/src/main/java/com/aapeli/tools/QuickTimerListener.java +++ b/client/src/main/java/com/aapeli/tools/QuickTimerListener.java @@ -1,6 +1,5 @@ package com.aapeli.tools; - public interface QuickTimerListener { void qtFinished(); diff --git a/client/src/main/java/com/aapeli/tools/Tools.java b/client/src/main/java/com/aapeli/tools/Tools.java index f0ee8e4b..49cfbd83 100644 --- a/client/src/main/java/com/aapeli/tools/Tools.java +++ b/client/src/main/java/com/aapeli/tools/Tools.java @@ -4,7 +4,6 @@ import java.awt.Component; import java.awt.Graphics; import java.util.Calendar; -import java.util.List; import java.util.StringTokenizer; public class Tools { @@ -12,7 +11,6 @@ public class Tools { private static long aLong1731 = -1L; private static long aLong1732 = -1L; - public static boolean sleep(long var0) { if (var0 <= 0L) { return true; @@ -72,7 +70,12 @@ public static String changeFromSaveable(String s) { sb.append('^'); } else { if (c != 'd') { - System.out.println("Program error: Tools.changeFromSaveable(\"" + s + "\"), " + "unexpected character '" + c + "' after '$'"); + System.out.println("Program error: Tools.changeFromSaveable(\"" + + s + + "\"), " + + "unexpected character '" + + c + + "' after '$'"); return null; } diff --git a/client/src/main/java/com/aapeli/tools/XmlUnit.java b/client/src/main/java/com/aapeli/tools/XmlUnit.java index 5a11efee..2f35065b 100644 --- a/client/src/main/java/com/aapeli/tools/XmlUnit.java +++ b/client/src/main/java/com/aapeli/tools/XmlUnit.java @@ -14,7 +14,6 @@ public class XmlUnit { private List children; private Hashtable attributes; - private XmlUnit(String var1) { this.name = var1; this.value = null; @@ -25,7 +24,8 @@ private XmlUnit(String var1) { public static XmlUnit parseString(String declarationTag, boolean var1, boolean var2) throws Exception { declarationTag = declarationTag.trim(); if (declarationTag.startsWith("') + 1).trim(); + declarationTag = + declarationTag.substring(declarationTag.indexOf('>') + 1).trim(); } return method1876(declarationTag, var2); @@ -192,7 +192,11 @@ private static XmlUnit method1876(String var0, boolean var1) throws Exception { } if (!tagStart.getName().equals(tagEnd.toString())) { - throw new Exception("End tag name (" + tagEnd + ") is different than start tag (" + tagStart.getName() + ")"); + throw new Exception("End tag name (" + + tagEnd + + ") is different than start tag (" + + tagStart.getName() + + ")"); } var11 = true; diff --git a/client/src/main/java/org/moparforia/client/Game.java b/client/src/main/java/org/moparforia/client/Game.java index 8ebe455f..5415fa7a 100644 --- a/client/src/main/java/org/moparforia/client/Game.java +++ b/client/src/main/java/org/moparforia/client/Game.java @@ -1,23 +1,22 @@ package org.moparforia.client; import agolf.AGolf; - -import javax.swing.JFrame; import java.applet.Applet; import java.applet.AppletContext; import java.applet.AppletStub; import java.net.URL; import java.util.HashMap; import java.util.Map; +import javax.swing.JFrame; public class Game { private static final int WIDTH = 735; private static final int HEIGHT = 525; - public Game(JFrame frame, String server, int port, String lang, String username, boolean verbose, boolean norandom) { + public Game( + JFrame frame, String server, int port, String lang, String username, boolean verbose, boolean norandom) { Applet game = new AGolf(); - game.setStub(new Stub(server, lang, username, port, verbose, norandom)); game.setSize(WIDTH, HEIGHT); game.init(); @@ -41,7 +40,9 @@ public Stub(String server, String lang, String username, int port, boolean verbo } params = new HashMap<>(); params.put("initmessage", "Loading game..."); - params.put("ld_page", "javascript:Playray.Notify.delegate({ jvm: { version: '%v', vendor: '%w', t1: '%r', t2: '%f' } })"); + params.put( + "ld_page", + "javascript:Playray.Notify.delegate({ jvm: { version: '%v', vendor: '%w', t1: '%r', t2: '%f' } })"); params.put("image", "/appletloader_playforia.gif"); /*if(serverBox.isSelected()) { params.put("server", "149.255.111.161" + ":" + g.port); @@ -51,10 +52,10 @@ public Stub(String server, String lang, String username, int port, boolean verbo params.put("server", server + ":" + port); - //params.put("locale", "en"); - //params.put("lang", en_US); + // params.put("locale", "en"); + // params.put("lang", en_US); - params.put("locale", lang.substring(0, 2)); //use first part of en_US, fi_FI or sv_SE + params.put("locale", lang.substring(0, 2)); // use first part of en_US, fi_FI or sv_SE params.put("lang", lang); params.put("sitename", "playray"); params.put("quitpage", "http://www.playforia.com/games/"); @@ -75,10 +76,10 @@ public Stub(String server, String lang, String username, int port, boolean verbo params.put("norandom", Boolean.toString(norandom)); params.put("username", username); - //if(serverBox.isSelected()) - //params.put("tracktestmode", "true"); - //params.put("session", "7vkBHjUIcQKg-J,c2bXzYdy,lJd"); - //params.put("sessionlang", "en"); + // if(serverBox.isSelected()) + // params.put("tracktestmode", "true"); + // params.put("session", "7vkBHjUIcQKg-J,c2bXzYdy,lJd"); + // params.put("sessionlang", "en"); } public boolean isActive() { @@ -99,8 +100,7 @@ public URL getCodeBase() { } public String getParameter(String name) { - if (!params.containsKey(name)) - return ""; + if (!params.containsKey(name)) return ""; return params.get(name); } @@ -108,8 +108,6 @@ public AppletContext getAppletContext() { return null; } - - public void appletResize(int width, int height) { - } + public void appletResize(int width, int height) {} } } diff --git a/client/src/main/java/org/moparforia/client/Launcher.java b/client/src/main/java/org/moparforia/client/Launcher.java index c4b20ba4..fb10b642 100644 --- a/client/src/main/java/org/moparforia/client/Launcher.java +++ b/client/src/main/java/org/moparforia/client/Launcher.java @@ -1,9 +1,11 @@ package org.moparforia.client; import com.aapeli.multiuser.UsernameValidator; -import org.moparforia.shared.ManifestVersionProvider; -import picocli.CommandLine; - +import java.awt.GridLayout; +import java.awt.Image; +import java.io.IOException; +import java.text.ParseException; +import java.util.concurrent.Callable; import javax.imageio.ImageIO; import javax.swing.JFrame; import javax.swing.JLabel; @@ -13,48 +15,51 @@ import javax.swing.JSpinner; import javax.swing.JTextField; import javax.swing.SpinnerNumberModel; -import java.awt.GridLayout; -import java.awt.Image; -import java.io.IOException; -import java.text.ParseException; -import java.util.concurrent.Callable; - +import org.moparforia.shared.ManifestVersionProvider; +import picocli.CommandLine; @CommandLine.Command( description = "Starts Minigolf Client", name = "client", mixinStandardHelpOptions = true, - versionProvider = ManifestVersionProvider.class -) + versionProvider = ManifestVersionProvider.class) public class Launcher implements Callable { public static final String DEFAULT_SERVER = "127.0.0.1"; public static final int DEFAULT_PORT = 4242; // CLI options - @CommandLine.Option(names = {"--hostname", "-ip"}, + @CommandLine.Option( + names = {"--hostname", "-ip"}, description = "Sets server hostname", defaultValue = "") private String hostname; - @CommandLine.Option(names = {"--port", "-p"}, + @CommandLine.Option( + names = {"--port", "-p"}, description = "Sets server port", defaultValue = "0") private int port; - @CommandLine.Option(names = {"--lang", "-l"}, + @CommandLine.Option( + names = {"--lang", "-l"}, description = "Sets language of the game, available values:\n ${COMPLETION-CANDIDATES}", defaultValue = "en_us") private Language lang; - @CommandLine.Option(names = {"--username", "-u"}, + @CommandLine.Option( + names = {"--username", "-u"}, description = "Sets the username to use when connecting to the server") private String username; - @CommandLine.Option(names = {"--verbose", "-v"}, description = "Set if you want verbose information") + @CommandLine.Option( + names = {"--verbose", "-v"}, + description = "Set if you want verbose information") private static boolean verbose = false; - @CommandLine.Option(names = {"--norandom", "-n"}, description = "Set if you want to disable randomization for shots") + @CommandLine.Option( + names = {"--norandom", "-n"}, + description = "Set if you want to disable randomization for shots") private static boolean norandom = false; public static boolean debug() { @@ -62,14 +67,12 @@ public static boolean debug() { } public static boolean isUsingCustomServer() { - return true;//instance.serverBox.isSelected(); + return true; // instance.serverBox.isSelected(); } public static void main(String... args) { Launcher launcher = new Launcher(); - new CommandLine(launcher) - .setCaseInsensitiveEnumValuesAllowed(true) - .execute(args); + new CommandLine(launcher).setCaseInsensitiveEnumValuesAllowed(true).execute(args); } public boolean showSettingDialog(JFrame frame, String server, int port) throws ParseException { @@ -83,8 +86,8 @@ public boolean showSettingDialog(JFrame frame, String server, int port) throws P pane.add(serverField); JSpinner portSpinner = new JSpinner(); - portSpinner.setModel(new SpinnerNumberModel(port,1, Integer.MAX_VALUE,1)); - JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner,"#"); + portSpinner.setModel(new SpinnerNumberModel(port, 1, Integer.MAX_VALUE, 1)); + JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner, "#"); // Align spinner values to the left editor.getTextField().setHorizontalAlignment(JTextField.LEFT); portSpinner.setEditor(editor); @@ -102,6 +105,7 @@ public boolean showSettingDialog(JFrame frame, String server, int port) throws P return false; } } + private String[] login(JFrame frame) { JPanel pane = new JPanel(); pane.setLayout(new GridLayout(2, 2)); @@ -119,15 +123,14 @@ private String[] login(JFrame frame) { if (option == JOptionPane.OK_OPTION) { String user = userField.getText(); String pass = new String(passField.getPassword()); - return new String[]{user, pass}; + return new String[] {user, pass}; } else { - return new String[]{null, null}; + return new String[] {null, null}; } - } @Override - public Integer call() throws Exception{ + public Integer call() throws Exception { JFrame frame = createFrame(); if (hostname.isEmpty() || port == 0) { // Determine which of these was actually false @@ -158,7 +161,14 @@ public JFrame createFrame() throws IOException { return frame; } - public Game launchGame(JFrame frame, String hostname, int port, Language lang, String username, boolean verbose, boolean norandom) { + public Game launchGame( + JFrame frame, + String hostname, + int port, + Language lang, + String username, + boolean verbose, + boolean norandom) { return new Game(frame, hostname, port, lang.toString(), username, verbose, norandom); } diff --git a/client/src/test/java/org/moparforia/client/LauncherCLITest.java b/client/src/test/java/org/moparforia/client/LauncherCLITest.java index 13434423..7215ef72 100644 --- a/client/src/test/java/org/moparforia/client/LauncherCLITest.java +++ b/client/src/test/java/org/moparforia/client/LauncherCLITest.java @@ -1,17 +1,5 @@ package org.moparforia.client; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.junit.jupiter.MockitoExtension; -import org.mockito.quality.Strictness; -import picocli.CommandLine; - -import javax.swing.JFrame; -import java.io.PrintWriter; -import java.io.StringWriter; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.mockito.Mockito.any; @@ -27,8 +15,20 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.withSettings; +import java.io.PrintWriter; +import java.io.StringWriter; +import javax.swing.JFrame; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.quality.Strictness; +import picocli.CommandLine; + /** - * Tests that CLI parsing works as expected, it doesn't test the main method, but it tests the picocli annotations + * Tests that CLI parsing works as expected, it doesn't test the main method, but it tests the + * picocli annotations */ @ExtendWith(MockitoExtension.class) class LauncherCLITest { @@ -42,9 +42,8 @@ class LauncherCLITest { @BeforeEach void setUp() throws Exception { // Mock game - launcher = mock(Launcher.class, withSettings() - .strictness(Strictness.LENIENT) - .withoutAnnotations()); + launcher = mock( + Launcher.class, withSettings().strictness(Strictness.LENIENT).withoutAnnotations()); // Use real methods doCallRealMethod().when(launcher).call(); @@ -53,11 +52,12 @@ void setUp() throws Exception { doReturn(mock(JFrame.class)).when(launcher).createFrame(); doAnswer((invocaton) -> { - launcher.setPort(invocaton.getArgument(2)); - launcher.setHostname(invocaton.getArgument(1)); - return true; - }).when(launcher).showSettingDialog(any(JFrame.class), anyString(), anyInt()); - + launcher.setPort(invocaton.getArgument(2)); + launcher.setHostname(invocaton.getArgument(1)); + return true; + }) + .when(launcher) + .showSettingDialog(any(JFrame.class), anyString(), anyInt()); cmd = new CommandLine(launcher).setCaseInsensitiveEnumValuesAllowed(true); @@ -89,42 +89,50 @@ void testInvalidLang() { @Test void testValidLang() { assertEquals(0, cmd.execute("-l", "en_US")); - verify(launcher).launchGame(any(), - eq(Launcher.DEFAULT_SERVER), - eq(Launcher.DEFAULT_PORT), - eq(Launcher.Language.EN_US), - any(), - anyBoolean(), - anyBoolean()); + verify(launcher) + .launchGame( + any(), + eq(Launcher.DEFAULT_SERVER), + eq(Launcher.DEFAULT_PORT), + eq(Launcher.Language.EN_US), + any(), + anyBoolean(), + anyBoolean()); assertEquals(0, cmd.execute("--lang=Fi_fI")); - verify(launcher).launchGame(any(), - eq(Launcher.DEFAULT_SERVER), - eq(Launcher.DEFAULT_PORT), - eq(Launcher.Language.FI_FI), - any(), - anyBoolean(), - anyBoolean()); + verify(launcher) + .launchGame( + any(), + eq(Launcher.DEFAULT_SERVER), + eq(Launcher.DEFAULT_PORT), + eq(Launcher.Language.FI_FI), + any(), + anyBoolean(), + anyBoolean()); } @Test void testValidUsername() { assertEquals(0, cmd.execute("-u", "user")); - verify(launcher).launchGame(any(), - eq(Launcher.DEFAULT_SERVER), - eq(Launcher.DEFAULT_PORT), - any(), - eq("user"), - anyBoolean(), - anyBoolean()); + verify(launcher) + .launchGame( + any(), + eq(Launcher.DEFAULT_SERVER), + eq(Launcher.DEFAULT_PORT), + any(), + eq("user"), + anyBoolean(), + anyBoolean()); assertEquals(0, cmd.execute("--username=user2")); - verify(launcher).launchGame(any(), - eq(Launcher.DEFAULT_SERVER), - eq(Launcher.DEFAULT_PORT), - any(), - eq("user2"), - anyBoolean(), - anyBoolean()); + verify(launcher) + .launchGame( + any(), + eq(Launcher.DEFAULT_SERVER), + eq(Launcher.DEFAULT_PORT), + any(), + eq("user2"), + anyBoolean(), + anyBoolean()); } @Test @@ -148,27 +156,35 @@ void testValidPortAndHostname() { @Test void testOnlyPort() { assertEquals(0, cmd.execute("-p", "1111")); - verify(launcher).launchGame(any(), eq(Launcher.DEFAULT_SERVER), eq(1111), any(), any(), anyBoolean(), anyBoolean()); + verify(launcher) + .launchGame(any(), eq(Launcher.DEFAULT_SERVER), eq(1111), any(), any(), anyBoolean(), anyBoolean()); } @Test void testOnlyHostname() { assertEquals(0, cmd.execute("-ip", "127.127.127.127")); - verify(launcher).launchGame(any(), eq("127.127.127.127"), eq(Launcher.DEFAULT_PORT), any(), any(), anyBoolean(), - anyBoolean()); + verify(launcher) + .launchGame( + any(), + eq("127.127.127.127"), + eq(Launcher.DEFAULT_PORT), + any(), + any(), + anyBoolean(), + anyBoolean()); } @Test void testDefaultValues() { assertEquals(0, cmd.execute()); - verify(launcher).launchGame( - any(), - eq(Launcher.DEFAULT_SERVER), - eq(Launcher.DEFAULT_PORT), - eq(Launcher.Language.EN_US), - eq(null), - eq(false), - eq(false) - ); + verify(launcher) + .launchGame( + any(), + eq(Launcher.DEFAULT_SERVER), + eq(Launcher.DEFAULT_PORT), + eq(Launcher.Language.EN_US), + eq(null), + eq(false), + eq(false)); } -} \ No newline at end of file +} diff --git a/client/src/test/java/org/moparforia/client/ResourceLoadTest.java b/client/src/test/java/org/moparforia/client/ResourceLoadTest.java index 69ed4972..10affdf3 100644 --- a/client/src/test/java/org/moparforia/client/ResourceLoadTest.java +++ b/client/src/test/java/org/moparforia/client/ResourceLoadTest.java @@ -1,22 +1,16 @@ package org.moparforia.client; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import org.junit.jupiter.api.Test; -/** - * Tests that resources can be loaded - */ +/** Tests that resources can be loaded */ class ResourceLoadTest { - /** - * Tests that Launcher icon can be loaded - */ + /** Tests that Launcher icon can be loaded */ @Test void testLoadIcon() { Launcher launcher = new Launcher(); assertDoesNotThrow(launcher::loadIcon); } - -} \ No newline at end of file +} diff --git a/editor/pom.xml b/editor/pom.xml index 444344c2..0c83500d 100644 --- a/editor/pom.xml +++ b/editor/pom.xml @@ -2,15 +2,15 @@ 4.0.0 - editor - 2.2.1.0-BETA - org.moparforia playforia-minigolf 2.2.1.0-BETA + editor + 2.2.1.0-BETA + org.moparforia.editor.TrackEditor @@ -39,8 +39,8 @@ - plantuml-generator-maven-plugin de.elnarion.maven + plantuml-generator-maven-plugin 1.1.2 diff --git a/editor/src/main/java/org/moparforia/editor/EditorPanel.java b/editor/src/main/java/org/moparforia/editor/EditorPanel.java index 5b202d74..f8052b82 100644 --- a/editor/src/main/java/org/moparforia/editor/EditorPanel.java +++ b/editor/src/main/java/org/moparforia/editor/EditorPanel.java @@ -1,16 +1,15 @@ package org.moparforia.editor; -import org.moparforia.shared.tracks.Track; -import org.moparforia.shared.tracks.TrackCategory; - -import javax.swing.*; -import javax.swing.border.Border; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import java.io.FileOutputStream; import java.io.PrintStream; +import javax.swing.*; +import javax.swing.border.Border; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.TrackCategory; public class EditorPanel extends JPanel { @@ -24,7 +23,6 @@ public class EditorPanel extends JPanel { Border borderBlack; Track currentTrack; - public EditorPanel(MapCanvas canvas) { this.canvas = canvas; setLayout(new GridLayout(3, 2)); @@ -150,7 +148,6 @@ public void actionPerformed(ActionEvent e) { } }; - ActionListener shapeSelection = new ActionListener() { public void actionPerformed(ActionEvent e) { JButton source = (JButton) e.getSource(); @@ -170,7 +167,6 @@ public void actionPerformed(ActionEvent e) { currentTile.setShapeIndex(currentShapeSelection); canvas.setSelectedTile(currentTile); System.out.println("new: " + currentTile); - } }; @@ -193,8 +189,6 @@ public void actionPerformed(ActionEvent e) { currentTile.setShapeIndex(currentSpecialSelection); canvas.setSelectedTile(currentTile); System.out.println("new: " + currentTile); - - } }; @@ -202,9 +196,10 @@ public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) { try { JFileChooser chooser = new JFileChooser("."); - chooser.showDialog(getThis(),"hurr"); + chooser.showDialog(getThis(), "hurr"); File f = chooser.getSelectedFile(); - //currentTrack = TrackStore.getTrack(f);//todo get rid of this (uses org.moparforia.server.track.TrackStore)!! + // currentTrack = TrackStore.getTrack(f);//todo get rid of this (uses + // org.moparforia.server.track.TrackStore)!! currentTrack = TrackEditor.loadTrack(f.toPath()); Map m = new MapDecompressor().decompress(currentTrack.getMap()); canvas.setMap(m); @@ -212,7 +207,6 @@ public void actionPerformed(ActionEvent e) { exp.printStackTrace(); System.err.println("PROBLEMO WITH LOADING MAP"); } - } }; @@ -222,9 +216,9 @@ public EditorPanel getThis() { ActionListener generateMap = new ActionListener() { public void actionPerformed(ActionEvent e) { - if(currentTrack == null) { + if (currentTrack == null) { String data = new MapCompressor().compress(canvas.getMap()); - String name = JOptionPane.showInputDialog(getThis(),"WUTS THE NAME OF THIS TRACK?"); + String name = JOptionPane.showInputDialog(getThis(), "WUTS THE NAME OF THIS TRACK?"); Track track = new Track(name, "fc", data, TrackCategory.UNKNOWN); currentTrack = track; } @@ -240,55 +234,46 @@ public void actionPerformed(ActionEvent e) { out.print(save); } catch (Exception ignored) { } - } }; - public JButton getCurrentElementButton(boolean fireAction) { JButton button = elementButtons[currentElementSelection]; - if (fireAction) - button.getActionListeners()[0].actionPerformed(new ActionEvent(button, 0, null)); + if (fireAction) button.getActionListeners()[0].actionPerformed(new ActionEvent(button, 0, null)); return button; } public JButton selectNextElementButton() { elementButtons[currentElementSelection].setBorder(borderGrey); currentElementSelection++; - if (currentElementSelection >= elementButtons.length) - currentElementSelection = 0; + if (currentElementSelection >= elementButtons.length) currentElementSelection = 0; return getCurrentElementButton(true); } public JButton selectPrevElementButton() { elementButtons[currentElementSelection].setBorder(borderGrey); currentElementSelection--; - if (currentElementSelection <= 0) - currentElementSelection = elementButtons.length - 1; + if (currentElementSelection <= 0) currentElementSelection = elementButtons.length - 1; return getCurrentElementButton(true); } public JButton getCurrentElement2Button(boolean fireAction) { JButton button = element2Buttons[currentElement2Selection]; - if (fireAction) - button.getActionListeners()[0].actionPerformed(new ActionEvent(button, 0, null)); + if (fireAction) button.getActionListeners()[0].actionPerformed(new ActionEvent(button, 0, null)); return button; } public JButton selectNextElement2Button() { element2Buttons[currentElement2Selection].setBorder(borderGrey); currentElement2Selection++; - if (currentElement2Selection >= element2Buttons.length) - currentElement2Selection = 0; + if (currentElement2Selection >= element2Buttons.length) currentElement2Selection = 0; return getCurrentElement2Button(true); } public JButton selectPrevElement2Button() { element2Buttons[currentElement2Selection].setBorder(borderGrey); currentElement2Selection--; - if (currentElement2Selection <= 0) - currentElement2Selection = element2Buttons.length - 1; + if (currentElement2Selection <= 0) currentElement2Selection = element2Buttons.length - 1; return getCurrentElement2Button(true); } - } diff --git a/editor/src/main/java/org/moparforia/editor/IEditor.java b/editor/src/main/java/org/moparforia/editor/IEditor.java index dc4533a6..b1928284 100644 --- a/editor/src/main/java/org/moparforia/editor/IEditor.java +++ b/editor/src/main/java/org/moparforia/editor/IEditor.java @@ -1,12 +1,7 @@ package org.moparforia.editor; -/** - * User: Johan - * Date: 2013-07-31 - * Time: 11:14 - */ +/** User: Johan Date: 2013-07-31 Time: 11:14 */ public interface IEditor { int getDrawMode(); - } diff --git a/editor/src/main/java/org/moparforia/editor/Map.java b/editor/src/main/java/org/moparforia/editor/Map.java index 8586dbc4..439208d9 100644 --- a/editor/src/main/java/org/moparforia/editor/Map.java +++ b/editor/src/main/java/org/moparforia/editor/Map.java @@ -4,7 +4,6 @@ public class Map { public Tile[][] tiles = new Tile[49][25]; - public Map(Tile[][] init) throws Exception { boolean valid = true; if (init.length == 49 && init[0].length == 25) { @@ -62,14 +61,12 @@ public Tile[][] toTileArray() { return tiles; } - public void printMap() { for (int y = 0; y < tiles[0].length; y++) { for (int x = 0; x < tiles.length; x++) { - System.out.print(Integer.toString(tiles[x][y].getTileCode(),16) + " | "); + System.out.print(Integer.toString(tiles[x][y].getTileCode(), 16) + " | "); } System.out.println(); } } - } diff --git a/editor/src/main/java/org/moparforia/editor/MapCanvas.java b/editor/src/main/java/org/moparforia/editor/MapCanvas.java index 387d3a94..61fb674b 100644 --- a/editor/src/main/java/org/moparforia/editor/MapCanvas.java +++ b/editor/src/main/java/org/moparforia/editor/MapCanvas.java @@ -1,11 +1,10 @@ package org.moparforia.editor; -import org.moparforia.editor.util.RectangleDragSelector; - -import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.BufferedImage; +import javax.swing.*; +import org.moparforia.editor.util.RectangleDragSelector; public class MapCanvas extends JPanel implements MouseListener, MouseMotionListener, MouseWheelListener { @@ -48,11 +47,8 @@ public int getTrackCategory() { } /** - * returns the following sprites in this format - * a[0][] = shapes - * a[1][] = elements - * a[2][] = specials - * a[3][] = balls + * returns the following sprites in this format a[0][] = shapes a[1][] = elements a[2][] = + * specials a[3][] = balls * * @return 2d array of all sprites */ @@ -97,7 +93,6 @@ public boolean setSelectedTile(Tile t) { } else { return false; } - } public void toggleGrid() { @@ -114,11 +109,11 @@ protected void paintComponent(Graphics g) { if (spriteManager != null && m != null) { for (int tileX = 0; tileX < 49; tileX++) { for (int tileY = 0; tileY < 25; tileY++) { - int[] tilePixels = spriteManager.getPixelsFromTileCode(m.getTile(tileX, tileY).getTileCode()); + int[] tilePixels = spriteManager.getPixelsFromTileCode( + m.getTile(tileX, tileY).getTileCode()); int y = 0; for (int pixel = 0; pixel < tilePixels.length; pixel++) { - if (pixel % 15 == 0 && pixel != 0) - y++; + if (pixel % 15 == 0 && pixel != 0) y++; buffer.setRGB(tileX * 15 + (pixel % 15), tileY * 15 + y, tilePixels[pixel]); } } @@ -168,7 +163,7 @@ private void fillRect() { } public void mouseClicked(MouseEvent e) { - switch(editor.getDrawMode()) { + switch (editor.getDrawMode()) { case 0: drawTile(e); } @@ -176,25 +171,25 @@ public void mouseClicked(MouseEvent e) { } public void mouseDragged(MouseEvent e) { - switch(editor.getDrawMode()) { + switch (editor.getDrawMode()) { case 0: drawTile(e); case 1: - rectangleDragSelector.refresh((int)Math.ceil(e.getX() / 15), (int)Math.ceil(e.getY() / 15)); + rectangleDragSelector.refresh((int) Math.ceil(e.getX() / 15), (int) Math.ceil(e.getY() / 15)); } repaint(); } public void mousePressed(MouseEvent e) { - switch(editor.getDrawMode()) { + switch (editor.getDrawMode()) { case 1: - rectangleDragSelector.reset(); + rectangleDragSelector.reset(); } } public void mouseReleased(MouseEvent e) { - switch(editor.getDrawMode()) { + switch (editor.getDrawMode()) { case 0: return; case 1: @@ -203,15 +198,14 @@ public void mouseReleased(MouseEvent e) { repaint(); } - public void mouseEntered(MouseEvent e) { - } + public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) { - //To change body of implemented methods use File | Settings | File Templates. + // To change body of implemented methods use File | Settings | File Templates. } public void mouseMoved(MouseEvent e) { - //To change body of implemented methods use File | Settings | File Templates. + // To change body of implemented methods use File | Settings | File Templates. } public void mouseWheelMoved(MouseWheelEvent e) { diff --git a/editor/src/main/java/org/moparforia/editor/MapCompressor.java b/editor/src/main/java/org/moparforia/editor/MapCompressor.java index dd4146b4..7f41a82f 100644 --- a/editor/src/main/java/org/moparforia/editor/MapCompressor.java +++ b/editor/src/main/java/org/moparforia/editor/MapCompressor.java @@ -1,8 +1,6 @@ package org.moparforia.editor; -/** - * makes maps smaller so Svitvona's ISP wont complain about too much bandwidth. - */ +/** makes maps smaller so Svitvona's ISP wont complain about too much bandwidth. */ public class MapCompressor { private static final String mapChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -25,13 +23,13 @@ private String shortenString(String map) { for (int i = 0; i < map.length(); i++) { int count = 1; - if(i+1 < map.length()) { + if (i + 1 < map.length()) { while (map.charAt(i) == map.charAt(i + 1)) { count++; i++; if (i + 1 == map.length()) break; } - } + } if (count > 1) { buff.append(Integer.toString(count)); @@ -58,7 +56,6 @@ private String encodeMapTiles() { } buff.append(tileCodeToString(mapTiles[x][y])); - } } return buff.toString(); @@ -67,7 +64,7 @@ private String encodeMapTiles() { private char checkContiguousRegion(int tileX, int tileY) { if (tileX > 0) - if (this.mapTiles[tileX][tileY] == this.mapTiles[tileX - 1][tileY]) { // if input = D + if (this.mapTiles[tileX][tileY] == this.mapTiles[tileX - 1][tileY]) { // if input = D // tile to west is same as current return 'D'; } @@ -85,7 +82,7 @@ private char checkContiguousRegion(int tileX, int tileY) { } if (tileX > 1) - if (this.mapTiles[tileX][tileY] == this.mapTiles[tileX - 2][tileY]) { // if input = G; + if (this.mapTiles[tileX][tileY] == this.mapTiles[tileX - 2][tileY]) { // if input = G; // 2 tiles west is same as current (skip a tile to the left) return 'G'; } @@ -110,9 +107,13 @@ private String tileCodeToString(int tileCode) { int foregroundElementIndex = tileCode / 256 % 256; int backgroundElementIndex = tileCode % 256; - - return mapChars.charAt(isNoSpecial) + "" + mapChars.charAt(shapeIndex) + - "" + mapChars.charAt(foregroundElementIndex) + "" + (isNoSpecial == 2 ? "" : mapChars.charAt(backgroundElementIndex)); + return mapChars.charAt(isNoSpecial) + + "" + + mapChars.charAt(shapeIndex) + + "" + + mapChars.charAt(foregroundElementIndex) + + "" + + (isNoSpecial == 2 ? "" : mapChars.charAt(backgroundElementIndex)); } private int[][] tileTotileCodes(Tile[][] tiles) { diff --git a/editor/src/main/java/org/moparforia/editor/MapDecompressor.java b/editor/src/main/java/org/moparforia/editor/MapDecompressor.java index 0f39d41c..cd38f94d 100644 --- a/editor/src/main/java/org/moparforia/editor/MapDecompressor.java +++ b/editor/src/main/java/org/moparforia/editor/MapDecompressor.java @@ -9,9 +9,9 @@ public MapDecompressor() { this.mapTiles = new int[49][25]; } - public Map decompress(String mapData) throws Exception{ + public Map decompress(String mapData) throws Exception { String expandData = expandMap(mapData); - System.out.println("input: "+mapData+"\nexpand:"+expandData); + System.out.println("input: " + mapData + "\nexpand:" + expandData); parseMap(expandData); Tile[][] tiles = convertCodesToTiles(); @@ -19,19 +19,19 @@ public Map decompress(String mapData) throws Exception{ } public Tile[][] convertCodesToTiles() { - Tile[][] result = new Tile[49][25]; + Tile[][] result = new Tile[49][25]; for (int y = 0; y < 25; y++) { - for (int x = 0; x < 49; x++) { - int tileCode = mapTiles[x][y]; - int isNoSpecial = tileCode / 16777216; - int shapeIndex = tileCode / 65536 % 256; // Becomes the SpecialIndex if isNoSpecial==2 - int foregroundElementIndex = tileCode / 256 % 256; - int backgroundElementIndex = tileCode % 256; - result[x][y] = new Tile(shapeIndex,foregroundElementIndex,backgroundElementIndex,isNoSpecial); - } - } - - return result; + for (int x = 0; x < 49; x++) { + int tileCode = mapTiles[x][y]; + int isNoSpecial = tileCode / 16777216; + int shapeIndex = tileCode / 65536 % 256; // Becomes the SpecialIndex if isNoSpecial==2 + int foregroundElementIndex = tileCode / 256 % 256; + int backgroundElementIndex = tileCode % 256; + result[x][y] = new Tile(shapeIndex, foregroundElementIndex, backgroundElementIndex, isNoSpecial); + } + } + + return result; } private void parseMap(final String data) { @@ -44,7 +44,7 @@ private void parseMap(final String data) { int currentMapIndex = mapChars.indexOf(mapData.charAt(cursorIndex)); - if (currentMapIndex <= 2) { // if input= A,B or C + if (currentMapIndex <= 2) { // if input= A,B or C int mapcursor_one_ahead; int mapcursor_two_ahead; int mapcursor_three_ahead; @@ -61,43 +61,53 @@ private void parseMap(final String data) { cursorIndex += 3; } - // (currentMapIndex << 24) + (mapcursor_one_ahead << 16) + (mapcursor_two_ahead << 8) + mapcursor_three_ahead; - this.mapTiles[tileX][tileY] = currentMapIndex * 256 * 256 * 256 + mapcursor_one_ahead * 256 * 256 + mapcursor_two_ahead * 256 + mapcursor_three_ahead; + // (currentMapIndex << 24) + (mapcursor_one_ahead << 16) + (mapcursor_two_ahead + // << 8) + mapcursor_three_ahead; + this.mapTiles[tileX][tileY] = currentMapIndex * 256 * 256 * 256 + + mapcursor_one_ahead * 256 * 256 + + mapcursor_two_ahead * 256 + + mapcursor_three_ahead; } else { - if (currentMapIndex == 3) { // if input = D - this.mapTiles[tileX][tileY] = this.mapTiles[tileX - 1][tileY]; // tile to west is same as current + if (currentMapIndex == 3) { // if input = D + this.mapTiles[tileX][tileY] = + this.mapTiles[tileX - 1][tileY]; // tile to west is same as current } if (currentMapIndex == 4) { // if input = E; - this.mapTiles[tileX][tileY] = this.mapTiles[tileX][tileY - 1]; // tile to the north is same as current + this.mapTiles[tileX][tileY] = + this.mapTiles[tileX][tileY - 1]; // tile to the north is same as current } if (currentMapIndex == 5) { // if input = F; - this.mapTiles[tileX][tileY] = this.mapTiles[tileX - 1][tileY - 1]; // tile to the northwest is same as current + this.mapTiles[tileX][tileY] = + this.mapTiles[tileX - 1][tileY - 1]; // tile to the northwest is same as current } - if (currentMapIndex == 6) { // if input = G; - this.mapTiles[tileX][tileY] = this.mapTiles[tileX - 2][tileY]; // 2 tiles west is same as current (skip a tile to the left) + if (currentMapIndex == 6) { // if input = G; + this.mapTiles[tileX][tileY] = + this.mapTiles[tileX - 2][tileY]; // 2 tiles west is same as current (skip a tile to + // the left) } if (currentMapIndex == 7) { // if input = H - this.mapTiles[tileX][tileY] = this.mapTiles[tileX][tileY - 2]; // 2 tiles north is same as current (skip the tile above) + this.mapTiles[tileX][tileY] = + this.mapTiles[tileX][tileY - 2]; // 2 tiles north is same as current (skip the + // tile above) } if (currentMapIndex == 8) { // if input= I - this.mapTiles[tileX][tileY] = this.mapTiles[tileX - 2][tileY - 2]; // 2 tiles northwest is same as current (skip the diagonal) + this.mapTiles[tileX][tileY] = + this.mapTiles[tileX - 2][tileY - 2]; // 2 tiles northwest is same as current (skip + // the diagonal) } ++cursorIndex; } } } - - } - private static String expandMap(String mapString) { StringBuffer buffer = new StringBuffer(4900); int length = mapString.length(); @@ -148,6 +158,4 @@ private static int method123(String input, int cursor) { ++cursor; } } - - } diff --git a/editor/src/main/java/org/moparforia/editor/SpriteManager.java b/editor/src/main/java/org/moparforia/editor/SpriteManager.java index d8f35db6..8f6e77d4 100644 --- a/editor/src/main/java/org/moparforia/editor/SpriteManager.java +++ b/editor/src/main/java/org/moparforia/editor/SpriteManager.java @@ -1,10 +1,10 @@ package org.moparforia.editor; -import javax.imageio.ImageIO; -import javax.swing.*; import java.awt.*; import java.awt.image.MemoryImageSource; import java.awt.image.PixelGrabber; +import javax.imageio.ImageIO; +import javax.swing.*; public class SpriteManager { @@ -28,110 +28,110 @@ public SpriteManager(JFrame j) { } public Image[][] getSprites() { - return new Image[][]{this.shapes,this.elements,this.specials,this.balls}; + return new Image[][] {this.shapes, this.elements, this.specials, this.balls}; } public int[] getPixelsFromTileCode(int tileCode) { - if(tileCode == 0) { - return null; - } else { - int isNoSpecial = tileCode / 16777216; - int shapeIndex = tileCode / 65536 % 256; // Becomes the SpecialIndex if isNoSpecial==2 - int foregroundElementIndex = tileCode / 256 % 256; - int backgroundElementIndex = tileCode % 256; - /** - * element index's - * 0=grass, 1=dirt, 2=mud, 3=ice, 4=speed-n, 5=speed-ne, 6=speed-e, 7=speed-se - * 8=speed-s, 9=speed-sw, 10=speed-w, 11=speed-nw - * 12=water, 13=piss, 14=grass+water, 15=grass+piss, 16=block, 17=sticky-block - * 18=bouncy-block, 19=hackblock?!? 20=solid-n, 21=solid-e 22=solid-s 23=solid-w - * - * - * special index's - * 0=blank, 1=hole, 2=hole, 3=moveable-block, 4=mine, 5=blowmine, 6=BIGmine, 7=blownmine2 - * 8=blue-T-source, 9= blue-T-destination, 10=red-T-source, 11= red-T-destination, - * 12=yellow-T-source, 13= yellow-T-destination, 14=green-T-source, 15= green-T-destination, - * 16=fullbricks, 17=threequarterbricks, 18=halfbricks, 19=quarterbricks, - * 20=magnet-attract, 21=magnet-repel, 22=moveableblock?, 23= greenmoveableblock - */ - - // first check if we're combining 2 elements, then element+special. - return isNoSpecial == 1?this.combineElementAndElement(shapeIndex, foregroundElementIndex, backgroundElementIndex):(isNoSpecial == 2?this.combineElementAndSpecial(shapeIndex, foregroundElementIndex):null); - } + if (tileCode == 0) { + return null; + } else { + int isNoSpecial = tileCode / 16777216; + int shapeIndex = tileCode / 65536 % 256; // Becomes the SpecialIndex if isNoSpecial==2 + int foregroundElementIndex = tileCode / 256 % 256; + int backgroundElementIndex = tileCode % 256; + /** + * element index's 0=grass, 1=dirt, 2=mud, 3=ice, 4=speed-n, 5=speed-ne, 6=speed-e, + * 7=speed-se 8=speed-s, 9=speed-sw, 10=speed-w, 11=speed-nw 12=water, 13=piss, + * 14=grass+water, 15=grass+piss, 16=block, 17=sticky-block 18=bouncy-block, + * 19=hackblock?!? 20=solid-n, 21=solid-e 22=solid-s 23=solid-w + * + *

special index's 0=blank, 1=hole, 2=hole, 3=moveable-block, 4=mine, 5=blowmine, + * 6=BIGmine, 7=blownmine2 8=blue-T-source, 9= blue-T-destination, 10=red-T-source, 11= + * red-T-destination, 12=yellow-T-source, 13= yellow-T-destination, 14=green-T-source, + * 15= green-T-destination, 16=fullbricks, 17=threequarterbricks, 18=halfbricks, + * 19=quarterbricks, 20=magnet-attract, 21=magnet-repel, 22=moveableblock?, 23= + * greenmoveableblock + */ + + // first check if we're combining 2 elements, then element+special. + return isNoSpecial == 1 + ? this.combineElementAndElement(shapeIndex, foregroundElementIndex, backgroundElementIndex) + : (isNoSpecial == 2 ? this.combineElementAndSpecial(shapeIndex, foregroundElementIndex) : null); + } } private int[] combineElementAndElement(int shapeMaskIndex, int firstElementIndex, int secondElementIndex) { - int[][] shapeMask = this.getShapePixelMask(shapeMaskIndex); - int[] foregroundElement = getPixels(this.elements[firstElementIndex], 15, 15); - int[] backgroundElement = getPixels(this.elements[secondElementIndex], 15, 15); - return this.combineShapeAndTwoElements(shapeMask, foregroundElement, backgroundElement); + int[][] shapeMask = this.getShapePixelMask(shapeMaskIndex); + int[] foregroundElement = getPixels(this.elements[firstElementIndex], 15, 15); + int[] backgroundElement = getPixels(this.elements[secondElementIndex], 15, 15); + return this.combineShapeAndTwoElements(shapeMask, foregroundElement, backgroundElement); } private int[] combineElementAndSpecial(int specialIndex, int backgroundIndex) { - int[][] specialMask = this.getSpecialPixels(specialIndex); - int[] backgroundElement = getPixels(this.elements[backgroundIndex], 15, 15); - int[] specialPixels = getPixels(this.specials[specialIndex], 15, 15); - return this.combineShapeAndTwoElements(specialMask, backgroundElement, specialPixels); + int[][] specialMask = this.getSpecialPixels(specialIndex); + int[] backgroundElement = getPixels(this.elements[backgroundIndex], 15, 15); + int[] specialPixels = getPixels(this.specials[specialIndex], 15, 15); + return this.combineShapeAndTwoElements(specialMask, backgroundElement, specialPixels); } /** * Creates a pixel mask, 1=white, 2=black as shown + * * @param pixelMaskIndex Index of the Shape * @return 2d array of 1's and 2's representing the pixel mask */ - private int[][] getShapePixelMask(int pixelMaskIndex) { - if(this.pixelshapeMasks[pixelMaskIndex] == null) { - int[] var2 = getPixels(this.shapes[pixelMaskIndex], 15, 15); - this.pixelshapeMasks[pixelMaskIndex] = this.createShapeMask(var2); - } + private int[][] getShapePixelMask(int pixelMaskIndex) { + if (this.pixelshapeMasks[pixelMaskIndex] == null) { + int[] var2 = getPixels(this.shapes[pixelMaskIndex], 15, 15); + this.pixelshapeMasks[pixelMaskIndex] = this.createShapeMask(var2); + } - return this.pixelshapeMasks[pixelMaskIndex]; - } + return this.pixelshapeMasks[pixelMaskIndex]; + } private int[][] getSpecialPixels(int specialIndex) { - if(this.specialPixelMasks[specialIndex] == null) { - int[] specialPixels = getPixels(this.specials[specialIndex], 15, 15); - this.specialPixelMasks[specialIndex] = this.createShapeMask(specialPixels); - } + if (this.specialPixelMasks[specialIndex] == null) { + int[] specialPixels = getPixels(this.specials[specialIndex], 15, 15); + this.specialPixelMasks[specialIndex] = this.createShapeMask(specialPixels); + } - return this.specialPixelMasks[specialIndex]; + return this.specialPixelMasks[specialIndex]; } private int[][] createShapeMask(int[] var1) { - int[][] result = new int[15][15]; + int[][] result = new int[15][15]; - for(int y = 0; y < 15; ++y) { - for(int x = 0; x < 15; ++x) { - int currentPixel = var1[y * 15 + x] & 16777215; - result[x][y] = currentPixel == 13421823?1:2; - } - } + for (int y = 0; y < 15; ++y) { + for (int x = 0; x < 15; ++x) { + int currentPixel = var1[y * 15 + x] & 16777215; + result[x][y] = currentPixel == 13421823 ? 1 : 2; + } + } - return result; + return result; } private int[] combineShapeAndTwoElements(int[][] var1, int[] var2, int[] var3) { - int[] var4 = new int[225]; + int[] var4 = new int[225]; - for(int var5 = 0; var5 < 15; ++var5) { - for(int var6 = 0; var6 < 15; ++var6) { - int var7 = 16777215; - if(var1[var6][var5] == 1) { - var7 = var2[var5 * 15 + var6]; - } + for (int var5 = 0; var5 < 15; ++var5) { + for (int var6 = 0; var6 < 15; ++var6) { + int var7 = 16777215; + if (var1[var6][var5] == 1) { + var7 = var2[var5 * 15 + var6]; + } - if(var1[var6][var5] == 2) { - var7 = var3[var5 * 15 + var6]; - } + if (var1[var6][var5] == 2) { + var7 = var3[var5 * 15 + var6]; + } - var4[var5 * 15 + var6] = var7; - } - } + var4[var5 * 15 + var6] = var7; + } + } - return var4; + return var4; } - public int getWidth(Image var1) { return var1.getWidth(frame); } @@ -166,7 +166,7 @@ public Image getImage(String var1) { try { result = ImageIO.read(getClass().getResourceAsStream("/" + var1 + ".gif")); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); } return result; } @@ -191,8 +191,8 @@ public Image createImage(int[] imageData, int width, int heigh, Component var4) return var5; } - - private Image[] parseSpriteSheet(String spriteSheetName, int spriteCount, int spritesPerRow, int spriteWidth, int spriteHeight) { + private Image[] parseSpriteSheet( + String spriteSheetName, int spriteCount, int spritesPerRow, int spriteWidth, int spriteHeight) { Image spriteSheet = getImage(spriteSheetName); int sheetWidth = getWidth(spriteSheet); int sheetHeight = getHeight(spriteSheet); @@ -208,7 +208,12 @@ private Image[] parseSpriteSheet(String spriteSheetName, int spriteCount, int sp for (int var15 = 0; var15 < spriteHeight; ++var15) { for (int var16 = 0; var16 < spriteWidth; ++var16) { - var14[var15 * spriteWidth + var16] = var9[(var12 * spriteHeight + var12 + 1 + var15) * sheetWidth + var13 * spriteWidth + var13 + 1 + var16]; + var14[var15 * spriteWidth + var16] = var9[ + (var12 * spriteHeight + var12 + 1 + var15) * sheetWidth + + var13 * spriteWidth + + var13 + + 1 + + var16]; } } diff --git a/editor/src/main/java/org/moparforia/editor/Tile.java b/editor/src/main/java/org/moparforia/editor/Tile.java index e173f027..c6f0c44a 100644 --- a/editor/src/main/java/org/moparforia/editor/Tile.java +++ b/editor/src/main/java/org/moparforia/editor/Tile.java @@ -2,21 +2,17 @@ public class Tile { - /** - * Sprite index of the shape mask. - */ + /** Sprite index of the shape mask. */ private int shapeIndex; - /** - * Sprite index of the foreground Element tile. - */ + + /** Sprite index of the foreground Element tile. */ private int backgroundElementIndex; - /** - * Sprite index of the background Element tile (only used when two are layered I THINK)... - */ + + /** Sprite index of the background Element tile (only used when two are layered I THINK)... */ private int foregroundElementIndex; + /** - * Code for whether we're drawing a special sprite or just two elements together. - * 1=normal + * Code for whether we're drawing a special sprite or just two elements together. 1=normal * 2=special. */ private int isSpecial; @@ -57,17 +53,18 @@ public boolean isStartPosition() { } public boolean isHole() { - return isSpecial() && shapeIndex == 1 ; + return isSpecial() && shapeIndex == 1; } public boolean isPassable() { - return !(!isSpecial() && (backgroundElementIndex == 12 || - backgroundElementIndex ==13 || - (backgroundElementIndex >=16 && backgroundElementIndex <=18) )); + return !(!isSpecial() + && (backgroundElementIndex == 12 + || backgroundElementIndex == 13 + || (backgroundElementIndex >= 16 && backgroundElementIndex <= 18))); } public Tile clone() { - return new Tile(shapeIndex,backgroundElementIndex,foregroundElementIndex,isSpecial); + return new Tile(shapeIndex, backgroundElementIndex, foregroundElementIndex, isSpecial); } @Override @@ -86,8 +83,17 @@ public boolean equals(Object o) { @Override public String toString() { - return "tilecode:" + getTileCode() + " shape:" + shapeIndex + " back:" + backgroundElementIndex + " " + - "fore:"+foregroundElementIndex+" special:"+isSpecial; + return "tilecode:" + + getTileCode() + + " shape:" + + shapeIndex + + " back:" + + backgroundElementIndex + + " " + + "fore:" + + foregroundElementIndex + + " special:" + + isSpecial; } public int getTileCode() { diff --git a/editor/src/main/java/org/moparforia/editor/TrackEditor.java b/editor/src/main/java/org/moparforia/editor/TrackEditor.java index e8e37ea4..a06a0173 100644 --- a/editor/src/main/java/org/moparforia/editor/TrackEditor.java +++ b/editor/src/main/java/org/moparforia/editor/TrackEditor.java @@ -4,14 +4,6 @@ package org.moparforia.editor; -import org.moparforia.shared.tracks.Track; -import org.moparforia.shared.tracks.TrackCategory; -import org.moparforia.shared.tracks.filesystem.FileSystemTrackManager; -import org.moparforia.shared.tracks.parsers.VersionedTrackFileParser; - -import javax.swing.*; -import javax.swing.border.TitledBorder; -import javax.swing.filechooser.FileFilter; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -20,6 +12,13 @@ import java.io.*; import java.nio.file.Path; import java.util.ArrayList; +import javax.swing.*; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileFilter; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.TrackCategory; +import org.moparforia.shared.tracks.filesystem.FileSystemTrackManager; +import org.moparforia.shared.tracks.parsers.VersionedTrackFileParser; /** * @author Johan Ljungberg @@ -109,7 +108,6 @@ public void mouseClicked(MouseEvent e) { newTile.setShapeIndex(index); break; case 1: - if (SwingUtilities.isLeftMouseButton(e)) { newTile.setBackground(index); backSelection.setIcon(icon); @@ -132,26 +130,29 @@ public void mouseClicked(MouseEvent e) { @Override public void mousePressed(MouseEvent e) { - //To change body of implemented methods use File | Settings | File Templates. + // To change body of implemented methods use File | Settings | File + // Templates. } @Override public void mouseReleased(MouseEvent e) { - //To change body of implemented methods use File | Settings | File Templates. + // To change body of implemented methods use File | Settings | File + // Templates. } @Override public void mouseEntered(MouseEvent e) { - //To change body of implemented methods use File | Settings | File Templates. + // To change body of implemented methods use File | Settings | File + // Templates. } @Override public void mouseExited(MouseEvent e) { - //To change body of implemented methods use File | Settings | File Templates. + // To change body of implemented methods use File | Settings | File + // Templates. } }); - panel.add(button); } if (groupIndex == 0) { @@ -208,8 +209,11 @@ private void menuOpenActionPerformed(ActionEvent e) { Map m = new MapDecompressor().decompress(currentTrack.getMap()); TrackCategory category = TrackCategory.UNKNOWN; if (!currentTrack.getCategories().isEmpty()) { - // Oneliner to get one random category from loaded set, editor cannot work wiht multiple categories yet - category = currentTrack.getCategories().stream().reduce((t, u) -> t).orElse(TrackCategory.UNKNOWN); + // Oneliner to get one random category from loaded set, editor cannot work wiht + // multiple categories yet + category = currentTrack.getCategories().stream() + .reduce((t, u) -> t) + .orElse(TrackCategory.UNKNOWN); } mapCanvas.updateProperties(currentTrack.getName(), category.getId()); mapCanvas.setMap(m); @@ -223,12 +227,20 @@ private void menuOpenActionPerformed(ActionEvent e) { private void menuSaveActionPerformed(ActionEvent e) { if (!isValidTrack(mapCanvas.getMap())) { - JOptionPane.showMessageDialog(this, "The current track is impassable, please ensure there is a starting position, finishing hole and a valid path between.", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog( + this, + "The current track is impassable, please ensure there is a starting position, finishing hole and a valid path between.", + "Error", + JOptionPane.ERROR_MESSAGE); return; } if (mapCanvas.getTrackName().equals("") || mapCanvas.getTrackCategory() == 0) { - JOptionPane.showMessageDialog(this, "You need to specify a Track Name and/or Category before saving!", "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog( + this, + "You need to specify a Track Name and/or Category before saving!", + "Error", + JOptionPane.ERROR_MESSAGE); new TrackPropertiesDialog(this).setVisible(true); menuSaveActionPerformed(e); return; @@ -288,10 +300,10 @@ public static boolean isValidTrack(Map m) { if (!containsHole || (startX.isEmpty() && startY.isEmpty())) { return false; // if there is no hole or starting positions, ITS NOT VALID! } - for(int i = 0; i < startX.size(); i++) { - System.out.println(startX.get(i)+" "+startY.get(i)); - boolean[][] visited = new boolean[tiles.length][tiles[0].length]; - if(!traverseTrack(m, visited, startX.get(i), startY.get(i))) { + for (int i = 0; i < startX.size(); i++) { + System.out.println(startX.get(i) + " " + startY.get(i)); + boolean[][] visited = new boolean[tiles.length][tiles[0].length]; + if (!traverseTrack(m, visited, startX.get(i), startY.get(i))) { return false; // if any starting positions don't work, then bye bye. } } @@ -359,20 +371,19 @@ private void initComponents() { toggleCircle = new JToggleButton(); toggleFill = new JToggleButton(); - - //======== this ======== + // ======== this ======== setTitle("Playforia Minigolf Track Editor (BETA)"); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); - //======== menuBar ======== + // ======== menuBar ======== { - //======== menuFile ======== + // ======== menuFile ======== { menuFile.setText("File"); - //---- menuNew ---- + // ---- menuNew ---- menuNew.setText("New"); menuNew.addActionListener(new ActionListener() { @Override @@ -383,7 +394,7 @@ public void actionPerformed(ActionEvent e) { menuFile.add(menuNew); menuFile.addSeparator(); - //---- menuOpen ---- + // ---- menuOpen ---- menuOpen.setText("Open"); menuOpen.addActionListener(new ActionListener() { @Override @@ -393,7 +404,7 @@ public void actionPerformed(ActionEvent e) { }); menuFile.add(menuOpen); - //---- menuSave ---- + // ---- menuSave ---- menuSave.setText("Save"); menuSave.addActionListener(new ActionListener() { @Override @@ -404,7 +415,7 @@ public void actionPerformed(ActionEvent e) { menuFile.add(menuSave); menuFile.addSeparator(); - //---- menuQuit ---- + // ---- menuQuit ---- menuQuit.setText("Quit"); menuQuit.addActionListener(new ActionListener() { @Override @@ -416,11 +427,11 @@ public void actionPerformed(ActionEvent e) { } menuBar.add(menuFile); - //======== menuTrack ======== + // ======== menuTrack ======== { menuTrack.setText("Track"); - //---- menuPreferences ---- + // ---- menuPreferences ---- menuPreferences.setText("Preferences"); menuPreferences.addActionListener(new ActionListener() { @Override @@ -432,11 +443,11 @@ public void actionPerformed(ActionEvent e) { } menuBar.add(menuTrack); - //======== menuView ======== + // ======== menuView ======== { menuView.setText("View"); - //---- menuGrid ---- + // ---- menuGrid ---- menuGrid.setText("Grid"); menuGrid.setSelected(true); menuGrid.addActionListener(new ActionListener() { @@ -451,7 +462,7 @@ public void actionPerformed(ActionEvent e) { } setJMenuBar(menuBar); - //======== trackCanvas ======== + // ======== trackCanvas ======== { trackCanvas.setPreferredSize(new Dimension(735, 375)); trackCanvas.setLayout(null); @@ -468,38 +479,37 @@ public void actionPerformed(ActionEvent e) { preferredSize.height += insets.bottom; trackCanvas.setMinimumSize(preferredSize); trackCanvas.setPreferredSize(preferredSize); - } } contentPane.add(trackCanvas, BorderLayout.CENTER); - //======== canvasPanel ======== + // ======== canvasPanel ======== { canvasPanel.setBorder(new TitledBorder("Palette")); canvasPanel.setLayout(new BorderLayout()); } contentPane.add(canvasPanel, BorderLayout.SOUTH); - //======== maskPanel ======== + // ======== maskPanel ======== { maskPanel.setFloatable(false); maskPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 1)); maskPanel.setPreferredSize(new Dimension(16, 80)); - //---- togglePencil ---- + // ---- togglePencil ---- togglePencil.setIcon(new ImageIcon(getClass().getResource("/pencil_icon&16.png"))); maskPanel.add(togglePencil); - //---- toggleRectangle ---- + // ---- toggleRectangle ---- toggleRectangle.setIcon(new ImageIcon(getClass().getResource("/playback_stop_icon&16.png"))); maskPanel.add(toggleRectangle); - //---- toggleCircle ---- + // ---- toggleCircle ---- toggleCircle.setIcon(new ImageIcon(getClass().getResource("/playback_rec_icon&16.png"))); toggleCircle.setEnabled(false); maskPanel.add(toggleCircle); - //---- toggleFill ---- + // ---- toggleFill ---- toggleFill.setIcon(new ImageIcon(getClass().getResource("/fill_icon&16.png"))); toggleFill.setEnabled(false); maskPanel.add(toggleFill, BorderLayout.NORTH); diff --git a/editor/src/main/java/org/moparforia/editor/TrackPropertiesDialog.java b/editor/src/main/java/org/moparforia/editor/TrackPropertiesDialog.java index 3d9a14e5..ddb05298 100644 --- a/editor/src/main/java/org/moparforia/editor/TrackPropertiesDialog.java +++ b/editor/src/main/java/org/moparforia/editor/TrackPropertiesDialog.java @@ -4,12 +4,11 @@ package org.moparforia.editor; -import org.moparforia.shared.tracks.TrackCategory; - import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; +import org.moparforia.shared.tracks.TrackCategory; /** * @author Johan Ljungberg @@ -27,16 +26,18 @@ public TrackPropertiesDialog(Dialog owner) { } private void loadValues() { - textTrackName.setText(((TrackEditor)getOwner()).getMapCanvas().getTrackName()); + textTrackName.setText(((TrackEditor) getOwner()).getMapCanvas().getTrackName()); comboTrackCategory.setSelectedIndex(TrackCategory.BASIC.getId()); } private void okButtonActionPerformed(ActionEvent e) { - if(textTrackName.getText().equals("")) { + if (textTrackName.getText().equals("")) { JOptionPane.showMessageDialog(this, "Track name cannot be empty!", "Error", JOptionPane.ERROR_MESSAGE); return; } - ((TrackEditor)getOwner()).getMapCanvas().updateProperties(textTrackName.getText(), comboTrackCategory.getSelectedIndex() + 1); + ((TrackEditor) getOwner()) + .getMapCanvas() + .updateProperties(textTrackName.getText(), comboTrackCategory.getSelectedIndex() + 1); this.dispose(); } @@ -58,7 +59,7 @@ private void initComponents() { okButton = new JButton(); cancelButton = new JButton(); - //======== this ======== + // ======== this ======== setTitle("Track Properties"); setAlwaysOnTop(true); setResizable(false); @@ -67,62 +68,55 @@ private void initComponents() { Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); - //======== dialogPane ======== + // ======== dialogPane ======== { dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12)); dialogPane.setLayout(new BorderLayout()); - //======== contentPanel ======== + // ======== contentPanel ======== { contentPanel.setLayout(new GridLayout(0, 1)); - //======== panel2 ======== + // ======== panel2 ======== { panel2.setLayout(new FlowLayout()); - //---- label3 ---- + // ---- label3 ---- label3.setText("Track Name:"); panel2.add(label3); - //---- textTrackName ---- + // ---- textTrackName ---- textTrackName.setPreferredSize(new Dimension(200, 20)); panel2.add(textTrackName); } contentPanel.add(panel2); - //======== panel1 ======== + // ======== panel1 ======== { panel1.setLayout(new FlowLayout()); - //---- label2 ---- + // ---- label2 ---- label2.setText("Track Category"); panel1.add(label2); - //---- comboTrackCategory ---- + // ---- comboTrackCategory ---- comboTrackCategory.setPreferredSize(new Dimension(200, 20)); - comboTrackCategory.setModel(new DefaultComboBoxModel<>(new String[] { - "Basic", - "Traditional", - "Modern", - "Hole In One", - "Short", - "Long", - "Custom" - })); + comboTrackCategory.setModel(new DefaultComboBoxModel<>( + new String[] {"Basic", "Traditional", "Modern", "Hole In One", "Short", "Long", "Custom"})); panel1.add(comboTrackCategory); } contentPanel.add(panel1); } dialogPane.add(contentPanel, BorderLayout.CENTER); - //======== buttonBar ======== + // ======== buttonBar ======== { buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0)); buttonBar.setLayout(new GridBagLayout()); - ((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; - ((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; + ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80}; + ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0}; - //---- okButton ---- + // ---- okButton ---- okButton.setText("OK"); okButton.addActionListener(new ActionListener() { @Override @@ -130,11 +124,22 @@ public void actionPerformed(ActionEvent e) { okButtonActionPerformed(e); } }); - buttonBar.add(okButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(0, 0, 0, 5), 0, 0)); - - //---- cancelButton ---- + buttonBar.add( + okButton, + new GridBagConstraints( + 1, + 0, + 1, + 1, + 0.0, + 0.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(0, 0, 0, 5), + 0, + 0)); + + // ---- cancelButton ---- cancelButton.setText("Cancel"); cancelButton.addActionListener(new ActionListener() { @Override @@ -142,9 +147,20 @@ public void actionPerformed(ActionEvent e) { cancelButtonActionPerformed(e); } }); - buttonBar.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(0, 0, 0, 0), 0, 0)); + buttonBar.add( + cancelButton, + new GridBagConstraints( + 2, + 0, + 1, + 1, + 0.0, + 0.0, + GridBagConstraints.CENTER, + GridBagConstraints.BOTH, + new Insets(0, 0, 0, 0), + 0, + 0)); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } diff --git a/editor/src/main/java/org/moparforia/editor/util/RectangleDragSelector.java b/editor/src/main/java/org/moparforia/editor/util/RectangleDragSelector.java index 0e5f1ec4..51b26e68 100644 --- a/editor/src/main/java/org/moparforia/editor/util/RectangleDragSelector.java +++ b/editor/src/main/java/org/moparforia/editor/util/RectangleDragSelector.java @@ -2,11 +2,7 @@ import java.awt.*; -/** - * User: Johan - * Date: 2013-07-31 - * Time: 11:23 - */ +/** User: Johan Date: 2013-07-31 Time: 11:23 */ public class RectangleDragSelector { private int x1, x2, y1, y2; diff --git a/pom.xml b/pom.xml index 131d755f..d2fec17d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,17 +1,17 @@ - + 4.0.0 org.moparforia playforia-minigolf - pom 2.2.1.0-BETA + pom Playforia Minigolf + An online multiplayer minigolf game + 2002 Playforia - 2002 - An online multiplayer minigolf game server @@ -25,6 +25,58 @@ test.mainClass 4.7.6 + + + + + io.netty + netty-all + 4.1.112.Final + compile + + + org.moparforia + shared + 2.2.1.0-BETA + + + info.picocli + picocli + ${picocli.version} + + + + + org.junit.jupiter + junit-jupiter-engine + 5.10.2 + test + + + org.mockito + mockito-core + 5.12.0 + test + + + org.mockito + mockito-junit-jupiter + 5.12.0 + test + + + com.github.marschall + memoryfilesystem + 2.8.0 + test + + + de.elnarion.util + plantuml-generator-util + 2.4.1 + + + @@ -43,10 +95,10 @@ 3.5.3 - package shade + package @@ -112,56 +164,4 @@ - - - - - io.netty - netty-all - 4.1.112.Final - compile - - - org.moparforia - shared - 2.2.1.0-BETA - - - info.picocli - picocli - ${picocli.version} - - - - - org.junit.jupiter - junit-jupiter-engine - 5.10.2 - test - - - org.mockito - mockito-core - 5.12.0 - test - - - org.mockito - mockito-junit-jupiter - 5.12.0 - test - - - com.github.marschall - memoryfilesystem - 2.8.0 - test - - - de.elnarion.util - plantuml-generator-util - 2.4.1 - - - diff --git a/server/pom.xml b/server/pom.xml index fc7199c8..ae3521bd 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -2,15 +2,15 @@ 4.0.0 - server - 2.2.1.0-BETA - org.moparforia playforia-minigolf 2.2.1.0-BETA + server + 2.2.1.0-BETA + UTF-8 org.moparforia.server.Launcher @@ -79,8 +79,8 @@ maven-shade-plugin - plantuml-generator-maven-plugin de.elnarion.maven + plantuml-generator-maven-plugin 2.4.1 diff --git a/server/src/main/java/org/moparforia/server/Converter.java b/server/src/main/java/org/moparforia/server/Converter.java index 44b7cca8..868a07c4 100644 --- a/server/src/main/java/org/moparforia/server/Converter.java +++ b/server/src/main/java/org/moparforia/server/Converter.java @@ -1,12 +1,12 @@ package org.moparforia.server; -import org.moparforia.shared.tracks.parsers.TrackConverter; -import picocli.CommandLine; - import java.nio.file.Path; import java.util.concurrent.Callable; +import org.moparforia.shared.tracks.parsers.TrackConverter; +import picocli.CommandLine; -@CommandLine.Command(name = "convert", +@CommandLine.Command( + name = "convert", mixinStandardHelpOptions = true, description = "Converts all tracks in the folder into v2 track file versions", version = "1.0") diff --git a/server/src/main/java/org/moparforia/server/Launcher.java b/server/src/main/java/org/moparforia/server/Launcher.java index 23cd2098..2a7e55ae 100644 --- a/server/src/main/java/org/moparforia/server/Launcher.java +++ b/server/src/main/java/org/moparforia/server/Launcher.java @@ -1,20 +1,16 @@ package org.moparforia.server; -import org.moparforia.shared.ManifestVersionProvider; -import picocli.CommandLine; - import java.util.Optional; import java.util.concurrent.Callable; +import org.moparforia.shared.ManifestVersionProvider; +import picocli.CommandLine; @CommandLine.Command( description = "Starts Minigolf Server", name = "server", mixinStandardHelpOptions = true, versionProvider = ManifestVersionProvider.class, - subcommands = { - Converter.class - } -) + subcommands = {Converter.class}) public class Launcher implements Callable { public static final String DEFAULT_HOST = "0.0.0.0"; @@ -23,34 +19,28 @@ public class Launcher implements Callable { @CommandLine.Option( names = {"--hostname", "-ip"}, description = "Sets server hostname", - defaultValue = DEFAULT_HOST - ) + defaultValue = DEFAULT_HOST) private String host; @CommandLine.Option( names = {"--port", "-p"}, description = "Sets server port", - defaultValue = DEFAULT_PORT - ) + defaultValue = DEFAULT_PORT) private int port; @CommandLine.Option( names = {"--verbose", "-v"}, - description = "Sets server to log more verbosely" - ) + description = "Sets server to log more verbosely") private boolean verbose = false; @CommandLine.Option( names = {"--tracks-dir", "-t"}, - description = "Sets where to look for tracks and track sets" - ) + description = "Sets where to look for tracks and track sets") private String tracksDirectory; public static void main(String... args) { Launcher launcher = new Launcher(); - new CommandLine(launcher) - .setCaseInsensitiveEnumValuesAllowed(true) - .execute(args); + new CommandLine(launcher).setCaseInsensitiveEnumValuesAllowed(true).execute(args); } @Override diff --git a/server/src/main/java/org/moparforia/server/Server.java b/server/src/main/java/org/moparforia/server/Server.java index fd5dbbe4..00aa6a5c 100644 --- a/server/src/main/java/org/moparforia/server/Server.java +++ b/server/src/main/java/org/moparforia/server/Server.java @@ -15,16 +15,6 @@ import io.netty.handler.codec.Delimiters; import io.netty.handler.timeout.IdleStateHandler; import io.netty.util.concurrent.GlobalEventExecutor; -import org.moparforia.server.event.Event; -import org.moparforia.server.game.Lobby; -import org.moparforia.server.game.LobbyType; -import org.moparforia.server.game.Player; -import org.moparforia.server.net.*; -import org.moparforia.shared.tracks.TrackLoadException; -import org.moparforia.shared.tracks.TracksLocation; -import org.moparforia.shared.tracks.filesystem.FileSystemTrackManager; -import org.moparforia.shared.tracks.filesystem.FileSystemStatsManager; - import java.io.IOException; import java.net.InetSocketAddress; import java.net.URI; @@ -38,7 +28,15 @@ import java.util.Optional; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; - +import org.moparforia.server.event.Event; +import org.moparforia.server.game.Lobby; +import org.moparforia.server.game.LobbyType; +import org.moparforia.server.game.Player; +import org.moparforia.server.net.*; +import org.moparforia.shared.tracks.TrackLoadException; +import org.moparforia.shared.tracks.TracksLocation; +import org.moparforia.shared.tracks.filesystem.FileSystemStatsManager; +import org.moparforia.shared.tracks.filesystem.FileSystemTrackManager; public class Server implements Runnable { @@ -59,13 +57,12 @@ public class Server implements Runnable { private boolean running; private HashMap lobbies = new HashMap<>(); - //private ArrayList lobbies = new ArrayList(); - //private HashMap games = new HashMap(); + // private ArrayList lobbies = new ArrayList(); + // private HashMap games = new HashMap(); private int playerIdCounter; private int gameIdCounter; - public Server(String host, int port, boolean verbose, Optional tracksDirectory) { this.host = host; this.port = port; @@ -85,8 +82,7 @@ public int getNextGameId() { } public Lobby getLobby(LobbyType id) { - if (lobbies.containsKey(id)) - return lobbies.get(id); + if (lobbies.containsKey(id)) return lobbies.get(id); return null; } @@ -138,7 +134,8 @@ public void addChannel(Channel channel) { } /** - * This is the only method that should be called from another thread (ie, the ClientChannelHandler) + * This is the only method that should be called from another thread (ie, the + * ClientChannelHandler) */ public void addEvent(Event evt) { try { @@ -165,8 +162,7 @@ public Player getPlayer(int id) { } public void addPlayer(Player p) { - if (!players.containsValue(p)) - players.put(p.getId(), p); + if (!players.containsValue(p)) players.put(p.getId(), p); } public void start() { @@ -186,26 +182,26 @@ public void start() { EventLoopGroup bossGroup = new NioEventLoopGroup(); EventLoopGroup workerGroup = new NioEventLoopGroup(); ServerBootstrap bootstrap = new ServerBootstrap() - .group(bossGroup, workerGroup) - .channel(NioServerSocketChannel.class) - .childHandler(new ChannelInitializer() { - @Override - protected void initChannel(SocketChannel ch) { - ch.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).set(new ClientState()); - ch.pipeline() - .addLast( - new DelimiterBasedFrameDecoder(2000, Delimiters.lineDelimiter()), - new PacketDecoder(), - new PacketEncoder(Server.this.verbose), - new IdleStateHandler(2, 0, 0), - new ClientChannelHandler(Server.this) - ); - } + .group(bossGroup, workerGroup) + .channel(NioServerSocketChannel.class) + .childHandler(new ChannelInitializer() { + @Override + protected void initChannel(SocketChannel ch) { + ch.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).set(new ClientState()); + ch.pipeline() + .addLast( + new DelimiterBasedFrameDecoder(2000, Delimiters.lineDelimiter()), + new PacketDecoder(), + new PacketEncoder(Server.this.verbose), + new IdleStateHandler(2, 0, 0), + new ClientChannelHandler(Server.this)); + } }) - .childOption(ChannelOption.TCP_NODELAY, true) - .childOption(ChannelOption.SO_KEEPALIVE, true); + .childOption(ChannelOption.TCP_NODELAY, true) + .childOption(ChannelOption.SO_KEEPALIVE, true); try { - this.serverChannelFuture = bootstrap.bind(new InetSocketAddress(host, port)).sync(); + this.serverChannelFuture = + bootstrap.bind(new InetSocketAddress(host, port)).sync(); this.running = true; new Thread(this).start(); } catch (Exception ex) { @@ -234,12 +230,10 @@ public void run() { } /** - * Determines where to look for tracks. - * In order of priority: - * 1. If user has specified a tracks directory CLI flags, search for it in the default FileSystem - * 2. Else, if running in a jar file, use bundled tracks - * 3. Else, if running in an IDE, use resources folder - * 4. Else, use default filesystem and look in default directory + * Determines where to look for tracks. In order of priority: 1. If user has specified a tracks + * directory CLI flags, search for it in the default FileSystem 2. Else, if running in a jar + * file, use bundled tracks 3. Else, if running in an IDE, use resources folder 4. Else, use + * default filesystem and look in default directory */ private TracksLocation getTracksLocation() throws URISyntaxException, IOException { if (tracksDirectory.isPresent()) { diff --git a/server/src/main/java/org/moparforia/server/event/ClientConnectedEvent.java b/server/src/main/java/org/moparforia/server/event/ClientConnectedEvent.java index 9bd63476..2b415b82 100644 --- a/server/src/main/java/org/moparforia/server/event/ClientConnectedEvent.java +++ b/server/src/main/java/org/moparforia/server/event/ClientConnectedEvent.java @@ -1,9 +1,8 @@ package org.moparforia.server.event; import io.netty.channel.Channel; -import org.moparforia.server.Server; - import java.util.Random; +import org.moparforia.server.Server; public class ClientConnectedEvent extends Event { @@ -19,5 +18,4 @@ public void process(Server server) { server.addChannel(channel); channel.writeAndFlush("h 1\nc io " + new Random().nextInt(1000000000) + "\nc crt 250\nc ctr\n"); } - } diff --git a/server/src/main/java/org/moparforia/server/event/ClientDisconnectedEvent.java b/server/src/main/java/org/moparforia/server/event/ClientDisconnectedEvent.java index 69307ae5..ca59524e 100644 --- a/server/src/main/java/org/moparforia/server/event/ClientDisconnectedEvent.java +++ b/server/src/main/java/org/moparforia/server/event/ClientDisconnectedEvent.java @@ -18,11 +18,10 @@ public void process(Server server) { Player player = channel.attr(Player.PLAYER_ATTRIBUTE_KEY).get(); if (player != null) { if (player.getLobby() != null) { - player.getLobby().removePlayer(player, Lobby.PART_REASON_USERLEFT); + player.getLobby().removePlayer(player, Lobby.PART_REASON_USERLEFT); } } System.out.println("Client disconnected: " + channel); channel = null; } - } diff --git a/server/src/main/java/org/moparforia/server/event/Event.java b/server/src/main/java/org/moparforia/server/event/Event.java index 0ab12f96..f3d95f21 100644 --- a/server/src/main/java/org/moparforia/server/event/Event.java +++ b/server/src/main/java/org/moparforia/server/event/Event.java @@ -9,5 +9,4 @@ public boolean shouldProcess(Server server) { } public abstract void process(Server server); - } diff --git a/server/src/main/java/org/moparforia/server/event/PacketReceivedEvent.java b/server/src/main/java/org/moparforia/server/event/PacketReceivedEvent.java index ce76774c..70178011 100644 --- a/server/src/main/java/org/moparforia/server/event/PacketReceivedEvent.java +++ b/server/src/main/java/org/moparforia/server/event/PacketReceivedEvent.java @@ -1,12 +1,11 @@ package org.moparforia.server.event; +import java.util.ArrayList; +import java.util.regex.Matcher; import org.moparforia.server.Server; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketHandler; -import java.util.ArrayList; -import java.util.regex.Matcher; - public class PacketReceivedEvent extends Event { private final Packet packet; @@ -26,7 +25,7 @@ public void process(Server server) { private static boolean processMessage(Server server, Packet packet) { // todo: smarter, should this method be on the server class ? ArrayList handlers = server.getPacketHandlers(packet.getType()); - //todo packethandlers for each game type + // todo packethandlers for each game type boolean processed = false; if (handlers != null) for (PacketHandler ph : handlers) { @@ -37,5 +36,4 @@ private static boolean processMessage(Server server, Packet packet) { } return processed; } - } diff --git a/server/src/main/java/org/moparforia/server/event/PlayerConnectedEvent.java b/server/src/main/java/org/moparforia/server/event/PlayerConnectedEvent.java index 541c1e39..5cee2052 100644 --- a/server/src/main/java/org/moparforia/server/event/PlayerConnectedEvent.java +++ b/server/src/main/java/org/moparforia/server/event/PlayerConnectedEvent.java @@ -17,5 +17,4 @@ public void process(Server server) { System.out.println("Player connected: " + id + ", reconnecting:" + reconnecting); // todo: is this event even needed } - } diff --git a/server/src/main/java/org/moparforia/server/event/PlayerDisconnectEvent.java b/server/src/main/java/org/moparforia/server/event/PlayerDisconnectEvent.java index 7d044298..15ea1bab 100644 --- a/server/src/main/java/org/moparforia/server/event/PlayerDisconnectEvent.java +++ b/server/src/main/java/org/moparforia/server/event/PlayerDisconnectEvent.java @@ -14,7 +14,7 @@ public PlayerDisconnectEvent(int id) { public void process(Server server) { System.out.println("Player disconnected: " + id); server.getPlayers().remove(id); - // todo: some shit here like removing them from the game and notifying people in game they're gone and not just dc'd + // todo: some shit here like removing them from the game and notifying people in game + // they're gone and not just dc'd } - } diff --git a/server/src/main/java/org/moparforia/server/event/TimedEvent.java b/server/src/main/java/org/moparforia/server/event/TimedEvent.java index c3b5e93e..bbf3ee41 100644 --- a/server/src/main/java/org/moparforia/server/event/TimedEvent.java +++ b/server/src/main/java/org/moparforia/server/event/TimedEvent.java @@ -17,5 +17,4 @@ public boolean shouldProcess(Server server) { @Override public abstract void process(Server server); - } diff --git a/server/src/main/java/org/moparforia/server/game/Game.java b/server/src/main/java/org/moparforia/server/game/Game.java index 9840e381..e2dc0d88 100644 --- a/server/src/main/java/org/moparforia/server/game/Game.java +++ b/server/src/main/java/org/moparforia/server/game/Game.java @@ -1,15 +1,14 @@ package org.moparforia.server.game; import io.netty.channel.Channel; +import java.util.ArrayList; +import java.util.regex.Matcher; import org.moparforia.server.Server; import org.moparforia.server.game.gametypes.golf.MultiGame; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.ArrayList; -import java.util.regex.Matcher; - public abstract class Game extends PlayerCollection { protected final int gameId; @@ -61,10 +60,14 @@ public boolean isPublic() { } public boolean removePlayer(Player player) { - if (!hasPlayer(player)) - return false; - - writeExcluding(player, new Packet(PacketType.DATA, Tools.tabularize("game", "part", playersNumber.get(getPlayers().indexOf(player)), 4))); + if (!hasPlayer(player)) return false; + + writeExcluding( + player, + new Packet( + PacketType.DATA, + Tools.tabularize( + "game", "part", playersNumber.get(getPlayers().indexOf(player)), 4))); playersNumber.remove((Integer) getPlayerId(player)); // be wary of this... super.removePlayer(player); @@ -72,8 +75,7 @@ public boolean removePlayer(Player player) { } public boolean addPlayer(Player player) { - if (hasPlayer(player)) - return false; + if (hasPlayer(player)) return false; if (player.getLobby() != null) { int reason = Lobby.PART_REASON_STARTED_SP; // dont like this bit but important to tell the client how we're leaving lobby. @@ -97,21 +99,26 @@ public boolean addPlayer(Player player) { protected void sendJoinMessages(Player player) { sendGameInfo(player); sendPlayerNames(player); - writeExcluding(player, new Packet(PacketType.DATA, Tools.tabularize("game", "join", playerCount(), player.getNick(), player.getClan()))); - player.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("game", "owninfo", numberIndex, player.getNick(), player.getClan()))); + writeExcluding( + player, + new Packet( + PacketType.DATA, + Tools.tabularize("game", "join", playerCount(), player.getNick(), player.getClan()))); + player.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize("game", "owninfo", numberIndex, player.getNick(), player.getClan()))); } protected void sendPlayerNames(Player player) { Channel c = player.getChannel(); String playersData = Tools.tabularize("game", "players"); for (Player p : getPlayers()) { - if (!p.equals(player)) - playersData += Tools.tabularize("", getPlayerId(p), p.getNick(), p.getClan()); + if (!p.equals(player)) playersData += Tools.tabularize("", getPlayerId(p), p.getNick(), p.getClan()); } c.writeAndFlush(new Packet(PacketType.DATA, playersData)); } - protected int getFirstPlayer() { return playersNumber.get(0); } @@ -141,5 +148,4 @@ public Player playerForId(int id) { public boolean isEmpty() { return getPlayers().size() == 0; } - } diff --git a/server/src/main/java/org/moparforia/server/game/GameType.java b/server/src/main/java/org/moparforia/server/game/GameType.java index 2d0c10fb..3fdd212b 100644 --- a/server/src/main/java/org/moparforia/server/game/GameType.java +++ b/server/src/main/java/org/moparforia/server/game/GameType.java @@ -1,8 +1,10 @@ package org.moparforia.server.game; public enum GameType { - - GOLF(35), GOLF2(14), CANNONS(24), POOL(41);//, DRAW(16) + GOLF(35), + GOLF2(14), + CANNONS(24), + POOL(41); // , DRAW(16) private final int version; diff --git a/server/src/main/java/org/moparforia/server/game/Lobby.java b/server/src/main/java/org/moparforia/server/game/Lobby.java index 67d75b88..5e6af445 100644 --- a/server/src/main/java/org/moparforia/server/game/Lobby.java +++ b/server/src/main/java/org/moparforia/server/game/Lobby.java @@ -1,13 +1,12 @@ package org.moparforia.server.game; +import java.util.ArrayList; +import java.util.HashMap; import org.moparforia.server.game.gametypes.golf.MultiGame; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.ArrayList; -import java.util.HashMap; - public class Lobby extends PlayerCollection { public static final int PART_REASON_STARTED_SP = 1; // todo: enum this ? @@ -31,12 +30,10 @@ public LobbyType getLobbyType() { } public boolean removePlayer(Player player, int partReason, String... gameName) { - if (!super.removePlayer(player)) - return false; + if (!super.removePlayer(player)) return false; String cmd = Tools.tabularize("lobby", "part", player.getNick(), partReason); - if (partReason == PART_REASON_JOINED_MP && gameName != null && gameName.length == 1) - cmd += '\t' + gameName[0]; + if (partReason == PART_REASON_JOINED_MP && gameName != null && gameName.length == 1) cmd += '\t' + gameName[0]; writeAll(new Packet(PacketType.DATA, cmd)); @@ -50,23 +47,34 @@ public boolean addPlayer(Player player, int joinType) { if (player.getLobby() != null) { player.getLobby().removePlayer(player, PART_REASON_USERLEFT); } - player.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("status", "lobby", type + (player.isChatHidden() ? "h" : "")))); + player.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize("status", "lobby", type + (player.isChatHidden() ? "h" : "")))); String[] otherPlayers = new String[playerCount()]; int pointer = 0; for (Player p : getPlayers()) { - p.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize( - "lobby", joinType == JOIN_TYPE_NORMAL ? "join" : "joinfromgame", player.toString()//todo not sure if should be getNick or getGameString - ))); + p.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize( + "lobby", + joinType == JOIN_TYPE_NORMAL ? "join" : "joinfromgame", + player.toString() // todo not sure if should be + // getNick or getGameString + ))); otherPlayers[pointer++] = p.toString(); } if (pointer != 0) { - player.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "users", otherPlayers))); + player.getChannel() + .writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "users", otherPlayers))); } else { player.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "users"))); } - player.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "ownjoin", player.toString()))); + player.getChannel() + .writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "ownjoin", player.toString()))); if (getLobbyType() == LobbyType.MULTI) { sendGameList(player); } @@ -85,7 +93,9 @@ public void sendGameList(Player player) { length++; } } - player.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "full", length, buff.toString()))); + player.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, Tools.tabularize("lobby", "gamelist", "full", length, buff.toString()))); } public Game getGame(int id) { @@ -125,13 +135,12 @@ public boolean removeGame(Game g) { */ public int totalPlayerCount() { int inGames = 0; - for(Game g: games.values()) { + for (Game g : games.values()) { inGames += g.playerCount(); } return playerCount() + inGames; } - @Override public boolean equals(Object obj) { return obj != null && obj instanceof Lobby && ((Lobby) obj).getLobbyType() == this.getLobbyType(); diff --git a/server/src/main/java/org/moparforia/server/game/Player.java b/server/src/main/java/org/moparforia/server/game/Player.java index c0d83a30..ea4dddfc 100644 --- a/server/src/main/java/org/moparforia/server/game/Player.java +++ b/server/src/main/java/org/moparforia/server/game/Player.java @@ -21,7 +21,7 @@ public class Player { private String clan; private int accessLevel; private int ranking; - private boolean emailVerified;// todo or something like that maybe, find out + private boolean emailVerified; // todo or something like that maybe, find out private boolean registered; private boolean vip; private boolean sheriff; @@ -208,21 +208,20 @@ public void setGameType(GameType gameType) { } public boolean equals(Object o) { - if (o == null || !(o instanceof Player)) - return false; + if (o == null || !(o instanceof Player)) return false; Player p = (Player) o; return nick.equals(p.nick) && ranking == p.ranking && locale.equals(p.locale); } public String toString() { - String tmp = (registered ? "r" : "") + (vip ? "v" : "") + (sheriff ? "s" : "") + (notAcceptingChallenges ? "n" : ""); + String tmp = + (registered ? "r" : "") + (vip ? "v" : "") + (sheriff ? "s" : "") + (notAcceptingChallenges ? "n" : ""); return Tools.triangelize( "3:" + (nick != null ? nick : ""), tmp.equals("") ? "w" : tmp, ranking, locale != null ? locale : "", profileUrl != null ? profileUrl : "", - avatarUrl != null ? avatarUrl : "" - ); + avatarUrl != null ? avatarUrl : ""); } } diff --git a/server/src/main/java/org/moparforia/server/game/PlayerCollection.java b/server/src/main/java/org/moparforia/server/game/PlayerCollection.java index ef61b462..a72fb1ce 100644 --- a/server/src/main/java/org/moparforia/server/game/PlayerCollection.java +++ b/server/src/main/java/org/moparforia/server/game/PlayerCollection.java @@ -1,8 +1,7 @@ package org.moparforia.server.game; -import org.moparforia.server.net.Packet; - import java.util.ArrayList; +import org.moparforia.server.net.Packet; public class PlayerCollection { diff --git a/server/src/main/java/org/moparforia/server/game/gametypes/GolfGame.java b/server/src/main/java/org/moparforia/server/game/gametypes/GolfGame.java index 91ff7e04..bb57eb68 100644 --- a/server/src/main/java/org/moparforia/server/game/gametypes/GolfGame.java +++ b/server/src/main/java/org/moparforia/server/game/gametypes/GolfGame.java @@ -1,6 +1,8 @@ package org.moparforia.server.game.gametypes; import io.netty.channel.Channel; +import java.util.List; +import java.util.regex.Matcher; import org.moparforia.server.Server; import org.moparforia.server.game.Game; import org.moparforia.server.game.Lobby; @@ -16,9 +18,6 @@ import org.moparforia.shared.tracks.stats.StatsManager; import org.moparforia.shared.tracks.stats.TrackStats; -import java.util.List; -import java.util.regex.Matcher; - public abstract class GolfGame extends Game { protected static final TrackManager manager = FileSystemTrackManager.getInstance(); protected static final StatsManager statsManager = FileSystemStatsManager.getInstance(); @@ -52,11 +51,26 @@ public abstract class GolfGame extends Game { protected int currentTrack = 0; protected int strokeCounter = 0; protected int strokesThisTrack = 0; - protected String playStatus; // string where each character represents one player status. t = finished, f = not finished, p = ? - - public GolfGame(int gameId, LobbyType lobbyId, String name, String password, boolean passworded, - int numberOfTracks, int perms, int tracksType, int maxStrokes, int strokeTimeout, - int waterEvent, int collision, int trackScoring, int trackScoringEnd, int numPlayers) { + protected String playStatus; // string where each character represents one player status. t = finished, f + + // = not finished, p = ? + + public GolfGame( + int gameId, + LobbyType lobbyId, + String name, + String password, + boolean passworded, + int numberOfTracks, + int perms, + int tracksType, + int maxStrokes, + int strokeTimeout, + int waterEvent, + int collision, + int trackScoring, + int trackScoringEnd, + int numPlayers) { super(gameId, lobbyId, name, password, passworded); this.numberOfTracks = numberOfTracks; this.perms = perms; @@ -71,16 +85,14 @@ public GolfGame(int gameId, LobbyType lobbyId, String name, String password, boo this.playerStrokesThisTrack = new int[numPlayers]; this.playerStrokesTotal = new int[numPlayers]; tracks = initTracks(); - } - public abstract List initTracks(); @Override public boolean handlePacket(Server server, Player player, Matcher message) { if (message.group(1).equals("beginstroke")) { - //beginstroke\t7sw8 + // beginstroke\t7sw8 String mouseCoords = message.group(2); beginStroke(player, mouseCoords); @@ -88,11 +100,13 @@ public boolean handlePacket(Server server, Player player, Matcher message) { endStroke(player, message.group(3)); // 999 dirty hack here due to regex borking itself, keep "voteski" - } else if (message.group(1).equals("voteskip") || message.group(1).equals("voteski") - || message.group(1).equals("skip") || message.group(1).equals("ski")) { + } else if (message.group(1).equals("voteskip") + || message.group(1).equals("voteski") + || message.group(1).equals("skip") + || message.group(1).equals("ski")) { voteSkip(player); } else if (message.group(1).contains("rate")) { - rateTrack(message.group(2)); //todo: fix the matcher bs, does not work properly here + rateTrack(message.group(2)); // todo: fix the matcher bs, does not work properly here } else if (message.group(1).equals("newgame")) { wantsNewGame(player); } else if (message.group(1).equals("back")) { @@ -118,15 +132,16 @@ protected void reset() { tracks = initTracks(); } - public void startGame() { writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "start"))); StringBuilder buff = new StringBuilder(); buff.append("t".repeat(getPlayers().size())); playStatus = buff.toString().replace("t", "f"); - TrackStats track = statsManager.getStats(tracks.get(0)); + TrackStats track = statsManager.getStats(tracks.get(0)); writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "resetvoteskip"))); - writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "starttrack", buff.toString(), gameId, track.networkSerialize()))); + writeAll(new Packet( + PacketType.DATA, + Tools.tabularize("game", "starttrack", buff.toString(), gameId, track.networkSerialize()))); writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "startturn", 0))); } @@ -134,16 +149,30 @@ public void rateTrack(String rating) { statsManager.rate(getCurrentTrack(), Integer.parseInt(rating)); } - public void sendGameInfo(Player player) { Channel c = player.getChannel(); c.writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("status", "game"))); - c.writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("game", "gameinfo", - name, passworded ? "t" : "f", gameId, numPlayers, tracks.size(), - tracksType, maxStrokes, strokeTimeout, waterEvent, collision, trackScoring, - trackScoringEnd, "f"))); + c.writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize( + "game", + "gameinfo", + name, + passworded ? "t" : "f", + gameId, + numPlayers, + tracks.size(), + tracksType, + maxStrokes, + strokeTimeout, + waterEvent, + collision, + trackScoring, + trackScoringEnd, + "f"))); // Conn.writeD(session, "game", "gameinfo", name, "t", gameId, playerCount, - // numberOfTracks, trackType, maxStrokes, strokeTimeout, water, collision, scoreSystem, weightEnd, "f"); + // numberOfTracks, trackType, maxStrokes, strokeTimeout, water, collision, + // scoreSystem, weightEnd, "f"); } public void endStroke(Player p, String playStatus) { @@ -163,7 +192,7 @@ public void endStroke(Player p, String playStatus) { confirmCount++; // only sends the command after everyone confirms end stroke. if (confirmCount == getPlayers().size()) { - playerStrokesThisTrack[ strokeCounter % getPlayers().size()] += 1; + playerStrokesThisTrack[strokeCounter % getPlayers().size()] += 1; confirmCount = 0; if (finished) { nextTrack(); @@ -171,28 +200,22 @@ public void endStroke(Player p, String playStatus) { writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "startturn", getNextPlayer(playStatus)))); } } - } protected int getNextPlayer(String playStatus) { strokeCounter++; int player = strokeCounter % getPlayers().size(); - if (playStatus.charAt(player) == 't') { // if this player has already finihed + if (playStatus.charAt(player) == 't') { // if this player has already finihed getNextPlayer(playStatus); } - return playersNumber.get(strokeCounter % getPlayers().size()); } - protected void updateStats() { - getPlayers().stream() - .filter(p -> !p.hasSkipped()) - .forEach(player -> { - statsManager.addScore(getCurrentTrack(), player.getNick(), playerStrokesThisTrack[getPlayerId(player)]); - }); - + getPlayers().stream().filter(p -> !p.hasSkipped()).forEach(player -> { + statsManager.addScore(getCurrentTrack(), player.getNick(), playerStrokesThisTrack[getPlayerId(player)]); + }); } protected void nextTrack() { @@ -212,7 +235,9 @@ protected void nextTrack() { } playStatus = buff.toString().replace("t", "f"); writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "resetvoteskip"))); - writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "starttrack", buff.toString(), gameId, track.networkSerialize()))); + writeAll(new Packet( + PacketType.DATA, + Tools.tabularize("game", "starttrack", buff.toString(), gameId, track.networkSerialize()))); writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "startturn", getFirstPlayer()))); } else { endGame(); @@ -223,7 +248,6 @@ public int getFirstPlayer() { return (strokeCounter += currentTrack % playerCount()); } - public void voteSkip(Player p) { p.setSkipped(true); writeExcluding(p, new Packet(PacketType.DATA, Tools.tabularize("game", "voteskip", getPlayerId(p)))); @@ -246,22 +270,36 @@ public void voteSkip(Player p) { buff.append(playerStrokesThisTrack[id]).append("\t"); } if (needsChange && playerCount() > 1 && numberOfSkippers < playerCount()) { - writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "changescore", currentTrack, buff.toString()))); + writeAll(new Packet( + PacketType.DATA, Tools.tabularize("game", "changescore", currentTrack, buff.toString()))); } nextTrack(); } public void beginStroke(Player p, String mouseCoords) { - //todo: anti cheat mechanisms! - writeExcluding(p, new Packet(PacketType.DATA, Tools.tabularize("game", "beginstroke", getPlayerId(p), mouseCoords))); - + // todo: anti cheat mechanisms! + writeExcluding( + p, new Packet(PacketType.DATA, Tools.tabularize("game", "beginstroke", getPlayerId(p), mouseCoords))); } public String getGameString() { - return Tools.tabularize(gameId, name, passworded ? "t" : "f", perms, - numPlayers, -1, tracks.size(), tracksType, maxStrokes, strokeTimeout, - waterEvent, collision, trackScoring, trackScoringEnd, getPlayers().size()); + return Tools.tabularize( + gameId, + name, + passworded ? "t" : "f", + perms, + numPlayers, + -1, + tracks.size(), + tracksType, + maxStrokes, + strokeTimeout, + waterEvent, + collision, + trackScoring, + trackScoringEnd, + getPlayers().size()); } private Track getCurrentTrack() { diff --git a/server/src/main/java/org/moparforia/server/game/gametypes/golf/ChampionshipGame.java b/server/src/main/java/org/moparforia/server/game/gametypes/golf/ChampionshipGame.java index 03e26fe3..ddcc57f8 100644 --- a/server/src/main/java/org/moparforia/server/game/gametypes/golf/ChampionshipGame.java +++ b/server/src/main/java/org/moparforia/server/game/gametypes/golf/ChampionshipGame.java @@ -1,22 +1,34 @@ package org.moparforia.server.game.gametypes.golf; -import org.moparforia.shared.tracks.Track; +import java.util.List; import org.moparforia.server.game.Lobby; import org.moparforia.server.game.LobbyType; import org.moparforia.server.game.Player; import org.moparforia.server.game.gametypes.GolfGame; +import org.moparforia.shared.tracks.Track; import org.moparforia.shared.tracks.filesystem.FileSystemTrackManager; -import java.util.List; - public class ChampionshipGame extends GolfGame { private int championshipId; public ChampionshipGame(Player p, int gameId, int championshipId) { - super(gameId, LobbyType.SINGLE, "derp", null, false, 10, - PERM_EVERYONE, 0, STROKES_UNLIMITED, STROKETIMEOUT_INFINITE, - WATER_START, COLLSION_YES, SCORING_STROKE, SCORING_WEIGHT_END_NONE, 1); + super( + gameId, + LobbyType.SINGLE, + "derp", + null, + false, + 10, + PERM_EVERYONE, + 0, + STROKES_UNLIMITED, + STROKETIMEOUT_INFINITE, + WATER_START, + COLLSION_YES, + SCORING_STROKE, + SCORING_WEIGHT_END_NONE, + 1); this.championshipId = championshipId; tracks = initTracks(); @@ -25,7 +37,7 @@ public ChampionshipGame(Player p, int gameId, int championshipId) { lob.addGame(this); startGame(); } else { - //todo: if adding da player failed init!! + // todo: if adding da player failed init!! } } diff --git a/server/src/main/java/org/moparforia/server/game/gametypes/golf/DualGame.java b/server/src/main/java/org/moparforia/server/game/gametypes/golf/DualGame.java index 1bdf8739..4f5a768d 100644 --- a/server/src/main/java/org/moparforia/server/game/gametypes/golf/DualGame.java +++ b/server/src/main/java/org/moparforia/server/game/gametypes/golf/DualGame.java @@ -1,31 +1,63 @@ package org.moparforia.server.game.gametypes.golf; -import org.moparforia.shared.tracks.Track; +import java.util.List; import org.moparforia.server.game.LobbyType; import org.moparforia.server.game.Player; import org.moparforia.server.game.gametypes.GolfGame; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketType; -import org.moparforia.shared.tracks.TrackCategory; import org.moparforia.shared.Tools; - -import java.util.List; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.TrackCategory; public class DualGame extends GolfGame { private boolean started; - public DualGame(Player challenger, Player challenged, int gameId, int numberOfTracks, - int tracksType, int maxStrokes, int strokeTimeout, int waterEvent, - int collision, int trackScoring, int trackScoringEnd) { - super(gameId, LobbyType.DUAL, "dualgame-" + (int) (Math.random() * 10000), null, - false, numberOfTracks, -1, tracksType, - maxStrokes, strokeTimeout, waterEvent, collision, - trackScoring, trackScoringEnd, 2); - challenged.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("lobby", "challenge", challenger.getNick(), numberOfTracks, - tracksType, maxStrokes, strokeTimeout, waterEvent, - collision, trackScoring, trackScoringEnd))); + public DualGame( + Player challenger, + Player challenged, + int gameId, + int numberOfTracks, + int tracksType, + int maxStrokes, + int strokeTimeout, + int waterEvent, + int collision, + int trackScoring, + int trackScoringEnd) { + super( + gameId, + LobbyType.DUAL, + "dualgame-" + (int) (Math.random() * 10000), + null, + false, + numberOfTracks, + -1, + tracksType, + maxStrokes, + strokeTimeout, + waterEvent, + collision, + trackScoring, + trackScoringEnd, + 2); + challenged + .getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize( + "lobby", + "challenge", + challenger.getNick(), + numberOfTracks, + tracksType, + maxStrokes, + strokeTimeout, + waterEvent, + collision, + trackScoring, + trackScoringEnd))); addPlayer(challenger); challenger.getLobby().addGame(this); } @@ -37,14 +69,12 @@ public List initTracks() { @Override public void sendJoinMessages(Player player) { - if (started) - super.sendJoinMessages(player); + if (started) super.sendJoinMessages(player); } public void start() { startGame(); started = true; - for (Player p : getPlayers()) - sendJoinMessages(p); + for (Player p : getPlayers()) sendJoinMessages(p); } } diff --git a/server/src/main/java/org/moparforia/server/game/gametypes/golf/MultiGame.java b/server/src/main/java/org/moparforia/server/game/gametypes/golf/MultiGame.java index a58b88f2..9b2b9ec6 100644 --- a/server/src/main/java/org/moparforia/server/game/gametypes/golf/MultiGame.java +++ b/server/src/main/java/org/moparforia/server/game/gametypes/golf/MultiGame.java @@ -1,5 +1,7 @@ package org.moparforia.server.game.gametypes.golf; +import java.util.Arrays; +import java.util.List; import org.moparforia.server.game.Lobby; import org.moparforia.server.game.LobbyType; import org.moparforia.server.game.Player; @@ -10,46 +12,77 @@ import org.moparforia.shared.tracks.Track; import org.moparforia.shared.tracks.TrackCategory; -import java.util.Arrays; -import java.util.List; - public class MultiGame extends GolfGame { - - public MultiGame(Player p, int gameId, String name, String password, int numberOfTracks, - int perms, int tracksType, int maxStrokes, int strokeTimeout, - int waterEvent, int collision, int trackScoring, int trackScoringEnd, - int numPlayers) { - - super(gameId, LobbyType.MULTI, name, password, password.equals("-") || password.equals("") ? false : true, - numberOfTracks, perms, tracksType, maxStrokes, strokeTimeout, - waterEvent, collision, trackScoring, trackScoringEnd, numPlayers); + public MultiGame( + Player p, + int gameId, + String name, + String password, + int numberOfTracks, + int perms, + int tracksType, + int maxStrokes, + int strokeTimeout, + int waterEvent, + int collision, + int trackScoring, + int trackScoringEnd, + int numPlayers) { + + super( + gameId, + LobbyType.MULTI, + name, + password, + password.equals("-") || password.equals("") ? false : true, + numberOfTracks, + perms, + tracksType, + maxStrokes, + strokeTimeout, + waterEvent, + collision, + trackScoring, + trackScoringEnd, + numPlayers); addPlayer(p, password); - p.getLobby().writeAll(new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "add", getGameString()))); + p.getLobby() + .writeAll(new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "add", getGameString()))); p.getLobby().addGame(this); } - public boolean addPlayer(Player player, String pass) { Lobby lobby = player.getLobby(); if (passworded && (!pass.equals(this.password))) { - lobby.addPlayer(player, Lobby.JOIN_TYPE_FROMGAME); // LOL YOU GOT THE PASSWORD WRONG BACK TO THE LOBBY U GO + lobby.addPlayer(player, Lobby.JOIN_TYPE_FROMGAME); // LOL YOU GOT THE PASSWORD WRONG BACK TO THE + // LOBBY U GO return false; } else { // correct password or no password - writeAll(new Packet(PacketType.DATA, Tools.tabularize("game", "join", playerCount(), player.getNick(), player.getClan()))); // important this happens before players added. + writeAll(new Packet( + PacketType.DATA, + Tools.tabularize( + "game", + "join", + playerCount(), + player.getNick(), + player.getClan()))); // important this happens before players + // added. super.addPlayer(player); if (playerCount() > 1) { // if this is not the first player, update list. - lobby.writeAll(new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "change", getGameString()))); + lobby.writeAll( + new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "change", getGameString()))); } if (numPlayers == playerCount()) { // if game filled up, start!! isPublic = false; - lobby.writeAll(new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "remove", getGameId()))); + lobby.writeAll( + new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "remove", getGameId()))); startGame(); } return true; @@ -65,7 +98,9 @@ public boolean removePlayer(Player player) { } } else { // if game is empty, remove from list init!1!1! - player.getLobby().writeAll(new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "remove", getGameId()))); + player.getLobby() + .writeAll( + new Packet(PacketType.DATA, Tools.tabularize("lobby", "gamelist", "remove", getGameId()))); } return true; } @@ -92,22 +127,23 @@ public List initTracks() { return manager.getRandomTracks(numberOfTracks, TrackCategory.getByTypeId(tracksType)); } - /** - * 1 == winner - * 0 == draw - * -1 == loser - */ + /** 1 == winner 0 == draw -1 == loser */ private int[] getStrokeScoringWinner() { int minStrokes = Arrays.stream(this.playerStrokesTotal).min().orElse(0); - boolean draw = Arrays.stream(this.playerStrokesTotal).filter(strokes -> strokes == minStrokes).count() > 1; - return Arrays.stream(this.playerStrokesTotal).map(strokes -> { - if (draw && strokes == minStrokes) { - return 0; - } else if (strokes == minStrokes) { - return 1; - } else { - return -1; - } - }).toArray(); + boolean draw = Arrays.stream(this.playerStrokesTotal) + .filter(strokes -> strokes == minStrokes) + .count() + > 1; + return Arrays.stream(this.playerStrokesTotal) + .map(strokes -> { + if (draw && strokes == minStrokes) { + return 0; + } else if (strokes == minStrokes) { + return 1; + } else { + return -1; + } + }) + .toArray(); } } diff --git a/server/src/main/java/org/moparforia/server/game/gametypes/golf/TrainingGame.java b/server/src/main/java/org/moparforia/server/game/gametypes/golf/TrainingGame.java index 827f8455..7e9ce791 100644 --- a/server/src/main/java/org/moparforia/server/game/gametypes/golf/TrainingGame.java +++ b/server/src/main/java/org/moparforia/server/game/gametypes/golf/TrainingGame.java @@ -1,20 +1,32 @@ package org.moparforia.server.game.gametypes.golf; -import org.moparforia.shared.tracks.Track; +import java.util.List; import org.moparforia.server.game.Lobby; import org.moparforia.server.game.LobbyType; import org.moparforia.server.game.Player; import org.moparforia.server.game.gametypes.GolfGame; +import org.moparforia.shared.tracks.Track; import org.moparforia.shared.tracks.TrackCategory; -import java.util.List; - public class TrainingGame extends GolfGame { public TrainingGame(Player p, int gameId, int tracksType, int numberOfTracks, int water) { - super(gameId, LobbyType.SINGLE, "derp", null, false, numberOfTracks, - PERM_EVERYONE, tracksType, STROKES_UNLIMITED, STROKETIMEOUT_INFINITE, - water, COLLSION_YES, SCORING_STROKE, SCORING_WEIGHT_END_NONE, 1); + super( + gameId, + LobbyType.SINGLE, + "derp", + null, + false, + numberOfTracks, + PERM_EVERYONE, + tracksType, + STROKES_UNLIMITED, + STROKETIMEOUT_INFINITE, + water, + COLLSION_YES, + SCORING_STROKE, + SCORING_WEIGHT_END_NONE, + 1); Lobby lob = p.getLobby(); if (addPlayer(p)) { @@ -22,7 +34,7 @@ public TrainingGame(Player p, int gameId, int tracksType, int numberOfTracks, in startGame(); } else { - //todo: if adding da player failed init!! + // todo: if adding da player failed init!! } } diff --git a/server/src/main/java/org/moparforia/server/net/ClientChannelHandler.java b/server/src/main/java/org/moparforia/server/net/ClientChannelHandler.java index 1e06f2d3..82040874 100644 --- a/server/src/main/java/org/moparforia/server/net/ClientChannelHandler.java +++ b/server/src/main/java/org/moparforia/server/net/ClientChannelHandler.java @@ -21,7 +21,10 @@ public ClientChannelHandler(Server server) { public void channelRead(ChannelHandlerContext ctx, Object msg) { Packet packet = (Packet) msg; System.out.println("<<< " + packet); - ctx.channel().attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get().setLastActivityTime(System.currentTimeMillis()); + ctx.channel() + .attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY) + .get() + .setLastActivityTime(System.currentTimeMillis()); server.addEvent(new PacketReceivedEvent(packet)); } @@ -29,7 +32,9 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) { public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { if (evt instanceof IdleStateEvent e) { if (e.state() == IdleState.READER_IDLE) { - ClientState state = ctx.channel().attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get(); + ClientState state = ctx.channel() + .attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY) + .get(); long time = System.currentTimeMillis() - state.getLastActivityTime(); if (time > 20000) { ctx.channel().close(); @@ -58,15 +63,17 @@ public void channelInactive(ChannelHandlerContext ctx) { Player player = channel.attr(Player.PLAYER_ATTRIBUTE_KEY).get(); if (player != null && server.hasPlayer(player.getId())) { int id = player.getId(); - server.addEvent(new TimedEvent(30_000) { // todo: confirm this time - @Override - public void process(Server server) { - if (server.hasPlayer(id) && !server.getPlayer(id).getChannel().isOpen()) { - System.out.println("Player timed-out: " + id); - server.addEvent(new PlayerDisconnectEvent(id)); - } - } - }); + server.addEvent( + new TimedEvent(30_000) { // todo: confirm this time + @Override + public void process(Server server) { + if (server.hasPlayer(id) + && !server.getPlayer(id).getChannel().isOpen()) { + System.out.println("Player timed-out: " + id); + server.addEvent(new PlayerDisconnectEvent(id)); + } + } + }); } } } diff --git a/server/src/main/java/org/moparforia/server/net/ClientState.java b/server/src/main/java/org/moparforia/server/net/ClientState.java index 863fe2b4..d1702cc9 100644 --- a/server/src/main/java/org/moparforia/server/net/ClientState.java +++ b/server/src/main/java/org/moparforia/server/net/ClientState.java @@ -1,9 +1,7 @@ package org.moparforia.server.net; - import io.netty.util.AttributeKey; - public final class ClientState { public static final AttributeKey CLIENT_STATE_ATTRIBUTE_KEY = AttributeKey.valueOf("MESSAGE_COUNTS"); diff --git a/server/src/main/java/org/moparforia/server/net/Packet.java b/server/src/main/java/org/moparforia/server/net/Packet.java index 7cab2b38..aeb47c65 100644 --- a/server/src/main/java/org/moparforia/server/net/Packet.java +++ b/server/src/main/java/org/moparforia/server/net/Packet.java @@ -61,12 +61,16 @@ public String getMessage() { @Override public String toString() { - return "Packet{" + - "channel=" + channel + - ", type=" + type + - ", count=" + count + - ", message='" + message.replace("\t", "\\t") + '\'' + - '}'; + return "Packet{" + + "channel=" + + channel + + ", type=" + + type + + ", count=" + + count + + ", message='" + + message.replace("\t", "\\t") + + '\'' + + '}'; } - } diff --git a/server/src/main/java/org/moparforia/server/net/PacketDecoder.java b/server/src/main/java/org/moparforia/server/net/PacketDecoder.java index bf1438ed..9cd94d95 100644 --- a/server/src/main/java/org/moparforia/server/net/PacketDecoder.java +++ b/server/src/main/java/org/moparforia/server/net/PacketDecoder.java @@ -5,7 +5,6 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.ByteToMessageDecoder; import io.netty.util.CharsetUtil; - import java.util.List; public class PacketDecoder extends ByteToMessageDecoder { @@ -14,7 +13,8 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List out) { Channel channel = ctx.channel(); Packet packet = new Packet(channel, in.readBytes(in.readableBytes()).toString(CharsetUtil.UTF_8)); if (packet.getType() == PacketType.DATA) { - long count = channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get().getReceivedCount(); + long count = + channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get().getReceivedCount(); if (count == packet.getCount()) { channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get().setReceivedCount(count + 1); } else { diff --git a/server/src/main/java/org/moparforia/server/net/PacketEncoder.java b/server/src/main/java/org/moparforia/server/net/PacketEncoder.java index 04ce0ff7..9904d7e6 100644 --- a/server/src/main/java/org/moparforia/server/net/PacketEncoder.java +++ b/server/src/main/java/org/moparforia/server/net/PacketEncoder.java @@ -1,13 +1,13 @@ package org.moparforia.server.net; +import static io.netty.buffer.Unpooled.copiedBuffer; + import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import io.netty.handler.codec.MessageToByteEncoder; import io.netty.util.CharsetUtil; -import static io.netty.buffer.Unpooled.copiedBuffer; - public class PacketEncoder extends MessageToByteEncoder { private final boolean verbose; @@ -24,7 +24,9 @@ protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) { if (packet.getType() != PacketType.NONE) { encoded = packet.getType().toString().toLowerCase().charAt(0) + " "; if (packet.getType() == PacketType.DATA) { - long count = channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get().getSentCount(); + long count = channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY) + .get() + .getSentCount(); encoded += count + " "; channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get().setSentCount(count + 1); } @@ -41,7 +43,9 @@ protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) { m += "\n"; } if (m.startsWith("d ")) { - long count = channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get().getSentCount(); + long count = channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY) + .get() + .getSentCount(); m = "d " + count + " " + m.substring(2); channel.attr(ClientState.CLIENT_STATE_ATTRIBUTE_KEY).get().setSentCount(count + 1); } diff --git a/server/src/main/java/org/moparforia/server/net/PacketHandler.java b/server/src/main/java/org/moparforia/server/net/PacketHandler.java index 73708258..43324688 100644 --- a/server/src/main/java/org/moparforia/server/net/PacketHandler.java +++ b/server/src/main/java/org/moparforia/server/net/PacketHandler.java @@ -1,9 +1,8 @@ package org.moparforia.server.net; -import org.moparforia.server.Server; - import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.moparforia.server.Server; public interface PacketHandler { public PacketType getType(); diff --git a/server/src/main/java/org/moparforia/server/net/PacketHandlerFactory.java b/server/src/main/java/org/moparforia/server/net/PacketHandlerFactory.java index 5b24a7db..c8bb188f 100644 --- a/server/src/main/java/org/moparforia/server/net/PacketHandlerFactory.java +++ b/server/src/main/java/org/moparforia/server/net/PacketHandlerFactory.java @@ -1,21 +1,35 @@ package org.moparforia.server.net; -import org.moparforia.server.net.packethandlers.*; -import org.moparforia.server.net.packethandlers.golf.*; - import java.util.ArrayList; import java.util.HashMap; +import org.moparforia.server.net.packethandlers.*; +import org.moparforia.server.net.packethandlers.golf.*; public class PacketHandlerFactory { - //todo packethandlers for each game type ( should be pretty much the same for golf and golf2 ) + // todo packethandlers for each game type ( should be pretty much the same for golf and golf2 ) public static final HashMap> getPacketHandlers() { - PacketHandler[] handlers = new PacketHandler[]{new ChatHandler(), new GameHandler(), - new LanguageHandler(), new LobbyHandler(), new LobbySelectHandler(), new LoginHandler(), - new LoginTypeHandler(), new NewHandler(), new PongHandler(), new ReconnectHandler(), - new TlogHandler(), new TrackTestLoginHandler(), new VersionHandler(), new LobbyCreateSinglePlayerHandler(), - new LobbyMultiplayerHandler(), new LobbyDualplayerHandler(), new QuitHandler(), new ErrorDebugHandler(), - new EndHandler()}; + PacketHandler[] handlers = new PacketHandler[] { + new ChatHandler(), + new GameHandler(), + new LanguageHandler(), + new LobbyHandler(), + new LobbySelectHandler(), + new LoginHandler(), + new LoginTypeHandler(), + new NewHandler(), + new PongHandler(), + new ReconnectHandler(), + new TlogHandler(), + new TrackTestLoginHandler(), + new VersionHandler(), + new LobbyCreateSinglePlayerHandler(), + new LobbyMultiplayerHandler(), + new LobbyDualplayerHandler(), + new QuitHandler(), + new ErrorDebugHandler(), + new EndHandler() + }; ArrayList data = new ArrayList<>(); ArrayList command = new ArrayList<>(); ArrayList string = new ArrayList<>(); diff --git a/server/src/main/java/org/moparforia/server/net/PacketType.java b/server/src/main/java/org/moparforia/server/net/PacketType.java index 6e4f4fda..a2d919c3 100644 --- a/server/src/main/java/org/moparforia/server/net/PacketType.java +++ b/server/src/main/java/org/moparforia/server/net/PacketType.java @@ -1,5 +1,8 @@ package org.moparforia.server.net; public enum PacketType { - DATA, STRING, COMMAND, NONE + DATA, + STRING, + COMMAND, + NONE } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/EndHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/EndHandler.java index 8ae9f48c..8d68e799 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/EndHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/EndHandler.java @@ -1,16 +1,12 @@ package org.moparforia.server.net.packethandlers; -import io.netty.channel.Channel; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; -import org.moparforia.server.event.PlayerConnectedEvent; -import org.moparforia.server.game.Player; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class EndHandler implements PacketHandler { @Override @@ -27,5 +23,4 @@ public Pattern getPattern() { public boolean handle(Server server, Packet packet, Matcher message) { return true; } - } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/ErrorDebugHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/ErrorDebugHandler.java index 4e19192e..9c700a11 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/ErrorDebugHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/ErrorDebugHandler.java @@ -1,14 +1,13 @@ package org.moparforia.server.net.packethandlers; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Player; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class ErrorDebugHandler implements PacketHandler { @Override public PacketType getType() { @@ -16,7 +15,9 @@ public PacketType getType() { } @Override - // error-debug\t4\tjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1\tgame\starttrack\t\0\V 1\A Dewlor\N Witch\T BAQQ48DEBGAQB3ADBAHA15DBWJHBAJA6DEB3ABAKA10DBABB3DBAKADB3AEEB3ADDE15DEE6D3E10DE3DED4ECBAEBLAQBAQQ7DE6DEE6D3E10DE3DED4E9DBHAQEE6DEE6D3E10DEDDBKABED3EBFAQE9DEE6DEE6D3E10DEBIBAB3ADED3E7DBNAQEDDEE6DEE6D3E10DEB3ADDED3EBGAQH9DEE6DBAQQE6D3E10DEEDDED3EB3A10DEE6DEE6D3E10DEEDDED4EDDBIAQBAQQDDBJAQEDDEE6DEE6D3E10DBOABEDDED4EDDBLAQEDDBKAQEDDEE6DEE6D3E10DB3A3DED4E10DEE6DEE6D3E10DE3DED4E9DBKQAEE6DEE6D3E10DE3DED3EBAIADDBPIQBAQQ7DI6DEG6D3E10DE3DED4E9DBJQIEE6DEE6D3E10DE3DED4E10DEE6DEE6D3E10DBMAMEDDED4E10DEE6DEE6D3E10DBAMMEDDED4E10DEE6DEE6D3E10DEEDDED4E10DBLIQE6DEE6DBLKQF7DBNKQEDDEEDDED4E11DE6DEE6DBAKA12DEBLMAEDED4E11DE6DEE6DE12DEDDBJAMED4E11DE6DEE6DE12DE3DEDCAA3E10DBKAIE6DEE6DE12DE3DEDHEEB3A17DBKQAEBLQAE5DE12DE3DED3E48D,Ads:B2220\I 64508,788552,2,66\B pot-shot,1138226400000\R 286,75,80,115,127,505,377,368,266,166,1108\tgame\resetvoteskip\tgame\voteskip + // error-debug\t4\tjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length + // 1\tgame\starttrack\t\0\V 1\A Dewlor\N Witch\T + // BAQQ48DEBGAQB3ADBAHA15DBWJHBAJA6DEB3ABAKA10DBABB3DBAKADB3AEEB3ADDE15DEE6D3E10DE3DED4ECBAEBLAQBAQQ7DE6DEE6D3E10DE3DED4E9DBHAQEE6DEE6D3E10DEDDBKABED3EBFAQE9DEE6DEE6D3E10DEBIBAB3ADED3E7DBNAQEDDEE6DEE6D3E10DEB3ADDED3EBGAQH9DEE6DBAQQE6D3E10DEEDDED3EB3A10DEE6DEE6D3E10DEEDDED4EDDBIAQBAQQDDBJAQEDDEE6DEE6D3E10DBOABEDDED4EDDBLAQEDDBKAQEDDEE6DEE6D3E10DB3A3DED4E10DEE6DEE6D3E10DE3DED4E9DBKQAEE6DEE6D3E10DE3DED3EBAIADDBPIQBAQQ7DI6DEG6D3E10DE3DED4E9DBJQIEE6DEE6D3E10DE3DED4E10DEE6DEE6D3E10DBMAMEDDED4E10DEE6DEE6D3E10DBAMMEDDED4E10DEE6DEE6D3E10DEEDDED4E10DBLIQE6DEE6DBLKQF7DBNKQEDDEEDDED4E11DE6DEE6DBAKA12DEBLMAEDED4E11DE6DEE6DE12DEDDBJAMED4E11DE6DEE6DE12DE3DEDCAA3E10DBKAIE6DEE6DE12DE3DEDHEEB3A17DBKQAEBLQAE5DE12DE3DED3E48D,Ads:B2220\I 64508,788552,2,66\B pot-shot,1138226400000\R 286,75,80,115,127,505,377,368,266,166,1108\tgame\resetvoteskip\tgame\voteskip public Pattern getPattern() { return Pattern.compile("error-debug\\t(\\d)\\t(.*)\\t(.*)\\t(.*)\\t(.*)"); } @@ -29,7 +30,20 @@ public boolean handle(Server server, Packet packet, Matcher message) { String lastPacketSentToClient = message.group(3); String secondLastPacketSentToClient = message.group(4); String lastPacketReceivedFromClient = message.group(5); - System.out.println("Fatal error for player '" + player.getNick() + "' (id " + player.getId() + "): " + errorMessage + ", activePanel: " + activePanel + ", lastPacketSentToClient: " + lastPacketSentToClient + ", secondLastPacketSentToClient: " + secondLastPacketSentToClient + ", lastPacketReceivedFromClient: " + lastPacketReceivedFromClient); + System.out.println("Fatal error for player '" + + player.getNick() + + "' (id " + + player.getId() + + "): " + + errorMessage + + ", activePanel: " + + activePanel + + ", lastPacketSentToClient: " + + lastPacketSentToClient + + ", secondLastPacketSentToClient: " + + secondLastPacketSentToClient + + ", lastPacketReceivedFromClient: " + + lastPacketReceivedFromClient); return true; } } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/NewHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/NewHandler.java index f63ffb0c..9f047ce6 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/NewHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/NewHandler.java @@ -1,6 +1,8 @@ package org.moparforia.server.net.packethandlers; import io.netty.channel.Channel; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.event.PlayerConnectedEvent; import org.moparforia.server.game.Player; @@ -8,9 +10,6 @@ import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class NewHandler implements PacketHandler { @Override @@ -34,5 +33,4 @@ public boolean handle(Server server, Packet packet, Matcher message) { server.addEvent(new PlayerConnectedEvent(player.getId(), false)); return true; } - } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/PongHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/PongHandler.java index 771c9ae4..6ea57e96 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/PongHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/PongHandler.java @@ -1,13 +1,12 @@ package org.moparforia.server.net.packethandlers; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class PongHandler implements PacketHandler { @Override @@ -24,5 +23,4 @@ public Pattern getPattern() { public boolean handle(Server server, Packet packet, Matcher message) { return true; } - } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/QuitHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/QuitHandler.java index b229a61b..5f634e39 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/QuitHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/QuitHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Lobby; import org.moparforia.server.game.Player; @@ -7,9 +9,6 @@ import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class QuitHandler implements PacketHandler { @Override public PacketType getType() { diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/ReconnectHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/ReconnectHandler.java index 8524f767..bbf34ac5 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/ReconnectHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/ReconnectHandler.java @@ -1,6 +1,8 @@ package org.moparforia.server.net.packethandlers; import io.netty.channel.Channel; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.event.PlayerConnectedEvent; import org.moparforia.server.game.Player; @@ -8,9 +10,6 @@ import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class ReconnectHandler implements PacketHandler { @Override @@ -26,8 +25,7 @@ public Pattern getPattern() { @Override public boolean handle(Server server, Packet packet, Matcher message) { int id = Integer.valueOf(message.group(1)); - if (!server.hasPlayer(id)) - packet.getChannel().close(); + if (!server.hasPlayer(id)) packet.getChannel().close(); else { Player p = server.getPlayer(id); Channel c = packet.getChannel(); @@ -38,5 +36,4 @@ public boolean handle(Server server, Packet packet, Matcher message) { } return true; } - } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/TlogHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/TlogHandler.java index 7c21b77a..f51a8ab5 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/TlogHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/TlogHandler.java @@ -1,13 +1,12 @@ package org.moparforia.server.net.packethandlers; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class TlogHandler implements PacketHandler { @Override @@ -24,5 +23,4 @@ public Pattern getPattern() { public boolean handle(Server server, Packet packet, Matcher message) { return true; } - } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/VersionHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/VersionHandler.java index 854befac..f76617cd 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/VersionHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/VersionHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.GameType; import org.moparforia.server.game.Player; @@ -8,9 +10,6 @@ import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class VersionHandler implements PacketHandler { @Override @@ -32,10 +31,9 @@ public boolean handle(Server server, Packet packet, Matcher message) { } Player player = packet.getChannel().attr(Player.PLAYER_ATTRIBUTE_KEY).get(); player.setGameType(gameType); - if(gameType == GameType.GOLF) { + if (gameType == GameType.GOLF) { player.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("status", "login"))); - }//todo + } // todo return true; } - } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/ChatHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/ChatHandler.java index c212f871..405db6ed 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/ChatHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/ChatHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Game; import org.moparforia.server.game.Player; @@ -9,9 +11,6 @@ import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class ChatHandler implements PacketHandler { @Override public PacketType getType() { @@ -39,19 +38,33 @@ public boolean handle(Server server, Packet packet, Matcher message) { for (Player otherPlayer : destination.getPlayers()) { if (player != otherPlayer) { if (message.group(1).equals("game")) { - otherPlayer.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("game", "say", ((Game) destination).getPlayerId(player), message.group(3)))); + otherPlayer + .getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize( + "game", + "say", + ((Game) destination).getPlayerId(player), + message.group(3)))); } else { - otherPlayer.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("lobby", "say", message.group(3), player.getNick(), message.group(4)))); + otherPlayer + .getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize( + "lobby", "say", message.group(3), player.getNick(), message.group(4)))); } } } } else if (message.group(2).equals("sayp")) { for (Player otherPlayer : destination.getPlayers()) { if (otherPlayer.getNick().equals(message.group(3))) { - otherPlayer.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize(message.group(1), "sayp", player.getNick(), message.group(4)))); + otherPlayer + .getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize(message.group(1), "sayp", player.getNick(), message.group(4)))); break; } } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/GameHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/GameHandler.java index ff7f92be..90bc2374 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/GameHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/GameHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Game; import org.moparforia.server.game.Player; @@ -7,9 +9,6 @@ import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class GameHandler implements PacketHandler { @Override public PacketType getType() { @@ -18,7 +17,8 @@ public PacketType getType() { @Override public Pattern getPattern() { - // return Pattern.compile("game\\t(beginstroke|endstroke|voteskip|skip|newgame|back)(?:\\t([0-9a-z]{4}|[0-9]))?(?:\\t)?([ft]+)?"); + // return + // Pattern.compile("game\\t(beginstroke|endstroke|voteskip|skip|newgame|back)(?:\\t([0-9a-z]{4}|[0-9]))?(?:\\t)?([ft]+)?"); return Pattern.compile("game\\t(.+?)(?:\\t([0-9a-z]{4}|[0-9]))?(?:\\t)?([ftp]+)?"); } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LanguageHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LanguageHandler.java index d3ab0d28..e79ab56b 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LanguageHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LanguageHandler.java @@ -1,14 +1,13 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Player; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class LanguageHandler implements PacketHandler { @Override @@ -27,5 +26,4 @@ public boolean handle(Server server, Packet packet, Matcher message) { player.setLocale(message.group(1)); // todo: check if we axly support this locale return true; } - } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyCreateSinglePlayerHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyCreateSinglePlayerHandler.java index 41e41b85..c2ead932 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyCreateSinglePlayerHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyCreateSinglePlayerHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Lobby; import org.moparforia.server.game.LobbyType; @@ -10,9 +12,6 @@ import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class LobbyCreateSinglePlayerHandler implements PacketHandler { @Override public PacketType getType() { @@ -22,7 +21,7 @@ public PacketType getType() { @Override public Pattern getPattern() { return Pattern.compile("(lobby|lobbyselect)\\tcsp(t|c)\\t(\\d+)(?:\\t(\\d+)\\t(\\d+))?"); - } //CLIENT> WRITE "d 5 lobby cspt 10 7 0" + } // CLIENT> WRITE "d 5 lobby cspt 10 7 0" @Override public boolean handle(Server server, Packet packet, Matcher message) { diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyDualplayerHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyDualplayerHandler.java index 323258e9..e44b0936 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyDualplayerHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyDualplayerHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.LobbyType; import org.moparforia.server.game.Player; @@ -9,9 +11,6 @@ import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class LobbyDualplayerHandler implements PacketHandler { @Override public PacketType getType() { @@ -20,7 +19,8 @@ public PacketType getType() { @Override public Pattern getPattern() { - return Pattern.compile("(game|lobby)\\t(challenge|accept|cancel|cfail|nc)\\t([ -~]+)(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?"); + return Pattern.compile( + "(game|lobby)\\t(challenge|accept|cancel|cfail|nc)\\t([ -~]+)(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?"); } @Override @@ -29,12 +29,12 @@ public boolean handle(Server server, Packet packet, Matcher message) { if (message.group(1).equals("lobby")) { if (message.group(2).equals("challenge")) { Player other = getPlayer(server, message.group(3)); - if (other == null) {// || other.isNotAcceptingChallenges()) { - player.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("lobby", "cfail", "nochall"))); + if (other == null) { // || other.isNotAcceptingChallenges()) { + player.getChannel() + .writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "cfail", "nochall"))); return true; } - int BigGrinWinkTongue = 4;// :) + int BigGrinWinkTongue = 4; // :) int numberOfTracks = Integer.parseInt(message.group(BigGrinWinkTongue++)); int tracksType = Integer.parseInt(message.group(BigGrinWinkTongue++)); int maxStrokes = Integer.parseInt(message.group(BigGrinWinkTongue++)); @@ -43,35 +43,51 @@ public boolean handle(Server server, Packet packet, Matcher message) { int collision = Integer.parseInt(message.group(BigGrinWinkTongue++)); int trackScoring = Integer.parseInt(message.group(BigGrinWinkTongue++)); int trackScoringEnd = Integer.parseInt(message.group(BigGrinWinkTongue++)); - new DualGame(player, other, server.getNextGameId(), numberOfTracks, tracksType, maxStrokes, strokeTimeout, waterEvent, collision, trackScoring, trackScoringEnd); + new DualGame( + player, + other, + server.getNextGameId(), + numberOfTracks, + tracksType, + maxStrokes, + strokeTimeout, + waterEvent, + collision, + trackScoring, + trackScoringEnd); } else if (message.group(2).equals("accept")) { Player other = getPlayer(server, message.group(3)); if (other == null || !(other.getGame() instanceof DualGame)) { - player.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("lobby", "cfail", "nouser")));//todo kick the faggot + player.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize("lobby", "cfail", "nouser"))); // todo kick the faggot return true; } ((DualGame) player.getGame()).start(); - //todo lobby part ~anonym-1234 1 + // todo lobby part ~anonym-1234 1 } else if (message.group(2).equals("cancel")) { Player other = getPlayer(server, message.group(3)); if (other == null || !(other.getGame() instanceof DualGame)) { - player.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("lobby", "cfail", "nouser")));//todo kick the faggot + player.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize("lobby", "cfail", "nouser"))); // todo kick the faggot return true; } - other.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("lobby", "cancel"))); + other.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "cancel"))); } else if (message.group(2).equals("cfail") && message.group(4).equals("refuse")) { Player other = getPlayer(server, message.group(3)); if (other == null || !(other.getGame() instanceof DualGame)) { - player.getChannel().writeAndFlush(new Packet(PacketType.DATA,//todo kick the faggot - Tools.tabularize("lobby", "cfail", "nouser"))); + player.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, // todo kick the faggot + Tools.tabularize("lobby", "cfail", "nouser"))); return true; } - other.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("lobby", "cfail", "refuse"))); - //todo HOW TO REMOVE THE GAME FROM THE SERVER + other.getChannel() + .writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "cfail", "refuse"))); + // todo HOW TO REMOVE THE GAME FROM THE SERVER } else if (message.group(2).equals("nc")) { player.setNotAcceptingChallenges(message.group(3).equals("t")); return true; @@ -82,8 +98,7 @@ public boolean handle(Server server, Packet packet, Matcher message) { private Player getPlayer(Server server, String nick) { for (Player p : server.getLobby(LobbyType.DUAL).getPlayers()) - if (p.getNick().equals(nick)) - return p; + if (p.getNick().equals(nick)) return p; return null; } } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyHandler.java index 8dda2529..bbbc0a45 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyHandler.java @@ -1,5 +1,8 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Lobby; import org.moparforia.server.game.LobbyType; @@ -12,10 +15,6 @@ import org.moparforia.shared.tracks.TrackSet; import org.moparforia.shared.tracks.filesystem.FileSystemTrackManager; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class LobbyHandler implements PacketHandler { private static final TrackManager manager = FileSystemTrackManager.getInstance(); @@ -49,7 +48,8 @@ public boolean handle(Server server, Packet packet, Matcher message) { } else if (player.getLobby() == lobby) { // todo: will this ever happen ? } else { - int reason = newLobbyType == LobbyType.MULTI ? Lobby.PART_REASON_JOINED_MP : Lobby.PART_REASON_SWITCHEDLOBBY; + int reason = + newLobbyType == LobbyType.MULTI ? Lobby.PART_REASON_JOINED_MP : Lobby.PART_REASON_SWITCHEDLOBBY; player.getLobby().removePlayer(player, reason); } lobby.addPlayer(player, Lobby.JOIN_TYPE_NORMAL); @@ -61,7 +61,7 @@ public boolean handle(Server server, Packet packet, Matcher message) { tracksInfo[i][0] = trackSet.getName(); tracksInfo[i][1] = String.valueOf(trackSet.getDifficulty().getId()); tracksInfo[i][2] = String.valueOf(trackSet.getTracks().size()); - for (int j = 3; j < 11; j++) {//todo track records + for (int j = 3; j < 11; j++) { // todo track records tracksInfo[i][j] = j % 2 == 0 ? "1" : "No one"; } } @@ -69,8 +69,8 @@ public boolean handle(Server server, Packet packet, Matcher message) { for (int i = 0; i < tracksInfo.length; i++) { cmd += Tools.tabularize(tracksInfo[i]) + (i == tracksInfo.length - 1 ? "" : '\t'); } - packet.getChannel().writeAndFlush(new Packet(PacketType.DATA, - Tools.tabularize("lobby", "tracksetlist", cmd))); + packet.getChannel() + .writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("lobby", "tracksetlist", cmd))); } return true; } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyMultiplayerHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyMultiplayerHandler.java index 60a8d14b..f733357c 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyMultiplayerHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbyMultiplayerHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Lobby; import org.moparforia.server.game.Player; @@ -8,9 +10,6 @@ import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class LobbyMultiplayerHandler implements PacketHandler { public PacketType getType() { @@ -18,12 +17,13 @@ public PacketType getType() { } // lobby cmpt - - 0 3 10 1 20 60 0 1 0 0 - //lobby cmpt - - 0 2 10 1 20 60 0 1 0 0" + // lobby cmpt - - 0 2 10 1 20 60 0 1 0 0" // lobby jmpt 543543 // lobby jmpt 542534 cock public Pattern getPattern() { - return Pattern.compile("lobby\\t(c|j)mpt\\t([a-zA-Z0-9 _`~!@#$%^&*()+={}:;<>,\\\\.\\[\\]\\'\\\"?\\/|\\-]+)(?:\\t)?([a-zA-Z0-9 _`~!@#$%^&*()+={}:;<>,\\\\.\\[\\]\\'\\\"?\\/|\\-]+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?"); + return Pattern.compile( + "lobby\\t(c|j)mpt\\t([a-zA-Z0-9 _`~!@#$%^&*()+={}:;<>,\\\\.\\[\\]\\'\\\"?\\/|\\-]+)(?:\\t)?([a-zA-Z0-9 _`~!@#$%^&*()+={}:;<>,\\\\.\\[\\]\\'\\\"?\\/|\\-]+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?(?:\\t)?(\\d+)?"); } public boolean handle(Server server, Packet packet, Matcher message) { @@ -45,8 +45,21 @@ public boolean handle(Server server, Packet packet, Matcher message) { int scoreSystem = Integer.parseInt(message.group(12)); int weightEnd = Integer.parseInt(message.group(13)); - new MultiGame(player, server.getNextGameId(), gameName, password, numberOfTracks, perms, trackType, maxStrokes, strokeTimeout, - water, collision, scoreSystem, weightEnd, playerCount); + new MultiGame( + player, + server.getNextGameId(), + gameName, + password, + numberOfTracks, + perms, + trackType, + maxStrokes, + strokeTimeout, + water, + collision, + scoreSystem, + weightEnd, + playerCount); } else if (message.group(1).equals("j")) { int gameId = Integer.parseInt(message.group(2)); diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbySelectHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbySelectHandler.java index ec4d4d02..1e4437ca 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbySelectHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LobbySelectHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Lobby; import org.moparforia.server.game.LobbyType; @@ -9,9 +11,6 @@ import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class LobbySelectHandler implements PacketHandler { public PacketType getType() { @@ -26,15 +25,22 @@ public Pattern getPattern() { @Override public boolean handle(Server server, Packet packet, Matcher message) { if (message.group(1).equals("rnop")) { // request number of players - packet.getChannel().writeAndFlush("d lobbyselect\tnop\t" + Tools.tabularize(server.getLobby(LobbyType.SINGLE).totalPlayerCount(), server.getLobby(LobbyType.DUAL).totalPlayerCount(), server.getLobby(LobbyType.MULTI).totalPlayerCount())); + packet.getChannel() + .writeAndFlush("d lobbyselect\tnop\t" + + Tools.tabularize( + server.getLobby(LobbyType.SINGLE).totalPlayerCount(), + server.getLobby(LobbyType.DUAL).totalPlayerCount(), + server.getLobby(LobbyType.MULTI).totalPlayerCount())); } else if (message.group(1).equals("select")) { // 1 for single, 1h for single hidden chat, 2 for dual, x for multi LobbyType lobbyType = LobbyType.getLobby(message.group(2)); - Player player = packet.getChannel().attr(Player.PLAYER_ATTRIBUTE_KEY).get(); + Player player = + packet.getChannel().attr(Player.PLAYER_ATTRIBUTE_KEY).get(); player.setChatHidden(message.group(3) != null && message.group(3).equals("h")); server.getLobby(lobbyType).addPlayer(player, Lobby.JOIN_TYPE_NORMAL); } else if (message.group(1).equals("qmpt")) { // multiplayer quick start - Player player = packet.getChannel().attr(Player.PLAYER_ATTRIBUTE_KEY).get(); + Player player = + packet.getChannel().attr(Player.PLAYER_ATTRIBUTE_KEY).get(); player.setChatHidden(message.group(3) != null && message.group(3).equals("h")); server.getLobby(LobbyType.MULTI).addPlayer(player, Lobby.JOIN_TYPE_NORMAL); } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LoginHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LoginHandler.java index 1ae1ec89..302d2749 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LoginHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LoginHandler.java @@ -1,5 +1,7 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.game.Player; import org.moparforia.server.net.Packet; @@ -7,9 +9,6 @@ import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class LoginHandler implements PacketHandler { @Override public PacketType getType() { @@ -25,15 +24,18 @@ public Pattern getPattern() { public boolean handle(Server server, Packet packet, Matcher message) { Player player = packet.getChannel().attr(Player.PLAYER_ATTRIBUTE_KEY).get(); - String username = "~anonym-" + (int) (Math.random() * 10000); player.setNick(username); player.setEmailVerified(true); player.setRegistered(false); - packet.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("basicinfo", player.isEmailVerified(), player.getAccessLevel(), "t", "t"))); - packet.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("status", "lobbyselect", "300"))); + packet.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize("basicinfo", player.isEmailVerified(), player.getAccessLevel(), "t", "t"))); + packet.getChannel() + .writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("status", "lobbyselect", "300"))); return true; } } diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LoginTypeHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LoginTypeHandler.java index bd1a9e30..95d9a3e9 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LoginTypeHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/LoginTypeHandler.java @@ -1,14 +1,13 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class LoginTypeHandler implements PacketHandler { @Override public PacketType getType() { diff --git a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/TrackTestLoginHandler.java b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/TrackTestLoginHandler.java index 07e2bc24..71e57000 100644 --- a/server/src/main/java/org/moparforia/server/net/packethandlers/golf/TrackTestLoginHandler.java +++ b/server/src/main/java/org/moparforia/server/net/packethandlers/golf/TrackTestLoginHandler.java @@ -1,16 +1,14 @@ package org.moparforia.server.net.packethandlers.golf; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.moparforia.server.Server; -//import org.moparforia.server.db.Database; import org.moparforia.server.game.Player; import org.moparforia.server.net.Packet; import org.moparforia.server.net.PacketHandler; import org.moparforia.server.net.PacketType; import org.moparforia.shared.Tools; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - public class TrackTestLoginHandler implements PacketHandler { Pattern namePattern; @@ -33,12 +31,12 @@ public boolean handle(Server server, Packet packet, Matcher message) { String username = message.group(1); username = username.trim(); if (namePattern.matcher(username).find()) { - return false;//todo disconnect client + return false; // todo disconnect client } String password = message.group(2); - //todo load player from db? + // todo load player from db? - boolean anonym = true; //!Database.getInstance().authenticateUser(username,password); + boolean anonym = true; // !Database.getInstance().authenticateUser(username,password); if (anonym) { if (username.length() == 0) { username = "~anonym-" + (int) (Math.random() * 10000); @@ -50,7 +48,10 @@ public boolean handle(Server server, Packet packet, Matcher message) { player.setNick(username); player.setEmailVerified(true); player.setRegistered(true); - packet.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("basicinfo", player.isEmailVerified(), player.getAccessLevel(), "t", "f"))); + packet.getChannel() + .writeAndFlush(new Packet( + PacketType.DATA, + Tools.tabularize("basicinfo", player.isEmailVerified(), player.getAccessLevel(), "t", "f"))); packet.getChannel().writeAndFlush(new Packet(PacketType.DATA, Tools.tabularize("status", "lobbyselect", 300))); return true; } diff --git a/server/src/main/java/org/moparforia/server/util/StockTrackUploader.java b/server/src/main/java/org/moparforia/server/util/StockTrackUploader.java index 2cf4e54c..6eaf4494 100644 --- a/server/src/main/java/org/moparforia/server/util/StockTrackUploader.java +++ b/server/src/main/java/org/moparforia/server/util/StockTrackUploader.java @@ -1,18 +1,13 @@ package org.moparforia.server.util; -import org.moparforia.shared.tracks.Track; -import org.moparforia.shared.tracks.TrackCategory; - import java.io.IOException; import java.nio.file.*; import java.util.ArrayList; import java.util.Scanner; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.TrackCategory; -/** - * User: Johan - * Date: 2013-08-09 - * Time: 08:35 - */ +/** User: Johan Date: 2013-08-09 Time: 08:35 */ public class StockTrackUploader { private static ArrayList tracks; @@ -29,17 +24,19 @@ private static void loadTracks() throws IOException { tracks = new ArrayList(); FileSystem fs = FileSystems.getDefault(); for (TrackCategory type : TrackCategory.values()) { - //if (type == TrackCategory.ALL || type == TrackCategory.CUSTOM || type == TrackCategory.UNKNOWN) { + // if (type == TrackCategory.ALL || type == TrackCategory.CUSTOM || type == + // TrackCategory.UNKNOWN) { if (type == TrackCategory.ALL || type == TrackCategory.UNKNOWN) { continue; } Path tracksPath = fs.getPath("tracks", type.getDir()); - DirectoryStream directoryStream = Files.newDirectoryStream(tracksPath, new DirectoryStream.Filter() { - @Override - public boolean accept(Path entry) throws IOException { - return entry.toString().endsWith(".track"); - } - }); + DirectoryStream directoryStream = + Files.newDirectoryStream(tracksPath, new DirectoryStream.Filter() { + @Override + public boolean accept(Path entry) throws IOException { + return entry.toString().endsWith(".track"); + } + }); for (Path filePath : directoryStream) { String name = null, author = null, data = null; Scanner scanner = new Scanner(filePath); @@ -60,69 +57,72 @@ public boolean accept(Path entry) throws IOException { tracks.add(new Track(name, author, data, type)); } } - //uploadTracks(); + // uploadTracks(); System.out.println("Done."); } -// private static final void loadTrackSets() throws IOException { -// if (tracks == null) { -// return; -// } -// ArrayList trackSets = new ArrayList(); -// FileSystem fs = FileSystems.getDefault(); -// DirectoryStream directoryStream = Files.newDirectoryStream(fs.getPath("tracks", "sets"), new DirectoryStream.Filter() { -// @Override -// public boolean accept(Path entry) throws IOException { -// return entry.getFileName().toString().endsWith(".trackset"); -// } -// }); -// for (Path filePath : directoryStream) { -// Scanner scanner = new Scanner(filePath); -// String setName = scanner.nextLine(); -// TrackSetDifficulty trackSetDifficulty = TrackSetDifficulty.valueOf(scanner.nextLine()); -// ArrayList fileNames = new ArrayList(); -// while (scanner.hasNextLine()) { -// String line = scanner.nextLine().trim(); -// if(!line.isEmpty()) { -// fileNames.add(line); -// } -// } -// trackSets.add(new TrackSet(setName, trackSetDifficulty, fileNames)); -// } -// uploadTrackSets(trackSets); -// } + // private static final void loadTrackSets() throws IOException { + // if (tracks == null) { + // return; + // } + // ArrayList trackSets = new ArrayList(); + // FileSystem fs = FileSystems.getDefault(); + // DirectoryStream directoryStream = Files.newDirectoryStream(fs.getPath("tracks", + // "sets"), new DirectoryStream.Filter() { + // @Override + // public boolean accept(Path entry) throws IOException { + // return entry.getFileName().toString().endsWith(".trackset"); + // } + // }); + // for (Path filePath : directoryStream) { + // Scanner scanner = new Scanner(filePath); + // String setName = scanner.nextLine(); + // TrackSetDifficulty trackSetDifficulty = + // TrackSetDifficulty.valueOf(scanner.nextLine()); + // ArrayList fileNames = new ArrayList(); + // while (scanner.hasNextLine()) { + // String line = scanner.nextLine().trim(); + // if(!line.isEmpty()) { + // fileNames.add(line); + // } + // } + // trackSets.add(new TrackSet(setName, trackSetDifficulty, fileNames)); + // } + // uploadTrackSets(trackSets); + // } -// private static void uploadTracks() { -// ArrayList _tracks = new ArrayList(); -// for (Track track : tracks){ -// _tracks.add(new BasicDBObjectBuilder().append("name", track.getName()). -// append("author", track.getAuthor()). -// append("data", track.getData()). -// append("category", track.getCategory()). -// append("version", 1). -// append("num_completions", 0). -// append("num_strokes", 0). -// append("num_best_strokes", 0). -// append("first_best_name", ""). -// append("first_best_time", 0). -// append("last_best_name", ""). -// append("last_best_time", 0). -// append("ratings", new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}). -// append("num_best_players", 0).get()); -// } -// DBCollection tracks = Database.getInstance().getDatabase().getCollection("tracks"); -// tracks.insert(_tracks); -// } + // private static void uploadTracks() { + // ArrayList _tracks = new ArrayList(); + // for (Track track : tracks){ + // _tracks.add(new BasicDBObjectBuilder().append("name", track.getName()). + // append("author", track.getAuthor()). + // append("data", track.getData()). + // append("category", track.getCategory()). + // append("version", 1). + // append("num_completions", 0). + // append("num_strokes", 0). + // append("num_best_strokes", 0). + // append("first_best_name", ""). + // append("first_best_time", 0). + // append("last_best_name", ""). + // append("last_best_time", 0). + // append("ratings", new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}). + // append("num_best_players", 0).get()); + // } + // DBCollection tracks = Database.getInstance().getDatabase().getCollection("tracks"); + // tracks.insert(_tracks); + // } -// private static void uploadTrackSets(ArrayList trackSets) { -// ArrayList _tracks = new ArrayList(); -// for (TrackSet track : trackSets){ -// _tracks.add(new BasicDBObjectBuilder().append("name", track.getName()). -// append("difficulty", track.getDifficulty().getId()). -// append("times_played", 0). -// append("ratings", new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}).get()); -// } -// DBCollection tracks = Database.getInstance().getDatabase().getCollection("track_sets"); -// tracks.insert(_tracks); -// } + // private static void uploadTrackSets(ArrayList trackSets) { + // ArrayList _tracks = new ArrayList(); + // for (TrackSet track : trackSets){ + // _tracks.add(new BasicDBObjectBuilder().append("name", track.getName()). + // append("difficulty", track.getDifficulty().getId()). + // append("times_played", 0). + // append("ratings", new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}).get()); + // } + // DBCollection tracks = + // Database.getInstance().getDatabase().getCollection("track_sets"); + // tracks.insert(_tracks); + // } } diff --git a/server/src/test/java/org/moparforia/server/LauncherCLITest.java b/server/src/test/java/org/moparforia/server/LauncherCLITest.java index a0e79d8f..364c9683 100644 --- a/server/src/test/java/org/moparforia/server/LauncherCLITest.java +++ b/server/src/test/java/org/moparforia/server/LauncherCLITest.java @@ -1,5 +1,12 @@ package org.moparforia.server; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; + +import java.io.PrintWriter; +import java.io.StringWriter; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -7,16 +14,9 @@ import org.mockito.junit.jupiter.MockitoExtension; import picocli.CommandLine; -import java.io.PrintWriter; -import java.io.StringWriter; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - /** - * Tests that CLI parsing works as expected, it doesn't test the main method, but it tests the picocli annotations + * Tests that CLI parsing works as expected, it doesn't test the main method, but it tests the + * picocli annotations */ @ExtendWith(MockitoExtension.class) class LauncherCLITest { @@ -30,9 +30,7 @@ class LauncherCLITest { @BeforeEach void setUp() { // Mock Launcher instance - launcher = mock(Launcher.class, withSettings() - .lenient() - .withoutAnnotations()); + launcher = mock(Launcher.class, withSettings().lenient().withoutAnnotations()); doReturn(mock(Server.class)).when(launcher).getServer(anyString(), anyInt(), anyBoolean(), any()); when(launcher.call()).thenCallRealMethod(); @@ -69,7 +67,8 @@ void testValidOptions() { assertEquals(0, cmd.execute("-p=2222", "-ip=127.127.127.127", "-v", "-t=/some/path")); verify(launcher).getServer(eq("127.127.127.127"), eq(2222), eq(true), eq("/some/path")); - assertEquals(0, cmd.execute("--port=3333", "--hostname=126.126.126.126", "--verbose", "--tracks-dir=/some/path")); + assertEquals( + 0, cmd.execute("--port=3333", "--hostname=126.126.126.126", "--verbose", "--tracks-dir=/some/path")); verify(launcher).getServer(eq("126.126.126.126"), eq(3333), eq(true), eq("/some/path")); } diff --git a/server/src/test/java/org/moparforia/server/ServerTest.java b/server/src/test/java/org/moparforia/server/ServerTest.java index e99b8d69..6bcf1b2d 100644 --- a/server/src/test/java/org/moparforia/server/ServerTest.java +++ b/server/src/test/java/org/moparforia/server/ServerTest.java @@ -1,6 +1,7 @@ package org.moparforia.server; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -11,9 +12,7 @@ import java.io.OutputStreamWriter; import java.net.Socket; import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.Test; public class ServerTest { @@ -25,7 +24,7 @@ private void sendMessage(BufferedWriter writer, String message) throws IOExcepti @Test void testSinglePlayerFlow() throws IOException, InterruptedException { - Server server = new Server("127.0.0.1", 4243, false,Optional.empty()); + Server server = new Server("127.0.0.1", 4243, false, Optional.empty()); server.start(); Socket socket = new Socket("127.0.0.1", 4243); @@ -80,7 +79,9 @@ void testSinglePlayerFlow() throws IOException, InterruptedException { assertEquals("d 6 lobby\townjoin\t3:" + nickname + "^r^0^-^-^-", lobbyOwnjoin); this.sendMessage(writer, "d 4 lobby\ttracksetlist"); String tracksetlist = reader.readLine(); - assertEquals(tracksetlist, "d 7 lobby\ttracksetlist\tBirchwood\t1\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tOak Park\t1\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tOne by One\t2\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tScary Set\t3\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tSpruce Corpse\t2\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tThe First\t2\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tTorment Fields\t3\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1"); + assertEquals( + tracksetlist, + "d 7 lobby\ttracksetlist\tBirchwood\t1\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tOak Park\t1\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tOne by One\t2\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tScary Set\t3\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tSpruce Corpse\t2\t9\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tThe First\t2\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1\tTorment Fields\t3\t18\tNo one\t1\tNo one\t1\tNo one\t1\tNo one\t1"); // start championship game this.sendMessage(writer, "d 5 lobby\tcspc\t6"); @@ -98,7 +99,9 @@ void testSinglePlayerFlow() throws IOException, InterruptedException { assertEquals("d 11 game\towninfo\t0\t" + nickname + "\t-", ownInfo); assertEquals("d 12 game\tstart", gameStart); assertEquals("d 13 game\tresetvoteskip", resetVoteSkip); - assertTrue(startTrack.matches("d 14 game\tstarttrack\tt\t0\tV 1\tA Leonardo\tN Revocations\tT BAMM21DBAQQ7DBAMM18DBAQQDB3ADDBAQQ6DEDDBAQQ7DB3A11DBHAQBGAQB3ABAQQ4DB3ADDBHAMEDEB3A10DEDDB3A3DBHAQBGAQB3AEE14DBAGABAIADDBAKAE3DEDEE10DEDDE6DEE6DBAQQE6DEEDDEE3DEDEE10DEDDE4DBIAHBAIAEE6DEE6DEEDDEE3DEDEE10DEDDE4DBAGA3EDBGMABHMAEDDEE6DEEDDEE3DEDEE10DEDDE4D4EDBHAMBGAMEDDEE6DEEDDEE3DEDEE10DEDDE4D4E6DEE6DEEDDEE3DEDEE9DBGLABAEADDBHFAE3DBAQQ3E6DEE6DEEDDEE3DEDEE9DBAKAGDDBAGAE3D4E6DEEDBAQQ6DEG7DBAMMEDBEAQBFAQE5DEEDDEE3D4E6DEE5DEDDEE7DEEDBHAQBAQQDE4DEEDDEE3DEBAGADE6DEE5DEG9D3EDDEBGAQE4DEEDDEE3DEDDE6DEE5DEE9DEBAQQE9DEEDDEE5DEE6DEE5DBGAQE9D3E9DEEDDEE5DEE4DBAQQDDE16D3E5DBAQQ4DEDDBAQQ7DE4DEBAGADE5DBEAQBAQQDDBGAQEDDBGMABAMMDDEBFAQE4DEBAMM3DEDDBAMA7DE4DEBAEAGE5DBAQQBGAQH4DBGMABAMM3DEDFE3DEE3DEDDE7DE4D4E5DEG5DBHAMEBGAMB3ABAQQEDDFEDDEEBIMAB3A17D4E5DEE6DBSAMGDEE3DFEDEEB3A18DBAGA3E5DEE9DEEBIQAB3A4DEEBLMAE17D4EDDBQAMEDEE9DEEB3ACBAE3DEE3DEDDBAMA7DE4D4EDBEAMBAMMBFAM3E7DCAA3EBLQAF4DEE3DEDDE7DEDBEAQBFAQ5EBEAMBAMMDBEMA3E9DEE11DEDDBAQQ15DBAMMDDBEMAB3ADE11DBAMM10DE4DBAMM32D,Ads:C0204\tI 308939,4480252,4,2203\tB d2b,\\d+\tR 633,173,118,129,125,546,495,461,467,556,4472")); + assertTrue( + startTrack.matches( + "d 14 game\tstarttrack\tt\t0\tV 1\tA Leonardo\tN Revocations\tT BAMM21DBAQQ7DBAMM18DBAQQDB3ADDBAQQ6DEDDBAQQ7DB3A11DBHAQBGAQB3ABAQQ4DB3ADDBHAMEDEB3A10DEDDB3A3DBHAQBGAQB3AEE14DBAGABAIADDBAKAE3DEDEE10DEDDE6DEE6DBAQQE6DEEDDEE3DEDEE10DEDDE4DBIAHBAIAEE6DEE6DEEDDEE3DEDEE10DEDDE4DBAGA3EDBGMABHMAEDDEE6DEEDDEE3DEDEE10DEDDE4D4EDBHAMBGAMEDDEE6DEEDDEE3DEDEE10DEDDE4D4E6DEE6DEEDDEE3DEDEE9DBGLABAEADDBHFAE3DBAQQ3E6DEE6DEEDDEE3DEDEE9DBAKAGDDBAGAE3D4E6DEEDBAQQ6DEG7DBAMMEDBEAQBFAQE5DEEDDEE3D4E6DEE5DEDDEE7DEEDBHAQBAQQDE4DEEDDEE3DEBAGADE6DEE5DEG9D3EDDEBGAQE4DEEDDEE3DEDDE6DEE5DEE9DEBAQQE9DEEDDEE5DEE6DEE5DBGAQE9D3E9DEEDDEE5DEE4DBAQQDDE16D3E5DBAQQ4DEDDBAQQ7DE4DEBAGADE5DBEAQBAQQDDBGAQEDDBGMABAMMDDEBFAQE4DEBAMM3DEDDBAMA7DE4DEBAEAGE5DBAQQBGAQH4DBGMABAMM3DEDFE3DEE3DEDDE7DE4D4E5DEG5DBHAMEBGAMB3ABAQQEDDFEDDEEBIMAB3A17D4E5DEE6DBSAMGDEE3DFEDEEB3A18DBAGA3E5DEE9DEEBIQAB3A4DEEBLMAE17D4EDDBQAMEDEE9DEEB3ACBAE3DEE3DEDDBAMA7DE4D4EDBEAMBAMMBFAM3E7DCAA3EBLQAF4DEE3DEDDE7DEDBEAQBFAQ5EBEAMBAMMDBEMA3E9DEE11DEDDBAQQ15DBAMMDDBEMAB3ADE11DBAMM10DE4DBAMM32D,Ads:C0204\tI 308939,4480252,4,2203\tB d2b,\\d+\tR 633,173,118,129,125,546,495,461,467,556,4472")); assertEquals("d 15 game\tstartturn\t0", startTurn); // leave game diff --git a/shared/pom.xml b/shared/pom.xml index 4c08acc1..ca3755ac 100644 --- a/shared/pom.xml +++ b/shared/pom.xml @@ -2,15 +2,15 @@ 4.0.0 - shared - 2.2.1.0-BETA - org.moparforia playforia-minigolf 2.2.1.0-BETA + shared + 2.2.1.0-BETA + info.picocli @@ -46,8 +46,8 @@ maven-compiler-plugin - plantuml-generator-maven-plugin de.elnarion.maven + plantuml-generator-maven-plugin 2.4.1 diff --git a/shared/src/main/java/org/moparforia/shared/Tools.java b/shared/src/main/java/org/moparforia/shared/Tools.java index d5512cc6..4931e7dc 100644 --- a/shared/src/main/java/org/moparforia/shared/Tools.java +++ b/shared/src/main/java/org/moparforia/shared/Tools.java @@ -3,8 +3,7 @@ public class Tools { private static String toString(Object o) { - if (o instanceof Boolean) - return (Boolean) o ? "t" : "f"; + if (o instanceof Boolean) return (Boolean) o ? "t" : "f"; return o.toString(); } @@ -23,16 +22,15 @@ public static String izer(String splitter, Object... args) { return s; } - public static String tabularize(Object... args) {// lololol + public static String tabularize(Object... args) { // lololol return izer("\t", args); - } - public static String triangelize(Object... args) {// hhhehehe + public static String triangelize(Object... args) { // hhhehehe return izer("^", args); } - public static String commaize(Object... args) {// hhhehehe + public static String commaize(Object... args) { // hhhehehe return izer(",", args); } -} \ No newline at end of file +} diff --git a/shared/src/main/java/org/moparforia/shared/tracks/Track.java b/shared/src/main/java/org/moparforia/shared/tracks/Track.java index 0d866507..2799b923 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/Track.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/Track.java @@ -1,11 +1,10 @@ package org.moparforia.shared.tracks; -import org.moparforia.shared.Tools; - import java.util.Collections; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import org.moparforia.shared.Tools; public class Track { @@ -33,11 +32,12 @@ public Track(String track, String author, String map, TrackCategory category) { } /** - * new Track(1,"Boats and hoes","fc","B3A48DE48DE48DE48DE48DE48DEBAQQ46D3EG13DEG14DEG13D5E13DEE14DEE13D5E13DEE14DEE13D5E13DEE14DEE13D5E13DEE6DBMAQE6DEE13D5ECAAE11DEE6DBAQQE6DEE11DCBA6E13DBOAQE6DEE6DBOAQE13D5E21DEE21D5E21DEE21D5E21DEE21D5E21DEE21D4E46DEE48DE48DE48DE48DE48DE48D", - * new int[]{2629492,7166639,2,1191141},new String[] {"fc","Tiikoni"}, new int[]{1034197200000,1370170660930}, - * new int[]{1630,567,647,835,1148,3945,3755,3346,2924,2672,21566}); + * new Track(1,"Boats and + * hoes","fc","B3A48DE48DE48DE48DE48DE48DEBAQQ46D3EG13DEG14DEG13D5E13DEE14DEE13D5E13DEE14DEE13D5E13DEE14DEE13D5E13DEE6DBMAQE6DEE13D5ECAAE11DEE6DBAQQE6DEE11DCBA6E13DBOAQE6DEE6DBOAQE13D5E21DEE21D5E21DEE21D5E21DEE21D5E21DEE21D4E46DEE48DE48DE48DE48DE48DE48D", + * new int[]{2629492,7166639,2,1191141},new String[] {"fc","Tiikoni"}, new + * int[]{1034197200000,1370170660930}, new + * int[]{1630,567,647,835,1148,3945,3755,3346,2924,2672,21566}); */ - public String getName() { return track; } @@ -67,10 +67,10 @@ public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Track)) return false; Track track1 = (Track) o; - return track.equals(track1.track) && - getAuthor().equals(track1.getAuthor()) && - getMap().equals(track1.getMap()) && - getCategories().equals(track1.getCategories()); + return track.equals(track1.track) + && getAuthor().equals(track1.getAuthor()) + && getMap().equals(track1.getMap()) + && getCategories().equals(track1.getCategories()); } @Override @@ -79,16 +79,9 @@ public int hashCode() { } public String serialize(String splitter) { - String categories = getCategories() - .stream() + String categories = getCategories().stream() .map(category -> String.valueOf(category.getId())) .collect(Collectors.joining(",")); - return Tools.izer(splitter, - "V 2", - "A " + getAuthor(), - "N " + getName(), - "T " + getMap(), - "C " + categories); + return Tools.izer(splitter, "V 2", "A " + getAuthor(), "N " + getName(), "T " + getMap(), "C " + categories); } - -} \ No newline at end of file +} diff --git a/shared/src/main/java/org/moparforia/shared/tracks/TrackCategory.java b/shared/src/main/java/org/moparforia/shared/tracks/TrackCategory.java index 360ce797..ed84b02b 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/TrackCategory.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/TrackCategory.java @@ -1,7 +1,6 @@ package org.moparforia.shared.tracks; public enum TrackCategory { - UNKNOWN("?", -1), ALL("-", 0), BASIC("basic", 1), @@ -28,11 +27,8 @@ public int getId() { } public static TrackCategory getByTypeId(int id) { - for (TrackCategory type : TrackCategory.values()) - if (type.getId() == id) - return type; + for (TrackCategory type : TrackCategory.values()) if (type.getId() == id) return type; return TrackCategory.UNKNOWN; } - } diff --git a/shared/src/main/java/org/moparforia/shared/tracks/TrackManager.java b/shared/src/main/java/org/moparforia/shared/tracks/TrackManager.java index 7c01e639..53e8cfc2 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/TrackManager.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/TrackManager.java @@ -2,9 +2,7 @@ import java.util.List; -/** - * Interface representing Manager that provides Tracks - */ +/** Interface representing Manager that provides Tracks */ public interface TrackManager { /** @@ -15,13 +13,13 @@ public interface TrackManager { /** * Returns random tracks * - * @param limit Maximum tracks that should be returned, if there are not enough tracks, it can be return less - * @param type What category should be track belong to + * @param limit Maximum tracks that should be returned, if there are not enough tracks, it can + * be return less + * @param type What category should be track belong to * @return Random tracks */ List getRandomTracks(int limit, TrackCategory type); - List getTracks(); TrackSet getTrackSet(String name); @@ -34,6 +32,7 @@ public interface TrackManager { /** * Loads all Tracks and TrackSets + * * @throws TrackLoadException Exception */ void load(TracksLocation tracksLocation) throws TrackLoadException; diff --git a/shared/src/main/java/org/moparforia/shared/tracks/TrackSetDifficulty.java b/shared/src/main/java/org/moparforia/shared/tracks/TrackSetDifficulty.java index 87e9352e..0479fbe2 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/TrackSetDifficulty.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/TrackSetDifficulty.java @@ -1,8 +1,9 @@ package org.moparforia.shared.tracks; public enum TrackSetDifficulty { - - EASY(1), MEDIUM(2), HARD(3); + EASY(1), + MEDIUM(2), + HARD(3); private final int id; diff --git a/shared/src/main/java/org/moparforia/shared/tracks/TracksLocation.java b/shared/src/main/java/org/moparforia/shared/tracks/TracksLocation.java index a2e9dcd4..f83ba8ba 100755 --- a/shared/src/main/java/org/moparforia/shared/tracks/TracksLocation.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/TracksLocation.java @@ -2,5 +2,4 @@ import java.nio.file.FileSystem; -public record TracksLocation(FileSystem fileSystem, String path) { -} +public record TracksLocation(FileSystem fileSystem, String path) {} diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemStatsManager.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemStatsManager.java index aae7054d..1a0805fe 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemStatsManager.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemStatsManager.java @@ -1,12 +1,5 @@ package org.moparforia.shared.tracks.filesystem; -import org.moparforia.shared.tracks.Track; -import org.moparforia.shared.tracks.TracksLocation; -import org.moparforia.shared.tracks.parsers.TrackParser; -import org.moparforia.shared.tracks.parsers.VersionedTrackFileParser; -import org.moparforia.shared.tracks.stats.TrackStats; -import org.moparforia.shared.tracks.stats.StatsManager; - import java.io.IOException; import java.nio.file.*; import java.util.ArrayList; @@ -15,17 +8,22 @@ import java.util.Map; import java.util.logging.Logger; import java.util.stream.Collectors; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.TracksLocation; +import org.moparforia.shared.tracks.parsers.TrackParser; +import org.moparforia.shared.tracks.parsers.VersionedTrackFileParser; +import org.moparforia.shared.tracks.stats.StatsManager; +import org.moparforia.shared.tracks.stats.TrackStats; public class FileSystemStatsManager implements StatsManager { private static FileSystemStatsManager instance; - private final Logger logger = Logger.getLogger(FileSystemStatsManager.class.getName()); + private final Logger logger = Logger.getLogger(FileSystemStatsManager.class.getName()); private final TrackParser parser = new VersionedTrackFileParser(); private Map stats; - public FileSystemStatsManager() { - } + public FileSystemStatsManager() {} public static FileSystemStatsManager getInstance() { if (instance == null) { @@ -47,10 +45,8 @@ public Map loadStats(TracksLocation tracksLocation) throws IO logger.warning("Directory " + tracksLocation.path() + "/tracks was not found, ignoring."); return Collections.emptyMap(); } - DirectoryStream directoryStream = Files.newDirectoryStream( - tracksPath, - entry -> entry.toString().endsWith(".track") - ); + DirectoryStream directoryStream = + Files.newDirectoryStream(tracksPath, entry -> entry.toString().endsWith(".track")); for (Path filePath : directoryStream) { try { tracks.add(parser.parseStats(filePath)); @@ -59,8 +55,7 @@ public Map loadStats(TracksLocation tracksLocation) throws IO logger.info(e.toString()); } } - return tracks.stream() - .collect(Collectors.toMap(TrackStats::getTrack, stats -> stats)); + return tracks.stream().collect(Collectors.toMap(TrackStats::getTrack, stats -> stats)); } @Override diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackManager.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackManager.java index c0c3c12f..7bdbfa0a 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackManager.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackManager.java @@ -1,21 +1,20 @@ package org.moparforia.shared.tracks.filesystem; -import org.moparforia.shared.Tools; -import org.moparforia.shared.tracks.*; -import org.moparforia.shared.tracks.parsers.TrackParser; -import org.moparforia.shared.tracks.parsers.VersionedTrackFileParser; -import org.moparforia.shared.utils.CollectorUtils; - import java.io.IOException; import java.nio.file.*; import java.util.*; import java.util.logging.Logger; import java.util.stream.Collectors; +import org.moparforia.shared.Tools; +import org.moparforia.shared.tracks.*; +import org.moparforia.shared.tracks.parsers.TrackParser; +import org.moparforia.shared.tracks.parsers.VersionedTrackFileParser; +import org.moparforia.shared.utils.CollectorUtils; public class FileSystemTrackManager implements TrackManager { private static FileSystemTrackManager instance; private static final TrackParser parser = new VersionedTrackFileParser(); - private final Logger logger = Logger.getLogger(FileSystemTrackManager.class.getName()); + private final Logger logger = Logger.getLogger(FileSystemTrackManager.class.getName()); private List tracks; private List trackSets; @@ -47,17 +46,12 @@ public boolean isLoaded() { return hasLoaded; } - public void save(Track track) { // No-op, this implementation is only read-only } public static String convertTrack(Track track) { - return Tools.tabularize( - "V 1", - "A " + track.getAuthor(), - "N " + track.getName(), - "T " + track.getMap()); + return Tools.tabularize("V 1", "A " + track.getAuthor(), "N " + track.getName(), "T " + track.getMap()); } private List loadTracks(TracksLocation tracksLocation) throws IOException { @@ -68,8 +62,8 @@ private List loadTracks(TracksLocation tracksLocation) throws IOException logger.warning("Tracks directory (" + tracksLocation.path() + "/tracks) was not found, ignoring."); return Collections.emptyList(); } - DirectoryStream directoryStream = Files.newDirectoryStream(tracksPath, - entry -> entry.toString().endsWith(".track")); + DirectoryStream directoryStream = + Files.newDirectoryStream(tracksPath, entry -> entry.toString().endsWith(".track")); for (Path filePath : directoryStream) { try { tracks.add(parser.parseTrack(filePath)); @@ -85,12 +79,13 @@ private List loadTrackSets(TracksLocation tracksLocation) throws IOExc List trackSets = new ArrayList<>(); Path sets = tracksLocation.fileSystem().getPath(tracksLocation.path(), "sets"); if (!Files.exists(sets)) { - logger.warning("Can't load tracksets, directory " + tracksLocation.path() + "/sets does not exist, ignoring."); + logger.warning( + "Can't load tracksets, directory " + tracksLocation.path() + "/sets does not exist, ignoring."); return trackSets; } - DirectoryStream directoryStream = Files.newDirectoryStream(sets, - entry -> entry.getFileName().toString().endsWith(".trackset")); + DirectoryStream directoryStream = Files.newDirectoryStream( + sets, entry -> entry.getFileName().toString().endsWith(".trackset")); for (Path filePath : directoryStream) { Scanner scanner = new Scanner(filePath); String setName = scanner.nextLine(); @@ -116,7 +111,11 @@ private List loadTrackSets(TracksLocation tracksLocation) throws IOExc if (tracks.size() < trackNames.size()) { List found_tracks = tracks.stream().map(Track::getName).toList(); trackNames.removeAll(found_tracks); - logger.warning("TrackSet " + setName + " contains not existing tracks (" + Arrays.toString(trackNames.toArray()) + ")"); + logger.warning("TrackSet " + + setName + + " contains not existing tracks (" + + Arrays.toString(trackNames.toArray()) + + ")"); } trackSets.add(new TrackSet(setName, trackSetDifficulty, tracks)); } @@ -124,18 +123,17 @@ private List loadTrackSets(TracksLocation tracksLocation) throws IOExc return trackSets; } - public List getRandomTracks(int limit, TrackCategory type) { if (limit < 1) { throw new IllegalArgumentException("Number of tracks must be at least 1"); } return getTracks().stream() - .filter(track -> type == TrackCategory.ALL || track.getCategories().contains(type)) + .filter(track -> + type == TrackCategory.ALL || track.getCategories().contains(type)) .collect(CollectorUtils.toShuffledStream()) .limit(limit) .collect(Collectors.toList()); - } @Override @@ -145,8 +143,7 @@ public List getTracks() { @Override public TrackSet getTrackSet(String name) { - return getTrackSets() - .stream() + return getTrackSets().stream() .filter(trackset -> trackset.getName().equals(name)) .findFirst() .orElse(null); diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackStats.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackStats.java index c5c91232..0b2ae2d8 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackStats.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackStats.java @@ -1,13 +1,12 @@ package org.moparforia.shared.tracks.filesystem; -import org.moparforia.shared.Tools; -import org.moparforia.shared.tracks.Track; -import org.moparforia.shared.tracks.stats.TrackStats; - import java.time.LocalDate; import java.time.ZoneId; import java.util.Arrays; import java.util.Objects; +import org.moparforia.shared.Tools; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.stats.TrackStats; public class FileSystemTrackStats implements TrackStats { private final int totalAttempts; @@ -20,8 +19,16 @@ public class FileSystemTrackStats implements TrackStats { private final int[] ratings; private Track track; - public FileSystemTrackStats(int totalAttempts, int strokes, int bestPar, double percentageofBestPar, - int numberOfBestPar, String bestPlayer, LocalDate bestTime, int[] ratings, Track track) { + public FileSystemTrackStats( + int totalAttempts, + int strokes, + int bestPar, + double percentageofBestPar, + int numberOfBestPar, + String bestPlayer, + LocalDate bestTime, + int[] ratings, + Track track) { this.totalAttempts = totalAttempts; this.strokes = strokes; this.bestPar = bestPar; @@ -93,19 +100,24 @@ public int getNumberOfRatings() { return Arrays.stream(ratings).sum(); } - @Override public String serialize(String splitter) { StringBuilder output = new StringBuilder(getTrack().serialize(splitter)); output.append(splitter); - output.append(Tools.izer(splitter, + output.append(Tools.izer( + splitter, "I " + Tools.commaize(getTotalAttempts(), getTotalStrokes(), getBestPar(), numberOfBestPar), "R " + ratingsToString())); output.append(splitter); if (getBestPar() > 0) { - output.append( - Tools.izer(splitter, "B " + Tools.commaize(getBestPlayer(), - bestTime.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli()))); + output.append(Tools.izer( + splitter, + "B " + + Tools.commaize( + getBestPlayer(), + bestTime.atStartOfDay(ZoneId.systemDefault()) + .toInstant() + .toEpochMilli()))); } return output.toString(); } @@ -115,20 +127,28 @@ public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof FileSystemTrackStats)) return false; FileSystemTrackStats that = (FileSystemTrackStats) o; - return getTotalAttempts() == that.getTotalAttempts() && - strokes == that.strokes && - getBestPar() == that.getBestPar() && - Double.compare(that.bestParPercentage, bestParPercentage) == 0 && - numberOfBestPar == that.numberOfBestPar && - Objects.equals(getBestPlayer(), that.getBestPlayer()) && - Objects.equals(bestTime, that.bestTime) && - Arrays.equals(getRatings(), that.getRatings()) && - getTrack().equals(that.getTrack()); + return getTotalAttempts() == that.getTotalAttempts() + && strokes == that.strokes + && getBestPar() == that.getBestPar() + && Double.compare(that.bestParPercentage, bestParPercentage) == 0 + && numberOfBestPar == that.numberOfBestPar + && Objects.equals(getBestPlayer(), that.getBestPlayer()) + && Objects.equals(bestTime, that.bestTime) + && Arrays.equals(getRatings(), that.getRatings()) + && getTrack().equals(that.getTrack()); } @Override public int hashCode() { - int result = Objects.hash(getTotalAttempts(), strokes, getBestPar(), bestParPercentage, numberOfBestPar, getBestPlayer(), bestTime, getTrack()); + int result = Objects.hash( + getTotalAttempts(), + strokes, + getBestPar(), + bestParPercentage, + numberOfBestPar, + getBestPlayer(), + bestTime, + getTrack()); result = 31 * result + Arrays.hashCode(getRatings()); return result; } @@ -159,7 +179,12 @@ public String networkSerialize() { "N " + getTrack().getName(), "T " + getTrack().getMap(), "I " + Tools.commaize(getTotalAttempts(), getTotalStrokes(), getBestPar(), numberOfBestPar), - "B " + Tools.commaize(getBestPlayer(), bestTime.atStartOfDay(ZoneId.systemDefault()).toInstant().toEpochMilli()), + "B " + + Tools.commaize( + getBestPlayer(), + bestTime.atStartOfDay(ZoneId.systemDefault()) + .toInstant() + .toEpochMilli()), "R " + ratingsToString()); } } diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/BestTimeLineParser.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/BestTimeLineParser.java index 34e104c6..7f08456a 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/BestTimeLineParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/BestTimeLineParser.java @@ -1,12 +1,11 @@ package org.moparforia.shared.tracks.filesystem.lineparser; -import org.moparforia.shared.tracks.parsers.LineParser; - import java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; import java.util.HashMap; import java.util.Map; +import org.moparforia.shared.tracks.parsers.LineParser; public class BestTimeLineParser implements LineParser { @@ -24,7 +23,8 @@ public Map apply(String s) { String[] parts = s.split(","); map.put(player_parameter, parts[0]); long epochMilli = Long.parseLong(parts[1]); - LocalDate date = Instant.ofEpochMilli(epochMilli).atZone(ZoneId.systemDefault()).toLocalDate(); + LocalDate date = + Instant.ofEpochMilli(epochMilli).atZone(ZoneId.systemDefault()).toLocalDate(); map.put(date_parameter, date); return map; } diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/CategoriesLineParser.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/CategoriesLineParser.java index ab66db13..312e606d 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/CategoriesLineParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/CategoriesLineParser.java @@ -1,18 +1,16 @@ package org.moparforia.shared.tracks.filesystem.lineparser; -import org.moparforia.shared.tracks.TrackCategory; -import org.moparforia.shared.tracks.parsers.LineParser; - import java.util.*; import java.util.stream.Collectors; +import org.moparforia.shared.tracks.TrackCategory; +import org.moparforia.shared.tracks.parsers.LineParser; public class CategoriesLineParser implements LineParser { @Override public Map apply(String line) { - List possibleValues = Arrays.stream(TrackCategory.values()) - .map(TrackCategory::getId) - .collect(Collectors.toList()); + List possibleValues = + Arrays.stream(TrackCategory.values()).map(TrackCategory::getId).collect(Collectors.toList()); String[] parts = line.split(","); Map map = new HashMap<>(); @@ -26,4 +24,4 @@ public Map apply(String line) { map.put("categories", categories); return map; } -} \ No newline at end of file +} diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/RatingsLineParser.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/RatingsLineParser.java index 072c2c87..2ef2e768 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/RatingsLineParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/RatingsLineParser.java @@ -1,9 +1,8 @@ package org.moparforia.shared.tracks.filesystem.lineparser; -import org.moparforia.shared.tracks.parsers.LineParser; - import java.util.Collections; import java.util.Map; +import org.moparforia.shared.tracks.parsers.LineParser; public class RatingsLineParser implements LineParser { @Override diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/ScoreInfoLineParser.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/ScoreInfoLineParser.java index 4e747035..9524afdf 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/ScoreInfoLineParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/ScoreInfoLineParser.java @@ -1,9 +1,8 @@ package org.moparforia.shared.tracks.filesystem.lineparser; -import org.moparforia.shared.tracks.parsers.LineParser; - import java.util.HashMap; import java.util.Map; +import org.moparforia.shared.tracks.parsers.LineParser; public class ScoreInfoLineParser implements LineParser { @Override diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/SimpleLineParser.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/SimpleLineParser.java index 7d65ac33..c0a03c6f 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/SimpleLineParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/SimpleLineParser.java @@ -2,10 +2,7 @@ import java.util.function.Function; - -/** - * Line parser that returns entire contents of the line - */ +/** Line parser that returns entire contents of the line */ public class SimpleLineParser extends SingleArgumentLineParser { public SimpleLineParser(String parameter_name) { diff --git a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/SingleArgumentLineParser.java b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/SingleArgumentLineParser.java index ed2bfde5..f8b5de76 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/SingleArgumentLineParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/filesystem/lineparser/SingleArgumentLineParser.java @@ -1,15 +1,14 @@ package org.moparforia.shared.tracks.filesystem.lineparser; -import org.moparforia.shared.tracks.parsers.LineParser; - import java.util.Collections; import java.util.Map; import java.util.function.Function; +import org.moparforia.shared.tracks.parsers.LineParser; public class SingleArgumentLineParser implements LineParser { private final String parameter_name; - private final Function converter; + private final Function converter; public SingleArgumentLineParser(String parameter_name, Function converter) { this.parameter_name = parameter_name; diff --git a/shared/src/main/java/org/moparforia/shared/tracks/parsers/GenericTrackParser.java b/shared/src/main/java/org/moparforia/shared/tracks/parsers/GenericTrackParser.java index db0040b3..f5d12a0c 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/parsers/GenericTrackParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/parsers/GenericTrackParser.java @@ -10,12 +10,7 @@ /** * Class for parsing files in format of * - * - * - * ... - * e.g. - * V 1 - * T tzetete + *

... e.g. V 1 T tzetete */ public class GenericTrackParser { @@ -23,10 +18,7 @@ public Map parse(Map parser, Path path) t return Files.lines(path) .map(line -> parseLine(parser, line)) .flatMap(m -> m.entrySet().stream()) - .collect(Collectors.toMap( - Map.Entry::getKey, - Map.Entry::getValue) - ); + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } private Map parseLine(Map parsers, String line) { @@ -36,6 +28,4 @@ private Map parseLine(Map parsers, String } return Collections.emptyMap(); } - - } diff --git a/shared/src/main/java/org/moparforia/shared/tracks/parsers/InvalidTrackVersion.java b/shared/src/main/java/org/moparforia/shared/tracks/parsers/InvalidTrackVersion.java index 19c4fe72..cb636ae8 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/parsers/InvalidTrackVersion.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/parsers/InvalidTrackVersion.java @@ -3,8 +3,7 @@ import java.io.IOException; public class InvalidTrackVersion extends IOException { - public InvalidTrackVersion() { - } + public InvalidTrackVersion() {} public InvalidTrackVersion(String s) { super(s); diff --git a/shared/src/main/java/org/moparforia/shared/tracks/parsers/LineParser.java b/shared/src/main/java/org/moparforia/shared/tracks/parsers/LineParser.java index 6749cb36..ac186801 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/parsers/LineParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/parsers/LineParser.java @@ -3,7 +3,5 @@ import java.util.Map; import java.util.function.Function; -/** - * Class that takes line and returns map of parsed parameters - */ +/** Class that takes line and returns map of parsed parameters */ public interface LineParser extends Function> {} diff --git a/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackConverter.java b/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackConverter.java index 7f907cac..66848ffb 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackConverter.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackConverter.java @@ -1,9 +1,5 @@ package org.moparforia.shared.tracks.parsers; -import org.moparforia.shared.tracks.Track; -import org.moparforia.shared.tracks.TrackCategory; -import org.moparforia.shared.tracks.stats.TrackStats; - import java.io.IOException; import java.io.OutputStreamWriter; import java.nio.file.DirectoryStream; @@ -12,9 +8,12 @@ import java.util.*; import java.util.logging.Logger; import java.util.stream.Collectors; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.TrackCategory; +import org.moparforia.shared.tracks.stats.TrackStats; public class TrackConverter { - private static final Logger logger = Logger.getLogger(TrackConverter.class.getName()); + private static final Logger logger = Logger.getLogger(TrackConverter.class.getName()); public static List loadOldTracks(Path path) throws IOException { List tracks = new ArrayList<>(); @@ -28,14 +27,13 @@ public static List loadOldTracks(Path path) throws IOException { continue; } TrackFileParser parser = new TrackFileParser(type); - DirectoryStream directoryStream = Files.newDirectoryStream(tracksPath, - entry -> entry.toString().endsWith(".track")); + DirectoryStream directoryStream = Files.newDirectoryStream( + tracksPath, entry -> entry.toString().endsWith(".track")); for (Path filePath : directoryStream) { tracks.add(parser.parseStats(filePath)); } } return tracks; - } public static void convertTracks(Path rootDir) throws IOException { @@ -62,11 +60,12 @@ public static void convertTracks(Path rootDir) throws IOException { } counter++; } - logger.info("Converted " + counter + " tracks, ignored " + ignored +" tracks"); + logger.info("Converted " + counter + " tracks, ignored " + ignored + " tracks"); } /** * Consolidates categories of duplicate tracks + * * @param allStats List of all TrackStats * @return Consolidated collection of TrackStats */ @@ -78,8 +77,8 @@ public static Collection consolidateTracks(List allStats return allStats.stream() .filter(stat -> distinct.containsKey(stat.getTrack().getName())) .collect( - Collectors.toMap(stats -> stats.getTrack().getName(), stats -> stats, (first, second) -> first) - ).values(); + Collectors.toMap(stats -> stats.getTrack().getName(), stats -> stats, (first, second) -> first)) + .values(); } private static Track combineTracks(Track one, Track two) { diff --git a/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackFileParser.java b/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackFileParser.java index a924077b..e2fce167 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackFileParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackFileParser.java @@ -1,32 +1,26 @@ package org.moparforia.shared.tracks.parsers; +import java.io.IOException; +import java.nio.file.Path; +import java.time.LocalDate; +import java.util.*; import org.moparforia.shared.tracks.Track; import org.moparforia.shared.tracks.TrackCategory; import org.moparforia.shared.tracks.filesystem.FileSystemTrackStats; import org.moparforia.shared.tracks.filesystem.lineparser.*; -import org.moparforia.shared.tracks.parsers.GenericTrackParser; -import org.moparforia.shared.tracks.parsers.LineParser; -import org.moparforia.shared.tracks.parsers.TrackParser; import org.moparforia.shared.tracks.stats.TrackStats; -import java.io.IOException; -import java.nio.file.Path; -import java.time.LocalDate; -import java.util.*; - /** - * Class for parsing Track V1 file in format like this. - * Allows for parsing of similar files or adding custom properties. + * Class for parsing Track V1 file in format like this. Allows for parsing of similar files or + * adding custom properties. * - * @deprecated "TrackFileParser can only parser V1 tracks without category, use VersionedTrackFileParser for V2+" - * V 1 - * A {AUTHOR OF TRACK} - * N {NAME OF TRACK} - * T data - * I {NUMBER OF PLAYERS TO COMPLETE},{NUMBER OF STROKES},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT GOT BEST STROKE} - * B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 - * L {LAST BEST PAR PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 - * R {RATING: 0},{RATING: 1},{RATING: 2},{RATING: 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: 9},{RATING: 10} + * @deprecated "TrackFileParser can only parser V1 tracks without category, use + * VersionedTrackFileParser for V2+" V 1 A {AUTHOR OF TRACK} N {NAME OF TRACK} T data I {NUMBER + * OF PLAYERS TO COMPLETE},{NUMBER OF STROKES},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT + * GOT BEST STROKE} B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 L {LAST BEST + * PAR PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 R {RATING: 0},{RATING: 1},{RATING: + * 2},{RATING: 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: + * 9},{RATING: 10} */ @Deprecated public class TrackFileParser extends GenericTrackParser implements TrackParser { @@ -35,9 +29,9 @@ public class TrackFileParser extends GenericTrackParser implements TrackParser { private static final Map STATS_PARSERS; private final Set categories; + // Initialize parser with all LineParsers - static - { + static { HashMap tmp_map = new HashMap<>(); tmp_map.put('A', new SimpleLineParser("author")); tmp_map.put('N', new SimpleLineParser("name")); @@ -46,8 +40,8 @@ public class TrackFileParser extends GenericTrackParser implements TrackParser { tmp_map.put('R', new RatingsLineParser()); tmp_map.put('I', new ScoreInfoLineParser()); tmp_map.put('B', new BestTimeLineParser("bestTime", "bestPlayer")); -// Uncomment if you want to also parse lastTime and lastPlayer -// tmp_map.put("L", new BestTimeLineParser("lastTime", "lastPlayer")); + // Uncomment if you want to also parse lastTime and lastPlayer + // tmp_map.put("L", new BestTimeLineParser("lastTime", "lastPlayer")); STATS_PARSERS = Collections.unmodifiableMap(tmp_map); } @@ -83,8 +77,6 @@ public TrackStats parseStats(Path path) throws IOException { double bestParPercentage = (double) numberOfBestPar / attempts; return new FileSystemTrackStats( - attempts, strokes, bestPar, bestParPercentage, numberOfBestPar, bestPlayer, bestTime, ratings, track - ); + attempts, strokes, bestPar, bestParPercentage, numberOfBestPar, bestPlayer, bestTime, ratings, track); } - } diff --git a/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackParser.java b/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackParser.java index 4d131e7b..7eb16462 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/parsers/TrackParser.java @@ -1,10 +1,9 @@ package org.moparforia.shared.tracks.parsers; -import org.moparforia.shared.tracks.Track; -import org.moparforia.shared.tracks.stats.TrackStats; - import java.io.IOException; import java.nio.file.Path; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.stats.TrackStats; public interface TrackParser { Track parseTrack(Path path) throws IOException; diff --git a/shared/src/main/java/org/moparforia/shared/tracks/parsers/VersionedTrackFileParser.java b/shared/src/main/java/org/moparforia/shared/tracks/parsers/VersionedTrackFileParser.java index 31899704..cbdc1983 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/parsers/VersionedTrackFileParser.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/parsers/VersionedTrackFileParser.java @@ -1,11 +1,5 @@ package org.moparforia.shared.tracks.parsers; -import org.moparforia.shared.tracks.Track; -import org.moparforia.shared.tracks.TrackCategory; -import org.moparforia.shared.tracks.filesystem.FileSystemTrackStats; -import org.moparforia.shared.tracks.filesystem.lineparser.*; -import org.moparforia.shared.tracks.stats.TrackStats; - import java.io.IOException; import java.nio.file.Path; import java.time.LocalDate; @@ -13,22 +7,22 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import org.moparforia.shared.tracks.Track; +import org.moparforia.shared.tracks.TrackCategory; +import org.moparforia.shared.tracks.filesystem.FileSystemTrackStats; +import org.moparforia.shared.tracks.filesystem.lineparser.*; +import org.moparforia.shared.tracks.stats.TrackStats; /** - * Class for parsing Track V2 file which has this format. - * It differs from V1 file format in that it include list of categories - * There is intentional code duplication from TrackFileParser because I want to make them independent of each other as - * TrackFileParser is deprecated + * Class for parsing Track V2 file which has this format. It differs from V1 file format in that it + * include list of categories There is intentional code duplication from TrackFileParser because I + * want to make them independent of each other as TrackFileParser is deprecated * - * V >=2 - * A {AUTHOR OF TRACK} - * N {NAME OF TRACK} - * T data - * C {CategoryId}, {CategoryId}, ... - * I {NUMBER OF PLAYERS TO COMPLETE},{NUMBER OF STROKES},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT GOT BEST STROKE} - * B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 - * L {LAST BEST PAR PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 - * R {RATING: 0},{RATING: 1},{RATING: 2},{RATING: 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: 9},{RATING: 10} + *

V >=2 A {AUTHOR OF TRACK} N {NAME OF TRACK} T data C {CategoryId}, {CategoryId}, ... I {NUMBER + * OF PLAYERS TO COMPLETE},{NUMBER OF STROKES},{BEST NUMBER OF STROKES},{NUMBER OF PEOPLE THAT GOT + * BEST STROKE} B {FIRST BEST PAR PLAYER},{UNIX TIMESTAMP OF FIRST BEST PAR}000 L {LAST BEST PAR + * PLAYER},{UNIX TIMESTAMP OF LAST BEST PAR}000 R {RATING: 0},{RATING: 1},{RATING: 2},{RATING: + * 3},{RATING: 4},{RATING: 5},{RATING: 6},{RATING: 7},{RATING: 8},{RATING: 9},{RATING: 10} */ public class VersionedTrackFileParser extends GenericTrackParser implements TrackParser { public static final int DEFAULT_ALLOWED_FILE_VERSION = 2; @@ -36,8 +30,7 @@ public class VersionedTrackFileParser extends GenericTrackParser implements Trac protected static final Map STATS_PARSERS; // Initialize parser with all LineParsers - static - { + static { HashMap tmp_map = new HashMap<>(); tmp_map.put('V', new SingleArgumentLineParser<>("version", Integer::parseInt)); tmp_map.put('A', new SimpleLineParser("author")); @@ -48,8 +41,8 @@ public class VersionedTrackFileParser extends GenericTrackParser implements Trac tmp_map.put('R', new RatingsLineParser()); tmp_map.put('I', new ScoreInfoLineParser()); tmp_map.put('B', new BestTimeLineParser("bestTime", "bestPlayer")); -// Uncomment if you want to also parse lastTime and lastPlayer -// tmp_map.put("L", new BestTimeLineParser("lastTime", "lastPlayer")); + // Uncomment if you want to also parse lastTime and lastPlayer + // tmp_map.put("L", new BestTimeLineParser("lastTime", "lastPlayer")); STATS_PARSERS = Collections.unmodifiableMap(tmp_map); } @@ -67,7 +60,12 @@ public Track parseTrack(Path path) throws IOException { Map parsed = parse(BASE_PARSERS, path); int version = (int) parsed.getOrDefault("version", 0); if (version < allowed_version) { - throw new InvalidTrackVersion("Track in file " + path + " has unsupported version " + version + ", while this parser requires " + allowed_version); + throw new InvalidTrackVersion("Track in file " + + path + + " has unsupported version " + + version + + ", while this parser requires " + + allowed_version); } return constructTrack(parsed); } @@ -85,7 +83,12 @@ public TrackStats parseStats(Path path) throws IOException { Map parsed = parse(STATS_PARSERS, path); int version = (int) parsed.getOrDefault("version", 0); if (version < allowed_version) { - throw new InvalidTrackVersion("Track in file " + path + " has unsupported version " + version + ", while this parser requires " + allowed_version); + throw new InvalidTrackVersion("Track in file " + + path + + " has unsupported version " + + version + + ", while this parser requires " + + allowed_version); } Track track = constructTrack(parsed); int[] ratings = (int[]) parsed.getOrDefault("ratings", new int[10]); @@ -101,7 +104,6 @@ public TrackStats parseStats(Path path) throws IOException { double bestParPercentage = (double) numberOfBestPar / attempts; return new FileSystemTrackStats( - attempts, strokes, bestPar, bestParPercentage, numberOfBestPar, bestPlayer, bestTime, ratings, track - ); + attempts, strokes, bestPar, bestParPercentage, numberOfBestPar, bestPlayer, bestTime, ratings, track); } } diff --git a/shared/src/main/java/org/moparforia/shared/tracks/stats/StatsManager.java b/shared/src/main/java/org/moparforia/shared/tracks/stats/StatsManager.java index db88b20d..8f988bcb 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/stats/StatsManager.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/stats/StatsManager.java @@ -20,8 +20,8 @@ public interface StatsManager { /** * Add score to the player for that tracks * - * @param player Name of the player that scored par - * @param par Par + * @param player Name of the player that scored par + * @param par Par */ void addScore(Track track, String player, int par); diff --git a/shared/src/main/java/org/moparforia/shared/tracks/stats/TrackStats.java b/shared/src/main/java/org/moparforia/shared/tracks/stats/TrackStats.java index 678cac12..abac8bde 100644 --- a/shared/src/main/java/org/moparforia/shared/tracks/stats/TrackStats.java +++ b/shared/src/main/java/org/moparforia/shared/tracks/stats/TrackStats.java @@ -1,11 +1,11 @@ package org.moparforia.shared.tracks.stats; -import org.moparforia.shared.tracks.Track; - import java.time.LocalDate; +import org.moparforia.shared.tracks.Track; /** - * Interface that represent all the statistics for specific track, class is interface so it supports lazy loading + * Interface that represent all the statistics for specific track, class is interface so it supports + * lazy loading */ public interface TrackStats { @@ -44,10 +44,10 @@ public interface TrackStats { */ LocalDate getBestParTime(); - /** - * Returns ratings of this track. - * Index is representing the actual rating and the value is number of ratings of that value + * Returns ratings of this track. Index is representing the actual rating and the value is + * number of ratings of that value + * * @return Array of all the ratings of size 10 */ int[] getRatings(); @@ -64,12 +64,11 @@ public interface TrackStats { /** * Converts TrackStats into serializable string + * * @return Serialized string, separated by splitter */ String serialize(String splitter); - /** - * Converts to format supported by Client - */ + /** Converts to format supported by Client */ String networkSerialize(); } diff --git a/shared/src/main/java/org/moparforia/shared/utils/CollectorUtils.java b/shared/src/main/java/org/moparforia/shared/utils/CollectorUtils.java index 443daba4..a29a56b5 100644 --- a/shared/src/main/java/org/moparforia/shared/utils/CollectorUtils.java +++ b/shared/src/main/java/org/moparforia/shared/utils/CollectorUtils.java @@ -13,5 +13,4 @@ public class CollectorUtils { return collected.stream(); }); } - } diff --git a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/Convert.java b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/Convert.java index e181af9a..00cbe22d 100644 --- a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/Convert.java +++ b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/Convert.java @@ -1,12 +1,11 @@ package org.moparforia.shared.tracks.filesystem; -import org.moparforia.shared.tracks.parsers.TrackConverter; - import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; +import org.moparforia.shared.tracks.parsers.TrackConverter; public class Convert { public static void main(String[] args) throws URISyntaxException, IOException { diff --git a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/FileSystemStatsManagerTest.java b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/FileSystemStatsManagerTest.java index 70186761..5a13beae 100644 --- a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/FileSystemStatsManagerTest.java +++ b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/FileSystemStatsManagerTest.java @@ -1,5 +1,13 @@ package org.moparforia.shared.tracks.filesystem; +import static java.lang.Double.NaN; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -9,16 +17,6 @@ import org.moparforia.shared.tracks.stats.TrackStats; import org.moparforia.shared.tracks.util.FileSystemExtension; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.FileSystem; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; - -import static java.lang.Double.NaN; -import static org.junit.jupiter.api.Assertions.assertEquals; - class FileSystemStatsManagerTest { private final double PRECISION = 0.001d; @@ -27,8 +25,8 @@ class FileSystemStatsManagerTest { FileSystemStatsManager statsManager; - Track single = new Track("4 da Crew", "Aither", "Data", - new HashSet<>(Arrays.asList(TrackCategory.MODERN, TrackCategory.BASIC))); + Track single = new Track( + "4 da Crew", "Aither", "Data", new HashSet<>(Arrays.asList(TrackCategory.MODERN, TrackCategory.BASIC))); Track empty_stats = new Track("SprtTrack", "Sprt", "Data", Collections.singleton(TrackCategory.MODERN)); @BeforeEach @@ -47,7 +45,7 @@ void testSimpleLoad() throws IOException, URISyntaxException { assertEquals(537, stats.getTotalAttempts()); assertEquals(11734, stats.getTotalStrokes()); assertEquals(4, stats.getBestPar()); - assertEquals(0.039 , stats.getPercentageOfBestPar(), PRECISION); + assertEquals(0.039, stats.getPercentageOfBestPar(), PRECISION); assertEquals(7.752, stats.getAverageRating(), PRECISION); } @@ -62,8 +60,7 @@ void testEmptyStats() throws IOException, URISyntaxException { assertEquals(0, stats.getTotalAttempts()); assertEquals(0, stats.getTotalStrokes()); assertEquals(-1, stats.getBestPar()); - assertEquals(NaN , stats.getPercentageOfBestPar(), PRECISION); + assertEquals(NaN, stats.getPercentageOfBestPar(), PRECISION); assertEquals(NaN, stats.getAverageRating(), PRECISION); - } -} \ No newline at end of file +} diff --git a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackManagerTest.java b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackManagerTest.java index 7b26da08..b3606fc0 100644 --- a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackManagerTest.java +++ b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/FileSystemTrackManagerTest.java @@ -1,17 +1,16 @@ package org.moparforia.shared.tracks.filesystem; +import static org.junit.jupiter.api.Assertions.*; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.FileSystem; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.moparforia.shared.tracks.*; import org.moparforia.shared.tracks.util.FileSystemExtension; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.FileSystem; - -import static org.junit.jupiter.api.Assertions.*; - class FileSystemTrackManagerTest { @RegisterExtension final FileSystemExtension extension = new FileSystemExtension("v2/"); @@ -27,48 +26,46 @@ void beforeEach() { } /** - * Loads modern tracks - * Loads Tracksets + * Loads modern tracks Loads Tracksets * - * oakpark.trackset should be ignored because it didnt contain any loaded tracks + *

oakpark.trackset should be ignored because it didnt contain any loaded tracks * birchwood.trackset should have only 2 tracks */ - @Test - void testSimpleSetLoad() throws IOException, URISyntaxException, TrackLoadException { - extension.copyAll(); - - manager.load(tracksLocation); - assertEquals(1, manager.getTrackSets().size()); - TrackSet birchwood = manager.getTrackSet("Birchwood"); + @Test + void testSimpleSetLoad() throws IOException, URISyntaxException, TrackLoadException { + extension.copyAll(); - assertEquals(2, birchwood.getTracks().size()); - assertEquals("Birchwood", birchwood.getName()); - assertEquals(TrackSetDifficulty.EASY, birchwood.getDifficulty()); + manager.load(tracksLocation); + assertEquals(1, manager.getTrackSets().size()); + TrackSet birchwood = manager.getTrackSet("Birchwood"); - } + assertEquals(2, birchwood.getTracks().size()); + assertEquals("Birchwood", birchwood.getName()); + assertEquals(TrackSetDifficulty.EASY, birchwood.getDifficulty()); + } - @Test - void testLoad() throws IOException, URISyntaxException, TrackLoadException { - extension.copyAll(); + @Test + void testLoad() throws IOException, URISyntaxException, TrackLoadException { + extension.copyAll(); - manager.load(tracksLocation); - assertEquals(17, manager.getTracks().size()); - assertEquals(1, manager.getTrackSets().size()); + manager.load(tracksLocation); + assertEquals(17, manager.getTracks().size()); + assertEquals(1, manager.getTrackSets().size()); - assertEquals(6, manager.findAllByCategory(TrackCategory.MODERN).size()); - assertEquals(17, manager.findAllByCategory(TrackCategory.ALL).size()); - assertEquals(2, manager.findAllByCategory(TrackCategory.SHORT).size()); - assertEquals(3, manager.findAllByCategory(TrackCategory.TRADITIONAL).size()); - assertEquals(2 ,manager.findAllByCategory(TrackCategory.HIO).size()); - assertEquals(3, manager.findAllByCategory(TrackCategory.BASIC).size()); + assertEquals(6, manager.findAllByCategory(TrackCategory.MODERN).size()); + assertEquals(17, manager.findAllByCategory(TrackCategory.ALL).size()); + assertEquals(2, manager.findAllByCategory(TrackCategory.SHORT).size()); + assertEquals(3, manager.findAllByCategory(TrackCategory.TRADITIONAL).size()); + assertEquals(2, manager.findAllByCategory(TrackCategory.HIO).size()); + assertEquals(3, manager.findAllByCategory(TrackCategory.BASIC).size()); - assert manager.isLoaded(); - } + assert manager.isLoaded(); + } @Test void testRandomTracksIncorrectLimit() { - assertThrows(IllegalArgumentException.class, () -> manager.getRandomTracks(0, TrackCategory.ALL)); - assertThrows(IllegalArgumentException.class, () -> manager.getRandomTracks(-1, TrackCategory.ALL)); + assertThrows(IllegalArgumentException.class, () -> manager.getRandomTracks(0, TrackCategory.ALL)); + assertThrows(IllegalArgumentException.class, () -> manager.getRandomTracks(-1, TrackCategory.ALL)); } @Test @@ -78,14 +75,15 @@ void testRandomTracks() throws IOException, URISyntaxException, TrackLoadExcepti manager.load(tracksLocation); assertEquals(3, manager.getRandomTracks(3, TrackCategory.MODERN).size()); assertEquals(6, manager.getRandomTracks(50, TrackCategory.MODERN).size()); - } + } /** - * This means that if randomTracks is called on a category that doesn't have any tracks it will return empty list + * This means that if randomTracks is called on a category that doesn't have any tracks it will + * return empty list */ - @Test - void testRandomTracksEmpty() throws TrackLoadException { - manager.load(tracksLocation); - assertEquals(0, manager.getRandomTracks(50, TrackCategory.BASIC).size()); - } + @Test + void testRandomTracksEmpty() throws TrackLoadException { + manager.load(tracksLocation); + assertEquals(0, manager.getRandomTracks(50, TrackCategory.BASIC).size()); + } } diff --git a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/VersionTest.java b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/VersionTest.java index b1c480d0..46111f05 100644 --- a/shared/src/test/java/org/moparforia/shared/tracks/filesystem/VersionTest.java +++ b/shared/src/test/java/org/moparforia/shared/tracks/filesystem/VersionTest.java @@ -1,5 +1,9 @@ package org.moparforia.shared.tracks.filesystem; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.net.URISyntaxException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.moparforia.shared.tracks.TrackLoadException; @@ -7,11 +11,6 @@ import org.moparforia.shared.tracks.TracksLocation; import org.moparforia.shared.tracks.util.FileSystemExtension; -import java.io.IOException; -import java.net.URISyntaxException; - -import static org.junit.jupiter.api.Assertions.assertEquals; - public class VersionTest { @RegisterExtension final FileSystemExtension extension = new FileSystemExtension("v2/invalid"); @@ -26,5 +25,4 @@ void testTrackManagerInvalidVersions() throws IOException, URISyntaxException, T assertEquals(1, manager.getTracks().size()); } - } diff --git a/shared/src/test/java/org/moparforia/shared/tracks/parsers/TrackConverterTest.java b/shared/src/test/java/org/moparforia/shared/tracks/parsers/TrackConverterTest.java index 719a676c..38af07e8 100644 --- a/shared/src/test/java/org/moparforia/shared/tracks/parsers/TrackConverterTest.java +++ b/shared/src/test/java/org/moparforia/shared/tracks/parsers/TrackConverterTest.java @@ -1,5 +1,12 @@ package org.moparforia.shared.tracks.parsers; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Path; +import java.util.Collection; +import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.moparforia.shared.tracks.Track; @@ -8,22 +15,9 @@ import org.moparforia.shared.tracks.stats.TrackStats; import org.moparforia.shared.tracks.util.FileSystemExtension; -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Path; -import java.util.Collection; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertEquals; - class TrackConverterTest { - private final String[] DIRS = new String[]{ - "tracks/modern", - "tracks/traditional", - "tracks/short", - "tracks/long", - "tracks/basic", - "tracks/hio", + private final String[] DIRS = new String[] { + "tracks/modern", "tracks/traditional", "tracks/short", "tracks/long", "tracks/basic", "tracks/hio", }; @RegisterExtension @@ -37,7 +31,6 @@ void testConvertTracks() throws IOException, URISyntaxException { FileSystemStatsManager statsManager = new FileSystemStatsManager(); TracksLocation tracksLocation = new TracksLocation(this.extension.getFileSystem(), "tracks"); - Path tracks = extension.getFileSystem().getPath("tracks"); List stats = TrackConverter.loadOldTracks(tracks); Collection consolidated = TrackConverter.consolidateTracks(stats); @@ -51,4 +44,4 @@ void testConvertTracks() throws IOException, URISyntaxException { assertEquals(stat, statsManager.getStats(track)); } } -} \ No newline at end of file +} diff --git a/shared/src/test/java/org/moparforia/shared/tracks/util/FileSystemExtension.java b/shared/src/test/java/org/moparforia/shared/tracks/util/FileSystemExtension.java index cc204f9c..2e9c6f7e 100644 --- a/shared/src/test/java/org/moparforia/shared/tracks/util/FileSystemExtension.java +++ b/shared/src/test/java/org/moparforia/shared/tracks/util/FileSystemExtension.java @@ -1,10 +1,6 @@ package org.moparforia.shared.tracks.util; import com.github.marschall.memoryfilesystem.MemoryFileSystemBuilder; -import org.junit.jupiter.api.extension.AfterEachCallback; -import org.junit.jupiter.api.extension.BeforeEachCallback; -import org.junit.jupiter.api.extension.ExtensionContext; - import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.FileSystem; @@ -14,19 +10,20 @@ import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; +import org.junit.jupiter.api.extension.AfterEachCallback; +import org.junit.jupiter.api.extension.BeforeEachCallback; +import org.junit.jupiter.api.extension.ExtensionContext; public class FileSystemExtension implements BeforeEachCallback, AfterEachCallback { private static final String[] DIRS = { - "/tracks/tracks", - "/tracks/sets", + "/tracks/tracks", "/tracks/sets", }; private FileSystem fileSystem; private final String rootDir; private final String[] createDirs; - public FileSystemExtension(String rootDir, String[] dirs) - { + public FileSystemExtension(String rootDir, String[] dirs) { this.createDirs = dirs; this.rootDir = rootDir; } @@ -47,16 +44,17 @@ public void copyFile(String src) throws IOException, URISyntaxException { /** * Copies directory from resource folder into InMemory file system + * * @param dir Path to the dir */ public void copyDir(String dir) throws IOException, URISyntaxException { Path base = getRootDir(); Path resource = base.resolve(dir); - List files = Files.walk(resource) - .filter(Files::isRegularFile) - .collect(Collectors.toList()); + List files = Files.walk(resource).filter(Files::isRegularFile).collect(Collectors.toList()); for (Path file : files) { - Path relative_path = fileSystem.getPath(base.relativize(file).toString().replace(FileSystems.getDefault().getSeparator(), fileSystem.getSeparator())); + Path relative_path = fileSystem.getPath(base.relativize(file) + .toString() + .replace(FileSystems.getDefault().getSeparator(), fileSystem.getSeparator())); Files.copy(base.resolve(file), relative_path); } } From 5e7c667bef424fb1bb8e4c68712d1237da93c128 Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Fri, 20 Sep 2024 08:41:22 +0300 Subject: [PATCH 3/4] Docs: Add .git-blame-ignore-revs This way the formatting from Spotless changes do not show up in `git blame`. --- .git-blame-ignore-revs | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..2e5ecbf6 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,5 @@ +# This file keeps `git blame` clean. +# See https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view + +# Reformat the codebase with Spotless +6e262ce1d8d66ac83af70b557269f1ed584f7438 From 200c77c53ffb8b57b1cf181c6fd92a3b146a43ab Mon Sep 17 00:00:00 2001 From: Sten Laane <21343173+StenAL@users.noreply.github.com> Date: Fri, 20 Sep 2024 08:41:23 +0300 Subject: [PATCH 4/4] Build: Run Spotless formatting checks This will ensure that the codebase remains consistently formatted. --- pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pom.xml b/pom.xml index d2fec17d..636d9a3d 100644 --- a/pom.xml +++ b/pom.xml @@ -160,6 +160,13 @@ + + + + check + + +