More plugin customization / Renamed Rectangle
This commit is contained in:
@@ -63,7 +63,7 @@ public class Control implements ApplicationListener, Loadable{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(PlayEvent.class, event -> {
|
Events.on(PlayEvent.class, event -> {
|
||||||
player.setTeam(state.rules.pvp ? netServer.assignTeam(player, playerGroup.all()) : state.rules.defaultTeam);
|
player.setTeam(netServer.assignTeam(player, playerGroup.all()));
|
||||||
player.setDead(true);
|
player.setDead(true);
|
||||||
player.add();
|
player.add();
|
||||||
|
|
||||||
|
|||||||
@@ -160,9 +160,17 @@ public class NetClient implements ApplicationListener{
|
|||||||
throw new ValidateException(player, "Player has sent a message above the text limit.");
|
throw new ValidateException(player, "Player has sent a message above the text limit.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String original = message;
|
||||||
|
|
||||||
//check if it's a command
|
//check if it's a command
|
||||||
CommandResponse response = netServer.clientCommands.handleMessage(message, player);
|
CommandResponse response = netServer.clientCommands.handleMessage(message, player);
|
||||||
if(response.type == ResponseType.noCommand){ //no command to handle
|
if(response.type == ResponseType.noCommand){ //no command to handle
|
||||||
|
message = netServer.admins.filterMessage(player, message);
|
||||||
|
//supress chat message if it's filtered out
|
||||||
|
if(message == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//server console logging
|
//server console logging
|
||||||
Log.info("&y{0}: &lb{1}", player.name, message);
|
Log.info("&y{0}: &lb{1}", player.name, message);
|
||||||
|
|
||||||
@@ -190,7 +198,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Events.fire(new PlayerChatEvent(player, message));
|
Events.fire(new PlayerChatEvent(player, message, original));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String colorizeName(int id, String name){
|
public static String colorizeName(int id, String name){
|
||||||
|
|||||||
@@ -33,14 +33,31 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class NetServer implements ApplicationListener{
|
public class NetServer implements ApplicationListener{
|
||||||
private final static int maxSnapshotSize = 430, timerBlockSync = 0;
|
private final static int maxSnapshotSize = 430, timerBlockSync = 0;
|
||||||
private final static float serverSyncTime = 12, kickDuration = 30 * 1000, blockSyncTime = 60 * 10;
|
private final static float serverSyncTime = 12, kickDuration = 30 * 1000, blockSyncTime = 60 * 8;
|
||||||
private final static Vec2 vector = new Vec2();
|
private final static Vec2 vector = new Vec2();
|
||||||
private final static Rectangle viewport = new Rectangle();
|
private final static Rect viewport = new Rect();
|
||||||
/** If a player goes away of their server-side coordinates by this distance, they get teleported back. */
|
/** If a player goes away of their server-side coordinates by this distance, they get teleported back. */
|
||||||
private final static float correctDist = 16f;
|
private final static float correctDist = 16f;
|
||||||
|
|
||||||
public final Administration admins = new Administration();
|
public final Administration admins = new Administration();
|
||||||
public final CommandHandler clientCommands = new CommandHandler("/");
|
public final CommandHandler clientCommands = new CommandHandler("/");
|
||||||
|
public TeamAssigner assigner = (player, players) -> {
|
||||||
|
if(state.rules.pvp){
|
||||||
|
//find team with minimum amount of players and auto-assign player to that.
|
||||||
|
TeamData re = state.teams.getActive().min(data -> {
|
||||||
|
int count = 0;
|
||||||
|
for(Player other : players){
|
||||||
|
if(other.getTeam() == data.team && other != player){
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
});
|
||||||
|
return re == null ? null : re.team;
|
||||||
|
}
|
||||||
|
|
||||||
|
return state.rules.defaultTeam;
|
||||||
|
};
|
||||||
|
|
||||||
private boolean closing = false;
|
private boolean closing = false;
|
||||||
private Interval timer = new Interval();
|
private Interval timer = new Interval();
|
||||||
@@ -199,10 +216,8 @@ public class NetServer implements ApplicationListener{
|
|||||||
con.player = player;
|
con.player = player;
|
||||||
|
|
||||||
//playing in pvp mode automatically assigns players to teams
|
//playing in pvp mode automatically assigns players to teams
|
||||||
if(state.rules.pvp){
|
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());
|
||||||
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
|
|
||||||
}
|
|
||||||
|
|
||||||
sendWorldData(player);
|
sendWorldData(player);
|
||||||
|
|
||||||
@@ -403,17 +418,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Team assignTeam(Player current, Iterable<Player> players){
|
public Team assignTeam(Player current, Iterable<Player> players){
|
||||||
//find team with minimum amount of players and auto-assign player to that.
|
return assigner.assign(current, players);
|
||||||
TeamData re = state.teams.getActive().min(data -> {
|
|
||||||
int count = 0;
|
|
||||||
for(Player other : players){
|
|
||||||
if(other.getTeam() == data.team && other != current){
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
});
|
|
||||||
return re == null ? null : re.team;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendWorldData(Player player){
|
public void sendWorldData(Player player){
|
||||||
@@ -784,4 +789,8 @@ public class NetServer implements ApplicationListener{
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface TeamAssigner{
|
||||||
|
Team assign(Player player, Iterable<Player> players);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
private float camerascale = targetscale;
|
private float camerascale = targetscale;
|
||||||
private float landscale = 0f, landTime;
|
private float landscale = 0f, landTime;
|
||||||
private float minZoomScl = Scl.scl(0.01f);
|
private float minZoomScl = Scl.scl(0.01f);
|
||||||
private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
|
private Rect rect = new Rect(), rect2 = new Rect();
|
||||||
private float shakeIntensity, shaketime;
|
private float shakeIntensity, shaketime;
|
||||||
|
|
||||||
public Renderer(){
|
public Renderer(){
|
||||||
@@ -56,8 +56,8 @@ public class Renderer implements ApplicationListener{
|
|||||||
Effects.setEffectProvider((effect, color, x, y, rotation, data) -> {
|
Effects.setEffectProvider((effect, color, x, y, rotation, data) -> {
|
||||||
if(effect == Fx.none) return;
|
if(effect == Fx.none) return;
|
||||||
if(Core.settings.getBool("effects")){
|
if(Core.settings.getBool("effects")){
|
||||||
Rectangle view = camera.bounds(rect);
|
Rect view = camera.bounds(rect);
|
||||||
Rectangle pos = rect2.setSize(effect.size).setCenter(x, y);
|
Rect pos = rect2.setSize(effect.size).setCenter(x, y);
|
||||||
|
|
||||||
if(view.overlaps(pos)){
|
if(view.overlaps(pos)){
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class MapView extends Element implements GestureListener{
|
|||||||
private boolean grid = false;
|
private boolean grid = false;
|
||||||
private GridImage image = new GridImage(0, 0);
|
private GridImage image = new GridImage(0, 0);
|
||||||
private Vec2 vec = new Vec2();
|
private Vec2 vec = new Vec2();
|
||||||
private Rectangle rect = new Rectangle();
|
private Rect rect = new Rect();
|
||||||
private Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
private Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
||||||
|
|
||||||
private boolean drawing;
|
private boolean drawing;
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
/** Utility class for damaging in an area. */
|
/** Utility class for damaging in an area. */
|
||||||
public class Damage{
|
public class Damage{
|
||||||
private static Rectangle rect = new Rectangle();
|
private static Rect rect = new Rect();
|
||||||
private static Rectangle hitrect = new Rectangle();
|
private static Rect hitrect = new Rect();
|
||||||
private static Vec2 tr = new Vec2();
|
private static Vec2 tr = new Vec2();
|
||||||
private static GridBits bits = new GridBits(30, 30);
|
private static GridBits bits = new GridBits(30, 30);
|
||||||
private static IntQueue propagation = new IntQueue();
|
private static IntQueue propagation = new IntQueue();
|
||||||
@@ -127,7 +127,7 @@ public class Damage{
|
|||||||
|
|
||||||
Cons<Unit> cons = e -> {
|
Cons<Unit> cons = e -> {
|
||||||
e.hitbox(hitrect);
|
e.hitbox(hitrect);
|
||||||
Rectangle other = hitrect;
|
Rect other = hitrect;
|
||||||
other.y -= expand;
|
other.y -= expand;
|
||||||
other.x -= expand;
|
other.x -= expand;
|
||||||
other.width += expand * 2;
|
other.width += expand * 2;
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ public class EntityCollisions{
|
|||||||
private static final float seg = 1f;
|
private static final float seg = 1f;
|
||||||
|
|
||||||
//tile collisions
|
//tile collisions
|
||||||
private Rectangle tmp = new Rectangle();
|
private Rect tmp = new Rect();
|
||||||
private Vec2 vector = new Vec2();
|
private Vec2 vector = new Vec2();
|
||||||
private Vec2 l1 = new Vec2();
|
private Vec2 l1 = new Vec2();
|
||||||
private Rectangle r1 = new Rectangle();
|
private Rect r1 = new Rect();
|
||||||
private Rectangle r2 = new Rectangle();
|
private Rect r2 = new Rect();
|
||||||
|
|
||||||
//entity collisions
|
//entity collisions
|
||||||
private Array<SolidTrait> arrOut = new Array<>();
|
private Array<SolidTrait> arrOut = new Array<>();
|
||||||
@@ -57,7 +57,7 @@ public class EntityCollisions{
|
|||||||
|
|
||||||
public void moveDelta(SolidTrait entity, float deltax, float deltay, boolean x){
|
public void moveDelta(SolidTrait entity, float deltax, float deltay, boolean x){
|
||||||
|
|
||||||
Rectangle rect = r1;
|
Rect rect = r1;
|
||||||
entity.hitboxTile(rect);
|
entity.hitboxTile(rect);
|
||||||
entity.hitboxTile(r2);
|
entity.hitboxTile(r2);
|
||||||
rect.x += deltax;
|
rect.x += deltax;
|
||||||
@@ -84,7 +84,7 @@ public class EntityCollisions{
|
|||||||
entity.setY(entity.getY() + rect.y - r2.y);
|
entity.setY(entity.getY() + rect.y - r2.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean overlapsTile(Rectangle rect){
|
public boolean overlapsTile(Rect rect){
|
||||||
rect.getCenter(vector);
|
rect.getCenter(vector);
|
||||||
int r = 1;
|
int r = 1;
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ public class EntityGroup<T extends Entity>{
|
|||||||
private final Array<T> entitiesToRemove = new Array<>(false, 32);
|
private final Array<T> entitiesToRemove = new Array<>(false, 32);
|
||||||
private final Array<T> entitiesToAdd = new Array<>(false, 32);
|
private final Array<T> entitiesToAdd = new Array<>(false, 32);
|
||||||
private final Array<T> intersectArray = new Array<>();
|
private final Array<T> intersectArray = new Array<>();
|
||||||
private final Rectangle intersectRect = new Rectangle();
|
private final Rect intersectRect = new Rect();
|
||||||
private IntMap<T> map;
|
private IntMap<T> map;
|
||||||
private QuadTree tree;
|
private QuadTree tree;
|
||||||
private Cons<T> removeListener;
|
private Cons<T> removeListener;
|
||||||
private Cons<T> addListener;
|
private Cons<T> addListener;
|
||||||
|
|
||||||
private final Rectangle viewport = new Rectangle();
|
private final Rect viewport = new Rect();
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
|
|
||||||
public EntityGroup(int id, Class<T> type, boolean useTree){
|
public EntityGroup(int id, Class<T> type, boolean useTree){
|
||||||
@@ -34,7 +34,7 @@ public class EntityGroup<T extends Entity>{
|
|||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
if(useTree){
|
if(useTree){
|
||||||
tree = new QuadTree<>(new Rectangle(0, 0, 0, 0));
|
tree = new QuadTree<>(new Rect(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ public class EntityGroup<T extends Entity>{
|
|||||||
/** Resizes the internal quadtree, if it is enabled.*/
|
/** Resizes the internal quadtree, if it is enabled.*/
|
||||||
public void resize(float x, float y, float w, float h){
|
public void resize(float x, float y, float w, float h){
|
||||||
if(useTree){
|
if(useTree){
|
||||||
tree = new QuadTree<>(new Rectangle(x, y, w, h));
|
tree = new QuadTree<>(new Rect(x, y, w, h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
/** Utility class for unit and team interactions.*/
|
/** Utility class for unit and team interactions.*/
|
||||||
public class Units{
|
public class Units{
|
||||||
private static Rectangle hitrect = new Rectangle();
|
private static Rect hitrect = new Rect();
|
||||||
private static Unit result;
|
private static Unit result;
|
||||||
private static float cdist;
|
private static float cdist;
|
||||||
private static boolean boolResult;
|
private static boolean boolResult;
|
||||||
@@ -188,7 +188,7 @@ public class Units{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Iterates over all units in a rectangle. */
|
/** Iterates over all units in a rectangle. */
|
||||||
public static void nearby(Rectangle rect, Cons<Unit> cons){
|
public static void nearby(Rect rect, Cons<Unit> cons){
|
||||||
nearby(rect.x, rect.y, rect.width, rect.height, cons);
|
nearby(rect.x, rect.y, rect.width, rect.height, cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ public class Units{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Iterates over all units that are enemies of this team. */
|
/** Iterates over all units that are enemies of this team. */
|
||||||
public static void nearbyEnemies(Team team, Rectangle rect, Cons<Unit> cons){
|
public static void nearbyEnemies(Team team, Rect rect, Cons<Unit> cons){
|
||||||
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
|
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package mindustry.entities.bullet;
|
package mindustry.entities.bullet;
|
||||||
|
|
||||||
import arc.math.geom.Rectangle;
|
import arc.math.geom.Rect;
|
||||||
import arc.util.Time;
|
import arc.util.Time;
|
||||||
import mindustry.content.Fx;
|
import mindustry.content.Fx;
|
||||||
import mindustry.entities.Units;
|
import mindustry.entities.Units;
|
||||||
import mindustry.entities.type.Bullet;
|
import mindustry.entities.type.Bullet;
|
||||||
|
|
||||||
public class FlakBulletType extends BasicBulletType{
|
public class FlakBulletType extends BasicBulletType{
|
||||||
protected static Rectangle rect = new Rectangle();
|
protected static Rect rect = new Rect();
|
||||||
protected float explodeRange = 30f;
|
protected float explodeRange = 30f;
|
||||||
|
|
||||||
public FlakBulletType(float speed, float damage){
|
public FlakBulletType(float speed, float damage){
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
|
|||||||
public static final float lifetime = 10f;
|
public static final float lifetime = 10f;
|
||||||
|
|
||||||
private static final RandomXS128 random = new RandomXS128();
|
private static final RandomXS128 random = new RandomXS128();
|
||||||
private static final Rectangle rect = new Rectangle();
|
private static final Rect rect = new Rect();
|
||||||
private static final Array<Unit> entities = new Array<>();
|
private static final Array<Unit> entities = new Array<>();
|
||||||
private static final IntSet hit = new IntSet();
|
private static final IntSet hit = new IntSet();
|
||||||
private static final int maxChain = 8;
|
private static final int maxChain = 8;
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||||||
private static final float maxLiquid = 70f;
|
private static final float maxLiquid = 70f;
|
||||||
private static final int maxGeneration = 2;
|
private static final int maxGeneration = 2;
|
||||||
private static final Color tmp = new Color();
|
private static final Color tmp = new Color();
|
||||||
private static final Rectangle rect = new Rectangle();
|
private static final Rect rect = new Rect();
|
||||||
private static final Rectangle rect2 = new Rectangle();
|
private static final Rect rect2 = new Rect();
|
||||||
private static int seeds;
|
private static int seeds;
|
||||||
|
|
||||||
private int loadedPosition = -1;
|
private int loadedPosition = -1;
|
||||||
@@ -151,13 +151,13 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hitbox(Rectangle rectangle){
|
public void hitbox(Rect rect){
|
||||||
rectangle.setCenter(x, y).setSize(tilesize);
|
rect.setCenter(x, y).setSize(tilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hitboxTile(Rectangle rectangle){
|
public void hitboxTile(Rect rect){
|
||||||
rectangle.setCenter(x, y).setSize(0f);
|
rect.setCenter(x, y).setSize(0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle bounds(Rectangle rect){
|
public Rect bounds(Rect rect){
|
||||||
if(breaking){
|
if(breaking){
|
||||||
return rect.set(-100f, -100f, 0f, 0f);
|
return rect.set(-100f, -100f, 0f, 0f);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import mindustry.Vars;
|
|||||||
|
|
||||||
public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, Entity, Position{
|
public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, Entity, Position{
|
||||||
|
|
||||||
void hitbox(Rectangle rectangle);
|
void hitbox(Rect rect);
|
||||||
|
|
||||||
void hitboxTile(Rectangle rectangle);
|
void hitboxTile(Rect rect);
|
||||||
|
|
||||||
Vec2 lastPosition();
|
Vec2 lastPosition();
|
||||||
|
|
||||||
|
|||||||
@@ -352,13 +352,13 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hitbox(Rectangle rectangle){
|
public void hitbox(Rect rect){
|
||||||
rectangle.setSize(type.hitsize).setCenter(x, y);
|
rect.setSize(type.hitsize).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hitboxTile(Rectangle rectangle){
|
public void hitboxTile(Rect rect){
|
||||||
rectangle.setSize(type.hitsizeTile).setCenter(x, y);
|
rect.setSize(type.hitsizeTile).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -246,13 +246,13 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hitbox(Rectangle rectangle){
|
public void hitbox(Rect rect){
|
||||||
rectangle.setSize(type.hitSize).setCenter(x, y);
|
rect.setSize(type.hitSize).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hitboxTile(Rectangle rectangle){
|
public void hitboxTile(Rect rect){
|
||||||
rectangle.setSize(type.hitSize).setCenter(x, y);
|
rect.setSize(type.hitSize).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||||||
private static final int timerShootRight = 1;
|
private static final int timerShootRight = 1;
|
||||||
private static final float liftoffBoost = 0.2f;
|
private static final float liftoffBoost = 0.2f;
|
||||||
|
|
||||||
private static final Rectangle rect = new Rectangle();
|
private static final Rect rect = new Rect();
|
||||||
|
|
||||||
//region instance variables
|
//region instance variables
|
||||||
|
|
||||||
@@ -93,13 +93,13 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hitbox(Rectangle rectangle){
|
public void hitbox(Rect rect){
|
||||||
rectangle.setSize(mech.hitsize).setCenter(x, y);
|
rect.setSize(mech.hitsize).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hitboxTile(Rectangle rectangle){
|
public void hitboxTile(Rect rect){
|
||||||
rectangle.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
|
rect.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -62,10 +62,13 @@ public class EventType{
|
|||||||
public static class PlayerChatEvent{
|
public static class PlayerChatEvent{
|
||||||
public final Player player;
|
public final Player player;
|
||||||
public final String message;
|
public final String message;
|
||||||
|
/** The original, unfiltered message. */
|
||||||
|
public final String originalMessage;
|
||||||
|
|
||||||
public PlayerChatEvent(Player player, String message){
|
public PlayerChatEvent(Player player, String message, String originalMessage){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
this.originalMessage = originalMessage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ public class Rules{
|
|||||||
public Team defaultTeam = Team.sharded;
|
public Team defaultTeam = Team.sharded;
|
||||||
/** team of the enemy in waves/sectors */
|
/** team of the enemy in waves/sectors */
|
||||||
public Team waveTeam = Team.crux;
|
public Team waveTeam = Team.crux;
|
||||||
|
/** special tags for additional info */
|
||||||
|
public StringMap tags = new StringMap();
|
||||||
|
|
||||||
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
/** Copies this ruleset exactly. Not very efficient at all, do not use often. */
|
||||||
public Rules copy(){
|
public Rules copy(){
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class MinimapRenderer implements Disposable{
|
|||||||
private Pixmap pixmap;
|
private Pixmap pixmap;
|
||||||
private Texture texture;
|
private Texture texture;
|
||||||
private TextureRegion region;
|
private TextureRegion region;
|
||||||
private Rectangle rect = new Rectangle();
|
private Rect rect = new Rect();
|
||||||
private float zoom = 4;
|
private float zoom = 4;
|
||||||
|
|
||||||
public MinimapRenderer(){
|
public MinimapRenderer(){
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import static mindustry.Vars.*;
|
|||||||
public class OverlayRenderer{
|
public class OverlayRenderer{
|
||||||
private static final float indicatorLength = 14f;
|
private static final float indicatorLength = 14f;
|
||||||
private static final float spawnerMargin = tilesize*11f;
|
private static final float spawnerMargin = tilesize*11f;
|
||||||
private static final Rectangle rect = new Rectangle();
|
private static final Rect rect = new Rect();
|
||||||
private float buildFadeTime;
|
private float buildFadeTime;
|
||||||
|
|
||||||
public void drawBottom(){
|
public void drawBottom(){
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
/** Maximum line length. */
|
/** Maximum line length. */
|
||||||
final static int maxLength = 100;
|
final static int maxLength = 100;
|
||||||
final static Vec2 stackTrns = new Vec2();
|
final static Vec2 stackTrns = new Vec2();
|
||||||
final static Rectangle r1 = new Rectangle(), r2 = new Rectangle();
|
final static Rect r1 = new Rect(), r2 = new Rect();
|
||||||
/** Distance on the back from where items originate. */
|
/** Distance on the back from where items originate. */
|
||||||
final static float backTrns = 3f;
|
final static float backTrns = 3f;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class JsonIO{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeValue(Object value, Class knownType, Class elementType){
|
public void writeValue(Object value, Class knownType, Class elementType){
|
||||||
if(value instanceof mindustry.ctype.MappableContent){
|
if(value instanceof MappableContent){
|
||||||
try{
|
try{
|
||||||
getWriter().value(((MappableContent)value).name);
|
getWriter().value(((MappableContent)value).name);
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
@@ -95,6 +95,18 @@ public class JsonIO{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
json.setSerializer(Team.class, new Serializer<Team>(){
|
||||||
|
@Override
|
||||||
|
public void write(Json json, Team object, Class knownType){
|
||||||
|
json.writeValue(object.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Team read(Json json, JsonValue jsonData, Class type){
|
||||||
|
return Team.get(jsonData.asInt());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
json.setSerializer(Block.class, new Serializer<Block>(){
|
json.setSerializer(Block.class, new Serializer<Block>(){
|
||||||
@Override
|
@Override
|
||||||
public void write(Json json, Block object, Class knownType){
|
public void write(Json json, Block object, Class knownType){
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package mindustry.net;
|
package mindustry.net;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import mindustry.Vars;
|
import arc.util.ArcAnnotate.*;
|
||||||
|
import mindustry.*;
|
||||||
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.entities.type.*;
|
||||||
|
|
||||||
import static mindustry.Vars.headless;
|
import static mindustry.Vars.headless;
|
||||||
import static mindustry.game.EventType.*;
|
import static mindustry.game.EventType.*;
|
||||||
@@ -14,6 +15,7 @@ public class Administration{
|
|||||||
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<>();
|
private Array<String> whitelist = new Array<>();
|
||||||
|
private Array<ChatFilter> chatFilters = new Array<>();
|
||||||
|
|
||||||
public Administration(){
|
public Administration(){
|
||||||
Core.settings.defaults(
|
Core.settings.defaults(
|
||||||
@@ -24,6 +26,23 @@ public class Administration{
|
|||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Adds a chat filter. This will transform the chat messages of every player.
|
||||||
|
* This functionality can be used to implement things like swear filters and special commands.
|
||||||
|
* Note that commands (starting with /) are not filtered.*/
|
||||||
|
public void addChatFilter(ChatFilter filter){
|
||||||
|
chatFilters.add(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Filters out a chat message. */
|
||||||
|
public @Nullable String filterMessage(Player player, String message){
|
||||||
|
String current = message;
|
||||||
|
for(ChatFilter f : chatFilters){
|
||||||
|
current = f.filter(player, message);
|
||||||
|
if(current == null) return null;
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPlayerLimit(){
|
public int getPlayerLimit(){
|
||||||
return Core.settings.getInt("playerlimit", 0);
|
return Core.settings.getInt("playerlimit", 0);
|
||||||
}
|
}
|
||||||
@@ -334,6 +353,11 @@ public class Administration{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface ChatFilter{
|
||||||
|
/** @return the filtered message; a null string signals that the message should not be sent. */
|
||||||
|
@Nullable String filter(Player player, String message);
|
||||||
|
}
|
||||||
|
|
||||||
public static class TraceInfo{
|
public static class TraceInfo{
|
||||||
public String ip, uuid;
|
public String ip, uuid;
|
||||||
public boolean modded, mobile;
|
public boolean modded, mobile;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import arc.util.pooling.*;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
public class Bar extends Element{
|
public class Bar extends Element{
|
||||||
private static Rectangle scissor = new Rectangle();
|
private static Rect scissor = new Rect();
|
||||||
|
|
||||||
private Floatp fraction;
|
private Floatp fraction;
|
||||||
private String name = "";
|
private String name = "";
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class DeployDialog extends FloatingDialog{
|
|||||||
private final float nodeSize = Scl.scl(230f);
|
private final float nodeSize = Scl.scl(230f);
|
||||||
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
|
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
|
||||||
private ZoneInfoDialog info = new ZoneInfoDialog();
|
private ZoneInfoDialog info = new ZoneInfoDialog();
|
||||||
private Rectangle bounds = new Rectangle();
|
private Rect bounds = new Rect();
|
||||||
private View view = new View();
|
private View view = new View();
|
||||||
|
|
||||||
public DeployDialog(){
|
public DeployDialog(){
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class TechTreeDialog extends FloatingDialog{
|
|||||||
private final float nodeSize = Scl.scl(60f);
|
private final float nodeSize = Scl.scl(60f);
|
||||||
private ObjectSet<TechTreeNode> nodes = new ObjectSet<>();
|
private ObjectSet<TechTreeNode> nodes = new ObjectSet<>();
|
||||||
private TechTreeNode root = new TechTreeNode(TechTree.root, null);
|
private TechTreeNode root = new TechTreeNode(TechTree.root, null);
|
||||||
private Rectangle bounds = new Rectangle();
|
private Rect bounds = new Rect();
|
||||||
private ItemsDisplay items;
|
private ItemsDisplay items;
|
||||||
private View view;
|
private View view;
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public class TechTreeDialog extends FloatingDialog{
|
|||||||
miny = Math.min(n.y - n.height/2f, miny);
|
miny = Math.min(n.y - n.height/2f, miny);
|
||||||
maxy = Math.max(n.y + n.height/2f, maxy);
|
maxy = Math.max(n.y + n.height/2f, maxy);
|
||||||
}
|
}
|
||||||
bounds = new Rectangle(minx, miny, maxx - minx, maxy - miny);
|
bounds = new Rect(minx, miny, maxx - minx, maxy - miny);
|
||||||
bounds.y += nodeSize*1.5f;
|
bounds.y += nodeSize*1.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ public class BranchTreeLayout implements TreeLayout{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle getBounds(){
|
public Rect getBounds(){
|
||||||
return new Rectangle(boundsLeft, boundsBottom, boundsRight - boundsLeft, boundsTop - boundsBottom);
|
return new Rect(boundsLeft, boundsBottom, boundsRight - boundsLeft, boundsTop - boundsBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calcSizeOfLevels(TreeNode node, int level){
|
private void calcSizeOfLevels(TreeNode node, int level){
|
||||||
|
|||||||
@@ -864,7 +864,7 @@ public class Block extends BlockStorage{
|
|||||||
return ((size + 1) % 2) * tilesize / 2f;
|
return ((size + 1) % 2) * tilesize / 2f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle bounds(int x, int y, Rectangle rect){
|
public Rect bounds(int x, int y, Rect rect){
|
||||||
return rect.setSize(size * tilesize).setCenter(x * tilesize + offset(), y * tilesize + offset());
|
return rect.setSize(size * tilesize).setCenter(x * tilesize + offset(), y * tilesize + offset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ public class Tile implements Position, TargetTrait{
|
|||||||
return tmpArray;
|
return tmpArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle getHitbox(Rectangle rect){
|
public Rect getHitbox(Rect rect){
|
||||||
return rect.setSize(block().size * tilesize).setCenter(drawx(), drawy());
|
return rect.setSize(block().size * tilesize).setCenter(drawx(), drawy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ public class DeflectorWall extends Wall{
|
|||||||
public static final float hitTime = 10f;
|
public static final float hitTime = 10f;
|
||||||
|
|
||||||
protected float maxDamageDeflect = 10f;
|
protected float maxDamageDeflect = 10f;
|
||||||
protected Rectangle rect = new Rectangle();
|
protected Rect rect = new Rect();
|
||||||
protected Rectangle rect2 = new Rectangle();
|
protected Rect rect2 = new Rect();
|
||||||
|
|
||||||
public DeflectorWall(String name){
|
public DeflectorWall(String name){
|
||||||
super(name);
|
super(name);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import java.io.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class Door extends Wall{
|
public class Door extends Wall{
|
||||||
protected final static Rectangle rect = new Rectangle();
|
protected final static Rect rect = new Rect();
|
||||||
|
|
||||||
public final int timerToggle = timers++;
|
public final int timerToggle = timers++;
|
||||||
public Effect openfx = Fx.dooropen;
|
public Effect openfx = Fx.dooropen;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import arc.graphics.Color;
|
|||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.Angles;
|
import arc.math.Angles;
|
||||||
import arc.math.Mathf;
|
import arc.math.Mathf;
|
||||||
import arc.math.geom.Rectangle;
|
import arc.math.geom.Rect;
|
||||||
import arc.util.Time;
|
import arc.util.Time;
|
||||||
import mindustry.entities.Units;
|
import mindustry.entities.Units;
|
||||||
import mindustry.entities.type.TileEntity;
|
import mindustry.entities.type.TileEntity;
|
||||||
@@ -19,7 +19,7 @@ import mindustry.world.meta.*;
|
|||||||
import static mindustry.Vars.tilesize;
|
import static mindustry.Vars.tilesize;
|
||||||
|
|
||||||
public class RepairPoint extends Block{
|
public class RepairPoint extends Block{
|
||||||
private static Rectangle rect = new Rectangle();
|
private static Rect rect = new Rect();
|
||||||
|
|
||||||
public int timerTarget = timers++;
|
public int timerTarget = timers++;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=29782072a3c824715118f51ebe23c189ba0d9597
|
archash=60a9ebe264f92f2c3082596c77b9ab29474c4a7f
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
|
import arc.util.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.io.TypeIO;
|
import mindustry.io.*;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.*;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.*;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
|
||||||
|
|
||||||
public class IOTests{
|
public class IOTests{
|
||||||
|
|
||||||
@@ -49,5 +49,23 @@ public class IOTests{
|
|||||||
assertEquals(rules.attackMode, res.attackMode);
|
assertEquals(rules.attackMode, res.attackMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void writeRules2(){
|
||||||
|
Rules rules = new Rules();
|
||||||
|
rules.attackMode = true;
|
||||||
|
rules.tags.put("blah", "bleh");
|
||||||
|
rules.buildSpeedMultiplier = 99.1f;
|
||||||
|
|
||||||
|
String str = JsonIO.write(rules);
|
||||||
|
Rules res = JsonIO.read(Rules.class, str);
|
||||||
|
|
||||||
|
assertEquals(rules.buildSpeedMultiplier, res.buildSpeedMultiplier);
|
||||||
|
assertEquals(rules.attackMode, res.attackMode);
|
||||||
|
assertEquals(rules.tags.get("blah"), res.tags.get("blah"));
|
||||||
|
|
||||||
|
String str2 = JsonIO.write(new Rules(){{
|
||||||
|
attackMode = true;
|
||||||
|
}});
|
||||||
|
Log.info(str2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user