mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-10-12 02:13:42 -04:00
Changed SWGNameGenerator to use StringBuffer for name generation and fixed some small issues in other classes
This commit is contained in:
@@ -34,8 +34,8 @@ import java.nio.charset.Charset;
|
||||
|
||||
|
||||
public class Packet {
|
||||
public static Charset ascii = Charset.forName("UTF-8");
|
||||
public static Charset unicode = Charset.forName("UTF-16LE");
|
||||
public static final Charset ascii = Charset.forName("UTF-8");
|
||||
public static final Charset unicode = Charset.forName("UTF-16LE");
|
||||
private InetAddress address;
|
||||
private ByteBuffer data;
|
||||
private int port = 0;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ObjectMenuResponse extends ObjectController {
|
||||
|
||||
public ObjectMenuResponse(ByteBuffer data) {
|
||||
super(CRC);
|
||||
options = new ArrayList<RadialOption>();
|
||||
options = new ArrayList<>();
|
||||
decode(data);
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public class ObjectMenuResponse extends ObjectController {
|
||||
option.setId(getShort(data));
|
||||
option.setOptionType(getByte(data));
|
||||
option.setText(getUnicode(data));
|
||||
options.add(option);
|
||||
}
|
||||
counter = getByte(data);
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ import java.util.*;
|
||||
public abstract class ContainerPermissions implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static WorldPermissions WORLD = new WorldPermissions();
|
||||
public static InventoryPermissions INVENTORY = new InventoryPermissions();
|
||||
public static final WorldPermissions WORLD = new WorldPermissions();
|
||||
public static final InventoryPermissions INVENTORY = new InventoryPermissions();
|
||||
|
||||
private Map<String, Integer> permissionGroups;
|
||||
private List<String> joinedGroups;
|
||||
@@ -160,7 +160,8 @@ public abstract class ContainerPermissions implements Serializable {
|
||||
}
|
||||
|
||||
public static int valueOf(EnumSet<Permission> bitmaskSet) {
|
||||
return valueOf(bitmaskSet);
|
||||
Permission[] permissions = bitmaskSet.toArray(new Permission[0]);
|
||||
return valueOf(permissions);
|
||||
}
|
||||
|
||||
public static int valueOf(Permission... permissions) {
|
||||
|
||||
@@ -478,7 +478,7 @@ public abstract class SWGObject implements Serializable, Comparable<SWGObject> {
|
||||
}
|
||||
|
||||
public int getMaxContainerSize() {
|
||||
return Integer.valueOf(templateAttributes.get("containerVolumeLimit").toString());
|
||||
return Integer.parseInt(templateAttributes.get("containerVolumeLimit").toString());
|
||||
}
|
||||
|
||||
public void setBuildout(boolean buildout) {
|
||||
|
||||
@@ -133,7 +133,7 @@ public class WeaponObject extends TangibleObject implements Encodable{
|
||||
byte[] data3 = bb.buildAsBaselinePacket();
|
||||
|
||||
bb = new BaselineBuilder(this, BaselineType.WEAO, 6);
|
||||
createBaseline6(null, bb);
|
||||
createBaseline6(null, bb); // TODO: This needs to have a target otherwise null pointer will be thrown, new encode function in encodable?
|
||||
byte[] data6 = bb.buildAsBaselinePacket();
|
||||
|
||||
byte[] ret = new byte[data3.length + data6.length];
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
***********************************************************************************/
|
||||
package utilities.namegen;
|
||||
|
||||
import resources.Race;
|
||||
import resources.zone.NameFilter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -35,9 +38,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import resources.Race;
|
||||
import resources.zone.NameFilter;
|
||||
|
||||
public class SWGNameGenerator {
|
||||
|
||||
private Map<String, RaceNameRule> ruleMap = new HashMap<>();
|
||||
@@ -158,29 +158,35 @@ public class SWGNameGenerator {
|
||||
}
|
||||
|
||||
private String getNameByRule(RaceNameRule rule) {
|
||||
String name = "";
|
||||
StringBuffer buffer = new StringBuffer("");
|
||||
String instructions = getRandomInstruction(rule);
|
||||
int l = instructions.length();
|
||||
|
||||
for (int i = 0; i < l; i++) {
|
||||
char x = instructions.charAt(0);
|
||||
|
||||
switch (x) {
|
||||
case 'v': name += removeExcessDuplications(rule.getVowels(), name, getRandomElementFrom(rule.getVowels()));
|
||||
break;
|
||||
case 'c': name += removeExcessDuplications(rule.getStartConsonants(), name, getRandomElementFrom(rule.getStartConsonants()));
|
||||
break;
|
||||
case 'd': name += removeExcessDuplications(rule.getEndConsonants(), name, getRandomElementFrom(rule.getEndConsonants()));
|
||||
break;
|
||||
case '/': name += "'";
|
||||
break;
|
||||
switch (x) {
|
||||
case 'v':
|
||||
buffer.append(removeExcessDuplications(rule.getVowels(), buffer.toString(), getRandomElementFrom(rule.getVowels())));
|
||||
break;
|
||||
case 'c':
|
||||
buffer.append(removeExcessDuplications(rule.getStartConsonants(), buffer.toString(), getRandomElementFrom(rule.getStartConsonants())));
|
||||
break;
|
||||
case 'd':
|
||||
buffer.append(removeExcessDuplications(rule.getEndConsonants(), buffer.toString(), getRandomElementFrom(rule.getEndConsonants())));
|
||||
break;
|
||||
case '/':
|
||||
buffer.append("'");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
instructions = instructions.substring(1);
|
||||
}
|
||||
if (name.isEmpty())
|
||||
if (buffer.length() == 0)
|
||||
return getNameByRule(rule);
|
||||
return name;
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
private String getRandomInstruction(RaceNameRule rule) {
|
||||
@@ -251,6 +257,7 @@ public class SWGNameGenerator {
|
||||
case "Instructions":
|
||||
rule.addInstruction(line);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user