Added update trigger / Server moddability tweaks
This commit is contained in:
@@ -155,6 +155,7 @@ server.kicked.nameEmpty = Your chosen name is invalid.
|
|||||||
server.kicked.idInUse = You are already on this server! Connecting with two accounts is not permitted.
|
server.kicked.idInUse = You are already on this server! Connecting with two accounts is not permitted.
|
||||||
server.kicked.customClient = This server does not support custom builds. Download an official version.
|
server.kicked.customClient = This server does not support custom builds. Download an official version.
|
||||||
server.kicked.gameover = Game over!
|
server.kicked.gameover = Game over!
|
||||||
|
server.kicked.serverRestarting = The server is restarting.
|
||||||
server.versions = Your version:[accent] {0}[]\nServer version:[accent] {1}[]
|
server.versions = Your version:[accent] {0}[]\nServer version:[accent] {1}[]
|
||||||
host.info = The [accent]host[] button hosts a server on port [scarlet]6567[]. \nAnybody on the same [lightgray]wifi or local network[] should be able to see your server in their server list.\n\nIf you want people to be able to connect from anywhere by IP, [accent]port forwarding[] is required.\n\n[lightgray]Note: If someone is experiencing trouble connecting to your LAN game, make sure you have allowed Mindustry access to your local network in your firewall settings. Note that public networks sometimes do not allow server discovery.
|
host.info = The [accent]host[] button hosts a server on port [scarlet]6567[]. \nAnybody on the same [lightgray]wifi or local network[] should be able to see your server in their server list.\n\nIf you want people to be able to connect from anywhere by IP, [accent]port forwarding[] is required.\n\n[lightgray]Note: If someone is experiencing trouble connecting to your LAN game, make sure you have allowed Mindustry access to your local network in your firewall settings. Note that public networks sometimes do not allow server discovery.
|
||||||
join.info = Here, you can enter a [accent]server IP[] to connect to, or discover [accent]local network[] servers to connect to.\nBoth LAN and WAN multiplayer is supported.\n\n[lightgray]Note: There is no automatic global server list; if you want to connect to someone by IP, you would need to ask the host for their IP.
|
join.info = Here, you can enter a [accent]server IP[] to connect to, or discover [accent]local network[] servers to connect to.\nBoth LAN and WAN multiplayer is supported.\n\n[lightgray]Note: There is no automatic global server list; if you want to connect to someone by IP, you would need to ask the host for their IP.
|
||||||
|
|||||||
@@ -209,6 +209,7 @@ public class Logic implements ApplicationListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
Events.fire(Trigger.update);
|
||||||
|
|
||||||
if(!state.is(State.menu)){
|
if(!state.is(State.menu)){
|
||||||
if(!net.client()){
|
if(!net.client()){
|
||||||
@@ -260,7 +261,7 @@ public class Logic implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!net.client() && !world.isInvalidMap() && !state.isEditor()){
|
if(!net.client() && !world.isInvalidMap() && !state.isEditor() && !state.rules.canGameOver){
|
||||||
checkGameOver();
|
checkGameOver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,7 +217,6 @@ public class NetServer implements ApplicationListener{
|
|||||||
|
|
||||||
//playing in pvp mode automatically assigns players to teams
|
//playing in pvp mode automatically assigns players to teams
|
||||||
player.setTeam(assignTeam(player, playerGroup.all()));
|
player.setTeam(assignTeam(player, playerGroup.all()));
|
||||||
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
|
|
||||||
|
|
||||||
sendWorldData(player);
|
sendWorldData(player);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public class EventType{
|
|||||||
suicideBomb,
|
suicideBomb,
|
||||||
openWiki,
|
openWiki,
|
||||||
teamCoreDamage,
|
teamCoreDamage,
|
||||||
socketConfigChanged
|
socketConfigChanged,
|
||||||
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WinEvent{}
|
public static class WinEvent{}
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ public class Rules{
|
|||||||
public boolean editor = false;
|
public boolean editor = false;
|
||||||
/** Whether the tutorial is enabled. False by default. */
|
/** Whether the tutorial is enabled. False by default. */
|
||||||
public boolean tutorial = false;
|
public boolean tutorial = false;
|
||||||
|
/** Whether a gameover can happen at all. Set this to false to implement custom gameover conditions. */
|
||||||
|
public boolean canGameOver = true;
|
||||||
/** Starting items put in cores */
|
/** Starting items put in cores */
|
||||||
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
|
public Array<ItemStack> loadout = Array.with(ItemStack.with(Items.copper, 100));
|
||||||
/** Blocks that cannot be placed. */
|
/** Blocks that cannot be placed. */
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import mindustry.core.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.net.Administration.*;
|
import mindustry.net.Administration.*;
|
||||||
|
import mindustry.net.Packets.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
|
|
||||||
@@ -126,13 +127,16 @@ public class BeControl{
|
|||||||
len -> Core.app.post(() -> Log.info("&ly| Size: {0} MB.", Strings.fixed((float)len / 1024 / 1024, 2))),
|
len -> Core.app.post(() -> Log.info("&ly| Size: {0} MB.", Strings.fixed((float)len / 1024 / 1024, 2))),
|
||||||
progress -> {},
|
progress -> {},
|
||||||
() -> false,
|
() -> false,
|
||||||
() -> {
|
() -> Core.app.post(() -> {
|
||||||
|
netServer.kickAll(KickReason.serverRestarting);
|
||||||
|
Threads.sleep(32);
|
||||||
|
|
||||||
Log.info("&lcVersion downloaded, exiting. Note that if you are not using a auto-restart script, the server will not restart automatically.");
|
Log.info("&lcVersion downloaded, exiting. Note that if you are not using a auto-restart script, the server will not restart automatically.");
|
||||||
//replace old file with new
|
//replace old file with new
|
||||||
dest.copyTo(source);
|
dest.copyTo(source);
|
||||||
dest.delete();
|
dest.delete();
|
||||||
System.exit(2); //this will cause a restart if using the script
|
System.exit(2); //this will cause a restart if using the script
|
||||||
},
|
}),
|
||||||
Throwable::printStackTrace);
|
Throwable::printStackTrace);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public class Packets{
|
|||||||
|
|
||||||
public enum KickReason{
|
public enum KickReason{
|
||||||
kick, clientOutdated, serverOutdated, banned, gameover(true), recentKick,
|
kick, clientOutdated, serverOutdated, banned, gameover(true), recentKick,
|
||||||
nameInUse, idInUse, nameEmpty, customClient, serverClose, vote, typeMismatch, whitelist, playerLimit;
|
nameInUse, idInUse, nameEmpty, customClient, serverClose, vote, typeMismatch,
|
||||||
|
whitelist, playerLimit, serverRestarting;
|
||||||
|
|
||||||
public final boolean quiet;
|
public final boolean quiet;
|
||||||
|
|
||||||
|
|||||||
@@ -163,6 +163,15 @@ public class ServerControl implements ApplicationListener{
|
|||||||
toggleSocket(Config.socketInput.bool());
|
toggleSocket(Config.socketInput.bool());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Events.on(PlayEvent.class, e -> {
|
||||||
|
try{
|
||||||
|
JsonValue value = JsonIO.json().fromJson(null, Core.settings.getString("globalrules"));
|
||||||
|
JsonIO.json().readFields(state.rules, value);
|
||||||
|
}catch(Throwable t){
|
||||||
|
Log.err("Error applying custom rules, proceeding without them.", t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if(!mods.list().isEmpty()){
|
if(!mods.list().isEmpty()){
|
||||||
info("&lc{0} mods loaded.", mods.list().size);
|
info("&lc{0} mods loaded.", mods.list().size);
|
||||||
}
|
}
|
||||||
@@ -238,7 +247,6 @@ public class ServerControl implements ApplicationListener{
|
|||||||
try{
|
try{
|
||||||
world.loadMap(result, result.applyRules(lastMode));
|
world.loadMap(result, result.applyRules(lastMode));
|
||||||
state.rules = result.applyRules(preset);
|
state.rules = result.applyRules(preset);
|
||||||
applyRules();
|
|
||||||
logic.play();
|
logic.play();
|
||||||
|
|
||||||
info("Map loaded.");
|
info("Map loaded.");
|
||||||
@@ -390,7 +398,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
base.addChild(arg[1], value);
|
base.addChild(arg[1], value);
|
||||||
Log.info("Changed rule: &ly{0}", value.toString().replace("\n", " "));
|
Log.info("Changed rule: &ly{0}", value.toString().replace("\n", " "));
|
||||||
}catch(Throwable e){
|
}catch(Throwable e){
|
||||||
Log.err("Error parsing rule JSON", e);
|
Log.err("Error parsing rule JSON: {0}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,15 +785,6 @@ public class ServerControl implements ApplicationListener{
|
|||||||
mods.eachClass(p -> p.registerClientCommands(netServer.clientCommands));
|
mods.eachClass(p -> p.registerClientCommands(netServer.clientCommands));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyRules(){
|
|
||||||
try{
|
|
||||||
JsonValue value = JsonIO.json().fromJson(null, Core.settings.getString("globalrules"));
|
|
||||||
JsonIO.json().readFields(state.rules, value);
|
|
||||||
}catch(Throwable t){
|
|
||||||
Log.err("Error applying custom rules, proceeding without them.", t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readCommands(){
|
private void readCommands(){
|
||||||
|
|
||||||
Scanner scan = new Scanner(System.in);
|
Scanner scan = new Scanner(System.in);
|
||||||
@@ -836,9 +835,8 @@ public class ServerControl implements ApplicationListener{
|
|||||||
|
|
||||||
Call.onWorldDataBegin();
|
Call.onWorldDataBegin();
|
||||||
run.run();
|
run.run();
|
||||||
logic.play();
|
|
||||||
state.rules = world.getMap().applyRules(lastMode);
|
state.rules = world.getMap().applyRules(lastMode);
|
||||||
applyRules();
|
logic.play();
|
||||||
|
|
||||||
for(Player p : players){
|
for(Player p : players){
|
||||||
if(p.con == null) continue;
|
if(p.con == null) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user