Skip to content

Commit b8b873e

Browse files
authored
Merge pull request #38 from LewMC/2.0.0
2.0.0
2 parents e515091 + a0646ce commit b8b873e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+9873
-1431
lines changed

dependency-reduced-pom.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>net.lewmc</groupId>
55
<artifactId>kryptonite</artifactId>
66
<name>Kryptonite</name>
7-
<version>1.4.0</version>
7+
<version>2.0.0</version>
88
<build>
99
<resources>
1010
<resource>
@@ -36,6 +36,10 @@
3636
<pattern>com.tchristofferson</pattern>
3737
<shadedPattern>net.lewmc.kryptonite</shadedPattern>
3838
</relocation>
39+
<relocation>
40+
<pattern>com.tcoded.folialib</pattern>
41+
<shadedPattern>net.lewmc.kryptonite.lib.folialib</shadedPattern>
42+
</relocation>
3943
</relocations>
4044
</configuration>
4145
</execution>
@@ -56,6 +60,10 @@
5660
<id>minebench-repo</id>
5761
<url>https://repo.minebench.de/</url>
5862
</repository>
63+
<repository>
64+
<id>jitpack</id>
65+
<url>https://jitpack.io</url>
66+
</repository>
5967
</repositories>
6068
<dependencies>
6169
<dependency>

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>net.lewmc</groupId>
88
<artifactId>kryptonite</artifactId>
9-
<version>1.4.0</version>
9+
<version>2.0.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Kryptonite</name>
@@ -43,6 +43,10 @@
4343
<pattern>com.tchristofferson</pattern>
4444
<shadedPattern>net.lewmc.kryptonite</shadedPattern>
4545
</relocation>
46+
<relocation>
47+
<pattern>com.tcoded.folialib</pattern>
48+
<shadedPattern>net.lewmc.kryptonite.lib.folialib</shadedPattern>
49+
</relocation>
4650
</relocations>
4751
</configuration>
4852
</execution>
@@ -70,6 +74,10 @@
7074
<id>minebench-repo</id>
7175
<url>https://repo.minebench.de/</url>
7276
</repository>
77+
<repository>
78+
<id>jitpack</id>
79+
<url>https://jitpack.io</url>
80+
</repository>
7381
</repositories>
7482

7583
<dependencies>
@@ -96,5 +104,11 @@
96104
<version>1.6.4-SNAPSHOT</version>
97105
<scope>compile</scope>
98106
</dependency>
107+
<dependency>
108+
<groupId>com.github.technicallycoded</groupId>
109+
<artifactId>FoliaLib</artifactId>
110+
<version>main-SNAPSHOT</version>
111+
<scope>compile</scope>
112+
</dependency>
99113
</dependencies>
100114
</project>

src/main/java/net/lewmc/kryptonite/Kryptonite.java

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package net.lewmc.kryptonite;
22

3+
import com.tcoded.folialib.FoliaLib;
34
import net.lewmc.kryptonite.commands.ExploitDBCommand;
45
import net.lewmc.kryptonite.commands.KryptoniteCommand;
56
import net.lewmc.kryptonite.commands.OptimiseCommand;
7+
import net.lewmc.kryptonite.event.JoinEvent;
68
import net.lewmc.kryptonite.utils.CompatablityUtil;
79
import net.lewmc.kryptonite.utils.LogUtil;
810
import net.lewmc.kryptonite.utils.UpdateUtil;
11+
import org.bukkit.Bukkit;
912
import org.bukkit.plugin.java.JavaPlugin;
1013

1114
import java.io.File;
@@ -26,6 +29,8 @@ public enum ConfigurationOptions {
2629
PUFFERFISH
2730
}
2831
public List<ConfigurationOptions> SupportedConfigurations = new ArrayList<>();
32+
public boolean restartRequired = false;
33+
public boolean updatePending = false;
2934

3035
@Override
3136
public void onEnable() {
@@ -39,54 +44,65 @@ public void onEnable() {
3944
this.log.info("Beginning startup...");
4045
this.log.info("");
4146

42-
int pluginId = 21962; // <-- Replace with the id of your plugin!
47+
int pluginId = 21962;
4348
new Metrics(this, pluginId);
4449

4550
this.initFilesystem();
4651
this.loadCommands();
4752
this.checkSoftware();
4853
this.detectBadPlugins();
54+
this.loadEventHandlers();
4955

5056
this.log.info("");
5157
this.log.info("Startup completed.");
58+
59+
if (Objects.equals(System.getProperty("KRYPTONITE_LOADED", ""), "TRUE")) {
60+
this.log.severe("");
61+
this.log.severe("WARNING: RELOAD DETECTED!");
62+
this.log.severe("");
63+
this.log.severe("This may cause issues with Kryptonite, other plugins, and your server overall.");
64+
this.log.severe("These issues include breaking permissions and other crashing exceptions.");
65+
this.log.severe("If you are reloading datapacks use /minecraft:reload instead.");
66+
this.log.severe("");
67+
this.log.severe("WE HIGHLY RECOMMEND RESTARTING YOUR SERVER.");
68+
this.log.severe("");
69+
this.log.severe("We will not provide support for any issues when plugin reloaders are used.");
70+
this.log.severe("");
71+
this.log.severe("More info: https://madelinemiller.dev/blog/problem-with-reload");
72+
this.log.severe("");
73+
Bukkit.getPluginManager().disablePlugin(this);
74+
}
75+
76+
System.setProperty("KRYPTONITE_LOADED", "TRUE");
5277
}
5378

5479
private void initFilesystem() {
5580
UpdateUtil update = new UpdateUtil(this);
5681

5782
this.saveDefaultConfig();
5883

59-
File YHTProfile = new File(getDataFolder() + File.separator + "profiles/YouHaveTrouble.kos");
60-
if (!YHTProfile.exists()) {
61-
saveResource("profiles/YouHaveTrouble.kos", false);
84+
if (!(new File(this.getDataFolder(), "kryptonite.log").exists())) {
85+
this.saveResource("kryptonite.log", false);
6286
}
6387

64-
File FFProfile = new File(getDataFolder() + File.separator + "profiles/FarmFriendly.kos");
65-
if (!FFProfile.exists()) {
66-
saveResource("profiles/FarmFriendly.kos", false);
88+
if (!(new File(this.getDataFolder(), "profiles/YouHaveTrouble.kos").exists())) {
89+
this.saveResource("profiles/YouHaveTrouble.kos", false);
6790
}
6891

69-
File profilesFolder = new File(getDataFolder() + File.separator + "profiles");
70-
if (!profilesFolder.exists()) {
71-
if (!profilesFolder.mkdirs()) {
72-
this.log.info("");
73-
log.severe("Unable to make data folder.");
74-
log.severe("The plugin is being disabled, most of the plugin's features will not work without the profiles folder.");
75-
log.warn("Please create a folder called 'profiles' in the 'Kryptonite' folder.");
76-
log.warn("Once this is complete, restart the server and Essence will re-enable.");
77-
this.log.info("");
78-
getServer().getPluginManager().disablePlugin(this);
79-
}
92+
if (!(new File(this.getDataFolder(), "profiles/FarmFriendly.kos").exists())) {
93+
this.saveResource("profiles/FarmFriendly.kos", false);
8094
}
8195

8296
update.VersionCheck();
8397
update.UpdateConfig();
84-
update.UpdatePatches();
98+
update.UpdateProfiles();
99+
update.DeleteOldFiles();
85100
}
86101

87102
@Override
88103
public void onDisable() {
89-
// Plugin shutdown logic
104+
FoliaLib foliaLib = new FoliaLib(this);
105+
foliaLib.getScheduler().cancelAllTasks();
90106
}
91107

92108
/**
@@ -158,4 +174,11 @@ private void detectBadPlugins() {
158174
this.log.severe("");
159175
}
160176
}
177+
178+
/**
179+
* Loads and registers all the plugin's event handlers.
180+
*/
181+
private void loadEventHandlers() {
182+
Bukkit.getServer().getPluginManager().registerEvents(new JoinEvent(this), this);
183+
}
161184
}

src/main/java/net/lewmc/kryptonite/commands/ExploitDBCommand.java

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import net.lewmc.kryptonite.Kryptonite;
44
import net.lewmc.kryptonite.edb.Check;
55
import net.lewmc.kryptonite.edb.Patch;
6+
import net.lewmc.kryptonite.edb.gui.EDB_MainGui;
67
import net.lewmc.kryptonite.utils.MessageUtil;
78
import net.lewmc.kryptonite.utils.PermissionUtil;
89
import net.lewmc.kryptonite.utils.SoftwareUtil;
910
import org.bukkit.command.Command;
1011
import org.bukkit.command.CommandExecutor;
1112
import org.bukkit.command.CommandSender;
13+
import org.bukkit.entity.Player;
1214

1315
import java.util.Objects;
1416

@@ -44,12 +46,12 @@ public boolean onCommand(
4446

4547
if (perm.isOperator(commandSender)) {
4648
if (args.length >= 1) {
47-
Check check = new Check(plugin);
49+
Check check = new Check(plugin, commandSender);
4850
if (Objects.equals(args[0].toLowerCase(), "check")) {
4951
this.checkAll(check);
5052
} else if (Objects.equals(args[0].toLowerCase(), "patch")) {
5153
if (args.length >= 2) {
52-
Patch patch = new Patch(this.plugin);
54+
Patch patch = new Patch(this.plugin, commandSender);
5355
switch (args[1].toLowerCase()) {
5456
case "all":
5557
message.Info("Patching all...");
@@ -58,8 +60,6 @@ public boolean onCommand(
5860
} else {
5961
message.Error("Unable to patch all exploits. Run /edb check to verify.");
6062
}
61-
message.Warning("EDB-10 needs to be patched manually.");
62-
message.Warning("To patch use '/edb patch edb-10'");
6363
break;
6464
case "edb-1":
6565
if (patch.edb1()) {
@@ -125,24 +125,24 @@ public boolean onCommand(
125125
}
126126
break;
127127
case "edb-10":
128-
message.Warning("EDB-10 has two possible fixes. Please select one.'");
129-
message.Info("Fix A: Disable treasure maps.");
130-
message.Info("Fix B: Check maps are valid.");
131-
message.Error("Only use Fix B if you have pregenerated your world and applied a vanilla world border!");
132-
message.Info("Usage: '/edb patch EDB-10-A' OR '/edb patch EDB-10-B'");
128+
if (patch.edb10()) {
129+
message.Success("Exploit EDB-10 patched!");
130+
} else {
131+
message.Error("Unable to patch exploit EDB-10.");
132+
}
133133
break;
134-
case "edb-10-a":
135-
if (patch.edb10a()) {
136-
message.Success("Exploit EDB-10 patched using Fix A!");
134+
case "edb-11":
135+
if (patch.edb10()) {
136+
message.Success("Exploit EDB-11 patched!");
137137
} else {
138-
message.Error("Unable to patch exploit EDB-10 using Fix A.");
138+
message.Error("Unable to patch exploit EDB-11.");
139139
}
140140
break;
141-
case "edb-10-b":
142-
if (patch.edb10b()) {
143-
message.Success("Exploit EDB-10 patched using Fix B!");
141+
case "edb-12":
142+
if (patch.edb10()) {
143+
message.Success("Exploit EDB-12 patched!");
144144
} else {
145-
message.Error("Unable to patch exploit EDB-10 using Fix B.");
145+
message.Error("Unable to patch exploit EDB-12.");
146146
}
147147
break;
148148
default:
@@ -157,11 +157,17 @@ public boolean onCommand(
157157
} else {
158158
message.Error("Unknown command. Use '/edb' for help.");
159159
}
160+
160161
} else {
161-
message.Info("ExploitDB");
162-
message.Info("");
163-
message.Info("/edb check - Check your server.");
164-
message.Info("/edb patch - Patch your server.");
162+
if (commandSender instanceof Player) {
163+
EDB_MainGui mg = new EDB_MainGui(this.plugin, commandSender);
164+
mg.show();
165+
} else {
166+
message.Info("ExploitDB");
167+
message.Info("");
168+
message.Info("/edb check - Check your server.");
169+
message.Info("/edb patch - Patch your server.");
170+
}
165171
}
166172
} else {
167173
message.Error("You do not have the required permissions to run this command.");
@@ -180,7 +186,9 @@ private void checkAll(Check check) {
180186
try { this.complete(check.edb7(), "EDB-7"); } catch (Exception e) { this.message.Error("Unable to check EDB7."); }
181187
try { this.complete(check.edb8(), "EDB-8"); } catch (Exception e) { this.message.Error("Unable to check EDB8."); }
182188
try { this.complete(check.edb9(), "EDB-9"); } catch (Exception e) { this.message.Error("Unable to check EDB9."); }
183-
try { this.complete((check.edb10a() || check.edb10b()), "EDB-10"); } catch (Exception e) { this.message.Error("Unable to check EDB10."); }
189+
try { this.complete(check.edb10(), "EDB-10"); } catch (Exception e) { this.message.Error("Unable to check EDB10."); }
190+
try { this.complete(check.edb11(), "EDB-11"); } catch (Exception e) { this.message.Error("Unable to check EDB11."); }
191+
try { this.complete(check.edb12(), "EDB-12"); } catch (Exception e) { this.message.Error("Unable to check EDB12."); }
184192

185193
SoftwareUtil software = new SoftwareUtil(plugin);
186194
if (!software.supportsPaperWorld()) {

src/main/java/net/lewmc/kryptonite/commands/KryptoniteCommand.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
4040
}
4141
} else {
4242
message.Info("Kryptonite version "+this.plugin.getDescription().getVersion()+ " by LewMC.");
43-
message.Info("You must be an operator to run Kryptonite commands.");
43+
message.Info("You must be an operator to run Kryptonite");
44+
message.Info("commands.");
45+
message.Info("");
46+
message.Info("Feedback: https://github.com/lewmc/Kryptonite");
4447
message.Info("");
4548
message.Info("/kr - Main command.");
4649
message.Info("/kos - Kryptonite Optimisation System.");

src/main/java/net/lewmc/kryptonite/commands/OptimiseCommand.java

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package net.lewmc.kryptonite.commands;
22

33
import net.lewmc.kryptonite.Kryptonite;
4-
import net.lewmc.kryptonite.kos.KOS;
5-
import net.lewmc.kryptonite.kos.gui.KosMainGui;
4+
import net.lewmc.kryptonite.kos.AutoKOS;
5+
import net.lewmc.kryptonite.kos.gui.KOS_MainGui;
66
import net.lewmc.kryptonite.utils.MessageUtil;
77
import net.lewmc.kryptonite.utils.PermissionUtil;
88
import org.bukkit.command.Command;
@@ -38,47 +38,36 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
3838

3939
if (perm.isOperator(commandSender)) {
4040
if (commandSender instanceof Player) {
41-
KosMainGui gui = new KosMainGui(this.plugin, commandSender);
41+
KOS_MainGui gui = new KOS_MainGui(this.plugin, commandSender);
4242
gui.show();
4343
} else {
44-
if (args.length == 1) {
45-
if (Objects.equals(args[0].toLowerCase(), "yes")) {
46-
message.Info("Kryptonite will now run it's optimisation system.");
47-
message.Info("You should backup your server before running Kryptonite.");
48-
message.Info("You'll need to restart the server after completion for changes to be made.");
49-
message.Info("");
50-
message.Info("Using profile '" + this.plugin.getConfig().getString("kos.default-profile") + "'");
51-
52-
KOS kos = new KOS(commandSender, this.plugin, this.plugin.getConfig().getString("kos.default-profile"));
53-
kos.runDefault(true);
54-
} else if (Objects.equals(args[0].toLowerCase(), "no") && perm.isOperator(commandSender)) {
55-
message.Info("Kryptonite will now run it's optimisation system.");
56-
message.Info("You should backup your server before running Kryptonite.");
57-
message.Info("You'll need to restart the server after completion for changes to be made.");
58-
message.Info("");
59-
message.Info("Using profile '" + this.plugin.getConfig().getString("kos.default-profile") + "'");
60-
61-
KOS kos = new KOS(commandSender, this.plugin, this.plugin.getConfig().getString("kos.default-profile"));
62-
kos.runDefault(false);
44+
message.Success("KOS is better in-game.");
45+
message.Success("You can access more features through our in-game GUI.");
46+
message.Info("Starting KOS CLI...");
47+
message.Info("");
48+
if (args.length == 0) {
49+
message.Warning("Please specify a profile file to use.");
50+
message.Warning("For example: /kos YouHaveTrouble.kos");
51+
} else if (args.length == 1) {
52+
message.Warning("Please specify if your server world is pre-generated.");
53+
message.Warning("For example: /kos "+args[0]+" true");
54+
message.Warning("For example: /kos "+args[0]+" false");
55+
} else {
56+
AutoKOS ak = new AutoKOS(this.plugin, commandSender);
57+
if (Objects.equals(args[1], "true") || Objects.equals(args[1], "yes") || Objects.equals(args[1], "y")) {
58+
ak.run(true, args[0]);
59+
} else if (Objects.equals(args[1], "false") || Objects.equals(args[1], "no") || Objects.equals(args[1], "n")) {
60+
ak.run(false, args[0]);
6361
} else {
64-
message.Error("Unknown command. Use /kos for help.");
62+
message.Warning("Please specify if your server world is pre-generated.");
63+
message.Warning("For example: /kos "+args[0]+" true");
64+
message.Warning("For example: /kos "+args[0]+" false");
6565
}
66-
} else {
67-
message.Info("--- KRYPTONITE OPTIMISATION SYSTEM ---");
68-
message.Info("KOS will use the kos.default-profile value set in Kryptonite.yml");
69-
message.Info("Please ensure this is correct before continuing.");
70-
message.Info("Current profile: " + this.plugin.getConfig().getString("kos.default-profile"));
71-
message.Info("");
72-
message.Info("Have you pregenerated your world and set a vanilla world border?");
73-
message.Info("This will affect which optimisations can be applied.");
74-
message.Info("");
75-
message.Info("To continue enter '/kos yes' if you have pregenerated");
76-
message.Info("or '/kos no' if you have not.");
7766
}
7867
}
7968
} else {
8069
message.Error("You do not have the required permissions to run this command.");
81-
message.Error("Please visit https://wiki.lewmc.net/index.php/Kryptonite_Commands for more information.");
70+
message.Error("Please visit https://wiki.lewmc.net/kr-commands.html for more information.");
8271
}
8372
return true;
8473
}

0 commit comments

Comments
 (0)