Skip to content

Commit

Permalink
Merge 296740d into b7ad013
Browse files Browse the repository at this point in the history
  • Loading branch information
deanomus authored Aug 10, 2021
2 parents b7ad013 + 296740d commit 0daebfa
Show file tree
Hide file tree
Showing 12 changed files with 637 additions and 2 deletions.
12 changes: 11 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@

<groupId>de.deanomus</groupId>
<artifactId>TCLobbySwitcher</artifactId>
<version>1.0-SNAPSHOT</version>
<version>3.0</version>

<build>
<finalName>TCLobbySwitcher</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/de/deanomus/tclobbyswitcher/TCLobbySwitcher.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package de.deanomus.tclobbyswitcher;

import java.util.logging.Logger;

import de.deanomus.tclobbyswitcher.cmd.LobbySwitcher_CMD;
import de.deanomus.tclobbyswitcher.objects.ItemBuilder;
import de.deanomus.tclobbyswitcher.utils.chat.Colors;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.annotation.command.Command;
import org.bukkit.plugin.java.annotation.command.Commands;
import org.bukkit.plugin.java.annotation.plugin.Description;
import org.bukkit.plugin.java.annotation.plugin.Plugin;
import org.bukkit.plugin.java.annotation.plugin.author.Author;
Expand All @@ -15,6 +22,9 @@
@Plugin(name="TCLobbySwitcher", version="3.0")
@Description(value="An TimoCloud Addon which adds an LobbySwitcher")
@Author(value="deanomus")
@Commands(
@Command(name = "lobbyswitcher", desc = "Open's the lobbyswitcher gui")
)
//@Dependency (value="TimoCloud")
public class TCLobbySwitcher extends JavaPlugin {

Expand All @@ -23,13 +33,18 @@ public class TCLobbySwitcher extends JavaPlugin {
public void onEnable() {
Logger log = Bukkit.getLogger();

log.info("$aIt's starting o.O");
getCommand("lobbyswitcher").setExecutor(new LobbySwitcher_CMD());

log.info("It's starting o.O");
}


public void onDisable() {


}




}
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;
}
}
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;
}


}
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 src/main/java/de/deanomus/tclobbyswitcher/objects/GUI.java
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 src/main/java/de/deanomus/tclobbyswitcher/objects/ItemBuilder.java
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;
}
}
4 changes: 4 additions & 0 deletions src/main/java/de/deanomus/tclobbyswitcher/utils/Helpers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package de.deanomus.tclobbyswitcher.utils;

public class Helpers {
}
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;
}
}
Loading

0 comments on commit 0daebfa

Please sign in to comment.