Skip to content

Commit d93b722

Browse files
committed
Testing needed
1 parent 97958e6 commit d93b722

File tree

19 files changed

+137
-51
lines changed

19 files changed

+137
-51
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
<dependency>
8282
<groupId>com.comphenix.protocol</groupId>
8383
<artifactId>ProtocolLib</artifactId>
84-
<version>4.6.0</version>
84+
<version>4.7.0</version>
8585
<scope>provided</scope>
8686
</dependency>
8787
</dependencies>

src/main/java/me/krymz0n/simpleexploitfixer/Main.java

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package me.krymz0n.simpleexploitfixer;
22

3+
import com.comphenix.protocol.ProtocolManager;
34
import me.krymz0n.simpleexploitfixer.commands.Reload;
45
import me.krymz0n.simpleexploitfixer.listener.*;
5-
import me.krymz0n.simpleexploitfixer.util.ItemUtil;
6-
import org.bstats.bukkit.Metrics;
6+
import me.krymz0n.simpleexploitfixer.listener.exploit.BowBomb;
7+
import me.krymz0n.simpleexploitfixer.listener.exploit.TabComplete;
8+
import me.krymz0n.simpleexploitfixer.listener.lag.*;
9+
import me.krymz0n.simpleexploitfixer.listener.misc.Chat;
10+
import me.krymz0n.simpleexploitfixer.listener.misc.CreatureSpawn;
11+
import me.krymz0n.simpleexploitfixer.listener.misc.InteractEvent;
12+
import me.krymz0n.simpleexploitfixer.util.Utils;
713
import org.bukkit.Bukkit;
814
import org.bukkit.Chunk;
915
import org.bukkit.Material;
@@ -19,10 +25,14 @@
1925
import java.util.Objects;
2026

2127
public final class Main extends JavaPlugin implements Listener {
28+
private static Main instance;
29+
private ProtocolManager protocolManager;
2230

2331
@Override
2432
public void onEnable() {
2533
saveDefaultConfig();
34+
35+
// Plugin registries
2636
PluginManager pm = getServer().getPluginManager();
2737
pm.registerEvents(this, this);
2838
pm.registerEvents(new Bees(this), this);
@@ -34,11 +44,14 @@ public void onEnable() {
3444
pm.registerEvents(new RedstoneLag(this), this);
3545
pm.registerEvents(new Rail(this), this);
3646
pm.registerEvents(new Chat(this), this);
37-
pm.registerEvents(new TabComplete(this), this);
3847
pm.registerEvents(new BowBomb(this), this);
48+
pm.registerEvents(new TabComplete(this), this);
3949

4050
Objects.requireNonNull(getCommand("sef")).setExecutor(new Reload(this));
4151

52+
if (instance == null) instance = this;
53+
54+
// Protocol Lib shit
4255
if (getConfig().getBoolean("DisableAllProtocolLib")) {
4356
getLogger().info("You specified to disable all ProtocolLib patches.");
4457
} else {
@@ -50,7 +63,7 @@ public void onEnable() {
5063
}
5164
}
5265

53-
if (getConfig().getBoolean("StrictBeeCheck")) {
66+
if (getConfig().getBoolean("StrictBeeCheck")) { // This checks for bees more strictly
5467
Bukkit.getScheduler().runTaskTimer(this, () -> {
5568
for (World w : Bukkit.getWorlds()) {
5669
for (Chunk c : w.getLoadedChunks()) {
@@ -69,13 +82,13 @@ public void onEnable() {
6982

7083
}
7184

72-
if (getConfig().getBoolean("PreventTooManyEntitiesInChunk")) {
85+
if (getConfig().getBoolean("PreventTooManyEntitiesInChunk")) { // Preventing too much of entities in chunks
7386
Bukkit.getScheduler().runTaskTimer(this, () -> {
7487
for (World w : Bukkit.getWorlds()) {
7588
for (Chunk c : w.getLoadedChunks()) {
7689
int count = 0;
7790
for (Entity entity : c.getEntities()) {
78-
if (ItemUtil.isEntity(entity) && !(entity instanceof LivingEntity)) {
91+
if (Utils.isEntity(entity) && !(entity instanceof LivingEntity)) {
7992
if (count > getConfig().getInt("MaxEntitiesInChunk")) {
8093
entity.remove();
8194
if (getConfig().getBoolean("LogEntityRemovals")) {
@@ -90,7 +103,7 @@ public void onEnable() {
90103
}, 0L, getConfig().getInt("EntityCheckTimeTicks"));
91104
}
92105

93-
if (getConfig().getBoolean("StrictArmorStandCheck")) {
106+
if (getConfig().getBoolean("StrictArmorStandCheck")) { // Strict check for Armor stands
94107
Bukkit.getScheduler().runTaskTimer(this, () -> {
95108
for (World w : Bukkit.getWorlds()) {
96109
for (Chunk c : w.getLoadedChunks()) {
@@ -109,7 +122,7 @@ public void onEnable() {
109122

110123
}
111124

112-
if (getConfig().getBoolean("PreventChunkBan")) {
125+
if (getConfig().getBoolean("PreventChunkBan")) { // I think a strict check for item frames, but I made it weird? probs gonna fix later
113126
Bukkit.getScheduler().runTaskTimer(this, () -> {
114127
for (World w : Bukkit.getWorlds()) {
115128
for (Chunk c : w.getLoadedChunks()) {
@@ -128,23 +141,31 @@ public void onEnable() {
128141

129142
}
130143
}
131-
public Integer count(Chunk c, Material m ) {
132-
int num = 0;
133-
for (int x = 0; x < 16; x++) {
134-
for (int z = 0; z < 16; z++) {
135-
for (int y = 0; y < 256; y++) {
136-
if (c.getBlock(x, y, z).getType() == m) {
137-
num++;
138-
}
139-
}
144+
public Integer count(Chunk c, Material m ) { // Super cool count feature to count the amount of blocks per chunk.
145+
int num = 0;
146+
for (int x = 0; x < 16; x++) {
147+
for (int z = 0; z < 16; z++) {
148+
for (int y = 0; y < 256; y++) {
149+
if (c.getBlock(x, y, z).getType() == m) {
150+
num++;
140151
}
141152
}
142-
return num;
143153
}
154+
}
155+
return num;
156+
}
144157

145158

146159
@Override
147160
public void onDisable() {
148161
// Plugin shutdown logic
149162
}
163+
164+
public static Main getInstance() {
165+
return instance;
166+
}
167+
168+
public ProtocolManager getProtocolManager() {
169+
return protocolManager;
170+
}
150171
}

src/main/java/me/krymz0n/simpleexploitfixer/commands/Reload.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
2626
sender.sendMessage(ChatColor.RED + "You do not have permission to execute this command!");
2727
}
2828
}
29+
2930
if (args[0].equalsIgnoreCase("ver")) {
3031
sender.sendMessage(ChatColor.GREEN + "This server is currently running SimpleExploitFixer " + ChatColor.GRAY + "v" + ChatColor.GREEN + plugin.getDescription().getVersion());
3132
}
33+
34+
if (args[0].equalsIgnoreCase("test")) {
35+
sender.sendMessage("WOrks");
36+
}
3237
return false;
3338
}
3439
}

src/main/java/me/krymz0n/simpleexploitfixer/listener/ProtocolLib.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
import com.comphenix.protocol.ProtocolManager;
66
import com.comphenix.protocol.events.ListenerPriority;
77
import com.comphenix.protocol.events.PacketAdapter;
8+
import com.comphenix.protocol.events.PacketContainer;
89
import com.comphenix.protocol.events.PacketEvent;
910
import com.comphenix.protocol.wrappers.BlockPosition;
1011
import com.comphenix.protocol.wrappers.EnumWrappers;
1112
import me.krymz0n.simpleexploitfixer.Main;
13+
import me.krymz0n.simpleexploitfixer.util.Utils;
14+
import org.bukkit.entity.Player;
1215

1316
public class ProtocolLib {
1417
public static void protocolLibWrapper(Main plugin) {
@@ -43,6 +46,35 @@ public void onPacketReceiving(PacketEvent event) {
4346
}
4447
}
4548
});
49+
50+
protocolManager.addPacketListener(
51+
new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.TAB_COMPLETE) {
52+
53+
@Override
54+
public void onPacketReceiving(PacketEvent event) {
55+
if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
56+
System.out.println("0");
57+
PacketContainer packet = event.getPacket();
58+
String command = packet.getStrings().read(0); // reads the amount of strings that are sent on the packet.
59+
if (command.equals("/")) {
60+
event.setCancelled(true);
61+
System.out.println("1");
62+
if (plugin.getConfig().getBoolean("SendFakePlugins")) {
63+
Player player = event.getPlayer();
64+
PacketContainer response = new PacketContainer(PacketType.Play.Server.TAB_COMPLETE);
65+
response.getStringArrays().write(0, Utils.formatPlugins());
66+
try {
67+
Main.getInstance().getProtocolManager().sendServerPacket(player, response);
68+
} catch (Exception e) {
69+
e.printStackTrace();
70+
}
71+
}
72+
73+
}
74+
}
75+
}
76+
}
77+
);
4678
}
4779
}
4880
}

src/main/java/me/krymz0n/simpleexploitfixer/listener/TabComplete.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/main/java/me/krymz0n/simpleexploitfixer/listener/BowBomb.java renamed to src/main/java/me/krymz0n/simpleexploitfixer/listener/exploit/BowBomb.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.krymz0n.simpleexploitfixer.listener;
1+
package me.krymz0n.simpleexploitfixer.listener.exploit;
22

33
import me.krymz0n.simpleexploitfixer.Main;
44
import org.bukkit.entity.Arrow;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package me.krymz0n.simpleexploitfixer.listener.exploit;
2+
3+
import me.krymz0n.simpleexploitfixer.Main;
4+
import me.krymz0n.simpleexploitfixer.util.Utils;
5+
import org.bukkit.event.EventHandler;
6+
import org.bukkit.event.Listener;
7+
import org.bukkit.event.player.PlayerCommandSendEvent;
8+
import org.bukkit.event.server.TabCompleteEvent;
9+
10+
public class TabComplete implements Listener {
11+
private final Main plugin;
12+
13+
public TabComplete(Main plugin) {
14+
this.plugin = plugin;
15+
}
16+
17+
@EventHandler // should work as a patch, however I need more testing before I make a new release.
18+
public void onTabComplete(TabCompleteEvent evt) {
19+
System.out.println("test");
20+
if (evt.getBuffer().equalsIgnoreCase("/")) {
21+
evt.setCompletions(plugin.getConfig().getStringList("FakePluginList"));
22+
}
23+
}
24+
}

src/main/java/me/krymz0n/simpleexploitfixer/listener/ArmorStand.java renamed to src/main/java/me/krymz0n/simpleexploitfixer/listener/lag/ArmorStand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.krymz0n.simpleexploitfixer.listener;
1+
package me.krymz0n.simpleexploitfixer.listener.lag;
22

33
import me.krymz0n.simpleexploitfixer.Main;
44
import org.bukkit.Chunk;

src/main/java/me/krymz0n/simpleexploitfixer/listener/Bees.java renamed to src/main/java/me/krymz0n/simpleexploitfixer/listener/lag/Bees.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.krymz0n.simpleexploitfixer.listener;
1+
package me.krymz0n.simpleexploitfixer.listener.lag;
22

33
import me.krymz0n.simpleexploitfixer.Main;
44
import org.bukkit.Chunk;

src/main/java/me/krymz0n/simpleexploitfixer/listener/ChunkBan.java renamed to src/main/java/me/krymz0n/simpleexploitfixer/listener/lag/ChunkBan.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package me.krymz0n.simpleexploitfixer.listener;
1+
package me.krymz0n.simpleexploitfixer.listener.lag;
22

33
import me.krymz0n.simpleexploitfixer.Main;
44
import net.kyori.adventure.audience.Audience;

0 commit comments

Comments
 (0)