From 40d27c787c63ebd972c881d900f3dd7b0b52602d Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 1 Sep 2019 13:21:20 -0400 Subject: [PATCH 1/7] Fixed drones not finding blocked ores --- core/src/io/anuke/mindustry/ai/BlockIndexer.java | 9 ++++----- core/src/io/anuke/mindustry/core/NetServer.java | 4 ++-- core/src/io/anuke/mindustry/game/MusicControl.java | 2 +- core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java | 2 +- .../world/blocks/power/ItemLiquidGenerator.java | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/io/anuke/mindustry/ai/BlockIndexer.java b/core/src/io/anuke/mindustry/ai/BlockIndexer.java index a31b2bbf8a..a9e575f35d 100644 --- a/core/src/io/anuke/mindustry/ai/BlockIndexer.java +++ b/core/src/io/anuke/mindustry/ai/BlockIndexer.java @@ -242,14 +242,13 @@ public class BlockIndexer{ int quadrantY = tile.y / quadrantSize; itemSet.clear(); - Tile rounded = world.tile(Mathf.clamp(quadrantX * quadrantSize + quadrantSize / 2, 0, world.width() - 1), - Mathf.clamp(quadrantY * quadrantSize + quadrantSize / 2, 0, world.height() - 1)); + Tile rounded = world.tile(Mathf.clamp(quadrantX * quadrantSize + quadrantSize / 2, 0, world.width() - 1), Mathf.clamp(quadrantY * quadrantSize + quadrantSize / 2, 0, world.height() - 1)); //find all items that this quadrant contains - for(int x = quadrantX * quadrantSize; x < world.width() && x < (quadrantX + 1) * quadrantSize; x++){ - for(int y = quadrantY * quadrantSize; y < world.height() && y < (quadrantY + 1) * quadrantSize; y++){ + for(int x = Math.max(0, rounded.x - quadrantSize / 2); x < rounded.x + quadrantSize / 2 && x < world.width(); x++){ + for(int y = Math.max(0, rounded.y - quadrantSize / 2); y < rounded.y + quadrantSize / 2 && y < world.height(); y++){ Tile result = world.tile(x, y); - if(result == null || result.drop() == null || !scanOres.contains(result.drop())) continue; + if(result == null || result.drop() == null || !scanOres.contains(result.drop()) || result.block() != Blocks.air) continue; itemSet.add(result.drop()); } diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index c27120d513..dc05026b2d 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -261,7 +261,7 @@ public class NetServer implements ApplicationListener{ } //cooldown between votes - int voteTime = 60 * 10; + int voteTime = 60 * 5; Timekeeper vtime = new Timekeeper(voteTime); //current kick sessions ObjectMap currentlyKicking = new ObjectMap<>(); @@ -332,7 +332,7 @@ public class NetServer implements ApplicationListener{ } public int votesRequired(){ - return playerGroup.size() * 2 / 3; + return 2 + (int)(playerGroup.size() * 0.2f); } public Team assignTeam(Player current, Iterable players){ diff --git a/core/src/io/anuke/mindustry/game/MusicControl.java b/core/src/io/anuke/mindustry/game/MusicControl.java index 28991e87e2..dc16c5d464 100644 --- a/core/src/io/anuke/mindustry/game/MusicControl.java +++ b/core/src/io/anuke/mindustry/game/MusicControl.java @@ -14,7 +14,7 @@ import static io.anuke.mindustry.Vars.*; /** Controls playback of multiple music tracks.*/ public class MusicControl{ - private static final float finTime = 120f, foutTime = 120f, musicInterval = 60 * 60 * 3f, musicChance = 0.5f, musicWaveChance = 0.4f; + private static final float finTime = 120f, foutTime = 120f, musicInterval = 60 * 60 * 3f, musicChance = 0.6f, musicWaveChance = 0.5f; /** normal, ambient music, plays at any time */ public final Array ambientMusic = Array.with(Musics.game1, Musics.game3, Musics.game4, Musics.game6); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java index 11aa1a3a4f..1f2c04873b 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/MapsDialog.java @@ -80,7 +80,7 @@ public class MapsDialog extends FloatingDialog{ String name = map.tags.getOr("name", () -> { String result = "unknown"; int number = 0; - while(maps.byName(result + number++) != null) ; + while(maps.byName(result + number++) != null); return result + number; }); diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java index a57f165907..a72d5ae1d8 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java @@ -37,7 +37,7 @@ public class ItemLiquidGenerator extends PowerGenerator{ protected Effects.Effect explodeEffect = Fx.generatespark; protected Color heatColor = Color.valueOf("ff9b59"); protected TextureRegion topRegion, liquidRegion; - protected boolean randomlyExplode = false; + protected boolean randomlyExplode = true; public ItemLiquidGenerator(boolean hasItems, boolean hasLiquids, String name){ super(name); From 494c3ffbc4d741b3be1fd13575ca70ad2957f096 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 1 Sep 2019 13:34:20 -0400 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/io/anuke/mindustry/world/Block.java | 2 +- .../mindustry/world/blocks/power/ItemLiquidGenerator.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 189911c66f..3ef71587e2 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -581,7 +581,7 @@ public class Block extends BlockStorage{ }); } - Damage.dynamicExplosion(x, y, flammability, explosiveness, power, tilesize * size / 2f, Pal.darkFlame); + Damage.dynamicExplosion(x, y, flammability, explosiveness * 3.5f, power, tilesize * size / 2f, Pal.darkFlame); if(!tile.floor().solid && !tile.floor().isLiquid){ RubbleDecal.create(tile.drawx(), tile.drawy(), size); } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java index a72d5ae1d8..d32813791d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java @@ -127,8 +127,10 @@ public class ItemLiquidGenerator extends PowerGenerator{ if(randomlyExplode && Mathf.chance(entity.delta() * 0.06 * Mathf.clamp(entity.explosiveness - 0.5f))){ //this block is run last so that in the event of a block destruction, no code relies on the block type - entity.damage(Mathf.random(11f)); - Effects.effect(explodeEffect, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f)); + Core.app.post(() -> { + entity.damage(Mathf.random(11f)); + Effects.effect(explodeEffect, tile.worldx() + Mathf.range(size * tilesize / 2f), tile.worldy() + Mathf.range(size * tilesize / 2f)); + }); } }else{ entity.productionEfficiency = 0.0f; From e8d89b6c43cf681dd11bf6d61b0f882ae01f8255 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 1 Sep 2019 15:52:07 -0400 Subject: [PATCH 3/7] Bugfixes --- .../io/anuke/mindustry/core/NetServer.java | 19 +++++++++++++------ .../mindustry/entities/type/BaseUnit.java | 2 +- .../anuke/mindustry/entities/type/Player.java | 3 ++- .../anuke/mindustry/input/InputHandler.java | 4 ++-- .../ui/fragments/BlockInventoryFragment.java | 2 +- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index dc05026b2d..ce6c8a5eea 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -228,7 +228,7 @@ public class NetServer implements ApplicationListener{ }); //duration of a a kick in seconds - int kickDuration = 10 * 60; + int kickDuration = 15 * 60; class VoteSession{ Player target; @@ -243,9 +243,9 @@ public class NetServer implements ApplicationListener{ this.task = Timer.schedule(() -> { if(!checkPass()){ Call.sendMessage(Strings.format("[lightgray]Vote failed. Not enough votes to kick[orange] {0}[lightgray].", target.name)); + map.remove(target); + task.cancel(); } - map.remove(target); - task.cancel(); }, 60 * 1.5f); } @@ -254,6 +254,8 @@ public class NetServer implements ApplicationListener{ Call.sendMessage(Strings.format("[orange]Vote passed.[scarlet] {0}[orange] will be kicked from the server.", target.name)); admins.getInfo(target.uuid).lastKicked = Time.millis() + kickDuration*1000; kick(target.con.id, KickReason.vote); + map.remove(target); + task.cancel(); return true; } return false; @@ -272,6 +274,11 @@ public class NetServer implements ApplicationListener{ return; } + if(player.isLocal){ + player.sendMessage("[scarlet]Just kick them yourself if you're the host."); + return; + } + if(currentlyKicking.values().toArray().contains(v -> v.voted.contains(player.uuid) || v.voted.contains(admins.getInfo(player.uuid).lastIP))){ player.sendMessage("[scarlet]You've already voted. Sit down."); return; @@ -296,10 +303,10 @@ public class NetServer implements ApplicationListener{ } if(found != null){ - if(player == found){ - player.sendMessage("[scarlet]If you're interested in kicking yourself, just leave."); - }else if(found.isAdmin){ + if(found.isAdmin){ player.sendMessage("[scarlet]Did you really expect to be able to kick an admin?"); + }else if(found.isLocal){ + player.sendMessage("[scarlet]Local players cannot be kicked."); }else{ if(!currentlyKicking.containsKey(found) && !vtime.get()){ player.sendMessage("[scarlet]You must wait " + voteTime/60 + " minutes between votekicks."); diff --git a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java index 82615e8a01..1c38ceb45c 100644 --- a/core/src/io/anuke/mindustry/entities/type/BaseUnit.java +++ b/core/src/io/anuke/mindustry/entities/type/BaseUnit.java @@ -58,7 +58,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{ //visual only. if(Net.client()){ Tile tile = world.tile(unit.spawner); - if(tile != null && !Net.client()){ + if(tile != null){ tile.block().unitRemoved(tile, unit); } diff --git a/core/src/io/anuke/mindustry/entities/type/Player.java b/core/src/io/anuke/mindustry/entities/type/Player.java index 0b481a6105..70a60ab4b1 100644 --- a/core/src/io/anuke/mindustry/entities/type/Player.java +++ b/core/src/io/anuke/mindustry/entities/type/Player.java @@ -37,6 +37,7 @@ import static io.anuke.mindustry.Vars.*; public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{ public static final int timerSync = 2; public static final int timerAbility = 3; + public static final int timerTransfer = 4; private static final int timerShootLeft = 0; private static final int timerShootRight = 1; private static final float liftoffBoost = 0.2f; @@ -59,7 +60,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{ public NetConnection con; public boolean isLocal = false; - public Interval timer = new Interval(4); + public Interval timer = new Interval(6); public TargetTrait target; public TargetTrait moveTarget; diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 6ed371a7ec..81de174e73 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -59,7 +59,7 @@ public abstract class InputHandler implements InputProcessor{ @Remote(targets = Loc.both, forward = true, called = Loc.server) public static void transferInventory(Player player, Tile tile){ - if(Net.server() && (player.item().amount <= 0 || player.isTransferring)){ + if(Net.server() && (player.item().amount <= 0 || player.isTransferring || !player.timer.get(Player.timerTransfer, 40))){ throw new ValidateException(player, "Player cannot transfer an item."); } @@ -288,7 +288,7 @@ public abstract class InputHandler implements InputProcessor{ } public void tryDropItems(Tile tile, float x, float y){ - if(!droppingItem || player.item().amount <= 0 || canTapPlayer(x, y) || state.isPaused()){ + if(!droppingItem || player.item().amount <= 0 || canTapPlayer(x, y) || state.isPaused() || !player.timer.check(Player.timerTransfer, 40)){ droppingItem = false; return; } diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java index 4a8b96707e..2ee2359185 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java @@ -40,7 +40,7 @@ public class BlockInventoryFragment extends Fragment{ @Remote(called = Loc.server, targets = Loc.both, forward = true) public static void requestItem(Player player, Tile tile, Item item, int amount){ - if(player == null || tile == null) return; + if(player == null || tile == null || !player.timer.get(Player.timerTransfer, 20)) return; int removed = tile.block().removeStack(tile, item, amount); From 9eed39c2aec2fa7fca064035b444c7b0acd99960 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 2 Sep 2019 12:34:15 -0400 Subject: [PATCH 4/7] Update NetServer.java --- .../io/anuke/mindustry/core/NetServer.java | 67 +++++++++++++------ 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index ce6c8a5eea..e050820def 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -233,20 +233,29 @@ public class NetServer implements ApplicationListener{ class VoteSession{ Player target; ObjectSet voted = new ObjectSet<>(); - ObjectMap map; + VoteSession[] map; Timer.Task task; int votes; - public VoteSession(ObjectMap map, Player target){ + public VoteSession(VoteSession[] map, Player target){ this.target = target; this.map = map; this.task = Timer.schedule(() -> { if(!checkPass()){ Call.sendMessage(Strings.format("[lightgray]Vote failed. Not enough votes to kick[orange] {0}[lightgray].", target.name)); - map.remove(target); + map[0] = null; task.cancel(); } - }, 60 * 1.5f); + }, 60 * 1); + } + + void vote(Player player, int d){ + votes += d; + voted.addAll(player.uuid, admins.getInfo(player.uuid).lastIP); + + Call.sendMessage(Strings.format("[orange]{0}[lightgray] has voted to kick[orange] {1}[].[accent] ({2}/{3})\n[lightgray]Type[orange] /vote [] to agree.", + player.name, target.name, votes, votesRequired())); + //checkPass(); } boolean checkPass(){ @@ -254,7 +263,7 @@ public class NetServer implements ApplicationListener{ Call.sendMessage(Strings.format("[orange]Vote passed.[scarlet] {0}[orange] will be kicked from the server.", target.name)); admins.getInfo(target.uuid).lastKicked = Time.millis() + kickDuration*1000; kick(target.con.id, KickReason.vote); - map.remove(target); + map[0] = null; task.cancel(); return true; } @@ -266,7 +275,7 @@ public class NetServer implements ApplicationListener{ int voteTime = 60 * 5; Timekeeper vtime = new Timekeeper(voteTime); //current kick sessions - ObjectMap currentlyKicking = new ObjectMap<>(); + VoteSession[] currentlyKicking = {null}; clientCommands.register("votekick", "[player...]", "Vote to kick a player, with a cooldown.", (args, player) -> { if(playerGroup.size() < 3){ @@ -279,11 +288,6 @@ public class NetServer implements ApplicationListener{ return; } - if(currentlyKicking.values().toArray().contains(v -> v.voted.contains(player.uuid) || v.voted.contains(admins.getInfo(player.uuid).lastIP))){ - player.sendMessage("[scarlet]You've already voted. Sit down."); - return; - } - if(args.length == 0){ StringBuilder builder = new StringBuilder(); builder.append("[orange]Players to kick: \n"); @@ -308,19 +312,15 @@ public class NetServer implements ApplicationListener{ }else if(found.isLocal){ player.sendMessage("[scarlet]Local players cannot be kicked."); }else{ - if(!currentlyKicking.containsKey(found) && !vtime.get()){ + if(!vtime.get()){ player.sendMessage("[scarlet]You must wait " + voteTime/60 + " minutes between votekicks."); return; } - VoteSession session = currentlyKicking.getOr(found, () -> new VoteSession(currentlyKicking, found)); - session.votes ++; - session.voted.addAll(player.uuid, admins.getInfo(player.uuid).lastIP); - - Call.sendMessage(Strings.format("[orange]{0}[lightgray] has voted to kick[orange] {1}[].[accent] ({2}/{3})\n[lightgray]Type[orange] /votekick #{4}[] to agree.", - player.name, found.name, session.votes, votesRequired(), found.con.id)); - session.checkPass(); - vtime.reset(); + VoteSession session = new VoteSession(currentlyKicking, found); + session.vote(player, 1); + vtime.reset(); + currentlyKicking[0] = session; } }else{ player.sendMessage("[scarlet]No player[orange]'" + args[0] + "'[scarlet] found."); @@ -328,6 +328,31 @@ public class NetServer implements ApplicationListener{ } }); + clientCommands.register("vote", "", "Vote to kick the current player.", (args, player) -> { + if(currentlyKicking[0] == null){ + player.sendMessage("[scarlet]Nobody is being voted on."); + }else{ + if(currentlyKicking[0].voted.contains(player.uuid) || currentlyKicking[0].voted.contains(admins.getInfo(player.uuid).lastIP)){ + player.sendMessage("[scarlet]You've already voted. Sit down."); + return; + } + + if(currentlyKicking[0].target == player){ + player.sendMessage("[scarlet]You can't vote on your own trial."); + return; + } + + if(!arg[0].toLowerCase().equals("y") && !arg[0].toLowerCase().equals("n")){ + player.sendMessage("[scarlet]Vote either 'y' (yes) or 'n' (no)."); + return; + } + + int sign = arg[0].toLowerCase().equals("y") ? 1 : -1; + currentlyKicking[0].vote(player, sign); + } + }); + + clientCommands.register("sync", "Re-synchronize world state.", (args, player) -> { if(player.isLocal){ player.sendMessage("[scarlet]Re-synchronizing as the host is pointless."); @@ -339,7 +364,7 @@ public class NetServer implements ApplicationListener{ } public int votesRequired(){ - return 2 + (int)(playerGroup.size() * 0.2f); + return 2 + (playerGroup.size() > 4 ? 1 : 0); } public Team assignTeam(Player current, Iterable players){ From 2c0d2c5e2201c8a047e89e3e73fce8ebfc13a686 Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 2 Sep 2019 12:37:25 -0400 Subject: [PATCH 5/7] Update NetServer.java --- core/src/io/anuke/mindustry/core/NetServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index e050820def..59b5b57745 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -328,7 +328,7 @@ public class NetServer implements ApplicationListener{ } }); - clientCommands.register("vote", "", "Vote to kick the current player.", (args, player) -> { + clientCommands.register("vote", "", "Vote to kick the current player.", (arg, player) -> { if(currentlyKicking[0] == null){ player.sendMessage("[scarlet]Nobody is being voted on."); }else{ From e640042e5d74115a4c8f07f8c3da0b5050741f2f Mon Sep 17 00:00:00 2001 From: Anuken Date: Mon, 2 Sep 2019 12:40:52 -0400 Subject: [PATCH 6/7] Update build.gradle --- build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 578fe451c6..f887b13607 100644 --- a/build.gradle +++ b/build.gradle @@ -201,6 +201,7 @@ project(":core"){ apply plugin: "java" task preGen{ + outputs.upToDateWhen{ false } generateLocales() writeVersion() } @@ -321,4 +322,4 @@ task deployAll{ dependsOn "desktop:packrMacOS" dependsOn "server:deploy" dependsOn "android:deploy" -} \ No newline at end of file +} From ef0b56eb2277a1ccf3d1e4e1bbc0a02633fc4940 Mon Sep 17 00:00:00 2001 From: J-VdS <38380578+J-VdS@users.noreply.github.com> Date: Tue, 3 Sep 2019 01:37:38 +0200 Subject: [PATCH 7/7] Extra events (#630) * eventype player join * playerjoin event * player leave * player leave event * typo * remove * leave fix --- .../src/io/anuke/mindustry/core/NetServer.java | 9 ++++++--- .../src/io/anuke/mindustry/game/EventType.java | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 59b5b57745..adc7d4ffcf 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -20,7 +20,7 @@ import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest; import io.anuke.mindustry.entities.traits.Entity; import io.anuke.mindustry.entities.traits.SyncTrait; import io.anuke.mindustry.entities.type.Player; -import io.anuke.mindustry.game.EventType.WorldLoadEvent; +import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Version; import io.anuke.mindustry.gen.Call; @@ -74,7 +74,7 @@ public class NetServer implements ApplicationListener{ }); Net.handleServer(Disconnect.class, (id, packet) -> { - Player player = connections.get(id); + Player player = connections.get(id); if(player != null){ onDisconnect(player, packet.reason); } @@ -185,6 +185,8 @@ public class NetServer implements ApplicationListener{ sendWorldData(player, id); platform.updateRPC(); + + Events.fire(new PlayerJoin(player)); }); Net.handleServer(InvokePacket.class, (id, packet) -> { @@ -402,8 +404,9 @@ public class NetServer implements ApplicationListener{ } if(player.con.hasConnected){ + Events.fire(new PlayerLeave(player)); Call.sendMessage("[accent]" + player.name + "[accent] has disconnected."); - Call.onPlayerDisconnect(player.id); + Call.onPlayerDisconnect(player.id); } player.remove(); netServer.connections.remove(player.con.id); diff --git a/core/src/io/anuke/mindustry/game/EventType.java b/core/src/io/anuke/mindustry/game/EventType.java index 6d8b8a0b40..d1158e1265 100644 --- a/core/src/io/anuke/mindustry/game/EventType.java +++ b/core/src/io/anuke/mindustry/game/EventType.java @@ -5,6 +5,7 @@ import io.anuke.mindustry.entities.traits.BuilderTrait; import io.anuke.mindustry.entities.type.Unit; import io.anuke.mindustry.type.Zone; import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.entities.type.Player; public class EventType{ @@ -184,5 +185,22 @@ public class EventType{ public static class ResizeEvent{ } + + public static class PlayerJoin{ + public final Player player; + + public PlayerJoin(Player player){ + this.player = player; + } + } + + public static class PlayerLeave{ + public final Player player; + + public PlayerLeave(Player player){ + this.player = player; + } + } + }