Skip to content

Commit

Permalink
Merge pull request #5 from udu3324/master
Browse files Browse the repository at this point in the history
Add BlockLobbyMapAds & Fix BlockLobbyWelcome
  • Loading branch information
udu3324 authored Jan 28, 2023
2 parents f3d3dbb + 78baa4e commit fbe542b
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 29 deletions.
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

![Mod Banner](https://github.com/udu3324/Poinpow/blob/master/src/main/resources/assets/poinpow/banner.png?raw=true)

![License](https://img.shields.io/github/license/udu3324/poinpow)
![Latest Releases](https://img.shields.io/github/v/release/udu3324/Poinpow)
![Github Downloads](https://img.shields.io/github/downloads/udu3324/poinpow/total)
![Modrinth Downloads](https://modrinth-utils.vercel.app/api/badge/downloads?id=zmUzIoT1)
![Mod loader: Fabric](https://img.shields.io/badge/modloader-Fabric-decea6?style=round)
![Requires](https://img.shields.io/badge/requires-Fabric%20API-dece5a?style=round)
![License](https://img.shields.io/github/license/udu3324/poinpow)
![Latest Releases](https://img.shields.io/github/v/release/udu3324/Poinpow)
![Github Downloads](https://img.shields.io/github/downloads/udu3324/poinpow/total)
![Modrinth Downloads](https://modrinth-utils.vercel.app/api/badge/downloads?id=zmUzIoT1)
![Mod loader: Fabric](https://img.shields.io/badge/modloader-Fabric-decea6?style=round)
![Requires](https://img.shields.io/badge/requires-Fabric%20API-dece5a?style=round)
[![Discord Server](https://img.shields.io/badge/Official%20Discord%20Server-7289DA?style=round&logo=discord&logoColor=white)](https://discord.gg/NXm9tJvyBT)

# 📘 Features
Expand All @@ -17,14 +18,15 @@ Poinpow adds **utilities/features** that **make the player experience 102% bette
- **RemoveLobbyRanks** - Removes ranks from players in lobby, and generalize colors
- **BlockFreeCredits** - Blocks the vote messages encouraging free credits | `Example: [Minehut] PuppiesAreNice just got free credits by voting via /vote`
- **BlockLobbyWelcome** - Blocks the lobby join message that sometimes has an ad in it
- **BlockLobbyMapAds** - Removes the humungous map art that advertises things in lobby.

Skipping ads **automatically** with AutoSkipBarrier **(very fast)**

![](https://cdn.modrinth.com/data/zmUzIoT1/images/aaa8cda2723de8979014cde22db46d34c8160553.png)

Example of **Block Lobby Ads** (blocks /ad commands by player) It clears up chat so much!!
Example of **Block Lobby Ads** (blocks /ad commands by player) and BlockLobbyMapAds. It clears up chat a lot and blocks those awful map ads.

![](https://cdn.modrinth.com/data/zmUzIoT1/images/469c7fe6b0d73545fed47ea104dda8ca882c5607.png)
![](https://cdn.modrinth.com/data/zmUzIoT1/images/c49843c5f4e7412df0c53670e94f3434eb4c4238.png)

/poinpow - **intractable/clickable** help command

Expand All @@ -51,5 +53,5 @@ If you want to **contribute to the code** or **make the jar yourself**, you can
## 🧾 Is it Against the Rules?
**No.** I read the rules, and it doesn't break any. Unless..... "Minehut reserves the right to suspend or refuse service for users and servers at any time at their discretion." bruh

## How to Contribute
You can contribute by starring the repo, reporting issues, and creating pull requests. You can also send feedback in the [discord server](https://discord.gg/NXm9tJvyBT).
## 💚 How to Contribute
You can contribute by starring the repo, reporting issues, and creating pull requests. You can also send feedback in the [discord server](https://discord.gg/NXm9tJvyBT).
2 changes: 2 additions & 0 deletions src/main/java/com/udu3324/poinpow/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static void create() {
w.write(BlockLobbyAds.name + ": true" + System.lineSeparator());
w.write(BlockMinehutAds.name + ": true" + System.lineSeparator());
w.write(BlockFreeCredits.name + ": true" + System.lineSeparator());
w.write(BlockLobbyMapAds.name + ": true" + System.lineSeparator());
w.close();

Poinpow.log.info("New config created.");
Expand All @@ -136,6 +137,7 @@ public static void create() {
BlockLobbyAds.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockLobbyAds.name)));
BlockMinehutAds.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockMinehutAds.name)));
BlockFreeCredits.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockFreeCredits.name)));
BlockLobbyMapAds.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockLobbyMapAds.name)));
}
}
} catch (IOException e) {
Expand Down
45 changes: 32 additions & 13 deletions src/main/java/com/udu3324/poinpow/commands/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
.executes(ctx -> description(ctx.getSource(), BlockFreeCredits.name, BlockFreeCredits.description, BlockFreeCredits.toggled))
.then(literal("true").executes(ctx -> toggle(ctx.getSource(), BlockFreeCredits.name, BlockFreeCredits.toggled, true)))
.then(literal("false").executes(ctx -> toggle(ctx.getSource(), BlockFreeCredits.name, BlockFreeCredits.toggled, false))))

.then(literal(BlockLobbyMapAds.name)
.executes(ctx -> description(ctx.getSource(), BlockLobbyMapAds.name, BlockLobbyMapAds.description, BlockLobbyMapAds.toggled))
.then(literal("true").executes(ctx -> toggle(ctx.getSource(), BlockLobbyMapAds.name, BlockLobbyMapAds.toggled, true)))
.then(literal("false").executes(ctx -> toggle(ctx.getSource(), BlockLobbyMapAds.name, BlockLobbyMapAds.toggled, false))))
);
}

Expand All @@ -72,11 +77,12 @@ private static int description(FabricClientCommandSource source, String name, St
running = true;

//show the command
source.sendFeedback(Text.literal("\n/poinpow " + name + " [toggled|" + toggled.get() + "]").styled(style -> style
source.sendFeedback(Text.literal("\n/poinpow " + name + " toggled|" + toggled.get()).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to Toggle!")))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/poinpow " + name + " " + !toggled.get()))
.withColor(Formatting.GOLD)
.withUnderline(true)));

//show the command's description
source.sendFeedback(Text.literal(description).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal("Click to Toggle!")))
Expand Down Expand Up @@ -104,39 +110,52 @@ private static int help(FabricClientCommandSource source) {
));

//remove lobby ranks
source.sendFeedback(Text.literal("/poinpow " + RemoveLobbyRanks.name + " [toggled|" + RemoveLobbyRanks.toggled + "]").styled(style -> style
source.sendFeedback(Text.literal("[toggled|" + RemoveLobbyRanks.toggled + "] " + RemoveLobbyRanks.name + " (click 2 toggle)").styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(RemoveLobbyRanks.description + "\n\nClick to Toggle")))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RemoveLobbyRanks.name + " " + !RemoveLobbyRanks.toggled.get()))
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/poinpow " + RemoveLobbyRanks.name + " " + !RemoveLobbyRanks.toggled.get()))
.withColor(Formatting.DARK_GRAY)
));

//auto skip barrier
source.sendFeedback(Text.literal("/poinpow " + AutoSkipBarrier.name + " [toggled|" + AutoSkipBarrier.toggled + "]").styled(style -> style
source.sendFeedback(Text.literal("[toggled|" + AutoSkipBarrier.toggled + "] " + AutoSkipBarrier.name).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(AutoSkipBarrier.description + "\n\nClick to Toggle")))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + AutoSkipBarrier.name + " " + !AutoSkipBarrier.toggled.get()))
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/poinpow " + AutoSkipBarrier.name + " " + !AutoSkipBarrier.toggled.get()))
.withColor(Formatting.DARK_GRAY)
));

//block lobby welcome
source.sendFeedback(Text.literal("/poinpow " + BlockLobbyWelcome.name + " [toggled|" + BlockLobbyWelcome.toggled + "]").styled(style -> style
source.sendFeedback(Text.literal("[toggled|" + BlockLobbyWelcome.toggled + "] " + BlockLobbyWelcome.name).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(BlockLobbyWelcome.description + "\n\nClick to Toggle")))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + BlockLobbyWelcome.name + " " + !BlockLobbyWelcome.toggled.get()))
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/poinpow " + BlockLobbyWelcome.name + " " + !BlockLobbyWelcome.toggled.get()))
.withColor(Formatting.DARK_GRAY)
));

//block lobby ads
source.sendFeedback(Text.literal("/poinpow " + BlockLobbyAds.name + " [toggled|" + BlockLobbyAds.toggled + "]").styled(style -> style
source.sendFeedback(Text.literal("[toggled|" + BlockLobbyAds.toggled + "] " + BlockLobbyAds.name).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(BlockLobbyAds.description + "\n\nClick to Toggle")))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + BlockLobbyAds.name + " " + !BlockLobbyAds.toggled.get()))
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/poinpow " + BlockLobbyAds.name + " " + !BlockLobbyAds.toggled.get()))
.withColor(Formatting.DARK_GRAY)
));

//block minehut ads
source.sendFeedback(Text.literal("/poinpow " + BlockMinehutAds.name + " [toggled|" + BlockMinehutAds.toggled + "]").styled(style -> style
source.sendFeedback(Text.literal("[toggled|" + BlockMinehutAds.toggled + "] " + BlockMinehutAds.name).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(BlockMinehutAds.description + "\n\nClick to Toggle")))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + BlockMinehutAds.name + " " + !BlockMinehutAds.toggled.get()))
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/poinpow " + BlockMinehutAds.name + " " + !BlockMinehutAds.toggled.get()))
.withColor(Formatting.DARK_GRAY)
));

//block free credits
source.sendFeedback(Text.literal("/poinpow " + BlockFreeCredits.name + " [toggled|" + BlockFreeCredits.toggled + "]").styled(style -> style
source.sendFeedback(Text.literal("[toggled|" + BlockFreeCredits.toggled + "] " + BlockFreeCredits.name).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(BlockFreeCredits.description + "\n\nClick to Toggle")))
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + BlockFreeCredits.name + " " + !BlockFreeCredits.toggled.get()))
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/poinpow " + BlockFreeCredits.name + " " + !BlockFreeCredits.toggled.get()))
.withColor(Formatting.DARK_GRAY)
));

//block lobby map ads
source.sendFeedback(Text.literal("[toggled|" + BlockLobbyMapAds.toggled + "] " + BlockLobbyMapAds.name).styled(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(BlockLobbyMapAds.description + "\n\nClick to Toggle")))
.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/poinpow " + BlockLobbyMapAds.name + " " + !BlockLobbyMapAds.toggled.get()))
.withColor(Formatting.DARK_GRAY)
));

running = false;
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/udu3324/poinpow/mixin/MapartMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.udu3324.poinpow.mixin;

import com.udu3324.poinpow.utils.BlockLobbyMapAds;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.ItemFrameEntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ItemFrameEntityRenderer.class)
public class MapartMixin {
@Inject(method = "render(Lnet/minecraft/entity/Entity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"))
private void onRender(Entity entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
BlockLobbyMapAds.block(entity);
}
}
48 changes: 48 additions & 0 deletions src/main/java/com/udu3324/poinpow/utils/BlockLobbyMapAds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.udu3324.poinpow.utils;

import com.udu3324.poinpow.Poinpow;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.scoreboard.ScoreboardObjective;
import net.minecraft.text.Text;

import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;

public class BlockLobbyMapAds {
public static String name = "block_lobby_map_ads";
public static String description = "Removes the humungous map art that advertises things in lobby.";
public static AtomicBoolean toggled = new AtomicBoolean(true);
private static final ItemStack item = new ItemStack(Items.DIAMOND, 1).setCustomName(Text.of("Poinpow by udu3324"));

public static void block(Entity entity) {
// return if toggled off (no need for bool)
if (!toggled.get()) return;

// return if not on minehut
if (!Poinpow.onMinehut) return;

if (MinecraftClient.getInstance().player == null) return;

// check for scoreboard
Scoreboard scoreboard = MinecraftClient.getInstance().player.getScoreboard();
ArrayList<String> objectivesList = scoreboard.getObjectives().stream().map(ScoreboardObjective::getName).collect(Collectors.toCollection(ArrayList::new));

if (!objectivesList.contains("Minehut")) return;

// remove if item frame has a map in it
ItemFrameEntity itemFrame = (ItemFrameEntity) entity;

if (!itemFrame.containsMap()) return;

Poinpow.log.info("Blocked: Lobby Map Ad (" + itemFrame.getBlockX() + ", " + itemFrame.getBlockY() + ", " + itemFrame.getBlockZ() + ")");

itemFrame.setHeldItemStack(item);
itemFrame.setRotation(1);
}
}
11 changes: 6 additions & 5 deletions src/main/java/com/udu3324/poinpow/utils/BlockLobbyWelcome.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ public static Boolean check(String chat, CallbackInfo ci) {
if (ignoreChat) {
limit++;

//parsing failed
if (limit >= 6) {
if (chat.contains("https://go.minehut.com")) ignoreChat = false;
blocked = true;

//parsing failed (either it went over limit of 6, or a player sent a msg)
if (limit >= 6 || (chat.contains(":") && !chat.contains("http"))) {
ignoreChat = false;
limit = 0;
blocked = false;
}

if (chat.contains("https://go.minehut.com")) ignoreChat = false;
blocked = true;
}

Pattern pattern = Pattern.compile("^Welcome back, [a-zA-Z0-9_.]{1,16}$");
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/poinpow.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"package": "com.udu3324.poinpow.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"WorldLoadedMixin"
"WorldLoadedMixin",
"MapartMixin"
],
"client": [
"ChatMixin"
Expand Down

0 comments on commit fbe542b

Please sign in to comment.