mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
I have some random ideas sometimes
- Adjusting some RequiredTypes fitting their partners/default behavior - A plot doesn't need to be claimed to get the center - Adapting another gamemode acronym - Fix copyFile to adapt the latest changes - Removing HastebinUtility, we have our own paste service
This commit is contained in:
parent
bb97fb8e19
commit
41052b27a0
8 changed files with 7 additions and 79 deletions
|
@ -251,12 +251,12 @@ import java.util.zip.ZipInputStream;
|
|||
copyFile("addplots.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("addsigns.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("automerge.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("fixborders.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("furthest.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("mycommand.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("setbiomes.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("start.js", Settings.Paths.SCRIPTS);
|
||||
copyFile("town.template", Settings.Paths.TEMPLATES);
|
||||
copyFile("skyblock.template", Settings.Paths.TEMPLATES);
|
||||
copyFile("bridge.template", Settings.Paths.TEMPLATES);
|
||||
copyFile("de-DE.yml", Settings.Paths.TRANSLATIONS);
|
||||
copyFile("es-ES.yml", Settings.Paths.TRANSLATIONS);
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.concurrent.CompletableFuture;
|
|||
@CommandDeclaration(command = "leave",
|
||||
description = "Removes self from being trusted or a member of the plot",
|
||||
permission = "plots.leave", category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE) public class Leave extends Command {
|
||||
requiredType = RequiredType.PLAYER) public class Leave extends Command {
|
||||
public Leave() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||
*/
|
||||
@CommandDeclaration(command = "middle", aliases = {"center", "centre"},
|
||||
description = "Teleports you to the center of the plot", usage = "/plot middle",
|
||||
category = CommandCategory.TELEPORT, requiredType = RequiredType.NONE) public class Middle
|
||||
category = CommandCategory.TELEPORT, requiredType = RequiredType.PLAYER) public class Middle
|
||||
extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||
|
@ -20,9 +20,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||
if (plot == null) {
|
||||
return sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
}
|
||||
player.teleport(plot.getCenter());
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@CommandDeclaration(command = "relight", description = "Relight your plot", usage = "/plot relight",
|
||||
category = CommandCategory.DEBUG) public class Relight extends Command {
|
||||
category = CommandCategory.DEBUG, requiredType = RequiredType.PLAYER) public class Relight extends Command {
|
||||
public Relight() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.UUID;
|
|||
|
||||
@CommandDeclaration(command = "remove", aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"},
|
||||
description = "Remove a player from a plot", usage = "/plot remove <player>",
|
||||
category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.remove") public class Remove extends SubCommand {
|
||||
|
||||
public Remove() {
|
||||
|
|
|
@ -10,7 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|||
|
||||
@CommandDeclaration(command = "sethome", permission = "plots.set.home",
|
||||
description = "Set the plot home to your current position", usage = "/plot sethome [none]",
|
||||
aliases = {"sh", "seth"}, category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE)
|
||||
aliases = {"sh", "seth"}, category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER)
|
||||
public class SetHome extends SetCommand {
|
||||
|
||||
@Override public boolean set(PlotPlayer player, Plot plot, String value) {
|
||||
|
|
|
@ -27,6 +27,7 @@ public class GameModeFlag extends Flag<PlotGameMode> {
|
|||
case "2":
|
||||
return PlotGameMode.ADVENTURE;
|
||||
case "spectator":
|
||||
case "sp":
|
||||
case "3":
|
||||
return PlotGameMode.SPECTATOR;
|
||||
default:
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
package com.github.intellectualsites.plotsquared.plot.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class HastebinUtility {
|
||||
|
||||
public static final String BIN_URL = "https://hastebin.com/documents", USER_AGENT =
|
||||
"Mozilla/5.0";
|
||||
public static final Pattern PATTERN = Pattern.compile("\\{\"key\":\"([\\S\\s]*)\"\\}");
|
||||
|
||||
public static String upload(final String string) throws IOException {
|
||||
final URL url = new URL(BIN_URL);
|
||||
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("User-Agent", USER_AGENT);
|
||||
connection.setDoOutput(true);
|
||||
|
||||
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||
outputStream.write(string.getBytes());
|
||||
outputStream.flush();
|
||||
}
|
||||
|
||||
StringBuilder response;
|
||||
try (BufferedReader in = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream()))) {
|
||||
response = new StringBuilder();
|
||||
|
||||
String inputLine;
|
||||
while ((inputLine = in.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
}
|
||||
|
||||
Matcher matcher = PATTERN.matcher(response.toString());
|
||||
if (matcher.matches()) {
|
||||
return "https://hastebin.com/" + matcher.group(1);
|
||||
} else {
|
||||
throw new RuntimeException("Couldn't read response!");
|
||||
}
|
||||
}
|
||||
|
||||
public static String upload(final File file) throws IOException {
|
||||
List<String> lines = new ArrayList<>();
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
int i = 0;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
final StringBuilder content = new StringBuilder();
|
||||
for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) {
|
||||
content.append(lines.get(i)).append("\n");
|
||||
}
|
||||
return upload(content.toString());
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue