Browse Source

Upload All Files

Upload All Files
master
Juan Molina 1 year ago
parent
commit
b510bf839d
  1. 3
      .gitignore
  2. 36
      pom.xml
  3. 78
      src/main/java/es/publicroom/PublicRoom.java
  4. 30
      src/main/java/es/publicroom/commands/CommandPublicRoom.java
  5. 11
      src/main/java/es/publicroom/core/ReadAll.java
  6. 20
      src/main/java/es/publicroom/core/ReadCommands.java
  7. 20
      src/main/java/es/publicroom/core/ReadTexts.java
  8. 7
      src/main/java/es/publicroom/room/Listener.java
  9. 5
      src/main/resources/plugin.json

3
.gitignore

@ -0,0 +1,3 @@
*.iml
.idea/
target/

36
pom.xml

@ -0,0 +1,36 @@
<?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>es.publicroom</groupId>
<artifactId>publicroom</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>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.eu.habbo</groupId>
<artifactId>Habbo</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
</project>

78
src/main/java/es/publicroom/PublicRoom.java

@ -0,0 +1,78 @@
package es.publicroom;
import com.eu.habbo.Emulator;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static es.publicroom.core.ReadAll.readAll;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class PublicRoom extends HabboPlugin implements EventListener {
public static PublicRoom INSTANCE = null;
public static String name = "PublicRoom Plugin";
public static String author = "Juan Molina (Ouis)";
public static String version = "1.0";
private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class);
@Override
public void onEnable() {
INSTANCE = this;
Emulator.getPluginManager().registerEvents(this, this);
if (Emulator.isReady) {
this.checkDatabase();
LOGGER.info("Detected Plugin `" + name + "` por " + author + " version " + version + "! Support @ Juan Molina (Ouis)");
}
}
@Override
public void onDisable() {
LOGGER.info("Disabled Plugin `" + name + "` por " + author + " version " + version + " -> OK!");
}
@Override
public boolean hasPermission(Habbo habbo, String s) {
return false;
}
private boolean registerPermissions(String name, String options, String defect, boolean returns)
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
try (PreparedStatement statement = connection.prepareStatement("ALTER TABLE `permissions` ADD `" + name +"` ENUM( " + options + " ) NOT NULL DEFAULT '" + defect + "'")) {
statement.execute();
return true;
}
}
catch (SQLException e) {}
return returns;
}
@EventHandler
public static void onEmulatorLoaded(EmulatorLoadedEvent event) throws Exception {
INSTANCE.checkDatabase();
readAll();
LOGGER.info("Plugin "+ name +" version "+ version +" loaded!");
}
public void checkDatabase() {
boolean permissions = false;
permissions = this.registerPermissions("cmd_publicroom", "'0', '1'", "0", permissions);
if (permissions)
Emulator.getGameEnvironment().getPermissionsManager().reload();
}
public static void main(String[] args) {
System.out.println("¡Por favor, mueve este archivo a tu carpeta de plugins!");
}
}

30
src/main/java/es/publicroom/commands/CommandPublicRoom.java

@ -0,0 +1,30 @@
package es.publicroom.commands;
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.RoomChatMessageBubbles;
public class CommandPublicRoom extends Command {
public CommandPublicRoom(String permission, String[] keys)
{
super(permission, keys);
}
@Override
public boolean handle(GameClient client, String[] vars) {
if(client.getHabbo().getRoomUnit().getRoom().isPublicRoom()){
client.getHabbo().getRoomUnit().getRoom().setPublicRoom(false);
client.getHabbo().whisper(Emulator.getTexts().getValue("commands.success.publicroom.disabled"), RoomChatMessageBubbles.ALERT);
}else{
client.getHabbo().getRoomUnit().getRoom().setPublicRoom(true);
client.getHabbo().whisper(Emulator.getTexts().getValue("commands.success.publicroom.enabled"), RoomChatMessageBubbles.ALERT);
}
Emulator.getGameEnvironment().getNavigatorManager().loadNavigator();
Emulator.getGameEnvironment().getRoomManager().loadRoomModels();
return true;
}
}

11
src/main/java/es/publicroom/core/ReadAll.java

@ -0,0 +1,11 @@
package es.publicroom.core;
import com.eu.habbo.Emulator;
import es.publicroom.PublicRoom;
public class ReadAll {
public static void readAll() {
ReadCommands.readCommand();
ReadTexts.readText();
}
}

20
src/main/java/es/publicroom/core/ReadCommands.java

@ -0,0 +1,20 @@
package es.publicroom.core;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.CommandHandler;
import es.publicroom.commands.CommandPublicRoom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReadCommands {
private static final Logger LOGGER = LoggerFactory.getLogger(ReadCommands.class);
public static void readCommand() {
try {
CommandHandler.addCommand(new CommandPublicRoom("cmd_publicroom", Emulator.getTexts().getValue("habbo.cmd_publicroom.keys").split(";")));
} catch (Exception ex) {
LOGGER.error("Error while loading habbo commands", ex);
}
}
}

20
src/main/java/es/publicroom/core/ReadTexts.java

@ -0,0 +1,20 @@
package es.publicroom.core;
import com.eu.habbo.Emulator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ReadTexts {
private static final Logger LOGGER = LoggerFactory.getLogger(ReadTexts.class);
public static void readText() {
try {
Emulator.getTexts().register("commands.success.publicroom.enabled", "¡Felicidades, ahora está sala se encuentra pública!");
Emulator.getTexts().register("commands.success.publicroom.disabled", "¡Es una pena, ahora está sala ha dejado de ser pública!");
Emulator.getTexts().register("habbo.cmd_publicroom.keys", "publicroom;pr");
} catch (Exception ex) {
LOGGER.error("Error while loading habbo texts", ex);
}
}
}

7
src/main/java/es/publicroom/room/Listener.java

@ -0,0 +1,7 @@
package es.roleplay.room;
import com.eu.habbo.plugin.EventListener;
public class Listener implements EventListener {
//
}

5
src/main/resources/plugin.json

@ -0,0 +1,5 @@
{
"main" : "es.publicroom.PublicRoom",
"name" : "PublicRoom",
"author" : "Juan Molina (Ouis)"
}
Loading…
Cancel
Save