Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,167 additions
and
927 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
nmshandler/src/main/java/net/aufdemrand/denizen/nms/abstracts/BiomeNMS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package net.aufdemrand.denizen.nms.abstracts; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.block.Biome; | ||
import org.bukkit.entity.EntityType; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class BiomeNMS { | ||
|
||
private final String name; | ||
|
||
public BiomeNMS(Biome biome) { | ||
this.name = biome.name(); | ||
} | ||
|
||
public DownfallType getDownfallType() { | ||
if (getDoesSnow()) { | ||
return DownfallType.SNOW; | ||
} | ||
else if (getDoesRain()) { | ||
return DownfallType.RAIN; | ||
} | ||
else { | ||
return DownfallType.NONE; | ||
} | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public abstract float getHumidity(); | ||
|
||
public abstract float getTemperature(); | ||
|
||
public List<EntityType> getAllEntities() { | ||
List<EntityType> entityTypes = new ArrayList<EntityType>(); | ||
entityTypes.addAll(getAmbientEntities()); | ||
entityTypes.addAll(getCreatureEntities()); | ||
entityTypes.addAll(getMonsterEntities()); | ||
entityTypes.addAll(getWaterEntities()); | ||
return entityTypes; | ||
} | ||
|
||
public abstract List<EntityType> getAmbientEntities(); | ||
|
||
public abstract List<EntityType> getCreatureEntities(); | ||
|
||
public abstract List<EntityType> getMonsterEntities(); | ||
|
||
public abstract List<EntityType> getWaterEntities(); | ||
|
||
public abstract void setHumidity(float humidity); | ||
|
||
public abstract void setTemperature(float temperature); | ||
|
||
public abstract void changeBlockBiome(Location location); | ||
|
||
public enum DownfallType { | ||
RAIN, SNOW, NONE | ||
} | ||
|
||
protected abstract boolean getDoesRain(); | ||
|
||
protected abstract boolean getDoesSnow(); | ||
} |
78 changes: 78 additions & 0 deletions
78
nmshandler/src/main/java/net/aufdemrand/denizen/nms/abstracts/ProfileEditor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package net.aufdemrand.denizen.nms.abstracts; | ||
|
||
import net.aufdemrand.denizen.nms.NMSHandler; | ||
import net.aufdemrand.denizen.nms.util.PlayerProfile; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
public abstract class ProfileEditor { | ||
|
||
protected static final Map<UUID, PlayerProfile> fakeProfiles = new HashMap<UUID, PlayerProfile>(); | ||
|
||
protected final JavaPlugin plugin; | ||
|
||
public ProfileEditor(JavaPlugin plugin) { | ||
this.plugin = plugin; | ||
plugin.getServer().getPluginManager().registerEvents(new PlayerProfileEditorListener(), plugin); | ||
} | ||
|
||
public void setPlayerName(Player player, String name) { | ||
PlayerProfile profile = getFakeProfile(player); | ||
profile.setName(name); | ||
updatePlayer(player, false); | ||
} | ||
|
||
public String getPlayerName(Player player) { | ||
return getFakeProfile(player).getName(); | ||
} | ||
|
||
public void setPlayerSkin(Player player, String name) { | ||
PlayerProfile profile = getFakeProfile(player); | ||
PlayerProfile skinProfile = NMSHandler.getInstance().fillPlayerProfile(new PlayerProfile(name, null)); | ||
profile.setTexture(skinProfile.getTexture()); | ||
profile.setTextureSignature(skinProfile.getTextureSignature()); | ||
updatePlayer(player, true); | ||
} | ||
|
||
public void setPlayerSkinBlob(Player player, String blob) { | ||
PlayerProfile profile = getFakeProfile(player); | ||
profile.setTexture(blob); | ||
profile.setTextureSignature(null); | ||
updatePlayer(player, true); | ||
} | ||
|
||
public String getPlayerSkinBlob(Player player) { | ||
return getFakeProfile(player).getTexture(); | ||
} | ||
|
||
protected abstract void updatePlayer(Player player, boolean isSkinChanging); | ||
|
||
private PlayerProfile getFakeProfile(Player player) { | ||
UUID uuid = player.getUniqueId(); | ||
if (fakeProfiles.containsKey(uuid)) { | ||
return fakeProfiles.get(uuid); | ||
} | ||
else { | ||
PlayerProfile fakeProfile = NMSHandler.getInstance().getPlayerProfile(player); | ||
fakeProfiles.put(uuid, fakeProfile); | ||
return fakeProfile; | ||
} | ||
} | ||
|
||
private static class PlayerProfileEditorListener implements Listener { | ||
@EventHandler | ||
public void onPlayerQuit(PlayerQuitEvent event) { | ||
UUID uuid = event.getPlayer().getUniqueId(); | ||
if (fakeProfiles.containsKey(uuid)) { | ||
fakeProfiles.remove(uuid); | ||
} | ||
} | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
nmshandler/src/main/java/net/aufdemrand/denizen/nms/abstracts/Sidebar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package net.aufdemrand.denizen.nms.abstracts; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public abstract class Sidebar { | ||
|
||
protected final Player player; | ||
protected String title; | ||
protected String[] lines; | ||
protected int[] scores; | ||
protected int start; | ||
protected int increment; | ||
|
||
public Sidebar(Player player) { | ||
this.player = player; | ||
setTitle(""); | ||
this.lines = new String[15]; | ||
this.scores = new int[15]; | ||
this.start = Integer.MIN_VALUE; | ||
this.increment = -1; | ||
} | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public List<String> getLines() { | ||
return new ArrayList<String>(Arrays.asList(lines)); | ||
} | ||
|
||
public int[] getScores() { | ||
return scores; | ||
} | ||
|
||
public int getStart() { | ||
return start; | ||
} | ||
|
||
public int getIncrement() { | ||
return increment; | ||
} | ||
|
||
public final void setTitle(String title) { | ||
if (title.length() > 32) { | ||
title = title.substring(0, 32); | ||
} | ||
if (this.title == null || !this.title.equals(title)) { | ||
this.title = title; | ||
setDisplayName(title); | ||
} | ||
} | ||
|
||
protected abstract void setDisplayName(String title); | ||
|
||
public void setStart(int start) { | ||
this.start = start; | ||
} | ||
|
||
public void setIncrement(int increment) { | ||
this.increment = increment; | ||
} | ||
|
||
public void setLines(List<String> lines) { | ||
lines.removeAll(Collections.singleton((String) null)); | ||
this.lines = new String[15]; | ||
this.scores = new int[15]; | ||
int score = this.start; | ||
if (score == Integer.MIN_VALUE) { | ||
score = lines.size(); | ||
} | ||
for (int i = 0; i < lines.size() && i < this.lines.length; i++, score += this.increment) { | ||
String line = lines.get(i); | ||
if (line.length() > 40) { | ||
line = line.substring(0, 40); | ||
} | ||
this.lines[i] = line; | ||
this.scores[i] = score; | ||
} | ||
} | ||
|
||
public abstract void sendUpdate(); | ||
|
||
public abstract void remove(); | ||
} |
8 changes: 8 additions & 0 deletions
8
nmshandler/src/main/java/net/aufdemrand/denizen/nms/interfaces/ChunkHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.aufdemrand.denizen.nms.interfaces; | ||
|
||
import org.bukkit.Chunk; | ||
|
||
public interface ChunkHelper { | ||
|
||
int[] getHeightMap(Chunk chunk); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
nmshandler/src/main/java/net/aufdemrand/denizen/nms/interfaces/PacketHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.aufdemrand.denizen.nms.interfaces; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public interface PacketHelper { | ||
|
||
void setSlot(Player player, int slot, ItemStack itemStack, boolean playerOnly); | ||
|
||
void showBlockAction(Player player, Location location, int action, int state); | ||
|
||
void showBlockCrack(Player player, int id, Location location, int progress); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
nmshandler/src/main/java/net/aufdemrand/denizen/nms/interfaces/WorldAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.aufdemrand.denizen.nms.interfaces; | ||
|
||
import org.bukkit.entity.Entity; | ||
|
||
public interface WorldAccess { | ||
|
||
void despawn(Entity entity); | ||
} |
14 changes: 14 additions & 0 deletions
14
nmshandler/src/main/java/net/aufdemrand/denizen/nms/interfaces/WorldHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package net.aufdemrand.denizen.nms.interfaces; | ||
|
||
import org.bukkit.World; | ||
|
||
public interface WorldHelper { | ||
|
||
boolean isStatic(World world); | ||
|
||
void setStatic(World world, boolean isStatic); | ||
|
||
void setWorldAccess(World world, WorldAccess worldAccess); | ||
|
||
void removeWorldAccess(World world); | ||
} |
Oops, something went wrong.