mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 16:56:40 +00:00
Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
1d0fb85fa1 | |||
665a2f4e72 | |||
9c67911c1b | |||
f1ebbc3664 | |||
4aa3ae7c50 | |||
08e2f31eae | |||
a1c009909d | |||
7d2c44975d | |||
b2faec70a9 | |||
a0cca2aea5 | |||
337334d403 | |||
2e8fe8767e | |||
dbdf720a9e | |||
5a9d6dd60d | |||
84a9535123 | |||
41aff575d0 | |||
65b8188b37 | |||
c8a35c8e0e | |||
13acf7ba9d | |||
5fe48cfd7f | |||
abf2aca0f2 | |||
dc4ac39fe4 | |||
1ae8e779b1 | |||
658f4a4b05 | |||
7ccfb2ad27 |
40
.github/workflows/codeql-analysis.yml
vendored
40
.github/workflows/codeql-analysis.yml
vendored
@ -1,14 +1,3 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
@ -18,7 +7,7 @@ on:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '29 4 * * *'
|
||||
- cron: '30 4 * * *'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
@ -33,45 +22,26 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'java' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
java: [17]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
- name: Set up JDK ${{ matrix.java }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
java-version: ${{ matrix.java }}
|
||||
cache: gradle
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
- run: |
|
||||
chmod +x gradlew
|
||||
./gradlew build --no-daemon
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
40
.github/workflows/gradle.yml
vendored
40
.github/workflows/gradle.yml
vendored
@ -1,18 +1,26 @@
|
||||
name: Gradle
|
||||
|
||||
on: [ push ]
|
||||
# Adapted from Paper's build script
|
||||
name: Build
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
cache: gradle
|
||||
- name: Build with Gradle
|
||||
run: chmod a+x gradlew && ./gradlew build --no-daemon
|
||||
build:
|
||||
# Only run on PRs if the source branch is on someone else's repo
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [17]
|
||||
fail-fast: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: JDK ${{ matrix.java }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
cache: 'gradle'
|
||||
distribution: 'temurin'
|
||||
- name: Build
|
||||
run: |
|
||||
git config --global user.email "no-reply@github.com"
|
||||
git config --global user.name "Github Actions"
|
||||
./gradlew build --stacktrace
|
||||
|
@ -1,8 +1,8 @@
|
||||
# Plex [](https://ci.plex.us.org/job/Plex/job/master/)
|
||||
# Plex [](https://ci.plex.us.org/job/Plex/job/master/) 
|
||||
|
||||
Plex is a new freedom plugin. It is an alternative to TotalFreedomMod. It has many of the features that make a freedom
|
||||
server unique, but also many features that TotalFreedomMod doesn’t have. For example, there is full support for using a
|
||||
permissions plugin instead of ranks. It is also much more performance oriented. You can use Redis to store indefinite
|
||||
bans and store player data in MongoDB, MariaDB, or SQLite. Plex is also fully customizable as you can change almost all
|
||||
of the messages within the plugin. Plex also has a module system which can be used to add additional functionality. Plex
|
||||
is not a rewrite, "debloat", or related to TotalFreedomMod. Plex is an entirely new experience.
|
||||
is not a rewrite, "debloat", or related to TotalFreedomMod. Plex is an entirely new experience.
|
||||
|
@ -27,6 +27,6 @@ publishing {
|
||||
dependencies {
|
||||
compileOnly "org.projectlombok:lombok:1.18.24"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.24"
|
||||
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
|
||||
compileOnly "io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT"
|
||||
compileOnly "org.json:json:20220320"
|
||||
}
|
@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.1"
|
||||
version = "1.1.1"
|
||||
description = "Plex"
|
||||
|
||||
subprojects {
|
||||
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom") version "1.2.0"
|
||||
id("net.kyori.blossom") version "1.3.0"
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
|
@ -7,9 +7,9 @@ dependencies {
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.24"
|
||||
library "org.json:json:20220320"
|
||||
library "commons-io:commons-io:2.11.0"
|
||||
library "dev.morphia.morphia:morphia-core:2.2.6"
|
||||
library "redis.clients:jedis:4.2.2"
|
||||
library "org.mariadb.jdbc:mariadb-java-client:3.0.4"
|
||||
library "dev.morphia.morphia:morphia-core:2.2.7"
|
||||
library "redis.clients:jedis:4.2.3"
|
||||
library "org.mariadb.jdbc:mariadb-java-client:3.0.5"
|
||||
library "com.zaxxer:HikariCP:5.0.1"
|
||||
library "org.apache.httpcomponents:httpclient:4.5.13"
|
||||
library "org.apache.commons:commons-lang3:3.12.0"
|
||||
@ -22,7 +22,7 @@ dependencies {
|
||||
library "org.eclipse.jetty:jetty-servlet:11.0.9"
|
||||
library "org.eclipse.jetty:jetty-proxy:11.0.9"
|
||||
library "com.google.code.gson:gson:2.9.0"
|
||||
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
|
||||
compileOnly "io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT"
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") {
|
||||
exclude group: "org.bukkit", module: "bukkit"
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import dev.plex.util.PlexUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -8,7 +8,7 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -22,7 +22,7 @@ import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -7,7 +7,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -18,7 +18,7 @@ import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "localspawn", description = "Teleport to the spawnpoint of the world you are in")
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.spawnpoint", source = RequiredCommandSource.IN_GAME)
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.localspawn", source = RequiredCommandSource.IN_GAME)
|
||||
public class LocalSpawnCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -16,7 +16,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -7,7 +7,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -7,7 +7,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
|
@ -11,7 +11,7 @@ import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -18,7 +18,7 @@ import dev.plex.util.WebUtils;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -31,6 +31,7 @@ public class ToggleCMD extends PlexCommand
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Explosions" + status("explosions")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Fluidspread" + status("fluidspread")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Drops" + status("drops")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Redstone" + status("redstone")));
|
||||
return null;
|
||||
}
|
||||
switch (args[0].toLowerCase())
|
||||
@ -47,6 +48,10 @@ public class ToggleCMD extends PlexCommand
|
||||
{
|
||||
return toggle("drops");
|
||||
}
|
||||
case "redstone" ->
|
||||
{
|
||||
return toggle("redstone");
|
||||
}
|
||||
default ->
|
||||
{
|
||||
return messageComponent("invalidToggle");
|
||||
|
@ -38,9 +38,8 @@ public class BlockListener extends PlexListener
|
||||
{
|
||||
blockedBlocks.add(Material.valueOf(block.toUpperCase()));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -3,13 +3,24 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
|
||||
public class TogglesListener extends PlexListener
|
||||
{
|
||||
@EventHandler
|
||||
public void onEntityExplode(ExplosionPrimeEvent event)
|
||||
public void onBlockExplode(ExplosionPrimeEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("explosions"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("explosions"))
|
||||
{
|
||||
@ -34,4 +45,18 @@ public class TogglesListener extends PlexListener
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* I have no idea if this is the best way to do this
|
||||
There is a very weird bug where if you try to create a loop using two repeaters and a lever, after disabling
|
||||
and re-enabling redstone, you are unable to recreate the loop with a lever. Using a redstone torch works fine.
|
||||
Using a lever works fine also as long as you never toggle redstone.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onBlockRedstone(BlockRedstoneEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("redstone"))
|
||||
{
|
||||
event.setNewCurrent(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
@ -13,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
@ -31,42 +30,41 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WorldListener extends PlexListener
|
||||
{
|
||||
private final List<String> EDIT_COMMANDS = Arrays.asList("bigtree", "ebigtree", "largetree", "elargetree",
|
||||
"break", "ebreak", "antioch", "nuke", "editsign", "tree", "etree");
|
||||
private final List<String> EDIT_COMMANDS = Arrays.asList("bigtree", "ebigtree", "largetree", "elargetree", "break", "ebreak", "antioch", "nuke", "editsign", "tree", "etree");
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (!checkPermission(e.getPlayer(), true))
|
||||
if (!canModifyWorld(event.getPlayer(), true))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (!checkPermission(e.getPlayer(), true))
|
||||
if (!canModifyWorld(event.getPlayer(), true))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e)
|
||||
public void onEntitySpawn(EntitySpawnEvent event)
|
||||
{
|
||||
if (e.getEntityType() != EntityType.SLIME)
|
||||
if (event.getEntityType() != EntityType.SLIME)
|
||||
{
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
// If the person has permission to modify the world, we don't need to block WorldEdit
|
||||
if (checkPermission(event.getPlayer(), false))
|
||||
if (canModifyWorld(event.getPlayer(), false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -88,26 +86,12 @@ public class WorldListener extends PlexListener
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add an entry setting in the config.yml and allow checking for all worlds
|
||||
@EventHandler
|
||||
public void onWorldTeleport(PlayerTeleportEvent e)
|
||||
public void onWorldTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
final World adminworld = Bukkit.getWorld("adminworld");
|
||||
if (adminworld == null)
|
||||
if (!canEnterWorld(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(e.getPlayer().getUniqueId());
|
||||
if (e.getTo().getWorld().equals(adminworld))
|
||||
{
|
||||
if (plugin.getSystem().equals("ranks") && !plexPlayer.isAdminActive())
|
||||
{
|
||||
e.setCancelled(true);
|
||||
}
|
||||
else if (plugin.getSystem().equals("permissions") && !plugin.getPermissionHandler().hasPermission(e.getPlayer(), "plex.adminworld.enter"))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,13 +136,20 @@ public class WorldListener extends PlexListener
|
||||
return hasAccess;
|
||||
}
|
||||
|
||||
private boolean checkPermission(Player player, boolean showMessage)
|
||||
/**
|
||||
* Check if a Player has the ability to modify the world they are in
|
||||
*
|
||||
* @param player The player who wants to modify the world
|
||||
* @param showMessage Whether the message from the config.yml should be shown
|
||||
* @return Returns true if the person has the ability to modify the world
|
||||
*/
|
||||
private boolean canModifyWorld(Player player, boolean showMessage)
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(player.getUniqueId());
|
||||
World world = player.getWorld();
|
||||
if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
String permission = plugin.config.getString("plex." + world.getName().toLowerCase() + ".permission");
|
||||
String permission = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".modification.permission");
|
||||
if (permission == null)
|
||||
{
|
||||
return true;
|
||||
@ -170,9 +161,9 @@ public class WorldListener extends PlexListener
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
if (plugin.config.contains("worlds." + world.getName().toLowerCase() + ".requiredLevels"))
|
||||
if (plugin.config.contains("worlds." + world.getName().toLowerCase() + ".modification.requiredLevels"))
|
||||
{
|
||||
@NotNull List<String> requiredLevel = plugin.config.getStringList("worlds." + world.getName().toLowerCase() + ".requiredLevels");
|
||||
@NotNull List<String> requiredLevel = plugin.config.getStringList("worlds." + world.getName().toLowerCase() + ".modification.requiredLevels");
|
||||
if (checkLevel(plexPlayer, requiredLevel.toArray(String[]::new)))
|
||||
{
|
||||
return true;
|
||||
@ -186,12 +177,57 @@ public class WorldListener extends PlexListener
|
||||
|
||||
if (showMessage)
|
||||
{
|
||||
String noEdit = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".noEdit");
|
||||
String noEdit = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".modification.message");
|
||||
if (noEdit != null)
|
||||
{
|
||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(noEdit));
|
||||
player.sendMessage(MiniMessage.miniMessage().deserialize(noEdit));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Player has the ability to enter the requested world
|
||||
* @param player The player who wants to enter the world
|
||||
* @return Returns true if the person has the ability to enter the world
|
||||
*/
|
||||
private boolean canEnterWorld(Player player)
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(player.getUniqueId());
|
||||
World world = player.getWorld();
|
||||
if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
String permission = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".entry.permission");
|
||||
if (permission == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (plugin.getPermissionHandler().hasPermission(player, permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
if (plugin.config.contains("worlds." + world.getName().toLowerCase() + ".entry.requiredLevels"))
|
||||
{
|
||||
@NotNull List<String> requiredLevel = plugin.config.getStringList("worlds." + world.getName().toLowerCase() + ".entry.requiredLevels");
|
||||
if (checkLevel(plexPlayer, requiredLevel.toArray(String[]::new)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String noEntry = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".entry.message");
|
||||
if (noEntry != null)
|
||||
{
|
||||
player.sendMessage(MiniMessage.miniMessage().deserialize(noEntry));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -21,10 +21,11 @@ public class ToggleMenu extends AbstractMenu implements PlexBase
|
||||
public ToggleMenu()
|
||||
{
|
||||
super("§a§lToggles");
|
||||
Inventory inventory = Bukkit.createInventory(null, 54, PlexUtils.mmDeserialize("Toggles"));
|
||||
Inventory inventory = Bukkit.createInventory(null, 9, PlexUtils.mmDeserialize("Toggles"));
|
||||
resetExplosionItem(inventory);
|
||||
resetFluidspreadItem(inventory);
|
||||
resetDropsItem(inventory);
|
||||
resetRedstoneItem(inventory);
|
||||
inventories.add(inventory);
|
||||
}
|
||||
|
||||
@ -77,6 +78,12 @@ public class ToggleMenu extends AbstractMenu implements PlexBase
|
||||
resetDropsItem(inv);
|
||||
event.getWhoClicked().sendMessage(PlexUtils.mmDeserialize("<gray>Toggled drops."));
|
||||
}
|
||||
if (item.getType() == Material.REDSTONE)
|
||||
{
|
||||
plugin.toggles.set("redstone", !plugin.toggles.getBoolean("redstone"));
|
||||
resetRedstoneItem(inv);
|
||||
event.getWhoClicked().sendMessage(PlexUtils.mmDeserialize("<gray>Toggled redstone."));
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentInventoryIndex(Inventory inventory)
|
||||
@ -125,4 +132,14 @@ public class ToggleMenu extends AbstractMenu implements PlexBase
|
||||
feather.setItemMeta(featherItemMeta);
|
||||
inventory.setItem(2, feather);
|
||||
}
|
||||
|
||||
private void resetRedstoneItem(Inventory inventory)
|
||||
{
|
||||
ItemStack redstone = new ItemStack(Material.REDSTONE);
|
||||
ItemMeta redstoneItemMeta = redstone.getItemMeta();
|
||||
redstoneItemMeta.displayName(PlexUtils.mmDeserialize("<light_purple>Redstone"));
|
||||
redstoneItemMeta.lore(List.of(PlexUtils.mmDeserialize("<yellow>Redstone is " + (plugin.toggles.getBoolean("redstone") ? "<green>enabled" : "<red>disabled"))));
|
||||
redstone.setItemMeta(redstoneItemMeta);
|
||||
inventory.setItem(3, redstone);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@Getter
|
||||
public class ModuleManager
|
||||
{
|
||||
|
||||
private final List<PlexModule> modules = Lists.newArrayList();
|
||||
private final LibraryLoader libraryLoader;
|
||||
|
||||
|
@ -4,11 +4,13 @@ import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexLog;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import lombok.AccessLevel;
|
||||
@ -46,22 +48,42 @@ public abstract class PlexModule
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a PlexListener within a module
|
||||
*
|
||||
* @param listener The PlexListener to be registered
|
||||
*/
|
||||
public void registerListener(PlexListener listener)
|
||||
{
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a PlexListener. Handled by Plex automatically
|
||||
*
|
||||
* @param listener The PlexListener to be registered
|
||||
*/
|
||||
public void unregisterListener(PlexListener listener)
|
||||
{
|
||||
listeners.remove(listener);
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a PlexCommand within a module
|
||||
*
|
||||
* @param command The PlexCommand to be registered
|
||||
*/
|
||||
public void registerCommand(PlexCommand command)
|
||||
{
|
||||
commands.add(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a PlexCommand. Handled by Plex automatically
|
||||
*
|
||||
* @param command The PlexCommand to be registered
|
||||
*/
|
||||
public void unregisterCommand(PlexCommand command)
|
||||
{
|
||||
commands.remove(command);
|
||||
@ -72,6 +94,41 @@ public abstract class PlexModule
|
||||
return commands.stream().filter(plexCommand -> plexCommand.getName().equalsIgnoreCase(name) || plexCommand.getAliases().stream().map(String::toLowerCase).toList().contains(name.toLowerCase(Locale.ROOT))).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message to the messages.yml file
|
||||
*
|
||||
* @param message The key value for the message
|
||||
* @param initValue The message itself
|
||||
*/
|
||||
public void addDefaultMessage(String message, Object initValue)
|
||||
{
|
||||
if (plex.messages.getString(message) == null)
|
||||
{
|
||||
plex.messages.set(message, initValue);
|
||||
plex.messages.save();
|
||||
PlexLog.debug("'{0}' message added from " + plexModuleFile.getName(), message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message to the messages.yml with a comment
|
||||
*
|
||||
* @param message The key value for the message
|
||||
* @param initValue The message itself
|
||||
* @param comments The comments to be placed above the message
|
||||
*/
|
||||
public void addDefaultMessage(String message, Object initValue, String... comments)
|
||||
{
|
||||
if (plex.messages.getString(message) == null)
|
||||
{
|
||||
plex.messages.set(message, initValue);
|
||||
plex.messages.save();
|
||||
plex.messages.setComments(message, Arrays.asList(comments));
|
||||
plex.messages.save();
|
||||
PlexLog.debug("'{0}' message added from " + plexModuleFile.getName(), message);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InputStream getResource(@NotNull String filename)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ package dev.plex.util;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
@ -9,7 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
public class TimeUtils
|
||||
{
|
||||
|
@ -38,7 +38,8 @@ public class UpdateChecker implements PlexBase
|
||||
* > 0 = Number of commits behind
|
||||
*/
|
||||
private final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/";
|
||||
private String branch = plugin.config.getString("update_branch");
|
||||
private String BRANCH = plugin.config.getString("update_branch");
|
||||
private final String REPO = plugin.config.getString("update_repo");
|
||||
private int distance = -4;
|
||||
|
||||
// Adapted from Paper
|
||||
@ -85,15 +86,15 @@ public class UpdateChecker implements PlexBase
|
||||
// If verbose is 2, it will display all messages
|
||||
public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, int verbosity)
|
||||
{
|
||||
if (branch == null)
|
||||
if (BRANCH == null)
|
||||
{
|
||||
PlexLog.error("You did not specify a branch to use for update checking. Defaulting to master.");
|
||||
branch = "master";
|
||||
BRANCH = "master";
|
||||
}
|
||||
// If it's -4, it hasn't checked for updates yet
|
||||
if (distance == -4)
|
||||
{
|
||||
distance = fetchDistanceFromGitHub("plexusorg/Plex", branch, BuildInfo.getHead());
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getHead());
|
||||
PlexLog.debug("Never checked for updates, checking now...");
|
||||
}
|
||||
else
|
||||
@ -101,7 +102,7 @@ public class UpdateChecker implements PlexBase
|
||||
// If the request isn't asked to be cached, fetch it
|
||||
if (!cached)
|
||||
{
|
||||
distance = fetchDistanceFromGitHub("plexusorg/Plex", branch, BuildInfo.getHead());
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getHead());
|
||||
PlexLog.debug("We have checked for updates before, but this request was not asked to be cached.");
|
||||
}
|
||||
else
|
||||
@ -155,7 +156,7 @@ public class UpdateChecker implements PlexBase
|
||||
AtomicReference<String> url = new AtomicReference<>(DOWNLOAD_PAGE + name);
|
||||
if (!module)
|
||||
{
|
||||
url.set(url.get() + "/job/" + branch);
|
||||
url.set(url.get() + "/job/" + BRANCH);
|
||||
}
|
||||
PlexLog.debug(url.toString());
|
||||
HttpGet get = new HttpGet(url + "/lastSuccessfulBuild/api/json");
|
||||
|
@ -169,8 +169,9 @@ global_gamerules:
|
||||
worlds:
|
||||
flatlands:
|
||||
name: "Flatlands"
|
||||
permission: "plex.world.flatlands"
|
||||
noEdit: "&cYou can't edit this world!"
|
||||
modification:
|
||||
permission: "plex.world.flatlands.modify"
|
||||
message: "<red>You do not have permission to modify this world."
|
||||
gameRules:
|
||||
# The gamerules here override the global gamerules
|
||||
- "doWeatherCycle;false"
|
||||
@ -182,10 +183,18 @@ worlds:
|
||||
bedrock: 1
|
||||
adminworld:
|
||||
name: "Admin World"
|
||||
permission: "plex.world.adminworld"
|
||||
requiredLevels:
|
||||
- "Rank.ADMIN" # Minimum rank requirement
|
||||
noEdit: "&cYou can't edit this world!"
|
||||
entry:
|
||||
permission: "plex.world.adminworld.enter"
|
||||
# Minimum rank requirement
|
||||
requiredLevels:
|
||||
- "Rank.ADMIN"
|
||||
message: "<red>You do not have permission to enter this world."
|
||||
modification:
|
||||
permission: "plex.world.adminworld.modify"
|
||||
# Minimum rank requirement
|
||||
requiredLevels:
|
||||
- "Rank.ADMIN"
|
||||
message: "<red>You do not have permission to modify this world."
|
||||
gameRules:
|
||||
- "doWeatherCycle;false"
|
||||
- "doDaylightCycle;false"
|
||||
@ -196,10 +205,17 @@ worlds:
|
||||
bedrock: 1
|
||||
masterbuilderworld:
|
||||
name: "MasterBuilder World"
|
||||
permission: "plex.world.masterbuilderworld"
|
||||
requiredLevels:
|
||||
- "Title.MASTER_BUILDER" # Title has no "minimum", so this will have to be their title
|
||||
noEdit: "&cYou can't edit this world!"
|
||||
entry:
|
||||
permission: "plex.world.masterbuilderworld.enter"
|
||||
requiredLevels:
|
||||
- "Rank.OP"
|
||||
message: "<red>You do not have permission to enter this world."
|
||||
modification:
|
||||
permission: "plex.world.masterbuilderworld.modify"
|
||||
requiredLevels:
|
||||
# Title has no "minimum", so this will have to be their title
|
||||
- "Title.MASTER_BUILDER"
|
||||
message: "<red><red>You do not have permission to modify this world."
|
||||
gameRules:
|
||||
- "doWeatherCycle;false"
|
||||
- "doDaylightCycle;false"
|
||||
@ -209,8 +225,11 @@ worlds:
|
||||
stone: 16
|
||||
bedrock: 1
|
||||
|
||||
# If you are running a custom fork of Plex, you may wish to check for updates from a different repository.
|
||||
update_repo: "plexusorg/Plex"
|
||||
|
||||
# What branch should Plex fetch updates from?
|
||||
update_branch: master
|
||||
update_branch: "master"
|
||||
|
||||
# Additional logging for debugging
|
||||
debug: false
|
@ -7,4 +7,7 @@ explosions: false
|
||||
fluidspread: true
|
||||
|
||||
# Should drops be enabled?
|
||||
drops: true
|
||||
drops: true
|
||||
|
||||
# Should redstone be enabled?
|
||||
redstone: true
|
Reference in New Issue
Block a user