-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6e716f
commit dbedb31
Showing
46 changed files
with
577 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
userdevVer=1.5.9 | ||
userdevVer=1.7.0 | ||
shadowVer=8.1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
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 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
zipStorePath=wrapper/dists |
Binary file not shown.
Binary file not shown.
Binary file not shown.
49 changes: 0 additions & 49 deletions
49
main/src/main/java/com/github/kaspiandev/antipopup/listeners/PacketEventsListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
plugins { | ||
id "java" | ||
} | ||
|
||
dependencies { | ||
compileOnly "org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT" | ||
} |
6 changes: 3 additions & 3 deletions
6
...andev/antipopup/nms/AbstractInjector.java → .../antipopup/spigot/nms/PacketInjector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package com.github.kaspiandev.antipopup.nms; | ||
package com.github.kaspiandev.antipopup.spigot.nms; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
public interface AbstractInjector { | ||
public interface PacketInjector { | ||
|
||
void inject(Player player); | ||
|
||
void uninject(Player player); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
shared/src/main/java/com/github/kaspiandev/antipopup/config/APConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package com.github.kaspiandev.antipopup.config; | ||
|
||
import dev.dejvokep.boostedyaml.YamlDocument; | ||
import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning; | ||
import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings; | ||
import dev.dejvokep.boostedyaml.settings.general.GeneralSettings; | ||
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings; | ||
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class APConfig { | ||
|
||
private final YamlDocument document; | ||
|
||
public APConfig(File folder, ClassLoader loader) throws IOException { | ||
this.document = YamlDocument.create(new File(folder, "config.yml"), | ||
Objects.requireNonNull(loader.getResourceAsStream("config.yml")), | ||
GeneralSettings.DEFAULT, LoaderSettings.builder().setAutoUpdate(true).build(), | ||
DumperSettings.DEFAULT, | ||
UpdaterSettings.builder().setVersioning(new BasicVersioning("config-version")) | ||
.build()); | ||
} | ||
|
||
public boolean isBstats() { | ||
return document.getBoolean("bstats"); | ||
} | ||
|
||
public boolean isFilterNotSecure() { | ||
return document.getBoolean("filter-not-secure"); | ||
} | ||
|
||
public boolean isSendHeader() { | ||
return document.getBoolean("send-header"); | ||
} | ||
|
||
public boolean isAutoSetup() { | ||
return document.getBoolean("auto-setup"); | ||
} | ||
|
||
public boolean isBlockChatReports() { | ||
return document.getBoolean("block-chat-reports"); | ||
} | ||
|
||
public void setBlockChatReports(boolean value) { | ||
document.set("block-chat-reports", value); | ||
} | ||
|
||
public boolean isClickableUrls() { | ||
return document.getBoolean("clickable-urls"); | ||
} | ||
|
||
public String getPropertiesLocation() { | ||
return document.getString("properties-location"); | ||
} | ||
|
||
public boolean isFirstRun() { | ||
return document.getBoolean("first-run"); | ||
} | ||
|
||
public void setFirstRun(boolean value) { | ||
document.set("first-run", value); | ||
} | ||
|
||
public boolean isAskBstats() { | ||
return document.getBoolean("ask-bstats"); | ||
} | ||
|
||
public void setAskBstats(boolean value) { | ||
document.set("ask-bstats", value); | ||
} | ||
|
||
public boolean isSetupMode() { | ||
return document.getBoolean("setup-mode"); | ||
} | ||
|
||
public void setSetupMode(boolean value) { | ||
document.set("setup-mode", value); | ||
} | ||
|
||
public boolean isShowPopup() { | ||
return document.getBoolean("show-popup"); | ||
} | ||
|
||
public void save() { | ||
try { | ||
document.save(); | ||
} catch (IOException ex) { | ||
throw new RuntimeException("Could not save the config.", ex); | ||
} | ||
} | ||
|
||
public void reload() { | ||
try { | ||
document.reload(); | ||
} catch (IOException ex) { | ||
throw new RuntimeException("Could not reload the config.", ex); | ||
} | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
shared/src/main/java/com/github/kaspiandev/antipopup/format/ChatFormat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.github.kaspiandev.antipopup.format; | ||
|
||
public interface ChatFormat { | ||
|
||
|
||
} |
59 changes: 59 additions & 0 deletions
59
shared/src/main/java/com/github/kaspiandev/antipopup/listener/PacketEventsListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.github.kaspiandev.antipopup.listener; | ||
|
||
import com.github.kaspiandev.antipopup.platform.Platform; | ||
import com.github.retrooper.packetevents.event.PacketListenerAbstract; | ||
import com.github.retrooper.packetevents.event.PacketListenerPriority; | ||
import com.github.retrooper.packetevents.event.PacketReceiveEvent; | ||
import com.github.retrooper.packetevents.event.PacketSendEvent; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketType; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon; | ||
import com.github.retrooper.packetevents.protocol.player.ClientVersion; | ||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerJoinGame; | ||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerServerData; | ||
import com.github.retrooper.packetevents.wrapper.status.server.WrapperStatusServerResponse; | ||
import com.google.gson.JsonObject; | ||
|
||
public class PacketEventsListener extends PacketListenerAbstract { | ||
|
||
private final Platform platform; | ||
|
||
public PacketEventsListener(Platform platform) { | ||
super(PacketListenerPriority.LOW); | ||
this.platform = platform; | ||
} | ||
|
||
@Override | ||
public void onPacketSend(PacketSendEvent event) { | ||
PacketTypeCommon packetType = event.getPacketType(); | ||
ClientVersion clientVersion = event.getUser().getClientVersion(); | ||
if (packetType == PacketType.Status.Server.RESPONSE | ||
&& clientVersion.isNewerThan(ClientVersion.V_1_18_2)) { | ||
WrapperStatusServerResponse wrapper = new WrapperStatusServerResponse(event); | ||
JsonObject newObj = wrapper.getComponent(); | ||
newObj.addProperty("preventsChatReports", true); | ||
wrapper.setComponent(newObj); | ||
} else if (packetType == PacketType.Play.Server.SERVER_DATA | ||
&& clientVersion.isOlderThan(ClientVersion.V_1_20_5) | ||
&& !platform.getApConfig().isShowPopup()) { | ||
WrapperPlayServerServerData wrapper = new WrapperPlayServerServerData(event); | ||
wrapper.setEnforceSecureChat(true); | ||
} else if (packetType == PacketType.Play.Server.JOIN_GAME | ||
&& clientVersion.isNewerThan(ClientVersion.V_1_20_3) | ||
&& !platform.getApConfig().isShowPopup()) { | ||
WrapperPlayServerJoinGame wrapper = new WrapperPlayServerJoinGame(event); | ||
wrapper.setEnforcesSecureChat(true); | ||
} else if (packetType == PacketType.Play.Server.PLAYER_CHAT_HEADER | ||
&& !platform.getApConfig().isSendHeader()) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
PacketTypeCommon packetType = event.getPacketType(); | ||
if (packetType == PacketType.Play.Client.CHAT_SESSION_UPDATE) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
shared/src/main/java/com/github/kaspiandev/antipopup/platform/Platform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.github.kaspiandev.antipopup.platform; | ||
|
||
import com.github.kaspiandev.antipopup.config.APConfig; | ||
|
||
import java.util.UUID; | ||
|
||
public abstract class Platform { | ||
|
||
private final APConfig apConfig; | ||
|
||
protected Platform(APConfig apConfig) { | ||
this.apConfig = apConfig; | ||
} | ||
|
||
public APConfig getApConfig() { | ||
return apConfig; | ||
} | ||
|
||
public abstract String getPlayerName(UUID playerUUID); | ||
|
||
} |
Oops, something went wrong.