Skip to content

Commit

Permalink
Read line separator from local file instead of using the OS separator.
Browse files Browse the repository at this point in the history
…Closes #3
  • Loading branch information
NiklasEi committed Jul 13, 2018
1 parent 98a4875 commit 1ff050b
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 7 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### v 2.0.2
- fix problems loading puzzles with some operating systems
- bump GameBox dependency to 2.1.4

### v 2.0.1
- change way to detect OS dependent length of lines in the puzzles files
- push gamebox min version to 2.1.0
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.nikl</groupId>
<artifactId>logicpuzzles</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>

<repositories>
<repository>
Expand All @@ -31,7 +31,7 @@
<dependency>
<groupId>me.nikl</groupId>
<artifactId>gamebox-core</artifactId>
<version>2.1.2</version>
<version>2.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/nikl/logicpuzzles/sudoku/Sudoku.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public void loadSettings() {
gameSettings.setGameType(GameSettings.GameType.SINGLE_PLAYER);
gameSettings.setGameGuiSize(54);
gameSettings.setHandleClicksOnHotbar(false);
gameSettings.setGameBoxMinimumVersion("2.1.0");
gameSettings.setGameBoxMinimumVersion("2.1.4");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.nikl.gamebox.game.exceptions.GameStartException;
import me.nikl.gamebox.game.manager.GameManager;
import me.nikl.gamebox.game.rules.GameRule;
import me.nikl.gamebox.utility.FileUtility;
import me.nikl.gamebox.utility.ItemStackUtility;
import me.nikl.gamebox.utility.Permission;
import me.nikl.gamebox.utility.StringUtility;
Expand Down Expand Up @@ -35,7 +36,7 @@
* Sudoku GameManager
*/
public class SudokuGameManager implements GameManager {
private static final int NEW_LINE_CHAR_LENGTH = System.lineSeparator().getBytes().length;
private static int NEW_LINE_CHAR_LENGTH;
private static int LINE_LENGTH;
private Sudoku game;
private Map<UUID, SudokuGame> games = new HashMap<>();
Expand All @@ -61,6 +62,7 @@ public SudokuGameManager(Sudoku game){
}
try {
this.raf = new RandomAccessFile(puzzle, "r");
NEW_LINE_CHAR_LENGTH = FileUtility.retrieveLineSeparator(puzzle).getBytes().length;
LINE_LENGTH = raf.readLine().getBytes().length + NEW_LINE_CHAR_LENGTH;
} catch (FileNotFoundException e) {
Bukkit.getConsoleSender().sendMessage(lang.PREFIX + ChatColor.RED + " Puzzles file is missing!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void loadSettings() {
gameSettings.setGameType(GameSettings.GameType.SINGLE_PLAYER);
gameSettings.setHandleClicksOnHotbar(false);
gameSettings.setGameGuiSize(54);
gameSettings.setGameBoxMinimumVersion("2.1.0");
gameSettings.setGameBoxMinimumVersion("2.1.4");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.nikl.gamebox.game.exceptions.GameStartException;
import me.nikl.gamebox.game.manager.GameManager;
import me.nikl.gamebox.game.rules.GameRule;
import me.nikl.gamebox.utility.FileUtility;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
Expand All @@ -26,7 +27,7 @@
* Created by nikl on 25.02.18.
*/
public class TiarManager implements GameManager {
private static final int NEW_LINE_CHAR_LENGTH = System.lineSeparator().getBytes().length;
private static int NEW_LINE_CHAR_LENGTH;
private static int LINE_LENGTH;
private ThreeInARow game;
private Map<UUID, TiarGame> games = new HashMap<>();
Expand All @@ -52,6 +53,7 @@ private void loadPuzzles() {
}
try {
this.raf = new RandomAccessFile(puzzle, "r");
NEW_LINE_CHAR_LENGTH = FileUtility.retrieveLineSeparator(puzzle).getBytes().length;
LINE_LENGTH = raf.readLine().getBytes().length + NEW_LINE_CHAR_LENGTH;
} catch (FileNotFoundException e) {
game.warn(" Puzzles file is missing!");
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: LogicPuzzles
author: Nikl
main: me.nikl.logicpuzzles.LogicPuzzles
version: 2.0.1
version: 2.0.2
website: nikl.me
depend: [GameBox]

0 comments on commit 1ff050b

Please sign in to comment.