25 Commits

Author SHA1 Message Date
1d0fb85fa1 Remove maven local 2022-06-13 23:19:24 -05:00
665a2f4e72 Merge branch '1.19' 2022-06-13 23:18:39 -05:00
9c67911c1b Plex v1.1.1 2022-06-13 23:17:10 -05:00
f1ebbc3664 Fix incorrect permission 2022-06-09 21:12:19 -05:00
4aa3ae7c50 Update Blossom
(cherry picked from commit 08e2f31eae)
2022-06-08 17:21:35 -05:00
08e2f31eae Update Blossom 2022-06-08 17:20:44 -05:00
a1c009909d Lang to lang3 2022-06-08 15:09:42 -05:00
7d2c44975d Update for 1.19 2022-06-08 14:37:16 -05:00
b2faec70a9 oops 2022-06-08 14:33:04 -05:00
a0cca2aea5 Update codeql-analysis.yml 2022-06-08 14:32:09 -05:00
337334d403 Update gradle.yml 2022-06-08 14:30:23 -05:00
2e8fe8767e Update codeql-analysis.yml 2022-06-08 14:28:25 -05:00
dbdf720a9e Update workflow 2022-06-08 14:22:14 -05:00
5a9d6dd60d fix messages 2022-06-05 22:55:11 -05:00
84a9535123 ok so apparently this matters 2022-06-05 22:39:41 -05:00
41aff575d0 big think, it should be public 2022-06-05 22:34:16 -05:00
65b8188b37 Merge branch 'master' of https://github.com/plexusorg/Plex 2022-06-05 22:27:25 -05:00
c8a35c8e0e Add the ability to add messages into Plex
Code originally from TFMExtras by taah
2022-06-05 22:27:24 -05:00
13acf7ba9d Properly disable explosions (#45)
* Remove unused import

* Properly disable explosions
2022-06-05 15:29:49 -05:00
5fe48cfd7f Allow toggling redstone 2022-06-04 22:48:18 -05:00
abf2aca0f2 Resolves #12 (major config changes)
Also allows more customization within the updater
2022-06-04 22:08:13 -05:00
dc4ac39fe4 Switch legacy to MiniMessage 2022-06-04 21:31:36 -05:00
1ae8e779b1 Merge pull request #44 from plexusorg/codeql-readme
Add CodeQL to the README.md
2022-06-01 01:56:58 -07:00
658f4a4b05 Add CodeQL to the README.md 2022-06-01 09:55:40 +01:00
7ccfb2ad27 Back to snapshot 2022-05-28 22:55:48 -05:00
32 changed files with 274 additions and 135 deletions

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,4 @@
# Plex [![Build Status](https://ci.plex.us.org/job/Plex/job/master/badge/icon)](https://ci.plex.us.org/job/Plex/job/master/)
# Plex [![Build Status](https://ci.plex.us.org/job/Plex/job/master/badge/icon)](https://ci.plex.us.org/job/Plex/job/master/) ![CodeQL](https://github.com/plexusorg/Plex/workflows/CodeQL/badge.svg)
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 doesnt have. For example, there is full support for using a

View File

@ -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"
}

View File

@ -5,7 +5,7 @@ plugins {
}
group = "dev.plex"
version = "1.1"
version = "1.1.1"
description = "Plex"
subprojects {

View File

@ -1,5 +1,5 @@
plugins {
id("net.kyori.blossom") version "1.2.0"
id("net.kyori.blossom") version "1.3.0"
}
group = rootProject.group

View File

@ -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"
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -38,9 +38,8 @@ public class BlockListener extends PlexListener
{
blockedBlocks.add(Material.valueOf(block.toUpperCase()));
}
catch (IllegalArgumentException e)
catch (IllegalArgumentException ignored)
{
//
}
}
}

View File

@ -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;

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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)
{

View File

@ -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;

View File

@ -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
{

View File

@ -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");

View File

@ -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

View File

@ -8,3 +8,6 @@ fluidspread: true
# Should drops be enabled?
drops: true
# Should redstone be enabled?
redstone: true