Skip to content

Commit b80351d

Browse files
committed
Merge branch 'master' of github.com:sk89q/commandhelper
2 parents 98fb8d7 + d99ef6f commit b80351d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+353
-243
lines changed

src/main/java/com/laytonsmith/PureUtilities/ClassLoading/ClassDiscovery.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public boolean doesClassExtend(ClassMirror subClass, Class superClass){
565565
return true;
566566
} else {
567567
//We need to add change the reference to su
568-
su = new ClassReferenceMirror("L" + clazz.getSuperclass().getName().replace(".", "/") + ";");
568+
su = new ClassReferenceMirror("L" + clazz.getSuperclass().getName().replace('.', '/') + ";");
569569
}
570570
} catch (ClassNotFoundException ex) {
571571
//Hmm, ok? I guess something bad happened, so let's break
@@ -593,7 +593,7 @@ public boolean doesClassExtend(ClassMirror subClass, Class superClass){
593593
try {
594594
Class clazz = Class.forName(r.toString());
595595
for (Class c : clazz.getInterfaces()) {
596-
interfaces.add(new ClassReferenceMirror("L" + c.getName().replace(".", "/") + ";"));
596+
interfaces.add(new ClassReferenceMirror("L" + c.getName().replace('.', '/') + ";"));
597597
}
598598
} catch (ClassNotFoundException ex) {
599599
return false;

src/main/java/com/laytonsmith/PureUtilities/ClassLoading/ClassMirror/ClassMirror.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public String getJVMClassName(){
139139
*/
140140
public String getClassName(){
141141
if(underlyingClass != null){
142-
return underlyingClass.getName().replace("$", ".");
142+
return underlyingClass.getName().replace('$', '.');
143143
}
144144
return info.name.replaceAll("[/$]", ".");
145145
}
@@ -453,7 +453,7 @@ public boolean directlyExtendsFrom(Class superClass){
453453
if(underlyingClass != null){
454454
return (underlyingClass.getSuperclass() == superClass);
455455
}
456-
String name = superClass.getName().replace(".", "/");
456+
String name = superClass.getName().replace('.', '/');
457457
if(info.superClass.equals(name)){
458458
return true;
459459
}

src/main/java/com/laytonsmith/PureUtilities/Common/ClassUtils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private static Class forCanonicalName(String className, boolean useInitializer,
157157
public static String getJVMName(Class clazz){
158158
//For arrays, .getName() is fine.
159159
if(clazz.isArray()){
160-
return clazz.getName().replace(".", "/");
160+
return clazz.getName().replace('.', '/');
161161
}
162162
if(clazz == boolean.class){
163163
return "Z";
@@ -176,7 +176,7 @@ public static String getJVMName(Class clazz){
176176
} else if(clazz == char.class){
177177
return "C";
178178
} else {
179-
return "L" + clazz.getName().replace(".", "/") + ";";
179+
return "L" + clazz.getName().replace('.', '/') + ";";
180180
}
181181
}
182182

@@ -231,7 +231,7 @@ public static String getCommonNameFromJVMName(String classname){
231231
} else if("V".equals(classname)){
232232
return "void"; //special case
233233
} else {
234-
classname = classname.substring(1, classname.length() - 1).replace("/", ".").replace("$", ".");
234+
classname = classname.substring(1, classname.length() - 1).replace('/', '.').replace('$', '.');
235235
}
236236
return classname + StringUtils.stringMultiply(arrayCount, "[]");
237237
}

src/main/java/com/laytonsmith/PureUtilities/TermColors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private static String special(String type){
196196
}
197197
}
198198
if(type.equals("reset")){
199-
return "\033[0m";
199+
return "\033[m";
200200
}
201201
return "";
202202
}

src/main/java/com/laytonsmith/PureUtilities/VirtualFS/RealFileSystemLayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public VirtualFile[] listFiles() throws IOException {
6161

6262
private VirtualFile normalize(File real) throws IOException {
6363
String path = real.getCanonicalPath().replaceFirst(Pattern.quote(fileSystem.root.getCanonicalPath()), "");
64-
path = path.replace("\\", "/");
64+
path = path.replace('\\', '/');
6565
if (!path.startsWith("/")) {
6666
path = "/" + path;
6767
}

src/main/java/com/laytonsmith/PureUtilities/VirtualFS/VirtualFile.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class VirtualFile {
1919

2020
public VirtualFile(String path){
2121
String working = path;
22-
working = working.replace("\\", "/");
22+
working = working.replace('\\', '/');
2323
for(String s : RESTRICTED_CHARS){
2424
if(working.contains(s)){
2525
throw new InvalidVirtualFile("VirtualFiles cannot contain the '" + s + "' character.");

src/main/java/com/laytonsmith/PureUtilities/ZipReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public ZipReader(File file){
9797
String newFile = file.getPath().substring(5);
9898
//Replace all \ with /, to simply processing, but also replace ! with /, since jar addresses
9999
//use that to denote the jar. We don't care, it's just a folder, so replace that with a slash.
100-
newFile = newFile.replace("\\", "/").replace("!", "/");
100+
newFile = newFile.replace('\\', '/').replace('!', '/');
101101
while(newFile.startsWith("//")){
102102
//We only want up to one slash here
103103
newFile = newFile.substring(1);

src/main/java/com/laytonsmith/abstraction/AbstractConvertor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ public void run() {
194194
task.run();
195195
if(!repeater){
196196
unregister();
197+
synchronized(tasks){
198+
tasks.remove(id);
199+
}
197200
}
198201
}
199202
}, initialDelay, interval);

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCCommand.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import com.laytonsmith.core.constructs.Construct;
1717
import com.laytonsmith.core.constructs.Target;
1818
import com.laytonsmith.core.environments.CommandHelperEnvironment;
19-
import com.laytonsmith.core.environments.Environment;
2019
import com.laytonsmith.core.events.Driver;
2120
import com.laytonsmith.core.events.EventUtils;
2221
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
@@ -209,11 +208,11 @@ public List<String> handleTabComplete(MCCommandSender sender, String alias, Stri
209208
for (String arg : args) {
210209
cargs.push(new CString(arg, t), t);
211210
}
211+
CClosure closure = Commands.onTabComplete.get(cmd.getName().toLowerCase());
212212
try {
213-
Commands.onTabComplete.get(cmd.getName().toLowerCase()).execute(new Construct[]{
214-
new CString(alias, t), new CString(sender.getName(), t), cargs,
215-
new CArray(t) // reserved for an obgen style command array
216-
});
213+
closure.execute(new CString(alias, t), new CString(sender.getName(), t), cargs,
214+
new CArray(t) // reserved for an obgen style command array
215+
);
217216
} catch (FunctionReturnException e) {
218217
Construct fret = e.getReturn();
219218
if (fret instanceof CArray) {
@@ -229,10 +228,12 @@ public List<String> handleTabComplete(MCCommandSender sender, String alias, Stri
229228
}
230229
return ret;
231230
}
231+
} catch (ConfigRuntimeException cre){
232+
ConfigRuntimeException.HandleUncaughtException(cre, closure.getEnv());
233+
return new ArrayList<>();
232234
}
233235
}
234236
BukkitMCCommandTabCompleteEvent event = new BukkitMCCommandTabCompleteEvent(sender, cmd, alias, args);
235-
EventUtils.TriggerExternal(event);
236237
EventUtils.TriggerListener(Driver.TAB_COMPLETE, "tab_complete_command", event);
237238
return event.getCompletions();
238239
}
@@ -255,10 +256,9 @@ public boolean handleCustomCommand(MCCommandSender sender, String label, String[
255256
}
256257

257258
try {
258-
closure.execute(new Construct[]{
259-
new CString(label, t), new CString(sender.getName(), t), cargs,
260-
new CArray(t) // reserved for an obgen style command array
261-
});
259+
closure.execute(new CString(label, t), new CString(sender.getName(), t), cargs,
260+
new CArray(t) // reserved for an obgen style command array
261+
);
262262
} catch (FunctionReturnException e) {
263263
Construct fret = e.getReturn();
264264
if (fret instanceof CBoolean) {

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCProjectile.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ public void setBounce(boolean doesBounce) {
4848
}
4949

5050
@Override
51-
public void setShooter(MCProjectileSource shooter) {
52-
proj.setShooter((ProjectileSource) shooter.getHandle());
51+
public void setShooter(MCProjectileSource shooter){
52+
if(shooter == null){
53+
proj.setShooter(null);
54+
} else {
55+
proj.setShooter((ProjectileSource) shooter.getHandle());
56+
}
5357
}
5458

5559
public Projectile asProjectile() {

0 commit comments

Comments
 (0)