1
Fork 0
mirror of https://github.com/Quackster/Havana.git synced 2025-07-03 13:17:46 +00:00

Merge branch 'develop'

This commit is contained in:
Quackster 2022-11-27 16:48:48 +10:00
commit 68c15b7888
11 changed files with 106 additions and 40 deletions

View file

@ -115,28 +115,36 @@ public class BanDao {
} }
} }
public static List<Ban> getActiveBans() { public static List<Ban> getActiveBans(int page, String sortBy) {
List<Ban> banList = new ArrayList<>(); List<Ban> banList = new ArrayList<>();
Connection sqlConnection = null; int rows = 25;
PreparedStatement preparedStatement = null; int nextOffset = page * rows;
ResultSet resultSet = null;
try { if (nextOffset >= 0) {
sqlConnection = Storage.getStorage().getConnection(); Connection sqlConnection = null;
preparedStatement = Storage.getStorage().prepare("SELECT * FROM users_bans WHERE is_active = 1 ORDER BY banned_at DESC", sqlConnection); PreparedStatement preparedStatement = null;
resultSet = preparedStatement.executeQuery(); ResultSet resultSet = null;
while (resultSet.next()) { try {
banList.add(new Ban(BanType.valueOf(resultSet.getString("ban_type")), resultSet.getString("banned_value"), resultSet.getString("message"), resultSet.getTime("banned_until").getTime() / 1000L, sqlConnection = Storage.getStorage().getConnection();
resultSet.getTime("banned_at").getTime() / 1000L, resultSet.getInt("banned_by"))); preparedStatement = Storage.getStorage().prepare("SELECT * FROM users_bans WHERE is_active = 1 ORDER BY " + sortBy + " DESC LIMIT ? OFFSET ?", sqlConnection);
preparedStatement.setInt(1, rows);
preparedStatement.setInt(2, nextOffset);
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
banList.add(new Ban(BanType.valueOf(resultSet.getString("ban_type")), resultSet.getString("banned_value"), resultSet.getString("message"), resultSet.getTime("banned_until").getTime() / 1000L,
resultSet.getTime("banned_at").getTime() / 1000L, resultSet.getInt("banned_by")));
}
} catch (Exception e) {
Storage.logError(e);
} finally {
Storage.closeSilently(sqlConnection);
Storage.closeSilently(preparedStatement);
Storage.closeSilently(resultSet);
} }
} catch (Exception e) {
Storage.logError(e);
} finally {
Storage.closeSilently(sqlConnection);
Storage.closeSilently(preparedStatement);
Storage.closeSilently(resultSet);
} }
return banList; return banList;

View file

@ -80,7 +80,7 @@ public class ClubSubscription {
* @param playerDetails the details of the player that subscribed * @param playerDetails the details of the player that subscribed
* @param choice the subscription choice * @param choice the subscription choice
*/ */
public static boolean subscribeClub(PlayerDetails playerDetails, int choice) { public static boolean subscribeClub(PlayerDetails playerDetails, int choice) throws SQLException {
var choiceData = getChoiceData(choice); var choiceData = getChoiceData(choice);
int credits = choiceData.getKey(); int credits = choiceData.getKey();
@ -124,6 +124,17 @@ public class ClubSubscription {
PlayerDao.saveSubscription(playerDetails.getId(), playerDetails.getFirstClubSubscription(), playerDetails.getClubExpiration()); PlayerDao.saveSubscription(playerDetails.getId(), playerDetails.getFirstClubSubscription(), playerDetails.getClubExpiration());
CurrencyDao.decreaseCredits(playerDetails, credits); CurrencyDao.decreaseCredits(playerDetails, credits);
TransactionDao.createTransaction(
playerDetails.getId(),
"0",
"0",
days,
"Habbo Club purchase",
credits,
0,
true
);
return true; return true;
} }

View file

@ -13,6 +13,7 @@ import org.alexdev.havana.util.DateUtil;
import org.alexdev.havana.util.config.GameConfiguration; import org.alexdev.havana.util.config.GameConfiguration;
import org.alexdev.http.util.RconUtil; import org.alexdev.http.util.RconUtil;
import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -39,7 +40,7 @@ public class HabboClubHabblet {
template.render(); template.render();
} }
public static void subscribe(WebConnection webConnection) { public static void subscribe(WebConnection webConnection) throws SQLException {
if (!webConnection.session().getBoolean("authenticated")) { if (!webConnection.session().getBoolean("authenticated")) {
return; return;
} }

View file

@ -15,6 +15,21 @@ public class HousekeepingBansController {
return; return;
} }
int currentPage = 0;
if (client.get().contains("page")) {
currentPage = Integer.parseInt(client.get().getString("page"));
}
String sortBy = "banned_at";
if (client.get().contains("sort")) {
if (client.get().getString("sort").equals("banned_at") ||
client.get().getString("sort").equals("banned_until")) {
sortBy = client.get().getString("sort");
}
}
Template tpl = client.template("housekeeping/users_bans"); Template tpl = client.template("housekeeping/users_bans");
tpl.set("housekeepingManager", HousekeepingManager.getInstance()); tpl.set("housekeepingManager", HousekeepingManager.getInstance());
@ -25,7 +40,12 @@ public class HousekeepingBansController {
return; return;
} }
tpl.set("bans", BanDao.getActiveBans()); tpl.set("pageName", "Bans");
tpl.set("bans", BanDao.getActiveBans(currentPage, sortBy));
tpl.set("nextBans", BanDao.getActiveBans(currentPage + 1, sortBy));
tpl.set("previousBans", BanDao.getActiveBans(currentPage - 1, sortBy));
tpl.set("page", currentPage);
tpl.set("sortBy", sortBy);
tpl.render(); tpl.render();
// Delete alert after it's been rendered // Delete alert after it's been rendered

View file

@ -16,4 +16,28 @@ public class HousekeepingStats {
this.petCount = petCount; this.petCount = petCount;
this.photoCount = photoCount; this.photoCount = photoCount;
} }
public int getUserCount() {
return userCount;
}
public int getInventoryItemsCount() {
return inventoryItemsCount;
}
public int getRoomItemCount() {
return roomItemCount;
}
public int getGroupCount() {
return groupCount;
}
public int getPetCount() {
return petCount;
}
public int getPhotoCount() {
return photoCount;
}
} }

View file

@ -198,17 +198,9 @@ Download the [havana_www.zip](https://www.mediafire.com/file/x94neh4qbu3l2s2/hav
*(This is the default directory for static content within the Havana-Web project, but the directory where it looks for static images can be configured in the Housekeeping settings).* *(This is the default directory for static content within the Havana-Web project, but the directory where it looks for static images can be configured in the Housekeeping settings).*
Open Havana-Web.jar via Start Havana-Web via start_web.sh (Unix/Linux distros) or start_web.bat (Windows)
``` Start Havana-Server via start_server.sh (Unix/Linux distros) or start_server.bat (Windows)
java -jar Havana-Web.jar
```
Open Havana-Server.jar via
```
java -jar Havana-Server.jar
```
Your server should be up and running and accessible via http://localhost/ Your server should be up and running and accessible via http://localhost/

View file

@ -6,8 +6,8 @@
<meta name="description" content=""> <meta name="description" content="">
<meta name="author" content=""> <meta name="author" content="">
<title>{{ site.siteName }}: {{ pageName }}</title> <title>{{ site.siteName }}: {{ pageName }}</title>
<link href="{{ site.sitePath }}/public/hk/css/bootstrap.min.css" rel="stylesheet"> <link href="{{ site.staticContentPath }}/public/hk/css/bootstrap.min.css" rel="stylesheet">
<link href="{{ site.sitePath }}/public/hk/css/simple-sidebar.css" rel="stylesheet"> <link href="{{ site.staticContentPath }}/public/hk/css/simple-sidebar.css" rel="stylesheet">
</head> </head>

View file

@ -90,7 +90,7 @@
<td>{{ player.id }}</td> <td>{{ player.id }}</td>
<td><a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/users/edit?id={{ player.id }}">{{ player.name }}</a> - <a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/transaction/lookup?searchQuery={{ player.getName() }}">Transactons</a></td> <td><a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/users/edit?id={{ player.id }}">{{ player.name }}</a> - <a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/transaction/lookup?searchQuery={{ player.getName() }}">Transactons</a></td>
<td>{{ player.email }}</td> <td>{{ player.email }}</td>
<td><img src="https://www.habbo.com.tr/habbo-imaging/avatarimage?figure={{ player.figure }}&size=s"></td> <td><img src="{{ site.habboImagingPath }}/habbo-imaging/avatarimage?figure={{ player.figure }}&size=s"></td>
<td>{{ player.motto }}</td> <td>{{ player.motto }}</td>
<td>{{ player.credits }}</td> <td>{{ player.credits }}</td>
<td>{{ player.pixels }}</td> <td>{{ player.pixels }}</td>

View file

@ -7,9 +7,9 @@
<meta name="author" content=""> <meta name="author" content="">
<link rel="icon" href="../../favicon.ico"> <link rel="icon" href="../../favicon.ico">
<title>{{ site.siteName }}: Housekeeping</title> <title>{{ site.siteName }}: Housekeeping</title>
<link href="{{ site.sitePath }}/public/hk/css/bootstrap.min.css" rel="stylesheet"> <link href="{{ site.staticContentPath }}/public/hk/css/bootstrap.min.css" rel="stylesheet">
<link href="{{ site.sitePath }}/public/hk/css/bootstrap.login.override.css" rel="stylesheet"> <link href="{{ site.staticContentPath }}/public/hk/css/bootstrap.login.override.css" rel="stylesheet">
<link href="{{ site.sitePath }}/public/hk/css/sticky-footer.css" rel="stylesheet"> <link href="{{ site.staticContentPath }}/public/hk/css/sticky-footer.css" rel="stylesheet">
</head> </head>
<body> <body>
@ -40,6 +40,6 @@
<span class="text-muted">&copy; Copyright 2018 - Alex Miller</span> <span class="text-muted">&copy; Copyright 2018 - Alex Miller</span>
</div> </div>
</footer> </footer>
<script src="{{ site.sitePath }}/public/hk/js/ie10-viewport-bug-workaround.js"></script> <script src="{{ site.staticContentPath }}/public/hk/js/ie10-viewport-bug-workaround.js"></script>
</body> </body>
</html> </html>

View file

@ -5,6 +5,16 @@
<h1 class="mt-4">View and manage bans</h1> <h1 class="mt-4">View and manage bans</h1>
{% include "housekeeping/base/alert.tpl" %} {% include "housekeeping/base/alert.tpl" %}
<p>Manage all currently active bans on the hotel</p> <p>Manage all currently active bans on the hotel</p>
<div style="margin:10px">
{% if nextBans|length > 0 %}
{% set ourNextPage = page + 1 %}
<a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/bans?page={{ ourNextPage }}&sort={{ sortBy }}"><button type="button" class="btn btn-info">Next Page</button></a>
{% endif %}
{% if previousBans|length > 0 %}
{% set ourNextPage = page - 1 %}
<a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/bans?page={{ ourNextPage }}&sort={{ sortBy }}"><button type="button" class="btn btn-warning">Go back</button></a>
{% endif %}
</div>
<div class="table-responsive"> <div class="table-responsive">
<form method="post"> <form method="post">
<table class="table table-striped"> <table class="table table-striped">
@ -13,8 +23,8 @@
<th>Type</th> <th>Type</th>
<th>Value</th> <th>Value</th>
<th>Message</th> <th>Message</th>
<th>Banned Util</th> <th><a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/bans?page={{ page }}&sort=banned_until">Banned Util</a></th>
<th>Banned At</th> <th><a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/bans?page={{ page }}&sort=banned_at">Banned At</a></th>
<th>Banned By</th> <th>Banned By</th>
</tr> </tr>
</thead> </thead>

View file

@ -56,7 +56,7 @@
<td>{{ player.id }}</td> <td>{{ player.id }}</td>
<td><a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/users/edit?id={{ player.id }}">{{ player.name }}</a></td> <td><a href="{{ site.sitePath }}/{{ site.housekeepingPath }}/users/edit?id={{ player.id }}">{{ player.name }}</a></td>
<td>{{ player.email }}</td> <td>{{ player.email }}</td>
<td><img src="https://www.habbo.com.tr/habbo-imaging/avatarimage?figure={{ player.figure }}&size=s"></td> <td><img src="{{ site.habboImagingPath }}/habbo-imaging/avatarimage?figure={{ player.figure }}&size=s"></td>
<td>{{ player.mission }}</td> <td>{{ player.mission }}</td>
<td>{{ player.credits }}</td> <td>{{ player.credits }}</td>
<td>{{ player.pixels }}</td> <td>{{ player.pixels }}</td>