mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-16 03:24:31 +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).
|
# We recommend not enabling chest protection signs if you don't intend to use them, (or are using LWC/Lockette).
|
||||||
|
|
||||||
enabledSigns:
|
enabledSigns:
|
||||||
#- color
|
|
||||||
#- balance
|
#- balance
|
||||||
#- buy
|
#- buy
|
||||||
#- sell
|
#- disposal
|
||||||
#- trade
|
#- enchant
|
||||||
#- free
|
#- free
|
||||||
#- disposal
|
#- gamemode
|
||||||
#- warp
|
#- heal
|
||||||
#- kit
|
#- info
|
||||||
#- mail
|
#- kit
|
||||||
#- enchant
|
#- mail
|
||||||
#- gamemode
|
#- protection
|
||||||
#- heal
|
#- repair
|
||||||
#- spawnmob
|
#- sell
|
||||||
#- time
|
#- spawnmob
|
||||||
#- weather
|
#- time
|
||||||
#- protection
|
#- trade
|
||||||
|
#- warp
|
||||||
|
#- weather
|
||||||
|
|
||||||
# How many times per second can Essentials signs be interacted with.
|
# How many times per second can Essentials signs be interacted with.
|
||||||
# Values should be between 1-20, 20 being virtually no lag protection.s
|
# 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.
|
description: Determine the username behind a nickname.
|
||||||
usage: /<command> <nickname>
|
usage: /<command> <nickname>
|
||||||
aliases: [ewhois]
|
aliases: [ewhois]
|
||||||
|
workbench:
|
||||||
|
description: Opens up a workbench
|
||||||
|
usage: /<command>
|
||||||
|
aliases: [eworkbench,wb,ewb,wbench,ewbench]
|
||||||
world:
|
world:
|
||||||
description: Switch between worlds.
|
description: Switch between worlds.
|
||||||
usage: /<command> [world]
|
usage: /<command> [world]
|
||||||
|
@@ -19,16 +19,30 @@ public class SignGameMode extends EssentialsSign
|
|||||||
@Override
|
@Override
|
||||||
protected boolean onSignCreate(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
|
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);
|
charge.isAffordableFor(player);
|
||||||
|
|
||||||
|
//this needs to be fixed
|
||||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||||
player.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
player.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||||
charge.charge(player);
|
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()),
|
FREE(new SignFree()),
|
||||||
GAMEMODE(new SignGameMode()),
|
GAMEMODE(new SignGameMode()),
|
||||||
HEAL(new SignHeal()),
|
HEAL(new SignHeal()),
|
||||||
|
INFO(new SignInfo()),
|
||||||
KIT(new SignKit()),
|
KIT(new SignKit()),
|
||||||
MAIL(new SignMail()),
|
MAIL(new SignMail()),
|
||||||
PROTECTION(new SignProtection()),
|
PROTECTION(new SignProtection()),
|
||||||
|
REPAIR(new SignRepair()),
|
||||||
SELL(new SignSell()),
|
SELL(new SignSell()),
|
||||||
SPAWNMOB(new SignSpawnmob()),
|
SPAWNMOB(new SignSpawnmob()),
|
||||||
TIME(new SignTime()),
|
TIME(new SignTime()),
|
||||||
|
Reference in New Issue
Block a user