Map improvements (#8682)
* Update Map.java * Update MapListDialog.java * Update ServerControl.java
This commit is contained in:
@@ -117,6 +117,10 @@ public class Map implements Comparable<Map>, Publishable{
|
|||||||
}
|
}
|
||||||
return maps.readFilters(tags.get("genfilters", ""));
|
return maps.readFilters(tags.get("genfilters", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String name(){
|
||||||
|
return tag("name");
|
||||||
|
}
|
||||||
|
|
||||||
public String author(){
|
public String author(){
|
||||||
return tag("author");
|
return tag("author");
|
||||||
@@ -125,17 +129,25 @@ public class Map implements Comparable<Map>, Publishable{
|
|||||||
public String description(){
|
public String description(){
|
||||||
return tag("description");
|
return tag("description");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String plainName() {
|
||||||
|
return Strings.stripColors(name());
|
||||||
|
}
|
||||||
|
|
||||||
public String name(){
|
public String plainAuthor(){
|
||||||
return tag("name");
|
return Strings.stripColors(author());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String plainDescription(){
|
||||||
|
return Strings.stripColors(description());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String tag(String name){
|
public String tag(String name){
|
||||||
return tags.containsKey(name) && !tags.get(name).trim().isEmpty() ? tags.get(name) : Core.bundle.get("unknown", "unknown");
|
return hasTag(name) ? tags.get(name) : Core.bundle.get("unknown", "unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasTag(String name){
|
public boolean hasTag(String name){
|
||||||
return tags.containsKey(name);
|
return tags.containsKey(name) && !tags.get(name).trim().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -146,21 +158,22 @@ public class Map implements Comparable<Map>, Publishable{
|
|||||||
@Override
|
@Override
|
||||||
public void addSteamID(String id){
|
public void addSteamID(String id){
|
||||||
tags.put("steamid", id);
|
tags.put("steamid", id);
|
||||||
|
|
||||||
editor.tags.put("steamid", id);
|
editor.tags.put("steamid", id);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
ui.editor.save();
|
ui.editor.save();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Log.err(e);
|
Log.err(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Events.fire(new MapPublishEvent());
|
Events.fire(new MapPublishEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeSteamID(){
|
public void removeSteamID(){
|
||||||
tags.remove("steamid");
|
tags.remove("steamid");
|
||||||
|
|
||||||
editor.tags.remove("steamid");
|
editor.tags.remove("steamid");
|
||||||
|
|
||||||
try{
|
try{
|
||||||
ui.editor.save();
|
ui.editor.save();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
@@ -205,9 +218,9 @@ public class Map implements Comparable<Map>, Publishable{
|
|||||||
@Override
|
@Override
|
||||||
public boolean prePublish(){
|
public boolean prePublish(){
|
||||||
tags.put("author", player.name);
|
tags.put("author", player.name);
|
||||||
editor.tags.put("author", tags.get("author"));
|
editor.tags.put("author", player.name);
|
||||||
|
|
||||||
ui.editor.save();
|
ui.editor.save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,9 +114,9 @@ public abstract class MapListDialog extends BaseDialog{
|
|||||||
invalid |= !mode.valid(map);
|
invalid |= !mode.valid(map);
|
||||||
}
|
}
|
||||||
if(invalid || (searchString != null
|
if(invalid || (searchString != null
|
||||||
&& !Strings.stripColors(map.name()).toLowerCase().contains(searchString)
|
&& !map.plainName().toLowerCase().contains(searchString)
|
||||||
&& (!searchAuthor || !Strings.stripColors(map.author()).toLowerCase().contains(searchString))
|
&& (!searchAuthor || !map.plainAuthor().toLowerCase().contains(searchString))
|
||||||
&& (!searchDescription || !Strings.stripColors(map.description()).toLowerCase().contains(searchString)))){
|
&& (!searchDescription || !map.plainDescription().toLowerCase().contains(searchString)))){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,9 +175,9 @@ public class ServerControl implements ApplicationListener{
|
|||||||
Events.on(GameOverEvent.class, event -> {
|
Events.on(GameOverEvent.class, event -> {
|
||||||
if(inGameOverWait) return;
|
if(inGameOverWait) return;
|
||||||
if(state.rules.waves){
|
if(state.rules.waves){
|
||||||
info("Game over! Reached wave @ with @ players online on map @.", state.wave, Groups.player.size(), Strings.capitalize(Strings.stripColors(state.map.name())));
|
info("Game over! Reached wave @ with @ players online on map @.", state.wave, Groups.player.size(), Strings.capitalize(state.map.plainName()));
|
||||||
}else{
|
}else{
|
||||||
info("Game over! Team @ is victorious with @ players online on map @.", event.winner.name, Groups.player.size(), Strings.capitalize(Strings.stripColors(state.map.name())));
|
info("Game over! Team @ is victorious with @ players online on map @.", event.winner.name, Groups.player.size(), Strings.capitalize(state.map.plainName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
//set next map to be played
|
//set next map to be played
|
||||||
@@ -186,14 +186,14 @@ public class ServerControl implements ApplicationListener{
|
|||||||
if(map != null){
|
if(map != null){
|
||||||
Call.infoMessage((state.rules.pvp
|
Call.infoMessage((state.rules.pvp
|
||||||
? "[accent]The " + event.winner.name + " team is victorious![]\n" : "[scarlet]Game over![]\n")
|
? "[accent]The " + event.winner.name + " team is victorious![]\n" : "[scarlet]Game over![]\n")
|
||||||
+ "\nNext selected map:[accent] " + Strings.stripColors(map.name()) + "[]"
|
+ "\nNext selected map: [accent]" + map.name() + "[white]"
|
||||||
+ (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[white]" : "") + "." +
|
+ (map.hasTag("author") ? " by[accent] " + map.author() + "[white]" : "") + "." +
|
||||||
"\nNew game begins in " + roundExtraTime + " seconds.");
|
"\nNew game begins in " + roundExtraTime + " seconds.");
|
||||||
|
|
||||||
state.gameOver = true;
|
state.gameOver = true;
|
||||||
Call.updateGameOver(event.winner);
|
Call.updateGameOver(event.winner);
|
||||||
|
|
||||||
info("Selected next map to be @.", Strings.stripColors(map.name()));
|
info("Selected next map to be @.", map.plainName());
|
||||||
|
|
||||||
play(true, () -> world.loadMap(map, map.applyRules(lastMode)));
|
play(true, () -> world.loadMap(map, map.applyRules(lastMode)));
|
||||||
}else{
|
}else{
|
||||||
@@ -362,7 +362,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
|
|
||||||
Map result;
|
Map result;
|
||||||
if(arg.length > 0){
|
if(arg.length > 0){
|
||||||
result = maps.all().find(map -> Strings.stripColors(map.name().replace('_', ' ')).equalsIgnoreCase(Strings.stripColors(arg[0]).replace('_', ' ')));
|
result = maps.all().find(map -> map.plainName().replace('_', ' ').equalsIgnoreCase(Strings.stripColors(arg[0]).replace('_', ' ')));
|
||||||
|
|
||||||
if(result == null){
|
if(result == null){
|
||||||
err("No map with name '@' found.", arg[0]);
|
err("No map with name '@' found.", arg[0]);
|
||||||
@@ -370,7 +370,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
result = maps.getShuffleMode().next(preset, state.map);
|
result = maps.getShuffleMode().next(preset, state.map);
|
||||||
info("Randomized next map to be @.", result.name());
|
info("Randomized next map to be @.", result.plainName());
|
||||||
}
|
}
|
||||||
|
|
||||||
info("Loading map...");
|
info("Loading map...");
|
||||||
@@ -392,7 +392,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
autoPaused = true;
|
autoPaused = true;
|
||||||
}
|
}
|
||||||
}catch(MapException e){
|
}catch(MapException e){
|
||||||
err(e.map.name() + ": " + e.getMessage());
|
err(e.map.plainName() + ": " + e.getMessage());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
info("Maps:");
|
info("Maps:");
|
||||||
|
|
||||||
for(Map map : all){
|
for(Map map : all){
|
||||||
String mapName = Strings.stripColors(map.name()).replace(' ', '_');
|
String mapName = map.plainName().replace(' ', '_');
|
||||||
if(map.custom){
|
if(map.custom){
|
||||||
info(" @ (@): &fiCustom / @x@", mapName, map.file.name(), map.width, map.height);
|
info(" @ (@): &fiCustom / @x@", mapName, map.file.name(), map.width, map.height);
|
||||||
}else{
|
}else{
|
||||||
@@ -443,7 +443,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
info("Status: &rserver closed");
|
info("Status: &rserver closed");
|
||||||
}else{
|
}else{
|
||||||
info("Status:");
|
info("Status:");
|
||||||
info(" Playing on map &fi@ / Wave @", Strings.capitalize(Strings.stripColors(state.map.name())), state.wave);
|
info(" Playing on map &fi@ / Wave @", Strings.capitalize(state.map.plainName()), state.wave);
|
||||||
|
|
||||||
if(state.rules.waves){
|
if(state.rules.waves){
|
||||||
info(" @ seconds until next wave.", (int)(state.wavetime / 60));
|
info(" @ seconds until next wave.", (int)(state.wavetime / 60));
|
||||||
@@ -733,10 +733,10 @@ public class ServerControl implements ApplicationListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
handler.register("nextmap", "<mapname...>", "Set the next map to be played after a game-over. Overrides shuffling.", arg -> {
|
handler.register("nextmap", "<mapname...>", "Set the next map to be played after a game-over. Overrides shuffling.", arg -> {
|
||||||
Map res = maps.all().find(map -> Strings.stripColors(map.name().replace('_', ' ')).equalsIgnoreCase(Strings.stripColors(arg[0]).replace('_', ' ')));
|
Map res = maps.all().find(map -> map.plainName().replace('_', ' ').equalsIgnoreCase(Strings.stripColors(arg[0]).replace('_', ' ')));
|
||||||
if(res != null){
|
if(res != null){
|
||||||
nextMapOverride = res;
|
nextMapOverride = res;
|
||||||
info("Next map set to '@'.", Strings.stripColors(res.name()));
|
info("Next map set to '@'.", res.plainName());
|
||||||
}else{
|
}else{
|
||||||
err("No map '@' found.", arg[0]);
|
err("No map '@' found.", arg[0]);
|
||||||
}
|
}
|
||||||
@@ -1075,7 +1075,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
try{
|
try{
|
||||||
r.run();
|
r.run();
|
||||||
}catch(MapException e){
|
}catch(MapException e){
|
||||||
err(e.map.name() + ": " + e.getMessage());
|
err(e.map.plainName() + ": " + e.getMessage());
|
||||||
net.closeServer();
|
net.closeServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user