Stub implementation of action filters
This commit is contained in:
@@ -15,6 +15,7 @@ import mindustry.entities.*;
|
|||||||
import mindustry.entities.traits.BuilderTrait.*;
|
import mindustry.entities.traits.BuilderTrait.*;
|
||||||
import mindustry.entities.traits.*;
|
import mindustry.entities.traits.*;
|
||||||
import mindustry.entities.type.*;
|
import mindustry.entities.type.*;
|
||||||
|
import mindustry.net.Administration;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.game.Teams.*;
|
import mindustry.game.Teams.*;
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||||||
public float baseRotation;
|
public float baseRotation;
|
||||||
public float pointerX, pointerY;
|
public float pointerX, pointerY;
|
||||||
public String name = "noname";
|
public String name = "noname";
|
||||||
public @Nullable
|
public @Nullable String uuid, usid;
|
||||||
String uuid, usid;
|
|
||||||
public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile, isTyping, isBuilding = true;
|
public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile, isTyping, isBuilding = true;
|
||||||
public boolean buildWasAutoPaused = false;
|
public boolean buildWasAutoPaused = false;
|
||||||
public float boostHeat, shootHeat, destructTime;
|
public float boostHeat, shootHeat, destructTime;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public class Administration{
|
|||||||
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<>();
|
private Array<ChatFilter> chatFilters = new Array<>();
|
||||||
|
private Array<ActionFilter> actionFilters = new Array<>();
|
||||||
|
|
||||||
public Administration(){
|
public Administration(){
|
||||||
load();
|
load();
|
||||||
@@ -71,6 +72,21 @@ public class Administration{
|
|||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Add a filter to actions, preventing things such as breaking or configuring blocks. */
|
||||||
|
public void addActionFilter(ActionFilter filter){
|
||||||
|
actionFilters.add(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return whether this action is allowed by the action filters. */
|
||||||
|
public boolean allowAction(Player player, PlayerAction action){
|
||||||
|
for(ActionFilter filter : actionFilters){
|
||||||
|
if(!filter.allow(player, action)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPlayerLimit(){
|
public int getPlayerLimit(){
|
||||||
return Core.settings.getInt("playerlimit", 0);
|
return Core.settings.getInt("playerlimit", 0);
|
||||||
}
|
}
|
||||||
@@ -452,11 +468,18 @@ public class Administration{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Handles chat messages from players and changes their contents. */
|
||||||
public interface ChatFilter{
|
public interface ChatFilter{
|
||||||
/** @return the filtered message; a null string signals that the message should not be sent. */
|
/** @return the filtered message; a null string signals that the message should not be sent. */
|
||||||
@Nullable String filter(Player player, String message);
|
@Nullable String filter(Player player, String message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Allows or disallows player actions. */
|
||||||
|
public interface ActionFilter{
|
||||||
|
/** @return whether this action should be permitted. if applicable, make sure to send this player a message specify why the action was prohibited. */
|
||||||
|
boolean allow(Player player, PlayerAction action);
|
||||||
|
}
|
||||||
|
|
||||||
public static class TraceInfo{
|
public static class TraceInfo{
|
||||||
public String ip, uuid;
|
public String ip, uuid;
|
||||||
public boolean modded, mobile;
|
public boolean modded, mobile;
|
||||||
@@ -469,4 +492,9 @@ public class Administration{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO implement
|
||||||
|
public static class PlayerAction{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ import static mindustry.Vars.netServer;
|
|||||||
public abstract class NetConnection{
|
public abstract class NetConnection{
|
||||||
public final String address;
|
public final String address;
|
||||||
public boolean mobile, modclient;
|
public boolean mobile, modclient;
|
||||||
public @Nullable
|
public @Nullable Player player;
|
||||||
Player player;
|
|
||||||
|
|
||||||
/** ID of last recieved client snapshot. */
|
/** ID of last recieved client snapshot. */
|
||||||
public int lastRecievedClientSnapshot = -1;
|
public int lastRecievedClientSnapshot = -1;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=dbdce4d5bfcf9d53dd21480c7d14e90a637eaa8e
|
archash=3b9feb19bb8e608958bcf52ca8efa99b1bd90b96
|
||||||
|
|||||||
Reference in New Issue
Block a user