Skip to content

Commit

Permalink
Merge pull request #39 from PXAV/development
Browse files Browse the repository at this point in the history
Changes for release 0.1.0 - "The sidebar update"
  • Loading branch information
PXAV committed Jan 28, 2021
2 parents a5804a5 + d39e8a8 commit bd6cf65
Show file tree
Hide file tree
Showing 52 changed files with 1,752 additions and 1,062 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG/kelp-v0.1.0.md
@@ -0,0 +1,23 @@
# v0.1.0
> Release date: 28.01.2021
**The sidebar update**:
* Rework sidebar system:
* The old, annotation-based sidebar system using `@CreateSidebar` is not available anymore. Plugins that have been using this system will have to upgrade.
* Rework component system (stateful & stateless)
* Add new component `StatefulListComponent` to display dynamic lists in sidebars
* Developers can now choose between lazy updating (manipulating team prefixes, flicker free) or normal updating (resetting the scoreboard), which was not possible with the old system.
* Move version dependent scoreboard code out of the core module to the version modules (scoreboard team handling, etc.)
* Rework animation system by replacing it with a cluster-based system
* Add new events for handling sidebars:
* `KelpSidebarRenderEvent`
* `KelpSidebarUpdateEvent`
* `KelpSidebarRemoveEvent`
* Create new event base: `KelpPlayerEvent`, which should replace the `PlayerEvent` for better integration of `KelpPlayer` into event handling. So if you create anything player-related with custom events, use this class instead.
* Sidebar components and sidebar objects are now created using static factory methods. If you like the old approach more, you can still rely on the old factory classes such as `SidebarComponentFactory`
* Sidebars can now be properly removed/hidden from a player
* Documentation improvements in `KelpPlayer` and all newly added classes.
* `TextAnimations` can now be created using static factory methods.
* Add `ksidebar` command in testing-module to demonstrate some sidebar components.
* Refactor testing-module by assigning dedicated packages to each feature to test
* Fix bug that `TimeConverter` did not convert milliseconds <-> ticks correctly
20 changes: 8 additions & 12 deletions README.md
Expand Up @@ -93,7 +93,8 @@ playerConnection.sendPacket(spawnPacket);
- **Particle engine:** Easily create custom and prebuilt particle effects
- **Schedulers**: Create sync and async schedulers and make use of powerful thread synchronization tools
- **Events**: Custom events for NPCs, Inventories and more as well as new listener techniques

- **Prompts**: Interact with your player by prompting input from chat, anvils ans signs.
- **and more** to discover in the [Wiki](https://github.com/PXAV/kelp/wiki)


## Support & Requirements
Expand All @@ -119,28 +120,23 @@ There are version implementations for the following version implementations avai

## Downloading

#### Maven
### Maven
```xml
<dependency>
<groupId>com.github.pxav.kelp</groupId>
<artifactId>core</artifactId>
<version>0.0.4</version>
<version>0.1.0</version>
</dependency>
```

### Gradle
```shell script
implementation 'com.github.pxav.kelp:core:0.0.4'
compile group: 'com.github.pxav.kelp', name: 'core', version: '0.1.0'
```

### Bazel
```shell script
maven_jar(
name = "core",
artifact = "com.github.pxav.kelp:core:0.0.4",
sha1 = "4743f29c20f3b033de5fe8c1eddb374511fa31d8",
)
```
### Other build tools
The dependency can be found here including suggestions for other build tools.
[Kelp Mavenrepository](https://mvnrepository.com/artifact/com.github.pxav.kelp/core/)

### Pre-built files
If you are a server owner who simply needs the jar files or a developer who does not use a built tool like Maven, you can simply download the pre-built jar files from the [Releaes page](https://github.com/PXAV/kelp/releases). There you can find all versions, but it's recommended to use the latest.
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.github.pxav.kelp</groupId>
<artifactId>parent</artifactId>
<version>0.0.5</version>
<version>0.1.0</version>
</parent>

<modelVersion>4.0.0</modelVersion>
Expand Down
8 changes: 3 additions & 5 deletions core/src/main/java/de/pxav/kelp/core/KelpPlugin.java
Expand Up @@ -35,7 +35,7 @@
*
* @author pxav
*/
@Plugin(name = "Kelp", version = "0.0.4")
@Plugin(name = "Kelp", version = "0.1.0")
@Author("pxav")
@Description("A cross version spigot framework.")
@Singleton
Expand Down Expand Up @@ -100,9 +100,6 @@ public void onEnable() {
injector.getInstance(EventHandlerRegistration.class).initialize(this.getClass().getPackage().getName());
injector.getInstance(KelpEventRepository.class).detectSubscriptions(this.getClass().getPackage().getName());

injector.getInstance(SidebarRepository.class).loadSidebars(this.getClass().getPackage().getName());
injector.getInstance(SidebarRepository.class).schedule();

injector.getInstance(KelpCommandRepository.class).loadCommands(this.getClass().getPackage().getName());

injector.getInstance(KelpNpcRepository.class).startScheduler();
Expand Down Expand Up @@ -130,7 +127,8 @@ public void onDisable() {
injector.getInstance(KelpApplicationRepository.class).disableApplications();

injector.getInstance(KelpNpcRepository.class).stopScheduler();
injector.getInstance(SidebarRepository.class).interruptAnimations();
injector.getInstance(SidebarRepository.class).stopAllClusters();
logger().log("[SIDEBAR] Removed all animation clusters.");
injector.getInstance(ParticleEffectRepository.class).stopAllTimers();
injector.getInstance(KelpSchedulerRepository.class).interruptAll();

Expand Down
@@ -1,5 +1,6 @@
package de.pxav.kelp.core.animation;

import de.pxav.kelp.core.KelpPlugin;
import de.pxav.kelp.core.common.StringUtils;

import java.util.ArrayList;
Expand Down Expand Up @@ -32,6 +33,12 @@ public BuildingTextAnimation(StringUtils stringUtils) {
this.stringUtils = stringUtils;
}

public static BuildingTextAnimation create() {
return new BuildingTextAnimation(
KelpPlugin.getInjector().getInstance(StringUtils.class)
);
}

public BuildingTextAnimation text(String text) {
this.text = text;
return this;
Expand Down
Expand Up @@ -23,6 +23,10 @@ public class CustomTextAnimation implements TextAnimation {

public CustomTextAnimation() {}

public static CustomTextAnimation create() {
return new CustomTextAnimation();
}

public CustomTextAnimation addStates(String... states) {
this.states.addAll(Arrays.asList(states));
return this;
Expand Down
Expand Up @@ -16,8 +16,10 @@ public class FloatingTextAnimation implements TextAnimation {
private boolean slideIn;
private SlideDirection slideDirection;

public FloatingTextAnimation() {
public FloatingTextAnimation() {}

public static FloatingTextAnimation create() {
return new FloatingTextAnimation();
}

public FloatingTextAnimation text(String text) {
Expand Down Expand Up @@ -74,7 +76,6 @@ private List<String> slideAnimation(SlideDirection slideDirection) {

@Override
public List<String> states() {

return Lists.newArrayList();
}

Expand Down
@@ -1,6 +1,5 @@
package de.pxav.kelp.core.animation;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -19,6 +18,10 @@ public final class StaticTextAnimation implements TextAnimation {

StaticTextAnimation() {}

public static StaticTextAnimation create() {
return new StaticTextAnimation();
}

public StaticTextAnimation text(String text) {
this.text = text;
return this;
Expand Down
@@ -0,0 +1,35 @@
package de.pxav.kelp.core.event.kelpevent;

import de.pxav.kelp.core.player.KelpPlayer;
import org.bukkit.event.Event;

/**
* Represents a specific type of event. It is basically a replacement
* class for bukkit's normal {@link org.bukkit.event.player.PlayerEvent}, but
* does not hold a normal {@link org.bukkit.entity.Player} instance. Instead
* the {@code #getPlayer()} method returns a {@link KelpPlayer} to offer better
* integration of custom Kelp events into your plugins. You don't need to
* manually fetch the player anymore with the {@link de.pxav.kelp.core.player.KelpPlayerRepository}
* but can directly retrieve it from the event.
*
* @author pxav
*/
public abstract class KelpPlayerEvent extends Event {

protected KelpPlayer player;

public KelpPlayerEvent(KelpPlayer who) {
this.player = who;
}

/**
* Gets the player who has triggered the event or
* the player who should be handled by this event.
*
* @return The player of this event.
*/
public final KelpPlayer getPlayer() {
return this.player;
}

}
@@ -0,0 +1,32 @@
package de.pxav.kelp.core.event.kelpevent.sidebar;

import de.pxav.kelp.core.event.kelpevent.KelpPlayerEvent;
import de.pxav.kelp.core.player.KelpPlayer;
import org.bukkit.event.HandlerList;

/**
* This event is triggered when any sidebar is removed from a player
* and the corresponding animation schedulers, etc. are stopped. It
* does only handle {@link de.pxav.kelp.core.sidebar.type.KelpSidebar<>} ano
* no default bukkit scoreboards.
*
* @author pxav
*/
public class KelpSidebarRemoveEvent extends KelpPlayerEvent {

private static final HandlerList handlers = new HandlerList();

public KelpSidebarRemoveEvent(KelpPlayer who) {
super(who);
}

public static HandlerList getHandlerList() {
return handlers;
}

@Override
public HandlerList getHandlers() {
return handlers;
}

}
@@ -0,0 +1,43 @@
package de.pxav.kelp.core.event.kelpevent.sidebar;

import de.pxav.kelp.core.event.kelpevent.KelpPlayerEvent;
import de.pxav.kelp.core.player.KelpPlayer;
import de.pxav.kelp.core.sidebar.type.KelpSidebar;
import org.bukkit.event.HandlerList;

/**
* This event is triggered when a {@link KelpSidebar} is rendered to a player,
* which means that the sidebar is displayed to them for the first time.
*
* @author pxav
*/
public class KelpSidebarRenderEvent extends KelpPlayerEvent {

private static final HandlerList handlers = new HandlerList();

private KelpSidebar sidebar;

public KelpSidebarRenderEvent(KelpPlayer who, KelpSidebar sidebar) {
super(who);
this.sidebar = sidebar;
}

public static HandlerList getHandlerList() {
return handlers;
}

/**
* Gets the instance of the sidebar that has been rendered to the player.
*
* @return The current scoreboard object.
*/
public KelpSidebar getSidebar() {
return sidebar;
}

@Override
public HandlerList getHandlers() {
return handlers;
}

}
@@ -0,0 +1,58 @@
package de.pxav.kelp.core.event.kelpevent.sidebar;

import de.pxav.kelp.core.event.kelpevent.KelpPlayerEvent;
import de.pxav.kelp.core.player.KelpPlayer;
import de.pxav.kelp.core.sidebar.type.KelpSidebar;
import org.bukkit.event.HandlerList;

/**
* This event is triggered when any {@link KelpSidebar<>} is updated no
* matter if it is a lazy or normal update. Title updates are not
* included.
*
* @author pxav
*/
public class KelpSidebarUpdateEvent extends KelpPlayerEvent {

private static final HandlerList handlers = new HandlerList();

private boolean lazyUpdate;
private KelpSidebar sidebar;

public KelpSidebarUpdateEvent(KelpPlayer who, KelpSidebar sidebar, boolean lazyUpdate) {
super(who);
this.sidebar = sidebar;
this.lazyUpdate = lazyUpdate;
}

public static HandlerList getHandlerList() {
return handlers;
}

/**
* Checks if the update was performed lazy, which means that
* no scores have been added/deleted from the board.
*
* @return {@code true} if the update was lazy.
*/
public boolean isLazyUpdate() {
return lazyUpdate;
}

/**
* Gets an instance of the scoreboard that has been updated.
* It can be casted to the specific type such as {@link de.pxav.kelp.core.sidebar.type.AnimatedSidebar}
* for example if needed.
*
* @return The current sidebar object.
*/
public KelpSidebar getSidebar() {
return sidebar;
}

@Override
public HandlerList getHandlers() {
return handlers;
}

}

0 comments on commit bd6cf65

Please sign in to comment.