Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/staging' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed Jun 28, 2020
2 parents 3109d8a + dc74c0a commit 39c142e
Show file tree
Hide file tree
Showing 38 changed files with 155 additions and 1,032 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
os: linux
language: java
sudo: required
dist: bionic
dist: focal
jdk:
- openjdk11

Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 4.7.0 - I'll be there someday (28/06/2020)

This update focuses on updating Chimera to support Spigot 1.16.1.

### Commons

- Add `ClientSuggstionProvider.BIOMES`
- Change `NativeMapper` to `SpigotMapper`
- Fix `PointType.CUBIC` displaying 2D coordinates
- Remove `com.karuslabs.commons.command.synchronization.*` - See https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/675/overview

### Scribe Annotations

- Add `com.karuslabs.scribe.annotations.Version.V1_16`


## 4.6.1 - When the road looks rough ahead (03/06/2020)

This update focuses on fixing an issue with code generated using command annotations.
Expand All @@ -6,6 +22,7 @@ This update focuses on fixing an issue with code generated using command annotat
- Add `Literal(String, Execution<CommandSender>, Predicate<CommandSender>)`
- Fix issue with the generic type of generated local variables not being inferable


## 4.6.0 - Boy, and as the years go by (01/06/2020)

This update focuses on introducing compile-time command annotations in addition
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Karus Labs' mono-repository for spigot libraries & tools.

| Chimera Version | Minecraft Version |
|-----------------|-------------------|
| 4.7.0 | 1.16.1 |
| 4.6.1 | 1.15.2 |
| 4.5.0 | 1.15.2 |
| 4.4.0 | 1.15 - 1.15.2 |
Expand All @@ -39,72 +40,72 @@ Karus Labs' mono-repository for spigot libraries & tools.
#### Annotations - Contains general purpose annotations
[![releases-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-releases/com/karuslabs/chimera/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-releases/com/karuslabs/annotations/)
[![snapshots-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-snapshots/com/karuslabs/chimera/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-snapshots/com/karuslabs/annotations/)
[![javadoc](https://img.shields.io/badge/javadoc-4.6.1-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.6.1/annotations/apidocs/index.html)
[![javadoc](https://img.shields.io/badge/javadoc-4.7.0-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.7.0/annotations/apidocs/index.html)
```XML
<dependency>
<groupId>com.karuslabs</groupId>
<artifactId>annotations</artifactId>
<version>4.6.1</version>
<version>4.7.0</version>
</dependency>
```

***
#### Commons - Contains the command framework and other common utilities for Spigot plugin development
[![releases-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-releases/com/karuslabs/chimera/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-releases/com/karuslabs/commons)
[![snapshots-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-snapshots/com/karuslabs/chimera/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-snapshots/com/karuslabs/commons)
[![javadoc](https://img.shields.io/badge/javadoc-4.6.1-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.6.1/commons/apidocs/index.html)
[![javadoc](https://img.shields.io/badge/javadoc-4.7.0-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.7.0/commons/apidocs/index.html)
```XML
<dependency>
<groupId>com.karuslabs</groupId>
<artifactId>commons</artifactId>
<version>4.6.1</version>
<version>4.7.0</version>
</dependency>
```

***
#### Scribe Annotations - Contains annotations that other scribe projects use to generate a plugin.yml
[![releases-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-releases/com/karuslabs/scribe-annotations/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-releases/com/karuslabs/scribe-annotations)
[![snapshots-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-snapshots/com/karuslabs/scribe-annotations/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-snapshots/com/karuslabs/scribe-annotations)
[![javadoc](https://img.shields.io/badge/javadoc-4.6.1-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.6.1/scribe/scribe-annotations/apidocs/index.html)
[![javadoc](https://img.shields.io/badge/javadoc-4.7.0-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.7.0/scribe/scribe-annotations/apidocs/index.html)

```XML
<dependency>
<groupId>com.karuslabs</groupId>
<artifactId>scribe-annotations</artifactId>
<version>4.6.1</version>
<version>4.7.0</version>
</dependency>
```

***
#### Scribe Standalone - Standalone annotation processor that generates a plugin.yml
[![releases-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-releases/com/karuslabs/scribe-standalone/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-releases/com/karuslabs/scribe-standalone)
[![snapshots-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-snapshots/com/karuslabs/scribe-standalone/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-snapshots/com/karuslabs/scribe-standalone)
[![javadoc](https://img.shields.io/badge/javadoc-4.6.1-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.6.1/scribe/scribe-standalone/apidocs/index.html)
[![javadoc](https://img.shields.io/badge/javadoc-4.7.0-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.7.0/scribe/scribe-standalone/apidocs/index.html)
```XML
<!-- Standalone annotation processor, provides scribe-annotations as a transitive dependency -->
<dependency>
<groupId>com.karuslabs</groupId>
<artifactId>scribe-standalone</artifactId>
<version>4.6.1</version>
<version>4.7.0</version>
</dependency>
```

***
#### Scribe Maven Plugin - Maven plugin that generates a plugin.yml and infers values from a project's pom.xml
[![releases-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-releases/com/karuslabs/scribe-maven-plugin/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-releases/com/karuslabs/scribe-maven-plugin)
[![snapshots-maven](https://img.shields.io/maven-metadata/v/https/repo.karuslabs.com/repository/chimera-snapshots/com/karuslabs/scribe-maven-plugin/maven-metadata.xml.svg)](https://repo.karuslabs.com/service/rest/repository/browse/chimera-snapshots/com/karuslabs/scribe-maven-plugin)
[![javadoc](https://img.shields.io/badge/javadoc-4.6.1-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.6.1/scribe/scribe-maven-plugin/apidocs/index.html)
[![javadoc](https://img.shields.io/badge/javadoc-4.7.0-brightgreen.svg)](https://repo.karuslabs.com/repository/chimera/4.7.0/scribe/scribe-maven-plugin/apidocs/index.html)
```XML
<dependency>
<groupId>com.karuslabs</groupId>
<artifactId>scribe-annotations</artifactId>
<version>4.6.1</version>
<version>4.7.0</version>
</dependency>

<plugin>
<groupId>com.karuslabs</groupId>
<artifactId>scribe-maven-plugin</artifactId>
<version>4.6.1</version>
<version>4.7.0</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.karuslabs</groupId>
<artifactId>chimera</artifactId>
<version>4.6.1</version>
<version>4.7.0</version>
</parent>

<artifactId>annotations</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.karuslabs</groupId>
<artifactId>chimera</artifactId>
<version>4.6.1</version>
<version>4.7.0</version>
</parent>

<artifactId>commons</artifactId>
Expand All @@ -25,7 +25,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.15-R0.1-SNAPSHOT</version>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
public enum ClientSuggestionProvider implements SuggestionProvider<CommandSender> {

ENTITIES, RECIPES, SOUNDS;
BIOMES, ENTITIES, RECIPES, SOUNDS;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package com.karuslabs.commons.command.dispatcher;

import com.karuslabs.commons.command.synchronization.*;
import com.karuslabs.commons.command.tree.nodes.Root;
import com.karuslabs.commons.command.tree.TreeWalker;
import com.karuslabs.commons.command.tree.nodes.Literal;
Expand All @@ -33,10 +32,10 @@

import java.util.Map;

import net.minecraft.server.v1_15_R1.*;
import net.minecraft.server.v1_16_R1.*;

import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
import org.bukkit.craftbukkit.v1_15_R1.command.CraftCommandMap;
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
import org.bukkit.craftbukkit.v1_16_R1.command.CraftCommandMap;

import org.bukkit.Server;
import org.bukkit.command.CommandSender;
Expand All @@ -57,16 +56,13 @@
* This dispatcher holds a reference to the internal dispatcher of the server. The
* internal dispatcher is flushed after all plugins are enabled when the server
* is either started or reloaded. In both cases, this dispatcher and the internal
* dispatcher are synchronized automatically. After synchronization between this
* dispatcher and the internal dispatcher, the internal dispatcher and clients are
* then also automatically synchronized via a {@link Synchronizer}.
* dispatcher are synchronized automatically.
*/
public class Dispatcher extends CommandDispatcher<CommandSender> implements Listener {

private MinecraftServer server;
private Root root;
CommandDispatcher<CommandListenerWrapper> dispatcher;
Synchronizer synchronizer;
TreeWalker<CommandSender, CommandListenerWrapper> walker;


Expand All @@ -80,20 +76,13 @@ public static Dispatcher of(Plugin plugin) {
var prefix = plugin.getName().toLowerCase();
var server = ((CraftServer) plugin.getServer());

var synchronizer = Synchronizer.of(plugin);

var map = new SpigotMap(prefix, plugin, (CraftCommandMap) server.getCommandMap());
var root = new Root(prefix, map);
var dispatcher = new Dispatcher(server, root, synchronizer);
var dispatcher = new Dispatcher(server, root);
map.dispatcher = dispatcher;

server.getPluginManager().registerEvents(dispatcher, plugin);

var listener = new PulseListener(synchronizer, plugin);
listener.register();

server.getPluginManager().registerEvents(listener, plugin);

return dispatcher;
}

Expand All @@ -105,15 +94,13 @@ public static Dispatcher of(Plugin plugin) {
*
* @param server the server
* @param root the root for this dispatcher
* @param synchronizer the synchronizer
*/
protected Dispatcher(Server server, Root root, Synchronizer synchronizer) {
protected Dispatcher(Server server, Root root) {
super(root);
this.root = root;
this.server = ((CraftServer) server).getServer();
this.dispatcher = this.server.commandDispatcher.a();
this.synchronizer = synchronizer;
this.walker = new TreeWalker<>(new NativeMapper(this));
this.dispatcher = this.server.getCommandDispatcher().a();
this.walker = new TreeWalker<>(new SpigotMapper(this));
}


Expand Down Expand Up @@ -142,7 +129,9 @@ public Literal<CommandSender> register(Literal.Builder<CommandSender> command) {
*/
public void update() {
walker.prune(dispatcher.getRoot(), getRoot().getChildren());
synchronizer.synchronize();
for (var player : server.server.getOnlinePlayers()) {
player.updateCommands();
}
}


Expand All @@ -154,7 +143,7 @@ public void update() {
*/
@EventHandler
protected void update(ServerLoadEvent event) {
dispatcher = server.commandDispatcher.a();
dispatcher = server.getCommandDispatcher().a();
walker.prune(dispatcher.getRoot(), getRoot().getChildren());
}

Expand All @@ -163,15 +152,5 @@ protected void update(ServerLoadEvent event) {
public Root getRoot() {
return root;
}


/**
* Returns a {@code Synchronizer}.
*
* @return a {@code Synchronizer}
*/
public Synchronizer synchronizer() {
return synchronizer;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

import com.mojang.brigadier.exceptions.CommandSyntaxException;

import net.minecraft.server.v1_15_R1.*;
import net.minecraft.server.v1_16_R1.*;

import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
import org.bukkit.craftbukkit.v1_15_R1.command.*;
import org.bukkit.craftbukkit.v1_15_R1.entity.*;
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
import org.bukkit.craftbukkit.v1_16_R1.command.*;
import org.bukkit.craftbukkit.v1_16_R1.entity.*;

import org.bukkit.command.*;
import org.bukkit.entity.Player;
Expand All @@ -56,7 +56,7 @@
/**
* Reports the given exception to the {@code sender}.
*
* Source: net.minecraft.server.CommandDispatcher #line: 187
* Source: net.minecraft.server.CommandDispatcher #line: 188
*
* @param sender the sender
* @param exception the exception
Expand All @@ -70,28 +70,23 @@ static void report(CommandSender sender, CommandSyntaxException exception) {
if (input != null && exception.getCursor() >= 0) {
var index = Math.min(input.length(), exception.getCursor());

var text = new ChatComponentText("");
var text = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format(modifier ->
modifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, input))
);

if (index > 10) {
text.a("...");
text.c("...");
}

text.a(input.substring(Math.max(0, index - 10), index));
text.c(input.substring(Math.max(0, index - 10), index));

if (index < input.length()) {
var error = new ChatComponentText(input.substring(index));
error.getChatModifier().setColor(EnumChatFormat.RED);
error.getChatModifier().setUnderline(true);

var error = new ChatComponentText(input.substring(index)).a(new EnumChatFormat[]{EnumChatFormat.RED, EnumChatFormat.UNDERLINE});
text.addSibling(error);
}

var context = new ChatMessage("command.context.here", EMPTY);
context.getChatModifier().setItalic(true);
context.getChatModifier().setColor(EnumChatFormat.RED);

var context = new ChatMessage("command.context.here").a(new EnumChatFormat[]{EnumChatFormat.RED, EnumChatFormat.ITALIC});
text.addSibling(context);
text.getChatModifier().setColor(EnumChatFormat.GRAY);
text.getChatModifier().setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, input));

listener.sendFailureMessage(text);
}
Expand All @@ -101,27 +96,34 @@ static void report(CommandSender sender, CommandSyntaxException exception) {
/**
* Reports the given exception to the {@code sender}.
*
* Source: net.minecraft.server.CommandDispatcher #line: 212
* Source: net.minecraft.server.CommandDispatcher #line: 213
*
* @param sender the sender
* @param exception the exception
*/
//
static void report(CommandSender sender, Exception exception) {
var listener = from(sender);

var message = exception.getMessage();
var details = new ChatComponentText(message == null ? exception.getClass().getName() : message);
var details = new ChatComponentText(message == null ? exception.getClass().getName() : message);

// We send the stacktrace regardless of whether debug is enabled since we
// cannot access the CommandDispatcher's logger.
var stacktrace = exception.getStackTrace();
for (int i = 0; i < Math.min(stacktrace.length, 3); i++) {
details.a("\n\n" + stacktrace[i].getMethodName() + "\n " + stacktrace[i].getFileName() + ":" + stacktrace[i].getLineNumber());
var element = stacktrace[i];
details.c("\n\n").c(element.getMethodName()).c("\n ").c(element.getFileName()).c(":").c(String.valueOf(element.getLineNumber()));
}

var failure = new ChatMessage("command.failed", EMPTY);
failure.getChatModifier().setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, details));

var failure = new ChatMessage("command.failed").format(modifier ->
modifier.setChatHoverable(new ChatHoverable(ChatHoverable.EnumHoverAction.SHOW_TEXT, details))
);
listener.sendFailureMessage(failure);

if (SharedConstants.d) {
listener.sendFailureMessage(new ChatComponentText(SystemUtils.d(exception)));
// We do not log the error since we cannot access the logger
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.bukkit.command.*;
import org.bukkit.plugin.Plugin;

import org.bukkit.craftbukkit.v1_15_R1.command.CraftCommandMap;
import org.bukkit.craftbukkit.v1_16_R1.command.CraftCommandMap;

import org.checkerframework.checker.nullness.qual.Nullable;

Expand Down
Loading

0 comments on commit 39c142e

Please sign in to comment.