Permalink
Browse files

Merge branch 'master' of github.com:EngineHub/commandhelper

  • Loading branch information...
LadyCailin committed Oct 9, 2018
2 parents dba776a + 391a19c commit 867e07168e5db02990c00985fed1b04aee1a5fe2
Showing with 555 additions and 504 deletions.
  1. +3 −3 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCServer.java
  2. +0 −10 src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCBoat.java
  3. +1 −1 src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitEntityEvents.java
  4. +6 −1 src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitPlayerEvents.java
  5. +0 −2 src/main/java/com/laytonsmith/abstraction/entities/MCBoat.java
  6. +9 −8 src/main/java/com/laytonsmith/core/AliasCore.java
  7. +1 −1 src/main/java/com/laytonsmith/core/CHLog.java
  8. +1 −1 src/main/java/com/laytonsmith/core/Main.java
  9. +2 −2 src/main/java/com/laytonsmith/core/Static.java
  10. +2 −2 src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java
  11. +1 −1 src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java
  12. +2 −2 src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java
  13. +31 −8 src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java
  14. +2 −0 src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java
  15. +3 −3 src/main/java/com/laytonsmith/core/functions/Cmdline.java
  16. +78 −79 src/main/java/com/laytonsmith/core/functions/EntityManagement.java
  17. +37 −27 src/main/java/com/laytonsmith/core/functions/Environment.java
  18. +21 −18 src/main/java/com/laytonsmith/core/functions/Minecraft.java
  19. +50 −46 src/main/java/com/laytonsmith/core/functions/MobManagement.java
  20. +1 −2 src/main/java/com/laytonsmith/core/functions/Permissions.java
  21. +193 −187 src/main/java/com/laytonsmith/core/functions/PlayerManagement.java
  22. +3 −3 src/main/java/com/laytonsmith/core/functions/Recipes.java
  23. +12 −12 src/main/java/com/laytonsmith/core/functions/Scoreboards.java
  24. +13 −15 src/main/java/com/laytonsmith/core/functions/Weather.java
  25. +54 −51 src/main/java/com/laytonsmith/core/functions/World.java
  26. +5 −5 src/main/java/com/laytonsmith/core/profiler/Profiler.java
  27. +12 −12 src/main/java/com/laytonsmith/tools/docgen/sitedeploy/SiteDeploy.java
  28. +12 −2 src/main/resources/docs/Cross_Casting
@@ -400,7 +400,7 @@ public int getMaxPlayers() {
public List<MCOfflinePlayer> getBannedPlayers() {
List<MCOfflinePlayer> list = new ArrayList<>();
for(OfflinePlayer p : s.getBannedPlayers()) {
list.add(getOfflinePlayer(p.getName()));
list.add(new BukkitMCOfflinePlayer(p));
}
return list;
}
@@ -409,7 +409,7 @@ public int getMaxPlayers() {
public List<MCOfflinePlayer> getWhitelistedPlayers() {
List<MCOfflinePlayer> list = new ArrayList<>();
for(OfflinePlayer p : s.getWhitelistedPlayers()) {
list.add(getOfflinePlayer(p.getName()));
list.add(new BukkitMCOfflinePlayer(p));
}
return list;
}
@@ -418,7 +418,7 @@ public int getMaxPlayers() {
public List<MCOfflinePlayer> getOperators() {
List<MCOfflinePlayer> list = new ArrayList<>();
for(OfflinePlayer p : s.getOperators()) {
list.add(getOfflinePlayer(p.getName()));
list.add(new BukkitMCOfflinePlayer(p));
}
return list;
}
@@ -15,16 +15,6 @@ public BukkitMCBoat(Entity e) {
this.b = (Boat) e;
}
@Override
public double getMaxSpeed() {
return b.getMaxSpeed();
}
@Override
public void setMaxSpeed(double speed) {
b.setMaxSpeed(speed);
}
@Override
public MCTreeSpecies getWoodType() {
return BukkitMCTreeSpecies.getConvertor().getAbstractedEnum(b.getWoodType());
@@ -535,7 +535,7 @@ public void setItemStack(MCItemStack stack) {
ItemStack is = (ItemStack) stack.getHandle();
e.setCancelled(true);
e.getItem().remove();
if(is != null && is.getType().equals(Material.AIR)) {
if(is != null && !is.getType().equals(Material.AIR)) {
((Player) e.getEntity()).getInventory().addItem(is);
//and for added realism :)
e.getEntity().getWorld().playSound(e.getItem().getLocation(),
@@ -831,9 +831,14 @@ public void setNewBookMeta(MCBookMeta bookMeta) {
pebe.setNewBookMeta(((BukkitMCBookMeta) bookMeta).getBookMeta());
}
@SuppressWarnings("deprecation")
@Override
public int getSlot() {
return pebe.getSlot();
int slot = pebe.getSlot();
if(slot == -1) { // bukkit offhand slot
return -106; // vanilla offhand slot
}
return slot;
}
@Override
@@ -3,8 +3,6 @@
import com.laytonsmith.abstraction.enums.MCTreeSpecies;
public interface MCBoat extends MCVehicle {
double getMaxSpeed();
void setMaxSpeed(double speed);
MCTreeSpecies getWoodType();
void setWoodType(MCTreeSpecies type);
}
@@ -34,7 +34,7 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
@@ -43,6 +43,7 @@
import java.io.StringWriter;
import java.io.Writer;
import java.net.URI;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
@@ -536,14 +537,14 @@ public boolean reloadExtensions() {
* @throws Exception if the file cannot be found
*/
public static String file_get_contents(String fileLocation) throws IOException {
BufferedReader in = new BufferedReader(new FileReader(fileLocation));
String ret = "";
String str;
while((str = in.readLine()) != null) {
ret += str + "\n";
StringBuilder ret = new StringBuilder();
try(BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileLocation), Charset.forName("UTF-8")))) {
String str;
while((str = in.readLine()) != null) {
ret.append(str).append('\n');
}
}
in.close();
return ret;
return ret.toString();
}
/**
@@ -118,7 +118,7 @@ private static LogLevel GetLevel(Tags tag) {
}
LogLevel level;
try {
String pref = (String) prefs.getPreference(tag.name);
String pref = prefs.getStringPreference(tag.name);
if("ON".equals(pref)) {
level = LogLevel.ERROR;
} else {
@@ -603,7 +603,7 @@ public static void main(String[] args) throws Exception {
password = reader.readLine("Enter password: ", cha);
} finally {
if(reader != null) {
reader.shutdown();
reader.close();
}
}
}
@@ -631,11 +631,11 @@ public static MCItemStack ParseItemNotation(String functionName, String notation
type = Integer.parseInt(notation);
}
} catch (NumberFormatException e) {
throw new CREFormatException("Invalid item notation: " + notation, t);
throw new CREFormatException("Invalid item format: " + notation, t);
}
MCMaterial mat = StaticLayer.GetMaterialFromLegacy(type, data);
if(mat == null) {
throw new CREFormatException("Invalid item values: " + notation, t);
throw new CREFormatException("Invalid item format: " + notation, t);
}
MCItemStack is = StaticLayer.GetItemStack(mat, qty);
CHLog.GetLogger().w(CHLog.Tags.DEPRECATION, "Item notation is deprecated."
@@ -593,7 +593,7 @@ public String docs() {
+ " | ignitingblock: the block's type, if caused by block"
+ " | ignitingblocklocation: the block's location that ignited"
+ " | location: the locationArray that got ignited"
+ " | cause: the cause of ignition, one of: " + StringUtils.Join(MCIgniteCause.values(), ", ") + "}"
+ " | cause: the cause of ignition, one of " + StringUtils.Join(MCIgniteCause.values(), ", ") + "}"
+ "{}"
+ "{}";
}
@@ -1294,7 +1294,7 @@ public Driver driver() {
public String docs() {
return "{}"
+ " This event is called when a noteblock is activated via player interaction or redstone."
+ " The instrument may be one of: " + StringUtils.Join(MCInstrument.values(), ", ", ", or ") + "."
+ " The instrument may be one of " + StringUtils.Join(MCInstrument.values(), ", ", ", or ") + "."
+ " {location: The location of the noteblock | instrument: The name of the sound"
+ " | tone: The note played (eg. F#) | octave: The octave the tone was played (0 - 2)}"
+ " {}"
@@ -2020,7 +2020,7 @@ public String docs() {
+ " Fired when an entity regained the health."
+ " {id: The entity ID of regained entity"
+ " amount: The amount of regained the health |"
+ " cause: The cause of regain, one of: " + StringUtils.Join(MCRegainReason.values(), ", ")
+ " cause: The cause of regain, one of " + StringUtils.Join(MCRegainReason.values(), ", ")
+ " player: The regained player}"
+ " {amount}"
+ " {}";
@@ -348,7 +348,7 @@ public String docs() {
+ "| from: <location match> This should be a location array (x, y, z, world)."
+ "| to: <location match> The location the player is now in. This should be a location array as well.} "
+ "{player | from: The location the player is coming from | to: The location the player is now in | "
+ "type: the type of teleport occuring, one of: " + StringUtils.Join(MCTeleportCause.values(), ", ") + "}"
+ "type: the type of teleport occuring, one of " + StringUtils.Join(MCTeleportCause.values(), ", ") + "}"
+ "{to}"
+ "{}";
}
@@ -445,7 +445,7 @@ public String getName() {
public String docs() {
return "{player: <macro> | from: <location match> This should be a location array (x, y, z, world)."
+ " | to: <location match> The location the player is coming to. This should be a location array as well."
+ " | type: <macro> the type of portal occuring, one of: " + StringUtils.Join(MCTeleportCause.values(), ", ") + "}"
+ " | type: <macro> the type of portal occuring, one of " + StringUtils.Join(MCTeleportCause.values(), ", ") + "}"
+ "Fired when a player collides with portal."
+ "{player: The player that teleport | from: The location the player is coming from"
+ " | to: The location the player is coming to. Returns null when using Nether portal and \"allow-nether\""
@@ -1,8 +1,12 @@
package com.laytonsmith.core.events.drivers;
import com.laytonsmith.PureUtilities.Version;
import com.laytonsmith.abstraction.MCBlockCommandSender;
import com.laytonsmith.abstraction.MCCommandSender;
import com.laytonsmith.abstraction.MCConsoleCommandSender;
import com.laytonsmith.abstraction.MCLocation;
import com.laytonsmith.abstraction.MCPlayer;
import com.laytonsmith.abstraction.entities.MCCommandMinecart;
import com.laytonsmith.abstraction.events.MCBroadcastMessageEvent;
import com.laytonsmith.abstraction.events.MCCommandTabCompleteEvent;
import com.laytonsmith.abstraction.events.MCServerCommandEvent;
@@ -16,6 +20,7 @@
import com.laytonsmith.core.constructs.CArray;
import com.laytonsmith.core.constructs.CBoolean;
import com.laytonsmith.core.constructs.CInt;
import com.laytonsmith.core.constructs.CNull;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
@@ -55,11 +60,14 @@ public String getName() {
@Override
public String docs() {
return "{prefix: <string match> The first part of the command, i.e. 'cmd' in '/cmd blah blah'}"
return "{prefix: <string match> The first part of the command, i.e. 'cmd' in '/cmd blah blah'"
+ " | type: <string match> The command sender type}"
+ "This event is fired off when any command is run from the console or commandblock. This fires"
+ " before CommandHelper aliases, allowing you to insert control beforehand. Be careful with this"
+ " event, because it can override ALL server commands, potentially creating all sorts of havoc."
+ "{command: The entire command | prefix: Just the prefix of the command}"
+ "{command: The entire command | prefix: The prefix of the command"
+ " | sendertype: The command sender type. This is one of: console, command_block,"
+ " command_minecart or null if the sender is unknown to CommandHelper.}"
+ "{command}"
+ "{}";
}
@@ -80,12 +88,10 @@ public boolean matches(Map<String, Construct> prefilter, BindableEvent e) throws
return false;
}
MCServerCommandEvent event = (MCServerCommandEvent) e;
if(prefilter.containsKey("prefix")) {
String prefix = event.getCommand().split(" ", 2)[0];
if(!prefix.equals(prefilter.get("prefix").val())) {
return false;
}
}
String prefix = event.getCommand().split(" ", 2)[0];
Prefilters.match(prefilter, "prefix", prefix, PrefilterType.STRING_MATCH);
Prefilters.match(prefilter, "sendertype",
getCommandsenderString(event.getCommandSender()), PrefilterType.STRING_MATCH);
return true;
}
@@ -104,9 +110,26 @@ public BindableEvent convert(CArray manualObject, Target t) {
map.put("command", new CString(event.getCommand(), Target.UNKNOWN));
String prefix = event.getCommand().split(" ", 2)[0];
map.put("prefix", new CString(prefix, Target.UNKNOWN));
// Set the command sender type.
String type = getCommandsenderString(event.getCommandSender());
map.put("sendertype", (type == null ? CNull.NULL : new CString(type, Target.UNKNOWN)));
return map;
}
private static String getCommandsenderString(MCCommandSender sender) {
if(sender instanceof MCConsoleCommandSender) {
return "console";
} else if(sender instanceof MCBlockCommandSender) {
return "command_block";
} else if(sender instanceof MCCommandMinecart) {
return "command_minecart";
} else {
return null; // Unknown sender implementation.
}
}
@Override
public boolean modifyEvent(String key, Construct value, BindableEvent event) {
if(event instanceof MCServerCommandEvent) {
@@ -32,10 +32,12 @@
private List<StackTraceElement> stackTrace = null;
@SuppressWarnings("deprecation")
public AbstractCREException(String msg, Target t) {
super(msg, t);
}
@SuppressWarnings("deprecation")
public AbstractCREException(String msg, Target t, Throwable cause) {
super(msg, t, cause);
}
@@ -645,7 +645,7 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
throw new CREIOException(ex.getMessage(), t);
} finally {
if(reader != null) {
reader.shutdown();
reader.close();
}
}
@@ -723,7 +723,7 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
throw new CREIOException(ex.getMessage(), t);
} finally {
if(reader != null) {
reader.shutdown();
reader.close();
}
}
@@ -788,7 +788,7 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
throw new CREIOException(ex.getMessage(), t);
} finally {
if(reader != null) {
reader.shutdown();
reader.close();
}
}
Oops, something went wrong.

0 comments on commit 867e071

Please sign in to comment.