Skip to content

Commit

Permalink
Merge pull request #28 from udu3324/master
Browse files Browse the repository at this point in the history
update
  • Loading branch information
udu3324 authored May 25, 2024
2 parents 64531be + 9cac976 commit 89b3a28
Show file tree
Hide file tree
Showing 27 changed files with 467 additions and 121 deletions.
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,48 @@
# 📘 Features
Poinpow adds **utilities/features** that **make the player experience 102% better**. If you catch a bug, create an issue in the repo or send it to me in this [discord server](https://discord.gg/NXm9tJvyBT).

- **HubCommandBack** - Adds back the hub (instead of /mh) command in servers that don't have it
- **BlockMinehutAds** - Blocks ads from minehut that are sent in free servers | `Example: [Minehut] boost your server speed!!! go to this link!!!`
- **ChatPhraseFilter** - Store a user made list of regex and filter lobby`Example: /poinpow chat_phrase_filter "join my server"`
- **BlockLobbyAds** - Blocks player made ads in the lobby | `Example: [Ad] NintendoOS: /join fishwind join my server for op yes`
- **AutoSkipBarrier** - Automatically skip the ads when joining minehut or free servers
- **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
- **AutoSkipBarrier** - Automatically skip the ads when joining minehut or free servers.
- **HubCommandBack** - Adds back the hub command.
- **BlockMinehutAds** - Blocks ads from minehut that are sent in free servers `Example: [Minehut] boost your server speed!!!`
- **ChatPhraseFilter** - Filters and blocks messages in chat based on a regex list.
- **BlockLobbyAds** - Blocks player made ads in the lobby. `Example: [Ad] NintendoOS: /join fishwind join my server for op yes`
- **BlockFreeCredits** - Blocks the vote messages encouraging to vote for free credits.
- **BlockLobbyWelcome** - Blocks the lobby join message that sometimes has an ad in it.
- **BlockLobbyMapAds** - Removes the humungous map art that advertises things in lobby.
- **LookupServer** - A command to see details about a minehut server. (contributed by [BuggyAl](https://github.com/BuggyAl))

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

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

- **BlockRaids** - Blocks the raid messages in hub.
- **ToggleSpecificAds** - Extends BlockLobbyAds to toggle which ranks can advertise.
- **BlockChestAds** - Removes the ads inside the compass server listing in hub.
- **ServerLookup** - A command to see details about a minehut server. (by [BuggyAl](https://github.com/BuggyAl))

![](https://cdn.modrinth.com/data/zmUzIoT1/images/aaa8cda2723de8979014cde22db46d34c8160553.png)
Skipping ads **automatically** with AutoSkipBarrier **(extremely fast)**

![](https://cdn.modrinth.com/data/zmUzIoT1/images/c49843c5f4e7412df0c53670e94f3434eb4c4238.png)
Example of **BlockLobbyAds** (blocks ads made by player) and **BlockLobbyMapAds**. It clears up chat a lot and blocks those awful map ads.

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

/poinpow - An **intractable/clickable** help command that easily allows the toggling of certain features.

![](https://cdn.modrinth.com/data/zmUzIoT1/images/257cc486abee7e7f68aca9fb0c6d5fc2d8979cd5.png)
![](https://cdn.modrinth.com/data/zmUzIoT1/images/75745e7d81968d0ad369493ab3174f0d2a605517.png)
/poinpow - An **intractable/clickable** help command that easily allows the toggling of features.

## 💾 How to Install
0. Make sure you have **[Fabric](https://fabricmc.net/use/installer/)** installed in your mc launcher
1. Download the latest release of **Poinpow** [here](https://github.com/udu3324/poinpow/releases)
2. Download the latest release of **Fabric API** [here](https://modrinth.com/mod/fabric-api/versions)
3. Move the **two jars** you downloaded into the mods folder **(its usually .minecraft/mods)**
4. Launch Minecraft and **enjoy the mod!**
5. **(optional)** Star the repository to support me :> You can join the [discord server](https://discord.gg/NXm9tJvyBT) to send feedback about the mod too.

## 🛠 How to Compile Jar
1. Make sure you have **[Fabric](https://fabricmc.net/use/installer/)** installed in your mc launcher
2. Download the latest release of **Poinpow** [here](https://github.com/udu3324/poinpow/releases)
3. Download the latest release of **Fabric API** [here](https://modrinth.com/mod/fabric-api/versions)
4. Move the **two jars** you downloaded into the mods folder **(its usually .minecraft/mods)**
5. Launch Minecraft and **enjoy the mod!**
6. **(optional)** Star the repository to support me :> You can join the [discord server](https://discord.gg/NXm9tJvyBT) to send feedback about the mod too.

## 🛠 How to Compile the Jar
If you want to **contribute to the code** or **make the jar yourself**, you can follow the steps below.

0. Make sure you have **JDK 17** or above installed.
1. Clone the repository and extract it to a folder
2. Open a terminal and cd to the folder
3. Run `gradlew build` or `.\gradlew build` depending on your system os
4. Done! The jar should be in `/build/libs`
5. (optional) Open up the folder in your IDE (intellij recommended) to look at the code and contribute to it if you want :>
1. Make sure you have **JDK 17** or above installed.
2. Clone the repository and extract it to a folder
3. Open a terminal and cd to the folder
4. Run `gradlew build` or `.\gradlew build` depending on your system os
5. Done! The jar should be in `/build/libs`
6. (optional) Open up the folder in your IDE (intellij recommended) to look at the code and contribute to it if you want :>

## 🧾 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) or send me a [ko-fi](https://ko-fi.com/udu3324).
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ org.gradle.parallel=true
loader_version=0.15.3

# Mod Properties
mod_version = 1.6.2
mod_version = 1.6.3
maven_group = com.udu3324
archives_base_name = poinpow

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
73 changes: 51 additions & 22 deletions src/main/java/com/udu3324/poinpow/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
import java.util.ArrayList;
import java.util.regex.Pattern;

import static com.udu3324.poinpow.utils.ToggleSpecificAds.*;

public class Config {
private static final ModContainer mod = FabricLoader.getInstance()
.getModContainer("poinpow")
.orElseThrow(NullPointerException::new);
public static final String version = mod.getMetadata().getVersion().getFriendlyString();
public static File configFile = new File(FabricLoader.getInstance().getConfigDir().toString() + File.separator + "poinpow.cfg");

//get the version number stored in the config
public static Boolean isLatestModVersion() throws IOException {
BufferedReader brTest = new BufferedReader(new FileReader(configFile));
String text = brTest.readLine();
Expand Down Expand Up @@ -95,7 +98,7 @@ public static void setValueFromConfig(String value, String data) {
}
}

//
//this gets the list of regex at the bottom of the config
public static ArrayList<Pattern> getListOfRegex() {
try {
ArrayList<String> lines = getConfig();
Expand Down Expand Up @@ -133,6 +136,7 @@ public static ArrayList<Pattern> getListOfRegex() {
}
}

//this adds a line of regex at the bottom of the config
public static void addRegex(String regex) {
try {
FileWriter writer = new FileWriter(configFile, true);
Expand All @@ -144,6 +148,7 @@ public static void addRegex(String regex) {
}
}

//this removes a line of regex at the bottom of the config
public static void removeRegex(String regex) {
try {
ArrayList<String> lines = getConfig();
Expand Down Expand Up @@ -202,40 +207,55 @@ public static void delete() {
Poinpow.log.info("Error! Config file couldn't be deleted!");
}

//creates a config if possible, does other stuff if it cant
public static void create() {
try {
//try making a new config
if (configFile.createNewFile()) {
writeDefaultConfig();
Poinpow.log.info("New config created.");
} else {
Poinpow.log.info("Config already exists.");
//delete config if bad version
if (!isLatestModVersion()) {
Poinpow.log.info("Config is outdated!"); // reset config
delete();
create();
} else {
//set values from config since its good
AutoSkipBarrier.toggled.set(Boolean.parseBoolean(getValueFromConfig(AutoSkipBarrier.name)));
ChatPhraseFilter.toggled.set(Boolean.parseBoolean(getValueFromConfig(ChatPhraseFilter.name)));
BlockLobbyWelcome.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockLobbyWelcome.name)));
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)));
HubCommandBack.toggled.set(Boolean.parseBoolean(getValueFromConfig(HubCommandBack.name)));
BlockRaids.toggled.set(Boolean.parseBoolean(getValueFromConfig(HubCommandBack.name)));
}
return;
}

Poinpow.log.info("Config already exists.");

//delete config if bad version
if (!isLatestModVersion()) {
Poinpow.log.info("Config is outdated!"); // reset config
delete();
create();
return;
}

//set values from config since its good
AutoSkipBarrier.toggled.set(Boolean.parseBoolean(getValueFromConfig(AutoSkipBarrier.name)));
ChatPhraseFilter.toggled.set(Boolean.parseBoolean(getValueFromConfig(ChatPhraseFilter.name)));
BlockLobbyWelcome.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockLobbyWelcome.name)));
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)));
HubCommandBack.toggled.set(Boolean.parseBoolean(getValueFromConfig(HubCommandBack.name)));
BlockRaids.toggled.set(Boolean.parseBoolean(getValueFromConfig(HubCommandBack.name)));
BlockChestAds.toggled.set(Boolean.parseBoolean(getValueFromConfig(BlockChestAds.name)));

defaultRank = Boolean.parseBoolean(getValueFromConfig(name + "_default"));
vip = Boolean.parseBoolean(getValueFromConfig(name + "_vip"));
vipPlus = Boolean.parseBoolean(getValueFromConfig(name + "_vipPlus"));
pro = Boolean.parseBoolean(getValueFromConfig(name + "_pro"));
legend = Boolean.parseBoolean(getValueFromConfig(name + "_legend"));
patron = Boolean.parseBoolean(getValueFromConfig(name + "_patron"));

} catch (IOException e) {
Poinpow.log.error("Error! Poinpow couldn't create a config! ");
e.printStackTrace();
}
}

//this writes a new config with all the default values
private static void writeDefaultConfig() throws IOException {
FileWriter w = new FileWriter(configFile, true);
w.write("# Poinpow v" + version + " by udu3324 | Config" + System.lineSeparator());
w.write("# Poinpow v" + version + " by udu3324 | Discord: https://discord.gg/NXm9tJvyBT | Config" + System.lineSeparator());
w.write("# Hey! I suggest you use the in-game commands instead of editing the config directly." + System.lineSeparator());
w.write(System.lineSeparator());
w.write(AutoSkipBarrier.name + ": true" + System.lineSeparator());
Expand All @@ -247,9 +267,18 @@ private static void writeDefaultConfig() throws IOException {
w.write(BlockLobbyMapAds.name + ": true" + System.lineSeparator());
w.write(HubCommandBack.name + ": true" + System.lineSeparator());
w.write(BlockRaids.name + ": true" + System.lineSeparator());
w.write(BlockChestAds.name + ": true" + System.lineSeparator());

w.write(name + "_default: false" + System.lineSeparator());
w.write(name + "_vip: false" + System.lineSeparator());
w.write(name + "_vipPlus: false" + System.lineSeparator());
w.write(name + "_pro: false" + System.lineSeparator());
w.write(name + "_legend: false" + System.lineSeparator());
w.write(name + "_patron: false" + System.lineSeparator());

w.write(System.lineSeparator());
w.write("# Each line below is regex for ChatPhraseFilter to use." + System.lineSeparator());
w.write("/join");
w.write("this_is_a_example");
w.close();
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/udu3324/poinpow/Poinpow.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
public class Poinpow implements ModInitializer {
public static final Logger log = LoggerFactory.getLogger("poinpow");
public static Boolean onMinehut = false;

@Override
public void onInitialize() {
log.info("udu3324 was here!!! | poinpow v" + Config.version);
log.info("udu3324 was here!!! | poinpow v{}", Config.version);

// register the commands
ClientCommandRegistrationCallback.EVENT.register(Poinpow::registerCommands);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/udu3324/poinpow/api/GitHubVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.ArrayList;

public class GitHubVersion {
//this gets the latest version of poinpow released
private static String get() {
try {
URL obj = new URL("https://api.github.com/repos/udu3324/poinpow/tags");
Expand All @@ -24,7 +25,7 @@ private static String get() {
con.setRequestMethod("GET");

int responseCode = con.getResponseCode();
Poinpow.log.info("Request Type: " + con.getRequestMethod() + " | Response Code: " + responseCode + " | URL Requested " + obj);
Poinpow.log.info("Request Type: {} | Response Code: {} | URL Requested {}", con.getRequestMethod(), responseCode, obj);

//return only if response is not 200 (ok)
if (responseCode != 200) return null;
Expand Down Expand Up @@ -53,6 +54,7 @@ private static String get() {
return null;
}

//this checks the current and latest version of poinpow to then send an alert to update
private static boolean canSend = true;
public static void check() {
String latestVersion = get();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/udu3324/poinpow/api/Minehut.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.net.URL;

public class Minehut {
//(BuggyAl) this gets information about a server in json
public static JsonObject getServer(ClientPlayerEntity player, String serverName) {
try {
URL apiURL = new URL("https://api.minehut.com/server/" + serverName + "?byName=true");
Expand All @@ -30,7 +31,7 @@ public static JsonObject getServer(ClientPlayerEntity player, String serverName)

return obj;
} catch (Exception e) {
Poinpow.log.error("Error while looking up server: " + serverName + " - " + e);
Poinpow.log.error("Error while looking up server: {} - {}", serverName, e);
player.sendMessage(Text.literal("Response to minehut api was unsuccessful. Server name: " + serverName));
return null;
}
Expand Down
Loading

0 comments on commit 89b3a28

Please sign in to comment.