Skip to content

Commit

Permalink
[API] Upgrade 1.20.4 + Player wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Moderrek committed Feb 1, 2024
1 parent c31baac commit cc409af
Show file tree
Hide file tree
Showing 13 changed files with 3,561 additions and 2,938 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repositories {
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
implementation 'io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT'
implementation 'io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT'
implementation 'com.google.code.gson:gson:2.10.1'
}

Expand Down
18 changes: 8 additions & 10 deletions src/main/java/com/impact/lib/ImpactLibPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;

import java.sql.SQLException;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -117,14 +116,14 @@ public void onEnable() {
Impact.setServer(getServer(), logger);
logger.info("Started loading");
// Local database
database = new ImpactDatabaseManager(this);
try {
database.connect();
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
this.setEnabled(false);
return;
}
// database = new ImpactDatabaseManager(this);
// try {
// database.connect();
// } catch (ClassNotFoundException | SQLException e) {
// e.printStackTrace();
// this.setEnabled(false);
// return;
// }
// Custom Item Module
itemModule = new CustomItemModule();
itemModule.enable(this);
Expand All @@ -139,7 +138,6 @@ public void onEnable() {
customBlockModule.enable(this);
// Listeners
Impact.addListener(new PluginDisableListener(this), this);

Impact.getPlayers().forEach(impactPlayer -> {
ImpactRegistries.CUSTOM_ITEM.getAll().forEach(customItem -> {
impactPlayer.giveItem(customItem.getItemStack(1));
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/com/impact/lib/api/command/MCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
Expand All @@ -17,6 +18,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
Expand All @@ -37,7 +40,15 @@ public final boolean execute(@NotNull CommandSender sender, @NotNull String comm
this.label = commandLabel;
this.args = args;
this.sender = sender;
boolean response = onCommand(sender, this, commandLabel, args);
boolean response = true;
try {
response = onCommand(sender, this, commandLabel, args);
} catch (Exception exception) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
exception.printStackTrace(pw);
sender.sendMessage(Component.text("Caught exception: " + exception.getMessage()).color(NamedTextColor.RED).hoverEvent(HoverEvent.showText(Component.text(pw.toString()).color(NamedTextColor.RED))));
}
this.label = null;
this.args = null;
this.sender = null;
Expand Down
Loading

0 comments on commit cc409af

Please sign in to comment.