Skip to content

Commit

Permalink
add inventory functions, some improvments and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MariuszT committed Aug 22, 2013
1 parent 3c62e0c commit 0aef291
Show file tree
Hide file tree
Showing 9 changed files with 509 additions and 38 deletions.
Expand Up @@ -179,7 +179,7 @@ public static RawHTTPResponse getWebStream(URL url, RequestSettings settings) th
}
}
if(username != null && password != null){
conn.setRequestProperty("Authorization", "Basic " + new String(Base64.encodeBase64(password.getBytes("UTF-8")), "UTF-8"));
conn.setRequestProperty("Authorization", "Basic " + new String(Base64.encodeBase64((username + ":" + password).getBytes("UTF-8")), "UTF-8"));
}
if (headers != null) {
for (String key : headers.keySet()) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/laytonsmith/abstraction/MCServer.java
Expand Up @@ -35,6 +35,7 @@ public interface MCServer extends AbstractionObject{
public String getServerName();
public String getModVersion();
public String getVersion();
public int getPort();
public Boolean getAllowEnd();
public Boolean getAllowFlight();
public Boolean getAllowNether();
Expand Down
Expand Up @@ -151,6 +151,10 @@ public String getVersion() {
return s.getVersion();
}

public int getPort() {
return s.getPort();
}

public Boolean getAllowEnd() {
return s.getAllowEnd();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/laytonsmith/core/Static.java
Expand Up @@ -588,10 +588,10 @@ public static String ParseItemNotation(MCItemStack is) {
return "0";
}
String append = null;
if (is.getData() != null) {
append = Integer.toString(is.getData().getData());
} else if (is.getDurability() != 0) {
if (is.getDurability() != 0) {
append = Short.toString(is.getDurability());
} else if (is.getData() != null) {
append = Integer.toString(is.getData().getData());
}
return is.getTypeId() + (append == null ? "" : ":" + append);
}
Expand Down
Expand Up @@ -480,10 +480,10 @@ public String getName() {
}

public String docs() {
return "{type: <macro> The type of entity being damaged | cause: <macro>}"
return "{type: <macro> The type of entity being damaged | cause: <macro> | world: <string match>}"
+ " Fires when any loaded entity takes damage."
+ " {type: The type of entity the got damaged | id: The entityID of the victim"
+ " | player: the player who got damaged (only present if type is PLAYER)"
+ " | player: the player who got damaged (only present if type is PLAYER) | world"
+ " | cause: The type of damage | amount | damager: If the source of damage is a player this will"
+ " contain their name, otherwise it will be the entityID of the damager (only available when"
+ " an entity causes damage) | shooter: The name of the player who shot, otherwise the entityID"
Expand All @@ -498,6 +498,7 @@ public boolean matches(Map<String, Construct> prefilter, BindableEvent event)
MCEntityDamageEvent e = (MCEntityDamageEvent) event;
Prefilters.match(prefilter, "type", e.getEntity().getType().name(), Prefilters.PrefilterType.MACRO);
Prefilters.match(prefilter, "cause", e.getCause().name(), Prefilters.PrefilterType.MACRO);
Prefilters.match(prefilter, "world", e.getEntity().getWorld().getName(), Prefilters.PrefilterType.STRING_MATCH);

return true;
}
Expand Down Expand Up @@ -1086,6 +1087,7 @@ public static Map<String, Construct> parseEntityDamageEvent(MCEntityDamageEvent
map.put("id", new CInt(victim.getEntityId(), Target.UNKNOWN));
map.put("cause", new CString(event.getCause().name(), Target.UNKNOWN));
map.put("amount", new CDouble(event.getDamage(), Target.UNKNOWN));
map.put("world", new CString(event.getEntity().getWorld().getName(), Target.UNKNOWN));

if (event instanceof MCEntityDamageByEntityEvent) {
MCEntity damager = ((MCEntityDamageByEntityEvent) event).getDamager();
Expand Down
Expand Up @@ -166,10 +166,10 @@ public String getName() {
}

public String docs() {
return "{world: <string match> World name | type: <macro> Can be " + StringUtils.Join(MCDragType.values(), ", ", ", or ") + " } "
+ " | cursoritem: <item match> item in hand, before event starts"
return "{world: <string match> World name | type: <macro> Can be " + StringUtils.Join(MCDragType.values(), ", ", ", or ")
+ " | cursoritem: <item match> item in hand, before event starts}"
+ "Fired when a player clicks (by left or right mouse button) a slot in inventory and drag mouse across slots. "
+ "{player: The player who clicked | newcursoritem: item on cursro, after event | oldcursoritem: item on cursor,"
+ "{player: The player who clicked | newcursoritem: item on cursor, after event | oldcursoritem: item on cursor,"
+ " before event | slots: used slots | rawslots: used slots, as the numbers of the slots in whole inventory window"
+ " | newitems: array of items which are dropped in selected slots | inventorytype | inventorysize: number of slots in"
+ " opened inventory} {cursoritem: the item on the cursor, after event} "
Expand Down

0 comments on commit 0aef291

Please sign in to comment.