Skip to content

Commit 7fba3dc

Browse files
committed
Skript timings WIP
1 parent 881d931 commit 7fba3dc

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed

src/main/java/ch/njol/skript/aliases/ItemType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ public boolean removeAll(final Inventory invi) {
794794
* @return Whether everything could be removed from the inventory
795795
*/
796796
public boolean removeFrom(final Inventory invi) {
797-
final ItemStack[] buf = invi.getContents();
797+
final ItemStack[] buf = getStorageContents(invi);
798798
final ItemStack[] armour = invi instanceof PlayerInventory ? ((PlayerInventory) invi).getArmorContents() : null;
799799

800800
@SuppressWarnings("unchecked")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* This file is part of Skript.
3+
*
4+
* Skript is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Skript is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with Skript. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*
18+
* Copyright 2011-2016 Peter Güttinger and contributors
19+
*
20+
*/
21+
22+
package ch.njol.skript.timings;
23+
24+
/**
25+
*
26+
*/
27+
public class Timing {
28+
29+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* This file is part of Skript.
3+
*
4+
* Skript is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Skript is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with Skript. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*
18+
* Copyright 2011-2016 Peter Güttinger and contributors
19+
*
20+
*/
21+
22+
package ch.njol.skript.timings;
23+
24+
import java.util.HashMap;
25+
import java.util.Map;
26+
import java.util.concurrent.ConcurrentHashMap;
27+
import java.util.concurrent.atomic.AtomicLong;
28+
29+
/**
30+
* Static utils for Skript timings.
31+
*/
32+
public class Timings {
33+
34+
static class TimingObject extends HashMap<String,Timing> {}
35+
36+
private static Map<Object,TimingObject> timings = new HashMap<Object,TimingObject>();
37+
38+
public static Timing of(Object obj, String name) {
39+
TimingObject map;
40+
synchronized (timings) {
41+
if (timings.containsKey(obj)) {
42+
map = timings.get(obj);
43+
} else {
44+
map = new TimingObject();
45+
timings.put(obj, map);
46+
}
47+
}
48+
49+
synchronized (map) {
50+
if (map.containsKey(name)) {
51+
return map.get(name);
52+
} else {
53+
Timing timing = new Timing();
54+
map.put(name, timing);
55+
return timing;
56+
}
57+
}
58+
}
59+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Code related to item aliases.
3+
*
4+
* @author Peter Güttinger
5+
*/
6+
@NonNullByDefault
7+
package ch.njol.skript.timings;
8+
9+
import org.eclipse.jdt.annotation.NonNullByDefault;
10+

0 commit comments

Comments
 (0)