Fixed iOS crash
This commit is contained in:
@@ -86,10 +86,9 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
//load.addStatement(name + " = io.anuke.arc.Core.audio."+loadMethod+"(io.anuke.arc.Core.files.internal(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S))",
|
//load.addStatement(name + " = io.anuke.arc.Core.audio."+loadMethod+"(io.anuke.arc.Core.files.internal(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S))",
|
||||||
//filepath, filepath.replace(".ogg", ".mp3"));
|
//filepath, filepath.replace(".ogg", ".mp3"));
|
||||||
|
String filename = "io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? \"" + filepath + "\" : \"" + filepath.replace(".ogg", ".mp3")+"\"";
|
||||||
|
|
||||||
loadBegin.addStatement("io.anuke.arc.Core.assets.load(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S, "+rtype+".class, " +
|
loadBegin.addStatement("io.anuke.arc.Core.assets.load("+filename +", "+rtype+".class).loaded = a -> " + name + " = ("+rtype+")a", filepath, filepath.replace(".ogg", ".mp3"));
|
||||||
"new io.anuke.arc.assets.loaders."+classname.substring(0, classname.length()-1)+"Loader."+classname.substring(0, classname.length()-1)+"Parameter((m, name, type) -> " + name + " = m.get(\"" + filepath + "\")))",
|
|
||||||
filepath, filepath.replace(".ogg", ".mp3"));
|
|
||||||
|
|
||||||
|
|
||||||
dispose.addStatement(name + ".dispose()");
|
dispose.addStatement(name + ".dispose()");
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ players = {0} players online
|
|||||||
players.single = {0} player online
|
players.single = {0} player online
|
||||||
server.closing = [accent]Closing server...
|
server.closing = [accent]Closing server...
|
||||||
server.kicked.kick = You have been kicked from the server!
|
server.kicked.kick = You have been kicked from the server!
|
||||||
|
server.kicked.whitelist = You are not whitelisted here.
|
||||||
server.kicked.serverClose = Server closed.
|
server.kicked.serverClose = Server closed.
|
||||||
server.kicked.vote = You have been vote-kicked. Goodbye.
|
server.kicked.vote = You have been vote-kicked. Goodbye.
|
||||||
server.kicked.clientOutdated = Outdated client! Update your game!
|
server.kicked.clientOutdated = Outdated client! Update your game!
|
||||||
|
|||||||
@@ -1,39 +1,32 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.*;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.ApplicationListener;
|
|
||||||
import io.anuke.arc.Events;
|
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.graphics.Colors;
|
import io.anuke.arc.math.*;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.CommandHandler.*;
|
import io.anuke.arc.util.CommandHandler.*;
|
||||||
import io.anuke.arc.util.io.*;
|
import io.anuke.arc.util.io.*;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.*;
|
||||||
import io.anuke.mindustry.entities.EntityGroup;
|
import io.anuke.mindustry.entities.*;
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait.BuildRequest;
|
import io.anuke.mindustry.entities.traits.BuilderTrait.*;
|
||||||
import io.anuke.mindustry.entities.traits.Entity;
|
import io.anuke.mindustry.entities.traits.*;
|
||||||
import io.anuke.mindustry.entities.traits.SyncTrait;
|
import io.anuke.mindustry.entities.type.*;
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.game.Version;
|
|
||||||
import io.anuke.mindustry.gen.Call;
|
|
||||||
import io.anuke.mindustry.gen.RemoteReadServer;
|
|
||||||
import io.anuke.mindustry.net.*;
|
import io.anuke.mindustry.net.*;
|
||||||
import io.anuke.mindustry.net.Administration.PlayerInfo;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.Administration.TraceInfo;
|
import io.anuke.mindustry.net.Administration.*;
|
||||||
import io.anuke.mindustry.net.Packets.*;
|
import io.anuke.mindustry.net.Packets.*;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.*;
|
||||||
import java.util.zip.DeflaterOutputStream;
|
import java.util.zip.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -110,6 +103,22 @@ public class NetServer implements ApplicationListener{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(admins.isIDBanned(uuid)){
|
||||||
|
kick(id, KickReason.banned);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!admins.isWhitelisted(packet.uuid, packet.usid)){
|
||||||
|
info.adminUsid = packet.usid;
|
||||||
|
info.lastName = packet.name;
|
||||||
|
info.id = packet.uuid;
|
||||||
|
admins.save();
|
||||||
|
Call.onInfoMessage(id, "You are not whitelisted here.");
|
||||||
|
Log.info("&lcDo &lywhitelist-add {0}&lc to whitelist the player &lb'{1}'", packet.uuid, packet.name);
|
||||||
|
kick(id, KickReason.whitelist);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(packet.versionType == null || ((packet.version == -1 || !packet.versionType.equals(Version.type)) && Version.build != -1 && !admins.allowsCustomClients())){
|
if(packet.versionType == null || ((packet.version == -1 || !packet.versionType.equals(Version.type)) && Version.build != -1 && !admins.allowsCustomClients())){
|
||||||
kick(id, !Version.type.equals(packet.versionType) ? KickReason.typeMismatch : KickReason.customClient);
|
kick(id, !Version.type.equals(packet.versionType) ? KickReason.typeMismatch : KickReason.customClient);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.anuke.mindustry.net;
|
package io.anuke.mindustry.net;
|
||||||
|
|
||||||
import io.anuke.annotations.Annotations.Serialize;
|
import io.anuke.annotations.Annotations.*;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.headless;
|
import static io.anuke.mindustry.Vars.headless;
|
||||||
@@ -10,6 +10,7 @@ public class Administration{
|
|||||||
/** All player info. Maps UUIDs to info. This persists throughout restarts. */
|
/** All player info. Maps UUIDs to info. This persists throughout restarts. */
|
||||||
private ObjectMap<String, PlayerInfo> playerInfo = new ObjectMap<>();
|
private ObjectMap<String, PlayerInfo> playerInfo = new ObjectMap<>();
|
||||||
private Array<String> bannedIPs = new Array<>();
|
private Array<String> bannedIPs = new Array<>();
|
||||||
|
private Array<String> whitelist = new Array<>();
|
||||||
|
|
||||||
public Administration(){
|
public Administration(){
|
||||||
Core.settings.defaults(
|
Core.settings.defaults(
|
||||||
@@ -186,6 +187,36 @@ public class Administration{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWhitelistEnabled(){
|
||||||
|
return Core.settings.getBool("whitelist", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWhitelist(boolean enabled){
|
||||||
|
Core.settings.putSave("whitelist", enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWhitelisted(String id, String usid){
|
||||||
|
return !isWhitelistEnabled() || whitelist.contains(usid + id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean whitelist(String id){
|
||||||
|
PlayerInfo info = getCreateInfo(id);
|
||||||
|
if(whitelist.contains(info.adminUsid + id)) return false;
|
||||||
|
whitelist.add(info.adminUsid + id);
|
||||||
|
save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean unwhitelist(String id){
|
||||||
|
PlayerInfo info = getCreateInfo(id);
|
||||||
|
if(whitelist.contains(info.adminUsid + id)){
|
||||||
|
whitelist.remove(info.adminUsid + id);
|
||||||
|
save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isIPBanned(String ip){
|
public boolean isIPBanned(String ip){
|
||||||
return bannedIPs.contains(ip, false) || (findByIP(ip) != null && findByIP(ip).banned);
|
return bannedIPs.contains(ip, false) || (findByIP(ip) != null && findByIP(ip).banned);
|
||||||
}
|
}
|
||||||
@@ -242,6 +273,10 @@ public class Administration{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Array<PlayerInfo> getWhitelisted(){
|
||||||
|
return playerInfo.values().toArray().select(p -> isWhitelisted(p.id, p.adminUsid));
|
||||||
|
}
|
||||||
|
|
||||||
private PlayerInfo getCreateInfo(String id){
|
private PlayerInfo getCreateInfo(String id){
|
||||||
if(playerInfo.containsKey(id)){
|
if(playerInfo.containsKey(id)){
|
||||||
return playerInfo.get(id);
|
return playerInfo.get(id);
|
||||||
@@ -256,6 +291,7 @@ public class Administration{
|
|||||||
public void save(){
|
public void save(){
|
||||||
Core.settings.putObject("player-info", playerInfo);
|
Core.settings.putObject("player-info", playerInfo);
|
||||||
Core.settings.putObject("banned-ips", bannedIPs);
|
Core.settings.putObject("banned-ips", bannedIPs);
|
||||||
|
Core.settings.putObject("whitelisted", whitelist);
|
||||||
Core.settings.save();
|
Core.settings.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,6 +299,7 @@ public class Administration{
|
|||||||
private void load(){
|
private void load(){
|
||||||
playerInfo = Core.settings.getObject("player-info", ObjectMap.class, ObjectMap::new);
|
playerInfo = Core.settings.getObject("player-info", ObjectMap.class, ObjectMap::new);
|
||||||
bannedIPs = Core.settings.getObject("banned-ips", Array.class, Array::new);
|
bannedIPs = Core.settings.getObject("banned-ips", Array.class, Array::new);
|
||||||
|
whitelist = Core.settings.getObject("whitelisted", Array.class, Array::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serialize
|
@Serialize
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ 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;
|
nameInUse, idInUse, nameEmpty, customClient, serverClose, vote, typeMismatch, whitelist;
|
||||||
|
|
||||||
public final boolean quiet;
|
public final boolean quiet;
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class ServerControl implements ApplicationListener{
|
|||||||
private static final int commandSocketPort = 6859;
|
private static final int commandSocketPort = 6859;
|
||||||
|
|
||||||
private final CommandHandler handler = new CommandHandler("");
|
private final CommandHandler handler = new CommandHandler("");
|
||||||
private final FileHandle logFolder = Core.files.local("logs/");
|
private final FileHandle logFolder = Core.settings.getDataDirectory().child("logs/");
|
||||||
private final io.anuke.mindustry.plugin.Plugins plugins = new Plugins();
|
private final io.anuke.mindustry.plugin.Plugins plugins = new Plugins();
|
||||||
|
|
||||||
private FileHandle currentLogFile;
|
private FileHandle currentLogFile;
|
||||||
@@ -401,6 +401,48 @@ public class ServerControl implements ApplicationListener{
|
|||||||
info("Server name is now &lc'{0}'.", arg[0]);
|
info("Server name is now &lc'{0}'.", arg[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
handler.register("whitelist", "[on/off...]", "Enable/disable whitelisting.", arg -> {
|
||||||
|
if(arg.length == 0){
|
||||||
|
info("Whitelist is currently &lc{0}.", netServer.admins.isWhitelistEnabled() ? "on" : "off");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean on = arg[0].equalsIgnoreCase("on");
|
||||||
|
netServer.admins.setWhitelist(on);
|
||||||
|
info("Whitelist is now &lc{0}.", on ? "on" : "off");
|
||||||
|
});
|
||||||
|
|
||||||
|
handler.register("whitelisted", "List the entire whitelist.", arg -> {
|
||||||
|
if(netServer.admins.getWhitelisted().isEmpty()){
|
||||||
|
info("&lyNo whitelisted players found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info("&lyWhitelist:");
|
||||||
|
netServer.admins.getWhitelisted().each(p -> Log.info("- &ly{0}", p.lastName));
|
||||||
|
});
|
||||||
|
|
||||||
|
handler.register("whitelist-add", "<ID>", "Add a player to the whitelist by ID.", arg -> {
|
||||||
|
PlayerInfo info = netServer.admins.getInfoOptional(arg[0]);
|
||||||
|
if(info == null){
|
||||||
|
err("Player ID not found. You must use the ID displayed when a player joins a server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
netServer.admins.whitelist(arg[0]);
|
||||||
|
info("Player &ly'{0}'&lg has been whitelisted.", info.lastName);
|
||||||
|
});
|
||||||
|
|
||||||
|
handler.register("whitelist-remove", "<ID>", "Remove a player to the whitelist by ID.", arg -> {
|
||||||
|
PlayerInfo info = netServer.admins.getInfoOptional(arg[0]);
|
||||||
|
if(info == null){
|
||||||
|
err("Player ID not found. You must use the ID displayed when a player joins a server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
netServer.admins.unwhitelist(arg[0]);
|
||||||
|
info("Player &ly'{0}'&lg has been un-whitelisted.", info.lastName);
|
||||||
|
});
|
||||||
|
|
||||||
handler.register("crashreport", "<on/off>", "Disables or enables automatic crash reporting", arg -> {
|
handler.register("crashreport", "<on/off>", "Disables or enables automatic crash reporting", arg -> {
|
||||||
boolean value = arg[0].equalsIgnoreCase("on");
|
boolean value = arg[0].equalsIgnoreCase("on");
|
||||||
Core.settings.put("crashreport", value);
|
Core.settings.put("crashreport", value);
|
||||||
|
|||||||
Reference in New Issue
Block a user