Skip to content

Commit

Permalink
Add plugin website attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Nov 18, 2024
1 parent d0a0704 commit 80b4d9a
Show file tree
Hide file tree
Showing 25 changed files with 123 additions and 25 deletions.
1 change: 1 addition & 0 deletions proto/src/main/proto/soulfire/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ message ServerPlugin {
string description = 3;
string author = 4;
string license = 5;
string website = 6;
}

message ClientDataResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.soulfiremc.server.injection.SFDefaultMixinExtension;
import com.soulfiremc.server.util.PortHelper;
import com.soulfiremc.server.util.SFPathConstants;
import com.soulfiremc.server.util.pf4j.SFManifestPluginDescriptorFinder;
import com.soulfiremc.server.util.structs.CustomClassProvider;
import com.soulfiremc.server.util.structs.SFLogAppender;
import io.netty.util.ResourceLeakDetector;
Expand Down Expand Up @@ -72,7 +73,12 @@ public abstract class SoulFireAbstractBootstrap {
}

protected final Path pluginsDirectory = SFPathConstants.getPluginsDirectory(getBaseDirectory());
protected final PluginManager pluginManager = new JarPluginManager(pluginsDirectory);
protected final PluginManager pluginManager = new JarPluginManager(pluginsDirectory) {
@Override
protected SFManifestPluginDescriptorFinder createPluginDescriptorFinder() {
return new SFManifestPluginDescriptorFinder();
}
};

protected SoulFireAbstractBootstrap() {}

Expand Down
10 changes: 6 additions & 4 deletions server/src/main/java/com/soulfiremc/server/api/PluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
package com.soulfiremc.server.api;

import com.soulfiremc.grpc.generated.ServerPlugin;
import com.soulfiremc.server.util.pf4j.SFPluginDescriptor;
import lombok.SneakyThrows;
import org.pf4j.PluginClassLoader;
import org.pf4j.PluginDescriptor;

import java.lang.reflect.Field;

Expand All @@ -34,7 +34,7 @@
* @param author The plugin author
* @param license The plugin license
*/
public record PluginInfo(String id, String version, String description, String author, String license) {
public record PluginInfo(String id, String version, String description, String author, String license, String website) {
private static final Field PLUGIN_DESCRIPTOR_FIELD;

static {
Expand All @@ -60,13 +60,14 @@ public static PluginInfo fromClassLoader(Class<?> clazz) {
throw new IllegalArgumentException("Class is not a plugin");
}

var descriptor = (PluginDescriptor) PLUGIN_DESCRIPTOR_FIELD.get(plugin);
var descriptor = (SFPluginDescriptor) PLUGIN_DESCRIPTOR_FIELD.get(plugin);
return new PluginInfo(
descriptor.getPluginId(),
descriptor.getVersion(),
descriptor.getPluginDescription(),
descriptor.getProvider(),
descriptor.getLicense()
descriptor.getLicense(),
descriptor.website()
);
}

Expand All @@ -77,6 +78,7 @@ public ServerPlugin toProto() {
.setDescription(description)
.setAuthor(author)
.setLicense(license)
.setWebsite(website)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public AIChatBot() {
"1.0.0",
"Allow players to chat with an AI",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public AntiAFK() {
"1.0.0",
"Automatically moves x amount of blocks in a random direction to prevent being kicked for being AFK",
"AlexProgrammerDE",
"GPL-3.0"));
"GPL-3.0",
"https://soulfiremc.com"));
}

@EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public AutoArmor() {
"1.0.0",
"Automatically puts on the best armor",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public AutoChatMessage() {
"1.0.0",
"Automatically sends messages in a configured delay",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public AutoEat() {
"1.0.0",
"Automatically eats food when hungry",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public AutoJump() {
"1.0.0",
"Automatically jumps randomly",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public AutoReconnect() {
"1.0.0",
"Automatically reconnects bots when they time out or are kicked",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public AutoRegister() {
"1.0.0",
"Automatically registers bots on servers",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public AutoRespawn() {
"1.0.0",
"Automatically respawns after death",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public AutoTotem() {
"1.0.0",
"Automatically puts totems in the offhand slot",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public ChatControl() {
"1.0.0",
"Control the bot with chat messages",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public ChatMessageLogger() {
"1.0.0",
"Logs all received chat messages to the terminal",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public ClientBrand() {
"1.0.0",
"Sends the client brand to the server",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public ClientSettings() {
"1.0.0",
"Sends client settings to the server",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public FakeVirtualHost() {
"1.0.0",
"Fakes the virtual host",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public ForwardingBypass() {
"1.0.0",
"Allows bypassing proxy forwarding",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public KillAura() {
"1.0.0",
"Automatically attacks entities",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public ModLoaderSupport() {
"1.0.0",
"Supports mod loaders like Forge",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ public POVServer() {
"1.0.0",
"A plugin that allows users to control bots from a first-person perspective.",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public ServerListBypass() {
"1.0.0",
"Bypasses server list anti-bots",
"AlexProgrammerDE",
"GPL-3.0"
"GPL-3.0",
"https://soulfiremc.com"
));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* SoulFire
* Copyright (C) 2024 AlexProgrammerDE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.soulfiremc.server.util.pf4j;

import org.pf4j.ManifestPluginDescriptorFinder;
import org.pf4j.PluginDescriptor;

import java.util.jar.Manifest;

public class SFManifestPluginDescriptorFinder extends ManifestPluginDescriptorFinder {
public static final String PLUGIN_WEBSITE = "Plugin-Website";

protected PluginDescriptor createPluginDescriptor(Manifest manifest) {
var descriptor = (SFPluginDescriptor) super.createPluginDescriptor(manifest);
var attributes = manifest.getMainAttributes();

descriptor.website(attributes.getValue(PLUGIN_WEBSITE));

return descriptor;
}

@Override
protected SFPluginDescriptor createPluginDescriptorInstance() {
return new SFPluginDescriptor();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SoulFire
* Copyright (C) 2024 AlexProgrammerDE
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.soulfiremc.server.util.pf4j;

import lombok.Getter;
import lombok.Setter;
import org.pf4j.DefaultPluginDescriptor;

@Getter
@Setter
public class SFPluginDescriptor extends DefaultPluginDescriptor {
private String website;
}

0 comments on commit 80b4d9a

Please sign in to comment.