Skip to content

Commit

Permalink
Vistas token
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindgamesnl committed Aug 5, 2023
1 parent c502190 commit 5922490
Show file tree
Hide file tree
Showing 14 changed files with 46 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java openjdk-18.0.2.1
java adoptopenjdk-8.0.332+9
2 changes: 2 additions & 0 deletions dev-resources/bungee-test/plugins/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.jar
.jar
Binary file modified dev-resources/bungee-test/plugins/openaudiomc-6.8.7.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion dev-resources/vistas-test/vistas/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
voicechat-hint-interval: 120,
voicechat-hint-range: 135,
redstone-tick-speakers: true,
redstone-tick-speakers-interval: 5
redstone-tick-speakers-interval: 5,
ignore-regions-on-vehicles: false
},
papi: {
client-connected: Connected,
Expand Down
2 changes: 1 addition & 1 deletion modules/jutils/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@
</plugins>
</build>
<properties>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
</project>

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public VistasRedisClient(Configuration configuration) {
spigotAudioCommandEvent.setCanceled(true);
sendPacket(new UserExecuteAudioCommandPacket(
spigotAudioCommandEvent.getCommandSender().getName(),
((Player) spigotAudioCommandEvent.getCommandSender()).getUniqueId()
((Player) spigotAudioCommandEvent.getCommandSender()).getUniqueId(),
spigotAudioCommandEvent.getArgs()
));
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public class UserExecuteAudioCommandPacket extends AbstractPacketPayload {

private String playerName;
private UUID playerUuid;
private String[] args = new String[0];

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.craftmend.openaudiomc.vistas.client.server.networking;

import com.craftmend.openaudiomc.OpenAudioMc;
import com.craftmend.openaudiomc.generic.authentication.driver.AuthenticationDriver;
import com.craftmend.openaudiomc.generic.client.session.ClientAuth;
import com.craftmend.openaudiomc.generic.commands.CommandService;
import com.craftmend.openaudiomc.generic.commands.interfaces.SubCommand;
import com.craftmend.openaudiomc.generic.environment.MagicValue;
Expand Down Expand Up @@ -52,8 +54,22 @@ public VistasRedisServer(Configuration configuration) {
});

packetEvents.registerPacket(UserExecuteAudioCommandPacket.class).setHandler(userExecuteAudioCommandPacket -> {
OpenAudioMc.getService(NetworkingService.class).getClient(userExecuteAudioCommandPacket.getPlayerUuid())
.getAuth().publishSessionUrl();

// does the user have args?
ClientAuth authenticationDriver = OpenAudioMc.getService(NetworkingService.class).getClient(userExecuteAudioCommandPacket.getPlayerUuid())
.getAuth();

if (userExecuteAudioCommandPacket.getArgs().length == 0) {
authenticationDriver.publishSessionUrl();
} else {
User sender = OpenAudioMc.resolveDependency(UserHooks.class).byUuid(userExecuteAudioCommandPacket.getPlayerUuid());

if (sender == null) {
OpenAudioLogger.toConsole("User " + userExecuteAudioCommandPacket.getPlayerUuid() + " is not online, but tried to execute a command");
return;
}
authenticationDriver.activateToken(sender, userExecuteAudioCommandPacket.getArgs()[0]);
}
});

packetEvents.registerPacket(UserLeavePacket.class).setHandler(leavePacket -> {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/bash/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="911"
BUILD_NUM="916"
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ public class SpigotAudioCommandEvent extends AudioEvent {
private boolean canceled = false;
@Getter
private CommandSender commandSender;
@Getter
private String[] args;

public SpigotAudioCommandEvent(CommandSender commandSender) {
public SpigotAudioCommandEvent(CommandSender commandSender, String[] args) {
this.commandSender = commandSender;
this.args = args;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ public void makeBackup(boolean force) {
);
} catch (IOException e) {}

try {
Files.copy(
new File(MagicValue.STORAGE_DIRECTORY.get(File.class), "storm.db").toPath(),
new File(backupDir, "storm.db").toPath(),
StandardCopyOption.REPLACE_EXISTING
);
} catch (IOException e) {}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ public class SpigotAudioCommand implements CommandExecutor {

@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
SpigotAudioCommandEvent event = AudioApi.getInstance().getEventDriver().fire(new SpigotAudioCommandEvent(commandSender));
SpigotAudioCommandEvent event = AudioApi.getInstance().getEventDriver().fire(new SpigotAudioCommandEvent(commandSender, args));
if (event.isCanceled()) {
return true;
}



User sua = OpenAudioMc.resolveDependency(UserHooks.class).fromCommandSender(commandSender);

if (CommandMiddewareExecutor.shouldBeCanceled(sua, null, commandMiddleware))
Expand Down Expand Up @@ -71,7 +73,6 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
}

if (commandSender instanceof Player) {

// do we have an argument called "token", "bedrock" or "key"?
if (args.length == 1) {
OpenAudioMc.getService(NetworkingService.class).getClient(sua.getUniqueId()).getAuth().activateToken(
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/main/resources/data.bin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
BUILD_NUM="911"
BUILD_NUM="916"
4 changes: 2 additions & 2 deletions plugin/src/main/resources/openaudiomc-build.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
BUILD_VERSION="911"
BUILD_COMMIT="e52622900ffb0568a1633abb7970b4e08d829eed"
BUILD_VERSION="916"
BUILD_COMMIT="c502190aec61aedb320d2a8726819f3feb3266e3"
BUILD_AUTHOR="Mats"

0 comments on commit 5922490

Please sign in to comment.