mirror of
https://github.com/TotalFreedomMC/TotalFreedomMod.git
synced 2024-05-20 19:41:24 +00:00
fix some bugs
This commit is contained in:
parent
d323807675
commit
82b4873b19
6
.github/workflows/maven.yml
vendored
6
.github/workflows/maven.yml
vendored
|
@ -4,14 +4,12 @@ on: [push]
|
|||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Set up JDK 1.8
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
java-version: 16
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.totalfreedom.totalfreedommod.caging;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -89,8 +90,7 @@ public class CageData
|
|||
try
|
||||
{
|
||||
Skull skull = (Skull)block.getState();
|
||||
// This may or may not work in future versions of spigot
|
||||
skull.setOwner(input);
|
||||
skull.setOwningPlayer(Bukkit.getOfflinePlayer(input));
|
||||
skull.update();
|
||||
}
|
||||
catch (ClassCastException ignored)
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
|
@ -19,7 +20,6 @@ import org.bukkit.entity.Player;
|
|||
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
||||
public class Command_cage extends FreedomCommand
|
||||
{
|
||||
|
||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||
{
|
||||
if (args.length == 0)
|
||||
|
@ -60,28 +60,38 @@ public class Command_cage extends FreedomCommand
|
|||
final String s = args[1];
|
||||
switch (s)
|
||||
{
|
||||
case "head":
|
||||
{
|
||||
case "head" -> {
|
||||
outerMaterial = Material.PLAYER_HEAD;
|
||||
if (args.length >= 3)
|
||||
{
|
||||
if (!FUtil.isValidUsername(args[2]))
|
||||
{
|
||||
msg("That is an invalid player name!", ChatColor.RED);
|
||||
return true;
|
||||
}
|
||||
skullName = args[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
outerMaterial = Material.SKELETON_SKULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "block":
|
||||
{
|
||||
if (Material.matchMaterial(args[2]) != null)
|
||||
case "block" -> {
|
||||
if (args.length == 3)
|
||||
{
|
||||
outerMaterial = Material.matchMaterial(args[2]);
|
||||
break;
|
||||
String block = args[2].toUpperCase();
|
||||
if (Material.matchMaterial(block) != null && Objects.requireNonNull(Material.getMaterial(block)).isBlock())
|
||||
{
|
||||
outerMaterial = Material.matchMaterial(block);
|
||||
break;
|
||||
}
|
||||
msg("The block you specified is invalid.", ChatColor.RED);
|
||||
}
|
||||
msg("Invalid block!", ChatColor.RED);
|
||||
break;
|
||||
else
|
||||
{
|
||||
msg("You must specify a block.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +107,7 @@ public class Command_cage extends FreedomCommand
|
|||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
||||
}
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
|
||||
if (outerMaterial == Material.PLAYER_HEAD)
|
||||
{
|
||||
|
|
|
@ -47,6 +47,8 @@ public enum ConfigEntry
|
|||
//
|
||||
HTTPD_ENABLED(Boolean.class, "httpd.enabled"),
|
||||
HTTPD_HOST(String.class, "httpd.host"),
|
||||
HTTPD_REVERSE_PROXY(Boolean.class, "httpd.reverse_proxy"),
|
||||
HTTPD_REVERSE_PROXY_PORT(Integer.class, "httpd.reverse_proxy_port"),
|
||||
HTTPD_PORT(Integer.class, "httpd.port"),
|
||||
HTTPD_PUBLIC_FOLDER(String.class, "httpd.public_folder"),
|
||||
//
|
||||
|
|
|
@ -473,9 +473,9 @@ public class Discord extends FreedomService
|
|||
if (bot != null)
|
||||
{
|
||||
messageChatChannel("**Server has stopped**");
|
||||
bot.shutdown();
|
||||
FLog.info("Discord verification bot has successfully shutdown.");
|
||||
}
|
||||
|
||||
FLog.info("Discord verification bot has successfully shutdown.");
|
||||
}
|
||||
|
||||
public String deformat(String input)
|
||||
|
|
|
@ -42,10 +42,10 @@ public class Module_index extends HTTPDModule
|
|||
|
||||
// <a href="http://localhost:28966/index">index</a>
|
||||
sb.append("<ul><li>");
|
||||
sb.append("<a href=\"https://")
|
||||
sb.append(ConfigEntry.HTTPD_REVERSE_PROXY.getBoolean() ? "<a href=\"https://" : "<a href=\"http://")
|
||||
.append(ConfigEntry.HTTPD_HOST.getString())
|
||||
.append(":")
|
||||
.append("28966")
|
||||
.append(ConfigEntry.HTTPD_REVERSE_PROXY.getBoolean() ? ConfigEntry.HTTPD_REVERSE_PROXY_PORT : ConfigEntry.HTTPD_PORT)
|
||||
.append("/")
|
||||
.append(name)
|
||||
.append("\">")
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
public class Module_schematic extends HTTPDModule
|
||||
{
|
||||
|
||||
private static final File SCHEMATIC_FOLDER = new File("./plugins/WorldEdit/schematics/");
|
||||
private static final String REQUEST_FORM_FILE_ELEMENT_NAME = "schematicFile";
|
||||
private static final Pattern SCHEMATIC_FILENAME_LC = Pattern.compile("^[a-z0-9_'!,\\-]*\\.(schem|schematic)$");
|
||||
|
@ -162,16 +161,16 @@ public class Module_schematic extends HTTPDModule
|
|||
{
|
||||
out.append(HTMLGenerationTools.heading("Schematic Submodules", 1));
|
||||
out.append("<ul><li>");
|
||||
out.append("<a href=\"https://")
|
||||
out.append(ConfigEntry.HTTPD_REVERSE_PROXY.getBoolean() ? "<a href=\"https://" : "<a href=\"http://")
|
||||
.append(ConfigEntry.HTTPD_HOST.getString())
|
||||
.append(":")
|
||||
.append("28966")
|
||||
.append(ConfigEntry.HTTPD_REVERSE_PROXY.getBoolean() ? ConfigEntry.HTTPD_REVERSE_PROXY_PORT : ConfigEntry.HTTPD_PORT)
|
||||
.append("/schematic/list")
|
||||
.append("\">Schematic List</a></li>")
|
||||
.append("<li><a href=\"https://")
|
||||
.append(ConfigEntry.HTTPD_REVERSE_PROXY.getBoolean() ? "<a href=\"https://" : "<a href=\"http://")
|
||||
.append(ConfigEntry.HTTPD_HOST.getString())
|
||||
.append(":")
|
||||
.append("28966")
|
||||
.append(ConfigEntry.HTTPD_REVERSE_PROXY.getBoolean() ? ConfigEntry.HTTPD_REVERSE_PROXY_PORT : ConfigEntry.HTTPD_PORT)
|
||||
.append("/schematic/upload")
|
||||
.append("\">Upload Schematics</a></li></ul>");
|
||||
break;
|
||||
|
|
|
@ -1,5 +1,32 @@
|
|||
package me.totalfreedom.totalfreedommod.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.SplittableRandom;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
@ -20,18 +47,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.json.simple.JSONArray;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
public class FUtil
|
||||
|
@ -388,6 +403,10 @@ public class FUtil
|
|||
add("s");
|
||||
}};
|
||||
|
||||
public static boolean isValidUsername(String s) {
|
||||
return s != null && s.matches("^[a-zA-Z0-9_]*$");
|
||||
}
|
||||
|
||||
private static long a(String parse)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
|
@ -751,7 +751,11 @@ service_checker_url: http://status.mojang.com/check
|
|||
httpd:
|
||||
enabled: true
|
||||
host: play.totalfreedom.me
|
||||
# Leave this at false unless you know what you're doing. This will change the HTTPD server to use HTTPS
|
||||
reverse_proxy: false
|
||||
port: 28966
|
||||
# Does not change anything unless the reverse proxy option is set to true
|
||||
reverse_proxy_port: 28967
|
||||
public_folder: ./public_html
|
||||
|
||||
# Inactivity Auto-Kick (Requires Essentials)
|
||||
|
|
Loading…
Reference in a new issue