mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-26 14:32:06 -08:00
Stub implementation of action filters
This commit is contained in:
parent
f8f3ecd451
commit
6e5d506a35
5 changed files with 32 additions and 5 deletions
|
|
@ -15,6 +15,7 @@ import mindustry.entities.*;
|
|||
import mindustry.entities.traits.BuilderTrait.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.net.Administration;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Teams.*;
|
||||
|
|
|
|||
|
|
@ -48,8 +48,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||
public float baseRotation;
|
||||
public float pointerX, pointerY;
|
||||
public String name = "noname";
|
||||
public @Nullable
|
||||
String uuid, usid;
|
||||
public @Nullable String uuid, usid;
|
||||
public boolean isAdmin, isTransferring, isShooting, isBoosting, isMobile, isTyping, isBuilding = true;
|
||||
public boolean buildWasAutoPaused = false;
|
||||
public float boostHeat, shootHeat, destructTime;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ public class Administration{
|
|||
private Array<String> bannedIPs = new Array<>();
|
||||
private Array<String> whitelist = new Array<>();
|
||||
private Array<ChatFilter> chatFilters = new Array<>();
|
||||
private Array<ActionFilter> actionFilters = new Array<>();
|
||||
|
||||
public Administration(){
|
||||
load();
|
||||
|
|
@ -71,6 +72,21 @@ public class Administration{
|
|||
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(){
|
||||
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{
|
||||
/** @return the filtered message; a null string signals that the message should not be sent. */
|
||||
@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 String ip, uuid;
|
||||
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 final String address;
|
||||
public boolean mobile, modclient;
|
||||
public @Nullable
|
||||
Player player;
|
||||
public @Nullable Player player;
|
||||
|
||||
/** ID of last recieved client snapshot. */
|
||||
public int lastRecievedClientSnapshot = -1;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=dbdce4d5bfcf9d53dd21480c7d14e90a637eaa8e
|
||||
archash=3b9feb19bb8e608958bcf52ca8efa99b1bd90b96
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue