Skip to content

Commit

Permalink
Merge pull request #228 from ClubObsidian/5.0.0
Browse files Browse the repository at this point in the history
5.0.0 Update
  • Loading branch information
virustotalop authored May 9, 2022
2 parents 4f223f4 + 5b5ef76 commit cb3caab
Show file tree
Hide file tree
Showing 410 changed files with 12,195 additions and 5,486 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#DynamicGui
core/mock_data/cooldowns.yml

# Compiled class file
*.class

Expand All @@ -22,6 +25,7 @@ hs_err_pid*

.gradle
build/
out/

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
3 changes: 0 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

First off thank you for considering contributing to DynamicGui! Below are a few different ways you can contribute.


## Issues

If you run into a bug please report it, **please note if this is a bug that could result in item duplication or some other security risk please report it to `virustotal#0001` on the DynamicGui Discord server.** If the bug is not a security risk or could do damage to servers that are using the plugin please file a bug report at https://github.com/ClubObsidian/DynamicGui/issues
Expand All @@ -15,8 +14,6 @@ We gladly accept most contributions which do not break backwards compatability.

If you are updating documentation please put `[ci skip]` in your commit so that your commit gets skipped by github actions, you can [read more about that here.](https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/)

**Please note before your code will be accepted please sign our [CLA.](https://cla-assistant.io/ClubObsidian/DynamicGui)**


## Features

Expand Down
2 changes: 1 addition & 1 deletion LICENSE_HEADER → HEADER.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2021 Club Obsidian and contributors.
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.
Expand Down
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@
<h1>DynamicGui</h1>

[![build](https://github.com/ClubObsidian/DynamicGui/actions/workflows/build.yml/badge.svg)](https://github.com/ClubObsidian/DynamicGui/actions/workflows/build.yml)
[![CLA assistant](https://cla-assistant.io/readme/badge/ClubObsidian/DynamicGui)](https://cla-assistant.io/ClubObsidian/DynamicGui)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

A plugin designed to make writing menus for Minecraft easy. Menus can be written in the configuration language of your choice: yaml, hocon, json or xml.
</div>

A rewrite of the plugin originally created at Club Obsidian.

Designed to make writing menus easy.


## Features

* Multi server support in one jar
* Bukkit - Fully supported
* Sponge - Support dropped for now
* A number of functions to use to customize menus
* Asynchronous functions
* Functions use latebinding
* Addons can be written for more functions
* Use conditions with replacers using [EvalEx](https://github.com/uklimaschewski/EvalEx)
Expand All @@ -44,6 +37,9 @@ Designed to make writing menus easy.
* Hopper
* Workbench

## Future features

* Support for sponge

## Use cases

Expand All @@ -59,18 +55,13 @@ Just a few uses for DynamicGui.
* Quests
* Shop
* Staff tools
* Punishments

## Downloads

You can get [development builds from our jenkins.](https://ci.ravenlab.dev/job/DynamicGui/)
You can get [development builds from Github actions](https://github.com/ClubObsidian/DynamicGui/actions/workflows/build.yml) but you will need a Github account.

## Getting Started

### Gui Examples

You can find [gui examples here](https://github.com/ClubObsidian/DynamicGuiExamples).

### Gui Documentation

You find find [gui documentation here](https://dynamicgui.github.io/documentation/).
Expand Down
83 changes: 80 additions & 3 deletions build.gradle
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"
}
}
32 changes: 3 additions & 29 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,13 @@ processResources {
}

shadowJar {
minimize()
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.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'

archiveBaseName.set('DynamicGui')
archiveClassifier.set('')
archiveBaseName.set('DynamicGui-Bukkit')
}

dependencies {
implementation project(path: ':core')
compileOnly 'com.github.clubobsidian:foundry:2.0.1'
compileOnly 'com.github.clubobsidian:foundry:2.0.2'
compileOnly 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
compileOnly 'net.md-5:bungeecord-api:1.8-SNAPSHOT'
implementation "cloud.commandframework:cloud-paper:$cloudVersion"
}
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);
}
}
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;
}
}
Loading

0 comments on commit cb3caab

Please sign in to comment.