Added a buffer variable system.
This commit is contained in:
parent
33efff8915
commit
c9983e8032
27
plugin.yml
27
plugin.yml
@ -34,9 +34,16 @@ permissions:
|
||||
mcore.usys.aspect.list: {description: list aspects, default: false}
|
||||
mcore.usys.aspect.show: {description: show aspect, default: false}
|
||||
mcore.usys.aspect.use: {description: set multiverse for aspect, default: false}
|
||||
mcore.buffer: {description: use the buffer command, default: false}
|
||||
mcore.buffer.print: {description: print buffer, default: false}
|
||||
mcore.buffer.clear: {description: clear buffer, default: false}
|
||||
mcore.buffer.set: {description: set buffer, default: false}
|
||||
mcore.buffer.add: {description: add to buffer, default: false}
|
||||
mcore.buffer.whitespace: {description: add whitespace to buffer, default: false}
|
||||
# misc
|
||||
mcore.notpdelay: {description: teleport without delay, default: false}
|
||||
mcore.variablebook: {description: replace ***book*** with content of book in your hand, default: false}
|
||||
mcore.variable.book: {description: replace ***book*** with content of book in your hand, default: false}
|
||||
mcore.variable.buffer: {description: replace ***buffer*** with content of your buffer, default: false}
|
||||
# -------------------------------------------- #
|
||||
# STAR NOTATION
|
||||
# -------------------------------------------- #
|
||||
@ -67,8 +74,15 @@ permissions:
|
||||
mcore.usys.aspect.list: true
|
||||
mcore.usys.aspect.show: true
|
||||
mcore.usys.aspect.use: true
|
||||
mcore.buffer: true
|
||||
mcore.buffer.print: true
|
||||
mcore.buffer.clear: true
|
||||
mcore.buffer.set: true
|
||||
mcore.buffer.add: true
|
||||
mcore.buffer.whitespace: true
|
||||
mcore.notpdelay: true
|
||||
mcore.variablebook: true
|
||||
mcore.variable.book: true
|
||||
mcore.variable.buffer: true
|
||||
# -------------------------------------------- #
|
||||
# KITS
|
||||
# -------------------------------------------- #
|
||||
@ -99,8 +113,15 @@ permissions:
|
||||
mcore.usys.aspect: true
|
||||
mcore.usys.aspect.list: true
|
||||
mcore.usys.aspect.show: true
|
||||
mcore.buffer: true
|
||||
mcore.buffer.print: true
|
||||
mcore.buffer.clear: true
|
||||
mcore.buffer.set: true
|
||||
mcore.buffer.add: true
|
||||
mcore.buffer.whitespace: true
|
||||
mcore.notpdelay: true
|
||||
mcore.variablebook: true
|
||||
mcore.variable.book: true
|
||||
mcore.variable.buffer: true
|
||||
mcore.kit.rank0:
|
||||
default: false
|
||||
children:
|
||||
|
139
src/com/massivecraft/mcore/EngineMCoreVariable.java
Normal file
139
src/com/massivecraft/mcore/EngineMCoreVariable.java
Normal file
@ -0,0 +1,139 @@
|
||||
package com.massivecraft.mcore;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.massivecraft.mcore.util.IdUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class EngineMCoreVariable extends EngineAbstract
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static EngineMCoreVariable i = new EngineMCoreVariable();
|
||||
public static EngineMCoreVariable get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Plugin getPlugin()
|
||||
{
|
||||
return MCore.get();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// VARIABLE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void variable(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
event.setMessage(variable(event.getPlayer(), event.getMessage()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void variable(AsyncPlayerChatEvent event)
|
||||
{
|
||||
event.setMessage(variable(event.getPlayer(), event.getMessage()));
|
||||
}
|
||||
|
||||
public static String variable(Player player, String message)
|
||||
{
|
||||
message = variableBook(player, message);
|
||||
message = variableBuffer(player, message);
|
||||
return message;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// VARIABLE BOOK
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static String getBookText(CommandSender sender)
|
||||
{
|
||||
if (sender == null) return null;
|
||||
if (!(sender instanceof HumanEntity)) return null;
|
||||
HumanEntity human = (HumanEntity)sender;
|
||||
ItemStack item = human.getItemInHand();
|
||||
if (item == null) return null;
|
||||
if (!item.hasItemMeta()) return null;
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (!(itemMeta instanceof BookMeta)) return null;
|
||||
BookMeta bookMeta = (BookMeta)itemMeta;
|
||||
if (!bookMeta.hasPages()) return null;
|
||||
List<String> pages = bookMeta.getPages();
|
||||
String ret = Txt.implode(pages, " ");
|
||||
ret = ret.replaceAll("\\n+", " ");
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static String variableBook(Player player, String message)
|
||||
{
|
||||
// If we are using this variable ...
|
||||
if (!MCoreConf.get().usingVariableBook) return message;
|
||||
|
||||
// ... get the variable content ...
|
||||
String content = getBookText(player);
|
||||
if (content == null) return message;
|
||||
|
||||
// ... check use permission ...
|
||||
if (!MCorePerm.VARIABLE_BOOK.has(player, false)) return message;
|
||||
|
||||
// ... and replace.
|
||||
return StringUtils.replace(message, MCoreConf.get().variableBook, content);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// VARIABLE BUFFER
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static final Map<String, String> idToBuffer = new HashMap<String, String>();
|
||||
|
||||
public static String getBuffer(Object senderObject)
|
||||
{
|
||||
String id = IdUtil.getId(senderObject);
|
||||
if (id == null) return null;
|
||||
String ret = idToBuffer.get(id);
|
||||
if (ret == null) ret = "";
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void setBuffer(Object senderObject, String buffer)
|
||||
{
|
||||
String id = IdUtil.getId(senderObject);
|
||||
idToBuffer.put(id, buffer);
|
||||
}
|
||||
|
||||
public static String variableBuffer(Player player, String message)
|
||||
{
|
||||
// If we are using this variable ...
|
||||
if (!MCoreConf.get().usingVariableBuffer) return message;
|
||||
|
||||
// ... get the variable content ...
|
||||
String content = getBuffer(player);
|
||||
if (content == null) return message;
|
||||
|
||||
// ... check use permission ...
|
||||
if (!MCorePerm.VARIABLE_BUFFER.has(player, false)) return message;
|
||||
|
||||
// ... and replace.
|
||||
return StringUtils.replace(message, MCoreConf.get().variableBuffer, content);
|
||||
}
|
||||
}
|
@ -2,15 +2,12 @@ package com.massivecraft.mcore;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -21,13 +18,9 @@ import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.massivecraft.mcore.event.MCoreAfterPlayerRespawnEvent;
|
||||
@ -42,7 +35,6 @@ import com.massivecraft.mcore.store.Coll;
|
||||
import com.massivecraft.mcore.store.SenderColl;
|
||||
import com.massivecraft.mcore.util.IdUtil;
|
||||
import com.massivecraft.mcore.util.SmokeUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class EngineMainMCore extends EngineAbstract
|
||||
{
|
||||
@ -158,56 +150,6 @@ public class EngineMainMCore extends EngineAbstract
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// VARIABLE BOOK
|
||||
// -------------------------------------------- //
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void variableBook(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
event.setMessage(variableBook(event.getPlayer(), event.getMessage()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void variableBook(AsyncPlayerChatEvent event)
|
||||
{
|
||||
event.setMessage(variableBook(event.getPlayer(), event.getMessage()));
|
||||
}
|
||||
|
||||
public static String variableBook(Player player, String message)
|
||||
{
|
||||
// If we are using command variable book ...
|
||||
if (!MCoreConf.get().usingVariableBook) return message;
|
||||
|
||||
// ... and the player has a book text ...
|
||||
String bookText = getBookText(player);
|
||||
if (bookText == null) return message;
|
||||
|
||||
// ... and permission to use command variable book ...
|
||||
if (!MCorePerm.VARIABLEBOOK.has(player, false)) return message;
|
||||
|
||||
// ... then replace.
|
||||
return StringUtils.replace(message, MCoreConf.get().variableBook, bookText);
|
||||
}
|
||||
|
||||
public static String getBookText(CommandSender sender)
|
||||
{
|
||||
if (sender == null) return null;
|
||||
if (!(sender instanceof HumanEntity)) return null;
|
||||
HumanEntity human = (HumanEntity)sender;
|
||||
ItemStack item = human.getItemInHand();
|
||||
if (item == null) return null;
|
||||
if (!item.hasItemMeta()) return null;
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (!(itemMeta instanceof BookMeta)) return null;
|
||||
BookMeta bookMeta = (BookMeta)itemMeta;
|
||||
if (!bookMeta.hasPages()) return null;
|
||||
List<String> pages = bookMeta.getPages();
|
||||
String ret = Txt.implode(pages, " ");
|
||||
ret = ret.replaceAll("\\n+", " ");
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXPLOSION FX
|
||||
// -------------------------------------------- //
|
||||
|
@ -25,6 +25,7 @@ import com.massivecraft.mcore.fetcher.IdAndName;
|
||||
import com.massivecraft.mcore.integration.protocollib.ProtocolLibFeatures;
|
||||
import com.massivecraft.mcore.integration.vault.VaultFeatures;
|
||||
import com.massivecraft.mcore.mcorecmd.CmdMCore;
|
||||
import com.massivecraft.mcore.mcorecmd.CmdMCoreBuffer;
|
||||
import com.massivecraft.mcore.mcorecmd.CmdMCoreMStore;
|
||||
import com.massivecraft.mcore.mcorecmd.CmdMCoreUsys;
|
||||
import com.massivecraft.mcore.mixin.EngineTeleportMixinCause;
|
||||
@ -105,6 +106,9 @@ public class MCore extends MPlugin
|
||||
private CmdMCoreMStore outerCmdMCoreMStore;
|
||||
public CmdMCoreMStore getOuterCmdMCoreMStore() { return this.outerCmdMCoreMStore; }
|
||||
|
||||
private CmdMCoreBuffer outerCmdMCoreBuffer;
|
||||
public CmdMCoreBuffer getOuterCmdMCoreBuffer() { return this.outerCmdMCoreBuffer; }
|
||||
|
||||
// Runnables
|
||||
// TODO: Make this one a singleton
|
||||
private Runnable collTickTask = new Runnable()
|
||||
@ -158,6 +162,7 @@ public class MCore extends MPlugin
|
||||
|
||||
// Register events
|
||||
EngineMainMCore.get().activate();
|
||||
EngineMCoreVariable.get().activate();
|
||||
EngineScheduledTeleport.get().activate();
|
||||
EngineTeleportMixinCause.get().activate();
|
||||
EngineWorldNameSet.get().activate();
|
||||
@ -182,6 +187,9 @@ public class MCore extends MPlugin
|
||||
this.outerCmdMCoreMStore = new CmdMCoreMStore() { public List<String> getAliases() { return MCoreConf.get().aliasesOuterMCoreMStore; } };
|
||||
this.outerCmdMCoreMStore.register();
|
||||
|
||||
this.outerCmdMCoreBuffer = new CmdMCoreBuffer() { public List<String> getAliases() { return MCoreConf.get().aliasesOuterMCoreBuffer; } };
|
||||
this.outerCmdMCoreBuffer.register();
|
||||
|
||||
// Integration
|
||||
this.integrate(
|
||||
ProtocolLibFeatures.get(),
|
||||
|
@ -30,6 +30,8 @@ public class MCoreConf extends Entity<MCoreConf>
|
||||
|
||||
public List<String> aliasesOuterMCoreMStore = MUtil.list("mstore");
|
||||
|
||||
public List<String> aliasesOuterMCoreBuffer = MUtil.list("buffer");
|
||||
|
||||
public boolean usingRecipientChatEvent = true;
|
||||
|
||||
public Map<String, String> permissionDeniedFormats = MUtil.map(
|
||||
@ -84,4 +86,7 @@ public class MCoreConf extends Entity<MCoreConf>
|
||||
public String variableBook = "***book***";
|
||||
public boolean usingVariableBook = true;
|
||||
|
||||
public String variableBuffer = "***buffer***";
|
||||
public boolean usingVariableBuffer = true;
|
||||
|
||||
}
|
@ -34,8 +34,16 @@ public enum MCorePerm
|
||||
USYS_ASPECT_LIST("usys.aspect.list"),
|
||||
USYS_ASPECT_SHOW("usys.aspect.show"),
|
||||
USYS_ASPECT_USE("usys.aspect.use"),
|
||||
BUFFER("buffer"),
|
||||
BUFFER_PRINT("buffer.print"),
|
||||
BUFFER_CLEAR("buffer.clear"),
|
||||
BUFFER_SET("buffer.set"),
|
||||
BUFFER_ADD("buffer.add"),
|
||||
BUFFER_WHITESPACE("buffer.whitespace"),
|
||||
NOTPDELAY("notpdelay"),
|
||||
VARIABLEBOOK("variablebook"),
|
||||
VARIABLE_BOOK("variable.book"),
|
||||
VARIABLE_BUFFER("variable.buffer"),
|
||||
|
||||
// END OF LIST
|
||||
;
|
||||
|
||||
|
@ -17,6 +17,7 @@ public class CmdMCore extends MCommand
|
||||
public CmdMCoreId cmdMCoreId = new CmdMCoreId();
|
||||
public CmdMCoreTest cmdMCoreTest = new CmdMCoreTest();
|
||||
public CmdMCoreHearsound cmdMCoreHearsound = new CmdMCoreHearsound();
|
||||
public CmdMCoreBuffer cmdMCoreBuffer = new CmdMCoreBuffer();
|
||||
public VersionCommand cmdMCoreVersion = new VersionCommand(MCore.get(), MCorePerm.VERSION.node, "v", "version");
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -31,6 +32,7 @@ public class CmdMCore extends MCommand
|
||||
this.addSubCommand(this.cmdMCoreId);
|
||||
this.addSubCommand(this.cmdMCoreTest);
|
||||
this.addSubCommand(this.cmdMCoreHearsound);
|
||||
this.addSubCommand(this.cmdMCoreBuffer);
|
||||
this.addSubCommand(this.cmdMCoreVersion);
|
||||
|
||||
// Requirements
|
||||
|
39
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBuffer.java
Normal file
39
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBuffer.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.massivecraft.mcore.mcorecmd;
|
||||
|
||||
import com.massivecraft.mcore.MCorePerm;
|
||||
import com.massivecraft.mcore.cmd.MCommand;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdMCoreBuffer extends MCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdMCoreBufferPrint cmdMCoreBufferPrint = new CmdMCoreBufferPrint();
|
||||
public CmdMCoreBufferClear cmdMCoreBufferClear = new CmdMCoreBufferClear();
|
||||
public CmdMCoreBufferSet cmdMCoreBufferSet = new CmdMCoreBufferSet();
|
||||
public CmdMCoreBufferAdd cmdMCoreBufferAdd = new CmdMCoreBufferAdd();
|
||||
public CmdMCoreBufferWhitespace cmdMCoreBufferWhitespace = new CmdMCoreBufferWhitespace();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdMCoreBuffer()
|
||||
{
|
||||
// SubCommands
|
||||
this.addSubCommand(this.cmdMCoreBufferPrint);
|
||||
this.addSubCommand(this.cmdMCoreBufferClear);
|
||||
this.addSubCommand(this.cmdMCoreBufferSet);
|
||||
this.addSubCommand(this.cmdMCoreBufferAdd);
|
||||
this.addSubCommand(this.cmdMCoreBufferWhitespace);
|
||||
|
||||
// Aliases
|
||||
this.addAliases("buffer");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(MCorePerm.BUFFER.node));
|
||||
}
|
||||
|
||||
}
|
44
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBufferAdd.java
Normal file
44
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBufferAdd.java
Normal file
@ -0,0 +1,44 @@
|
||||
package com.massivecraft.mcore.mcorecmd;
|
||||
|
||||
import com.massivecraft.mcore.EngineMCoreVariable;
|
||||
import com.massivecraft.mcore.MCorePerm;
|
||||
import com.massivecraft.mcore.cmd.MCommand;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdMCoreBufferAdd extends MCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdMCoreBufferAdd()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("a", "add");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("string");
|
||||
this.setErrorOnToManyArgs(false);
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(MCorePerm.BUFFER_ADD.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
String string = this.argConcatFrom(0);
|
||||
if (string == null) return;
|
||||
|
||||
String buffer = EngineMCoreVariable.getBuffer(sender);
|
||||
buffer += string;
|
||||
EngineMCoreVariable.setBuffer(sender, buffer);
|
||||
|
||||
msg("<i>Buffer Add");
|
||||
}
|
||||
|
||||
}
|
35
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBufferClear.java
Normal file
35
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBufferClear.java
Normal file
@ -0,0 +1,35 @@
|
||||
package com.massivecraft.mcore.mcorecmd;
|
||||
|
||||
import com.massivecraft.mcore.EngineMCoreVariable;
|
||||
import com.massivecraft.mcore.MCorePerm;
|
||||
import com.massivecraft.mcore.cmd.MCommand;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdMCoreBufferClear extends MCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdMCoreBufferClear()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("c", "clear");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(MCorePerm.BUFFER_CLEAR.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
EngineMCoreVariable.setBuffer(sender, "");
|
||||
|
||||
msg("<i>Buffer Clear");
|
||||
}
|
||||
|
||||
}
|
41
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBufferPrint.java
Normal file
41
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBufferPrint.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.massivecraft.mcore.mcorecmd;
|
||||
|
||||
import com.massivecraft.mcore.EngineMCoreVariable;
|
||||
import com.massivecraft.mcore.MCorePerm;
|
||||
import com.massivecraft.mcore.cmd.MCommand;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdMCoreBufferPrint extends MCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdMCoreBufferPrint()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("p", "print");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(MCorePerm.BUFFER_PRINT.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
String buffer = EngineMCoreVariable.getBuffer(sender);
|
||||
if (buffer == null || buffer.length() == 0)
|
||||
{
|
||||
msg("<i>Nothing to print. Your buffer is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
msg("<i>Printing your buffer on the line below:");
|
||||
sendMessage(buffer);
|
||||
}
|
||||
|
||||
}
|
42
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBufferSet.java
Normal file
42
src/com/massivecraft/mcore/mcorecmd/CmdMCoreBufferSet.java
Normal file
@ -0,0 +1,42 @@
|
||||
package com.massivecraft.mcore.mcorecmd;
|
||||
|
||||
import com.massivecraft.mcore.EngineMCoreVariable;
|
||||
import com.massivecraft.mcore.MCorePerm;
|
||||
import com.massivecraft.mcore.cmd.MCommand;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdMCoreBufferSet extends MCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdMCoreBufferSet()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("s", "set");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("string");
|
||||
this.setErrorOnToManyArgs(false);
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(MCorePerm.BUFFER_SET.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
String string = this.argConcatFrom(0);
|
||||
if (string == null) return;
|
||||
|
||||
EngineMCoreVariable.setBuffer(sender, string);
|
||||
|
||||
msg("<i>Buffer was Set");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.massivecraft.mcore.mcorecmd;
|
||||
|
||||
import com.massivecraft.mcore.EngineMCoreVariable;
|
||||
import com.massivecraft.mcore.MCorePerm;
|
||||
import com.massivecraft.mcore.cmd.MCommand;
|
||||
import com.massivecraft.mcore.cmd.arg.ARInteger;
|
||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public class CmdMCoreBufferWhitespace extends MCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdMCoreBufferWhitespace()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("w", "whitespace");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("times", "1");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(MCorePerm.BUFFER_WHITESPACE.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
Integer times = this.arg(0, ARInteger.get(), 1);
|
||||
if (times == null) return;
|
||||
|
||||
String string = Txt.repeat(" ", times);
|
||||
|
||||
String buffer = EngineMCoreVariable.getBuffer(sender);
|
||||
buffer += string;
|
||||
EngineMCoreVariable.setBuffer(sender, buffer);
|
||||
|
||||
msg("<i>Buffer Whitespace");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user