1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-25 20:16:13 +01:00

Small step for a man...

This commit is contained in:
Zrips 2019-05-02 15:59:22 +03:00
parent 23dee5d93e
commit 6ad9b86d3b
6 changed files with 66 additions and 97 deletions

16
pom.xml
View File

@ -182,14 +182,14 @@
<target>1.8</target>
</configuration>
</plugin>
<!-- <plugin> -->
<!-- <groupId>org.apache.maven.plugins</groupId> -->
<!-- <artifactId>maven-jar-plugin</artifactId> -->
<!-- <version>2.3.1</version> -->
<!-- <configuration> -->
<!-- <outputDirectory>C:\Users\Arte\Desktop\Server 1.14\plugins</outputDirectory> -->
<!-- </configuration> -->
<!-- </plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>C:\Users\Arte\Desktop\Server 1.14\plugins</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -78,47 +78,6 @@ public class Reflections {
return Class.forName("net.minecraft.server." + Jobs.getVersionCheckManager().getVersion() + "." + nmsClassString);
}
public String getItemMinecraftName(ItemStack item) {
try {
Object nmsStack = asNMSCopy(item);
Method itemMeth = Item.getMethod("getById", int.class);
@SuppressWarnings("deprecation")
Object res = itemMeth.invoke(Item, item.getType().getId());
String ff = "b";
switch (Jobs.getVersionCheckManager().getVersion()) {
case v1_10_R1:
case v1_9_R1:
case v1_9_R2:
case v1_8_R1:
case v1_8_R3:
case v1_8_R2:
ff = "a";
break;
case v1_11_R1:
case v1_12_R1:
case v1_13_R2:
case v1_13_R1:
ff = "b";
break;
case v1_7_R1:
case v1_7_R2:
case v1_7_R3:
case v1_7_R4:
ff = "n";
break;
default:
break;
}
Method meth2 = res.getClass().getMethod(ff, IStack);
Object name = meth2.invoke(res, nmsStack);
return name.toString();
} catch (Throwable e) {
return item != null ? item.getType().name() : "";
}
}
public ItemStack removeNbt(ItemStack item, String base, String path) {
if (item == null)
return null;

View File

@ -33,8 +33,11 @@ import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
public class JobLimitedItems {
private String node;
@Deprecated
private int id;
@Deprecated
private int data;
CMIMaterial mat;
private int amount;
private String name;
private List<String> lore;
@ -58,8 +61,8 @@ public class JobLimitedItems {
public ItemStack getItemStack(Player player) {
try {
CMIMaterial cm = CMIMaterial.get(id, data);
ItemStack item = cm.newItemStack();
mat = CMIMaterial.get(id, data);
ItemStack item = mat.newItemStack();
item.setAmount(amount);
ItemMeta meta = item.getItemMeta();
if (this.name != null)
@ -83,10 +86,15 @@ public class JobLimitedItems {
return null;
}
@Deprecated
public int getId() {
return id;
}
public CMIMaterial getType(){
return mat;
}
public String getName() {
return name;
}

View File

@ -691,7 +691,7 @@ public class JobsListener implements Listener {
for (Entry<String, JobLimitedItems> oneItem : one.getJob().getLimitedItems().entrySet()) {
if (one.getLevel() >= oneItem.getValue().getLevel())
continue;
if (!isThisItem(oneItem.getValue(), iih.getType().getId(), name, lore, enchants))
if (!isThisItem(oneItem.getValue(), CMIMaterial.get(iih), name, lore, enchants))
continue;
meinOk = one.getJob().getName();
break mein;
@ -704,9 +704,9 @@ public class JobsListener implements Listener {
}
}
private static boolean isThisItem(JobLimitedItems oneItem, int id, String name, List<String> lore, Map<Enchantment, Integer> enchants) {
private static boolean isThisItem(JobLimitedItems oneItem, CMIMaterial mat, String name, List<String> lore, Map<Enchantment, Integer> enchants) {
if (oneItem.getId() != id)
if (oneItem.getType() != mat)
return false;
if (oneItem.getName() != null && name != null) {

View File

@ -581,9 +581,9 @@ public class JobsPaymentListener implements Listener {
// For dye check
List<ItemStack> DyeStack = new ArrayList<>();
int y = -1;
int first = 0;
int second = 0;
int third = 0;
CMIMaterial first = null;
CMIMaterial second = null;
CMIMaterial third = null;
boolean leather = false;
for (int i = 0; i < sourceItems.length; i++) {
if (sourceItems[i] == null)
@ -592,15 +592,15 @@ public class JobsPaymentListener implements Listener {
if (CMIMaterial.isDye(sourceItems[i].getType()))
DyeStack.add(sourceItems[i]);
int id = sourceItems[i].getType().getId();
if (id > 0) {
CMIMaterial mat = CMIMaterial.get(sourceItems[i]);
if (mat != CMIMaterial.NONE) {
y++;
if (y == 0)
first = id;
first = mat;
if (y == 1)
second = id;
second = mat;
if (y == 2)
third = id;
third = mat;
}
switch (CMIMaterial.get(sourceItems[i])) {
@ -624,7 +624,7 @@ public class JobsPaymentListener implements Listener {
// Check Dyes
if (y >= 2) {
if ((CMIMaterial.get(third).isDye() || CMIMaterial.get(second).isDye()) && leather) {
if ((third != null && third.isDye() || second != null && second.isDye()) && leather) {
Jobs.action(jPlayer, new ItemActionInfo(sourceItems[0], ActionType.DYE));
for (ItemStack OneDye : DyeStack) {
Jobs.action(jPlayer, new ItemActionInfo(OneDye, ActionType.DYE));
@ -715,7 +715,9 @@ public class JobsPaymentListener implements Listener {
return b == null;
else if (b == null)
return false;
return a.getType().getId() == b.getType().getId() && a.getDurability() == b.getDurability() && Objects.equal(a.getData(), b.getData()) && Objects.equal(a.getEnchantments(), b
CMIMaterial mat1 = CMIMaterial.get(a);
CMIMaterial mat2 = CMIMaterial.get(b);
return mat1 == mat2 && a.getDurability() == b.getDurability() && Objects.equal(a.getData(), b.getData()) && Objects.equal(a.getEnchantments(), b
.getEnchantments());
}