Add option to change disposal title via sign (#3269)

Closes #2628.
This commit is contained in:
Josh Roy 2020-06-05 11:16:47 -04:00 committed by GitHub
parent 25c7ebcf39
commit dc2462c277
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.User;
import net.ess3.api.IEssentials;
@ -11,9 +12,23 @@ public class SignDisposal extends EssentialsSign {
super("Disposal");
}
@Override
protected boolean onSignCreate(ISign sign, User player, String username, IEssentials ess) throws SignException, ChargeException {
if (!player.isAuthorized("essentials.signs.disposal.name")) {
sign.setLine(1, "");
sign.setLine(2, "");
sign.setLine(3, "");
}
return true;
}
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) {
player.getBase().openInventory(ess.getServer().createInventory(player.getBase(), 36, tl("disposal")));
String title = (sign.getLine(1) + " " + sign.getLine(2) + " " + sign.getLine(3)).trim();
if (title.isEmpty()) {
title = tl("disposal");
}
player.getBase().openInventory(ess.getServer().createInventory(player.getBase(), 36, title));
return true;
}
}