Image for post
Image for post

So I recently decided to play around with web components. Polymer is kind of the goto there; giving you some useful patterns you remember from Vue, Angular, React and other similar libraries. At first glance, the threshold for using Polymer — especially with its seemingly weird in-between-components-communications via attributes presented in the official “get started”-tutorials — was rather high. So I figured I’d go wild and do a small minimal view library myself; inspired mostly by Vue.

My kind of boilerplate requirements for the “library” was:

  • “Dumb isolated components”. No passed in data via attributes/props, only identifiers to retrieve data…

I boken “Svenska adelns ättar-taflor” från Gabirel Angrep kan man läsa följande om adelsätten Skraggensköld;

Om Skraggeslägtens upphof är den berättelse, att då en Konung i Skottland blifvit af sina fiender fördrifven och med ett skepp kommit till en obebodd ö, hvarpå ej annat funnits än vilda getter, skall Konungen, i behof af föda, utlofvat belöning åt den, som först fasttog en bock. Detta skall stamfadern till nämnde slägt hafva verkställt, och till följe deraf fått namnet Skragge, som på Skottska betyder Bock, likasom Skram Get, samt sedermera blifvit begåfvad med godset Kragie. …

The Spigot/Bukkit API does not expose an event to which you can react to jumps. When creating my MushPoof plugin for Minecraft, I needed a way to detect it.

After some investigation, I noticed that when a user is not jumping, the Y value of the velocity object is constant at -0.0784000015258789.

So I’ve set this as a variable in my file;

final double STILL = -0.0784000015258789;

Then, we need to listen to the PlayerMoveEvent. And in this, we check that the Y value of the velocity of the player is bigger than the STILL variable defined above;

public void onPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();
boolean isJumping = player.getVelocity().getY() > STILL;

Jeremy Karlsson

Scripting connoisseur at TIDAL. Writing the web app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store