Skip to content

Commit

Permalink
Update adblock to include fish ads
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Oct 16, 2023
1 parent 2302518 commit 54cd19d
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 77 deletions.
4 changes: 1 addition & 3 deletions core/src/mindustry/client/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ object Client {

if (!configs.isEmpty()) {
try {
if (ratelimitRemaining > 0) { // Run the config
configs.poll().run()
}
if (ratelimitRemaining > 1) configs.poll().run() // Run the config (leave 1 free config just in case)
} catch (e: Exception) {
Log.err(e)
}
Expand Down
12 changes: 6 additions & 6 deletions core/src/mindustry/client/ClientVars.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public class ClientVars {

// Hotkeys
public static boolean
showingTurrets, showingAllyTurrets, showingInvTurrets,
hidingUnits, hidingAirUnits,
hidingBlocks, hidingPlans,
dispatchingBuildPlans,
showingOverdrives,
showingMassDrivers;
showingTurrets, showingAllyTurrets, showingInvTurrets,
hidingUnits, hidingAirUnits,
hidingBlocks, hidingPlans,
dispatchingBuildPlans,
showingOverdrives,
showingMassDrivers;
@NotNull public static Seq<OverdriveProjector.OverdriveBuild> overdrives = new Seq<>(); // For whatever reason the stupid allBuildings method hates me so im just not using it FINISHME: Replace this by just expanding block clipsize and drawing a circle in the draw method rather than using this
@NotNull public static Seq<MassDriver.MassDriverBuild> massDrivers = new Seq<>(); // FINISHME: this too.
@NotNull public static Seq<PayloadMassDriver.PayloadDriverBuild> payloadMassDrivers = new Seq<>(); // i literally just copypasted the code
Expand Down
230 changes: 176 additions & 54 deletions core/src/mindustry/client/utils/ServerUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum class Server( // FINISHME: This is horrible. Why have I done this?
other(null),
nydus("nydus"),
cn("Chaotic Neutral", rtv = Cmd("/rtv")),
io("io", MapVote(), Cmd("/w"), Cmd("/rtv"), object : Cmd("/freeze", 4){
io("io", MapVote(), Cmd("/w"), Cmd("/rtv"), object : Cmd("/freeze", 4) {
override fun run(vararg args: String) { // Freeze command requires admin in game but the packet does not
if (!player.admin) Call.serverPacketReliable("freeze_by_id", args[0]) // Yes this will cause a crash when args.size == 0, it shouldn't happen
else super.run(*args)
Expand All @@ -59,7 +59,25 @@ enum class Server( // FINISHME: This is horrible. Why have I done this?
},
phoenix("Phoenix Network", null, Cmd("/w"), Cmd("/rtv"), Cmd("/freeze", 9), votekickString = "Type [cyan]/vote y"),
korea("Korea", ghost = true),
fish("Fish", null, Cmd("/msg")),
fish("Fish", null, Cmd("/msg")) {
override fun handleMessage(msg: String, unformatted: String?, sender: Player?): Boolean {
if (sender == null && ohnoTask != null) { // Very hacky way of handling autoOhno
if ("Too close to an enemy tile!" in msg || "You cannot spawn ohnos while dead." in msg) return true // We don't care honestly
if ("Sorry, the max number of ohno units has been reached." in msg || "Ohnos have been temporarily disabled." in msg || "Ohnos are disabled in PVP." in msg) {
Time.run(60f) {
ohnoTask?.cancel()
ohnoTask = null
} // Null it out a second later, this is just to prevent any additional messages from bypassing the return below
ohnoTask!!.cancel()
return true
}
}

if (sender == null && "Fish Membership" in msg) return true // Adblock

return false // All other messages are okay
}
},
darkdustry("Darkdustry")
;

Expand Down Expand Up @@ -141,6 +159,9 @@ enum class Server( // FINISHME: This is horrible. Why have I done this?
}

fun isVotekick(msg: String) = votekickString in msg

/** Handle's a message on a server. If true is returned, the message will be discarded and not printed. */
open fun handleMessage(msg: String, unformatted: String?, sender: Player?): Boolean = false
}

enum class CustomMode {
Expand All @@ -151,59 +172,160 @@ enum class CustomMode {
override fun enable() {
super.enable()

overwrites( // This system is awful but it (mostly) works and it wasn't hard to implement.
UnitTypes.pulsar, "abilities", Seq<Ability>(0), // Pulsar shield regen field removed
UnitTypes.crawler, "health", 100f,
UnitTypes.crawler, "speed", 1.5f,
UnitTypes.crawler, "accel", 0.08f,
UnitTypes.crawler, "drag", 0.016f,
UnitTypes.crawler, "flying", true,
UnitTypes.atrax, "speed", 0.5f,
UnitTypes.spiroct, "speed", 0.4f,
UnitTypes.spiroct, "targetAir", false,
UnitTypes.arkyid, "speed", 0.5f ,
UnitTypes.arkyid, "targetAir", false,
UnitTypes.toxopid, "targetAir", false,
UnitTypes.flare, "health", 275,
UnitTypes.flare, "range", 140,
UnitTypes.horizon, "itemCapacity", 20, // Horizons can pick up items in flood, this just allows the items to draw correctly
UnitTypes.horizon, "health", 440,
UnitTypes.horizon, "speed", 1.7f,
UnitTypes.zenith, "health", 1400,
UnitTypes.zenith, "speed", 1.8f,
UnitTypes.oct, "abilities", Seq.with(ForceFieldAbility(140f, 16f, 15000f, 60f * 8)), // Oct heal removed, force field buff
UnitTypes.bryde, "abilities", Seq<Ability>(0), // Bryde shield regen field removed

Blocks.surgeWall, "lightningChance", 0f,
Blocks.reinforcedSurgeWall, "lightningChance", 0f,
Blocks.mender, "healAmount", 6f,
Blocks.mender, "phaseBoost", 2f,
Blocks.mendProjector, "phaseBoost", 12f,
Blocks.mendProjector, "phaseBoost", 2f,
Blocks.forceProjector, "shieldHealth", 2500f,
Blocks.forceProjector, "coolantConsumer", ConsumeCoolant(.1f), // FINISHME: This one probably breaks things, also it wont display correctly in the stats page
Blocks.radar, "health", 500,
Blocks.regenProjector, "healPercent", 12f, // Nice balance, a casual 180x buff
Blocks.shockwaveTower, "health", 2000,
overwrites(
// This system is awful but it (mostly) works and it wasn't hard to implement.
UnitTypes.pulsar,
"abilities",
Seq<Ability>(0), // Pulsar shield regen field removed
UnitTypes.crawler,
"health",
100f,
UnitTypes.crawler,
"speed",
1.5f,
UnitTypes.crawler,
"accel",
0.08f,
UnitTypes.crawler,
"drag",
0.016f,
UnitTypes.crawler,
"flying",
true,
UnitTypes.atrax,
"speed",
0.5f,
UnitTypes.spiroct,
"speed",
0.4f,
UnitTypes.spiroct,
"targetAir",
false,
UnitTypes.arkyid,
"speed",
0.5f,
UnitTypes.arkyid,
"targetAir",
false,
UnitTypes.toxopid,
"targetAir",
false,
UnitTypes.flare,
"health",
275,
UnitTypes.flare,
"range",
140,
UnitTypes.horizon,
"itemCapacity",
20, // Horizons can pick up items in flood, this just allows the items to draw correctly
UnitTypes.horizon,
"health",
440,
UnitTypes.horizon,
"speed",
1.7f,
UnitTypes.zenith,
"health",
1400,
UnitTypes.zenith,
"speed",
1.8f,
UnitTypes.oct,
"abilities",
Seq.with(ForceFieldAbility(140f, 16f, 15000f, 60f * 8)), // Oct heal removed, force field buff
UnitTypes.bryde,
"abilities",
Seq<Ability>(0), // Bryde shield regen field removed

Blocks.surgeWall,
"lightningChance",
0f,
Blocks.reinforcedSurgeWall,
"lightningChance",
0f,
Blocks.mender,
"healAmount",
6f,
Blocks.mender,
"phaseBoost",
2f,
Blocks.mendProjector,
"phaseBoost",
12f,
Blocks.mendProjector,
"phaseBoost",
2f,
Blocks.forceProjector,
"shieldHealth",
2500f,
Blocks.forceProjector,
"coolantConsumer",
ConsumeCoolant(.1f), // FINISHME: This one probably breaks things, also it wont display correctly in the stats page
Blocks.radar,
"health",
500,
Blocks.regenProjector,
"healPercent",
12f, // Nice balance, a casual 180x buff
Blocks.shockwaveTower,
"health",
2000,
// Blocks.shockwaveTower, "consumeLiquids", Blocks.shockwaveTower.consumeLiquids(*LiquidStack.with(Liquids.cyanogen, 1f / 60f)) // FINISHME: This one too, consumers are annoying
Blocks.plastaniumConveyor, "absorbLasers", true,
Blocks.plastaniumConveyor, "health", 225,
Blocks.thoriumReactor, "health", 1400,
(Blocks.lancer as PowerTurret).shootType, "damage", 10,
(Blocks.arc as PowerTurret).shootType, "damage", 4,
(Blocks.arc as PowerTurret).shootType, "lightningLength", 15,
(Blocks.swarmer as ItemTurret).shoot, "shots", 5,
(Blocks.swarmer as ItemTurret).shoot, "shotDelay", 4f,
Blocks.segment, "range", 160f,
Blocks.segment, "reload", 9f,
Blocks.tsunami, "reload", 2f,
(Blocks.fuse as ItemTurret).ammoTypes.get(Items.titanium), "pierce", false,
(Blocks.fuse as ItemTurret).ammoTypes.get(Items.titanium), "damage", 10f,
(Blocks.fuse as ItemTurret).ammoTypes.get(Items.thorium), "pierce", false,
(Blocks.fuse as ItemTurret).ammoTypes.get(Items.thorium), "damage", 20f,
Blocks.breach, "targetUnderBlocks", true,
Blocks.diffuse, "targetUnderBlocks", true,
Blocks.scathe, "targetUnderBlocks", true,
Blocks.plastaniumConveyor,
"absorbLasers",
true,
Blocks.plastaniumConveyor,
"health",
225,
Blocks.thoriumReactor,
"health",
1400,
(Blocks.lancer as PowerTurret).shootType,
"damage",
10,
(Blocks.arc as PowerTurret).shootType,
"damage",
4,
(Blocks.arc as PowerTurret).shootType,
"lightningLength",
15,
(Blocks.swarmer as ItemTurret).shoot,
"shots",
5,
(Blocks.swarmer as ItemTurret).shoot,
"shotDelay",
4f,
Blocks.segment,
"range",
160f,
Blocks.segment,
"reload",
9f,
Blocks.tsunami,
"reload",
2f,
(Blocks.fuse as ItemTurret).ammoTypes.get(Items.titanium),
"pierce",
false,
(Blocks.fuse as ItemTurret).ammoTypes.get(Items.titanium),
"damage",
10f,
(Blocks.fuse as ItemTurret).ammoTypes.get(Items.thorium),
"pierce",
false,
(Blocks.fuse as ItemTurret).ammoTypes.get(Items.thorium),
"damage",
20f,
Blocks.breach,
"targetUnderBlocks",
true,
Blocks.diffuse,
"targetUnderBlocks",
true,
Blocks.scathe,
"targetUnderBlocks",
true,
)

val fsAmmo = (Blocks.foreshadow as ItemTurret).ammoTypes
Expand Down
18 changes: 4 additions & 14 deletions core/src/mindustry/core/NetClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,12 @@ public static void effectReliable(Effect effect, float x, float y, float rotatio

@Remote(targets = Loc.server, variants = Variant.both)
public static void sendMessage(String message, @Nullable String unformatted, @Nullable Player playersender){
if(Server.fish.b() && Server.ohnoTask != null) { // Very hacky
if (message.contains("Too close to an enemy tile!") || message.contains("You cannot spawn ohnos while dead.")) return; // We don't care honestly
if (message.contains("Sorry, the max number of ohno units has been reached.") || message.contains("Ohnos have been temporarily disabled.")) {
Time.run(60f, () -> {
if (Server.ohnoTask != null) Server.ohnoTask.cancel();
Server.ohnoTask = null;
}); // Null it out a second later, this is just to prevent any additional messages from bypassing the return below
Server.ohnoTask.cancel();
return;
}
}

Events.fire(new PlayerChatEvent(playersender, unformatted != null ? unformatted : message != null ? message : "")); // Foo addition, why is this not a vanilla thing?
// message is the full formatted message from the server, including the sender
// unformatted is the message content itself, i.e. "gg", null for server messages
// playersender is exactly what you think it is, null for server messages
if(Server.current.handleMessage(message, unformatted, playersender)) return;

Events.fire(new PlayerChatEvent(playersender, unformatted != null ? unformatted : message != null ? message : "")); // Foo addition, why is this not a vanilla thing?

Color background = null;
if(Vars.ui != null){
Expand Down Expand Up @@ -804,7 +794,7 @@ void sync(){
int uid = player.dead() ? -1 : unit.id;
Vec2 aimPos = Main.INSTANCE.floatEmbed();

TypeIO.useConfigLocal = true; // FINISHME: Awful.
TypeIO.useConfigLocal = true; // Awful.
Call.clientSnapshot(
lastSent++,
uid,
Expand Down

0 comments on commit 54cd19d

Please sign in to comment.