Removed "on" prefix from all remote methods

This commit is contained in:
Anuken
2020-07-03 18:48:31 -04:00
parent 7ff2e98420
commit 8576d535bd
22 changed files with 108 additions and 84 deletions
@@ -66,7 +66,7 @@ public class RemoteWriteGenerator{
//create builder //create builder
MethodSpec.Builder method = MethodSpec.methodBuilder(elem.getSimpleName().toString() + (forwarded ? "__forward" : "")) //add except suffix when forwarding MethodSpec.Builder method = MethodSpec.methodBuilder(elem.getSimpleName().toString() + (forwarded ? "__forward" : "")) //add except suffix when forwarding
.addModifiers(Modifier.STATIC, Modifier.SYNCHRONIZED) .addModifiers(Modifier.STATIC)
.returns(void.class); .returns(void.class);
//forwarded methods aren't intended for use, and are not public //forwarded methods aren't intended for use, and are not public
+3 -3
View File
@@ -210,11 +210,11 @@ public class BlockIndexer{
} }
public void notifyTileDamaged(Building entity){ public void notifyTileDamaged(Building entity){
if(damagedTiles[(int)entity.team().id] == null){ if(damagedTiles[entity.team().id] == null){
damagedTiles[(int)entity.team().id] = new TileArray(); damagedTiles[entity.team().id] = new TileArray();
} }
TileArray set = damagedTiles[(int)entity.team().id]; TileArray set = damagedTiles[entity.team().id];
set.add(entity.tile()); set.add(entity.tile());
} }
+1 -1
View File
@@ -111,7 +111,7 @@ public class Control implements ApplicationListener, Loadable{
state.stats.wavesLasted = state.wave; state.stats.wavesLasted = state.wave;
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y); Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
//the restart dialog can show info for any number of scenarios //the restart dialog can show info for any number of scenarios
Call.onGameOver(event.winner); Call.gameOver(event.winner);
}); });
//autohost for pvp maps //autohost for pvp maps
+1 -1
View File
@@ -294,7 +294,7 @@ public class Logic implements ApplicationListener{
} }
@Remote(called = Loc.both) @Remote(called = Loc.both)
public static void onGameOver(Team winner){ public static void gameOver(Team winner){
state.stats.wavesLasted = state.wave; state.stats.wavesLasted = state.wave;
ui.restart.show(winner); ui.restart.show(winner);
netClient.setQuiet(); netClient.setQuiet();
+20 -20
View File
@@ -230,7 +230,7 @@ public class NetClient implements ApplicationListener{
} }
@Remote(called = Loc.client, variants = Variant.one) @Remote(called = Loc.client, variants = Variant.one)
public static void onConnect(String ip, int port){ public static void connect(String ip, int port){
netClient.disconnectQuietly(); netClient.disconnectQuietly();
logic.reset(); logic.reset();
@@ -238,24 +238,24 @@ public class NetClient implements ApplicationListener{
} }
@Remote(targets = Loc.client) @Remote(targets = Loc.client)
public static void onPing(Player player, long time){ public static void ping(Player player, long time){
Call.onPingResponse(player.con, time); Call.pingResponse(player.con, time);
} }
@Remote(variants = Variant.one) @Remote(variants = Variant.one)
public static void onPingResponse(long time){ public static void pingResponse(long time){
netClient.ping = Time.timeSinceMillis(time); netClient.ping = Time.timeSinceMillis(time);
} }
@Remote(variants = Variant.one) @Remote(variants = Variant.one)
public static void onTraceInfo(Player player, TraceInfo info){ public static void traceInfo(Player player, TraceInfo info){
if(player != null){ if(player != null){
ui.traces.show(player, info); ui.traces.show(player, info);
} }
} }
@Remote(variants = Variant.one, priority = PacketPriority.high) @Remote(variants = Variant.one, priority = PacketPriority.high)
public static void onKick(KickReason reason){ public static void kick(KickReason reason){
netClient.disconnectQuietly(); netClient.disconnectQuietly();
logic.reset(); logic.reset();
@@ -270,7 +270,7 @@ public class NetClient implements ApplicationListener{
} }
@Remote(variants = Variant.one, priority = PacketPriority.high) @Remote(variants = Variant.one, priority = PacketPriority.high)
public static void onKick(String reason){ public static void kick(String reason){
netClient.disconnectQuietly(); netClient.disconnectQuietly();
logic.reset(); logic.reset();
ui.showText("$disconnect", reason, Align.left); ui.showText("$disconnect", reason, Align.left);
@@ -296,21 +296,21 @@ public class NetClient implements ApplicationListener{
} }
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void onInfoMessage(String message){ public static void infoMessage(String message){
if(message == null) return; if(message == null) return;
ui.showText("", message); ui.showText("", message);
} }
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void onInfoPopup(String message, float duration, int align, int top, int left, int bottom, int right){ public static void infoPopup(String message, float duration, int align, int top, int left, int bottom, int right){
if(message == null) return; if(message == null) return;
ui.showInfoPopup(message, duration, align, top, left, bottom, right); ui.showInfoPopup(message, duration, align, top, left, bottom, right);
} }
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void onLabel(String message, float duration, float worldx, float worldy){ public static void label(String message, float duration, float worldx, float worldy){
if(message == null) return; if(message == null) return;
ui.showLabel(message, duration, worldx, worldy); ui.showLabel(message, duration, worldx, worldy);
@@ -330,19 +330,19 @@ public class NetClient implements ApplicationListener{
}*/ }*/
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void onInfoToast(String message, float duration){ public static void infoToast(String message, float duration){
if(message == null) return; if(message == null) return;
ui.showInfoToast(message, duration); ui.showInfoToast(message, duration);
} }
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void onSetRules(Rules rules){ public static void setRules(Rules rules){
state.rules = rules; state.rules = rules;
} }
@Remote(variants = Variant.both) @Remote(variants = Variant.both)
public static void onWorldDataBegin(){ public static void worldDataBegin(){
Groups.all.clear(); Groups.all.clear();
netClient.removed.clear(); netClient.removed.clear();
logic.reset(); logic.reset();
@@ -360,17 +360,17 @@ public class NetClient implements ApplicationListener{
} }
@Remote(variants = Variant.one) @Remote(variants = Variant.one)
public static void onPositionSet(float x, float y){ public static void setPosition(float x, float y){
player.set(x, y); player.set(x, y);
} }
@Remote @Remote
public static void onPlayerDisconnect(int playerid){ public static void playerDisconnect(int playerid){
Groups.player.removeByID(playerid); Groups.player.removeByID(playerid);
} }
@Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true) @Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true)
public static void onEntitySnapshot(short amount, short dataLen, byte[] data){ public static void entitySnapshot(short amount, short dataLen, byte[] data){
try{ try{
netClient.byteStream.setBytes(net.decompressSnapshot(data, dataLen)); netClient.byteStream.setBytes(net.decompressSnapshot(data, dataLen));
DataInputStream input = netClient.dataStream; DataInputStream input = netClient.dataStream;
@@ -417,7 +417,7 @@ public class NetClient implements ApplicationListener{
} }
@Remote(variants = Variant.both, priority = PacketPriority.low, unreliable = true) @Remote(variants = Variant.both, priority = PacketPriority.low, unreliable = true)
public static void onBlockSnapshot(short amount, short dataLen, byte[] data){ public static void blockSnapshot(short amount, short dataLen, byte[] data){
try{ try{
netClient.byteStream.setBytes(net.decompressSnapshot(data, dataLen)); netClient.byteStream.setBytes(net.decompressSnapshot(data, dataLen));
DataInputStream input = netClient.dataStream; DataInputStream input = netClient.dataStream;
@@ -437,7 +437,7 @@ public class NetClient implements ApplicationListener{
} }
@Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true) @Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true)
public static void onStateSnapshot(float waveTime, int wave, int enemies, boolean paused, short coreDataLen, byte[] coreData){ public static void stateSnapshot(float waveTime, int wave, int enemies, boolean paused, short coreDataLen, byte[] coreData){
try{ try{
if(wave > state.wave){ if(wave > state.wave){
state.wave = wave; state.wave = wave;
@@ -565,7 +565,7 @@ public class NetClient implements ApplicationListener{
Unit unit = player.dead() ? Nulls.unit : player.unit(); Unit unit = player.dead() ? Nulls.unit : player.unit();
Call.onClientShapshot(lastSent++, Call.clientShapshot(lastSent++,
unit.x, unit.y, unit.x, unit.y,
player.unit().aimX(), player.unit().aimY(), player.unit().aimX(), player.unit().aimY(),
unit.rotation, unit.rotation,
@@ -579,7 +579,7 @@ public class NetClient implements ApplicationListener{
} }
if(timer.get(1, 60)){ if(timer.get(1, 60)){
Call.onPing(Time.millis()); Call.ping(Time.millis());
} }
} }
+13 -13
View File
@@ -162,7 +162,7 @@ public class NetServer implements ApplicationListener{
info.lastName = packet.name; info.lastName = packet.name;
info.id = packet.uuid; info.id = packet.uuid;
admins.save(); admins.save();
Call.onInfoMessage(con, "You are not whitelisted here."); Call.infoMessage(con, "You are not whitelisted here.");
Log.info("&lcDo &lywhitelist-add @&lc to whitelist the player &lb'@'", packet.uuid, packet.name); Log.info("&lcDo &lywhitelist-add @&lc to whitelist the player &lb'@'", packet.uuid, packet.name);
con.kick(KickReason.whitelist); con.kick(KickReason.whitelist);
return; return;
@@ -453,7 +453,7 @@ public class NetServer implements ApplicationListener{
} }
player.getInfo().lastSyncTime = Time.millis(); player.getInfo().lastSyncTime = Time.millis();
Call.onWorldDataBegin(player.con); Call.worldDataBegin(player.con);
netServer.sendWorldData(player); netServer.sendWorldData(player);
} }
}); });
@@ -501,7 +501,7 @@ public class NetServer implements ApplicationListener{
if(player.con.hasConnected){ if(player.con.hasConnected){
Events.fire(new PlayerLeave(player)); Events.fire(new PlayerLeave(player));
if(Config.showConnectMessages.bool()) Call.sendMessage("[accent]" + player.name + "[accent] has disconnected."); if(Config.showConnectMessages.bool()) Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
Call.onPlayerDisconnect(player.id()); Call.playerDisconnect(player.id());
} }
if(Config.showConnectMessages.bool()) Log.info("&lm[@] &lc@ has disconnected. &lg&fi(@)", player.uuid(), player.name, reason); if(Config.showConnectMessages.bool()) Log.info("&lm[@] &lc@ has disconnected. &lg&fi(@)", player.uuid(), player.name, reason);
@@ -526,7 +526,7 @@ public class NetServer implements ApplicationListener{
} }
@Remote(targets = Loc.client, unreliable = true) @Remote(targets = Loc.client, unreliable = true)
public static void onClientShapshot( public static void clientShapshot(
Player player, Player player,
int snapshotID, int snapshotID,
float x, float y, float x, float y,
@@ -633,7 +633,7 @@ public class NetServer implements ApplicationListener{
newx = x; newx = x;
newy = y; newy = y;
}else if(!Mathf.within(x, y, newx, newy, correctDist)){ }else if(!Mathf.within(x, y, newx, newy, correctDist)){
Call.onPositionSet(player.con, newx, newy); //teleport and correct position when necessary Call.setPosition(player.con, newx, newy); //teleport and correct position when necessary
} }
//reset player to previous synced position so it gets interpolated //reset player to previous synced position so it gets interpolated
@@ -666,7 +666,7 @@ public class NetServer implements ApplicationListener{
} }
@Remote(targets = Loc.client, called = Loc.server) @Remote(targets = Loc.client, called = Loc.server)
public static void onAdminRequest(Player player, Player other, AdminAction action){ public static void adminRequest(Player player, Player other, AdminAction action){
if(!player.admin){ if(!player.admin){
Log.warn("ACCESS DENIED: Player @ / @ attempted to perform admin action without proper security access.", Log.warn("ACCESS DENIED: Player @ / @ attempted to perform admin action without proper security access.",
@@ -693,9 +693,9 @@ public class NetServer implements ApplicationListener{
}else if(action == AdminAction.trace){ }else if(action == AdminAction.trace){
TraceInfo info = new TraceInfo(other.con.address, other.uuid(), other.con.modclient, other.con.mobile); TraceInfo info = new TraceInfo(other.con.address, other.uuid(), other.con.modclient, other.con.mobile);
if(player.con != null){ if(player.con != null){
Call.onTraceInfo(player.con, other, info); Call.traceInfo(player.con, other, info);
}else{ }else{
NetClient.onTraceInfo(other, info); NetClient.traceInfo(other, info);
} }
Log.info("&lc@ has requested trace info of @.", player.name, other.name); Log.info("&lc@ has requested trace info of @.", player.name, other.name);
} }
@@ -785,7 +785,7 @@ public class NetServer implements ApplicationListener{
if(syncStream.size() > maxSnapshotSize){ if(syncStream.size() > maxSnapshotSize){
dataStream.close(); dataStream.close();
byte[] stateBytes = syncStream.toByteArray(); byte[] stateBytes = syncStream.toByteArray();
Call.onBlockSnapshot(sent, (short)stateBytes.length, net.compressSnapshot(stateBytes)); Call.blockSnapshot(sent, (short)stateBytes.length, net.compressSnapshot(stateBytes));
sent = 0; sent = 0;
syncStream.reset(); syncStream.reset();
} }
@@ -794,7 +794,7 @@ public class NetServer implements ApplicationListener{
if(sent > 0){ if(sent > 0){
dataStream.close(); dataStream.close();
byte[] stateBytes = syncStream.toByteArray(); byte[] stateBytes = syncStream.toByteArray();
Call.onBlockSnapshot(sent, (short)stateBytes.length, net.compressSnapshot(stateBytes)); Call.blockSnapshot(sent, (short)stateBytes.length, net.compressSnapshot(stateBytes));
} }
} }
@@ -813,7 +813,7 @@ public class NetServer implements ApplicationListener{
byte[] stateBytes = syncStream.toByteArray(); byte[] stateBytes = syncStream.toByteArray();
//write basic state data. //write basic state data.
Call.onStateSnapshot(player.con, state.wavetime, state.wave, state.enemies, state.serverPaused, (short)stateBytes.length, net.compressSnapshot(stateBytes)); Call.stateSnapshot(player.con, state.wavetime, state.wave, state.enemies, state.serverPaused, (short)stateBytes.length, net.compressSnapshot(stateBytes));
viewport.setSize(player.con.viewWidth, player.con.viewHeight).setCenter(player.con.viewX, player.con.viewY); viewport.setSize(player.con.viewWidth, player.con.viewHeight).setCenter(player.con.viewX, player.con.viewY);
@@ -832,7 +832,7 @@ public class NetServer implements ApplicationListener{
if(syncStream.size() > maxSnapshotSize){ if(syncStream.size() > maxSnapshotSize){
dataStream.close(); dataStream.close();
byte[] syncBytes = syncStream.toByteArray(); byte[] syncBytes = syncStream.toByteArray();
Call.onEntitySnapshot(player.con, (short)sent, (short)syncBytes.length, net.compressSnapshot(syncBytes)); Call.entitySnapshot(player.con, (short)sent, (short)syncBytes.length, net.compressSnapshot(syncBytes));
sent = 0; sent = 0;
syncStream.reset(); syncStream.reset();
} }
@@ -842,7 +842,7 @@ public class NetServer implements ApplicationListener{
dataStream.close(); dataStream.close();
byte[] syncBytes = syncStream.toByteArray(); byte[] syncBytes = syncStream.toByteArray();
Call.onEntitySnapshot(player.con, (short)sent, (short)syncBytes.length, net.compressSnapshot(syncBytes)); Call.entitySnapshot(player.con, (short)sent, (short)syncBytes.length, net.compressSnapshot(syncBytes));
} }
} }
+1 -1
View File
@@ -17,7 +17,7 @@ public class Units{
private static boolean boolResult; private static boolean boolResult;
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void onUnitDeath(Unit unit){ public static void unitDeath(Unit unit){
unit.killed(); unit.killed();
} }
@@ -118,7 +118,7 @@ abstract class BuilderComp implements Unitc{
}else{ }else{
if(entity.construct(base(), core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){ if(entity.construct(base(), core, 1f / entity.buildCost * Time.delta() * type().buildSpeed * state.rules.buildSpeedMultiplier, current.hasConfig)){
if(current.hasConfig){ if(current.hasConfig){
Call.onTileConfig(null, tile.build, current.config); Call.tileConfig(null, tile.build, current.config);
} }
} }
} }
@@ -174,12 +174,12 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
public void configure(Object value){ public void configure(Object value){
//save last used config //save last used config
block.lastConfig = value; block.lastConfig = value;
Call.onTileConfig(player, base(), value); Call.tileConfig(player, base(), value);
} }
/** Configure from a server. */ /** Configure from a server. */
public void configureAny(Object value){ public void configureAny(Object value){
Call.onTileConfig(null, base(), value); Call.tileConfig(null, base(), value);
} }
/** Deselect this tile from configuration. */ /** Deselect this tile from configuration. */
@@ -1128,6 +1128,30 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
return tile.build == base() && !dead(); return tile.build == base() && !dead();
} }
@Replace
@Override
public void kill(){
Call.tileDestroyed(base());
}
@Replace
@Override
public void damage(float damage){
if(dead()) return;
if(Mathf.zero(state.rules.blockHealthMultiplier)){
damage = health + 1;
}else{
damage /= state.rules.blockHealthMultiplier;
}
Call.tileDamage(base(), health - handleDamage(damage));
if(health <= 0){
Call.tileDestroyed(base());
}
}
@Override @Override
public void remove(){ public void remove(){
if(sound != null){ if(sound != null){
@@ -262,6 +262,6 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
if(dead || net.client()) return; if(dead || net.client()) return;
//deaths are synced; this calls killed() //deaths are synced; this calls killed()
Call.onUnitDeath(base()); Call.unitDeath(base());
} }
} }
+3 -3
View File
@@ -205,7 +205,7 @@ public class DesktopInput extends InputHandler{
if(Core.input.keyDown(Binding.control) && Core.input.keyTap(Binding.select)){ if(Core.input.keyDown(Binding.control) && Core.input.keyTap(Binding.select)){
Unit on = selectedUnit(); Unit on = selectedUnit();
if(on != null){ if(on != null){
Call.onUnitControl(player, on); Call.unitControl(player, on);
shouldShoot = false; shouldShoot = false;
} }
} }
@@ -215,7 +215,7 @@ public class DesktopInput extends InputHandler{
updateMovement(player.unit()); updateMovement(player.unit());
if(Core.input.keyDown(Binding.respawn) && !player.unit().spawnedByCore()){ if(Core.input.keyDown(Binding.respawn) && !player.unit().spawnedByCore()){
Call.onUnitClear(player); Call.unitClear(player);
controlledType = null; controlledType = null;
} }
} }
@@ -621,7 +621,7 @@ public class DesktopInput extends InputHandler{
if(unit instanceof Commanderc){ if(unit instanceof Commanderc){
if(Core.input.keyTap(Binding.command)){ if(Core.input.keyTap(Binding.command)){
Call.onUnitCommand(player); Call.unitCommand(player);
} }
} }
} }
+8 -8
View File
@@ -156,7 +156,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
@Remote(targets = Loc.both, called = Loc.server, forward = true) @Remote(targets = Loc.both, called = Loc.server, forward = true)
public static void onTileTapped(Player player, Building tile){ public static void tileTapped(Player player, Building tile){
if(tile == null || player == null) return; if(tile == null || player == null) return;
if(net.server() && (!Units.canInteract(player, tile) || if(net.server() && (!Units.canInteract(player, tile) ||
!netServer.admins.allowAction(player, ActionType.tapTile, tile.tile(), action -> {}))) throw new ValidateException(player, "Player cannot tap a tile."); !netServer.admins.allowAction(player, ActionType.tapTile, tile.tile(), action -> {}))) throw new ValidateException(player, "Player cannot tap a tile.");
@@ -165,7 +165,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
@Remote(targets = Loc.both, called = Loc.both, forward = true) @Remote(targets = Loc.both, called = Loc.both, forward = true)
public static void onTileConfig(Player player, Building tile, @Nullable Object value){ public static void tileConfig(Player player, Building tile, @Nullable Object value){
if(tile == null) return; if(tile == null) return;
if(net.server() && (!Units.canInteract(player, tile) || if(net.server() && (!Units.canInteract(player, tile) ||
!netServer.admins.allowAction(player, ActionType.configure, tile.tile(), action -> action.config = value))) throw new ValidateException(player, "Player cannot configure a tile."); !netServer.admins.allowAction(player, ActionType.configure, tile.tile(), action -> action.config = value))) throw new ValidateException(player, "Player cannot configure a tile.");
@@ -174,7 +174,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
@Remote(targets = Loc.both, called = Loc.server, forward = true) @Remote(targets = Loc.both, called = Loc.server, forward = true)
public static void onUnitControl(Player player, @Nullable Unit unit){ public static void unitControl(Player player, @Nullable Unit unit){
//clear player unit when they possess a core //clear player unit when they possess a core
if((unit instanceof BlockUnitc && ((BlockUnitc)unit).tile() instanceof CoreEntity)){ if((unit instanceof BlockUnitc && ((BlockUnitc)unit).tile() instanceof CoreEntity)){
Fx.spawn.at(player); Fx.spawn.at(player);
@@ -193,7 +193,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
@Remote(targets = Loc.both, called = Loc.server, forward = true) @Remote(targets = Loc.both, called = Loc.server, forward = true)
public static void onUnitClear(Player player){ public static void unitClear(Player player){
//no free core teleports? //no free core teleports?
if(!player.dead() && player.unit().spawnedByCore) return; if(!player.dead() && player.unit().spawnedByCore) return;
@@ -203,7 +203,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
@Remote(targets = Loc.both, called = Loc.server, forward = true) @Remote(targets = Loc.both, called = Loc.server, forward = true)
public static void onUnitCommand(Player player){ public static void unitCommand(Player player){
if(player.dead() || !(player.unit() instanceof Commanderc)) return; if(player.dead() || !(player.unit() instanceof Commanderc)) return;
Commanderc commander = (Commanderc)player.unit(); Commanderc commander = (Commanderc)player.unit();
@@ -263,7 +263,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType); Unit unit = Units.closest(player.team(), player.x, player.y, u -> !u.isPlayer() && u.type() == controlledType);
if(unit != null){ if(unit != null){
Call.onUnitControl(player, unit); Call.unitControl(player, unit);
} }
} }
} }
@@ -277,7 +277,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
if(unit != null){ if(unit != null){
if(net.client()){ if(net.client()){
Call.onUnitControl(player, unit); Call.unitControl(player, unit);
}else{ }else{
unit.controller(player); unit.controller(player);
} }
@@ -695,7 +695,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
//call tapped event //call tapped event
if(!consumed && tile.interactable(player.team())){ if(!consumed && tile.interactable(player.team())){
Call.onTileTapped(player, tile); Call.tileTapped(player, tile);
} }
//consume tap event if necessary //consume tap event if necessary
+1 -1
View File
@@ -138,7 +138,7 @@ public class Net{
*/ */
public void closeServer(){ public void closeServer(){
for(NetConnection con : getConnections()){ for(NetConnection con : getConnections()){
Call.onKick(con, KickReason.serverClose); Call.kick(con, KickReason.serverClose);
} }
provider.closeServer(); provider.closeServer();
+2 -2
View File
@@ -46,7 +46,7 @@ public abstract class NetConnection{
info.lastKicked = Math.max(Time.millis() + 30 * 1000, info.lastKicked); info.lastKicked = Math.max(Time.millis() + 30 * 1000, info.lastKicked);
} }
Call.onKick(this, reason); Call.kick(this, reason);
Time.runTask(2f, this::close); Time.runTask(2f, this::close);
@@ -66,7 +66,7 @@ public abstract class NetConnection{
info.timesKicked++; info.timesKicked++;
info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked); info.lastKicked = Math.max(Time.millis() + kickDuration, info.lastKicked);
Call.onKick(this, reason); Call.kick(this, reason);
Time.runTask(2f, this::close); Time.runTask(2f, this::close);
@@ -652,7 +652,7 @@ public class HudFragment extends Fragment{
private void addPlayButton(Table table){ private void addPlayButton(Table table){
table.right().button(Icon.play, Styles.righti, 30f, () -> { table.right().button(Icon.play, Styles.righti, 30f, () -> {
if(net.client() && player.admin){ if(net.client() && player.admin){
Call.onAdminRequest(player, AdminAction.wave); Call.adminRequest(player, AdminAction.wave);
}else if(inLaunchWave()){ }else if(inLaunchWave()){
ui.showConfirm("$confirm", "$launch.skip.confirm", () -> !canSkipWave(), () -> state.wavetime = 0f); ui.showConfirm("$confirm", "$launch.skip.confirm", () -> !canSkipWave(), () -> state.wavetime = 0f);
}else{ }else{
@@ -116,11 +116,11 @@ public class PlayerListFragment extends Fragment{
t.button(Icon.hammer, Styles.clearPartiali, t.button(Icon.hammer, Styles.clearPartiali,
() -> { () -> {
ui.showConfirm("$confirm", Core.bundle.format("confirmban", user.name()), () -> Call.onAdminRequest(user, AdminAction.ban)); ui.showConfirm("$confirm", Core.bundle.format("confirmban", user.name()), () -> Call.adminRequest(user, AdminAction.ban));
}); });
t.button(Icon.cancel, Styles.clearPartiali, t.button(Icon.cancel, Styles.clearPartiali,
() -> { () -> {
ui.showConfirm("$confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.onAdminRequest(user, AdminAction.kick)); ui.showConfirm("$confirm", Core.bundle.format("confirmkick", user.name()), () -> Call.adminRequest(user, AdminAction.kick));
}); });
t.row(); t.row();
@@ -140,7 +140,7 @@ public class PlayerListFragment extends Fragment{
.touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled) .touchable(() -> net.client() ? Touchable.disabled : Touchable.enabled)
.checked(user.admin); .checked(user.admin);
t.button(Icon.zoom, Styles.clearPartiali, () -> Call.onAdminRequest(user, AdminAction.trace)); t.button(Icon.zoom, Styles.clearPartiali, () -> Call.adminRequest(user, AdminAction.trace));
}).padRight(12).size(bs + 10f, bs); }).padRight(12).size(bs + 10f, bs);
}else if(!user.isLocal() && !user.admin && net.client() && Groups.player.size() >= 3 && player.team() == user.team()){ //votekick }else if(!user.isLocal() && !user.admin && net.client() && Groups.player.size() >= 3 && player.team() == user.team()){ //votekick
+9 -9
View File
@@ -641,19 +641,19 @@ public class Tile implements Position, QuadTreeObject, Displayable{
} }
@Remote(called = Loc.server, unreliable = true) @Remote(called = Loc.server, unreliable = true)
public static void onTileDamage(Tile tile, float health){ public static void tileDamage(Building build, float health){
if(tile.build != null){ if(build == null) return;
tile.build.health = health;
if(tile.build.damaged()){ build.health = health;
indexer.notifyTileDamaged(tile.build);
} if(build.damaged()){
indexer.notifyTileDamaged(build);
} }
} }
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void onTileDestroyed(Tile tile){ public static void tileDestroyed(Building build){
if(tile.build == null) return; if(build == null) return;
tile.build.killed(); build.killed();
} }
} }
@@ -48,7 +48,7 @@ public class BuildBlock extends Block{
} }
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void onDeconstructFinish(Tile tile, Block block, int builderID){ public static void deconstructFinish(Tile tile, Block block, int builderID){
Team team = tile.team(); Team team = tile.team();
Fx.breakBlock.at(tile.drawx(), tile.drawy(), block.size); Fx.breakBlock.at(tile.drawx(), tile.drawy(), block.size);
Events.fire(new BlockBuildEndEvent(tile, Groups.unit.getByID(builderID), team, true)); Events.fire(new BlockBuildEndEvent(tile, Groups.unit.getByID(builderID), team, true));
@@ -57,7 +57,7 @@ public class BuildBlock extends Block{
} }
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void onConstructFinish(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){ public static void constructFinish(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
if(tile == null) return; if(tile == null) return;
float healthf = tile.build.healthf(); float healthf = tile.build.healthf();
tile.setBlock(block, team, rotation); tile.setBlock(block, team, rotation);
@@ -96,7 +96,7 @@ public class BuildBlock extends Block{
} }
public static void constructed(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){ public static void constructed(Tile tile, Block block, int builderID, byte rotation, Team team, boolean skipConfig){
Call.onConstructFinish(tile, block, builderID, rotation, team, skipConfig); Call.constructFinish(tile, block, builderID, rotation, team, skipConfig);
tile.build.placed(); tile.build.placed();
Events.fire(new BlockBuildEndEvent(tile, Groups.unit.getByID(builderID), team, false)); Events.fire(new BlockBuildEndEvent(tile, Groups.unit.getByID(builderID), team, false));
@@ -256,7 +256,7 @@ public class BuildBlock extends Block{
builderID = builder.id(); builderID = builder.id();
if(progress <= 0 || state.rules.infiniteResources){ if(progress <= 0 || state.rules.infiniteResources){
Call.onDeconstructFinish(tile, this.cblock == null ? previous : this.cblock, builderID); Call.deconstructFinish(tile, this.cblock == null ? previous : this.cblock, builderID);
} }
} }
@@ -53,7 +53,7 @@ public class CoreBlock extends StorageBlock{
} }
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void onPlayerSpawn(Tile tile, Player player){ public static void playerSpawn(Tile tile, Player player){
if(player == null || tile == null) return; if(player == null || tile == null) return;
CoreEntity entity = tile.bc(); CoreEntity entity = tile.bc();
@@ -171,7 +171,7 @@ public class CoreBlock extends StorageBlock{
} }
public void requestSpawn(Player player){ public void requestSpawn(Player player){
Call.onPlayerSpawn(tile, player); Call.playerSpawn(tile, player);
} }
@Override @Override
@@ -25,7 +25,7 @@ public class UnitBlock extends PayloadAcceptor{
} }
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void onUnitBlockSpawn(Tile tile){ public static void unitBlockSpawn(Tile tile){
if(!(tile.build instanceof UnitBlockEntity)) return; if(!(tile.build instanceof UnitBlockEntity)) return;
tile.<UnitBlockEntity>bc().spawned(); tile.<UnitBlockEntity>bc().spawned();
} }
@@ -55,7 +55,7 @@ public class UnitBlock extends PayloadAcceptor{
@Override @Override
public void dumpPayload(){ public void dumpPayload(){
Call.onUnitBlockSpawn(tile); Call.unitBlockSpawn(tile);
} }
} }
} }
@@ -137,7 +137,7 @@ public class ServerControl implements ApplicationListener{
Map map = nextMapOverride != null ? nextMapOverride : maps.getNextMap(lastMode, state.map); Map map = nextMapOverride != null ? nextMapOverride : maps.getNextMap(lastMode, state.map);
nextMapOverride = null; nextMapOverride = null;
if(map != null){ if(map != null){
Call.onInfoMessage((state.rules.pvp Call.infoMessage((state.rules.pvp
? "[yellow]The " + event.winner.name + " team is victorious![]" : "[scarlet]Game over![]") ? "[yellow]The " + event.winner.name + " team is victorious![]" : "[scarlet]Game over![]")
+ "\nNext selected map:[accent] " + map.name() + "[]" + "\nNext selected map:[accent] " + map.name() + "[]"
+ (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[white]" : "") + "." + + (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[white]" : "") + "." +
@@ -395,7 +395,7 @@ public class ServerControl implements ApplicationListener{
} }
Core.settings.put("globalrules", base.toString()); Core.settings.put("globalrules", base.toString());
Call.onSetRules(state.rules); Call.setRules(state.rules);
} }
}); });
@@ -885,7 +885,7 @@ public class ServerControl implements ApplicationListener{
logic.reset(); logic.reset();
Call.onWorldDataBegin(); Call.worldDataBegin();
run.run(); run.run();
state.rules = state.map.applyRules(lastMode); state.rules = state.map.applyRules(lastMode);
logic.play(); logic.play();