diff --git a/build.gradle b/build.gradle index 2af357a..33fa2ff 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ import org.gradle.internal.os.OperatingSystem; apply plugin: 'java' apply plugin: 'idea' -def major = 1, minor = 4, patch = 4; +def major = 1, minor = 4, patch = 5 version = "$major.$minor.$patch" @@ -60,30 +60,30 @@ repositories { jcenter() } -def minecraftFolder; +def minecraftFolder if (OperatingSystem.current().isMacOsX()) { - minecraftFolder = "${System.properties['user.home']}/Library/Application Support/minecraft"; + minecraftFolder = "${System.properties['user.home']}/Library/Application Support/minecraft" } else if (OperatingSystem.current().isLinux()) { - minecraftFolder = "${System.properties['user.home']}/.minecraft"; + minecraftFolder = "${System.properties['user.home']}/.minecraft" } else if (OperatingSystem.current().isWindows()) { - minecraftFolder = "$System.env.APPDATA/.minecraft"; + minecraftFolder = "$System.env.APPDATA/.minecraft" } else { - throw new FileNotFoundException("No minecraft folder detected"); + throw new FileNotFoundException("No minecraft folder detected") } def minecraftLibraries = fileTree(dir: "$minecraftFolder/libraries", include: '**/*.jar') dependencies { - compile 'org.json:json:20170516' + compile 'org.json:json:20171018' compile 'org.iq80.leveldb:leveldb:0.9' // the following dependencies are provided at runtime by minecraft compileOnly 'org.apache.httpcomponents:httpclient:4.5.3' - compileOnly 'com.google.code.gson:gson:2.8.1' - compileOnly 'org.apache.logging.log4j:log4j-api:2.9.0' - compileOnly 'com.google.guava:guava:23.0' + compileOnly 'com.google.code.gson:gson:2.8.2' + compileOnly 'org.apache.logging.log4j:log4j-api:2.9.1' + compileOnly 'com.google.guava:guava:23.4-jre' compileOnly 'org.lwjgl.lwjgl:lwjgl:2.9.3' - compileOnly 'org.apache.commons:commons-lang3:3.6' + compileOnly 'org.apache.commons:commons-lang3:3.7' compileOnly minecraftLibraries.matching { include '**/authlib-1.5.25.jar' } compileOnly fileTree(dir: 'libs', include: 'The-5zig-API-*.jar') diff --git a/src/main/java/net/frozenbit/plugin5zig/cubecraft/Main.java b/src/main/java/net/frozenbit/plugin5zig/cubecraft/Main.java index ec82b5b..07e9097 100644 --- a/src/main/java/net/frozenbit/plugin5zig/cubecraft/Main.java +++ b/src/main/java/net/frozenbit/plugin5zig/cubecraft/Main.java @@ -140,38 +140,15 @@ public void onLoad(LoadEvent loadEvent) { The5zigAPI.getAPI().registerModuleItem(this, "cubecraftstalker", StalkerItem.class, "cubecraft"); The5zigAPI.getAPI().registerModuleItem(this, "cubecraftassassinationmoney", MoneyItem.class, "cubecraft"); The5zigAPI.getAPI().registerModuleItem(this, "cubecraftduelsopponent", OpponentItem.class, "cubecraft"); - The5zigAPI.getAPI().registerModuleItem(this, "cubecrafttowerdefencebanter", TowerBanterItem.class, "cubecraft"); + //The5zigAPI.getAPI().registerModuleItem(this, "cubecrafttowerdefencebanter", TowerBanterItem.class, "cubecraft"); leaveKey = The5zigAPI.getAPI().registerKeyBiding("Leave the current game", Keyboard.KEY_L, "Cubecraft"); snakeKey = The5zigAPI.getAPI().registerKeyBiding("Toggle Snake", Keyboard.KEY_P, "Misc"); } - // copy the old skywars database - REMOVE THIS SOME TIME IN THE FUTURE! - migrateSkywarsDb(); - instance = this; } - private void migrateSkywarsDb() { - File source = new File("stalker.db"); - File target = PLUGIN_PATH.resolve("stalker/Skywars.db").toFile(); - if (source.isDirectory() && !target.isDirectory()) { - File[] db_files = source.listFiles(); - if (db_files == null) { - getLogger().println("old skywars stalker.db exists but can not be read"); - return; - } - try { - java.nio.file.Files.createDirectories(target.toPath()); - for (File file : db_files) { - Files.copy(file, new File(target, file.getName())); - } - } catch (IOException e) { - getLogger().println(e); - } - } - } - @EventHandler public void onJoin(ServerJoinEvent event) { if (!pluginEnabled && ServerInstance.isCubeCraft(event.getHost())) { diff --git a/src/main/java/net/frozenbit/plugin5zig/cubecraft/items/StalkerItem.java b/src/main/java/net/frozenbit/plugin5zig/cubecraft/items/StalkerItem.java index ed6130a..de483a6 100644 --- a/src/main/java/net/frozenbit/plugin5zig/cubecraft/items/StalkerItem.java +++ b/src/main/java/net/frozenbit/plugin5zig/cubecraft/items/StalkerItem.java @@ -33,7 +33,7 @@ public void render(int x, int y, RenderLocation renderLocation, boolean dummy) { return; drawHeader(x, y); int lineNumber = 1; - synchronized (stalkedPlayers) { + synchronized (getGameMode().getStalker().getStalkedPlayerList()) { for (StalkedPlayer player : stalkedPlayers) { if (player.getKills() == 0 && player.getDeaths() == 0) continue; diff --git a/src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/Stalker.java b/src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/Stalker.java index febf2f5..69a8aa3 100644 --- a/src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/Stalker.java +++ b/src/main/java/net/frozenbit/plugin5zig/cubecraft/stalker/Stalker.java @@ -15,7 +15,7 @@ public class Stalker { private String ownName; private GameMode gameMode; private final List stalkedPlayerList; - private final List provisionalStalkedPlayerList; + private final List internalStalkedPlayerList; private int maxNameWidth = 0; private int shownPlayerCount = 0; private int playerListIteration = 0; @@ -25,7 +25,7 @@ public Stalker(GameMode gameMode) { storage = new Storage(gameMode); ownName = The5zigAPI.getAPI().getGameProfile().getName(); stalkedPlayerList = new ArrayList<>(); - provisionalStalkedPlayerList = new ArrayList<>(); + internalStalkedPlayerList = new ArrayList<>(); } public void onKill(String victim, String killer) { @@ -62,8 +62,8 @@ public void onPlayerListUpdate(final List playerList) { final int frozenPlayerListIteration = ++playerListIteration; shownPlayerCount = 0; new Thread(() -> { - provisionalStalkedPlayerList.clear(); - synchronized (provisionalStalkedPlayerList) { + synchronized (internalStalkedPlayerList) { + internalStalkedPlayerList.clear(); for (CubeCraftPlayer cubeCraftPlayer : playerList) { if (playerListIteration != frozenPlayerListIteration) return; @@ -71,10 +71,13 @@ public void onPlayerListUpdate(final List playerList) { StalkedPlayer stalkedPlayer = storage.getStalkedPlayer(cubeCraftPlayer); if (stalkedPlayer.getKills() != 0 || stalkedPlayer.getDeaths() != 0) ++shownPlayerCount; - provisionalStalkedPlayerList.add(stalkedPlayer); + internalStalkedPlayerList.add(stalkedPlayer); } + if (playerListIteration != frozenPlayerListIteration) + return; synchronized (stalkedPlayerList) { - stalkedPlayerList.addAll(provisionalStalkedPlayerList); + stalkedPlayerList.clear(); + stalkedPlayerList.addAll(internalStalkedPlayerList); } } }).start(); diff --git a/src/main/resources/core/messages/cubecraft.properties b/src/main/resources/core/messages/cubecraft.properties index ecf3022..3e2e2ae 100644 --- a/src/main/resources/core/messages/cubecraft.properties +++ b/src/main/resources/core/messages/cubecraft.properties @@ -6,13 +6,13 @@ # will be accessible in this IPatternResult. # Some expressions are already pre-defined and will be replaced by the mod: %p will match any valid # Minecraft player name, %d will match any (positive or negative) integer. -generic.welcome=Welcome to CubeCraft Games! +generic.welcome=\u0020+ message.receive.friend=\\[Friend\\] (%p): .* message.receive.pm=:.+: (%p) -> Me: .* generic.playerList=There are %d players online: (.+) generic.points=\\+(%d) points? -generic.join=%p joined the game\\. %d/%d -generic.left=(%p) left the game\\. %d/%d +generic.join=\\[\\+\\] %p joined your game \\(%d/%d\\). +generic.left=\\[-\\] (%p) left your game \\(%d/%d\\). generic.kit=Selected kit (.+) generic.death.fall=(%p) (?:fell to their death|couldn't fly)\\.? generic.death.fire=(%p) (?:burned to death|burnt to a crisp)\\.? diff --git a/src/main/resources/lang/language_en_US.properties b/src/main/resources/lang/language_en_US.properties index 4d3323e..d71f21b 100644 --- a/src/main/resources/lang/language_en_US.properties +++ b/src/main/resources/lang/language_en_US.properties @@ -11,8 +11,8 @@ modules.item.cubecraftassassinationmoney=Money Assassinations modules.item.cubecraftassassinationmoney.desc=Shows how much money you have in your inventory in Assassinations modules.item.cubecraftduelsopponent=Opponent Duels modules.item.cubecraftduelsopponent.desc=Shows the name and ping of the player you are fighting against Duels. -modules.item.cubecrafttowerdefencebanter=Tower prices -modules.item.cubecrafttowerdefencebanter.desc=Shows a list of all towers, their price and whether you have enough coins CubeCraft Tower Defence. +#modules.item.cubecrafttowerdefencebanter=Tower prices +#modules.item.cubecrafttowerdefencebanter.desc=Shows a list of all towers, their price and whether you have enough coins CubeCraft Tower Defence. modules.item.snake=Snake game modules.item.snake.desc=Play a game of snake! (toggle with P) #