mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01: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
@ -251,12 +251,12 @@ import java.util.zip.ZipInputStream;
|
|||||||
copyFile("addplots.js", Settings.Paths.SCRIPTS);
|
copyFile("addplots.js", Settings.Paths.SCRIPTS);
|
||||||
copyFile("addsigns.js", Settings.Paths.SCRIPTS);
|
copyFile("addsigns.js", Settings.Paths.SCRIPTS);
|
||||||
copyFile("automerge.js", Settings.Paths.SCRIPTS);
|
copyFile("automerge.js", Settings.Paths.SCRIPTS);
|
||||||
|
copyFile("fixborders.js", Settings.Paths.SCRIPTS);
|
||||||
copyFile("furthest.js", Settings.Paths.SCRIPTS);
|
copyFile("furthest.js", Settings.Paths.SCRIPTS);
|
||||||
copyFile("mycommand.js", Settings.Paths.SCRIPTS);
|
copyFile("mycommand.js", Settings.Paths.SCRIPTS);
|
||||||
copyFile("setbiomes.js", Settings.Paths.SCRIPTS);
|
copyFile("setbiomes.js", Settings.Paths.SCRIPTS);
|
||||||
copyFile("start.js", Settings.Paths.SCRIPTS);
|
copyFile("start.js", Settings.Paths.SCRIPTS);
|
||||||
copyFile("town.template", Settings.Paths.TEMPLATES);
|
copyFile("town.template", Settings.Paths.TEMPLATES);
|
||||||
copyFile("skyblock.template", Settings.Paths.TEMPLATES);
|
|
||||||
copyFile("bridge.template", Settings.Paths.TEMPLATES);
|
copyFile("bridge.template", Settings.Paths.TEMPLATES);
|
||||||
copyFile("de-DE.yml", Settings.Paths.TRANSLATIONS);
|
copyFile("de-DE.yml", Settings.Paths.TRANSLATIONS);
|
||||||
copyFile("es-ES.yml", Settings.Paths.TRANSLATIONS);
|
copyFile("es-ES.yml", Settings.Paths.TRANSLATIONS);
|
||||||
|
@ -16,7 +16,7 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
@CommandDeclaration(command = "leave",
|
@CommandDeclaration(command = "leave",
|
||||||
description = "Removes self from being trusted or a member of the plot",
|
description = "Removes self from being trusted or a member of the plot",
|
||||||
permission = "plots.leave", category = CommandCategory.CLAIMING,
|
permission = "plots.leave", category = CommandCategory.CLAIMING,
|
||||||
requiredType = RequiredType.NONE) public class Leave extends Command {
|
requiredType = RequiredType.PLAYER) public class Leave extends Command {
|
||||||
public Leave() {
|
public Leave() {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||||||
*/
|
*/
|
||||||
@CommandDeclaration(command = "middle", aliases = {"center", "centre"},
|
@CommandDeclaration(command = "middle", aliases = {"center", "centre"},
|
||||||
description = "Teleports you to the center of the plot", usage = "/plot middle",
|
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 {
|
extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer player, String[] arguments) {
|
@Override public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||||
@ -20,9 +20,6 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return sendMessage(player, Captions.NOT_IN_PLOT);
|
return sendMessage(player, Captions.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner()) {
|
|
||||||
return sendMessage(player, Captions.PLOT_UNOWNED);
|
|
||||||
}
|
|
||||||
player.teleport(plot.getCenter());
|
player.teleport(plot.getCenter());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
|||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@CommandDeclaration(command = "relight", description = "Relight your plot", usage = "/plot relight",
|
@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() {
|
public Relight() {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
@CommandDeclaration(command = "remove", aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"},
|
@CommandDeclaration(command = "remove", aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"},
|
||||||
description = "Remove a player from a plot", usage = "/plot remove <player>",
|
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 {
|
permission = "plots.remove") public class Remove extends SubCommand {
|
||||||
|
|
||||||
public Remove() {
|
public Remove() {
|
||||||
|
@ -10,7 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|||||||
|
|
||||||
@CommandDeclaration(command = "sethome", permission = "plots.set.home",
|
@CommandDeclaration(command = "sethome", permission = "plots.set.home",
|
||||||
description = "Set the plot home to your current position", usage = "/plot sethome [none]",
|
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 {
|
public class SetHome extends SetCommand {
|
||||||
|
|
||||||
@Override public boolean set(PlotPlayer player, Plot plot, String value) {
|
@Override public boolean set(PlotPlayer player, Plot plot, String value) {
|
||||||
|
@ -27,6 +27,7 @@ public class GameModeFlag extends Flag<PlotGameMode> {
|
|||||||
case "2":
|
case "2":
|
||||||
return PlotGameMode.ADVENTURE;
|
return PlotGameMode.ADVENTURE;
|
||||||
case "spectator":
|
case "spectator":
|
||||||
|
case "sp":
|
||||||
case "3":
|
case "3":
|
||||||
return PlotGameMode.SPECTATOR;
|
return PlotGameMode.SPECTATOR;
|
||||||
default:
|
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 New Issue
Block a user