Author SHA1 Message Date
ARR4NN 48f211b1ad Add support for custom lang for the update message. 2024-05-29 11:40:53 +01:00
RonanCraft 077c55723d version bump 2024-05-24 14:27:34 -04:00
RonanCraft 2971c1a407 ignore node_modules 2024-05-24 14:14:17 -04:00
ZepsiZola e6ccb3be55 Fixed MinRadius Issue (#211)
* Fixed MinRadius Issue

No longer sends players to exclusively the corners of the map. Now sends them to anywhere where x or z is above the MinRadius (while both being below the MaxRadius)

* Fixed MinRadius Issue

No longer sends players to exclusively the corners of the map. Now sends them to anywhere where x or z is above the MinRadius (while both being below the MaxRadius)


Fixes this issue.
https://github.com/RonanPlugins/BetterRTP/issues/210

* Update QueueHandler.java

* MaxRadius and MinRadius fix
2024-05-05 19:44:39 -04:00
RonanCraft 9ab1648bfb Update README.md 2024-03-30 11:24:44 -04:00
21 changed files with 37 additions and 4605 deletions

No files matched your search

+1
View File
@@ -9,3 +9,4 @@ target
BetterRTP.wiki/ BetterRTP.wiki/
.DS_Store .DS_Store
.vscode/ .vscode/
node_modules/
+3
View File
@@ -2,6 +2,9 @@
<b><a>Welcome to BetterRTPAddons's repository!</a></b> <b><a>Welcome to BetterRTPAddons's repository!</a></b>
</p> </p>
BetterRTP-Addons is a paid resource, adding optional middleware to BetterRTP to help financially support the developement of BetterRTP.
But this can be compiled free of charge if you know how to compile maven resources!
## Where's the Lang files?/Want to Contribute translating? ## Where's the Lang files?/Want to Contribute translating?
All language files are located [here](src/main/resources/lang) All language files are located [here](src/main/resources/lang)
feel free to fork one of the language files and help translate! feel free to fork one of the language files and help translate!
+1 -2
View File
@@ -7,7 +7,7 @@
<groupId>me.SuperRonanCraft</groupId> <groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTPAddons</artifactId> <artifactId>BetterRTPAddons</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.8.9</version> <version>1.8.8</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
@@ -52,7 +52,6 @@
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version> <version>3.2.0</version>
<configuration> <configuration>
<!-- Builds to local storage 3 folders back from where its saved, it's for Ronan :D -->
<outputDirectory>../../../Java/plugins</outputDirectory> <outputDirectory>../../../Java/plugins</outputDirectory>
</configuration> </configuration>
</plugin> </plugin>
-1
View File
@@ -1 +0,0 @@
node_modules/
@@ -5,8 +5,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BetterRTP - API</title> <title>BetterRTP - API</title>
</head> </head>
<body> <body></body>
<p>BetterRTP API coming soon!</p>
</body>
<script src="index.js"></script> <script src="index.js"></script>
</html> </html>
View File
Whitespace-only changes.
-4455
View File
File diff suppressed because it is too large. Load diff
+2 -9
View File
@@ -4,16 +4,9 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "jest" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"keywords": [], "keywords": [],
"author": "", "author": "",
"license": "ISC", "license": "ISC"
"dependencies": {
"express": "^4.19.2"
},
"devDependencies": {
"jest": "^29.7.0",
"supertest": "^6.3.4"
}
} }
-12
View File
@@ -1,12 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BetterRTP - Routes</title>
</head>
<body>
<p>BetterRTP API Routes coming soon!</p>
</body>
<script src="index.js"></script>
</html>
-31
View File
@@ -1,31 +0,0 @@
const express = require("express");
const path = require("path");
const app = express();
const api = require("./index.js");
//Middleware
//Allows to send json body
app.use(express.json());
// app.use((req, red, next) => {
// const yellow = "\x1b[33m%s\x1b[0m";
// // Log out the request type and resource
// console.log(yellow, `${req.method} request to ${req.path}`);
// next();
// });
app.use(express.static("public"));
//Routes
//Send all requests starting with /api to index.js to routes folder
app.use("/api", api);
//https://localhost route to default page
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "/public/index.html"));
});
module.exports = app;
-12
View File
@@ -1,12 +0,0 @@
const router = require("express").Router();
const path = require("path");
const rtp = require("./rtp");
router.use("/rtp", rtp);
router.get("/", (req, res) => {
res.sendFile(path(__dirname, "../public/api/index.html"));
});
module.exports = router;
-28
View File
@@ -1,28 +0,0 @@
const rtpdata = require("express").Router();
rtpdata.post("/", (req, res) => {
const validate = () =>
new Promise((resolve, reject) => {
const json = req.body;
if (json !== undefined) {
resolve(json);
} else {
reject(new Error("No Json"));
}
});
validate()
.then((data) => {
console.log("Validate:", data);
res.json({
added: true,
});
})
.catch((err) => {
console.log("Error:", err);
res.json({
added: false,
});
});
});
module.exports = rtpdata;
-9
View File
@@ -1,9 +0,0 @@
const express = require("express");
const path = require("path");
const app = require("./routes/app.js");
const port = 3001;
app.listen(port, () => {
console.log(`BetterRTP Server online at http://localhost:${port}`);
});
-25
View File
@@ -1,25 +0,0 @@
const request = require("supertest");
const app = require("../routes/app.js");
describe("GET /api", () => {
it("responds with html file", async () => {
const res = await request(app).get("/api");
// console.log(res.header);
expect(res.header["content-type"]).toBe("text/html; charset=UTF-8");
});
});
describe("POST /api/rtp", () => {
it("responds with json and `added = false`", async () => {
const res = await request(app).post("/api/rtp");
expect(res.header["content-type"]).toBe("application/json; charset=utf-8");
expect(res.body.added).toBe(false);
});
it("responds with json and `added = true`", async () => {
const res = await request(app).post("/api/rtp").send({
playerId: "test123",
});
expect(res.header["content-type"]).toBe("application/json; charset=utf-8");
expect(res.body.added).toBe(true);
});
});
+1 -1
View File
@@ -7,7 +7,7 @@
<groupId>me.SuperRonanCraft</groupId> <groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId> <artifactId>BetterRTP</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>3.6.12</version> <version>3.6.13</version>
<!-- Upload patches to https://repo.ronanplugins.com/#/ --> <!-- Upload patches to https://repo.ronanplugins.com/#/ -->
@@ -5,6 +5,7 @@ import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_TYPE;
import me.SuperRonanCraft.BetterRTP.references.PermissionNode; import me.SuperRonanCraft.BetterRTP.references.PermissionNode;
import me.SuperRonanCraft.BetterRTP.references.file.FileOther; import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP; import me.SuperRonanCraft.BetterRTP.references.messages.Message_RTP;
import me.SuperRonanCraft.BetterRTP.references.messages.MessagesCore;
import me.SuperRonanCraft.BetterRTP.references.web.Updater; import me.SuperRonanCraft.BetterRTP.references.web.Updater;
import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP; import me.SuperRonanCraft.BetterRTP.references.helpers.HelperRTP;
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler; import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
@@ -12,6 +13,8 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import java.util.Arrays;
public class Join { public class Join {
static void event(PlayerJoinEvent e) { static void event(PlayerJoinEvent e) {
@@ -25,11 +28,16 @@ public class Join {
//Updater //Updater
private static void updater(Player p) { private static void updater(Player p) {
if (!getPl().getFiles().getType(FileOther.FILETYPE.CONFIG).getBoolean("Settings.DisableUpdater") && PermissionNode.UPDATER.check(p)) if (!getPl().getFiles().getType(FileOther.FILETYPE.CONFIG).getBoolean("Settings.DisableUpdater") && PermissionNode.UPDATER.check(p)) {
if (!getPl().getDescription().getVersion().equals(Updater.updatedVersion)) if (!getPl().getDescription().getVersion().equals(Updater.updatedVersion)) {
Message_RTP.sms(p, "&7There is currently an update for &6BetterRTP &7version &e#" + String currentVersion = getPl().getDescription().getVersion();
Updater.updatedVersion + " &7you have version &e#" + getPl().getDescription().getVersion()); String newVersion = Updater.updatedVersion;
MessagesCore.UPDATE.send(p, Arrays.asList(currentVersion, newVersion));
} }
}
}
//RTP on first join //RTP on first join
private static void rtpOnFirstJoin(Player p) { private static void rtpOnFirstJoin(Player p) {
@@ -19,6 +19,7 @@ public enum MessagesCore {
OTHER_BIOME("Other.Biome"), OTHER_BIOME("Other.Biome"),
NOTEXIST("NotExist"), NOTEXIST("NotExist"),
RELOAD("Reload"), RELOAD("Reload"),
UPDATE("Update"),
NOPERMISSION("NoPermission.Basic"), NOPERMISSION("NoPermission.Basic"),
NOPERMISSION_WORLD("NoPermission.World"), NOPERMISSION_WORLD("NoPermission.World"),
DISABLED_WORLD("DisabledWorld"), DISABLED_WORLD("DisabledWorld"),
@@ -64,9 +64,13 @@ public class PlaceholderAnalyzer {
str = str.replaceAll(Placeholders.WORLD.name, info); str = str.replaceAll(Placeholders.WORLD.name, info);
if (str.contains(Placeholders.COOLDOWN.name)) if (str.contains(Placeholders.COOLDOWN.name))
str = str.replaceAll(Placeholders.COOLDOWN.name, info); str = str.replaceAll(Placeholders.COOLDOWN.name, info);
if (str.contains(Placeholders.CURRENTDVERSION.name))
str = str.replaceAll(Placeholders.CURRENTDVERSION.name, info);
if (str.contains(Placeholders.NEWVERSION.name))
str = str.replaceAll(Placeholders.NEWVERSION.name, info);
return str; return str;
} }
private static String location(String str, Location loc) { private static String location(String str, Location loc) {
if (str.contains(Placeholders.LOCATION_X.name)) if (str.contains(Placeholders.LOCATION_X.name))
str = str.replace(Placeholders.LOCATION_X.name, String.valueOf(loc.getBlockX())); str = str.replace(Placeholders.LOCATION_X.name, String.valueOf(loc.getBlockX()));
@@ -17,6 +17,9 @@ public enum Placeholders {
PRICE("price"), PRICE("price"),
DELAY("delay"), DELAY("delay"),
TIME("time"), TIME("time"),
// Updater
NEWVERSION("newVersion"),
CURRENTDVERSION("currentVersion"),
//Other //Other
BIOME("biome") BIOME("biome")
; ;
@@ -105,19 +105,13 @@ public class QueueHandler implements Listener { //Randomly queues up some safe l
} }
public static boolean isInSquare(Location loc, RTPWorld rtpWorld) { public static boolean isInSquare(Location loc, RTPWorld rtpWorld) {
int center_x = rtpWorld.getCenterX(); int radius_max = rtpWorld.getMaxRadius();
int center_z = rtpWorld.getCenterZ();
int radius = rtpWorld.getMaxRadius();
int radius_min = rtpWorld.getMinRadius(); int radius_min = rtpWorld.getMinRadius();
int x = loc.getBlockX(); int x = loc.getBlockX() - rtpWorld.getCenterX();
int z = loc.getBlockZ(); int z = loc.getBlockZ() - rtpWorld.getCenterZ();
boolean xright = x <= center_x + radius && x >= center_x + radius_min; return ((Math.abs(x)>=radius_min || Math.abs(z)>=radius_min) && (Math.abs(x) <= radius_max && Math.abs(z) <= radius_max));
boolean xleft = x >= center_x - radius && x <= center_x - radius_min; // Returns true if the x or z coordinate is above the MinRadius and if they are both under the MaxRadius. Returns false otherwise.
if (!(xleft || xright)) // (All locations provided should be below the MaxRadius anyway, but I put it in just in-case.)
return false;
boolean zbottom = z <= center_z + radius && z >= center_z + radius_min;
boolean ztop = z >= center_z - radius && z <= center_z - radius_min;
return ztop || zbottom;
} }
} }
+1
View File
@@ -15,6 +15,7 @@ Messages:
NotSafe: '&cCould not find safe spot within %attempts% attempts! &7%player% was not rtp''d!' NotSafe: '&cCould not find safe spot within %attempts% attempts! &7%player% was not rtp''d!'
Biome: '&cSeems like the biome&7 %biome%&c does not exist! &7Try using the tab list!' Biome: '&cSeems like the biome&7 %biome%&c does not exist! &7Try using the tab list!'
Reload: '&eConfig reloaded successfully!' Reload: '&eConfig reloaded successfully!'
Update: '&7There is currently an update for &6BetterRTP &7version &e#%newVersion% &7you have version &e#%currentVersion%'
NoPermission: NoPermission:
Basic: '&cSorry! &7You don''t have permission to use this command! &8Permission: %permission%' Basic: '&cSorry! &7You don''t have permission to use this command! &8Permission: %permission%'
World: '&cSorry! &7You are not allowed rtp in the %world% world! &8Permission: %permission%' World: '&cSorry! &7You are not allowed rtp in the %world% world! &8Permission: %permission%'