Skip to content

Commit

Permalink
🔼 Add secure profile remover
Browse files Browse the repository at this point in the history
  • Loading branch information
KaspianDev committed Aug 6, 2022
1 parent b2db0a2 commit 200d388
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'screw.microsoft'
version = '2.7'
version = '3'

repositories {
mavenCentral()
Expand Down
75 changes: 44 additions & 31 deletions src/main/java/screw/microsoft/antipopup/AntiPopup.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Objects;
import java.util.Properties;

public final class AntiPopup extends JavaPlugin {

Expand Down Expand Up @@ -45,38 +49,47 @@ public void onEnable() {
PacketEvents.getAPI().getEventManager().registerListener(new PacketEventsListener());
PacketEvents.getAPI().init();
getLogger().info("Initiated PacketEvents");
if(PacketEvents.getAPI().getServerManager().getVersion().is(VersionComparison.EQUALS, ServerVersion.V_1_19)
&& !config.getBoolean("no-warning")) {
getLogger().warning("!!! WARNING !!!");
getLogger().warning("There is a known problem with using");
getLogger().warning("AntiPopup with ViaVersion on 1.19.");
getLogger().warning("Players will still get the popup, either");
getLogger().warning("wait for a fix or download a patched ViaVersion.");
getLogger().warning("You can also update your server to 1.19.1+.");
getLogger().warning("");
getLogger().warning("Patch: https://github.com/KaspianDev/ViaVersion-patched/actions");
getLogger().warning("Note: It is not ideal, I recommend just updating your server.");
getLogger().warning("Remove warning by setting no-warning to true in config.");
}

// To be added soon
/*
if(config.getBoolean("first-run").equals(true)) {
try {
FileInputStream in=new FileInputStream("server.properties");
Properties props = new Properties();
props.load(in);
props.setProperty("enforce-secure-profile", String.valueOf(false));
in.close();
FileOutputStream out=new FileOutputStream("server.properties");
props.store(out, "");
out.close();
config.set("first-run", false);
} catch (IOException io) {
io.printStackTrace();
Bukkit.getScheduler().runTask(this, () -> {
if (PacketEvents.getAPI().getServerManager().getVersion().is(VersionComparison.EQUALS, ServerVersion.V_1_19)
&& !config.getBoolean("no-warning")) {
getLogger().warning("-------------------------[ WARNING ]-------------------------");
getLogger().warning("There is a known problem with using");
getLogger().warning("AntiPopup with ViaVersion on 1.19.");
getLogger().warning("Players will still get the popup, either");
getLogger().warning("wait for a fix or download a patched ViaVersion.");
getLogger().warning("You can also update your server to 1.19.1+.");
getLogger().warning("");
getLogger().warning("Link: https://github.com/KaspianDev/ViaVersion-patched/actions");
getLogger().warning("Note: It is not ideal, I recommend just updating your server.");
getLogger().warning("Remove warning by setting no-warning to true in config.");
getLogger().warning("-------------------------------------------------------------");
}
}
*/
if (config.getBoolean("first-run")) {
try {
FileInputStream in = new FileInputStream("server.properties");
Properties props = new Properties();
props.load(in);
if (Boolean.parseBoolean(props.getProperty("enforce-secure-profile"))) {
getLogger().warning("------------------[ READ ME PLEASE ]------------------");
getLogger().warning("This is your first startup with AntiPopup.");
getLogger().warning("We decided to disable enforce-secure-profile");
getLogger().warning("for better experience. If you wish to re-enable");
getLogger().warning("it, you can do it in server.properties (if you");
getLogger().warning("know what you are doing). Thanks for using AntiPopup!");
getLogger().warning("------------------------------------------------------");
props.setProperty("enforce-secure-profile", String.valueOf(false));
in.close();
FileOutputStream out = new FileOutputStream("server.properties");
props.store(out, "");
out.close();
}
config.set("first-run", false);
config.save();
} catch (IOException io) {
io.printStackTrace();
}
}
});
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void onPacketSend(PacketSendEvent event) {
serverData.setEnforceSecureChat(true);
}
if (event.getPacketType() == PacketType.Play.Server.CHAT_MESSAGE
&& AntiPopup.config.getBoolean("strip-signature", true)) {
&& AntiPopup.config.getBoolean("strip-signature", true)) {
WrapperPlayServerChatMessage chatMessage = new WrapperPlayServerChatMessage(event);
ChatMessage message = chatMessage.getMessage();

Expand Down

0 comments on commit 200d388

Please sign in to comment.