Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
brenoepics committed Jan 16, 2022
0 parents commit b7981f1
Show file tree
Hide file tree
Showing 11 changed files with 489 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
target/*
!target/MentionPlugin-*-jar-with-dependencies.jar
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# PrizePlugin

Working with Arcturus Morningstar 3.0.0

## How to use?
you just need to send:
```:prize <username>```

- update prize list with :update_prize [x]
- Prize per level (credits, diamonds, duckets, points, badge, furni...)[x]
- Kick user [x]
- User won event BubbleAlert[x]
- Discord logging [x]

## How can i install it?

1. Download a pre-compiled version. [PrizePlugin](https://github.com/brenoepics/PrizePlugin/releases/)
2. Run the sql and add badges/texts.
3. Paste the PrizePlugin-1.0-jar-with-dependencies.jar file into your emulator's plugins folder and start/restart the emulator.
4. Now you need to give permission for your staffs to use prize command, to do it open your database in the permissions table, and change the permissions cmd_prize and cmd_update_prize.
5. Then, open prize_plugin table, and configure rewards.
6. Now, enter your hotel and type: :update_permissions and :update_prize and then try :prize <username>

7. if you want to configure webhooks check [Config webhook](#Discord)

## configuration

<b>OBS: the level -1 is the default reward if there's none on user's level.</b>

Permissions:

| Key | Default Value |
|----------------------|---------------|
| cmd_prize | 0 |
| cmd_update_prize | 0 |

## Discord
![print](https://imgur.com/4VgDJ5c.png)
1. Open your emulator_settings, and change the key `prizeplugin.logging_discord` to 1.
2. Go to the discord channel, Click the gear icon (Edit Channel) of the channel you want to post to.
3. Click Webhooks in the left menu.
4. Click the Create Webhook button.
5. Enter a Name of your choice.
6. Click the Copy button of the Webhook URL.
7. Click the Save button.
8. Paste the Webhook URL into emulator_settings, key `prizeplugin.logging.discord-webhook.url`


My Discord: BrenoEpic#9671
70 changes: 70 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.brenoepic</groupId>
<artifactId>PrizePlugin</artifactId>
<version>1.0</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.brenoepic.PrizePlugin</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>

</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.eu.habbo</groupId>
<artifactId>Habbo</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.brenoepics</groupId>
<artifactId>discord-webhooks</artifactId>
<version>0.2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

</project>
83 changes: 83 additions & 0 deletions src/main/java/com/brenoepic/PrizePlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.brenoepic;

import com.brenoepic.command.UpdateLevelsCommand;
import com.brenoepic.level.LevelManager;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.CommandHandler;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.plugin.EventHandler;
import com.eu.habbo.plugin.EventListener;
import com.eu.habbo.plugin.HabboPlugin;
import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent;


import com.brenoepic.command.PrizeCommand;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class PrizePlugin extends HabboPlugin implements EventListener {

PrizePlugin INSTANCE;
public static final Logger LOGGER = LoggerFactory.getLogger(PrizePlugin.class);
public static LevelManager levels;

public void onEnable(){
Emulator.getPluginManager().registerEvents(this, this);
INSTANCE = this;
LOGGER.info("[prizeplugin 1.0] was successfully Loaded! Discord: BrenoEpic#9671");
}

public void onDisable(){

}

public boolean hasPermission(Habbo habbo, String s) {
return false;
}

@EventHandler
public void onEmulatorLoaded(EmulatorLoadedEvent event){
levels = new LevelManager();
// Load texts
Emulator.getTexts().register("commands.description.cmd_prize", ":prize <username>");
Emulator.getTexts().register("commands.description.cmd_update_prize", ":update_prize");
Emulator.getTexts().register("commands.keys.cmd_update_prize", "update_prize");
Emulator.getTexts().register("commands.keys.cmd_prize", "prize");
Emulator.getTexts().register("commands.cmd_prize.none", "Missing the winning username!");
Emulator.getTexts().register("commands.cmd_prize.not-found", "User not found or offline!!");
Emulator.getTexts().register("commands.cmd_prize.not-self", "You can't reward yourself!");
Emulator.getTexts().register("commands.cmd_prize.successfully", "You have successfully awarded user %USERNAME%!");
Emulator.getTexts().register("commands.cmd_prize.update-successfully", "You have successfully updated rewards!");
Emulator.getTexts().register("commands.cmd_prize.update-error", "Oops, Something went wrong!");
Emulator.getTexts().register("prizeplugin.bubblealert-message", "The user %WINNER% won an event");
Emulator.getTexts().register("prizeplugin.webhook-message", "The user %WINNER% won an event and reached level %LEVEL%");

Emulator.getTexts().register("prizeplugin.webhook.title", "A user has just won an event!");

// Load config
Emulator.getConfig().register("prizeplugin.webhook.hotel-url", "https://habbo.com");
Emulator.getConfig().register("prizeplugin.prize_badge-prefix", "LVL");
Emulator.getConfig().register("prizeplugin.bubblealert-image", "${image.library.url}notifications/fig/%LOOK%.png");
Emulator.getConfig().register("prizeplugin.webhook-thumbnail", "https://habbo.com/habbo-imaging/avatarimage?figure=%LOOK%&head_direction=4&headonly=1");
Emulator.getConfig().register("prizeplugin.prize_level.type", "504");
Emulator.getConfig().register("prizeplugin.kickonwin", "1");

Emulator.getConfig().register("prizeplugin.logging_discord", "0");
Emulator.getConfig().register("prizeplugin.logging.discord-webhook.url", "DISCORDWEBHOOKURL");


// Commands
CommandHandler.addCommand(new PrizeCommand("cmd_prize", Emulator.getTexts().getValue("commands.keys.cmd_prize").split(";")));
CommandHandler.addCommand(new UpdateLevelsCommand("cmd_update_prize", Emulator.getTexts().getValue("commands.keys.cmd_update_prize").split(";")));

}

public static LevelManager getLevels(){
return levels;
}

public static void main(String[] args) {
System.out.println("Hello world!");
}

}
60 changes: 60 additions & 0 deletions src/main/java/com/brenoepic/command/PrizeCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.brenoepic.command;

import com.brenoepic.PrizePlugin;
import com.brenoepic.utils.Functions;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;


import static com.eu.habbo.Emulator.*;


public class PrizeCommand extends Command {

public PrizeCommand(String permission, String[] keys)
{
super(permission, keys);
}

@Override
public boolean handle(GameClient gameClient, String[] params)
{
if (params.length < 2){
gameClient.getHabbo().whisper(getTexts().getValue("commands.cmd_prize.none"));
return false;
}else{

Habbo habbo = getGameEnvironment().getHabboManager().getHabbo(params[1]);
if(habbo == null){
gameClient.getHabbo().whisper(getTexts().getValue("commands.cmd_prize.not-found"));
return false;
}

if (habbo == gameClient.getHabbo()) {
gameClient.getHabbo().whisper(getTexts().getValue("commands.cmd_prize.not-self"));
return false;
}
final int level = habbo.getHabboInfo().getCurrencyAmount(getConfig().getInt("prizeplugin.prize_level.type", 504));
final int NewLevel = (level + 1);

boolean rewarded = PrizePlugin.getLevels().giveReward(habbo.getHabboInfo().getId(), NewLevel);

getGameServer().getGameClientManager().sendBroadcastResponse(new BubbleAlertComposer("prizeplugin", Functions.BubbleAlert(habbo)));

final Room room = habbo.getHabboInfo().getCurrentRoom();
if (room != null && getConfig().getBoolean("prizeplugin.kickonwin")) {
room.kickHabbo(habbo.getHabboInfo().getCurrentRoom().getHabbo(habbo.getHabboInfo().getUsername()), false);
}
if(rewarded) {
gameClient.getHabbo().whisper(getTexts().getValue("commands.cmd_prize.successfully").replace("%USERNAME%", habbo.getHabboInfo().getUsername()));
Functions.DiscordEmbed(habbo, gameClient.getHabbo());
}else{
gameClient.getHabbo().whisper(getTexts().getValue("commands.cmd_prize.update-error"));
}
}
return true;
}
}
32 changes: 32 additions & 0 deletions src/main/java/com/brenoepic/command/UpdateLevelsCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.brenoepic.command;

import com.brenoepic.PrizePlugin;
import com.brenoepic.utils.Functions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;


import static com.eu.habbo.Emulator.*;


public class UpdateLevelsCommand extends Command {

public UpdateLevelsCommand(String permission, String[] keys)
{
super(permission, keys);
}

@Override
public boolean handle(GameClient gameClient, String[] params)
{
boolean loaded = PrizePlugin.getLevels().load();
if(loaded)
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.cmd_prize.update-successfully"));
else gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.cmd_prize.update-error"));
return true;
}
}
51 changes: 51 additions & 0 deletions src/main/java/com/brenoepic/level/Level.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.brenoepic.level;

import java.sql.ResultSet;
import java.sql.SQLException;

public class Level
{
private final int level;
private final int credits;
private final int diamonds;
private final int pixels;
private final int points;
private final int points_type;
private final int furni;
public Level(final ResultSet result) throws SQLException {
this.level = result.getInt("level");
this.credits = result.getInt("credits");
this.diamonds = result.getInt("diamonds");
this.points = result.getInt("points");
this.points_type = result.getInt("points_type");
this.furni = result.getInt("item");
this.pixels = result.getInt("pixels");
}

public int getLevel() {
return this.level;
}

public int getCredits() {
return this.credits;
}

public int getDiamonds() {
return this.diamonds;
}

public int getPixels(){
return this.pixels;
}
public int getPoints() {
return this.points;
}

public int getPointsType() {
return this.points_type;
}

public int getFurniture() {
return this.furni;
}
}
Loading

0 comments on commit b7981f1

Please sign in to comment.