Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
shuoros committed Jul 9, 2022
2 parents 57eadc6 + 6705b58 commit 2916b26
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 102 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<p align="center">If you are tired of coding, invite Pepe to throw a party in your terminal!</p>
</p>
<p align="center">
<img style="height: 500px" src="https://user-images.githubusercontent.com/45015114/177473188-f355fa59-585b-4ebe-b70b-4ac7c1c82c7e.gif" alt="dancing pepe" />
<img width="200" src="https://user-images.githubusercontent.com/45015114/177473188-f355fa59-585b-4ebe-b70b-4ac7c1c82c7e.gif" alt="dancing pepe" />
</p>
<h4 align="center">Powered by</h4>
<p align="center">
Expand All @@ -13,11 +13,14 @@
</a>
</p>
<p align="center">
<a href="https://github.com/TheXSolutions/badgify/search?l=java">
<img src="https://badgify.thex.solutions/api/badge/link?title=8&icon=java&size=m&bg=random" />
</a>
<a href="https://github.com/TheXSolutions/badgify/blob/main/LICENSE">
<img src="https://badgify.thex.solutions/api/badge/link?title=MIT&icon=scale-balanced&size=m&bg=random" />
<a href="https://github.com/shuoros/pepe-party">
<img src="https://badgify.thex.solutions/api/badge/link?title=pepe-party-v1.1.0&icon=github&size=m&bg=orange" />
</a>
<a href="https://github.com/shuoros/pepe-party/search?l=java">
<img src="https://badgify.thex.solutions/api/badge/link?title=8&icon=java&size=m&bg=yellow" />
</a>
<a href="https://github.com/shuoros/pepe-party/blob/main/LICENSE">
<img src="https://badgify.thex.solutions/api/badge/link?title=MIT&icon=scale-balanced&size=m&bg=lavender" />
</a>
</p>
<p align="center">
Expand Down Expand Up @@ -70,7 +73,7 @@ pepe-party
```

## Quit
You can quit the party by either hitting `Esc` or `Ctrl+C`.
You can quit the party by hitting `Ctrl+C`.

## Authors
The `Pepe Party` is developed by [Soroush Shemshadi](https://shuoros.github.io) and the [contributors](https://github.com/shuoros/pepe-party/blob/main/CONTRIBUTORS.md).
Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.shuoros</groupId>
<artifactId>pepe-party</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
<packaging>jar</packaging>
<name>pepe-party</name>
<description>If you are tired of coding, invite Pepe to throw a party in your terminal.</description>
Expand Down Expand Up @@ -47,11 +47,6 @@
</properties>

<dependencies>
<dependency>
<groupId>com.1stleg</groupId>
<artifactId>jnativehook</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>io.github.shuoros</groupId>
<artifactId>JTerminal</artifactId>
Expand Down
15 changes: 7 additions & 8 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: pepe-party-party
version: '1.0.0'
name: pepe-party
version: '1.1.0'
summary: Invite pepe-party to your terminal!
description: |
If you are tired of coding, invite Pepe to throw a party in your terminal.!
To invite Pepe, run "pepe" command in your terminal!
To invite Pepe, run "pepe-party" command in your terminal!
To quit the party either hit "Esc" or "Ctrl+C"
Have fun:D!
Homepage: https://github.com/shuoros/pepe-party
title: Pepe Party
website: https://github.com/shuoros/pepe-party-party
website: https://github.com/shuoros/pepe-party
contact: [email protected]
issues: https://github.com/shuoros/pepe-party-party/issues
icon: ./icon.png
issues: https://github.com/shuoros/pepe-party/issues
license: MIT

base: core18
Expand All @@ -21,12 +20,12 @@ confinement: strict

apps:
pepe-party:
command: bin/java -jar $SNAP/jar/pepe-party-party-$SNAP_VERSION-jar-with-dependencies.jar
command: bin/java -jar $SNAP/jar/pepe-party-$SNAP_VERSION-jar-with-dependencies.jar

parts:
pepe-party:
plugin: maven
source: https://github.com/shuoros/pepe-party-party.git
source: https://github.com/shuoros/pepe-party.git
source-tag: main
source-type: git
maven-options: [-DskipTests]
Expand Down
89 changes: 8 additions & 81 deletions src/main/java/com/github/shuoros/pepeParty/PepeParty.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package com.github.shuoros.pepeParty;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;

import com.github.shuoros.pepeParty.model.Frame;
import com.github.shuoros.pepeParty.util.EntityLoader;
import com.github.shuoros.pepeParty.util.FrameLoader;
import io.github.shuoros.jterminal.JTerminal;
import io.github.shuoros.jterminal.util.TextEntity;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;

import com.github.shuoros.pepeParty.model.Frame;
import com.github.shuoros.pepeParty.util.FrameLoader;
import java.util.ArrayList;
import java.util.List;

/**
* If you are tired of life, invite Pepe to throw a party in your terminal.
Expand All @@ -24,19 +16,17 @@
* @version 0.1.0
* @since 0.1.0
*/
public class PepeParty implements NativeKeyListener {
public class PepeParty {

private static List<Frame> frames = new ArrayList<>();
private static List<List<TextEntity>> entities = new ArrayList<>();
private static int frameIndex = 0;
private static String currentFrame;
private static List<TextEntity> currentEntity;
private static boolean shutdown = false;

/**
* Application runner. First it load the frames by
* {@link com.github.shuoros.pepeParty.util.FrameLoader} then register the
* {@link org.jnativehook.keyboard.NativeKeyListener} and then call the
* Application runner. First it loads the frames by
* {@link com.github.shuoros.pepeParty.util.FrameLoader} and then call the
* {@code run()} to run the party.
*
* @param args Command line arguments.
Expand All @@ -45,8 +35,6 @@ public static void main(String[] args) {
frames = FrameLoader.load("frames.files");
entities = EntityLoader.load("entities.files");

registerKeyListener();

run();
}

Expand Down Expand Up @@ -82,7 +70,7 @@ private static void create(int frameIndex) {
* Render the {@code currentFrame} on terminal.
*/
private static void render() {
JTerminal.println(currentFrame, currentEntity);
JTerminal.println(currentFrame, currentEntity);
}

/**
Expand All @@ -94,12 +82,6 @@ private static void render() {
* @param wait Time duration between two frames.
*/
private static void dispose(int wait) {
if (shutdown) {
JTerminal.clear();
unRegisterKeyListener();
System.exit(0);
}

frameIndex++;

if (frameIndex >= frames.size()) {
Expand All @@ -109,59 +91,4 @@ private static void dispose(int wait) {
JTerminal.clear(wait);
}

/**
* Register the {@link org.jnativehook.keyboard.NativeKeyListener} to screen and
* turn off {@link org.jnativehook.keyboard.NativeKeyListener} logs.
*/
private static void registerKeyListener() {
LogManager.getLogManager().reset();
Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
logger.setLevel(Level.OFF);

try {
GlobalScreen.registerNativeHook();
} catch (NativeHookException ex) {
System.err.println("There was a problem registering the native hook.");
System.err.println(ex.getMessage());
System.exit(1);
}

GlobalScreen.addNativeKeyListener(new PepeParty());

}

private static void unRegisterKeyListener(){
try {
GlobalScreen.unregisterNativeHook();
}
catch (NativeHookException ex) {
ex.printStackTrace();
}
}

/**
* There is no need to KeyPressed event.
*/
@Override
public void nativeKeyPressed(NativeKeyEvent e) {
}

/**
* If escape button pressed and released turn shut down to {@code true} and exit
* the application.
*/
@Override
public void nativeKeyReleased(NativeKeyEvent e) {
if (e.getKeyCode() == NativeKeyEvent.VC_ESCAPE) {
shutdown = true;
}
}

/**
* There is no need to KeyTyped event.
*/
@Override
public void nativeKeyTyped(NativeKeyEvent e) {
}

}

0 comments on commit 2916b26

Please sign in to comment.