Handle /p f add message properly

- Leave a note if the database connection has been established properly
This commit is contained in:
NotMyFault 2021-07-12 22:55:28 +02:00
parent 2d1e3b8c03
commit a797d748ea
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
3 changed files with 11 additions and 13 deletions

View File

@ -1300,6 +1300,7 @@ public class PlotSquared {
area.loadDefaultConfiguration(section); area.loadDefaultConfiguration(section);
} }
this.clustersTmp = DBFunc.getClusters(); this.clustersTmp = DBFunc.getClusters();
LOGGER.info("Connection to database established. Type: {}", Storage.MySQL.USE ? "MySQL" : "SQLite");
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
LOGGER.error( LOGGER.error(
"Failed to open database connection ({}). Disabling PlotSquared", "Failed to open database connection ({}). Disabling PlotSquared",

View File

@ -30,9 +30,7 @@ import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
/** /**
* @deprecated Deprecated in favor of "/plot toggle wea" and scheduled for removal within the next major release. * @deprecated Deprecated in favor of "/plot toggle chat" and scheduled for removal within the next major release.
* <br>
* Other command aliases are "/plot toggle worldedit", "/plot toggle we".
*/ */
@Deprecated(forRemoval = true) @Deprecated(forRemoval = true)
@CommandDeclaration(command = "chat", @CommandDeclaration(command = "chat",

View File

@ -419,8 +419,8 @@ public final class FlagCommand extends Command {
player.sendMessage(TranslatableCaption.of("flag.flag_not_added")); player.sendMessage(TranslatableCaption.of("flag.flag_not_added"));
return; return;
} }
player.sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", String.valueOf(event.getFlag())), player.sendMessage(TranslatableCaption.of("flag.flag_added"), Template.of("flag", String.valueOf(args[0])),
Template.of("value", String.valueOf(event.getFlag().getValue()))); Template.of("value", String.valueOf(parsed)));
} }
@CommandDeclaration(command = "remove", @CommandDeclaration(command = "remove",
@ -468,11 +468,10 @@ public final class FlagCommand extends Command {
return; return;
} }
} }
if (args.length == 2 && flag instanceof ListFlag) { if (args.length == 2 && flag instanceof final ListFlag<?, ?> listFlag) {
String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " "); String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
final ListFlag listFlag = (ListFlag) flag; final List<?> list =
final List list = new ArrayList<>(plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass()));
new ArrayList(plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass()));
final PlotFlag parsedFlag; final PlotFlag parsedFlag;
try { try {
parsedFlag = listFlag.parse(value); parsedFlag = listFlag.parse(value);
@ -485,16 +484,16 @@ public final class FlagCommand extends Command {
); );
return; return;
} }
if (((List) parsedFlag.getValue()).isEmpty()) { if (((List<?>) parsedFlag.getValue()).isEmpty()) {
player.sendMessage(TranslatableCaption.of("flag.flag_not_removed")); player.sendMessage(TranslatableCaption.of("flag.flag_not_removed"));
return; return;
} }
if (list.removeAll((List) parsedFlag.getValue())) { if (list.removeAll((List) parsedFlag.getValue())) {
if (list.isEmpty()) { if (list.isEmpty()) {
if (plot.removeFlag(flag)) { if (plot.removeFlag(flag)) {
player.sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", String.valueOf(flag)), Template.of( player.sendMessage(TranslatableCaption.of("flag.flag_removed"), Template.of("flag", args[0]), Template.of(
"value", "value",
String.valueOf(parsedFlag.getValue()) String.valueOf(flag)
)); ));
return; return;
} else { } else {
@ -502,7 +501,7 @@ public final class FlagCommand extends Command {
return; return;
} }
} else { } else {
PlotFlag plotFlag = parsedFlag.createFlagInstance(list); PlotFlag<?, ?> plotFlag = parsedFlag.createFlagInstance(list);
PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot); PlotFlagAddEvent addEvent = new PlotFlagAddEvent(plotFlag, plot);
if (addEvent.getEventResult() == Result.DENY) { if (addEvent.getEventResult() == Result.DENY) {
player.sendMessage( player.sendMessage(