1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 14:59:20 +00:00

Register permissions on Spigot. Profile ID can be null. Fixed submodule

This commit is contained in:
Tim203
2022-02-06 02:10:17 +01:00
parent 141643f381
commit 039b398dad
13 changed files with 63 additions and 33 deletions

View File

@@ -63,19 +63,16 @@ public final class SpigotPlugin extends JavaPlugin {
@Override
public void onEnable() {
boolean usePaperListener = ReflectionUtils.getClassSilently(
"com.destroystokyo.paper.event.profile.PreFillProfileEvent") != null;
platform.enable(
new SpigotCommandModule(this),
new SpigotAddonModule(),
new PluginMessageModule()
new PluginMessageModule(),
(usePaperListener ? new PaperListenerModule() : new SpigotListenerModule())
);
if (ReflectionUtils.getClassSilently(
"com.destroystokyo.paper.event.profile.PreFillProfileEvent") != null) {
platform.enable(new PaperListenerModule());
} else {
platform.enable(new SpigotListenerModule());
}
//todo add proper support for disabling things on shutdown and enabling this on enable
injector.getInstance(HandshakeHandlers.class)
.addHandshakeHandler(injector.getInstance(SpigotHandshakeHandler.class));

View File

@@ -41,7 +41,9 @@ public final class PaperProfileListener implements Listener {
@EventHandler
public void onFill(PreFillProfileEvent event) {
UUID id = event.getPlayerProfile().getId();
if (!this.api.isFloodgatePlayer(id) ||
// back when this event got added the PlayerProfile class didn't have the
// hasProperty / hasTextures methods
if (id == null || !this.api.isFloodgatePlayer(id) ||
event.getPlayerProfile().getProperties().stream().anyMatch(
prop -> "textures".equals(prop.getName()))) {
return;

View File

@@ -32,8 +32,12 @@ import com.google.inject.Provides;
import com.google.inject.Singleton;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager;
import org.geysermc.floodgate.SpigotPlugin;
import org.geysermc.floodgate.command.util.Permission;
import org.geysermc.floodgate.platform.command.CommandUtil;
import org.geysermc.floodgate.player.FloodgateCommandPreprocessor;
import org.geysermc.floodgate.player.UserAudience;
@@ -42,6 +46,12 @@ import org.geysermc.floodgate.player.UserAudience;
public final class SpigotCommandModule extends CommandModule {
private final SpigotPlugin plugin;
@Override
protected void configure() {
super.configure();
registerPermissions();
}
@Provides
@Singleton
@SneakyThrows
@@ -55,4 +65,20 @@ public final class SpigotCommandModule extends CommandModule {
commandManager.registerCommandPreProcessor(new FloodgateCommandPreprocessor<>(commandUtil));
return commandManager;
}
private void registerPermissions() {
PluginManager manager = Bukkit.getPluginManager();
for (Permission permission : Permission.values()) {
if (manager.getPermission(permission.get()) != null) {
continue;
}
PermissionDefault defaultValue =
PermissionDefault.getByName(permission.defaultValue().name());
manager.addPermission(new org.bukkit.permissions.Permission(
permission.get(), defaultValue
));
}
}
}

View File

@@ -43,8 +43,6 @@ public class SpigotPluginMessageRegistration implements PluginMessageRegistratio
(channel1, player, message) ->
channel.handleServerCall(message, player.getUniqueId(), player.getName()));
//todo actually do something with the result, lol
messenger.registerOutgoingPluginChannel(plugin, channel.getIdentifier());
}
}