Skip to content

Commit 78eb707

Browse files
committed
Merge branch 'release/1.4.0'
2 parents b8f96b4 + 2fcc47c commit 78eb707

17 files changed

Lines changed: 159 additions & 145 deletions

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ Then you will find the binary under the `build/libs/` directory.
4141
Reporting a bug or requesting a feature can be useful for further development of the plugin. To do that you just need
4242
to fill one of the issue templates we made for you:
4343
[Click here to report a bug](https://github.com/devblook/akropolis/issues/new?assignees=zetastormy&labels=bug&template=bug_report.yml&title=A+brief+description+of+your+report)
44-
or [click here to request a feature](https://github.com/devblook/akropolis/issues/new?assignees=zetastormy&labels=enhancement&template=feature_request.yml&title=A+brief+description+of+your+request)
45-
.
44+
or [click here to request a feature](https://github.com/devblook/akropolis/issues/new?assignees=zetastormy&labels=enhancement&template=feature_request.yml&title=A+brief+description+of+your+request).
4645

4746
### Contribute
4847

build.gradle.kts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
java
3-
id("com.github.johnrengelman.shadow") version ("8.1.0")
3+
id("com.github.johnrengelman.shadow") version ("8.1.1")
4+
id("io.papermc.paperweight.userdev") version ("1.5.5")
45
}
56

67
group = "team.devblook"
@@ -20,26 +21,27 @@ repositories {
2021
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
2122
maven("https://jitpack.io")
2223
maven("https://repo.papermc.io/repository/maven-public/")
23-
mavenCentral()
2424
}
2525

2626
dependencies {
27+
paperweight.paperDevBundle("1.20-R0.1-SNAPSHOT")
28+
2729
implementation("javax.inject:javax.inject:1")
2830

29-
implementation("com.github.MegavexNetwork.scoreboard-library:scoreboard-library-api:2.0.0-RC7")
30-
runtimeOnly("com.github.MegavexNetwork.scoreboard-library:scoreboard-library-implementation:2.0.0-RC7")
31-
runtimeOnly("com.github.MegavexNetwork.scoreboard-library:scoreboard-library-v1_19_R3:2.0.0-RC7")
31+
implementation("com.github.MegavexNetwork.scoreboard-library:scoreboard-library-api:2.0.0-RC9")
32+
runtimeOnly("com.github.MegavexNetwork.scoreboard-library:scoreboard-library-implementation:2.0.0-RC9")
33+
runtimeOnly("com.github.MegavexNetwork.scoreboard-library:scoreboard-library-v1_20_R1:2.0.0-RC9")
3234

33-
compileOnly("net.kyori:adventure-text-minimessage:4.13.1")
34-
compileOnly("net.kyori:adventure-api:4.13.1")
35+
compileOnly("net.kyori:adventure-text-minimessage:4.14.0")
36+
compileOnly("net.kyori:adventure-api:4.14.0")
3537

36-
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
38+
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
3739

3840
compileOnly("com.mojang:authlib:1.5.25")
3941
compileOnly("me.clip:placeholderapi:2.11.3")
4042
compileOnly("com.arcaniax:HeadDatabase-API:1.3.1")
41-
compileOnly("com.github.cryptomorin:XSeries:9.3.1")
42-
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.1.0")
43+
compileOnly("com.github.cryptomorin:XSeries:9.4.0")
44+
compileOnly("io.github.miniplaceholders:miniplaceholders-api:2.2.0")
4345
}
4446

4547
configurations.implementation {
@@ -48,7 +50,7 @@ configurations.implementation {
4850

4951
tasks {
5052
processResources {
51-
filesMatching("plugin.yml") {
53+
filesMatching("paper-plugin.yml") {
5254
expand("version" to project.version)
5355
}
5456
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
org.gradle.caching=true
22
org.gradle.parallel=true
33
org.gradle.jvmargs='-Dfile.encoding=UTF-8'
4-
projectVersion=1.3.1
4+
projectVersion=1.4.0
55
libsPackage=team.devblook.akropolis.libs

gradle/wrapper/gradle-wrapper.jar

468 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

gradlew

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/team/devblook/akropolis/AkropolisPlugin.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import net.megavex.scoreboardlibrary.api.exception.NoPacketAdapterAvailableException;
2424
import net.megavex.scoreboardlibrary.api.noop.NoopScoreboardLibrary;
2525
import org.bukkit.Bukkit;
26+
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
2627
import org.bukkit.event.HandlerList;
2728
import org.bukkit.plugin.java.JavaPlugin;
2829
import team.devblook.akropolis.action.ActionManager;
@@ -65,16 +66,6 @@ public void onEnable() {
6566
getLogger().log(Level.INFO, "Based on DeluxeHub by ItsLewizz.");
6667
getLogger().log(Level.INFO, "--------");
6768

68-
// Check if using Paper
69-
try {
70-
Class.forName("com.destroystokyo.paper.PaperConfig");
71-
} catch (ClassNotFoundException ex) {
72-
getLogger().severe("Akropolis requires Paper 1.19+ to run, you can download");
73-
getLogger().severe("Paper here: https://papermc.io/downloads.");
74-
setEnabled(false);
75-
return;
76-
}
77-
7869
// Check plugin hooks
7970
hooksManager = new HooksManager(this);
8071

@@ -140,7 +131,12 @@ public void reload() {
140131

141132
scoreboardLibrary.close();
142133

143-
getCommandManager().reload();
134+
try {
135+
commandManager.reload();
136+
((CraftServer) getServer()).syncCommands();
137+
} catch (Exception e) {
138+
e.printStackTrace();
139+
}
144140

145141
try {
146142
scoreboardLibrary = ScoreboardLibrary.loadScoreboardLibrary(plugin);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This file is part of Akropolis
3+
*
4+
* Copyright (c) 2023 DevBlook Team and others
5+
*
6+
* Akropolis free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Akropolis is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with Akropolis. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
package team.devblook.akropolis;
21+
22+
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
23+
import io.papermc.paper.plugin.loader.PluginLoader;
24+
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
25+
import org.eclipse.aether.artifact.DefaultArtifact;
26+
import org.eclipse.aether.graph.Dependency;
27+
import org.eclipse.aether.repository.RemoteRepository;
28+
29+
@SuppressWarnings("UnstableApiUsage")
30+
public class AkropolisPluginLoader implements PluginLoader {
31+
32+
@Override
33+
public void classloader(PluginClasspathBuilder classpathBuilder) {
34+
MavenLibraryResolver resolver = new MavenLibraryResolver();
35+
resolver.addDependency(new Dependency(new DefaultArtifact("com.github.cryptomorin:XSeries:9.4.0"), null));
36+
resolver.addRepository(new RemoteRepository.Builder("central", "default", "https://repo1.maven.org/maven2/").build());
37+
38+
classpathBuilder.addLibrary(resolver);
39+
}
40+
}

src/main/java/team/devblook/akropolis/action/actions/TitleAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void execute(AkropolisPlugin plugin, Player player, String data) {
5050
fadeIn = Duration.ofSeconds(Long.parseLong(args[2]));
5151
stay = Duration.ofSeconds(Long.parseLong(args[3]));
5252
fadeOut = Duration.ofSeconds(Long.parseLong(args[4]));
53-
} catch (NumberFormatException ex) {
53+
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
5454
fadeIn = Duration.ofSeconds(1);
5555
stay = Duration.ofSeconds(3);
5656
fadeOut = Duration.ofSeconds(1);

src/main/java/team/devblook/akropolis/command/CommandManager.java

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.bukkit.command.CommandMap;
2424
import org.bukkit.configuration.ConfigurationSection;
2525
import org.bukkit.configuration.file.FileConfiguration;
26+
import org.bukkit.entity.Player;
2627
import team.devblook.akropolis.AkropolisPlugin;
2728
import team.devblook.akropolis.command.commands.*;
2829
import team.devblook.akropolis.command.commands.gamemode.*;
@@ -35,22 +36,22 @@
3536

3637
public class CommandManager {
3738
private final AkropolisPlugin plugin;
38-
private final FileConfiguration config;
39-
4039
private final Set<InjectableCommand> commands;
4140
private final List<CustomCommand> customCommands;
4241
private final CommandMap commandMap;
42+
private FileConfiguration config;
4343

4444
public CommandManager(AkropolisPlugin plugin) {
4545
this.plugin = plugin;
46-
this.config = plugin.getConfigManager().getFile(ConfigType.COMMANDS).get();
4746
this.commands = new HashSet<>();
4847
this.customCommands = new ArrayList<>();
4948
this.commandMap = Bukkit.getCommandMap();
5049
}
5150

5251
public void reload() {
53-
commands.forEach(c -> c.unregister(commandMap));
52+
config = plugin.getConfigManager().getFile(ConfigType.COMMANDS).get();
53+
54+
commands.forEach(this::unregisterCommand);
5455
if (!commands.isEmpty()) commands.clear();
5556

5657
registerCommand(new AkropolisCommand(plugin));
@@ -63,16 +64,21 @@ public void reload() {
6364
}
6465

6566
for (String command : commandsSection.getKeys(false)) {
66-
if (!config.getBoolean("commands." + command + ".enabled")) continue;
67+
if (!config.getBoolean("commands." + command + ".enabled")) {
68+
continue;
69+
}
6770

6871
registerCommand(command, commandsSection.getStringList(command + ".aliases"));
6972
}
7073

7174
reloadCustomCommands();
75+
Bukkit.getOnlinePlayers().forEach(Player::updateCommands);
7276
}
7377

7478
public void reloadCustomCommands() {
79+
customCommands.forEach(this::unregisterCommand);
7580
if (!customCommands.isEmpty()) customCommands.clear();
81+
7682
if (!config.isSet("custom_commands")) return;
7783

7884
ConfigurationSection customCommandsSection = config.getConfigurationSection("custom_commands");
@@ -83,19 +89,20 @@ public void reloadCustomCommands() {
8389
}
8490

8591
for (String entry : customCommandsSection.getKeys(false)) {
86-
87-
CustomCommand customCommand = new CustomCommand(entry,
88-
customCommandsSection.getStringList(entry + ".actions"));
92+
List<String> actions = customCommandsSection.getStringList(entry + ".actions");
93+
List<String> aliases = new ArrayList<>();
8994

9095
if (customCommandsSection.contains(entry + ".aliases")) {
91-
customCommand.addAliases(config.getStringList("custom_commands." + entry + ".aliases"));
96+
aliases = config.getStringList("custom_commands." + entry + ".aliases");
9297
}
9398

99+
CustomCommand customCommand = new CustomCommand(plugin, entry, aliases, actions);
100+
94101
if (customCommandsSection.contains(entry + ".permission")) {
95102
customCommand.setPermission(config.getString("custom_commands." + entry + ".permission"));
96103
}
97104

98-
this.customCommands.add(customCommand);
105+
registerCommand(customCommand);
99106
}
100107
}
101108

@@ -126,6 +133,17 @@ private void registerCommand(InjectableCommand command) {
126133
}
127134
}
128135

136+
private void unregisterCommand(InjectableCommand command) {
137+
try {
138+
command.getAliases().forEach(a -> commandMap.getKnownCommands().remove(a));
139+
commandMap.getKnownCommands().remove(command.getName());
140+
commandMap.getKnownCommands().remove("akropolis:" + command.getName());
141+
command.unregister(commandMap);
142+
} catch (Exception e) {
143+
e.printStackTrace();
144+
}
145+
}
146+
129147
public List<CustomCommand> getCustomCommands() {
130148
return customCommands;
131149
}

0 commit comments

Comments
 (0)