Added admin wave sending / Admin system fixes / Build fix
This commit is contained in:
@@ -219,6 +219,7 @@ public class NetClient extends Module {
|
|||||||
new Random().nextBytes(bytes);
|
new Random().nextBytes(bytes);
|
||||||
String result = new String(Base64Coder.encode(bytes));
|
String result = new String(Base64Coder.encode(bytes));
|
||||||
Settings.putString("usid-" + ip, result);
|
Settings.putString("usid-" + ip, result);
|
||||||
|
Settings.save();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,14 +485,18 @@ public class NetServer extends Module{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(other == null || other.isAdmin){
|
if(other == null || (other.isAdmin && other != player)){ //fun fact: this means you can ban yourself
|
||||||
Log.err("{0} attempted to perform admin action on nonexistant or admin player.", player.name);
|
Log.err("{0} attempted to perform admin action on nonexistant or admin player.", player.name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ip = player.con.address;
|
String ip = player.con.address;
|
||||||
|
|
||||||
if(action == AdminAction.ban){
|
if(action == AdminAction.wave) {
|
||||||
|
//no verification is done, so admins can hypothetically spam waves
|
||||||
|
//not a real issue, because server owners may want to do just that
|
||||||
|
state.wavetime = 0f;
|
||||||
|
}else if(action == AdminAction.ban){
|
||||||
netServer.admins.banPlayerIP(ip);
|
netServer.admins.banPlayerIP(ip);
|
||||||
netServer.kick(other.con.id, KickReason.banned);
|
netServer.kick(other.con.id, KickReason.banned);
|
||||||
Log.info("&lc{0} has banned {1}.", player.name, other.name);
|
Log.info("&lc{0} has banned {1}.", player.name, other.name);
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class Packets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum AdminAction{
|
public enum AdminAction{
|
||||||
kick, ban, trace
|
kick, ban, trace, wave
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Marks the beginning of a stream.*/
|
/**Marks the beginning of a stream.*/
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import com.badlogic.gdx.utils.Scaling;
|
import com.badlogic.gdx.utils.Scaling;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
|
import io.anuke.mindustry.net.Packets.AdminAction;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.ui.IntFormat;
|
import io.anuke.mindustry.ui.IntFormat;
|
||||||
import io.anuke.mindustry.ui.Minimap;
|
import io.anuke.mindustry.ui.Minimap;
|
||||||
@@ -331,13 +333,17 @@ public class HudFragment extends Fragment{
|
|||||||
|
|
||||||
private void playButton(float uheight){
|
private void playButton(float uheight){
|
||||||
new imagebutton("icon-play", 30f, () -> {
|
new imagebutton("icon-play", 30f, () -> {
|
||||||
state.wavetime = 0f;
|
if(Net.client() && players[0].isAdmin){
|
||||||
|
Call.onAdminRequest(players[0], AdminAction.wave);
|
||||||
|
}else {
|
||||||
|
state.wavetime = 0f;
|
||||||
|
}
|
||||||
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padLeft(-15).padRight(-10).width(40f).update(l->{
|
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padLeft(-15).padRight(-10).width(40f).update(l->{
|
||||||
boolean vis = state.mode.disableWaveTimer && (Net.server() || !Net.active());
|
boolean vis = state.mode.disableWaveTimer && ((Net.server() || players[0].isAdmin) || !Net.active());
|
||||||
boolean paused = state.is(State.paused) || !vis;
|
boolean paused = state.is(State.paused) || !vis;
|
||||||
|
|
||||||
l.getStyle().imageUp = Core.skin.getDrawable(vis ? "icon-play" : "clear");
|
l.getStyle().imageUp = Core.skin.getDrawable(vis ? "icon-play" : "clear");
|
||||||
l.setTouchable(!paused ? Touchable.enabled : Touchable.disabled);
|
l.setTouchable(!paused ? Touchable.enabled : Touchable.disabled);
|
||||||
}).visible(() -> state.mode.disableWaveTimer && (Net.server() || !Net.active()) && unitGroups[Team.red.ordinal()].size() == 0);
|
}).visible(() -> state.mode.disableWaveTimer && ((Net.server() || players[0].isAdmin) || !Net.active()) && unitGroups[Team.red.ordinal()].size() == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.mindustry.game.Difficulty;
|
import io.anuke.mindustry.game.Difficulty;
|
||||||
import io.anuke.mindustry.game.EventType.GameOverEvent;
|
import io.anuke.mindustry.game.EventType.GameOverEvent;
|
||||||
import io.anuke.mindustry.game.GameMode;
|
import io.anuke.mindustry.game.GameMode;
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.io.Map;
|
import io.anuke.mindustry.io.Map;
|
||||||
import io.anuke.mindustry.io.SaveIO;
|
import io.anuke.mindustry.io.SaveIO;
|
||||||
@@ -138,7 +139,7 @@ public class ServerControl extends Module {
|
|||||||
Log.info("Stopped server.");
|
Log.info("Stopped server.");
|
||||||
});
|
});
|
||||||
|
|
||||||
handler.register("host", "[mapname] [mode]", "Open the server with a specific map.", arg -> {
|
handler.register("host", "[mode] [mapname]", "Open the server with a specific map.", arg -> {
|
||||||
if(state.is(State.playing)){
|
if(state.is(State.playing)){
|
||||||
err("Already hosting. Type 'stop' to stop hosting first.");
|
err("Already hosting. Type 'stop' to stop hosting first.");
|
||||||
return;
|
return;
|
||||||
@@ -147,34 +148,39 @@ public class ServerControl extends Module {
|
|||||||
Map result = null;
|
Map result = null;
|
||||||
|
|
||||||
if(arg.length > 0) {
|
if(arg.length > 0) {
|
||||||
String search = arg[0];
|
|
||||||
for (Map map : world.maps().all()) {
|
|
||||||
if (map.name.equalsIgnoreCase(search))
|
|
||||||
result = map;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(result == null){
|
|
||||||
err("No map with name &y'{0}'&lr found.", search);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameMode mode;
|
GameMode mode;
|
||||||
try{
|
try{
|
||||||
mode = arg.length < 2 ? GameMode.waves : GameMode.valueOf(arg[1]);
|
mode = GameMode.valueOf(arg[0]);
|
||||||
}catch (IllegalArgumentException e){
|
}catch (IllegalArgumentException e){
|
||||||
err("No gamemode '{0}' found.", arg[1]);
|
err("No gamemode '{0}' found.", arg[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
info("Loading map...");
|
info("Loading map...");
|
||||||
state.mode = mode;
|
state.mode = mode;
|
||||||
|
|
||||||
logic.reset();
|
if(arg.length > 1) {
|
||||||
world.loadMap(result);
|
String search = arg[1];
|
||||||
|
for (Map map : world.maps().all()) {
|
||||||
|
if (map.name.equalsIgnoreCase(search))
|
||||||
|
result = map;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result == null) {
|
||||||
|
err("No map with name &y'{0}'&lr found.", search);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logic.reset();
|
||||||
|
world.loadMap(result);
|
||||||
|
}else{
|
||||||
|
Log.info("&ly&fiNo map specified, so a procedural one was generated.");
|
||||||
|
world.loadProceduralMap();
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
world.loadProceduralMap();
|
|
||||||
Log.info("&ly&fiNo map specified, so a procedural one was generated.");
|
Log.info("&ly&fiNo map specified, so a procedural one was generated.");
|
||||||
|
world.loadProceduralMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
logic.play();
|
logic.play();
|
||||||
@@ -194,10 +200,10 @@ public class ServerControl extends Module {
|
|||||||
if(state.is(State.menu)){
|
if(state.is(State.menu)){
|
||||||
info("&lyStatus: &rserver closed");
|
info("&lyStatus: &rserver closed");
|
||||||
}else{
|
}else{
|
||||||
info("&lyStatus: &lcPlaying on map &fi{0}&fb &lb/&lc Wave {1} &lb/&lc {2}",
|
info("&lyStatus: &lcPlaying on map &fi{0}&fb &lb/&lc Wave {1} &lb/&lc {2} &lb/&lc {3}",
|
||||||
Strings.capitalize(world.getMap().name), state.wave, Strings.capitalize(state.difficulty.name()));
|
Strings.capitalize(world.getMap().name), state.wave, Strings.capitalize(state.difficulty.name()), Strings.capitalize(state.mode.name()));
|
||||||
if(state.enemies > 0){
|
if(state.mode.disableWaveTimer){
|
||||||
info("&ly{0} enemies remaining.", state.enemies);
|
info("&ly{0} enemies.", unitGroups[Team.red.ordinal()].size());
|
||||||
}else{
|
}else{
|
||||||
info("&ly{0} seconds until next wave.", (int)(state.wavetime / 60));
|
info("&ly{0} seconds until next wave.", (int)(state.wavetime / 60));
|
||||||
}
|
}
|
||||||
@@ -464,6 +470,7 @@ public class ServerControl extends Module {
|
|||||||
|
|
||||||
if(target != null){
|
if(target != null){
|
||||||
netServer.admins.adminPlayer(target.uuid, target.usid);
|
netServer.admins.adminPlayer(target.uuid, target.usid);
|
||||||
|
target.isAdmin = true;
|
||||||
info("Admin-ed player by ID: {0} / {1}", target.uuid, arg[0]);
|
info("Admin-ed player by ID: {0} / {1}", target.uuid, arg[0]);
|
||||||
}else{
|
}else{
|
||||||
info("Nobody with that name could be found.");
|
info("Nobody with that name could be found.");
|
||||||
@@ -487,6 +494,7 @@ public class ServerControl extends Module {
|
|||||||
|
|
||||||
if(target != null){
|
if(target != null){
|
||||||
netServer.admins.unAdminPlayer(target.uuid);
|
netServer.admins.unAdminPlayer(target.uuid);
|
||||||
|
target.isAdmin = false;
|
||||||
info("Un-admin-ed player by ID: {0} / {1}", target.uuid, arg[0]);
|
info("Un-admin-ed player by ID: {0} / {1}", target.uuid, arg[0]);
|
||||||
}else{
|
}else{
|
||||||
info("Nobody with that name could be found.");
|
info("Nobody with that name could be found.");
|
||||||
@@ -509,8 +517,6 @@ public class ServerControl extends Module {
|
|||||||
handler.register("runwave", "Trigger the next wave.", arg -> {
|
handler.register("runwave", "Trigger the next wave.", arg -> {
|
||||||
if(!state.is(State.playing)) {
|
if(!state.is(State.playing)) {
|
||||||
err("Not hosting. Host a game first.");
|
err("Not hosting. Host a game first.");
|
||||||
}else if(state.enemies > 0){
|
|
||||||
err("There are still {0} enemies remaining.", state.enemies);
|
|
||||||
}else{
|
}else{
|
||||||
logic.runWave();
|
logic.runWave();
|
||||||
info("Wave spawned.");
|
info("Wave spawned.");
|
||||||
|
|||||||
Reference in New Issue
Block a user