-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #228 from ClubObsidian/5.0.0
5.0.0 Update
- Loading branch information
Showing
410 changed files
with
12,195 additions
and
5,486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,109 @@ | ||
plugins { | ||
id 'java-library' | ||
id 'com.github.johnrengelman.shadow' version '7.1.1' | ||
id 'org.cadixdev.licenser' version '0.6.1' | ||
id 'eclipse' | ||
id 'idea' | ||
id 'maven-publish' | ||
} | ||
|
||
allprojects { | ||
group 'com.clubobsidian' | ||
version '5.0.0' | ||
ext { | ||
junitVersion = '5.8.2' | ||
cloudVersion = '1.6.2' | ||
} | ||
} | ||
|
||
subprojects { | ||
apply plugin: 'java-library' | ||
apply plugin: 'com.github.johnrengelman.shadow' | ||
apply plugin: 'org.cadixdev.licenser' | ||
apply plugin: 'maven-publish' | ||
|
||
group 'com.clubobsidian' | ||
version '4.1.0' | ||
publishing { | ||
publications { | ||
shadow(MavenPublication) { | ||
groupId 'com.clubobsidian' | ||
artifactId project.name | ||
version '5.0.0' | ||
artifact shadowJar | ||
} | ||
} | ||
} | ||
|
||
tasks.withType(JavaCompile) { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
|
||
license { | ||
header = project.rootProject.file('HEADER.txt') | ||
include '**/*.java' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
|
||
shadowJar { | ||
archiveClassifier.set('') | ||
minimize() { | ||
exclude(project(":core")) | ||
} | ||
relocate 'org.spongepowered.configurate', 'com.clubobsidian.dynamicgui.shaded.configurate' | ||
relocate 'com.google.common', 'com.clubobsidian.dynamicgui.shaded.guava' | ||
relocate 'com.google.gson', 'com.clubobsidian.dynamicgui.shaded.gson' | ||
relocate 'org.yaml.snakeyaml', 'com.clubobsidian.dynamicgui.shaded.snakeyaml' | ||
relocate 'com.clubobsidian.trident', 'com.clubobsidian.dynamicgui.shaded.trident' | ||
relocate 'com.clubobsidian.wrappy', 'com.clubobsidian.dynamicgui.shaded.wrappy' | ||
relocate 'net.kyori', 'com.clubobsidian.dynamicgui.shaded.kyori' | ||
relocate 'com.clubobsidian.fuzzutil', 'com.clubobsidian.dynamicgui.shaded.fuzzutil' | ||
relocate 'io.leangen', 'com.clubobsidian.dynamicgui.shaded.leangen' | ||
relocate 'org.codehaus.mojo', 'com.clubobsidian.dynamicgui.shaded.mojo' | ||
relocate 'org.checkerframework.framework', 'com.clubobsidian.dynamicgui.shaded.checkerframework.framework' | ||
relocate 'org.checkerframework.common', 'com.clubobsidian.dynamicgui.shaded.checkerframework.common' | ||
relocate 'org.checkerframework.checker', 'com.clubobsidian.dynamicgui.shaded.checkerframework.checker' | ||
relocate 'org.checkerframework.dataflow', 'com.clubobsidian.dynamicgui.shaded.checkerframework.dataflow' | ||
relocate 'org.apache.commons', 'com.clubobsidian.dynamicgui.shaded.apachecommons' | ||
relocate 'org.aopalliance.intercept', 'com.clubobsidian.dynamicgui.shaded.aopalliance.intercept' | ||
relocate 'org.aopalliance.aop', 'com.clubobsidian.dynamicgui.shaded.aopalliance.aop' | ||
relocate 'javax.inject', 'com.clubobsidian.dynamicgui.shaded.javax.inject' | ||
relocate 'com.udojava.evalex', 'com.clubobsidian.dynamicgui.shaded.evalex' | ||
relocate 'com.typesafe.config', 'com.clubobsidian.dynamicgui.shaded.typesafeconfig' | ||
relocate 'com.google.j2objc', 'com.clubobsidian.dynamicgui.shaded.j2objc' | ||
relocate 'com.google.inject', 'com.clubobsidian.dynamicgui.shaded.guice' | ||
relocate 'javax.annotation', 'com.clubobsidian.dynamicgui.shaded.javaxannotation' | ||
relocate 'com.google.errorprone', 'com.clubobsidian.dynamicgui.shaded.errorprone' | ||
relocate 'com.fasterxml.jackson', 'com.clubobsidian.dynamicgui.shaded.jackson' | ||
relocate 'com.github.benmanes.caffeine', 'com.clubobsidian.dynamicgui.shaded.caffeine' | ||
relocate 'cloud', 'com.clubobsidian.dynamicgui.shaded.cloud' | ||
relocate 'com.google.thirdparty', 'com.clubobsidian.dynamicgui.shaded.google.thirdparty' | ||
relocate 'io.github.classgraph', 'com.clubobsidian.dynamicgui.shaded.classgraph' | ||
relocate 'nonapi.io.github.classgraph', 'com.clubobsidian.dynamicgui.shaded.nonapi.io.github.classgraph' | ||
relocate 'javassist', 'com.clubobsidian.dynamicgui.shaded.javassist' | ||
} | ||
|
||
repositories { | ||
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots"} | ||
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" } | ||
mavenCentral() | ||
maven { url 'https://jitpack.io' } | ||
} | ||
|
||
|
||
|
||
dependencies { | ||
testImplementation 'junit:junit:4.13.2' | ||
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion" | ||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion" | ||
testImplementation 'org.mockito:mockito-core:4.3.1' | ||
api 'org.apache.commons:commons-lang3:3.12.0' | ||
api 'com.github.clubobsidian:wrappy:2.3.2' | ||
api 'com.github.ben-manes.caffeine:caffeine:3.0.4' | ||
compileOnly "cloud.commandframework:cloud-core:$cloudVersion" | ||
testImplementation "cloud.commandframework:cloud-core:$cloudVersion" | ||
api "cloud.commandframework:cloud-annotations:$cloudVersion" | ||
api "io.github.classgraph:classgraph:4.8.138" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
bukkit/src/main/java/com/clubobsidian/dynamicgui/bukkit/command/BukkitGuiCommandSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2022 virustotalop and contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.clubobsidian.dynamicgui.bukkit.command; | ||
|
||
import com.clubobsidian.dynamicgui.core.command.GuiCommandSender; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class BukkitGuiCommandSender implements GuiCommandSender { | ||
|
||
private final CommandSender sender; | ||
|
||
public BukkitGuiCommandSender(CommandSender sender) { | ||
this.sender = sender; | ||
} | ||
|
||
@Override | ||
public Object getNativeSender() { | ||
return this.sender; | ||
} | ||
|
||
@Override | ||
public boolean isPlayer() { | ||
return this.sender instanceof Player; | ||
} | ||
|
||
@Override | ||
public void sendMessage(String message) { | ||
this.sender.sendMessage(message); | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
...t/src/main/java/com/clubobsidian/dynamicgui/bukkit/command/cloud/BukkitCloudExtender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright 2022 virustotalop and contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.clubobsidian.dynamicgui.bukkit.command.cloud; | ||
|
||
import cloud.commandframework.Command; | ||
import cloud.commandframework.CommandManager; | ||
import cloud.commandframework.arguments.CommandArgument; | ||
import cloud.commandframework.bukkit.BukkitPluginRegistrationHandler; | ||
import cloud.commandframework.internal.CommandRegistrationHandler; | ||
import com.clubobsidian.dynamicgui.core.Key; | ||
import com.clubobsidian.dynamicgui.core.command.cloud.CloudExtender; | ||
import com.clubobsidian.dynamicgui.core.util.ReflectionUtil; | ||
|
||
import java.util.Iterator; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
public class BukkitCloudExtender implements CloudExtender { | ||
|
||
private final boolean brigadierEnabled = this.checkForBrigadier(); | ||
|
||
@Override | ||
public boolean unregister(CommandManager commandManager, Command command, String alias) { | ||
BukkitPluginRegistrationHandler handler = (BukkitPluginRegistrationHandler) | ||
commandManager.getCommandRegistrationHandler(); | ||
boolean handlerUnregistered = this.unregisterHandler(handler, alias); | ||
boolean aliasesUnregistered = this.unregisterAliases(handler, alias); | ||
boolean bukkitUnregistered = this.unregisterBukkitCommand(handler, alias); | ||
boolean brigadierUnregistered = this.unregisterBrigadier(alias); | ||
return handlerUnregistered || aliasesUnregistered || bukkitUnregistered || brigadierUnregistered; | ||
} | ||
|
||
private boolean checkForBrigadier() { | ||
try { | ||
Class.forName("com.mojang.brigadier.CommandDispatcher"); | ||
return true; | ||
} catch(ClassNotFoundException ex) { | ||
return false; | ||
} | ||
} | ||
|
||
private boolean unregisterBukkitCommand(BukkitPluginRegistrationHandler handler, String alias) { | ||
Map<String, org.bukkit.command.Command> bukkitCommands = | ||
ReflectionUtil.get(handler, handler.getClass(), "bukkitCommands"); | ||
boolean removed = bukkitCommands.remove(alias) != null; | ||
boolean namespaceRemoved = bukkitCommands.remove(Key.create(alias).toString()) != null; | ||
return removed || namespaceRemoved; | ||
} | ||
|
||
private boolean unregisterHandler(CommandRegistrationHandler handler, String alias) { | ||
Map<CommandArgument<?, ?>, org.bukkit.command.Command> registeredCommands = | ||
ReflectionUtil.get(handler, BukkitPluginRegistrationHandler.class, "registeredCommands"); | ||
Iterator<Map.Entry<CommandArgument<?, ?>, org.bukkit.command.Command>> it = registeredCommands.entrySet().iterator(); | ||
boolean removed = false; | ||
String namespaceAlias = Key.create(alias).toString(); | ||
while (it.hasNext()) { | ||
org.bukkit.command.Command command = it.next().getValue(); | ||
if(command.getName().equals(alias) | ||
|| command.getName().equals(namespaceAlias) | ||
|| command.getAliases().contains(alias) | ||
|| command.getAliases().contains(namespaceAlias) | ||
|| command.getLabel().equals(alias) | ||
|| command.getLabel().equals(namespaceAlias)) { | ||
it.remove(); | ||
removed = true; | ||
} | ||
} | ||
return removed; | ||
} | ||
|
||
private boolean unregisterAliases(BukkitPluginRegistrationHandler handler, String alias) { | ||
Set<String> aliases = ReflectionUtil.get(handler, handler.getClass(), "recognizedAliases"); | ||
boolean original = aliases.remove(alias); | ||
boolean namespace = aliases.remove(Key.create(alias).toString()); | ||
return original || namespace; | ||
} | ||
|
||
private boolean unregisterBrigadier(String alias) { | ||
if (this.brigadierEnabled) { | ||
//TODO - implement unregistering brigadier | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.