Skip to content

Commit ab97584

Browse files
committed
Broken - Re-add modules to project
1 parent 59c0cb7 commit ab97584

5 files changed

Lines changed: 363 additions & 1 deletion

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<dependency>
3838
<groupId>org.spigotmc</groupId>
3939
<artifactId>spigot</artifactId>
40-
<version>1.15.2-R0.1-SNAPSHOT</version>
40+
<version>1.14.4-R0.1-SNAPSHOT</version>
4141
</dependency>
4242
<dependency>
4343
<groupId>mc.promcteam</groupId>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package su.nightexpress.quantumrpg.modules.list.activeitems;
2+
3+
import org.jetbrains.annotations.NotNull;
4+
import su.nexmedia.engine.config.api.JYML;
5+
import su.nightexpress.quantumrpg.QuantumRPG;
6+
import su.nightexpress.quantumrpg.modules.UsableItem;
7+
import su.nightexpress.quantumrpg.modules.api.QModuleUsage;
8+
9+
public class ActiveItemManager extends QModuleUsage<ActiveItemManager.ActiveItem> {
10+
public ActiveItemManager(@NotNull QuantumRPG plugin) {
11+
super(plugin, ActiveItem.class);
12+
}
13+
14+
@NotNull
15+
public String getId() {
16+
return "active_items";
17+
}
18+
19+
@NotNull
20+
public String version() {
21+
return "1.3.0";
22+
}
23+
24+
public void setup() {
25+
}
26+
27+
public void shutdown() {
28+
}
29+
30+
public class ActiveItem extends UsableItem {
31+
public ActiveItem(@NotNull QuantumRPG plugin, JYML cfg) {
32+
super(plugin, cfg, ActiveItemManager.this);
33+
}
34+
}
35+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
package su.nightexpress.quantumrpg.modules.list.consumables;
2+
3+
import org.bukkit.command.CommandSender;
4+
import org.bukkit.entity.LivingEntity;
5+
import org.bukkit.entity.Player;
6+
import org.bukkit.event.EventHandler;
7+
import org.bukkit.event.EventPriority;
8+
import org.bukkit.inventory.ItemStack;
9+
import org.jetbrains.annotations.NotNull;
10+
import su.nexmedia.engine.config.api.JYML;
11+
import su.nexmedia.engine.utils.ItemUT;
12+
import su.nightexpress.quantumrpg.QuantumRPG;
13+
import su.nightexpress.quantumrpg.api.events.QuantumPlayerItemUseEvent;
14+
import su.nightexpress.quantumrpg.modules.UsableItem;
15+
import su.nightexpress.quantumrpg.modules.api.QModuleUsage;
16+
import su.nightexpress.quantumrpg.stats.EntityStats;
17+
18+
public class ConsumablesManager extends QModuleUsage<ConsumablesManager.Consume> {
19+
private boolean allowConsumeFullHealth;
20+
21+
private boolean allowConsumeFullFood;
22+
23+
public ConsumablesManager(@NotNull QuantumRPG plugin) {
24+
super(plugin, Consume.class);
25+
}
26+
27+
@NotNull
28+
public String getId() {
29+
return "consumables";
30+
}
31+
32+
@NotNull
33+
public String version() {
34+
return "1.8.0";
35+
}
36+
37+
public void setup() {
38+
this.allowConsumeFullHealth = this.cfg.getBoolean("consuming.allow-on-full-health");
39+
this.allowConsumeFullFood = this.cfg.getBoolean("consuming.allow-on-full-food");
40+
}
41+
42+
public void shutdown() {
43+
}
44+
45+
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
46+
public void onConsume(QuantumPlayerItemUseEvent e) {
47+
UsableItem uItem = e.getItem();
48+
if (!(uItem instanceof Consume))
49+
return;
50+
Player p = e.getPlayer();
51+
Consume c = (Consume) uItem;
52+
ItemStack i = e.getItemStack();
53+
double maxHealth = EntityStats.getEntityMaxHealth((LivingEntity) p);
54+
if (c.getHealth() > 0.0D && !isConsumingAllowedOnFullHealth() && p.getHealth() >= maxHealth) {
55+
(((QuantumRPG) this.plugin).lang()).Consumables_Consume_Error_HealthLevel.replace("%item%", ItemUT.getItemName(i)).send((CommandSender) p, true);
56+
e.setCancelled(true);
57+
return;
58+
}
59+
if (c.getHunger() > 0.0D && !isConsumingAllowedOnFullFood() && p.getFoodLevel() >= 20) {
60+
(((QuantumRPG) this.plugin).lang()).Consumables_Consume_Error_FoodLevel.replace("%item%", ItemUT.getItemName(i)).send((CommandSender) p, true);
61+
e.setCancelled(true);
62+
return;
63+
}
64+
c.applyEffects(p);
65+
}
66+
67+
public boolean isConsumingAllowedOnFullHealth() {
68+
return this.allowConsumeFullHealth;
69+
}
70+
71+
public boolean isConsumingAllowedOnFullFood() {
72+
return this.allowConsumeFullFood;
73+
}
74+
75+
public class Consume extends UsableItem {
76+
private double hp;
77+
78+
private double hunger;
79+
80+
public Consume(@NotNull QuantumRPG plugin, JYML cfg) {
81+
super(plugin, cfg, ConsumablesManager.this);
82+
this.hp = cfg.getDouble("effects.health");
83+
this.hunger = cfg.getDouble("effects.hunger");
84+
}
85+
86+
public double getHealth() {
87+
return this.hp;
88+
}
89+
90+
public double getHunger() {
91+
return this.hunger;
92+
}
93+
94+
public void applyEffects(@NotNull Player p) {
95+
double max = EntityStats.getEntityMaxHealth((LivingEntity) p);
96+
int food = (int) Math.min(20.0D, p.getFoodLevel() + getHunger());
97+
int saturation = 20 - food;
98+
p.setHealth(Math.min(p.getHealth() + getHealth(), max));
99+
p.setFoodLevel(food);
100+
p.setSaturation(saturation);
101+
}
102+
}
103+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package su.nightexpress.quantumrpg.nms.engine.versions;
2+
3+
import su.nightexpress.quantumrpg.nms.engine.PMS;
4+
5+
public class V1_13_R2 implements PMS {
6+
7+
// @Override
8+
// public void changeSkull(Block b, String hash) {
9+
// TileEntitySkull skullTile = (TileEntitySkull)((CraftWorld)b.getWorld()).getHandle().getTileEntity(new BlockPosition(b.getX(), b.getY(), b.getZ()));
10+
// skullTile.setGameProfile(ItemUtils.getNonPlayerProfile(hash));
11+
// b.getState().update(true);
12+
// }
13+
//
14+
// @Override
15+
// public float getAttackCooldown(@NotNull Player p) {
16+
// EntityPlayer ep = ((CraftPlayer)p).getHandle();
17+
// return ep.s(0);
18+
// }
19+
//
20+
// @Nullable
21+
// private Multimap<String, AttributeModifier> getAttributes(@NotNull ItemStack itemStack) {
22+
// Item item = CraftItemStack.asNMSCopy(itemStack).getItem();
23+
// Multimap<String, AttributeModifier> attMap = null;
24+
//
25+
// if (item instanceof ItemArmor) {
26+
// ItemArmor tool = (ItemArmor) item;
27+
// attMap = tool.a(tool.b());
28+
// }
29+
// else if (item instanceof ItemTool) {
30+
// ItemTool tool = (ItemTool) item;
31+
// attMap = tool.a(EnumItemSlot.MAINHAND);
32+
// }
33+
// else if (item instanceof ItemSword) {
34+
// ItemSword tool = (ItemSword) item;
35+
// attMap = tool.a(EnumItemSlot.MAINHAND);
36+
// }
37+
// else if (item instanceof ItemTrident) {
38+
// ItemTrident tool = (ItemTrident) item;
39+
// attMap = tool.a(EnumItemSlot.MAINHAND);
40+
// }
41+
//
42+
// return attMap;
43+
// }
44+
45+
// @Override
46+
// public double getDefaultDamage(@NotNull ItemStack itemStack) {
47+
// if (ItemUtils.isBow(itemStack)) return 10D;
48+
//
49+
// Multimap<String, AttributeModifier> attMap = this.getAttributes(itemStack);
50+
// if (attMap == null) return 1D;
51+
//
52+
// Collection<AttributeModifier> att = attMap.get(GenericAttributes.ATTACK_DAMAGE.getName());
53+
// double damage = (att == null || att.isEmpty()) ? 0 : att.stream().findFirst().get().getAmount();
54+
//
55+
// return damage + 1;
56+
// }
57+
//
58+
// @Override
59+
// public double getDefaultSpeed(@NotNull ItemStack itemStack) {
60+
// Multimap<String, AttributeModifier> attMap = this.getAttributes(itemStack);
61+
// if (attMap == null) return 0D;
62+
//
63+
// Collection<AttributeModifier> att = attMap.get(GenericAttributes.ATTACK_SPEED.getName());
64+
// double speed = (att == null || att.isEmpty()) ? 0D : att.stream().findFirst().get().getAmount();
65+
//
66+
// return speed; // 4D +
67+
// }
68+
//
69+
// @Override
70+
// public double getDefaultArmor(@NotNull ItemStack itemStack) {
71+
// Multimap<String, AttributeModifier> attMap = this.getAttributes(itemStack);
72+
// if (attMap == null) return 0D;
73+
//
74+
// Collection<AttributeModifier> att = attMap.get(GenericAttributes.ARMOR.getName());
75+
// double speed = (att == null || att.isEmpty()) ? 0D : att.stream().findFirst().get().getAmount();
76+
//
77+
// return speed;
78+
// }
79+
//
80+
// @Override
81+
// public double getDefaultToughness(@NotNull ItemStack itemStack) {
82+
// Multimap<String, AttributeModifier> attMap = this.getAttributes(itemStack);
83+
// if (attMap == null) return 0D;
84+
//
85+
// Collection<AttributeModifier> att = attMap.get(GenericAttributes.ARMOR_TOUGHNESS.getName());
86+
// double speed = (att == null || att.isEmpty()) ? 0D : att.stream().findFirst().get().getAmount();
87+
//
88+
// return speed;
89+
// }
90+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package su.nightexpress.quantumrpg.nms.packets.versions;
2+
3+
import org.jetbrains.annotations.NotNull;
4+
import su.nightexpress.quantumrpg.QuantumRPG;
5+
6+
public class V1_13_R2 extends UniversalPacketHandler {
7+
8+
public V1_13_R2(@NotNull QuantumRPG plugin) {
9+
super(plugin);
10+
}
11+
12+
// @Override
13+
// public void managePlayerPacket(@NotNull EnginePlayerPacketEvent e) {
14+
// Object packet = e.getPacket();
15+
//
16+
// if (EngineCfg.PACKETS_REDUCE_COMBAT_PARTICLES && packet instanceof PacketPlayOutWorldParticles) {
17+
// this.manageDamageParticle(e, packet);
18+
// }
19+
//
20+
// if (EngineCfg.PACKETS_MOD_GLOW_COLOR && packet instanceof PacketPlayOutSpawnEntity) {
21+
// this.manageCustomGlow(e, packet);
22+
// Object oId = Reflex.getFieldValue(packet, "b"); // Entity UUID
23+
// if (oId == null) return;
24+
//
25+
// // Do a tick delay to let entity be spawned in the world before we can get it by UUID
26+
// plugin.getServer().getScheduler().runTask(plugin, () -> {
27+
// UUID id = (UUID) oId;
28+
//
29+
// // Get entity and check if it's a dropped item
30+
// Entity entity = plugin.getServer().getEntity(id);
31+
// if (!(entity instanceof org.bukkit.entity.Item)) return;
32+
//
33+
// // Check if Glow setting is applicable to this item stack.
34+
// org.bukkit.entity.Item item = (org.bukkit.entity.Item) entity;
35+
// ItemHintsManager hintManager = plugin.getModuleCache().getItemHintsManager();
36+
// if (hintManager == null || !hintManager.isGlow(item)) return;
37+
//
38+
// // Get list of fake team entities to add our item into it
39+
// PacketPlayOutScoreboardTeam pTeam = new PacketPlayOutScoreboardTeam();
40+
// Object oEntities = Reflex.getFieldValue(pTeam, "h"); // List of team entities
41+
// if (oEntities == null) return;
42+
// Collection<String> entities = (Collection<String>) oEntities;
43+
// entities.add(id.toString());
44+
//
45+
// // Set item custom hint via HintManager before apply glowing
46+
// //hintManager.setItemHint(item, 0);
47+
//
48+
// // Get glowing color depends on hint color.
49+
// ChatColor cc = ChatColor.WHITE;
50+
// String name = ItemUT.getItemName(item.getItemStack());
51+
// if (name.length() > 2) {
52+
// String ss = String.valueOf(cc.getChar());
53+
// if (name.startsWith(String.valueOf(ChatColor.COLOR_CHAR))) {
54+
// ss = name.substring(1, 2);
55+
// }
56+
// ChatColor c2 = ChatColor.getByChar(ss);
57+
// if (c2 != null && c2.isColor()) cc = c2;
58+
// }
59+
// EnumChatFormat ec = EnumChatFormat.valueOf(cc.name());
60+
//
61+
// Player p = e.getReciever();
62+
//
63+
// // Check if team for this color is already created
64+
// // Also Check team per player in case of logout
65+
// boolean newTeam = true;
66+
// Set<ChatColor> hash = PacketManager.COLOR_CACHE.get(p);
67+
// if (hash != null) {
68+
// if (hash.contains(cc)) {
69+
// newTeam = false;
70+
// }
71+
// } else {
72+
// hash = new HashSet<>();
73+
// }
74+
// hash.add(cc);
75+
// PacketManager.COLOR_CACHE.put(p, hash);
76+
//
77+
// // Set team name for each color
78+
// String teamId = "GLOW_" + ec.name();
79+
// if (teamId.length() > 16) teamId = teamId.substring(0, 16);
80+
//
81+
// // Set team fields
82+
// Reflex.setFieldValue(pTeam, "i", newTeam ? 0 : 3); // 0 = new team, 3 = add entity, 4 = remove entity
83+
// Reflex.setFieldValue(pTeam, "a", teamId); // Internal team name
84+
//
85+
// if (newTeam) {
86+
// Reflex.setFieldValue(pTeam, "g", ec); // Team color
87+
// Reflex.setFieldValue(pTeam, "b", new ChatComponentText(teamId)); // Team display name
88+
// Reflex.setFieldValue(pTeam, "c", new ChatComponentText("")); // Team prefix
89+
// }
90+
//
91+
// // Send packet to a player
92+
// plugin.getPacketManager().sendPacket(e.getReciever(), pTeam);
93+
// // Activate colored glowing
94+
// entity.setGlowing(true);
95+
// });
96+
//
97+
98+
// return;
99+
// }
100+
101+
// if (packet instanceof PacketPlayOutUpdateAttributes) {
102+
// this.manageEquipmentChanges(e, packet);
103+
// PacketPlayOutUpdateAttributes equip = (PacketPlayOutUpdateAttributes) packet;
104+
//
105+
// Integer entityId = (Integer) Reflex.getFieldValue(equip, "a");
106+
// if (entityId == null) return;
107+
//
108+
// CraftServer server = (CraftServer) Bukkit.getServer();
109+
// net.minecraft.server.v1_14_R1.Entity nmsEntity = null;
110+
// for (WorldServer worldServer : server.getServer().getWorlds()) {
111+
// nmsEntity = worldServer.getEntity(entityId.intValue());
112+
// if (nmsEntity != null) {
113+
// break;
114+
// }
115+
// }
116+
//
117+
// if (nmsEntity == null) return;
118+
//
119+
// Entity bukkitEntity = plugin.getServer().getEntity(nmsEntity.getUniqueID());
120+
// if (!(bukkitEntity instanceof LivingEntity)) return;
121+
// if (EntityManager.isPacketDuplicatorFixed(bukkitEntity)) return;
122+
//
123+
// plugin.getServer().getScheduler().runTask(plugin, () -> {
124+
// EntityEquipmentChangeEvent event = new EntityEquipmentChangeEvent((LivingEntity) bukkitEntity);
125+
// plugin.getServer().getPluginManager().callEvent(event);
126+
// });
127+
// }
128+
// }
129+
//
130+
// @Override
131+
// public void manageServerPacket(@NotNull EngineServerPacketEvent e) {
132+
//
133+
// }
134+
}

0 commit comments

Comments
 (0)