Skip to content

Commit e1675ec

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 8fb3c62 + 001cf32 commit e1675ec

21 files changed

Lines changed: 244 additions & 135 deletions

File tree

.github/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Configure how the release notes are generated for GitHub releases
2+
3+
changelog:
4+
# List of authors (like bots) and labels to exclude from pull requests
5+
exclude:
6+
labels:
7+
- ignore-for-release
8+
categories:
9+
- title: 🛠 Breaking Changes
10+
labels:
11+
- Semver-Major
12+
- breaking-change
13+
- title: 🎉 Exciting New Features
14+
labels:
15+
- Semver-Minor
16+
- enhancement
17+
- title: 🐞 Bugfixes
18+
labels:
19+
- bug
20+
- title: 👒 Dependencies
21+
labels:
22+
- dependencies
23+
- title: Other Changes
24+
labels:
25+
- "*"

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,4 @@ jobs:
6464

6565
- name: Submit Dependency Snapshot
6666
if: ${{ github.event_name == 'push' }}
67-
uses: advanced-security/maven-dependency-submission-action@v4.1.2
67+
uses: advanced-security/maven-dependency-submission-action@v5.0.0

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ Development builds contain the latest changes from the Source-Code. They are ble
3232
but also include features, enhancements and bug fixes that are not yet in a released version. If you click on the left
3333
side on `Changes`, you can see iterative change sets leading to a specific build.
3434

35-
You can download them from here: https://ci.codemc.org/job/Games647/job/FastLogin/
35+
~~You can download them from here: [CodeMC(Jenkins)](https://ci.codemc.org/job/Games647/job/FastLogin/)~~
36+
37+
Currently broken due changed usernames. Download it from [here](https://github.com/TuxCoding/FastLogin/releases)
38+
39+
3640

3741
***
3842

bukkit/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@
354354
<version>v3.0.0</version>
355355
<scope>provided</scope>
356356
<optional>true</optional>
357+
358+
<!-- Exclude dependencies to prevent potential version conflicts-->
359+
<exclusions>
360+
<exclusion>
361+
<groupId>*</groupId>
362+
<artifactId>*</artifactId>
363+
</exclusion>
364+
</exclusions>
357365
</dependency>
358366

359367
<!--No maven repository :(-->

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/FastLoginBukkit.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.comphenix.protocol.ProtocolLibrary;
2929
import com.github.games647.fastlogin.bukkit.command.CrackedCommand;
3030
import com.github.games647.fastlogin.bukkit.command.PremiumCommand;
31+
import com.github.games647.fastlogin.bukkit.command.DeleteCommand;
3132
import com.github.games647.fastlogin.bukkit.listener.ConnectionListener;
3233
import com.github.games647.fastlogin.bukkit.listener.PaperCacheListener;
3334
import com.github.games647.fastlogin.bukkit.listener.protocollib.ProtocolLibListener;
@@ -155,6 +156,7 @@ private void registerCommands() {
155156
//register commands using a unique name
156157
Optional.ofNullable(getCommand("premium")).ifPresent(c -> c.setExecutor(new PremiumCommand(this)));
157158
Optional.ofNullable(getCommand("cracked")).ifPresent(c -> c.setExecutor(new CrackedCommand(this)));
159+
Optional.ofNullable(getCommand("fldelete")).ifPresent(c -> c.setExecutor(new DeleteCommand(this)));
158160
}
159161

160162
private boolean initializeFloodgate() {
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* SPDX-License-Identifier: MIT
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2015-2024 games647 and contributors
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all
16+
* copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
* SOFTWARE.
25+
*/
26+
package com.github.games647.fastlogin.bukkit.command;
27+
28+
import java.util.ArrayList;
29+
import java.util.List;
30+
31+
import org.bukkit.Bukkit;
32+
import org.bukkit.command.Command;
33+
import org.bukkit.command.CommandSender;
34+
import org.bukkit.command.ConsoleCommandSender;
35+
import org.bukkit.command.TabExecutor;
36+
import org.bukkit.entity.Player;
37+
38+
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
39+
40+
public class DeleteCommand implements TabExecutor {
41+
private final FastLoginBukkit plugin;
42+
43+
public DeleteCommand(FastLoginBukkit plugin) {
44+
this.plugin = plugin;
45+
}
46+
47+
/**
48+
* Handles the command to delete profiles.
49+
*/
50+
@Override
51+
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
52+
53+
if (!sender.hasPermission(command.getPermission())) {
54+
plugin.getCore().sendLocaleMessage("no-permission", sender);
55+
return true;
56+
}
57+
58+
if (plugin.getBungeeManager().isEnabled()) {
59+
sender.sendMessage("Error: Cannot delete profile entries when using BungeeCord!");
60+
return false;
61+
}
62+
63+
if (args.length < 1) {
64+
sender.sendMessage("Error: Must supply username to delete!");
65+
return false;
66+
}
67+
68+
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
69+
int count = plugin.getCore().getStorage().deleteProfile(args[0]);
70+
if (!(sender instanceof ConsoleCommandSender)) {
71+
Bukkit.getScheduler().runTask(plugin, () -> {
72+
if (count == 0) {
73+
sender.sendMessage("Error: No profile entries found!");
74+
} else {
75+
sender.sendMessage("Deleted " + count + " matching profile entries");
76+
}
77+
});
78+
}
79+
});
80+
81+
return true;
82+
}
83+
84+
@Override
85+
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
86+
List<String> list = new ArrayList<>();
87+
for (Player p : Bukkit.getOnlinePlayers()) {
88+
if (p.getName().toLowerCase().startsWith(args[0])) {
89+
list.add(p.getName());
90+
}
91+
}
92+
return null;
93+
}
94+
}

bukkit/src/main/resources/plugin.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ commands:
4545
usage: /<command> [player]
4646
permission: ${project.artifactId}.command.cracked
4747

48+
fldelete:
49+
description: 'Delete player profile data'
50+
usage: /<command> [player]
51+
permission: ${project.artifactId}.command.delete
52+
4853
permissions:
4954
${project.artifactId}.command.premium:
5055
description: 'Label themselves as premium'
@@ -63,3 +68,7 @@ permissions:
6368
description: 'Label others as cracked'
6469
children:
6570
${project.artifactId}.command.cracked: true
71+
72+
${project.artifactId}.command.delete:
73+
description: 'Delete other players profile data'
74+
default: op

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@
203203
<dependency>
204204
<groupId>com.github.games647</groupId>
205205
<artifactId>craftapi</artifactId>
206-
<version>0.8.1</version>
206+
<version>1.0-SNAPSHOT</version>
207207
</dependency>
208208

209209
<!-- Database driver included in Spigot -->

core/src/main/java/com/github/games647/fastlogin/core/ProxyAgnosticMojangResolver.java

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727

2828
import com.github.games647.craftapi.model.auth.Verification;
2929
import com.github.games647.craftapi.resolver.MojangResolver;
30+
import com.github.games647.craftapi.resolver.Options;
3031

3132
import java.io.IOException;
32-
import java.io.InputStream;
33-
import java.net.HttpURLConnection;
3433
import java.net.InetAddress;
3534
import java.util.Optional;
3635

@@ -44,38 +43,12 @@
4443
*/
4544
public class ProxyAgnosticMojangResolver extends MojangResolver {
4645

47-
private static final String HOST = "sessionserver.mojang.com";
48-
49-
/**
50-
* A formatting string containing a URL used to call the {@code hasJoined} method on mojang session servers.
51-
* <p>
52-
* Formatting parameters:
53-
* 1. The username of the player in question
54-
* 2. The serverId of this server
55-
*/
56-
public static final String ENDPOINT = "https://" + HOST + "/session/minecraft/hasJoined?username=%s&serverId=%s";
57-
46+
public ProxyAgnosticMojangResolver(Options options) {
47+
super(options);
48+
}
5849
@Override
5950
public Optional<Verification> hasJoined(String username, String serverHash, InetAddress hostIp)
6051
throws IOException {
61-
String url = String.format(ENDPOINT, username, serverHash);
62-
63-
HttpURLConnection conn = this.getConnection(url);
64-
int responseCode = conn.getResponseCode();
65-
66-
Verification verification = null;
67-
68-
// Mojang session servers send HTTP 204 (NO CONTENT) when the authentication seems invalid
69-
// If that's not our case, the authentication is valid, and so we can parse the response.
70-
if (responseCode != HttpURLConnection.HTTP_NO_CONTENT) {
71-
verification = this.parseRequest(conn, this::parseVerification);
72-
}
73-
74-
return Optional.ofNullable(verification);
75-
}
76-
77-
// Functional implementation of InputStreamAction, used in hasJoined method in parseRequest call
78-
protected Verification parseVerification(InputStream input) throws IOException {
79-
return this.readJson(input, Verification.class);
52+
return super.hasJoined(username, serverHash, null);
8053
}
8154
}

core/src/main/java/com/github/games647/fastlogin/core/scheduler/AbstractAsyncScheduler.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,30 @@ public AbstractAsyncScheduler(Logger logger, Executor processingPool) {
4343
this.processingPool = processingPool;
4444
}
4545

46-
public abstract CompletableFuture<Void> runAsync(Runnable task);
46+
public CompletableFuture<Void> runAsync(Runnable task) {
47+
return CompletableFuture.runAsync(() -> process(task), processingPool).exceptionally(error -> {
48+
logger.warn("Error occurred on thread pool", error);
49+
return null;
50+
});
51+
}
4752

48-
public abstract CompletableFuture<Void> runAsyncDelayed(Runnable task, Duration delay);
53+
public CompletableFuture<Void> runAsyncDelayed(Runnable task, Duration delay) {
54+
return CompletableFuture.runAsync(() -> {
55+
currentlyRunning.incrementAndGet();
56+
try {
57+
Thread.sleep(delay.toMillis());
58+
task.run();
59+
} catch (InterruptedException interruptedException) {
60+
// restore interrupt flag
61+
Thread.currentThread().interrupt();
62+
} finally {
63+
currentlyRunning.getAndDecrement();
64+
}
65+
}, processingPool).exceptionally(error -> {
66+
logger.warn("Error occurred on thread pool", error);
67+
return null;
68+
});
69+
}
4970

5071
protected void process(Runnable task) {
5172
currentlyRunning.incrementAndGet();

0 commit comments

Comments
 (0)