Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool Items #147

Merged
merged 3 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/net/tiagofar78/prisonescape/items/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public boolean isFunctional() {
return false;
}

public boolean isTool() {
return false;
}

public abstract Material getMaterial();

public String getConfigName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class ItemFactory {

private static Item[] items =
{new AntenaItem(), new BatteryItem(), new BoltsItem(), new CircuitBoardItem(), new CopperItem(), new DuctTapeItem(), new EnergyDrinkItem(), new GoldBarItem(), new HandcuffsItem(), new MatchesItem(), new MetalPlateItem(), new NotePartItem(), new OilItem(), new PlasticPlateItem(), new SearchItem(), new SelectNoneTeamItem(), new SelectPoliceTeamItem(), new SelectPrisionerTeamItem(), new StickItem()};
{new AntenaItem(), new BatteryItem(), new BoltsItem(), new CircuitBoardItem(), new CopperItem(), new DuctTapeItem(), new EnergyDrinkItem(), new GoldBarItem(), new HandcuffsItem(), new MatchesItem(), new MetalPlateItem(), new MetalShovelItem(), new MetalSpoonItem(), new NotePartItem(), new OilItem(), new PlasticPlateItem(), new PlasticShovelItem(), new PlasticSpoonItem(), new SearchItem(), new SelectNoneTeamItem(), new SelectPoliceTeamItem(), new SelectPrisionerTeamItem(), new StickItem(), new WireCutterItem(), new WrenchItem()};

public static Item createItem(ItemStack bukkitItem) {
for (Item item : items) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.tiagofar78.prisonescape.items;

import org.bukkit.Material;

public class MetalShovelItem extends ToolItem {

@Override
protected int usesAmount() {
return 11;
}

@Override
public int damageToBlock() {
return 100;
}

@Override
public boolean isMetalic() {
return true;
}

@Override
public boolean isIllegal() {
return true;
}

@Override
public Material getMaterial() {
return Material.DIAMOND_SHOVEL;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.tiagofar78.prisonescape.items;

import org.bukkit.Material;

public class MetalSpoonItem extends ToolItem {

@Override
protected int usesAmount() {
return 8;
}

@Override
public int damageToBlock() {
return 50;
}

@Override
public boolean isMetalic() {
return true;
}

@Override
public boolean isIllegal() {
return true;
}

@Override
public Material getMaterial() {
return Material.GOLDEN_SHOVEL;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.tiagofar78.prisonescape.items;

import org.bukkit.Material;

public class PlasticShovelItem extends ToolItem {

@Override
protected int usesAmount() {
return 10;
}

@Override
public int damageToBlock() {
return 50;
}

@Override
public boolean isMetalic() {
return false;
}

@Override
public boolean isIllegal() {
return true;
}

@Override
public Material getMaterial() {
return Material.STONE_SHOVEL;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.tiagofar78.prisonescape.items;

import org.bukkit.Material;

public class PlasticSpoonItem extends ToolItem {

@Override
protected int usesAmount() {
return 6;
}

@Override
public int damageToBlock() {
return 25;
}

@Override
public boolean isMetalic() {
return false;
}

@Override
public boolean isIllegal() {
return false;
}

@Override
public Material getMaterial() {
return Material.WOODEN_SHOVEL;
}

}
26 changes: 26 additions & 0 deletions src/main/java/net/tiagofar78/prisonescape/items/ToolItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.tiagofar78.prisonescape.items;

public abstract class ToolItem extends Item {

private double _durability = 100;

@Override
public boolean isTool() {
return true;
}

/**
* @return true if durability is now 0 or less<br>
* false otherwise
*/
public boolean decreaseDurability() {
_durability -= (double) 100 / (double) usesAmount();

return _durability <= 0;
}

protected abstract int usesAmount();

public abstract int damageToBlock();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.tiagofar78.prisonescape.items;

import org.bukkit.Material;

public class WireCutterItem extends ToolItem {

@Override
protected int usesAmount() {
return 5;
}

@Override
public int damageToBlock() {
return 20;
}

@Override
public boolean isMetalic() {
return true;
}

@Override
public boolean isIllegal() {
return true;
}

@Override
public Material getMaterial() {
return Material.SHEARS;
}

}
32 changes: 32 additions & 0 deletions src/main/java/net/tiagofar78/prisonescape/items/WrenchItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package net.tiagofar78.prisonescape.items;

import org.bukkit.Material;

public class WrenchItem extends ToolItem {

@Override
protected int usesAmount() {
return 5;
}

@Override
public int damageToBlock() {
return 20;
}

@Override
public boolean isMetalic() {
return true;
}

@Override
public boolean isIllegal() {
return true;
}

@Override
public Material getMaterial() {
return Material.IRON_PICKAXE;
}

}
12 changes: 12 additions & 0 deletions src/main/resources/languages/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ Items:
Name: "Energy Drink"
Handcuffs:
Name: "Handcuffs"
PlasticSpoon:
Name: "Wooden Shovel"
TiagoFar78 marked this conversation as resolved.
Show resolved Hide resolved
MetalSpoon:
Name: "Golden Shovel"
TiagoFar78 marked this conversation as resolved.
Show resolved Hide resolved
PlasticShovel:
Name: "Stone Shovel"
MetalShovel:
Name: "Diamond Shovel"
WireCutter:
Name: "Wire Cutter"
Wrench:
Name: "Pickaxe"
ItemsProperties:
Metalic: "&8Metalic"
Illegal: "&cIllegal"
Expand Down
Loading