Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-20 05:20:07 +01:00
Expose API for managing and using GameRules. Adds BUKKIT-2757
Dieser Commit ist enthalten in:
Ursprung
59dc403a61
Commit
9e4e2c62af
@ -230,16 +230,19 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
||||||
|
boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory");
|
||||||
|
|
||||||
for (int i = 0; i < this.inventory.items.length; ++i) {
|
if (!keepInventory) {
|
||||||
if (this.inventory.items[i] != null) {
|
for (int i = 0; i < this.inventory.items.length; ++i) {
|
||||||
loot.add(new CraftItemStack(this.inventory.items[i]));
|
if (this.inventory.items[i] != null) {
|
||||||
|
loot.add(new CraftItemStack(this.inventory.items[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < this.inventory.armor.length; ++i) {
|
for (int i = 0; i < this.inventory.armor.length; ++i) {
|
||||||
if (this.inventory.armor[i] != null) {
|
if (this.inventory.armor[i] != null) {
|
||||||
loot.add(new CraftItemStack(this.inventory.armor[i]));
|
loot.add(new CraftItemStack(this.inventory.armor[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,12 +255,14 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
// CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
||||||
for (int i = 0; i < this.inventory.items.length; ++i) {
|
if (!keepInventory) {
|
||||||
this.inventory.items[i] = null;
|
for (int i = 0; i < this.inventory.items.length; ++i) {
|
||||||
}
|
this.inventory.items[i] = null;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < this.inventory.armor.length; ++i) {
|
for (int i = 0; i < this.inventory.armor.length; ++i) {
|
||||||
this.inventory.armor[i] = null;
|
this.inventory.armor[i] = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.closeInventory();
|
this.closeInventory();
|
||||||
|
@ -767,11 +767,12 @@ public class WorldServer extends World implements org.bukkit.BlockChangeDelegate
|
|||||||
explosion.b = flag1;
|
explosion.b = flag1;
|
||||||
explosion.a();
|
explosion.a();
|
||||||
explosion.a(false);
|
explosion.a(false);
|
||||||
|
*/
|
||||||
|
// CraftBukkit end - TODO: Check if explosions are still properly implemented
|
||||||
|
|
||||||
if (!flag1) {
|
if (!flag1) {
|
||||||
explosion.blocks.clear();
|
explosion.blocks.clear();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// CraftBukkit end - TODO: Check if explosions are still properly implemented
|
|
||||||
|
|
||||||
Iterator iterator = this.players.iterator();
|
Iterator iterator = this.players.iterator();
|
||||||
|
|
||||||
|
@ -1197,4 +1197,26 @@ public class CraftWorld implements World {
|
|||||||
|
|
||||||
getHandle().makeSound(x, y, z, CraftSound.getSound(sound), volume, pitch);
|
getHandle().makeSound(x, y, z, CraftSound.getSound(sound), volume, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGameRuleValue(String rule) {
|
||||||
|
return getHandle().getGameRules().get(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setGameRuleValue(String rule, String value) {
|
||||||
|
// No null values allowed
|
||||||
|
if (rule == null || value == null) return false;
|
||||||
|
|
||||||
|
if (!isGameRule(rule)) return false;
|
||||||
|
|
||||||
|
getHandle().getGameRules().set(rule, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getGameRules() {
|
||||||
|
return getHandle().getGameRules().b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGameRule(String rule) {
|
||||||
|
return getHandle().getGameRules().e(rule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren