Skip to content

Commit 6e62a30

Browse files
committed
Update to new MC 1.5.2 Blocks, bugfix, and cleanup.
1 parent eb2d612 commit 6e62a30

File tree

9 files changed

+32
-142
lines changed

9 files changed

+32
-142
lines changed

.gitignore

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
11
.settings
22
target
33
.classpath
4-
.project
4+
.project
5+
plugins
6+
world
7+
world_nether
8+
world_the_end
9+
banned-ips.txt
10+
banned-players.txt
11+
bukkit.yml
12+
help.yml
13+
ops.txt
14+
permissions.yml
15+
server.log
16+
server.log.lck
17+
server.properties
18+
white-list.txt

src/main/java/de/davboecki/signcodepad/App.java

-13
This file was deleted.

src/main/java/de/davboecki/signcodepad/CodePadPlayerListener.java

+6-13
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private double getXpos(Player player, Sign sign, Location signloc) {
6666

6767
break;
6868

69-
//S�den
69+
//Süden
7070
case 4:
7171
x = signloc.getX() - playerloc.getX() + 1;
7272
z = playerloc.getZ() - signloc.getZ();
@@ -100,7 +100,7 @@ private double getXposSuba(double Yaw, int value) {
100100

101101
break;
102102

103-
//S�den
103+
//Süden
104104
case 4:
105105
Yaw -= 270;
106106

@@ -196,7 +196,7 @@ private void Sternchen(String Code, Sign sign) {
196196
}
197197

198198
private void setError(Sign sign, Player player, String Type) {
199-
sign.setLine(0, "1 2 3 | cErr ");
199+
sign.setLine(0, "1 2 3 | §cErr ");
200200
sign.update();
201201
new ErrorReset(sign, player).start();
202202

@@ -602,7 +602,7 @@ private void HandleTorchPad(PlayerInteractEvent event) {
602602
}
603603

604604
Sign sign = (Sign) event.getClickedBlock().getState();
605-
sign.setLine(0, "1 2 3 | aOK ");
605+
sign.setLine(0, "1 2 3 | §aOK ");
606606
sign.update();
607607

608608
try {
@@ -620,10 +620,6 @@ private void HandleBlockPad(PlayerInteractEvent event) {
620620
Sign sign = (Sign) event.getClickedBlock().getState();
621621
Block block = event.getClickedBlock().getWorld().getBlockAt((Location) plugin.getSetting(event.getClickedBlock().getLocation(),"Block"));
622622

623-
byte data = event.getClickedBlock().getData();
624-
625-
//event.getClickedBlock().setTypeId(0);
626-
627623
isLocalInteract = true;
628624
PlayerInteractEvent interactevent = new PlayerInteractEvent(event.getPlayer(), Action.RIGHT_CLICK_BLOCK, event.getItem(), block, event.getBlockFace());
629625
try {
@@ -633,15 +629,12 @@ private void HandleBlockPad(PlayerInteractEvent event) {
633629
//net.minecraft.server.Block.byId[block.getTypeId()].interact(((CraftWorld)block.getWorld()).getHandle(), block.getX(), block.getY(), block.getZ(), ((CraftPlayer)event.getPlayer()).getHandle());
634630
}
635631
} catch(Exception e) {
632+
e.printStackTrace();
636633
event.getPlayer().sendMessage(ChatColor.RED+"Couldn't automaticly interact locked block. Please report this problem.");
637634
}
638635
isLocalInteract = false;
639636

640-
//event.getClickedBlock().setType(Material.WALL_SIGN);
641-
//event.getClickedBlock().setData(data);
642-
643-
//sign = (Sign) event.getClickedBlock().getState();
644-
sign.setLine(0, "1 2 3 | �aOK ");
637+
sign.setLine(0, "1 2 3 | §aOK ");
645638
sign.setLine(1, "4 5 6 | ----");
646639
sign.setLine(2, "7 8 9 | <<- ");
647640
sign.setLine(3, "* 0 # | OK ");

src/main/java/de/davboecki/signcodepad/MinecraftBridgeCalls.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public MinecraftBridgeCalls() throws PluginOutOfDateException {
99
super();
1010
add("Block", "net.minecraft.server." + mcFolderVersion + ".Block");
1111
add("World", "net.minecraft.server." + mcFolderVersion + ".World");
12-
add("Player", "net.minecraft.server." + mcFolderVersion + ".EntityPlayer");
12+
add("Player", "net.minecraft.server." + mcFolderVersion + ".EntityHuman");
1313
add("CraftWorld", "org.bukkit.craftbukkit." + mcFolderVersion + ".CraftWorld");
1414
add("CraftPlayer", "org.bukkit.craftbukkit." + mcFolderVersion + ".entity.CraftPlayer");
1515
}
@@ -20,6 +20,6 @@ public void interactOnBlock(int x, int y, int z, World world, Player player, int
2020
//Method interact = block.getClass().getDeclaredMethod("interact", new Class[]{MinecraftBridge.loadClass(cbMapping.get("World")),int.class,int.class,int.class, MinecraftBridge.loadClass(cbMapping.get("Player"))});
2121
Object NMSWorld = MinecraftBridge.invokeMethod(cbMapping.get("CraftWorld"), "getHandle", world, new Class[]{});
2222
Object NMSPlayer = MinecraftBridge.invokeMethod(cbMapping.get("CraftPlayer"), "getHandle", player, new Class[]{});
23-
MinecraftBridge.invokeMethod(cbMapping.get("Block"), "interact", block, new Class[]{MinecraftBridge.loadClass(cbMapping.get("World")),int.class,int.class,int.class, MinecraftBridge.loadClass(cbMapping.get("Player"))}, new Object[]{NMSWorld, x, y, z, NMSPlayer});
23+
MinecraftBridge.invokeMethod(cbMapping.get("Block"), "interact", block, new Class[]{MinecraftBridge.loadClass(cbMapping.get("World")),int.class,int.class,int.class, MinecraftBridge.loadClass(cbMapping.get("Player")),int.class,float.class,float.class,float.class}, new Object[]{NMSWorld, x, y, z, NMSPlayer,0, 0F, 0F, 0F});
2424
}
2525
}

src/main/java/de/davboecki/signcodepad/Settings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.bukkit.Location;
77

88
public class Settings {
9-
public Settings(){}
9+
1010
public static HashMap<Location, HashMap<String, Object>> Settings = new HashMap<Location, HashMap<String, Object>>();
1111

1212
public boolean containsKey(Object key){

src/main/java/de/davboecki/signcodepad/SettingsSave.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
public class SettingsSave {
66
public SettingsSave(){}
7-
public SettingsSave(HashMap<SignLoc, HashMap<String, Object>> Settings){
8-
}
9-
public HashMap<SignLoc, HashMap<String, Object>> Settings;
7+
public HashMap<Object, HashMap<String, Object>> Settings;
108
}
119

src/main/java/de/davboecki/signcodepad/SignCodePad.java

+5-66
Original file line numberDiff line numberDiff line change
@@ -128,60 +128,6 @@ public boolean hasPermission(Player player, String node) {
128128
return player.hasPermission(node) || player.isOp();
129129
}
130130

131-
private void Correct_Path(String file){
132-
String s;
133-
String Filecontent = "";
134-
try {
135-
BufferedReader in = new BufferedReader(new InputStreamReader(
136-
new FileInputStream(getDataFolder().getPath() + file)));
137-
138-
try {
139-
while (null != (s = in.readLine())) {
140-
Filecontent += s+"\n";
141-
}
142-
} catch (Exception ex) {
143-
System.out.println(ex);
144-
} finally {
145-
if (in != null) {
146-
try {
147-
in.close();
148-
} catch (IOException e) {
149-
e.printStackTrace();
150-
}
151-
}
152-
}
153-
} catch (FileNotFoundException ex) {}
154-
String[] FileSplit = Filecontent.split("me.boecki.SignCodePad");
155-
Filecontent = "";
156-
for(String Part: FileSplit){
157-
if(Filecontent != "")
158-
Filecontent += "de.davboecki.signcodepad";
159-
Filecontent += Part;
160-
}
161-
BufferedWriter out;
162-
try {
163-
out = new BufferedWriter(new OutputStreamWriter(
164-
new FileOutputStream(getDataFolder().getPath() + file)));
165-
166-
try {
167-
for(String Part: Filecontent.split("\n")){
168-
out.write(Part, 0, Part.length());
169-
out.newLine();
170-
}
171-
} catch (IOException ex) {
172-
System.out.println(ex);
173-
} finally {
174-
if (out != null) {
175-
try {
176-
out.close();
177-
} catch (IOException e) {
178-
e.printStackTrace();
179-
}
180-
}
181-
}
182-
} catch (FileNotFoundException e) {}
183-
}
184-
185131
public void onEnable() {
186132
PluginManager pm = this.getServer().getPluginManager();
187133
pm.registerEvents(CodePadPlayerListener, this);
@@ -196,13 +142,10 @@ public void onEnable() {
196142

197143
FileInputStream pFile;
198144

199-
SettingsSave SettingsSave = new SettingsSave(null);
200-
SettingsSave.Settings = new HashMap<SignLoc, HashMap<String, Object>>();
201-
Correct_Path("/Signs.yml");
145+
SettingsSave SettingsSave = new SettingsSave();
146+
SettingsSave.Settings = new HashMap<Object, HashMap<String, Object>>();
202147
try {
203-
pFile = new FileInputStream(new File(getDataFolder().getPath() +
204-
"/Signs.yml"));
205-
148+
pFile = new FileInputStream(new File(getDataFolder().getPath() + "/Signs.yml"));
206149
SettingsSave = (SettingsSave) yaml.load(new UnicodeReader(pFile));
207150
} catch (FileNotFoundException e) {
208151
log.warning("[SignCodePad] Could not Load Sign Config. File Not Found. (This is normal on first run.)");
@@ -236,10 +179,6 @@ public void onEnable() {
236179
pDesc.putListPropertyType("CalibrationList", Calibration.class);
237180
cstr.addTypeDescription(pDesc_b);
238181
this.yaml_b = new Yaml(cstr_b);
239-
240-
FileInputStream pFile_b;
241-
242-
Correct_Path("/Calibration.yml");
243182
try {
244183
pFile = new FileInputStream(new File(getDataFolder().getPath() +
245184
"/Calibration.yml"));
@@ -276,8 +215,8 @@ public void onEnable() {
276215
}
277216

278217
public void save() {
279-
SettingsSave SettingsSave = new SettingsSave(null);
280-
SettingsSave.Settings = new HashMap<SignLoc, HashMap<String, Object>>();
218+
SettingsSave SettingsSave = new SettingsSave();
219+
SettingsSave.Settings = new HashMap<Object, HashMap<String, Object>>();
281220

282221
for (Location loc : Settings.keySet()) {
283222
for (String key : Settings.Settings.get(loc).keySet()) {

src/main/java/de/davboecki/signcodepad/event/SignCreate.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,14 @@ public void onSignChange(SignChangeEvent event) {
200200
Location loc = event.getBlock().getLocation();
201201
loc.setY(event.getBlock().getLocation().getY() - 1);
202202
ArrayList<Integer> Lockable = new ArrayList<Integer>();
203-
ArrayList<Integer> DataValueCahnge = new ArrayList<Integer>();
204203
Lockable.add(Material.CHEST.getId());
205204
Lockable.add(Material.FURNACE.getId());
206205
Lockable.add(Material.BURNING_FURNACE.getId());
207206
Lockable.add(Material.WORKBENCH.getId());
208207
Lockable.add(Material.LEVER.getId());
209-
//Lockable.add(Material.STONE_BUTTON.getId());
210208
Lockable.add(Material.DISPENSER.getId());
211-
DataValueCahnge.add(Material.CHEST.getId());
212-
DataValueCahnge.add(Material.FURNACE.getId());
213-
DataValueCahnge.add(Material.BURNING_FURNACE.getId());
209+
Lockable.add(Material.ANVIL.getId());
210+
Lockable.add(Material.DROPPER.getId());
214211

215212

216213
if(!Lockable.contains(loc.getBlock().getTypeId())) {

src/test/java/de/davboecki/signcodepad/AppTest.java

-38
This file was deleted.

0 commit comments

Comments
 (0)