-
Notifications
You must be signed in to change notification settings - Fork 0
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
12 changed files
with
637 additions
and
2 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
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
22 changes: 22 additions & 0 deletions
22
src/main/java/de/deanomus/tclobbyswitcher/cmd/LobbySwitcher_CMD.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,22 @@ | ||
package de.deanomus.tclobbyswitcher.cmd; | ||
|
||
import de.deanomus.tclobbyswitcher.utils.chat.Colors; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class LobbySwitcher_CMD implements CommandExecutor { //TODO: Gui | ||
|
||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||
if (!(sender instanceof Player)) { | ||
sender.sendMessage(Colors.RED + "Only players can execute this command!"); | ||
return false; | ||
} | ||
Player p = (Player)sender; | ||
|
||
p.sendMessage(Colors.ForestGreen + "Hello " + Colors.Aqua + p.getDisplayName() + Colors.ForestGreen + "."); | ||
|
||
return false; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/de/deanomus/tclobbyswitcher/gui/ServerSelectorGUI.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,15 @@ | ||
package de.deanomus.tclobbyswitcher.gui; | ||
|
||
public class ServerSelectorGUI { | ||
|
||
|
||
private String | ||
servername; | ||
|
||
|
||
public ServerSelectorGUI(String servername) { | ||
this.servername = servername; | ||
} | ||
|
||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/de/deanomus/tclobbyswitcher/listener/ClickListener.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,24 @@ | ||
package de.deanomus.tclobbyswitcher.listener; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
import org.bukkit.material.MaterialData; | ||
|
||
public class ClickListener implements Listener { | ||
|
||
@EventHandler | ||
public void onLeftClick(PlayerInteractEvent e) { | ||
Player p = e.getPlayer(); | ||
|
||
if (e.getItem().getItemMeta().hasDisplayName()) { | ||
p.sendMessage("Item: " + e.getItem().getItemMeta().getDisplayName()); | ||
} else { | ||
p.sendMessage("Item"); | ||
} | ||
|
||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/de/deanomus/tclobbyswitcher/objects/GUI.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,11 @@ | ||
package de.deanomus.tclobbyswitcher.objects; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.inventory.Inventory; | ||
|
||
public class GUI { | ||
|
||
|
||
|
||
|
||
} |
177 changes: 177 additions & 0 deletions
177
src/main/java/de/deanomus/tclobbyswitcher/objects/ItemBuilder.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,177 @@ | ||
package de.deanomus.tclobbyswitcher.objects; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class ItemBuilder { | ||
|
||
// MUST ! | ||
private Material | ||
material; | ||
|
||
private short | ||
subId; | ||
|
||
private int | ||
amount; | ||
|
||
|
||
// OPTIONIALLY BUT RECOMMENED | ||
private String | ||
name; | ||
|
||
// OPTIONIALLY | ||
private ArrayList<String> lores; | ||
|
||
|
||
public ItemBuilder() { | ||
this.material = Material.STONE; | ||
this.subId = (short)0; | ||
this.amount = 1; | ||
} | ||
|
||
/** | ||
* Generate finally the ItemStack | ||
* @return ItemStack | ||
*/ | ||
public ItemStack build() { | ||
ItemStack item = new ItemStack(material, amount, subId); | ||
ItemMeta itemMeta = item.getItemMeta(); | ||
|
||
// SET (DISPLAY-)NAME | ||
if (this.name != null) { | ||
itemMeta.setDisplayName(this.name); | ||
} | ||
// SET LORE | ||
if (this.lores != null && this.lores.size() >= 1) { | ||
itemMeta.setLore(this.lores); | ||
} | ||
|
||
|
||
item.setItemMeta(itemMeta); | ||
return item; | ||
} | ||
|
||
/** | ||
* Add loretext to lores array | ||
* @param text | ||
* @return ItemBuilder | ||
*/ | ||
public ItemBuilder addLoreText(String text) { | ||
if (this.lores == null) { | ||
this.lores = new ArrayList<String>(); | ||
} | ||
this.lores.add(text); | ||
return this; | ||
} | ||
|
||
/** | ||
* Add list of lorelexts to lores array | ||
* @param text | ||
* @return ItemBuilder | ||
*/ | ||
public ItemBuilder addLoreText(String[] text) { | ||
for (String s : text) { | ||
addLoreText(s); | ||
} | ||
return this; | ||
} | ||
|
||
|
||
|
||
// GETTER & SETTER | ||
|
||
/** | ||
* Returns the material | ||
* | ||
* @return Material | ||
*/ | ||
public Material getMaterial() { | ||
return material; | ||
} | ||
|
||
/** | ||
* Sets the material | ||
* @param material | ||
* @return ItemBuilder | ||
*/ | ||
public ItemBuilder setMaterial(Material material) { | ||
this.material = material; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the subId of material | ||
* @return subId | ||
*/ | ||
public short getSubId() { | ||
return subId; | ||
} | ||
|
||
/** | ||
* Sets the subId | ||
* @param subId | ||
* @return ItemBuilder | ||
*/ | ||
public ItemBuilder setSubId(short subId) { | ||
this.subId = subId; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the amount | ||
* @return amount | ||
*/ | ||
public int getAmount() { | ||
return amount; | ||
} | ||
|
||
/** | ||
* Sets the amount | ||
* @param amount | ||
* @return ItemBuilder | ||
*/ | ||
public ItemBuilder setAmount(int amount) { | ||
this.amount = amount; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the (display-)name | ||
* @return | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* Sets the (display-)name | ||
* @param name | ||
* @return ItemBuilder | ||
*/ | ||
public ItemBuilder setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the lores as list | ||
* @return lores | ||
*/ | ||
public ArrayList<String> getLores() { | ||
return lores; | ||
} | ||
|
||
/** | ||
* Sets the lores | ||
* @param lores | ||
* @return ItemBuilder | ||
*/ | ||
public ItemBuilder setLores(ArrayList<String> lores) { | ||
this.lores = lores; | ||
return this; | ||
} | ||
} |
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,4 @@ | ||
package de.deanomus.tclobbyswitcher.utils; | ||
|
||
public class Helpers { | ||
} |
54 changes: 54 additions & 0 deletions
54
src/main/java/de/deanomus/tclobbyswitcher/utils/MinecraftVersion.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,54 @@ | ||
/** | ||
* Thanks to TechsCode for this code snippet | ||
*/ | ||
package de.deanomus.tclobbyswitcher.utils; | ||
|
||
import org.bukkit.Bukkit; | ||
|
||
import java.io.File; | ||
|
||
public enum MinecraftVersion { | ||
UNKOWN, | ||
V1_8_R1, | ||
V1_8_R2, | ||
V1_8_R3, | ||
V1_9_R1, | ||
V1_9_R2, | ||
V1_10_R1, | ||
V1_11_R1, | ||
V1_12_R1, | ||
V1_13_R1, | ||
V1_13_R2, | ||
V1_14_R1, | ||
V1_15_R1, | ||
V1_16_R1, | ||
V1_16_R2, | ||
V1_16_R3, | ||
V1_16_R4; | ||
|
||
|
||
private static MinecraftVersion currentVersion; | ||
|
||
static { | ||
try { | ||
File file1 = new File("server.properties"); | ||
File file2 = new File("bukkit.yml"); | ||
|
||
if (file1.exists() && file2.exists()) { | ||
currentVersion = valueOf(Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3].toUpperCase()); | ||
} else { | ||
currentVersion = UNKOWN; | ||
} | ||
} catch (Exception exception) { | ||
currentVersion = UNKOWN; | ||
} | ||
} | ||
|
||
public boolean isAboveOrEqual(MinecraftVersion paramMinecraftVersion) { | ||
return (ordinal() >= paramMinecraftVersion.ordinal()); | ||
} | ||
|
||
public static MinecraftVersion getServersVersion() { | ||
return currentVersion; | ||
} | ||
} |
Oops, something went wrong.