Allow relative coordinates in /bot region

Also remove codeql
This commit is contained in:
ThisTestUser
2023-01-02 15:21:37 -05:00
parent 910b53f54f
commit 945b2627d1
2 changed files with 43 additions and 55 deletions

View File

@@ -3,59 +3,30 @@ name: "CodeQL"
on: [push, pull_request]
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
gradle:
strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Cache local repo
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Execute Gradle build
run: ./gradlew build
- name: Execute Gradle build
run: ./gradlew build
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
- name: Upload a Build Artifact
uses: actions/upload-artifact@v3
if: success()
with:
name: TerminatorPlus
path: build/libs/
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2.2.4
if: success()
with:
name: TerminatorPlus
path: build/libs/

View File

@@ -434,12 +434,13 @@ public class BotCommand extends CommandInstance {
}
double x1, y1, z1, x2, y2, z2, wX, wY, wZ;
try {
x1 = Double.parseDouble(args.get(1));
y1 = Double.parseDouble(args.get(2));
z1 = Double.parseDouble(args.get(3));
x2 = Double.parseDouble(args.get(4));
y2 = Double.parseDouble(args.get(5));
z2 = Double.parseDouble(args.get(6));
Location loc = sender instanceof Player pl ? pl.getLocation() : null;
x1 = parseDoubleOrRelative(args.get(1), loc, 0);
y1 = parseDoubleOrRelative(args.get(2), loc, 1);
z1 = parseDoubleOrRelative(args.get(3), loc, 2);
x2 = parseDoubleOrRelative(args.get(4), loc, 0);
y2 = parseDoubleOrRelative(args.get(5), loc, 1);
z2 = parseDoubleOrRelative(args.get(6), loc, 2);
if (strict)
wX = wY = wZ = 0;
else {
@@ -518,4 +519,20 @@ public class BotCommand extends CommandInstance {
public void debug(CommandSender sender, @Arg("expression") String expression) {
new Debugger(sender).execute(expression);
}
private double parseDoubleOrRelative(String pos, Location loc, int type) {
if (loc == null || pos.length() == 0 || pos.charAt(0) != '~')
return Double.parseDouble(pos);
double relative = Double.parseDouble(pos.substring(1));
switch (type) {
case 0:
return relative + loc.getX();
case 1:
return relative + loc.getY();
case 2:
return relative + loc.getZ();
default:
return 0;
}
}
}