mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-15 02:59:06 +02:00
2.9 -> 3.0 (new commands and signs)
This commit is contained in:
@@ -212,24 +212,24 @@ kits:
|
||||
# We recommend not enabling chest protection signs if you don't intend to use them, (or are using LWC/Lockette).
|
||||
|
||||
enabledSigns:
|
||||
#- color
|
||||
#- balance
|
||||
#- buy
|
||||
#- sell
|
||||
#- trade
|
||||
#- free
|
||||
#- disposal
|
||||
#- warp
|
||||
#- kit
|
||||
#- mail
|
||||
#- enchant
|
||||
#- gamemode
|
||||
#- heal
|
||||
#- spawnmob
|
||||
#- time
|
||||
#- weather
|
||||
#- protection
|
||||
|
||||
#- buy
|
||||
#- disposal
|
||||
#- enchant
|
||||
#- free
|
||||
#- gamemode
|
||||
#- heal
|
||||
#- info
|
||||
#- kit
|
||||
#- mail
|
||||
#- protection
|
||||
#- repair
|
||||
#- sell
|
||||
#- spawnmob
|
||||
#- time
|
||||
#- trade
|
||||
#- warp
|
||||
#- weather
|
||||
|
||||
# How many times per second can Essentials signs be interacted with.
|
||||
# Values should be between 1-20, 20 being virtually no lag protection.s
|
||||
|
20
Essentials/src/net/ess3/commands/Commandworkbench.java
Normal file
20
Essentials/src/net/ess3/commands/Commandworkbench.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package net.ess3.commands;
|
||||
|
||||
import net.ess3.api.server.Server;
|
||||
import net.ess3.user.User;
|
||||
|
||||
|
||||
public class Commandworkbench extends EssentialsCommand
|
||||
{
|
||||
public Commandworkbench()
|
||||
{
|
||||
super("workbench");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
user.openWorkbench(null, true);
|
||||
}
|
||||
}
|
@@ -438,6 +438,10 @@ commands:
|
||||
description: Determine the username behind a nickname.
|
||||
usage: /<command> <nickname>
|
||||
aliases: [ewhois]
|
||||
workbench:
|
||||
description: Opens up a workbench
|
||||
usage: /<command>
|
||||
aliases: [eworkbench,wb,ewb,wbench,ewbench]
|
||||
world:
|
||||
description: Switch between worlds.
|
||||
usage: /<command> [world]
|
||||
|
@@ -19,16 +19,30 @@ public class SignGameMode extends EssentialsSign
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
validateTrade(sign, 1, ess);
|
||||
final String gamemode = sign.getLine(1);
|
||||
if (gamemode.isEmpty())
|
||||
{
|
||||
sign.setLine(1, "Survival");
|
||||
}
|
||||
|
||||
validateTrade(sign, 2, ess);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
final Trade charge = getTrade(sign, 1, ess);
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
final String mode = sign.getLine(1).trim();
|
||||
|
||||
if (mode.isEmpty())
|
||||
{
|
||||
throw new SignException(_("invalidSignLine", 2));
|
||||
}
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
|
||||
//this needs to be fixed
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
player.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||
charge.charge(player);
|
||||
|
58
EssentialsSigns/src/net/ess3/signs/SignInfo.java
Normal file
58
EssentialsSigns/src/net/ess3/signs/SignInfo.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package net.ess3.signs;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import net.ess3.api.ChargeException;
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.economy.Trade;
|
||||
import net.ess3.user.User;
|
||||
import net.ess3.utils.textreader.IText;
|
||||
import net.ess3.utils.textreader.KeywordReplacer;
|
||||
import net.ess3.utils.textreader.TextInput;
|
||||
import net.ess3.utils.textreader.TextPager;
|
||||
|
||||
|
||||
public class SignInfo extends EssentialsSign
|
||||
{
|
||||
public SignInfo()
|
||||
{
|
||||
super("Info");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
validateTrade(sign, 3, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
final Trade charge = getTrade(sign, 3, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
String chapter = sign.getLine(1);
|
||||
String page = sign.getLine(2);
|
||||
|
||||
final IText input;
|
||||
try
|
||||
{
|
||||
input = new TextInput(player, "info", true, ess);
|
||||
final IText output = new KeywordReplacer(input, player, ess);
|
||||
final TextPager pager = new TextPager(output);
|
||||
pager.showPage(chapter, page, null, player);
|
||||
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
55
EssentialsSigns/src/net/ess3/signs/SignRepair.java
Normal file
55
EssentialsSigns/src/net/ess3/signs/SignRepair.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package net.ess3.signs;
|
||||
|
||||
import net.ess3.api.IEssentials;
|
||||
import net.ess3.commands.Commandrepair;
|
||||
import net.ess3.economy.Trade;
|
||||
import net.ess3.user.User;
|
||||
|
||||
|
||||
public class SignRepair extends EssentialsSign
|
||||
{
|
||||
public SignRepair()
|
||||
{
|
||||
super("Repair");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
|
||||
{
|
||||
final String repairTarget = sign.getLine(1);
|
||||
if (repairTarget.isEmpty())
|
||||
{
|
||||
sign.setLine(1, "Hand");
|
||||
}
|
||||
else if (!repairTarget.equalsIgnoreCase("all") && !repairTarget.equalsIgnoreCase("hand") )
|
||||
{
|
||||
throw new SignException(_("invalidSignLine", 2));
|
||||
}
|
||||
validateTrade(sign, 2, ess);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException
|
||||
{
|
||||
final Trade charge = getTrade(sign, 2, ess);
|
||||
charge.isAffordableFor(player);
|
||||
|
||||
Commandrepair command = new Commandrepair();
|
||||
command.setEssentials(ess);
|
||||
String[] args = new String[]
|
||||
{
|
||||
sign.getLine(1)
|
||||
};
|
||||
try
|
||||
{
|
||||
command.run(ess.getServer(), player, "repair", args);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new SignException(ex.getMessage(), ex);
|
||||
}
|
||||
charge.charge(player);
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -10,9 +10,11 @@ public enum Signs
|
||||
FREE(new SignFree()),
|
||||
GAMEMODE(new SignGameMode()),
|
||||
HEAL(new SignHeal()),
|
||||
INFO(new SignInfo()),
|
||||
KIT(new SignKit()),
|
||||
MAIL(new SignMail()),
|
||||
PROTECTION(new SignProtection()),
|
||||
REPAIR(new SignRepair()),
|
||||
SELL(new SignSell()),
|
||||
SPAWNMOB(new SignSpawnmob()),
|
||||
TIME(new SignTime()),
|
||||
|
Reference in New Issue
Block a user